cvs: phpweb / error.php /include errors.inc
| From: | Gabor Hojtsy | Date: | Sat, 06 Sep 2003 09:14:58 +0000 |
| Subject: | cvs: phpweb / error.php /include errors.inc | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-20816@lists.php.net to get a copy of this message | ||
goba Sat Sep 6 05:14:58 2003 EDT
Added files:
/phpweb/include errors.inc
Modified files:
/phpweb error.php
Log:
Move the error functions out to an include file,
so we can reuse them if needed
Index: phpweb/error.php
diff -u phpweb/error.php:1.9 phpweb/error.php:1.10
--- phpweb/error.php:1.9 Sat Sep 6 04:51:10 2003
+++ phpweb/error.php Sat Sep 6 05:14:58 2003
@@ -1,6 +1,6 @@
<?php
-// $Id: error.php,v 1.9 2003/09/06 08:51:10 goba Exp $
+// $Id: error.php,v 1.10 2003/09/06 09:14:58 goba Exp $
/*
@@ -15,6 +15,7 @@
// Ensure that our environment is set up
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/prepend.inc';
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/loadavg.inc';
+include_once $_SERVER['DOCUMENT_ROOT'] . '/include/errors.inc';
// Get URI for this request (without the leading slash, and
// without any query string attached)
@@ -25,7 +26,7 @@
// ============================================================================
// For images, display a 404 automatically (no redirect)
-if (preg_match("!\\.(pdf|gif|jpg|png)$!i", $URI)) { make404(); }
+if (preg_match("!\\.(pdf|gif|jpg|png)$!i", $URI)) { error_404(); }
// ============================================================================
// BC: handle .php3 files that were renamed to .php
@@ -234,7 +235,7 @@
// ============================================================================
// 404 page for manual pages (eg. not built language)
if (strpos($URI, "manual/") === 0) {
- manual404();
+ error_404_manual();
}
// ============================================================================
@@ -246,50 +247,4 @@
'&pattern=' . urlencode(substr($_SERVER['REQUEST_URI'], 1))
);
-// A 'good looking' 404 error message page
-function make404()
-{
- global $_SERVER;
- status_header(404);
- site_header('404 Not Found', array("noindex"));
- echo "<h1>Not Found</h1>\n" .
- "<p><strong>" . htmlspecialchars($_SERVER['REQUEST_URI'])
.
- "</strong> not found on this server.</p>\n";
- site_footer();
- exit;
-}
-
-// A 'good looking' 404 error message page for manual pages
-function manual404()
-{
- global $_SERVER;
- status_header(404);
- site_header('404 Not Found', array("noindex"));
- echo "<h1>Not Found</h1>\n" .
- "<p>The manual page you are looking for (<strong>" .
- htmlspecialchars($_SERVER['REQUEST_URI']) .
- "</strong>) is not available on this server right now. " .
- "Please check back later, or if the problem persist, " .
- "<a href=\"/copyright.php#contact\">contact the
webmasters</a>.</p>\n";
- site_footer();
- exit;
-}
-
-// Send out a proper status header
-function status_header($num)
-{
- // Set status text
- switch ($num) {
- case 404: $status = "Not Found"; break;
- case 200: $status = "OK"; break;
- default: return FALSE;
- }
-
- // BC code for PHP < 4.3.0
- @header("HTTP/1.1 $num $status");
- @header("Status: $num $status", TRUE, $num);
-
- return TRUE;
-}
-
-?>
+?>
\ No newline at end of file
Index: phpweb/include/errors.inc
+++ phpweb/include/errors.inc
<?php
// $Id: errors.inc,v 1.1 2003/09/06 09:14:58 goba Exp $
/*
This script provides functions to print out
error messages for users in case something is
not available.
*/
// A 'good looking' 404 error message page
function error_404()
{
status_header(404);
site_header('404 Not Found', array("noindex"));
echo "<h1>Not Found</h1>\n" .
"<p><strong>" . htmlspecialchars($_SERVER['REQUEST_URI']) .
"</strong> not found on this server.</p>\n";
site_footer();
exit;
}
// A 'good looking' 404 error message page for manual pages
function error_404_manual()
{
status_header(404);
site_header('404 Not Found', array("noindex"));
echo "<h1>Not Found</h1>\n" .
"<p>The manual page you are looking for (<strong>" .
htmlspecialchars($_SERVER['REQUEST_URI']) .
"</strong>) is not available on this server right now. " .
"Please check back later, or if the problem persist, " .
"<a href=\"/copyright.php#contact\">contact the
webmasters</a>.</p>\n";
site_footer();
exit;
}
// This service is not working right now
function error_noservice()
{
site_header('Service not working', array("noindex"));
echo "<h1>Service not working</h1>\n" .
"<p>The service you tried to access with the URL: <strong>" .
htmlspecialchars($_SERVER['REQUEST_URI']) .
"</strong> is not available on this server right now. " .
"Please check back later, or if the problem persist, " .
"<a href=\"/copyright.php#contact\">contact the
webmasters</a>.</p>\n";
site_footer();
exit;
}
// Send out a proper status header
function status_header($num)
{
// Set status text
switch ($num) {
case 404: $status = "Not Found"; break;
case 200: $status = "OK"; break;
default: return FALSE;
}
// BC code for PHP < 4.3.0
@header("HTTP/1.1 $num $status");
@header("Status: $num $status", TRUE, $num);
return TRUE;
}