📄 mymessage.asp
字号:
<!-- #include file="Setup.asp" --><%
RecipientUserName=HTMLEncode(Request("RecipientUserName"))
UserName=HTMLEncode(Request("UserName"))
Subject=HTMLEncode(Request("Subject"))
Body=HTMLEncode(Request("Body"))
box=HTMLEncode(Request("box"))
MessageID=RequestInt("MessageID")
ForumID=RequestInt("ForumID")
MaxPrivateMessageSize=SiteConfig("MaxPrivateMessageSize")
if Request("menu")="Post" then
if CookieUserName=empty then Alert("您还未登录")
if MessageID > 0 then
Rs.open "select * from [Wo_PrivateMessages] where MessageID="&MessageID&"",conn,1
if not rs.eof then
Subject=Rs("Subject")
Body=replace(Rs("Body"),"<br>",vbcrlf)
end if
if RecipientUserName<>empty then '回复
Subject="RE: "&Subject
Body=""
else '转发
Body=vbcrlf&vbcrlf&vbcrlf&vbcrlf&"------------------------------------"&vbcrlf&"日期: "&Rs("CreateTime")&vbcrlf&"发件人: "&Rs("SenderUserName")&vbcrlf&"收件人: "&Rs("RecipientUserName")&vbcrlf&"主题: "&Subject&vbcrlf&vbcrlf&Body&""
Subject="FW: "&Subject
end if
Rs.close
end if
Response.clear
%>
<title>发送讯息</title>
<body style="FONT-SIZE:9pt;">
<form name="form" action="MyMessage.asp" method="POST" onsubmit="return CheckMessage()">
<input type="hidden" name="menu" value="addPost">
发件人:<input type="text" name="SendUserName" value="<%=CookieUserName%>" readonly><br>
收件人:<input id="RecipientUserName" name="RecipientUserName" type="text" value="<%=RecipientUserName%>">
<select onchange="Javascript:document.getElementById('RecipientUserName').value=this.value">
<%
Response.Write("<option value=''>好友列表</option>")
set rs=Conn.Execute("select FriendUserName from WO_FavoriteUsers where OwnerUserName='"&CookieUserName&"'")
if not rs.eof then
do while not Rs.eof
Response.Write("<option value="&Rs("FriendUserName")&">"&Rs("FriendUserName")&"</option>")
Rs.movenext
loop
end if
rs.close
Response.write("</select>")
%>
<%
if ForumID > 0 then
%> <select onchange="Javascript:document.getElementById('RecipientUserName').value=this.value">
<%
ModeratedList=Conn.Execute("select Moderated from [Wo_Forums] where ForumID="&ForumID&"")(0)
if ModeratedList<>"" then
Response.Write("<option value=''>组长列表</option>")
Moderated=split(ModeratedList,"|")
for i=0 to Ubound(Moderated)
Response.Write("<option value="&Moderated(i)&">"&Moderated(i)&"</option>")
next
else
Response.Write("<option value=''>管理员列表</option>")
ModeratedList=(0)
Set Rs=Conn.Execute("select UserName from [Wo_Users] where (UserRoleID=1 or UserRoleID=2) and UserAccountStatus=1")
do while not Rs.eof
Response.Write("<option value="&Rs("UserName")&">"&Rs("UserName")&"</option>")
Rs.movenext
loop
end if
Response.write("</select>")
end if
%><br>
主 题:<input size="60" name="Subject" value="<%=Subject%>" /><br>
<textarea name="Body" style="width:100%;height:200px"><%=Body%></textarea><br>
<input type="checkbox" name="IsSaveOutbox" id="IsSaveOutbox" value="1"><label for=IsSaveOutbox>保存到已发送</label>
<div style="float:right"><input type="submit" value="发送讯息"> </div>
</form>
</body>
<script language="JavaScript">
function CheckMessage(){
var FormObject = document.form;
if (FormObject.elements["RecipientUserName"].value == "")
{
alert("请输入收件人名字!");
FormObject.elements["RecipientUserName"].focus()
return false;
}
if ( FormObject.elements["Subject"].value.length < 2)
{
alert("请输入主题不能少于2个字节!");
FormObject.elements["Subject"].focus()
return false;
}
if (FormObject.elements["Body"].value.length < 2)
{
alert("请输入内容不能少于2个字节!");
FormObject.elements["Body"].focus()
return false;
}
if (FormObject.elements["RecipientUserName"].value == FormObject.elements["SendUserName"].value)
{
alert("不能自己给自己发送讯息!");
FormObject.elements["RecipientUserName"].focus()
return false;
}
return true;
}
</script>
<%
elseif Request("menu")="addPost" then
if CookieUserName=empty then Alert("您还未登录")
IsSaveOutbox=RequestInt("IsSaveOutbox")
IsSenderDelete=0
if IsSaveOutbox=0 then IsSenderDelete=1
if Len(Subject)<2 then Alert("标题不能小于 2 字符")
if Len(Body)<2 then Alert("内容不能小于 2 字符")
if RecipientUserName="" or Lcase(RecipientUserName)=Lcase(CookieUserName) then Alert("请输入接收的对象且不能是自己")
if Conn.Execute("Select UserID From [Wo_Users] where UserName='"&RecipientUserName&"'").eof Then Alert("系统不存在"&RecipientUserName&"的资料")
if IsSaveOutbox=1 and Conn.Execute("Select count(MessageID) From [Wo_PrivateMessages] where RecipientUserName='"&CookieUserName&"' and IsRecipientDelete=0 or SenderUserName='"&CookieUserName&"' and IsSenderDelete=0")(0)>MaxPrivateMessageSize Then Alert("您的短信箱已满不能保存短讯!本次发送失败!")
if Conn.Execute("Select count(MessageID) From [Wo_PrivateMessages] where RecipientUserName='"&RecipientUserName&"' and IsRecipientDelete=0 or SenderUserName='"&RecipientUserName&"' and IsSenderDelete=0")(0)>MaxPrivateMessageSize Then Alert("窝友"&RecipientUserName&"的短信箱已满!本次发送失败!")
sql="insert into [Wo_PrivateMessages](SenderUserName,RecipientUserName,Subject,Body,IsSenderDelete) values ('"&CookieUserName&"','"&RecipientUserName&"','"&Subject&"','"&Body&"',"&IsSenderDelete&")"
Conn.Execute(sql)
Conn.execute("update [Wo_Users] set NewMessage=NewMessage+1 where UserName='"&RecipientUserName&"'")
%>
<script language="JavaScript">parent.Wo_Modal.Close();</script>
<%
else
if CookieUserName=empty then error("您还未<a href=Login.asp?ReturnUrl="&ReturnUrl&">登录</a>")
HtmlTop
RecipientCount=conn.execute("select count(messageID) from [Wo_PrivateMessages] where RecipientUserName='"&CookieUserName&"' and IsRecipientDelete=0 or SenderUserName='"&CookieUserName&"' and IsSenderDelete=0")(0)
UsedMessageSize=RecipientCount/MaxPrivateMessageSize*100
%>
<table width="900" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td><div id="CommonBreadCrumbArea"><%ClubTree%> → 短信服务</div></td>
</tr>
</table>
<table cellspacing="1" cellpadding="0" width="900" id="CommonListArea" align="center">
<tr id="CommonListTitle3">
<td align="center"><a href="EditProfile.asp">资料修改</a></td>
<td align="center"><a href="EditProfile.asp?menu=pass">密码修改</a></td>
<td align="center"><a href="MyUpFiles.asp">上传管理</a></td>
<td align="center"><a href="MyFavorites.asp">收 藏 夹</a></td>
<td align="center"><a href="MyMessage.asp">短信服务</a></td>
</tr>
</table>
<br>
<table border="0" width="900" id="table14" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="150" valign="top">
<table border="0" width="100%" cellspacing="1" cellpadding="0" border="0" id="CommonListArea">
<tr id="CommonListTitle3">
<td><b>文件夹</b></td>
</tr>
<tr id="CommonListCell">
<td height="30"> <img src="images/i_inbox.gif" align="absmiddle">
<a href="?menu=Inbox">收件箱</a>[<b><%=conn.execute("select count(messageID) from [Wo_PrivateMessages] where RecipientUserName='"&CookieUserName&"' and IsRecipientDelete=0")(0)%></b>]</td>
</tr>
<tr id="CommonListCell">
<td height="30"> <img src="images/i_sent.gif" align="absmiddle">
<a href="?menu=Outbox">已发送</a>[<b><%=conn.execute("select count(messageID) from [Wo_PrivateMessages] where SenderUserName='"&CookieUserName&"' and IsSenderDelete=0")(0)%></b>]</td>
</tr>
</table>
<br>
<table cellspacing="1" cellpadding="1" width="100%">
<tr>
<td>
<div class="percent">
<div style="width:<%=UsedMessageSize%>%">
</div>
</div>
<%=UsedMessageSize%>% (<%=RecipientCount%>/<%=MaxPrivateMessageSize%>)</td>
</tr>
</table>
</td>
<td width="1%"></td>
<td valign="top"><%
select case Request("menu")
case "Read"
ReadMessage
case "Delete"
for each ho in Request("MessageID")
ho=int(ho)
rs.open "select * from [Wo_PrivateMessages] where ( RecipientUserName='"&CookieUserName&"' or SenderUserName='"&CookieUserName&"' ) and MessageID="&ho&"",Conn,1,3
if LCASE(rs("RecipientUserName"))=LCASE(CookieUserName) then rs("IsRecipientDelete")=1
if LCASE(rs("SenderUserName"))=LCASE(CookieUserName) then rs("IsSenderDelete")=1
rs.update
rs.close
next
Conn.execute("Delete from [Wo_PrivateMessages] where IsRecipientDelete=1 and IsSenderDelete=1")
response.redirect("?")
case else
InOutbox
end select
%> </td>
</tr>
</table>
<br>
<%
Sub InOutbox
MessageMenu=Request("Menu")
if MessageMenu=empty then MessageMenu="Inbox"
if MessageMenu="Inbox" then
tdstr="<td align=center width='15%'>发件人</td>"
sql="select * from [Wo_PrivateMessages] where RecipientUserName='"&CookieUserName&"' and IsRecipientDelete=0 order by MessageID Desc"
else
tdstr="<td align=center width='15%'>收件人</td>"
sql="select * from [Wo_PrivateMessages] where SenderUserName='"&CookieUserName&"' and IsSenderDelete=0 order by MessageID Desc"
end if
%>
<form name="showMessage" action="?Menu=Delete" method="post">
<table cellspacing="1" cellpadding="0" width="100%" id="CommonListArea">
<tr id="CommonListTitle3">
<td colspan="5">
<a href="javascript:Wo_Modal.Open('MyMessage.asp?Menu=Post',600,350);">
<img src="images/i_new_msg.gif" border="0" align="absmiddle">新建</a> <a onclick="if(window.confirm('您确定执行本次操作?')){document.showMessage.submit();}"><img src="images/i_delete.gif" border="0" align="absmiddle">删除</a></td>
</tr>
<tr id="CommonListHeader">
<td align="center" width="6%">
<input type="checkbox" name="chkall" onclick="CheckAll(this.form)" value="ON"></td>
<%=tdstr%>
<td align="center" width="46%">主题</td>
<td align="center" width="22%">日期</td>
<td align="center" width="10%">大小</td>
</tr>
<%
Rs.Open sql,Conn,1
PageSetup=20 '设定每页的显示数量
Rs.Pagesize=PageSetup
TotalPage=Rs.Pagecount '总页数
PageCount = RequestInt("PageIndex")
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
%>
<tr id="CommonListCell" <%if rs("isread")=0 then response.write" style='font-weight:bold'"%>>
<td valign="center" align="center" width="5%">
<input type="checkbox" value="<%=Rs("MessageID")%>" name="MessageID"></td>
<%if MessageMenu="Inbox" then%>
<td align="center">
<a href="Profile.asp?UserName=<%=Rs("SenderUserName")%>" target="wh">
<%=Rs("SenderUserName")%></a></td>
<%else%>
<td align="center">
<a href="Profile.asp?UserName=<%=Rs("RecipientUserName")%>" target="wh">
<%=Rs("RecipientUserName")%></a></td>
<%end if%>
<td width="10%">
<a href="?Menu=Read&MessageID=<%=Rs("MessageID")%>&box=<%=MessageMenu%>">
<%=Rs("Subject")%></a></td>
<td align="center" width="15%"><%=Rs("CreateTime")%></td>
<td align="center" width="10%"><%=CheckSize(Len(""&Rs("Body")&""))%></td>
</tr>
<%
Rs.MoveNext
loop
Rs.Close
if NewMessage>0 then Conn.execute("update [Wo_Users] set NewMessage=0 where UserID="&CookieUserID&"")
%>
</table>
<table cellspacing="1" cellpadding="1" width="100%">
<tr>
<td colspan="5"><%ShowPage()%></td>
</tr>
</table>
</form>
<%
End Sub
Sub ReadMessage
if box="Inbox" then
FieldName="RecipientUserName"
DeleteFieldName="IsRecipientDelete"
else
FieldName="SenderUserName"
DeleteFieldName="IsSenderDelete"
end if
if Request("pageIndex")="previous" then
SQL="select top 1 * from [Wo_PrivateMessages] where "&FieldName&"='"&CookieUserName&"' and "&DeleteFieldName&"=0 and MessageID>"&MessageID&" order by messageID"
elseif Request("pageIndex")="next" then
SQL="select top 1 * from [Wo_PrivateMessages] where "&FieldName&"='"&CookieUserName&"' and "&DeleteFieldName&"=0 and MessageID<"&MessageID&" order by messageID desc"
else
SQL="select * from [Wo_PrivateMessages] where (RecipientUserName='"&CookieUserName&"' or SenderUserName='"&CookieUserName&"') and MessageID="&MessageID&""
end if
Rs.Open SQL,Conn,1,3
if ReturnUrl="" then ReturnUrl="Default.asp"
if Rs.eof then response.redirect ReturnUrl
%>
<table cellspacing="1" cellpadding="5" width="100%" id="CommonListArea">
<tr id="CommonListTitle3">
<td colspan="5">
<div style="float:left">
<a href="javascript:Wo_Modal.Open('MyMessage.asp?menu=Post', 600, 350);">
<img src="images/i_new_msg.gif" border="0" align="absmiddle">新建</a> <a href="?menu=Delete&MessageID=<%=Rs("MessageID")%>" onclick="return window.confirm('您确定执行本次操作?');"><img src="images/i_delete.gif" border="0" align="absmiddle">删除</a><%if Rs("SenderUserName")<>CookieUserName then%> <img src="images/i_reply.gif" border="0" align="absmiddle"><a href="javascript:Wo_Modal.Open('MyMessage.asp?menu=Post&MessageID=<%=Rs("MessageID")%>&RecipientUserName=<%=Rs("SenderUserName")%>',600,350);">回复</a><%end if%> <a href="javascript:Wo_Modal.Open('MyMessage.asp?menu=Post&MessageID=<%=Rs("MessageID")%>',600,350);"><img src="images/i_forward.gif" border="0" align="absmiddle">转发</a></div>
<div style="float:right">
<a href="?menu=Read&MessageID=<%=Rs("messageID")%>&pageIndex=previous&box=<%=box%>" title="上一条">
<img src="images/i_previous.gif" border="0" align="absmiddle"></a>
<a href="?menu=Read&MessageID=<%=Rs("messageID")%>&pageIndex=next&box=<%=box%>" title="下一条">
<img src="images/i_next.gif" border="0" align="absmiddle"></a></div>
</td>
</tr>
<tr id="CommonListCell">
<td width="10%" style="line-height:150%">
<div style="float:left">
发件人:<a target="wh" href="Profile.asp?UserName=<%=Rs("SenderUserName")%>"><%=Rs("SenderUserName")%></a><%if Rs("SenderUserName")<>CookieUserName then%> <a href="MyFavorites.asp?Menu=FavoriteFriend&FriendUserName=<%=Rs("SenderUserName")%>">+添加好友</a><%end if%></div>
<div style="float:right">
<%=Rs("CreateTime")%></div>
<br>
收件人:<a target="wh" href="Profile.asp?UserName=<%=Rs("RecipientUserName")%>"><%=Rs("RecipientUserName")%></a><%if Rs("RecipientUserName")<>CookieUserName then%> <a href="MyFavorites.asp?Menu=FavoriteFriend&FriendUserName=<%=Rs("RecipientUserName")%>">+添加好友</a><%end if%>
<br>
主 题:<%=Rs("Subject")%></td>
</tr>
<tr id="CommonListCell">
<td><%=Rs("Body")%></td>
</tr>
</table>
<%
if LCASE(Rs("RecipientUserName"))=LCASE(CookieUserName) and Rs("IsRead")=0 then Rs("IsRead")=1
Rs.update
Rs.close
End Sub
HtmlBottom
end if
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -