繁体中文
设为首页
加入收藏
当前位置:ASP技术首页 >> ASP基础 >> 一个实用的FSO-实时统计在线人数

一个实用的FSO-实时统计在线人数

2006-07-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介:count.ASP: 实时统计在线人数 '每隔10秒刷新 60 then ly(i*2-1)="" ly(i*2)="" countly=countly-2 end if if Request.ServerVariables("REMOTE_ADDR")=ly(i*2-1) then sameip=1 'I...

count.ASP:

<%Server.ScriptTimeout=300

id=Trim(Request.QueryString("id"))

fc=Trim(Request.QueryString("fc"))

if fc="" then fc="FFFF00"

bg=Trim(Request.QueryString("bg"))

if bg="" then bg="000000"

bc=Trim(Request.QueryString("bc"))

if bc="" then bc="00FF00"

sername=Request.ServerVariables("SERVER_NAME")

scrname=Request.ServerVariables("SCRIPT_NAME")

linkurl="http://" & sername & scrname

%>

实时统计在线人数

'每隔10秒刷新

<%

countfile=server.mappath("people.ASP")

Set fs=CreateObject("Scripting.FileSystemObject")

n=Year(date())

y=Month(date())

r=Day(date())

s=Hour(time())

f=Minute(time())

m=Second(time())

if len(y)=1 then y="0" & y

if len(r)=1 then r="0" & r

if len(s)=1 then s="0" & s

if len(f)=1 then f="0" & f

if len(m)=1 then m="0" & m

sj = n & "-" & y & "-" & r & " " & s & ":" & f & ":" & m

'格式化日期、时间

dim ly()

Set thisfile=fs.OpenTextFile(countfile,1,False)

countly=0

do while not thisfile.AtEndOfStream

thisline = thisfile.readline

Redim preserve ly(countly)

ly(countly) = thisline

countly = countly + 1

loop '将people.ASP中内容读到数组中

thisfile.close

sameip=0

for i=1 to (countly-1)/2

if DateDiff("s",ly(i*2),sj)>60 then

ly(i*2-1)=""

ly(i*2)=""

countly=countly-2

end if

if Request.ServerVariables("REMOTE_ADDR")=ly(i*2-1) then

sameip=1 'IP已经存在

ly(i*2)=sj

end if

next

set outfile=fs.CreateTextFile(countfile)

for i=0 to countly-1

if ly(i)<>"" then

outfile.WriteLine ly(i)

end if

next

if sameip=0 then

outfile.WriteLine Request.ServerVariables("REMOTE_ADDR")

outfile.WriteLine sj  '添加新记录

outfile.Close

end if

Set thisfile=fs.OpenTextFile(countfile,1,False)

countly=0

do while not thisfile.AtEndOfStream

thisline = thisfile.readline

Redim preserve ly(countly)

ly(countly) = thisline

countly = countly + 1'总的记录行数

loop

thisfile.close

total=(countly-1)/2 '统计总人数,每人有两行记录:IP、时间

%>

people.ASP:

<%Response.end%>

172.16.20.230'用户IP

2003-06-15 09:53:57'登录时间

责任编辑:admin
相关文章