talevtehnology
Registered
Здравейте на всички,
проблема е следния колкото и човека да има на линия ,все показва 1 и не мога да разбера къде е грешката :?
ето го и php -то
<?php
// Store user IP address.
$remote = $_SERVER["REMOTE_ADDR"];
// File name.
$file = "usersonline.txt";
//How long the user stays on, before classed offline [in seconds]
$timeoutseconds = 600;
// Current time.
$timestamp = time();
$timeout = ($timestamp-$timeoutseconds);
// Open file.
$fp = fopen("$file", "a+");
$write = $remote ."||". $timestamp;
// Save new data in file.
fwrite($fp, $write);
// Close file.
fclose($fp);
// See how much users online.
$online_array = array();
$file_array = file($file);
foreach($file_array as $newdata)
{
list($ip, $time) = explode("||", $newdata);
if($time >= $timeout)
{
array_push($online_array, $ip);
}
}
$online_array = array_unique($online_array);
$online = count($online_array);
echo 'Users Online:' .$online;
?>
проблема е следния колкото и човека да има на линия ,все показва 1 и не мога да разбера къде е грешката :?
ето го и php -то
<?php
// Store user IP address.
$remote = $_SERVER["REMOTE_ADDR"];
// File name.
$file = "usersonline.txt";
//How long the user stays on, before classed offline [in seconds]
$timeoutseconds = 600;
// Current time.
$timestamp = time();
$timeout = ($timestamp-$timeoutseconds);
// Open file.
$fp = fopen("$file", "a+");
$write = $remote ."||". $timestamp;
// Save new data in file.
fwrite($fp, $write);
// Close file.
fclose($fp);
// See how much users online.
$online_array = array();
$file_array = file($file);
foreach($file_array as $newdata)
{
list($ip, $time) = explode("||", $newdata);
if($time >= $timeout)
{
array_push($online_array, $ip);
}
}
$online_array = array_unique($online_array);
$online = count($online_array);
echo 'Users Online:' .$online;
?>