<%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
%>
<html>
<head>
<title>实时统计在线人数</title>
<meta http-equiv="refresh" content="10; url=<%=linkurl%>"> '每隔10秒刷新
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
p {font-size: 9pt; font-color: #eeeeee}
a {text-decoration: none}
a:link {color: #0068a3}
a:visited {color: #0068a3}
a:hover {color: #2f00ff; text-decoration: underline}
.ourfont {font-size: 9pt }
body { font-size: 9pt}
table { font-size: 9pt}
-->
</style>
</head>
<%
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、时间
%>
<body>
<p><select name="online" size="1">
<option selected value="online"><%=total%>人在线上</option>
<%
for i=1 to total
response.write "<option>"&ly(i*2-1)&"</option>"
next
%>
</select></p>
</body>
</html>
people.asp:
<%response.end%>
172.16.20.230'用户ip
2003-06-15 09:53:57'登录时间
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!