| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 521 人关注过本帖
标题:[求助]实现限制ip访问时出错! 错误 '800a0009'
只看楼主 加入收藏
yanziyz
Rank: 1
等 级:新手上路
帖 子:171
专家分:0
注 册:2006-5-20
结帖率:75%
收藏
 问题点数:0 回复次数:2 
[求助]实现限制ip访问时出错! 错误 '800a0009'
请教高手,我在实现限制ip访问时程序运行出现以下错误

icrosoft VBScript 运行时错误 错误 '800a0009'

下标越界: '[number: 2]'

/lyb/lyb.asp,行 156


lyb.asp的程序代码如下:

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

''允许的IP地址段为202.200.200.0~202.200.207.255
allowip1="202.200.200.0"
allowip2="202.200.207.255"
response.write checkip(ip,allowip1,allowip2)
function checkip(clientip,allowip1,allowip2)
dim check(5)
checkip=false
ipstr=split(clientip,".")
allow1=split(allowip1,".")
allow2=split(allowip2,".")
if cint(allow1(0))>cint(allow2(0)) then ''判断IP地址段是否合法

exit function
response.redirect "error.htm"
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 '行 156 (cint(allow2(2))>cint(ipstr(2))) then '行 156
checkip=true
end if
end function
%>


我是低手,ip限制也是摸索着作,在这里迫切寻求高手的帮助!多谢了
搜索更多相关主题的帖子: 访问 
2007-03-23 09:21
阳光白雪
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:39
帖 子:2220
专家分:0
注 册:2005-11-18
收藏
得分:0 

<%
''获取访问者的地址
dim ClientIp,BeginIp,EndIp
ClientIp = Request.ServerVariables("REMOTE_ADDR")
''允许的IP地址段为202.200.200.0~202.200.207.255
BeginIp = "202.200.200.0"
EndIp = "202.200.207.255"
response.write CheckIp(ClientIp,BeginIp,EndIp)

Function CheckIp(ClientIp,BeginIp,EndIp)
Dim BeginIpArr,EndIpArr,ClientIpArr,BeginIpStr,EndIpStr,ClientIpStr
CheckIp = True
BeginIpArr = Split(BeginIp,".")
EndIpArr = Split(EndIp,".")
ClientIpArr = Split(ClientIp,".")
For i = 0 To Ubound(BeginIpArr)
BeginIpArr(i) = Right("000"& BeginIpArr(i),3)
EndIpArr(i) = Right("000"& EndIpArr(i),3)
ClientIpArr(i) = Right("000"& ClientIpArr(i),3)
BeginIpStr = BeginIpStr & BeginIpArr(i)
EndIpStr = EndIpStr & EndIpArr(i)
ClientIpStr = ClientIpStr & ClientIpArr(i)
Next
BeginIpStr = FormatNumber(BeginIpStr,0)
EndIpStr = FormatNumber(EndIpStr,0)
ClientIpStr = FormatNumber(ClientIpStr,0)
If ClientIpStr-BeginIpStr<0 Or ClientIpStr-EndIpStr>0 Then
CheckIp = False
End If
End Function
%>

[此贴子已经被作者于2007-3-23 11:20:59编辑过]


专注于WEB前端交互平台开发:[url=http://blog./]blog.[/url](富客户端技术(RIA)交流平台)
2007-03-23 10:00
yanziyz
Rank: 1
等 级:新手上路
帖 子:171
专家分:0
注 册:2006-5-20
收藏
得分:0 
阳光白雪:太感谢你了,我使用你的ip限制函数,问题解决了,你太棒了。。。对你、对藏在论坛背后的各位热心的高手有太多的感谢。。。。。
2007-03-23 11:06
快速回复:[求助]实现限制ip访问时出错! 错误 '800a0009'
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014504 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved