asp阻止中国ip访问访问

来源:经典论坛 时间:2011-09-13 12:55:37 

因为外贸网站,禁止同行抄袭,所以防止中国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://ip.qq.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://www.countryipblocks.net/ 右上角有一块自动生成的。

 

标签:ip,访问
0
投稿

猜你喜欢

  • 基于ExtJs框架的B/S高级查询界面

    2008-10-07 18:05:00
  • ASP ,IP地址分段计算

    2008-04-13 06:55:00
  • 理清mysql外链的含义和命令

    2010-03-09 15:55:00
  • js 混淆加密工具代码

    2007-09-22 18:10:00
  • 如何用ASP发送HTML格式的邮件?

    2010-06-11 19:41:00
  • Javascript的数组总结

    2009-02-03 13:07:00
  • ASP+AJAX做类似google的搜索提示

    2008-10-24 13:49:00
  • ASP链接Mysql数据库 非DSN连接的方法

    2009-03-09 18:24:00
  • utf-8 网页不显示+utf-8网页乱码的通用解决方法

    2011-04-19 10:47:00
  • YUI学习笔记(1)

    2009-01-12 18:06:00
  • word-wrap同word-break的区别

    2007-10-24 20:08:00
  • asp随机生成文件名的函数

    2009-02-11 13:41:00
  • ASP利用Google实现在线翻译功能

    2010-03-07 17:28:00
  • 我所理解的网页推广设计的几个要点

    2011-01-25 12:37:00
  • 用XML和XSL来生成动态页面

    2008-09-04 10:35:00
  • HTML,CSS和JavaScript速查表

    2010-09-16 13:02:00
  • SQL语句练习实例之二——找出销售冠军

    2011-10-24 19:52:45
  • MySQL 查询缓存的实际应用代码示例

    2010-06-11 12:04:00
  • SQL Server中的执行引擎入门 图解

    2012-06-06 20:08:26
  • CSS模块化设计

    2009-01-05 12:10:00
  • asp之家 网络编程 m.aspxhome.com