예제 #1
0
파일: Page.php 프로젝트: kaibosh/nZEDb
 public function __construct()
 {
     parent::__construct();
     $role = Users::ROLE_GUEST;
     if ($this->userdata != null) {
         $role = $this->userdata["role"];
     }
     $content = new Contents(['Settings' => $this->settings]);
     $menu = new Menu($this->settings);
     $this->smarty->assign('menulist', $menu->get($role, $this->serverurl));
     $this->smarty->assign('usefulcontentlist', $content->getForMenuByTypeAndRole(Contents::TYPEUSEFUL, $role));
     $this->smarty->assign('articlecontentlist', $content->getForMenuByTypeAndRole(Contents::TYPEARTICLE, $role));
     $this->smarty->assign('main_menu', $this->smarty->fetch('mainmenu.tpl'));
     $this->smarty->assign('useful_menu', $this->smarty->fetch('usefullinksmenu.tpl'));
     $this->smarty->assign('article_menu', $this->smarty->fetch('articlesmenu.tpl'));
     $category = new Category(['Settings' => $content->pdo]);
     if ($this->userdata != null) {
         $parentcatlist = $category->getForMenu($this->userdata["categoryexclusions"]);
     } else {
         $parentcatlist = $category->getForMenu();
     }
     // Add in system types to console categories to make the boot strap drop down list less long.
     $consoleCatList = [];
     foreach ($parentcatlist as $parent) {
         if ($parent['title'] === 'Console') {
             foreach ($parent['subcatlist'] as $consoleCat) {
                 if (preg_match('/^XBOX/i', $consoleCat['title'])) {
                     $consoleCatList['Microsoft'][] = $consoleCat;
                 } else {
                     if (preg_match('/^([3N]DS|N?GC)$|^WII/i', $consoleCat['title'])) {
                         $consoleCatList['Nintendo'][] = $consoleCat;
                     } else {
                         if (preg_match('/PS[\\dXP ]/i', $consoleCat['title'])) {
                             $consoleCatList['Sony'][] = $consoleCat;
                         } else {
                             $consoleCatList['Other'][] = $consoleCat;
                         }
                     }
                 }
             }
             break;
         }
     }
     $this->smarty->assign('consolecatlist', $consoleCatList);
     $this->smarty->assign('parentcatlist', $parentcatlist);
     $searchStr = '';
     if ($this->page == 'search' && isset($_REQUEST["id"])) {
         $searchStr = (string) $_REQUEST["id"];
     }
     $this->smarty->assign('header_menu_search', $searchStr);
     if (isset($_REQUEST["t"])) {
         $this->smarty->assign('header_menu_cat', $_REQUEST["t"]);
     } else {
         $this->smarty->assign('header_menu_cat', '');
     }
     $header_menu = $this->smarty->fetch('headermenu.tpl');
     $this->smarty->assign('header_menu', $header_menu);
 }
예제 #2
0
파일: rss.php 프로젝트: Atmos01/nZEDb
// If no content id provided then show user the rss selection page.
if (!isset($_GET["t"]) && !isset($_GET["rage"]) && !isset($_GET["anidb"])) {
    // User has to either be logged in, or using rsskey.
    if (!$page->users->isLoggedIn()) {
        if ($page->settings->getSetting('registerstatus') != Settings::REGISTER_STATUS_API_ONLY) {
            header('X-nZEDb: ERROR: You must be logged in or provide a valid User ID and API key!');
            $page->show403();
        } else {
            header("Location: " . $page->settings->getSetting('code'));
        }
    }
    $page->title = "Rss Feeds";
    $page->meta_title = "Rss Nzb Feeds";
    $page->meta_keywords = "view,nzb,description,details,rss,atom";
    $page->meta_description = "View available Rss Nzb feeds.";
    $page->smarty->assign(['categorylist' => $category->get(true, $page->userdata["categoryexclusions"]), 'parentcategorylist' => $category->getForMenu($page->userdata["categoryexclusions"])]);
    $page->content = $page->smarty->fetch('rssdesc.tpl');
    $page->render();
} else {
    $rssToken = $uid = -1;
    // User requested a feed, ensure either logged in or passing a valid token.
    if ($page->users->isLoggedIn()) {
        $uid = $page->userdata["id"];
        $rssToken = $page->userdata["rsstoken"];
        $maxRequests = $page->userdata['apirequests'];
    } else {
        if ($page->settings->getSetting('registerstatus') == Settings::REGISTER_STATUS_API_ONLY) {
            $res = $page->users->getById(0);
        } else {
            if (!isset($_GET["i"]) || !isset($_GET["r"])) {
                header('X-nZEDb: ERROR: Both the User ID and API key are required for viewing the RSS!');
예제 #3
0
파일: api.php 프로젝트: advhamstrong/nZEDb
         showApiError(200, 'Missing parameter (id is required for downloading an NZB)');
     }
     $page->users->addApiRequest($uid, $_SERVER['REQUEST_URI']);
     $data = $releases->getByGuid($_GET['id']);
     $relData = [];
     if ($data) {
         $relData[] = $data;
     }
     printOutput($relData, $outputXML, $page, offset());
     break;
     // Capabilities request.
 // Capabilities request.
 case 'c':
     //get categories
     $category = new Category(['Settings' => $page->settings]);
     $cats = $category->getForMenu();
     //insert cats into template variable
     $page->smarty->assign('parentcatlist', $cats);
     if ($outputXML) {
         //use apicaps.tpl if xml is requested
         $response = $page->smarty->fetch('apicaps.tpl');
         header('Content-type: text/xml');
         header('Content-Length: ' . strlen($response));
         echo $response;
     } else {
         //otherwise construct array of capabilities and categories
         //get capabilities
         $caps = (new Capabilities(['Settings' => $page->settings]))->getForMenu();
         $caps['categories'] = $cats;
         //use json_encode
         $response = json_encode($caps);
예제 #4
0
파일: api.php 프로젝트: sebst3r/nZEDb
     if (!isset($_GET['id'])) {
         showApiError(200, 'Missing parameter (id is required for downloading an NZB)');
     }
     $page->users->addApiRequest($uid, $_SERVER['REQUEST_URI']);
     $data = $releases->getByGuid($_GET['id']);
     $relData = [];
     if ($data) {
         $relData[] = $data;
     }
     printOutput($relData, $outputXML, $page, offset());
     break;
     // Capabilities request.
 // Capabilities request.
 case 'c':
     $category = new Category(['Settings' => $page->settings]);
     $page->smarty->assign('parentcatlist', $category->getForMenu());
     header('Content-type: text/xml');
     echo $page->smarty->fetch('apicaps.tpl');
     break;
     // Register request.
 // Register request.
 case 'r':
     verifyEmptyParameter('email');
     if (!in_array((int) $page->settings->getSetting('registerstatus'), [Settings::REGISTER_STATUS_OPEN, Settings::REGISTER_STATUS_API_ONLY])) {
         showApiError(104);
     }
     // Check email is valid format.
     if (!$page->users->isValidEmail($_GET['email'])) {
         showApiError(106);
     }
     // Check email isn't taken.
예제 #5
0
파일: rss.php 프로젝트: sebst3r/nZEDb
    // User has to either be logged in, or using rsskey.
    if (!$page->users->isLoggedIn()) {
        if ($page->settings->getSetting('registerstatus') != Settings::REGISTER_STATUS_API_ONLY) {
            header('X-nZEDb: ERROR: You must be logged in or provide a valid User ID and API key!');
            $page->show403();
        } else {
            header("Location: " . $page->settings->getSetting('code'));
        }
    }
    $page->title = "Rss Feeds";
    $page->meta_title = "Rss Nzb Feeds";
    $page->meta_keywords = "view,nzb,description,details,rss,atom";
    $page->meta_description = "View available Rss Nzb feeds.";
    $categorylist = $category->get(true, $page->userdata["categoryexclusions"]);
    $page->smarty->assign('categorylist', $categorylist);
    $parentcategorylist = $category->getForMenu($page->userdata["categoryexclusions"]);
    $page->smarty->assign('parentcategorylist', $parentcategorylist);
    $page->content = $page->smarty->fetch('rssdesc.tpl');
    $page->render();
} else {
    $rsstoken = $uid = -1;
    // User requested a feed, ensure either logged in or passing a valid token.
    if ($page->users->isLoggedIn()) {
        $uid = $page->userdata["id"];
        $rsstoken = $page->userdata["rsstoken"];
        $maxrequests = $page->userdata['apirequests'];
    } else {
        if ($page->settings->getSetting('registerstatus') == Settings::REGISTER_STATUS_API_ONLY) {
            $res = $page->users->getById(0);
        } else {
            if (!isset($_GET["i"]) || !isset($_GET["r"])) {