| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 582 人关注过本帖
标题:限制IP访问ASP页面代码应该写在什么位置?
只看楼主 加入收藏
leejxing
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-7-29
收藏
 问题点数:0 回复次数:3 
限制IP访问ASP页面代码应该写在什么位置?

我想限制IP访问我的页面,不知应该写在什么位置,谁可以告诉我?
代码如下:
<%
''获取访问者的地址
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 "禁止访问"
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 位置 页面 代码 
2006-07-29 20:50
vrowang123
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2006-7-24
收藏
得分:0 
<body>
here
2006-07-30 16:25
yeshirow
Rank: 4
等 级:贵宾
威 望:10
帖 子:854
专家分:0
注 册:2006-6-8
收藏
得分:0 
太長了, 沒看,
限制訪問該頁, 在 asp 輸出或跳轉之前作檢查

原來朋友仔感情再天真, 亦是我永遠也會愛惜的人, 明日愛他人, 也記住學會不要緊; 原來朋友比戀人更高分, 亦讓我開始懂得不記恨, 若大家都敏感, 我更要永遠記得拒絕再因小事怪人, 爲何沒有這條校訓...Twins-朋友仔 MCSD Training
2006-07-30 19:45
jimn2000
Rank: 2
等 级:新手上路
威 望:3
帖 子:274
专家分:0
注 册:2006-4-3
收藏
得分:0 
的确太长了拉
for i=0 to ubound(ipstr)

下面分别用叔祖里的四个做判断是否在10-10,0-68,0-63,0-255
if then
if then
check(i)=true
checkip=true
exit for
else
禁止访问

欢迎大家访问我的网站 www. 域名代理网站 web.
2006-07-31 09:24
快速回复:限制IP访问ASP页面代码应该写在什么位置?
数据加载中...
 
   



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

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