<!-- #include file="Setup.asp" -->
<!--#include file="Pet/PetSetup.asp"-->
<!--#include file="Pet/Inc/Class_PetSkill.asp"-->
<%
top
if CookieUserName=empty then error("<li>您还未<a href=Login.asp>登录</a>论坛")
If not Conn.Execute("Select UserName From [BBSXP_Prison] where UserName='"&CookieUserName&"'" ).eof Then error("<li>您被关进<a href=Prison.asp>监狱</a>")
ForumID=int(Request("ForumID"))
VoteExpiry=int(Request.Form("VoteExpiry"))

sql="select * from [BBSXP_Forums] where id="&ForumID&""
Set Rs=Conn.Execute(sql)
if Rs.Eof then error("<li>系统不存在此论坛的资料")
ForumName=Rs("ForumName")
ForumLogo=Rs("ForumLogo")
Moderated=Rs("Moderated")
FollowID=Rs("FollowID")
TolSpecialTopic=Rs("TolSpecialTopic")
IsModerated=Rs("IsModerated")
NPostM=Rs("NPostM")''''分版加金币
NPostE=Rs("NPostE")''''分版加经验

Rs.close

if SiteSettings("sortshowforum")=0 then
If Not Conn.Execute("Select ID From [BBSXP_Forums] where FollowID="&ForumID&"" ).eof Then error("<li>类别无法发表帖子")
end if

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

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
if Request.ServerVariables("request_method") = "POST" then
if Request.Form=Application("LastPost") then error("<li>请不要提交重复数据")
if SiteSettings("EnableAntiSpamTextGenerateForPost")=1 then
if Request.Form("VerifyCode")<>Session("VerifyCode") then Message=Message&"<li>验证码错误"
end if

color=HTMLEncode(Request.Form("color"))
icon=Request.Form("icon")
Subject=HTMLEncode(Request.Form("Subject"))
Category=HTMLEncode(Request.Form("Category"))
Content=ContentEncode(Request.Form("Content"))
if Request.Form("DisableYBBCode")<>1 then Content=YbbEncode(Content)

if Len(Subject)<2 then Message=Message&"<li>文章主题不能小于 2 字符"
if Len(content)<2 then Message=Message&"<li>文章内容不能小于 2 字符"

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 Request.Form("Vote")<>"" then
Vote=Request("Vote")
if instr(Vote,"|") > 0 then error("<li>投票选项中不能含有“|”字符")
pollTopic=split(Vote,chr(13)&chr(10))
j=0
for i = 0 to ubound(pollTopic)
if not (pollTopic(i)="" or pollTopic(i)=" ") then
allpollTopic=""&allpollTopic&""&pollTopic(i)&"|"
j=j+1
end if
next

if j<SiteSettings("MinVoteOptions") or j>SiteSettings("MaxVoteOptions") then error("<li>投票选项不能少于 "&SiteSettings("MinVoteOptions")&" 个<li>投票选项超过 "&SiteSettings("MaxVoteOptions")&" 个")


for y = 1 to j
Votenum=""&Votenum&"0|"
next

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

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



sql="select * from [BBSXP_Users] where ID="&CookieUserID&""
Rs.Open sql,Conn,1,3

if SiteSettings("DuplicatePostIntervalInMinutes") > 0 then
StopPostTime=int(DateDiff("s",Rs("UserLandTime"),Now()))
if StopPostTime < int(SiteSettings("DuplicatePostIntervalInMinutes")) then Message=Message&"<li>论坛限制一个人两次发帖间隔必须大于 "&SiteSettings("DuplicatePostIntervalInMinutes")&" 秒！<li>您必须再等待 "&SiteSettings("DuplicatePostIntervalInMinutes")-StopPostTime&" 秒！"
end if

if SiteSettings("RegUserTimePost") > 0 then
StopPostTime=int(DateDiff("s",Rs("UserRegTime"),Now()))
if StopPostTime < int(SiteSettings("RegUserTimePost")) then Message=Message&"<li>新注册用户必须等待 "&SiteSettings("RegUserTimePost")&" 秒后才能发帖！<li>您必须再等待 "&SiteSettings("RegUserTimePost")-StopPostTime&" 秒！"
end if
<!--------分版加金币和经验修改--------->
if Message<>"" then error(""&Message&"")

Rs("PostTopic")=Rs("PostTopic")+1
Rs("UserMoney")=Rs("UserMoney")+NPostM
Rs("experience")=Rs("experience")+NPostE
Rs("UserLandTime")=now()
Rs("UserLastIP")=Request.ServerVariables("REMOTE_ADDR")
Rs.update
Rs.close
<!--------分版加金币和经验修改--------->


Rs.Open "select * from [BBSXP_Threads]",Conn,1,3
Rs.addNew
Rs("UserName")=CookieUserName
Rs("PostTime")=now()
Rs("lastname")=CookieUserName
Rs("lasttime")=now()
Rs("Topic")=Subject
Rs("ForumID")=ForumID
Rs("SpecialTopic")=Category
if Request("icon")<>"" then Rs("icon")=icon
if Request("Vote")<>"" then Rs("isVote")=1
if Request("IsLocked")=1 then Rs("IsLocked")=1
if IsModerated=1 then Rs("IsDel")=1
Rs.update
ID=Rs("ID")
PostsTableName=Rs("PostsTableName")
Rs.close

if Request.Form("Vote")<>"" then
Conn.Execute("insert into [BBSXP_Vote] (ThreadID,Type,Items,Result,Expiry) values ('"&ID&"','"&int(Request.Form("multiplicity"))&"','"&HTMLEncode(allpollTopic)&"','"&Votenum&"','"&now()+VoteExpiry&"')")
end if

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

Conn.Execute("insert into [BBSXP_Posts"&PostsTableName&"] (ThreadID,IsTopic,UserName,Subject,content,Postip) values ('"&ID&"','1','"&CookieUserName&"','"&Subject&"','"&content&"','"&Request.ServerVariables("REMOTE_ADDR")&"')")




Conn.execute("update [BBSXP_Forums] set lastTopic='<a href=ShowPost.asp?ThreadID="&id&">"&Left(HTMLEncode(Request.Form("Subject")),11)&"</a>',lastname='"&CookieUserName&"',lasttime="&SqlNowString&",ForumToday=ForumToday+1,ForumThreads=ForumThreads+1,ForumPosts=ForumPosts+1 where id="&ForumID&" or ID="&FollowID&"")
Conn.execute("update [BBSXP_SiteSettings] set DaysPosts=DaysPosts+1,DaysTopics=DaysTopics+1,TotalPosts=TotalPosts+1,TotalTopics=TotalTopics+1")

if Request.Form("IsAddBlog")=1 then Conn.Execute("insert into [BBSXP_Blogs] (Subject,Content,UserName,Category,BlogDate) values ('"&Subject&"','"&content&"','"&CookieUserName&"','"&Category&"','"&year(now)&"-"&month(now)&"')")

Session("VerifyCode")=""
<!--------宠物新贴回帖得金币以及相关技能-------->
Set LaunchPetSkill=New PetSkillsClass
LaunchPetSkill.SkillInNewTopic
Set LaunchPetSkill=Nothing
<!--------宠物新贴回帖得金币以及相关技能-------->
Application("LastPost")=Request.Form


if IsModerated=1 then
EnableCensorship="由于论坛设有审查制度，您发表的帖子需要等待激活才能显示。"
else
EnableCensorship="<a href=ShowPost.asp?ThreadID="&id&">返回主题</a>"
end if

Message="<li>新主题发表成功<li>"&EnableCensorship&"<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 align=center class=a2 width=100% >
		<tr class=a3>
			<td>&nbsp;<img src=images/Forum_nav.gif>&nbsp; <%ClubTree%> → <%ForumTree(FollowID)%><%=ForumTreeList%> <a href=ShowForum.asp?ForumID=<%=ForumID%>><%=ForumName%></a> → 发表帖子</td>
		</tr>
	</table><br>


<table cellspacing=1 cellpadding=5 border=0 align=center class=a2  width=100%>
<form name="form" method="post" onSubmit="return CheckForm(this);">
<input name="content" type="hidden">
<input name="UpFileID" type="hidden">
<input type=hidden name=ForumID value=<%=ForumID%>>
<TR>
<TD 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>


<%if SiteSettings("EnableAntiSpamTextGenerateForPost")=1 then%>
	<tr>
<TD class=a3><b>验证码</b></TD>
<TD class=a3 height=6>
<input name="VerifyCode" size="10"> <img src="VerifyCode.asp" title="验证码,看不清楚?请点击刷新验证码" style=cursor:pointer onclick="this.src='VerifyCode.asp'"></TD>
	</tr>
<%end if%>
	
<TR>
<TD class=a3 width="180"><B>文章标题 </B> （<a onclick="ChangeCategory('#');return false;" href="#">添加类别</a>）

</TD>
<TD class=a3>

<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
%>
</SELECT>
<INPUT maxLength=50 size=60 name=Subject>
</TD></TR>
<TR>
<TD vAlign=top align=Left class=a4><B>您的表情</B></TD>
<TD class=a4>
<script>
for(i=1;i<=12;i++) {
document.write("<INPUT type=radio value="+i+" name=icon><IMG src=images/brow/"+i+".gif>　")
}
</script>

 </TD></TR>

<%if PermissionsCreatePoll=1 and Request("Poll")=1 then%>
<TR class=a3>
<TD vAlign=top align=Left>
<FONT color=000000><B>投票项目</B><BR>
每行一个投票项目<BR>


<INPUT type=radio CHECKED value=0 name=multiplicity id=multiplicity>
<label for=multiplicity>单选投票</label>
<BR><INPUT type=radio value=1 name=multiplicity id=multiplicity_1> <label for=multiplicity_1>多选投票</label></FONT> 

<br>
过期时间 <select name="VoteExpiry" size="1">
<option value="1">一天后</option>
<option value="2">两天后</option>
<option value="3">三天后</option>
<option value="7" selected>一星期后</option>
<option value="14">两星期后</option>
<option value="30">一个月后</option>
<option value="60">两个月后</option>
<option value="90">三个月后</option>
<option value="180">六个月后</option>
</select>
</TD>
<TD>
<TEXTAREA name=Vote rows=5 style="width:100%"></TEXTAREA>
</TD></TR>
<%end if%>



<TR>
<TD vAlign=top class=a3>

<br><B>文章内容</B><BR>
（<a href="javascript:CheckLength();">查看内容长度</a>）<BR><BR>

<INPUT id=IsAddBlog name=IsAddBlog type=checkbox value=1><label for=IsAddBlog> 同时添加到我的共享空间</label><br>
<INPUT id=LockMyPost name=IsLocked type=checkbox value=1><label for=LockMyPost> 主题锁定，不允许回复</label><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=showdz3 name=showdz3 type=checkbox value=1 onClick="showdz(3)"><label for=showdz3> 特殊贴子选项</label><br>


<BR><span id=UpFile></span>
<TD class=a3 height=250>

<SCRIPT src="inc/Post.js"></SCRIPT>
<script src="inc/mt.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
%>