$sort['direction'] = $tmp[1]; 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
/** * Fetches changelog for addresses in subnet for all slave subnets * * @access public * @param mixed $subnetId * @param int $limit (default: 50) * @return void */ public function fetch_subnet_addresses_changelog_recursive($subnetId, $limit = 50) { # get all addresses ids $ips = array(); $Addresses = new Addresses($this->Database); $ips = $Addresses->fetch_subnet_addresses_recursive($subnetId, false); # fetch changelog for IPs if (sizeof($ips) > 0) { # query $query = "select\n\t\t \t\t\t`u`.`real_name`,`o`.`id`,`o`.`ip_addr`,`o`.`description`,`o`.`id`,`o`.`subnetId`,`c`.`caction`,`c`.`cresult`,`c`.`cdate`,`c`.`cdiff`\n\t\t\t\t\t\tfrom `changelog` as `c`, `users` as `u`, `ipaddresses` as `o`\n\t\t\t\t\t\twhere `c`.`cuser` = `u`.`id` and `c`.`coid`=`o`.`id`\n\t\t\t\t\t\tand ("; $args = array(); foreach ($ips as $ip) { $query .= "`c`.`coid` = ? or "; $args[] = $ip->id; } $query = substr($query, 0, -3); $query .= ") and `c`.`ctype` = 'ip_addr' order by `c`.`cid` desc limit {$limit};"; # fetch try { $logs = $this->Database->getObjectsQuery($query, array_filter($args)); } catch (Exception $e) { $this->Result->show("danger", $e->getMessage(), false); return false; } # return result return $logs; } else { return false; } }
print "</blockquote>"; } 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))); } }