本文整理汇总了PHP中Addresses::get_first_available_address方法的典型用法代码示例。如果您正苦于以下问题:PHP Addresses::get_first_available_address方法的具体用法?PHP Addresses::get_first_available_address怎么用?PHP Addresses::get_first_available_address使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Addresses
的用法示例。
在下文中一共展示了Addresses::get_first_available_address方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: provided
$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);
示例2: explode
$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 {
示例3: _
<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>