当前位置: 首页 > 图文教程 > 网络编程 > PHP > php实现的在线人员函数库

PHP
用PHP生成html分页列表的代码
php中的session完全教程
PHP session常见问题集锦及解决办法总结
PHP 中dirname(_file_)讲解
PHP_MySQL教程-第一天
PHP_MySQL教程-第二天while循环与数据库操作
PHP_MySQL教程-第三天 基本函数
一篇不错的PHP基础学习笔记
PHP5中的this,self和parent关键字详解教程
phpMyAdmin 安装教程全攻略
PHP入门速成教程
php之字符串变相相减的代码
php中的实现trim函数代码
IIS6的PHP最佳配置方法
简单介绍下 PHP5 中引入的 MYSQLI的用途
php分页示例代码
生成静态页面的php函数,php爱好者站推荐
隐藏你的.php文件的实现方法
推荐一篇入门级的Class文章
PHP配置文件中最常用四个ini函数

PHP 中的 php实现的在线人员函数库


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 89 ::
收藏到网摘: n/a

ME之前用的..找到了.. 在线人员函数库
//增加用户
function AddUser($username){
global $db;
$Ip=getenv('REMOTE_ADDR');
$Ip1 = getenv('HTTP_X_FORWARDED_FOR');
if (($Ip1 != "") && ($Ip1 != "unknown")) $Ip=$Ip1;
$current_time=date("Y-m-d H:i:s");
$SQL="select user from class_online where user='$username'";
$res=mysql_query($SQL,$db);
$row=@mysql_num_rows($res);
if($row==0) {
$SQL="insert into class_online (user,ip,lasttime) values('$username','$Ip','$current_time')";
mysql_query($SQL,$db);
}
}
//更新在线用户名单
function UpdateMember(){
global $db;
$SQL="delete from class_online where UNIX_TIMESTAMP()-UNIX_TIMESTAMP(lasttime)>180"; //3分钟不活动则退出
//echo $SQL;
mysql_query($SQL,$db);
}
//更新在线状态
function UpdateOnline($username){
global $db;
$current_time=date("Y-m-d H:i:s");;
$SQL="update class_online set lasttime='$current_time' where user='$username'";
$res=mysql_query($SQL,$db);
}
//删除用户
function OutOneUser($user){
global $db;
$SQL="delete from class_online where user='$user'";
mysql_query($SQL,$db);
return true;
}
//检查是否在线
function CheckUser($user){
global $db;
$SQL="select user from class_online where user='$user'";
$res=mysql_query($SQL,$db);
$row=mysql_num_rows($res);
if($row>0) return true;
else return false;
}
//取在线名单
function ReadOnlineName(){
global $db;
$SQL="select * from class_online";
$res=mysql_query($SQL,$db);
while($row=mysql_fetch_array($res)){
$result[]=$row[user];
}
return $result;
}
//********************在线人员函数库***************end