<!-- #include file="Setup.asp" -->
<%
if CookieUserName=empty then error2("请登录后才能使用此功能！")
incept=HTMLEncode(Request("incept"))
UserName=HTMLEncode(Request("UserName"))
ParentID=int(Request("ParentID"))
IsPublish=int(Request("IsPublish"))

select case Request("menu")
case "add"
add
case "bad"
bad
case "Del"
Del
case "Post"
Post
case "look"
look
case "loadLog"
loadLog
case "addPost"
addPost
case ""
index
end select



sub add
if UserName="" then error2("请输入您要添加的好友名字！")

if UserName=CookieUserName then error2("不能添加自己！")

If Conn.Execute("Select id From [BBSXP_Users] where UserName='"&UserName&"'" ).eof Then error2("数据库不存在此用户的资料！")

sql="select UserFriend from [BBSXP_Users] where ID="&CookieUserID&""
Rs.Open sql,Conn,1,3
master=split(""&Rs("UserFriend")&"","|")
if ubound(master) > 20 then error2("系统允许最多添加20个好友，您已经达到上限")
if instr(Rs("UserFriend"),"|"&UserName&"|")>0 then error2("此好友已经添加！")
Rs("UserFriend")=""&Rs("UserFriend")&""&UserName&"|"
Rs.update
Rs.close
error2("已经成功添加好友!")
end sub


sub Del
sql="select UserFriend from [BBSXP_Users] where ID="&CookieUserID&""
Rs.Open sql,Conn,1,3
Rs("UserFriend")=replace(Rs("UserFriend"),"|"&UserName&"|","|")
Rs.update
Rs.close
index
end sub

sub look

Conn.execute("update [BBSXP_Users] set NewMessage=0 where ID="&CookieUserID&"")

Page=Request("Page")
if Page<1 then
disabled="disabled=true"
Page=0
end if
count=Conn.execute("Select count(id)from [BBSXP_Messages] where incept='"&CookieUserName&"'")(0)
sql="select * from [BBSXP_Messages] where incept='"&CookieUserName&"' order by id Desc"
Set Rs=Conn.Execute(sql)

if Count-Page<2 then disabled2="disabled=true"

if Rs.eof then error2("您没有短讯息！")

Rs.Move Page
%>
<title>查看消息</title>
<body topmargin=0 class="footerSection">
<TABLE WIDTH=300 BORDER=0 CELLSPACING=0 CELLPADDING=0><TR class="nsf"><TD>&nbsp;昵称：<input readOnly type="text" value="<%=Rs("UserName")%>" size="8">
</TD><TD align=right><a target=_blank href=Profile.asp?UserName=<%=Rs("UserName")%>>

<select size="1">
<option value="0" <%if RS("IsPublish")=0 then%>selected<%end if%>>悄悄话</option>
<option value="1" <%if RS("IsPublish")=1 then%>selected<%end if%>>公开</option>
</select>
</TD></TR><TR class=a3><TD VALIGN=top ALIGN=right colspan="2">
<script>
document.write ('<iframe id="HtmlEditor"  MARGINHEIGHT=1 MARGINWIDTH=1 height="100" width=100% frameborder=1></iframe>')
var IframeID=document.getElementById("HtmlEditor").contentWindow;
IframeID.document.open();
IframeID.document.write('<%=Rs("content")%>');
IframeID.document.close();
IframeID.document.body.style.fontSize="10pt";
</script>

</TD></TR></TABLE>
<TABLE WIDTH=300 BORDER=0 CELLSPACING=0 CELLPADDING=0 height="30">
<tr ALIGN=center><TD><input type="button" value="回复讯息" onclick=javascript:OpenFriendWindow('MyFriend.asp?menu=Post&incept=<%=Rs("UserName")%>&ParentID=<%=Rs("ID")%>','_top','toolbar=no')>
</td><TD><input type="button" value="<<上一条" <%=disabled%> onclick=javascript:OpenFriendWindow('MyFriend.asp?menu=look&Page=<%=Page-1%>','_top','')> </td><TD><input type="button" value="下一条>>" <%=disabled2%> onclick=javascript:OpenFriendWindow('MyFriend.asp?menu=look&Page=<%=Page+1%>','_top','')>
</td>
</TR></TABLE>

<%
end sub

sub loadLog
sql="select * from [BBSXP_Messages] where (UserName='"&CookieUserName&"' and incept='"&incept&"') or (UserName='"&incept&"' and incept='"&CookieUserName&"') order by id Desc"
Set Rs=Conn.Execute(sql)
do while not Rs.eof
content=content&"<font color=red>("&Rs("DateCreated")&")　　"&Rs("UserName")&"</font><br><font color=0000FF>"&Rs("content")&"</font><br>"
Rs.Movenext
loop
Rs.close
if content="" then content="(空)"
%>
<script>
var Log=parent.document.getElementById("Log")
Log.innerHTML='<iframe id="HtmlEditor"  MARGINHEIGHT=1 MARGINWIDTH=1 height="100" width=100% frameborder=1></iframe>'
IframeID=parent.document.getElementById("HtmlEditor").contentWindow;
IframeID.document.open();
IframeID.document.write("<body bgcolor=#FFFFFF><%=content%></body>");
IframeID.document.close();
IframeID.document.body.style.fontSize="10pt";
</script>
<%
end sub

sub Post

%>
<iframe frameborder=0 height=0 width=0 name=hiddenframe></iframe>
<body topmargin=0 class="footerSection">
<title>发送讯息</title>

<TABLE WIDTH=300 BORDER=0 CELLSPACING=0 CELLPADDING=0><TR class="nsf">
<form name=form action="MyFriend.asp" method="POST">
<input type="hidden" name="menu" value="addPost">
<input type="hidden" name="ParentID" value="<%=ParentID%>">

<TD>
&nbsp;昵称：<input name="incept" type="text" value="<%=incept%>" size="8"></TD><TD align=right>

<%if Request("Moderated")<> "" then%>
<select onchange=document.form.incept.value=this.options[this.selectedIndex].value>
<option value="">版主列表</option>
<SCRIPT>
var UserList="<%=Request("Moderated")%>"
var list= UserList.split ('|'); 
for(i=0;i<list.length;i++) {
if (list[i] !=""){document.write("<option value="+list[i]+">"+list[i]+"</option>")}
}
</SCRIPT>
</select>
<%end if%>


<%if Request("FriendList")<> "" then%>
<select onchange=document.form.incept.value=this.options[this.selectedIndex].value>
<option value="">好友列表</option>
<SCRIPT>
var UserList="<%=Conn.Execute("Select UserFriend From [BBSXP_Users] where ID="&CookieUserID&"")(0)%>"
var list= UserList.split ('|'); 
for(i=0;i<list.length;i++) {
if (list[i] !=""){document.write("<option value="+list[i]+">"+list[i]+"</option>")}
}
</SCRIPT>
</select>
<%end if%>



<select size="1" name="IsPublish">
<option value="0">悄悄话</option>
<option value="1" <%if Request("IsPublish")=1 then%>selected<%end if%>>公开</option>
</select>


</TD></TR><TR class=a3><TD VALIGN=top ALIGN=right colspan="2">
<textarea name="content" style="width:99%;height:90px"><%=HTMLEncode(Request("body"))%></textarea>
</TD></TR></TABLE><TABLE WIDTH=300 BORDER=0 CELLSPACING=0 CELLPADDING=0 height="30">
<tr ALIGN=center><TD><input type="button" value="聊天记录" onclick=lookLog(); name=LookLogButton>
</td><TD><input type="reset" value="取消发送" OnClick="window.close();"> </td><TD><input type="submit" value="发送讯息"></td>
</TR></form>
</TABLE>

<span id=Log></span>
<script>
function lookLog(){
resizeTo(330,310)
frames["hiddenframe"].location.replace("?menu=loadLog&incept=<%=incept%>");
document.form.LookLogButton.disabled = true;
}

function presskey(eventobject){if(event.ctrlKey && window.event.keyCode==13){this.document.form.submit();}}

<%if Request("Log")=1 then%>lookLog()<%end if%>
</script>


<%


end sub

sub addPost

if incept="" then error2("请输入发送的对象")
if Len(Request.Form("content"))<2 then error2("内容不能小于 2 字符")
If Conn.Execute("Select id From [BBSXP_Users] where UserName='"&incept&"'" ).eof Then error2("系统不存在"&incept&"的资料")

sql="insert into [BBSXP_Messages](UserName,incept,content,ParentID,IsPublish) values ('"&CookieUserName&"','"&incept&"','"&HTMLEncode(Request.Form("content"))&"',"&ParentID&","&IsPublish&")"
Conn.Execute(SQL)
if incept<>CookieUserName then Conn.execute("update [BBSXP_Users] set NewMessage=NewMessage+1 where UserName='"&incept&"'")

%><center><span class="nsf">发送成功！<br><br>3秒钟后自动关闭该窗口！</span></center>
<script>
window.setTimeout("window.close();",3000)
</script>
<%
end sub


sub index

top


sql="select UserName From [BBSXP_UsersOnline] where Eremite=0"
Set Rs=Conn.Execute(sql)
Do While Not Rs.EOF
OnlineUserList=OnlineUserList&""&Rs("UserName")&"|"
Rs.MoveNext
loop
Rs.close


%>

<SCRIPT>
var Onlinelist= "<%=Onlinelist%>";

function add(){
var id=prompt("请输入您要添加的好友名称！","");
if(id){
document.location='MyFriend.asp?menu=add&UserName='+id+'';
}
}
</SCRIPT>
<div class="mainnav">
<table cellspacing=1 cellpadding=5 border=0 width=100% class=a2>
<tr class=a3>
<td>&nbsp;<img src=images/Forum_nav.gif>&nbsp; <%ClubTree%> → 控制面板</td>
</tr>
</table>
<br>

<table cellspacing=1 cellpadding=5 border=0 width=100% class=a2>
	<TR id=TableTitleLink class=a1>
		<Td align="center"><b><a href="UserCp.asp">控制面板</a></b></td>
		<TD align="center"><b><a href="EditProfile.asp">资料修改</a></b></td>
		<TD align="center"><b><a href="EditProfile.asp?menu=pass">密码修改</a></b></td>
		<TD align="center"><b><a href="MySettings.asp">个性设置</a></b></td>
		<TD align="center"><b><a href="MyUpFiles.asp">上传管理</a></b></td>
		<TD align="center"><b><a href="MyFavorites.asp">管理书签</a></b></td>
		<TD align="center"><b><a href="MyMessage.asp">短信服务</a></b></td>
		<TD align="center"><b><a href="MyFriend.asp">好友列表</a></b></td>
	</TR>
</TABLE></div>
<br>

<form method="POST">
<input type=hidden name="menu" value="Del">
<div class="mainnav">
<table cellspacing=1 cellpadding=5 border=0 width=100% class=a2>
  <tr>
    <td class=a1 align="center">昵称 </td>
    <td class=a1 align="center" width="80"> 邮件 </td>
    <td class=a1 align="center" width="80"> 主页</td>
    <td class=a1 align="center" width="80">共享空间 </td>
    <td class=a1 align="center" width="80">个人帖子</td>

    <td class=a1 align="center" width="80">发短信 </td>
        <td class=a1 align="center">状态 </td>
    <td class=a1 align="center">操作 </td>
  </tr>
<%

on error resume next '找不到好友资料时候忽略错误

sql="select UserFriend,Userface from [BBSXP_Users] where ID="&CookieUserID&""
Set Rs=Conn.Execute(sql)
master=split(Rs("UserFriend"),"|")
for i = 1 to ubound(master)-1


Set Rs1=Conn.Execute("[BBSXP_Users] where UserName='"&master(i)&"'")
UserMail=Rs1("UserMail")
Userhome=Rs1("Userhome")
Set Rs1 = Nothing


%>
  <tr class=a3>
    <td vAlign=center align=center><a href=Profile.asp?UserName=<%=master(i)%>><%=master(i)%></a>
    <td align=center><a href=Mailto:<%=UserMail%>><img border="0" src="Images/email.gif"></a>
　<td align="center"><a href=<%=Userhome%> target=_blank><img border="0" src="Images/home.gif"></a>
　<td align="center"><a href=Blog.asp?BlogUserName=<%=master(i)%> target=_blank><img border="0" src="Images/Blog.gif"></a>
    <td align="center"><a href=ShowBBS.asp?menu=5&UserName=<%=master(i)%> target=_blank><img border="0" src="Images/finds.gif"></a>
    <td align=center><a style=cursor:hand onclick="javascript:OpenFriendWindow('MyFriend.asp?menu=Post&incept=<%=master(i)%>')"><img border="0" src="Images/message.gif"></a></td>
    <td align=center><%if instr("|"&OnlineUserList&"","|"&master(i)&"|")>0 then%> 在 线 <%else%> 离 线 <%end if%></td>
    <td align=center><INPUT type=radio value=<%=master(i)%> name=UserName></td>
  </tr>
  
  
  

<%
next
Rs.close
%>


  
  

  
  <tr class=a3>
    <td vAlign="center" align="right" colSpan="8">
    <input onclick="javascript:add();" type="button" value="添加好友" name="action">&nbsp;<input onclick="return confirm('确定删除选定的好友吗?');" type="submit" value="删除"></td>
  </tr></form>
</table></div>

<%

htmlend
end sub

%>