Пример #1
0
     if ($action !== "delete") {
         if (strlen(@$address['mac']) > 0) {
             if ($User->validate_mac($address['mac']) === false) {
                 $errors[] = _('Invalid MAC address') . "!";
             } else {
                 $address['mac'] = $User->reformat_mac_address($address['mac'], 1);
             }
         }
     }
     # modify action - if delete ok, dynamically reset add / edit -> if IP already exists set edit
     if ($action != "delete") {
         $address['action'] = $Addresses->address_exists($m, $address['subnetId']) === true ? "edit" : "add";
     }
     # if it fails set error log
     if (!$Addresses->modify_address($address, false)) {
         $errors[] = _('Cannot') . ' ' . $address['action'] . ' ' . _('IP address') . ' ' . $Addresses->transform_to_dotted($m);
     }
     # next IP
     $m = gmp_strval(gmp_add($m, 1));
 }
 # print errors if they exist
 if (isset($errors)) {
     $log = $Result->array_to_log($errors);
     $Result->show("danger", $log, false);
     $Log->write("IP address modification", "'Error {$action} range {$address['start']} - {$address['stop']}<br> {$log}", 2);
 } else {
     # reset IP for mailing
     $address['ip_addr'] = $address['start'] . ' - ' . $address['stop'];
     # log and changelog
     $Result->show("success", _("Range") . " {$address['start']} - {$address['stop']} " . _($action) . " " . _("successfull") . "!", false);
     $Log->write("IP address modification", "Range {$address['start']} - {$address['stop']} {$action} successfull!", 0);
Пример #2
0
    $request = (array) $request;
}
# verify permissions
if ($Subnets->check_permission($User->user, $request['subnetId']) != 3) {
    $Result->show("danger", _('You do not have permissions to process this request') . "!", true, true);
}
# set IP address
# if provided (requested from logged in user) check if already in use, if it is warn and set next free
# else get next free
if (strlen($request['ip_addr']) > 0) {
    // check if it exists
    if ($Addresses->address_exists($request['ip_addr'], $request['subnetId'])) {
        $errmsg = "Requested IP address ({$request['ip_addr']}) already used. First available address automatically provided.";
        $errmsg_class = "warning";
        //fetch first free
        $ip_address = $Addresses->transform_to_dotted($Addresses->get_first_available_address($request['subnetId'], $Subnets));
    } else {
        $ip_address = $request['ip_addr'];
    }
} else {
    // fetch first free
    $ip_address = $Addresses->transform_to_dotted($Addresses->get_first_available_address($request['subnetId'], $Subnets));
}
// false
if ($ip_address === false) {
    $ip_address = "";
    $errmsg = "No IP addresses available in requested subnet";
    $errmsg_class = "danger";
}
# set selected address fields array
$selected_ip_fields = explode(";", $User->settings->IPfilter);
Пример #3
0
# fetch subnet
$subnet = (array) $Admin->fetch_object("subnets", "id", $_POST['subnetId']);
/* if action is reject set processed and accepted to 1 and 0 */
if ($_POST['action'] == "reject") {
    //set reject values
    $values = array("id" => $_POST['requestId'], "processed" => 1, "accepted" => 0, "adminComment" => @$_POST['adminComment']);
    if (!$Admin->object_modify("requests", "edit", "id", $values)) {
        $Result->show("danger", _("Failed to reject IP request"), true);
    } else {
        $Result->show("success", _("Request has beed rejected"), false);
    }
    # send mail
    $Tools->ip_request_send_mail("reject", $_POST);
} else {
    // fetch subnet
    $subnet_temp = $Addresses->transform_to_dotted($subnet['subnet']) . "/" . $subnet['mask'];
    //verify IP and subnet
    $Addresses->verify_address($Addresses->transform_address($_POST['ip_addr'], "dotted"), $subnet_temp, false, true);
    //check if already existing and die
    if ($Addresses->address_exists($Addresses->transform_address($_POST['ip_addr'], "decimal"), $subnet['id'])) {
        $Result->show("danger", _('IP address already exists'), true);
    }
    //insert to ipaddresses table
    $values = array("action" => "add", "ip_addr" => $Addresses->transform_address($_POST['ip_addr'], "decimal"), "subnetId" => $_POST['subnetId'], "description" => @$_POST['description'], "dns_name" => @$_POST['dns_name'], "mac" => @$_POST['mac'], "owner" => @$_POST['owner'], "state" => @$_POST['state'], "switch" => @$_POST['switch'], "port" => @$_POST['port'], "note" => @$_POST['note']);
    if (!$Addresses->modify_address($values)) {
        $Result->show("danger", _("Failed to create IP address"), true);
    }
    //accept message
    $values2 = array("id" => $_POST['requestId'], "processed" => 1, "accepted" => 1, "adminComment" => $comment);
    if (!$Admin->object_modify("requests", "edit", "id", $values2)) {
        $Result->show("danger", _("Cannot confirm IP address"), true);
Пример #4
0
    }
}
# fetch subnet
$subnet = (array) $Admin->fetch_object("subnets", "id", $_POST['subnetId']);
/* if action is reject set processed and accepted to 1 and 0 */
if ($_POST['action'] == "reject") {
    //set reject values
    $values = array("id" => $_POST['requestId'], "processed" => 1, "accepted" => 0, "adminComment" => @$_POST['adminComment']);
    if (!$Admin->object_modify("requests", "edit", "id", $values)) {
        $Result->show("danger", _("Failed to reject IP request"), true);
    } else {
        $Result->show("success", _("Request has beed rejected"), false);
    }
} else {
    // fetch subnet
    $subnet_temp = $Addresses->transform_to_dotted($subnet['subnet']) . "/" . $subnet['mask'];
    //verify IP and subnet
    $Addresses->verify_address($Addresses->transform_address($_POST['ip_addr'], "dotted"), $subnet_temp, false, true);
    //check if already existing and die
    if ($Addresses->address_exists($Addresses->transform_address($_POST['ip_addr'], "decimal"), $subnet['id'])) {
        $Result->show("danger", _('IP address already exists'), true);
    }
    //insert to ipaddresses table
    $values = array("action" => "add", "ip_addr" => $Addresses->transform_address($_POST['ip_addr'], "decimal"), "subnetId" => $_POST['subnetId'], "description" => @$_POST['description'], "dns_name" => @$_POST['dns_name'], "mac" => @$_POST['mac'], "owner" => @$_POST['owner'], "state" => @$_POST['state'], "switch" => @$_POST['switch'], "port" => @$_POST['port'], "note" => @$_POST['note']);
    if (!$Addresses->modify_address($values)) {
        $Result->show("danger", _("Failed to create IP address"), true);
    }
    //accept message
    $values = array("id" => $_POST['requestId'], "processed" => 1, "accepted" => 1, "adminComment" => $comment);
    if (!$Admin->object_modify("requests", "edit", "id", $values)) {
        $Result->show("danger", _("Cannot confirm IP address"), true);