作者:stone2zz 时间: 2004-03-11 文档类型:原创 来自:蓝色理想
看了一些IP限制的函数,觉得太复杂。所以,试着写了一个,比较简单。请网友参考指教。谢谢!~
作者联系邮件 stone2zz#21cn.com
代码拷贝框<% '获取访问者的地址 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 %>[Ctrl+A 全部选择 然后拷贝]
出处:蓝色理想 责任编辑:蓝色
◎进入论坛网络编程版块参加讨论
蓝色理想版权申明:除部分特别声明不要转载,或者授权我站独家播发的文章外,大家可以自由转载我站点的原创文章,但原作者和来自我站的链接必须保留(非我站原创的,按照原来自一节,自行链接)。文章版权归我站和作者共有。
转载要求:转载之图片、文件,链接请不要盗链到本站,且不准打上各自站点的水印,亦不能抹去我站点水印。
特别注意:本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有,文章若有侵犯作者版权,请与我们联系,我们将立即删除修改。