用户登陆|用户注册|建站服务|广告合作
您现在的位置: 首页 >> 建站实务 >> 网络编程 >> ASP篇 >> 正文
站内搜索:
asp中对ip进行过滤限制函数
[作者:佚名|来源:赛酷建站|时间:2006-08-20| 收藏 投稿 ]【

〈% 
  ’获取访问者的地址 
  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 "IP地址段出错!" 
  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 
  %〉


Tags:
最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
快速注册通道
赛酷网·中国西部第一建站门户
关于我们 | 投稿指南 | 广告服务 | 建站服务 | 联系我们 | 网站地图 | 友情连接 | 诚征英才
地址:中国·昆明盘龙区丽水天锦A栋15楼A06 服务热线:0871-5610002 5732371联系我55693344 联系我80796509
建站交流群:17577271 下载交流群:11885804 22003060 35468519 交流论坛
© CopyRight 2005-2007, Syku.Net, Inc. All Rights Reserved
赛酷网络版权所有 滇ICP备05000398号