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

ASP
WEB打印设置解决方案四
截取固定长度字符串显示在页面
如何得到上一次插入记录后自动产生的ID
组件:Adodb.Stream 浅释
一个统计当前在线用户的解决方案
实例演练ASP+XML编程
IP地址分段计算
身份证验证代码函数
简单购物车教程
ASP分页函数
asp中对ip进行过滤限制函数
不用Golobal和session实现在线人数统计
ASP实现结构化列举并查看某路径下所有文件
常用Response对象的使用祥解
在ASP网站设计中表单验证
动网论坛代码分析
轻松实现将上传图片到数据库
读取数据库中数据到数组的类
网址和邮件地址的转换函数
ASP编码优化

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


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