Пример #1
0
 do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
 /* either MAC or Client-ID must be specified */
 if (empty($_POST['mac']) && empty($_POST['cid'])) {
     $input_errors[] = gettext("Either MAC address or Client identifier must be specified");
 }
 /* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
 $_POST['mac'] = strtolower(str_replace("-", ":", $_POST['mac']));
 if ($_POST['hostname']) {
     preg_match("/\\-\$/", $_POST['hostname'], $matches);
     if ($matches) {
         $input_errors[] = gettext("The hostname cannot end with a hyphen according to RFC952");
     }
     if (!is_hostname($_POST['hostname'])) {
         $input_errors[] = gettext("The hostname can only contain the characters A-Z, 0-9 and '-'.");
     } else {
         if (!is_unqualified_hostname($_POST['hostname'])) {
             $input_errors[] = gettext("A valid hostname is specified, but the domain name part should be omitted");
         }
     }
 }
 if ($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr'])) {
     $input_errors[] = gettext("A valid IP address must be specified.");
 }
 if ($_POST['mac'] && !is_macaddr($_POST['mac'])) {
     $input_errors[] = gettext("A valid MAC address must be specified.");
 }
 if ($static_arp_enabled && !$_POST['ipaddr']) {
     $input_errors[] = gettext("Static ARP is enabled.  You must specify an IP address.");
 }
 /* check for overlaps */
 foreach ($a_maps as $mapent) {
     }
     if (ctype_digit($entry)) {
         $aliases[$entry][$field] = $value;
     }
 }
 $pconfig['aliases']['item'] = $aliases;
 /* validate aliases */
 foreach ($aliases as $idx => $alias) {
     $aliasreqdfields = array('aliasdomain' . $idx);
     $aliasreqdfieldsn = array(gettext("Alias Domain"));
     do_input_validation($_POST, $aliasreqdfields, $aliasreqdfieldsn, $input_errors);
     if ($alias['host']) {
         if (!is_hostname($alias['host'])) {
             $input_errors[] = gettext("Hostnames in an alias list can only contain the characters A-Z, 0-9 and '-'. They may not start or end with '-'.");
         } else {
             if (!is_unqualified_hostname($alias['host'])) {
                 $input_errors[] = gettext("A valid alias hostname is specified, but the domain name part should be omitted");
             }
         }
     }
     if ($alias['domain'] && !is_domain($alias['domain'])) {
         $input_errors[] = gettext("A valid domain must be specified in alias list.");
     }
 }
 /* check for overlaps */
 foreach ($a_hosts as $hostent) {
     if (isset($id) && $a_hosts[$id] && $a_hosts[$id] === $hostent) {
         continue;
     }
     if ($hostent['host'] == $_POST['host'] && $hostent['domain'] == $_POST['domain'] && (is_ipaddrv4($hostent['ip']) && is_ipaddrv4($_POST['ip']) || is_ipaddrv6($hostent['ip']) && is_ipaddrv6($_POST['ip']))) {
         $input_errors[] = gettext("This host/domain already exists.");