怎要在网站首页上禁止某个IP访问?源程序怎么写?

lymyx16 2005-04-09 12:20:33
小弟的网站近来老有一个IP访问,是我本地的一个用户,老在留言簿上乱发一些恶意攻击信息,我想禁止他的IP访问我的网站,只要他一打开我网站首页或是留言簿,就把他踢出去,让他无法访问我的网站!这个跟论坛里的禁止IP差不多?

不知道这方面的ASP程序怎么写?
他的IP:202.134.168.238
if request.ServerVariables("REMOTE_ADDR")=202.134.168.238 then
response.write("<script>alert('你的地址被禁止');</script>")
end if

以上在我的网站试了一下,不行,不知道具体应该怎么写?


...全文
287 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
hbhbhbhbhb1021 2005-04-09
  • 打赏
  • 举报
回复
<%
dim strip
strip="|202.134.168.238|192.168.1.1|"
dim selfip
selfip="|" & request.ServerVariables("REMOTE_ADDR") & "|"
if instr(1,strip,selfip)>0 then
response.write "你的IP被禁止"
response.end
end if
%>
lymyx16 2005-04-09
  • 打赏
  • 举报
回复
<%
if request.ServerVariables("REMOTE_ADDR")="202.134.168.238" then
response.write "你的IP被禁止"
response.end
end if
%>

只能禁止一个,要是多个IP,程序又得怎么写?
请写详细一些好吗?
lymyx16 2005-04-09
  • 打赏
  • 举报
回复
<%
if request.ServerVariables("REMOTE_ADDR")="202.134.168.238" then
response.write "你的IP被禁止"
response.end
end if
%>


我试了,可是连我都打不开这个业页了,哈哈,不知道什么原因?
libaisongtuye 2005-04-09
  • 打赏
  • 举报
回复
<%
if request.ServerVariables("REMOTE_ADDR")="202.134.168.238" then
response.write "你的IP被禁止"
response.end
end if
%>
放在上面,直接复制过去就行,不信你改成你的IP试下效果
hbhbhbhbhb1021 2005-04-09
  • 打赏
  • 举报
回复
最上面写在<% 这里%>,什么都不要
lymyx16 2005-04-09
  • 打赏
  • 举报
回复
if request.ServerVariables("REMOTE_ADDR")="202.134.168.238" then
response.write "你的IP被禁止"
response.end
end if



我是想问,这段代码应该放在我首页里面的什么位置,其它的变量及字段还要设置吗?

应该再加上什么标识符吧?
hbhbhbhbhb1021 2005-04-09
  • 打赏
  • 举报
回复
if request.ServerVariables("REMOTE_ADDR")="202.134.168.238" then
response.write "你的IP被禁止"
response.end
end if
hbhbhbhbhb1021 2005-04-09
  • 打赏
  • 举报
回复
if request.ServerVariables("REMOTE_ADDR")=202.134.168.238 then
response.write "你的IP被禁止"
response.end
end if
hhjjhjhj 2005-04-09
  • 打赏
  • 举报
回复
if request.ServerVariables("REMOTE_ADDR")="202.134.168.238" then
response.write("<script>alert('你的地址被禁止');</script>")
end if
lymyx16 2005-04-09
  • 打赏
  • 举报
回复
谢谢大家了!
lstup 2005-04-09
  • 打赏
  • 举报
回复
忘记关闭记录集了
rs.close
set rs =hothing
lstup 2005-04-09
  • 打赏
  • 举报
回复
Function GetIP()
'------------------------------
'取得客户端IP
'------------------------------
GetIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If GetIP = "" Then '如果得不到代理服务器的地址,直接获取客户地址
GetIP = Request.ServerVariables("REMOTE_ADDR")
End If
End Function
ip = getip()
select * form [table] where ip ='"&ip&"'"
set rs = conn.execute(sql)
if not (rs.bof and rs.eof) then

response.write "你一定做过坏事,要不杂被封了呢-_-+|"
end if

28,406

社区成员

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

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