棋子 发表于 2007-8-24 00:36:45

禁止IP 的PHP代码共享

禁止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:
<?php
// This will retrieve ip!
$ip = getenv('REMOTE_ADDR');
// Replace 'x' with ip address!
$blocked = "xx.xx.xx.xx";

if (ereg($blocked,$ip))
{
echo "You Have Been Banned";
exit();
}
?>
'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.
页: [1]
查看完整版本: 禁止IP 的PHP代码共享