<select name="subnet" class="selectpicker" data-style="btn-default" data-width="auto" data-size="10" dataid="subnet"><?php for ($i = 32; $i > 0; $i--):?> <option value="<?=$i;?>" <?=$i == $pconfig['subnet'] ? "selected=\"selected\"" : "";?>><?=$i;?></option><?php endfor;?></select>
<?php for ($i = 32; $i > 0; $i--):?>
<?php endfor;?>
<?phpfunction ipv4cidr2subnet($cidr) { static $max_ip; if (!isset($max_ip)) $max_ip = ip2long('255.255.255.255'); if ($cidr < 0 || $cidr > 32) return NULL; $subnet_long = $max_ip << (32 - $cidr); return long2ip($subnet_long);}
<?phpfunction ipv4_cidr_subnets() { static $subnets = []; if (empty($subnets)) { $max_ip = ip2long('255.255.255.255'); for ($i = 0; $i <= 32; $i++) $subnets[$i] = long2ip($max_ip << (32 - $i)); } return $subnets;}
<?php for ($i = 32; $i > 0; $i--):?><option value="<?=$i;?>" <?=$i == $pconfig['subnet'] ? "selected=\"selected\"" : "";?>> <?= ipv4cidr2subnet($i);?> ( /<?= $i;?> )</option> <?php endfor;?>