#!/usr/local/bin/perl5 # Name: backyard/capture.cgi Author: Joe Smith 04-Jul-98 # Purpose: <!--#exec cgi="./capture.cgi"--> returns <A HREF><IMG SRC></A>. # Purpose: Returns most recent capture file for <A HREF="capture.jpg">. # The latter requires two things be set up on an NCSA-style web server: # ln capture.cgi capture.jpg # echo "AddType application/x-httpd-cgi capture.jpg" >>.bhtaccess # Since the Apache web server does not allow AddType on individual files, # capture.jpg needs to be a symlink to the most recent picture. # # Netscape has this nasty habit of not reloading an image when the file # is updated. Especially when an has WIDTH= and HEIGHT= to # for the image to be displayed at other than full size. A workaround is # to name each capture file uniquely. In this case, capture.cgi is needed # to obtain the name of the most recent capture file. # # Some other sites (such as The Wall of Snap) have a link to # "http://www.inwap.com/backyard/capture.jpg". The web server has been told # to execute this script, which sends the contents of the appropriate file. $dir = "current-hour"; # Place where current image is stored # Note: Relative pathnames work OK with NCSA, Apache, and Sambar web servers. # Not tested with IIS or any other Microsoft web server. open(IN,"$dir/capture.txt"); $_ = ; close(IN); # 07032325.jpg 21019 07/03/98 23:22:19 299 640x480 ($file,$bytes,$date,$time) = split; $alt = "$date $time, " . int(($bytes+1023)/1024) . "K"; $ENV{COUNTER_INFO} = $0; @count = `../../cgi-bin/count-ssi.cgi -fcapture.count`; $count = pop @count; # When invoked as "capture.jpg", return the contents of the JPEG file. # When invoked as "capture.cgi", return a halfsize reference to the JPEG file. if ($0 =~ /jpg$/ or $ENV{QUERY_STRING} =~ /jpg$/) {# "backyard/capture.cgi?.jpg" $| = 1; # Force header to come out before copy() print <; close(IN); # print STDOUT $entire_file; } else { # If invoked as "backyard/capture.cgi" print <$alt
$time $date ($bytes bytes) $count viewing EOM }