summaryrefslogtreecommitdiffstats
path: root/src/usr/local/www/services_unbound_host_edit.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr/local/www/services_unbound_host_edit.php')
-rw-r--r--src/usr/local/www/services_unbound_host_edit.php97
1 files changed, 50 insertions, 47 deletions
diff --git a/src/usr/local/www/services_unbound_host_edit.php b/src/usr/local/www/services_unbound_host_edit.php
index 29ebc3c..cab96ed 100644
--- a/src/usr/local/www/services_unbound_host_edit.php
+++ b/src/usr/local/www/services_unbound_host_edit.php
@@ -106,7 +106,6 @@ if (isset($id) && $a_hosts[$id]) {
}
if ($_POST) {
-
unset($input_errors);
$pconfig = $_POST;
@@ -136,43 +135,45 @@ 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;
+ $pconfig['aliases']['item'] = $aliases;
- /* validate aliases */
- foreach ($aliases as $idx => $alias) {
- $aliasreqdfields = array('aliasdomain' . $idx);
- $aliasreqdfieldsn = array(gettext("Alias Domain"));
+ /* validate aliases */
+ foreach ($aliases as $idx => $alias) {
+ $aliasreqdfields = array('aliasdomain' . $idx);
+ $aliasreqdfieldsn = array(gettext("Alias Domain"));
- do_input_validation($_POST, $aliasreqdfields, $aliasreqdfieldsn, $input_errors);
+ 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['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.");
+ }
}
}
@@ -235,6 +236,9 @@ $pgtitle = array(gettext("Services"),gettext("DNS Resolver"),gettext("Edit Host
$shortcut_section = "resolver";
include("head.inc");
+if ($input_errors)
+ print_input_errors($input_errors);
+
$form = new Form();
$section = new Form_Section('Host override options');
@@ -282,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,
@@ -310,28 +319,22 @@ if( $pconfig['aliases']['item']) {
$item['description']
))->setHelp($counter == $last ? 'Description':null);
- $btn = new Form_Button(
- 'btn' . $counter,
- 'Delete',
- 'services_unbound_host_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_unbound_host_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