diff options
Diffstat (limited to 'src/usr/local/www')
-rw-r--r-- | src/usr/local/www/classes/Form.class.php | 5 | ||||
-rw-r--r-- | src/usr/local/www/classes/Form/Checkbox.class.php | 8 | ||||
-rw-r--r-- | src/usr/local/www/classes/Form/Section.class.php | 4 | ||||
-rwxr-xr-x | src/usr/local/www/firewall_aliases_edit.php | 7 | ||||
-rw-r--r-- | src/usr/local/www/firewall_nat_1to1_edit.php | 2 | ||||
-rw-r--r-- | src/usr/local/www/firewall_rules_edit.php | 4 | ||||
-rw-r--r-- | src/usr/local/www/index.php | 20 | ||||
-rw-r--r-- | src/usr/local/www/jquery/pfSenseHelpers.js | 19 | ||||
-rw-r--r-- | src/usr/local/www/services_dnsmasq.php | 1 | ||||
-rw-r--r-- | src/usr/local/www/services_dnsmasq_edit.php | 103 | ||||
-rw-r--r-- | src/usr/local/www/services_unbound_host_edit.php | 66 |
11 files changed, 125 insertions, 114 deletions
diff --git a/src/usr/local/www/classes/Form.class.php b/src/usr/local/www/classes/Form.class.php index 7964d12..6f30f69 100644 --- a/src/usr/local/www/classes/Form.class.php +++ b/src/usr/local/www/classes/Form.class.php @@ -35,8 +35,6 @@ class Form extends Form_Element protected $_attributes = array( 'class' => array('form-horizontal' => true), 'method' => 'post', - // Empty is interpreted by all browsers to submit to the current URI - 'action' => '', ); protected $_sections = array(); protected $_global = array(); @@ -54,6 +52,9 @@ class Form extends Form_Element if (false !== $submit) $this->addGlobal($submit); + + if (!isset($this->_attributes['action'])) + $this->_attributes['action'] = htmlspecialchars($_SERVER['REQUEST_URI']); } public function add(Form_Section $section) diff --git a/src/usr/local/www/classes/Form/Checkbox.class.php b/src/usr/local/www/classes/Form/Checkbox.class.php index e0734de..d94c210 100644 --- a/src/usr/local/www/classes/Form/Checkbox.class.php +++ b/src/usr/local/www/classes/Form/Checkbox.class.php @@ -46,10 +46,16 @@ class Form_Checkbox extends Form_Input $this->column->addClass('checkbox'); } - public function displayAsRadio() + public function displayAsRadio($id = null) { $this->_attributes['type'] = 'radio'; + if ($id != null) { + $this->_attributes['id'] = $id; + } else { + $this->_attributes['id'] = $this->_attributes['name'] . '_' . $this->_attributes['value'] . ':' .substr(uniqid(), 9); + } + return $this; } diff --git a/src/usr/local/www/classes/Form/Section.class.php b/src/usr/local/www/classes/Form/Section.class.php index ac1587d..eff386a 100644 --- a/src/usr/local/www/classes/Form/Section.class.php +++ b/src/usr/local/www/classes/Form/Section.class.php @@ -81,11 +81,11 @@ class Form_Section extends Form_Element if ($this->_collapsible & COLLAPSIBLE) { $hdricon = '<span class="widget-heading-icon">' . - '<a data-toggle="collapse" href="#' . $this->_attributes['id'] . ' .panel-body">' . + '<a data-toggle="collapse" href="#' . $this->_attributes['id'] . '_panel-body">' . '<i class="fa fa-plus-circle"></i>' . '</a>' . '</span>'; - $bodyclass = '<div class="panel-body collapse '; + $bodyclass = '<div id="' . $this->_attributes['id'] . '_panel-body" class="panel-body collapse '; if (($this->_collapsible & SEC_CLOSED)) { $bodyclass .= 'out">'; } else { diff --git a/src/usr/local/www/firewall_aliases_edit.php b/src/usr/local/www/firewall_aliases_edit.php index b0625d3..0adc184 100755 --- a/src/usr/local/www/firewall_aliases_edit.php +++ b/src/usr/local/www/firewall_aliases_edit.php @@ -629,13 +629,6 @@ $form->addGlobal(new Form_Input( )); $form->addGlobal(new Form_Input( - 'tab', - null, - 'hidden', - $tab -)); - -$form->addGlobal(new Form_Input( 'origname', null, 'hidden', diff --git a/src/usr/local/www/firewall_nat_1to1_edit.php b/src/usr/local/www/firewall_nat_1to1_edit.php index c058a55..4b4d960 100644 --- a/src/usr/local/www/firewall_nat_1to1_edit.php +++ b/src/usr/local/www/firewall_nat_1to1_edit.php @@ -477,7 +477,7 @@ $group->add(new Form_Checkbox( 'dstnot', null, 'Not', - $pconfig['srcnot'] + $pconfig['dstnot'] ))->setHelp('Invert the sense of the match.'); $group->add(new Form_Select( diff --git a/src/usr/local/www/firewall_rules_edit.php b/src/usr/local/www/firewall_rules_edit.php index e24d097..32d6342 100644 --- a/src/usr/local/www/firewall_rules_edit.php +++ b/src/usr/local/www/firewall_rules_edit.php @@ -1477,7 +1477,7 @@ $section->addInput(new Form_Input( 'Max. src. conn. Rate', 'number', $pconfig['max-src-conn-rate'] -))->setHelp('Maximum state entries per host'); +))->setHelp('Maximum new connections per host (TCP only)'); $section->addInput(new Form_Input( 'max-src-conn-rates', @@ -1485,7 +1485,7 @@ $section->addInput(new Form_Input( 'number', $pconfig['max-src-conn-rates'], ['min' => 1, 'max' => 255] -))->setHelp('Maximum new connections per host / per second(s) (TCP only)'); +))->setHelp('/ per how many second(s) (TCP only)'); $section->addInput(new Form_Input( 'statetimeout', diff --git a/src/usr/local/www/index.php b/src/usr/local/www/index.php index d44b8f6..350ddb7 100644 --- a/src/usr/local/www/index.php +++ b/src/usr/local/www/index.php @@ -312,19 +312,19 @@ pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard"); <div class="panel panel-default" id="widget-available"> <div class="panel-heading"><?=gettext("Available Widgets"); ?> <span class="widget-heading-icon"> - <a data-toggle="collapse" href="#widget-available .panel-body" name="widgets-available"> + <a data-toggle="collapse" href="#widget-available_panel-body" id="widgets-available"> <i class="fa fa-plus-circle"></i> </a> </span> </div> - <div class="panel-body collapse out"> + <div id="widget-available_panel-body" class="panel-body collapse out"> <div class="content"> <div class="row"> <?php foreach ($widgets as $widgetname => $widgetconfig): if ($widgetconfig['display'] == 'none'): ?> - <div class="col-sm-3"><a href="#" name="btnadd-<?=$widgetname?>"><i class="fa fa-plus"></i> <?=$widgetconfig['name']?></a></div> + <div class="col-sm-3"><a href="#" id="btnadd-<?=$widgetname?>"><i class="fa fa-plus"></i> <?=$widgetconfig['name']?></a></div> <?php endif; ?> <?php endforeach; ?> </div> @@ -355,7 +355,7 @@ foreach ($widgets as $widgetname => $widgetconfig): </div> <div class="hidden" id="widgetSequence"> - <form action="/" method="post" id="widgetSequence" name="widgetForm"> + <form action="/" method="post" id="widgetSequence_Form" name="widgetForm"> <input type="hidden" name="sequence" value="" /> <button type="submit" id="btnstore" class="btn btn-primary">Store widget configuration</button> @@ -403,10 +403,10 @@ foreach ($widgets as $widgetname => $widgetconfig) <div class="panel-heading"> <?=$wtitle?> <span class="widget-heading-icon"> - <a data-toggle="collapse" href="#widget-<?=$widgetname?> .panel-footer" class="config hidden"> + <a data-toggle="collapse" href="#widget-<?=$widgetname?>_panel-footer" class="config hidden"> <i class="fa fa-wrench"></i> </a> - <a data-toggle="collapse" href="#widget-<?=$widgetname?> .panel-body"> + <a data-toggle="collapse" href="#widget-<?=$widgetname?>_panel-body"> <!-- actual icon is determined in css based on state of body --> <i class="fa fa-plus-circle"></i> </a> @@ -415,7 +415,7 @@ foreach ($widgets as $widgetname => $widgetconfig) </a> </span> </div> - <div class="panel-body collapse<?=($widgetconfig['display']=='close' ? '' : ' in')?>"> + <div id="widget-<?=$widgetname?>_panel-body" class="panel-body collapse<?=($widgetconfig['display']=='close' ? '' : ' in')?>"> <?php include('/usr/local/www/widgets/widgets/'. $widgetname.'.widget.php'); ?> </div> </div> @@ -449,7 +449,7 @@ function updateWidgets(newWidget) sequence += newWidget + ':' + 'col2:open'; $('#widgetSequence').removeClass('hidden'); - $('input[name=sequence]', $('#widgetSequence')).val(sequence); + $('input[name=sequence]', $('#widgetSequence_Form')).val(sequence); } events.push(function() { @@ -471,9 +471,9 @@ events.push(function() { }); // On clicking a widget to install . . - $('[name^=btnadd-]').click(function(event) { + $('[id^=btnadd-]').click(function(event) { // Add the widget name to the list of displayed widgets - updateWidgets(this.name.replace('btnadd-', '')); + updateWidgets(this.id.replace('btnadd-', '')); // We don't want to see the "Store" button because we are doing that automatically $('#btnstore').hide(); diff --git a/src/usr/local/www/jquery/pfSenseHelpers.js b/src/usr/local/www/jquery/pfSenseHelpers.js index fb810c6..4fbe9f8 100644 --- a/src/usr/local/www/jquery/pfSenseHelpers.js +++ b/src/usr/local/www/jquery/pfSenseHelpers.js @@ -138,7 +138,7 @@ function hideLabel(text, hide) { element.parent('div').removeClass('hidden'); } -// Toggle table row chackboxes and background colors on the pages that use sortable tables: +// Toggle table row checkboxes and background colors on the pages that use sortable tables: // /usr/local/www/firewall_nat.php // /usr/local/www/firewall_nat_1to1.php // /usr/local/www/firewall_nat_out.php @@ -214,13 +214,18 @@ function moveHelpText(id) { var helpSpan; if(!$(this).hasClass('pfIpMask') && !$(this).hasClass('btn')) { - - helpSpan = $('#' + fromId).parent('div').parent('div').find('span:last').clone(); + if($('#' + decrStringInt(fromId)).parent('div').hasClass('input-group')) { + helpSpan = $('#' + fromId).parent('div').parent('div').find('span:last').clone(); + } else { + helpSpan = $('#' + fromId).parent('div').find('span:last').clone(); + } if($(helpSpan).hasClass('help-block')) { - if($('#' + decrStringInt(fromId)).parent('div').hasClass('input-group')) + if($('#' + decrStringInt(fromId)).parent('div').hasClass('input-group')) { $('#' + decrStringInt(fromId)).parent('div').after(helpSpan); - else + } + else { $('#' + decrStringInt(fromId)).after(helpSpan); + } } } }); @@ -422,7 +427,7 @@ $('tbody:empty').html("<tr><td></td></tr>"); $(el).children('i').toggleClass('fa-minus-circle', true); $(el).children('i').toggleClass('fa-plus-circle', false); - if($(el).closest('a').attr('name') != 'widgets-available') { + if($(el).closest('a').attr('id') != 'widgets-available') { updateWidgets(); } }); @@ -431,7 +436,7 @@ $('tbody:empty').html("<tr><td></td></tr>"); $(el).children('i').toggleClass('fa-minus-circle', false); $(el).children('i').toggleClass('fa-plus-circle', true); - if($(el).closest('a').attr('name') != 'widgets-available') { + if($(el).closest('a').attr('id') != 'widgets-available') { updateWidgets(); } }); diff --git a/src/usr/local/www/services_dnsmasq.php b/src/usr/local/www/services_dnsmasq.php index dabeb7d..d6b7710 100644 --- a/src/usr/local/www/services_dnsmasq.php +++ b/src/usr/local/www/services_dnsmasq.php @@ -404,6 +404,7 @@ foreach ($a_hosts as $i => $hostent): Alias for <?=$hostent['host'] ? $hostent['host'] . '.' . $hostent['domain'] : $hostent['domain']?> </td> <td> + <i class="fa fa-angle-double-right text-info"></i> <?=htmlspecialchars($alias['description'])?> </td> <td> 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); diff --git a/src/usr/local/www/services_unbound_host_edit.php b/src/usr/local/www/services_unbound_host_edit.php index 7a4d696..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'); |