本文整理汇总了PHP中ip_range_to_subnet_array函数的典型用法代码示例。如果您正苦于以下问题:PHP ip_range_to_subnet_array函数的具体用法?PHP ip_range_to_subnet_array怎么用?PHP ip_range_to_subnet_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ip_range_to_subnet_array函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: substr
// trim and truncate description to max 200 characters
$impdesc = substr(trim($implinea[1]), 0, 200);
} else {
// no description given, use alias description
$impdesc = trim(str_replace('|', ' ', $pconfig['descr']));
}
if (strpos($impip, '-') !== false) {
// ip range provided
$ipaddr1 = explode('-', $impip)[0];
$ipaddr2 = explode('-', $impip)[1];
if (!is_ipaddr($ipaddr1)) {
$input_errors[] = sprintf(gettext("%s is not an IP address. Please correct the error to continue"), $ipaddr1);
} elseif (!is_ipaddr($ipaddr2)) {
$input_errors[] = sprintf(gettext("%s is not an IP address. Please correct the error to continue"), $ipaddr2);
} else {
foreach (ip_range_to_subnet_array($ipaddr1, $ipaddr2) as $network) {
$imported_ips[] = $network;
$imported_descs[] = $impdesc;
}
}
} else {
// single ip or network
if (!is_ipaddr($impip) && !is_subnet($impip) && !is_hostname($impip) && !empty($impip)) {
$input_errors[] = sprintf(gettext("%s is not an IP address. Please correct the error to continue"), $impip);
} else {
$imported_ips[] = $impip;
$imported_descs[] = $impdesc;
}
}
}
if (count($input_errors) == 0) {
示例2: sprintf
if (!$desc_fmt_err_found) {
$input_errors[] = $vertical_bar_err_text;
$desc_fmt_err_found = true;
}
}
} else {
$detail_text = sprintf(gettext("Entry added %s"), date('r'));
}
$address_items = explode(" ", trim($_POST["address{$x}"]));
foreach ($address_items as $address_item) {
$iprange_type = is_iprange($address_item);
if ($iprange_type == 4) {
list($startip, $endip) = explode('-', $address_item);
if ($_POST['type'] == "network") {
// For network type aliases, expand an IPv4 range into an array of subnets.
$rangesubnets = ip_range_to_subnet_array($startip, $endip);
foreach ($rangesubnets as $rangesubnet) {
if ($alias_address_count > $max_alias_addresses) {
break;
}
list($address_part, $subnet_part) = explode("/", $rangesubnet);
$input_addresses[] = $address_part;
$input_address_subnet[] = $subnet_part;
$final_address_details[] = $detail_text;
$alias_address_count++;
}
} else {
// For host type aliases, expand an IPv4 range into a list of individual IPv4 addresses.
$rangeaddresses = ip_range_to_address_array($startip, $endip, $max_alias_addresses - $alias_address_count);
if (is_array($rangeaddresses)) {
foreach ($rangeaddresses as $rangeaddress) {
示例3: array
$natent['natport'] = "";
$a_out[] = $natent;
$natent = array();
$natent['source']['network'] = "127.0.0.0/8";
$natent['dstport'] = "";
$natent['descr'] = sprintf(gettext('Auto created rule for localhost to %1$s'), $ifdesc2);
$natent['target'] = "";
$natent['interface'] = $if2;
$natent['destination']['any'] = true;
$natent['staticnatport'] = false;
$natent['natport'] = "1024:65535";
$a_out[] = $natent;
/* PPTP subnet */
if ($config['pptpd']['mode'] == "server" && is_private_ip($config['pptpd']['remoteip'])) {
$pptptopip = $config['pptpd']['n_pptp_units'] - 1;
$pptp_subnets = ip_range_to_subnet_array($config['pptpd']['remoteip'], long2ip32(ip2long($config['pptpd']['remoteip']) + $pptptopip));
foreach ($pptp_subnets as $pptpsn) {
$natent = array();
$natent['source']['network'] = $pptpsn;
$natent['sourceport'] = "";
$natent['descr'] = gettext("Auto created rule for PPTP server");
$natent['target'] = "";
$natent['interface'] = $if2;
$natent['destination']['any'] = true;
$natent['natport'] = "";
$a_out[] = $natent;
}
}
/* PPPoE subnet */
if (is_pppoe_server_enabled() && have_ruleint_access("pppoe")) {
foreach ($config['pppoes']['pppoe'] as $pppoes) {