手机
当前位置:查字典教程网 >编程开发 >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+ajax实现无刷新动态加载数据技术

php自定义hash函数实例

利用文件属性结合Session实现在线人数统计

php分页函数

php实现文本数据导入SQL SERVER

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

用PHP实现XML备份Mysql数据库

php实现paypal 授权登录

精品推荐
分类导航