Viewing server_error.cgi


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" "">
<html xmlns="">
<!--chtml include "//webinfo/incs/"-->
<title>Server Error</title>
<link rel="stylesheet" href="/webinfo/webinfo.css" type="text/css"/>

<h1>Server Error</h1>
<!--chtml include "//webinfo/incs/"-->

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/"-->

close TMP;

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