找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1677|回复: 0
打印 上一主题 下一主题

定制404错误页面,并发信给管理员的程序

[复制链接]

2647

主题

2647

帖子

7881

积分

论坛元老

Rank: 8Rank: 8

积分
7881
跳转到指定楼层
楼主
发表于 2018-2-14 09:41:25 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

            如果您的用户找不到他要的页面,如何给他一个友好的答复,并且你也知道发生了这个错误呢,看看下面这段程序,是用来定制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 $hoursminutes";  
   # 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;
?>
            
            
您可能感兴趣的文章:
  • 定制 404 页面的一些心得
  • 运行asp.net时出现 http错误404-文件或目录未找到
  • php 404错误页面实现代码
  • asp.net 在global中拦截404错误的实现方法
  • asp.net网站的404错误页面的正确设置方法
  • IIS设置404页面图文教程(选择URL还是文件 )
  • php 定义404页面的实现代码
  • 用php来改写404错误页让你的页面更友好
  • flex 开发项目报错之404错误解决方案
            
  • 分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    用户反馈
    客户端