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


PHP is_iprange函数代码示例

本文整理汇总了PHP中is_iprange函数的典型用法代码示例。如果您正苦于以下问题:PHP is_iprange函数的具体用法?PHP is_iprange怎么用?PHP is_iprange使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了is_iprange函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: preg_replace

         $detail_text = $_POST["detail{$x}"];
     } else {
         /* Remove leading and trailing vertical bars and replace multiple vertical bars with single, */
         /* and put in the output array so the text is at least redisplayed for the user. */
         $detail_text = preg_replace('/\\|\\|+/', '|', trim($_POST["detail{$x}"], "|"));
         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++;
             }
开发者ID:jefersonJim,项目名称:pfsense,代码行数:31,代码来源:firewall_aliases_edit.php

示例2: explode

         break;
     }
 }
 if ($_POST['aliasimport']) {
     $tocheck = explode("\n", $_POST['aliasimport']);
     $imported_ips = array();
     $imported_descs = array();
     $desc_len_err_found = false;
     $desc_fmt_err_found = false;
     foreach ($tocheck as $impline) {
         $implinea = explode(" ", trim($impline), 2);
         $impip = $implinea[0];
         $impdesc = trim($implinea[1]);
         if (strlen($impdesc) < 200) {
             if (strpos($impdesc, "||") === false && substr($impdesc, 0, 1) != "|" && substr($impdesc, -1, 1) != "|") {
                 $iprange_type = is_iprange($impip);
                 if ($iprange_type == 4) {
                     list($startip, $endip) = explode('-', $impip);
                     $rangesubnets = ip_range_to_subnet_array($startip, $endip);
                     $imported_ips = array_merge($imported_ips, $rangesubnets);
                     $rangedescs = array_fill(0, count($rangesubnets), $impdesc);
                     $imported_descs = array_merge($imported_descs, $rangedescs);
                 } else {
                     if ($iprange_type == 6) {
                         $input_errors[] = sprintf(gettext('IPv6 address ranges are not supported (%s)'), $impip);
                     } else {
                         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);
                         } elseif (!empty($impip)) {
                             $imported_ips[] = $impip;
                             $imported_descs[] = $impdesc;
开发者ID:nwholloway,项目名称:pfsense,代码行数:31,代码来源:firewall_aliases_import.php

示例3: gettext

         }
     }
 } else {
     if ($_POST['type'] == "port") {
         if (!is_port($_POST["address{$x}"]) && !is_portrange($_POST["address{$x}"])) {
             $input_errors[] = $_POST["address{$x}"] . " " . gettext("is not a valid port or alias.");
         }
     } else {
         if ($_POST['type'] == "host" || $_POST['type'] == "network") {
             if (is_subnet($_POST["address{$x}"]) || !is_ipaddr($_POST["address{$x}"]) && !is_hostname($_POST["address{$x}"]) && !is_iprange($_POST["address{$x}"])) {
                 $input_errors[] = sprintf(gettext('%1$s is not a valid %2$s alias.'), $_POST["address{$x}"], $_POST['type']);
             }
         }
     }
 }
 if (is_iprange($_POST["address{$x}"])) {
     list($startip, $endip) = explode('-', $_POST["address{$x}"]);
     $rangesubnets = ip_range_to_subnet_array($startip, $endip);
     $address = array_merge($address, $rangesubnets);
 } else {
     $tmpaddress = $_POST["address{$x}"];
     if ($_POST['type'] != "host" && is_ipaddr($_POST["address{$x}"]) && $_POST["address_subnet{$x}"] != "") {
         if (!is_subnet($_POST["address{$x}"] . "/" . $_POST["address_subnet{$x}"])) {
             $input_errors[] = sprintf(gettext('%s/%s is not a valid subnet.'), $_POST["address{$x}"], $_POST["address_subnet{$x}"]);
         } else {
             $tmpaddress .= "/" . $_POST["address_subnet{$x}"];
         }
     }
     $address[] = $tmpaddress;
 }
 if ($_POST["detail{$x}"] != "") {
开发者ID:wcchandler,项目名称:pfsense,代码行数:31,代码来源:firewall_aliases_edit.php

示例4: explode

         break;
     }
 }
 if ($_POST['aliasimport']) {
     $tocheck = explode("\n", $_POST['aliasimport']);
     $imported_ips = array();
     $imported_descs = array();
     $desc_len_err_found = false;
     $desc_fmt_err_found = false;
     foreach ($tocheck as $impline) {
         $implinea = explode(" ", trim($impline), 2);
         $impip = $implinea[0];
         $impdesc = trim($implinea[1]);
         if (strlen($impdesc) < 200) {
             if (strpos($impdesc, "||") === false && substr($impdesc, 0, 1) != "|" && substr($impdesc, -1, 1) != "|") {
                 if (is_iprange($impip)) {
                     list($startip, $endip) = explode('-', $impip);
                     $rangesubnets = ip_range_to_subnet_array($startip, $endip);
                     $imported_ips = array_merge($imported_ips, $rangesubnets);
                     $rangedescs = array_fill(0, count($rangesubnets), $impdesc);
                     $imported_descs = array_merge($imported_descs, $rangedescs);
                 } else {
                     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);
                     } elseif (!empty($impip)) {
                         $imported_ips[] = $impip;
                         $imported_descs[] = $impdesc;
                     }
                 }
             } else {
                 if (!$desc_fmt_err_found) {
开发者ID:Toudix,项目名称:core,代码行数:31,代码来源:firewall_aliases_import.php


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