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

ASP
javascript css 三级目录(简单的)
asp下sql和access数据库随机取10条记录的代码newid()
新增加一个防垃圾评论的asp代码,鄙视垃圾
asp ADO GetString函数与用GetString来提高ASP的速度
windows2003下使用asp WScript.Shell的设置方法
asp UTF-8 乱码问题的解决方法小结
JavaScript面向对象的两种书写方法以及差别
响应对象 错误 ''ASP 0185 : 80020003'' 缺少默认属性
ASP生成伪参数程序设计技巧
asp中使用mysql数据库的注意实现
使用FSO修改文件夹的名称实现文件转移防盗链
asp下request.querystring("id")与request("id")区别
asp将全角的字符转变成半角字符,将半角转变成全角d的代码
asp创建表,复制表 字段类型附录
asp加密解密函数decrypt
asp获取当前网页地址的代码
asp下经常用到的代码
asp 的中文分词
修改正确的asp冒泡排序
rustysun同学ASP代码书写规范

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


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