Page 1 of 1

Is it possible to ban local IPs?!

Posted: Wed Aug 18, 2004 4:35 pm
by Black Majin
<?php
$banned_ip = array();
$banned_ip[] = '65.65.82.217';

foreach($banned_ip as $banned) {
$ip = $_SERVER['REMOTE_ADDR'];
if($ip == $banned){
echo "You are banned. Now how do you like dem apples.";
exit();
}
}
?>

I put that at the top of the page after the HTML tag. It works just fine. But for various reasons, I'd like to ban somone in my household from going to my site without banning my computer also. So is there a way to do this? I tried just putting in the local IP for his computer but it didnt work. Help!!

Posted: Wed Aug 18, 2004 5:06 pm
by tim

Code: Select all

<?php
$ip = $_SERVER["REMOTE_ADDR"];

if ($ip == "the ip of the machine") {
echo "banned";
}
?>
hmm, maybe i'm missing something?

Posted: Wed Aug 18, 2004 5:13 pm
by pickle
Is the setup such that both computers access the internet through a router/switch? If so, there's no way to do what you want, since neither of your computers are going out on the internet, the router's going out for you. So, both your and the other computer will have the same IP.

Posted: Wed Aug 18, 2004 5:30 pm
by m3mn0n
User authentication is a good solution.

Posted: Wed Aug 18, 2004 5:36 pm
by Black Majin
pickle wrote:Is the setup such that both computers access the internet through a router/switch? If so, there's no way to do what you want, since neither of your computers are going out on the internet, the router's going out for you. So, both your and the other computer will have the same IP.
But isnt there like a way I can make it so it will find the internet IP AND the local IP so I can ban my internet IP but only my brothers local IP from his computer. Come on theres gotta be a way.

Posted: Wed Aug 18, 2004 6:01 pm
by m3mn0n
Sami wrote:User authentication is a good solution.
That's a way. 8)

Posted: Wed Aug 18, 2004 6:04 pm
by qads
or just check the ip, if it is yours, then ask for a secret key to load the site :D

Posted: Wed Aug 18, 2004 9:42 pm
by anjanesh

Posted: Wed Aug 18, 2004 9:58 pm
by feyd
pssst, that's not actually mine ;) .. just another Dune lover, I guess.. :lol: