日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

ASP在線統(tǒng)計代碼

 悟靜 2010-05-22

< %
sessionID = session.SessionID
timeout = 30
' 設(shè)置session的過期時間
Conn_String = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("count.mdb")
'建立數(shù)據(jù)庫連接項
Set ConnCount =Server.CreateObject("ADODB.Connection")
ConnCount.Open Conn_String

' dateadd函數(shù)的運用,指定n分鐘為計量單位,計算now()+(-timeout)是時間,也就是過期時間
aaa = dateadd("n", -timeout, now())
connCount.Execute ("delete * from count where postdate < #" & aaa & "#")
'連接變量也可以用execute方法,對數(shù)據(jù)庫進(jìn)行操作,注意時間變量要用#隔開

' 以下語句是檢查客戶sessionID是否在數(shù)據(jù)庫中,如果不是就加入,客戶如果是第一次訪問那么數(shù)據(jù)庫中沒有值.也是用連接變量的execute方法,注意insert into count (sess,postdate) values('"&sessionID&"','"&now()&"')"運用
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

'計算數(shù)據(jù)庫中的值,count(sess)產(chǎn)生新的值,最終用rs(0)讀出
sql2 = "select count(sess) from count"
set rs = connCount.Execute (sql2)
count = rs(0)
rs.close
set rs = nothing

'再對數(shù)據(jù)進(jìn)行全盤檢查看看是否有超期的數(shù)據(jù),有則數(shù)據(jù)count減一
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
% >

document.write('當(dāng)前<%=count%>人在線');
'最終得出結(jié)果
'要計數(shù)的頁面中還要,插入<script language="javascript" src="XXXX/online.asp"></script>

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多