淺淡如何用ASP實現(xiàn)在線人數(shù)統(tǒng)計
(jaklin2000.8.17)
我發(fā)現(xiàn)這幾天問此問題的人挺多的。就此我想說說我個的用法, 請各位大蝦指教。
在線人數(shù)是指一個時段內(nèi)的訪客人數(shù)統(tǒng)計,時間的長短是由設(shè)計者設(shè)定的。
在這個時段內(nèi),各個不同IP訪問本站點的總數(shù),就是當(dāng)前的線上人數(shù)。在ASP中,一般是使用Session對象來實現(xiàn)統(tǒng)計,實現(xiàn)代碼如下:
1. 在Golobal.asa文件中:
〈SCRIPT LANGUAGE=″VBScript″ RUNAT=″Server″〉
Sub Session_OnStart
application(″online″)=application(″online″)+1
End Sub
Sub Session_OnEnd
application(″online″)=application(″online″)-1
End Sub
sub Application_OnStart
application(″online″)=0
End Sub
sub Application_OnEnd
application(″online″)=0
End Sub
〈/SCRIPT〉
2. Online.asp 文件內(nèi)容
〈% tmp=application(″online″)
tmp=Cstr(tmp)
dim disp(20)
dim images(20)
dbbits=len(tmp)
for i= 1 to dbbits
disp(i)=left(right(tmp,i),i-(i-1))
next
for i=dbbits to 1 step -1
images(i)=″〈img src=http://cfan.net.cn/info/″&″http://xxxx.com.cn/pic″&″/″&disp(i)&″.gif〉″
response.write ″document.write(′ ″&images(i)&″ ′);″
next %〉
若那位大蝦有更好的方法, 也順便告訴我一下:fz_chenjl@163.net. OK?
|