#!/usr/bin/perl #Basic Counter 1.0 #Copyright 2002 Christofer Eriksson # #********************************# #This script is free to use and # #redistribute as long as the # #copyright information remain. # #********************************# # - - - - Edit Below This Line - - - - # # You can edit the logfile and ip logfile names here # This is not necessary $logfile = 'logfile.log'; $iplog = 'ips.log'; # You can change the font and the size of the font # This is not necessary $counter_font = 'verdana'; $counter_size = '2'; # Change $display to 1 to show raw hits # or 0 to display unique hits $display = 1; # - - - - Do NOT Edit Below This Line - - - - # $ip = $ENV{'REMOTE_ADDR'}; #**********************************# # Check to see if the IP is unique # #----------------------------------# # If the IP is unique, save it # #**********************************# open (logfile, "$iplog"); while () { $TheLine = $_; if($TheLine == $ip) { $unique = "FALSE"; last; } else { $unique = "TRUE"; } } close logfile; if ($unique eq "TRUE") { open (logfile, ">> $iplog"); print logfile $ip, "\n"; close logfile; $unique_count = 1; } else { $unique_count = 0; } #*********************************# # Count hits and save them to log # #*********************************# open logfile,"$logfile"; @content = (); close logfile; $hits_content = $content[0]; ($raw_hits, $unique_hits) = split (/\|\|/,$hits_content); $raw_hits = $raw_hits + 1; $unique_hits = $unique_hits + $unique_count; $hits_record = $raw_hits . "\||" . $unique_hits . "\||"; open logfile,"> $logfile"; print logfile $hits_record, "\n"; close logfile; #***********************************# # Displays raw or unique hits # #-----------------------------------# # if $display is 1 then display raw # # if 0 then display uniques, else # # display error msg. # #***********************************# if ($display == 1) { print "$raw_hits"; } elsif ($display == 0) { print "$unique_hits"; } else { print "Error in settings"; }