$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++;
             }
         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;
         }
     }
 } 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}"] != "") {
示例#4
0
         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) {