asp阻止中国ip访问访问

2013 年 3 月 7 日5050

因为外贸网站,禁止同行抄袭,所以防止中国ip访问访问,访问的时候有密码提示,这样的代码如何写.请给一个提示.或者有好的代码,请分享下。

<%
Function leleToStr(str)
Dim stream
Set stream=Server.CreateObject("ADODB.Stream")
With stream
.Type=1
.Mode=3
.Open
.Write str
.Position = 0
.Type = 2
.Charset = "gb2312"
leleToStr = .ReadText
.Close
End With
Set stream=Nothing
End Function


'获取IP所在地区
Function getIPAddress()
on error resume next
dim xmlhttp,url
url = "http://http://www.zjjv.com//"
set xmlhttp = server.CreateObject("Msxml2.XMLHTTP")
xmlhttp.open "get",url,false
xmlhttp.send

'开始截取字符
dim StartStr,EndStr,html
html = leleToStr(xmlhttp.responseBody)
StartStr = Instr(html,"所在地为:")
EndStr = Instr(html,"如果该IP")
html = mid(html,StartStr,EndStr-StartStr)

'再次获取
StartStr = Instr(html,"<span>")
StartStr = StartStr + 6
EndStr = Instr(html,"</span>")
html = mid(html,StartStr,EndStr-StartStr)

getIPAddress = html
if err then err.clear:html = ""
set xmlhttp = nothing
End Function

if Instr(getIPAddress(),"中国")>0 then response.end
%>

网上搜索到的:
# Chinese IP addresses follow:
# 中国ip地址
deny from 58.22.0.0/15 58.56.0.0/15 58.58.0.0/16 58.59.0.0/17 58.60.0.0/14 58.82.0.0/15 58.208.0.0/12 58.246.0.0/15 58.248.0.0/13 59.32.0.0/13 59.40.0.0/15 59.42.0.0/16 59.56.0.0/13 60.12.0.0/16 60.28.0.0/15 60.160.0.0/11 60.194.0.0/15 60.208.0.0/13 60.216.0.0/15 61.4.64.0/20 61.48.0.0/13 61.128.0.0/10 61.135.0.0/16 61.145.73.208/28 61.179.0.0/16 61.183.0.0/16 61.184.0.0/16 61.185.219.232/29 61.188.0.0/16 61.232.0.0/14 61.236.0.0/15 118.132.0.0/14 119.18.192.0/20 121.32.0.0/14 123.4.0.0/14 124.42.64.0/18 124.236.0.0/14 125.40.0.0/13 159.226.0.0/16 202.66.0.0/16 202.96.0.0/12 202.96.128.0/18 202.108.0.0/16 203.69.0.0/16 203.169.160.0/19 210.5.0.0/19 210.14.128.0/19 210.21.0.0/16 210.51.0.0/16 210.192.96.0/19 211.76.96.0/20 211.78.208.0/20 211.90.0.0/15 211.136.0.0/13 211.233.70.0/24 211.144.12.0/22 211.144.160.0/20 211.152.14.0/24 211.154.128.0/19 211.157.32.0/19 211.161.24.128/26 218.0.0.0/11 218.56.0.0/13 218.64.0.0/11 218.88.0.0/13 218.96.0.0/14 218.102.0.0/16 218.104.136.128/25 218.242.0.0/16 219.128.0.0/11 219.232.0.0/19 220.160.0.0/11 220.181.0.0/16 220.192.0.0/12 220.228.70.0/24 220.248.0.0/14 220.250.0.0/19 220.252.0.0/16 221.10.0.0/16 221.11.0.0/16 221.192.0.0/14 221.208.0.0/14 221.212.0.0/16 221.216.0.0/13 221.224.0.0/13 221.228.0.0/14 221.238.0.0/15 222.32.0.0/11 222.76.0.0/14 222.80.0.0/12 222.136.0.0/13 222.166.0.0/16 222.168.0.0/15 222.172.222.0/24 222.184.0.0/13

这个是.htaccess的。ASP的如果支持伪静态的话,也可以写类似的进去。或者访问http://http://www.zjjv.com/// 右上角有一块自动生成的。

0 0