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

ASP
防止网站被采集的理论分析以及十条方法对策
Asp 操作Access数据库时出现死锁.ldb的解决方法
asp HTTP_X_FORWARDED_FOR和REMOTE_ADDR
ASP 代码出现80040e14错误的解决方法
Asp 编码互转的研究和实现代码
asp fckeditor自定义上传文件的文件名
asp javascript picasa相册外链批量导出
asp MD5加密方式使用建议
asp javascript值的互相传递方法
ASP UTF-8编码下字符串截取和获取长度函数
asp vbcrlf是什么意思
ASP 相关文章或者相关产品
在Win2003 64位下ASP无法连接Access数据库
asp 得到动态数组中元素的个数
Session.TimeOut的最大取值是1440,超出会报错
Form Post提交容量大的数据
启动iis出现发生意外0x8ffe2740的解决方法
asp 实现当有新信息时播放语音提示的效果
asp 延时 页面延迟的三种方法
Asp 日期格式化问题

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


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