sub template { my $gzaccept= $ENV{'HTTP_ACCEPT_ENCODING'}=~/\bgzip\b/ || $gzforce; ### Start Today Counter $Cdate = $ENV{'HTTP_COOKIE'}; # Get the Cookie $Cdate =~ /Cdate=([^;]*)/; $Cdate = $1; if ($maintenance ne '1'){ Maintenance Mode ? 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); fopen(DATA,"<$vardir/datet.txt"); ###### Open day $tdate = ; fclose (DATA); chomp $tdate; if ($tdate ne $mday) { # find if new day if ($mday eq '01') { # This Month Counter... zero count $thismonth = 0; } fopen(DATA,">$vardir/datet.txt"); @Now = "$mday"; print DATA "@Now\n"; fclose (DATA); $yesterdaycount = $thecount; if ($highestdaycount < $thecount) { $highestdaycount = $thecount; } $thecount = 0; fopen (wrecord, ">$vardir/IPlist.txt"); # Reset IP list file $host = "$mday"; print wrecord "$host\n"; fclose (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 <= 550; $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"); # Save IP list for over 500 visitors 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 by apppend 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 } # no $maintenance mode... # End TodayCounter ################### if ($gzcomp && $gzaccept) { if($yySetCookies1 || $yySetCookies2) { print header(-cookie=>[$yySetCookies1, $yySetCookies2, $yySetCdate] , 'Content-Encoding' => 'gzip', -charset=>$yycharset ); } else { print header(-status=>'200 OK', -cookie=>[$yySetCdate] , 'Content-Encoding' => 'gzip', -charset=>$yycharset ); } } else { if($yySetCookies1 || $yySetCookies2) { print header(-status=>"200 OK", -cookie=>[$yySetCookies1, $yySetCookies2, $yySetCdate], -charset=>$yycharset); } else { print header(-status=>"200 OK", -cookie=>[$yySetCdate], -charset=>$yycharset); } }