diff --git a/www/index.php b/www/index.php index a0ef96d83..26119a69e 100644 --- a/www/index.php +++ b/www/index.php @@ -1,4 +1,5 @@ site->style != "default" && file_exists(NN_WWW.'pages/'.$page->site->style."/".$page->page.'.php')) - include(NN_WWW.'pages/'.$page->site->style."/".$page->page.'.php'); -elseif (file_exists(WWW_DIR.'pages/'.$page->page.'.php')) - include(NN_WWW.'pages/'.$page->page.'.php'); -else - $page->show404(); + +switch ($page->page) { + case 'ajax_mediainfo': + case 'ajax_mymovies': + case 'ajax_preinfo': + case 'ajax_profile': + case 'ajax_release-admin': + case 'ajax_rarfilelist': + case 'ajax_titleinfo': + case 'ajax_tvinfo': + case 'anime': + case 'apihelp': + case 'bookmodal': + case 'books': + case 'browse': + case 'browsegroup': + case 'calendar': + case 'cart': + case 'console': + case 'consolemodal': + case 'contact-us': + case 'content': + case 'details': + case 'filelist': + case 'forgottenpassword': + case 'forum': + case 'forumpost': + case 'games': + case 'getimage': + case 'logout': + case 'movies': + case 'movie': + case 'music': + case 'musicmodal': + case 'myshows': + case 'mymovies': + case 'mymoviesedit': + case 'newposterwall': + case 'nfo': + case 'nzbgetqueuedata': + case 'predb': + case 'profile': + case 'profileedit': + case 'queue': + case 'register': + case 'rss-info': + case 'sabqueuedata': + case 'search': + case 'sendtoqueue': + case 'series': + case 'sitemap': + case 'sysinfo': + case 'terms-and-conditions': + case 'upcoming': + case 'xxx': + case 'xxxmodal': + // Don't show these pages if it's an API-only site. + if (!$page->users->isLoggedIn() && $page->settings->getSetting('registerstatus') == Settings::REGISTER_STATUS_API_ONLY) { + header("Location: " . $page->settings->getSetting('code')); + break; + } + case 'api': + case 'getnzb': + case 'login': + case 'preinfo': + case 'rss': + include(NN_WWW . 'pages/' . $page->page . '.php'); + break; + default: + $page->show404(); + break; +} diff --git a/www/pages/ajax_mediainfo.php b/www/pages/ajax_mediainfo.php index a0d9a77be..259a0971d 100644 --- a/www/pages/ajax_mediainfo.php +++ b/www/pages/ajax_mediainfo.php @@ -1,5 +1,5 @@ isLoggedIn()) { +if (!$page->users->isLoggedIn()) { $page->show403(); } diff --git a/www/pages/ajax_mymovies.php b/www/pages/ajax_mymovies.php index a65370bd0..1c162a6ea 100644 --- a/www/pages/ajax_mymovies.php +++ b/www/pages/ajax_mymovies.php @@ -1,6 +1,6 @@ isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); $um = new UserMovies(); @@ -8,7 +8,7 @@ $um = new UserMovies(); if (isset($_REQUEST["del"])) { - $usermovies = $um->delMovie($users->currentUserId(), $_REQUEST["del"]); + $usermovies = $um->delMovie($page->users->currentUserId(), $_REQUEST["del"]); } elseif (isset($_REQUEST["add"])) { @@ -24,7 +24,7 @@ elseif (isset($_REQUEST["add"])) if (!$mi) $m->updateMovieInfo($_REQUEST["add"]); - $usermovies = $um->addMovie($users->currentUserId(), $_REQUEST["add"], $cats); + $usermovies = $um->addMovie($page->users->currentUserId(), $_REQUEST["add"], $cats); } else { @@ -76,7 +76,7 @@ else } $userimdbs = array(); - $usermovies = $um->getMovies($users->currentUserId()); + $usermovies = $um->getMovies($page->users->currentUserId()); foreach ($usermovies as $umovie) $userimdbs[$umovie["imdbID"]] = $umovie["imdbID"]; diff --git a/www/pages/ajax_prehashinfo.php b/www/pages/ajax_prehashinfo.php index 78f37a6cf..fe6f1657d 100644 --- a/www/pages/ajax_prehashinfo.php +++ b/www/pages/ajax_prehashinfo.php @@ -1,5 +1,5 @@ isLoggedIn()) { +if (!$page->users->isLoggedIn()) { $page->show403(); } diff --git a/www/pages/ajax_preinfo.php b/www/pages/ajax_preinfo.php index ac79f6503..1e5f0db2e 100644 --- a/www/pages/ajax_preinfo.php +++ b/www/pages/ajax_preinfo.php @@ -1,6 +1,6 @@ isLoggedIn() || $page->userdata["canpre"] != 1) +if(!$page->users->isLoggedIn() || $page->userdata["canpre"] != 1) $page->show403(); if(!isset($_REQUEST['searchname'])) diff --git a/www/pages/ajax_profile.php b/www/pages/ajax_profile.php index 66fb82b81..4bb8cc5e6 100644 --- a/www/pages/ajax_profile.php +++ b/www/pages/ajax_profile.php @@ -1,12 +1,12 @@ isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); if (isset($_GET['action']) && $_GET['action'] == "1" && isset($_GET['emailto'])) { $emailto = $_GET['emailto']; - $ret = $users->sendInvite($page->site->title, $page->site->email, $page->serverurl, $users->currentUserId(), $emailto); + $ret = $page->users->sendInvite($page->site->title, $page->site->email, $page->serverurl, $page->users->currentUserId(), $emailto); if (!$ret) print "Invite not sent."; else diff --git a/www/pages/ajax_rarfilelist.php b/www/pages/ajax_rarfilelist.php index 74f0b9ec4..002d32972 100644 --- a/www/pages/ajax_rarfilelist.php +++ b/www/pages/ajax_rarfilelist.php @@ -1,6 +1,6 @@ isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); if (!isset($_REQUEST["id"])) diff --git a/www/pages/ajax_tvinfo.php b/www/pages/ajax_tvinfo.php index 2ee77e9e2..0179a5a89 100644 --- a/www/pages/ajax_tvinfo.php +++ b/www/pages/ajax_tvinfo.php @@ -1,6 +1,6 @@ isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); if (!isset($_REQUEST["id"])) diff --git a/www/pages/anime.php b/www/pages/anime.php index d6562ddff..a79f5f915 100644 --- a/www/pages/anime.php +++ b/www/pages/anime.php @@ -1,6 +1,6 @@ isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); $Releases = new Releases(['Settings' => $page->settings]); diff --git a/www/pages/api.php b/www/pages/api.php index e12ecc4ee..1bda31209 100644 --- a/www/pages/api.php +++ b/www/pages/api.php @@ -72,7 +72,7 @@ $hosthash = ''; $catExclusions = []; $maxRequests = 0; // Page is accessible only by the apikey, or logged in users. -if ($users->isLoggedIn()) { +if ($page->users->isLoggedIn()) { $uid = $page->userdata['id']; $apiKey = $page->userdata['rsstoken']; $catExclusions = $page->userdata['categoryexclusions']; @@ -82,7 +82,7 @@ if ($users->isLoggedIn()) { if (!isset($_GET['apikey'])) { showApiError(200, 'Missing parameter (apikey)'); } - $res = $users->getByRssToken($_GET['apikey']); + $res = $page->users->getByRssToken($_GET['apikey']); $apiKey = $_GET['apikey']; if (!$res) { @@ -90,12 +90,12 @@ if ($users->isLoggedIn()) { } $uid = $res['id']; - $catExclusions = $users->getCategoryExclusion($uid); + $catExclusions = $page->users->getCategoryExclusion($uid); // // A hash of the users ip to record against the api hit // if ($page->site->storeuserips == 1) - $hosthash = $users->getHostHash($_SERVER["REMOTE_ADDR"], $page->site->siteseed); + $hosthash = $page->users->getHostHash($_SERVER["REMOTE_ADDR"], $page->site->siteseed); $maxRequests = $res['apirequests']; } } @@ -105,8 +105,8 @@ $page->smarty->assign('rsstoken', $apiKey); // Record user access to the api, if its been called by a user (i.e. capabilities request do not require a user to be logged in or key provided). if ($uid != '') { - $users->updateApiAccessed($uid); - $apiRequests = $users->getApiRequests($uid); + $page->users->updateApiAccessed($uid); + $apiRequests = $page->users->getApiRequests($uid); if ($apiRequests['num'] > $maxRequests) { showApiError(500, 'Request limit reached (' . $apiRequests['num'] . '/' . $maxRequests . ')'); } @@ -134,7 +134,7 @@ switch ($function) { case 's': verifyEmptyParameter('q'); $maxAge = maxAge(); - $users->addApiRequest($uid, $_SERVER['REQUEST_URI'], $hosthash); + $page->users->addApiRequest($uid, $_SERVER['REQUEST_URI'], $hosthash); $categoryID = categoryid(); $limit = limit(); $offset = offset(); @@ -161,7 +161,7 @@ switch ($function) { verifyEmptyParameter('season'); verifyEmptyParameter('ep'); $maxAge = maxAge(); - $users->addApiRequest($uid, $_SERVER['REQUEST_URI'], $hosthash); + $page->users->addApiRequest($uid, $_SERVER['REQUEST_URI'], $hosthash); $offset = offset(); $relData = $releases->searchbyRageId( @@ -186,7 +186,7 @@ switch ($function) { if (!isset($_GET["id"])) showApiError(200); - $users->addApiRequest($uid, $_SERVER['REQUEST_URI'], $hosthash); + $page->users->addApiRequest($uid, $_SERVER['REQUEST_URI'], $hosthash); $reldata = $releases->getByGuid($_GET["id"]); if (!$reldata) @@ -226,7 +226,7 @@ switch ($function) { if (!isset($_GET["id"])) showApiError(200); - $users->addApiRequest($uid, $_SERVER['REQUEST_URI'], $hosthash); + $page->users->addApiRequest($uid, $_SERVER['REQUEST_URI'], $hosthash); $data = $rc->getCommentsByGuid($_GET["id"]); if ($data) @@ -254,7 +254,7 @@ switch ($function) { if (!isset($_GET["text"])) showApiError(200); - $users->addApiRequest($uid, $_SERVER['REQUEST_URI'], $hosthash); + $page->users->addApiRequest($uid, $_SERVER['REQUEST_URI'], $hosthash); $reldata = $releases->getByGuid($_GET["id"]); if ($reldata) @@ -291,7 +291,7 @@ switch ($function) { $maxage = $_GET["maxage"]; } - $users->addApiRequest($uid, $_SERVER['REQUEST_URI'], $hosthash); + $page->users->addApiRequest($uid, $_SERVER['REQUEST_URI'], $hosthash); $limit = 100; if (isset($_GET["limit"]) && is_numeric($_GET["limit"]) && $_GET["limit"] < 100) @@ -339,7 +339,7 @@ switch ($function) { else $genreId[] = -1; - $users->addApiRequest($uid, $_SERVER['REQUEST_URI'], $hosthash); + $page->users->addApiRequest($uid, $_SERVER['REQUEST_URI'], $hosthash); $limit = 100; if (isset($_GET["limit"]) && is_numeric($_GET["limit"]) && $_GET["limit"] < 100) @@ -363,7 +363,7 @@ switch ($function) { verifyEmptyParameter('q'); verifyEmptyParameter('imdbid'); $maxAge = maxAge(); - $users->addApiRequest($uid, $_SERVER['REQUEST_URI'], $hosthash); + $page->users->addApiRequest($uid, $_SERVER['REQUEST_URI'], $hosthash); $offset = offset(); $imdbId = (isset($_GET['imdbid']) ? $_GET['imdbid'] : '-1'); @@ -417,7 +417,7 @@ switch ($function) { showApiError(200, 'Missing parameter (id is required for downloading an NZB)'); } - $users->addApiRequest($uid, $_SERVER['REQUEST_URI'], $hosthash); + $page->users->addApiRequest($uid, $_SERVER['REQUEST_URI'], $hosthash); $data = $releases->getByGuid($_GET['id']); $relData = []; @@ -445,28 +445,28 @@ switch ($function) { } // Check email is valid format. - if (!$users->isValidEmail($_GET['email'])) { + if (!$page->users->isValidEmail($_GET['email'])) { showApiError(106); } // Check email isn't taken. - $ret = $users->getByEmail($_GET['email']); + $ret = $page->users->getByEmail($_GET['email']); if (isset($ret['id'])) { showApiError(105); } // Create username/pass and register. - $username = $users->generateUsername($_GET['email']); - $password = $users->generatePassword(); + $username = $page->users->generateUsername($_GET['email']); + $password = $page->users->generatePassword(); // Register. - $userDefault = $users->getDefaultRole(); - $uid = $users->signup( + $userDefault = $page->users->getDefaultRole(); + $uid = $page->users->signup( $username, $password, $_GET['email'], $_SERVER['REMOTE_ADDR'], $userDefault['id'], "", $userDefault['defaultinvites'], "", false, false, false, true ); // Check if it succeeded. - $userData = $users->getById($uid); + $userData = $page->users->getById($uid); if (!$userData) { showApiError(107); } diff --git a/www/pages/bookmodal.php b/www/pages/bookmodal.php index 3b8577d7e..501f37c20 100644 --- a/www/pages/bookmodal.php +++ b/www/pages/bookmodal.php @@ -2,7 +2,7 @@ $b = new Book; -if (!$users->isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); if (isset($_GET["id"]) && ctype_digit($_GET["id"])) diff --git a/www/pages/books.php b/www/pages/books.php index 57a181636..6b39cc4f9 100644 --- a/www/pages/books.php +++ b/www/pages/books.php @@ -2,7 +2,7 @@ $b = new Book; -if (!$users->isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); $category = Category::CAT_BOOK_EBOOK; diff --git a/www/pages/browse.php b/www/pages/browse.php index f53045574..0dfd05b2d 100644 --- a/www/pages/browse.php +++ b/www/pages/browse.php @@ -2,7 +2,7 @@ $releases = new Releases(['Settings' => $page->settings]); -if (!$users->isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); $category = -1; diff --git a/www/pages/browsegroup.php b/www/pages/browsegroup.php index 069bab64e..268781ec1 100644 --- a/www/pages/browsegroup.php +++ b/www/pages/browsegroup.php @@ -1,5 +1,5 @@ isLoggedIn()) { +if (!$page->users->isLoggedIn()) { $page->show403(); } diff --git a/www/pages/calendar.php b/www/pages/calendar.php index 88bc548b5..14c561f1c 100644 --- a/www/pages/calendar.php +++ b/www/pages/calendar.php @@ -1,6 +1,6 @@ isLoggedIn()) { +if (!$page->users->isLoggedIn()) { $page->show403(); } diff --git a/www/pages/cart.php b/www/pages/cart.php index 7d5958510..7863fa7bf 100644 --- a/www/pages/cart.php +++ b/www/pages/cart.php @@ -37,7 +37,7 @@ if (isset($_GET["add"])) { $page->meta_keywords = "search,add,to,cart,nzb,description,details"; $page->meta_description = "Manage Your Nzb Cart"; - $results = $users->getCart($page->users->currentUserId()); + $results = $page->users->getCart($page->users->currentUserId()); $page->smarty->assign('results', $results); $page->content = $page->smarty->fetch('cart.tpl'); diff --git a/www/pages/console.php b/www/pages/console.php index 655228bd4..734e27fdb 100644 --- a/www/pages/console.php +++ b/www/pages/console.php @@ -4,7 +4,7 @@ $console = new Console; $cat = new Category; $gen = new Genres; -if (!$users->isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); diff --git a/www/pages/consolemodal.php b/www/pages/consolemodal.php index 1adb8b773..e48c76e34 100644 --- a/www/pages/consolemodal.php +++ b/www/pages/consolemodal.php @@ -2,7 +2,7 @@ $console = new Console; -if (!$users->isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); if (isset($_GET["id"]) && ctype_digit($_GET["id"])) diff --git a/www/pages/details.php b/www/pages/details.php index bcdc849ea..9bc0b1d36 100644 --- a/www/pages/details.php +++ b/www/pages/details.php @@ -1,6 +1,6 @@ isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); if (isset($_GET["id"])) @@ -14,7 +14,7 @@ if (isset($_GET["id"])) $page->show404(); if ($page->isPostBack()) - $rc->addComment($data["id"], $data["gid"], $_POST["txtAddComment"], $users->currentUserId(), $_SERVER['REMOTE_ADDR']); + $rc->addComment($data["id"], $data["gid"], $_POST["txtAddComment"], $page->users->currentUserId(), $_SERVER['REMOTE_ADDR']); $nfo = $releases->getReleaseNfo($data["id"], false); $reVideo = $re->getVideo($data["id"]); diff --git a/www/pages/dlbrowse.php b/www/pages/dlbrowse.php index 66aced714..859b7f973 100644 --- a/www/pages/dlbrowse.php +++ b/www/pages/dlbrowse.php @@ -3,7 +3,7 @@ use newznab\db\Settings; use newznab\utility\Utility; -if (!$users->isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); $r = new Releases(); diff --git a/www/pages/failed.php b/www/pages/failed.php index ecb3385f3..dd5e201d0 100644 --- a/www/pages/failed.php +++ b/www/pages/failed.php @@ -1,7 +1,7 @@ $page->settings]); -$users = new Users(); +$page->users = new Users(); $page = new Page(); if (isset($_GET['userid']) && is_numeric($_GET['userid']) && isset($_GET['rsstoken']) && isset($_GET['guid'])) { diff --git a/www/pages/filelist.php b/www/pages/filelist.php index 739cda772..212c1b875 100644 --- a/www/pages/filelist.php +++ b/www/pages/filelist.php @@ -3,7 +3,7 @@ $releases = new Releases; $nzb = new NZB; -if (!$users->isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); if (isset($_GET["id"])) diff --git a/www/pages/forum.php b/www/pages/forum.php index d106e3fd0..7c15b5f18 100644 --- a/www/pages/forum.php +++ b/www/pages/forum.php @@ -2,7 +2,7 @@ $forum = new Forum; -if (!$users->isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); if ($page->isPostBack()) @@ -12,7 +12,7 @@ if ($page->isPostBack()) if (!isset($_POST["addMessage"]) || empty($_POST["addMessage"])) $page->show403(); - $forum->add(0, $users->currentUserId(), $_POST["addSubject"], $_POST["addMessage"]); + $forum->add(0, $page->users->currentUserId(), $_POST["addSubject"], $_POST["addMessage"]); header("Location:".WWW_TOP."/forum"); die(); } diff --git a/www/pages/forumpost.php b/www/pages/forumpost.php index 729123cea..02da5c56a 100644 --- a/www/pages/forumpost.php +++ b/www/pages/forumpost.php @@ -1,6 +1,6 @@ isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); $id = $_GET["id"] + 0; @@ -8,7 +8,7 @@ $id = $_GET["id"] + 0; $forum = new Forum(); if ($page->isPostBack()) { - $forum->add($id, $users->currentUserId(), "", $_POST["addReply"]); + $forum->add($id, $page->users->currentUserId(), "", $_POST["addReply"]); header("Location:".WWW_TOP."/forumpost/".$id."#last"); die(); } diff --git a/www/pages/games.php b/www/pages/games.php index 3a2801b1b..d2cfcab20 100644 --- a/www/pages/games.php +++ b/www/pages/games.php @@ -1,6 +1,6 @@ isLoggedIn()) { +if (!$page->users->isLoggedIn()) { $page->show403(); } diff --git a/www/pages/getimage.php b/www/pages/getimage.php index b4c0663e7..3286b78cb 100644 --- a/www/pages/getimage.php +++ b/www/pages/getimage.php @@ -3,7 +3,7 @@ // // page is accessible only to logged in users. // -if (!$users->isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); if (!isset($_GET["type"]) || !isset($_GET["id"]) || !ctype_digit($_GET["id"])) diff --git a/www/pages/getnzb.php b/www/pages/getnzb.php index 0584dca56..5e9c18102 100644 --- a/www/pages/getnzb.php +++ b/www/pages/getnzb.php @@ -5,13 +5,13 @@ $rel = new Releases(['Settings' => $page->settings]); $uid = 0; // Page is accessible only by the rss token, or logged in users. -if ($users->isLoggedIn()) { - $uid = $users->currentUserId(); +if ($page->users->isLoggedIn()) { + $uid = $page->users->currentUserId(); $maxdls = $page->userdata["downloadrequests"]; $rsstoken = $page->userdata['rsstoken']; } else { if ($page->site->registerstatus == Sites::REGISTER_STATUS_API_ONLY) { - $res = $users->getById(0); + $res = $page->users->getById(0); } else { if ((!isset($_GET["i"]) || !isset($_GET["r"]))) { header("X-DNZB-RCode: 400"); @@ -19,7 +19,7 @@ if ($users->isLoggedIn()) { $page->show403(); } - $res = $users->getByIdAndRssToken($_GET["i"], $_GET["r"]); + $res = $page->users->getByIdAndRssToken($_GET["i"], $_GET["r"]); if (!$res) { header("X-DNZB-RCode: 401"); header("X-DNZB-RText: Unauthorised, wrong user ID or rss key!"); @@ -40,10 +40,10 @@ if (isset($_GET['id'])) { // $hosthash = ""; if ($page->site->storeuserips == 1) { - $hosthash = $users->getHostHash($_SERVER["REMOTE_ADDR"], $page->site->siteseed); + $hosthash = $page->users->getHostHash($_SERVER["REMOTE_ADDR"], $page->site->siteseed); } // Check download limit on user role. -$dlrequests = $users->getDownloadRequests($uid); +$dlrequests = $page->users->getDownloadRequests($uid); if ($dlrequests['num'] > $maxdls) { header("X-DNZB-RCode: 503"); header("X-DNZB-RText: User has exceeded maximum downloads for the day!"); @@ -61,13 +61,13 @@ if (isset($_GET["id"]) && isset($_GET["zip"]) && $_GET["zip"] == "1") { $zip = $rel->getZipped($guids); if (strlen($zip) > 0) { - $users->incrementGrabs($uid, count($guids)); + $page->users->incrementGrabs($uid, count($guids)); foreach ($guids as $guid) { $rel->updateGrab($guid); - $users->addDownloadRequest($uid, $rel['id']); + $page->users->addDownloadRequest($uid, $rel['id']); if (isset($_GET["del"]) && $_GET["del"] == 1) { - $users->delCartByUserAndRelease($guid, $uid); + $page->users->delCartByUserAndRelease($guid, $uid); } } @@ -93,10 +93,10 @@ if (isset($_GET["id"])) { if ($reldata) { $rel->updateGrab($_GET["id"]); - $users->addDownloadRequest($uid, $reldata['id']); - $users->incrementGrabs($uid); + $page->users->addDownloadRequest($uid, $reldata['id']); + $page->users->incrementGrabs($uid); if (isset($_GET["del"]) && $_GET["del"] == 1) { - $users->delCartByUserAndRelease($_GET["id"], $uid); + $page->users->delCartByUserAndRelease($_GET["id"], $uid); } } else { header("X-DNZB-RCode: 404"); diff --git a/www/pages/login.php b/www/pages/login.php index 952ef6eef..640e687f2 100644 --- a/www/pages/login.php +++ b/www/pages/login.php @@ -26,10 +26,11 @@ if ($page->isPostBack()) $rememberMe = (isset($_POST['rememberme']) && $_POST['rememberme'] == 'on') ? 1 : 0; $page->users->login($res["id"], $_SERVER['REMOTE_ADDR'], $rememberMe); - if (isset($_POST["redirect"]) && $_POST["redirect"] != "") - header("Location: ".$_POST["redirect"]); - else - header("Location: ".WWW_TOP.$page->site->home_link); + if (isset($_POST["redirect"]) && $_POST["redirect"] != "") { + header("Location: " . $_POST["redirect"]); + } else { + header("Location: " . WWW_TOP . $page->settings->getSetting('home_link')); + } die(); } else diff --git a/www/pages/logout.php b/www/pages/logout.php index 7ca3f4fb6..026865ddd 100644 --- a/www/pages/logout.php +++ b/www/pages/logout.php @@ -1,4 +1,4 @@ logout(); +$page->users->logout(); header("Location: ".WWW_TOP."/"); diff --git a/www/pages/movie.php b/www/pages/movie.php index ff9ea7eea..9e8142dd2 100644 --- a/www/pages/movie.php +++ b/www/pages/movie.php @@ -2,7 +2,7 @@ $movie = new Movie; -if (!$users->isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); if (isset($_GET["id"]) && ctype_digit($_GET["id"])) diff --git a/www/pages/movies.php b/www/pages/movies.php index c8ae6594a..8ad62cd6c 100644 --- a/www/pages/movies.php +++ b/www/pages/movies.php @@ -3,7 +3,7 @@ $movie = new Movie; $cat = new Category(['Settings' => $page->settings]); -if (!$users->isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); @@ -17,7 +17,7 @@ $category = (isset($_GET["imdb"]) ? -1 : Category::CAT_PARENT_MOVIE); if (isset($_REQUEST["t"]) && array_key_exists($_REQUEST['t'], $mtmp)) $category = $_REQUEST["t"] + 0; -$user = $users->getById($users->currentUserId()); +$user = $page->users->getById($page->users->currentUserId()); $cpapi = $user['cp_api']; $cpurl = $user['cp_url']; $page->smarty->assign('cpapi', $cpapi); diff --git a/www/pages/movietrailer.php b/www/pages/movietrailer.php index 9c9fd29e1..837673256 100644 --- a/www/pages/movietrailer.php +++ b/www/pages/movietrailer.php @@ -2,7 +2,7 @@ $movie = new Movie; -if (!$users->isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); if (isset($_GET["id"]) && ctype_digit($_GET["id"])) diff --git a/www/pages/music.php b/www/pages/music.php index 06a9f654d..5b860e3f1 100644 --- a/www/pages/music.php +++ b/www/pages/music.php @@ -1,6 +1,6 @@ isLoggedIn()) { +if (!$page->users->isLoggedIn()) { $page->show403(); } diff --git a/www/pages/musicmodal.php b/www/pages/musicmodal.php index 17ec9006f..b4bb7098a 100644 --- a/www/pages/musicmodal.php +++ b/www/pages/musicmodal.php @@ -2,7 +2,7 @@ $music = new Music; -if (!$users->isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); if (isset($_GET["id"]) && ctype_digit($_GET["id"])) diff --git a/www/pages/mymovies.php b/www/pages/mymovies.php index 07a5315d4..87a4f11f7 100644 --- a/www/pages/mymovies.php +++ b/www/pages/mymovies.php @@ -1,7 +1,7 @@ isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); - + $page->title = "My Movies"; $page->meta_title = "My Movies"; $page->meta_keywords = "couch,potato,movie,add"; diff --git a/www/pages/mymoviesedit.php b/www/pages/mymoviesedit.php index 33b0ea3ec..ac940a301 100644 --- a/www/pages/mymoviesedit.php +++ b/www/pages/mymoviesedit.php @@ -1,14 +1,14 @@ isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); $um = new UserMovies(); if (isset($_REQUEST["del"])) { - $um->delMovie($users->currentUserId(), $_REQUEST["del"]); + $um->delMovie($page->users->currentUserId(), $_REQUEST["del"]); } $cat = new Category; @@ -17,7 +17,7 @@ $categories = array(); foreach($tmpcats as $c) $categories[$c['ID']] = $c['title']; -$movies = $um->getMovies($users->currentUserId()); +$movies = $um->getMovies($page->users->currentUserId()); $results = array(); foreach ($movies as $mov=>$m) { diff --git a/www/pages/myshows.php b/www/pages/myshows.php index fd92875a5..61d99fd8c 100644 --- a/www/pages/myshows.php +++ b/www/pages/myshows.php @@ -2,7 +2,7 @@ use newznab\db\Settings; -if (!$users->isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); $us = new UserSeries(); @@ -12,12 +12,12 @@ $rid = isset($_REQUEST['subpage']) ? $_REQUEST['subpage'] : ''; switch($action) { case 'delete': - $show = $us->getShow($users->currentUserId(), $rid); + $show = $us->getShow($page->users->currentUserId(), $rid); if (!$show) $page->show404('Not subscribed'); else - $us->delShow($users->currentUserId(), $rid); + $us->delShow($page->users->currentUserId(), $rid); if (isset($_REQUEST['from'])) header("Location:".WWW_TOP.$_REQUEST['from']); @@ -26,7 +26,7 @@ switch($action) { break; case 'add': case 'doadd': - $show = $us->getShow($users->currentUserId(), $rid); + $show = $us->getShow($page->users->currentUserId(), $rid); if ($show) { @@ -43,7 +43,7 @@ switch($action) { if ($action == 'doadd') { $category = (isset($_REQUEST['category']) && is_array($_REQUEST['category']) && !empty($_REQUEST['category'])) ? $_REQUEST['category'] :[]; - $us->addShow($users->currentUserId(), $rid, $category); + $us->addShow($page->users->currentUserId(), $rid, $category); if (isset($_REQUEST['from'])) header("Location:".$_REQUEST['from']); else @@ -71,7 +71,7 @@ switch($action) { break; case 'edit': case 'doedit': - $show = $us->getShow($users->currentUserId(), $rid); + $show = $us->getShow($page->users->currentUserId(), $rid); if (!$show) $page->show404(); @@ -79,7 +79,7 @@ switch($action) { if ($action == 'doedit') { $category = (isset($_REQUEST['category']) && is_array($_REQUEST['category']) && !empty($_REQUEST['category'])) ? $_REQUEST['category'] :[]; - $us->updateShow($users->currentUserId(), $rid, $category); + $us->updateShow($page->users->currentUserId(), $rid, $category); if (isset($_REQUEST['from'])) header("Location:".WWW_TOP.$_REQUEST['from']); else @@ -113,7 +113,7 @@ switch($action) { $page->meta_keywords = "search,add,to,cart,nzb,description,details"; $page->meta_description = "Browse Your Shows"; - $shows = $us->getShows($users->currentUserId()); + $shows = $us->getShows($page->users->currentUserId()); $releases = new Releases; $browsecount = $releases->getShowsCount($shows, -1, $page->userdata["categoryexclusions"]); @@ -160,7 +160,7 @@ switch($action) { foreach($tmpcats as $c) $categories[$c['id']] = $c['title']; - $shows = $us->getShows($users->currentUserId()); + $shows = $us->getShows($page->users->currentUserId()); $results =[]; foreach ($shows as $showk=>$show) { diff --git a/www/pages/newposterwall.php b/www/pages/newposterwall.php index ced2270f4..1c327325f 100644 --- a/www/pages/newposterwall.php +++ b/www/pages/newposterwall.php @@ -1,6 +1,6 @@ isLoggedIn()) { +if (!$page->users->isLoggedIn()) { $page->show403(); } @@ -50,7 +50,7 @@ if (!$error) { $getnewestmovies = $releases->getNewestMovies(); $page->smarty->assign('newest', $getnewestmovies); - $user = $users->getById($users->currentUserId()); + $user = $page->users->getById($page->users->currentUserId()); $page->smarty->assign('cpapi', $user['cp_api']); $page->smarty->assign('cpurl', $user['cp_url']); $page->smarty->assign('goto', 'movies'); diff --git a/www/pages/nfo.php b/www/pages/nfo.php index 79e1b01b3..9a8d03ada 100644 --- a/www/pages/nfo.php +++ b/www/pages/nfo.php @@ -4,7 +4,7 @@ use newznab\utility\Utility; $releases = new Releases; -if (!$users->isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); if (isset($_GET["id"])) { diff --git a/www/pages/nzbgetqueuedata.php b/www/pages/nzbgetqueuedata.php index 5555385c7..62a53d69c 100644 --- a/www/pages/nzbgetqueuedata.php +++ b/www/pages/nzbgetqueuedata.php @@ -2,7 +2,7 @@ use newznab\utility\Utility; -if (!$users->isLoggedIn()) { +if (!$page->users->isLoggedIn()) { $page->show403(); } diff --git a/www/pages/nzbvortex.php b/www/pages/nzbvortex.php index 784b127d6..9333f4751 100644 --- a/www/pages/nzbvortex.php +++ b/www/pages/nzbvortex.php @@ -1,6 +1,6 @@ isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); try diff --git a/www/pages/predb.php b/www/pages/predb.php index a59163b5b..da784bc2c 100644 --- a/www/pages/predb.php +++ b/www/pages/predb.php @@ -2,7 +2,7 @@ $PreDB = new PreDB(); -if (!$users->isLoggedIn() || $page->userdata["canpre"] != 1) +if (!$page->users->isLoggedIn() || $page->userdata["canpre"] != 1) $page->show403(); $page->title = 'PreDB'; diff --git a/www/pages/prehash.php b/www/pages/prehash.php index bd58606a0..634ae2539 100644 --- a/www/pages/prehash.php +++ b/www/pages/prehash.php @@ -1,6 +1,6 @@ isLoggedIn()) { +if (!$page->users->isLoggedIn()) { $page->show403(); } diff --git a/www/pages/prehashinfo.php b/www/pages/prehashinfo.php index 699281a5f..887cb77e8 100644 --- a/www/pages/prehashinfo.php +++ b/www/pages/prehashinfo.php @@ -97,12 +97,12 @@ // You can make this page accessible by all (even people without an API key) by setting this to false : if (true) { - if (!$users->isLoggedIn()) { + if (!$page->users->isLoggedIn()) { if (!isset($_GET['apikey'])) { apiError('Missing parameter (apikey)', 200); } - if (!$users->getByRssToken($_GET['apikey'])) { + if (!$page->users->getByRssToken($_GET['apikey'])) { apiError('Incorrect user credentials (api key is wrong)', 100); } } diff --git a/www/pages/profile.php b/www/pages/profile.php index 6c527c3e9..7adbee96a 100644 --- a/www/pages/profile.php +++ b/www/pages/profile.php @@ -4,7 +4,7 @@ $rc = new ReleaseComments; $sab = new SABnzbd($page); $nzbget = new NZBGet($page); -if (!$users->isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); $userid = 0; @@ -12,14 +12,14 @@ if (isset($_GET["id"])) $userid = $_GET["id"] + 0; elseif (isset($_GET["name"])) { - $res = $users->getByUsername($_GET["name"]); + $res = $page->users->getByUsername($_GET["name"]); if ($res) $userid = $res["id"]; } else - $userid = $users->currentUserId(); + $userid = $page->users->currentUserId(); -$privileged = ($users->isAdmin($userid) || $users->isModerator($userid)) ? true : false; +$privileged = ($page->users->isAdmin($userid) || $page->users->isModerator($userid)) ? true : false; $privateProfiles = ($page->settings->getSetting('privateprofiles') == 1) ? true : false; $publicView = false; @@ -30,7 +30,7 @@ if (!$privateProfiles || $privileged) { // If both 'id' and 'name' are specified, 'id' should take precedence. if ($altID === false && $altUsername !== false) { - $user = $users->getByUsername($altUsername); + $user = $page->users->getByUsername($altUsername); if ($user) { $altID = $user['id']; } @@ -42,16 +42,16 @@ if (!$privateProfiles || $privileged) { -$data = $users->getById($userid); +$data = $page->users->getById($userid); if (!$data) $page->show404(); $invitedby = ''; if ($data["invitedby"] != "") - $invitedby = $users->getById($data["invitedby"]); + $invitedby = $page->users->getById($data["invitedby"]); -$page->smarty->assign('apihits', $users->getApiRequests($userid)); -$page->smarty->assign('grabstoday', $users->getDownloadRequests($userid)); +$page->smarty->assign('apihits', $page->users->getApiRequests($userid)); +$page->smarty->assign('grabstoday', $page->users->getDownloadRequests($userid)); $page->smarty->assign('userinvitedby',$invitedby); $page->smarty->assign('user',$data); $page->smarty->assign('privateprofiles', $privateProfiles); @@ -73,11 +73,11 @@ $page->smarty->assign('pager', $pager); $commentslist = $rc->getCommentsForUserRange($userid, $offset, ITEMS_PER_PAGE); $page->smarty->assign('commentslist',$commentslist); -$downloadlist = $users->getDownloadRequestsForUserAndAllHostHashes($userid); +$downloadlist = $page->users->getDownloadRequestsForUserAndAllHostHashes($userid); $page->smarty->assign('downloadlist',$downloadlist); -$exccats = $users->getCategoryExclusionNames($userid); +$exccats = $page->users->getCategoryExclusionNames($userid); $page->smarty->assign('exccats', implode(",", $exccats)); $page->smarty->assign('saburl', $sab->url); diff --git a/www/pages/profileedit.php b/www/pages/profileedit.php index e7b1c2051..6f344b4ff 100644 --- a/www/pages/profileedit.php +++ b/www/pages/profileedit.php @@ -5,17 +5,17 @@ use newznab\utility\Utility; $category = new Category; $sab = new SABnzbd($page); $nzbGet = new NZBGet($page); -$users = new Users(); +$page->users = new Users(); $s = new Sites(); $site = $s->get(); -if (!$users->isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view'; -$userid = $users->currentUserId(); -$data = $users->getById($userid); +$userid = $page->users->currentUserId(); +$data = $page->users->getById($userid); if (!$data) $page->show404(); @@ -23,7 +23,7 @@ $errorStr = ''; switch ($action) { case 'newapikey': - $users->updateRssKey($userid); + $page->users->updateRssKey($userid); header("Location: profileedit"); break; case 'clearcookies': @@ -38,14 +38,14 @@ switch ($action) { if ($_POST['password'] != "" && $_POST['password'] != $_POST['confirmpassword']) { $errorStr = "Password Mismatch"; - } else if ($_POST['password'] != "" && !$users->isValidPassword($_POST['password'])) { + } else if ($_POST['password'] != "" && !$page->users->isValidPassword($_POST['password'])) { $errorStr = "Your password must be longer than five characters."; } else if (isset($_POST['nzbgeturl']) && $nzbGet->verifyURL($_POST['nzbgeturl']) === false) { $errorStr = "The NZBGet URL you entered is invalid!"; - } else if (!$users->isValidEmail($_POST['email'])) { + } else if (!$page->users->isValidEmail($_POST['email'])) { $errorStr = "Your email is not a valid format."; } else { - $res = $users->getByEmail($_POST['email']); + $res = $page->users->getByEmail($_POST['email']); if ($res && $res["id"] != $userid) { $errorStr = "Sorry, the email is already in use."; } elseif ((empty($_POST['saburl']) && !empty($_POST['sabapikey'])) || (!empty($_POST['saburl']) && empty($_POST['sabapikey']))) { @@ -56,7 +56,7 @@ switch ($action) { $_POST['saburl'] = $_POST['sabapikey'] = $_POST['sabpriority'] = $_POST['sabapikeytype'] = false; } - $users->update( + $page->users->update( $userid, $data["username"], $_POST['email'], @@ -86,10 +86,10 @@ switch ($action) { ); $_POST['exccat'] = (!isset($_POST['exccat']) || !is_array($_POST['exccat'])) ? array() : $_POST['exccat']; - $users->addCategoryExclusions($userid, $_POST['exccat']); + $page->users->addCategoryExclusions($userid, $_POST['exccat']); if ($_POST['password'] != "") - $users->updatePassword($userid, $_POST['password']); + $page->users->updatePassword($userid, $_POST['password']); header("Location:" . WWW_TOP . "/profile"); die(); @@ -116,7 +116,7 @@ $page->smarty->assign('themelist', $themeList); $page->smarty->assign('error', $errorStr); $page->smarty->assign('user', $data); -$page->smarty->assign('userexccat', $users->getCategoryExclusion($userid)); +$page->smarty->assign('userexccat', $page->users->getCategoryExclusion($userid)); $page->smarty->assign('saburl_selected', $sab->url); $page->smarty->assign('sabapikey_selected', $sab->apikey); diff --git a/www/pages/queue.php b/www/pages/queue.php index 45a50e707..d6e2e04e8 100644 --- a/www/pages/queue.php +++ b/www/pages/queue.php @@ -1,10 +1,10 @@ isLoggedIn()) { +if (!$page->users->isLoggedIn()) { $page->show403(); } -$userData = $users->getById($users->currentUserId()); +$userData = $page->users->getById($page->users->currentUserId()); if (!$userData) { $page->show404(); } @@ -78,7 +78,7 @@ if (!is_null($queue)) { } } -$page->smarty->assign(array('queueType' => $queueType, 'error' => $error, 'user', $users)); +$page->smarty->assign(array('queueType' => $queueType, 'error' => $error, 'user', $page->users)); $page->title = "Your $queueType Download Queue"; $page->meta_title = "View $queueType Queue"; $page->meta_keywords = "view," . strtolower($queueType) .",queue"; diff --git a/www/pages/queuedata.php b/www/pages/queuedata.php index 0d50ad95b..38874a173 100644 --- a/www/pages/queuedata.php +++ b/www/pages/queuedata.php @@ -1,6 +1,6 @@ isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); $sab = new SABnzbd($page); diff --git a/www/pages/register.php b/www/pages/register.php index b4deeacb8..f4ea60022 100644 --- a/www/pages/register.php +++ b/www/pages/register.php @@ -1,6 +1,6 @@ isLoggedIn()) +if ($page->users->isLoggedIn()) $page->show404(); $showregister = 1; @@ -54,11 +54,11 @@ else { $page->smarty->assign('error', "Password Mismatch"); } else { //get the default user role - $userdefault = $users->getDefaultRole(); + $userdefault = $page->users->getDefaultRole(); - $ret = $users->signup($username, $password, $email, $_SERVER['REMOTE_ADDR'], $userdefault['id'], "", $userdefault['defaultinvites'], $invitecode, false); + $ret = $page->users->signup($username, $password, $email, $_SERVER['REMOTE_ADDR'], $userdefault['id'], "", $userdefault['defaultinvites'], $invitecode, false); if ($ret > 0) { - $users->login($ret, $_SERVER['REMOTE_ADDR']); + $page->users->login($ret, $_SERVER['REMOTE_ADDR']); header("Location: " . WWW_TOP . "/"); } else { switch ($ret) { @@ -94,7 +94,7 @@ else { // // see if it is a valid invite // - $invite = $users->getInvite($invitecode); + $invite = $page->users->getInvite($invitecode); if (!$invite) { $page->smarty->assign('error', sprintf("Bad or invite code older than %d days.", Users::DEFAULT_INVITE_EXPIRY_DAYS)); $page->smarty->assign('showregister', "0"); diff --git a/www/pages/rss.php b/www/pages/rss.php index 1f2e31eb1..f6aaf414e 100644 --- a/www/pages/rss.php +++ b/www/pages/rss.php @@ -77,7 +77,7 @@ if (!isset($_GET["t"]) && !isset($_GET["rage"]) && !isset($_GET["anidb"])) { $usercat = ($_GET["t"] == 0 ? -1 : $_GET["t"]); } - $userrage = $useranidb = $userseries = -1; + $userrage = $useranidb = $page->userseries = -1; if (isset($_GET["rage"])) { $userrage = ($_GET["rage"] == 0 ? -1 : $_GET["rage"] + 0); } elseif (isset($_GET["anidb"])) { diff --git a/www/pages/sendtonzbget.php b/www/pages/sendtonzbget.php index 82d528930..c38460ff6 100644 --- a/www/pages/sendtonzbget.php +++ b/www/pages/sendtonzbget.php @@ -1,7 +1,7 @@ isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); if (empty($_GET["id"])) diff --git a/www/pages/sendtoqueue.php b/www/pages/sendtoqueue.php index 11db9998c..9bc4038dc 100644 --- a/www/pages/sendtoqueue.php +++ b/www/pages/sendtoqueue.php @@ -1,6 +1,6 @@ isLoggedIn()) { +if (!$page->users->isLoggedIn()) { $page->show403(); } @@ -8,7 +8,7 @@ if (empty($_GET["id"])) { $page->show404(); } -$user = $users->getById($users->currentUserId()); +$user = $page->users->getById($page->users->currentUserId()); if ($user['queuetype'] != 2) { $sab = new SABnzbd($page); diff --git a/www/pages/sendtosab.php b/www/pages/sendtosab.php index e810f3930..2d85d0432 100644 --- a/www/pages/sendtosab.php +++ b/www/pages/sendtosab.php @@ -1,6 +1,6 @@ isLoggedIn()) +if (!$page->users->isLoggedIn()) $page->show403(); if (empty($_GET["id"])) diff --git a/www/pages/series.php b/www/pages/series.php index 351070bae..35f57b4f8 100644 --- a/www/pages/series.php +++ b/www/pages/series.php @@ -1,6 +1,6 @@ isLoggedIn()) { +if (!$page->users->isLoggedIn()) { $page->show403(); } @@ -26,7 +26,7 @@ if (isset($_GET["id"]) && ctype_digit($_GET['id'])) { } elseif (!$rel) { $page->smarty->assign("nodata", "No releases for this series."); } else { - $myshows = $us->getShow($users->currentUserId(), $rage[0]['rageid']); + $myshows = $us->getShow($page->users->currentUserId(), $rage[0]['rageid']); // Sort releases by season, episode, date posted. $season = $episode = $posted = array(); @@ -94,7 +94,7 @@ if (isset($_GET["id"]) && ctype_digit($_GET['id'])) { $letter = ""; } - $masterserieslist = $tvrage->getSeriesList($users->currentUserId(), $letter, $ragename); + $masterserieslist = $tvrage->getSeriesList($page->users->currentUserId(), $letter, $ragename); $page->title = 'Series List'; $page->meta_title = "View Series List"; diff --git a/www/pages/upcoming.php b/www/pages/upcoming.php index a5b8e8fd8..fabeea4b0 100644 --- a/www/pages/upcoming.php +++ b/www/pages/upcoming.php @@ -1,6 +1,6 @@ isLoggedIn()) { +if (!$page->users->isLoggedIn()) { $page->show403(); } @@ -9,7 +9,7 @@ $m = new Film(); if (!isset($_GET["id"])) { $_GET["id"] = 1; } -$user = $users->getById($users->currentUserId()); +$user = $page->users->getById($page->users->currentUserId()); $cpapi = $user['cp_api']; $cpurl = $user['cp_url']; $page->smarty->assign('cpapi', $cpapi); diff --git a/www/pages/xxx.php b/www/pages/xxx.php index e21d2d066..db171324f 100644 --- a/www/pages/xxx.php +++ b/www/pages/xxx.php @@ -1,6 +1,6 @@ isLoggedIn()) { +if (!$page->users->isLoggedIn()) { $page->show403(); }