diff options
-rw-r--r-- | Zotlabs/Module/Login.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Sse.php | 78 | ||||
-rw-r--r-- | boot.php | 94 | ||||
-rw-r--r-- | view/pdl/mod_home.pdl | 3 | ||||
-rw-r--r-- | view/pdl/mod_login.pdl | 6 |
5 files changed, 100 insertions, 83 deletions
diff --git a/Zotlabs/Module/Login.php b/Zotlabs/Module/Login.php index 721ac15ac..6430939b4 100644 --- a/Zotlabs/Module/Login.php +++ b/Zotlabs/Module/Login.php @@ -12,5 +12,5 @@ class Login extends \Zotlabs\Web\Controller { return login(true); } - + } diff --git a/Zotlabs/Module/Sse.php b/Zotlabs/Module/Sse.php index a5b5c7e35..df4a74f7b 100644 --- a/Zotlabs/Module/Sse.php +++ b/Zotlabs/Module/Sse.php @@ -23,7 +23,14 @@ class Sse extends Controller { killme(); } + if(! intval(Config::Get('system','open_pubstream',1))) { + if(! get_observer_hash()) { + killme(); + } + } + // this is important! + session_write_close(); ignore_user_abort(true); self::$uid = local_channel(); @@ -41,8 +48,6 @@ class Sse extends Controller { } } - - if (self::$uid) { self::$vnotify = get_pconfig(self::$uid, 'system', 'vnotify'); } @@ -97,6 +102,7 @@ class Sse extends Controller { } } + $result = []; XConfig::Load(self::$ob_hash); @@ -104,19 +110,9 @@ class Sse extends Controller { $lock = XConfig::Get(self::$ob_hash, 'sse', 'lock'); if (!$lock) { - $result_db = XConfig::Get(self::$ob_hash, 'sse', 'notifications', []); - } - - if (!empty($_SESSION['sysmsg'])) { - $result['notice']['notifications'] = $_SESSION['sysmsg']; - } - - if (!empty($_SESSION['sysmsg_info'])) { - $result['info']['notifications'] = $_SESSION['sysmsg_info']; + $result = XConfig::Get(self::$ob_hash, 'sse', 'notifications', []); } - $result = array_merge($result, $result_db); - // We do not have the local_channel in the addon. // Reset pubs here if the app is not installed. if (self::$uid && (!(self::$vnotify & VNOTIFY_PUBS) || !Apps::system_app_installed(self::$uid, 'Public Stream'))) { @@ -137,36 +133,22 @@ class Sse extends Controller { echo "\n\n"; } + if (ob_get_length() > 0) { + ob_end_flush(); + } + + flush(); + if (connection_status() != CONNECTION_NORMAL || connection_aborted()) { XConfig::Set(self::$ob_hash, 'sse', 'timestamp', NULL_DATE); XConfig::Set(self::$ob_hash, 'sse', 'notifications', []); - $_SESSION['sysmsg'] = []; - $_SESSION['sysmsg_info'] = []; - - if (ob_get_length() > 0) { - ob_end_flush(); - } - - flush(); - exit; } - if (ob_get_length() > 0) { - ob_flush(); - } - - flush(); - usleep($sleep); if ($result) { - if ($result_db) { - XConfig::Set(self::$ob_hash, 'sse', 'notifications', []); - } - - $_SESSION['sysmsg'] = []; - $_SESSION['sysmsg_info'] = []; + XConfig::Set(self::$ob_hash, 'sse', 'notifications', []); } $i++; @@ -204,35 +186,13 @@ class Sse extends Controller { } } - $result = []; - $result_db = []; - XConfig::Load(self::$ob_hash); + $result = XConfig::Get(self::$ob_hash, 'sse', 'notifications', []); $lock = XConfig::Get(self::$ob_hash, 'sse', 'lock'); - if (!$lock) { - $result_db = XConfig::Get(self::$ob_hash, 'sse', 'notifications', []); - } - - if (!empty($_SESSION['sysmsg'])) { - $result['notice']['notifications'] = $_SESSION['sysmsg']; - } - - if (!empty($_SESSION['sysmsg_info'])) { - $result['info']['notifications'] = $_SESSION['sysmsg_info']; - } - - $result = array_merge($result, $result_db); - - if($result) { - if ($result_db) { - XConfig::Set(self::$ob_hash, 'sse', 'notifications', []); - } - - $_SESSION['sysmsg'] = []; - $_SESSION['sysmsg_info'] = []; - + if($result && !$lock) { + XConfig::Set(self::$ob_hash, 'sse', 'notifications', []); json_return_and_die($result); } @@ -1897,22 +1897,57 @@ function can_view_public_stream() { */ function notice($s) { - if (!session_id()) { - return; + /* + if(! session_id()) + return; + + if(! x($_SESSION, 'sysmsg')) $_SESSION['sysmsg'] = array(); + + // ignore duplicated error messages which haven't yet been displayed + // - typically seen as multiple 'permission denied' messages + // as a result of auto-reloading a protected page with &JS=1 + + if(in_array($s, $_SESSION['sysmsg'])) + return; + + if(App::$interactive) { + $_SESSION['sysmsg'][] = $s; + } + */ + + $hash = get_observer_hash(); + $sse_id = false; + + if (!$hash) { + if (session_id()) { + $sse_id = true; + $hash = 'sse_id.' . session_id(); + } + else { + return; + } } - if (!isset($_SESSION['sysmsg'])) { - $_SESSION['sysmsg'] = []; + $x = null; + + $t = get_xconfig($hash, 'sse', 'timestamp', NULL_DATE); + + if (datetime_convert('UTC', 'UTC', $t) < datetime_convert('UTC', 'UTC', '- 30 seconds')) { + set_xconfig($hash, 'sse', 'notifications', []); + $x = []; } - // ignore duplicated error messages which haven't yet been displayed + if ($x === null) { + $x = get_xconfig($hash, 'sse', 'notifications', []); + } - if (in_array($s, $_SESSION['sysmsg'])) { + if (isset($x['notice']) && in_array($s, $x['notice']['notifications'])) { return; } if (App::$interactive) { - $_SESSION['sysmsg'][] = $s; + $x['notice']['notifications'][] = $s; + set_xconfig($hash, 'sse', 'notifications', $x); } } @@ -1929,22 +1964,53 @@ function notice($s) { */ function info($s) { - if (!session_id()) { - return; + /* + if(! session_id()) + return; + + if(! x($_SESSION, 'sysmsg_info')) + $_SESSION['sysmsg_info'] = array(); + + if(in_array($s, $_SESSION['sysmsg_info'])) + return; + + if(App::$interactive) + $_SESSION['sysmsg_info'][] = $s; + */ + + $hash = get_observer_hash(); + $sse_id = false; + + if (!$hash) { + if (session_id()) { + $sse_id = true; + $hash = 'sse_id.' . session_id(); + } + else { + return; + } } - if (!isset($_SESSION['sysmsg_info'])) { - $_SESSION['sysmsg_info'] = []; + $x = null; + + $t = get_xconfig($hash, 'sse', 'timestamp', NULL_DATE); + + if (datetime_convert('UTC', 'UTC', $t) < datetime_convert('UTC', 'UTC', '- 30 seconds')) { + set_xconfig($hash, 'sse', 'notifications', []); + $x = []; } - // ignore duplicated error messages which haven't yet been displayed + if ($x === null) { + $x = get_xconfig($hash, 'sse', 'notifications', []); + } - if (in_array($s, $_SESSION['sysmsg_info'])) { + if (isset($x['info']) && in_array($s, $x['info']['notifications'])) { return; } if (App::$interactive) { - $_SESSION['sysmsg_info'][] = $s; + $x['info']['notifications'][] = $s; + set_xconfig($hash, 'sse', 'notifications', $x); } } diff --git a/view/pdl/mod_home.pdl b/view/pdl/mod_home.pdl index 2660f63e0..8b3ff52f8 100644 --- a/view/pdl/mod_home.pdl +++ b/view/pdl/mod_home.pdl @@ -1,6 +1,3 @@ -[region=aside] -[widget=notifications][var=sys_only]1[/var][/widget] -[/region] [region=content] $content [/region] diff --git a/view/pdl/mod_login.pdl b/view/pdl/mod_login.pdl deleted file mode 100644 index 3065703de..000000000 --- a/view/pdl/mod_login.pdl +++ /dev/null @@ -1,6 +0,0 @@ -[region=aside] -[widget=notifications][var=sys_only]1[/var][/widget] -[/region] -[region=content] -$content -[/region] |