網(wǎng)站當(dāng)前的在線人數(shù)
更新時(shí)間:2006年10月09日 00:00:00 作者:
這是我的多用戶統(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ù)庫操作類。
///////////////////
//在線統(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];
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ù)庫操作類。
///////////////////
//在線統(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];
相關(guān)文章
php+mysql 實(shí)現(xiàn)身份驗(yàn)證代碼
form php mysql實(shí)現(xiàn)身份驗(yàn)證2010-03-03