<%@language=vbscript codepage=936 %>
<%
option explicit
response.buffer=true
%>
<!--#include file="../Conn.asp"-->
<!--#include file="../Inc/Cl_ClsSysTem.asp"-->
<!--#include file="../Inc/Cl_Function_Public.asp"-->
<!--#include file="../Inc/Cl_ClsUbb.asp"-->
<%
Const Max_sEnd=5	'群发限制人数
Const Max_sms=1000	'内容最多字符数
Const ChannelID=1
const MaxPerPage=20
Cl.Page_Admin=True
Cl.GetWeb_Setting()
If Not Cl.ChkUserLogin Then
	User_ShowErr("<li>以下操作需要登录后方或进行，您未登录。</li><li>请点击<a href='LogIn.asp' target='_Top'>这里登录</a>。")
	Response.End
End If

Dim ComeUrl,FoundErr,Errmsg
Dim SQL,Rs,i,Action
Dim TotalPut,CurrentPage,TotalPages
Action=Lcase(request("action"))
ComeUrl=Cstr(Request.ServerVariables("HTTP_REFERER"))
CurrentPage	= Cl.ChkClng(request("page"))
If ComeUrl="" Then ComeUrl="User_Message.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">
<%
User_MsgNav
OpenConn_U
Select Case Action
Case "new" : sEndmsg
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 : SmsMain
End Select
Footer
'发送信息
Sub sEndmsg()
	dim sEndtime,title,content
	If request("id")<>"" and isNumeric(request("id")) Then
		Set rs=server.createobject("adodb.recordSet")
		sql="Select sEndtime,title,content from " & Db.MessageTable & " where incept='"&Cl.User_Info(5)&"' and id="&Clng(request("id"))
		rs.open sql,Conn_U,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="User_Message.asp" method=post name=messager>
<table cellpadding=3 cellspacing=1 align=center class=border>
          <tr> 
            <th class="title" colspan=3 align=center><b>发送短消息（请输入完整信息）</b></th>
          </tr>
          <tr> 
            <td Class=tdbg valign=middle><b>收件人：</b></td>
            <td Class=tdbg valign=middle>
			  <input type=hidden name="action" value="sEnd">
              <input type=text name="touser" value="<%=request("touser")%>" size=80>
              <Select name=font onchange=DoTitle(this.options[this.selectedIndex].value)>
              <OPTION selected value="">选择</OPTION>
<%
Set rs=server.createobject("adodb.recordSet")
sql="Select F_friEnd from " & Db.FriEndTable & " where F_username='"&Cl.User_Info(5)&"' order by F_addtime desc"
rs.open sql,Conn_U,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 Class=tdbg valign=top width=15%><b>标题：</b></td>
            <td Class=tdbg valign=middle>
              <input type=text name="title" size=90 maxlength=90 value="<%=title%>">
            </td>
          </tr>
          <tr> 
            <td Class=tdbg valign=top width=15%><b>内容：</b></td>
            <td  Class=tdbg valign=middle>
              <textarea cols=76 rows=16 name="message" title="Ctrl+Enter发送"><%If request("id")<>"" Then%>
====== 在 <%=sEndtime%> 您来信中写道： ======
<%=server.htmlencode(content)%>
=====================================
<%End If%></textarea>
            </td>
          </tr>
          <tr> 
            <td Class=tdbg 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 class=tdbg valign=middle colspan=2 align=center> 
              <input type=Submit value="发送" name=Submit>
              &nbsp; 
              <input type=Submit value="保存" name=Submit>
              &nbsp; 
              <input type="reSet" name="Clear" value="清除">
              &nbsp; 
<%If request("reaction")="chatlog" Then%>
              <input type=button value="关闭聊天记录" name="chatlog" onclick="location.href='?action=new&id=<%=request("id")%>&touser=<%=request("touser")%>'">
<%Else%>
              <input type=button value="查看聊天记录" name="chatlog" onclick="location.href='?action=new&id=<%=request("id")%>&touser=<%=request("touser")%>&reaction=chatlog'">
<%End If%>
              &nbsp; 
              <input type="button" name="close" value="关闭" onclick="window.close()">
            </td>
          </tr>
<%If request("reaction")="chatlog" Then%>
          <tr Class=title> 
            <td colspan=3>我与<%=request("touser")%>的聊天记录</td>
          </tr>
<%If Cl.User_Info(5)=request("touser") Then%>
          <tr> 
            <td Class=tdbg colspan=3>自己跟自己的聊天记录没什么好看的：）</td>
          </tr>
<%Else%>
<%
	Set rs=server.createobject("adodb.recordSet")
	sql="Select * from " & Db.MessageTable & " where ((sEnder='"&Trim(Cl.User_Info(5))&"' and incept='"&replace(request("touser"),"'","")&"') or (sEnder='"&replace(request("touser"),"'","")&"' and incept='"&Cl.User_Info(5)&"')) and delS=0 order by sEndtime desc"
	rs.open sql,Conn_U,1,1
	If rs.eof and rs.bof Then
%>
          <tr> 
            <td Class=tdbg colspan=3>还没有任何聊天记录！</td>
          </tr>
<%
	Else
	do while not rs.eof
%>
                <tr>
                    <td class=tdbg height=25 colspan=3>
<%If rs("sEnder")=Cl.User_Info(5) Then%>
                    在<b><%=rs("sEndtime")%></b>，您发送此消息给<b><%=Cl.HTMLEncode(rs("incept"))%></b>！
<%Else%>
		    在<b><%=rs("sEndtime")%></b>，<b><%=Cl.HTMLEncode(rs("sEnder"))%></b>给您发送的消息！
<%End If%></td>
                </tr>
                <tr>
                    <td  Class=tdbg valign=top align=left colspan=3>
                    <b>消息标题：<%=Cl.HTMLEncode(rs("title"))%></b><hr size=1>
                    <%=Cl.Ubbcode(Cl.HTMLEncode(rs("content")))%>
		    </td>
                </tr>
<%
	rs.movenext
	loop
	End If
	rs.close:Set rs=Nothing
%>
<%End If%>
<%End If%>
        </table>
</form>
<%
	DoTitleJs
End Sub
'读取信息
Sub read()
	If request("id")="" or not isNumeric(request("id")) Then
		Call Cl.OutMsg("请指定正确的参数。","javascript:history.go(-1)")
	End If
	Set rs=server.createobject("adodb.recordSet")
	If request("action")="read" Then
		Cl.Execute_U("update " & Db.MessageTable & " Set flag=1 where ID="&Clng(request("id")))
	End If
	sql="Select * from " & Db.MessageTable & " where (incept='"&Cl.User_Info(5)&"' or sEnder='"&Cl.User_Info(5)&"') and id="&Clng(request("id"))
	rs.open sql,Conn_U,1,1
	If rs.eof and rs.bof Then
		rs.close:Set rs=Nothing
		Call Cl.OutMsg("你是不是跑到别人的信箱啦、或者该信息已经收件人删除。","javascript:history.go(-1)")
	Else
%>
<table cellpadding=3 cellspacing=1 align=center class=border>
            <tr>
                <th class="tdbg_main" colspan=3>欢迎使用短消息接收，<%=Cl.User_Info(5)%></th>
            </tr>
            <tr>
                <td Class=tdbg valign=middle align=center colspan=3><a href="User_Message.asp?action=delet&id=<%=rs("id")%>&ComeUrl=<%=ComeUrl%>"><img src="<%=Cl.WebDir%>images/Message/delete.gIf" border=0 alt="删除消息"></a> &nbsp; <a href="User_Message.asp?action=new"><img src="<%=Cl.WebDir%>images/Message/write.gIf" border=0 alt="发送消息"></a> &nbsp;<a href="User_Message.asp?action=new&touser=<%=Cl.HTMLEncode(rs("sEnder"))%>&id=<%=request("id")%>"><img src="<%=Cl.WebDir%>images/Message/reply.gIf" border=0 alt="回复消息"></a>&nbsp;<a href="User_Message.asp?action=fw&id=<%=request("id")%>"><img src="<%=Cl.WebDir%>images/Message/fw.gIf" border=0 alt=转发消息></a></td>
            </tr>
                <tr>
                    <td class="title" height=25>
<%If request("action")="outread" Then%>
                    在<b><%=rs("sEndtime")%></b>，您发送此消息给<b><%=Cl.HTMLEncode(rs("incept"))%></b>！
<%Else%>
		    在<b><%=rs("sEndtime")%></b>，<b><%=Cl.HTMLEncode(rs("sEnder"))%></b>给您发送的消息！
<%End If%></td>
                </tr>
                <tr>
                    <td  Class=tdbg valign=top align=left>
                    <b>消息标题：<%=Cl.HTMLEncode(rs("title"))%></b><hr size=1>
                    <%=Cl.UBBCode(rs("content"))%>
		    </td>
                </tr>
<%
	rs.close:Set rs=Nothing
	sql="Select id,sEnder from " & Db.MessageTable & " where incept='"&Cl.User_Info(5)&"' and flag=0 and issEnd=1 and id>"&Cl.ChkClng(request("id")&" order by sEndtime")
	Set rs=Cl.Execute_U(sql)
	If not (rs.eof and rs.bof) Then
%>
                <tr>
                    <td class="tdbg" align=right><a href=User_Message.asp?action=read&id=<%=rs(0)%>&sEnder=<%=rs(1)%>>[读取下一条信息]</a>
		    </td>
                </tr>
<%
End If
rs.close:Set rs=Nothing
%>
                </table>
<%
	Cl.Update_User_Msg(Cl.User_Info(5))
	End If
End Sub
'转发信息
Sub fw()
	dim title,content,sEnder
	If request("id")<>"" and isNumeric(request("id")) Then
		Set rs=server.createobject("adodb.recordSet")
		sql="Select title,content,sEnder from " & Db.MessageTable & " where (incept='"&Cl.User_Info(5)&"' or sEnder='"&Cl.User_Info(5)&"') and id="&Clng(request("id"))
		rs.open sql,Conn_U,1,1
		If rs.eof and rs.bof Then
			rs.close:Set rs=Nothing
			Call Cl.OutMsg("请选择相关参数。","javascript:history.go(-1)")
		Else
		title=rs("title"):content=rs("content"):sEnder=rs("sEnder")
		End If
		rs.close:Set rs=Nothing
	End If
%>
<form action="User_Message.asp" method=post name=messager>
        <table cellpadding=3 cellspacing=1 align=center class=border>
          <tr> 
            <th colspan=2 height=25 class="title">
              <input type=hidden name="action" value="sEnd">
              发送短消息--请完整输入下列信息</th>
          </tr>
          <tr> 
            <td Class=tdbg valign=middle width=15%><b>收件人：</b></td>
            <td  Class=tdbg valign=middle>
              <input type=text name="touser" value="<%=request("touser")%>" size=80>
              <Select name="font" onchange="DoTitle(this.options[this.selectedIndex].value)">
              <OPTION selected value="">选择</OPTION>
<%
Set rs=server.createobject("adodb.recordSet")
sql="Select F_friEnd from " & Db.FriEndTable & " where F_username='"&Cl.User_Info(5)&"' order by F_addtime desc"
rs.open sql,Conn_U,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 Class=tdbg valign=top><b>标题：</b></td>
            <td Class=tdbg valign=middle>
              <input type=text name="title" size=90 maxlength=90 value="Fw：<%=title%>">&nbsp;
            </td>
          </tr>
          <tr> 
            <td Class=tdbg valign=top><b>内容：</b></td>
            <td Class=tdbg valign=middle>
              <textarea cols=76 rows=16 name="message" title="Ctrl+Enter发送">


========== 下面是转发信息 =========
原发件人：<%=sEnder%><%=chr(13)&chr(13)%>
<%=server.htmlencode(content)%>
===================================</textarea>
            </td>
          </tr>
          <tr> 
            <td  Class=tdbg 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 Class=tdbg> 
            <td valign=middle colspan=2 align=center> 
              <input type=Submit value="发送" name=Submit>
              &nbsp; 
              <input type=Submit value="保存" name=Submit>
              &nbsp; 
              <input type="reSet" name="Clear" value="清除">
              &nbsp; 
              <input type="button" name="close" value="关闭" onclick="window.close()">
            </td>
          </tr>
        </table>
</form>
<%
	DoTitleJs
End Sub

Sub savemsg()
	dim incept,title,message,i,sUname
	If request("touser")="" Then
		Call Cl.OutMsg("您忘记填写发送对象了吧。","javascript:history.go(-1)")
	Else
		incept=Cl.Checkstr(request("touser"))
		incept=split(incept,",")
	End If
	If request("title")="" Then
		Call Cl.OutMsg("您还没有填写标题呀。","javascript:history.go(-1)")
	ElseIf Cl.strLength(request("title"))>50 Then
		Call Cl.OutMsg("标题限定最多50个字符。","javascript:history.go(-1)")
	Else
		title=Cl.Checkstr(request("title"))
	End If
	If request("message")="" Then
		Call Cl.OutMsg("内容是必须要填写的噢。","javascript:history.go(-1)")
	ElseIf Cl.strLength(request("message"))>Cint(max_sms) Then
		Call Cl.OutMsg("内容限定最多"&max_sms&"个字符。","javascript:history.go(-1)")
	Else
		message=Cl.Checkstr(request("message"))
	End If

	for i=0 to ubound(incept)
		sUname=replace(incept(i),"'","")
		sql="Select "&Db.UserName&" from "&Db.UserTable&" where "&Db.UserName&"='"&sUname&"'"
		Set rs=Cl.Execute_U(sql)
		If rs.eof and rs.bof Then
			rs.close:Set rs=Nothing
			Call Cl.OutMsg("系统没有这个用户，看看你的发送对象写对了嘛？","javascript:history.go(-1)")
		End If
		rs.close:Set rs=Nothing
		Select Case request("Submit")
		Case "发送"
			sql="insert into " & Db.MessageTable & " (incept,sEnder,title,content,sEndtime,flag,issEnd) values ('"&sUname&"','"&Cl.User_Info(5)&"','"&title&"','"&message&"',"&SqlNowString_U&",0,1)"
		Case "保存"
			sql="insert into " & Db.MessageTable & " (incept,sEnder,title,content,sEndtime,flag,issEnd) values ('"&sUname&"','"&Cl.User_Info(5)&"','"&title&"','"&message&"',"&SqlNowString_U&",0,0)"
		Case Else
			sql="insert into " & Db.MessageTable & " (incept,sEnder,title,content,sEndtime,flag,issEnd) values ('"&sUname&"','"&Cl.User_Info(5)&"','"&title&"','"&message&"',"&SqlNowString_U&",0,1)"
		End Select
		Cl.Execute_U(sql)
		Cl.Update_User_Msg(sUname)
		If i>Cint(max_sEnd)-1 Then
			Call Cl.OutMsg("最多只能发送给"&max_sEnd&"个用户，您的名单"&max_sEnd&"位以后的请重新发送","javascript:history.go(-1)")	
			exit for
		End If
	next
	if request("Submit")="保存" then
    Call Cl.OutMsg("恭喜您，保存短信息成功。消息已经保存在您的发件箱中。","User_Message.asp")
	else
    Call Cl.OutMsg("恭喜您，发送短信息成功。发送的消息同时保存在您的已发送信息中。","User_Message.asp")
	end if
End Sub

'更改信息
Sub edit()
	dim incept,title,content,id
	If request("id")<>"" and isNumeric(request("id")) Then
		Set rs=server.createobject("adodb.recordSet")
		sql="Select id,incept,title,content from " & Db.MessageTable & " where sEnder='"&Cl.User_Info(5)&"' and issEnd=0 and id="&Clng(request("id"))
		rs.open sql,Conn_U,1,1
		If not(rs.eof and rs.bof) Then
			incept=rs("incept"):title=rs("title"):content=rs("content"):id=rs("id")
		Else
			Call Cl.OutMsg("没有找到您要编辑的信息。","javascript:history.go(-1)")
		End If
		rs.close:Set rs=Nothing
	Else
		Call Cl.OutMsg("请指定相关参数。","javascript:history.go(-1)")
	End If
%>
<form action="User_Message.asp" method=post name=messager>
        <table cellpadding=3 cellspacing=1 align=center class=border>
          <tr> 
            <th colspan=2 height=25 class="title"> 
              <input type=hidden name="action" value="savedit"> 
              <input type=hidden name="id" value="<%=id%>">
              发送短消息--请完整输入下列信息</th>
          </tr>
          <tr> 
            <td  Class=tdbg valign=middle><b>收件人：</b></td>
            <td  Class=tdbg valign=middle>
              <input type=text name="touser" value="<%=incept%>" size=60>
            </td>
          </tr>
          <tr> 
            <td Class=tdbg valign=top><b>标题：</b></td>
            <td  Class=tdbg valign=middle>
              <input type=text name="title" size=60 maxlength=80 value="<%=title%>">
            </td>
          </tr>
          <tr> 
            <td  Class=tdbg valign=top><b>内容：</b></td>
            <td  Class=tdbg valign=middle>
              <textarea cols=52 rows=6 name="message" title=""><%=server.htmlencode(content)%></textarea>
            </td>
          </tr>
          <tr> 
            <td  Class=tdbg colspan=2>
<b>说明</b>：<br />
① 您可以使用<b>Ctrl+Enter</b>键快捷发送短信<br />
② 标题最多<b>50</b>个字符，内容最多<b><%=max_sms%></b>个字符<br />
            </td>
          </tr>
          <tr> 
            <td  class=tdbg valign=middle colspan=2 align=center> 
              <input type=Submit value="发送" name=Submit>
              &nbsp; 
              <input type=Submit value="保存" name=Submit>
              &nbsp; 
              <input type="reSet" name="Clear" value="清除">
              &nbsp; 
              <input type="button" name="close" value="关闭" onclick="window.close()">
            </td>
          </tr>
        </table>
</form>
<%
End Sub

Sub savedit()
	dim incept,title,message
	If request("id")="" or not isNumeric(request("id")) Then
		Call Cl.OutMsg("请指定相关参数。","javascript:history.go(-1)")
	End If
	If request("touser")="" Then
		Call Cl.OutMsg("您忘记填写发送对象了吧。","javascript:history.go(-1)")
	Else
		incept=Cl.Checkstr(request("touser"))
	End If
	If request("title")="" Then
		Call Cl.OutMsg("您还没有填写标题呀。","javascript:history.go(-1)")
	Else
		title=Cl.Checkstr(request("title"))
	End If
	If request("message")="" Then
		Call Cl.OutMsg("内容是必须要填写的噢。","javascript:history.go(-1)")
	Else
		message=Cl.Checkstr(request("message"))
	End If

	sql="Select "&Db.UserName&" from "&Db.UserTable&" where "&Db.UserName&"='"&incept&"'"
	Set rs=Cl.Execute_U(sql)
	If rs.eof and rs.bof Then
		Set rs=Nothing
		Call Cl.OutMsg("系统没有这个用户，看看你的发送对象写对了嘛？","javascript:history.go(-1)")
	End If
	Set rs=Nothing

	If request("Submit")="发送" Then
		sql="update " & Db.MessageTable & " Set incept='"&incept&"',sEnder='"&Cl.User_Info(5)&"',title='"&title&"',content='"&message&"',sEndtime=Now(),flag=0,issEnd=1 where id="&Clng(request("id"))
	Else
		sql="update " & Db.MessageTable & " Set incept='"&incept&"',sEnder='"&Cl.User_Info(5)&"',title='"&title&"',content='"&message&"',sEndtime=Now(),flag=0,issEnd=0 where id="&Clng(request("id"))
	End If
	Set rs=Cl.Execute_U(sql)
	if request("Submit")="发送" then
    Call Cl.OutMsg("恭喜您，发送短信息成功。发送的消息同时保存在您的已发送信息中。","User_Message.asp")
	else
    Call Cl.OutMsg("恭喜您，保存短信息成功。消息已经保存在您的发件箱中。","User_Message.asp")
	end if
End Sub

'收件逻辑删除，置于回收站，入口字段delR，可用于批量及单个删除
Sub delinbox()
	dim delid
	delid=replace(request("id"),"'","")
	delid=replace(request("id")," ","")
	If delid="" or isnull(delid) or Not IsNumeric(Replace(delid,",","")) Then
		Call Cl.OutMsg("请选择相关参数。","javascript:history.go(-1)")
	Else
		Cl.Execute_U("update " & Db.MessageTable & " Set delR=1 where incept='"&Trim(Cl.User_Info(5))&"' and id in ("&delid&")")
		Call Cl.OutMsg("删除短信息成功。删除的消息将转移到您的回收站。",ComeUrl)
	End If
End Sub

Sub AllDelinbox()
	Cl.Execute_U("update " & Db.MessageTable & " Set delR=1 where incept='"&Trim(Cl.User_Info(5))&"' and delR=0")
	Call Cl.OutMsg("删除短信息成功。删除的消息将转移到您的回收站。",ComeUrl)
End Sub

'发件逻辑删除，置于回收站，入口字段delS，可用于批量及单个删除
Sub deloutbox()
	dim delid
	delid=replace(request("id")," ","")
	If delid="" or isnull(delid) or Not IsNumeric(Replace(delid,",","")) Then
		Call Cl.OutMsg("请选择相关参数。","javascript:history.go(-1)")
	Else
		Cl.Execute_U("update " & Db.MessageTable & " Set delS=1 where sEnder='"&Trim(Cl.User_Info(5))&"' and issEnd=0 and id in ("&delid&")")
		Call Cl.OutMsg("删除短信息成功。删除的消息将转移到您的回收站。",ComeUrl)
	End If
End Sub

Sub AllDeloutbox()
	Cl.Execute_U("update " & Db.MessageTable & " Set delS=1 where sEnder='"&Trim(Cl.User_Info(5))&"' and delS=0 and issEnd=0")
	Call Cl.OutMsg("删除短信息成功。删除的消息将转移到您的回收站。",ComeUrl)
End Sub

'已发送逻辑删除，置于回收站，入口字段delS，可用于批量及单个删除
'delS：0未操作，1发送者删除，2发送者从回收站删除
Sub delissEnd()
	dim delid
	delid=replace(request("id")," ","")
	If delid="" or isnull(delid) or Not IsNumeric(Replace(delid,",","")) Then
		Call Cl.OutMsg("请选择相关参数。","javascript:history.go(-1)")
	Else
		Cl.Execute_U("update " & Db.MessageTable & " Set delS=1 where sEnder='"&Trim(Cl.User_Info(5))&"' and issEnd=1 and id in ("&delid&")")
		Call Cl.OutMsg("删除短信息成功。删除的消息将转移到您的回收站。",ComeUrl)
	End If
End Sub

Sub AllDelissEnd()
	Cl.Execute_U("update " & Db.MessageTable & " Set delS=1 where sEnder='"&Trim(Cl.User_Info(5))&"' and delS=0 and issEnd=1")
	Call Cl.OutMsg("删除短信息成功。删除的消息将转移到您的回收站。",ComeUrl)
End Sub

'用户能完全删除收到信息和逻辑删除所发送信息，逻辑删除所发送信息设置入口字段delS参数为2
Sub delrecycle()
	dim delid
	delid=replace(request("id")," ","")
	If delid="" or isnull(delid) or Not IsNumeric(Replace(delid,",","")) Then
		Call Cl.OutMsg("请选择相关参数。","javascript:history.go(-1)")
	Else
		Cl.Execute_U("delete * from " & Db.MessageTable & " where incept='"&Cl.User_Info(5)&"' and delR=1 and id in ("&delid&")")
		Cl.Execute_U("update " & Db.MessageTable & " Set delS=2 where sEnder='"&Trim(Cl.User_Info(5))&"' and delS=1 and id in ("&delid&")")
		Call Cl.OutMsg("删除短信息成功。删除的消息将不可恢复。",ComeUrl)
	End If
End Sub
Sub AllDelrecycle()
	Cl.Execute_U("delete * from " & Db.MessageTable & " where incept='"&Cl.User_Info(5)&"' and delR=1")	
	Cl.Execute_U("update " & Db.MessageTable & " Set delS=2 where sEnder='"&Trim(Cl.User_Info(5))&"' and delS=1")
	Call Cl.OutMsg("删除短信息成功。删除的消息将不可恢复。",ComeUrl)
End Sub

Sub delete()
	dim delid
	delid=Cl.Checkstr(request("id"))
	ComeUrl=Request("ComeUrl")
	If ComeUrl="" Then ComeUrl="User_Message.Asp"
	If not isNumeric(request("id")) or delid="" or isnull(delid) Then
		Call Cl.OutMsg("请选择相关参数。","javascript:history.go(-1)")
	Else
		Cl.Execute_U("update " & Db.MessageTable & " Set delR=1 where incept='"&Trim(Cl.User_Info(5))&"' and id="&Clng(delid))
		Cl.Execute_U("update " & Db.MessageTable & " Set delS=1 where sEnder='"&Trim(Cl.User_Info(5))&"' and id="&Clng(delid))
		Call Cl.OutMsg("删除短信息成功。删除的消息将置于您的回收站内。",ComeUrl)
	End If
End Sub

sub smsmain()
	dim newstyle,boxName,smstype,readaction,turl
	SQL = "Select id,sender,incept,title,content,flag,sendtime,delR,delS,isSend From " & Db.MessageTable & " where "
	Select Case Action
	Case "inbox"
		boxName="收件箱":smstype="inbox":readaction="read":turl="readsms"
		sql=SQL & "incept='"&Trim(Cl.User_Info(5))&"' and issend=1 and delR=0 order by flag,id desc"
	Case "outbox"
		boxName="草稿箱":smstype="outbox":readaction="edit":turl="sms"
		sql=SQL & "sender='"&Trim(Cl.User_Info(5))&"' and issend=0 and delS=0 order by id desc"
	Case "issend"
		boxName="已发送的消息":smstype="issend":readaction="outread":turl="readsms"
		sql=SQL & "sender='"&Trim(Cl.User_Info(5))&"' and issend=1 and delS=0 order by id desc"
	Case "recycle"
		boxName="垃圾箱":smstype="recycle":readaction="read":turl="readsms"
		sql=SQL & " ((sender='"&Trim(Cl.User_Info(5))&"' and delS=1) or (incept='"&Trim(Cl.User_Info(5))&"' and delR=1)) and not delS=2 order by id desc"
	Case Else
		boxName="收件箱":smstype="inbox":readaction="read":turl="readsms"
		sql=SQL & "incept='"&Trim(Cl.User_Info(5))&"'  and issend=1 and delR=0 order by flag,id desc"
	End Select
%>
<table border="0" align="center" cellpadding="0" cellspacing="1" class=border>
<tr>
<td Class=title align=center valign=middle colspan=6>我的<%=boxname%></td>
</tr>
<form action="User_Message.asp" method=post name=inbox>
<tr height='23' class="title2">
<td align="center" width=30>已读</td>
<td align="center" width=100>
<%if smstype="inbox" or smstype="recycle" then response.write "发件人" else response.write "收件人"%>
</td>
<td align="center" width=300>主题</td>
<td align="center" width=150>日期</td>
<td align="center" width=50>大小</td>
<td align="center" width=30>操作</td>
</tr>
<%
	set rs=server.createobject("adodb.recordset")
	OpenConn_U
	rs.open sql,Conn_U,1,1
	if rs.eof and rs.bof then
%>
<tr>
<td Class=tdbg align=center valign=middle colspan=6>您的<%=boxname%>中没有任何内容。</td>
</tr>
<%
rs.close:set rs=Nothing
else

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
SQL=rs.GetRows(MaxPerPage)
rs.close:set rs=Nothing
For i=0 To Ubound(SQL,2)
%>
<tr>
<td Class=tdbg align=center valign=middle>
<%
select case smstype
case "inbox"
	if SQL(5,i)=0 then
		newstyle="font-weight:bold"
		response.write "<img src=""../images/Message/news.gif"">"
	else
		response.write "<img src=""../images/Message/olds.gif"">"
		newstyle="font-weight:normal"
	end if
case "outbox"
	if SQL(5,i)=0 then
		newstyle="font-weight:bold"
	else
		newstyle="font-weight:normal"
	end if
	response.write "<img src=""../images/Message/issend_2.gif"">"
case "issend"
	if SQL(5,i)=0 then
		newstyle="font-weight:bold"
	else
		newstyle="font-weight:normal"
	end if
	response.write "<img src=""../images/Message/issend_1.gif"">"
case "recycle"
	if SQL(5,i)=0 then
		newstyle="font-weight:bold"
		response.write "<img src=""../images/Message/news.gif"">"
	else
		response.write "<img src=""../images/Message/olds.gif"">"
		newstyle="font-weight:normal"
	end if
end select
%>
</td>
<td Class=tdbg align=center valign=middle style="<%=newstyle%>">
<%if smstype="inbox" or smstype="recycle" then%>
<%=Cl.HTMLEncode(SQL(1,i))%>
<%else%>
<%=Cl.HTMLEncode(SQL(2,i))%>
<%end if

'id,sender,incept=2,title,content,flag=5,sendtime,delR=7,delS,isSend=9
%>
</td>
<td Class=tdbg align=left style="<%=newstyle%>"><a href="User_Message.asp?action=<%=readaction%>&id=<%=SQL(0,i)%>&sender=<%=SQL(1,i)%>"><%=Cl.HTMLEncode(SQL(3,i))%></a>	</td>
<td Class=tdbg style="<%=newstyle%>"><%=SQL(6,i)%></td>
<td Class=tdbg style="<%=newstyle%>"><%=len(SQL(4,i))%>Byte</td>
<td align=center valign=middle width=30 Class=tdbg><input type=checkbox name=id value=<%=SQL(0,i)%>></td>
</tr>
<%
	Next
end if
%>
<tr> 
<td align=right valign=middle colspan=6 Class=tdbg>节省每一分空间，请及时删除无用信息&nbsp;<input type=checkbox name=chkall value=on onclick="CheckAll(this.form)">选中所有显示记录&nbsp;<input type=submit name=action onclick="{if(confirm('确定删除选定的纪录吗?')){this.document.inbox.submit();return true;}return false;}" value="删除<%=replace(boxname,"箱","")%>">&nbsp;<input type=submit name=action onclick="{if(confirm('确定清除<%=boxname%>所有的纪录吗?')){this.document.inbox.submit();return true;}return false;}" value="清空<%=boxname%>"></td>
</tr>
</form>
<tr> 
<td align=right valign=middle colspan=6 Class=tdbg><%=Cl.ShowPage("User_Message.asp?action="&action,TotalPut,MaxPerPage,"条","信息")%></td>
</tr>
</table>
<script language="JavaScript" type="text/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 DoTitleJs()
%>
<script language="JavaScript" type="text/javascript"> 
function DoTitle(addTitle) {  
 var revisedTitle;  
 var currenttitle = document.messager.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.messager.touser.value=revisedTitle;  
 document.messager.touser.focus(); 
 return; 
} 
</script>
<%
End Sub

'===================================================
' 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.
'===================================================
%>