#!/usr/local/bin/perl # # Checks the client's IP address, and returns either a random image # or a specific image for the current month. This allows a randomly # changing image on the U of S home page for most people, and a # less frequently changing image for people using the (slower) # campus dialups. # # Monthly images are, eg. January.gif, February.gif, ... December.gif # # Written by Earl Fogel, May 1997 # Configuration $DocumentRoot = "/www"; $ServerURL = "http://$ENV{'HTTP_HOST'}"; $Directory = "/images/mainpage"; # this is the default @slowhosts = ("192.139.76.", "198.169.16."); # Directory may be passed in as extra path info if you are very trusting # $Directory = $ENV{'PATH_INFO'} if $ENV{'PATH_INFO'} =~ /./; foreach $ip (@slowhosts) { $ip =~ s/\./\\\./; $slow = 1 if $ENV{'REMOTE_ADDR'} =~ /^$ip/; } if ($slow) { @months = ( "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); ($sec,$min,$hour,$mday,$mon,$year) = localtime(time); $newURL = "$ServerURL$Directory/$months[$mon].gif"; } else { chdir "$DocumentRoot/$Directory" || chdir "$Directory" || die("Can't cd to $Directory: $!\n"); srand; # seed the random number generator @pool = <*.gif>; # list of gif files in $Directory $pick = int rand $#pool+1; # pick a random number $file = $pool[$pick]; # file corresponding to that number $newURL = "$Directory/$file"; $newURL =~ s#//#/#g; $newURL =~ "$ServerURL$Directory/$file"; } print "Status: 302\n"; print "Location: $newURL\n\n";