If the user who is visiting your site temporarily appears unable to access the page for a variety of reasons, how to give him a friendly reply, and you know that this error occurred, look at the following procedure, is used to customize the 404 error page and notify the network management.
# set $domain for your domain (note no www)
$domain = "Oncoding.net";
# set URL, note no underline/
$docroot = "Http://oncoding.net";
# Set the font for error messages
$fontface = "Verdana";
# Set the font size of 404 pages
$fontsize = "2";
# Set the background color of the 404 page, the default is white
$bgcolor = "#ffffff";
# set text color, default is black
$textcolor = "#000000";
# Use $reportlevel variables to control whether a letter is sent to the network administrator
# 0 = no letters at all, hey, NB. How could we have gone wrong?
# 1 = Send a letter only if the page contains your domain name
# 2 = Even if it is connected with my connection, also send a letter, there may be a friendship site
$reportlevel = 2; This is the safest.
$emailaddress = "Webmaster@oncoding.net"; Set up mailboxes to receive error messages
function Print_details ()
{
# Request access to the global variables we need
Global $fontface, $fontsize, $docroot, $REQUEST _uri, $reportlevel;
Global $bgcolor, $textcolor;
# Print the 404 error in Web format
echo "echo "<body bgcolor=" $bgcolor "text=" $textcolor ">";
echo "<b>echo "<p><font face=" $fontface "size=" $fontsize ">";
echo "oncoding Code Battalion reminds you that the page you requested $docroot $request_uri, doesn ' t exist";
echo "on this server.</font></p>";
if ($reportlevel!= 0)
{
echo "<p><font face=" $fontface "size=" $fontsize ">";
echo "error message has been sent to the Oncoding Code battalion Administrator mailbox.";
}
Return
}
# Email processing function
function Send_email ()
{
# Request access to the global variables we need
Global $REQUEST _uri, $HTTP _referer, $emailaddress, $REMOTE _addr, $docroot;
# Custom sent messages, such as time and place.
$today = getdate ();
$month = $today [Mon];
$mday = $today [Mday];
$year = $today [year];
$hours = $today [hours];
$minutes = $today [minutes];
$errortime = "$month/$mday/$year at $hours: $minutes";
# Create The body of the email message
$message. = "404 error Reportnna 404 error is encountered by $REMOTE _addr";
$message. = "on $errortime. nn";
$message. = "The URI which generated the error Is:n$docroot$request_urinn";
$message. = "The referring page was:n$http_referernn";
# Send the mail message. This assumes mail () would work on your system!
Mail ("$emailaddress", "404 Error", $message, "from: $emailaddress"); Send a message
Return
}
# Here are the letters or not based on the settings of the variable $reportlevel.
Print_details ();
# Whether or not we should send an email. If so, do it.
if ($reportlevel!= 0)
if ($reportlevel = = 1) {
if (eregi ($domain, $HTTP _referer))
Send_email (); }
Else
Send_email ();
# all done!
Exit
?>