晕。。。。。只是显示一个在线的东西,怎么用搞的那么麻烦,用最兼容的办法写一个,VBscript可以吗?是否也出现这么多不定的因素??
你用下面这段代码来替换<img src="OnlineCount.asp">显示当前在线人数试试:
<%
cnt=0
dnt=0
s=Request.ServerVariables("path_translated")
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
cName=Server.MapPath("chy.cnt")
dName=Server.MapPath("dchy.cnt")
Set objCountFile = objFSO.OpenTextFile(cName,1,True)
If Not objCountFile.AtEndOfStream Then cnt=CLng(objCountFile.ReadAll)
objCountFile.Close
Set objCountFile=Nothing
cnt=cnt+1
Set objCountFile=objFSO.CreateTextFile(cName,True)
objCountFile.Write cnt
objCountFile.Close
Set objCountFile=Nothing
if application("dntime")<=cint(hour(time())) then
Set objCountFile = objFSO.OpenTextFile(dName,1,True)
If Not objCountFile.AtEndOfStream Then dnt=CLng(objCountFile.ReadAll)
objCountFile.Close
Set objCountFile=Nothing
end if
application("dntime")=cint(hour(time()))
dnt=dnt+1
Set objCountFile=objFSO.CreateTextFile(dName,True)
objCountFile.Write dnt
objCountFile.Close
Set objCountFile=Nothing
Set objFSO = Nothing
t=(cint(day(date()))*24+cint(hour(time())))*60+cint(minute(time()))
k=0
i=1
y=0
Do While application("zxip"&i)<>""
if application("zxip"&i)=Request.ServerVariables("REMOTE_ADDR") then
application("zxsj"&i)=t
y=1
end if
if t-application("zxsj"&i)>9 or t<application("zxsj"&i) then
k=k+1
else
if k>0 then
application.lock
application("zxip"&i-k)=application("zxip"&i)
application("zxsj"&i-k)=application("zxsj"&i)
application.unlock
end if
end if
if k>0 then
application.lock
application("zxip"&i)=""
application.unlock
end if
i=i+1
loop
if y=0 then
application("zxip"&i)=Request.ServerVariables("REMOTE_ADDR")
application("zxsj"&i)=t
else
i=i-1
end if%>
<tr><td><b><%=i%></b></div>