Asp限制IP访问

时间:2008-10-07 12:00:48  来源:第二电脑网上收集  作者:

  第二电脑网导读: checkip(ip,allowip1,allowip2)dim check(4)checkip=falseipstr=split(ip,".")allow1=split(allowip1,".")allow2=split(allowip2,".")if cint(allow1(0))>cint(allow2(0)) then ''判断IP地址段是否合法response.write "禁止访问"exit functionend iffor i=0 to ubound(ipstr)if cint(allow1(i))<cint(allow2(i)) thenif cint(all...
  正文: <%
''获取访问者的地址
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
iphotoshop/ target=_blank class=infotextkey>pstr=split(ip,".")
allow1=split(allowip1,".")
allow2=split(allowip2,".")
if cint(allow1(0))>cint(allow2(0)) then ''判断IP地址段是否合法
response.write "禁止访问"
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
%>

"Asp限制IP访问"由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Programming/ASP/2008-10-07/2812.html


关键字:

关于《Asp限制IP访问》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td