網(wǎng)站當(dāng)前的在線人數(shù)
發(fā)表時(shí)間:2024-05-23 來(lái)源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]這是我的多用戶統(tǒng)計(jì)的在線統(tǒng)計(jì)部分 gb_temp表: temp1 用戶ID temp2 流覽IP地址 temp3 online//做了個(gè)標(biāo)記,因?yàn)槠渌δ芤惨褂眠@個(gè)表 temp4 登陸時(shí)間 onlinetime最長(zhǎng)離線時(shí)間分鐘 db_class是我定義的一個(gè)數(shù)據(jù)庫(kù)操作類。 //////////...
這是我的多用戶統(tǒng)計(jì)的在線統(tǒng)計(jì)部分
gb_temp表:
temp1 用戶ID
temp2 流覽IP地址
temp3 online//做了個(gè)標(biāo)記,因?yàn)槠渌δ芤惨褂眠@個(gè)表
temp4 登陸時(shí)間
$onlinetime最長(zhǎng)離線時(shí)間分鐘
db_class是我定義的一個(gè)數(shù)據(jù)庫(kù)操作類。
///////////////////
//在線統(tǒng)計(jì)
$db = new db_class;
$db->connect();
$limit_time = time() - ($onlinetime * 60);
$online_time = time();
$db->query("delete from gb_temp where (temp4<$limit_time or temp2='$ip') and temp1='$id' and temp3='online'"); //刪除離線$onlinetime分鐘的用戶
$db->query("insert into gb_temp (temp1,temp2,temp3,temp4) values ('$id','$ip','online','$online_time')");
$onres = $db->query("select count(*) from gb_temp where temp1='$id' and temp3='online'");
$onlineuser = $db->fetch_array($onres);
$onlineuser = $onlineuser[0];