|
2008-05-09
, 22:09
|
|
Posts: 880 |
Thanked: 264 times |
Joined on Feb 2007
@ Cambridge, UK
|
#12
|
#!/usr/bin/perl -w use strict; use CGI qw(:standard); my $TIMEOUT = 20; my @IMAGEDIRS = ('/xxxx', '/yyyy'); # FIXME #### check the function my $p_function = defined(param('function')) ? param('function') : ''; my $p_device = defined(param('device')) ? param('device') : ''; if ($p_function eq 'picture') { chdir $IMAGEDIRS[rand($#IMAGEDIRS)];; # FIXME according to your image directories my @sub1Dirs = <*>; my $sub1Dir = ''; while ($sub1Dir !~ /^\d+\d+\d+\d+$/) { $sub1Dir = @sub1Dirs[rand($#sub1Dirs)]; } chdir $sub1Dir; my @sub2Dirs = <*>; my $sub2Dir = @sub2Dirs[rand($#sub2Dirs)]; chdir $sub2Dir; my @pictures = <*.jpg>; my $picture = @pictures[rand($#pictures)]; #if (0) if (open(FH, "<$picture")) { print "Content-type: image/jpeg\n\n"; while (<FH>) { print $_; } close(FH); print "\n"; } else { print "Content-type: text/plain\n\nERROR!\n"; print "sub1Dirs list is " . join (', ', @sub1Dirs) . "\n"; print "sub1Dir chosen was $sub1Dir\n"; print "sub2Dirs list is " . join (', ', @sub2Dirs) . "\n"; print "sub2Dir chosen was $sub2Dir\n"; print "picture list is " . join (', ', @pictures) . "\n"; print "picture file name is '$picture' \n"; } } else { print "Content-type: text/html\n\n"; print "<html><head>\n<meta http-equiv=\"refresh\" content=\"$TIMEOUT\">"; #print `date` . "<br />\n"; print "<img src=\"?function=picture\""; if ($p_device eq 'tablet') { print " width=\"800\" height=\"480\" "; } print "/>"; print "</body>\n</html>\n"; }
|
2008-05-09
, 22:53
|
|
Posts: 880 |
Thanked: 264 times |
Joined on Feb 2007
@ Cambridge, UK
|
#13
|
The Following User Says Thank You to speculatrix For This Useful Post: | ||
|
2008-05-10
, 06:15
|
Posts: 7 |
Thanked: 2 times |
Joined on May 2008
@ Toronto
|
#14
|
Hmm, I like that idea, might have a hack at it myself!