php实现的在线人员函数库


Posted in PHP onApril 09, 2008

//增加用户    
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  

PHP 相关文章推荐
用php+mysql一个名片库程序
Oct 09 PHP
在JavaScript中调用php程序
Mar 09 PHP
ThinkPHP 连接Oracle数据库的详细教程[全]
Jul 16 PHP
使用php显示搜索引擎来的关键词
Feb 13 PHP
php socket实现的聊天室代码分享
Aug 16 PHP
PHP程序员必须清楚的问题汇总
Dec 18 PHP
PHP、Java des加密解密实例
Apr 27 PHP
thinkphp框架实现数据添加和显示功能
Jun 29 PHP
PHP魔术方法以及关于独立实例与相连实例的全面讲解
Oct 18 PHP
PHP实现的最大正向匹配算法示例
Dec 19 PHP
PHP有序表查找之二分查找(折半查找)算法示例
Feb 09 PHP
PHP设计模式之适配器模式定义与用法详解
Apr 03 PHP
PHP循环获取GET和POST值的代码
Apr 09 #PHP
生成卡号php代码
Apr 09 #PHP
PHP获取网卡地址的代码
Apr 09 #PHP
PHP防注入安全代码
Apr 09 #PHP
PHP中用header图片地址 简单隐藏图片源地址
Apr 09 #PHP
PHP中的extract的作用分析
Apr 09 #PHP
如何在PHP程序中防止盗链
Apr 09 #PHP
You might like
destoon实现调用当前栏目分类及子分类和三级分类的方法
2014/08/21 PHP
PHP中filter函数校验数据的方法详解
2015/07/31 PHP
无需数据库在线投票调查php代码
2016/07/20 PHP
Yii框架结合sphinx,Ajax实现搜索分页功能示例
2016/10/18 PHP
Javascript条件判断使用小技巧总结
2008/09/08 Javascript
5款Javascript颜色选择器
2009/10/25 Javascript
JavaScript利用append添加元素报错的解决方法
2014/07/01 Javascript
Javascript学习指南
2014/12/01 Javascript
jQuery实用小技巧_输入框文字获取和失去焦点的简单实例
2016/08/25 Javascript
jQuery实现的无限级下拉菜单功能示例
2016/09/12 Javascript
一篇看懂vuejs的状态管理神器 vuex状态管理模式
2017/04/20 Javascript
node.js连接MongoDB数据库的2种方法教程
2017/05/17 Javascript
在Vue中使用echarts的方法
2018/02/05 Javascript
Vue项目webpack打包部署到Tomcat刷新报404错误问题的解决方案
2018/05/15 Javascript
JS对象和字符串之间互换操作实例分析
2019/02/02 Javascript
js实现无缝滚动双图切换效果
2019/07/09 Javascript
python sqlobject(mysql)中文乱码解决方法
2008/11/14 Python
python使用PyFetion来发送短信的例子
2014/04/22 Python
python处理PHP数组文本文件实例
2014/09/18 Python
Python Matplotlib库入门指南
2015/05/18 Python
python中Matplotlib实现绘制3D图的示例代码
2017/09/04 Python
Python实现生成随机数据插入mysql数据库的方法
2017/12/25 Python
python 读入多行数据的实例
2018/04/19 Python
在cmder下安装ipython以及环境的搭建
2018/10/19 Python
详解Python 爬取13个旅游城市,告诉你五一大家最爱去哪玩?
2019/05/07 Python
jupyter notebook 添加kernel permission denied的操作
2020/04/21 Python
Django如何使用jwt获取用户信息
2020/04/21 Python
python 深度学习中的4种激活函数
2020/09/18 Python
求职简历中自我评价
2014/01/28 职场文书
新闻发布会策划方案
2014/06/12 职场文书
安全目标责任书
2014/07/22 职场文书
人事专员岗位职责说明书
2014/07/30 职场文书
英语复习计划
2015/01/19 职场文书
普通员工辞职信范文
2015/05/12 职场文书
刑事上诉状范文
2015/05/22 职场文书
详解Redis实现限流的三种方式
2021/04/27 Redis