Update index.php and other pages, remove api only site check

This commit is contained in:
DariusIII
2017-12-26 00:41:22 +01:00
parent 0379432636
commit 8cef9832e2
4 changed files with 19 additions and 48 deletions
-8
View File
@@ -2,8 +2,6 @@
require_once __DIR__.DIRECTORY_SEPARATOR.'smarty.php';
use App\Models\User;
use App\Models\Settings;
$page = new Page;
@@ -67,12 +65,6 @@ switch ($page->page) {
case 'upcoming':
case 'xxx':
case 'xxxmodal':
// Don't show these pages if it's an API-only site.
if (! User::isLoggedIn() && (int) Settings::settingValue('..registerstatus') === Settings::REGISTER_STATUS_API_ONLY) {
header('Location: '.Settings::settingValue('site.main.code'));
break;
}
// no break
case 'api':
case 'failed':
case 'getnzb':
+5 -16
View File
@@ -1,7 +1,6 @@
<?php
use App\Models\User;
use App\Models\Settings;
use nntmux\DnzbFailures;
// Page is accessible only by the rss token, or logged in users.
@@ -9,22 +8,12 @@ if (User::isLoggedIn()) {
$uid = User::currentUserId();
$rssToken = $page->userdata['rsstoken'];
} else {
if ((int) Settings::settingValue('..registerstatus') === Settings::REGISTER_STATUS_API_ONLY) {
if (! isset($_GET['rsstoken'])) {
header('X-DNZB-RCode: 400');
header('X-DNZB-RText: Bad request, please supply all parameters!');
$page->show403();
} else {
$res = User::getByRssToken($_GET['rsstoken']);
}
if (! isset($_GET['userid']) || ! isset($_GET['rsstoken'])) {
header('X-DNZB-RCode: 400');
header('X-DNZB-RText: Bad request, please supply all parameters!');
$page->show403();
} else {
if (! isset($_GET['userid']) || ! isset($_GET['rsstoken'])) {
header('X-DNZB-RCode: 400');
header('X-DNZB-RText: Bad request, please supply all parameters!');
$page->show403();
} else {
$res = User::getByIdAndRssToken($_GET['userid'], $_GET['rsstoken']);
}
$res = User::getByIdAndRssToken($_GET['userid'], $_GET['rsstoken']);
}
if (! isset($res)) {
header('X-DNZB-RCode: 401');
+9 -11
View File
@@ -1,5 +1,6 @@
<?php
use App\Models\User;
use nntmux\NZB;
use nntmux\Releases;
use App\Models\Settings;
@@ -18,18 +19,15 @@ if (User::isLoggedIn()) {
Utility::showApiError(101);
}
} else {
if ((int) Settings::settingValue('..registerstatus') === Settings::REGISTER_STATUS_API_ONLY) {
$res = User::getById(0);
} else {
if (! isset($_GET['i']) || ! isset($_GET['r'])) {
Utility::showApiError(200);
}
$res = User::getByIdAndRssToken($_GET['i'], $_GET['r']);
if (! $res) {
Utility::showApiError(100);
}
if (! isset($_GET['i']) || ! isset($_GET['r'])) {
Utility::showApiError(200);
}
$res = User::getByIdAndRssToken($_GET['i'], $_GET['r']);
if (! $res) {
Utility::showApiError(100);
}
$uid = $res['id'];
$rssToken = $res['rsstoken'];
$maxDownloads = $res->role->downloadrequests;
+5 -13
View File
@@ -15,11 +15,7 @@ $offset = 0;
if (! isset($_GET['t']) && ! isset($_GET['show']) && ! isset($_GET['anidb'])) {
// User has to either be logged in, or using rsskey.
if (! User::isLoggedIn()) {
if ((int) Settings::settingValue('..registerstatus') !== Settings::REGISTER_STATUS_API_ONLY) {
Utility::showApiError(100);
} else {
header('Location: '.Settings::settingValue('site.main.code'));
}
header('Location: '.Settings::settingValue('site.main.code'));
}
$page->title = 'Rss Info';
@@ -59,16 +55,12 @@ if (! isset($_GET['t']) && ! isset($_GET['show']) && ! isset($_GET['anidb'])) {
$rssToken = $page->userdata['rsstoken'];
$maxRequests = $page->userdata->role->apirequests;
} else {
if ((int) Settings::settingValue('..registerstatus') === Settings::REGISTER_STATUS_API_ONLY) {
$res = User::getById(0);
} else {
if (! isset($_GET['i']) || ! isset($_GET['r'])) {
Utility::showApiError(100, 'Both the User ID and API key are required for viewing the RSS!');
}
$res = User::getByIdAndRssToken($_GET['i'], $_GET['r']);
if (! isset($_GET['i']) || ! isset($_GET['r'])) {
Utility::showApiError(100, 'Both the User ID and API key are required for viewing the RSS!');
}
$res = User::getByIdAndRssToken($_GET['i'], $_GET['r']);
if (! $res) {
Utility::showApiError(100);
}