#!/usr/local/bin/perl # # counter cgi # © 2000 Jackie Hamilton - http://www.cgi101.com/ # # this cgi increments a counter in a file, then returns a gif image. # (use either a small, 1-pixel "invisible" image, or your logo or something.) # HTML code to call this: # # # # this is good for use as a "hidden" counter within a page. # # note: be sure that the counter file is set WRITABLE by the httpd # daemon owner or group. in Unix you'll need to 'chmod 775 countfile' # or possibly 'chmod 777 countfile'. $countfile = "cgicount"; $giffile = "small.gif"; $count = `cat $countfile`; chop($count); $count = $count + 1; open(INF,">$countfile"); print INF "$count\n"; close(INF); # if you're using a JPEG instead of a GIF, you should change this # line to print type image/jpg. print "Content-type:image/gif\n\n"; @gifdata = `cat $giffile`; print @gifdata; # the end.