#!/usr/local/bin/perl # please enter full path to directory on your server # where you keep random files on the line below # Please, note if you are using virtual server absolute paths # may/will likely be different with the paths from your main (your "root") # directory. Please, ask your provider what absolute paths you should use. # You can also telnet to your account and on the command line type: # pwd # The output will tell you absolute path to the directory you are in. # Example: # $root="/mnt/web/guide/musicstores/random"; # For Windows NT server substitute \ with \\ in path # e.g. $root="c:\\html\\random"; $root="./img"; print "Content-type: text/html\n\n"; opendir (DIR, $root); while ($file=readdir(DIR)) { if (($file !~ /^\./) && (!(-d "$root/$file"))) { push (@files, $file); } } closedir(DIR); srand(); $number=@files; $number=rand($number); $number=int($number); $file="$root/$files[$number]"; #print "number is $number, file is $file
"; unless (open(FILE, $file)) { print "Cannot open file $file"; exit; } print ();