It is one of the effective code for banning the IP address from your website.
Just paste the codeinto your PHP page.
[PHP]<?php
// This will retrieve ip!
$ip = getenv('REMOTE_ADDR');
// Replace 'x' with ip address!
$blocked = "****.****.****.****";
if (ereg($blocked,$ip))
{
echo "You Have Been Banned";
exit();
}
?>[/PHP]
'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.
(PHP) Ban Ip From Your Site
It is better to use this instead:
I read this somewhere on php.net.
Code: Select all
$_SERVER['REMOTE_ADDR']
php
Yeah php is pretty good but i prefer java
.............................:: Spirit of Fire ::..................................
Could be really uesful, possible to add more IP's?
$blocked = "****.****.****.****, ****.****.****.****";
Or will you get an error ?
$blocked = "****.****.****.****, ****.****.****.****";
Or will you get an error ?
Tired of Newbies asking Questions? Tell them www.UseGoogleFFS.com
So that wont work then? :OTails5 wrote:You'd have to define an array for that, and do a while loop to check if the IP is banned.
Tired of Newbies asking Questions? Tell them www.UseGoogleFFS.com
Oh alright, Im glad I could come up with that idea, I just started to learn phpTails5 wrote:Sure it'll work, it'll just be more complex...
Tired of Newbies asking Questions? Tell them www.UseGoogleFFS.com