不用Global.asa实现在线人数统计
2001-05-21 10:18:54 来源:WEB开发网核心提示:<%'count online user without using Global.asa'script by Narong Khotarasakit'webmaster of ezebox.com'report bug : info@ezebox.comsessionID = s
<%
'count online user without using Global.asa
'script by Narong Khotarasakit
'webmaster of ezebox.com
'report bug : info@ezebox.com
sessionID = session.SessionID
timeout = 5
' set how long to keep this session in minute you can increase this number
Conn_String = "DRIVER={Microsoft access Driver (*.mdb)};DBQ=" & Server.MapPath("count.mdb")
'Conn_String = "activeUser"
'set your DSN = "activeuser" is a better way because you need include this file to all your asp scripts.
Set ConnCount =Server.CreateObject("ADODB.Connection")
ConnCount.Open Conn_String
' delete session after timeout
aaa = dateadd("n", -timeout, now())
connCount.Execute ("delete * from count where postdate < #" & aaa & "#")
' keep sessionID
sql0 = "select sess from count where sess='" & sessionID & "'"
set rscheck = connCount.Execute (sql0)
if rscheck.eof then
sql = "insert into count (sess,postdate) values('" & sessionID & "', '" & now() & "')"
connCount.Execute (sql)
end if
rscheck.close
set rscheck = nothing
'count sessionID
sql2 = "select count(sess) from count"
set rs = connCount.Execute (sql2)
count = rs(0)
rs.close
set rs = nothing
sql3 = "select * from count"
set rsPRedel = connCount.Execute (sql3)
do until rspredel.eof
xxx=DateDiff("n", rspredel("postdate"), Now())
if xxx > timeout then
count = count-1
end if
rspredel.movenext
loop
rspredel.close
set rspredel = nothing
connCount.Close
set connCount = nothing
if count = 0 then
count = 1
end if
%>
<%=count%> Active users
'count online user without using Global.asa
'script by Narong Khotarasakit
'webmaster of ezebox.com
'report bug : info@ezebox.com
sessionID = session.SessionID
timeout = 5
' set how long to keep this session in minute you can increase this number
Conn_String = "DRIVER={Microsoft access Driver (*.mdb)};DBQ=" & Server.MapPath("count.mdb")
'Conn_String = "activeUser"
'set your DSN = "activeuser" is a better way because you need include this file to all your asp scripts.
Set ConnCount =Server.CreateObject("ADODB.Connection")
ConnCount.Open Conn_String
' delete session after timeout
aaa = dateadd("n", -timeout, now())
connCount.Execute ("delete * from count where postdate < #" & aaa & "#")
' keep sessionID
sql0 = "select sess from count where sess='" & sessionID & "'"
set rscheck = connCount.Execute (sql0)
if rscheck.eof then
sql = "insert into count (sess,postdate) values('" & sessionID & "', '" & now() & "')"
connCount.Execute (sql)
end if
rscheck.close
set rscheck = nothing
'count sessionID
sql2 = "select count(sess) from count"
set rs = connCount.Execute (sql2)
count = rs(0)
rs.close
set rs = nothing
sql3 = "select * from count"
set rsPRedel = connCount.Execute (sql3)
do until rspredel.eof
xxx=DateDiff("n", rspredel("postdate"), Now())
if xxx > timeout then
count = count-1
end if
rspredel.movenext
loop
rspredel.close
set rspredel = nothing
connCount.Close
set connCount = nothing
if count = 0 then
count = 1
end if
%>
<%=count%> Active users
[]
- ››不用登录也可与好友聊MSN
- ››不用蛮力用巧劲——升级本本搞定Win7
- ››不用安装 QQ 软件 android 系统手机照样也能用 QQ...
- ››不用组合键 鼠标调用Win 7立体窗口
- ››不用无线路由器设置 WIFI 环境 让iphone/ipod tou...
- ››不用重装系统 Windows 7直接开启AHCI
- ››不用重装系统直接开启Windows 7 AHCI
- ››不用做外链的SEO服务
- ››不用spring,hibernate超傻瓜JAVA开发(javabean+数...
- ››不用Word软件 轻松批量打印多个文档
- ››不用root密码也可以執行root的程序--Sudo
- ››不用布尔运算的开窗凿洞MAX教程
更多精彩
赞助商链接