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

如何控制不让一个国家的IP访问一个网站,急!
请问高手,如何控制不让一个国家的IP访问一个网站,怎么做才做到,程序是怎样写的,谢谢!急呀

------解决方案--------------------
IP=Request.ServerVariables( "REMOTE_ADDR ")
If IP= "指定IP " Then
Response.Write( "您的IP受限,请与网站管理员联系. ")
Response.End()
End If
------解决方案--------------------
<%
ip_start= "61.143.129.0 " //IP开始地址
ip_end = "61.143.133.255 " //IP结束地址
ip_start_arr =split(ip_start, ". ")
ip_end_arr =split(ip_end, ". ")
ip_start_str= " "
ip_end_str= " "
ip_user_str= " "
for i=0 to 3
ip_start_str=ip_start_str&right(Cstr(formatnumber(Cint(ip_start_arr(i))/1000,3)),3)
ip_end_str=ip_end_str&right(Cstr(formatnumber(Cint(ip_end_arr(i))/1000,3)),3)
next
'测试客户端是否用代理
userip = Request.ServerVariables( "HTTP_X_FORWARDED_FOR ")
If userip = " " Then userip = Request.ServerVariables( "REMOTE_ADDR ")
ip_user_arr =split(userip, ". ")
for i=0 to 3
ip_user_str=ip_user_str&right(Cstr(formatnumber(Cint(ip_user_arr(i))/1000,3)),3)
next
if CDbl(ip_user_str)> CDbl(ip_end_str) or CDbl(ip_user_str) <CDbl(ip_start_str) then
response.write "超出访问范围 "
end if
%>
------解决方案--------------------
首先你得建立一个IP库...