ขณะนี้ online : $gap = 60; // 60 seconds
$t = $_SERVER["REMOTE_ADDR"].",".time()."\n";
$f = "userfiles/useronline/countuser.txt";
$c = 0;
$new = 1; // ตั้งไว้ก่อนว่าเป็นคนใหม่
if (file_exists($f)) {
$fr=file($f);
$fw=fopen ($f,"w");
foreach ($fr as $value) {
$ft = split(",",$value);
if ($ft[0] == $_SERVER["REMOTE_ADDR"]) {
fputs ($fw,$_SERVER["REMOTE_ADDR"].",".time()."\n");
$c = $c + 1;
$new = 0;
} else {
if ((time() - $gap) < $ft[1]) {
fputs ($fw,$value);
$c = $c + 1;
}
}
}
if ($new == 1) {
fputs ($fw,$t);
$c = $c + 1;
}
echo $c;
fclose ($fw);
} else {
$fw=fopen ($f,"w");
fputs ($fw,$t);
fclose ($fw);
echo "1";
}
?> คน
$t = $_SERVER["REMOTE_ADDR"].",".time()."\n";
$f = "userfiles/useronline/countuser.txt";
$c = 0;
$new = 1; // ตั้งไว้ก่อนว่าเป็นคนใหม่
if (file_exists($f)) {
$fr=file($f);
$fw=fopen ($f,"w");
foreach ($fr as $value) {
$ft = split(",",$value);
if ($ft[0] == $_SERVER["REMOTE_ADDR"]) {
fputs ($fw,$_SERVER["REMOTE_ADDR"].",".time()."\n");
$c = $c + 1;
$new = 0;
} else {
if ((time() - $gap) < $ft[1]) {
fputs ($fw,$value);
$c = $c + 1;
}
}
}
if ($new == 1) {
fputs ($fw,$t);
$c = $c + 1;
}
echo $c;
fclose ($fw);
} else {
$fw=fopen ($f,"w");
fputs ($fw,$t);
fclose ($fw);
echo "1";
}
?> คน