<!--#include file="mdb.asp"-->
<!--#Include File="Check_hx.asp"-->
<%
  ip=Request.ServerVariables("REMOTE_ADDR")
  vtid=cint(request.querystring("vt_id"))
  itemid=cint(request.form("item_id"))
  itemname=request.form("itemname")
  if itemid=0 then
    Response.Write "<script language=javascript>alert('请选定投票选项！');JavaScript:window.close();</script>"
    Response.End
  end if
  set rs=server.CreateObject("adodb.recordset")
  rs.open "select ip from vcount where ip='"& ip &"'",conn,1,1
  if not rs.eof and not rs.bof then
	   	   response.write"<SCRIPT language=JavaScript>alert('对不起，您已经投过票了，系统设置每个IP只能投一次！');"
	           response.write"JavaScript:window.close()</SCRIPT>"
		   Response.End
  else
  sql="select * from vcount"
  set rs=server.createobject("adodb.recordset")
  rs.open sql,conn,1,3
  rs.addnew
  rs("IP")=ip
  rs("vtotal")=vtid
  rs.update
  rs.close
  end if

  sql="update voteitem set item_count = item_count + 1 where item_id="&itemid
  conn.execute(sql)
  sql="select vt_id from voteitem where item_id="&itemid
  set rs=conn.execute(sql)
  vtid=rs("vt_id")
  sql="select vt_startdate,vt_expiredate from votetopic where vt_id="&vtid
  set rs=conn.execute(sql)
  vt_startdate=rs("vt_startdate")
  vt_expiredate=rs("vt_expiredate")
  rs.close
  set rs=nothing
  days=datediff("d",vt_startdate,vt_expiredate)
  cookies_time=dateadd("d",days,date())
  response.cookies("npw")("voted")="yes"
  response.cookies("npw")("topic")=request.QueryString("vt_name")
  response.cookies("npw")("itemname")=request.form("itemname")
  response.cookies("npw").expires=cookies_time
%>
<HTML>
<HEAD>
<title>投票成功！</title>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<meta http-equiv="refresh" content="1;URL=showvote.asp?vt_id=<%=vtid%>">
</HEAD>
<BODY leftMargin=0 topMargin=0 MARGINHEIGHT="0" MARGINWIDTH="0" onclick="JavaScript:window.close()">
<center><font color=red>投票成功！</font></center>
</body></html>

