Copy codeThe Code is as follows:
<? Php
# Set $ domain to your domain name (note that there is no www)
$ Domain = "jb51.net ";
# Set the URL. Note that there is no Dash/
$ Docroot = "http://jb51.net ";
# Set the font of the error message
$ Fontface = "Verdana ";
# Set the font size of the 404 page
$ Fontsize = "2 ";
# Set the background color of the 404 page. The default value is white.
$ Bgcolor = "# ffffff ";
# Set the text color. The default value is black.
$ Textcolor = "#000000 ";
# Use the $ reportlevel variable to control whether to send emails to the network administrator.
#0 = do not send emails at all. Hey, how can we make an error with NB?
#1 = Send a mail only when the page contains your DOMAIN NAME
#2 = even if a disconnected connection occurs with me, it may be a site of friendship.
$ Reportlevel = 2; // This is the safest
$ Emailaddress = "webmaster@jb51.net"; // set the mailbox for receiving 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 Camp reminds you that the requested page $ docroot $ REQUEST_URI, doesn't exist ";
Echo "on this server. </font> </p> ";
If ($ reportlevel! = 0)
{
Echo "<p> <font face =" $ fontface "size =" $ fontsize "> ";
Echo "the error message has been sent to the oncoding camp administrator mailbox .";
}
Return;
}
# EMAIL processing functions
Function send_email ()
{
# Request access to the global variables we need
Global $ REQUEST_URI, $ HTTP_REFERER, $ emailaddress, $ REMOTE_ADDR, $ docroot;
# Customize the sent message, such as the time and location.
$ 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 was 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 () will work on your system!
Mail ("$ emailaddress", "404 Error Report", $ message, "From: $ emailaddress"); // send information
Return;
}
# The following describes whether to send emails based on the $ reportlevel variable.
Print_details ();
# See whether or not we shoshould send an email report. If so, do it.
If ($ reportlevel! = 0)
If ($ reportlevel = 1 ){
If (eregi ($ domain, $ HTTP_REFERER ))
Send_email ();}
Else
Send_email ();
# All done!
Exit;
?>