$errors[] = $overlap; } } } else { if ($_POST['action'] == "add") { /* first verify user input */ $errors = verifyCidr($_POST['subnet']); /* verify that nested subnet is inside root subnet */ if ($section['strictMode'] == 1 && !$isFolder) { if (!($overlap = verifySubnetNesting($_POST['masterSubnetId'], $_POST['subnet']))) { $errors[] = _('Nested subnet not in root subnet!'); } } /* verify that no overlapping occurs if we are adding nested subnet */ if ($section['strictMode'] == 1 && !$isFolder) { if ($overlap = verifyNestedSubnetOverlapping($_POST['sectionId'], $_POST['subnet'], $_POST['vrfId'], $_POST['masterSubnetId'])) { $errors[] = $overlap; } } } else { if ($_POST['action'] == "edit") { if ($section['strictMode'] == 1 && !$isFolder) { /* verify that nested subnet is inside root subnet */ if (!($overlap = verifySubnetNesting($_POST['masterSubnetId'], $_POST['subnet'])) && $_POST['masterSubnetId'] != 0) { $errors[] = _('Nested subnet not in root subnet!'); } } /* for nesting - MasterId cannot be the same as subnetId! */ if ($_POST['masterSubnetId'] == $_POST['subnetId']) { $errors[] = _('Subnet cannot nest behind itself!'); }
//set subnet details $subnetDetails['action'] = "add"; $subnetDetails['subnet'] = $_POST['subnet-' . $m]; $subnetDetails['sectionId'] = $_POST['section-' . $m]; $subnetDetails['description'] = $_POST['description-' . $m]; $subnetDetails['VLAN'] = $_POST['vlan-' . $m]; $subnetDetails['masterSubnetId'] = 0; //cidr if (verifyCidr($subnetDetails['subnet'])) { $errors[] = verifyCidr($subnetDetails['subnet']); } else { if (verifySubnetOverlapping($subnetDetails['sectionId'], $subnetDetails['subnet'], "000")) { $errors[] = verifySubnetOverlapping($subnetDetails['sectionId'], $subnetDetails['subnet'], "000"); } else { if (verifyNestedSubnetOverlapping($subnetDetails['sectionId'], $subnetDetails['subnet'], "000")) { $errors[] = verifyNestedSubnetOverlapping($subnetDetails['sectionId'], $subnetDetails['subnet'], "000"); } else { $subnetInsert[] = $subnetDetails; } } } } /* print errors if they exist or success */ if (!isset($errors)) { $errors2 = 0; //insert if all other is ok! foreach ($subnetInsert as $subnetDetails) { if (!modifySubnetDetails($subnetDetails)) { print '<div class="alert alert-danger alert-absolute">' . _('Failed to import subnet') . ' ' . $subnetDetails['subnet'] . '</div>'; $errors2++; }