手机
当前位置:查字典教程网 >编程开发 >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的计数器程序

PHP实现的增强性mhash函数

如何使用PHP中的字符串函数

php实现的mongodb操作类实例

php实现paypal 授权登录

php实现的mongodb操作类

一个用于mysql的数据库抽象层函数库

用PHP实现XML备份Mysql数据库

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

精品推荐
分类导航