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

ASP
ASP六大对象介绍
使用Filter实现信息的二次检索
让弹出窗口变得“听话”一些
在ASP中利用“正则表达式” 对象实现UBB风格的论坛
“Web 匿名用户”帐户密码的位置
对一些编程初学者的良言警句
ASP编程中15个非常有用的例子
精彩:ASP遗留的二十大积习
关于Asp代码与页面的分离
教大家如何利用ASP打造网站论坛DIY(1)
教大家如何利用ASP打造网站论坛DIY(2)
网站安全:防范ASP木马的十大基本原则
用ASP设计一个留言薄
趣味访客计数器设计两则
我的ASP之旅—二级联动菜单制作
ASP编程--新手上路篇:ASP技术简介
用ASP实现网上考试系统
请注意!常见的ASP脚本攻击及防范技巧
ASP开发的WAP格式简易邮件系统实例
asp基础教程:网页间数据传递方法小结

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


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