Skip to content

Commit

Permalink
handle error pages
Browse files Browse the repository at this point in the history
  • Loading branch information
jared970 committed May 25, 2021
1 parent f1e1753 commit 6ff89c1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
3 changes: 2 additions & 1 deletion public_html/.htaccess
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
AddDefaultCharset off
RewriteEngine On

ErrorDocument 404 /error/404
ErrorDocument 403 /error/403
ErrorDocument 404 /error/404
ErrorDocument 418 /error/418
ErrorDocument 500 /error/500

<Files *.htaccess>
Expand Down
47 changes: 47 additions & 0 deletions public_html/error.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
require_once __DIR__ . '/../vendor/autoload.php';
$app = new App\Solution();
?>
<html>
<?php include_once './include/head.php'; ?>
<body>
<div class="uk-padding uk-text-lead uk-light">
<div class="uk-text-center">
<img src="/img/logo.svg" style="width: 128px; height: 128px;" />
<div class="uk-container">
<h2>An error has occurred</h2>
<?php
$errorCode = $app->dataFilter($_GET['code']);
$errorInfo = 'No data available for this error.';
switch($errorCode) {
case '404':
$errorInfo = 'The requested page was not found';
break;
case '500':
$errorInfo = 'Server-side error occurred';
break;
case '403':
$errorInfo = 'Access is denied';
break;
case '418':
$errorInfo = "Sorry, I'm teapot";
break;
}
?>
<p><?php echo $errorInfo; ?></p>
</div>

<br/>
<hr/>
<div class="uk-dark">
<h4>Links</h4>
<a href="/" class="uk-button uk-button-default uk-text-center uk-border-rounded">home</a>
<a href="/" class="uk-button uk-button-primary uk-text-center uk-border-rounded">Utopia</a>
<a href="/" class="uk-button uk-button-primary uk-text-center uk-border-rounded">Crypton</a>
</div>

</div>
</div>
<?php include_once './include/scripts.php'; ?>
</body>
</html>

0 comments on commit 6ff89c1

Please sign in to comment.