#!/usr/local/bin/perl # **************************************************************** # Program: Perl Animation Routine (animate.pl) # Author: Andrew Cowan # Date: Aug. 23, 1995 # # animate.pl (c) 1995 GlobalMedia Design Inc. # This code is released into the public domain. # **************************************************************** # Overall Concept derived from doit.c by Rob McCool # doit.c (c) 1995 Rob McCool # # Some concepts derived from cycleim.pl by Brian Valente # cycleim.pl (c) 1995 Brian Valente (which is released # into the public domain, so long as this copyright # notice is attached). # **************************************************************** # **************************************************************** # Configuration1 - No Need to Change These # **************************************************************** $ANHEAD="Content-type: multipart/x-mixed-replace;boundary=ThisRandomString\n"; $BOUNDARY="\n--ThisRandomString\n"; $ENDBOUNDS="\n--ThisRandomString--\n"; $GIFTYPE="Content-type: image/gif\n\n"; $JPGTYPE="Content-type: image/jpeg\n\n"; $HTMLTYPE="Content-type: text/html\n\n"; $agent = $ENV{'HTTP_USER_AGENT'}; # **************************************************************** # Configuration2 - These need to be modified for your needs # **************************************************************** $IMAGEDIR = "/home/jesse/www/serverpush/images"; $Continuous = 1; #@images = ("imagea.gif","imagec.gif","imagee.gif","imageg.gif","imagei.gif","imageb.gif","imaged.gif","imagef.gif","imageh.gif","imagej.gif"); @images = ("image1.jpg","image2.jpg","image3.jpg","image4.jpg","image5.jpg"); @sleep_time = (1,1,1,1,1); $TYPE = $JPGTYPE; # **************************************************************** # Main Routine # **************************************************************** undef $/; # Undefine the perl input record seperator. $|= 1; # Force a flush on every print for the specified filehandle (STDOUT). # New browser check routine which excludes Mozilla/1.0 # while allowing Mozilla/2.0 $_ = $agent; #if ((/^Mozilla\/1.[1-9]/i) || (/^Mozilla\/[23].[0-9]/i)){ &animate; #}else{ # &single_image; #} exit(0); # **************************************************************** # Subroutines Declarations Section # **************************************************************** # **************************************************************** # Animate - Routine to display server push animation # **************************************************************** sub animate{ print $ANHEAD; print $BOUNDARY; $count = 0; while(1){ print $TYPE; $image_file = "$IMAGEDIR/$images[$count]"; ($size) = (stat("$image_file"))[7]; open(IFILE, "$image_file"); read(IFILE, $image, $size); close(IFILE); sleep($sleep_time[$count]); print $image; print $BOUNDARY; $count++; if ($count == $#images+1){ if ($Continuous == 0){ last; print $ENDBOUND; }else{ $count = 0; } } } } # **************************************************************** # Single_Image - Routine to display a single image # **************************************************************** sub single_image{ print $TYPE; $image_file = "$IMAGEDIR/$images[$#images]"; ($size) = (stat("$image_file"))[7]; open(TFILE, "$image_file"); read(TFILE, $image, $size); print $image; close(TFILE); } # **************************************************************** # End of Perl Animation Script # ****************************************************************