如果您的用户找不到他要的页面,如何给他一个友好的答复,并且你也知道发生了这个错误呢,看看下面这段程序,是用来定制404错误页面和发通知给网管的好东西。---teaman翻译整理
<?php
$domain = "oso.com.cn";
$docroot = "http://www.oso.com.cn";
$fontface = "Verdana";
$fontsize = "2";
$bgcolor = "#ffffff";
$textcolor = "#000000";
$reportlevel = 2; //这种最保险了
$emailaddress = "webmaster@oso.com.cn"; //设置收错误信息的邮箱
function print_details()
{
global $fontface, $fontsize, $docroot, $REQUEST_URI, $reportlevel;
global $bgcolor, $textcolor;
echo "
";
echo "奥索网管提醒您,您要求的页面 $docroot$REQUEST_URI, doesn't exist";
echo " on this server.
if ($reportlevel != 0)
{
echo "
";
echo "错误信息已经发送到奥索网管手中.";
}
return;
}
function send_email()
{
global $REQUEST_URI, $HTTP_REFERER, $emailaddress, $REMOTE_ADDR, $docroot;
$today = getdate();
$month = $today[mon];
$mday = $today[mday];
$year = $today[year];
$hours = $today[hours];
$minutes = $today[minutes];
$errortime = "$month/$mday/$year at $hours:$minutes";
$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";
mail("$emailaddress", "404 Error Report", $message, "From: $emailaddress"); //好,把信发出去
return;
}
print_details();
if ($reportlevel != 0)
if ($reportlevel == 1) {
if (eregi($domain,$HTTP_REFERER))
send_email(); }
else
send_email();
exit;
?>