Vote_Ajax.asp
上传用户:jisenq
上传日期:2014-06-29
资源大小:7216k
文件大小:5k
源码类别:

数据库编程

开发平台:

ASP/ASPX

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
  2. <% Option Explicit %>
  3. <%session.CodePage="936"%>
  4. <!--#include file="../FS_Inc/Const.asp" -->
  5. <!--#include file="../FS_InterFace/MF_Function.asp" -->
  6. <!--#include file="../FS_Inc/Function.asp" -->
  7. <%
  8. Response.Buffer = True
  9. Response.Expires = -1
  10. Response.ExpiresAbsolute = Now() - 1
  11. Response.Expires = 0
  12. Response.CacheControl = "no-cache"
  13. response.Charset = "gb2312"
  14. Dim Conn,VS_Sql,VS_RS,VS_RS1,strShowErr,IID,TID,ItemValue,VisitIP ,IPInterView,IsSigned,Steps,MaxNum
  15. Dim TmpStr,TmpArr
  16. TID = NoSqlHack(request.QueryString("TID"))
  17. IID = NoSqlHack(request.form("Items"))
  18. MaxNum = request.QueryString("MaxNum")
  19. ItemValue =  NoSqlHack(request.QueryString("ItemsInput"))
  20. if TID="" or not isnumeric(TID) then response.Write("投票主题参数错误!"&TID)  :  response.End()
  21. if IID="" then response.Write("必须至少选择一项!") : response.End()
  22. IID = replace(IID," ","")
  23. TmpArr = split(IID,",")
  24. if MaxNum="" or not isnumeric(MaxNum) then MaxNum = 1
  25. if ubound(TmpArr)+1 > cint(MaxNum) then response.Write("选项不能超过"&MaxNum&"项!") : response.End()
  26. MF_Default_Conn 
  27. ''''得到基础设置
  28. VS_Sql = "select top 1 IPInterView,IsSigned from FS_VS_SysPara"
  29. set VS_RS = Conn.execute(VS_Sql)
  30. if Not VS_RS.eof then 
  31. IPInterView = VS_RS(0)
  32. IsSigned = VS_RS(1)
  33. else
  34. IPInterView = 1
  35. IsSigned = 0
  36. end if
  37. VS_RS.close
  38. if IsSigned = 1 then 
  39. ''必须注册
  40. if isnull(session("FS_UserNumber")) or session("FS_UserNumber")="" then response.Write("<a href=""/user/login.asp"" target=_blank>请先登陆在投票!</a>") : ConnClose
  41. end if
  42. '''''''''''''''''''''''''''''''''''
  43. VisitIP = request.ServerVariables("HTTP_X_FORWARDED_FOR")
  44. If VisitIP = "" then
  45. VisitIP = request.ServerVariables("REMOTE_ADDR")
  46. End If
  47. Set VS_RS = Conn.Execute("Select top 1 VoteTime from FS_VS_Items_Result where TID = "&TID&" and VoteIp='"&VisitIP&"' order by RID desc")
  48. If VS_RS.eof then
  49. for each TmpStr in TmpArr
  50. ''''得到可以填写的选项的IID
  51. if ItemValue<>"" then 
  52. set VS_RS1 = Conn.execute("select IID from FS_VS_Items where ItemMode = 2 and TID="&TID&" and IID="&TmpStr)
  53. if Not VS_RS1.eof then 
  54. Conn.execute("insert into FS_VS_Items_Result (IID,TID,ItemValue,VoteIp,VoteTime,UserNumber) values ("&TmpStr&","&TID&",'"&ItemValue&"','"&VisitIP&"','"&now&"','"&session("FS_UserNumber")&"')")
  55. else
  56. Conn.execute("insert into FS_VS_Items_Result (IID,TID,ItemValue,VoteIp,VoteTime,UserNumber) values ("&TmpStr&","&TID&",'','"&VisitIP&"','"&now&"','"&session("FS_UserNumber")&"')")
  57. end if
  58. VS_RS1.close
  59. else
  60. Conn.execute("insert into FS_VS_Items_Result (IID,TID,ItemValue,VoteIp,VoteTime,UserNumber) values ("&TmpStr&","&TID&",'','"&VisitIP&"','"&now&"','"&session("FS_UserNumber")&"')")
  61. end if
  62. next
  63. session("OldTID") = TID
  64. response.Cookies("FS_Cookies")(cstr(TID)&"_IID") = ","&IID&","
  65. response.Cookies("FS_Cookies")(cstr(TID)&"_ItemValue") = ItemValue
  66. response.Write("感谢你的投票!")
  67. RsClose : ConnClose
  68. else
  69. if cstr(session("OldTID")) = cstr(TID) then 
  70. if datediff("n",VS_RS("VoteTime"),now) < IPInterView then 
  71. response.Cookies("FS_Cookies")(cstr(TID)&"_IID") = ""
  72. response.Cookies("FS_Cookies")(cstr(TID)&"_ItemValue") = ""
  73. response.Write("请勿重复投票!"&IPInterView&"分钟后可以继续.")
  74. RsClose : ConnClose
  75. end if
  76. end if
  77. for each TmpStr in TmpArr
  78. ''''得到可以填写的选项的IID
  79. if ItemValue<>"" then 
  80. set VS_RS1 = Conn.execute("select IID from FS_VS_Items where ItemMode = 2 and TID="&TID&" and IID="&TmpStr)
  81. if Not VS_RS1.eof then 
  82. Conn.execute("insert into FS_VS_Items_Result (IID,TID,ItemValue,VoteIp,VoteTime,UserNumber) values ("&TmpStr&","&TID&",'"&ItemValue&"','"&VisitIP&"','"&now&"','"&session("FS_UserNumber")&"')")
  83. else
  84. Conn.execute("insert into FS_VS_Items_Result (IID,TID,ItemValue,VoteIp,VoteTime,UserNumber) values ("&TmpStr&","&TID&",'','"&VisitIP&"','"&now&"','"&session("FS_UserNumber")&"')")
  85. end if
  86. VS_RS1.close
  87. else
  88. Conn.execute("insert into FS_VS_Items_Result (IID,TID,ItemValue,VoteIp,VoteTime,UserNumber) values ("&TmpStr&","&TID&",'','"&VisitIP&"','"&now&"','"&session("FS_UserNumber")&"')")
  89. end if
  90. next
  91. response.Cookies("FS_Cookies")(cstr(TID)&"_IID") = ","&IID&","
  92. response.Cookies("FS_Cookies")(cstr(TID)&"_ItemValue") = ItemValue
  93. session("OldTID") = TID
  94. response.Write("感谢你的投票!")
  95. RsClose : ConnClose
  96. End if
  97. Sub RsClose()
  98. VS_RS.Close
  99. Set VS_RS = Nothing
  100. end Sub
  101. Sub ConnClose()
  102. Set Conn = Nothing
  103. response.End()
  104. End Sub
  105. %>