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
投稿

猜你喜欢

  • mysql 选择插入数据(包含不存在列)具体实现

    2024-01-21 15:15:56
  • golang 如何用反射reflect操作结构体

    2024-05-08 10:22:45
  • on error goto (Vbscript)和try catch

    2008-08-04 13:22:00
  • Python使用GitPython操作Git版本库的方法

    2021-04-28 07:22:16
  • vue实现简单全选和反选功能

    2024-05-09 09:29:47
  • scrapy爬虫完整实例

    2021-06-08 09:34:26
  • 教你怎么用python连接sql server

    2023-01-31 22:27:33
  • Python学习笔记整理3之输入输出、python eval函数

    2021-07-19 04:15:58
  • sql语句中单引号,双引号的处理方法

    2024-01-20 06:59:00
  • PHP simplexml_load_string()函数实例讲解

    2023-07-09 07:19:28
  • Oracle与SQL Server数据库镜像对比

    2009-03-25 14:27:00
  • 可以用ASP生成由客户浏览器处理的客户端脚本吗?

    2009-11-01 18:06:00
  • Python之Web框架Django项目搭建全过程

    2022-03-21 03:06:08
  • Python如何使用队列方式实现多线程爬虫

    2022-03-24 08:56:51
  • Python实现向QQ群成员自动发邮件的方法

    2021-08-16 13:41:33
  • Python常用模块介绍

    2021-01-03 10:11:53
  • Python生成随机密码

    2022-04-02 19:21:19
  • python多进程中的内存复制(实例讲解)

    2022-01-20 23:34:46
  • Python的Requests库示例讲解

    2023-07-24 22:03:29
  • 如何远程使用服务器上的Jupyter notebook

    2023-02-08 10:45:54
  • asp之家 网络编程 m.aspxhome.com