/** * creates mac address from provided IP address */ # 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); # verify that user is logged in $User->check_user_session(); # check that multicast is enabled if ($User->settings->enableMulticast != "1") { die("False"); } # validations if ($Subnets->verify_cidr($_POST['ip']) === false) { die("False"); } if ($Subnets->is_multicast($_POST['ip']) === false) { die("False"); } # get mac $text = $Subnets->create_multicast_mac($_POST['ip']); # print mas if ($text === false) { die("False"); } else { print $text; }
# 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>'; }