<!--#INCLUDE FILE="conn.asp" -->
<!-- #include file="Class_Checkuser.asp" -->
<!--#INCLUDE FILE="Class_Top.asp" -->
<!--#include file="inc/char.asp"-->
<!--#include file="inc/ubbcode.asp"-->

<%locat="短消息"
%>
<script language="javascript">
function DoTitle1(addTitle) { 
var revisedTitle; 
var currentTitle = document.messager.touser.value; 
if(currentTitle!=''){
revisedTitle = currentTitle+','+addTitle; }
else{
revisedTitle=addTitle;
}
document.messager.touser.value=revisedTitle; 
document.messager.touser.focus(); 
return; }
</script>
<%
	Dim msg,ErrMsg,founderr

if membername="" Then
  	ErrMsg=ErrMsg+"<br>"+"<li>您还没有<a href=Class_Login.asp><font color=red>登录或注册校友录</font></a>。"
	Call top(1,1)
	Call Error("Information",ErrMsg)
	
Else


	Select Case Request("action")
	Case "inbox"
		Call top(1,1)
		Call inbox()
	Case "outbox"
		Call top(1,1)
		Call outbox()
	Case "issend"
		Call top(1,1)
		Call issend()
	Case "recycle"
		Call top(1,1)
		Call recycle()
	Case "new"
		act="发送短消息"
		Call top(1,1)
		Call sendmsg()
	Case "read"
		act="阅读短消息"
		Call top(1,1)
		Call read()
	Case "outread"
		act="阅读短消息"
		Call top(1,1)
		Call read()
	Case "delete"
		act="删除短消息"
		Call top(1,1)
		Call delete()
	Case "send"
		act="发送短消息"
		Call top(1,1)
		Call savemsg()
	Case "newmsg"
		Call top(1,1)
		Call newmsg()
	Case "fw"
		act="回复短消息"
		Call top(1,1)
		Call fw()
	Case "edit"
		act="编辑短消息"
		Call top(1,1)
		Call edit()
	Case "savedit"
		act="编辑短消息"
		Call top(1,1)
		Call savedit()
	Case "删除收件"
		act="删除收件"
		Call top(1,1)
		Call delinbox()
	Case "清空收件箱"
		act="清空收件箱"
		Call top(1,1)
		Call AllDelinbox()
	Case "删除发件"
		act="删除发件"
		Call top(1,1)
		Call deloutbox()
	Case "清空发件箱"
		act="清空发件箱"
		Call top(1,1)
		Call AllDeloutbox()
	Case "删除已发信息"
		act="删除已发信息"
		Call top(1,1)
		Call delissend()
	Case "清空已发送信息"
		act="清空已发送信息"
		Call top(1,1)
		Call AllDelissend()
	Case "删除指定信息"
		act="删除回收站内信息"
		Call top(1,1)
		Call delrecycle()
	Case "清空回收站"
		act="清空回收站"
		Call top(1,1)
		Call AllDelrecycle()
	Case Else
		Call top(1,1)
		Call inbox()
	End Select
	if founderr Then Call Error("Information",ErrMsg)
End if

Sub nav()

Response.Write "<BR><TABLE border=0 width=90% align=center><TBODY>"&_
				"<TR><TD align=left><a href='"& HostURL &"'></a></TD>"&_
				"<TD Align=right nowrap>  <a href=Class_UserSms.asp?action=inbox><img src=images/m_inbox.gif border=0 alt=收件箱></a> &nbsp; <a href=Class_UserSms.asp?action=outbox><img src=images/M_outbox.gif border=0 alt=发件箱></a> &nbsp; <a href=Class_UserSms.asp?action=issend><img src=images/M_issend.gif border=0 alt=已发送邮件></a>&nbsp; <a href=Class_UserSms.asp?action=recycle><img src=images/M_recycle.gif border=0 alt=废件箱></a>&nbsp; <a href=Class_FriendList.asp><img src=images/M_address.gif border=0 alt=地址簿></a>&nbsp;<a href=Class_UserSms.asp?action=new&id=><img src=images/m_write.gif border=0 alt=发送消息></a> &nbsp;<a href=Class_UserSms.asp?action=new&touser="&htmlencode(Request("sender"))&"&id="&Request("id")&"><img src=images/m_reply.gif border=0 alt=回复消息></a> &nbsp;<a href=Class_UserSms.asp?action=fw&id="&Request("id")&"><img src=images/m_fw.gif border=0 alt=转发消息></a>&nbsp;<a href=Class_UserSms.asp?action=delete&id="&Request("id")&"><img src=images/m_delete.gif border=0 alt=删除消息></a>"&_
				"</TD></TR></TBODY></TABLE><br>"


End Sub


'收件箱
Sub inbox()
Call nav()
%>
<form action="Class_UserSms.asp" method=post name=inbox>
    <table cellpadding=0 cellspacing=0 border=0 width="100%" Class=TableBorder align=center>
        <tr>
            <td>
                <table cellpadding=5 cellspacing=1 border=0 width=100%>
            <tr >
                <th align=center valign=middle width=30><b>已读</b></th>
                <th align=center valign=middle width=100><b>发件人</b></th>
                <th align=center valign=middle width=300><b>主题</b></th>
                <th align=center valign=middle width=150><b>日期</b></th>
                <th align=center valign=middle width=50><b>大小</b></th>
                <th align=center valign=middle width=30><b>操作</b></th>
            </tr>
<%
	Set rs=server.createobject("adodb.recordset")
	sql="Select * from message where incept='"&trim(membername)&"' and issend=1 and delR=0 order by flag,sendtime desc"
	rs.open sql,conn,1,1
	if rs.eof and rs.bof Then
%>
                <tr>
                <td Class=LightTableBody align=center valign=middle colspan=6>您的收件箱中没有任何内容。</td>
                </tr>
<%Else%>
<%do while not rs.eof%>
                <tr bgcolor=<%if rs("flag")=0 Then%>"<%=DarkTBColor%>"<%Else%>"<%=LightTBColor%>"<%End if%>>
                    <td align=center valign=middle><%if rs("flag")=0 Then%><img src="images/m_news.gif"><%Else%><img src="images/m_olds.gif"><%End if%></td>
                    <td align=center valign=middle><%if rs("flag")=0 Then%><b><%End if%><a href="Class_Userinfo.asp?name=<%=htmlencode(rs("sender"))%>" target=_blank><%=htmlencode(rs("sender"))%></a></td>
                    <td align=left><a href="Class_UserSms.asp?action=read&id=<%=rs("id")%>&sender=<%=rs("sender")%>"><%if rs("flag")=0 Then%><b><%End if%><%=htmlencode(rs("title"))%></a>	</td>
                    <td><%if rs("flag")=0 Then%><b><%End if%><%=rs("sendtime")%></td>
                    <td><%if rs("flag")=0 Then%><b><%End if%><%=len(rs("content"))%>Byte</td>
                <td align=center valign=middle width=30><input type=checkbox name=id value=<%=rs("id")%>></td>
                </tr>
<%
	rs.movenext
	loop
	End if
	rs.close
	Set rs=Nothing
%>
                
        <tr bgcolor="<%=DarkTBColor%>"> 
          <td align=right valign=middle colspan=6 nowrap>节省每一分空间，请及时删除无用信息&nbsp;<input type=checkbox name=chkall value=on onClick="CheckAll(this.form)">选中所有显示记录&nbsp;<input type=submit name=action onClick="return confirm('确定删除选定的纪录吗?')" value="删除收件" class=button>&nbsp;<input type=submit name=action onClick="return confirm('确定清除收件箱所有的纪录吗?')" value="清空收件箱" class=button></td>
                </tr>
                </table></td></tr></table></form>
<%
End Sub
'收件逻辑删除，置于回收站，入口字段delR，可用于批量及单个删除
Sub delinbox()
Call nav
delid=Request("id")
if delid="" or isnull(delid) Then
Errmsg=Errmsg+"<li>"+"请选择相关参数。"
Founderr=True
Else
	conn.execute("update message Set delR=1 where incept='"&trim(membername)&"' and id in ("&delid&")")
	
	stitle="删除短信"
	smsg="<br>"+"<li><b>恭喜您，删除短信息成功。</b><br>删除的消息将转移到您的回收站。"
	Call success(stitle,smsg)
End if
End Sub
Sub AllDelinbox()
Call nav()
	conn.execute("update message Set delR=1 where incept='"&trim(membername)&"' and delR=0")
		stitle="删除短信"
	smsg="<br>"+"<li><b>恭喜您，删除短信息成功。</b><br>删除的消息将转移到您的回收站。"
	Call success(stitle,smsg)
End Sub

'发件箱
Sub outbox()
Call nav()
%>
<form action="Class_UserSms.asp" method=post name=inbox>
    <table cellpadding=0 cellspacing=0 border=0 width="100%" Class=TableBorder align=center>
        <tr>
            <td>
                <table cellpadding=5 cellspacing=1 border=0 width=100%>
            <tr >
                <th align=center valign=middle width=30><b>已读</b></th>
                <th align=center valign=middle width=100><b>收件人</b></th>
                <th align=center valign=middle width=300><b>主题</b></th>
                <th align=center valign=middle width=150><b>日期</b></th>
                <th align=center valign=middle width=50><b>大小</b></th>
                <th align=center valign=middle width=30><b>操作</b></th>
            </tr>
<%
	Set rs=server.createobject("adodb.recordset")
	sql="Select * from message where sender='"&trim(membername)&"' and issend=0 and delS=0 order by sendtime desc"
	rs.open sql,conn,1,1
	if rs.eof and rs.bof Then
%>
                <tr height=40>
                <td Class=LightTableBody align=center valign=middle colspan=6>您的发件箱中没有任何内容。</td>
                </tr>
<%Else%>
<%do while not rs.eof%>
                <tr bgcolor=<%if rs("flag")=0 Then%>"<%=DarkTBColor%>"<%Else%>"<%=LightTBColor%>"<%End if%>>
                    <td align=center valign=middle><img src="images/m_issend_2.gif"></td>
                    <td align=center valign=middle><%if rs("flag")=0 Then%><b><%End if%><a href="Class_Userinfo.asp?name=<%=htmlencode(rs("incept"))%>" target=_blank><%=htmlencode(rs("incept"))%></a></td>
                    <td align=left><a href="Class_UserSms.asp?action=edit&id=<%=rs("id")%>"><%if rs("flag")=0 Then%><b><%End if%><%=htmlencode(rs("title"))%></a>	</td>
                    <td><%if rs("flag")=0 Then%><b><%End if%><%=rs("sendtime")%></td>
                    <td><%if rs("flag")=0 Then%><b><%End if%><%=len(rs("content"))%>Byte</td>
                <td align=center valign=middle width=30><input type=checkbox name=id value=<%=rs("id")%>></td>
                </tr>
<%
	rs.movenext
	loop
	End if
	rs.close
	Set rs=Nothing
%>
                
        <tr bgcolor="<%=DarkTBColor%>"> 
          <td align=right valign=middle colspan=6>节省每一分空间，请及时删除无用信息&nbsp;<input type=checkbox name=chkall value=on onClick="CheckAll(this.form)">选中所有显示记录&nbsp;<input type=submit name=action onClick="return confirm('确定删除选定的纪录吗?')" value="删除发件" class=button>&nbsp;<input type=submit name=action onClick="return confirm('确定清除发件箱所有的纪录吗?')" value="清空发件箱" class=button></td>
                </tr>
                </table></td></tr></table></form>
<%
End Sub
'发件逻辑删除，置于回收站，入口字段delS，可用于批量及单个删除
Sub deloutbox()
Call nav()
delid=Request("id")
if delid="" or isnull(delid) Then
Errmsg=Errmsg+"<li>"+"请选择相关参数。"
Founderr=True
Else
	conn.execute("update message Set delS=1 where sender='"&trim(membername)&"' and issend=0 and id in ("&delid&")")
			stitle="删除短信"
	smsg="<br>"+"<li><b>恭喜您，删除短信息成功。</b><br>删除的消息将转移到您的回收站。"
	Call success(stitle,smsg)
End if
End Sub
Sub AllDeloutbox()
Call nav()
	conn.execute("update message Set delS=1 where sender='"&trim(membername)&"' and delS=0 and issend=0")
			stitle="删除短信"
	smsg="<br>"+"<li><b>恭喜您，删除短信息成功。</b><br>删除的消息将转移到您的回收站。"
	Call success(stitle,smsg)
End Sub

'已发送信息
Sub issend()
Call nav()
%>
<form action="Class_UserSms.asp" method=post name=inbox>
    <table cellpadding=0 cellspacing=0 border=0 width="100%" Class=TableBorder align=center>
        <tr>
            <td>
                <table cellpadding=5 cellspacing=1 border=0 width=100%>
            <tr>
                <th align=center valign=middle width=30><b>已读</b></th>
                <th align=center valign=middle width=100><b>收件人</b></th>
                <th align=center valign=middle width=300><b>主题</b></th>
                <th align=center valign=middle width=150><b>日期</b></th>
                <th align=center valign=middle width=50><b>大小</b></th>
                <th align=center valign=middle width=30><b>操作</b></th>
            </tr>
<%
	Set rs=server.createobject("adodb.recordset")
	sql="Select * from message where sender='"&trim(membername)&"' and issend=1 and delS=0 order by sendtime desc"
	rs.open sql,conn,1,1
	if rs.eof and rs.bof Then
%>
                <tr height=40>
                <td Class=LightTableBody align=center valign=middle colspan=6>您的已发送信息中没有任何内容。</td>
                </tr>
<%Else%>
<%do while not rs.eof%>
                <tr bgcolor=<%if rs("flag")=0 Then%>"<%=DarkTBColor%>"<%Else%>"<%=LightTBColor%>"<%End if%>>
                    <td align=center valign=middle><img src="images/m_issend_1.gif"></td>
                    <td align=center valign=middle><%if rs("flag")=0 Then%><b><%End if%><a href="Class_Userinfo.asp?name=<%=htmlencode(rs("incept"))%>" target=_blank><%=htmlencode(rs("incept"))%></a></td>
                    <td align=left><a href="Class_UserSms.asp?action=outread&id=<%=rs("id")%>"><%if rs("flag")=0 Then%><b><%End if%><%=htmlencode(rs("title"))%></a>	</td>
                    <td><%if rs("flag")=0 Then%><b><%End if%><%=rs("sendtime")%></td>
                    <td><%if rs("flag")=0 Then%><b><%End if%><%=len(rs("content"))%>Byte</td>
                <td align=center valign=middle width=30><input type=checkbox name=id value=<%=rs("id")%>></td>
                </tr>
<%
	rs.movenext
	loop
	End if
	rs.close
	Set rs=Nothing
%>
                
        <tr class=DarkTableBody> 
          <td align=right valign=middle colspan=6>节省每一分空间，请及时删除无用信息&nbsp;<input type=checkbox name=chkall value=on onClick="CheckAll(this.form)">选中所有显示记录&nbsp;<input type=submit name=action onClick="return confirm('确定删除选定的纪录吗?')" value="删除已发信息" class=button>&nbsp;<input type=submit name=action onClick="return confirm('确定清除已发送信息所有的纪录吗?')" value="清空已发信息" class=button></td>
                </tr>
                </table></td></tr></table></form>
<%
End Sub
'已发送逻辑删除，置于回收站，入口字段delS，可用于批量及单个删除
'delS：0未操作，1发送者删除，2发送者从回收站删除
Sub delissend()
Call nav()
delid=Request("id")
if delid="" or isnull(delid) Then
Errmsg=Errmsg+"<li>"+"请选择相关参数。"
Founderr=True
Else
	conn.execute("update message Set delS=1 where sender='"&trim(membername)&"' and issend=1 and id in ("&delid&")")
			stitle="删除短信"
	smsg="<br>"+"<li><b>恭喜您，删除短信息成功。</b><br>删除的消息将转移到您的回收站。"
	Call success(stitle,smsg)
End if
End Sub
Sub AllDelissend()
Call nav()
	conn.execute("update message Set delS=1 where sender='"&trim(membername)&"' and delS=0 and issend=1")
			stitle="删除短信"
	smsg="<br>"+"<li><b>恭喜您，删除短信息成功。</b><br>删除的消息将转移到您的回收站。"
	Call success(stitle,smsg)
End Sub
'回收站
Sub recycle()
Call nav()
%>
<form action="Class_UserSms.asp" method=post name=inbox>
    <table cellpadding=0 cellspacing=0 border=0 width="100%" Class=TableBorder align=center>
        <tr>
            <td>
                <table cellpadding=5 cellspacing=1 border=0 width=100%>
            <tr>
                <th align=center valign=middle width=30><b>已读</b></th>
                <th align=center valign=middle width=100><b>名字</b></th>
                <th align=center valign=middle width=300><b>主题</b></th>
                <th align=center valign=middle width=150><b>日期</b></th>
                <th align=center valign=middle width=50><b>大小</b></th>
                <th align=center valign=middle width=30><b>操作</b></th>
            </tr>
<%
	Set rs=server.createobject("adodb.recordset")
	sql="Select * from message where ((sender='"&trim(membername)&"' and delS=1) or (incept='"&trim(membername)&"' and delR=1)) and not delS=2 order by sendtime desc"
	rs.open sql,conn,1,1
	if rs.eof and rs.bof Then
%>
                <tr height=40>
                <td Class=LightTableBody align=center valign=middle colspan=6>您的废件箱中没有任何内容。</td>
                </tr>
<%Else%>
<%do while not rs.eof%>
                <tr bgcolor=<%if rs("flag")=0 Then%>"<%=DarkTBColor%>"<%Else%>"<%=LightTBColor%>"<%End if%>>
                    <td align=center valign=middle><font face="宋体" color="#333333"><%if rs("flag")=0 Then%><img src="images/m_news.gif"><%Else%><img src="images/m_olds.gif"><%End if%></td>
                    <td align=center valign=middle><%if rs("flag")=0 Then%><b><%End if%><a href="Class_Userinfo.asp?name=<%=htmlencode(rs("incept"))%>" target=_blank><%=htmlencode(rs("incept"))%></a></td>
                    <td align=left><a href="Class_UserSms.asp?action=read&id=<%=rs("id")%>"><%if rs("flag")=0 Then%><b><%End if%><%=htmlencode(rs("title"))%></a>	</td>
                    <td><%if rs("flag")=0 Then%><b><%End if%><%=rs("sendtime")%></td>
                    <td><%if rs("flag")=0 Then%><b><%End if%><%=len(rs("content"))%>Byte</td>
                <td align=center valign=middle width=30><input type=checkbox name=id value=<%=rs("id")%>></td>
                </tr>
<%
	rs.movenext
	loop
	End if
	rs.close
	Set rs=Nothing
%>
                
        <tr bgcolor="<%=DarkTBColor%>"> 
          <td align=right valign=middle colspan=6>节省每一分空间，请及时删除无用信息&nbsp;<input type=checkbox name=chkall value=on onClick="CheckAll(this.form)">选中所有显示记录&nbsp;<input type=submit name=action onClick="return confirm('确定删除选定的纪录吗?')" value="删除指定信息" class=button>&nbsp;<input type=submit name=action onClick="return confirm('确定清除回收站所有的纪录吗?')" value="清空回收站" class=button></td>
                </tr>
                </table></td></tr></table></form>
<%
End Sub
'用户能完全删除收到信息和逻辑删除所发送信息，逻辑删除所发送信息设置入口字段delS参数为2
Sub delrecycle()
Call nav()
delid=Request("id")
'Response.Write delid
if delid="" or isnull(delid) Then
Errmsg=Errmsg+"<li>"+"请选择相关参数。"
Founderr=True
Exit Sub
Else
	conn.execute("delete from message where incept='"&membername&"' and delR=1 and id in ("&delid&")")
	conn.execute("update message Set delS=2 where sender='"&trim(membername)&"' and delS=1 and id in ("&delid&")")
		stitle="删除短信"
	smsg="<br>"+"<li><b>恭喜您，删除短信息成功。</b><br>删除的消息将不可恢复。"
	Call success(stitle,smsg)
End if
End Sub
Sub AllDelrecycle()
Call nav()
	conn.execute("delete from message where incept='"&membername&"' and delR=1")	
	conn.execute("update message Set delS=2 where sender='"&trim(membername)&"' and delS=1")
	if BoolVar(1) Then
		Response.Write "<bgsound src=""sound/recycle.wav"" border=0>"
	End if
	stitle="删除短信"
	smsg="<br>"+"<li><b>恭喜您，删除短信息成功。</b><br>删除的消息将不可恢复。"
	Call success(stitle,smsg)
End Sub

Sub delete()
Call nav()
delid=Request("id")
if not isNumeric(Request("id")) or delid="" or isnull(delid) Then
Errmsg=Errmsg+"<br>"+"<li>"+"请选择相关参数。"
Founderr=True
Else
	conn.execute("update message Set delR=1 where incept='"&trim(membername)&"' and id="&delid)
	conn.execute("update message Set delS=1 where sender='"&trim(membername)&"' and id="&delid)
		stitle="删除短信"
	smsg="<br>"+"<li><b>恭喜您，删除短信息成功。</b><br>删除的消息将转移到您的回收站。"
	Call success(stitle,smsg)
	
End if
End Sub

'发送信息
Sub sendmsg()
Call nav()
if Request("id")<>"" and isNumeric(Request("id")) Then
Set rs=server.createobject("adodb.recordset")
sql="Select sendtime,title,content from message where incept='"&membername&"' and id="&Request("id")
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) Then
sendtime=rs("sendtime")
title="RE " & rs("title")
content=rs("content")
End if
rs.close
Set rs=Nothing
End if
%>
<form action="Class_UserSms.asp" method=post name=messager>
  <table cellpadding=0 cellspacing=0 border=0 width="100%" Class=TableBorder align=center>
    <tr> 
      <td> 
        <table cellpadding=5 cellspacing=1 border=0 width=100%>
          <tr> 
            <th colspan=2 align=center> 
              <input type=hidden name="action" value="send">
              <b>发送短消息</b>--请完整输入下列信息</th>
          </tr>
          <tr Class=LightTableBody> 
            <td valign=middle width=70><b>收件人：</b></td>
            <td valign=middle>
              <input type=text name="touser" value="<%=Request("touser")%>" size=50>
              <SELECT name=font onchange=if(this.selectedIndex!=0){DoTitle1(this.options[this.selectedIndex].value);}>
              <OPTION selected value="">选择</OPTION>
<%
Set rs=server.createobject("adodb.recordset")
sql="Select F_friend from Friend where F_username='"&membername&"' order by F_addtime desc"
rs.open sql,conn,1,1
do while not rs.eof
%>
			  <OPTION value="<%=rs(0)%>"><%=rs(0)%></OPTION> 
<%
rs.movenext
loop
rs.close
Set rs=Nothing
%>
			  </SELECT>
			  &nbsp;使用逗号（,）分开，最多5位用户
            </td>
          </tr>
          <tr Class=LightTableBody> 
            <td valign=top><b>标题：</b></td>
            <td valign=middle>
              <input type=text name="title" size=50 maxlength=80 value="<%=title%>">&nbsp;请限定50字内
            </td>
          </tr>
          <tr Class=LightTableBody> 
            <td valign=top><b>内容：</b><br></td>
            <td valign=middle>
              <textarea cols=70 rows=8 name="message" title="">

<%if Request("id")<>"" Then%>
============= 在 <%=sendtime%> 您来信中写道： ============
<%=content%>
========================================================<%End if%></textarea>
            </td>
          </tr>
          <tr Class=DarkTableBody> 
            <td valign=middle colspan=2 align=center> 
              <input type=Submit value="发送" name=Submit class=button style="width:50px">
              &nbsp; 
              <input type=Submit value="保存" name=Submit class=button style="width:50px">
              &nbsp; 
              <input type="reset" name="Clear" value="清除" class=button style="width:50px">
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</form>
<%
End Sub
'转发信息
Sub fw()
Call nav()
if Request("id")<>"" and isNumeric(Request("id")) Then
Set rs=server.createobject("adodb.recordset")
sql="Select title,content,sender from message where (incept='"&membername&"' or sender='"&membername&"') and id="&Request("id")
rs.open sql,conn,1,1
if rs.eof and rs.bof Then
Errmsg=Errmsg+"<br>"+"<li>请选择相关参数。"
Founderr=True
Exit Sub
Else
title=rs("title")
content=rs("content")
sender=rs("sender")
End if
rs.close
Set rs=Nothing
End if
%>
<form action="Class_UserSms.asp" method=post name=messager>
  <table cellpadding=0 cellspacing=0 border=0 width="100%" Class=TableBorder align=center>
    <tr> 
      <td> 
        <table cellpadding=5 cellspacing=1 border=0 width=100%>
          <tr> 
            <th colspan=2 align=center> 
              <input type=hidden name="action" value="send">
              <b>发送短消息</b>--请完整输入下列信息</th>
          </tr>
          <tr Class=LightTableBody> 
            <td  valign=middle width=70><b>收件人：</b></td>
            <td valign=middle>
              <input type=text name="touser" value="<%=Request("touser")%>" size=50>&nbsp;使用逗号（,）分开，最多5位用户
            </td>
          </tr>
          <tr Class=LightTableBody> 
            <td valign=top><b>标题：</b></td>
            <td valign=middle>
              <input type=text name="title" size=50 maxlength=80 value="Fw：<%=title%>">&nbsp;请限定50字内
            </td>
          </tr>
          <tr Class=LightTableBody> 
            <td valign=top><b>内容：</b><br></td>
            <td valign=middle>
              <textarea cols=70 rows=8 name="message" title="">


========== 下面是转发信息 =========
原发件人：<%=sender%><%=chr(13)&chr(13)%>
<%=content%>
===================================</textarea>
            </td>
          </tr>
          <tr Class=DarkTableBody> 
            <td valign=middle colspan=2 align=center> 
              <input type=Submit value="发送" name=Submit class=button style="width:50px">
              &nbsp; 
              <input type=Submit value="保存" name=Submit class=button style="width:50px">
              &nbsp; 
              <input type="reset" name="Clear" value="清除" class=button style="width:50px">
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</form>
<%
End Sub
'更改信息
Sub edit()
Call nav()
if Request("id")<>"" or isNumeric(Request("id")) Then
	Set rs=server.createobject("adodb.recordset")
sql="Select id,incept,title,content from message where sender='"&membername&"' and issend=0 and id="&Request("id")
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) Then
incept=rs("incept")
title=rs("title")
content=rs("content")
id=rs("id")
Else
Errmsg=Errmsg+"<br>"+"<li>没有找到您要编辑的信息。"
Founderr=True
Exit Sub
End if
rs.close
Set rs=Nothing
Else
Errmsg=Errmsg+"<br>"+"<li>请指定相关参数。"
Founderr=True
Exit Sub
End if
%>
<form action="Class_UserSms.asp" method=post name=messager>
        <table cellpadding=3 cellspacing=1 border=0 width=100% class=TableBorder align=center>
          <tr> 
            <th colspan=2 align=center> 
              <input type=hidden name="action" value="savedit"> 
              <input type=hidden name="id" value="<%=id%>">
              <b>发送短消息</b>--请完整输入下列信息</th>
          </tr>
          <tr  Class=LightTableBody> 
            <td valign=middle width=70><b>收件人：</b></td>
            <td valign=middle>
              <input type=text name="touser" value="<%=incept%>" size=70>
            </td>
          </tr>
          <tr Class=LightTableBody> 
            <td valign=top><b>标题：</b></td>
            <td valign=middle>
              <input type=text name="title" size=70 maxlength=80 value="<%=title%>">&nbsp;请限定50字内
            </td>
          </tr>
          <tr Class=LightTableBody> 
            <td valign=top><b>内容：</b><br></td>
            <td valign=middle>
              <textarea cols=70 rows=8 name="message" title=""><%=content%></textarea>
            </td>
          </tr>
          <tr Class=DarkTableBody> 
            <td valign=middle colspan=2 align=center> 
              <input type=Submit value="发送" name=Submit class=button style="width:50">
              &nbsp; 
              <input type=Submit value="保存" name=Submit class=button style="width:50">
              &nbsp; 
              <input type="reset" name="Clear" value="清除" class=button style="width:50">
            </td>
          </tr>
        </table>
</form>
<%
End Sub
'读取信息
Sub read()
Call nav()
if Request("id")="" or not isNumeric(Request("id")) Then
Errmsg=Errmsg+"<br>"+"<li>请指定相关参数。"
Founderr=True
Exit Sub
End if
	Set rs=server.createobject("adodb.recordset")
	if Request("action")="read" Then
   	sql="update message Set flag=1 where ID="&cstr(Request("id"))
	conn.execute(sql)
	End if
	sql="Select * from message where (incept='"&membername&"' or sender='"&membername&"') and id="&cstr(Request("id"))
	rs.open sql,conn,1,1
	if rs.eof and rs.bof Then
		ErrMsg=ErrMsg+"<br>"+"<li>你是不是跑到别人的信箱啦、或者该信息已经收件人删除。"
		founderr=True
	End if
	if not founderr Then
%>
<table cellpadding=0 cellspacing=0 border=0 width="100%" Class=TableBorder align=center>
        <tr>
            <td>
                <table cellpadding=3 cellspacing=1 border=0 width=100%>
                
            <tr>
                <th><font  color="#000000"><b>欢迎使用短消息接收，<%=membername%></b></th>
            </tr>
                <tr>
                    <td Class=LightTableBody>
<%if Request("action")="outread" Then%>
                    在<b><%=rs("sendtime")%></b>，您发送此消息给<b><%=htmlencode(rs("incept"))%></b>！
<%Else%>
		    在<b><%=rs("sendtime")%></b>，<b><%=htmlencode(rs("sender"))%></b>给您发送的消息！
<%End if%></td>
                </tr>
                <tr>
                    <td Class=DarkTableBody valign=top align=left><font color=#000000>
                    <b>消息标题：<%=htmlencode(rs("title"))%></b><hr size=1>
                    <%=ubbcode(rs("content"))%>
		    </td>
                </tr>
                </table></td></tr></table><BR>
<%End if%>
<%
rs.close
Set rs=Nothing
End Sub

Sub savemsg()
Call nav()
	if Request("touser")="" Then
		ErrMsg=ErrMsg+"<br>"+"<li>您忘记填写发送对象了吧。"
		founderr=True
	Else
		incept=Request("touser")
		incept=Split(incept,",")
	End if
	if Request("title")="" Then
		ErrMsg=ErrMsg+"<br>"+"<li>您还没有填写标题呀。"
		founderr=True
	Else
		title=Request("title")
	End if
	if Request("message")="" Then
		ErrMsg=ErrMsg+"<br>"+"<li>内容是必须要填写的噢。"
		founderr=True
	Else
		message=Request("message")
	End if
	if not founderr Then
		for i=0 to ubound(incept)
		Set rs=server.createobject("adodb.recordset")
		sql="Select userid from [student] where userid='"&incept(i)&"'"
		rs.open sql,conn,1,1
		if rs.eof and rs.bof Then
			ErrMsg=ErrMsg+"<br>"+"<li>校友录没有这个用户，看看你的发送对象写对了嘛？"
			founderr=True
		End if
		rs.close
		Set rs=Nothing

		if not founderr Then
		if Request("Submit")="发送" Then
		sql="insert into message (incept,sender,title,content,sendtime,flag,issend) values ('"&incept(i)&"','"&membername&"','"&title&"','"&message&"',getdate(),0,1)"
		subtype="已发送信息"
		Else
		sql="insert into message (incept,sender,title,content,sendtime,flag,issend) values ('"&incept(i)&"','"&membername&"','"&title&"','"&message&"',getdate(),0,0)"
		subtype="发件箱"
		End if
		conn.execute(sql)
			if i>4 Then
			ErrMsg=ErrMsg+"<br>"+"<li>最多只能发送给5个用户，您的名单5位以后的请重新发送"
			founderr=True
			Exit for
			End if
		End if
		next
		if not founderr Then
			stitle="发送短信"
	smsg="<br>"+"<li><b>恭喜您，发送短信息成功。</b><br>发送的消息同时保存在您的"&subtype&"中。"
	Call success(stitle,smsg)
		End if
	End if
End Sub
Sub savedit()
Call nav()
	if Request("id")="" or not isNumeric(Request("id")) Then
		Errmsg=Errmsg+"<br>"+"<li>请指定相关参数。"
		Founderr=True
		Exit Sub
	End if
	if Request("touser")="" Then
		ErrMsg=ErrMsg+"<br>"+"<li>您忘记填写发送对象了吧。"
		founderr=True
		Exit Sub
	Else
		incept=Request("touser")
	End if
	if Request("title")="" Then
		ErrMsg=ErrMsg+"<br>"+"<li>您还没有填写标题呀。"
		founderr=True
		Exit Sub
	Else
		title=Request("title")
	End if
	if Request("message")="" Then
		ErrMsg=ErrMsg+"<br>"+"<li>内容是必须要填写的噢。"
		founderr=True
		Exit Sub
	Else
		message=Request("message")
	End if
	if not founderr Then
		Set rs=server.createobject("adodb.recordset")
		sql="Select username from [user] where username='"&incept&"'"
		rs.open sql,conn,1,1
		if rs.eof and rs.bof Then
			ErrMsg=ErrMsg+"<br>"+"<li>校友录没有这个用户，看看你的发送对象写对了嘛？"
			founderr=True
			Exit Sub
		End if
		rs.close
		Set rs=Nothing

		if not founderr Then
		if Request("Submit")="发送" Then
		sql="update message Set incept='"&incept&"',sender='"&membername&"',title='"&title&"',content='"&message&"',sendtime=getdate(),flag=0,issend=1 where id="&Request("id")
		subtype="已发送信息"
		Else
		sql="update message Set incept='"&incept&"',sender='"&membername&"',title='"&title&"',content='"&message&"',sendtime=getdate(),flag=0,issend=0 where id="&Request("id")
		subtype="发件箱"
		End if
		conn.execute(sql)
		End if
		if not founderr Then
					stitle="发送短信"
	smsg="<br>"+"<li><b>恭喜您，发送短信息成功。</b><br>发送的消息同时保存在您的"&subtype&"中。"
	Call success(stitle,smsg)
		End if
	End if
End Sub

Sub newmsg()
Call nav()
%>
    <table cellpadding=0 cellspacing=0 border=0 width="750" bgcolor=<%=Tablebackcolor%> align=center>
        <tr>
            <td>
                <table cellpadding=3 cellspacing=1 border=0 width=100%>
    <tr align="center"> 
      <td width="100%">短消息通知</td>
    </tr>
    <tr> 
      <td width="100%" bgcolor=<%=Tablebodycolor%> align=center><br>
<a href=Class_UserSms.asp?action=inbox><img src="images/newmail.gif" border=0>有新的短消息</a><br>
                <br>
                <a href=Class_UserSms.asp?action=inbox>按此查看</a><br><br>
      </td>
    </tr>
    </table>   </td></tr></table>
<%
End Sub
%>


<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>
<%Call footer%>
