<!-- #include file="Setup.asp" --><%
top
if CookieUserName=empty then error("<li>您还未<a href=Login.asp>登录</a>论坛")


ThreadID=int(Request("ThreadID"))
PostID=int(Request("PostID"))

sql="Select * From [BBSXP_Threads] where ID="&ThreadID&""
Rs.Open sql,Conn,1
if Rs.eof or Rs.bof then error"<li>系统不存在该帖子的资料"
ForumID=Rs("ForumID")
PostsTableName=Rs("PostsTableName")
Rs.close

Moderated=Conn.Execute("Select Moderated From [BBSXP_Forums] where id="&ForumID&" ")(0)

%><!-- #include file="inc/ForumPermissions.asp" --><%
if PermissionsDelete=0 then error("<li>您的<a href=ShowForumPermissions.asp?ForumID="&ForumID&">权限</a>不够")


if Conn.Execute("Select IsDel From [BBSXP_Threads] where id="&ThreadID&" ")(0)=1 then error("<li>此帖子已经在回收站了")


if Request.ServerVariables("request_method") <> "POST" then
%>
<div class="mainnav">
<form method="Post" action="?<%=Request.ServerVariables("Query_String")%>">
	<table cellspacing="1" cellpadding="5" border="0" width="100%" class="a2">
		<tr class="a1">
			<td colspan="2" align="center">删除帖子</td>
		</tr>
		<tr class="a3">
			<td width="200">删除人：</td>
			<td><%=CookieUserName%></td>
		</tr>
		<tr class="a3">
			<td>发送短讯通知发帖人：</td>
			<td><input type="radio" value="1" name="IsSendMessage">是 
			<input type="radio" value="0" name="IsSendMessage" checked>否</td>
			</td>
		</tr>
		<tr class="a3">
			<td>原因：</td>
			<td><textarea name="content" rows="4" cols="75"></textarea></td>
		</tr>
		<tr class="a3">
			<td colspan="2" align="center"><input type="submit" value=" 确定 ">　　　<input onclick="history.back()" type="button" value=" 取消 "></td>
		</tr>
	</table></div>
</form>
<%
htmlend
end if





sql="select * from [BBSXP_Posts"&PostsTableName&"] where id="&PostID&""
Rs.Open sql,Conn,1,3
if Rs.eof or Rs.bof then error"<li>系统不存在该帖子的资料"
if Rs("UserName")<>CookieUserName and PermissionsManage=0 then error("<li>您的<a href=ShowForumPermissions.asp?ForumID="&ForumID&">权限</a>不够！")
Subject=Rs("Subject")
PostAuthor=Rs("UserName")
PostTime=Rs("PostTime")
if Rs("IsTopic")=1 then
Conn.execute("update [BBSXP_Users] set DelTopic=DelTopic+1,UserMoney=UserMoney+"&SiteSettings("IntegralDeleteThread")&",experience=experience+"&SiteSettings("IntegralDeleteThread")&" where UserName='"&Rs("UserName")&"'")
Conn.execute("update [BBSXP_Threads] set IsTop=0,IsDel=1,lastname='"&CookieUserName&"',lasttime="&SqlNowString&" where id="&RS("ThreadID")&"")
Conn.execute("update [BBSXP_Forums] set ForumThreads=ForumThreads-1,ForumPosts=ForumPosts-1 where id="&ForumID&"")
succtitle="删除主题成功"
else
Conn.execute("update [BBSXP_Users] set DelTopic=DelTopic+1,UserMoney=UserMoney+"&SiteSettings("IntegralDeletePost")&",experience=experience+"&SiteSettings("IntegralDeletePost")&" where UserName='"&Rs("UserName")&"'")
Conn.execute("update [BBSXP_Threads] set replies=replies-1 where id="&RS("ThreadID")&"")
Conn.execute("update [BBSXP_Forums] set ForumPosts=ForumPosts-1 where id="&ForumID&"")
Rs.Delete
succtitle="删除回帖成功"
end if
Rs.update
Rs.close


content=HTMLEncode(Request("content"))
if content<>"" then content="<br>删除原因："&content&""


if Request("IsSendMessage")=1 then
sql="insert into [BBSXP_Messages](UserName,incept,content) values ('"&CookieUserName&"','"&PostAuthor&"','<font color=0000FF>【系统通知】：您于 "&PostTime&" 发表的帖子《"&Subject&"》已经被 "&CookieUserName&" 删除了！</font>"&content&"')"
Conn.Execute(SQL)
Conn.execute("update [BBSXP_Users] set NewMessage=NewMessage+1 where UserName='"&PostAuthor&"'")
end if


if succtitle="" then error("<li>无效命令")
Log(""&succtitle&"，帖子标题："&Subject&"，主题ID："&ThreadID&"，帖子ID："&PostID&"")
Message="<li>"&succtitle&"<li><a href=ShowForum.asp?ForumID="&ForumID&">返回论坛</a><li><a href=Default.asp>返回社区首页</a>"
succeed(""&Message&"<meta http-equiv=refresh content=3;url=ShowForum.asp?ForumID="&ForumID&">")

%>