rendered paste body function cidr_to_ip($cidr_address) {
$first = substr($cidr_address, 0, strpos($cidr_address, "/"));
$netmask = substr(strstr($cidr_address, "/"), 1);
$first_bin = str_pad(decbin(ip2long($first)), 32, "0", STR_PAD_LEFT);
$netmask_bin = str_pad(str_repeat("1", (integer)$netmask), 32, "0", STR_PAD_RIGHT);
for ($i = 0; $i < 32; $i++) {
if ($netmask_bin[$i] == "1") {
$last_bin .= $first_bin[$i];
$firstfixed_bin .= $first_bin[$i];
} else {
$last_bin .= "1";
$firstfixed_bin .= "0";
}
}
$firstfixed = long2ip(bindec($firstfixed_bin));
$last = long2ip(bindec($last_bin));
return (array($firstfixed,$last));
}