# folder? if ($master_subnet['isFolder'] == 1) { $master_text = "<i class='fa fa-folder-o fa fa-gray'></i> {$master_subnet['description']}"; } else { $master_text = "{$master_subnet['ip']}/{$master_subnet['mask']}"; } } //tr print '<tr class="subnetSearch" subnetId="' . $line['id'] . '" sectionName="' . $section['name'] . '" sectionId="' . $section['id'] . '" link="' . $section['name'] . '|' . $line['id'] . '">' . "\n"; //section print ' <td>' . $section['name'] . '</td>' . "\n"; //folder? if ($line['isFolder'] == 1) { print ' <td><a href="' . create_link("subnets", $line['sectionId'], $line['id']) . '"><i class="fa fa-folder-o fa fa-gray"></i> ' . $line['description'] . '</a></td>' . "\n"; } else { print ' <td><a href="' . create_link("subnets", $line['sectionId'], $line['id']) . '">' . $Subnets->transform_to_dotted($line['subnet']) . '/' . $line['mask'] . '</a></td>' . "\n"; } print ' <td><a href="' . create_link("subnets", $line['sectionId'], $line['id']) . '">' . $line['description'] . '</a></td>' . "\n"; //master print ' <td>' . $master_text . '</td>' . "\n"; //vlan print ' <td>' . @$vlan['number'] . '</td>' . "\n"; //requests print ' <td>' . _($line['allowRequests']) . '</td>' . "\n"; # custom fields if (sizeof($custom_subnet_fields) > 0) { foreach ($custom_subnet_fields as $field) { if (!in_array($field['name'], $hidden_subnet_fields)) { $line[$field['name']] = $Result->create_links($line[$field['name']], $field['type']); print "\t<td class='hidden-xs hidden-sm'>" . $line[$field['name']] . "</td>"; }
print _('Truncate subnet'); ?> </div> <!-- content --> <div class="pContent"> <table class="table table-noborder table-condensed"> <!-- subnet --> <tr> <td class="middle"><?php print _('Subnet'); ?> </td> <td><?php print $Subnets->transform_to_dotted($subnet->subnet) . "/{$subnet->mask} ({$subnet->description})"; ?> </td> </tr> <!-- Mask --> <tr> <td class="middle"><?php print _('Number of IP addresses'); ?> </td> <td><?php print $Addresses->count_subnet_addresses($subnet->id); ?> </td> </tr> </table>
# format and verify each record foreach ($allSubnets as $subnet) { //get sequential number $m = str_replace("subnet-", "", $subnet); //reformat subnet $_temp = explode("/", $_POST['subnet-' . $m]); //set subnet details for importing $subnet_import['subnet'] = $Subnets->transform_to_decimal($_temp[0]); $subnet_import['mask'] = $_temp[1]; $subnet_import['sectionId'] = $_POST['section-' . $m]; $subnet_import['description'] = $_POST['description-' . $m]; $subnet_import['vlanId'] = $_POST['vlan-' . $m]; $subnet_import['vrfId'] = $_POST['vrf-' . $m]; $subnet_import['showName'] = $_POST['showName-' . $m]; //cidr if (strlen($err = $Subnets->verify_cidr($Subnets->transform_to_dotted($subnet_import['subnet']) . "/" . $subnet_import['mask'])) > 5) { $errors[] = $err; } else { if (strlen($err = $Subnets->verify_subnet_overlapping($subnet_import['sectionId'], $Subnets->transform_to_dotted($subnet_import['subnet']) . "/" . $subnet_import['mask'], $subnet_import['vrfId'])) > 5) { $errors[] = $err; } else { $subnets_to_insert[] = $subnet_import; } } } # print errors if they exist or success if (isset($errors)) { print '<div class="alert alert-danger alert-absolute">' . _('Please fix the following errors before inserting') . ':<hr>' . "\n"; foreach ($errors as $line) { print $line . '<br>'; }
print "\t<td colspan='{$colspan['unused']}' class='unused'>{$unused['ip']} ({$unused['hosts']})</td>"; print "</tr>"; } } # # print IP address # # ip - range if (@$addresses[$n]->class == "compressed-range") { print "<tr class='dhcp'>"; print "\t<td>"; # status icon if ($subnet['pingSubnet'] == "1") { print "\t\t<span class='status status-padded'></span>"; } print $Subnets->transform_to_dotted($addresses[$n]->ip_addr) . ' - ' . $Subnets->transform_to_dotted($addresses[$n]->stopIP) . " (" . $addresses[$n]->numHosts . ")"; print $Addresses->address_type_format_tag($addresses[$n]->state); print "\t</td>"; print "\t<td>" . $Addresses->address_type_index_to_type($addresses[$n]->state) . " (" . _("range") . ")</td>"; print "\t<td>" . $addresses[$n]->description . "</td>"; if ($colspan['dhcp'] != 0) { print "\t<td colspan='{$colspan['dhcp']}' class='unused'></td>"; } // tr ends after! } else { print "<tr>"; # status icon if ($subnet['pingSubnet'] == "1") { //calculate $tDiff = time() - strtotime($addresses[$n]->lastSeen); if ($addresses[$n]->excludePing == "1") {
$i = 1; foreach ($firewallZone->network as $network) { print '<tr>'; if ($i === 1) { print '<td rowspan="' . $rowspan . '" style="width:150px;vertical-align:top">Networks</td>'; } print '<td>'; print '<a class="btn btn-xs btn-danger editNetwork" style="margin-right:5px;" alt="' . _('Delete Network') . '" title="' . _('Delete Network') . '" data-action="delete" data-zoneId="' . $firewallZone->id . '" data-subnetId="' . $network->subnetId . '">'; print '<span><i class="fa fa-close"></i></span>'; print "</a>"; if ($network->subnetIsFolder == 1) { print 'Folder: ' . $network->subnetDescription . '</td>'; } else { # display network information with or without description if ($network->subnetDescription) { print $Subnets->transform_to_dotted($network->subnet) . '/' . $network->subnetMask . ' (' . $network->subnetDescription . ')</td>'; } else { print $Subnets->transform_to_dotted($network->subnet) . '/' . $network->subnetMask . '</td>'; } } print '</tr>'; $i++; } } ?> </table> </div> </form>
} $query[] = 'order by `ip_addr` ASC;'; //join $query = implode("\n", $query); } # fetch records $ipaddresses = $Database->getObjectsQuery($query); # try to update dns records foreach ($ipaddresses as $ip) { # fetch subnet $subnet = $Subnets->fetch_subnet("id", $ip->subnetId); $nsid = $subnet === false ? false : $subnet->nameserverId; # try to resolve $hostname = $DNS->resolve_address($ip->ip_addr, null, true, $nsid); # update if change if ($hostname['name'] != $Subnets->transform_to_dotted($ip->ip_addr)) { # values $values = array("dns_name" => $hostname['name'], "id" => $ip->id); # execute if (!$Admin->object_modify("ipaddresses", "edit", "id", $values)) { $Result->show_cli("Failed to update address " . $Subnets->transform_to_dotted($ip->ip_addr)); } # set text $res[] = 'updated ip address ' . $Subnets->transform_to_dotted($ip->ip_addr) . ' with hostname ' . $hostname['name']; } } # if verbose print result so it can be emailed via cron! if ($resolve_config['verbose'] == 1) { foreach ($res as $line) { print $line . "\n"; }
<div class="pContent"> <form id="editSubnetDetails"> <table class="editSubnetDetails table table-noborder table-condensed"> <!-- name --> <tr> <td class="middle"><?php print _('Subnet'); ?> </td> <td> <?php # set CIDR if (isset($subnet_old_temp['subnet'])) { $cidr = $Subnets->transform_to_dotted($subnet_old_temp['subnet']) . '/' . ($subnet_old_temp['mask'] + 1); } //for nested if (@$_POST['location'] == "ipcalc") { $cidr = $_POST['subnet'] . '/' . $_POST['bitmask']; } //from ipcalc if ($_POST['action'] != "add") { $cidr = $Subnets->transform_to_dotted($subnet_old_details['subnet']) . '/' . $subnet_old_details['mask']; } //editing existing ?> <input type="text" class="form-control input-sm input-w-200" name="subnet" placeholder="<?php print _('subnet in CIDR'); ?> " value="<?php
if (!is_numeric($_POST['subnetId'])) { $Result->show("danger", _("Invalid ID"), true, true); } # get subnet details $subnet = $Subnets->fetch_subnet(null, $_POST['subnetId']); # verify that user has write permissions for subnet $subnetPerm = $Subnets->check_permission($User->user, $subnet->id); if ($subnetPerm < 3) { $Result->show("danger", _('You do not have permissions to resize subnet') . '!', true, true); } # check if it has slaves - if yes it cannot be splitted! if ($Subnets->has_slaves($subnet->id)) { $Result->show("danger", _('Only subnets that have no nested subnets can be splitted') . "!", true, true); } # calculate max mask $max_new_mask = $Subnets->identify_address($Subnets->transform_to_dotted($subnet->subnet)) == "IPv4" ? 32 : 128; # die if too small if ($max_new_mask < $subnet->mask) { $Result->show("danger", _("Subnet too small to be splitted"), true, true); } $n = 2; # step $m = 0; # array id //set mask options for ($mask = $subnet->mask + 1; $mask <= $max_new_mask; $mask++) { # set vars $opts[$m]['mask'] = $mask; $opts[$m]['number'] = $n; $opts[$m]['max'] = $Subnets->get_max_hosts($mask, $Subnets->identify_address($Subnets->transform_to_dotted($subnet->subnet))); # next
} } /** * Select how to scan based on scan type. * * if ping/pear make threads, if fping than just check since it has built-in threading ! */ # fping if ($Scan->settings->scanPingType == "fping" && $argv[1] == "discovery") { # fetch subnet $subnet = $Subnets->fetch_subnet(null, $argv[2]); $subnet !== false ?: die(json_encode(array("status" => 1, "error" => "Invalid subnet ID provided"))); //set exit flag to true $Scan->ping_set_exit(false); # set cidr $subnet_cidr = $Subnets->transform_to_dotted($subnet->subnet) . "/" . $subnet->mask; # execute $retval = $Scan->ping_address_method_fping_subnet($subnet_cidr); # errors if ($retval == 3) { die(json_encode(array("status" => 1, "error" => "invalid command line arguments"))); } if ($retval == 4) { die(json_encode(array("status" => 1, "error" => "system call failure"))); } # parse result if (sizeof(@$Scan->fping_result) == 0) { die(json_encode(array("status" => 0, "values" => array("alive" => null)))); } else { //check each line foreach ($Scan->fping_result as $l) {
// columns if ($mapping->indicator == 0) { print '<td><span class="fa fa-home" title="' . _('Own Zone') . '"></span></td>'; } else { print '<td><span class="fa fa-group" title="' . _('Customer Zone') . '"></span></td>'; } print '<td>' . $mapping->zone . '</td>'; print '<td>' . $mapping->alias . '</td>'; print '<td>' . $mapping->description . '</td>'; print '<td>' . $mapping->interface . '</td>'; //print '<td>'.$Subnets->transform_to_dotted($mapping->subnet).'/'.$mapping->subnetMask.'</td>'; print '<td>'; // check if there is a subnetId and if it is convertable to dotted decimal if ($mapping->subnetId && $mapping->subnetDescription) { if (!$mapping->subnetIsFolder) { print '<a href="' . create_link("subnets", $mapping->sectionId, $mapping->subnetId) . '">' . $Subnets->transform_to_dotted($mapping->subnet) . '/' . $mapping->subnetMask . '</a>'; print '</td><td>'; print '<a href="' . create_link("subnets", $mapping->sectionId, $mapping->subnetId) . '">' . $mapping->subnetDescription . '</a>'; } else { print '<a href="' . create_link("subnets", $mapping->sectionId, $mapping->subnetId) . '">Folder</a>'; print '</td><td>'; print '<a href="' . create_link("subnets", $mapping->sectionId, $mapping->subnetId) . '">' . $mapping->subnetDescription . '</a>'; } } else { print '</td><td>'; } ?> </td> <td><a href="<?php create_link('tools', 'vlan', $mapping->domainId, $mapping->vlanId); ?>
$User->check_user_session(); //set filename $filename = "phpipam_hosts_" . date("Y-m-d"); //fetch all addresses with hostname set $hosts = $Tools->fetch_addresses_for_export(); //loop if (sizeof($hosts) > 0) { //details $m = 0; foreach ($hosts as $host) { //fetch subnet and section details on change! if (@$hosts[$m - 1]->subnetId != $hosts[$m]->subnetId) { $subnet = (array) $Subnets->fetch_subnet(null, $host->subnetId); $section = (array) $Sections->fetch_section(null, $subnet['sectionId']); //first print subnet and section details $res[] = "# {$subnet['description']} (" . $Subnets->transform_to_dotted($subnet['subnet']) . "/{$subnet['mask']}) - {$section['description']}"; } //than address details $diff = 17 - strlen($Subnets->transform_to_dotted($host->ip_addr)); //for print offset $diff > 0 ?: ($diff = 3); //IPv6 print offset $res[] = $Subnets->transform_to_dotted($host->ip_addr) . str_repeat(" ", $diff) . "{$host->dns_name}"; //break if ($hosts[$m]->subnetId != @$hosts[$m + 1]->subnetId) { $res[] = ""; } $m++; //next index } }
continue; } // grab IP addresses $ipaddresses = $Addresses->fetch_subnet_addresses($subnet['id']); if (sizeof($ipaddresses) == 0) { continue; } foreach ($ipaddresses as $ip) { //cast $ip = (array) $ip; if (isset($_GET['section']) && $_GET['section'] == "on") { $worksheet->write($lineCount, $rowCount, $section['name'], $format_text); $rowCount++; } if (isset($_GET['ip_addr']) && $_GET['ip_addr'] == "on") { $worksheet->write($lineCount, $rowCount, $Subnets->transform_to_dotted($ip['ip_addr']), $format_text); $rowCount++; } if (isset($_GET['dns_name']) && $_GET['dns_name'] == "on") { $worksheet->write($lineCount, $rowCount, $ip['dns_name'], $format_text); $rowCount++; } if (isset($_GET['description']) && $_GET['description'] == "on") { $worksheet->write($lineCount, $rowCount, $ip['description'], $format_text); $rowCount++; } if (isset($_GET['subnet']) && $_GET['subnet'] == "on") { $worksheet->write($lineCount, $rowCount, $subnet['ip'] . "/" . $subnet['mask'], $format_text); $rowCount++; } if (isset($_GET['state']) && $_GET['state'] == "on") {
print "\t<th>" . _('VLAN') . "</th>"; print "\t<th></th>"; print "</tr>"; # subnets foreach ($fsubnets as $f) { # must be either subnet or folder if (sizeof($f) > 0) { print "<tr class='favSubnet-{$f['subnetId']}'>"; if ($f['isFolder'] == 1) { $master = true; print "\t<td><a href='" . create_link("folder", $f['sectionId'], $f['subnetId']) . "'><i class='fa fa-sfolder fa-folder'></i> {$f['description']}</a></td>"; } else { //master? if ($Subnets->has_slaves($f['subnetId'])) { $master = true; print "\t<td><a href='" . create_link("subnets", $f['sectionId'], $f['subnetId']) . "'><i class='fa fa-sfolder fa-folder-o'></i>" . $Subnets->transform_to_dotted($f['subnet']) . "/{$f['mask']}</a></td>"; } else { $master = false; print "\t<td><a href='" . create_link("subnets", $f['sectionId'], $f['subnetId']) . "'><i class='fa fa-sfolder fa-sitemap' ></i>" . $Subnets->transform_to_dotted($f['subnet']) . "/{$f['mask']}</a></td>"; } } print "\t<td>{$f['description']}</td>"; print "\t<td><a href='" . create_link("subnets", $f['sectionId']) . "'>{$f['section']}</a></td>"; # get vlan info if (strlen($f['vlanId']) > 0 && $f['vlanId'] != 0) { $vlan = $Tools->fetch_object("vlans", "vlanId", $f['vlanId']); print "\t<td>{$vlan->number}</td>"; } else { print "\t<td>/</td>"; } # usage
<div class="pContent"> <!-- form --> <form id="networkEdit"> <!-- table --> <table class="table table-noborder table-condensed"> <?php if ($_POST['action'] == 'delete') { ?> <!-- delete warning and network information--> <tr> <td style="width:150px;"> <?php $subnet = $Subnets->fetch_subnet('id', $_POST['subnetId']); # display network information with or without description if ($subnet->description) { $network = $Subnets->transform_to_dotted($subnet->subnet) . '/' . $subnet->mask . ' (' . $subnet->description . ')'; } else { $network = $Subnets->transform_to_dotted($subnet->subnet) . '/' . $subnet->mask; } $Result->show("warning", "<strong>" . _('Warning') . ":</strong><br>" . _("You are about to remove the following Network from the firewall zone:<br>" . $network), false); ?> <input type="hidden" name="masterSubnetId" value="<?php print $_POST['subnetId']; ?> "> </td> <?php } else { # add a network to the zone ?> <tr>
$Result->show("danger", _("Temporary sharing disabled"), true, true); } if ($_POST['type'] != "subnets" && $_POST['type'] != "ipaddresses") { $Result->show("danger", _("Invalid type"), true, true); } if (!is_numeric($_POST['id'])) { $Result->show("danger", _("Invalid ID"), true, true); } //fetch object details $object = $Tools->fetch_object($_POST['type'], "id", $_POST['id']); # set share details $share = new StdClass(); //set details if ($_POST['type'] == "subnets") { $tmp[] = "Share type: subnet"; $tmp[] = $Subnets->transform_to_dotted($object->subnet) . "/{$object->mask}"; $tmp[] = $object->description; } else { $tmp[] = "Share type: IP address"; $tmp[] = $Subnets->transform_to_dotted($object->ip_addr); $tmp[] = $object->description; } $share->details = implode("<br>", $tmp); //set code and timeframe @($share->code = md5(time())); $share->validity = date("Y-m-d H:i:s", strtotime("+1 day")); # set url for printing $url = $Result->createURL() . create_link("temp_share", $share->code); ?>
<div class="pContent editIPAddress"> <form name="requestIP" id="requestIP"> <table id="requestIP" class="table table-condensed"> <tr> <td><?php print _('IP address'); ?> *</td> <td> <?php require_once '../../../functions/functions.php'; # get first IP address $first = $Subnets->transform_to_dotted($Addresses->get_first_available_address($_POST['subnetId'], $Subnets)); # get subnet details $subnet = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']); ?> <input type="text" name="ip_addr" class="ip_addr form-control" size="30" value="<?php print $first; ?> "> <input type="hidden" name="subnetId" value="<?php print $subnet['id']; ?> "> </td> </tr>
$subnet = (array) $subnet; //ignore folders! if ($subnet['isFolder'] != "1") { //vlan details $vlan = (array) $Tools->fetch_object("vlans", "vlanId", $subnet['vlanId']); if (strlen($vlan['number']) > 0) { $vlanText = " (vlan: " . $vlan['number']; if (strlen($vlan['name']) > 0) { $vlanText .= ' - ' . $vlan['name'] . ')'; } else { $vlanText .= ")"; } } else { $vlanText = ""; } $worksheet->write($lineCount, 0, $Subnets->transform_to_dotted($subnet['subnet']) . "/" . $subnet['mask'] . " - " . $subnet['description'] . $vlanText, $format_header); $worksheet->mergeCells($lineCount, 0, $lineCount, $colSize); $lineCount++; //IP addresses in subnet $ipaddresses = $Addresses->fetch_subnet_addresses($subnet['id']); //write headers $worksheet->write($lineCount, 0, _('ip address'), $format_title); $worksheet->write($lineCount, 1, _('ip state'), $format_title); $worksheet->write($lineCount, 2, _('description'), $format_title); $worksheet->write($lineCount, 3, _('hostname'), $format_title); $worksheet->write($lineCount, 4, _('mac'), $format_title); $worksheet->write($lineCount, 5, _('owner'), $format_title); $worksheet->write($lineCount, 6, _('device'), $format_title); $worksheet->write($lineCount, 7, _('port'), $format_title); $worksheet->write($lineCount, 8, _('note'), $format_title); $m = 9;
if (!is_numeric($_POST['subnetId'])) { $Result->show("danger", _("Invalid ID"), true, true); } # get subnet details $subnet = $Subnets->fetch_subnet(null, $_POST['subnetId']); # verify that user has write permissions for subnet $subnetPerm = $Subnets->check_permission($User->user, $subnet->id); if ($subnetPerm < 3) { $Result->show("danger", _('You do not have permissions to resize subnet') . '!', true, true); } # set prefix - folder or subnet $prefix = $subnet->isFolder == "1" ? "folder" : "subnet"; # reformat description $subnet->description = strlen($subnet->description) > 0 ? "({$subnet->description})" : ""; # set subnet $subnet->description = $subnet->isFolder == "1" ? $subnet->description : $Subnets->transform_to_dotted($subnet->subnet) . "/{$subnet->mask} {$subnet->description}"; ?> <!-- header --> <div class="pHeader"><?php print _("Truncate {$prefix}"); ?> </div> <!-- content --> <div class="pContent"> <table class="table table-noborder table-condensed"> <!-- subnet --> <tr> <td class="middle"><?php
if (sizeof($top_subnets) > 0) { ?> <script type="text/javascript"> $(function () { var data = [ <?php $m = 0; foreach ($top_subnets as $subnet) { # cast $subnet = (array) $subnet; if ($m < $slimit) { # verify user access $sp = $Subnets->check_permission($User->user, $subnet['id']); if ($sp != 0) { $subnet['subnet'] = $Subnets->transform_to_dotted($subnet['subnet']); $subnet['descriptionLong'] = $subnet['description']; # set percentage because of localisation $subnet['percentage'] = str_replace(",", ".", $subnet['percentage']); $subnet['percentage'] = $subnet['percentage']; # odd/even if more than 5 items if (sizeof($top_subnets) > 5) { if ($m & 1) { print "['|<br>" . addslashes($subnet['description']) . "', {$subnet['percentage']}, '" . addslashes($subnet['descriptionLong']) . " ({$subnet['subnet']}/{$subnet['mask']})'],"; } else { print "['" . addslashes($subnet['description']) . "', {$subnet['percentage']}, '" . addslashes($subnet['descriptionLong']) . " ({$subnet['subnet']}/{$subnet['mask']})'],"; } } else { print "['" . addslashes($subnet['description']) . "', {$subnet['percentage']}, '" . addslashes($subnet['descriptionLong']) . " ({$subnet['subnet']}/{$subnet['mask']})'],"; } $m++;
foreach ($mapping->network as $key => $network) { print '<tr class="border-top">'; if ($i === 1) { $title = $mapping->indicator == 0 ? 'Own Zone' : 'Customer Zone'; print '<td rowspan="' . $counter . '"><span class="fa fa-home" title="' . _($title) . '"></span></td>'; print '<td rowspan="' . $counter . '">' . $mapping->zone . '</td>'; print '<td rowspan="' . $counter . '">' . $mapping->alias . '</td>'; print '<td rowspan="' . $counter . '">' . $mapping->description . '</td>'; print '<td rowspan="' . $counter . '">' . $mapping->interface . '</td>'; } # display subnet informations if ($network->subnetId) { // description fix $network->subnetDescription = $network->subnetDescription ? " (" . $network->subnetDescription . ")" : ""; if (!$network->subnetIsFolder) { print '<td><a href="' . create_link("subnets", $network->sectionId, $network->subnetId) . '">' . $Subnets->transform_to_dotted($network->subnet) . '/' . $network->subnetMask . $network->subnetDescription . '</a></td>'; } else { print '<td><a href="' . create_link("subnets", $network->sectionId, $network->subnetId) . '">Folder' . $network->subnetDescription . '</a></td>'; } } else { print '<td>/</td>'; } # display vlan informations if ($network->vlanId) { $network->vlanName = strlen($network->vlanName) > 0 ? " (" . $network->vlanName . ")" : ""; print '<td><a href="' . create_link('tools', 'vlan', $network->domainId, $network->vlanId) . '">Vlan ' . $network->vlan . $network->vlanName . '</a></td>'; } else { print '<td>/</td>'; } print '</tr>'; # increase the loop counter
$vlanText = " (vlan: " . $vlan['number']; if (strlen($vlan['name']) > 0) { $vlanText .= ' - ' . $vlan['name'] . ')'; } else { $vlanText .= ")"; } } } else { $vlanText = ""; } //section change if ($result_addresses[$m]->subnetId != $result_addresses[$m - 1]->subnetId) { //new line $lineCount++; //subnet details $worksheet->write($lineCount, 0, $Subnets->transform_to_dotted($subnet['subnet']) . "/" . $subnet['mask'] . " - " . $subnet['description'] . $vlanText, $format_title); $worksheet->mergeCells($lineCount, 0, $lineCount, $colSpan - 1); //new line $lineCount++; } $m++; $x = 0; $worksheet->write($lineCount, $x, $Subnets->transform_to_dotted($ip['ip_addr']), $format_left); $x++; # state if (in_array('state', $selected_ip_fields)) { $worksheet->write($lineCount, $x, _($Addresses->address_type_index_to_type($ip['state']))); $x++; } $worksheet->write($lineCount, $x, $ip['description']); $x++;
//ago if (is_null($change['lastSeen']) || $change['lastSeen'] == "1970-01-01 00:00:01" || $change['lastSeen'] == "0000-00-00 00:00:00") { $ago = "never"; } else { $timeDiff = $now - strtotime($change['lastSeen']); // reformat $lastSeen = date("m/d H:i", strtotime($change['lastSeen'])); $ago = $lastSeen . " (" . $Result->sec2hms($timeDiff) . " ago)"; } // desc $change['description'] = strlen($change['description']) > 0 ? "{$Subnets->mail_font_style} {$change['description']}</font>" : "{$Subnets->mail_font_style} / </font>"; // subnet desc $subnet->description = strlen($subnet->description) > 0 ? "{$Subnets->mail_font_style} {$subnet->description}</font>" : "{$Subnets->mail_font_style} / </font>"; //content $content[] = "<tr>"; $content[] = "\t<td style='padding:3px 8px;border:1px solid #ccc;'><a href='" . rtrim(str_replace(BASE, "", $Scan->settings->siteURL), "/") . "" . create_link("subnets", $subnet->sectionId, $subnet->id) . "'>{$Subnets->mail_font_style_href} " . $Subnets->transform_to_dotted($change['ip_addr']) . "</font></a></td>"; $content[] = "\t<td style='padding:3px 8px;border:1px solid #ccc;'>{$Subnets->mail_font_style} {$change['description']}</font></td>"; $content[] = "\t<td style='padding:3px 8px;border:1px solid #ccc;'>{$Subnets->mail_font_style_href} {$change['dns_name']}</font></td>"; $content[] = "\t<td style='padding:3px 8px;border:1px solid #ccc;'><a href='" . rtrim(str_replace(BASE, "", $Scan->settings->siteURL), "/") . "" . create_link("subnets", $subnet->sectionId, $subnet->id) . "'>{$Subnets->mail_font_style_href} " . $Subnets->transform_to_dotted($subnet->subnet) . "/" . $subnet->mask . "</font></a>" . $subnet->description . "</td>"; $content[] = "\t<td style='padding:3px 8px;border:1px solid #ccc;'>{$Subnets->mail_font_style} {$ago}</td>"; $content[] = "\t<td style='padding:3px 8px;border:1px solid #ccc;'>{$Subnets->mail_font_style} {$oldStatus} > {$newStatus}</td>"; $content[] = "</tr>"; //plain content $content_plain[] = "\t * " . $Subnets->transform_to_dotted($change['ip_addr']) . " (" . $Subnets->transform_to_dotted($subnet->subnet) . "/" . $subnet->mask . ")\r\n \t " . strip_tags($oldStatus) . " => " . strip_tags($newStatus); } $content[] = "</table>"; # set content $content = $phpipam_mail->generate_message(implode("\r\n", $content)); $content_plain = implode("\r\n", $content_plain); # try to send try {
$content[] = "\t<th style='padding:3px 8px;border:1px solid silver;border-bottom:2px solid gray;'>Subnet</th>"; $content[] = "\t<th style='padding:3px 8px;border:1px solid silver;border-bottom:2px solid gray;'>Section</th>"; $content[] = "</tr>"; //plain $content_plain[] = "phpIPAM found {$discovered} new hosts\r\n------------------------------"; //Changes foreach ($scan_subnets as $s) { if (sizeof(@$s->discovered) > 0) { foreach ($s->discovered as $ip) { //set subnet $subnet = $Subnets->fetch_subnet(null, $s->id); //set section $section = $Admin->fetch_object("sections", "id", $s->sectionId); $content[] = "<tr>"; $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'>{$ip}</td>"; $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'><a href='" . rtrim($Scan->settings->siteURL, "/") . "" . create_link("subnets", $section->id, $subnet->id) . "'>" . $Subnets->transform_to_dotted($subnet->subnet) . "/" . $subnet->mask . " - " . $subnet->description . "</a></td>"; $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'><a href='" . rtrim($Scan->settings->siteURL, "/") . "" . create_link("subnets", $section->id) . "'>{$section->name} {$section->description}</a></td>"; $content[] = "</tr>"; //plain content $content_plain[] = "\t * {$ip} (" . $Subnets->transform_to_dotted($subnet->subnet) . "/" . $subnet->mask . ")"; } } } $content[] = "</table>"; # set content $content = $phpipam_mail->generate_message(implode("\r\n", $content)); $content_plain = implode("\r\n", $content_plain); # try to send try { $phpipam_mail->Php_mailer->setFrom($mail_settings->mAdminMail, $mail_settings->mAdminName); //add all admins to CC
?> </div> <!-- content --> <div class="pContent"> <form id="subnetResize"> <table class="table table-noborder table-condensed"> <!-- subnet --> <tr> <td class="middle"><?php print _('Subnet'); ?> </td> <td><?php print $Subnets->transform_to_dotted($subnet['subnet']) . " ({$subnet['description']})"; ?> </td> </tr> <!-- Mask --> <tr> <td class="middle"><?php print _('Current mask'); ?> </td> <td><?php print "/" . $subnet['mask']; ?> </td> </tr> <!-- new Mask -->
# set title $title = _('IP address details') . ' :: ' . $address['ip']; # address $content[] = "• " . _('IP address') . ": \t\t {$address['ip']}/{$subnet['mask']}"; # description empty($address['description']) ?: ($content[] = "• " . _('Description') . ":\t\t {$address['description']}"); # hostname empty($address['dns_name']) ?: ($content[] = "• " . _('Hostname') . ": \t {$address['dns_name']}"); # subnet desc $s_descrip = empty($subnet['description']) ? "" : " (" . $subnet['description'] . ")"; # subnet $content[] = "• " . _('Subnet') . ": \t\t {$subnet['ip']}/{$subnet['mask']} {$s_descrip}"; # gateway $gateway = $Subnets->find_gateway($subnet['id']); if ($gateway !== false) { $content[] = "• " . _('Gateway') . ": \t\t" . $Subnets->transform_to_dotted($gateway->ip_addr); } # VLAN empty($subnet['vlanId']) ?: ($content[] = "• " . _('VLAN ID') . ": \t\t {$vlan['number']} ({$vlan['name']})"); # Nameserver sets if (!empty($subnet['nameserverId'])) { $nslist = str_replace(";", ", ", $nameservers['namesrv1']); $content[] = "• " . _('Nameservers') . ": \t {$nslist} ({$nameservers['name']})"; } # Switch if (!empty($address['switch'])) { # get device by id $device = (array) $Tools->fetch_object("devices", "id", $address['switch']); !sizeof($device) > 1 ?: ($content[] = "• " . _('Device') . ": \t\t {$device['hostname']}"); } # port
foreach ($scan_addresses as $k => $v) { foreach ($ports as $p) { $addresses[] = array("ip" => $v, "port" => $p); } } # run per MAX_THREADS for ($m = 0; $m <= sizeof($addresses); $m += $Scan->settings->scanMaxThreads) { //create threads $threads = array(); //fork processes for ($i = 0; $i <= $Scan->settings->scanMaxThreads && $i <= sizeof($addresses); $i++) { //only if index exists! if (isset($addresses[$z])) { //start new thread $threads[$z] = new Thread('telnet_address'); $threads[$z]->start($Subnets->transform_to_dotted($addresses[$z]['ip']), $addresses[$z]['port'], 2); $z++; //next index } } //wait for all the threads to finish while (!empty($threads)) { foreach ($threads as $index => $thread) { if (!$thread->isAlive()) { //online, save to array if ($thread->getExitCode() == 0) { $out['alive'][$addresses[$index]['ip']][] = $addresses[$index]['port']; } else { $out['dead'][$addresses[$index]['ip']][] = $addresses[$index]['port']; } //remove thread
$newStatus = "<font style='color:#04B486'>Online</font>"; } //set subnet $subnet = $Subnets->fetch_subnet(null, $change['subnetId']); //set section $section = $Tools->fetch_object("sections", "id", $subnet->sectionId); //ago if (is_null($change['lastSeen']) || $change['lastSeen'] == "0000-00-00 00:00:00") { $ago = "never"; } else { $timeDiff = time() - strtotime($change['lastSeen']); $ago = $change['lastSeen'] . " (" . sec2hms($timeDiff) . " ago)"; } //content $content[] = "<tr>"; $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'><a href='" . $Scan->settings->siteURL . "" . create_link("subnets", $section->id, $subnet->id) . "'>" . $Subnets->transform_to_dotted($change['ip_addr']) . "</a></td>"; $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'>{$change['description']}</td>"; $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'><a href='" . $Scan->settings->siteURL . "" . create_link("subnets", $section->id, $subnet->id) . "'>" . $Subnets->transform_to_dotted($subnet->subnet) . "/" . $subnet->mask . " - " . $subnet->description . "</a></td>"; $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'><a href='" . $Scan->settings->siteURL . "" . create_link("subnets", $section->id) . "'>{$section->name} {$section->description}</a></td>"; $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'>{$ago}</td>"; $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'>{$oldStatus}</td>"; $content[] = "\t<td style='padding:3px 8px;border:1px solid silver;'>{$newStatus}</td>"; $content[] = "</tr>"; //plain content $content_plain[] = "\t * " . $Subnets->transform_to_dotted($change['ip_addr']) . " (" . $Subnets->transform_to_dotted($subnet->subnet) . "/" . $subnet->mask . ")\r\n \t " . strip_tags($oldStatus) . " => " . strip_tags($newStatus); } $content[] = "</table>"; # set content $content = $phpipam_mail->generate_message(implode("\r\n", $content)); $content_plain = implode("\r\n", $content_plain); # try to send
$section = (array) $section; # check permission $permission = $Sections->check_permission($User->user, $section['id']); if ($permission > 0) { $subnets = $Subnets->fetch_section_subnets($section['id']); if ($subnets !== false) { foreach ($subnets as $subnet) { # check permission $subpermission = $Subnets->check_permission($User->user, $subnet->id); if ($subpermission > 0) { /* show only subnets that allow IP exporting */ if ($subnet->allowRequests == 1) { $subnets_count++; /* must not have any nested subnets! */ if (!$Subnets->has_slaves($subnet->id)) { $html[] = '<option value="' . $subnet->id . '">' . $Subnets->transform_to_dotted($subnet->subnet) . '/' . $subnet->mask . ' [' . $subnet->description . ']</option>'; } } } } } } } } ?> <table class="table table-condensed table-hover"> <?php // if no subnets exist print it!