加入收藏 | 设为首页 | 会员中心 | 我要投稿 银川站长网 (https://www.0951zz.com/)- 云通信、基础存储、云上网络、机器学习、视觉智能!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

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

发布时间:2023-09-22 13:07:32 所属栏目:Asp教程 来源:
导读:ASP实现即时显示当前页面浏览人数:online.asp文件以下为引用的内容:<!--#include file="dbconn.asp" --><%onlineTimeout=10 &#39;&#39;定义在线活动时间的时间间隔Function Userip()GetClientIP = Request.ServerV

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

online.asp文件

以下为引用的内容:

<!--#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()&"人"")"%>

(编辑:银川站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章