手机
当前位置:查字典教程网 >编程开发 >php教程 >php实现的在线人员函数库
php实现的在线人员函数库
摘要://增加用户functionAddUser($username){global$db;$Ip=getenv('REMOTE_ADDR');$...

//增加用户

functionAddUser($username){

global$db;

$Ip=getenv('REMOTE_ADDR');

$Ip1=getenv('HTTP_X_FORWARDED_FOR');

if(($Ip1!="")&&($Ip1!="unknown"))$Ip=$Ip1;

$current_time=date("Y-m-dH:i:s");

$SQL="selectuserfromclass_onlinewhereuser='$username'";

$res=mysql_query($SQL,$db);

$row=@mysql_num_rows($res);

if($row==0){

$SQL="insertintoclass_online(user,ip,lasttime)values('$username','$Ip','$current_time')";

mysql_query($SQL,$db);

}

}

//更新在线用户名单

functionUpdateMember(){

global$db;

$SQL="deletefromclass_onlinewhereUNIX_TIMESTAMP()-UNIX_TIMESTAMP(lasttime)>180";//3分钟不活动则退出

//echo$SQL;

mysql_query($SQL,$db);

}

//更新在线状态

functionUpdateOnline($username){

global$db;

$current_time=date("Y-m-dH:i:s");;

$SQL="updateclass_onlinesetlasttime='$current_time'whereuser='$username'";

$res=mysql_query($SQL,$db);

}

//删除用户

functionOutOneUser($user){

global$db;

$SQL="deletefromclass_onlinewhereuser='$user'";

mysql_query($SQL,$db);

returntrue;

}

//检查是否在线

functionCheckUser($user){

global$db;

$SQL="selectuserfromclass_onlinewhereuser='$user'";

$res=mysql_query($SQL,$db);

$row=mysql_num_rows($res);

if($row>0)returntrue;

elsereturnfalse;

}

//取在线名单

functionReadOnlineName(){

global$db;

$SQL="select*fromclass_online";

$res=mysql_query($SQL,$db);

while($row=mysql_fetch_array($res)){

$result[]=$row[user];

}

return$result;

}

//********************在线人员函数库***************end

【php实现的在线人员函数库】相关文章:

用Php实现链结人气统计

php实现的mongodb操作类

php生成随机密码的自定义函数

php简单实现快速排序的方法

php实现文本数据导入SQL SERVER

php实现随机显示图片方法汇总

php实现TCP端口检测的方法

用PHP实现XML备份Mysql数据库

php的计数器程序

php中关于socket的系列函数总结

精品推荐
分类导航