Asp实现禁止IP访问代码

function banip(ip)
banips="221.204.*.*|118.74.*.*"
str=split(banips,"|")
ipstr=split(ip,".")
for i=lbound(str) to ubound(str)
 ban=true
 str2=split(str(i),".")
 for j=lbound(str2) to ubound(str2)
  if str2(j)<>ipstr(j) and str2(j)<>"*" then
  ban=false
  end if
 next
 if ban=true then
 banip=ban
 exit function
 end if
next
end function

使用示例:
ip="59.49.78.57"
if banip(ip)=true then
response.Write("IP被禁止访问!")
response.End()
end if

www.tianzhigang.com原创代码,转载请注明出处!



评论: 0 | 引用: 0 | 查看次数: 2441
发表评论
昵 称:
密 码: 游客发言不需要密码.
邮 箱: 邮件地址支持Gravatar头像,邮箱地址不会公开.
网 址: 输入网址便于回访.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 1000 字 | UBB代码 开启 | [img]标签 关闭

 广告位

↑返回顶部↑