<!--#include file="../act_inc/ACT.User.asp"-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>1</title>
<link href="Images/css/css.css" rel="stylesheet" type="text/css">
</head>
<body>
<%
 Dim  UserHS
 Set UserHS = New ACT_User
		IF Cbool(UserHS.UserLoginChecked)=false then
		  Response.Write "<script>top.location.href ='login.asp' ;</script>"
		  Response.end
		End If
		Private Max_sEnd
        Private Max_sms
		Private Max_Num
        Private Action
        Private RS,SqlStr,ComeUrl
		Private FoundErr,Errmsg
		Private i


			Max_sEnd=UserHS.G_Max_sEnd''群发限制人数
			Max_sms=UserHS.G_Max_sms	'内容最多字符数
			Max_Num=UserHS.G_Max_Num'最多允许存放条数
			  Action=Lcase(request("action"))
			  ComeUrl=Cstr(Request.ServerVariables("HTTP_REFERER"))
			  If ComeUrl="" Then ComeUrl="Message_User.asp"

		%>
				<script language = "JavaScript">
				function CheckForm()
				{
				if (document.myform.Touser.value=='')
				{
				   alert('请输入收信人!')
				   document.myform.Touser.focus();
				   return false;
				 }
				if (document.myform.title.value=='')
				{
				   alert('请输入信件主题!')
				   document.myform.title.focus();
				   return false;
				 }
			 }
				</script>
		<%
		IF Action<>"read" And Action<>"outread" Then
		 %>
		<div align="center" style="height:30">
						<a href="Message_User.asp?action=inbox"><img src="Images/inbox.gif" border=0 alt="收件箱"></a> &nbsp;
						<a href="Message_User.asp?action=outbox"><img src="Images/outbox.gif" border=0 alt="发件箱"></a> &nbsp; 		<a href="Message_User.asp?action=issend"><img src="Images/issend.gif" border=0 alt="已发送邮件"></a> &nbsp;
						<a href="Message_User.asp?action=recycle"><img src="Images/recycle.gif" border=0 alt="废件箱"></a> &nbsp; 		
						<a href="Message_User.asp?action=new"><img src="Images/write.gif" border=0 alt="发送消息"></a> 
		
		<table width="98%" border="0" align="center" class="table" cellpadding="2" cellspacing="1" style="display:nowrap">
<tr class="tdbg">
<td width="127" align="right" class="bg_tr">您的邮箱容量：</td>
<td width="602" class="bg_tr" ><img src="images/bar.gif" width="0" height="16" id="Sms_bar" align="absmiddle" /></td>
<td width="211"  align="center" class="bg_tr" id="Sms_txt">100%</td>
</tr></table>

		</div>
		 <%
response.write showtable("Sms_bar","Sms_txt",conn.execute("select count(*) from Message_Act where Incept='"&UserHS.UserName&"'")(0),Max_Num)

		Else
		 Response.Write "<br>"
		End IF
		
		Select Case Action
		Case "new" : sendMessage
		Case "read" : read
		Case "outread" : read
		Case "delet" : delete
		Case "newmsg" : newmsg
		Case "send" : savemsg
		Case "fw" : fw
		Case "edit" : edit
		Case "savedit" : savedit
		Case "删除收件箱" : delinbox
		Case "清空收件箱" : AllDelinbox
		Case "删除草稿" : deloutbox
		Case "清空草稿箱" : AllDeloutbox
		Case "删除已发送的消息" : DelIsSend
		Case "清空已发送的消息" : AllDelIsSend
		Case "删除垃圾箱" : delrecycle
		Case "清空垃圾箱" : AllDelrecycle
		Case Else : MessageMain
		End Select

		'发送信息
		Sub sendMessage()
			dim SendTime,title,content
			If actcms.s("ID")<>"" and isNumeric(actcms.s("ID")) Then
				Set rs=server.createobject("adodb.recordSet")
				SqlStr="Select SendTime,title,content from Message_Act where Incept='"&UserHS.UserName&"' and id="&Clng(actcms.s("ID"))
				RS.open SqlStr,Conn,1,1
				If not(RS.eof and RS.bof) Then
					SendTime=rs("SendTime")
					Title="RE " & rs("title")
					Content=server.htmlencode(rs("content"))
				End If
				RS.close
				Set rs=Nothing
			End If
		%>
		<table width="98%" align="center" cellpadding="2" cellspacing="1" class="table">
				<form action="Message_User.asp"  name="myform" method="post" id="myform" onSubmit="return CheckForm();">
				  <tr> 
					<td colspan=2 align=center class="bg_tr">
					发送短消息					</td>
				  </tr>
				  <tr > 
					<td width="100" align="right" valign=middle><b>收件人：</b></td>
					<td valign=middle>
					  <input type=hidden name="action" value="sEnd">
					  <input class="textbox" type=text name="Touser" value="<%=actcms.s("Touser")%>" size=60>
					  <Select class="textbox" name=font onchange=DoTitle(this.options[this.selectedIndex].value)>
					  <OPTION selected value="">选择</OPTION>
						<%
						Set rs=server.createobject("adodb.recordSet")
						SqlStr="Select friend from Friend_ACT where Username='"&UserHS.UserName&"' order by Addtime desc"
						RS.open SqlStr,Conn,1,1
						Do While not RS.eof
						%>
						<OPTION value="<%=rs(0)%>"><%=rs(0)%></OPTION>
						<%
						RS.movenext
						loop
						RS.close:Set rs=Nothing
						%>
					  </Select>
					  <a href="Friend_User.asp?action=addF">添加好友</a>
					</td>
				  </tr>
				  <tr > 
					<td width="100" align="right" valign=top><b>标　题：</b></td>
					<td valign=middle>
					  <input class="textbox" type=text name="title" size=70 maxlength=90 value="<%=title%>">
					</td>
				  </tr>
				  <tr > 
					<td width="100" align="right" valign=top><b>内　容：</b></td>
					<td valign=middle>
					  <%dim content1
					  If actcms.s("ID")<>"" Then
						content1=content1&"============= 在 "&SendTime&" 您来信中写道： ==============<br>"
						content1=content1&server.htmlencode(content)
						content1=content1&"======================================================="
					End If
					%>
<div><input type="hidden" id="content" name="content" value="<%= content1 %>" style="display:none" />
	  <input name="hidden" type="hidden" id="cont___Config" style="display:none" value="" />
	  <iframe id="cont___Frame" src="../editor/fckeditor/editor/fckeditor.html?InstanceName=content&amp;Toolbar=Simple" width="100%" height="280" frameborder="0" scrolling="no"> </iframe>
      </div>					</td>
				  </tr>
				  <tr > 
					<td colspan=2>
		<b>说明</b>：<br>
		① 您可以使用<b>Ctrl+Enter</b>键快捷发送短信<br>
		② 可以用英文状态下的逗号将用户名隔开实现群发，最多<b><%=max_sEnd%></b>个用户<br>
		③ 标题最多<b>50</b>个字符，内容最多<b><%=max_sms%></b>个字符<br>
					</td>
				  </tr>
				  <tr > 
					<td valign=middle colspan=2 align=center> 
					  <input class="ACT_btn" type=Submit value=" 发 送 " name=Submit>
					  &nbsp; 
					  <input class="ACT_btn" type=Submit value=" 保 存 " name=Submit>
					  &nbsp; 
					  <input class="ACT_btn" type="reSet" name="Clear" value=" 清 除 ">
					  &nbsp; 
		<%If request("reaction")="chatlog" Then%>
					  <input  class="ACT_btn" type=button value="关闭聊天记录" name="chatlog" onClick="location.href='?action=new&id=<%=s("ID")%>&Touser=<%=s("Touser")%>'">
		<%Else
		    If actcms.s("ID")<>"" and isNumeric(actcms.s("ID")) Then      
		     %>
					  <input class="ACT_btn" type=button value="查看聊天记录" name="chatlog" onClick="location.href='?action=new&id=<%=actcms.s("ID")%>&Touser=<%=actcms.s("Touser")%>&reaction=chatlog'">
		  <%Else%>
					  <input class="ACT_btn" type=button value="查看聊天记录" name="chatlog" disabled>
		<% End IF
		End If%>
					  &nbsp; 
					  <input class="ACT_btn" type="button" name="close" value=" 关 闭 " onClick="window.close()">
					</td>
				  </tr>
		<%If request("reaction")="chatlog" Then%>
				  <tr> 
					<td colspan=3 class="bg_tr" >我与<%=actcms.s("Touser")%>的聊天记录</td>
				  </tr>
		<%If UserHS.UserName=actcms.s("Touser") Then%>
				  <tr> 
					<td colspan=3 class="td_bg">自己跟自己的聊天记录没什么好看的^_^</td>
				  </tr>
		<%Else%>
		<%
			Set rs=server.createobject("adodb.recordSet")
			SqlStr="Select * from Message_Act where ((Incept='"&UserHS.UserName&"' and Incept='"&replace(s("Touser"),"'","")&"') or (sEnder='"&replace(s("Touser"),"'","")&"' and Incept='"&UserHS.UserName&"')) and delS=0 order by SendTime desc"
			RS.open SqlStr,Conn,1,1
			If RS.eof and RS.bof Then
		%>
				  <tr> 
					<td colspan=3>还没有任何聊天记录！</td>
				  </tr>
		<%
			Else
			Do While not RS.eof
		%>
						<tr>
							<td height=25 colspan=3 class="bg_tr">
		<%If rs("sEnder")=UserHS.UserName Then%>
							在<b><%=rs("SendTime")%></b>，您发送此消息给<b><%=server.htmlencode(rs("Incept"))%></b>！
		<%Else%>
					在<b><%=rs("SendTime")%></b>，<b><%=server.htmlencode(rs("sEnder"))%></b>给您发送的消息！
		<%End If%></td>
						</tr>
						<tr>
							<td valign=top align=left colspan=2 class="td_bg">
							<b>消息标题：<%=server.htmlencode(rs("title"))%></b><hr size=1>
							<%=server.htmlencode(rs("content"))%>
					</td>
						</tr>
		<%
			RS.movenext
			loop
			End If
			RS.close:Set rs=Nothing
		%>
		<%End If%>
		<%End If%>
				</form>
</table>
		<%
			DoTitleJs
		End Sub
		'读取信息
		Sub read()
			If actcms.s("id")=0 Then
				Response.Write "<script>alert('请指定正确的参数。');history.back();</script>"
			End If
			Set rs=server.createobject("adodb.recordSet")
			If request("action")="read" Then
				Conn.Execute("Update Message_Act Set flag=1 where ID="&Clng(actcms.s("id")))
			End If
			SqlStr="Select * from Message_Act where (Incept='"&UserHS.UserName&"' or sEnder='"&UserHS.UserName&"') and id="&Clng(actcms.s("ID"))
			RS.open SqlStr,Conn,1,1
			If RS.eof and RS.bof Then
				RS.close:Set rs=Nothing
				Response.Write "<script>alert('你是不是跑到别人的信箱啦、或者该信息已经被收件人删除。');history.back();</script>"
			Else
		%>
		<table width="98%" align=center cellpadding=2 cellspacing=1 class="table">
					<tr>
					  <td align="center" class="bg_tr">欢迎使用短消息接收，<%=UserHS.UserName%></td>
					</tr>
					<tr class="bg_tr">
						<td valign=middle align=center colspan=3><a href="Message_User.asp?action=delet&id=<%=rs("id")%>&ComeUrl=<%=ComeUrl%>"><img src="images/delete.gIf" border=0 alt="删除消息"></a> &nbsp; <a href="Message_User.asp?action=new"><img src="images/write.gIf" border=0 alt="发送消息"></a> &nbsp;<a href="Message_User.asp?action=new&Touser=<%=server.htmlencode(rs("sEnder"))%>&id=<%=actcms.s("ID")%>"><img src="images/reply.gIf" border=0 alt="回复消息"></a>&nbsp;<a href="Message_User.asp?action=fw&id=<%=actcms.s("ID")%>"><img src="images/fw.gIf" border=0 alt=转发消息></a></td>
		  </tr>
						<tr>
							<td height=25 class="td_bg">
		<%If request("action")="outread" Then%>
							在<b><%=rs("SendTime")%></b>，您发送此消息给<b><%=server.htmlencode(rs("Incept"))%></b>！
		<%Else%>
					在<b><%=rs("SendTime")%></b>，<b><%=server.htmlencode(rs("sEnder"))%></b>给您发送的消息！
		<%End If%></td>
						</tr>
						<tr>
							<td align=left valign=top class="td_bg">
							<b>消息标题：<%=server.htmlencode(rs("title"))%></b><hr size=1>
							<%=server.htmlencode(rs("content"))%>
					</td>
						</tr>
		<%
			RS.close:Set rs=Nothing
			SqlStr="Select id,sEnder from Message_Act where Incept='"&UserHS.UserName&"' and flag=0 and IsSend=1 and id>"&ACTCMS.ChkNumeric(actcms.s("ID")&" order by SendTime")
			Set rs=Conn.Execute(SqlStr)
			If not (RS.eof and RS.bof) Then
		%>
						<tr>
						  <td align=right valign=top class="td_bg"><a href=Message_User.asp?action=read&id=<%=rs(0)%>&sEnder=<%=rs(1)%>>[读取下一条信息]</a>					</td>
						</tr>
		<%
		End If
		RS.close:Set rs=Nothing
		%>
</table>
		<%
			End If
		End Sub
		'转发信息
		Sub fw()
			dim title,content,sEnder
			If actcms.s("ID")<>"" and isNumeric(actcms.s("ID")) Then
				Set rs=server.createobject("adodb.recordSet")
				SqlStr="Select title,content,sEnder from Message_Act where (Incept='"&UserHS.UserName&"' or sEnder='"&UserHS.UserName&"') and id="&Clng(actcms.s("ID"))
				RS.open SqlStr,Conn,1,1
				If RS.eof and RS.bof Then
					RS.close:Set rs=Nothing
					Response.Write "<script>alert('请指定正确的参数。');history.back();</script>"
				Else
				title=rs("title"):content=rs("content"):sEnder=rs("sEnder")
				End If
				RS.close:Set rs=Nothing
			End If
		%>
		<table width="100%" align=center cellpadding=2 cellspacing=1 class=table>
				<form action="Message_User.asp"  name="myform" method="post" id="myform" onSubmit="return CheckForm();">
				  <tr class="bg_tr"> 
					<td colspan=2 align=center height=25>
					 发送短消息
				    </td>
				  </tr>
				  <tr > 
					<td valign=middle width=100><b>收件人：</b></td>
					<td valign=middle>
					  <input type="hidden" name="action" value="sEnd">
					  <input class='textbox' type=text name="Touser" value="<%=actcms.s("Touser")%>" size=70>
					  <Select name="font" onChange="DoTitle(this.options[this.selectedIndex].value)">
					  <OPTION selected value="">选择</OPTION>
						<%
						Set rs=server.createobject("adodb.recordSet")
						SqlStr="Select friend from Friend_ACT where Username='"&UserHS.UserName&"' order by Addtime desc"
						RS.open SqlStr,Conn,1,1
						Do While not RS.eof
						%>
						<OPTION value="<%=rs(0)%>"><%=rs(0)%></OPTION>			
						<%
						RS.movenext
						loop
						RS.close:Set rs=Nothing
						%>
					  </Select>
					</td>
				  </tr>
				  <tr > 
					<td width="100" valign=top><b>标　题：</b></td>
					<td valign=middle>
					  <input class='textbox' type=text name="title" size=80 maxlength=90 value="Fw：<%=title%>">&nbsp;
					</td>
				  </tr>
				  <tr > 
					<td width="100" valign=top><b>内　容：</b></td>
					<td valign=middle>
<% dim content1
					  If actcms.s("ID")<>"" Then
						content1=content1&"============= 下面是转发信息 ==============<br>"
						content1=content1&"原发件人："&sEnder&"<br>"
						content1=content1&server.htmlencode(content)
						content1=content1&"======================================================="
					End If
		
 %>		
<div><input type="hidden" id="content" name="content" value="<%= content1 %>" style="display:none" />
	  <input name="hidden" type="hidden" id="cont___Config" style="display:none" value="" />
	  <iframe id="cont___Frame" src="../editor/fckeditor/editor/fckeditor.html?InstanceName=content&amp;Toolbar=Simple" width="100%" height="280" frameborder="0" scrolling="no"> </iframe>
      </div>					</td>
				  </tr>
				  <tr > 
					<td colspan=2>
		<b>说明</b>：<br>
		① 您可以使用<b>Ctrl+Enter</b>键快捷发送短信<br>
		② 可以用英文状态下的逗号将用户名隔开实现群发，最多<b><%=max_sEnd%></b>个用户<br>
		③ 标题最多<b>50</b>个字符，内容最多<b><%=max_sms%></b>个字符<br>
					</td>
				  </tr>
				  <tr > 
					<td valign=middle colspan=2 align=center> 
					  <input class="ACT_btn" type=Submit value=" 发 送 " name=Submit>
					  &nbsp; 
					  <input class="ACT_btn" type=Submit value=" 保 存 " name=Submit>
					  &nbsp; 
					  <input class="ACT_btn" type="reSet" name="Clear" value=" 清 除 ">
					  &nbsp; 
					  <input class="ACT_btn" type="button" name="close" value=" 关 闭 " onClick="window.close()">
					</td>
				  </tr>
			　</form>
</table>
		<%
			DoTitleJs
		End Sub
		
		Sub savemsg()
			dim Incept,title,message,Subtype,i,sUname
			If actcms.s("Touser")="" Then
				Response.Write("<script>alert('您忘记填写发送对象了吧。');history.back();</script>")
			Else
				Incept=actcms.s("Touser")
				Incept=split(Incept,",")
			End If
			If actcms.s("Title")="" Then
				Response.Write("<script>alert('您还没有填写标题呀。');history.back();</script>")
			ElseIf strLength(actcms.s("title"))>50 Then
				Response.Write("<script>alert('标题限定最多50个字符。');history.back();</script>")
			Else
				title=actcms.s("title")
			End If
			If actcms.s("content")="" Then
				Response.Write("<script>alert('内容是必须要填写的噢。');history.back();</script>")
			ElseIf strLength(actcms.s("content"))>Cint(max_sms) Then
				Response.Write("<script>alert('内容限定最多"&max_sms&"个字符。');history.back();</script>")
			Else
				message=actcms.s("content")
			End If
		
			for i=0 to ubound(Incept)
				sUname=replace(Incept(i),"'","")
				SqlStr="Select UserName from "&UserHS.TableName(UserHS.UModeID)&" where UserName='"&sUname&"'"
				Set rs=Conn.Execute(SqlStr)
				If RS.eof and RS.bof Then
					RS.close:Set rs=Nothing
					call actcms.Alert("系统没有这个用户，看看你的发送对象写对了嘛？","")
					response.end
				End If
				RS.Close
				rs.open "select username from Friend_ACT where username='" & sUname & "' and friend='" & UserHS.username & "' and flag=3",conn,1,1
				if not rs.eof then
					RS.close:Set rs=Nothing
					call actcms.Alert("对不起，你被" & sUname & "列为黑名单,不能发送短信给他！","")
					response.end
				end if
				RS.close:Set rs=Nothing
						
				Select Case actcms.s("Submit")
				Case " 发 送 "
					SqlStr="insert into Message_Act (Incept,sEnder,title,content,SendTime,flag,IsSend,DelR,DelS) values ('"&sUname&"','"&UserHS.UserName&"','"&title&"','"&message&"','"&Now()&"',0,1,0,0)"
					Subtype="已发送信息"
				Case " 保 存 "
					SqlStr="insert into Message_Act (Incept,sEnder,title,content,SendTime,flag,IsSend,DelR,DelS) values ('"&sUname&"','"&UserHS.UserName&"','"&title&"','"&message&"','"&Now()&"',0,0,0,0)"
					Subtype="发件箱"
				Case Else
					SqlStr="insert into Message_Act (Incept,sEnder,title,content,SendTime,flag,IsSend,DelR,DelS) values ('"&sUname&"','"&UserHS.UserName&"','"&title&"','"&message&"','"&Now()&"',0,1,0,0)"
					Subtype="已发送信息"
				End Select
				
				'判断对方信箱是否已满
				If conn.execute("select count(*) from Message_Act where Incept='"&sUname&"'")(0)>=Max_Num Then
					Response.Write("<script>alert('由于[" & sUname & "]的信箱已满，发送没有成功！');history.back();</script>")
				Else
				   Conn.Execute(SqlStr)
				End If

				
				If i>Cint(max_sEnd)-1 Then
					Response.Write("<script>alert('最多只能发送给"&max_sEnd&"个用户，您的名单"&max_sEnd&"位以后的请重新发送');history.back();</script>")
					exit for
				End If
			next
		Response.Write("<script>alert('恭喜您，发送短信息成功。发送的消息同时保存在您的"&Subtype&"中。');location.href='Message_User.asp';</script>")
		
		End Sub
		
		'更改信息
		Sub edit()
			dim Incept,title,content,id
			If actcms.s("ID")<>"" and isNumeric(actcms.s("ID")) Then
				Set rs=server.createobject("adodb.recordSet")
				SqlStr="Select id,Incept,title,content from Message_Act where sEnder='"&UserHS.UserName&"' and IsSend=0 and id="&Clng(s("ID"))
				RS.open SqlStr,Conn,1,1
				If not(RS.eof and RS.bof) Then
					Incept=rs("Incept"):title=rs("title"):content=rs("content"):id=rs("id")
				Else
					Response.Write("<script>alert('没有找到您要编辑的信息。');history.back();</script>")
				End If
				RS.close:Set rs=Nothing
			Else
				Response.Write("<script>alert('请指定相关参数。');history.back();</script>")
			End If
		%>
			<table width="100%" align=center cellpadding=2 cellspacing=1 class=table>
			<form action="Message_User.asp" method="post" name="myform" id="myform" onSubmit="return CheckForm();">
				  <tr> 
					<td height=25 colspan=2 align="center" class="bg_tr"> 
					  <input type=hidden name="action" value="savedit"> 
					  <input type=hidden name="id" value="<%=id%>">
				    发送短消息--请完整输入下列信息</td>
				  </tr>
				  <tr> 
					<td valign=middle class="td_bg"><b>收件人：</b></td>
					<td valign=middle class="td_bg">
					  <input type=text name="Touser" value="<%=Incept%>" size=80>
					</td>
				  </tr>
				  <tr> 
					<td valign=top class="td_bg"><b>标题：</b></td>
					<td valign=middle class="td_bg">
					  <input type=text name="title" size=80 maxlength=80 value="<%=title%>">
					</td>
				  </tr>
				  <tr> 
					<td valign=top class="td_bg"><b>内容：</b></td>
					<td valign=middle class="td_bg">
					
<div><input type="hidden" id="content" name="content" value="<%= server.htmlencode(content) %>" style="display:none" />
	  <input name="hidden" type="hidden" id="cont___Config" style="display:none" value="" />
	  <iframe id="cont___Frame" src="../editor/fckeditor/editor/fckeditor.html?InstanceName=content&amp;Toolbar=Simple" width="100%" height="280" frameborder="0" scrolling="no"> </iframe>
      </div>					</td>
				  </tr>
				  <tr> 
					<td colspan=2 class="td_bg">
		<b>说明</b>：<br>
		① 您可以使用<b>Ctrl+Enter</b>键快捷发送短信<br>
		② 标题最多<b>50</b>个字符，内容最多<b><%=max_sms%></b>个字符<br>
					</td>
				  </tr>
				  <tr> 
					<td colspan=2 align=center valign=middle class="td_bg"> 
					  <input class="ACT_btn" type=Submit value=" 发 送 " name="Submit">
					  &nbsp; 
					  <input class="ACT_btn" type=Submit value=" 保 存 " name="Submit">
					  &nbsp; 
					  <input class="ACT_btn" type="reSet" name="Clear" value=" 清 除 ">
					  &nbsp; 
					  <input class="ACT_btn" type="button" name="close" value=" 关 闭 " onClick="window.close()">
					</td>
				  </tr>
			  </form>
</table>
			  </td>
			</tr>
			
</table>
		
		<%
		End Sub
		
		Sub savedit()
			dim Incept,title,message,Subtype
			If s("ID")="" or not isNumeric(s("ID")) Then
				Response.Write("<script>alert('请指定相关参数。');history.back();</script>")
			End If
			If s("Touser")="" Then
				Response.Write("<script>alert('您忘记填写发送对象了吧。');history.back();</script>")
			Else
				Incept=s("Touser")
			End If
			If s("Title")="" Then
				Response.Write("<script>alert('您还没有填写标题呀!');history.back();</script>")
			Else
				title=s("title")
			End If
			If s("content")="" Then
			   Response.Write("<script>alert('内容是必须要填写的噢!');history.back();</script>")
			Else
				message=s("content")
			End If
		
			SqlStr="Select UserName from User_Act where UserName='"&Incept&"'"
			Set rs=Conn.Execute(SqlStr)
			If RS.eof and RS.bof Then
				Set rs=Nothing
				Response.Write("<script>alert('系统没有这个用户，看看你的发送对象写对了嘛？');history.back();</script>")
			End If
			Set rs=Nothing
		
			If s("Submit")=" 发 送 " Then
				SqlStr="Update Message_Act Set Incept='"&Incept&"',sEnder='"&UserHS.UserName&"',title='"&title&"',content='"&message&"',SendTime=Now(),flag=0,IsSend=1 where id="&Clng(s("ID"))
				Subtype="已发送信息"
			Else
				SqlStr="Update Message_Act Set Incept='"&Incept&"',sEnder='"&UserHS.UserName&"',title='"&title&"',content='"&message&"',SendTime=Now(),flag=0,IsSend=0 where id="&Clng(s("ID"))
				Subtype="发件箱"
			End If
			Set rs=Conn.Execute(SqlStr)
		   Response.Write("<script>alert('恭喜您，发送短信息成功。发送的消息同时保存在您的"&Subtype&"中。');location.href='Message_User.asp';</script>")
		End Sub
		
		'收件置于回收站，参数字段delR，可用于批量及单个删除
		Sub delinbox()
			dim DelID
			DelID=actcms.s("ID")
			If DelID="" or isnull(DelID) or Not IsNumeric(Replace(Replace(DelID,",","")," ","")) Then
				Response.Write "<script>alert('请选择相关参数!');history.go(-1);</script>"
				Exit Sub
			Else
				Conn.Execute("Update Message_Act Set delR=1 where Incept='"&UserHS.UserName&"' and id in ("&DelID&")")
				Response.Write "<script>alert('删除短信息成功。删除的消息将转移到您的回收站!');location.href='" & ComeUrl & "';</script>"
			
			End If
		End Sub
		
		Sub AllDelinbox()
			Conn.Execute("Update Message_Act Set delR=1 where Incept='"&UserHS.UserName&"' and delR=0")
			Response.Write "<script>alert('删除短信息成功。删除的消息将转移到您的回收站!');location.href='" & ComeUrl & "';</script>"
			Response.End
		End Sub
		
		'发件逻辑删除，置于回收站，入口字段delS，可用于批量及单个删除
		Sub deloutbox()
			dim DelID
			DelID=s("ID")
			If DelID="" or isnull(DelID) or Not IsNumeric(Replace(Replace(DelID,",","")," ","")) Then
				Response.Write "<script>alert('请选择相关参数!');history.go(-1);</script>"
			Else
				Conn.Execute("Update Message_Act Set delS=1 where Sender='"&UserHS.UserName&"' and IsSend=0 and id in ("&DelID&")")
				Response.Write "<script>alert('删除短信息成功。删除的消息将转移到您的回收站!');location.href='" & ComeUrl & "';</script>"
				Response.End
			End If
		End Sub
		
		Sub AllDeloutbox()
			Conn.Execute("Update Message_Act Set delS=1 where Sender='"&UserHS.UserName&"' and delS=0 and IsSend=0")
			Response.Write "<script>alert('删除短信息成功。删除的消息将转移到您的回收站!');location.href='" & ComeUrl & "';</script>"
			Response.End
		End Sub
		
		'已发送置于回收站，入口字段delS，可用于批量及单个删除
		'delS：0未操作，1发送者删除，2发送者从回收站删除
		Sub DelIsSend()
			dim DelID
			DelID=s("ID")
			If DelID="" or isnull(DelID) or Not IsNumeric(replace(Replace(DelID,",","")," ","")) Then
				Response.Write "<script>alert('请选择相关参数!');history.go(-1);</script>"
			Else
				Conn.Execute("Update Message_Act Set delS=1 where Sender='"&UserHS.UserName&"' and IsSend=1 and id in ("&DelID&")")
				Response.Write "<script>alert('删除短信息成功。删除的消息将转移到您的回收站!');location.href='" & ComeUrl & "';</script>"
				Response.End
			End If
		End Sub
		
		Sub AllDelIsSend()
			Conn.Execute("Update Message_Act Set delS=1 where Sender='"&UserHS.UserName&"' and delS=0 and IsSend=1")
			Response.Write "<script>alert('删除短信息成功。删除的消息将转移到您的回收站!');location.href='" & ComeUrl & "';</script>"
			Response.End
		End Sub
		
		'用户能完全删除收到信息和逻辑删除所发送信息，逻辑删除所发送信息设置入口字段delS参数为2
		Sub delrecycle()
			dim DelID
			DelID=ACTCMS.s("ID")
			If DelID="" or isnull(DelID) or Not IsNumeric(Replace(Replace(DelID,",","")," ","")) Then
				Response.Write "<script>alert('请选择相关参数!');history.go(-1);</script>"
			Else
				Conn.Execute("delete from Message_Act where Incept='"&UserHS.UserName&"' and id in ("&DelID&")")
				Conn.Execute("Update Message_Act Set delS=2 where Sender='"&UserHS.UserName&"' and delS=1 and id in ("&DelID&")")          
			Response.Write "<script language=""javascript"">alert('删除短信息成功。删除的消息将不可恢复');location.href='"&ComeUrl&"';</script>"
		    Response.End

				
			End If
		End Sub
	Public Function strLength(Str)
		On Error Resume Next
		Dim WINNT_CHINESE:WINNT_CHINESE = (Len("中国") = 2)
		If WINNT_CHINESE Then
			Dim l, T, c,I
			l = Len(Str)
			T = l
			For I = 1 To l
				c = Asc(Mid(Str, I, 1))
				If c < 0 Then c = c + 65536
				If c > 255 Then
					T = T + 1
				End If
			Next
			strLength = T
		Else
			strLength = Len(Str)
		End If
		If Err.Number <> 0 Then Err.Clear
	End Function
			Sub AllDelrecycle()
			Conn.Execute("delete from Message_Act where Incept='"&UserHS.UserName&"' and delR=1")	
			Conn.Execute("Update Message_Act Set delS=2 where Sender='"&UserHS.UserName&"' and delS=1")
			Response.Write "<script language=""javascript"">alert('删除短信息成功。删除的消息将不可恢复');location.href='"&ComeUrl&"';</script>"
			Response.End
		End Sub
		
		Sub delete()
			dim DelID
			DelID=ACTCMS.s("id")
			ComeUrl=Request("ComeUrl")
			'Response.End()
			If ComeUrl="" Then ComeUrl="Message_User.asp"
			If not isNumeric(DelID) or DelID="" or isnull(DelID) Then
				Response.Write "<script>alert('请选择相关参数!');history.go(-1);</script>"
			Else
				Conn.Execute("Update Message_Act Set delR=1 where Incept='"&UserHS.UserName&"' and id="&Clng(DelID))
				Conn.Execute("Update Message_Act Set delS=1 where sEnder='"&UserHS.UserName&"' and id="&Clng(DelID))
				Response.Write "<script language=""javascript"">alert('删除短信息成功。删除的消息将置于您的回收站内。');location.href='"&ComeUrl&"';</script>"
				Response.End
			End If
		End Sub
		
		Sub MessageMain()
			dim SqlStr,boxName,smstype,readaction,turl
			Select Case Action
			Case "inbox"
				boxName="收件箱":smstype="inbox":readaction="read":turl="readsms"
				SqlStr="select * from Message_Act where Incept='"&UserHS.UserName&"' and IsSend=1 and delR=0 order by flag,SendTime desc"
			Case "outbox"
				boxName="草稿箱":smstype="outbox":readaction="edit":turl="sms"
				SqlStr="select * from Message_Act where Sender='"&UserHS.UserName&"' and IsSend=0 and delS=0 order by SendTime desc"
			Case "issend"
				boxName="已发送的消息":smstype="IsSend":readaction="outread":turl="readsms"
				SqlStr="select * from Message_Act where Sender='"&UserHS.UserName&"' and IsSend=1 and delS=0 order by SendTime desc"
			Case "recycle"
				boxName="垃圾箱":smstype="recycle":readaction="read":turl="readsms"
				SqlStr="select * from Message_Act where ((Sender='"&UserHS.UserName&"' and delS=1) or (Incept='"&UserHS.UserName&"' and delR=1)) and not delS=2 order by SendTime desc"
			Case Else
				boxName="收件箱":smstype="inbox":readaction="read":turl="readsms"
				SqlStr="select * from Message_Act where Incept='"&UserHS.UserName&"' and IsSend=1 and delR=0 order by flag,SendTime desc"
			End Select
		%>
		<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1"  class="table">
		<form action="Message_User.asp" method="post" name="inbox">
		<tr height='23' class="Title">
		<td width="50" align="center" class="bg_tr">已读</td>
		<td width="277" align="center" class="bg_tr">主题</td>
		<td width="100"  height="26" align="center" class="bg_tr">
		<%if smstype="inbox" or smstype="recycle" then Response.Write "发件人" else Response.Write "收件人"%></td>
		<td width="140" align="center" class="bg_tr">日期</td>
		<td width="65" align="center" class="bg_tr">大小</td>
		<td align="center" class="bg_tr">操作</td>
		</tr>
		<%
			Dim RS:Set RS=server.createobject("adodb.recordset")
			ConnectionDatabase
			RS.open SqlStr,Conn,1,1
			if RS.eof and RS.bof then
		%>
		<tr>
		<td colspan=6 align=center valign=middle >您的<%=boxname%>中没有任何内容。</td>
		</tr>
		<%else
		Do While not RS.eof
		%>
		<tr   onMouseOver=overColor(this) onMouseOut=outColor(this)>
		<td height="25" align=center valign=middle class="td_bg">
		<%
		select case smstype
		case "inbox"
			if rs("flag")=0 then
				Response.Write "<img src=""images/news.gif"">"
			else
				Response.Write "<img src=""images/olds.gif"">"
			end if
		case "outbox"
			Response.Write "<img src=""images/IsSend_2.gif"">"
		Case "issend"
			Response.Write "<img src=""images/IsSend_1.gif"">"
		case "recycle"
			if rs("flag")=0 then
				Response.Write "<img src=""images/news.gif"">"
			else
				Response.Write "<img src=""images/olds.gif"">"
			end if
		end select
		%>
		</td>
		<td height="25" align=left class="td_bg"><a href="Message_User.asp?action=<%=readaction%>&id=<%=rs("id")%>&sender=<%=rs("sender")%>"><%=server.htmlencode(rs("title"))%></a>	</td>
		<td height="25" align=center valign=middle class="td_bg">
		<%if smstype="inbox" or smstype="recycle" then%>
		<%=server.htmlencode(rs("sender"))%>
		<%else%>
		<%=server.htmlencode(rs("Incept"))%>
		<%end if%>
		</td>
		<td height="25" align="center" class="td_bg"><%=formatdatetime(rs("SendTime"),2)%></td>
		<td height="25" align="center" class="td_bg"><%=len(rs("content"))%>Byte</td>
		<td width=47 height="25" align=center  class="td_bg"><input type=checkbox name=id value=<%=rs("id")%>></td>
		</tr>
		<%
			RS.movenext
			loop
			end if
			RS.close:set rs=Nothing
		%>
		<tr  > 
		<td height="26" colspan=6 align=right valign=middle>节省每一分空间，请及时删除无用信息&nbsp;
		  <input type=checkbox name=chkall value=on onClick="CheckAll(this.form)">选中所有显示记录&nbsp;<input class="ACT_btn" type=submit name=action onClick="{if(confirm('确定删除选定的纪录吗?')){this.document.inbox.submit();return true;}return false;}" value="删除<%=boxname%>">&nbsp;
		  <input type=submit class="ACT_btn" name=action onClick="{if(confirm('确定清除<%=boxname%>所有的纪录吗?')){this.document.inbox.submit();return true;}return false;}" value="清空<%=boxname%>"></td>
		</tr>
		</form>
</table>
		<br>
		<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; 
		}
		}
function overColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="tdbg1"
		Obj.bgColor="";
	}
	
}
function outColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="tdbg";
		Obj.bgColor="";
	}
}		</script>
		<%
		end sub
		
		Sub DoTitleJs()
		%>
		<script language="javascript"> 
		function DoTitle(addTitle) {  
		 var revisedTitle;  
		 var currenttitle = document.myform.Touser.value; 
		
		 if(currenttitle=="") revisedTitle = addTitle; 
		 else { 
		  var arr = currenttitle.split(","); 
		  for (var i=0; i < arr.length; i++) { 
		   if( addTitle.indexOf(arr[i]) >=0 && arr[i].length==addTitle.length ) return; 
		  } 
		  revisedTitle = currenttitle+","+addTitle; 
		 } 
		
		 document.myform.Touser.value=revisedTitle;  
		 document.myform.Touser.focus(); 
		 return; 
		} 
		function document.onkeydown()
		{
			if(event.ctrlKey && window.event.keyCode==13)
			{
				CheckForm();
			}
			
		}
		
		</script>
		<%
		End Sub
		 '（图片对象名称，标题对象名称，更新数，总数）
		Function ShowTable(SrcName,TxtName,str,c)
		Dim Tempstr,Src_js,Txt_js,TempPercent
		If C = 0 Then C = 99999999
		Tempstr = str/C
		TempPercent = FormatPercent(tempstr,0,-1)
		Src_js = "document.getElementById(""" + SrcName + """)"
		Txt_js = "document.getElementById(""" + TxtName + """)"
			ShowTable = VbCrLf + "<script>"
			ShowTable = ShowTable + Src_js + ".width=""" & FormatNumber(tempstr*600,0,-1) & """;"
			ShowTable = ShowTable + Src_js + ".title=""容量上限为："&c&"条，总共已储存（"&str&"）条站内短信！"";"
			ShowTable = ShowTable + Txt_js + ".innerHTML="""
			If FormatNumber(tempstr*100,0,-1) < 80 Then
				ShowTable = ShowTable + "已使用:" & TempPercent & """;"
			Else
				ShowTable = ShowTable + "<font color=\""red\"">已使用:" & TempPercent & ",请赶快清理！</font>"";"
			End If
			ShowTable = ShowTable + "</script>"
		End Function

%> 
