盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

局限内外网访问的ASP代码

时间:2024/9/29作者:未知来源:盾怪网教程人气:

[摘要]准备只区别内外网的,我们学校的内网都是192.168.*.*的,这个很容易区别,但是校内用户一用学校对外的代理,IP又变成服务器在外的代理,于是乎又加进去,现在变成了可以允许某些外网访问了。因为领导...

    准备只区别内外网的,我们学校的内网都是192.168.*.*的,这个很容易区别,但是校内用户一用学校对外的代理,IP又变成服务器在外的代理,于是乎又加进去,现在变成了可以允许某些外网访问了。因为领导要求就这些,只做到这点,以后还可以还可 以丰富,甚至做成组件。

    有些人可能需要这个东西,放上来共享!

    编程高手来提出宝贵意见~~~

    <%
    ip=Request.ServerVariables("REMOTE_ADDR")  '获取访问者的地址

    allowip1="192.168.0.0"    '第一允许IP段特点
    allowip2="192.168.255.255" '暂时无用
    allowip3="61.153.213.14"   '具体允许IP地址    
    allowip4="61.129.69.177"

    dim check(5)
    ipstr=split(ip,".")
    allow1=split(allowip1,".")
    allow2=split(allowip2,".")
    allow3=split(allowip3,".")
    allow4=split(allowip4,".")

    for aa=0 to 1
      for bb=0 to 3
      if cint(allow1(aa))&lt;&gt; cint(ipstr(aa)) then
         if cint(allow3(bb))&lt;&gt; cint(ipstr(bb)) then
        if cint(allow4(bb))&lt;&gt; cint(ipstr(bb)) then
        response.redirect "http://www.nhxx.net/err.php"
        end if
      end if
      end if
      next
    next
    %>

    这个也可以,优点是速度快,但输入IP麻烦

    <%
    '获取访问者的地址
    ip=Request.ServerVariables("REMOTE_ADDR")

    allowip1="192.168.0.0"
    allowip2="192.168.255.255"
 
    function checkip(ip,allowip1,allowip2)
    dim check(4)
    ipstr=split(ip,".")
    allow1=split(allowip1,".")
    allow2=split(allowip2,".")
      if cint(allow1(0))&lt;&gt; cint(ipstr(0))   then'判断IP地址段是否内网用户
        if cint(ipstr(0))=61 and cint(ipstr(1))=153 and cint(ipstr(2))=213 and cint(ipstr(3))=14 then '判断具体地址
        else
     if cint(ipstr(0))=61 and cint(ipstr(1))=129 and cint(ipstr(2))=69 and cint(ipstr(3))=166 then
     else
     response.redirect "http://www.nhxx.net/err.php"
     end if
       end if
      end if
    end function
    %>



关键词:局限内外网访问的ASP代码




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版