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

Source: Internet
Author: User
If your user cannot find the page he wants, how can he give him a friendly reply, and you know this error has occurred? let's look at the following program, is used to customize the 404 error page and send notifications to the network management. --- Teaman translate? P if your user cannot find the page he wants, how can he give him a friendly reply and you know 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

# Set $ domain to your domain name (note that no www is available)
$ Domain = 'oso .com.cn ';
# Set the URL. Note that there is no trailing line/
$ 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 = '# ffff ';
# Set text color. the default value is Xuan.
$ Textcolor = '#000000 ';

# Apply the $ reportlevel variable to determine whether to send emails to the network administrator.
#0 = do not send emails. Hey, how can teaman go wrong?
#1 = send a mail only when the page contains your DOMAIN NAME
#2 = send a message even if the connection is disconnected from me. it may be a friendship site.
$ Reportlevel = 2; // This is the safest

$ Emailaddress = 'webmaster @ oso.com.cn '; // sets the email address 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' 404 no page found';
Echo'';
Echo' 404 Sorry, I did not find the page you requested';
Echo'

';
Echo 'Oss network administrator prompts you, the requested page $ docroot $ REQUEST_URI, doesn't exist ';
Echo 'on this server.

';

If ($ reportlevel! = 0)
{
Echo'

';
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;

# 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 ';

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.