package Shell;
use strict;
$SIG{__DIE__} = \&catch_die;


sub catch_die {
    my $error=shift;
    my $LBPATH;
    my $pgm = $0;
    $pgm =~s/\\/\//g;
    $pgm =~s/^.*\/([^\/]+)$/$1/g;
    foreach ($0, $ENV{'SCRIPT_FILENAME'}, $ENV{'PATH_TRANSLATED'}) {
            s!\\!/!g; s/^(.*)\/[^\/]+$/$1/g;
            if (-e $_ . '/' .$pgm) { $LBPATH = $_; last; }
     }
    $error=~s!\\!/!g;
    $error =~ s!$ENV{'DOCUMENT_ROOT'}!/<b>你的WEB绝对路径</b>!i;
    $error =~ s!$LBPATH!/<b>你的脚本绝对路径</b>!i;
    my ($msg, $path) = split " at ",$error;
    print "content-type:text/html;charset=gb2312\n\n";
    print qq~
    <html>
    <head><title>雷傲论坛CGI运行错误!</title></head>
    <body bgcolor='#FFFFFF'>
    <font face='Arial' size='5' color='#333366'>LeoBoard CGI Error !</font>
    <hr size='1' color='#000000' noshade>
    <font face='Arial' size='3' color='#00000'>
    雷傲论坛程序已经正常退出,因为遇到了如下错误:
    <br><br><b>$msg</b><br><br>此错误发生在以下位置: <font color='#000099' face='Arial'>$path</font>
    <br><br><font size='3' color='#990000'><b>请注意,为了你的网站安全,你的绝对路径已经被隐藏.</b></font>
    </font>
     <br><br><hr size='1' color='#000000' noshade>
    <table width=80% align=center cellpadding=0 cellspacing=0 border=0><tr><td align=center><font color=#000000>&copy; 中文版权所有： <a href=http://www.cgier.com>CGI 编程者之家</a>　 版本： <a href="http://www.leoboard.com/download.htm">$LB::VERSION</a></font></td></tr></table>
	</body>
    </html>
    ~;
    close(STDOUT);
    exit;
} 


1;
