jsp線上人數統計代碼程式
/*
┌──────────────────── 深度空間 深度學習 ──┐
│函數名:OnlineCount
│作 用:線上人數統計
│參 數:
│傳回值:
│日 期:2006/7/18
└──────────────────── www.DeepTeach.com ──┘
*/
String OnlineCount ()
{
t=(cint(day(date()))*24+cint(hour(time())))*60+cint(minute(time()))
k=0
i=1
y=0
Do While application("OnlineIP"&i)<>""
if application("OnlineIP"&i)=Request.ServerVariables("REMOTE_ADDR") then
application("OnlineData"&i)=t
y=1
end if
if t-application("OnlineData"&i)>9 or t<application("OnlineData"&i) then
k=k+1
else
if k>0 then
application.lock
application("OnlineIP"&i-k)=application("OnlineIP"&i)
application("OnlineData"&i-k)=application("OnlineData"&i)
application.unlock
end if
end if
if k>0 then
application.lock
application("OnlineIP"&i)=""
application.unlock
end if
i=i+1
loop
if y=0 then
application("OnlineIP"&i)=Request.ServerVariables("REMOTE_ADDR")
application("OnlineData"&i)=t
else
i=i-1
end if
Response.Write(i)
}
%>