#! /usr/local/bin/perl # # Sample CGI to explain to the user that the URL is blocked and by which rule set # # By Pål Baltzersen 1998 # $QUERY_STRING = $ENV{'QUERY_STRING'}; $DOCUMENT_ROOT = $ENV{'DOCUMENT_ROOT'}; $clientaddr = ""; $clientname = ""; $clientident = ""; $srcclass = ""; $targetclass = ""; $url = ""; $time = time; @day = ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); @month = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); while ($QUERY_STRING =~ /^\&?([^&=]+)=([^&=]*)(.*)/) { $key = $1; $value = $2; $QUERY_STRING = $3; if ($key =~ /^(clientaddr|clientname|clientident|srcclass|targetclass|url)$/) { eval "\$$key = \$value"; } if ($QUERY_STRING =~ /^url=(.*)/) { $url = $1; $QUERY_STRING = ""; } } if ($url =~ /\.(gif|jpg|jpeg|mpg|mpeg|avi|mov)$/i) { print "Content-Type: image/gif\n"; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($time); printf "Expires: %s, %02d-%s-%02d %02d:%02d:%02d GMT\n\n", $day[$wday],$mday,$month[$mon],$year,$hour,$min,$sec; open(GIF, "$DOCUMENT_ROOT/images/blocked.gif"); while () { print; } close(GIF) } else { print "Content-type: text/html\n"; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($time); printf "Expires: %s, %02d-%s-%02d %02d:%02d:%02d GMT\n\n", $day[$wday],$mday,$month[$mon],$year,$hour,$min,$sec; print "\n\n \n 302 Access denied\n \n\n"; print " \n"; if ($srcclass eq "unknown") { print "

\n"; print " \n

\n\n"; print "

Access denied because
this client is not
defined on the proxy

\n\n"; print " \n"; print "
Supplementary info:\n"; print "
Client address=$clientaddr\n"; print "
Client name=$clientname\n"; print "
User ident=$clientident\n"; print "
Client group=$srcclass\n"; print "
\n\n"; print "

If this is wrong, contact
\n"; print " proxymaster\@foo.bar\n"; print "

\n\n"; } elsif ($targetclass eq "in-addr") { print "

\n"; print " \n

\n\n"; print "

IP address URLs
are not allowed
from this client

\n\n"; print " \n"; print "
Supplementary info:\n"; print "
Client address=$clientaddr\n"; print "
Client name=$clientname\n"; print "
User ident=$clientident\n"; print "
Client group=$srcclass\n"; print "
URL=$url\n"; print "
Target class=$targetclass\n"; print "
\n\n"; print "

Contact the webmaster of $url
\n"; print " and ask him to give the webserver a proper domain name\n"; print "

\n\n"; } else { print "

\n"; print " \n

\n\n"; print "

Access denied

\n\n"; print " \n"; print "
Supplementary info:\n"; print "
Client address=$clientaddr\n"; print "
Client name=$clientname\n"; print "
User ident=$clientident\n"; print "
Client group=$srcclass\n"; print "
URL=$url\n"; print "
Target class=$targetclass\n"; print "
\n\n"; print "

If this is wrong, contact
\n"; print " proxymaster\@foo.bar\n"; print "

\n\n"; } print " \n\n\n"; } exit 0;