From f4462954aaacbf1bba3b1318c004d9bc436efdf3 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 14 Apr 2014 07:40:17 -0700 Subject: [PATCH] Unset logfilesize rather than let it be zero 1) When saving Status: System logs: Settings, if the Log File Size field is left blank, it gets cast to (int) and ends pu as zero "0" in config.xml. That breaks the creation of clog files in /etc/rc during boot. /etc/rc expects logfilesize to be unset, blank or a valid integer >= 5120. So, if the field is empty, then make sure that it is unset in config.xml 2) For data items that are cast to (int) whenputting into the config (nentries and logfilesize), copy the resulting value back to the $pconfig array. When the user enters 123.45 the in field, is correctly truncated to (int) 123 in config.xml. By copying that back to $pconfig, the "123" also appears correctly on the GUI page after the save. 3) Mention the units of measure of Log File Size (Bytes) 4) Mention that the user should press Save first when changing values, then they can use "Reset Log Files" to set the log file sizes to the just-saved value. 5) Display a message when the log files have been reset - it's a bit more user-friendly IMHO. --- usr/local/www/diag_logs_settings.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/usr/local/www/diag_logs_settings.php b/usr/local/www/diag_logs_settings.php index 1ac8b6ca06..eb935f8da6 100644 --- a/usr/local/www/diag_logs_settings.php +++ b/usr/local/www/diag_logs_settings.php @@ -5,7 +5,7 @@ Copyright (C) 2004-2009 Scott Ullrich All rights reserved. - originially part of m0n0wall (http://m0n0.ch/wall) + originally part of m0n0wall (http://m0n0.ch/wall) Copyright (C) 2003-2004 Manuel Kasper . All rights reserved. @@ -85,6 +85,7 @@ function is_valid_syslog_server($target) { if ($_POST['resetlogs'] == gettext("Reset Log Files")) { clear_all_log_files(); + $savemsg .= gettext("The log files have been reset."); } elseif ($_POST) { unset($input_errors); @@ -113,7 +114,13 @@ if ($_POST['resetlogs'] == gettext("Reset Log Files")) { if (!$input_errors) { $config['syslog']['reverse'] = $_POST['reverse'] ? true : false; $config['syslog']['nentries'] = (int)$_POST['nentries']; - $config['syslog']['logfilesize'] = (int)$_POST['logfilesize']; + $pconfig['nentries'] = $config['syslog']['nentries']; + if (isset($_POST['logfilesize']) && (strlen($_POST['logfilesize']) > 0)) { + $config['syslog']['logfilesize'] = (int)$_POST['logfilesize']; + $pconfig['logfilesize'] = $config['syslog']['logfilesize']; + } else { + unset($config['syslog']['logfilesize']); + } $config['syslog']['remoteserver'] = $_POST['remoteserver']; $config['syslog']['remoteserver2'] = $_POST['remoteserver2']; $config['syslog']['remoteserver3'] = $_POST['remoteserver3']; @@ -285,7 +292,7 @@ function check_everything() { - Log File Size + Log File Size {Bytes)
@@ -349,7 +356,7 @@ function check_everything() { " onclick="return confirm('')" />

- +