Fix hostname checking when entering a dhcp static mapping and replace "." with "_" when writing "host-name" option in dhcpd.conf. Resolves #159

This commit is contained in:
pierrepomes 2009-11-27 16:57:48 -05:00
parent 64fba8ec93
commit 46c5b763ef
2 changed files with 9 additions and 2 deletions

View File

@ -341,6 +341,7 @@ EOD;
if ($sm['hostname']) {
$dhhostname = str_replace(" ", "_", $sm['hostname']);
$dhhostname = str_replace(".", "_", $dhhostname);
$dhcpdconf .= " option host-name {$dhhostname};\n";
}

View File

@ -109,8 +109,14 @@ if ($_POST) {
/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
$_POST['mac'] = strtolower(str_replace("-", ":", $_POST['mac']));
if (($_POST['hostname'] && !is_hostname($_POST['hostname']))) {
$input_errors[] = "A valid host name must be specified.";
if ($_POST['hostname']) {
if (!is_hostname($_POST['hostname'])) {
$input_errors[] = "A valid host name must be specified.";
} else {
if (strpos($_POST['hostname'],'.')) {
$input_errors[] = "A valid hostname is specified, but the domain name part should be omitted";
}
}
}
if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) {
$input_errors[] = "A valid IP address must be specified.";