#!/usr/bin/perl ###################################################################### +########## # This script randomly selects a file from a directory of graphics and + returns # that image to an HTML page. The proper method for calling this CGI w +ould be # from an HTML page, using <img src="randomimage.cgi"> # # Copyright 1998 Click Active Media # Code by Chuck Ivy (chuck@clickmedia.com) ###################################################################### +########## $directoryname = "rndimg"; opendir(FILES,$directoryname); @URL = readdir(FILES); &chooseURL; while (($random_URL eq ".") || ($random_URL eq "..")) { &chooseURL; } print "Expires: Wednesday, 27-Dec-95 05:29:10 GMT", "\n"; print "Pragma: no-cache", "\n"; print "Location: $directoryname/$random_URL", "\n\n"; closedir(FILES); sub chooseURL { srand (time | $$); $number_of_URL = $#URL; $random = int (rand ($number_of_URL)); $random_URL = $URL[$random]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Random Image in HTML
by turnstep (Parson) on Apr 25, 2000 at 02:26 UTC | |
by merlyn (Sage) on Apr 26, 2000 at 01:17 UTC | |
by swiftone (Curate) on May 17, 2000 at 23:18 UTC | |
by turnstep (Parson) on May 18, 2000 at 18:26 UTC | |
by brick (Sexton) on May 27, 2000 at 03:07 UTC | |
by brick (Sexton) on Jun 03, 2000 at 06:48 UTC | |
|
RE: Random Image in HTML
by turnstep (Parson) on Apr 25, 2000 at 01:37 UTC |