不用Global.asa实现在线人数统计

埋葬无悔的青春

埋葬无悔的青春

2016-01-29 18:25

不用Global.asa实现在线人数统计,不用Global.asa实现在线人数统计
  <%
'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



 
展开更多 50%)
分享

猜你喜欢

不用Global.asa实现在线人数统计

ASP
不用Global.asa实现在线人数统计

不用Golobal.asa和session实现在线人数统计

ASP
不用Golobal.asa和session实现在线人数统计

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

不用Golobal和session实现在线人数统计

ASP
不用Golobal和session实现在线人数统计

jsp 实现在线人数统计

Web开发
jsp 实现在线人数统计

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

利用global.asa计划执行程序

ASP
利用global.asa计划执行程序

利用global.asa计划执行程序(转)

ASP
利用global.asa计划执行程序(转)

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

javascript动态装入XML数据

javascript动态装入XML数据

让文档双剑合璧—轻松打造图文并茂Word文件

让文档双剑合璧—轻松打造图文并茂Word文件
下拉加载更多内容 ↓