<!--#include file="Inc.asp"-->
<!--#include file="ydzq.asp"-->

<!--#include file="forbbs.asp"-->
<%

call head()

dim tid,bbsid,voteid,ppage
tid=usb(request("tid"))
bbsid=usb(request("bbsid"))
voteid=usb(request("voteid"))
voteid = forbbs(voteid)
ppage=usb(request("ppage"))
if tid="" or IsNumeric(tid)=False then
  Call Error("<card title=""投票""><p>ID无效！")
end if
if bbsid="" or IsNumeric(bbsid)=False then
  Call Error("<card title=""投票""><p>ID无效！")
end if

set rs=server.CreateObject("ADODB.RecordSet")
rs.Open "SELECT ID,vote,addvote,voteid FROM sell WHERE yc=0 AND  ID="&tid,conn,1,2
if rs.eof then
  rs.close
  set rs=Nothing
  Call Error("<card title=""投票""><p>不存在的主题！")
end if
	if rs("vote")<>"" then
        dim addvote,vote,votenum_1,i
	addvote=split(rs("addvote"),",")
	vote=false
        For i = 0 to ubound(addvote)

	if cint(voteid)=i then
	addvote(i)=addvote(i)+1
	end if

	if votenum_1="" then
	votenum_1=addvote(i)
	else
        votenum_1=votenum_1 & "," & addvote(i)
	end if
            	Next
		dim votenid_1
		if rs("voteid")<>"" then
		voteid=split(rs("voteid"),",")
            	For i = 0 to ubound(voteid)
               		If clng(voteid(i)) = myid Then
				vote=true
			exit for
End If
Next
end if

if vote=true then
        Call Error("<card title=""投票""><p>你已经投票过了，请不要重复投票！")
        end if
	if rs("voteid")<>"" then
	votenid_1=rs("voteid") & "," & myid
	else
	votenid_1= myid
	end if
	rs("addvote")=votenum_1
	rs("voteid")=votenid_1
	rs.update
     end if
Rs.close
set rs=nothing
conn.close
set conn=Nothing

call cardz("投票","topic.asp?saytk="&saytk&"&amp;sid="&sid&"&amp;tid="&tid&"&amp;bbsid="&bbsid&"&amp;page="&ppage&"")


response.write "<a href=""/bbs/topic.asp?saytk="&saytk&"&amp;sid="&sid&"&amp;tid="&tid&"&amp;bbsid="&bbsid&"&amp;page="&ppage&""">投票</a><br/>"

%>
投票成功!正在返回...<br/>
<a href="board.asp?bbsid=<%=bbsid%>&amp;sid=<%=sid%>&saytk=<%=saytk%>">返回本版</a><br/>
<!--#include file="fanhui.asp"-->
<%call headsay()%>