<!-- #include file=../inc/BBSSetup.asp -->
<!-- #include file=../inc/User_Setup.ASP -->
<!-- #include file=../inc/Board_Popfun.asp -->
<!-- #include file=inc/UserTopic.asp -->
<%
DEF_BBS_HomeUrl = "../"
'DEF_MaxListNum = 100
If CheckSupervisorUserName = 0 Then
	GBL_CHK_PWdFlag = 0
	OpenDatabase
Else
	initDatabase
End If
SiteHead(DEF_SiteNameString & " - 用户会员区")
UpdateOnlineUserAtInfo GBL_board_ID,"查看在线用户"

Dim AtBoardID,AtBoardName,AtBoardIDCount
GetAtBoardIDInfo

If GBL_TableHeadString <> "" Then
	Response.Write "<table width=" & DEF_BBS_ScreenWidth & " border=0 cellspacing=0 cellpadding=0 align=center><tr><td>"
	Response.Write GBL_TableHeadString
	Response.Write "</td></tr></table>"
End If
%>
<table width="<%=DEF_BBS_ScreenWidth%>" border="0" cellspacing="1" cellpadding="0" align="center" bgcolor="<%=DEF_BBS_DarkColor%>" class=TBone>
  <tr>
    <td valign="top" bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9>
      <table width="100%" border="0" cellspacing="0" cellpadding="5" align="center">
        <tr> 
          <td height="20"><img src=../images/blank.gif height=3 width=2><br>
            <%If AtBoardID = 0 Then
            	DisplayUserNavigate("全体在线人员")
            Else
            	DisplayUserNavigate("<a href=userOnline.asp>全体在线人员</a> &gt;&gt; " & AtBoardName & "在线人员")
            End If
            %><br>
            </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<img src=../images/blank.gif wdith=2 height=2><table width="<%=DEF_BBS_ScreenWidth%>" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td valign="top">
      <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr> 
          <td height="20">
            <%
            	DisplayUserOnline%>
            </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<%
If GBL_TableBottomString <> "" Then
	%><table width=<%=DEF_BBS_ScreenWidth%> border=0 cellspacing=0 cellpadding=0 align=center><tr><td><%=GBL_TableBottomString%></td></tr></table><%
End If
closeDataBase
SiteBottom
If GBL_ShowBottomSure = 1 Then Response.Write GBL_SiteBottomString


Function GetAtBoardIDInfo

	AtBoardID = Left(Request("AtBoardID"),14)
	If isNumeric(AtBoardID) = 0 Then AtBoardID = 0
	AtBoardID = cCur(AtBoardID)
	If AtBoardID < 1 Then
		AtBoardID = 0
		Exit Function
	End If

	If isArray(Application(DEF_MasterCookies & "BoardInfo" & AtBoardID)) = False Then
		AtBoardID = 0
	Else
		AtBoardName = "<a href=../Board/Board.asp?BoardID=" & AtBoardID & ">" & Application(DEF_MasterCookies & "BoardInfo" & AtBoardID)(0,0) & "</a>"
	End If

End Function

Function DisplayUserOnline

	GBL_CHK_TempStr=""
	Dim Rs,SQL
	Dim UpDownPageFlag
	UpDownPageFlag = Request("UpDownPageFlag")

	Dim Start,recordCount
	recordCount=0
	Dim SQLendString

	Start = Left(Trim(Request("Start")),14)
	Start = start
	If isNumeric(Start)=0 or Start="" Then Start=0
	Start = cCur(Start)

	Dim SQLCountString,whereFlag
	'SQLendString=" where T1.UserID>1"
	'whereFlag = 1
	If AtBoardID > 0 Then
		SQLendString=" where T1.AtBoardID=" & AtBoardID
		whereFlag = 1
	End If

	Rem 下面的代码使目前暂不提供城市分类双重查询
	
	SQLCountString = SQLendString
	If UpDownPageFlag = "1" and Start>0 then
		If whereFlag = 1 Then
			SQLendString = SQLendString & " and T1.ID<" & Start
		Else
			SQLendString = SQLendString & " where T1.ID<" & Start
			whereFlag = 1
		End If
	Else
		If whereFlag = 1 Then
			SQLendString = SQLendString & " and T1.ID>" & Start
		Else
			SQLendString = SQLendString & " where T1.ID>" & Start
			whereFlag = 1
		End If
	end If

	If UpDownPageFlag = "1" then
		'If DEF_IDFocusFlag<> 2 Then SQLendString = SQLendString & " Order by  T2.ID DESC"
		SQLendString = SQLendString & " Order by  T1.ID DESC"
	Else
		'If DEF_IDFocusFlag<> 1 Then SQLendString = SQLendString & " Order by  T2.ID ASC"
		SQLendString = SQLendString & " Order by  T1.ID ASC"
	End If

	Dim MaxRecordID,MinRecordID
	MaxRecordID = 0

	SQL = "select Max(T1.id) from LeadBBS_onlineUser as T1 left join LeadBBS_User as T2 on T1.UserID=T2.ID" & SQLCountString
	Set Rs = Con.ExeCute(SQL)
	GBL_DBNum = GBL_DBNum + 1

	If not Rs.Eof Then
		If Rs(0) <> "" Then
			MaxRecordID = cCur(Rs(0))
		Else
			MaxRecordID = 0
		End If
	End If
	Rs.Close
	Set Rs = Nothing
	
	SQL = "select Min(T1.id) from LeadBBS_onlineUser as T1 left join LeadBBS_User as T2 on T1.UserID=T2.ID" & SQLCountString
	Set Rs = Con.ExeCute(SQL)
	GBL_DBNum = GBL_DBNum + 1

	If not Rs.Eof Then
		If Rs(0) <> "" Then
			MinRecordID = cCur(Rs(0))
		else
			MinRecordID = 0
		end If
	End If
	Rs.Close
	Set Rs = Nothing

	Dim FirstID,LastID	
	recordCount = application(DEF_MasterCookies & "ActiveUsers")

	SQL = "select TOP "&DEF_MaxListNum&" T1.ID,T2.UserName,T2.Points,T1.IP,T2.OnlineTime,T2.UserLevel,T2.ID,T1.AtUrl,T1.AtInfo,T2.Userphoto,T2.FaceUrl,T2.FaceWidth,T2.FaceHeight,T2.ShowFlag,T1.Browser,T1.System from LeadBBS_onlineUser as T1 left join LeadBBS_User As T2 on T1.UserID=T2.ID" & SQLendString
	Set Rs = Con.ExeCute(SQL)
	GBL_DBNum = GBL_DBNum + 1
	Dim Num
	Dim GetData
	If Not rs.Eof Then
		GetData = Rs.GetRows(-1)
		Num = Ubound(GetData,2)
	Else
		Num = -1
	End If
	Rs.close
	Set Rs = Nothing
	
	
	Dim i,N
	If Num>=0 Then
		i=1
	
	
	Dim MinN,MaxN,StepValue
	SQL = ubound(getdata,2)
	If UpDownPageFlag = "1" then
		MinN = SQL
		MaxN = 0
		StepValue = -1
	Else
		MinN = 0
		MaxN = SQL
		StepValue = 1
	End If
	
	LastID = cCur(GetData(0,MaxN))
	FirstID = cCur(GetData(0,MinN))

	Dim EndwriteQueryString,PageSplictString
	EndwriteQueryString = "?GBL_CTG_ID=0"
	If AtBoardID > 0 Then EndwriteQueryString = EndwriteQueryString & "&AtBoardID=" & AtBoardID

	PageSplictString = PageSplictString & "<table><tr><td>&nbsp;"
	if FirstID>MinRecordID and FirstID<>0 then
		PageSplictString = PageSplictString & "<a href=UserOnline.asp" & EndwriteQueryString & "&Start=0&SubmitFlag=3829EwoqIaNfoG>首页</a> " & VbCrLf
	else
		PageSplictString = PageSplictString & "<font color=999999 class=GrayFont>首页</font> " & VbCrLf
	end if

	if FirstID > MinRecordID and FirstID<>0 then
		PageSplictString = PageSplictString & " <a href=UserOnline.asp" & EndwriteQueryString & "&Start=" & FirstID & "&UpDownPageFlag=1&SubmitFlag=3829EwoqIaNfoG>上页</a> " & VbCrLf
	else
		PageSplictString = PageSplictString & " <font color=999999 class=GrayFont>上页</font> " & VbCrLf
	end if

	if LastID<MaxRecordID and LastID<>0 then
		PageSplictString = PageSplictString & " <a href=UserOnline.asp" & EndwriteQueryString & "&Start=" & LastID & "&SubmitFlag=3829EwoqIaNfoG>下页</a> " & VbCrLf
	else
		PageSplictString = PageSplictString & " <font color=999999 class=GrayFont>下页</font> " & VbCrLf
	end if

	if LastID < MaxRecordID and LastID<>0 then
		PageSplictString = PageSplictString & " <a href=UserOnline.asp" & EndwriteQueryString & "&Start=" & MaxRecordID+1 & "&UpDownPageFlag=1&SubmitFlag=3829EwoqIaNfoG>尾页</a> " & VbCrLf
	else
		PageSplictString = PageSplictString & " <font color=999999 class=GrayFont>尾页</font> " & VbCrLf
	end if
	PageSplictString = PageSplictString & "共<b>" & recordCount & "</b>人在线"
	If (recordCount mod DEF_MaxListNum)=0 Then
		PageSplictString = PageSplictString & " 计<b>" & clng(recordCount/DEF_MaxListNum) & "</b>页"
	Else
		If recordCount>=DEF_MaxListNum Then
			If (recordCount mod DEF_MaxListNum) = 0 Then
				PageSplictString = PageSplictString & " 计<b>" & clng(recordCount/DEF_MaxListNum) & "</b>页"
			Else
				PageSplictString = PageSplictString & " 计<b>" & clng(recordCount/DEF_MaxListNum)+1 & "</b>页"
			End If
		Else
			PageSplictString = PageSplictString & " 计<b>1</b>页"
		End If
	End If
	PageSplictString = PageSplictString & " 每页<b>" & DEF_MaxListNum & "</b>人"
	PageSplictString = PageSplictString & "</td><td></td></tr></table>"

	%>
			<table width="100%" border="0" cellspacing="1" cellpadding="5" bgcolor="<%=DEF_BBS_DarkColor%>" class=TBone>
				<tr bgcolor="<%=DEF_BBS_LightColor%>" class=TBBG9> 
					<td colspan=10> 
						<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" height="3">
						<tr>
							<td></td>
						</tr>
						</table>
						<%=PageSplictString%></td>
				</tr>
				<tr bgcolor="<%=DEF_BBS_TableHeadColor%>" align=center class=TBfour>
					<td width=<%=DEF_AllFaceMaxWidth%>><img src=../images/null.gif width=2 height=2><br><b>头像</b></td>
					<td width=68><img src=../images/null.gif width=2 height=2><br><b>用户名</b></td>
					<td width=40><img src=../images/null.gif width=2 height=2><br><b><%=DEF_PointsName%></b></td>
					<td width=40><img src=../images/null.gif width=2 height=2><br><b>经验</b></td><%If CheckSupervisorUserName = 1 Then%>
					<td width=90><img src=../images/null.gif width=2 height=2><br><b>ＩＰ地址</b></td><%End If%>
					<td width=58><img src=../images/null.gif width=2 height=2><br><b>等级</b></td>
					<td align=left width=150><img src=../images/null.gif width=2 height=2><br><b>浏览器/操作系统</b></td>
					<td align=left><img src=../images/null.gif width=2 height=2><br><b>所处位置</b></td>
				</tr>
<%		Dim Number
		Number=0
		for n= MinN to MaxN Step StepValue
			If CheckSupervisorUserName = 1 and GBL_UserID > 0 then GetData(13,N) = 0
			If Number=0 Then
				i = DEF_BBS_LightColor
				Number=1
			Else
				i = DEF_BBS_LightestColor
				Number=0
			End If
			%>
                    <tr bgcolor="<%=i%>" align=center height=<%=DEF_AllFaceMaxWidth%><%
			If Number=0 Then
				Response.Write " class=TBBG1"
			Else
				Response.Write " class=TBBG9"
			End If%>><%
				If isNull(GetData(1,n)) or GetData(1,n) = "" Then%>
                      <td height="20">&nbsp;</td>
                      <td width=68>
                      	<a href=LookUserMoreInfo.asp?OlID=<%=GetData(0,n)%>>游客</a></td>
                      <td width=40>&nbsp;</td>
                      <td width=40>&nbsp;</td><%If CheckSupervisorUserName = 1 Then%>
                      <td width=90><%=GetData(3,n)%></td><%End If%>
                      <td width=58>&nbsp;</td>
                      <td align=left width=150>浏 览 器：<%=htmlencode(GetData(14,n))%><br>操作系统：<%=htmlencode(GetData(15,n))%></td>
                      <td align=left><a href="<%=GetData(7,N)%>"><%
                      If StrLength(GetData(8,N)) > 130 Then
                      	Response.Write htmlencode(LeftTrue(GetData(8,N),127)) & "..."
                      Else
                      	Response.Write htmlencode(GetData(8,N))
                      End If%></a></td>
                      <%
				Else%>
                      <td height="20"><%
                      If (GetData(13,N) = True or GetData(13,N) = 1) and DEF_EnableUserHidden = 1 Then
                      	Response.Write "&nbsp;"
                      Else
                      	If DEF_AllDefineFace = 0 or GetData(10,N) & "" = "" Then%>
						<%If GetData(9,N)<>"" and isNumeric(GetData(9,N)) Then%><img src=../images/face/<%=string(4-len(cstr(GetData(9,N))),"0")&GetData(9,N)%>.gif align=absmiddle><%Else%><img src=../images/null.gif align=absmiddle><%End If%>
						<%Else%>
							<img src="<%=htmlencode(GetData(10,N))%>" align=absmiddle width=<%=GetData(11,N)%> height=<%=GetData(12,N)%>>
						<%End If
					End If%></td>
                      <td width=68><%If (GetData(13,N) = True or GetData(13,N) = 1) and DEF_EnableUserHidden = 1 Then%><a href=LookUserMoreInfo.asp?OlID=<%=GetData(0,n)%>>隐身</a><%Else%>
                      	<a href=LookUserInfo.asp?id=<%=GetData(6,n)%>><%=htmlencode(GetData(1,n))%></a><%End If%></td>
                      <td width=40><%If GetData(13,N) = False or GetData(13,N) = 0 or DEF_EnableUserHidden = 0 Then%><%=GetData(2,n)%><%Else%>&nbsp;<%End If%></td>
                      <td width=40><%If GetData(13,N) = False or GetData(13,N) = 0 or DEF_EnableUserHidden = 0  Then%><%=Clng(cCur(GetData(4,n))/60)%><%Else%>&nbsp;<%End If%></td><%If CheckSupervisorUserName = 1 Then%>
                      <td width=90><%=GetData(3,n)%></td><%End If%>
                      <td width=58><%If GetData(13,N) = False or GetData(13,N) = 0 or DEF_EnableUserHidden = 0  Then%><%=DEF_UserLevelString(GetData(5,n))%><%Else%>&nbsp;<%End If%></td>
					  <td align=left width=150>浏 览 器：<%=htmlencode(GetData(14,n))%><br>
					  操作系统：<%=htmlencode(GetData(15,n))%></td>
                      <td align=left><a href="<%=htmlencode(GetData(7,N))%>"><%
                      If StrLength(GetData(8,N)) > 130 Then
                      	Response.Write htmlencode(LeftTrue(GetData(8,N),127)) & "..."
                      Else
                      	Response.Write htmlencode(GetData(8,N))
                      End If%></a></td><%
				End If%>
                    </tr><%
		next
%>
				<tr bgcolor="<%=DEF_BBS_LightColor%>" class=TBBG9> 
					<td colspan=10> 
						<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" height="3">
						<tr>
							<td></td>
						</tr>
						</table>
						<%=PageSplictString%></td>
				</tr>
				</table>
	<%
	Else%>
				<table width="100%" border="0" cellspacing="1" cellpadding="10" bgcolor="<%=DEF_BBS_DarkColor%>" class=TBone>
					<tr bgcolor="<%=DEF_BBS_LightColor%>" class=TBBG9> 
						<td height=25> <%
		Response.Write GBL_CHK_TempStr & "		<p>没有在线用户。<br>" & VbCrLf
		%>
						</td>
					</tr>
				</table>
		<%
	End If

End Function%>