$input_errors[] = gettext("A valid IPv4 network bit count must be specified.");
     }
 }
 if ($_POST['network'] && is_ipv6addr($_POST['network']) && $_POST['network_subnet']) {
     if (filter_var($_POST['network_subnet'], FILTER_VALIDATE_INT, array('options' => array('min_range' => 1, 'max_range' => 128))) == false) {
         $input_errors[] = gettext("A valid IPv6 prefix must be specified.");
     }
 }
 if ($_POST['gateway'] && !is_ipaddr($_POST['gateway'])) {
     $input_errors[] = gettext("A valid gateway IP address must be specified.");
 }
 if ($_POST['gateway'] && $_POST['network']) {
     if (is_ipv4addr($_POST['gateway']) && !is_ipv4addr($_POST['network'])) {
         $input_errors[] = gettext("You must enter the same IP type for network and gateway.");
     } else {
         if (is_ipv6addr($_POST['gateway']) && !is_ipv6addr($_POST['network'])) {
             $input_errors[] = gettext("IP type mismatch for network and gateway.");
         }
     }
 }
 // Check for overlaps
 // gen_subnet work for IPv4 only... This function permit to fix user input error for network number.
 if (is_ipv4addr($_POST['network'])) {
     $osn = gen_subnet($_POST['network'], $_POST['network_subnet']) . "/" . $_POST['network_subnet'];
 } else {
     $osn = $_POST['network'] . "/" . $_POST['network_subnet'];
 }
 $index = array_search_ex($osn, $a_routes, "network");
 if (FALSE !== $index) {
     if (!(FALSE !== $cnid && $a_routes[$cnid]['uuid'] === $a_routes[$index]['uuid'])) {
         $input_errors[] = gettext("A route to this destination network already exists.");
Beispiel #2
0
     if ($_POST['type'] === "Static") {
         $reqdfields = explode(" ", "descr ipaddr subnet");
         $reqdfieldsn = array(gettext("Description"), gettext("IP address"), gettext("Subnet bit count"));
         do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
         if ($_POST['ipaddr'] && !is_ipv4addr($_POST['ipaddr'])) {
             $input_errors[] = gettext("A valid IP address must be specified.");
         }
         if ($_POST['subnet'] && !filter_var($_POST['subnet'], FILTER_VALIDATE_INT, array('options' => array('min_range' => 1, 'max_range' => 32)))) {
             $input_errors[] = gettext("A valid network bit count (1-32) must be specified.");
         }
     }
     if (isset($_POST['ipv6_enable']) && $_POST['ipv6_enable'] && $_POST['ipv6type'] === "Static") {
         $reqdfields = explode(" ", "ipv6addr ipv6subnet");
         $reqdfieldsn = array(gettext("IPv6 address"), gettext("Prefix"));
         do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
         if ($_POST['ipv6addr'] && !is_ipv6addr($_POST['ipv6addr'])) {
             $input_errors[] = gettext("A valid IPv6 address must be specified.");
         }
         if ($_POST['ipv6subnet'] && !filter_var($_POST['ipv6subnet'], FILTER_VALIDATE_INT, array('options' => array('min_range' => 1, 'max_range' => 128)))) {
             $input_errors[] = gettext("A valid prefix (1-128) must be specified.");
         }
         if ($_POST['mtu'] && !is_mtu($_POST['mtu'])) {
             $input_errors[] = gettext("A valid mtu size must be specified.");
         }
     }
 }
 // Wireless interface?
 if (isset($optcfg['wireless'])) {
     $wi_input_errors = wireless_config_post();
     if ($wi_input_errors) {
         if (is_array($input_errors)) {
 // Check for duplicates.
 $index = array_search_ex($_POST['tag'], $config['iscsitarget']['portalgroup'], "tag");
 if (FALSE !== $index) {
     if (!(FALSE !== $cnid && $config['iscsitarget']['portalgroup'][$cnid]['uuid'] === $config['iscsitarget']['portalgroup'][$index]['uuid'])) {
         $input_errors[] = gettext("This tag already exists.");
     }
 }
 $portals = array();
 foreach (explode("\n", $_POST['portals']) as $portal) {
     $portal = trim($portal, " \t\r\n");
     if (!empty($portal)) {
         if (preg_match("/^\\[([0-9a-fA-F:]+)\\](:([0-9]+))?\$/", $portal, $tmp)) {
             // IPv6
             $addr = normalize_ipv6addr($tmp[1]);
             $port = isset($tmp[3]) ? $tmp[3] : 3260;
             if (!is_ipv6addr($addr) || $port < 1 || $port > 65535) {
                 $input_errors[] = sprintf(gettext("The portal '%s' is invalid."), $portal);
             }
             $portals[] = sprintf("[%s]:%d", $addr, $port);
         } else {
             if (preg_match("/^([0-9\\.]+)(:([0-9]+))?\$/", $portal, $tmp)) {
                 // IPv4
                 $addr = $tmp[1];
                 $port = isset($tmp[3]) ? $tmp[3] : 3260;
                 if (!is_ipv4addr($addr) || $port < 1 || $port > 65535) {
                     $input_errors[] = sprintf(gettext("The portal '%s' is invalid."), $portal);
                 }
                 $portals[] = sprintf("%s:%d", $addr, $port);
             } else {
                 $input_errors[] = sprintf(gettext("The portal '%s' is invalid."), $portal);
             }
Beispiel #4
0
     $reqdfieldst = array_merge($reqdfieldst, array("port"));
 }
 do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
 do_input_validation_type($_POST, $reqdfields, $reqdfieldsn, $reqdfieldst, $input_errors);
 if (!empty($_POST['webguihostsallow'])) {
     foreach (explode(' ', $_POST['webguihostsallow']) as $a) {
         list($hp, $np) = explode('/', $a);
         if (!is_ipaddr($hp) || !empty($np) && !is_subnet($a)) {
             $input_errors[] = gettext("A valid IP address or CIDR notation must be specified for the hosts allow.");
         }
     }
 }
 if ($_POST['dns1'] && !is_ipv4addr($_POST['dns1']) || $_POST['dns2'] && !is_ipv4addr($_POST['dns2'])) {
     $input_errors[] = gettext("A valid IPv4 address must be specified for the primary/secondary DNS server.");
 }
 if ($_POST['ipv6dns1'] && !is_ipv6addr($_POST['ipv6dns1']) || $_POST['ipv6dns2'] && !is_ipv6addr($_POST['ipv6dns2'])) {
     $input_errors[] = gettext("A valid IPv6 address must be specified for the primary/secondary DNS server.");
 }
 if (isset($_POST['ntp_enable'])) {
     $t = (int) $_POST['ntp_updateinterval'];
     if ($t < 0 || $t > 0 && $t < 6 || $t > 1440) {
         $input_errors[] = gettext("The time update interval must be either between 6 and 1440.");
     }
     foreach (explode(' ', $_POST['ntp_timeservers']) as $ts) {
         if (!is_domain($ts)) {
             $input_errors[] = gettext("A NTP time server name may only contain the characters a-z, 0-9, '-' and '.'.");
         }
     }
 }
 // Check if port is already used.
 if (services_is_port_used(!empty($_POST['webguiport']) ? $_POST['webguiport'] : 80, "sysgui")) {
     }
     if ($_POST['subnet'] && !filter_var($_POST['subnet'], FILTER_VALIDATE_INT, array('options' => array('min_range' => 1, 'max_range' => 32)))) {
         $input_errors[] = gettext("A valid network bit count (1-32) must be specified.");
     }
 }
 if ($_POST['ipv6_enable'] && $_POST['ipv6type'] === "Static") {
     $reqdfields = explode(" ", "ipv6addr ipv6subnet");
     $reqdfieldsn = array(gettext("IPv6 address"), gettext("Prefix"));
     do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
     if ($_POST['ipv6addr'] && !is_ipv6addr($_POST['ipv6addr'])) {
         $input_errors[] = gettext("A valid IPv6 address must be specified.");
     }
     if ($_POST['ipv6subnet'] && !filter_var($_POST['ipv6subnet'], FILTER_VALIDATE_INT, array('options' => array('min_range' => 1, 'max_range' => 128)))) {
         $input_errors[] = gettext("A valid prefix (1-128) must be specified.");
     }
     if ($_POST['ipv6gatewayr'] && !is_ipv6addr($_POST['ipv6gateway'])) {
         $input_errors[] = gettext("A valid IPv6 Gateway address must be specified.");
     }
 }
 // Wireless interface?
 if (isset($lancfg['wireless'])) {
     $wi_input_errors = wireless_config_post();
     if ($wi_input_errors) {
         if (is_array($input_errors)) {
             $input_errors = array_merge($input_errors, $wi_input_errors);
         } else {
             $input_errors = $wi_input_errors;
         }
     }
 }
 if (!$input_errors) {
     if (!empty($initiator)) {
         $initiators[] = sprintf("%s", $initiator);
     }
 }
 if (count($initiators) == 0) {
     $input_errors[] = sprintf(gettext("The attribute '%s' is required."), gettext("Initiators"));
 }
 $netmasks = array();
 foreach (explode("\n", $_POST['netmasks']) as $netmask) {
     $netmask = trim($netmask, " \t\r\n");
     if (!empty($netmask)) {
         if (preg_match("/^\\[([0-9a-fA-F:]+)\\](\\/([0-9]+))?\$/", $netmask, $tmp)) {
             // IPv6
             $addr = normalize_ipv6addr($tmp[1]);
             $mask = isset($tmp[3]) ? $tmp[3] : 128;
             if (!is_ipv6addr($addr) || $mask < 0 || $mask > 128) {
                 $input_errors[] = sprintf(gettext("The network '%s' is invalid."), $netmask);
             }
             $netmasks[] = sprintf("[%s]/%d", $addr, $mask);
         } else {
             if (preg_match("/^([0-9\\.]+)(\\/([0-9]+))?\$/", $netmask, $tmp)) {
                 // IPv4
                 $addr = $tmp[1];
                 $mask = isset($tmp[3]) ? $tmp[3] : 32;
                 if (!is_ipv4addr($addr) || $mask < 0 || $mask > 32) {
                     $input_errors[] = sprintf(gettext("The network '%s' is invalid."), $netmask);
                 }
                 $netmasks[] = sprintf("%s/%d", $addr, $mask);
             } else {
                 if (strcasecmp("ALL", $netmask) == 0) {
                     $netmasks[] = sprintf("%s", $netmask);