Custom 404 error page, concurrent letter to Administrator's program

Source: Internet
Author: User
Tags mail domain domain name
If your users can't find the page he wants, how to give him a friendly reply, and you know that this error has occurred, look at the following program, is used to customize the 404 error page and send a notice to the network management of good things. ---teaman translation and Finishing

<?php
# set $domain for your domain (note no www)
$domain = "oso.com.cn";
# set URL, note no underline/
$docroot = "http://www.oso.com.cn";
# 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, how did Teaman go 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@oso.com.cn"; 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 "AO cable network management reminds you, you request the page $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 Osso network management.";
}

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"); All right, send the letter.

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

?>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.