if ($sort['direction'] == "asc") { $sort['directionNext'] = "desc"; } else { $sort['directionNext'] = "asc"; } # subnet-related variables $subnet = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']); //subnet details $subnet_detailed = $Subnets->get_network_boundaries($subnet['subnet'], $subnet['mask']); //set network boundaries $slaves = $Subnets->has_slaves($subnet['id']) ? true : false; //check if subnet has slaves and set slaves flag true/false # fetch all addresses - sorted if ($slaves) { $addresses = $Addresses->fetch_subnet_addresses_recursive($subnet['id'], false, $sort['field'], $sort['direction']); $slave_subnets = (array) $Subnets->fetch_subnet_slaves($subnet['id']); } else { $addresses = $Addresses->fetch_subnet_addresses($subnet['id'], $sort['field'], $sort['direction']); } # set permissions $subnet_permission = $Subnets->check_permission($User->user, $subnet['id']); } # We need DNS object $DNS = new DNS($Database, $User->settings); /* verifications */ # checks if (sizeof($subnet) == 0) { $Result->show("danger", _('Subnet does not exist'), true); } //subnet doesnt exist if ($subnet_permission == 0) {
} elseif (!isset($out)) { print "<hr>"; print "<blockquote style='margin-top:20px;margin-left:20px;'>"; print "<p>" . _("No subnet selected for threshold check available") . "</p>"; print "<small>" . _("No subnet with threshold check available") . "</small>"; print "</blockquote>"; } else { print "<div class='hContent' style='padding:10px;'>"; // count usage foreach ($out as $k => $s) { //check if subnet has slaves and set slaves flag true/false $slaves = $Subnets->has_slaves($s->id) ? true : false; # fetch all addresses and calculate usage if ($slaves) { $addresses = $Addresses->fetch_subnet_addresses_recursive($s->id, false); $slave_subnets = (array) $Subnets->fetch_subnet_slaves($s->id); // save count $addresses_cnt = gmp_strval(sizeof($addresses)); # full ? if (sizeof($slave_subnets) > 0) { foreach ($slave_subnets as $ss) { if ($ss->isFull == 1) { # calculate max $max_hosts = $Subnets->get_max_hosts($ss->mask, $Subnets->identify_address($ss->subnet), true); # count $count_hosts = $Addresses->count_subnet_addresses($ss->id); # add $addresses_cnt = gmp_strval(gmp_add($addresses_cnt, gmp_sub($max_hosts, $count_hosts))); } } }