Use php to customize the 404 error page and send it to the administrator program

Source: Internet
Author: User
If your user cannot find the page he wants, how can he 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 notifications to the network management. --- Teaman translation arrangement
<? Php
# Set $ domain to your domain name (note that there is no www)
$ Domain = "oso.com.cn ";
# Set the URL. Note that there is no dash/
$ Docroot = "http://www.oso.com.cn ";
# 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 teaman go wrong?
#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@oso.com.cn"; // 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 "osuo network management 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 Osos network administrator .";
}
Return;
}

# EMAIL processing functions
Function send_email ()
{
# Request access to the global variables we need
Global $ REQUEST_URI, $ HTTP_REFERER, $ emailaddress, $ REMOTE_ADDR, $ docroot;
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.