this took a couple minutes to write...I tested it on my pc so it looks like it should work for you.
save the following to a file called 'users.cgi'. chmod the file to 755.
Code:
#!/usr/local/bin/perl
use strict;
my $log = '/home/camelsoup/www/cgi-bin/data';
my $ip = $ENV{REMOTE_ADDR};
my $now = time();
my %ip;
my $count = 1;
open (LOG, "$log/log.db") or die("Could not open log file for reading: $!");
open (TEMP, ">$log/temp.db") or die("Couldn't create temp log file: $!");
flock (TEMP, 2);
while (<LOG>) {
chomp;
my @data = split /\|/, $_;
(($now - $data[1] > 600) or ($ip eq $data[0]) or (exists $ip{$data[0]})) and next;
$ip{$data[0]} = 1;
$count++;
print TEMP join("|", @data), "\n";
}
print TEMP join("|", ($ip, $now)), "\n";
close (TEMP);
close (LOG);
rename ("$log/temp.db", "$log/log.db");
print "Content-type: text/html\n\n";
print $count;
Create a file named 'log.db' and chmod it to 666. Put the full path (not including the file name), in the $log variable.
Then you can use an exec-cgi SSI call or similar in your home page.
It will count the number of unique IP's that have visited the page within the last 10 minutes (note the "600" in the code above is 60 seconds * 10 minutes).
Happy coding,
--Drew
http://www.camelsoup.com
ftp://ftp.camelsoup.com