if ($_POST['sectionId'] != @$_POST['sectionIdNew'] && $_POST['action'] == "edit") { //reset masterId - we are putting it to root $_POST['masterSubnetId'] = 0; //check for overlapping $sectionIdNew = (array) $Sections->fetch_section(null, $_POST['sectionIdNew']); if ($sectionIdNew['strictMode'] == 1 && !$parent_is_folder) { /* verify that no overlapping occurs if we are adding root subnet */ $overlap = $Subnets->verify_subnet_overlapping($_POST['sectionIdNew'], $_POST['cidr'], $_POST['vrfId']); if ($overlap !== false) { $errors[] = $overlap; } } } else { if ($_POST['action'] == "add" && $_POST['masterSubnetId'] == 0) { //verify cidr $cidr_check = $Subnets->verify_cidr_address($_POST['cidr']); if (strlen($cidr_check) > 5) { $errors[] = $cidr_check; } //check for overlapping if ($section['strictMode'] == 1 && !$parent_is_folder) { /* verify that no overlapping occurs if we are adding root subnet only check for overlapping if vrf is empty or not exists! */ $overlap = $Subnets->verify_subnet_overlapping($_POST['sectionId'], $_POST['cidr'], $_POST['vrfId']); if ($overlap !== false) { $errors[] = $overlap; } } } else { if ($_POST['action'] == "add") {
$msg .= "VLAN not found in provided domain."; $action = "error"; } else { $cdata['vlanId'] = $vlan_data[$cdom][$cdata['vlan']]['vlanId']; } } else { # no VLAN provided $cdata['vlanId'] = 0; } } } # check data format if ($action != "error") { if ($net = $Subnets->get_network_boundaries($cdata['subnet'], $cdata['mask'])) { $cdata['mask'] = $net['bitmask']; $cidr_check = $Subnets->verify_cidr_address($cdata['subnet'] . "/" . $cdata['mask']); if (strlen($cidr_check) > 5) { $msg .= $cidr_check; $action = "error"; } } else { $msg .= $net['message']; $action = "error"; } if (preg_match("/[;'\"]/", $cdata['description'])) { $msg .= "Invalid characters in description."; $action = "error"; } if (!empty($cdata['vrf']) && !preg_match("/^[a-zA-Z0-9-:]+\$/", $cdata['vrf'])) { $msg .= "Invalid VRF name format."; $action = "error";
*/ # include required scripts require dirname(__FILE__) . '/../../../functions/functions.php'; # initialize required objects $Database = new Database_PDO(); $Result = new Result(); $User = new User($Database); $Subnets = new Subnets($Database); $Sections = new Sections($Database); $Tools = new Tools($Database); # verify that user is logged in $User->check_user_session(); # get requested IP addresses in CIDR format $cidr = $_POST['cidr']; # verify input CIDR and die if errors $errors = $Subnets->verify_cidr_address($cidr, false); $errors === true ?: $Result->show("danger alert-absolute", _('Invalid input') . ': ' . $errors, true); # fetch all sections $all_sections = $Sections->fetch_all_sections(); # calculate results $calc_results = $Tools->calculate_ip_calc_results($cidr); ?> <hr> <h4><?php print _('Subnetting details for'); ?> <?php print $cidr; ?> :</h4>
$dropdown_menu = $Subnets->subnet_dropdown_print_available($_POST['sectionId'], $_POST['subnetId']); } if (@$_POST['location'] == "ipcalc") { $cidr = strlen($_POST['bitmask']) > 0 ? $_POST['subnet'] . '/' . $_POST['bitmask'] : $_POST['subnet']; } //from ipcalc if ($_POST['action'] != "add") { $cidr = $Subnets->transform_to_dotted($subnet_old_details['subnet']) . '/' . $subnet_old_details['mask']; } //editing existing # reset CIDR if $showDropMenuFull if ($showDropMenuFull && strlen(@$dropdown_menu) > 2) { $cidr = explode("\n", $dropdown_menu); $cidr = substr(strip_tags($cidr[1]), 2); //validate if ($Subnets->verify_cidr_address($cidr) === false) { unset($cidr); } } ?> <?php if (!$showDropMenuFull) { ?> <input type="text" class="form-control input-sm input-w-200" name="subnet" placeholder="<?php print _('subnet in CIDR'); ?> " value="<?php print @$cidr; ?>
} //check input parameters if (!isset($argv[1]) || !isset($argv[2])) { die(json_encode(array("status" => 1, "error" => "Missing required input parameters"))); } // test to see if threading is available if (!Thread::available()) { die(json_encode(array("status" => 1, "error" => "Threading is required for scanning subnets. Please recompile PHP with pcntl extension"))); } //check script if ($argv[1] != "update" && $argv[1] != "discovery") { die(json_encode(array("status" => 1, "error" => "Invalid scan type!"))); } //verify cidr if (!is_numeric($argv[2])) { if ($Subnets->verify_cidr_address($argv[2]) !== true) { die(json_encode(array("status" => 1, "error" => "Invalid subnet CIDR address provided"))); } } /** * 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);