diff --git a/Changelog b/Changelog index 3cfbc3f2b..bb16c2f8d 100755 --- a/Changelog +++ b/Changelog @@ -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 diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 9b9fb0fb1..7e2563a8c 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -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')); - } } diff --git a/app/Http/Controllers/Admin/BlacklistController.php b/app/Http/Controllers/Admin/BlacklistController.php index a396037bf..d9de5ea47 100644 --- a/app/Http/Controllers/Admin/BlacklistController.php +++ b/app/Http/Controllers/Admin/BlacklistController.php @@ -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'; diff --git a/app/Http/Controllers/Admin/CategoryRegexesController.php b/app/Http/Controllers/Admin/CategoryRegexesController.php index 8ca155d87..f482cf512 100644 --- a/app/Http/Controllers/Admin/CategoryRegexesController.php +++ b/app/Http/Controllers/Admin/CategoryRegexesController.php @@ -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'; diff --git a/app/Http/Controllers/Admin/CollectionRegexesController.php b/app/Http/Controllers/Admin/CollectionRegexesController.php index 05e0fe57b..f55e5daa7 100644 --- a/app/Http/Controllers/Admin/CollectionRegexesController.php +++ b/app/Http/Controllers/Admin/CollectionRegexesController.php @@ -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'); diff --git a/app/Http/Controllers/Admin/ConsoleController.php b/app/Http/Controllers/Admin/ConsoleController.php index be39a4645..d23b33ad5 100644 --- a/app/Http/Controllers/Admin/ConsoleController.php +++ b/app/Http/Controllers/Admin/ConsoleController.php @@ -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 diff --git a/app/Http/Controllers/Admin/GameController.php b/app/Http/Controllers/Admin/GameController.php index 369c8c4bf..dbf732411 100644 --- a/app/Http/Controllers/Admin/GameController.php +++ b/app/Http/Controllers/Admin/GameController.php @@ -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'; diff --git a/app/Http/Controllers/Admin/MovieController.php b/app/Http/Controllers/Admin/MovieController.php index 8dde560d9..0a517b2bd 100644 --- a/app/Http/Controllers/Admin/MovieController.php +++ b/app/Http/Controllers/Admin/MovieController.php @@ -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'; diff --git a/app/Http/Controllers/Admin/NzbController.php b/app/Http/Controllers/Admin/NzbController.php index a5795570a..3d5b6e9e3 100644 --- a/app/Http/Controllers/Admin/NzbController.php +++ b/app/Http/Controllers/Admin/NzbController.php @@ -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( diff --git a/app/Http/Controllers/Admin/ReleaseNamingRegexesController.php b/app/Http/Controllers/Admin/ReleaseNamingRegexesController.php index f9102190d..8c02ed976 100644 --- a/app/Http/Controllers/Admin/ReleaseNamingRegexesController.php +++ b/app/Http/Controllers/Admin/ReleaseNamingRegexesController.php @@ -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'); diff --git a/app/Http/Controllers/Admin/ReleasesController.php b/app/Http/Controllers/Admin/ReleasesController.php index ae52bac30..0e1d64a63 100644 --- a/app/Http/Controllers/Admin/ReleasesController.php +++ b/app/Http/Controllers/Admin/ReleasesController.php @@ -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); } diff --git a/app/Http/Controllers/BasePageController.php b/app/Http/Controllers/BasePageController.php index 279ec333d..3dde5ebe9 100644 --- a/app/Http/Controllers/BasePageController.php +++ b/app/Http/Controllers/BasePageController.php @@ -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();