日期:2014-05-17  浏览次数:20898 次

投票功能限制IP的问题,如果对是是代理服务器或者ADSL的话,请看代码
<%
hotid=request.QueryString("hotid")
if hotid<>"" then
userip1= Request.ServerVariables("HTTP_X_FORWARDED_FOR")
if userip1="" then
userip1 = Request.ServerVariables("REMOTE_ADDR") 
useriname=userip1
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("data/book.mdb")
timenow=Date()
exec11="select count(*) as total from ip where ip='"&userip1&"'"&"and timenow=#"&timenow&"#"&"and voteid="&hotid
set rs=server.createobject("adodb.recordset")
rs.open exec11,conn,1,1 
if not rs.eof then 
num=rs(0) 
else 
num=0 
end if 
rs.close 
set rs=nothing 

If num >5 Then
  response.write("<script>alert('你今天已经对这个选手投了五次票,请选择其他选手或者明天再来哦');location.href='girl.asp'</script>")
  Response.End
Else
  ' 执行投票
  ' 对IP进行记录
exec="insert into ip(ip,timenow,voteid)values('"&useriname&"','"&timenow&"',"&hotid&")"
exec2="delete from ip where timenow<#"&timenow&"#"
exec3="update girl set hot=hot+1 where id="&hotid
conn.execute exec
conn.execute exec2
conn.execute exec3
conn.close
set conn=nothing
response.write("<script>alert('投票成功');location.href='girl.asp'</script>")


End If

else
useriname=userip1
response.Write(useriname)

end if
else
response.write("<script>alert('请返回选择选手投票');location.href='girl.asp'</script>")
end if
现在这个代码可以限制IP投票,我想问下如果对方用代理的服务器,或者ADSL换IP的话怎么限制?

------解决方案--------------------
你都是通过IP来区分用户的话..换IP当然防不了啊...ADSL的话..更不可能了..除非你有ADSL的IP数据库..
简单点你干脆通过IP+cookie来做吧....复杂的...用户注册机制+实名认证什么之类的吧..