#!/usr/bin/perl -w my $documentroot = $ENV{'DOCUMENT_ROOT'} ; $IMAGE_DIRECTORY = "$documentroot/freevancard/random/"; ($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time); ###Nothing below this line should need to be configured.### my $line = ""; my $file1= ""; my $x=0; opendir (DIR,"$IMAGE_DIRECTORY"); while ($fileName = readdir(DIR)) { next if (-d $IMAGE_DIRECTORY . $fileName); next if ($fileName !~ /\w/); # if($fileName =~ /$prefix/i){ $ls[$x] = $fileName; $x+=1; # } } closedir(DIR); srand( ); $file1 = int(rand(@ls)); # print ("Pragma: no-cache\n"); if ($ls[$file1] =~ /\.gif$/i) { print ("Content-type: image/gif\n\n"); } elsif ($ls[$file1] =~ /\.jpg$|\.jpeg$/i) { print ("Content-type: image/jpg\n\n"); } else { #Not a gif or jpeg file. Exit the program. exit(0); } open (INPUT, $IMAGE_DIRECTORY . $ls[$file1]); while ($line = ) { #Print the image out to the browser. print ($line); } close(INPUT); exit(0);