#!/share/bin/perl ############################################################################## # Cliff's Counter Version 1.01 # # Copyright 1998 Shaven Ferret Productions # # Created 6/12/98 Last modified 6/18/98 # # Available at http://www.shavenferret.com/scripts # ############################################################################## # COPYRIGHT NOTICE # # Copyright 1998 Shaven Ferret Productions All Rights Reserved. # # # # This script can be used\modified free of charge as long as you don't # # change this header thing. By using this script you agree to indemnify # # me from any liability that might arise from its use. In simple English, # # if this script somehow makes your computer run amuck and kill the pope, # # it's not my fault. # # # # Redistributing\selling the code for this program without prior written # # consent is expressly forbidden. # ############################################################################## # Enter the path of the log file. This is where you can find the stats # for all your pages. This is also where all the data is kept. $logpath = "/~kfsk/www/count.html"; # If you don't want the number of visits to pop up whenever the counter is # called, delete the next line. $visible = 1; # Enter the minimum number of digits for the counter. If the actual number # is smaller than this, it will add zeros to the front. $pad = 5; ############################################################################## # Congratulations! You've finished defining the variables. If you want to, # # you can continue screwing with the script, but it isn't necessary. # ############################################################################## open (LOG, "$logpath"); @data = ; close(LOG); $url = "$ENV{'DOCUMENT_URI'}:"; $count = 0; $pad = "%.$pad"."d"; open (LOG, ">$logpath"); foreach $line(@data) { if ($line =~ /$url/) { $line =~ /(.*)<\/td>/; $count = $1; $count++; $count = sprintf($pad, $count); print LOG "$url$count\n"; } elsif ($count == 0 && substr($line,0,8) eq "") { $count++; $count = sprintf($pad, $count); print LOG "$url$count\n"; print LOG "$line"; } else { print LOG "$line"; } } close(LOG); if ($visible) { print "Content-type: text/html\n\n"; print "$count"; }