#!/usr/sbin/perl ###### Set the cgi to return a gif ###### print "Pragma: no-cache\n"; print "Cache-control: no-cache\n"; print "Expires: Fri, 12 May 1996 14:35:02 EST\n"; print "Content-type: image/gif\n\n"; ###### Take in the IP and Hostname ###### $ipreal = $ENV{'REMOTE_ADDR'}; $hostnamereal = $ENV{'REMOTE_HOST'}; ###### Vars needed later ################ $found = 0; ### Used in checking IP # ###### Open the tmpo file for writing ### open ( TMP, ">worthless.log"); ###### Open the hits file to read hits ## open ( FILE, " ) { chop; ###### Splits the line into 2 varibles ## ###### on the left the IP and Hostname ## ###### on the right the number of hits ## ($IPandHOST,$hits) = split(/,/, $_); ###### Splits IP and Hostname into ###### ###### seperate varibles $IP + $host #### ($IP,$host) = split(/\|/, $IPandHOST); ###### If you have been to the page ##### ###### before or at least you IP ######## if ($IP eq $ipreal) { $hits++; print TMP "$IPandHOST,$hits\n"; $found = 1; } ###### Else ############################# else { print TMP "$IPandHOST,$hits\n"; } ###### End the reading of the file ###### } ###### Close the hits file for reading ## close FILE; ###### If you have not visited the page # ###### before do this ################### if ($found == 0) { print TMP "$ipreal\|$hostnamereal,1\n"; } ###### Close the worthless file for ##### ###### Writing ########################## close TMP; ####### Run the image to routine ######## open (IMG, " ) { print $_; } close IMG; ###### Copy the worthless file to the ### ###### hits file ######################## system "cp worthless.log hits.log";