#!/usr/local/bin/perl

# Print all environment variables to a file that has the user's IP
# address in it. That way we won't confuse the results from different
# users.
if ( $ENV{'PATH_INFO'} ) {
    open(ENVIR,">/home/marcush/public_www/env$ENV{'PATH_INFO'}.txt");
    foreach (sort(keys(%ENV))) {
        print ENVIR "$_ = $ENV{$_}\n";
    };
    close(ENVIR);
};

# Pick one GIF at random from a directory
srand;                          # Seed the random number generator
$imagedir="/home/marcush/public_www/photo/landscapes/images";
@images = <$imagedir/*.gif>;    # Get directory listing of GIF files
$imagetobesent = $images[rand($#images+1)]; # select one image randomly

# Now send it.
undef $/;   # Undefine end-of-record marker (important for binary files)
print "Content-type: image/gif\n\n";
open(IMG,"$imagetobesent");
print <IMG>;
close(IMG);
