当前位置: 首页>>代码示例>>PHP>>正文


PHP ip_range_to_subnet_array函数代码示例

本文整理汇总了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) {
开发者ID:alisamar,项目名称:core,代码行数:31,代码来源:firewall_aliases_import.php

示例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) {
开发者ID:jefersonJim,项目名称:pfsense,代码行数:31,代码来源:firewall_aliases_edit.php

示例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) {
开发者ID:rdmenezes,项目名称:pfsense,代码行数:31,代码来源:firewall_nat_out.php


注:本文中的ip_range_to_subnet_array函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。