简单说下限制投票。
建立一个IP日志表,用来记录IP地址的。
有用户投票时,记录下IP地址,搜索当天时间该IP投票次数。
如果当天次数小于10,就可以投票。投票完成后就把对应该IP的次数加1。
如果当天次数大于等于10,就不让投票了。
Public Function GetIP()
Dim strIPAddr
If Request.ServerVariables("HTTP_X_FORWARDED_FOR") = "" Or InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), "unknown") > 0 Then
strIPAddr = Request.ServerVariables("REMOTE_ADDR")
ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",") > 0 Then
strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",")-1)
ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";") > 0 Then
strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";")-1)
Else
strIPAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
End If
getIP = Checkstr(Trim(Mid(strIPAddr, 1, 30)))
End Function
Public Function Checkstr(Str)
If Isnull(Str) Then
CheckStr = ""
Exit Function
End If
Str = Replace(Str,Chr(0),"")
CheckStr = Replace(Str,"'","''")
End Function
Dim count
count = conn.Execute("select count(*) from vote where IP='" & GetIP() & "' and [Date]='" & date() & "'")(0)
If count > 10 Then
Response.Write "不能投票"
Response.End
Else
' 执行投票
' 对IP进行记录
If count = 0 Then
conn.Execute("insert into vote(IP,[Date]....) value(...)")
Else
conn.Execute("update vote_from set .... where IP='' and [date]=...")
End If
End If