当前位置: 移动技术网 > IT编程>开发语言>.net > ASP实例:即时显示当前页面浏览人数

ASP实例:即时显示当前页面浏览人数

2019年01月18日  | 移动技术网IT编程  | 我要评论

魔兽电影字幕,花都秀全中学,10月15日是什么节日

online.文件

<!--#include file="dbconn.asp" -->
<%
onlinetimeout=10       定义在线活动时间的时间间隔
function userip()
    getclientip = request.servervariables("http_x_forwarded_for")             获得用户的虚拟ip地址
    if getclientip = "" or isnull(getclientip) or isempty(getclientip) then
        getclientip = request.servervariables("remote_addr")                   如果未使用代理服务器,就获得来源的ip地址
    end if
    userip = getclientip
end function
sql="select o_id from c_online where o_ip= "&userip()&" "           在中查找所获得 的ip地址的id
set rs=conn.execute(sql)
if rs.eof and rs.bof then
       sql="insert into c_online(o_ip) values( "&userip()&" )"         如果数据库中没有就表明是新ip,那么插入操作
       conn.execute(sql)
else
       sql="update c_online set o_ltime=now() where o_ip= "&userip()&" "        更数据库的当前时间
       conn.execute(sql)
end if
sql="delete from c_online where dateadd(s,"&onlinetimeout*60&",o_ltime) < now()"        定义十分钟刷新
conn.execute(sql)
rs.close
set rs=nothing
function allonline()
       tmprs=conn.execute("select count(o_id) from c_online")
       allonline=tmprs(0)
       set tmprs=nothing
end function
%>
<%response.write "document.write(""在线"&allonline()&"人"")"%>


如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网