/* 
 * if strict mode is enabled check that is is still inside master subnet!
 */
if ($section['strictMode'] == 1) {
    if (!($overlap = verifySubnetNesting($subnetOld['masterSubnetId'], transform2long($subnetOld['subnet']) . "/" . $_POST['newMask'])) && $subnetOld['masterSubnetId'] != 0) {
        # get master details
        $master = getSubnetDetailsById($subnetOld['masterSubnetId']);
        $master = Transform2long($master['subnet']) . "/" . $master['mask'] . " - " . $master['description'];
        $errors[] = _("New subnet not in master subnet") . "!<br>({$master})";
    }
}
/*
 * If subnet has slaves make sure all slaves are still inside!
 */
if ($section['strictMode'] == 1) {
    $slaves = getAllSlaveSubnetsBySubnetId($_POST['subnetId']);
    if (sizeof($slaves) > 0) {
        foreach ($slaves as $slave) {
            if (!isSubnetInsideSubnet(transform2long($slave['subnet']) . "/" . $slave['mask'], transform2long($subnetOld['subnet']) . "/" . $_POST['newMask'])) {
                $errors[] = _("Nested subnet out of new subnet") . "!<br>(" . transform2long($slave['subnet']) . "/{$slave['mask']} - {$slave['description']})";
            }
        }
    }
}
/* if no errors edit! */
if (sizeof($errors) > 0) {
    print "<div class='alert alert-danger'><ul>";
    foreach ($errors as $error) {
        print "<li>{$error}</li>";
    }
    print "</ul></div>";
Example #2
0
<?php

/*
 * Script to print pie graph for subnet usage
 ********************************************/
# if slaves reset IP addresses!
$slaves = getAllSlaveSubnetsBySubnetId($subnetId);
# check number of hosts for all subnets, including sub-subnets!
if (sizeof($slaves) > 0) {
    $ipaddresses = getIpAddressesBySubnetIdSlavesSort($subnetId);
}
# for statistics we need to deduct 2 for each subnet bigger than /31
$d = 0;
foreach ($slaves as $s) {
    if ($s['mask'] < 31) {
        $d = $d + 2;
    }
}
# get offline, reserved and DHCP
$out['offline'] = 0;
$out['online'] = 0;
$out['reserved'] = 0;
$out['dhcp'] = 0;
foreach ($ipaddresses as $ip) {
    if ($ip['state'] == "0") {
        $out['offline']++;
    } else {
        if ($ip['state'] == "1") {
            $out['online']++;
        } else {
            if ($ip['state'] == "2") {
Example #3
0
 print "\t<th>" . _('Description') . "</th>";
 print "\t<th>" . _('Section') . "</th>";
 print "\t<th class='hidden-xs hidden-sm'>" . _('VLAN') . "</th>";
 print "\t<th class='hidden-xs hidden-sm'>" . _('Used') . "</th>";
 print "\t<th style='width:5px;'></th>";
 print "</tr>";
 # logs
 foreach ($favs as $f) {
     # if subnet already removed (doesnt exist) dont print it!
     if (sizeof($f) > 0) {
         print "<tr class='favSubnet-{$f['subnetId']}'>";
         if ($f['isFolder'] == 1) {
             print "\t<td><a href='" . create_link("folder", $f['sectionId'], $f['subnetId']) . "'><i class='fa fa-folder fa-sfolder'></i> {$f['description']}</a></td>";
         } else {
             //master?
             if (sizeof(getAllSlaveSubnetsBySubnetId($f['subnetId'])) > 0) {
                 print "\t<td><a href='" . create_link("subnets", $f['sectionId'], $f['subnetId']) . "'><i class='fa fa-sfolder fa-folder-o'></i>" . transform2long($f['subnet']) . "/{$f['mask']}</a></td>";
             } else {
                 print "\t<td><a href='" . create_link("subnets", $f['sectionId'], $f['subnetId']) . "'><i class='fa fa-sfolder fa-sitemap' ></i> " . transform2long($f['subnet']) . "/{$f['mask']}</a></td>";
             }
         }
         print "\t<td>{$f['description']}</td>";
         print "\t<td><a href='" . create_link("folder", $f['sectionId']) . "'>{$f['section']}</a></td>";
         if (strlen($f['vlanId']) > 0) {
             # get vlan info
             $vlan = getVlanById($f['vlanId']);
             print "\t<td class='hidden-xs hidden-sm'>{$vlan['number']}</td>";
         } else {
             print "\t<td class='hidden-xs hidden-sm'>/</td>";
         }
         # used
 $slaveSize = sizeof($subnets);
 $m = 0;
 foreach ($subnets as $slave) {
     # reformat empty VLAN
     if (empty($slave['VLAN']) || $slave['VLAN'] == 0 || strlen($slave['VLAN']) == 0) {
         $slave['VLAN'] = "/";
     }
     # get VLAN details
     $slave['VLAN'] = subnetGetVLANdetailsById($slave['vlanId']);
     $slave['VLAN'] = $slave['VLAN']['number'];
     print "<tr>";
     print "\t<td class='small'>{$slave['VLAN']}</td>";
     print "\t<td class='small description'><a href='" . create_link("subnets", $section['id'], $slave['id']) . "'>{$slave['description']}</a></td>";
     print "\t<td><a href='" . create_link("subnets", $section['id'], $slave['id']) . "'>" . transform2long($slave['subnet']) . "/{$slave['mask']}</a></td>";
     # count IP addresses
     $hasSlaves = getAllSlaveSubnetsBySubnetId($slave['id']);
     # slaves details are provided with ipaddressprintslaves script
     if (sizeof($hasSlaves) > 0) {
         $ipCount = sizeof(getIpAddressesBySubnetIdSlavesSort($slave['id']));
     } else {
         $ipCount = countIpAddressesBySubnetId($slave['id']);
     }
     //ip count - direct subnet
     $calculate = calculateSubnetDetails(gmp_strval($ipCount), $slave['mask'], $slave['subnet']);
     print ' <td class="small hidden-xs hidden-sm">' . $calculate['used'] . '/' . $calculate['maxhosts'] . '</td>' . "\n";
     print '	<td class="small hidden-xs hidden-sm">' . $calculate['freehosts_percent'] . '</td>';
     # add to sum if IPv4
     if (IdentifyAddress($slave['subnet']) == "IPv4") {
         $usedSum = $usedSum + $calculate['used'];
         $allSum = $allSum + $calculate['maxhosts'];
     }
Example #5
0
<div class="ipaddresses">

<?php 
/**
 *	Script to show nested subnets / hierarchy or print IP address list and subnet details
 */
# fetch subnet details
$slaves = getAllSlaveSubnetsBySubnetId($_REQUEST['subnetId']);
# print subnet and ip addresses
if (sizeof($slaves) == 0) {
    # print subnets
    print "<div class='subnetDetails'>";
    include_once "subnetDetails.php";
    print "</div>";
    # IP address table
    print '<div class="ipaddresses_overlay">';
    include_once 'ipAddressPrintTable.php';
    print '</div>';
} else {
    # subnet details for slaves
    print "<div class='subnetDetails'>";
    include_once "subnetDetailsSlaves.php";
    print "</div>";
    # subnet slaves print subnets
    print "<div class='subnetSlaves'>";
    include_once "ipAddressPrintTableSlaves.php";
    print "</div>";
    # IP address table
    print '<div class="ipaddresses_overlay">';
    include_once 'ipAddressPrintTable.php';
    print '</div>';