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

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")
Topic=Rs("Topic")
SpecialTopic=Rs("SpecialTopic")
Rs.close

sql="select * from [BBSXP_Forums] where id="&ForumID&""
Set Rs=Conn.Execute(sql)
ForumName=Rs("ForumName")
ForumLogo=Rs("ForumLogo")
Moderated=Rs("Moderated")
followid=Rs("followid")
TolSpecialTopic=Rs("TolSpecialTopic")
Rs.close
%>
<!-- #include file="inc/ForumPermissions.asp" -->
<%if PermissionsEdit=0 then error("<li>您的<a href=ShowForumPermissions.asp?ForumID="&ForumID&">权限</a>不够")


sql="select * from [BBSXP_Posts"&PostsTableName&"] where id="&PostID&""
Set Rs=Conn.Execute(sql)
if Rs.eof or Rs.bof then error"<li>系统不存在该帖子的资料"
if Rs("UserName")<>CookieUserName and PermissionsManage=0 then error("<li>对不起，您的权限不够！")
Subject=ReplaceText(""&Rs("Subject")&"","<[^>]*>","")
content=Rs("content")
Rs.close


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

if Request.ServerVariables("request_method") = "POST" then
color=HTMLEncode(Request.Form("color"))
Subject=HTMLEncode(Request.Form("Subject"))
Content=ContentEncode(Request.Form("Content"))
if Request.Form("DisableYBBCode")<>1 then Content=YbbEncode(Content)


if SiteSettings("BannedText")<>empty then
filtrate=split(SiteSettings("BannedText"),"|")
for i = 0 to ubound(filtrate)
Subject=ReplaceText(Subject,""&filtrate(i)&"",string(len(filtrate(i)),"*"))
next
end if


if content=empty then Message=Message&"<li>内容没有填写"
if SiteSettings("DisplayEditNotes")=1 then content=""&content&"<p>［此帖子已被 "&CookieUserName&" 在 "&now()&" 编辑过］"

if Message<>"" then error(""&Message&"")

sql="select * from [BBSXP_Posts"&PostsTableName&"] where id="&PostID&""
Rs.Open sql,Conn,1,3
if Rs("IsTopic")=1 then Conn.execute("update [BBSXP_Threads] set Topic='"&Subject&"',SpecialTopic='"&Category&"' where ID="&Rs("ThreadID")&"")
Rs("Subject")=Subject
Rs("content")=content
Rs.update
Rs.close

if Request.Form("UpFileID")<>"" then
UpFileID=split(Request.form("UpFileID"),",")
for i = 0 to ubound(UpFileID)-1
Conn.execute("update [BBSXP_UpFiles] set Category='"&Category&"',Description='"&Subject&"' where id="&int(UpFileID(i))&" and UserName='"&CookieUserName&"'")
next
end if

Log("修改帖子成功，主题ID："&ThreadID&"，帖子ID："&PostID&"")

Message="<li>修改帖子成功<li><a href=ShowPost.asp?ThreadID="&ThreadID&">返回主题</a><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&">")

end if
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

%>
<script>
if ("<%=ForumLogo%>"!=''){Logo.innerHTML="<img border=0 src=<%=ForumLogo%> onload='javascript:if(this.height>60)this.height=60;'>"}

</script>

<div class="mainnav">
<table cellspacing=1 cellpadding=5 border=0 width=100% class=a2>
		<tr class=a3>
			<td>&nbsp;<img src=images/Forum_nav.gif>&nbsp; <%ClubTree%> → <%ForumTree(followid)%><%=ForumTreeList%> <a href=ShowForum.asp?ForumID=<%=ForumID%>><%=ForumName%></a> → <a href="ShowPost.asp?ThreadID=<%=ThreadID%>"><%=Topic%></a> → 编辑帖子</td>
		</tr>
	</table><br>


<table cellspacing=1 cellpadding=5 border=0 width=100% class=a2>
<form name="form" method="post" onSubmit="return CheckForm(this);">
<input name="content" type="hidden" value='<%=server.htmlencode(content)%>'>
<input name="UpFileID" type="hidden">
<TR>
<TD id=titlelarge vAlign=Left colSpan=2 class=a1><b>编辑帖子</b></TD></TR>

<script>
function showdz(sid)
{
whichEl = eval("dz" + sid);
if (whichEl.style.display == "none")
{
eval("dz" + sid + ".style.display=\"\";");
}
else
{
eval("dz" + sid + ".style.display=\"none\";");
}
}
</script>


<TR class=a4>
<TD width="180" ><B>文章标题</B> （<a onclick="ChangeCategory('#');return false;" href="#">添加类别</a>）
</TD>
<TD>

<SELECT name=Category size=1><OPTION value='' selected>类别</OPTION>
<%
if TolSpecialTopic<>empty then
filtrate=split(TolSpecialTopic,"|")
for i = 0 to ubound(filtrate)
response.write "<OPTION value='"&filtrate(i)&"'>["&filtrate(i)&"]</OPTION>"
next
end if
response.write "<OPTION value='"&SpecialTopic&"' selected>"&SpecialTopic&"</OPTION>"
%>
</SELECT>
<INPUT maxLength=50 size=60 name=Subject value="<%=Subject%>">
</TD></TR>

<TR>
<TD vAlign=top class=a3>
<TABLE cellSpacing=0 cellPadding=0 width=100% align=Left border=0 height="100%">

<TR>
<TD vAlign=top align=Left width=100% class=a3><br><B>文章内容</B><BR>
（<a href="javascript:CheckLength();">查看内容长度</a>）<BR><BR>


<INPUT id=DisableYBBCode name=DisableYBBCode type=checkbox value=1><label for=DisableYBBCode> 禁用YBB代码</label><br>
<INPUT id=showdz0 name=showdz0 type=checkbox value=1 onClick="showdz(0)"><label for=showdz0> 显示贴图选项</label><br>
<INPUT id=showdz31 name=showdz3 type=checkbox value=1 onClick="showdz(3)"><label for=showdz3> 特殊贴子选项</label>

<BR>
<BR><span id=UpFile></span>
</TD></TR>
</TABLE></TD>
<TD class=a3 height=250>
<SCRIPT src="inc/Post.js"></SCRIPT>
</TD></TR>

<TR id=dz0 style=DISPLAY:none>
<TD align=center width=160 class=a4>贴图图片系列<br>　</td>
<TD class=a4>
<script>

ii=0
for(i=1;i<=58;i++) {
index = Math.floor(Math.random() * 58+1);
ii=ii+1
document.write(" <a href=javascript:emoticon1('"+index+"')><img border=0 src=images/dongzuo/em"+index+".gif></a>")
if (ii==58){document.write("<br>");ii=0;}
}
</script>
</td></tr>

<TR id=dz3 style=DISPLAY:none>
<TD align=center width=160 class=a4>特殊贴子选项<br></td>
<TD class=a4>
&nbsp;<img src=images/ybb/001.gif alt=回复查看 type=checkbox value=1 onclick=replyview()>
&nbsp;<img src=images/ybb/002.gif alt=数量贴达到查看 type=checkbox value=1 onclick=YBBTopic()>
&nbsp;<img src=images/ybb/003.gif alt=经验查看 type=checkbox value=1 onclick=YBBExp()>
&nbsp;<img src=images/ybb/004.gif alt=公会查看 type=checkbox value=1 onclick=YBBCon()>
</td></tr>

<%if SiteSettings("UpFileOption")<>empty and PermissionsAttachment=1 then%>
<TR>
<TD align=Left class=a4>

<!-----附件分组设置------>
<%
if SiteSettings("Maxup2")=1 then
sql="select * from [BBSXP_Users] where ID="&Request.Cookies("UserID")&""
Set Rs3=Conn.Execute(SQL)
UserRoleID=Rs3("UserRoleID")
Maxup2=conn.execute("select Maxup2 from [BBSXP_Roles] where id="&UserRoleID&"")(0)
else
Maxup2=SiteSettings("MaxFileSize")
end if
%>
<IMG src=images/affix.gif alt="支持类型<%=SiteSettings("UpFileTypes")%>"><b>增加附件</b>（限

制:<b><%=CheckSize(int(Maxup2))%></b>）</TD>
<!-----附件分组设置------>

</TD>
<TD align=Left class=a4><IFRAME src="PostUpFile.asp" frameBorder=0 width="100%" scrolling=no height=21></IFRAME></TD></TR>
<%end if%>
<TR>
<TD align=center class=a3 colSpan=2>
<INPUT type=submit value=" 发表 " name=EditSubmit>　<input type="Button" value=" 预览 " onclick="Preview()">　<INPUT onclick="history.back()" type="button" value=" 取消 ">
</TD></TR></FORM>
</TABLE>
<form name=preview action=preview.asp method=post target=preview_page><input name="content" type="hidden"></form>
</div>




<%
htmlend
%>