#!/usr/bin/perl sub thispage () { my $thispage = $ENV{"DOCUMENT_URI"}; # Sometimes, particularly the case of going directly to the script, # DOCUMENT_URI doesn't work: if (! ($thispage =~ /[a-zA-Z0-9]/)) { $thispage = $ENV{"REQUEST_URI"}; } if (! ($thispage =~ /[a-zA-Z0-9]/)) { $thispage = ""; } $thispage =~ s/\/~([a-zA-Z])/$1/; return $thispage; } sub not_a_hitcount () { # Just return a random number. If viewers want to interpret it as a # hitcount, that's none of our business. srand (time); return int (rand (32768)); } sub print_footer () { print "Content-type: text/html\n\n"; my $prefix = "bin/"; my $thispage = &thispage (); # todo: we can count the number of /'s in $thispage and set prefix # according to that. I'll need to look up a Perl builtin or two # first, though; in the meantime, just hardcode the subdirectories: if ($thispage =~ /kfogel\/.*\//) { $prefix = "../bin/"; } if ($thispage =~ /footer\.cgi/) { $prefix = ""; my $sourcefile = "footer.cgi"; print "
\n"; print "
\n\n";
open (SELF, "<$sourcefile") or die "unable to open $sourcefile ($!)";
my $contents = "";
while ( \n";
print " \n";
print " \n";
}
if ($thispage =~ /kfogel\/index\.shtml/) {
# don't print the "Back to ..." message.
}
else {
print "(Back to \n";
print "Karl Fogel's home page.)\n";
print "\n";
print $contents;
print "
\n";
print "
\n";
print "
\n";
}
my $thiscount = ¬_a_hitcount ();
print "";
print "$thiscount";
print "\n";
}
&print_footer ();