-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy patherrorpage.php
74 lines (65 loc) · 2.5 KB
/
errorpage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
$error = $_SERVER['REDIRECT_STATUS'];
$referring_url = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
$requested_url = $_SERVER['REQUEST_URI'];
# $referring_ip = $_SERVER['REMOTE_ADDR'];
$server_name = $_SERVER['SERVER_NAME'];
switch ($error) {
# Error 400 - Bad Request
case 400:
$errorname = 'Error 400 - Bad Request';
$errordesc = '<h1>Bad Request</h1>
<h2>Error: 400</h2>
<p>
The URL that you requested — http://'.$server_name.$requested_url.' — does not exist on this server.</p>';
break;
# Error 401 - Authorization Required
case 401:
$errorname = 'Error 401 - Authorization Required';
$errordesc = '<h1>Authorization Required</h1>
<h2>Error: 401</h2>
<p>
The URL that you requested requires pre-authorization to access.</p>';
break;
# Error 403 - Access Forbidden
case 403:
$errorname = 'Error 403 - Access Forbidden';
$errordesc = '<h1>Access Forbidden</h1>
<h2>Error: 403</h2>
<p>
Access to the URL that you requested is forbidden.</p>';
break;
# Error 404 - Page Not Found
case 404:
$errorname = 'Error 404 - Page Not Found';
$errordesc = '<h1>File Not Found</h1>
<h2>Error: 404</h2>
<p>
Ooops! The page you are looking for — http://'.$server_name.$requested_url.' — cannot be found. This may be because:</p>
<ul>
<li>the path to the page was entered wrong;</li>
<li>the page no longer exists; or</li>
<li>there has been an error on the Web site.</li>
</ul>';
break;
# Error 500 - Server Configuration Error
case 500:
$errorname = 'Error 500 - Server Configuration Error';
$errordesc = '<h1>Server Configuration Error</h1>
<h2>Error: 500</h2>
<p>
The URL that you requested — <a href="http://'.$server_name.$requested_url.'">http://'.$server_name.$requested_url.'</a> — resulted in a server configuration error. It is possible that the condition causing the problem will be gone by the time you finish reading this.</p>';
break;
# Unknown error
default:
$errorname = 'Unknown Error';
$errordesc = '<h2>Unknown Error</h2>
<p>The URL that you requested — <a href="http://'.$server_name.$requested_url.'">http://'.$server_name.$requested_url.'</a> — resulted in an unknown error. It is possible that the condition causing the problem will be gone by the time you finish reading this. </p>';
}
echo($errordesc);
if (!$referring_url == '') {
echo '<p><a href="'.$referring_url.'"><< Go back to previous page.</a></p>';
} else {
echo '<p><a href="javascript:history.go(-1)"><< Go back to previous page.</a></p>';
}
?>