From 965c51c2d45a98db10543c5108ac486e4fc6459e Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 Nov 2019 20:29:58 +0000 Subject: sse: implement notifications for anonymous visitors (info, notice and pubs) and fix a potential memory leak --- boot.php | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'boot.php') diff --git a/boot.php b/boot.php index b0b838231..b4e472d47 100755 --- a/boot.php +++ b/boot.php @@ -1831,12 +1831,19 @@ function notice($s) { */ $hash = get_observer_hash(); + $sse_id = false; - if (! $hash) - return; - + if(! $hash) { + if(session_id()) { + $sse_id = true; + $hash = 'sse_id.' . session_id(); + } + else { + return; + } + } - $t = get_xconfig($hash, 'sse', 'timestamp'); + $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', []); @@ -1884,11 +1891,19 @@ function info($s) { */ $hash = get_observer_hash(); + $sse_id = false; - if (! $hash) - return; + if(! $hash) { + if(session_id()) { + $sse_id = true; + $hash = 'sse_id.' . session_id(); + } + else { + return; + } + } - $t = get_xconfig($hash, 'sse', 'timestamp'); + $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', []); -- cgit v1.2.3