<!-- #include file="Conn.asp" -->
<!-- #include file="inc/MD5.asp" -->
<%


SiteSettings=Conn.Execute("[BBSXP_SiteSettings]")
CookieUserName=HTMLEncode(unescape(Request.Cookies("UserName")))



if ""&SiteSettings("nowdate")&""<>""&date()&"" then
Conn.execute("update [BBSXP_SiteSettings] set Nowdate='"&date()&"'")
Conn.execute("update [BBSXP_Statistics_Site] set TodayPost=0")
Conn.execute("update [BBSXP_Forums] set ForumToday=0")
end if

dim toptrue,ForumsList,ForumTreeList,TotalPage,PageCount,RankName,RankIconUrl
ii=0
startime=timer()
Set rs = Server.CreateObject("ADODB.Recordset")
Server.ScriptTimeout=SiteSettings("Timeout")'设置脚本超时时间 单位:秒

function HTMLEncode(fString)
fString=Replace(fString,";","&#59;")
fString=Replace(fString,"<","&lt;")
fString=Replace(fString,">","&gt;")
fString=Replace(fString,"\","&#92;")
fString=Replace(fString,"--","&#45;&#45;")
fString=Replace(fString,CHR(9),"&#9;")
fString=Replace(fString,CHR(10),"<br>")
fString=Replace(fString,CHR(13),"")
fString=Replace(fString,CHR(22),"&#22;")
fString=Replace(fString,CHR(32),"&#32;")
fString=Replace(fString,CHR(34),"&#34;")'双引号
fString=Replace(fString,CHR(39),"&#39;")'单引号
fString=ReplaceText(fString,"&#([0-9]*)&#59;","&#$1;") '解决韩文字符问题
if IsSqlDataBase=0 then '过滤片假名(日文字符)[\u30A0-\u30FF] by yuzi首创
fString=escape(fString)
fString=ReplaceText(fString,"%u30([A-F][0-F])","&#x30$1;")
fString=unescape(fString)
end if
HTMLEncode=fString
end function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function ContentEncode(fString)
fString=Replace(fString,vbCrlf, "")
fString=Replace(fString,"\","&#92;")
fString=Replace(fString,"'","&#39;")
fString=Replace(fString,"<A href=","<A target=_blank href=") '点链接打开新窗口
if SiteSettings("BannedHtmlLabel")<>"" then fString=ReplaceText(fString,"<(\/|)("&SiteSettings("BannedHtmlLabel")&")", "&lt;$1$2")
if SiteSettings("BannedHtmlEvent")<>"" then fString=ReplaceText(fString,"<(.[^>]*)("&SiteSettings("BannedHtmlEvent")&")", "&lt;$1$2")
if SiteSettings("BannedText")<>"" then
filtrate=split(SiteSettings("BannedText"),"|")
for i = 0 to ubound(filtrate)
fString=ReplaceText(fString,""&filtrate(i)&"",string(len(filtrate(i)),"*"))
next
end if
contentEncode=fString
end function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function YbbEncode(str)
str=ReplaceText(str,"\[(\/|)(b|i|u|strike|center|marquee)\]","<$1$2>")
str=ReplaceText(str,"\[COLOR=([^[]*)\]","<FONT COLOR=$1>")
str=ReplaceText(str,"\[FONT=([^[]*)\]","<FONT face=$1>")
str=ReplaceText(str,"\[SIZE=([0-9]*)\]","<FONT size=$1>")
str=ReplaceText(str,"\[\/(SIZE|FONT|COLOR)\]","</FONT>")
str=ReplaceText(str,"\[QUOTE\]","<BLOCKQUOTE><strong>引用</strong>：<HR Size=1>")
str=ReplaceText(str,"\[\/QUOTE\]","<HR SIZE=1></BLOCKQUOTE>")
str=ReplaceText(str,"\[URL\]([^[]*)","<A TARGET=_blank HREF=$1>$1")
str=ReplaceText(str,"\[URL=([^[]*)\]","<A TARGET=_blank HREF=$1>")
str=ReplaceText(str,"\[\/URL\]","</A>")
str=ReplaceText(str,"\[EMAIL\](\S+\@[^[]*)(\[\/EMAIL\])","<a href=mailto:$1>$1</a>")
str=ReplaceText(str,"\[IMG\]([^[]*)(\[\/IMG\])","<img border=0 src=$1>")
YbbEncode=str
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function IsObjInstalled(strClassString)
On Error Resume Next
IsObjInstalled = False
Set xTestObj = Server.CreateObject(strClassString)
If 0 = Err Then IsObjInstalled = True
Set xTestObj = Nothing
On Error GoTo 0
End Function

Function CheckSize(ByteSize)
if ByteSize=>1024000 then
ByteSize=formatnumber(ByteSize/1024000)&" MB"
elseif ByteSize=>1024 then
ByteSize=formatnumber(ByteSize/1024)&" KB"
else
ByteSize=ByteSize&" 字节"
end if
CheckSize=ByteSize
End Function


'帐号验证
UserName=HTMLEncode(Request("UserName"))
Userpass=md5(Trim(Request("Userpass")))
if UserName=empty then
	response.Write("[err]用户名没有输入[/err]")
	CloseDatabase
end if

sql="select * from [BBSXP_Users] where UserName='"&UserName&"'"
Set Rs1=Conn.Execute(SQL)
if rs1.eof then
	response.Write("[err]此用户名还未注册[/err]")
	CloseDatabase
end if
if rs1("membercode")=0 then
	response.Write("[err]您的帐号尚未激活[/err]")
	CloseDatabase
end if

if Len(rs1("Userpass"))<16 then
	if Request("Userpass")<>rs1("Userpass") then
		response.Write("[err]您输入的密码错误[/err]")
		CloseDatabase
	end if
elseif Len(rs1("Userpass"))=16 then
	if md5(Request("Userpass"))<>rs1("Userpass") then
		response.Write("[err]您输入的密码错误[/err]")
		CloseDatabase
	end if
else
	if Userpass<>rs1("Userpass") then
		response.Write("[err]您输入的密码错误[/err]")
		CloseDatabase
	end if
end if

if trim(Request("ForumID"))="" then
	response.Write("[err]没有输入版块号[/err]")
	CloseDatabase
end if
ForumID=int(Request("ForumID"))
VoteExpiry=int(Request("VoteExpiry"))

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")
ForumPass=Rs("ForumPass")
ForumPassword=Rs("ForumPassword")
ForumUserList=Rs("ForumUserList")
TolSpecialTopic=Rs("TolSpecialTopic")
ForumPass=Rs("ForumPass")
Rs.close

if membercode>1 or instr("|"&moderated&"|","|"&CookieUserName&"|")>0 then UserPopedomPass=1


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'if Request.ServerVariables("request_method") = "POST" then



	'if sitesettings("EnableAntiSpamTextGenerateForPost")=1 then
	'if Request.Form("VerifyCode")<>Session("VerifyCode") then Message=Message&"<li>验证码错误"
	'end if

	color=HTMLEncode(Request("color"))
	icon=Request.Form("icon")
	Subject=HTMLEncode(Request("Subject"))
	SpecialTopic=HTMLEncode(Request("SpecialTopic"))
	Content=ContentEncode(Request("Content"))
	if Request("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("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
	response.Write("[err]"&Message&"[/err]")
	CloseDatabase
end if


sql="select * from [BBSXP_Users] where UserName='"&UserName&"'"
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
	response.Write("[err]"&Message&"[/err]")
	CloseDatabase
end if

Rs("PostTopic")=Rs("PostTopic")+1
Rs("UserMoney")=Rs("UserMoney")+SiteSettings("IntegralAddThread")
Rs("experience")=Rs("experience")+SiteSettings("IntegralAddThread")
Rs("UserLandTime")=now()
Rs("UserLastIP")=Request.ServerVariables("REMOTE_ADDR")
Rs.update
Rs.close


if UserPopedomPass=1 and color<>"" then Subject="<font color="&color&">"&Subject&"</font>"

Rs.Open "select * from [BBSXP_Threads]",Conn,1,3
Rs.addNew
Rs("UserName")=UserName
Rs("PostTime")=now()
Rs("lastname")=UserName
Rs("lasttime")=now()
Rs("Topic")=Subject
Rs("ForumID")=ForumID
Rs("PostsTableName")=SiteSettings("DefaultPostsName")
if Request("SpecialTopic")<>"" then Rs("SpecialTopic")=SpecialTopic
if Request("icon")<>"" then Rs("icon")=icon
if Request("Vote")<>"" then Rs("isVote")=1
if Request("IsLocked")=1 then Rs("IsLocked")=1
if ForumPass=5 then Rs("IsDel")=1
Rs.update
ID=Rs("ID")
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_PostAttachments] set ThreadID="&ID&",Description='"&Subject&"' where id="&int(UpFileID(i))&" and ThreadID=0")
'next
'end if

Conn.Execute("insert into [BBSXP_Posts"&SiteSettings("DefaultPostsName")&"] (ThreadID,IsTopic,UserName,Subject,content,Postip) values ('"&ID&"','1','"&UserName&"','"&Subject&"','"&content&"','"&Request.ServerVariables("REMOTE_ADDR")&"')")
Conn.execute("update [BBSXP_Forums] set lastTopic='<a href=ShowPost.asp?ThreadID="&id&">"&Left(HTMLEncode(Request("Subject")),15)&"</a>',lastname='"&UserName&"',lasttime="&SqlNowString&",ForumToday=ForumToday+1,ForumThreads=ForumThreads+1,ForumPosts=ForumPosts+1 where id="&ForumID&"")
Conn.execute("update [BBSXP_Statistics_Site] set TodayPost=TodayPost+1,TotalPost=TotalPost+1,TotalThread=TotalThread+1")

Session("VerifyCode")=""

'if ForumPass=5 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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
response.Write("1")
CloseDatabase


%>
