This repository was archived by the owner on Jun 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patherror.php
More file actions
151 lines (134 loc) · 5.21 KB
/
error.php
File metadata and controls
151 lines (134 loc) · 5.21 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
/*
Dynamic Error Pages v1.01
Created by: Sabre Web Design - Copyright (c) 2004 modified by Henry Stark
A dynamic PHP script which returns different error messages depending on the error received.
The script will also send an e-mail to your e-mail address with the time, error received,
requested page and the page they came from. (Optional). (Please note: To use this script
you need to be allowed use custom error pages on your host.)
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials
provided with the distribution.
* Redistributions of this script is free for Non-Commercial use ONLY!
* Neither the name of Sabre Web Design nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
// Setup
$email = 'chocolatkey@gmail.com'; //Change to your e-mail address
// Get Variables
$error = $_SERVER['REDIRECT_STATUS'];
$referring_url = $_SERVER['HTTP_REFERER'];
$requested_url = $_SERVER['REQUEST_URI'];
$referring_ip = $_SERVER['REMOTE_ADDR'];
$server_name = $_SERVER['SERVER_NAME'];
// Different error messages to display
switch ($error) {
# Error 400 - Bad Request
case 400:
$errorname = 'Error 400 - Bad Request';
$errordesc = '<h1>Bad Request</h1>
<p>
The URL that you requested — '.$server_name.$requested_url.' — does not exist on this server. You might want to re-check the spelling and the path.</p>';
break;
# Error 401 - Authorization Required
case 401:
$errorname = 'Error 401 - Authorization Required';
$errordesc = '<h1>Authorization Required</h1>
<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>
<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>
<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>
<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>';
}
?>
<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" >
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width">
<title>Error <?php echo $errorname; ?></title>
<link rev="made" href="mailto:<?php echo $email; ?>" />
<link href="/css/status.css" rel="stylesheet">
</head>
<body>
<div id="container">
<div class="leds">
<div class="green led"></div>
<div class="red led"></div>
</div>
<div class="leds">
<div class="green active led"></div>
<div class="red active blink led"></div>
</div>
<div class="flip">
Error<?php echo ' '.$error; ?>
<div class="break">
<div class="link left"></div>
<div class="link right"></div>
</div>
</div>
<div class="sorry">
<?php
// Display selected error message
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>';
}
?>
</div>
</div>
</body>
</html>