I want to put a script on my site that shows how many users are online
on my site. I found one, and that is shown below. It also shows a
log with the IP-addresses of those visitors. Buuut... the counter
always stays on 1...
When I look at the log, every visitor seems to have the same
IP-address. When I look up that address, I see it is from the host of
my webspace.
Can someone offer me a solution?
Thanx,
Bart
<?php
################################################## ######################
# Copyright © 2001 Wanja Hemmerich
#
# First version published April 2001 - This version November 2001
#
################################################## ######################
# COPYRIGHT NOTICE
#
# Copyright 2001 Wanja Hemmerich. All rights reserved.
#
#
#
# This program may be used and modified, as long as this copyright
#
# notice stays intact.
#
#
#
# Wanja Hemmerich is not responsible for damage, which is possibly
#
# caused by his program.
#
#
#
# This program code may not be sold, nor auctioneered, nor be used in
#
# any other commercial way in order to make money.
#
#
#
# This Programm may not be distributed to download neither by
#
# Internet, nor by another medium.
#
################################################## ######################
# By using this programm, you agree with these conditions.
#
#
#
################################################## ######################
# The text above must be kept intact under all circumstances.
#
################################################## ######################
include ("./config.php3");
if (!$datei) $datei = dirname(__FILE__)."/$filename";
$time = @time();
$ip = getenv("REMOTE_ADDR");
$string = "$ip|$time\n";
$a = fopen("$filename", "a+");
fputs($a, $string);
fclose($a);
$timeout = time()-(60*$timer);
$all = "";
$i = 0;
$datei = file($filename);
for ($num = 0; $num < count($datei); $num++) {
$pieces = explode("|",$datei[$num]);
if ($pieces[1] > $timeout) {
$all .= $pieces[0];
$all .= ",";
}
$i++;
}
$all = substr($all,0,strlen($all)-1);
$arraypieces = explode(",",$all);
$useronline = count(array_flip(array_flip($arraypieces)));
// display how many people where activ within $timeout
echo $useronline;
// Delete
$dell = "";
for ($numm = 0; $numm < count($datei); $numm++) {
$tiles = explode("|",$datei[$numm]);
if ($tiles[1] > $timeout) {
$dell .= "$tiles[0]|$tiles[1]";
}
}
if (!$datei) $datei = dirname(__FILE__)."/$filename";
$time = @time();
$ip = getenv("REMOTE_ADDR");
$string = "$dell";
$a = fopen("$filename", "w+");
fputs($a, $string);
fclose($a);
?>