allow ip range

Hi Guys

Thank you for any help in advange. Im new to PHP

I need to allow a range of IP.

I have this working for a list of IP

PHP Code:

[php]
// Only allow access from specific ips

$allowed_ips_array = array(

‘xxx.xx.xxx.x’,

‘xx.xx.xxx.x’,

‘xx.xx.xxx.x’);

if(!isset($_SERVER[‘HTTP_X_FORWARDED_FOR’])){

$client_ip = $_SERVER[‘REMOTE_ADDR’];}

else{

$client_ip = $_SERVER[‘HTTP_X_FORWARDED_FOR’];}

if(!in_array($client_ip, $allowed_ips_array)){

echo(‘Sorry, No Access…’);

exit;}
[/php]

I need to add I.P ranges
I tried to add the ranges into the array like
PHP Code:
[php]

‘xx.xx.xx.x/29’,

‘xx.xx.xx.xxx/29’,

‘xx.xxx.xxx.xxx/32’);
[/php]

but this does not work. So i guess you cant add IP range this?

Sponsor our Newsletter | Privacy Policy | Terms of Service