<!--#include file="conn.asp" -->
<!--#include file="inc/const.asp"-->
<%
	If Not IsNumeric(Request("id")) And Request("id")<>"" then
		Response.write"错误的系统参数!ID必须是数字"
		Response.End
	End If
   	Dim Rsonline,strUsername,statuserid,stridentity,remoteaddr,onlinemany
   	Dim Rs,SQL,Grades
	If Request.ServerVariables("HTTP_X_FORWARDED_FOR")=empty Then
		remoteaddr=Request.ServerVariables("REMOTE_ADDR")
	else
		remoteaddr=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
	End If
	If DownsysClass.membername="" Then
      		Grades = 0
      		strUsername ="匿名用户"
	else
      		Grades = CInt(DownsysClass.membergrade)
      		strUsername = DownsysClass.membername
	End If
	Set Rs=DownsysClass.Execute("select * from NC_UserGroup where Grades = "& Grades)
		stridentity = Rs("GroupName")
	Rs.Close
	Set Rs=Nothing
	Set Rsonline = server.CreateObject ("adodb.recordset")
   	SQL="select * from [NC_online] where ip='"&remoteaddr&"' and username='"&strUsername&"' or id="&session.sessionid
	Rsonline.Open SQL,Conn,1,3
	If Rsonline.EOF Then
	Rsonline.addnew

		Rsonline("identity") = stridentity
		Rsonline("startTime") = now()
		Rsonline("lastTime") = now()
		Rsonline("browser") = Request.ServerVariables("HTTP_USER_AGENT")
		Rsonline("ip") = remoteaddr
		Rsonline("username") = strUsername
		Rsonline("id") = session.sessionid
	else
		Rsonline("browser") = Request.ServerVariables("HTTP_USER_AGENT")
		Rsonline("lastTime") = now()
		Rsonline("identity") = stridentity
		Rsonline("ip") = remoteaddr
		Rsonline("username") = strUsername
		Rsonline("id") = session.sessionid
	End If
	Rsonline.update
	Rsonline.close
	Set Rsonline = Nothing
	Rem 删除超时用户
	If IsSQLDataBase = 1 Then
		conn.execute("delete from [NC_online] where DateDIff(s,lastTime,GetDate()) > "& CInt(DownsysClass.Setting(20)) &" * 60")
	else
		conn.execute("delete from [NC_online] where DateDIff('s',lastTime,Now()) > "& CInt(DownsysClass.Setting(20)) &" * 60")
	End If
	onlinemany = conn.execute("Select count(id)from NC_online")(0)
	If CInt(Request.Querystring("id")) = 1 Then
		Response.Write "document.writeln(" & chr(34) & ""& onlinemany &""& chr(34) & ");"
	End If
CloseConn
%>