免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 911 | 回复: 0
打印 上一主题 下一主题

用php定制404错误页面,并发信给管理员的程序 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-02-11 22:20 |只看该作者 |倒序浏览
如果您的用户找不到他要的页面,如何给他一个友好的答复,并且你也知道发生了这个错误呢,看看下面这段程序,是用来定制404错误页面和发通知给网管的好东西。---teaman翻译整理
404 没有找到页面";
   echo "";
   echo "404 对不起,我没有找到您要求的页面";
   echo "";
   echo "奥索网管提醒您,您要求的页面 $docroot$REQUEST_URI, doesn't exist";
   echo " on this server.";
   if ($reportlevel != 0)
     {
      echo "";
      echo "错误信息已经发送到奥索网管手中.";   
     }
   return;
  }
# EMAIL处理函数  
function send_email()
  {
   # Request access to the global variables we need
   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";  
   # Create the body of the email message
   $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";
   # Send the mail message. This assumes mail() will work on your system!
   mail("$emailaddress", "404 Error Report", $message, "From: $emailaddress");  //好,把信发出去
   
   return;
  }
# 下面这些是根据变量$reportlevel的设置来发信与否。
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;
?>


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/13830/showart_73629.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP