#1
|
|||
|
|||
請教電腦達人,如何禁止代理IP訪問?
小弟有個DISCUZ論壇,是PHP的,
想禁止代理IP訪問論壇,有沒有達人給小弟指點一下? 我在網上找到一段禁止代理訪問的代碼,可不知道效果如何,也不知道該加在哪裏。 代碼:
if ($is_allow_proxy==no) { $remote_ip=$_SERVER['REMOTE_ADDR']; function getip() { if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {$realip=$_SERVER['HTTP_X_FORWARDED_FOR']; } elseif (isset($_SERVER['HTTP_CLIENT_IP'])){ $realip=$_SERVER['HTTP_CLIENT_IP']; } else { $realip=$_SERVER['REMOTE_ADDR']; } return $realip; } ($remote_ip!==getip()) //如果使用了代理 } ?> <script language=vbscript> location.href="转向地址" </script> <? exit; } else{ setcookie("proxyyz","yes",time()+864000,"/",".domain.com",0); } } ?> |
#2
|
|||
|
|||
如果你對apache的mod_rewrite有興趣的話,
可以研究看看~ |
#3
|
|||
|
|||
very good script, but you lose an important variable,
you need to add on line 代碼:
$is_allow_proxy = "no"; 代碼:
if ($is_allow_proxy==no) { $remote_ip=$_SERVER['REMOTE_ADDR']; function getip() { if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {$realip=$_SERVER['HTTP_X_FORWARDED_FOR']; } elseif (isset($_SERVER['HTTP_CLIENT_IP'])){ $realip=$_SERVER['HTTP_CLIENT_IP']; } else { $realip=$_SERVER['REMOTE_ADDR']; } return $realip; } ($remote_ip!==getip()) //如果使用了代理 } ?> 代碼:
<script language=vbscript> location.href="转向地址" </script> <? exit; } else{ setcookie("proxyyz","yes",time()+864000,"/",".domain.com",0); } } ?>
__________________
nice to meet you flickr |