网络实验室

 找回密码
 注册账户
查看: 2024|回复: 0

禁止IP 的PHP代码共享

[复制链接]
无心的棋子 发表于 2007-8-24 00:36:45 | 显示全部楼层 |阅读模式
禁止IP 的PHP代码共享

It is one of the effective code for banning the IP address from your website.
Just paste the codeinto your PHP page.


PHP Code:
  1. <?php
  2. // This will retrieve ip!
  3. $ip = getenv('REMOTE_ADDR');
  4. // Replace 'x' with ip address!
  5. $blocked = "xx.xx.xx.xx";

  6. if (ereg($blocked,$ip))
  7. {
  8. echo "You Have Been Banned";
  9. exit();
  10. }
  11. ?>
复制代码

'echo "You Have Been Banned";' <-- this is the message which will be displayed when the banned ip goes on the page.

Remember to swap the x's with the IP you wish to ban.
您需要登录后才可以回帖 登录 | 注册账户

本版积分规则

黑屋|存档|手机|网络实验室 本站服务器由美国合租以及IDCLayer国际数据提供!!!

GMT+8, 2024-5-6 18:59 , Processed in 0.103167 second(s), 8 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表