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

ASP
ASP技巧:让Len,Left,Right函数识别中文
Flash和ASP实现的用户登录/注册程序
ASP随机显示不重复记录解决方案
ASP动态网页制作常用错误处理
ASP对网页进行限制性的访问
初学:ASP内建对象Response
ASP Server object error的解决办法
ASP教程,ASP实现防盗链的方法
更改windows XP 的IIS连接数
xmldom在服务器端生成静态html页面
asp技巧:防止被杀毒软件误删的代码
ASP教程:初步接触ASP缓存技术
ASP教程:rs.getrows的使用方法介绍
ASP技巧:Utf-8和Gb2312乱码问题的终结
ASP教程:applicaton对象的使用集合
ASP环境:启动停止IIS不重启电脑的技巧
利用FLV组件制作的播放器,动态获取变量,控制FLV文件
ASP教程:ASP错误ASP 0201的解决方法
ASP技巧教程:认识学习codepage的属性
Codepage参数和其对应的语言

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 98 ::
收藏到网摘: 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
%>