mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-28 17:01:16 +00:00
Start migrating to laravel's routing and authentification
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Models\User;
|
||||
use GuzzleHttp\Client;
|
||||
use App\Models\Settings;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
/**
|
||||
* Class SABnzbd.
|
||||
@@ -91,15 +92,15 @@ class SABnzbd
|
||||
private $client;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
* SABnzbd constructor.
|
||||
*
|
||||
* @param \BasePage $page
|
||||
* @param $page
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct(&$page)
|
||||
{
|
||||
$this->uid = User::currentUserId();
|
||||
$this->uid = Auth::id();
|
||||
$this->rsstoken = $page->userdata['rsstoken'];
|
||||
$this->serverurl = $page->serverurl;
|
||||
$this->client = new Client(['verify' => false]);
|
||||
|
||||
@@ -9,6 +9,7 @@ use Blacklight\db\DB;
|
||||
use Blacklight\SABnzbd;
|
||||
use App\Models\Settings;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Ytake\LaravelSmarty\Smarty;
|
||||
use App\Models\RoleExcludedCategory;
|
||||
|
||||
@@ -102,25 +103,6 @@ class BasePage
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if (session_id() === '') {
|
||||
session_start();
|
||||
|
||||
$lifetime = Carbon::now()->addMinutes(config('session.lifetime'))->timestamp;
|
||||
$domain = config('session.domain');
|
||||
$http_only = config('session.http_only');
|
||||
$secure = request()->secure();
|
||||
|
||||
if (empty($_SESSION['_token'])) {
|
||||
$_SESSION['_token'] = sodium_bin2hex(random_bytes(32));
|
||||
}
|
||||
setcookie('XSRF-TOKEN', $_SESSION['_token'], $lifetime, '/', $domain, $secure, false);
|
||||
setcookie(config('session.cookie'), $_SESSION['_token'], $lifetime, '/', $domain, $secure, $http_only);
|
||||
}
|
||||
|
||||
if (config('nntmux.flood_check')) {
|
||||
$this->floodCheck();
|
||||
}
|
||||
|
||||
// Buffer settings/DB connection.
|
||||
$this->settings = new Settings();
|
||||
$this->pdo = new DB();
|
||||
@@ -145,11 +127,9 @@ class BasePage
|
||||
$this->smarty->assign('serverroot', $this->serverurl);
|
||||
}
|
||||
|
||||
$this->smarty->assign('csrf_token', $_SESSION['_token']);
|
||||
|
||||
$this->page = request()->input('page') ?? 'content';
|
||||
|
||||
if (User::isLoggedIn()) {
|
||||
if (Auth::check()) {
|
||||
$this->setUserPreferences();
|
||||
} else {
|
||||
$this->theme = $this->getSettingValue('site.main.style');
|
||||
@@ -167,40 +147,6 @@ class BasePage
|
||||
$this->smarty->assign('page', $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the user is flooding.
|
||||
*/
|
||||
public function floodCheck(): void
|
||||
{
|
||||
$waitTime = (config('nntmux.flood_wait_time') < 1 ? 5 : config('nntmux.flood_wait_time'));
|
||||
// Check if this is not from CLI.
|
||||
if (empty($argc)) {
|
||||
// If flood wait set, the user must wait x seconds until they can access a page.
|
||||
if (isset($_SESSION['flood_wait_until']) && $_SESSION['flood_wait_until'] > microtime(true)) {
|
||||
$this->showFloodWarning($waitTime);
|
||||
} else {
|
||||
// If user not an admin, they are allowed three requests in FLOOD_THREE_REQUESTS_WITHIN_X_SECONDS seconds.
|
||||
if (! isset($_SESSION['flood_check_hits'])) {
|
||||
$_SESSION['flood_check_hits'] = 1;
|
||||
$_SESSION['flood_check_time'] = microtime(true);
|
||||
} else {
|
||||
if ($_SESSION['flood_check_hits'] >= (config('nntmux.flood_max_requests_per_second') < 1 ? 5 : config('nntmux.flood_max_requests_per_second'))) {
|
||||
if ($_SESSION['flood_check_time'] + 1 > microtime(true)) {
|
||||
$_SESSION['flood_wait_until'] = microtime(true) + $waitTime;
|
||||
unset($_SESSION['flood_check_hits']);
|
||||
$this->showFloodWarning($waitTime);
|
||||
} else {
|
||||
$_SESSION['flood_check_hits'] = 1;
|
||||
$_SESSION['flood_check_time'] = microtime(true);
|
||||
}
|
||||
} else {
|
||||
$_SESSION['flood_check_hits']++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Done in html here to reduce any smarty processing burden if a large flood is underway.
|
||||
*
|
||||
@@ -208,7 +154,7 @@ class BasePage
|
||||
*/
|
||||
public function showFloodWarning($seconds = 5): void
|
||||
{
|
||||
header('Retry-After: '.$seconds);
|
||||
request()->header('Retry-After: '.$seconds);
|
||||
$this->show503();
|
||||
}
|
||||
|
||||
@@ -245,7 +191,7 @@ class BasePage
|
||||
*/
|
||||
public function show404(): void
|
||||
{
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
request()->header('HTTP/1.1 404 Not Found');
|
||||
die(view('errors.404'));
|
||||
}
|
||||
|
||||
@@ -256,7 +202,7 @@ class BasePage
|
||||
*/
|
||||
public function show403($from_admin = false): void
|
||||
{
|
||||
header(
|
||||
request()->header(
|
||||
'Location: '.
|
||||
($from_admin ? str_replace('/admin', '', WWW_TOP) : WWW_TOP).
|
||||
'/login?redirect='.
|
||||
@@ -270,7 +216,7 @@ class BasePage
|
||||
*/
|
||||
public function show503(): void
|
||||
{
|
||||
header('HTTP/1.1 503 Service Temporarily Unavailable');
|
||||
request()->header('HTTP/1.1 503 Service Temporarily Unavailable');
|
||||
die(view('errors.503'));
|
||||
}
|
||||
|
||||
@@ -287,7 +233,7 @@ class BasePage
|
||||
*/
|
||||
public function showMaintenance(): void
|
||||
{
|
||||
header('HTTP/1.1 503 Service Temporarily Unavailable');
|
||||
request()->header('HTTP/1.1 503 Service Temporarily Unavailable');
|
||||
die(view('errors.maintenance'));
|
||||
}
|
||||
|
||||
@@ -296,7 +242,7 @@ class BasePage
|
||||
*/
|
||||
public function showTokenError(): void
|
||||
{
|
||||
header('HTTP/1.1 419 Token Mismatch Error');
|
||||
request()->header('HTTP/1.1 419 Token Mismatch Error');
|
||||
die(view('errors.tokenError'));
|
||||
}
|
||||
|
||||
@@ -305,9 +251,9 @@ class BasePage
|
||||
*/
|
||||
public function show429($retry = ''): void
|
||||
{
|
||||
header('HTTP/1.1 429 Too Many Requests');
|
||||
request()->header('HTTP/1.1 429 Too Many Requests');
|
||||
if ($retry !== '') {
|
||||
header('Retry-After: '.$retry);
|
||||
request()->header('Retry-After: '.$retry);
|
||||
}
|
||||
|
||||
echo '
|
||||
@@ -336,8 +282,8 @@ class BasePage
|
||||
*/
|
||||
protected function setUserPreferences(): void
|
||||
{
|
||||
$this->userdata = User::find(User::currentUserId());
|
||||
$this->userdata['categoryexclusions'] = User::getCategoryExclusion(User::currentUserId());
|
||||
$this->userdata = User::find(Auth::id());
|
||||
$this->userdata['categoryexclusions'] = User::getCategoryExclusion(Auth::id());
|
||||
$this->userdata['rolecategoryexclusions'] = RoleExcludedCategory::getRoleCategoryExclusion($this->userdata['user_roles_id']);
|
||||
|
||||
// Change the theme to user's selected theme if they selected one, else use the admin one.
|
||||
|
||||
@@ -84,7 +84,7 @@ abstract class Capabilities
|
||||
$response = (new XML_Response($options))->returnXML();
|
||||
|
||||
if ($xml) {
|
||||
header('Content-type: text/xml');
|
||||
request()->header('Content-type: text/xml');
|
||||
} else {
|
||||
// JSON encode the XMLWriter response
|
||||
$response = json_encode(
|
||||
@@ -102,12 +102,12 @@ abstract class Capabilities
|
||||
['rss']['channel'],
|
||||
JSON_PRETTY_PRINT + JSON_UNESCAPED_SLASHES
|
||||
);
|
||||
header('Content-type: application/json');
|
||||
request()->header('Content-type: application/json');
|
||||
}
|
||||
if ($response === false) {
|
||||
Utility::showApiError(201);
|
||||
} else {
|
||||
header('Content-Length: '.\strlen($response));
|
||||
request()->header('Content-Length: '.\strlen($response));
|
||||
echo $response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -948,10 +948,10 @@ class Utility
|
||||
$response =
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".
|
||||
'<error code="'.$errorCode.'" description="'.$errorText."\"/>\n";
|
||||
header('Content-type: text/xml');
|
||||
header('Content-Length: '.\strlen($response));
|
||||
header('X-NNTmux: API ERROR ['.$errorCode.'] '.$errorText);
|
||||
header($errorHeader);
|
||||
request()->header('Content-type: text/xml');
|
||||
request()->header('Content-Length: '.\strlen($response));
|
||||
request()->header('X-NNTmux: API ERROR ['.$errorCode.'] '.$errorText);
|
||||
request()->header($errorHeader);
|
||||
|
||||
exit($response);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
@@ -36,4 +38,33 @@ class LoginController extends Controller
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'username' => 'required',
|
||||
'password' => 'required',
|
||||
]);
|
||||
|
||||
$rememberMe = $request->has('rememberme') && $request->input('rememberme') === 'on';
|
||||
|
||||
$login_type = filter_var($request->input('username'), FILTER_VALIDATE_EMAIL )
|
||||
? 'email'
|
||||
: 'username';
|
||||
|
||||
$request->merge([
|
||||
$login_type => $request->input('username')
|
||||
]);
|
||||
|
||||
if (Auth::attempt($request->only($login_type, 'password'), $rememberMe)) {
|
||||
return redirect()->intended($this->redirectPath());
|
||||
}
|
||||
|
||||
return redirect()->back()
|
||||
->withInput()
|
||||
->withErrors([
|
||||
'login' => 'These credentials do not match our records.',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
|
||||
require __DIR__.DIRECTORY_SEPARATOR.'app.php';
|
||||
require_once 'constants.php';
|
||||
require_once __DIR__.DIRECTORY_SEPARATOR.'yenc.php';
|
||||
|
||||
use Dotenv\Dotenv;
|
||||
use Blacklight\utility\Utility;
|
||||
@@ -14,6 +15,5 @@ if (! defined('HAS_WHICH')) {
|
||||
define('HAS_WHICH', Utility::hasWhich() ? true : false);
|
||||
}
|
||||
|
||||
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
$app->handle(\Illuminate\Http\Request::capture());
|
||||
require_once __DIR__.DIRECTORY_SEPARATOR.'yenc.php';
|
||||
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
|
||||
|
||||
@@ -13,9 +13,7 @@ $page = new AdminPage;
|
||||
$pdo = new DB();
|
||||
$nzb = new NZB();
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
if (request()->has('id')) {
|
||||
$rel = Release::getByGuid(request()->input('id'));
|
||||
|
||||
@@ -4,6 +4,14 @@ use Blacklight\http\Page;
|
||||
|
||||
require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'resources/views/themes/smarty.php';
|
||||
|
||||
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
|
||||
|
||||
$response = $kernel->handle(
|
||||
$request = Illuminate\Http\Request::capture()
|
||||
);
|
||||
$response->send();
|
||||
$kernel->terminate($request, $response);
|
||||
|
||||
$page = new Page;
|
||||
|
||||
if ($app->isDownForMaintenance()) {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Blacklight\ReleaseExtra;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
if (! request()->has('id')) {
|
||||
$page->show404();
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Predb;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
if (! request()->has('id')) {
|
||||
$page->show404();
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
if (request()->has('action') && request()->has('emailto') && (int) request()->input('action') === 1) {
|
||||
$emailto = request()->input('emalto');
|
||||
$ret = User::sendInvite($page->serverurl, User::currentUserId(), $emailto);
|
||||
$ret = User::sendInvite($page->serverurl, Auth::id(), $emailto);
|
||||
if (! $ret) {
|
||||
echo 'Invite not sent.';
|
||||
} else {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\ReleaseFile;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,13 @@
|
||||
|
||||
use App\Models\Release;
|
||||
use App\Models\Category;
|
||||
use Blacklight\http\AdminPage;
|
||||
use Blacklight\Releases;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
$page = new AdminPage();
|
||||
$releases = new Releases(['Settings' => $page->settings]);
|
||||
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
use App\Models\UserRequest;
|
||||
use App\Models\UserDownload;
|
||||
use Blacklight\http\AdminPage;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
$page = new AdminPage();
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Video;
|
||||
use App\Models\Release;
|
||||
use Blacklight\Releases;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
@@ -13,7 +12,6 @@ if (! request()->has('id')) {
|
||||
$page->show404();
|
||||
}
|
||||
|
||||
$r = new Releases();
|
||||
$rel = Release::getByGuid(request()->input('id'));
|
||||
|
||||
if (! $rel) {
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Blacklight\AniDB;
|
||||
use App\Models\Category;
|
||||
use Blacklight\Releases;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
$releases = new Releases(['Settings' => $page->settings]);
|
||||
$aniDB = new AniDB(['Settings' => $page->settings]);
|
||||
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<?php
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
$page->title = 'Api';
|
||||
$page->meta_title = 'Api Help Topics';
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Blacklight\Books;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
$b = new Books;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
$b = new Books;
|
||||
|
||||
if (request()->has('id') && ctype_digit(request()->input('id'))) {
|
||||
$book = $b->getBookInfo(request()->input('id'));
|
||||
if (! $book) {
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Blacklight\Books;
|
||||
use App\Models\Category;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
$book = new Books(['Settings' => $page->settings]);
|
||||
|
||||
$boocats = Category::getChildren(Category::BOOKS_ROOT);
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Category;
|
||||
use Blacklight\Releases;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
$releases = new Releases(['Settings' => $page->settings]);
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
$releases = new Releases(['Settings' => $page->settings]);
|
||||
|
||||
$category = -1;
|
||||
if (request()->has('t')) {
|
||||
$category = request()->input('t');
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Group;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
$grouplist = Group::getGroupsRange(false, false, '', true);
|
||||
$page->smarty->assign('results', $grouplist);
|
||||
|
||||
|
||||
@@ -4,17 +4,18 @@ use App\Models\User;
|
||||
use App\Models\UserRole;
|
||||
use Blacklight\http\Page;
|
||||
use Blacklight\libraries\Geary;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
$page = new Page();
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
$page = new Page();
|
||||
|
||||
$gateway_id = env('MYCELIUM_GATEWAY_ID');
|
||||
$gateway_secret = env('MYCELIUM_GATEWAY_SECRET');
|
||||
|
||||
$userId = User::currentUserId();
|
||||
$userId = Auth::id();
|
||||
$user = User::find($userId);
|
||||
$action = request()->input('action') ?? 'view';
|
||||
$donation = UserRole::query()->where('donation', '>', 0)->get(['id', 'name', 'donation', 'addyears']);
|
||||
@@ -36,13 +37,13 @@ switch ($action) {
|
||||
if ($order->payment_id) {
|
||||
// Redirect to a payment gateway
|
||||
$url = 'https://gateway.gear.mycelium.com/pay/'.$order->payment_id;
|
||||
header('Location: '.$url);
|
||||
request()->header('Location: '.$url);
|
||||
die();
|
||||
}
|
||||
break;
|
||||
case 'view':
|
||||
default:
|
||||
$userId = User::currentUserId();
|
||||
$userId = Auth::id();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Release;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
use Blacklight\Releases;
|
||||
use App\Models\UsersRelease;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
if (request()->has('add')) {
|
||||
$releases = new Releases(['Settings' => $page->settings]);
|
||||
@@ -20,7 +20,7 @@ if (request()->has('add')) {
|
||||
}
|
||||
|
||||
foreach ($data as $d) {
|
||||
UsersRelease::addCart(User::currentUserId(), $d['id']);
|
||||
UsersRelease::addCart(Auth::id(), $d['id']);
|
||||
}
|
||||
} elseif (request()->has('delete')) {
|
||||
if (request()->has('delete') && ! empty(request()->input('delete'))) {
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Blacklight\Genres;
|
||||
use Blacklight\Console;
|
||||
use App\Models\Category;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
$console = new Console(['Settings' => $page->settings]);
|
||||
$gen = new Genres(['Settings' => $page->settings]);
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Blacklight\Console;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
if (request()->has('id') && ctype_digit(request()->input('id'))) {
|
||||
$console = new Console(['Settings' => $page->settings]);
|
||||
$con = $console->getConsoleInfo(request()->input('id'));
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
|
||||
use App\Models\User;
|
||||
use Blacklight\Contents;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
$contents = new Contents();
|
||||
|
||||
$role = 0;
|
||||
if (! empty($page->userdata) && User::isLoggedIn()) {
|
||||
if (! empty($page->userdata) && Auth::check()) {
|
||||
$role = $page->userdata['role'];
|
||||
}
|
||||
|
||||
|
||||
@@ -19,16 +19,18 @@ use App\Models\ReleaseFile;
|
||||
use App\Models\ReleaseRegex;
|
||||
use Blacklight\ReleaseExtra;
|
||||
use App\Models\ReleaseComment;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
if (request()->has('id')) {
|
||||
$releases = new Releases(['Settings' => $page->settings]);
|
||||
$re = new ReleaseExtra;
|
||||
$data = Release::getByGuid(request()->input('id'));
|
||||
$user = User::find(User::currentUserId());
|
||||
$user = User::find(Auth::id());
|
||||
$cpapi = $user['cp_api'];
|
||||
$cpurl = $user['cp_url'];
|
||||
$releaseRegex = ReleaseRegex::query()->where('releases_id', '=', $data['id'])->first();
|
||||
@@ -38,7 +40,7 @@ if (request()->has('id')) {
|
||||
}
|
||||
|
||||
if ($page->isPostBack()) {
|
||||
ReleaseComment::addComment($data['id'], $data['gid'], request()->input('txtAddComment'), User::currentUserId(), request()->id());
|
||||
ReleaseComment::addComment($data['id'], $data['gid'], request()->input('txtAddComment'), Auth::id(), request()->id());
|
||||
}
|
||||
|
||||
$nfo = ReleaseNfo::getReleaseNfo($data['id']);
|
||||
|
||||
+10
-9
@@ -2,22 +2,23 @@
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Release;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
// Page is accessible only by the rss token, or logged in users.
|
||||
if (User::isLoggedIn()) {
|
||||
$uid = User::currentUserId();
|
||||
if (Auth::check()) {
|
||||
$uid = Auth::id();
|
||||
$rssToken = $page->userdata['rsstoken'];
|
||||
} else {
|
||||
if (! request()->has('userid') || ! request()->has('rsstoken')) {
|
||||
header('X-DNZB-RCode: 400');
|
||||
header('X-DNZB-RText: Bad request, please supply all parameters!');
|
||||
request()->header('X-DNZB-RCode: 400');
|
||||
request()->header('X-DNZB-RText: Bad request, please supply all parameters!');
|
||||
$page->show403();
|
||||
} else {
|
||||
$res = User::getByIdAndRssToken(request()->input('userid'), request()->input('rsstoken'));
|
||||
}
|
||||
if (! isset($res)) {
|
||||
header('X-DNZB-RCode: 401');
|
||||
header('X-DNZB-RText: Unauthorised, wrong user ID or rss key!');
|
||||
request()->header('X-DNZB-RCode: 401');
|
||||
request()->header('X-DNZB-RText: Unauthorised, wrong user ID or rss key!');
|
||||
$page->show403();
|
||||
} else {
|
||||
$uid = $res['id'];
|
||||
@@ -28,10 +29,10 @@ if (User::isLoggedIn()) {
|
||||
if (isset($uid, $rssToken) && is_numeric($uid) && request()->has('guid')) {
|
||||
$alt = Release::getAlternate(request()->input('guid'), $uid);
|
||||
if ($alt === null) {
|
||||
header('X-DNZB-RCode: 404');
|
||||
header('X-DNZB-RText: No NZB found for alternate match.');
|
||||
request()->header('X-DNZB-RCode: 404');
|
||||
request()->header('X-DNZB-RText: No NZB found for alternate match.');
|
||||
$page->show404();
|
||||
} else {
|
||||
header('Location: '.$page->serverurl.'getnzb/'.$alt['guid'].'&i='.$uid.'&r='.$rssToken);
|
||||
request()->header('Location: '.$page->serverurl.'getnzb/'.$alt['guid'].'&i='.$uid.'&r='.$rssToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,7 @@ use App\Models\Release;
|
||||
$pdo = new DB();
|
||||
$nzb = new NZB();
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
if (request()->has('id')) {
|
||||
$rel = Release::getByGuid(request()->input('id'));
|
||||
|
||||
@@ -4,10 +4,11 @@ use App\Models\User;
|
||||
use Blacklight\Captcha;
|
||||
use App\Mail\PasswordReset;
|
||||
use App\Mail\ForgottenPassword;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
if (User::isLoggedIn()) {
|
||||
header('Location: '.WWW_TOP.'/');
|
||||
if (Auth::check()) {
|
||||
redirect('/');
|
||||
}
|
||||
|
||||
$action = request()->input('action') ?? 'view';
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Settings;
|
||||
use App\Models\Forumpost;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
if ($page->isPostBack() && request()->has('addMessage') && request()->has('addSubject')) {
|
||||
Forumpost::add(0, User::currentUserId(), request()->input('addSubject'), request()->input('addMessage'));
|
||||
header('Location:'.WWW_TOP.'/forum');
|
||||
die();
|
||||
Forumpost::add(0, Auth::id(), request()->input('addSubject'), request()->input('addMessage'));
|
||||
request()->header('/forum');
|
||||
}
|
||||
|
||||
$lock = $unlock = null;
|
||||
@@ -26,13 +25,13 @@ if (request()->has('unlock')) {
|
||||
|
||||
if ($lock !== null) {
|
||||
Forumpost::lockUnlockTopic($lock, 1);
|
||||
header('Location:'.WWW_TOP.'/forum');
|
||||
request()->header('/forum');
|
||||
die();
|
||||
}
|
||||
|
||||
if ($unlock !== null) {
|
||||
Forumpost::lockUnlockTopic($unlock, 0);
|
||||
header('Location:'.WWW_TOP.'/forum');
|
||||
request()->header('/forum');
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,22 +3,24 @@
|
||||
use App\Models\User;
|
||||
use App\Models\Settings;
|
||||
use App\Models\Forumpost;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
$id = request()->input('id') + 0;
|
||||
|
||||
if (! empty(request()->input('addMessage')) && $page->isPostBack()) {
|
||||
Forumpost::add($id, User::currentUserId(), '', request()->input('addMessage'));
|
||||
header('Location:'.WWW_TOP.'/forumpost/'.$id.'#last');
|
||||
Forumpost::add($id, Auth::id(), '', request()->input('addMessage'));
|
||||
request()->header('/forumpost/'.$id.'#last');
|
||||
die();
|
||||
}
|
||||
|
||||
$results = Forumpost::getPosts($id);
|
||||
if (count($results) === 0) {
|
||||
header('Location:'.WWW_TOP.'/forum');
|
||||
request()->header('/forum');
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,13 @@ use App\Models\User;
|
||||
use Blacklight\Games;
|
||||
use Blacklight\Genres;
|
||||
use App\Models\Category;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
$games = new Games(['Settings' => $page->settings]);
|
||||
$gen = new Genres(['Settings' => $page->settings]);
|
||||
|
||||
@@ -33,7 +35,7 @@ $ordering = $games->getGamesOrdering();
|
||||
|
||||
$orderby = request()->has('ob') && in_array(request()->input('ob'), $ordering, false) ? request()->input('ob') : '';
|
||||
|
||||
$results = $games2 = [];
|
||||
$games2 = [];
|
||||
$results = $games->getGamesRange($catarray, $offset, config('nntmux.items_per_cover_page'), $orderby, '', $page->userdata['categoryexclusions']);
|
||||
$maxwords = 50;
|
||||
foreach ($results as $result) {
|
||||
|
||||
@@ -8,12 +8,13 @@ use Blacklight\Releases;
|
||||
use App\Models\UserDownload;
|
||||
use App\Models\UsersRelease;
|
||||
use Blacklight\utility\Utility;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
$uid = 0;
|
||||
|
||||
// Page is accessible only by the rss token, or logged in users.
|
||||
if (User::isLoggedIn()) {
|
||||
$uid = User::currentUserId();
|
||||
if (Auth::check()) {
|
||||
$uid = Auth::id();
|
||||
$maxDownloads = $page->userdata->role->downloadrequests;
|
||||
$rssToken = $page->userdata['rsstoken'];
|
||||
if (User::isDisabled($page->userdata['username'])) {
|
||||
|
||||
@@ -1,55 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Blacklight\Captcha;
|
||||
use App\Models\Settings;
|
||||
use Blacklight\utility\Utility;
|
||||
|
||||
$page->smarty->assign(['error' => '', 'username' => '', 'rememberme' => '']);
|
||||
|
||||
$captcha = new Captcha($page);
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! request()->has('username') && ! request()->has('password')) {
|
||||
$page->smarty->assign('error', 'Please enter your username and password.');
|
||||
} elseif ($captcha->getError() === false) {
|
||||
$username = htmlspecialchars(request()->input('username'), ENT_QUOTES | ENT_HTML5);
|
||||
$page->smarty->assign('username', $username);
|
||||
if (Utility::checkCSRFToken() === true) {
|
||||
$res = User::getByUsername($username);
|
||||
if ($res === null) {
|
||||
$res = User::getByEmail($username);
|
||||
}
|
||||
|
||||
if ($res !== null) {
|
||||
$dis = User::isDisabled($username);
|
||||
if ($dis) {
|
||||
$page->smarty->assign('error', 'Your account has been disabled.');
|
||||
} elseif (User::checkPassword(request()->input('password'), $res['password'], $res['id'])) {
|
||||
$rememberMe = (request()->has('rememberme') && request()->input('rememberme') === 'on');
|
||||
User::login($res['id'], request()->ip(), $rememberMe);
|
||||
|
||||
if (request()->has('redirect') && request()->input('redirect') !== '') {
|
||||
header('Location: '.request()->input('redirect'));
|
||||
} else {
|
||||
header('Location: '.WWW_TOP.Settings::settingValue('site.main.home_link'));
|
||||
}
|
||||
die();
|
||||
} else {
|
||||
$page->smarty->assign('error', 'Incorrect username/email or password.');
|
||||
}
|
||||
} else {
|
||||
$page->smarty->assign('error', 'Incorrect username/email or password.');
|
||||
}
|
||||
} else {
|
||||
$page->showTokenError();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
header('Location: '.WWW_TOP.Settings::settingValue('site.main.home_link'));
|
||||
}
|
||||
|
||||
$page->smarty->assign('redirect', request()->input('redirect') ?? '');
|
||||
$page->meta_title = 'Login';
|
||||
$page->meta_keywords = 'Login';
|
||||
$page->meta_description = 'Login';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
User::logout();
|
||||
Auth::logout();
|
||||
|
||||
header('Location: '.WWW_TOP.'/login');
|
||||
redirect('/login');
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Blacklight\Movie;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
if (request()->has('modal') && request()->has('id') && ctype_digit(request()->input('id'))) {
|
||||
$movie = new Movie(['Settings' => $page->settings]);
|
||||
$mov = $movie->getMovieInfo(request()->input('id'));
|
||||
|
||||
@@ -4,11 +4,13 @@ use App\Models\User;
|
||||
use Blacklight\Movie;
|
||||
use App\Models\Category;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
$movie = new Movie(['Settings' => $page->settings]);
|
||||
|
||||
$moviecats = Category::getChildren(Category::MOVIE_ROOT);
|
||||
@@ -22,14 +24,14 @@ if (request()->has('t') && array_key_exists(request()->input('t'), $mtmp)) {
|
||||
$category = request()->input('t') + 0;
|
||||
}
|
||||
|
||||
$user = User::find(User::currentUserId());
|
||||
$user = User::find(Auth::id());
|
||||
$cpapi = $user['cp_api'];
|
||||
$cpurl = $user['cp_url'];
|
||||
$page->smarty->assign('cpapi', $cpapi);
|
||||
$page->smarty->assign('cpurl', $cpurl);
|
||||
|
||||
$catarray = [];
|
||||
if ($category != -1) {
|
||||
if ((int) $category !== -1) {
|
||||
$catarray[] = $category;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
use App\Models\User;
|
||||
use Blacklight\Movie;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
$movie = new Movie;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
$movie = new Movie;
|
||||
|
||||
if (request()->has('id') && ctype_digit(request()->input('id'))) {
|
||||
$mov = $movie->getMovieInfo(request()->input('id'));
|
||||
|
||||
|
||||
@@ -4,11 +4,13 @@ use App\Models\User;
|
||||
use Blacklight\Music;
|
||||
use Blacklight\Genres;
|
||||
use App\Models\Category;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
$music = new Music(['Settings' => $page->settings]);
|
||||
$gen = new Genres(['Settings' => $page->settings]);
|
||||
|
||||
@@ -32,7 +34,7 @@ $offset = (request()->has('offset') && ctype_digit(request()->input('offset')))
|
||||
$ordering = $music->getMusicOrdering();
|
||||
$orderby = request()->has('ob') && in_array(request()->input('ob'), $ordering) ? request()->input('ob') : '';
|
||||
|
||||
$results = $musics = [];
|
||||
$musics = [];
|
||||
$results = $music->getMusicRange($catarray, $offset, config('nntmux.items_per_cover_page'), $orderby, $page->userdata['categoryexclusions']);
|
||||
|
||||
$artist = (request()->has('artist') && ! empty(request()->input('artist'))) ? stripslashes(request()->input('artist')) : '';
|
||||
@@ -56,15 +58,15 @@ $genre = (request()->has('genre') && array_key_exists(request()->input('genre'),
|
||||
$page->smarty->assign('genres', $genres);
|
||||
$page->smarty->assign('genre', $genre);
|
||||
|
||||
$years = range(1950, (date('Y') + 1));
|
||||
$years = range(1950, date('Y') + 1);
|
||||
rsort($years);
|
||||
$year = (request()->has('year') && in_array(request()->input('year'), $years)) ? request()->input('year') : '';
|
||||
$year = (request()->has('year') && in_array(request()->input('year'), $years, false)) ? request()->input('year') : '';
|
||||
$page->smarty->assign('years', $years);
|
||||
$page->smarty->assign('year', $year);
|
||||
|
||||
$browseby_link = '&title='.$title.'&artist='.$artist.'&genre='.$genre.'&year='.$year;
|
||||
|
||||
$page->smarty->assign('pagertotalitems', isset($results[0]['_totalcount']) ? $results[0]['_totalcount'] : 0);
|
||||
$page->smarty->assign('pagertotalitems', $results[0]['_totalcount'] ?? 0);
|
||||
$page->smarty->assign('pageroffset', $offset);
|
||||
$page->smarty->assign('pageritemsperpage', config('nntmux.items_per_cover_page'));
|
||||
$page->smarty->assign('pagerquerybase', WWW_TOP.'/music?t='.$category.$browseby_link.'&ob='.$orderby.'&offset=');
|
||||
|
||||
@@ -5,9 +5,7 @@ use Blacklight\Music;
|
||||
|
||||
$music = new Music;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
if (request()->has('id') && ctype_digit(request()->input('id'))) {
|
||||
$mus = $music->getMusicInfo(request()->input('id'));
|
||||
|
||||
+13
-11
@@ -6,11 +6,13 @@ use App\Models\Category;
|
||||
use App\Models\Settings;
|
||||
use Blacklight\Releases;
|
||||
use App\Models\UserMovie;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
$mv = new Movie(['Settings' => $page->settings]);
|
||||
|
||||
$action = request()->input('id') ?? '';
|
||||
@@ -24,22 +26,22 @@ if (request()->has('from')) {
|
||||
|
||||
switch ($action) {
|
||||
case 'delete':
|
||||
$movie = UserMovie::getMovie(User::currentUserId(), $imdbid);
|
||||
$movie = UserMovie::getMovie(Auth::id(), $imdbid);
|
||||
if (request()->has('from')) {
|
||||
header('Location:'.WWW_TOP.request()->input('from'));
|
||||
} else {
|
||||
header('Location:'.WWW_TOP.'/mymovies');
|
||||
rredirect('/mymovies');
|
||||
}
|
||||
if (! $movie) {
|
||||
$page->show404('Not subscribed');
|
||||
} else {
|
||||
UserMovie::delMovie(User::currentUserId(), $imdbid);
|
||||
UserMovie::delMovie(Auth::id(), $imdbid);
|
||||
}
|
||||
|
||||
break;
|
||||
case 'add':
|
||||
case 'doadd':
|
||||
$movie = UserMovie::getMovie(User::currentUserId(), $imdbid);
|
||||
$movie = UserMovie::getMovie(Auth::id(), $imdbid);
|
||||
if ($movie) {
|
||||
$page->show404('Already subscribed');
|
||||
} else {
|
||||
@@ -51,11 +53,11 @@ switch ($action) {
|
||||
|
||||
if ($action === 'doadd') {
|
||||
$category = (request()->has('category') && is_array(request()->input('category')) && ! empty(request()->input('category'))) ? request()->input('category') : [];
|
||||
UserMovie::addMovie(User::currentUserId(), $imdbid, $category);
|
||||
UserMovie::addMovie(Auth::id(), $imdbid, $category);
|
||||
if (request()->has('from')) {
|
||||
header('Location:'.WWW_TOP.request()->input('from'));
|
||||
} else {
|
||||
header('Location:'.WWW_TOP.'/mymovies');
|
||||
rredirect('/mymovies');
|
||||
}
|
||||
} else {
|
||||
$tmpcats = Category::getChildren(Category::MOVIE_ROOT);
|
||||
@@ -79,7 +81,7 @@ switch ($action) {
|
||||
break;
|
||||
case 'edit':
|
||||
case 'doedit':
|
||||
$movie = UserMovie::getMovie(User::currentUserId(), $imdbid);
|
||||
$movie = UserMovie::getMovie(Auth::id(), $imdbid);
|
||||
|
||||
if (! $movie) {
|
||||
$page->show404();
|
||||
@@ -87,11 +89,11 @@ switch ($action) {
|
||||
|
||||
if ($action === 'doedit') {
|
||||
$category = (request()->has('category') && is_array(request()->input('category')) && ! empty(request()->input('category'))) ? request()->input('category') : [];
|
||||
UserMovie::updateMovie(User::currentUserId(), $imdbid, $category);
|
||||
UserMovie::updateMovie(Auth::id(), $imdbid, $category);
|
||||
if (request()->has('from')) {
|
||||
header('Location:'.WWW_TOP.request()->input('from'));
|
||||
redirect(request()->input('from'));
|
||||
} else {
|
||||
header('Location:'.WWW_TOP.'/mymovies');
|
||||
rredirect('/mymovies');
|
||||
}
|
||||
} else {
|
||||
$tmpcats = Category::getChildren(Category::MOVIE_ROOT);
|
||||
|
||||
+13
-11
@@ -6,11 +6,13 @@ use App\Models\Category;
|
||||
use App\Models\Settings;
|
||||
use Blacklight\Releases;
|
||||
use App\Models\UserSerie;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
$action = request()->input('id') ?? '';
|
||||
$videoId = request()->input('subpage') ?? '';
|
||||
|
||||
@@ -22,22 +24,22 @@ if (request()->has('from')) {
|
||||
|
||||
switch ($action) {
|
||||
case 'delete':
|
||||
$show = UserSerie::getShow(User::currentUserId(), $videoId);
|
||||
$show = UserSerie::getShow(Auth::id(), $videoId);
|
||||
if (request()->has('from')) {
|
||||
header('Location:'.WWW_TOP.request()->input('from'));
|
||||
} else {
|
||||
header('Location:'.WWW_TOP.'/myshows');
|
||||
redirect('/myshows');
|
||||
}
|
||||
if (! $show) {
|
||||
$page->show404('Not subscribed');
|
||||
} else {
|
||||
UserSerie::delShow(User::currentUserId(), $videoId);
|
||||
UserSerie::delShow(Auth::id(), $videoId);
|
||||
}
|
||||
|
||||
break;
|
||||
case 'add':
|
||||
case 'doadd':
|
||||
$show = UserSerie::getShow(User::currentUserId(), $videoId);
|
||||
$show = UserSerie::getShow(Auth::id(), $videoId);
|
||||
if ($show) {
|
||||
$page->show404('Already subscribed');
|
||||
} else {
|
||||
@@ -49,11 +51,11 @@ switch ($action) {
|
||||
|
||||
if ($action === 'doadd') {
|
||||
$category = (request()->has('category') && is_array(request()->input('category')) && ! empty(request()->input('category'))) ? request()->input('category') : [];
|
||||
UserSerie::addShow(User::currentUserId(), $videoId, $category);
|
||||
UserSerie::addShow(Auth::id(), $videoId, $category);
|
||||
if (request()->has('from')) {
|
||||
header('Location:'.WWW_TOP.request()->input('from'));
|
||||
} else {
|
||||
header('Location:'.WWW_TOP.'/myshows');
|
||||
redirect('/myshows');
|
||||
}
|
||||
} else {
|
||||
$tmpcats = Category::getChildren(Category::TV_ROOT);
|
||||
@@ -77,7 +79,7 @@ switch ($action) {
|
||||
break;
|
||||
case 'edit':
|
||||
case 'doedit':
|
||||
$show = UserSerie::getShow(User::currentUserId(), $videoId);
|
||||
$show = UserSerie::getShow(Auth::id(), $videoId);
|
||||
|
||||
if (! $show) {
|
||||
$page->show404();
|
||||
@@ -85,11 +87,11 @@ switch ($action) {
|
||||
|
||||
if ($action === 'doedit') {
|
||||
$category = (request()->has('category') && is_array(request()->input('category')) && ! empty(request()->input('category'))) ? request()->input('category') : [];
|
||||
UserSerie::updateShow(User::currentUserId(), $videoId, $category);
|
||||
UserSerie::updateShow(Auth::id(), $videoId, $category);
|
||||
if (request()->has('from')) {
|
||||
header('Location:'.WWW_TOP.request()->input('from'));
|
||||
redirect(request()->input('from'));
|
||||
} else {
|
||||
header('Location:'.WWW_TOP.'/myshows');
|
||||
redirect('/myshows');
|
||||
}
|
||||
} else {
|
||||
$tmpcats = Category::getChildren(Category::TV_ROOT);
|
||||
|
||||
@@ -4,11 +4,13 @@ use App\Models\User;
|
||||
use App\Models\Release;
|
||||
use App\Models\ReleaseNfo;
|
||||
use Blacklight\utility\Utility;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
if (request()->has('id')) {
|
||||
$rel = Release::getByGuid(request()->input('id'));
|
||||
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
use App\Models\User;
|
||||
use Blacklight\NZBGet;
|
||||
use Blacklight\utility\Utility;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
$nzbget = new NZBGet($page);
|
||||
|
||||
$output = '';
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
use Blacklight\NZBVortex;
|
||||
|
||||
try {
|
||||
|
||||
@@ -2,19 +2,21 @@
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Forumpost;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
$id = request()->input('id') + 0;
|
||||
|
||||
if (isset($id) && ! empty(request()->input('addMessage'))) {
|
||||
$parent = Forumpost::getPost($id);
|
||||
Forumpost::editPost($id, request()->input('addMessage'), User::currentUserId());
|
||||
if ((int) $parent['parentid'] !== 0) {
|
||||
header('Location:'.WWW_TOP.'/forumpost/'.$parent['parentid'].'#last');
|
||||
request()->header('/forumpost/'.$parent['parentid'].'#last');
|
||||
} else {
|
||||
header('Location:'.WWW_TOP.'/forumpost/'.$id);
|
||||
request()->header('/forumpost/'.$id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,15 +8,16 @@ use App\Models\UserRequest;
|
||||
use App\Models\UserDownload;
|
||||
use App\Models\ReleaseComment;
|
||||
use App\Models\UserExcludedCategory;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
$sab = new SABnzbd($page);
|
||||
$nzbget = new NZBGet($page);
|
||||
|
||||
$userID = User::currentUserId();
|
||||
$userID = Auth::id();
|
||||
$privileged = User::isAdmin($userID) || User::isModerator($userID);
|
||||
$privateProfiles = (int) Settings::settingValue('..privateprofiles') === 1;
|
||||
$publicView = false;
|
||||
|
||||
@@ -3,21 +3,23 @@
|
||||
use App\Models\User;
|
||||
use App\Models\Settings;
|
||||
use App\Mail\AccountDeleted;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
$userId = request()->input('id');
|
||||
|
||||
if ($userId !== null && $page->userdata->role->id !== User::ROLE_ADMIN && (int) $userId === User::currentUserId()) {
|
||||
if ($userId !== null && $page->userdata->role->id !== User::ROLE_ADMIN && (int) $userId === Auth::id()) {
|
||||
Mail::to(Settings::settingValue('site.main.email'))->send(new AccountDeleted($userId));
|
||||
User::logout();
|
||||
Auth::logout();
|
||||
User::deleteUser($userId);
|
||||
header('Location: '.WWW_TOP.'/');
|
||||
redirect(WWW_TOP.'/');
|
||||
} elseif ($page->userdata->role->id === User::ROLE_ADMIN) {
|
||||
header('Location: '.WWW_TOP.'profile');
|
||||
redirect(WWW_TOP.'profile');
|
||||
} else {
|
||||
$page->showBadBoy();
|
||||
}
|
||||
|
||||
@@ -7,17 +7,20 @@ use App\Models\Category;
|
||||
use App\Models\Settings;
|
||||
use Blacklight\utility\Utility;
|
||||
use App\Models\UserExcludedCategory;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
$sab = new SABnzbd($page);
|
||||
$nzbGet = new NZBGet($page);
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
$action = request()->input('action') ?? 'view';
|
||||
|
||||
$userid = User::currentUserId();
|
||||
$userid = Auth::id();
|
||||
$data = User::find($userid);
|
||||
if (! $data) {
|
||||
$page->show404();
|
||||
@@ -28,11 +31,11 @@ $errorStr = '';
|
||||
switch ($action) {
|
||||
case 'newapikey':
|
||||
User::updateRssKey($userid);
|
||||
header('Location: profileedit');
|
||||
redirect('/profileedit');
|
||||
break;
|
||||
case 'clearcookies':
|
||||
$sab->unsetCookie();
|
||||
header('Location: profileedit');
|
||||
redirect('/profileedit');
|
||||
break;
|
||||
case 'submit':
|
||||
|
||||
@@ -96,8 +99,7 @@ switch ($action) {
|
||||
User::updatePassword($userid, request()->input('password'));
|
||||
}
|
||||
|
||||
header('Location:'.WWW_TOP.'/profile');
|
||||
die();
|
||||
redirect('/profile');
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -4,12 +4,14 @@ use App\Models\User;
|
||||
use Blacklight\NZBGet;
|
||||
use Blacklight\SABnzbd;
|
||||
use App\Models\Settings;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
$userData = User::find(User::currentUserId());
|
||||
|
||||
$userData = User::find(Auth::id());
|
||||
if (! $userData) {
|
||||
$page->show404();
|
||||
}
|
||||
|
||||
@@ -7,8 +7,10 @@ use App\Models\UserRole;
|
||||
use App\Models\Invitation;
|
||||
use Blacklight\utility\Utility;
|
||||
|
||||
if (User::isLoggedIn()) {
|
||||
header('Location: '.WWW_TOP.'/');
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (Auth::check()) {
|
||||
redirect('/');
|
||||
}
|
||||
|
||||
$error = $userName = $password = $confirmPassword = $email = $inviteCode = $inviteCodeQuery = '';
|
||||
|
||||
@@ -6,6 +6,11 @@ use App\Models\Settings;
|
||||
use Blacklight\http\RSS;
|
||||
use App\Models\UserRequest;
|
||||
use Blacklight\utility\Utility;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
$rss = new RSS(['Settings' => $page->settings]);
|
||||
$offset = 0;
|
||||
@@ -13,9 +18,6 @@ $offset = 0;
|
||||
// If no content id provided then show user the rss selection page.
|
||||
if (! request()->has('t') && ! request()->has('show') && ! request()->has('anidb')) {
|
||||
// User has to either be logged in, or using rsskey.
|
||||
if (! User::isLoggedIn()) {
|
||||
header('Location: '.Settings::settingValue('site.main.code'));
|
||||
}
|
||||
|
||||
$page->title = 'Rss Info';
|
||||
$page->meta_title = 'Rss Nzb Info';
|
||||
@@ -49,8 +51,8 @@ if (! request()->has('t') && ! request()->has('show') && ! request()->has('anidb
|
||||
} else {
|
||||
$rssToken = $uid = -1;
|
||||
// User requested a feed, ensure either logged in or passing a valid token.
|
||||
if (User::isLoggedIn()) {
|
||||
$uid = $page->userdata['id'];
|
||||
if (Auth::check()) {
|
||||
$uid = Auth::id();
|
||||
$rssToken = $page->userdata['rsstoken'];
|
||||
$maxRequests = $page->userdata->role->apirequests;
|
||||
} else {
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
|
||||
use App\Models\User;
|
||||
use Blacklight\SABnzbd;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
$sab = new SABnzbd($page);
|
||||
|
||||
$output = '';
|
||||
|
||||
@@ -4,11 +4,13 @@ use App\Models\User;
|
||||
use App\Models\Group;
|
||||
use App\Models\Category;
|
||||
use Blacklight\Releases;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
$releases = new Releases(['Groups' => null, 'Settings' => $page->settings]);
|
||||
|
||||
$page->meta_title = 'Search Nzbs';
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
|
||||
use App\Models\User;
|
||||
use Blacklight\CouchPotato;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
if (empty(request()->input('id'))) {
|
||||
$page->show404();
|
||||
} else {
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
|
||||
use App\Models\User;
|
||||
use Blacklight\NZBGet;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
if (empty(request()->input('id'))) {
|
||||
$page->show404();
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
use App\Models\User;
|
||||
use Blacklight\NZBGet;
|
||||
use Blacklight\SABnzbd;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
if (empty(request()->input('id'))) {
|
||||
$page->show404();
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
|
||||
use App\Models\User;
|
||||
use Blacklight\SABnzbd;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
if (empty(request()->input('id'))) {
|
||||
$page->show404();
|
||||
}
|
||||
|
||||
@@ -4,11 +4,13 @@ use App\Models\User;
|
||||
use App\Models\Video;
|
||||
use Blacklight\Releases;
|
||||
use App\Models\UserSerie;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
$releases = new Releases(['Settings' => $page->settings]);
|
||||
|
||||
if (request()->has('id') && ctype_digit(request()->input('id'))) {
|
||||
@@ -28,7 +30,7 @@ if (request()->has('id') && ctype_digit(request()->input('id'))) {
|
||||
} elseif (! $rel) {
|
||||
$page->smarty->assign('nodata', 'No releases for this series.');
|
||||
} else {
|
||||
$myshows = UserSerie::getShow(User::currentUserId(), $show['id']);
|
||||
$myshows = UserSerie::getShow(Auth::id(), $show['id']);
|
||||
|
||||
// Sort releases by season, episode, date posted.
|
||||
$series = $episode = $posted = [];
|
||||
@@ -89,7 +91,7 @@ if (request()->has('id') && ctype_digit(request()->input('id'))) {
|
||||
$letter = '';
|
||||
}
|
||||
|
||||
$masterserieslist = Video::getSeriesList(User::currentUserId(), $letter, $showname);
|
||||
$masterserieslist = Video::getSeriesList(Auth::id(), $letter, $showname);
|
||||
|
||||
$page->title = 'Series List';
|
||||
$page->meta_title = 'View Series List';
|
||||
|
||||
@@ -11,7 +11,7 @@ $arPages = [];
|
||||
$arPages[] = buildURL('Home', 'Home Page', '/', 'daily', '1.0');
|
||||
|
||||
$role = 0;
|
||||
if ($page->userdata != null) {
|
||||
if ($page->userdata !== null) {
|
||||
$role = $page->userdata['role'];
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Forumpost;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
$id = request()->input('id') + 0;
|
||||
|
||||
if (isset($id)) {
|
||||
Forumpost::deleteParent($id);
|
||||
header('Location:'.WWW_TOP.'/forum');
|
||||
request()->header('/forum');
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
use Blacklight\XXX;
|
||||
use App\Models\User;
|
||||
use App\Models\Category;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
$movie = new XXX();
|
||||
|
||||
$moviecats = Category::getChildren(Category::XXX_ROOT);
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
|
||||
use Blacklight\XXX;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! User::isLoggedIn()) {
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
if (request()->has('modal') && request()->has('id') && ctype_digit(request()->input('id'))) {
|
||||
$movie = new XXX(['Settings' => $page->settings]);
|
||||
$mov = $movie->getXXXInfo(request()->input('id'));
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
<form action="profileedit?action=submit" method="post">
|
||||
<input type="hidden" name="_token" value="{$csrf_token}">
|
||||
{{csrf_field()}}
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade active in" id="tab2_1">
|
||||
<table cellpadding="0" cellspacing="0" width="100%">
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="csrf-token" content="{$csrf_token}">
|
||||
<meta name="csrf-token" content="{{csrf_token()}}">
|
||||
|
||||
<title>{$page->meta_title}{if $page->meta_title != "" && $site->metatitle != ""} - {/if}{$site->metatitle}</title>
|
||||
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
|
||||
|
||||
@@ -90,6 +90,7 @@
|
||||
</div>
|
||||
<div class="body">
|
||||
<form id="new-forum-thread" class="form-horizontal" action="" method="post">
|
||||
{{csrf_field()}}
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="addSubject">Subject</label>
|
||||
<div class="controls">
|
||||
|
||||
@@ -12,10 +12,7 @@
|
||||
<div class="login-box-body">
|
||||
<p class="login-box-msg">Please sign in to access the site</p>
|
||||
<form action="login" method="post">
|
||||
<input type="hidden" name="_token" value="{$csrf_token}">
|
||||
{if isset($redirect)}
|
||||
<input type="hidden" name="redirect" value="{$redirect|escape:"htmlall"}"/>
|
||||
{/if}
|
||||
{{csrf_field()}}
|
||||
<div class="form-group has-feedback">
|
||||
<input id="username" name="username" type="text" class="form-control" placeholder="Username or email"/>
|
||||
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
|
||||
|
||||
+115
-1
@@ -12,5 +12,119 @@
|
||||
*/
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
redirect('/');
|
||||
});
|
||||
|
||||
Route::get('/login', function () {
|
||||
redirect('/login');
|
||||
});
|
||||
|
||||
Route::post('/login', 'Auth\LoginController@login');
|
||||
|
||||
Route::get('/browse', function () {
|
||||
redirect('/browse');
|
||||
});
|
||||
|
||||
Route::get('/console', function () {
|
||||
redirect('/console');
|
||||
});
|
||||
|
||||
Route::get('/details/{id}', function () {
|
||||
redirect('/details');
|
||||
});
|
||||
|
||||
Route::get('/games', function () {
|
||||
redirect('/games');
|
||||
});
|
||||
|
||||
Route::get('/movies', function () {
|
||||
redirect('/movies');
|
||||
});
|
||||
|
||||
Route::get('/browsegroup', function () {
|
||||
redirect('/browsegroup');
|
||||
});
|
||||
|
||||
Route::get('/pc', function () {
|
||||
redirect('/pc');
|
||||
});
|
||||
|
||||
Route::get('/music', function () {
|
||||
redirect('/music');
|
||||
});
|
||||
|
||||
Route::get('/xxx', function () {
|
||||
redirect('/xxx');
|
||||
});
|
||||
|
||||
Route::get('/admin/{page}', function () {
|
||||
redirect('/admin');
|
||||
});
|
||||
|
||||
Route::get('/books', function () {
|
||||
redirect('/books');
|
||||
});
|
||||
|
||||
Route::get('/contact-us', function () {
|
||||
redirect('/contact-us');
|
||||
});
|
||||
|
||||
Route::get('/forum', function () {
|
||||
redirect('/forum');
|
||||
});
|
||||
|
||||
Route::post('/forum', function () {
|
||||
redirect('/forum');
|
||||
});
|
||||
|
||||
Route::get('/forumpost', function () {
|
||||
redirect('/forumpost');
|
||||
});
|
||||
|
||||
Route::post('/forumpost', function () {
|
||||
redirect('/forumpost');
|
||||
});
|
||||
|
||||
Route::get('/profileedit', function () {
|
||||
redirect('/profileedit');
|
||||
});
|
||||
|
||||
Route::post('/profileedit', function () {
|
||||
redirect('/profileedit');
|
||||
});
|
||||
|
||||
Route::get('/profile', function () {
|
||||
redirect('/profile');
|
||||
});
|
||||
|
||||
Route::get('/apihelp', function () {
|
||||
redirect('/apihelp');
|
||||
});
|
||||
|
||||
Route::get('/api', function () {
|
||||
redirect('/api');
|
||||
});
|
||||
|
||||
Route::post('/api', function () {
|
||||
redirect('/api');
|
||||
});
|
||||
|
||||
Route::get('/search', function () {
|
||||
redirect('/search');
|
||||
});
|
||||
|
||||
Route::post('/search/{id}', function () {
|
||||
redirect('/search');
|
||||
});
|
||||
|
||||
Route::get('/rss', function () {
|
||||
redirect('/rss');
|
||||
});
|
||||
|
||||
Route::post('/rss', function () {
|
||||
redirect('/rss');
|
||||
});
|
||||
|
||||
Route::get('/logout', function () {
|
||||
return Auth::logout();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user