唐山网站建设

设为主页 加入收藏 繁體中文

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

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

online.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()"        定义10分钟刷新
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()&"人"")"%>

唐山网站建设www.fw8.net


TAG:地址,定义,时间,在线,间隔
评论加载中...
内容:
评论者: 验证码: