There are currently
function active_users_text($file, $seperator, $showips = "")
{
//this function returns the number of users active at one time.
//if you would like the function to show the active ips call the function
//like this
// if you don't wanna show the ips, replace true with false or leave the last parameter blank
global $REMOTE_ADDR;
$delay = 300;
$time = time();
$deltime = $time + $delay;
$fp = fopen($file, "r");
while (!feof($fp))
{
$data .= fgets($fp, filesize($file));
if ($data == "")
{
break;
}
}
fclose($fp);
$filedata = str_replace("\r", "", $data);
$lines = explode("\n", $filedata);
$linecnt = count($lines);
for ($i = 0;$i <= $linecnt; $i++)
{
list ($ftime, $fip, $fdeltime) = explode($seperator, $lines[$i]);
if ($time > $fdeltime)
{
$lines[$i] = "";
}
if ($fip == $REMOTE_ADDR)
{
$lines[$i] = "";
}
}
array_push($lines, "$time$seperator$REMOTE_ADDR$seperator$deltime");
$lines = array_unique($lines);
$final = join("\n", $lines);
$to_count = explode("\n", $final);
$cnt = "0";
foreach ($to_count as $lol)
{
if ($lol != "")
{
$cnt++;
}
}
$fp = fopen($file, "w");
fputs($fp, $final);
fclose($fp);
return $cnt;
}
$active = active_users_text("../usersonpage.txt", "::", false);
echo "$active";
?>
readers online
|