Just Checking
Posted: Mon Nov 21, 2005 12:02 pm
I want to block out people from getting into an admin area. I would like to do this by using ip addresses and ranges. I wrote the following code and it works, but I just want to make sure its done correctly (or if there is a better way maybe).
Thanks
Code: Select all
$ips = array('192.168.15.1', '192.168.20', '192.168.19.55');
if(isset($ips) && is_array($ips)) {
$ip_check = implode('|^',$ips);
if (!preg_match("/^".$ip_check."/",$_SERVER['REMOTE_ADDR']))
{
die('Invalid IP<br />Access denied');
}
}