哪位达人能给段代码!

jtnwl 2009-02-27 03:30:37
现在想给特定版块增加IP限制。

原则是 所有IP都被禁止,只有特定IP段可以访问。

IP段不只是一段,也就是说 222.45.0.1 - 222.45.255.255 和 165.121.0.1 - 162.121.0.1 两个段都可以访问

哪位兄弟给段代码,谢谢了!
...全文
49 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
不耐烦 2009-02-27
  • 打赏
  • 举报
回复
<%
private function getIP()
dim strIPAddr
if Request.ServerVariables("HTTP_X_FORWARDED_FOR") = "" or instr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), "unknown") > 0 then
strIPAddr = Request.ServerVariables("REMOTE_ADDR")
elseif instr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",") > 0 then
strIPAddr = mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, instr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",") -1)
elseif instr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";") > 0 then
strIPAddr = mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, instr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";") -1)
else
strIPAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
end if
getIP = trim(mid(strIPAddr, 1, 30))
end function
a=split(getIP,".")
if a(0)<>"222" or a(1)<>"45" then
response.Write"禁止访问"
response.End()
end if
'因为后2段都是255了 就不必判读了
'第2个判断
if a(0)<161 and a(0)>166 and a(1)<>"121" and a(2)<>"0" and a(3)<>"1" then
response.Write"禁止访问"
response.End()
end if
%>
  • 打赏
  • 举报
回复
晕死,这个不是简单吗?

if instr(str,"222.45.")>0 then

end if

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧