All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
PHP实例:精确到每一秒钟的在线人数显示代码_php资料_编程技术

Writer: aaa Article type: Programming skills(编程技巧) Time: 2013/12/24 5:50:05 Browse times: 366 Comment times: 0

PHP实例:精确到每一秒钟的在线人数显示代码_php资料_编程技术


Head photo

Go homepage
Upload pictures
Write articles

PHP实例:精确到每一秒钟的在线人数显示代码_php资料_编程技术-你的首页-uuhomepage.com

session_start();
$dat_now1=date("H+i+s");//取时间
$p2=explode("+", $dat_now1);
$dat_number1=$p2[0]*3600+$p2[1]*60+$p2[2];//取秒

if($online_time<>"")//上次刷新时间
{$dat_h=substr($online_time,11,2);
$dat_i=substr($online_time,14,2);
$dat_s=substr($online_time,17,2);
$dat_number=$dat_h*3600+$dat_i*60+$dat_s;
}

$tmptime=$dat_number1-$dat_number;//上次到现在的间隔秒数
if(session_is_registered(username)&&(($tmptime>300)¦¦($tmptime<0)))//如果不到5分钟
{
$online_time=date("Y-m-d H:i:s");
$str="replace lt_t_online set lt_username='$username',lt_lasttime=now()";//写入数据库
$res=mysql_query($str);
}
?>
以上文件每分钟自动刷新一次
以下是5分钟运行一次的守护进程
$str = "delete from lt_t_online where UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(lt_lasttime)>300";
mysql_query($str);
?>






There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.