#!/usr/local/bin/perl
# push.cgi - by David Efflandt - efflandt@xnet.com 9/4/95 [updated 1/2/96]
# For NCSA or Apache server may need to rename 'nph-push.cgi'
# for unbuffered output if pausing between images.
#
# Pushes lettered or numbered gif files (filea.gif, fileb.gif, filec.gif) etc.
# or @list if defined ($path.'1.gif', $path.'2.gif', 'img/other.gif')
#
# See 'pushin.cgi to input imagelist from a file.
# path/[file_prefix] or /full_path_from_root/[file_prefix]
$path = 'img/fire';
# Pause between images (comment out if none)
$pause = 1/2; # fractional seconds allowed unless using sleep instead of select()
# Consecutive letter or number suffix if no @list
$first = 'a';
$last = 'j';
# Comment out (#) or empty @list when using the above
@list = (
#$path.'o.gif',
#$path.'l.gif',
#$path.'r.gif',
#$path.'o.gif',
#'img/homepage.gif',
);
# Make list from suffix if no @list
unless (@list) {
@list = ($first ..$last);
foreach $file (@list) {$file = $path.$file.'.gif';}
}
# Uncomment the following line for 'nph-':
# print "$ENV{'SERVER_PROTOCOL'} 200 OK\n";
# Use last image if not Netscape 1.1 or later (Mosaic 2.0 tested)
$agent = $ENV{'HTTP_USER_AGENT'};
undef($agent) if ($agent =~ /compatible/i); # fake Mozilla
($agent =~ /Mozilla\/(\S*)/) && ($agent = $1);
unless ($agent > 1) {
$file = $list[$#list];
open (IMG, $file) || die "Can't open $file: $!\n";
print "Content-type: image/gif\n";
$len = -s $file;
print "Content-length: $len\n\n";
print
;
close IMG;
exit;
}
# Send images
print "Content-type: multipart/x-mixed-replace;boundary=ThisRandomString\n";
$| = 1; # unbuffered
foreach $file (@list) {
print "\n--ThisRandomString\n";
if ($timeout) {
select(undef,undef,undef,$timeout); # Use sleep instead for DOS|Win
} else {
$timeout = $pause; # after 1st image
}
open (IMG, $file) || die "Can't open $file: $!\n";
print "Content-type: image/gif\n\n";
print
;
close IMG;
}
print "\n--ThisRandomString--\n";