diff --git a/Changelog b/Changelog index fae0c1247..18dac195d 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2017-08-10 DariusIII + * Chg: Add customized 404 page * Chg: Handle 500 errors in production properly * Chg: Further improve maintenance mode 2017-08-09 DariusIII diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 0fbb7ecb2..f0401d839 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -6,6 +6,7 @@ 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 { @@ -50,6 +51,11 @@ class Handler extends ExceptionHandler return response()->view('errors.404', [], 404); } + if ($exception instanceof NotFoundHttpException) + { + return response()->view('errors.404', [], 404); + } + if ($this->isHttpException($exception)) { return $this->renderHttpException($exception); } diff --git a/public/pages/BasePage.php b/public/pages/BasePage.php index 3ae4dfcda..5b36771bb 100644 --- a/public/pages/BasePage.php +++ b/public/pages/BasePage.php @@ -241,25 +241,10 @@ class BasePage /** * Show 404 page. */ - public function show404() + public function show404(): void { header('HTTP/1.1 404 Not Found'); - exit( - sprintf(' - - - 404 - File not found. - - -

404 - File not found.

-

%s%s

-

We could not find the above page or file on our servers.

- - ', - $this->serverurl, - $this->page - ) - ); + die(view('errors.404')); } /** @@ -306,7 +291,7 @@ class BasePage * Show maintenance page. * */ - public function showMaintenance() + public function showMaintenance(): void { header('HTTP/1.1 503 Service Temporarily Unavailable'); die(view('errors.503')); @@ -337,6 +322,7 @@ class BasePage die(); } + public function render() { $this->smarty->display($this->page_template); diff --git a/resources/views/errors/404.blade.php b/resources/views/errors/404.blade.php new file mode 100644 index 000000000..eead42205 --- /dev/null +++ b/resources/views/errors/404.blade.php @@ -0,0 +1,43 @@ + + + + HTTP/1.1 404 Not Found + + + + + + +
+
+
We could not find page you are looking for.
Monkeys are hard at work to find it for you!
Or you could try on your own.
+
+
+ + \ No newline at end of file