<!--#include file="conn.asp"-->
<%
dim new_online_sj
new_online_sj="5"                           '设置在线人数统计时间，默认为5分钟
set rs_dj=server.createobject("adodb.recordset")
sql_dj="select * from online_h where datediff(n,sj,getdate())>="&clng(new_online_sj)&""
rs_dj.open sql_dj,conn,1,3
if not (rs_dj.bof and rs_dj.eof) then
	do while not rs_dj.eof
		onlinesj=datediff("n",rs_dj("sj"),now())
		conn.execute("update djcount set onlinesj=onlinesj+"&onlinesj&" where huiyuan='"&rs_dj("huiyuan")&"'")
		rs_dj.movenext
	loop
end if
rs_dj.close
set rs_dj=nothing
conn.execute("delete from online_h where datediff(n,sj,getdate())>="&clng(new_online_sj)&"")
conn.execute("update djcount set onlinetime=onlinetime+int(onlinesj/60),onlinesj=onlinesj-int(onlinesj/60)*60 where onlinesj>=60")

if  Request.ServerVariables("HTTP_X_FORWARDED_FOR") = ""  then
ip=Request.ServerVariables("REMOTE_ADDR")
else
ip= Request.ServerVariables("HTTP_X_FORWARDED_FOR")
end if
if replace(Request.Cookies(my_url)("huiyuan"),"'","")<>"" then
	set jilu=conn.execute("select huiyuan from online_h where huiyuan='"&replace(Request.Cookies(my_url)("huiyuan"),"'","")&"'")
	if jilu.eof or jilu.bof then
	  conn.execute("insert into online_h (huiyuan,ip,DailiID)VALUES('"&replace(Request.Cookies(my_url)("huiyuan"),"'","")&"','"&ip&"',"&Request.Cookies(my_url)("DailiID")&")")
	end if
	jilu.close:set jilu=nothing

	set userdj=conn.execute("select huiyuan from djcount where huiyuan='"&replace(Request.Cookies(my_url)("huiyuan"),"'","")&"'")
	if userdj.eof or userdj.bof then
	  conn.execute("insert into djcount (huiyuan,DailiID)VALUES('"&replace(Request.Cookies(my_url)("huiyuan"),"'","")&"',"&Request.Cookies(my_url)("DailiID")&")")
	end if
	userdj.close:set userdj=nothing
end if
conn.close
conn=nothing
%>