本文整理汇总了PHP中is_inrange_v4函数的典型用法代码示例。如果您正苦于以下问题:PHP is_inrange_v4函数的具体用法?PHP is_inrange_v4怎么用?PHP is_inrange_v4使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_inrange_v4函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gettext
$existingFqn = "{$mapent['hostname']}.{$mapent['domain']}";
$candidateFqn = "{$_POST['hostname']}.{$_POST['domain']}";
if ($existingFqn == $candidateFqn && $mapent['hostname'] || $mapent['mac'] == $_POST['mac'] && $mapent['mac'] || $mapent['ipaddr'] == $_POST['ipaddr'] && $mapent['ipaddr'] || $mapent['cid'] == $_POST['cid'] && $mapent['cid']) {
$input_errors[] = gettext("This fully qualified hostname (Hostname + Domainname), IP, MAC address or Client identifier already exists.");
break;
}
}
/* make sure it's not within the dynamic subnet */
if ($_POST['ipaddr']) {
$dynsubnet_start = ip2ulong($config['dhcpd'][$if]['range']['from']);
$dynsubnet_end = ip2ulong($config['dhcpd'][$if]['range']['to']);
if (ip2ulong($_POST['ipaddr']) >= $dynsubnet_start && ip2ulong($_POST['ipaddr']) <= $dynsubnet_end) {
$input_errors[] = sprintf(gettext("The IP address must not be within the DHCP range for this interface."));
}
foreach ($a_pools as $pidx => $p) {
if (is_inrange_v4($_POST['ipaddr'], $p['range']['from'], $p['range']['to'])) {
$input_errors[] = gettext("The IP address must not be within the range configured on a DHCP pool for this interface.");
break;
}
}
$lansubnet_start = ip2ulong(gen_subnetv4($ifcfgip, $ifcfgsn));
$lansubnet_end = ip2ulong(gen_subnetv4_max($ifcfgip, $ifcfgsn));
$ipaddr_int = ip2ulong($_POST['ipaddr']);
if ($ipaddr_int < $lansubnet_start || $ipaddr_int > $lansubnet_end) {
$input_errors[] = sprintf(gettext("The IP address must lie in the %s subnet."), $ifcfgdescr);
}
if ($ipaddr_int == $lansubnet_start) {
$input_errors[] = sprintf(gettext("The IP address cannot be the %s network address."), $ifcfgdescr);
}
if ($ipaddr_int == $lansubnet_end) {
$input_errors[] = sprintf(gettext("The IP address cannot be the %s broadcast address."), $ifcfgdescr);
示例2: gettext
$input_errors[] = gettext("A valid IP address or hostname must be specified for the TFTP server.");
}
if ($_POST['nextserver'] && !is_ipaddrv4($_POST['nextserver'])) {
$input_errors[] = gettext("A valid IP address must be specified for the network boot server.");
}
if (gen_subnet($ifcfgip, $ifcfgsn) == $_POST['range_from']) {
$input_errors[] = gettext("You cannot use the network address in the starting subnet range.");
}
if (gen_subnet_max($ifcfgip, $ifcfgsn) == $_POST['range_to']) {
$input_errors[] = gettext("You cannot use the broadcast address in the ending subnet range.");
}
// Disallow a range that includes the virtualip
if (is_array($config['virtualip']['vip'])) {
foreach ($config['virtualip']['vip'] as $vip) {
if ($vip['interface'] == $if) {
if ($vip['subnet'] && is_inrange_v4($vip['subnet'], $_POST['range_from'], $_POST['range_to'])) {
$input_errors[] = sprintf(gettext("The subnet range cannot overlap with virtual IP address %s."), $vip['subnet']);
}
}
}
}
$noip = false;
if (is_array($a_maps)) {
foreach ($a_maps as $map) {
if (empty($map['ipaddr'])) {
$noip = true;
}
}
}
if ($_POST['staticarp'] && $noip) {
$input_errors[] = gettext("Cannot enable static ARP when you have static map entries without IP addresses. Ensure all static maps have IP addresses and try again.");
示例3: gettext
}
if (ip2ulong($_POST['range_from']) > ip2ulong($_POST['range_to'])) {
$input_errors[] = gettext("The range is invalid (first element higher than second element).");
}
if (is_numeric($pool) || $act == "newpool") {
$rfrom = $config['dhcpd'][$if]['range']['from'];
$rto = $config['dhcpd'][$if]['range']['to'];
if (is_inrange_v4($_POST['range_from'], $rfrom, $rto) || is_inrange_v4($_POST['range_to'], $rfrom, $rto)) {
$input_errors[] = gettext("The specified range must not be within the DHCP range for this interface.");
}
}
foreach ($a_pools as $id => $p) {
if (is_numeric($pool) && $id == $pool) {
continue;
}
if (is_inrange_v4($_POST['range_from'], $p['range']['from'], $p['range']['to']) || is_inrange_v4($_POST['range_to'], $p['range']['from'], $p['range']['to'])) {
$input_errors[] = gettext("The specified range must not be within the range configured on a DHCP pool for this interface.");
break;
}
}
/* make sure that the DHCP Relay isn't enabled on this interface */
if (isset($config['dhcrelay']['enable']) && stristr($config['dhcrelay']['interface'], $if) !== false) {
$input_errors[] = sprintf(gettext("You must disable the DHCP relay on the %s interface before enabling the DHCP server."), $iflist[$if]);
}
$dynsubnet_start = ip2ulong($_POST['range_from']);
$dynsubnet_end = ip2ulong($_POST['range_to']);
if (is_array($a_maps)) {
foreach ($a_maps as $map) {
if (empty($map['ipaddr'])) {
continue;
}
示例4: gettext
$input_errors[] = gettext("A valid remote start address must be specified.");
}
if ($_POST['radiusserver'] && !is_ipaddr($_POST['radiusserver'])) {
$input_errors[] = gettext("A valid RADIUS server address must be specified.");
}
if (!is_numericint($_POST['n_pppoe_units']) || $_POST['n_pppoe_units'] > 255) {
$input_errors[] = gettext("Number of PPPoE users must be between 1 and 255");
}
if (!is_numericint($_POST['n_pppoe_maxlogin']) || $_POST['n_pppoe_maxlogin'] > 255) {
$input_errors[] = gettext("User Max Logins must be between 1 and 255");
}
if (!is_numericint($_POST['pppoe_subnet']) || $_POST['pppoe_subnet'] > 32) {
$input_errors[] = gettext("Subnet mask must be an interger between 0 and 32");
}
$_POST['remoteip'] = $pconfig['remoteip'] = gen_subnet($_POST['remoteip'], $_POST['pppoe_subnet']);
if (is_inrange_v4($_POST['localip'], $_POST['remoteip'], ip_after($_POST['remoteip'], $_POST['pppoe_subnet'] - 1))) {
$input_errors[] = gettext("The specified server address lies in the remote subnet.");
}
if ($_POST['localip'] == get_interface_ip($_POST['interface'])) {
$input_errors[] = gettext("The specified server address is equal to an interface ip address.");
}
for ($x = 0; $x < 4999; $x++) {
if ($_POST["username{$x}"]) {
if (empty($_POST["password{$x}"])) {
$input_errors[] = sprintf(gettext("No password specified for username %s"), $_POST["username{$x}"]);
}
if ($_POST["ip{$x}"] != "" && !is_ipaddr($_POST["ip{$x}"])) {
$input_errors[] = sprintf(gettext("Incorrect ip address specified for username %s"), $_POST["username{$x}"]);
}
}
}
示例5: sprintf
}
}
/* make sure it's not within the dynamic subnet */
if ($_POST['ipaddr']) {
if (is_inrange_v4($_POST['ipaddr'], $config['dhcpd'][$if]['range']['from'], $config['dhcpd'][$if]['range']['to'])) {
$input_errors[] = sprintf(gettext("The IP address must not be within the DHCP range for this interface."));
}
foreach ($a_pools as $pidx => $p) {
if (is_inrange_v4($_POST['ipaddr'], $p['range']['from'], $p['range']['to'])) {
$input_errors[] = gettext("The IP address must not be within the range configured on a DHCP pool for this interface.");
break;
}
}
$lansubnet_start = gen_subnetv4($ifcfgip, $ifcfgsn);
$lansubnet_end = gen_subnetv4_max($ifcfgip, $ifcfgsn);
if (!is_inrange_v4($_POST['ipaddr'], $lansubnet_start, $lansubnet_end)) {
$input_errors[] = sprintf(gettext("The IP address must lie in the %s subnet."), $ifcfgdescr);
}
if ($_POST['ipaddr'] == $lansubnet_start) {
$input_errors[] = sprintf(gettext("The IP address cannot be the %s network address."), $ifcfgdescr);
}
if ($_POST['ipaddr'] == $lansubnet_end) {
$input_errors[] = sprintf(gettext("The IP address cannot be the %s broadcast address."), $ifcfgdescr);
}
}
if ($_POST['gateway'] && !is_ipaddrv4($_POST['gateway'])) {
$input_errors[] = gettext("A valid IP address must be specified for the gateway.");
}
if ($_POST['wins1'] && !is_ipaddrv4($_POST['wins1']) || $_POST['wins2'] && !is_ipaddrv4($_POST['wins2'])) {
$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary WINS servers.");
}
示例6: foreach
continue;
}
if (is_inrange_v4($data['ip'], $dhcpifconf['range']['from'], $dhcpifconf['range']['to'])) {
$data['if'] = $dhcpif;
$dlskey = $dhcpif . "-" . $dhcpifconf['range']['from'];
$dhcp_leases_subnet_counter[$dlskey]['dhcpif'] = $dhcpif;
$dhcp_leases_subnet_counter[$dlskey]['from'] = $dhcpifconf['range']['from'];
$dhcp_leases_subnet_counter[$dlskey]['to'] = $dhcpifconf['range']['to'];
$dhcp_leases_subnet_counter[$dlskey]['count'] += 1;
break;
}
// Check if the IP is in the range of any DHCP pools
if (is_array($dhcpifconf['pool'])) {
foreach ($dhcpifconf['pool'] as $dhcppool) {
if (is_array($dhcppool['range'])) {
if (is_inrange_v4($data['ip'], $dhcppool['range']['from'], $dhcppool['range']['to'])) {
$data['if'] = $dhcpif;
$dlskey = $dhcpif . "-" . $dhcppool['range']['from'];
$dhcp_leases_subnet_counter[$dlskey]['dhcpif'] = $dhcpif;
$dhcp_leases_subnet_counter[$dlskey]['from'] = $dhcppool['range']['from'];
$dhcp_leases_subnet_counter[$dlskey]['to'] = $dhcppool['range']['to'];
$dhcp_leases_subnet_counter[$dlskey]['count'] += 1;
break 2;
}
}
}
}
}
}
$mac = $data['mac'];
$mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]);
示例7: gettext
$input_errors[] = gettext("Secret and confirmation must match");
}
if ($_POST['radiussecret'] != $_POST['radiussecret_confirm']) {
$input_errors[] = gettext("Secret and confirmation must match");
}
if (!is_numericint($_POST['n_l2tp_units']) || $_POST['n_l2tp_units'] > 255) {
$input_errors[] = gettext("Number of L2TP users must be between 1 and 255");
}
/* if this is an AJAX caller then handle via JSON */
if (isAjax() && is_array($input_errors)) {
input_errors2Ajax($input_errors);
exit;
}
if (!$input_errors) {
$_POST['remoteip'] = $pconfig['remoteip'] = gen_subnet($_POST['remoteip'], $_POST['l2tp_subnet']);
if (is_inrange_v4($_POST['localip'], $_POST['remoteip'], ip_after($_POST['remoteip'], $_POST['n_l2tp_units'] - 1))) {
$input_errors[] = gettext("The specified server address lies in the remote subnet.");
}
if ($_POST['localip'] == get_interface_ip("lan")) {
$input_errors[] = gettext("The specified server address is equal to the LAN interface address.");
}
}
}
/* if this is an AJAX caller then handle via JSON */
if (isAjax() && is_array($input_errors)) {
input_errors2Ajax($input_errors);
exit;
}
if (!$input_errors) {
$l2tpcfg['remoteip'] = $_POST['remoteip'];
$l2tpcfg['localip'] = $_POST['localip'];
示例8: gettext
}
if (is_inrange_v4($_POST['range_from'], $p['range']['from'], $p['range']['to']) || is_inrange_v4($_POST['range_to'], $p['range']['from'], $p['range']['to'])) {
$input_errors[] = gettext("The specified range must not be within the range configured on a DHCP pool for this interface.");
break;
}
}
/* make sure that the DHCP Relay isn't enabled on this interface */
if (isset($config['dhcrelay']['enable']) && stristr($config['dhcrelay']['interface'], $if) !== false) {
$input_errors[] = sprintf(gettext("The DHCP relay on the %s interface must be disabled before enabling the DHCP server."), $iflist[$if]);
}
if (is_array($a_maps)) {
foreach ($a_maps as $map) {
if (empty($map['ipaddr'])) {
continue;
}
if (is_inrange_v4($map['ipaddr'], $_POST['range_from'], $_POST['range_to'])) {
$input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings."));
break;
}
}
}
}
}
if (!$input_errors) {
if (!is_numeric($pool)) {
if ($act == "newpool") {
$dhcpdconf = array();
} else {
if (!is_array($config['dhcpd'][$if])) {
$config['dhcpd'][$if] = array();
}
示例9: foreach
foreach ($config['dhcpd'][$ifname]['staticmap'] as $static) {
$slease = array();
$slease['ip'] = $static['ipaddr'];
$slease['act'] = "static";
$slease['staticmap_array_index'] = $staticmap_array_index;
$leases[] = $slease;
$staticmap_array_index++;
}
}
}
$ifcfgip = get_interface_ip($dhcpif);
$ifcfgsn = get_interface_subnet($dhcpif);
$subnet_start = gen_subnetv4($ifcfgip, $ifcfgsn);
$subnet_end = gen_subnetv4_max($ifcfgip, $ifcfgsn);
$result['range'] = ip_range_size_v4($config['dhcpd'][$dhcpif]['range']['from'], $config['dhcpd'][$dhcpif]['range']['to']);
foreach ($leases as $data) {
if ($data['act'] != "active" && $data['act'] != "static" && $_GET['all'] != 1) {
continue;
}
if ($data['act'] != "static") {
if (is_inrange_v4($data['ip'], $config['dhcpd'][$dhcpif]['range']['from'], $config['dhcpd'][$dhcpif]['range']['to'])) {
$result['active'] = $result['active'] + 1;
}
} else {
if (is_inrange_v4($data['ip'], $subnet_start, $subnet_end)) {
$result['static'] = $result['static'] + 1;
}
}
}
}
echo $result['active'] . ":" . $result['static'] . ":" . $result['range'];
示例10: elseif
continue;
}
if ($data['act'] == $active_string) {
$icon = 'fa-check-circle-o';
} elseif ($data['act'] == $expired_string) {
$icon = 'fa-ban';
} else {
$icon = 'fa-times-circle-o';
}
if ($data['act'] != $static_string) {
$dlsc = 0;
foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf) {
if (!is_array($dhcpifconf['range'])) {
continue;
}
if (is_inrange_v4($data['ip'], $dhcpifconf['range']['from'], $dhcpifconf['range']['to'])) {
$data['if'] = $dhcpif;
$dhcp_leases_subnet_counter[$dlsc]['dhcpif'] = $dhcpif;
$dhcp_leases_subnet_counter[$dlsc]['from'] = $dhcpifconf['range']['from'];
$dhcp_leases_subnet_counter[$dlsc]['to'] = $dhcpifconf['range']['to'];
$dhcp_leases_subnet_counter[$dlsc]['count'] = $dhcp_leases_subnet_counter[$dlsc]['count'] + 1;
break;
}
$dlsc++;
}
}
$mac = $data['mac'];
$mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]);
?>
<tr>
<td><i class="fa <?php