# Start TodayCounter ################# $Cdate = $ENV{'HTTP_COOKIE'}; # Get the Cookie $Cdate =~ /Cdate=([^;]*)/; $Cdate = $1; if ($Cdate ne $mday){ # if Cookie is Not set to today ($mday) # The Counter Code is only called if Cookie is not set fopen(counting,"$vardir/counting.txt"); # Open Count File $thecount = ; $yesterdaycount = ; $highestdaycount = ; $highestonline = ; $thismonth = ; $sincestart = ; fclose(counting); open(DATA,"<$vardir/datet.txt"); ###### Open day flock DATA, 2; $tdate = ; close (DATA); chomp $tdate; if ($tdate ne $mday) { # find if new day if ($mday eq '01') { # This Month Counter... zero count $thismonth = 0; } open(DATA,">$vardir/datet.txt"); flock DATA, 2; @Now = "$mday"; print DATA "@Now\n"; close (DATA); $yesterdaycount = $thecount; if ($highestdaycount < $thecount) { $highestdaycount = $thecount; } $thecount = 0; open (wrecord, ">$vardir/IPlist.txt"); # Reset IP list file flock wrecord, 2; $host = "$mday"; print wrecord "$host\n"; close (wrecord); } ########### End check new day $yySetCdate = cookie(-name => "Cdate", -value => "$mday", -path => "/", -expires => "Sunday, 17-Jan-2038 00:00:00 GMT"); if (!$ENV{'REMOTE_HOST'}) { # Get IP $thehost=$ENV{'REMOTE_ADDR'}; } else { $thehost=$ENV{'REMOTE_HOST'}; } fopen (therecord, "<$vardir/IPlist.txt") ; # Check IP for No Cookie Browsers @visitorlist = ; fclose (therecord); $thevisitor2=''; chomp $thehost; $totalIPs='0'; for ($i = 0; $i <= 502; $i++) { $thevisitor = "$visitorlist[$i]"; chomp $thevisitor; if ($thevisitor ne '') { $totalIPs++; } if ($thehost eq $thevisitor){ $thevisitor2=$thehost; } } if ($thehost ne $thevisitor2) { # if Not Last IP INC $thecount if ($totalIPs => '500') { fopen (wtherecord, ">$vardir/IPlist.txt"); for ($i = 1; $i <= $totalIPs; $i++) { print wtherecord "$visitorlist[$i]"; } print wtherecord "$thehost\n"; fclose (wtherecord); }else { fopen (wtherecord, ">>$vardir/IPlist.txt"); # Save Last IP print wtherecord "$thehost\n"; fclose (wtherecord); } $thecount++; $thismonth++; $sincestart++; chomp $thecount; chomp $yesterdaycount; chomp $highestdaycount; chomp $highestonline; chomp $thismonth; chomp $sincestart; fopen (counting, ">$vardir/counting.txt"); print counting "$thecount\n$yesterdaycount\n$highestdaycount\n$highestonline\n$thismonth\n$sincestart\n" ; fclose (counting); } } # End if Cookie is not set # End TodayCounter ###################