aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Web/CheckJS.php36
-rw-r--r--Zotlabs/Web/Session.php4
-rwxr-xr-xboot.php1
-rwxr-xr-xindex.php13
-rw-r--r--mod/channel.php11
-rw-r--r--mod/display.php16
-rw-r--r--mod/network.php2
-rw-r--r--mod/nojs.php10
-rw-r--r--version.inc2
-rwxr-xr-xview/tpl/head.tpl12
10 files changed, 69 insertions, 38 deletions
diff --git a/Zotlabs/Web/CheckJS.php b/Zotlabs/Web/CheckJS.php
new file mode 100644
index 000000000..3ad5fc1ed
--- /dev/null
+++ b/Zotlabs/Web/CheckJS.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace Zotlabs\Web;
+
+
+class CheckJS {
+
+ private static $jsdisabled = 0;
+
+ function __construct($test = 0) {
+ if(intval($_REQUEST['jsdisabled']))
+ $this->jsdisabled = 1;
+ if(intval($_COOKIE['jsdisabled']))
+ $this->jsdisabled = 1;
+
+ 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";
+ }
+ else {
+ \App::$page['htmlhead'] .= "\r\n" . '<noscript><meta http-equiv="refresh" content="0; url=' . z_root() . '/nojs?f=&redir=' . $page . '"></noscript>' . "\r\n";
+ }
+ }
+
+ }
+
+ function disabled() {
+ return self::$jsdisabled;
+ }
+
+
+}
+
+
diff --git a/Zotlabs/Web/Session.php b/Zotlabs/Web/Session.php
index 55536fdc7..f998df396 100644
--- a/Zotlabs/Web/Session.php
+++ b/Zotlabs/Web/Session.php
@@ -85,8 +85,8 @@ class Session {
else
logger('no session handler');
- if (x($_COOKIE, 'jsAvailable')) {
- setcookie('jsAvailable', $_COOKIE['jsAvailable'], $newxtime);
+ if (x($_COOKIE, 'jsdisabled')) {
+ setcookie('jsdisabled', $_COOKIE['jsdisabled'], $newxtime);
}
setcookie(session_name(),session_id(),$newxtime);
diff --git a/boot.php b/boot.php
index 682eafd59..e9fe29696 100755
--- a/boot.php
+++ b/boot.php
@@ -1065,6 +1065,7 @@ class App {
self::$page['htmlhead'] = replace_macros($tpl, array(
'$preload_images' => $preload_images,
'$user_scalable' => $user_scalable,
+ '$query' => urlencode(self::$query_string),
'$baseurl' => self::get_baseurl(),
'$local_channel' => local_channel(),
'$metas' => self::$meta->get(),
diff --git a/index.php b/index.php
index 025d84063..278be154c 100755
--- a/index.php
+++ b/index.php
@@ -149,19 +149,8 @@ $Router = new Zotlabs\Web\Router($a);
if(! x(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);
diff --git a/mod/channel.php b/mod/channel.php
index 2ef911bbb..9bc7332dc 100644
--- a/mod/channel.php
+++ b/mod/channel.php
@@ -54,6 +54,7 @@ function channel_content(&$a, $update = 0, $load = false) {
if($load)
$_SESSION['loadtime'] = datetime_convert();
+ $checkjs = new Zotlabs\Web\CheckJS();
$category = $datequery = $datequery2 = '';
@@ -209,7 +210,7 @@ function channel_content(&$a, $update = 0, $load = false) {
App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start']));
- if($load || ($_COOKIE['jsAvailable'] != 1)) {
+ if($load || ($checkjs->disabled())) {
if ($mid) {
$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",
@@ -338,13 +339,13 @@ function channel_content(&$a, $update = 0, $load = false) {
}
- if($_COOKIE['jsAvailable'] == 1) {
- $o .= conversation($a,$items,'channel',$update,$page_mode);
- } else {
+ if($checkjs->disabled()) {
$o .= conversation($a,$items,'channel',$update,'traditional');
+ } else {
+ $o .= conversation($a,$items,'channel',$update,$page_mode);
}
- if((! $update) || ($_COOKIE['jsAvailable'] != 1)) {
+ if((! $update) || ($checkjs->disabled())) {
$o .= alt_pager($a,count($items));
if ($mid && $items[0]['title'])
App::$page['title'] = $items[0]['title'] . " - " . App::$page['title'];
diff --git a/mod/display.php b/mod/display.php
index ef140d454..2844a1205 100644
--- a/mod/display.php
+++ b/mod/display.php
@@ -5,6 +5,10 @@ function display_content(&$a, $update = 0, $load = false) {
// logger("mod-display: update = $update load = $load");
+
+ $checkjs = new Zotlabs\Web\CheckJS();
+
+
if($load)
$_SESSION['loadtime'] = datetime_convert();
@@ -168,13 +172,13 @@ function display_content(&$a, $update = 0, $load = false) {
$sql_extra = public_permissions_sql($observer_hash);
- if(($update && $load) || ($_COOKIE['jsAvailable'] != 1)) {
+ if(($update && $load) || ($checkjs->disabled())) {
$updateable = false;
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']),intval(App::$pager['start']));
- if($load || ($_COOKIE['jsAvailable'] != 1)) {
+ if($load || ($checkjs->disabled())) {
$r = null;
require_once('include/identity.php');
@@ -290,13 +294,13 @@ function display_content(&$a, $update = 0, $load = false) {
}
- if ($_COOKIE['jsAvailable'] == 1) {
- $o .= conversation($a, $items, 'display', $update, 'client');
- } else {
+ if ($checkjs->disabled()) {
$o .= conversation($a, $items, 'display', $update, 'traditional');
if ($items[0]['title'])
App::$page['title'] = $items[0]['title'] . " - " . App::$page['title'];
-
+ }
+ else {
+ $o .= conversation($a, $items, 'display', $update, 'client');
}
if($updateable) {
diff --git a/mod/network.php b/mod/network.php
index 5465cd064..e6d02f572 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -13,7 +13,7 @@ function network_init(&$a) {
return;
}
- if((count($_GET) < 2) || (count($_GET) < 3 && $_GET['JS'])) {
+ if(count($_GET) < 2) {
$network_options = get_pconfig(local_channel(),'system','network_page_default');
if($network_options)
goaway('network' . '?f=&' . $network_options);
diff --git a/mod/nojs.php b/mod/nojs.php
new file mode 100644
index 000000000..c6e04a72b
--- /dev/null
+++ b/mod/nojs.php
@@ -0,0 +1,10 @@
+<?php
+
+function nojs_init(&$a) {
+
+ setcookie('jsdisabled', 1, 0);
+ $p = $_GET['query'];
+ $hasq = strpos($p,'?');
+ goaway(z_root() . (($p) ? '/' . $p : '') . (($hasq) ? '' : '?f=' ) . '&jsdisabled=1');
+
+} \ No newline at end of file
diff --git a/version.inc b/version.inc
index 4c06763d5..9c7ec8b61 100644
--- a/version.inc
+++ b/version.inc
@@ -1,3 +1,3 @@
-2016-04-12.1364H
+2016-04-13.1365H
diff --git a/view/tpl/head.tpl b/view/tpl/head.tpl
index ab229eaf7..9fcdf1735 100755
--- a/view/tpl/head.tpl
+++ b/view/tpl/head.tpl
@@ -7,20 +7,11 @@
<![endif]-->
{{$head_css}}
-
{{$js_strings}}
-
{{$head_js}}
-
<link rel="shortcut icon" href="{{$icon}}" />
-<link rel="search"
- href="{{$baseurl}}/opensearch"
- type="application/opensearchdescription+xml"
- title="{{$osearch}}" />
-
-
+<link rel="search" href="{{$baseurl}}/opensearch" type="application/opensearchdescription+xml" title="{{$osearch}}" />
<script>
-
var updateInterval = {{$update_interval}};
var localUser = {{if $local_channel}}{{$local_channel}}{{else}}false{{/if}};
var zid = {{if $zid}}'{{$zid}}'{{else}}null{{/if}};
@@ -28,7 +19,6 @@
{{if $channel_hash}}var channelHash = '{{$channel_hash}}';{{/if}}
{{if $channel_id}}var channelId = '{{$channel_id}}';{{/if}}{{* Used in e.g. autocomplete *}}
var preloadImages = {{$preload_images}};
-
</script>