Viewing not_found.cgi

#!/bin/sh

# Set up the URL to look pretty
# Define the method and default port.  If we're on SSL then they're different

METHOD=http
[ -n "$HTTPS" ] && {
    METHOD=https
}

# 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.

SERVER=$SERVER_NAME
[ -n "$HTTP_HOST" ] && SERVER=$HTTP_HOST
case $SERVER in
*:*) ;;
*) SERVER="$SERVER"
esac

# Finally write the requested URL.

URL=`echo "$METHOD://$SERVER$REDIRECT_URL" | \
	sed -e 's/\&/\&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g'`

# If a Referer: header field is sent, then let them know how they got
# here.  Otherwise give a more generic error message

if [ -n "$HTTP_REFERER" ]; then
    HTTP_REFERER=`echo $HTTP_REFERER | \
	sed -e 's/\&/\&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g'`
    REFERER="
You reached this URL from a link on <a href=\"$HTTP_REFERER\">$HTTP_REFERER</a>.
    "
else
    REFERER="
Please check the URL and try again, or if you came to this page via a
link, please inform the maintainer of that page.
"
fi

# Finally return information to the client

TMP=${SERVER_TMPDIR-/tmp}/webinfo-error$$.html

cat - <<EOS >$TMP
<!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>URL Not Found</title>
<link rel="stylesheet" href="/webinfo/webinfo.css" type="text/css"/>
</head>

<body>
<h1>URL Not Found</h1>
<!--chtml include "//webinfo/incs/navbar.inc"-->
The URL you were trying to view, <kbd>$URL</kbd>, was not found or is no
longer here.  $REFERER
<!--chtml include "//webinfo/incs/footer.inc"-->
</body>
</html>
EOS

touch -r $0 $TMP >/dev/null 2>&1

exec /www/lib/chtml-postproc -r -d `pwd` $TMP

exit 0