新客网WWW.XKER.COM:致力做中国最专业的网络学院!
学院: 操作系统 - 网络应用 - 服务器 - 网络安全 - 工具软件 - 办公软件 - Web开发 - 数据库 - 网页设计 - 图形图像 - 媒体动画 - 硬件学堂 - 存储频道 - QQ专区
您的位置:首页 > 软件开发 > Web开发 > Asp教程 > 正文:限制某段IP地址

限制某段IP地址

新客网 XKER.COM 2005-09-14 来源: 收藏本文

function IP2Num(sip)
 dim str1,str2,str3,str4
 dim num
 IP2Num=0
 if isnumeric(left(sip,2)) then
  str1=left(sip,instr(sip,".")-1)
  sip=mid(sip,instr(sip,".")+1)
  str2=left(sip,instr(sip,".")-1)
  sip=mid(sip,instr(sip,".")+1)
  str3=left(sip,instr(sip,".")-1)
  str4=mid(sip,instr(sip,".")+1)
  num=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
  IP2Num = num
 end if
end function

function Num2IP(nip)
 iip1 = int(nip/256/256/256)
 iip2 = int((nip-iip1*256*256*256)/256/256)
 iip3 = int((nip-iip1*256*256*256-iip2*256*256)/256)
 iip4 = int((nip-iip1*256*256*256-iip2*256*256-iip3*256) mod 256)
 iip0 = iip1 &"."& iip2 & "." &iip3 &"."& iip4
 Num2IP = iip0
end function

userIPnum = IP2Num(Request.ServerVariables("REMOTE_ADDR"))

if userIPnum > IP2Num("192.168.0.0") and userIPnum < IP2Num("192.168.0.255") then
 response.write ("<center>您的IP被禁止</center>")
 response.end
end if

收藏】 【评论】 【推荐】 【投稿】 【打印】 【关闭
发表评论
要记得去论坛讨论,点击注册新会员匿名评论
评论内容:不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
阅读排行
随机推荐
实用信息推荐