• 网络学院
  • IT资讯
  • 操作系统
  • 网络技术
  • 软件应用
  • 办公软件
  • 编程技术
  • 网站架设
  • 数据库类
  • 平面设计
  • 多媒体类
  • 游戏资讯
  • 教学论文
  • 认证考试
CGI教程(11)错误脚本
  站点:
  • 首 页
  • 最新软件
  • 文章教程
  • 国内软件
  • 国外软件
  • 绿色软件
  • 源码下载
  • 字体下载
CGI教程(11)错误脚本
软件发布 CGI教程(11)错误脚本
网络软件 系统工具 应用软件 联络聊天 图形图像 多媒体类 行业软件 游戏娱乐 编程开发 安全相关 教育教学 数码软件 绿软下载
热门软件: QQ 瑞星 pplive e话通 木马克星 千千静听 office2000 五笔字根 Photoshop 视频分割
返回文章教程首页 >> 文章首页 >> 编程技术 >> CGI教程 >> CGI教程(11)错误脚本

CGI教程(11)错误脚本

添加时间: 2006-5-9 4:45:06  作者: CGI教程  阅读次数:70   来源: http://d9soft.com

        错误脚本 额外的环境变量包括CGI 1.1 变量传递给错误脚本。这些CGI 1.1 变量有:

REDIRECT_REQUEST :这是当正确发送给服务器的请求。

REDIRECT_URL :这是导致错误的请求URL。

REDIRECT_STATUS :这是如果NCSA HTTPd 已经允许应答的状态数字和信息。

另外,NCSA HTTPd在err_string=error_message时作为NCSA HTTPd产生的QUERY_STRING错误字符串传递。一些错误信息可以需要一些不在CGI规范中的文件头。基于这个原因,以下给出一个没有解析的文件头的脚本,它是用Perl编写的:

#!/usr/local/bin/perl

# 这是一个利用Perl编写的没有解析文件头的CGI 1.1错误脚本来处理错误请求。

$error = $ENV{'QUERY_STRING'};

$redirect_request = $ENV{'REDIRECT_REQUEST'};

($redirect_method,$request_url,$redirect_protocal) = split(' ',$redirect_request);

$redirect_status = $ENV{'REDIRECT_STATUS'};

if (!defined($redirect_status)) {

$redirect_status = "200 Ok";

}

($redirect_number,$redirect_message) = split(' ',$redirect_status);

$error =~ s/error=//;



$title = "<HEAD><TITLE>".$redirect_status."</TITLE></HEAD>";



if ($redirect_method eq "HEAD") {

$head_only = 1;

} else {

$head_only = 0;

}



printf("%s %s\r\n",$ENV{'SERVER_PROTOCOL'},$redirect_status);

printf("Server: %s\r\n",$ENV{'SERVER_SOFTWARE'});

printf("Content-type: text/html\r\n");



$redirect_status = "<img alt=\"\" src=http://edu.chinaz.com/images/icon.gif>".$redirect_status;

if ($redirect_number == 302) {

if ($error !~ /http:/) {

printf("xLocation: http://%s:%s%s\r\n",

$ENV{'SERVER_NAME'},

$ENV{'SERVER_PORT'},

$error);

if (!$head_only) {

printf("%s\r\n",$title);

printf("<H1>%s</H1>\r\n",$redirect_status);

printf("This document has moved");

printf("<A HREF=\"http://%s:%s%s\">here</A>.\r\n",

$ENV{'SERVER_NAME'},

$ENV{'SERVER_PORT'},

$error);

}

} else {

printf("Location: %s\r\n",$error);

if (!$head_only) {

printf("%s\r\n",$title);

printf("<H1>%s</H1>\r\n",$redirect_status);

printf("This document has moved");

printf("<A HREF=\"%s\">here</A>.\r\n",$error);

}

}

} elsif ($redirect_number == 400) {

printf("\r\n");

if (!$head_only) {

printf("%s\r\n",$title);

printf("<H1>%s</H1>\r\n",$redirect_status);

printf("Your client sent a request that this server didn't");

printf(" understand.<br><b>Reason:</b> %s\r\n",$error);

}

} elsif ($redirect_number == 401) {

printf("WWW-Authenticate: %s\r\n",$error);

printf("\r\n");

if (!$head_only) {

printf("%s\r\n",$title);

printf("<H1>%s</H1>\r\n",$redirect_status);

printf("Browser not authentication-capable or ");

printf("authentication failed.\r\n");

}

} elsif ($redirect_number == 403) {

printf("\r\n");

if (!$head_only) {

printf("%s\r\n",$title);

printf("<H1>%s</H1>\r\n",$redirect_status);

printf("Your client does not have permission to get");

printf("URL:%s from this server.\r\n",$ENV{'REDIRECT_URL'});

}

} elsif ($redirect_number == 404) {

printf("\r\n");

if (!$head_only) {

printf("%s\r\n",$title);

printf("<H1>%s</H1>\r\n",$redirect_status);

printf("The requested URL:<code>%s</code> ",

$ENV{'REDIRECT_URL'});

printf("was not found on this server.\r\n");

}

} elsif ($redirect_number == 500) {

printf("\r\n");

if (!$head_only) {

printf("%s\r\n",$title);

printf("<H1>%s</H1>\r\n",$redirect_status);

printf("The server encountered an internal error or ");

printf("misconfiguration and was unable to complete your ");

printf("request \"<code>%s</code>\"\r\n",$redirect_request);

}

} elsif ($redirect_number == 501) {

printf("\r\n");

if (!$head_only) {

printf("%s\r\n",$title);

printf("<H1>%s</H1>\r\n",$redirect_status);

printf("The server is unable to perform the method ");

printf("<b>%s</b> at this time.",$redirect_method);

}

} else {

printf("\r\n");

if (!$head_only) {

printf("%s\r\n",$title);

printf("<H1>%s</H1>\r\n",$redirect_status);

}

}



if (!$head_only) {

printf("<p>The following might be useful in determining the problem:");

printf("<pre>\r\n");

open(ENV,"env");

while (<ENV>) {

printf("$_");

}

close(ENV);

printf("</pre>\r\n<hr>");

printf("<A HREF=\"http://%s:%s/\"><img alt=\"[Back to Top]\" src=\"/images/back.gif\"> Back to Root of Server</A>\r\n",

$ENV{'SERVER_NAME'},$ENV{'SERVER_PORT'});

printf("<hr><i><a href=\"mailto:webmaster\@%s\">webmaster\@%s</a></i> / ",

$ENV{'SERVER_NAME'},$ENV{'SERVER_NAME'});

printf("<i><a href=\"mailto:httpd\@ncsa.uiuc.edu\">httpd\@ncsa.uiuc.edu</a></i>");

printf("\r\n");

 

上下文章:

 

上一篇文章: CGI教程(12)ErrorDocument 指令 下一篇文章: CGI教程(10)CGI 规范之五

相关文章:

  • PS教程:神奇 用Photoshop让美女走出画框
  • PS教程:看看如何用Photoshop把照片演变成水墨画
  • Photoshop教程:教你如何创出发丝的炫彩莹亮效果
  • 彻底DIY Vista主题制作教程(上)
  • 金山软件7.15毒报:脚本下载器下载远程病毒

相关软件:

  • 极品五笔教程 2007
  • Script Expert 脚本大师 7.2
  • ASP脚本解密工具 V1.0
  • PhotoShop教程系列—鼠绘进阶教程
  • 3DS MAX 7客厅装饰设计教程 EXE格式电子书
  • BIOS设置图解教程 图文并茂讲解BIOS设置 EXE电子书

 

快速导航

  • 网络学院
  • 精品汇聚
  • 字体下载
  • 教程下载
  • ASP源码
  • PHP源码
  • Net源码
  • JSP 源码

编程技术分类导航

  • ASP & ASP.NET教程
  • PHP教程
  • JSP教程
  • C/C++教程
  • VB & VB.NET教程
  • VC教程
  • Delphi教程
  • BCB教程
  • VFP教程
  • PB教程
  • JAVA教程
  • XML教程
  • C#教程
  • CGI教程

本类经典文章推荐

  • CGI教程(1)
  • CGI教程(2)
  • CGI教程(3)
  • CGI教程(4)
  • CGI教程(5)
  • CGI教程(6)
  • CGI教程(7)
  • CGI教程(8)
  • CGI教程(9)
  • CGI教学:第一章 cgilib例

CGI教程阅读排行

  • CGI教程(1)
  • PERL 的 CGI 文件及目录操作
  • CGI教程(2)
  • CGI教程(3)
  • 文件加锁方法——通用锁函数
  • perl实例分析教程之一
  • CGI教程(4)
  • CGI教程(5)
  • CGI教学:第一章 cgilib例
  • CGI教程(7)

编程技术阅读总排行

  • VB入门教程之一
  • Java连接数据库实例
  • 第二章 PowerBuilder 入门之创建新...
  • VC++之List Box/Check List Box控...
  • 第一章 什么是PowerBuilder
  • VC++ List Ctrl控件
  • VC++ Combo Box/Combo Box Ex控件
  • 学C++不得不看的一篇文章
  • VB入门教程之二
  • VC++之Button控件

广告位置

字母检索 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 回到顶部

关于我们 | 版权声明 | 免责条款 | 广告联系 | 软件发布 | 下载帮助 | 下载排行 | 网站地图 | 特别鸣谢 | 友情连接

copyright; 2005-2008 D9soft.com 第九软件网 版权所有