Created
February 1, 2018 15:56
-
-
Save omar2205/18e99f4397bf4671eb21eb43dbb2bcf3 to your computer and use it in GitHub Desktop.
Custom Error Page PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Custom Error page | |
by Oscar | |
*/ | |
<?php | |
if (!function_exists('http_response_code_title')) | |
{ | |
function http_response_code_title($code = 403) | |
{ | |
$title = 'Forbidden'; | |
switch ($code) | |
{ | |
case 400: $title = 'Bad Request'; break; | |
case 401: $title = 'Unauthorized'; break; | |
case 403: $title = 'Forbidden'; break; | |
case 404: $title = 'Not Found'; break; | |
case 500: $title = 'Internal Server Error'; break; | |
case 423: $title = 'Locked Down'; break; | |
default: | |
$title = 'Forbidden'; | |
break; | |
} | |
return $title; | |
} | |
} | |
if (!function_exists('http_response_code_text')) | |
{ | |
function http_response_code_text($code = 403) | |
{ | |
$text = 'You don\'t have permission to access this URL'; | |
switch ($code) | |
{ | |
case 400: $text = 'Bad Request or something went wrong'; break; | |
case 401: $text = 'You don\'t have permission to access this URL'; break; | |
case 403: $text = 'You don\'t have permission to access this URL'; break; | |
case 404: $text = 'The URL you requested does not exist'; break; | |
case 500: $text = 'Internal Server Error That\'s all we know'; break; | |
case 423: $text = 'Website is locked down, try in a few seconds (email {{ email }} if you still can\'t access the website'; break; | |
default: | |
$text = 'You don\'t have permission to access this URL'; | |
break; | |
} | |
return $text; | |
} | |
} | |
$code = 403; | |
if(isset($_GET['code']{0})) | |
{ | |
$code = (int) $_GET['code']; | |
} | |
$title = http_response_code_title($code); | |
$text = http_response_code_text($code); | |
?> | |
<!doctype html> | |
<html> | |
<head> | |
<title><?php echo $code . " " . $title?></title> | |
<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<style> | |
body { | |
margin: 0 auto; | |
margin-top: 48px; | |
max-width: 616px; | |
padding: 0 16px; | |
font-family: 'Roboto', 'Helvetica Neue', sans-serif; | |
font-size: 16px; | |
line-height: 24px; | |
color: rgba(0,0,0,0.87); | |
} | |
h1, h2, h3 { | |
font-family: 'Roboto', 'Helvetica Neue', sans-serif; | |
font-weight: 300; | |
} | |
h1 { | |
margin: 200px 0 16px 0; | |
padding: 0 0 16px 0; | |
border-bottom: 1px solid rgba(0,0,0,0.1); | |
font-size: 32px; | |
line-height: 36px; | |
} | |
h2 { | |
margin: 24px 0 16px 0; | |
padding: 0; | |
font-size: 20px; | |
line-height: 32px; | |
color: rgba(0,0,0,0.54); | |
} | |
p { | |
margin: 0; | |
margin-bottom: 16px; | |
} | |
ol { | |
margin: 0; | |
} | |
ol li { | |
margin: 0; | |
line-height: 24px; | |
padding-left: 12px; | |
} | |
a { | |
color: #039BE5; | |
text-decoration: underline; | |
} | |
a:hover { | |
text-decoration: underline; | |
} | |
code { | |
display: inline-block; | |
padding: 3px 4px; | |
background-color: #ECEFF1; | |
border-radius: 3px; | |
font-family: 'Roboto Mono',"Liberation Mono",Courier,monospace; | |
font-size: 14px; | |
line-height: 1; | |
} | |
@media screen and (max-width: 616px) { | |
body { | |
margin-top: 24px; | |
} | |
} | |
</style> | |
</head> | |
<body> | |
<h1><?php echo $title . " "?><code>error <?php echo $code;?></code></h1> | |
<p><?php echo $text ?>.</p><br><br> | |
<a href="/">head home</a> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment