设置首页  |   加入收藏  |  联系我们   
您的位置: 主页>程序设计>ASP>正文
利用ASP代码实现对 IP 的访问限制
文章来源:  编辑:  发布时间:2007-11-27

这是以前用ASP写的,本想改成ASP.net的给大家,后来想大家能看懂算法就行了。IP比对的关键是IP地址的线性化,下面就是代码。

'可以进入的ip 
'218.7.44.0 - 218.7.45.253 
'61.180.240.0 - 61.180.240.253 
 
'202.118.208.0 - 202.118.223.253 
' 
'218.7.44.0 3657903103 
'218.7.45.253 3657903612 
' 
'61.180.240.0 1035268095 
'61.180.240.253 1035268348 
' 
'202.118.208.0 3396784127 
'202.118.223.253 3396788220 


ip=request.servervariables("remote_addr") 
sip=split(ip,".") 
num=cint(sip(0))*256*256*256+cint(sip(1))*256*256+ 

cint(sip(2))*256+cint(sip(3))-1 
response.write(ip) 
response.write("<br>") 
if ((num>=3657903103 and num<=3657903612) or   
(num>=1035268095 and num<=1035268348) 
or (num>=3396784127 and num<=3396788220)) then 
response.write("抱歉,您的ip不合法!") 
response.End() 
else 
response.write("您的ip合法") 
end if  




 
Tags:访问 限制 实现 代码 利用 quot ip sip response.write
Google
 
上一篇: 更正确的asp冒泡排序   下一篇: 用ASP打造一个小型的网页BBS系统
【返回顶部】 【打印】 【大】 【中】 【小】 【关闭】

 我来说两句
用户名: 新注册) 密码: 匿名评论 [论坛讨论]
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 相关文章
 热门文章

 
版权所有  2005-2006  Linux集中营  闽ICP备07500055号