Beispiel #1
0
 /**
  * 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 (NN_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(['user_frontend' => NN_WWW . 'templates/' . $this->settings->getSetting('style') . '/views/frontend', 'frontend' => NN_WWW . 'templates/default/views/frontend']);
     $this->smarty->setCompileDir(SMARTY_DIR . 'templates_c' . DIRECTORY_SEPARATOR);
     $this->smarty->setConfigDir(SMARTY_DIR . 'configs' . DIRECTORY_SEPARATOR);
     $this->smarty->setCacheDir(SMARTY_DIR . 'cache' . DIRECTORY_SEPARATOR);
     $this->smarty->error_reporting = NN_DEBUG ? E_ALL : E_ALL - E_NOTICE;
     $this->secure_connection = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443;
     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 ($this->settings->getSetting('userselstyle') == 1) {
             if (isset($this->userdata['style']) && $this->userdata['style'] !== 'None') {
                 $this->smarty->setTemplateDir(['user_frontend' => NN_WWW . 'templates/' . $this->userdata['style'] . '/views/frontend', 'frontend' => NN_WWW . 'templates/default/views/frontend']);
             }
         }
         //update lastlogin 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");
         if ($this->userdata['nzbvortex_api_key'] != '' && $this->userdata['nzbvortex_server_url'] != '') {
             $this->smarty->assign('weHasVortex', true);
         } else {
             $this->smarty->assign('weHasVortex', false);
         }
         $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');
         }
         if ($this->userdata["hideads"] == "1") {
             $this->settings->setSetting(['adheader', '']);
             $this->settings->setSetting(['adbrowse', '']);
             $this->settings->setSetting(['addetail', '']);
         }
         $this->floodCheck($this->userdata["role"]);
     } else {
         $this->smarty->assign('isadmin', 'false');
         $this->smarty->assign('ismod', 'false');
         $this->smarty->assign('loggedin', 'false');
         $this->floodCheck();
     }
     $this->smarty->assign('site', $this->settings);
     $this->smarty->assign('page', $this);
 }