I bump into a problem when I need to filter my application to be accessed from certain IP only. So, some googling around, i found s simple code to do this.
$targetAddr = "192.168.1..*";
if (ereg($targetAddr, $_SERVER['REMOTE_ADDR'])) {
echo "";
} else {
die("Sorry. Not allowed from your IP.");
}
This simple script will allow only IP that comes from 192.168.1.*, and will block all other IPs. You might want to put this in a file, and include it in all other code files.
Happy coding!
No related posts.




0 Responses to “filter by IP using PHP”
Please Wait
Leave a Reply