Is it possible to ban local IPs?!
Moderator: General Moderators
-
Black Majin
- Forum Newbie
- Posts: 22
- Joined: Wed Jul 16, 2003 12:51 pm
- Location: Garland, Texas
Is it possible to ban local IPs?!
<?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!!
$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!!
Code: Select all
<?php
$ip = $_SERVER["REMOTE_ADDR"];
if ($ip == "the ip of the machine") {
echo "banned";
}
?>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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
Black Majin
- Forum Newbie
- Posts: 22
- Joined: Wed Jul 16, 2003 12:51 pm
- Location: Garland, Texas
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.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.
Feyd's article : http://www.javascriptkit.com/howto/htaccess5.shtml