Viewing server_error.cgi

#!/usr/local/bin/perl5

require 5;

use strict;

# Set up the URL to look pretty

my $method = $ENV{'HTTPS'} ? 'https' : 'http';

# Get the name of the server.  If a HTTP/1.1 Host: field is there, use
# that.  Otherwise, use the generated name of this server.

my $server = $ENV{'HTTP_HOST'} || $ENV{'SERVER_NAME'};

# Finally write the requested URL.

my $url = "$method://$server" . $ENV{'REDIRECT_URL'};
$url =~ s/\&/\&/g;
$url =~ s/</\&lt;/g;
$url =~ s/>/\&gt;/g;

my $reason = 'A server error ocurred';
my $sreason = $ENV{'REDIRECT_ERROR_NOTES'};
if ($sreason) {
    $reason .= ": $sreason";
    $reason .= '.' unless $sreason =~ /\.$/;
} else {
    $reason .= '.';
}

# Finally return information to the client

my $tmp = ($ENV{'SERVER_TMPDIR'} || '/tmp') . "/webinfo-error$$.html";
exit 1 unless open TMP, ">$tmp";
print TMP <<"EOS";
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--chtml include "//webinfo/incs/header.inc"-->
<head>
<title>Server Error</title>
<link rel="stylesheet" href="/webinfo/webinfo.css" type="text/css"/>
</head>

<body>
<h1>Server Error</h1>
<!--chtml include "//webinfo/incs/navbar.inc"-->

$reason 
Please let
<a href="/webinfo/www-mgmt.html">www-mgmt</a>
know when the error occurred and the URL you were trying to access.
<!--chtml include "//webinfo/incs/footer.inc"-->
</body>
</html>
EOS

close TMP;

my $pwd = `pwd`;
chomp $pwd;
exit 0 unless exec "/www/lib/chtml-postproc -r -d $pwd $tmp";