$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);
$selected_ip_fields = $User->settings->IPfilter; $selected_ip_fields = explode(";", $selected_ip_fields); //format to array # get all custom fields $custom_fields = $Tools->fetch_custom_fields('ipaddresses'); # if subnet is full we cannot any more ip addresses if (($action == "add" || $action == "all-add") && $subnet['isFull'] == 1) { $Result->show("warning", _("Cannot add address as subnet is market as used"), true, true); } # if action is not add then fetch current details, otherwise fetch first available IP address if ($action == "all-add") { $address['ip_addr'] = $Subnets->transform_address($id, "dotted"); } else { if ($action == "add") { # get first available IP address $first = $Addresses->get_first_available_address($subnetId, $Subnets); $first = !$first ? "" : $Subnets->transform_address($first, "dotted"); $address['ip_addr'] = $first; } else { $address = (array) $Addresses->fetch_address(null, $id); } } # Set action and button text if ($action == "add") { $btnName = _("add"); $act = "add"; } else { if ($action == "all-add") { $btnName = _("add"); $act = "add"; } else {
<div class="pContent editIPAddress"> <form name="requestIP" id="requestIP"> <table id="requestIP" class="table table-condensed"> <tr> <td><?php print _('IP address'); ?> *</td> <td> <?php require_once '../../../functions/functions.php'; # get first IP address $first = $Subnets->transform_to_dotted($Addresses->get_first_available_address($_POST['subnetId'], $Subnets)); # get subnet details $subnet = (array) $Subnets->fetch_subnet(null, $_POST['subnetId']); ?> <input type="text" name="ip_addr" class="ip_addr form-control" size="30" value="<?php print $first; ?> "> <input type="hidden" name="subnetId" value="<?php print $subnet['id']; ?> "> </td> </tr>