コード例 #1
0
ファイル: basepage.php プロジェクト: ehsanguru/nnplus
 function BasePage()
 {
     @session_start();
     if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc() || ini_get('magic_quotes_sybase')) {
         foreach ($_GET as $k => $v) {
             $_GET[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v);
         }
         foreach ($_POST as $k => $v) {
             $_POST[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v);
         }
         foreach ($_REQUEST as $k => $v) {
             $_REQUEST[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v);
         }
         foreach ($_COOKIE as $k => $v) {
             $_COOKIE[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v);
         }
     }
     // set site variable
     $s = new Sites();
     $this->site = $s->get();
     $this->smarty = new Smarty();
     $this->smarty->template_dir = WWW_DIR . 'views/templates/' . $this->template_dir;
     $this->smarty->compile_dir = SMARTY_DIR . 'templates_c/';
     $this->smarty->config_dir = SMARTY_DIR . 'configs/';
     $this->smarty->cache_dir = SMARTY_DIR . 'cache/';
     $this->smarty->error_reporting = E_ALL - E_NOTICE;
     $this->smarty->assign('site', $this->site);
     $this->smarty->assign('page', $this);
     if (isset($_SERVER["SERVER_NAME"])) {
         $this->serverurl = (isset($_SERVER["HTTPS"]) ? "https://" : "http://") . $_SERVER["SERVER_NAME"] . ($_SERVER["SERVER_PORT"] != "80" ? ":" . $_SERVER["SERVER_PORT"] : "") . WWW_TOP . '/';
         $this->smarty->assign('serverroot', $this->serverurl);
     }
     $this->page = isset($_GET['page']) ? $_GET['page'] : 'content';
     $users = new Users();
     if ($users->isLoggedIn()) {
         $this->userdata = $users->getById($users->currentUserId());
         $this->userdata["categoryexclusions"] = $users->getCategoryExclusion($users->currentUserId());
         //update lastlogin every 15 mins
         if (strtotime($this->userdata['now']) - 900 > strtotime($this->userdata['lastlogin'])) {
             $users->updateSiteAccessed($this->userdata['ID']);
         }
         $this->smarty->assign('userdata', $this->userdata);
         $this->smarty->assign('loggedin', "true");
         $sab = new SABnzbd($this);
         if ($sab->integrated !== false && $sab->url != '' && $sab->apikey != '') {
             $this->smarty->assign('sabintegrated', $sab->integrated);
             $this->smarty->assign('sabapikeytype', $sab->apikeytype);
         }
         if ($this->userdata["role"] == Users::ROLE_ADMIN) {
             $this->smarty->assign('isadmin', "true");
         }
         $this->floodCheck(true, $this->userdata["role"]);
     } else {
         $this->smarty->assign('isadmin', "false");
         $this->smarty->assign('loggedin', "false");
         $this->floodCheck(false, "");
     }
 }
コード例 #2
0
ファイル: NZBVortex.php プロジェクト: engine9-/newznab-tmux
 /**
  * sendRequest()
  * @return array
  */
 protected function sendRequest($path, $params = array())
 {
     $user = new Users();
     $data = $user->getById($user->currentUserId());
     $url = sprintf('%s/api', $data['nzbvortex_server_url']);
     $params = http_build_query($params);
     $ch = curl_init(sprintf("%s/%s?%s", $url, $path, $params));
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
     #curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
     #curl_setopt($ch, CURLOPT_PROXY, 'localhost:8888');
     $response = curl_exec($ch);
     $response = json_decode($response, true);
     $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     $error = curl_error($ch);
     curl_close($ch);
     switch ($status) {
         case 0:
             throw new Exception(sprintf('Unable to connect. Is NZBVortex running? Is your API key correct? Is something blocking ports? (Err: %s)', $error));
             break;
         case 200:
             return $response;
             break;
         case 403:
             throw new Exception('Unable to login. Is your API key correct?');
             break;
         default:
             throw new Exception(sprintf("%s (%s): %s", $path, $status, $response['result']));
             break;
     }
 }
コード例 #3
0
ファイル: BasePage.php プロジェクト: engine9-/newznab-tmux
 /**
  * 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);
 }
コード例 #4
0
 function BasePage()
 {
     @session_start();
     if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc() || ini_get('magic_quotes_sybase')) {
         foreach ($_GET as $k => $v) {
             $_GET[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v);
         }
         foreach ($_POST as $k => $v) {
             $_POST[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v);
         }
         foreach ($_REQUEST as $k => $v) {
             $_REQUEST[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v);
         }
         foreach ($_COOKIE as $k => $v) {
             $_COOKIE[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v);
         }
     }
     // set site variable
     $s = new Sites();
     $this->site = $s->get();
     $this->smarty = new Smarty();
     if ($this->site->style != "default") {
         $this->smarty->addTemplateDir(WWW_DIR . 'templates/' . $this->site->style . '/views/frontend', 'style_frontend');
     }
     $this->smarty->addTemplateDir(WWW_DIR . 'templates/default/views/frontend', '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 = E_ALL - E_NOTICE;
     $this->secure_connection = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443;
     if (file_exists(WWW_DIR . 'templates/' . $this->site->style . '/theme.php')) {
         require_once WWW_DIR . 'templates/' . $this->site->style . '/theme.php';
     }
     $this->smarty->assign('themevars', isset($themevars) ? $themevars : null);
     $servername = null;
     if (defined('EXTERNAL_PROXY_IP') && defined('EXTERNAL_HOST_NAME') && isset($_SERVER["REMOTE_ADDR"]) && $_SERVER["REMOTE_ADDR"] == EXTERNAL_PROXY_IP) {
         $servername = EXTERNAL_HOST_NAME;
     } elseif (isset($_SERVER["SERVER_NAME"])) {
         $servername = $_SERVER["SERVER_NAME"];
     }
     if ($servername != "") {
         $this->serverurl = ($this->secure_connection ? "https://" : "http://") . $servername . ($_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';
     $users = new Users();
     if ($users->isLoggedIn()) {
         $this->userdata = $users->getById($users->currentUserId());
         //
         // user can still be logged in but have been disabled by admin, so if they are, log them off
         //
         if ($this->userdata["role"] == Users::ROLE_DISABLED) {
             $users->logout();
             $this->show403();
         }
         $this->userdata["categoryexclusions"] = $users->getCategoryExclusion($users->currentUserId());
         //update lastlogin every 15 mins
         if (strtotime($this->userdata['now']) - 900 > strtotime($this->userdata['lastlogin'])) {
             $users->updateSiteAccessed($this->userdata['ID']);
         }
         $this->smarty->assign('userdata', $this->userdata);
         $this->smarty->assign('loggedin', "true");
         if (!empty($this->userdata['nzbvortex_api_key']) && !empty($this->userdata['nzbvortex_server_url'])) {
             $this->smarty->assign('weHasVortex', true);
         }
         $sab = new SABnzbd($this);
         if ($sab->integrated !== false && $sab->url != '' && $sab->apikey != '') {
             $this->smarty->assign('sabintegrated', $sab->integrated);
             $this->smarty->assign('sabapikeytype', $sab->apikeytype);
         }
         $nzbget = new NZBGet($this);
         if ($nzbget->integrated !== false && $nzbget->url != '') {
             $this->smarty->assign('nzbgetintegrated', $nzbget->integrated);
         }
         if ($this->userdata["role"] == Users::ROLE_ADMIN) {
             $this->smarty->assign('isadmin', "true");
         }
         if ($this->userdata["hideads"] == "1") {
             $this->site->adheader = "";
             $this->site->adbrowse = "";
             $this->site->addetail = "";
         }
         $this->floodCheck($this->userdata["role"]);
     } else {
         $this->smarty->assign('isadmin', "false");
         $this->smarty->assign('loggedin', "false");
         $this->floodCheck();
     }
     $this->smarty->assign('site', $this->site);
     $this->smarty->assign('page', $this);
 }