<!--#include file="User_Const.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<link rel="stylesheet" type="text/css" href="../Skins/User_Style.Css">
<script language = "JavaScript" src="../Inc/Js/Admin.js"></script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<%
dim tablebody,strErr,action
dim boxName,smscount,smstype,readaction,turl
dim MaxPerPage
MaxPerPage=60
action=Trim(request("action"))
CurrentPage=Trim(request("page"))
if Isnumeric(CurrentPage) then
    CurrentPage=Clng(CurrentPage)
else
	CurrentPage=1
end if
User_MsgNav
OpenConn_U
select case action
case "info"
	call info()
case "addF"
	call addF()
case "saveF"
	call saveF()
case "删除"
	call DelFriend()
case "清空好友"
	call AllDelFriend()
case else
	call info()
end select
CloseAllObj
'if founderr then User_ShowErr(ErrMsg)

sub info()
%>
<table cellpadding=3 cellspacing=1 align=center class=border>
<tr>
<td Class=title align=center valign=middle colspan=6>我的好友</td>
</tr>
<form action="User_Friend.asp" method=post name=inbox>
	<tr height="23" class="title2">
		<td align="center" width="25%">姓名</td>
		<td align="center" width="25%">邮件</td>
		<td align="center" width="25%">主页</td>
		<td align="center" width="10%">QQ</td>
		<td align="center" width="10%">发短信</td>
		<td align="center" width="5%">操作</td>
	</tr>
<%
	set rs=server.createobject("adodb.recordset")
	sql="select F.*,U."&Db.UserEmail&",U."&Db.UserIM&" from " & Db.FriendTable & " F inner join "&Db.UserTable&" U on F.F_Friend=U."&Db.UserName&" where F.F_username='"&Cl.User_Info(5)&"' order by F.f_addtime desc"
	rs.open sql,Conn_U,1,1
	if rs.eof and rs.bof then
%>
                <tr>
                <td Class=tdbg align=center valign=middle colspan=6>您的好友列表中没有任何内容。</td>
                </tr>
		
<%else%>
<%do while not rs.eof
	dim UserIM
	UserIM=split(rs(Db.UserIM),"|||")
%>
                <tr>
                    <td align=center valign=middle Class=tdbg><a href="Info.Asp?UserName=<%=Cl.HTMLEncode(rs("F_friend"))%>" target=_blank><%=Cl.HTMLEncode(rs("F_friend"))%></a></td>
                    <td align=center valign=middle Class=tdbg><a href="mailto:<%=Cl.HTMLEncode(rs("UserEmail"))%>"><%=Cl.HTMLEncode(rs("UserEmail"))%></a></td>
                    <td align=center Class=tdbg><a href="<%=Cl.HTMLEncode(UserIM(0))%>" target=_blank><%=Cl.HTMLEncode(UserIM(0))%></a></td>
                    <td align=center Class=tdbg><%=Cl.HTMLEncode(UserIM(1))%></td>
                    <td align=center Class=tdbg><a href="User_Message.asp?action=new&touser=<%=Cl.HTMLEncode(rs("f_friend"))%>">发送短信</a></td>
                <td align=center Class=tdbg><input type=checkbox name=id value=<%=rs("f_id")%>></td>
                </tr>
<%
	rs.movenext
	loop
	end if
	rs.close
	set rs=Nothing
%>
                
        <tr> 
          <td align=right valign=middle colspan=6 Class=tdbg><input type=checkbox name=chkall value=on onclick="CheckAll(this.form)">选中所有显示记录&nbsp;<input type=button name=action onclick="location.href='User_Friend.asp?action=addF'" value="添加好友">&nbsp;<input type=submit name=action onclick="{if(confirm('确定删除选定的纪录吗?')){this.document.inbox.submit();return true;}return false;}" value="删除">&nbsp;<input type=submit name=action onclick="{if(confirm('确定清除所有的纪录吗?')){this.document.inbox.submit();return true;}return false;}" value="清空好友"></td>
		</tr>
		</form>
		</table>
<script language=javascript>
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)    {
var e = form.elements[i];
if (e.name != 'chkall')       e.checked = form.chkall.checked; 
}
}
</script>
<%
end sub

sub delFriend()
dim delid
delid=replace(request.form("id"),"'","")
if delid="" or isnull(delid) then
	Call Cl.OutMsg("您已经删除选定的好友记录。","javascript:history.go(-1)")
	exit sub
else
	Cl.Execute_U("delete * from " & Db.FriendTable & " where F_username='"&Cl.User_Info(5)&"' and F_id in ("&delid&")")
	Call Cl.OutMsg("您已经删除选定的好友记录。","User_Friend.asp")
end if
end sub

sub AllDelFriend()
	Cl.Execute_U("delete * from " & Db.FriendTable & " where F_username='"&Cl.User_Info(5)&"'")
	Call Cl.OutMsg("您已经删除了所有好友列表。","User_Friend.asp")
end sub

sub addF()
call userlist()
response.write Cl.ShowPage("User_Friend.asp?Action="&action,TotalPut,MaxPerPage,"个","用户")
%>
<br>
<table cellpadding=3 cellspacing=1 align=center class=border>
	<form action="User_Friend.asp" method=post name=messager>
          <tr> 
            <td class="title" colspan=2 align=center> 
              <input type=hidden name="action" value="saveF">
              加入好友--请完整输入下列信息</td>
          </tr>
          <tr height=50> 
            <td Class=tdbg valign=middle width=70><b>好友：</b></td>
            <td Class=tdbg valign=middle>
              <input type=text name="touser" size=50 value="<%=request("myFriend")%>">
			  &nbsp;使用逗号（,）分开，最多5位用户
            </td>
          </tr>
          <tr> 
            <td valign=middle colspan=2 align=center Class=tdbg> 
              <input type=Submit value="保存" name=Submit>
              &nbsp; 
              <input type="reset" name="Clear" value="清除">
            </td>
          </tr>
		</form>
 </table><br>
<%
end sub

sub saveF()
dim incept,i
if request("touser")="" then
	Call Cl.OutMsg("您忘记填写发送对象了吧。","javascript:history.go(-1)")
	exit sub
else
	incept=Cl.Checkstr(request("touser"))
	incept=split(incept,",")
end if

for i=0 to ubound(incept)
set rs=server.createobject("adodb.recordset")
sql="select "&Db.UserName&" from "&Db.UserTable&" where "&Db.UserName&"='"&incept(i)&"'"
set rs=Cl.Execute_U(sql)
if rs.eof and rs.bof then
	Call Cl.OutMsg("系统没有（"&incept(i)&"）这个用户，操作未成功。","javascript:history.go(-1)")
	exit sub
end if
set rs=Nothing

if Cl.User_Info(5)=Trim(incept(i)) then
	Call Cl.OutMsg("不能把自已添加为好友。","javascript:history.go(-1)")
end if

sql="select F_friend from " & Db.FriendTable & " where F_username='"&Cl.User_Info(5)&"' and  F_friend='"&incept(i)&"'"
set rs=Cl.Execute_U(sql)
if rs.eof and rs.bof then
	sql="insert into " & Db.FriendTable & " (F_username,F_friend,F_addtime) values ('"&Cl.User_Info(5)&"','"&Trim(incept(i))&"',"&SqlNowString_U&")"
	set rs=Cl.Execute_U(sql)
end if
if i>5 then
	Call Cl.OutMsg("每次最多只能添加5位用户，您的名单5位以后的请重新填写。","javascript:history.go(-1)")
	exit sub
	exit for
end if
next

Call Cl.OutMsg("恭喜您，好友添加成功。","User_Friend.asp")
end sub

sub userlist()
response.write "<table class=border align=center cellpadding=2 cellspacing=1 border=0><tr class=title><td>管理员组:</td></tr></table>"
response.write "<table class=border align=center cellpadding=2 cellspacing=1 border=0><tr class=tdbg>"
dim admin_face
sql="select "&Db.UserName&","&Db.UserSex&","&Db.UserIM&","&Db.UserEmail&" from "&Db.UserTable&" where "&Db.UserLevel&"=1 order by UserID"
set rs=Cl.Execute_U(sql)
i=0
do while not rs.eof
admin_face="<img src=""../Images/Other/admin_face.gif"" width=24 height=30>"
if Cl.User_Info(5)=rs(0) then
	response.write "<td width=""14%"">" & admin_face&"&nbsp;<a href=User_Friend.asp?action=saveF&touser="&rs(0)&" title=""管理员""><font color=""#0000ff"">"&rs(0)&"</font></a></td>"
else
	response.write "<td width=""14%"">" & admin_face&"&nbsp;<a href=User_Friend.asp?action=saveF&touser="&rs(0)&" title=""管理员"">"&rs(0)&"</a></td>"
end if
i=i+1
if i>=6 then
	response.write "</tr><tr>"
	i=0
end if
rs.movenext
loop
response.write "</tr></TABLE><br>"
set rs=Nothing

response.write "<table class=border align=center cellpadding=2 cellspacing=1 border=0><tr class=title><td>普通用户组:</td></tr></table>"
response.write "<table class=border align=center cellpadding=2 cellspacing=1 border=0><tr class=tdbg>"
dim user_face,user_info,sex,i,n
sql="select "&Db.UserName&","&Db.UserSex&","&Db.UserIM&","&Db.UserEmail&" from "&Db.UserTable&" where "&Db.UserLevel&"<>1 order by UserID"
set rs=Server.CreateObject("adodb.recordSet")
rs.Open sql,Conn_U,1,1
i=0:n=0:TotalPut=0
if not (rs.bof and rs.eof) then
	TotalPut=rs.recordcount
	if (TotalPut mod MaxPerPage)=0 then
		TotalPages = TotalPut \ MaxPerPage
	else
		TotalPages = TotalPut \ MaxPerPage + 1
	end if
	if CurrentPage > TotalPages then CurrentPage=TotalPages
	if CurrentPage < 1 then CurrentPage=1
	rs.move (CurrentPage-1)*MaxPerPage
	do while not rs.eof
	if rs(1)=1 then
		sex="男"
	else
		sex="女"
	end if
	user_info="性别："& sex & vbcrlf & "Q&nbsp;&nbsp;Q："& Split(rs(2),"|||")(1) & vbcrlf &"Email："& rs(3)
	user_face="<img src="""&Cl.WebDir&"images/Other/user_face.gif"" width=12 height=11>"
	if Cl.User_Info(5)=rs(0) then
		response.write "<td width=""14%"">" & user_face&"&nbsp;<a href=User_Friend.asp?action=saveF&touser="&rs(0)&" title="""& user_info &"""><font color=""#0000ff"">"&rs(0)&"</font></a></td>"
	else
		response.write "<td width=""14%"">" & user_face&"&nbsp;<a href=User_Friend.asp?action=saveF&touser="&rs(0)&" title="""& user_info &""">"&rs(0)&"</a></td>"
	end if
	i=i+1
	if i>=6 then 
		if i=6 then response.write "</tr><tr class=tdbg>"
		i=0
	end if
	n=n+1
	if n>= MaxPerPage then Exit Do
	rs.movenext
	loop
else
	response.write "<td>无任何用户</td>"
end if
response.write "</tr></TABLE><br>"
set rs=Nothing
end sub
%>
</body>
</html>
<%
'===================================================
' CreateLive CMS Version 3.1
'							Powered by Aspoo.CoM
'===================================================
' Mail: aspoo@126.com, Info@aspoo.cn
' Q  Q: 3315263, 596197794
' Msn : aspoo@126.com, Clw866@hotmail.com
' Web : http://www.aspoo.com, http://www.aspoo.net
' Bbs : http://bbs.aspoo.com, http://bbs.aspoo.net
' Copyright (C) 2005 Aspoo.CoM All Rights Reserved.
'===================================================
%>