<!-- #include file="setup.asp" -->
<%
if Request.Cookies("username")=empty then error2("您还未登录论坛")

id=int(Request.QueryString("id"))
username=HTMLEncode(Trim(Request.Cookies("username")))

if newmessage>0 then
conn.execute("update [user] set newmessage=0 where username='"&username&"'")
end if
usemuch=conn.execute("select count(id) from [message]  where (author='"&username&"' and mess<>1) or incept='"&username&"'" )(0)

if Request("menu")="online" then
%>


<SCRIPT>
<%
If conn.Execute("Select username From [online] where username='"&username&"'" ).eof Then
response.write "parent.online.innerHTML='离线'"
else
response.write "parent.online.innerHTML='在线'"
end if
%>
</SCRIPT>
<%
responseend

end if



if Request("menu")="post" then
	if (usemuch>=(membercode+0.1)*50) then
	error2("您的邮箱已满")
	end if
%>
<title>发送讯息</title>
<SCRIPT>
function check(theForm) {

if(theForm.incept.value == "" ) {
alert("昵称不能没有填写！");
return false;
}

if(theForm.incept.value == "<%=Request.Cookies("username")%>" ) {
alert("请输入您要发送的对象，不能发讯息给自己！");
return false;
}

if(theForm.incept.value == "免打扰服务名字" ) {
alert("区长正在工作中，请勿打扰，有事请论坛留言，谢谢合作！！！");
return false;
}

if(theForm.content.value == "" ) {
alert("不能发空讯息！");
return false;
}

if (theForm.content.value.length > 255){
alert("对不起，您的讯息不能超过 255 个字节！");
return false;
}

}

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


function DoTitle(addTitle) {
document.frames["hiddenframe"].location.replace("?menu=online&username="+addTitle+"");
document.form.incept.value=addTitle
}

function Check(){var Name=document.form.incept.value;
if(Name == ""){alert("昵称不能为空！");return false;}
window.open("friend.asp?menu=post&log=1&incept="+Name+"&content="+document.form.content.value+"","_blank","width=320,height=270");window.close()
}

function bQX_onclick() {
    window.close();
}

function submit1_onclick() {
    if (form.content.value == '') {
        window.alert('对不起，您不能发空留言！');
        return;
    }
	form.submit1.disabled = true;
    form.submit();    
}


function content_onkeyup() {
  form.tSY.value = 255 - form.content.value.length;
  if (form.tSY.value < 0) {
      form.tSY.value = 0;
  }    
  if (form.tSY.value < 20) {
      form.tSY.style.color = 'red';
  }
  else  {
      form.tSY.style.color = 'black';
  }        
}

function content_onkeypress() {
  if (form.tSY.value <= 0)  {
      event.returnValue = false;
  }      

}

function content_onpaste() {
    if (form.tSY.value <= 0)  {
        event.returnValue = false;
        return;
    }
    else  {     
        content_onkeyup();
    }    
}
function window_onunload() {
    if (window.opener != null) {
        window.opener.close();
    }
}

function content_onkeydown() {
    if (event.ctrlKey && (event.keyCode ==13)) submit1_onclick();
}

</SCRIPT><body topmargin=0>
<TABLE WIDTH=300 BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><form name=form action="friend.asp" method="post">
<input type="hidden" name="menu" value="addpost">
<TD height="35">
&nbsp;昵称：<input name="incept" type="text" size="10"></TD>
<TD height="35"><b><span id=online></span></b>
　</TD>
<TD align=right height="35">

<select onchange=DoTitle(this.options[this.selectedIndex].value)>


<%
if Request("report")="1" then
%>
<option>版主列表</option>
<SCRIPT>
var moderated="<%=Request("moderated")%>"
var list= moderated.split ('|'); 
for(i=0;i<list.length;i++) {
if (list[i] !=""){document.write("<option value="+list[i]+">"+list[i]+"</option>")}
}
</SCRIPT>
<%
else

%>
<option>好友列表</option>
<SCRIPT>
var moderated="<%=Conn.Execute("Select friend From [user] where username='"&Request.Cookies("username")&"'")(0)%>"
var list= moderated.split ('|'); 
for(i=0;i<list.length;i++) {
if (list[i] !=""){document.write("<option value="+list[i]+">"+list[i]+"</option>")}
}
</SCRIPT>
<%
end if

%>



</select>
 <td align=right>剩： 
        <input name="tSY" size="3" value=255 style="BACKGROUND-COLOR: #F7F7F7; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; BORDER-RIGHT: medium none; BORDER-TOP: medium none; COLOR: black">字&nbsp;</td></tr></table></td>
    </tr>
  <tr> 
    <TD VALIGN=top ALIGN=right colspan="3" bgcolor="F8F8F8"><TEXTAREA name="content" cols="39" rows="6" style="width:100%" LANGUAGE=javascript onkeyup="return content_onkeyup()" onkeypress="return content_onkeypress()" onpaste="return content_onpaste()" onkeydown="return content_onkeydown()"><%=Request("body")%></TEXTAREA></td>
  </tr>
  <tr> 
    <td height="28" bgcolor=#CDE1ED> 
      <div align="center">



<TABLE WIDTH=300 BORDER=0 CELLSPACING=0 CELLPADDING=0 height="30">
<tr ALIGN=center><TD>
<input onclick=javascript:Check() type="button" value="聊天记录">
</td><TD><input type="reset" value="取消发送" OnClick="window.close();"> </td><TD><input name=submit1 type="submit" value="发送讯息" onclick="return check(this.form)"></td>
</TR>
</TABLE>
      </div>
    </td>
  </tr>
</table></form>
<%
responseend

end if


top


if Request("menu")="del" then
conn.execute("delete from [message] where id="&id&" and incept='"&Request.Cookies("username")&"'")
error2("<li>删除成功")
elseif Request("menu")="alldel" then
conn.execute("delete from [message] where incept='"&Request.Cookies("username")&"'")
error2("已经成功清空收件箱")
end if
if Request("menu")="unsee" then conn.execute("update [message] set mess=1 where id="&id&" and author='"&Request.Cookies("username")&"'")
if Request("menu")="delall" then 
for each ho in request.form("UEid")
conn.execute("delete from [message] where id="&int(ho)&" and incept='"&username&"'")
next
succeed("<a href='javascript:history.go(-1)'><li>删除成功</a><meta http-equiv=refresh content=1;url=message.asp>")
end if
if Request("menu")="unseeall" then 

for each ho in request.form("UEid")
conn.execute("update [message] set mess=1 where id="&int(ho)&" and author='"&username&"'")
next
succeed("<a href='javascript:history.go(-1)'><li>删除成功</a><meta http-equiv=refresh content=1;url=message.asp?send=1>")
end if
%>



<table border=0 width=97% align=center cellspacing=1 cellpadding=4 class=a2>
<tr class=a3>
<td height=25>&nbsp;<img src=images/Forum_nav.gif>&nbsp; <%ClubTree%> → 控制面板</td>
</tr>
</table><br>

<script defer>
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>
<table cellspacing="1" cellpadding="1" width=97% align="center" border="0" class="a2">
  <TR id=TableTitleLink class=a1 height="25">
      <Td width="14%" align="center"><b><a href="usercp.asp">控制面板首页</a></b></td>
      <TD width="14%" align="center"><b><a href="EditProfile.asp">基本资料修改</a></b></td>
      <TD align="center"><b><a href="EditProfile.asp?menu=contact">联系资料修改</a></b></td>
      <TD width="14%" align="center"><b><a href="EditProfile.asp?menu=pass">用户密码修改</a></b></td>
      <TD width="14%" align="center"><b><a href="EditProfile.asp?menu=option">编辑论坛选项</a></b></td>
      <TD width="14%" align="center"><b><a href="message.asp">用户短信服务</a></b></td>
      <TD width="14%" align="center"><b><a href="friend.asp">编辑好友列表</a></b></td>
      </TR></TABLE>

<center>

<br>
<SCRIPT>valigntop()</SCRIPT>
<TABLE  cellSpacing=1 border=0 width="97%" class=a2 cellpadding="3">
<TR><TD align="center" bgcolor="FFFFFF" colspan=5>

          <a style="text-decoration: none; color: #000000" href="message.asp">
          <img alt src="images/m_inbox.gif" border="0" dypop="收件箱"></a>&nbsp;
          <a style="text-decoration: none; color: #000000" href="message.asp?send=1">
          <img alt src="images/M_issend.gif" border="0" dypop="已发送邮件"></a>&nbsp;
          <a href="message.asp?menu=alldel" onclick=checkclick('您确定要清空收件箱?')>
          <img alt src="images/recycle.gif" border="0" dypop="清空收件箱"></a>&nbsp;
          <a href="friend.asp">
          <img alt src="images/M_address.gif" border="0" dypop="发送讯息"></a>&nbsp;
          <a style=cursor:hand onclick="javascript:open('?menu=post','','width=320,height=170')"><img alt src="images/m_write.gif" border="0" dypop="发送讯息"></a></td></TR>
<TR><TD align="left" bgcolor="FFFFFF" colspan=5>
<%usemuch=conn.execute("select count(id) from message  where (author='"&username&"' and mess<>1) or incept='"&username&"'" )(0) 
if request.QueryString("send")="" then%><form method="post" action="?menu=delall">		<input type="submit" value="删除"><%end if%>	<% if request.QueryString("send")="1" then%><form method="post" action="?menu=unseeall">		<input type="submit" value="删除"><%end if%>　　您的信箱已使用<%=int(usemuch/(membercode+0.1)*2)%>%：	<img border=0 src=images/bar/message.gif width="<%=int(usemuch/(membercode+0.2)*10)%>" height=9 alt="<%=usemuch&"/"&(membercode*50)%>">
</td></TR>
  <TR>
          
    <TD vAlign=center align=middle   width=5% class=a1 height="20"><%if request.QueryString("send")<>"2" then%><input type=checkbox name=chkall onclick=CheckAll(this.form) value="ON"><%end if%></TD>
          
    <TD vAlign=center align=middle 
          width=12% class=a1 height="20"><B><span id=send>发件人</span></B></TD>
          
    <TD vAlign=center align=middle 
          width=50% class=a1 height="20"><B>内容</B></TD>
          
    <TD align=middle 
          width=17% class=a1 height="20"><B>日期</B></TD>
          
    <TD vAlign=center align=middle 
          width=16% class=a1 height="20"><B>操作[<a href=delnewmessage.asp>清除错误提示</a>]</B></TD>
  </TR>



<%

sql="select * from message where incept='"&Request.Cookies("username")&"' order by time Desc"
select case  Request.QueryString("send")
case  "1"
sql="select * from message where mess<>1 and author='"&Request.Cookies("username")&"' order by time Desc"
response.write "<script>send.innerText='收件人'</script>"
case "2"
sql="select * from message where mess=1 and author='"&Request.Cookies("username")&"' order by time Desc"
response.write "<script>send.innerText='收件人'</script>"
end select

rs.Open sql,Conn,1

pagesetup=30 '设定每页的显示数量
rs.pagesize=pagesetup
TotalPage=rs.pagecount  '总页数
PageCount = cint(Request.QueryString("ToPage"))
if PageCount <1 then PageCount = 1
if PageCount > TotalPage then PageCount = TotalPage
if TotalPage>0 then rs.absolutepage=PageCount '跳转到指定页数

i=0
Do While Not RS.EOF and i<pagesetup
i=i+1


if Request("send")="1" then
author=rs("incept")
del="<a style=cursor:hand onclick=javascript:open('friend.asp?menu=post&log=1&incept="&author&"','','width=320,height=270')>聊天记录</a> <a  href=?menu=unsee&id="&rs("id")&">删除</a>"

else
if Request("send")="2" then
author=rs("incept")
del="<a style=cursor:hand onclick=javascript:open('friend.asp?menu=post&log=1&incept="&author&"','','width=320,height=270')>聊天记录</a>"
else
author=rs("author")
del="<a style=cursor:hand onclick=javascript:open('friend.asp?menu=post&incept="&rs("author")&"','','width=320,height=170')><img alt='回复这个帖子' src=images/replynow.gif border=0></a> <a onclick=checkclick('您确定要删除此条讯息?') href=?menu=del&id="&rs("id")&"><img alt='删除该留言' src=images/del.gif border=0></a>"
end if

end if


%>



        <TR>
          
    <TD vAlign=center align=middle width="5%" bgcolor="FFFFFF"><% if request.QueryString("send")="2" then%>  <IMG    src="images/f_norm.gif"><%else %><INPUT type=checkbox value=<%=rs("id")%> name=UEid><%end if%></TD>
          
    <TD vAlign=center align=middle width="12%" bgcolor="FFFFFF"> <A href="Profile.asp?username=<%=author%>"><%=author%></A> 
      　</TD>
          
    <TD width="50%" bgcolor="FFFFFF">
<script>document.write(ybbcode("<%=rs("content")%>"))</script>
</TD>
    <TD align="center" width="17%" bgcolor="FFFFFF"><%=rs("time")%></FONT>　</TD>
          
    <TD align="center" width="16%" bgcolor="FFFFFF"> <%=del%> 　</TD>
  </TR>


<%
RS.MoveNext
loop
RS.Close
%>
</TD></TR>
</TABLE>
<SCRIPT>valignbottom()</SCRIPT><br>
Page：[
<script>
PageCount=<%=TotalPage%> //总页数
topage=<%=PageCount%>   //当前停留页
for (var i=1; i <= PageCount; i++) {
if (i <= topage+3 && i >= topage-3 || i==1 || i==PageCount){
if (i > topage+4 || i < topage-2 && i!=1 && i!=2 ){document.write(" ... ");}
if (topage==i){document.write(" "+ i +" ");}
else{
document.write("<a href=?send=<%=Request("send")%>&topage="+i+">"+ i +"</a> ");
}
}
}
</script>

]<br>
<tr>
<td><img src=images/skins/<%=Request.Cookies("skins")%>/endlogo.gif width=778></td>
</tr>
</TABLE>
