protected function setUserPreferences() { $this->userdata = $this->users->getById($this->users->currentUserId()); $this->userdata['categoryexclusions'] = $this->users->getCategoryExclusion($this->users->currentUserId()); // Change to the user's selected theme, if they selected one, else use the admin set one. $this->theme = isset($this->userdata['style']) ? $this->userdata['style'] : 'None'; if ($this->theme == 'None') { $this->theme = $this->settings->getSetting('site.main.style'); } if (lcfirst($this->theme) === $this->theme) { // TODO add redirect to error page telling the user their theme name is invalid (after SQL patch to update current users is added). $this->theme = ucfirst($this->theme); } // Update last login every 15 mins. if (strtotime($this->userdata['now']) - 900 > strtotime($this->userdata['lastlogin'])) { $this->users->updateSiteAccessed($this->userdata['id']); } $this->smarty->assign('userdata', $this->userdata); $this->smarty->assign('loggedin', 'true'); $sab = new SABnzbd($this); $this->smarty->assign('sabintegrated', $sab->integratedBool); if ($sab->integratedBool !== false && $sab->url != '' && $sab->apikey != '') { $this->smarty->assign('sabapikeytype', $sab->apikeytype); } switch ((int) $this->userdata['role']) { case Users::ROLE_ADMIN: $this->smarty->assign('isadmin', 'true'); break; case Users::ROLE_MODERATOR: $this->smarty->assign('ismod', 'true'); } }
/** * Set up session / smarty / user variables. */ public function __construct() { $this->https = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? true : false; session_set_cookie_params(0, '/', '', $this->https, true); @session_start(); if (nZEDb_FLOOD_CHECK) { $this->floodCheck(); } if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() || ini_get('magic_quotes_sybase')) { $this->stripSlashes($_GET); $this->stripSlashes($_POST); $this->stripSlashes($_REQUEST); $this->stripSlashes($_COOKIE); } // Buffer settings/DB connection. $this->settings = new Settings(); $this->smarty = new Smarty(); $this->smarty->setTemplateDir(array('user_frontend' => nZEDb_WWW . 'themes/' . $this->settings->getSetting('style') . '/templates/frontend', 'frontend' => nZEDb_WWW . 'themes/Default/templates/frontend')); $this->smarty->setCompileDir(SMARTY_DIR . 'templates_c/'); $this->smarty->setConfigDir(SMARTY_DIR . 'configs/'); $this->smarty->setCacheDir(SMARTY_DIR . 'cache/'); $this->smarty->error_reporting = nZEDb_DEBUG ? E_ALL : E_ALL - E_NOTICE; 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'] : '') . WWW_TOP . '/'; $this->smarty->assign('serverroot', $this->serverurl); } $this->page = isset($_GET['page']) ? $_GET['page'] : 'content'; $this->users = new Users(['Settings' => $this->settings]); if ($this->users->isLoggedIn()) { $this->userdata = $this->users->getById($this->users->currentUserId()); $this->userdata['categoryexclusions'] = $this->users->getCategoryExclusion($this->users->currentUserId()); // Change the theme to user's selected theme if they selected one, else use the admin one. if (isset($this->userdata['style']) && $this->userdata['style'] !== 'None') { $this->smarty->setTemplateDir(array('user_frontend' => nZEDb_WWW . 'themes/' . $this->userdata['style'] . '/templates/frontend', 'frontend' => nZEDb_WWW . 'themes/Default/templates/frontend')); } // Update last login every 15 mins. if (strtotime($this->userdata['now']) - 900 > strtotime($this->userdata['lastlogin'])) { $this->users->updateSiteAccessed($this->userdata['id']); } $this->smarty->assign('userdata', $this->userdata); $this->smarty->assign('loggedin', 'true'); $sab = new SABnzbd($this); $this->smarty->assign('sabintegrated', $sab->integratedBool); if ($sab->integratedBool !== false && $sab->url != '' && $sab->apikey != '') { $this->smarty->assign('sabapikeytype', $sab->apikeytype); } switch ((int) $this->userdata['role']) { case Users::ROLE_ADMIN: $this->smarty->assign('isadmin', 'true'); break; case Users::ROLE_MODERATOR: $this->smarty->assign('ismod', 'true'); } } else { $this->smarty->assign('isadmin', 'false'); $this->smarty->assign('ismod', 'false'); $this->smarty->assign('loggedin', 'false'); } $this->smarty->assign('site', $this->settings); $this->smarty->assign('page', $this); }