* Copyright (C) 2009 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: * * 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. * * 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"); require_once("filter.inc"); require_once("system.inc"); require_once("interfaces.inc"); function crypto_modules() { $modules = array( 'hifn' => gettext('Hifn 7751/7951/7811/7955/7956 Crypto Accelerator'), 'padlock' => gettext('Crypto and RNG in VIA C3, C7 and Eden Processors'), 'qat' => gettext('Intel QuickAssist Technology'), 'safe' => gettext('SafeNet Crypto Accelerator'), ); $available = array(); foreach ($modules as $name => $desc) { if (file_exists("/boot/kernel/{$name}.ko")) { $available[$name] = $desc; } } return $available; } function thermal_modules() { $modules = array( 'amdtemp' => gettext('AMD K8, K10 and K11 CPU on-die thermal sensor'), 'coretemp' => gettext('Intel Core* CPU on-die thermal sensor'), ); $available = array(); foreach ($modules as $name => $desc) { if (file_exists("/boot/kernel/{$name}.ko")) { $available[$name] = $desc; } } return $available; } if ($_SERVER['REQUEST_METHOD'] === 'GET') { $pconfig = array(); $pconfig['powerd_enable'] = isset($config['system']['powerd_enable']); $pconfig['crypto_hardware'] = !empty($config['system']['crypto_hardware']) ? explode(',', $config['system']['crypto_hardware']) : []; $pconfig['thermal_hardware'] = !empty($config['system']['thermal_hardware']) ? $config['system']['thermal_hardware'] : null; $pconfig['use_mfs_var'] = isset($config['system']['use_mfs_var']); $pconfig['max_mfs_var'] = $config['system']['max_mfs_var'] ?? null; $pconfig['use_mfs_tmp'] = isset($config['system']['use_mfs_tmp']); $pconfig['max_mfs_tmp'] = $config['system']['max_mfs_tmp'] ?? null; $pconfig['use_swap_file'] = isset($config['system']['use_swap_file']); $pconfig['rrdbackup'] = !empty($config['system']['rrdbackup']) ? $config['system']['rrdbackup'] : null; $pconfig['dhcpbackup'] = !empty($config['system']['dhcpbackup']) ? $config['system']['dhcpbackup'] : null; $pconfig['netflowbackup'] = !empty($config['system']['netflowbackup']) ? $config['system']['netflowbackup'] : null; $pconfig['captiveportalbackup'] = !empty($config['system']['captiveportalbackup']) ? $config['system']['captiveportalbackup'] : null; $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']; } $pconfig['powerd_normal_mode'] = "hadp"; if (!empty($config['system']['powerd_normal_mode'])) { $pconfig['powerd_normal_mode'] = $config['system']['powerd_normal_mode']; } // System Sounds $pconfig['disablebeep'] = isset($config['system']['disablebeep']); } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { $input_errors = array(); $pconfig = $_POST; if (!empty($pconfig['crypto_hardware'])) { if (count(array_intersect($pconfig['crypto_hardware'], crypto_modules())) == count($pconfig['crypto_hardware'])) { $input_errors[] = gettext('Please select a valid Cryptographic Accelerator.'); } } else { $pconfig['crypto_hardware'] = []; } if (isset($pconfig['max_mfs_var']) && $pconfig['max_mfs_var'] != '') { if (!is_numeric($pconfig['max_mfs_var'])) { $input_errors[] = gettext('Memory usage percentage is not a number.'); } else if ($pconfig['max_mfs_var'] < 0 || $pconfig['max_mfs_var'] > 100) { $input_errors[] = gettext('Memory usage percentage out of bounds.'); } } if (isset($pconfig['max_mfs_tmp']) && $pconfig['max_mfs_tmp'] != '') { if (!is_numeric($pconfig['max_mfs_tmp'])) { $input_errors[] = gettext('Memory usage percentage is not a number.'); } else if ($pconfig['max_mfs_tmp'] < 0 || $pconfig['max_mfs_tmp'] > 100) { $input_errors[] = gettext('Memory usage percentage out of bounds.'); } } if (!empty($pconfig['thermal_hardware']) && !array_key_exists($pconfig['thermal_hardware'], thermal_modules())) { $input_errors[] = gettext("Please select a valid Thermal Hardware Sensor."); } if (count($input_errors) == 0) { if (!empty($pconfig['powerd_enable'])) { $config['system']['powerd_enable'] = true; } elseif (isset($config['system']['powerd_enable'])) { unset($config['system']['powerd_enable']); } $config['system']['powerd_ac_mode'] = $pconfig['powerd_ac_mode']; $config['system']['powerd_battery_mode'] = $pconfig['powerd_battery_mode']; $config['system']['powerd_normal_mode'] = $pconfig['powerd_normal_mode']; if (!empty($pconfig['crypto_hardware'])) { $config['system']['crypto_hardware'] = implode(',', $pconfig['crypto_hardware']); } elseif (isset($config['system']['crypto_hardware'])) { unset($config['system']['crypto_hardware']); } if (!empty($pconfig['thermal_hardware'])) { $config['system']['thermal_hardware'] = $pconfig['thermal_hardware']; } elseif (isset($config['system']['thermal_hardware'])) { unset($config['system']['thermal_hardware']); } if (!empty($pconfig['use_mfs_var'])) { $config['system']['use_mfs_var'] = true; } elseif (isset($config['system']['use_mfs_var'])) { unset($config['system']['use_mfs_var']); } if (isset($pconfig['max_mfs_var']) && $pconfig['max_mfs_var'] != '') { $pconfig['max_mfs_var'] = trim($pconfig['max_mfs_var']); $config['system']['max_mfs_var'] = $pconfig['max_mfs_var']; } elseif (isset($config['system']['max_mfs_var'])) { unset($config['system']['max_mfs_var']); } if (!empty($pconfig['use_mfs_tmp'])) { $config['system']['use_mfs_tmp'] = true; } elseif (isset($config['system']['use_mfs_tmp'])) { unset($config['system']['use_mfs_tmp']); } if (isset($pconfig['max_mfs_tmp']) && $pconfig['max_mfs_tmp'] != '') { $pconfig['max_mfs_tmp'] = trim($pconfig['max_mfs_tmp']); $config['system']['max_mfs_tmp'] = $pconfig['max_mfs_tmp']; } elseif (isset($config['system']['max_mfs_tmp'])) { unset($config['system']['max_mfs_tmp']); } if (!empty($pconfig['use_swap_file'])) { /* set explicit value here in case we want to make it flexible */ $config['system']['use_swap_file'] = 2048; } elseif (isset($config['system']['use_swap_file'])) { unset($config['system']['use_swap_file']); } if (!empty($pconfig['rrdbackup'])) { $config['system']['rrdbackup'] = $pconfig['rrdbackup']; } elseif (isset($config['system']['rrdbackup'])) { unset($config['system']['rrdbackup']); } if (!empty($pconfig['dhcpbackup'])) { $config['system']['dhcpbackup'] = $pconfig['dhcpbackup']; } elseif (isset($config['system']['dhcpbackup'])) { unset($config['system']['dhcpbackup']); } if (!empty($pconfig['netflowbackup'])) { $config['system']['netflowbackup'] = $pconfig['netflowbackup']; } elseif (isset($config['system']['netflowbackup'])) { unset($config['system']['netflowbackup']); } if (!empty($pconfig['captiveportalbackup'])) { $config['system']['captiveportalbackup'] = $pconfig['captiveportalbackup']; } elseif (isset($config['system']['captiveportalbackup'])) { unset($config['system']['captiveportalbackup']); } if (!empty($pconfig['disablebeep'])) { $config['system']['disablebeep'] = true; } elseif (isset($config['system']['disablebeep'])) { unset($config['system']['disablebeep']); } write_config(); system_resolvconf_generate(); system_cron_configure(); system_powerd_configure(); system_kernel_configure(); $savemsg = get_std_save_message(); } } legacy_html_escape_form_data($pconfig); include("head.inc"); ?>
0) { print_input_errors($input_errors); } if (isset($savemsg)) { print_info_box($savemsg); } ?>

/>
/>
/>
/>
/>