I'm currently using some custom code to filter out IP addresses on a Magento store so I can access it whilst in development (maintenance mode).
My current code works fine except it's only for singular IP addresses added to an array.
How would I be best altering this to include cidr format addresses?
My current code is as follows:
$ip = $_SERVER['REMOTE_ADDR'];
$allowed = array('81.155.118.210','86.136.148.200'); // these are the IP's that are allowed to view the site.
and then further down
if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) {
include_once dirname(__FILE__) . '/errors/503.php';
exit;
}
I would like to be able to use IP addresses such as 195.170.169.0/255 so that I don't have to add them all in singular format however I'm unsure on the best way to add cidr style IP addresses to the array?
Can someone please help?