选择显示字体大小

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

如果您的用户找不到他要的页面,如何给他一个友好的答复,并且你也知道发生了这个错误呢,看看下面这段程序,是用来定制404错误页面和发通知给网管的好东西。---teaman翻译整理

<?php
# 设置 &#36;domain 为你的域名 (注意没有www)
&#36;domain = "oso.com.cn";
# 设置url,注意没有后划线 /
&#36;docroot = "http://www.oso.com.cn";
# 设置错误信息的字体
&#36;fontface = "verdana";
# 设置404页面的字体大小
&#36;fontsize = "2";
# 设置404页面的背景颜色,缺省是白色
&#36;bgcolor = "#ffffff";
# 设置文字颜色,缺省是黑色
&#36;textcolor = "#000000";

# 使用 &#36;reportlevel 变量来控制是否发信给网管
# 0 = 根本不用发信,嘿,teaman怎么会出错呢
# 1 = 只有在页面含有你的domain name时才发信
# 2 = 即使是与我连接出现的断连也发信,有可能是友情站点
&#36;reportlevel = 2;  //这种最保险了

&#36;emailaddress = "webmaster@oso.com.cn"; //设置收错误信息的邮箱


function print_details()
  {
   # request access to the global variables we need
   global &#36;fontface, &#36;fontsize, &#36;docroot, &#36;request_uri, &#36;reportlevel;
   global &#36;bgcolor, &#36;textcolor;

   # print the 404 error in web format
   echo "<html><head><title>404 没有找到页面</title></head>";
   echo "<body bgcolor="&#36;bgcolor" text="&#36;textcolor">";
   echo "<b><h1>404 对不起,我没有找到您要求的页面</h1></b>";
   echo "<p><font face="&#36;fontface" size="&#36;fontsize">";
   echo "奥索网管提醒您,您要求的页面 &#36;docroot&#36;request_uri, doesn&#39;t exist";
   echo " on this server.</font></p>";

   if (&#36;reportlevel != 0)
     {
      echo "<p><font face="&#36;fontface" size="&#36;fontsize">";
      echo "错误信息已经发送到奥索网管手中.";    
     }

   return;
  }


# email处理函数  

function send_email()
  {
   # request access to the global variables we need
   global &#36;request_uri, &#36;http_referer, &#36;emailaddress, &#36;remote_addr, &#36;docroot;

   # 定制发送的消息,如时间地点等.
   &#36;today = getdate();  
   &#36;month = &#36;today[mon];  
   &#36;mday = &#36;today[mday];  
   &#36;year = &#36;today[year];  
   &#36;hours = &#36;today[hours];
   &#36;minutes = &#36;today[minutes];
   &#36;errortime = "&#36;month/&#36;mday/&#36;year at &#36;hours:&#36;minutes";  

   # create the body of the email message
   &#36;message .= "404 error reportnna 404 error was encountered by &#36;remote_addr";
   &#36;message .= " on &#36;errortime.nn";
   &#36;message .= "the uri which generated the error is: n&#36;docroot&#36;request_urinn";
   &#36;message .= "the referring page was:n&#36;http_referernn";

   # send the mail message. this assumes mail() will work on your system!
   mail("&#36;emailaddress", "404 error report", &#36;message, "from: &#36;emailaddress");  //好,把信发出去
    
   return;
  }


# 下面这些是根据变量&#36;reportlevel的设置来发信与否。
print_details();

# see whether or not we should send an email report. if so, do it.
if (&#36;reportlevel != 0)                   
  if (&#36;reportlevel == 1) {               
    if (eregi(&#36;domain,&#36;http_referer))    
      send_email(); }
  else
     send_email();                        

# all done!
exit;

?>


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons