summaryrefslogtreecommitdiffstats
path: root/src/usr/local/www/services_dnsmasq_edit.php
diff options
context:
space:
mode:
authorStephen Beaver <sbeaver@netgate.com>2015-12-14 11:19:23 -0500
committerStephen Beaver <sbeaver@netgate.com>2015-12-14 11:19:50 -0500
commit39609bf9959f77394943f05352d4cab095a8a2c6 (patch)
tree8cc537a0f4cff6e37aea3c52ff8af3725a1933a2 /src/usr/local/www/services_dnsmasq_edit.php
parentfd6cd92bc4225bb6b41487b32e533e2544d18163 (diff)
downloadpfsense-39609bf9959f77394943f05352d4cab095a8a2c6.zip
pfsense-39609bf9959f77394943f05352d4cab095a8a2c6.tar.gz
Fixed #5638
Diffstat (limited to 'src/usr/local/www/services_dnsmasq_edit.php')
-rw-r--r--src/usr/local/www/services_dnsmasq_edit.php103
1 files changed, 52 insertions, 51 deletions
diff --git a/src/usr/local/www/services_dnsmasq_edit.php b/src/usr/local/www/services_dnsmasq_edit.php
index 9c3c811..3eedebb 100644
--- a/src/usr/local/www/services_dnsmasq_edit.php
+++ b/src/usr/local/www/services_dnsmasq_edit.php
@@ -133,47 +133,49 @@ if ($_POST) {
/* collect aliases */
$aliases = array();
- foreach ($_POST as $key => $value) {
- $entry = '';
- if (!substr_compare('aliashost', $key, 0, 9)) {
- $entry = substr($key, 9);
- $field = 'host';
- }
- elseif (!substr_compare('aliasdomain', $key, 0, 11)) {
- $entry = substr($key, 11);
- $field = 'domain';
- }
- elseif (!substr_compare('aliasdescription', $key, 0, 16)) {
- $entry = substr($key, 16);
- $field = 'description';
- }
- if (ctype_digit($entry)) {
- $aliases[$entry][$field] = $value;
+
+ if (!empty($_POST['aliashost0'])) {
+ foreach ($_POST as $key => $value) {
+ $entry = '';
+ if (!substr_compare('aliashost', $key, 0, 9)) {
+ $entry = substr($key, 9);
+ $field = 'host';
+ }
+ elseif (!substr_compare('aliasdomain', $key, 0, 11)) {
+ $entry = substr($key, 11);
+ $field = 'domain';
+ }
+ elseif (!substr_compare('aliasdescription', $key, 0, 16)) {
+ $entry = substr($key, 16);
+ $field = 'description';
+ }
+ 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");
+ $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.");
+ 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)) {
@@ -284,12 +286,17 @@ $form->add($section);
$section = new Form_Section('Additional names for this host');
+if(!$pconfig['aliases']['item']) {
+ $pconfig['aliases']['item'] = array('host' => "");
+}
+
if( $pconfig['aliases']['item']) {
$counter = 0;
$last = count($pconfig['aliases']['item']) - 1;
foreach($pconfig['aliases']['item'] as $item) {
$group = new Form_Group(null);
+ $group->addClass('repeatable');
$group->add(new Form_Input(
'aliashost' . $counter,
@@ -312,28 +319,22 @@ if( $pconfig['aliases']['item']) {
$item['description']
))->setHelp($counter == $last ? 'Description':null);
- $btn = new Form_Button(
- 'btn' . $counter,
- 'Delete',
- 'services_dnsmasq_edit.php?act=delopt' . '&id=' . $counter
- );
+ $group->add(new Form_Button(
+ 'deleterow' . $counter,
+ 'Delete'
+ ))->removeClass('btn-primary')->addClass('btn-warning');
- $btn->removeClass('btn-primary')->addClass('btn-danger btn-sm');
- $group->add($btn);
$section->add($group);
$counter++;
}
}
-$btnaddopt = new Form_Button(
- 'btnaddopt',
- 'Add Host name',
- 'services_dnsmasq_edit.php?act=addopt'
-);
-
-$btnaddopt->removeClass('btn-primary')->addClass('btn-success btn-sm');
-
-$section->addInput($btnaddopt);
+$form->addGlobal(new Form_Button(
+ 'addrow',
+ 'Add host name',
+ null,
+ 'fa-plus'
+))->removeClass('btn-primary')->addClass('btn-success addbtn');
$form->add($section);
print($form);
OpenPOWER on IntegriCloud