日期:2014-05-17 浏览次数:20955 次
'************************************************** '函数名:GetIP '作 用:取得正确的IP '返回值:IP字符串 '************************************************** 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