From 046c1cda073dd6100cf3ccb0143c1d06512e278b Mon Sep 17 00:00:00 2001 From: DariusIII Date: Tue, 25 Jul 2017 15:10:56 +0200 Subject: [PATCH] Try to prevent creating new session on every BasePage load --- Changelog | 1 + www/pages/BasePage.php | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Changelog b/Changelog index 18c35739d..af9baa7fb 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2017-07-25 DariusIII + * Chg: Try to prevent creating new session on every BasePage load * Chg: Add automatic user profile role change for expired roles (role change date) on users list check (admin area) 2017-07-23 DariusIII * Fix: Fix error for scandir in profileedit page diff --git a/www/pages/BasePage.php b/www/pages/BasePage.php index 5e89aba7a..af447a2b5 100644 --- a/www/pages/BasePage.php +++ b/www/pages/BasePage.php @@ -10,12 +10,12 @@ use nntmux\SABnzbd; class BasePage { /** - * @var \nntmux\db\Settings + * @var DB */ public $settings = null; /** - * @var nntmux\Users + * @var Users */ public $users = null; @@ -79,17 +79,21 @@ class BasePage * * @var string */ - protected $theme = 'Omicron'; + protected $theme = 'Gentele'; /** * Set up session / smarty / user variables. + * + * @throws \Exception */ public function __construct() { - $this->https = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? true : false); + $this->https = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on'; - session_set_cookie_params(0, '/', '', $this->https, true); - @session_start(); + if (session_id() === '') { + session_set_cookie_params(0, '/', '', $this->https, true); + @session_start(); + } if (NN_FLOOD_CHECK) { $this->floodCheck(); @@ -111,7 +115,7 @@ class BasePage if (isset($_SERVER['SERVER_NAME'])) { $this->serverurl = ( ($this->https === true ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . - (($_SERVER['SERVER_PORT'] != '80' && $_SERVER['SERVER_PORT'] != '443') ? ':' . $_SERVER['SERVER_PORT'] : '') . + (((int)$_SERVER['SERVER_PORT'] !== 80 && (int)$_SERVER['SERVER_PORT'] !== 443) ? ':' . $_SERVER['SERVER_PORT'] : '') . WWW_TOP . '/' ); $this->smarty->assign('serverroot', $this->serverurl);