PHP:404错误陷阱并email给管理员的程序
# Build the $errortime variable to contain the date/time of the error.
# Using date() likely would have been better, but I already had this code
# elsewhere, and I'm lazy.
$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 Report\n\nA 404 error was encountered by $REMOTE_ADDR";
$message .= " on $errortime.\n\n";
$message .= "The URI which generated the error is: \n$docroot$REQUEST_URI\n\n";
$message .= "The referring page was:\n$HTTP_REFERER\n\n";
# Send the mail message. This assumes mail() will work on your system!
mail("$emailaddress", "404 Error Report", $message, "From: $emailaddress");
return;
}
# Done with function declarations. Main function begins here.
# Send a 404 error to the user's browser
print_details();
# See whether or not we should send an email report. If so, do it.
if ($reportlevel != 0)
if ($reportlevel == 1) {
if (eregi($domain,$HTTP_REFERER))
send_email(); }
else
send_email();
# All done!
exit;
?>
【相关文章:】
PHP读取RSS feed源代码(带注释,可读取多个源)
模拟Google ToolBar直接提交PageRank请求
Apache+php+mysql安装与配置图解(最新版)
Apache与PHP的整合过程
PHP原版HTML编码器溢出问题的解决
用PHPINFO来实现PHP的配置统计过程
新手如何使用PHP创建RSS阅读器
半小时精通PHP正则表达式
PHP网页制作常用的正则表达式
PHP+MYSQL+Javascript数据库查询结果的动态显示
【发表评论】【打印此文】【关闭窗口】【点击数: 】
