
<!--#include file="conn.asp"-->
<!--#include file="inc/config.asp"-->
<!--#include file="../fuction.asp"-->
<% if session("username")=empty then
response.redirect "login.asp"
end if
bid=nosql(int(request.querystring("bid")))
 class2	=	Request.form("class2")
 class3	=	Request.form("class3")
 if class2 <> "" then
	 class2 = cint(class2)
	  if class3 <> "" then
		 class3 = cint(class3)
	 else
		 class3 =0
	 end if
	
 else
 class2 =0
 class3 =0
 end if
 

title=nosql(trim(Replace(Request.Form("title"),vbcrlf," ")))
title=server.htmlencode(title)
faceimg=nosql(trim(request.form("faceimg")))
body=ContentEncode(request.form("body"))
username=nosql(session("username"))
 
if len(title)<1 then
response.write"<script language='javascript'>alert('对不起，帖子主题不能小于一个字符')</script>"
response.write "<script language='javascript'>history.back(-1)</script>"
response.end
end if

if len(body)<1  then
response.write"<script language='javascript'>alert('对不起，内容不能小于一个字符')</script>"
response.write "<script language='javascript'>history.back(-1)</script>"
response.end
end if



set rs=server.CreateObject("adodb.recordset")
sql="select * from book"
rs.open sql,conn,1,3
rs.addnew
rs("title")=title
rs("body")=body
if class2 <> 0 then
rs("bbs_book_class2_id")=class2
end if
if class3 <> 0 then
rs("bbs_book_class3_id")=class3
end if

rs("bid")=bid
rs("username")=username
rs("faceimg")=faceimg
rs("type")=0
rs("fid")=0
rs("hits")=0
rs("reply")=0
rs("wdate")=now()
rs("ldate")=now()


'投票处理程序
if Request.form("vote")<>"" then
vote=Request.form("vote")
if instr(vote,"|") > 0 then error("<li>投票选项中不能含有“|”字符")
vote_title=split(vote,chr(13)&chr(10))
j=0
for i = 0 to ubound(vote_title)
if not (vote_title(i)="" or vote_title(i)=" ") then
allpolltopic=""&allpolltopic&""&vote_title(i)&"|"
j=j+1
end if
next

for y = 1 to j
votenum=""&votenum&"0|"
next
rs("vote_title")=server.htmlencode(allpolltopic)
rs("vote_body")=votenum
rs("vote_dx")=Request.form("vote_dx")
end if




rs.update
id=rs("id")
rs.close
set rs=nothing
if class2 <> 0 and class3 <>  0 then
conn.execute("update [bbs_class3] set class3_class3_newtie ='<a href=Show.asp?id="&id&">"&left(title,15)&"</a>',class3_class3_user='"&username&"',class3_class3_time='"&now()&"' where class3_id="&class3&"")

end if

if class2 <>0 and class3 =0 then

conn.execute("update [bbs_class2] set class2_class2_newtie='<a href=Show.asp?id="&id&">"&left(title,15)&"</a>',class2_class2_user='"&username&"',class2_class2_time='"&now()&"' where class2_id="&class2&"")


end if
if class2 = 0 and class3 =0 then
conn.execute("update [board] set lasttopic='<a href=Show.asp?id="&id&">"&left(title,15)&"</a>',lastname='"&username&"',lasttime='"&now()&"' where bid="&bid&"")
end if
conn.execute("update [info] set alltopic=alltopic+1")

conn.execute("update [shop_user] set topic=topic+1 where username='"&username&"'")
re_re_str ="class2.asp?class1="&bid
if class2 <> 0 then
re_re_str = "class3_list.asp?class1="& bid &"&class2=" & class2
if class3 <>0 then
re_re_str = "list.asp?class1="& bid &"&class2="&class2 &"&class3="&class3
end if
end if
response.redirect(re_re_str)
%>

