这段代码是一个限制IP的,但只能限制一个IP段,现在我想要限制三个IP段,可是无我怎样改都只能限制一个,请各位前辈看看该怎样进行修改。(注明,红色为我自己改的部分。) <%
dim xip,xip1,xip2,xip3,xip4,xip5,xip6 '定义ip变量
xip1="1.0.0.1"
xip2="1.0.0.125" '第一段 ip终止
xip3="1.2.1.161"
xip4="1.2.1.189" '第二段 ip终止
xip5="1.5.11.193"
xip6="1.5.11.221" '第三段 ip终止
xip=request.servervariables("remote_addr") '取得来访ip地址
xip=find_ip(xip) '对ip进行转换
xip6=find_ip(xip6)
xip5=find_ip(xip5)
xip4=find_ip(xip4)
xip3=find_ip(xip3)
xip2=find_ip(xip2)
xip1=find_ip(xip1)
if xip<xip1 or xip>xip2 then '进行ip判断
response.redirect "ShowArticle.html" '指向出错页面
if xip>xip2 ot xip<xip3 then
response.redirect "ShowArticle.html" '指向出错页面
if xip>xip4 or xip<xip5 then
response.redirect "ShowArticle.html" '指向出错页面
if xip>xip6 then
response.redirect "ShowArticle.html" '指向出错页面
response.end
end if
end if
end if end if
function find_ip(str)
dim i,j,k
dim result,result1,result2,result3
i=Instr(4,str,".",1) '搜索ip中的第二个"."
if i=0 or i=Null then
result=""
else '如果存在第二个"."
j=Instr(i+1,str,".",1) '搜索ip中的第三个"."
result1=mid(str,4,i-4)
if j=0 or j=Null then
result=mid(str,4,i-4)
else '如果存在第三个"."
k=len(str)
result2=mid(str,i+1,j-i-1)
result3=right(str,k-j)
end if
end if
result1=CSng(cstr(result1)*256*256)
result2=CSng(cstr(result2)*256)
result=result1+result2+cstr(result3)
find_ip=result
end function
%>
dim xip,xip1,xip2,xip3,xip4,xip5,xip6 '定义ip变量
xip1="1.0.0.1"
xip2="1.0.0.125" '第一段 ip终止
xip3="1.2.1.161"
xip4="1.2.1.189" '第二段 ip终止
xip5="1.5.11.193"
xip6="1.5.11.221" '第三段 ip终止
xip=request.servervariables("remote_addr") '取得来访ip地址
xip=find_ip(xip) '对ip进行转换
xip6=find_ip(xip6)
xip5=find_ip(xip5)
xip4=find_ip(xip4)
xip3=find_ip(xip3)
xip2=find_ip(xip2)
xip1=find_ip(xip1)
if xip<xip1 or xip>xip2 then '进行ip判断
response.redirect "ShowArticle.html" '指向出错页面
if xip>xip2 ot xip<xip3 then
response.redirect "ShowArticle.html" '指向出错页面
if xip>xip4 or xip<xip5 then
response.redirect "ShowArticle.html" '指向出错页面
if xip>xip6 then
response.redirect "ShowArticle.html" '指向出错页面
response.end
end if
end if
end if end if
function find_ip(str)
dim i,j,k
dim result,result1,result2,result3
i=Instr(4,str,".",1) '搜索ip中的第二个"."
if i=0 or i=Null then
result=""
else '如果存在第二个"."
j=Instr(i+1,str,".",1) '搜索ip中的第三个"."
result1=mid(str,4,i-4)
if j=0 or j=Null then
result=mid(str,4,i-4)
else '如果存在第三个"."
k=len(str)
result2=mid(str,i+1,j-i-1)
result3=right(str,k-j)
end if
end if
result1=CSng(cstr(result1)*256*256)
result2=CSng(cstr(result2)*256)
result=result1+result2+cstr(result3)
find_ip=result
end function
%>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货