<%
dim onlineip
onlineip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
if onlineip="" then onlineip = Request.ServerVariables("REMOTE_ADDR")

'lonline为会员离线时间

conn.Execute("delete from online where times <= '"&DateAdd("n", lonline, Now())&"'")


if myid=0  then '判断用户未登录

set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select id,times,onlineip,online,name,userid from online where id="&session.sessionid&" or onlineip='"&onlineip&"'",conn,1,2
if rs.eof then
rs.addnew
end if
rs("id")=session.sessionID
rs("online")=0
rs("onlineip")=onlineip
rs("times")=now()
rs("name")="游客"&session.sessionid
rs("userid")=0
rs.update
rs.close
set rs=nothing

else
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select id,times,onlineip,online,name,userid from online where id="&session.sessionid&" or userid="&myid,conn,1,2
if rs.eof then 
rs.addnew
end if
rs("id")=session.sessionID
rs("online")=1
rs("onlineip")=onlineip
rs("times")=now()
rs("name")=myni
rs("userid")=myid
rs.update
rs.close
set rs=nothing
end if
%>