<?php <BR># 设置 $domain 为你的域名 (注意没有www) <BR>$domain = "php.net"; <BR># 设置URL,注意没有后划线 / <BR>$docroot = "http://php.net"; <BR># 设置错误信息的字体 <BR>$fontface = "Verdana"; <BR># 设置404页面的字体大小 <BR>$fontsize = "2"; <BR># 设置404页面的背景颜色,缺省是白色 <BR>$bgcolor = "#ffffff"; <BR># 设置文字颜色,缺省是黑色 <BR>$textcolor = "#000000"; <BR># 使用 $reportlevel 变量来控制是否发信给网管 <BR># 0 = 根本不用发信,嘿,NB的我们怎么会出错呢 <BR># 1 = 只有在页面含有你的DOMAIN NAME时才发信 <BR># 2 = 即使是与我连接出现的断连也发信,有可能是友情站点 <BR>$reportlevel = 2; //这种最保险了 <BR>$emailaddress = "[email protected]"; //设置收错误信息的邮箱 <BR>function print_details() <BR>{ <BR># Request access to the global variables we need <BR>global $fontface, $fontsize, $docroot, $REQUEST_URI, $reportlevel; <BR>global $bgcolor, $textcolor; <BR># Print the 404 error in web format <BR>echo "<title>404 没有找到页面</title>"; <BR>echo "<body bgcolor="$bgcolor" text="$textcolor">"; <BR>echo "<b><h1>404 对不起,我没有找到您要求的页面</h1></b>"; <BR>echo "<p><font face="$fontface" size="$fontsize">"; <BR>echo "oncoding编码营提醒您,您要求的页面 $docroot$REQUEST_URI, doesn't exist"; <BR>echo " on this server.<span style="color:transparent">~来1源gaodai#ma#com搞*代#码1网</span><abbr>搞代gaodaima码</abbr></font></p>"; <BR>if ($reportlevel != 0) <BR>{ <BR>echo "<p><font face="$fontface" size="$fontsize">"; <BR>echo "错误信息已经发送到oncoding编码营管理员信箱."; <BR>} <BR>return; <BR>} <BR># EMAIL处理函数 <BR>function send_email() <BR>{ <BR># Request access to the global variables we need <BR>global $REQUEST_URI, $HTTP_REFERER, $emailaddress, $REMOTE_ADDR, $docroot; <BR># 定制发送的消息,如时间地点等. <BR>$today = getdate(); <BR>$month = $today[mon]; <BR>$mday = $today[mday]; <BR>$year = $today[year]; <BR>$hours = $today[hours]; <BR>$minutes = $today[minutes]; <BR>$errortime = "$month/$mday/$year at $hours:$minutes"; <BR># Create the body of the email message <BR>$message .= "404 Error ReportnnA 404 error was encountered by $REMOTE_ADDR"; <BR>$message .= " on $errortime.nn"; <BR>$message .= "The URI which generated the error is: n$docroot$REQUEST_URInn"; <BR>$message .= "The referring page was:n$HTTP_REFERERnn"; <BR># Send the mail message. This assumes mail() will work on your system! <BR>mail("$emailaddress", "404 Error Report", $message, "From: $emailaddress"); //发送信息 <BR>return; <BR>} <BR># 下面这些是根据变量$reportlevel的设置来发信与否。 <BR>print_details(); <BR># See whether or not we should send an email report. If so, do it. <BR>if ($reportlevel != 0) <BR>if ($reportlevel == 1) { <BR>if (eregi($domain,$HTTP_REFERER)) <BR>send_email(); } <BR>else <BR>send_email(); <BR># All done! <BR>exit; <BR>?> <br><br>