From ca55edc39342865816feef390616be8b770c889b Mon Sep 17 00:00:00 2001 From: stilez Date: Tue, 24 May 2016 10:01:07 +0100 Subject: Give settings section a more helpful/standard title to match other GUI settings tabs --- src/usr/local/www/diag_confbak.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/usr/local/www/diag_confbak.php b/src/usr/local/www/diag_confbak.php index 43aae0a..147238f 100644 --- a/src/usr/local/www/diag_confbak.php +++ b/src/usr/local/www/diag_confbak.php @@ -186,14 +186,14 @@ if ($diff) { $form = new Form(false); -$section = new Form_Section('Saved Configurations', 'savedconfig', COLLAPSIBLE|SEC_CLOSED); +$section = new Form_Section('Configuration Backup Cache Settings', 'configsettings', COLLAPSIBLE|SEC_CLOSED); $section->addInput(new Form_Input( 'backupcount', 'Backup Count', 'number', $config['system']['backupcount'] -))->setHelp('Maximum number of old configurations to keep. By default this is 30 for a full install or 5 on NanoBSD. '); +))->setHelp('Maximum number of old configurations to keep in the cache. By default this is 30 for a full install or 5 on NanoBSD. '); $space = exec("/usr/bin/du -sh /conf/backup | /usr/bin/awk '{print $1;}'"); -- cgit v1.1 From 09a283948eada745bc10b852e63b7dec50fb69d4 Mon Sep 17 00:00:00 2001 From: stilez Date: Tue, 24 May 2016 10:05:07 +0100 Subject: set default_config_backup_count based on platform At the same time the platform is being detected for PHP/GUI purposes, set the default number of backups. Also handle the case where (for any reason) detection fails, which it shouldn't, so the variables are still created --- src/etc/inc/globals.inc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/etc/inc/globals.inc b/src/etc/inc/globals.inc index 221df9e..abbaf20 100644 --- a/src/etc/inc/globals.inc +++ b/src/etc/inc/globals.inc @@ -151,11 +151,17 @@ if (file_exists("/etc/platform")) { if ($g['platform'] == "nanobsd") { $g['firmware_update_text']="pfSense-*.img.gz"; $g['hidebackupbeforeupgrade'] = true; - + $g['default_config_backup_count'] = 5; } else { $g['firmware_update_text']="pfSense-*.tgz"; + $g['default_config_backup_count'] = 30; } -} +} else { + // shouldn't happen but "just in case" no platform were detected + $g['platform'] = 'undetected'; + $g['default_config_backup_count'] = 30; +} + if (file_exists("{$g['etc_path']}/default-config-flavor")) { $flavor_array = file("{$g['etc_path']}/default-config-flavor"); -- cgit v1.1 From 16b17c15f9fc29e9480431b5bc7bebe2bd4b6230 Mon Sep 17 00:00:00 2001 From: stilez Date: Tue, 24 May 2016 10:15:03 +0100 Subject: fix logic and replace hard coded value by global backups should be a numeric int. text hint for number of backups can now refer to the global value for this platform (and explains how to get that default, by leaving blank) --- src/usr/local/www/diag_confbak.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/usr/local/www/diag_confbak.php b/src/usr/local/www/diag_confbak.php index 147238f..e951ef6 100644 --- a/src/usr/local/www/diag_confbak.php +++ b/src/usr/local/www/diag_confbak.php @@ -64,7 +64,7 @@ require("guiconfig.inc"); if (isset($_POST['backupcount'])) { - if (is_numeric($_POST['backupcount']) && ($_POST['backupcount'] >= 0)) { + if (is_numericint($_POST['backupcount']) && ($_POST['backupcount'] >= 0)) { $config['system']['backupcount'] = $_POST['backupcount']; $changedescr = $config['system']['backupcount']; } else { @@ -193,7 +193,7 @@ $section->addInput(new Form_Input( 'Backup Count', 'number', $config['system']['backupcount'] -))->setHelp('Maximum number of old configurations to keep in the cache. By default this is 30 for a full install or 5 on NanoBSD. '); +))->setHelp('Maximum number of old configurations to keep in the cache, 0 for no backups, or leave blank for the default value (' . $g['default_config_backup_count'] . ' for the current platform).'); $space = exec("/usr/bin/du -sh /conf/backup | /usr/bin/awk '{print $1;}'"); -- cgit v1.1 From 01b5410ae8391998ba560d40f447c7f556472c5b Mon Sep 17 00:00:00 2001 From: stilez Date: Tue, 24 May 2016 10:25:11 +0100 Subject: Use global backup count instead of hardcoded value and remove redundant function --- src/etc/inc/config.lib.inc | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/etc/inc/config.lib.inc b/src/etc/inc/config.lib.inc index 4285d3d..0a2c921 100644 --- a/src/etc/inc/config.lib.inc +++ b/src/etc/inc/config.lib.inc @@ -792,7 +792,7 @@ function cleanup_backupcache($lock = false) { global $g; $i = false; - $revisions = get_config_backup_count(); + $revisions = intval(is_numericint($config['system']['backupcount']) ? $config['system']['backupcount'] : $g['default_config_backup_count']); if (!$lock) { $lockkey = lock('config'); @@ -997,17 +997,6 @@ function make_config_revision_entry($desc = null, $override_user = null) { return $revision; } -function get_config_backup_count() { - global $config, $g; - if (isset($config['system']['backupcount']) && is_numeric($config['system']['backupcount']) && ($config['system']['backupcount'] >= 0)) { - return intval($config['system']['backupcount']); - } elseif ($g['platform'] == "nanobsd") { - return 5; - } else { - return 30; - } -} - function pfSense_clear_globals() { global $config, $FilterIfList, $GatewaysList, $filterdns, $aliases, $aliastable; -- cgit v1.1 From f208e9690e2ec4089cf3d3fe5f5f03fed5a36e6f Mon Sep 17 00:00:00 2001 From: stilez Date: Tue, 24 May 2016 10:27:50 +0100 Subject: redundant check - is_numericint() tests for >= 0 --- src/usr/local/www/diag_confbak.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/usr/local/www/diag_confbak.php b/src/usr/local/www/diag_confbak.php index e951ef6..f17210e 100644 --- a/src/usr/local/www/diag_confbak.php +++ b/src/usr/local/www/diag_confbak.php @@ -64,7 +64,7 @@ require("guiconfig.inc"); if (isset($_POST['backupcount'])) { - if (is_numericint($_POST['backupcount']) && ($_POST['backupcount'] >= 0)) { + if (is_numericint($_POST['backupcount'])) { $config['system']['backupcount'] = $_POST['backupcount']; $changedescr = $config['system']['backupcount']; } else { -- cgit v1.1