On Tue, 12 Feb 2002 08:24:08 -0800, [EMAIL PROTECTED] (Octavian Rasnita) wrote:

>Hi all,
>I made a counter in Perl and if a visitor refreshes the page, the counter
>increases.
>Can I modify the Perl script so that won't happend?
>Thanks.
>Teddy,

It's not perfect, but some people check the
REMOTE_ADDR and store it temporarily.
This is from 
 YAC 0.6.3 (Yet Another Counter) - a web counter and logger

The counter isn't incremented if the
REMOTE_ADDR is listed in the temp list.

something like this code fragment:

my $IP = $ENV{'REMOTE_ADDR'};

# check if a new visit
open(LATEST, "+< $latest_file") or die "Cannot open file";
flock(LATEST,LOCK_EX);
while (<LATEST>) {
  (my $ip_new, my $time_new) = split(/ /, $_);
  chop $time_new if $time_new =~ /\n$/;
  $latest{$ip_new} = $time_new;
}

then

# check if the current IP is in the list
if (%latest) {
  if ($latest{$IP}) {
    $new_visit = 0;
  }





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to