revert the reversal of checkjs logic, but still restrict the behaviour scope to just those urls that require it

This commit is contained in:
redmatrix 2016-04-20 22:10:00 -07:00
parent f00a701ad1
commit 2b0a04ea9e
4 changed files with 20 additions and 7 deletions

View File

@ -57,7 +57,7 @@ function get($update = 0, $load = false) {
if($load)
$_SESSION['loadtime'] = datetime_convert();
$checkjs = new \Zotlabs\Web\CheckJS();
$checkjs = new \Zotlabs\Web\CheckJS(1);
$category = $datequery = $datequery2 = '';

View File

@ -10,7 +10,7 @@ class Display extends \Zotlabs\Web\Controller {
// logger("mod-display: update = $update load = $load");
$checkjs = new \Zotlabs\Web\CheckJS();
$checkjs = new \Zotlabs\Web\CheckJS(1);
if($load)

View File

@ -5,11 +5,11 @@ namespace Zotlabs\Module;
class Nojs extends \Zotlabs\Web\Controller {
function init() {
setcookie('jsdisabled', 1, 0);
$p = $_GET['query'];
$n = ((argc() > 1) ? intval(argv(1)) : 1);
setcookie('jsdisabled', $n, 0, '/');
$p = $_GET['redir'];
$hasq = strpos($p,'?');
goaway(z_root() . (($p) ? '/' . $p : '') . (($hasq) ? '' : '?f=' ) . '&jsdisabled=1');
goaway(z_root() . (($p) ? '/' . $p : '') . (($hasq) ? '' : '?f=' ) . '&jsdisabled=' . $n);
}
}

View File

@ -10,14 +10,27 @@ class CheckJS {
function __construct($test = 0) {
if(intval($_REQUEST['jsdisabled']))
$this->jsdisabled = 1;
else
$this->jsdisabled = 0;
if(intval($_COOKIE['jsdisabled']))
$this->jsdisabled = 1;
else
$this->jsdisabled = 0;
if(! $this->jsdisabled) {
$page = urlencode(\App::$query_string);
if($test) {
\App::$page['htmlhead'] .= "\r\n" . '<meta http-equiv="refresh" content="0; url=' . z_root() . '/nojs?f=&redir=' . $page . '">' . "\r\n";
logger('page=' . $page);
if($_COOKIE['jsdisabled'] == 0) {
\App::$page['htmlhead'] .= "\r\n" . '<script>document.cookie="jsdisabled=0; path=/"; var jsMatch = /\&jsdisabled=0/; if (!jsMatch.exec(location.href)) { location.href = "' . z_root() . '/nojs/0?f=&redir=' . $page . '" ; }</script>' . "\r\n";
/* emulate JS cookie if cookies are not accepted */
if ($_GET['jsdisabled'] == 0) {
$_COOKIE['jsdisabled'] = 0;
}
}
}
else {
\App::$page['htmlhead'] .= "\r\n" . '<noscript><meta http-equiv="refresh" content="0; url=' . z_root() . '/nojs?f=&redir=' . $page . '"></noscript>' . "\r\n";