当前位置: 首页 > 图文教程 > 网络编程 > ASP > asp中对ip进行过滤限制函数

ASP
Dom遍历XML的一个例子,结果为树状结构
[原创]如何回到先前的页面的方法多中语言
几个经典的ASP应用
pjblog实现类似CMS的首页调用
PJblog友情链接LOGO地址失效的解决
ASP程序给上传的图片增添水印效果!
127.0.0.1无法访问,没有权限: GetObject
PJBLOG使用技巧
ASP数据库连接方式大全
ASP辅助代码
垃圾引用防治补丁以及发送引用修正补丁的自动安装程序
发一个采集(小偷)用的类,ASP+缓存实现
利用ASPUPLOAD,ASPJPEG实现图片上传自动生成缩略图及加上水印
后台管理登录篇-asp设计与数据库
使用Flash DownLoad编写采集器(之突破防盗连下载音乐文件)
[原创]随机增加网站点击的一个不错的方法
javascript asp教程第二课--转义字符
javascript asp教程第三课 new String() 构造器
javascript asp教程第六课-- response方法
简单的ASP中经常用到的代码[推荐]

ASP 中的 asp中对ip进行过滤限制函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 85 ::
收藏到网摘: n/a

<%
’获取访问者的地址
ip=Request.ServerVariables("REMOTE_ADDR") 
’允许的IP地址段为10.0.0.0~10.68.63.255
allowip1="10.0.0.0"
allowip2="10.68.10.71"
response.write checkip(ip,allowip1,allowip2)

function checkip(ip,allowip1,allowip2)
dim check(4)
checkip=false
ipstr=split(ip,".")
allow1=split(allowip1,".")
allow2=split(allowip2,".")
if cint(allow1(0))>cint(allow2(0)) then ’判断IP地址段是否合法
response.write "IP地址段出错!"
exit function
end if
for i=0 to ubound(ipstr)
if cint(allow1(i))<cint(allow2(i)) then
if cint(allow1(i))=cint(ipstr(i)) then
check(i)=true
checkip=true
exit for
else
if cint(ipstr(i))<cint(allow2(i)) then
check(i)=true
checkip=true
exit for
else
if cint(ipstr(i))>cint(allow2(i)) then
check(i)=false
checkip=false
exit for
else
check(i)=true
checkip=true
end if
end if
end if
else
if cint(allow1(i))>cint(ipstr(i)) or cint(allow1(i))<cint(ipstr(i)) then
check(i)=false
checkip=false
if i<>ubound(ipstr) then
exit for
end if
else
check(i)=true
end if
end if
next
if (check(0)=true and check(1)=true and check(2)=true and check(3)=false) and (cint(allow2(2))>cint(ipstr(2))) then
checkip=true
end if
end function
%>