[4.5] Fix Wrong CIDR

This commit is contained in:
FusionPBX 2020-12-14 18:11:09 -07:00 committed by GitHub
commit 74a55f3de2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 0 deletions

View File

@ -133,6 +133,24 @@
$voicemail_id = null;
}
$cidrs = preg_split("/[\s,]+/", $cidr);
$ips = array();
foreach ($cidrs as $ipaddr){
$cx = strpos($ipaddr, '/');
if ($cx){
$subnet = (int)(substr($ipaddr, $cx+1));
$ipaddr = substr($ipaddr, 0, $cx);
}
else{
$subnet = 32;
}
if(($addr = inet_pton($ipaddr)) !== false){
$ips[] = $ipaddr.'/'.$subnet;
}
}
$cidr = implode(',',$ips);
//change toll allow delimiter
$toll_allow = str_replace(',',':', $toll_allow);