<!-- #include file=../inc/BBSsetup.asp -->
<!-- #include file=../inc/Board_Popfun.asp -->
<!-- #include file=inc/UserTopic.asp -->
<%
DEF_BBS_HomeUrl = "../"
Dim GBL_ID,GBL_Name

GBL_CHK_TempStr = ""

initDatabase

SiteHead(DEF_SiteNameString & " - 用户会员区")
UpdateOnlineUserAtInfo GBL_board_ID,"查看好友"

If GBL_ID = 0 and GBL_Name = "" Then
	If GBL_ID = 0 Then GBL_ID = GBL_UserID
	GBL_CHK_TempStr = ""
	If GBL_ID = 0 Then
		GBL_CHK_TempStr = "找不到用户，要查看资料请先登录。<br>" & VbCrLf
	End If
Else
	If GBL_ID <> 0 Then GBL_Name = ""
	GBL_CHK_TempStr = ""
End If

UserTopicTopInfo
DisplayUserNavigate("我的好友")%><br>
<br>
<%if GBL_CHK_TempStr <> "" Then
	Response.Write "<p align=left><font color=ff0000 class=RedFont><b>" & GBL_CHK_TempStr & "</b></font>"
Else
	GBL_CHK_TempStr = ""
	If Request.QueryString("need") = "23" Then
		DisplayCenter2
	Else
		DisplayCenter
	End If
End If
UserTopicBottomInfo
closeDataBase
SiteBottom
If GBL_ShowBottomSure = 1 Then Response.Write GBL_SiteBottomString

Function DisplayCenter

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

	Dim Start

	Dim SQLendString

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

	Dim SQLCountString,whereFlag
	whereFlag = 1
	SQLendString = " where T1.UserID=" & GBL_ID

	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
		SQLendString = SQLendString & " Order by T1.ID ASC"
	Else
		SQLendString = SQLendString & " Order by T1.ID DESC"
	End If
	
	Dim MaxRecordID,MinRecordID
	MaxRecordID = 0

	SQL = "select Max(T1.id) from LeadBBS_FriendUser as T1 " & 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_FriendUser as T1 " & 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
	'Dim recordCount	
	'SQL = "select count(*) from LeadBBS_FriendUser as T1 " & SQLCountString
	'Set Rs = Con.ExeCute(SQL)
	'GBL_DBNum = GBL_DBNum + 1
	'if rs.eof then
	'	recordCount=0
	'else
	'	recordCount=rs(0)
	'	if recordCount="" or isNull(recordCount) or len(recordCount)<1 Then recordCount=0
	'End If
	'Rs.Close
	'Set Rs = Nothing

	SQL = "select TOP "&DEF_MaxListNum&" T2.UserName,T2.Mail,T2.Sex,T2.LastDoingTime,T2.Userphoto,T2.FaceUrl,T2.FaceWidth,T2.FaceHeight,T1.ID from LeadBBS_FriendUser as T1 inner join LeadBBS_User as T2 on T1.FriendUserID=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(DEF_MaxListNum)
		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(8,MaxN))
		FirstID = cCur(GetData(8,MinN))
	
		Dim EndwriteQueryString,PageSplictString
		EndwriteQueryString = "?ID=" & GBL_ID
	
		PageSplictString = PageSplictString & "&nbsp;"
		If FirstID >= MaxRecordID Then
			PageSplictString = PageSplictString & "<font color=999999 class=GrayFont>首页</font> " & VbCrLf
			PageSplictString = PageSplictString & " <font color=999999 class=GrayFont>上页</font> " & VbCrLf
		else
			PageSplictString = PageSplictString & "<a href=UserFriend.asp" & EndwriteQueryString & "&Start=0>首页</a> " & VbCrLf
			PageSplictString = PageSplictString & " <a href=UserFriend.asp" & EndwriteQueryString & "&Start=" & FirstID & "&UpDownPageFlag=1>上页</a> " & VbCrLf
		end if
	
		if LastID<MaxRecordID and LastID<>0 then
		else
		end if
	
		If LastID <= MinRecordID Then
			PageSplictString = PageSplictString & " <font color=999999 class=GrayFont>下页</font> " & VbCrLf
			PageSplictString = PageSplictString & " <font color=999999 class=GrayFont>尾页</font> " & VbCrLf
		else
			PageSplictString = PageSplictString & " <a href=UserFriend.asp" & EndwriteQueryString & "&Start=" & LastID & ">下页</a> " & VbCrLf
			PageSplictString = PageSplictString & " <a href=UserFriend.asp" & EndwriteQueryString & "&Start=1&UpDownPageFlag=1>尾页</a> " & 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
		'		PageSplictString = PageSplictString & " 计<b>" & clng(recordCount/DEF_MaxListNum)+1 & "</b>页"
		'	Else
		'		PageSplictString = PageSplictString & " 计<b>1</b>页"
		'	End If
		'End If
		PageSplictString = PageSplictString & " 每页<b>" & DEF_MaxListNum & "</b>个"
	
	End If
	%>
	
	<script language=javascript>
		function kill(killID)
		{
			window.open('DelFriend.asp?BoardID=<%=GBL_board_ID%>&DelID='+killID,'','width=450,height=37,scrollbars=auto,status=no');
		}
		function killall(str)
		{
			window.open('DelFriend.asp?kasdie=3&ClearFlag='+str,'','width=450,height=37,scrollbars=auto,status=no');
		}
		function addfriend(id)
		{
			window.open('../announce/AddFriend.asp?BoardID=<%=GBL_board_ID%>&AddSureFlag=yes&FriendName='+id,'','width=450,height=37,scrollbars=auto,status=no');
		}
	</script>
	<b>我的好友列表</b>
	<table width="100%" border="0" cellspacing="1" cellpadding="2" bordercolor="#000000" bgcolor=<%=DEF_BBS_LightColor%> class=TBBG1>
	  <tbody> 
	  <tr height="19" bgcolor=<%=DEF_BBS_TableHeadColor%> class=TBfour align=center>
	    <td width=<%=DEF_AllFaceMaxWidth%> align=center><b><font class=HeadFont>头像</font></b></td>
	    <td><img src=../images/blank.gif width=11 height=3><br>&nbsp;<b><font class=HeadFont>用户名</font></b>&nbsp;</td>
	    <td align=center><img src=../images/null.gif width=2 height=2><br><font class=HeadFont><b>邮箱</b></font></td>
	    <td align=left><img src=../images/null.gif width=5 height=2><br><font class=HeadFont><b>最后浏览时间</b></font></td>
	    <td align=left>&nbsp;</td>
	    <td width=20 align=center><font class=HeadFont><b>删</b></font></td>
	  </tr>
	<%
	If Num = -1 Then
		response.write "<tr bgcolor=" & DEF_BBS_LightestColor & " class=TBBG9><td colspan=6 height=30>&nbsp; 没有任何好友!</td></tr>"
	end if

	Dim TempN,Temp,Temp1
	
	if Num <> -1 then
		i=1
		LastID = GetData(0,ubound(getdata,2))
		For n = MinN to MaxN Step StepValue
			Response.Write "<tr height=19 bgcolor=" & DEF_BBS_LightestColor & " class=TBBG9 align=center><td align=center>"
			If DEF_AllDefineFace = 0 or GetData(5,N) & "" = "" Then
				If GetData(4,N)<>"" and isNumeric(GetData(4,N)) Then
					Response.Write "<img src=../images/face/" & string(4-len(cstr(GetData(4,N))),"0")&GetData(4,N) & ".gif align=absmiddle width=62 height=62>"
				Else
					Response.Write "<img src=../images/null.gif align=absmiddle>"
				End If
			Else
				Response.Write "<img src=""" & htmlencode(GetData(5,N)) & """ align=absmiddle width=" & GetData(6,N) & " height=" & GetData(7,N) & ">"
			End If
			Response.Write "</td><td>&nbsp;<a href=LookUserinfo.asp?name=" & htmlencode(GetData(0,n)) & ">" & htmlencode(GetData(0,n)) & "</a>"

			Response.Write "</td><td align=center>&nbsp;"
			Response.Write "&nbsp;<a href=""mailto:." & htmlencode(GetData(1,n)) & """>" & htmlencode(GetData(1,n)) & "</a>"
			Response.Write "</td><td align=center>&nbsp;" & RestoreTime(GetData(3,n)) & "</td>"
			Response.Write "<td align=center><a href=""SendMessage.asp?SdM_ToUser=" & htmlencode(GetData(0,n)) & """><img src=../images/" & GBL_DefineImage & "message.GIF border=0 title=给" & htmlencode(GetData(0,n)) & "发消息 align=absmiddle width=16 height=16></a></td>"
			Response.Write "<td align=center><a href='javascript:kill(" & urlencode(GetData(8,n)) & ");'><img src=../images/" & GBL_DefineImage & "Del.GIF border=0 title=删除此好友 align=absmiddle width=16 height=16></a></td>"
			Response.Write "</tr>" & VbCrLf
			i=i+1
		next
	End If
	Response.Write "<tr bgcolor=" & DEF_BBS_TableHeadColor & " class=TBfour><td colspan=6>" & PageSplictString
	Response.Write "&nbsp;<a href='javascript:addfriend("""");'>添加好友</a>"
	%>
	&nbsp;<a href='javascript:killall("dkeJje5");'><img src=../images/<%=GBL_DefineImage%>clear.gif width=16 border=0 align=absmiddle>清空好友</a>
	<%If GBL_UserID>0 and CheckSupervisorUserName = 1 Then%><a href='javascript:killall("dkeJje6");'><img src=../images/<%=GBL_DefineImage%>clear.gif width=16 border=0 align=absmiddle title=添空所有人的好友列表>清空全部</a><%End If%>
	<%Response.Write "</td></tr>"
	%>
	      </table>
	      <br><a href=UserFriendMe.asp>查看添加我为好友的用户</a> <a href=UserFriend.asp?need=23>查看我的在线好友</a><%

End Function


Function DisplayCenter2

	Dim Rs,SQL
	'SQL = "select TOP "&DEF_MaxListNum&" T2.UserName,T2.Mail,T2.Sex,T2.LastDoingTime,T2.Userphoto,T2.FaceUrl,T2.FaceWidth,T2.FaceHeight,T1.ID from LeadBBS_FriendUser as T1 inner join LeadBBS_User as T2 on T1.FriendUserID=T2.ID " & SQLendString
	SQL = "select T2.UserName,T2.AtUrl,T2.AtInfo,T2.LastDoingTime,T2.StartTime,T1.ID from LeadBBS_FriendUser as T1 inner join LeadBBS_onlineUser as T2 on T1.FriendUserID=T2.UserID where T1.UserID=" & GBL_UserID
	Set Rs = Con.ExeCute(SQL)
	GBL_DBNum = GBL_DBNum + 1
	Dim Num
	Dim GetData
	If Not rs.Eof Then
		GetData = Rs.GetRows(DEF_MaxListNum)
		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)
		MinN = 0
		MaxN = SQL
		StepValue = 1
	
		Dim EndwriteQueryString,PageSplictString
		EndwriteQueryString = "?ID=" & GBL_ID
		PageSplictString = PageSplictString & "&nbsp;共<b>" & SQL + 1 & "</b>个在线好友"
	End If
	%>
	
	<script language=javascript>
		function kill(killID)
		{
			window.open('DelFriend.asp?BoardID=<%=GBL_board_ID%>&DelID='+killID,'','width=450,height=37,scrollbars=auto,status=no');
		}
		function killall(str)
		{
			window.open('DelFriend.asp?kasdie=3&ClearFlag='+str,'','width=450,height=37,scrollbars=auto,status=no');
		}
		function addfriend(id)
		{
			window.open('../announce/AddFriend.asp?BoardID=<%=GBL_board_ID%>&AddSureFlag=yes&FriendName='+id,'','width=450,height=37,scrollbars=auto,status=no');
		}
	</script>
	<b>我的在线好友</b>
	<table width="100%" border="0" cellspacing="1" cellpadding="2" bordercolor="#000000" bgcolor=<%=DEF_BBS_Color%> class=TBtwo>
	  <tbody> 
	  <tr height="19" bgcolor=<%=DEF_BBS_TableHeadColor%> class=TBfour>
	    <td><img src=../images/blank.gif width=11 height=3><br>&nbsp;<b><font class=HeadFont>用户名</font></b>&nbsp;</td>
	    <td><img src=../images/null.gif width=2 height=2><br>&nbsp;<font class=HeadFont><b>当前状态</b></font></td>
	    <td align=left><img src=../images/null.gif width=5 height=2><br>&nbsp;<font class=HeadFont><b>最后浏览时间</b></font></td>
	    <td align=left><img src=../images/null.gif width=5 height=2><br><font class=HeadFont><b><img src=../images/<%=GBL_DefineImage%>message.GIF border=0 title=发送短消息 align=absmiddle width=16 height=16></b></font></td>
	    <td width=20 align=center><font class=HeadFont><b>删</b></font></td>
	  </tr>
	<%
	If Num = -1 Then
		response.write "<tr bgcolor=" & DEF_BBS_LightestColor & " class=TBBG9><td colspan=6 height=30>&nbsp; 没有任何好友!</td></tr>"
	end if

	Dim TempN,Temp,Temp1
	
	if Num <> -1 then
		i=1
		for n= MinN to MaxN Step StepValue
			Response.Write "<tr height=19 bgcolor=" & DEF_BBS_LightestColor & " class=TBBG9>"
			Response.Write "<td width=96>&nbsp;<a href=LookUserinfo.asp?name=" & htmlencode(GetData(0,n)) & ">" & htmlencode(GetData(0,n)) & "</a>"
			Response.Write "</td><td>&nbsp;"
			Response.Write "<a href=""" & htmlencode(GetData(1,n)) & """>" & htmlencode(GetData(2,n)) & "</a>"
			Response.Write "</td><td>&nbsp;" & RestoreTime(GetData(3,n)) & "</td>"
			Response.Write "<td><a href=""SendMessage.asp?SdM_ToUser=" & htmlencode(GetData(0,n)) & """><img src=../images/" & GBL_DefineImage & "message.GIF border=0 title=给" & htmlencode(GetData(0,n)) & "发消息 align=absmiddle width=16 height=16></a></td>"
			Response.Write "<td><a href='javascript:kill(" & urlencode(GetData(5,n)) & ");'><img src=../images/" & GBL_DefineImage & "Del.GIF border=0 title=删除此好友 align=absmiddle width=16 height=16></a></td>"
			Response.Write "</tr>" & VbCrLf
			i=i+1
		next
	End If
	If PageSplictString <> "" Then Response.Write "<tr bgcolor=" & DEF_BBS_TableHeadColor & " class=TBfour><td colspan=6>" & PageSplictString & "</td></tr>"
	%>
	      </table>
	      <br><a href=UserFriendMe.asp>查看添加我为好友的用户</a> <a href=UserFriend.asp>查看我的所有好友列表</a><%

End Function

Sub DisplayOnlineFriend

	Dim ActiveUsers
	ActiveUsers = 0

	%>
<table width=100%>
<script language=javascript>
var n=1;
var rguser=0;

function s(GetData0,GetData1,GetData2)
{
	var tempstr = ""
	if(GetData0 == "")return;
	if(n==1)tempstr+="<tr>";
	tempstr+="<td>&nbsp;";
	if(GetData1 == null || trim(GetData1) == "")
	{
		tempstr+="<font color=#8888ff>※</font><a href=LookUserMoreInfo.asp?OlID=" + GetData0 + ">游客</a></td>";
	}
	else
	{
		rguser+=1;
		if (GetData1 == "隐身会员")
		{
			tempstr+="<font color=gray class=GrayFont>※</font><a href=LookUserMoreInfo.asp?OlID=" + GetData0 + ">隐身会员</a></td>";
		}
		else
		{
			if(parseInt(GetData2)&(1<<(10-1))){tempstr+="<font color=Red class=RedFont>●</font>";}
			else
			{
				if(parseInt(GetData2)&(1<<(8-1))){tempstr+="<font color=Blue class=BlueFont>●</font>";}
				else
				{
					if(parseInt(GetData2)&(1<<(2-1))){tempstr+="<font color=Green class=GreenFont>●</font>";}
					else{tempstr+="<font color=green class=GreenFont>※</font>";}
				}
			}
			tempstr+="<a href='LookUserInfo.asp?name=" + GetData1 + "'>" + GetData1 + "</a></td>";
		}
	}
	n+=1;
	if(n>6)
	{
		tempstr+="</tr>";
		n=1;
	}
	document.write(tempstr);
}
function trim(str)
{
	var re = /( )/gi;
	var rv = str.replace(re,"");
	return(rv);
}
<%
	Dim Temp
	Temp = 0
	If ActiveUsers < Num + 1 Then ActiveUsers = Num + 1

	Dim Rs,SQL
	SQL = "select T2.ID,T2.UserName,T2.HiddenFlag,T2. from LeadBBS_FriendUser as T1 inner join LeadBBS_onlineUser as T2 on T1.FriendUserID=T2.UserID where T1.UserID=" & GBL_UserID

	Set Rs = Con.ExeCute(SQL)
	GBL_DBNum = GBL_DBNum + 1
	Dim Num
	Dim GetData
	If Not rs.Eof Then
		Response.Write "s("""
		Response.Write Rs.GetString(,,""",""",""");" & VbCrLf & "s(""","")
		'Response.Write Rs.GetString(,,""",",");" & VbCrLf & "s(""","")
		Response.Write ""","""",0);"
	Else
		Num = -1
	End If
	Rs.close
	Set Rs = Nothing

	If ActiveUsers < Num Then ActiveUsers = Num
	Temp = Num
	If isNumeric(application(DEF_MasterCookies & "ActiveUsers")) = 0 Then
		Application.Lock
		application(DEF_MasterCookies & "ActiveUsers") = 0
		Application.UnLock
	End If
	If application(DEF_MasterCookies & "ActiveUsers") < Temp Then
		Application.Lock
		application(DEF_MasterCookies & "ActiveUsers") = Temp
		Application.UnLock
	End If
	Response.Write "var online=" & cCur(application(DEF_MasterCookies & "ActiveUsers")) & ";" & VbCrLf & "if(online<rguser)online=rguser;" & VbCrLf
	Response.Write "document.write(""<tr><td colspan=7><img src=../images/null.gif width=2 height=4><br>&nbsp;目前论坛总共有 "" + online + "" 人在线。"
	Response.Write "其中好友 "" + rguser + "" 人 <a href=UserFriend.asp>点击这里查看我的所有好友</a>"
	Response.Write "</td></tr>"");"
%>
</script>
</table>
<%

End Sub
%>