正文

客户端IP地址判断,可以做很多事哦!2006-06-25 03:05:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/aspcode/16166.html

分享到:

比如禁止某地区的人访问网页。 <% '海南IP段'=================================='61.186.0.0 - 61.186.37.255'202.100.199.0 - 202.100.255.255'203.207.176.0 - 203.207.176.255'210.014.199.0 - 210.014.199.255'210.014.244.0- 210.014.244.255'210.014.255.0 - 210.014.255.255'210.37.0.0 - 210.37.255.255'210.053.207.135 - 210.053.207.136'210.72.56.0 - 210.72.56.255'211.97.96.0 - 211.97.103.255'211.163.89.0 - 211.163.89.255'218.77.128.0 - 218.77.230.255'218.138.160.0 - 218.138.160.255 '================================== function IP2Num(sip) dim str1,str2,str3,str4 dim num IP2Num=0 if isnumeric(left(sip,2)) then  str1=left(sip,instr(sip,".")-1)  sip=mid(sip,instr(sip,".")+1)  str2=left(sip,instr(sip,".")-1)  sip=mid(sip,instr(sip,".")+1)  str3=left(sip,instr(sip,".")-1)  str4=mid(sip,instr(sip,".")+1)  num=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)  IP2Num = num end ifend function function Num2IP(nip) iip1 = int(nip/256/256/256) iip2 = int((nip-iip1*256*256*256)/256/256) iip3 = int((nip-iip1*256*256*256-iip2*256*256)/256) iip4 = int((nip-iip1*256*256*256-iip2*256*256-iip3*256) mod 256) iip0 = iip1 &"."& iip2 & "." &iip3 &"."& iip4 Num2IP = iip0end function '获得真实IPDim useripuserip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")if userip = "" then userip = Request.ServerVariables("REMOTE_ADDR")end ifuserIPnum = IP2Num(userip) '对IP地址进行判断if userIPnum > IP2Num("127.0.0.0") and userIPnum < IP2Num("127.0.0.255") then response.write ("<center>您的IP被禁止</center>") response.endend if%>

阅读(1994) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册