From 0a3150896bc412868cfb79473293ed81c87a50a7 Mon Sep 17 00:00:00 2001 From: derelict-pf Date: Sun, 8 Jan 2017 18:03:04 -0800 Subject: Add requirestatefilter. Implements #7069. --- src/etc/inc/pfsense-utils.inc | 20 ++++++++++++++++++++ src/usr/local/www/diag_dump_states.php | 13 ++++++++++--- src/usr/local/www/system.php | 4 ++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/etc/inc/pfsense-utils.inc b/src/etc/inc/pfsense-utils.inc index aca0e90..9f290bb 100644 --- a/src/etc/inc/pfsense-utils.inc +++ b/src/etc/inc/pfsense-utils.inc @@ -366,6 +366,26 @@ function gen_user_settings_fields(&$section, $pconfig) { gen_pagenamefirst_field($section, $pconfig['pagenamefirst']); } +/****f* pfsense-utils/gen_requirestatefilter_field + * NAME + * gen_requirestatefilter_field + * INPUTS + * Pointer to section object + * Initial value for the field + * RESULT + * no return value, section object is updated + ******/ +function gen_requirestatefilter_field(&$section, $value) { + $section->addInput(new Form_Checkbox( + 'requirestatefilter', + 'Require State Filter', + 'Do not display state table without a filter', + $value + ))->setHelp('By default, the entire state table is displayed when entering '. + 'Diagnostics > States. This option requires a filter to be entered '. + 'before the states are displayed. Useful for systems with large state tables.'); +} + function hardware_offloading_applyflags($iface) { global $config; diff --git a/src/usr/local/www/diag_dump_states.php b/src/usr/local/www/diag_dump_states.php index 342d8f5..d1ad356 100644 --- a/src/usr/local/www/diag_dump_states.php +++ b/src/usr/local/www/diag_dump_states.php @@ -205,10 +205,14 @@ print $form; $arr[] = array("filter" => $_POST['filter']); } - if (count($arr) > 0) { - $res = pfSense_get_pf_states($arr); + if (isset($_POST['filter']) || !isset($config['system']['webgui']['requirestatefilter'])) { + if (count($arr) > 0) { + $res = pfSense_get_pf_states($arr); + } else { + $res = pfSense_get_pf_states(); + } } else { - $res = pfSense_get_pf_states(); + $res = NULL; } $states = 0; @@ -261,6 +265,9 @@ print $form; if ($states == 0) { if (isset($_POST['filter']) && !empty($_POST['filter'])) { $errmsg = gettext('No states were found that match the current filter.'); + } else if (!isset($_POST['filter']) && isset($config['system']['webgui']['requirestatefilter'])) { + $errmsg = gettext('State display suppressed without filter submission. '. + 'See System > General, Require State Filter.'); } else { $errmsg = gettext('No states were found.'); } diff --git a/src/usr/local/www/system.php b/src/usr/local/www/system.php index 0e52d9e..07afc46 100644 --- a/src/usr/local/www/system.php +++ b/src/usr/local/www/system.php @@ -68,6 +68,7 @@ $pconfig['webguihostnamemenu'] = $config['system']['webgui']['webguihostnamemenu $pconfig['dnslocalhost'] = isset($config['system']['dnslocalhost']); $pconfig['dashboardperiod'] = isset($config['widgets']['period']) ? $config['widgets']['period']:"10"; $pconfig['loginshowhost'] = isset($config['system']['webgui']['loginshowhost']); +$pconfig['requirestatefilter'] = isset($config['system']['webgui']['requirestatefilter']); if (!$pconfig['timezone']) { if (isset($g['default_timezone']) && !empty($g['default_timezone'])) { @@ -177,6 +178,8 @@ if ($_POST) { unset($config['system']['webgui']['dashboardcolumns']); } + $config['system']['webgui']['requirestatefilter'] = $_POST['requirestatefilter'] ? true : false; + if ($_POST['hostname']) { if (!is_hostname($_POST['hostname'])) { $input_errors[] = gettext("The hostname can only contain the characters A-Z, 0-9 and '-'. It may not start or end with '-'."); @@ -520,6 +523,7 @@ gen_associatedpanels_fields( $pconfig['systemlogsfilterpanel'], $pconfig['systemlogsmanagelogpanel'], $pconfig['statusmonitoringsettingspanel']); +gen_requirestatefilter_field($section, $pconfig['requirestatefilter']); gen_webguileftcolumnhyper_field($section, $pconfig['webguileftcolumnhyper']); $section->addInput(new Form_Checkbox( -- cgit v1.1 From 88081ea257fa683ed28b588c4c35260589604741 Mon Sep 17 00:00:00 2001 From: derelict-pf Date: Sun, 8 Jan 2017 18:03:04 -0800 Subject: Add requirestatefilter. Implements #7069. --- src/etc/inc/pfsense-utils.inc | 20 ++++++++++++++++++++ src/usr/local/www/diag_dump_states.php | 13 ++++++++++--- src/usr/local/www/system.php | 4 ++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/etc/inc/pfsense-utils.inc b/src/etc/inc/pfsense-utils.inc index aca0e90..9f290bb 100644 --- a/src/etc/inc/pfsense-utils.inc +++ b/src/etc/inc/pfsense-utils.inc @@ -366,6 +366,26 @@ function gen_user_settings_fields(&$section, $pconfig) { gen_pagenamefirst_field($section, $pconfig['pagenamefirst']); } +/****f* pfsense-utils/gen_requirestatefilter_field + * NAME + * gen_requirestatefilter_field + * INPUTS + * Pointer to section object + * Initial value for the field + * RESULT + * no return value, section object is updated + ******/ +function gen_requirestatefilter_field(&$section, $value) { + $section->addInput(new Form_Checkbox( + 'requirestatefilter', + 'Require State Filter', + 'Do not display state table without a filter', + $value + ))->setHelp('By default, the entire state table is displayed when entering '. + 'Diagnostics > States. This option requires a filter to be entered '. + 'before the states are displayed. Useful for systems with large state tables.'); +} + function hardware_offloading_applyflags($iface) { global $config; diff --git a/src/usr/local/www/diag_dump_states.php b/src/usr/local/www/diag_dump_states.php index 342d8f5..879617b 100644 --- a/src/usr/local/www/diag_dump_states.php +++ b/src/usr/local/www/diag_dump_states.php @@ -205,10 +205,14 @@ print $form; $arr[] = array("filter" => $_POST['filter']); } - if (count($arr) > 0) { - $res = pfSense_get_pf_states($arr); + if (isset($_POST['filter']) || !isset($config['system']['webgui']['requirestatefilter'])) { + if (count($arr) > 0) { + $res = pfSense_get_pf_states($arr); + } else { + $res = pfSense_get_pf_states(); + } } else { - $res = pfSense_get_pf_states(); + $res = NULL; } $states = 0; @@ -261,6 +265,9 @@ print $form; if ($states == 0) { if (isset($_POST['filter']) && !empty($_POST['filter'])) { $errmsg = gettext('No states were found that match the current filter.'); + } else if (!isset($_POST['filter']) && isset($config['system']['webgui']['requirestatefilter'])) { + $errmsg = gettext('State display suppressed without filter submission. '. + 'See System > General Setup, Require State Filter.'); } else { $errmsg = gettext('No states were found.'); } diff --git a/src/usr/local/www/system.php b/src/usr/local/www/system.php index 0e52d9e..07afc46 100644 --- a/src/usr/local/www/system.php +++ b/src/usr/local/www/system.php @@ -68,6 +68,7 @@ $pconfig['webguihostnamemenu'] = $config['system']['webgui']['webguihostnamemenu $pconfig['dnslocalhost'] = isset($config['system']['dnslocalhost']); $pconfig['dashboardperiod'] = isset($config['widgets']['period']) ? $config['widgets']['period']:"10"; $pconfig['loginshowhost'] = isset($config['system']['webgui']['loginshowhost']); +$pconfig['requirestatefilter'] = isset($config['system']['webgui']['requirestatefilter']); if (!$pconfig['timezone']) { if (isset($g['default_timezone']) && !empty($g['default_timezone'])) { @@ -177,6 +178,8 @@ if ($_POST) { unset($config['system']['webgui']['dashboardcolumns']); } + $config['system']['webgui']['requirestatefilter'] = $_POST['requirestatefilter'] ? true : false; + if ($_POST['hostname']) { if (!is_hostname($_POST['hostname'])) { $input_errors[] = gettext("The hostname can only contain the characters A-Z, 0-9 and '-'. It may not start or end with '-'."); @@ -520,6 +523,7 @@ gen_associatedpanels_fields( $pconfig['systemlogsfilterpanel'], $pconfig['systemlogsmanagelogpanel'], $pconfig['statusmonitoringsettingspanel']); +gen_requirestatefilter_field($section, $pconfig['requirestatefilter']); gen_webguileftcolumnhyper_field($section, $pconfig['webguileftcolumnhyper']); $section->addInput(new Form_Checkbox( -- cgit v1.1