README.
Ian's Log Script
By Ian Porteous
CLICK HERE TO VIEW THE LOG FOR THE SCRIPTS PAGE
******************************************************************************************************* LOG.PL #!/usr/bin/perl ############################## # Ian's Counter / Log script. # ############################## # #################################################################### # Amended by Chris Davis to:- # # change field separator to a ',' thus emulating a *.csv file, # # use 'gethostbyaddr' to try to obtain a little more information # # amending date format to dd/mm/yy rather than mm/dd/yy # # incrementing month value by one to ensure e.g. April recorded as 4 rather than 3 # #################################################################### # # Uses: counts the number of visits to your site. It's called from an IMG tag in ANY HTML # page - so you can use it from any website. # If you make more than one copy of this script - you can place it in different directories # and use them to monitor different sites. # # It also produces a log file which stores the browser type, date, remote host and refferer # so you can emulate the logs produced by the webserver - (which we don't usually get) # We expect you could use a tool like analog to analyse these files, but Ian will be creating a # script to do that soon. # # This script requires 3 extra files. For neatness we use the same directory - in this case withing cgi-bin and called logs # # 1. A .gif file called dummy.gif - please try to keep it small or it'll # slow down the server. # # 2. Counter - this is a text file used to store the hit count - to create it # either upload a blank text file called conter using ftp or from a telnet # session make sure you're in the dir with the scripts and type # # echo "" > counter # # # 3. Access - another text file - this is used to store the logs of visitors # once again, upload a blank one - or do the following # # echo "" > access # # The access, count AND the script files MUST be uploaded as ASCII files. # The gif should be uploaded as binary # # Make sure that you give rw (666) access to the text files # and rwxr-xr-x (755) to the scripts # and ensure the logs directory is 777 rwxrwxrwx # Change this to 0 if you only wish to count visitors $uselog = "1"; # replace "username" with your username $count_file = "/files/home/username/cgi-bin/logs/counter"; $access_log = "/files/home/username/cgi-bin/logs/access"; # opens the image file - reads it and closes it open( IMG, "/files/home/username/cgi-bin/logs/dummy.gif"); $/ = undef; my $img = ; close IMG; # do all the complicated stuff # note next to last line incementing date value by one as January = 0 if ($uselog == 1) { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); if ($sec < 10) { $sec = "0$sec"; } if ($min < 10) { $min = "0$min"; } if ($hour < 10) { $hour = "0$hour"; } if ($mday < 10) { $mday = "0$mday"; } if ($mon < 10) { $monc = "0$mon"; } $mon = $mon+1; $date = "$hour\:$min\:$sec $mday/$mon/$year"; } open(COUNT,"$count_file") || die "Can't Open Count Data File: $!\n"; $count =