From 0d2f56bd3bacb85e1192cab73ca44895fe731764 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Mon, 7 Dec 2015 18:40:48 +0100 Subject: [PATCH] (legacy) work in progress refactor system_advanced_misc.php --- src/www/system_advanced_misc.php | 747 +++++++++++++++---------------- 1 file changed, 365 insertions(+), 382 deletions(-) diff --git a/src/www/system_advanced_misc.php b/src/www/system_advanced_misc.php index 528f028a2..054ff91a5 100644 --- a/src/www/system_advanced_misc.php +++ b/src/www/system_advanced_misc.php @@ -1,32 +1,32 @@ . - All rights reserved. + Copyright (C) 2014-2015 Deciso B.V. + Copyright (C) 2005-2007 Scott Ullrich + Copyright (C) 2008 Shrew Soft Inc + Copyright (C) 2003-2004 Manuel Kasper . + All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. */ require_once("guiconfig.inc"); @@ -38,45 +38,47 @@ require_once("pfsense-utils.inc"); require_once("services.inc"); require_once("interfaces.inc"); -$pconfig['proxyurl'] = $config['system']['proxyurl']; -$pconfig['proxyport'] = $config['system']['proxyport']; -$pconfig['proxyuser'] = $config['system']['proxyuser']; -$pconfig['proxypass'] = $config['system']['proxypass']; -$pconfig['harddiskstandby'] = $config['system']['harddiskstandby']; -$pconfig['lb_use_sticky'] = isset($config['system']['lb_use_sticky']); -$pconfig['srctrack'] = $config['system']['srctrack']; -$pconfig['gw_switch_default'] = isset($config['system']['gw_switch_default']); -$pconfig['powerd_enable'] = isset($config['system']['powerd_enable']); -$pconfig['crypto_hardware'] = $config['system']['crypto_hardware']; -$pconfig['thermal_hardware'] = $config['system']['thermal_hardware']; -$pconfig['schedule_states'] = isset($config['system']['schedule_states']); -$pconfig['kill_states'] = isset($config['system']['kill_states']); -$pconfig['skip_rules_gw_down'] = isset($config['system']['skip_rules_gw_down']); -$pconfig['use_mfs_tmpvar'] = isset($config['system']['use_mfs_tmpvar']); - -$pconfig['powerd_ac_mode'] = "hadp"; -if (!empty($config['system']['powerd_ac_mode'])) { - $pconfig['powerd_ac_mode'] = $config['system']['powerd_ac_mode']; -} - -$pconfig['powerd_battery_mode'] = "hadp"; -if (!empty($config['system']['powerd_battery_mode'])) { - $pconfig['powerd_battery_mode'] = $config['system']['powerd_battery_mode']; -} $crypto_modules = array('glxsb' => gettext("AMD Geode LX Security Block"), - 'aesni' => gettext("AES-NI CPU-based Acceleration")); + 'aesni' => gettext("AES-NI CPU-based Acceleration") +); -$thermal_hardware_modules = array( 'coretemp' => gettext("Intel Core* CPU on-die thermal sensor"), - 'amdtemp' => gettext("AMD K8, K10 and K11 CPU on-die thermal sensor")); +$thermal_hardware_modules = array('coretemp' => gettext("Intel Core* CPU on-die thermal sensor"), + 'amdtemp' => gettext("AMD K8, K10 and K11 CPU on-die thermal sensor") +); -if ($_POST) { - unset($input_errors); + + +if ($_SERVER['REQUEST_METHOD'] === 'GET') { + $pconfig = array(); + $pconfig['proxyurl'] = !empty($config['system']['proxyurl']) ? $config['system']['proxyurl'] : null; + $pconfig['proxyport'] = !empty($config['system']['proxyport']) ? $config['system']['proxyport'] : null; + $pconfig['proxyuser'] = !empty($config['system']['proxyuser']) ? $config['system']['proxyuser'] : null; + $pconfig['proxypass'] = !empty($config['system']['proxypass']) ? $config['system']['proxypass'] : null; + $pconfig['harddiskstandby'] = !empty($config['system']['harddiskstandby']) ? $config['system']['harddiskstandby'] : null; + $pconfig['lb_use_sticky'] = isset($config['system']['lb_use_sticky']); + $pconfig['srctrack'] = !empty($config['system']['srctrack']) ? $config['system']['srctrack'] : null; + $pconfig['gw_switch_default'] = isset($config['system']['gw_switch_default']); + $pconfig['powerd_enable'] = isset($config['system']['powerd_enable']); + $pconfig['crypto_hardware'] = !empty($config['system']['crypto_hardware']) ? $config['system']['crypto_hardware'] : null; + $pconfig['thermal_hardware'] = !empty($config['system']['thermal_hardware']) ? $config['system']['thermal_hardware'] : null; + $pconfig['schedule_states'] = isset($config['system']['schedule_states']); + $pconfig['kill_states'] = isset($config['system']['kill_states']); + $pconfig['skip_rules_gw_down'] = isset($config['system']['skip_rules_gw_down']); + $pconfig['use_mfs_tmpvar'] = isset($config['system']['use_mfs_tmpvar']); + $pconfig['powerd_ac_mode'] = "hadp"; + if (!empty($config['system']['powerd_ac_mode'])) { + $pconfig['powerd_ac_mode'] = $config['system']['powerd_ac_mode']; + } + $pconfig['powerd_battery_mode'] = "hadp"; + if (!empty($config['system']['powerd_battery_mode'])) { + $pconfig['powerd_battery_mode'] = $config['system']['powerd_battery_mode']; + } +} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { + // + $input_errors = array(); $pconfig = $_POST; - ob_flush(); - flush(); - if (!empty($_POST['crypto_hardware']) && !array_key_exists($_POST['crypto_hardware'], $crypto_modules)) { $input_errors[] = gettext("Please select a valid Cryptographic Accelerator."); } @@ -85,7 +87,7 @@ if ($_POST) { $input_errors[] = gettext("Please select a valid Thermal Hardware Sensor."); } - if (!$input_errors) { + if (count($input_errors) == 0) { if ($_POST['harddiskstandby'] <> "") { $config['system']['harddiskstandby'] = $_POST['harddiskstandby']; system_set_harddisk_standby(); @@ -205,6 +207,7 @@ if ($_POST) { } } +legacy_html_escape_form_data($pconfig); $pgtitle = array(gettext("System"),gettext("Settings"),gettext("Miscellaneous")); include("head.inc"); @@ -217,110 +220,108 @@ include("head.inc"); +//]]> +
-
-
- 0) { - print_input_errors($input_errors); - } - if (isset($savemsg)) { - print_info_box($savemsg); - } - ?> -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + +
- " class="formfld unknown" /> -
- -
- " class="formfld unknown" /> -
- -
- " class="formfld unknown" /> -
- -
- " class="formfld unknown" /> -
- -
- /> -
- +
+ 0) { + print_input_errors($input_errors); + } + if (isset($savemsg)) { + print_info_box($savemsg); + } +?> +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - - -
+ + +
+ "/> + +
+ "/> + +
+ "/> + +
+ "/> + +
+ /> +
+
+ onclick="sticky_checked(this)" /> +
+
- /> -
-
-  :  - -    -  :  - -

- +
+ /> +
+ + + + + + + + + + + + + +
+ + + +
+
- -
- +
+ +
- -
- -

- -
- /> - -
-
+ +
+ + +
+ /> +
- /> - -
- -
-
- /> - -
- +
+ /> + + +
+ /> + +
- onclick="tmpvar_checked(this)" /> -
- +
+ onclick="tmpvar_checked(this)" /> +
- -
- -
-
-
- -
- -
-
-
  - " /> -
- -
-
+
+
+ +
+ +
+ + +
  + " /> +
+
-
+
+ +