作者dinos (流浪汉)
看板Web_Design
标题Re: [问题] 关於线上人数
时间Sat Jul 12 00:25:29 2003
※ 引述《hanzel (目标澎湖!!^^)》之铭言:
: 程式码可以提供一下吗??谢谢
: 是在线上的人数喔!!
[要显示有多少人那一页.php] =============================
<?php
echo "现在有 ".HowMuchPersons()." 人在线上";
?>
<?php
function HowMuchPersons();
{
$userhost = $REMOTE_ADDR;
$nowtime = date("U");
$fp = fopen("HowMuchPersons.txt","r");
$fo = fopen("HowMuchPersons.tot","w");
while(!feof($fp))
{
$userinfor = fscanf($fp,"%s\t%d\n"); //fscanf() 要 PHP4 以上才有
list($who,$idletime) = $userinfor;
$i++;
if($who!=$userhost && $idletime < $nowtime-3*60*60)
{
$userinfor = printf("%s\t%s\n",$who,$idletime);
fputs($fo,$userinfor);
}
else if($who==$userhost)
{
$userinfor = printf("%s\t%s\n",$who,$nowtime);
fputs($fo,$userinfor);
}
else $i--;
}
fclose($fo);
fclose($fp);
copy("HowMuchPersons.tot","HowMuchPersons.txt");
return $i;
}
?>
--
※ 发信站: 批踢踢实业坊(ptt.csie.ntu.edu.tw)
◆ From: 140.113.158.10