コード例 #1
0
/**
 * Set Query for update section
 */
function setUpdateSectionQuery($update)
{
    # add section
    if ($update['action'] == "add" || $update['action'] == "create") {
        $query = 'Insert into sections (`name`,`description`,`permissions`,`strictMode`,`subnetOrdering`,`showVLAN`,`showVRF`, `masterSection`) values ("' . $update['name'] . '", "' . $update['description'] . '", "' . $update['permissions'] . '", "' . isCheckbox($update['strictMode']) . '", "' . $update['subnetOrdering'] . '", "' . isCheckbox($update['showVLAN']) . '", "' . isCheckbox($update['showVRF']) . '", "' . $update['masterSection'] . '");';
    } else {
        if ($update['action'] == "edit" || $update['action'] == "update") {
            $section_old = getSectionDetailsById($update['id']);
            # Get old section name for update
            # Update section
            $query = "update `sections` set `name` = '{$update['name']}', `description` = '{$update['description']}', `permissions` = '{$update['permissions']}', `strictMode`='" . isCheckbox($update['strictMode']) . "', `subnetOrdering`='{$update['subnetOrdering']}', `showVLAN`='" . isCheckbox($update['showVLAN']) . "', `showVRF`='" . isCheckbox($update['showVRF']) . "', `masterSection`='{$update['masterSection']}' where `id` = '{$update['id']}';";
            # delegate permissions if set
            if ($update['delegate'] == 1) {
                $query .= "update `subnets` set `permissions` = '{$update['permissions']}' where `sectionId` = '{$update['id']}';";
            }
        } else {
            if ($update['action'] == "delete") {
                /* we must delete many entries - section, all belonging subnets and ip addresses */
                $sectionId = $update['id'];
                # delete sections query
                $query = "delete from `sections` where `id` = '{$sectionId}';" . "\n";
                # delete belonging subnets
                $query .= "delete from `subnets` where `sectionId` = '{$sectionId}';" . "\n";
                # delete IP addresses query
                $subnets = fetchSubnets($sectionId);
                if (sizeof($subnets) != 0) {
                    foreach ($subnets as $subnet) {
                        $query .= "delete from `ipaddresses` where `subnetId` = '{$subnet['id']}';" . "\n";
                    }
                }
                # if it has subsections delete all subsections and subnets/ip addresses
                if (sizeof($subsections = getAllSubSections($sectionId)) > 0) {
                    foreach ($subsections as $ss) {
                        $query .= "delete from `sections` where `id` = '{$ss['id']}';" . "\n";
                        $query .= "delete from `subnets` where `sectionId` = '{$ss['id']}';" . "\n";
                        $ssubnets = fetchSubnets($ss['id']);
                        if (sizeof($ssubnets) != 0) {
                            foreach ($ssubnets as $subnet) {
                                $query .= "delete from `ipaddresses` where `subnetId` = '{$subnet['id']}';" . "\n";
                            }
                        }
                    }
                }
            }
        }
    }
    /* return query */
    return $query;
}
コード例 #2
0
$update['showVLAN'] = $_POST['showVLAN'];
$update['showVRF'] = $_POST['showVRF'];
$update['masterSection'] = $_POST['masterSection'];
if (isset($_POST['delegate'])) {
    if ($_POST['delegate'] == 1) {
        $update['delegate'] = $_POST['delegate'];
    }
}
/* do action! */
if ($_POST['action'] == "delete" && !isset($_POST['deleteconfirm'])) {
    # for ajax to prevent reload
    print "<div style='display:none'>alert alert-danger</div>";
    # result
    print "<div class='alert alert-warning'>";
    # print what will be deleted
    $subsections = getAllSubSections($update['id']);
    # check also subsections
    if (sizeof($subsections) > 0) {
        $subnets = fetchSubnets($update['id']);
        $subnetsc = sizeof($subnets);
        foreach ($subnets as $s) {
            $out[] = $s;
        }
        foreach ($subsections as $ss) {
            $subssubnet = fetchSubnets($ss['id']);
            foreach ($subssubnet as $sss) {
                $out[] = $sss;
            }
            $subnetsc = $subnetsc + sizeof($subssubnet);
            $ipcnt = countAllIPinSection($out);
        }
コード例 #3
0
ファイル: subnets.php プロジェクト: btorresgil/phpipam
if (!is_numeric($sectionId) && $sectionId != "Administration") {
    $sectionId = getSectionIdFromSectionName($sectionId);
}
/**
 * Admin check, otherwise load requested subnets
 */
if ($sectionId == 'Administration') {
    /* Print all Admin actions if user is admin :) */
    if (!checkAdmin()) {
        print '<div class="alert alert-danger">' . _('Sorry, must be admin') . '!</div>';
    } else {
        include 'admin/adminMenu.php';
    }
} else {
    /* print subsections if they exist */
    $subsections = getAllSubSections($_REQUEST['section']);
    # permissions
    foreach ($subsections as $k => $ss) {
        $perm = checkSectionPermission($ss['id']);
        if ($perm > 0) {
        } else {
            unset($subsections[$k]);
        }
    }
    if (sizeof($subsections) > 0) {
        //title
        print "<h4>" . _('Belonging subsections') . "</h4><hr>";
        //table
        print "<table class='table table-noborder table-auto'>";
        foreach ($subsections as $ss) {
            print "<tr>";
コード例 #4
0
 print "\t<th class='hidden-xs hidden-sm'>" . _('Requests') . "</th>";
 print "\t<th class='hidden-xs hidden-sm'>" . _('Hosts check') . "</th>";
 if (sizeof($custom) > 0) {
     foreach ($custom as $field) {
         if (!in_array($field['name'], $ffields)) {
             print "\t<th class='hidden-xs hidden-sm'>{$field['name']}</th>";
         }
     }
 }
 print "\t<th class='actions' style='width:140px;white-space:nowrap;'></th>";
 print "</tr>";
 # no subnets
 if (sizeof($subnets) == 0) {
     print "<tr><td colspan='{$colCount}'><div class='alert alert-info'>" . _('Section has no subnets') . "!</div></td></tr>";
     # check Available subnets for subsection
     $subsections = getAllSubSections($_GET['section']);
     $colspan = 6 + sizeof($custom);
     if ($settings['enableVRF'] == 1) {
         $colspan++;
     }
 } else {
     # subnets
     $subnets2 = printSubnets($subnets, true, $settings['enableVRF'], $custom);
     print $subnets2;
 }
 # subsection subnets
 if (sizeof($subsections) > 0) {
     $colspan = 6 + sizeof($custom);
     if ($settings['enableVRF'] == 1) {
         $colspan++;
     }