From db866fa668c19e6ecaf6a4ee06200deefef25a15 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 20 Jan 2022 09:46:38 -0500 Subject: [PATCH] Implement zm_setcookie to simplify setting cookies, set samesite, deal with older php etc. Use it. --- web/includes/Group.php | 2 +- web/includes/session.php | 17 +++++++++++++++++ web/index.php | 17 ++--------------- web/skins/classic/views/montage.php | 9 +-------- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/web/includes/Group.php b/web/includes/Group.php index 34db0e869..93c20fc70 100644 --- a/web/includes/Group.php +++ b/web/includes/Group.php @@ -25,7 +25,7 @@ class Group extends ZM_Object { if ( isset($_COOKIE['zmGroup']) ) { if ( $this->{'Id'} == $_COOKIE['zmGroup'] ) { unset($_COOKIE['zmGroup']); - setcookie('zmGroup', '', time()-3600*24*2); + zm_setcookie('zmGroup', ''); } } } diff --git a/web/includes/session.php b/web/includes/session.php index 0190f9897..6e9c17670 100644 --- a/web/includes/session.php +++ b/web/includes/session.php @@ -1,4 +1,21 @@ =')) { + setcookie($cookie, $value, $options); + } else { + setcookie($cookie, $value, $options['expires'], '/; samesite=strict'); + } +} + // ZM session start function support timestamp management function zm_session_start() { diff --git a/web/index.php b/web/index.php index b3df502f6..5ace8e9b6 100644 --- a/web/index.php +++ b/web/index.php @@ -139,11 +139,6 @@ $skinBase[] = $skin; zm_session_start(); -$cookie_options = array( - 'expires'=>time()+3600*24*30*12*10, - 'samesite' => 'Strict', -); - if ( !isset($_SESSION['skin']) || isset($_REQUEST['skin']) || @@ -151,11 +146,7 @@ if ( ($_COOKIE['zmSkin'] != $skin) ) { $_SESSION['skin'] = $skin; - if (version_compare(phpversion(), '7.3.0', '>=')) { - setcookie('zmSkin', $skin, $cookie_options); - } else { - setcookie('zmSkin', $skin, $cookie_options['expires'], '/; samesite=strict'); - } + zm_setcookie('zmSkin', $skin); } if ( @@ -165,11 +156,7 @@ if ( ($_COOKIE['zmCSS'] != $css) ) { $_SESSION['css'] = $css; - if (version_compare(phpversion(), '7.3.0', '>=')) { - setcookie('zmCSS', $css, $cookie_options); - } else { - setcookie('zmCSS', $css, $cookie_options['expires'], '/; samesite=strict'); - } + zm_setcookie('zmCSS', $css); } # Running is global but only do the daemonCheck if it is actually needed diff --git a/web/skins/classic/views/montage.php b/web/skins/classic/views/montage.php index bb99916dd..a96e8a88e 100644 --- a/web/skins/classic/views/montage.php +++ b/web/skins/classic/views/montage.php @@ -307,14 +307,7 @@ foreach (array_reverse($zones) as $zone) { Type() != 'WebSite')) { -?> -
- : - -  -  -  fps -
-getMonitorStateHTML(); } ?>