mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 02:01:33 +00:00
Update controllers - remove Blacklight/db/DB, update app/Exception/Handler class
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
2018-05-07 DariusIII
|
||||
* CHg: Update controllers - remove Blacklight/db/DB, update app/Exception/Handler class
|
||||
* Chg: Update composer.json with new versions of used libraries
|
||||
* Chg: Define default value for $catsrch variable
|
||||
* Chg: Update return values of getCategorySearch function in Category model
|
||||
|
||||
+12
-43
@@ -3,25 +3,27 @@
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of the exception types that should not be reported.
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
\Illuminate\Auth\AuthenticationException::class,
|
||||
\Illuminate\Auth\Access\AuthorizationException::class,
|
||||
\Symfony\Component\HttpKernel\Exception\HttpException::class,
|
||||
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
|
||||
\Illuminate\Session\TokenMismatchException::class,
|
||||
\Illuminate\Validation\ValidationException::class,
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed for validation exceptions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -46,39 +48,6 @@ class Handler extends ExceptionHandler
|
||||
*/
|
||||
public function render($request, Exception $exception)
|
||||
{
|
||||
// 404 page when a model is not found
|
||||
if ($exception instanceof ModelNotFoundException) {
|
||||
return response()->view('errors.404', [], 404);
|
||||
}
|
||||
|
||||
if ($exception instanceof NotFoundHttpException) {
|
||||
return response()->view('errors.404', [], 404);
|
||||
}
|
||||
|
||||
if ($this->isHttpException($exception)) {
|
||||
return $this->renderHttpException($exception);
|
||||
}
|
||||
// Custom error 500 view on production
|
||||
if (app()->environment() === 'production') {
|
||||
return response()->view('errors.503', [], 500);
|
||||
}
|
||||
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an authentication exception into an unauthenticated response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Auth\AuthenticationException $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
protected function unauthenticated($request, AuthenticationException $exception)
|
||||
{
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(['error' => 'Unauthenticated.'], 401);
|
||||
}
|
||||
|
||||
return redirect()->guest(route('login'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class BlacklistController extends BasePageController
|
||||
public function edit(Request $request)
|
||||
{
|
||||
$this->setAdminPrefs();
|
||||
$binaries = new Binaries(['Settings' => $this->pdo]);
|
||||
$binaries = new Binaries(['Settings' => null]);
|
||||
$error = '';
|
||||
$regex = ['id' => '', 'groupname' => '', 'regex' => '', 'description' => '', 'msgcol' => 1, 'status' => 1, 'optype' => 1];
|
||||
$title = 'Binary Black/Whitelist';
|
||||
|
||||
@@ -17,7 +17,7 @@ class CategoryRegexesController extends BasePageController
|
||||
public function index(Request $request)
|
||||
{
|
||||
$this->setAdminPrefs();
|
||||
$regexes = new Regexes(['Settings' => $this->pdo, 'Table_Name' => 'category_regexes']);
|
||||
$regexes = new Regexes(['Settings' =>null, 'Table_Name' => 'category_regexes']);
|
||||
|
||||
$title = 'Category Regex List';
|
||||
|
||||
@@ -51,7 +51,7 @@ class CategoryRegexesController extends BasePageController
|
||||
public function edit(Request $request)
|
||||
{
|
||||
$this->setAdminPrefs();
|
||||
$regexes = new Regexes(['Settings' => $this->pdo, 'Table_Name' => 'category_regexes']);
|
||||
$regexes = new Regexes(['Settings' => null, 'Table_Name' => 'category_regexes']);
|
||||
|
||||
// Set the current action.
|
||||
$action = $request->input('action') ?? 'view';
|
||||
|
||||
@@ -17,7 +17,7 @@ class CollectionRegexesController extends BasePageController
|
||||
public function index(Request $request)
|
||||
{
|
||||
$this->setAdminPrefs();
|
||||
$regexes = new Regexes(['Settings' => $this->pdo, 'Table_Name' => 'collection_regexes']);
|
||||
$regexes = new Regexes(['Settings' => null, 'Table_Name' => 'collection_regexes']);
|
||||
|
||||
$title = 'Collections Regex List';
|
||||
|
||||
@@ -51,7 +51,7 @@ class CollectionRegexesController extends BasePageController
|
||||
public function edit(Request $request)
|
||||
{
|
||||
$this->setAdminPrefs();
|
||||
$regexes = new Regexes(['Settings' => $this->pdo, 'Table_Name' => 'collection_regexes']);
|
||||
$regexes = new Regexes(['Settings' => null, 'Table_Name' => 'collection_regexes']);
|
||||
$error = '';
|
||||
$regex = ['id' => '', 'regex' => '', 'description' => '', 'group_regex' => '', 'ordinal' => '', 'status' => 1];
|
||||
|
||||
@@ -130,7 +130,7 @@ class CollectionRegexesController extends BasePageController
|
||||
$this->smarty->assign(['group' => $group, 'regex' => $regex, 'limit' => $limit]);
|
||||
|
||||
if ($group && $regex) {
|
||||
$this->smarty->assign('data', (new Regexes(['Settings' => $this->pdo, 'Table_Name' => 'collection_regexes']))->testCollectionRegex($group, $regex, $limit));
|
||||
$this->smarty->assign('data', (new Regexes(['Settings' => null, 'Table_Name' => 'collection_regexes']))->testCollectionRegex($group, $regex, $limit));
|
||||
}
|
||||
|
||||
$content = $this->smarty->fetch('collection_regexes-test.tpl');
|
||||
|
||||
@@ -44,7 +44,7 @@ class ConsoleController extends BasePageController
|
||||
public function edit(Request $request)
|
||||
{
|
||||
$this->setAdminPrefs();
|
||||
$console = new Console(['Settings' => $this->pdo]);
|
||||
$console = new Console(['Settings' => null]);
|
||||
$gen = new Genres();
|
||||
|
||||
// set the current action
|
||||
|
||||
@@ -16,7 +16,7 @@ class GameController extends BasePageController
|
||||
public function index()
|
||||
{
|
||||
$this->setAdminPrefs();
|
||||
$game = new Games(['Settings' => $this->pdo]);
|
||||
$game = new Games(['Settings' => null]);
|
||||
|
||||
$title = 'Game List';
|
||||
|
||||
@@ -45,8 +45,8 @@ class GameController extends BasePageController
|
||||
public function edit(Request $request)
|
||||
{
|
||||
$this->setAdminPrefs();
|
||||
$games = new Games(['Settings' => $this->pdo]);
|
||||
$gen = new Genres(['Settings' => $this->pdo]);
|
||||
$games = new Games(['Settings' => null]);
|
||||
$gen = new Genres(['Settings' => null]);
|
||||
|
||||
// Set the current action.
|
||||
$action = $request->input('action') ?? 'view';
|
||||
|
||||
@@ -42,7 +42,7 @@ class MovieController extends BasePageController
|
||||
public function create(Request $request)
|
||||
{
|
||||
$this->setAdminPrefs();
|
||||
$movie = new Movie(['Settings' => $this->pdo]);
|
||||
$movie = new Movie(['Settings' => null]);
|
||||
|
||||
$title = 'Movie Add';
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class NzbController extends BasePageController
|
||||
if (\count($filesToProcess) > 0) {
|
||||
|
||||
// Create a new instance of NZBImport and send it the file locations.
|
||||
$NZBImport = new NZBImport(['Browser' => true, 'Settings' => $this->pdo]);
|
||||
$NZBImport = new NZBImport(['Browser' => true, 'Settings' => null]);
|
||||
|
||||
$this->smarty->assign(
|
||||
'output',
|
||||
@@ -87,7 +87,7 @@ class NzbController extends BasePageController
|
||||
}
|
||||
|
||||
$this->setAdminPrefs();
|
||||
$rel = new Releases(['Settings' => $this->pdo]);
|
||||
$rel = new Releases(['Settings' => null]);
|
||||
|
||||
if ($this->isPostBack()) {
|
||||
$path = $request->input('folder');
|
||||
@@ -98,7 +98,7 @@ class NzbController extends BasePageController
|
||||
|
||||
if ($path !== '') {
|
||||
$NE = new NZBExport([
|
||||
'Browser' => true, 'Settings' => $this->pdo,
|
||||
'Browser' => true, 'Settings' => null,
|
||||
'Releases' => $rel,
|
||||
]);
|
||||
$retVal = $NE->beginExport(
|
||||
|
||||
@@ -17,7 +17,7 @@ class ReleaseNamingRegexesController extends BasePageController
|
||||
public function index(Request $request)
|
||||
{
|
||||
$this->setAdminPrefs();
|
||||
$regexes = new Regexes(['Settings' => $this->pdo, 'Table_Name' => 'release_naming_regexes']);
|
||||
$regexes = new Regexes(['Settings' => null, 'Table_Name' => 'release_naming_regexes']);
|
||||
|
||||
$title = 'Release Naming Regex List';
|
||||
|
||||
@@ -46,7 +46,7 @@ class ReleaseNamingRegexesController extends BasePageController
|
||||
public function edit(Request $request)
|
||||
{
|
||||
$this->setAdminPrefs();
|
||||
$regexes = new Regexes(['Settings' => $this->pdo, 'Table_Name' => 'release_naming_regexes']);
|
||||
$regexes = new Regexes(['Settings' => null, 'Table_Name' => 'release_naming_regexes']);
|
||||
|
||||
// Set the current action.
|
||||
$action = $request->input('action') ?? 'view';
|
||||
@@ -127,7 +127,7 @@ class ReleaseNamingRegexesController extends BasePageController
|
||||
$this->smarty->assign(['group' => $group, 'regex' => $regex, 'showlimit' => $showLimit, 'querylimit' => $queryLimit]);
|
||||
|
||||
if ($group && $regex) {
|
||||
$this->smarty->assign('data', (new Regexes(['Settings' => $this->pdo, 'Table_Name' => 'release_naming_regexes']))->testReleaseNamingRegex($group, $regex, $showLimit, $queryLimit));
|
||||
$this->smarty->assign('data', (new Regexes(['Settings' => null, 'Table_Name' => 'release_naming_regexes']))->testReleaseNamingRegex($group, $regex, $showLimit, $queryLimit));
|
||||
}
|
||||
|
||||
$content = $this->smarty->fetch('release_naming_regexes-test.tpl');
|
||||
|
||||
@@ -108,7 +108,7 @@ class ReleasesController extends BasePageController
|
||||
public function destroy($id)
|
||||
{
|
||||
if ($id) {
|
||||
$releases = new Releases(['Settings' => $this->pdo]);
|
||||
$releases = new Releases(['Settings' => null]);
|
||||
$releases->deleteMultiple($id);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,13 +55,6 @@ class BasePageController extends Controller
|
||||
*/
|
||||
public $serverurl = '';
|
||||
|
||||
/**
|
||||
* Public access to Captcha object for error checking.
|
||||
*
|
||||
* @var \Blacklight\Captcha
|
||||
*/
|
||||
public $captcha;
|
||||
|
||||
/**
|
||||
* User's theme.
|
||||
*
|
||||
@@ -74,11 +67,6 @@ class BasePageController extends Controller
|
||||
*/
|
||||
public $token;
|
||||
|
||||
/**
|
||||
* @var \Blacklight\db\DB
|
||||
*/
|
||||
public $pdo;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Foundation\Application|mixed
|
||||
*/
|
||||
@@ -87,8 +75,6 @@ class BasePageController extends Controller
|
||||
/**
|
||||
* BasePageController constructor.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct()
|
||||
@@ -96,7 +82,6 @@ class BasePageController extends Controller
|
||||
$this->middleware('auth')->except('api', 'rss', 'contact', 'showContactForm', 'callback');
|
||||
// Buffer settings/DB connection.
|
||||
$this->settings = new Settings();
|
||||
$this->pdo = new DB();
|
||||
$this->smarty = app('smarty.view');
|
||||
|
||||
foreach (array_get(config('ytake-laravel-smarty'), 'plugins_paths', []) as $plugins) {
|
||||
@@ -110,7 +95,7 @@ class BasePageController extends Controller
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function setPrefs()
|
||||
protected function setPrefs(): void
|
||||
{
|
||||
if (Auth::check()) {
|
||||
$this->userdata = Auth::user();
|
||||
@@ -145,7 +130,7 @@ class BasePageController extends Controller
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isPostBack()
|
||||
public function isPostBack(): bool
|
||||
{
|
||||
return \request()->isMethod('POST');
|
||||
}
|
||||
@@ -175,7 +160,7 @@ class BasePageController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Show 503 page.
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function show503()
|
||||
{
|
||||
@@ -183,11 +168,11 @@ class BasePageController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Show 503 page.
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function showBadBoy(): void
|
||||
public function showBadBoy()
|
||||
{
|
||||
die(view('errors.badboy'));
|
||||
return view('errors.badboy')->with('Message', 'This is not you account.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,7 +180,7 @@ class BasePageController extends Controller
|
||||
*/
|
||||
public function showMaintenance()
|
||||
{
|
||||
return view('errors.maintenance')->with('Message', 'Service Temporarily Unavailable');
|
||||
return view('errors.maintenance')->with('Message', 'We are performing an site maintenance.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,7 +305,6 @@ class BasePageController extends Controller
|
||||
*/
|
||||
public function pagerender(): void
|
||||
{
|
||||
$this->smarty->assign('page', $this);
|
||||
$this->page_template = 'basepage.tpl';
|
||||
|
||||
$this->render();
|
||||
@@ -333,8 +317,6 @@ class BasePageController extends Controller
|
||||
*/
|
||||
public function adminrender(): void
|
||||
{
|
||||
$this->smarty->assign('page', $this);
|
||||
|
||||
$admin_menu = $this->smarty->fetch('adminmenu.tpl');
|
||||
$this->smarty->assign('admin_menu', $admin_menu);
|
||||
|
||||
@@ -346,7 +328,7 @@ class BasePageController extends Controller
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function basePage()
|
||||
public function basePage(): void
|
||||
{
|
||||
$this->setPrefs();
|
||||
$this->pagerender();
|
||||
@@ -355,7 +337,7 @@ class BasePageController extends Controller
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function adminBasePage()
|
||||
public function adminBasePage(): void
|
||||
{
|
||||
$this->setAdminPrefs();
|
||||
$this->adminrender();
|
||||
|
||||
Reference in New Issue
Block a user