reverse the logic of the jsenabled setting so that sessions without js are performance penalised instead of regular sessions.
This commit is contained in:
parent
f4a27afee9
commit
91cc365143
@ -85,8 +85,8 @@ class Session {
|
|||||||
else
|
else
|
||||||
logger('no session handler');
|
logger('no session handler');
|
||||||
|
|
||||||
if (x($_COOKIE, 'jsAvailable')) {
|
if (x($_COOKIE, 'jsdisabled')) {
|
||||||
setcookie('jsAvailable', $_COOKIE['jsAvailable'], $newxtime);
|
setcookie('jsdisabled', $_COOKIE['jsdisabled'], $newxtime);
|
||||||
}
|
}
|
||||||
setcookie(session_name(),session_id(),$newxtime);
|
setcookie(session_name(),session_id(),$newxtime);
|
||||||
|
|
||||||
|
1
boot.php
1
boot.php
@ -1065,6 +1065,7 @@ class App {
|
|||||||
self::$page['htmlhead'] = replace_macros($tpl, array(
|
self::$page['htmlhead'] = replace_macros($tpl, array(
|
||||||
'$preload_images' => $preload_images,
|
'$preload_images' => $preload_images,
|
||||||
'$user_scalable' => $user_scalable,
|
'$user_scalable' => $user_scalable,
|
||||||
|
'$query' => urlencode(self::$query_string),
|
||||||
'$baseurl' => self::get_baseurl(),
|
'$baseurl' => self::get_baseurl(),
|
||||||
'$local_channel' => local_channel(),
|
'$local_channel' => local_channel(),
|
||||||
'$metas' => self::$meta->get(),
|
'$metas' => self::$meta->get(),
|
||||||
|
13
index.php
13
index.php
@ -149,19 +149,8 @@ $Router = new Zotlabs\Web\Router($a);
|
|||||||
if(! x(App::$page, 'content'))
|
if(! x(App::$page, 'content'))
|
||||||
App::$page['content'] = '';
|
App::$page['content'] = '';
|
||||||
|
|
||||||
|
call_hooks('page_content_top', App::$page['content']);
|
||||||
|
|
||||||
if(! (App::$module === 'setup')) {
|
|
||||||
/* set JS cookie */
|
|
||||||
if($_COOKIE['jsAvailable'] != 1) {
|
|
||||||
App::$page['content'] .= '<script>document.cookie="jsAvailable=1; path=/"; var jsMatch = /\&JS=1/; if (!jsMatch.exec(location.href)) { location.href = location.href + "&JS=1"; }</script>';
|
|
||||||
/* emulate JS cookie if cookies are not accepted */
|
|
||||||
if ($_GET['JS'] == 1) {
|
|
||||||
$_COOKIE['jsAvailable'] = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
call_hooks('page_content_top', App::$page['content']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$Router->Dispatch($a);
|
$Router->Dispatch($a);
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ function channel_content(&$a, $update = 0, $load = false) {
|
|||||||
App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
|
App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
|
||||||
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start']));
|
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start']));
|
||||||
|
|
||||||
if($load || ($_COOKIE['jsAvailable'] != 1)) {
|
if($load || ($_COOKIE['jsdisabled'] == 1)) {
|
||||||
if ($mid) {
|
if ($mid) {
|
||||||
$r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d $item_normal
|
$r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d $item_normal
|
||||||
AND item_wall = 1 $sql_extra limit 1",
|
AND item_wall = 1 $sql_extra limit 1",
|
||||||
@ -338,13 +338,13 @@ function channel_content(&$a, $update = 0, $load = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($_COOKIE['jsAvailable'] == 1) {
|
if($_COOKIE['jsdisabled'] == 1) {
|
||||||
$o .= conversation($a,$items,'channel',$update,$page_mode);
|
|
||||||
} else {
|
|
||||||
$o .= conversation($a,$items,'channel',$update,'traditional');
|
$o .= conversation($a,$items,'channel',$update,'traditional');
|
||||||
|
} else {
|
||||||
|
$o .= conversation($a,$items,'channel',$update,$page_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((! $update) || ($_COOKIE['jsAvailable'] != 1)) {
|
if((! $update) || ($_COOKIE['jsdisabled'] == 1)) {
|
||||||
$o .= alt_pager($a,count($items));
|
$o .= alt_pager($a,count($items));
|
||||||
if ($mid && $items[0]['title'])
|
if ($mid && $items[0]['title'])
|
||||||
App::$page['title'] = $items[0]['title'] . " - " . App::$page['title'];
|
App::$page['title'] = $items[0]['title'] . " - " . App::$page['title'];
|
||||||
|
@ -168,13 +168,13 @@ function display_content(&$a, $update = 0, $load = false) {
|
|||||||
|
|
||||||
$sql_extra = public_permissions_sql($observer_hash);
|
$sql_extra = public_permissions_sql($observer_hash);
|
||||||
|
|
||||||
if(($update && $load) || ($_COOKIE['jsAvailable'] != 1)) {
|
if(($update && $load) || ($_COOKIE['jsdisabled'] == 1)) {
|
||||||
|
|
||||||
$updateable = false;
|
$updateable = false;
|
||||||
|
|
||||||
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']),intval(App::$pager['start']));
|
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']),intval(App::$pager['start']));
|
||||||
|
|
||||||
if($load || ($_COOKIE['jsAvailable'] != 1)) {
|
if($load || ($_COOKIE['jsdisabled'] == 1)) {
|
||||||
$r = null;
|
$r = null;
|
||||||
|
|
||||||
require_once('include/identity.php');
|
require_once('include/identity.php');
|
||||||
@ -290,13 +290,13 @@ function display_content(&$a, $update = 0, $load = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($_COOKIE['jsAvailable'] == 1) {
|
if ($_COOKIE['jsdisabled'] == 1) {
|
||||||
$o .= conversation($a, $items, 'display', $update, 'client');
|
|
||||||
} else {
|
|
||||||
$o .= conversation($a, $items, 'display', $update, 'traditional');
|
$o .= conversation($a, $items, 'display', $update, 'traditional');
|
||||||
if ($items[0]['title'])
|
if ($items[0]['title'])
|
||||||
App::$page['title'] = $items[0]['title'] . " - " . App::$page['title'];
|
App::$page['title'] = $items[0]['title'] . " - " . App::$page['title'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$o .= conversation($a, $items, 'display', $update, 'client');
|
||||||
}
|
}
|
||||||
|
|
||||||
if($updateable) {
|
if($updateable) {
|
||||||
|
@ -13,7 +13,7 @@ function network_init(&$a) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((count($_GET) < 2) || (count($_GET) < 3 && $_GET['JS'])) {
|
if(count($_GET) < 2) {
|
||||||
$network_options = get_pconfig(local_channel(),'system','network_page_default');
|
$network_options = get_pconfig(local_channel(),'system','network_page_default');
|
||||||
if($network_options)
|
if($network_options)
|
||||||
goaway('network' . '?f=&' . $network_options);
|
goaway('network' . '?f=&' . $network_options);
|
||||||
|
9
mod/nojs.php
Normal file
9
mod/nojs.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function nojs_init(&$a) {
|
||||||
|
|
||||||
|
setcookie('jsdisabled', 1, 0);
|
||||||
|
$p = $_GET['query'];
|
||||||
|
goaway(z_root() . (($p) ? '/' . $p : ''));
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||||
<base href="{{$baseurl}}/" />
|
<base href="{{$baseurl}}/" />
|
||||||
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, user-scalable={{$user_scalable}}" />
|
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, user-scalable={{$user_scalable}}" />
|
||||||
|
<noscript><meta http-equiv="refresh" content="0; url=nojs.php&redir={{$query}}"></noscript>
|
||||||
{{$metas}}
|
{{$metas}}
|
||||||
<!--[if IE]>
|
<!--[if IE]>
|
||||||
<script src="{{$baseurl}}/library/html5.js"></script>
|
<script src="{{$baseurl}}/library/html5.js"></script>
|
||||||
|
Reference in New Issue
Block a user