北风首页专栏登陆RSS收藏

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

作者:libin_8745 发布于:2009年02月26日 15:08

<%
’获取访问者的地址
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
%>

作者:libin_8745
来源:北风技术专栏
原文链接:http://column.ibeifeng.com/libin_8745/20090226278.shtml

( 内容完 )

添加收藏到:

您可能还对这些文章感兴趣:

  • 简述WebS简述WebService与.NET Remoting的区别及适应场合
  • java web程序究竟该如何布署?
  • IP及IP段进行访问限制的代码
  • Java编程思想:面向对象的逻辑思维方法
  • Asp.net的IP地址屏蔽功能设计
  • SQL注入
  • 关于我们
  • 隐私策略
  • ikon999原创:JsUnit测试之二
  • 谈谈#include和#include"stdio.h"的效率问题
  • 没有评论, 我来评论

    小贴士:评论需要管理员审核后才会显示。请不要发布与国家法律相抵触的言论,北风网将保留追究责任的权利。
    类似“顶”、“沙发”、“支持”之类没有营养的文字,对勤劳贡献的作者来说是令人沮丧的反馈信息。
    请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
    如果您发现自己的评论没有被审核或者不见了,请参考以上三条。

    每周之星

    陈臣陈臣

    七年Java和JEE开发经验,JEE应用设计和高级架构师,拥有Sun的多项Java和J2EE方面的技能认证,多年项目经理、技术部经理的管理经验。拥有全面、扎实的Java和JEE理论知识,丰富的JEE应用开发经验。

    更多作者:

  • Adam
  • ikon999
  • libin_8745
  • lifengxing
  • taohuang100
  • xingkong
  • 呆子
  • 子晨
  • 小白
  • 张章
  • 张维亮
  • 陈臣
  • 陶宝哥
  • 风风
  • 最新内容

    推荐内容

    标签

    分类

    北风专栏测试中,有任何问题请联系我们