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

ASP
ASP优化:几招提高ASP性能的最佳选择
ASP进阶:用ASP制作统计饼图、柱状图等
ASP应用进阶 ASP Error对象的相关知识
ASP常见数学函数 Abs Atn Cos 等详解
ASP优化 用数据绑定实现高效率动态网页
用着放心 为你的ASP程序作一个负载测试
ASP+Access的安全隐患以及解决方法
ASP中将视频文件转换成.flv格式
经典!5分钟编写一个ASP论坛
ASP实现小偷程序原理和简单示例
用ASP木马实现FTP和解压缩
如何用ASP编写网站统计系统
response.write与之间的区别
asp操作excel文件的函数
如何有效提高asp页面的访问速度
JS+ASP打造无刷新新闻列表
使用VB将ASP代码封装生成DLL文件
用ASP打造一个小型的网页BBS系统
ASP网站的漏洞分解以及入侵防范方法
破解网站发布系统 ASP生成静态页面方法

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


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