www.gusucode.com > 超文本多用户论坛程序 1.1 > bbs/zx.asp

    <%
dlip=Request.ServerVariables("REMOTE_ADDR") 
username=request.cookies("username")
xzs=now()

if username=empty then
username="访客"
end if

sqlyhcx="select id,cnuser from lsb where cnuser in('访客','"&username&"') and dlip='"&dlip&"'"
set cxyh=conn.execute(sqlyhcx)

if cxyh.eof then
sql="insert into lsb(cnuser,dlip)values('"&username&"','"&dlip&"')"
conn.execute(sql)
else
sqlxg="update lsb set cnuser='"&username&"',dldate='"&xzs&"'where id="&cxyh("id")&""
conn.execute(sqlxg)
end if

cxyh.close
set cxyh=nothing

'相隔5分钟清理一次
sqlql="select id,dldate from lsb"
set rs=conn.execute(sqlql)
do while not rs.eof

id=rs("id")
yqsj=rs("dldate")
a=datediff("n",xzs,yqsj)

if abs(a)>5 then
sqlsc="delete*from lsb where id="&id&""
conn.execute(sqlsc)
end if

rs.movenext
loop

rs.close
set rs=nothing
%>

<%
set zxrs=server.createobject("adodb.recordset")
zxrs.activeconnection=conn

sqlzczxrs="select * from lsb"
zxrs.cursortype=3
zxrs.open sqlzczxrs
zxrss=zxrs.recordcount'在线总人数

fks=0
for i=1 to zxrss
if zxrs("cnuser")="访客" then
fks=fks+1
end if
next
zxrs.movenext

zcrs=zxrss-fks'注册人数

zxrs.close
set zxrs=nothing
%>