#! /usr/local/bin/perl # cgicount.cgi Written by Yo kubota Dec.22.1997. This script is public domain. # constants definition $image = './image/'; # number.gif's directory $counter_file = './counter.txt'; # counter file name #----- Set up above to customize this script ------------; # read counter_file & count_up if neccesary open(COUNT, "+<$counter_file"); # open read & write flock(COUNT, 2); # lock count file $counter = ; if ($ARGV[1] == 1) { # count up ? $counter++; seek COUNT,0,0; # seek to the head of count file print COUNT $counter; } close(COUNT); # close & unlock # send number.gif to browser $number = length($counter) < $ARGV[0] ? 0 : substr($counter, -$ARGV[0], 1); $size = (stat("$image$number.gif"))[7]; # get number.gif size $| = 1; # flush buffer open GIF, "<$image$number.gif"; print "Content-type: image/gif\n"; print "Content-length: $size\n\n"; print ; close GIF;