From 8e06dbd75930aa688887006b5a545e5c5a64d4f2 Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Tue, 12 Aug 2008 10:38:33 +0000 Subject: do not bloat squid conf with unessential params and error check for input --- packages/squid/squid.inc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/squid/squid.inc b/packages/squid/squid.inc index 4c2cb82e..69941f77 100644 --- a/packages/squid/squid.inc +++ b/packages/squid/squid.inc @@ -351,6 +351,18 @@ function squid_validate_cache($post, $input_errors) { if (!is_numeric($value) || ($value < 0)) $input_errors[] = 'You must enter a valid value for \'Minimum object size\''; + if (!empty($post['cache_swap_low'])) { + $value = trim($post['cache_swap_low']); + if (!is_numeric($value) || ($value > 100)) + $input_errors[] = 'You must enter a valid value for \'Low-water-mark\''; + } + + if (!empty($post['cache_swap_high'])) { + $value = trim($post['cache_swap_high']); + if (!is_numeric($value) || ($value > 100)) + $input_errors[] = 'You must enter a valid value for \'High-water-mark\''; + } + if ($post['donotcache'] != "") { foreach (split("\n", $post['donotcache']) as $host) { $host = trim($host); @@ -539,8 +551,6 @@ function squid_resync_cache() { $min_objsize = ($settings['minimum_object_size'] ? $settings['minimum_object_size'] : 0); $cache_policy = ($settings['cache_replacement_policy'] ? $settings['cache_replacement_policy'] : 'heap LFUDA'); $memory_policy = ($settings['memory_replacement_policy'] ? $settings['memory_replacement_policy'] : 'heap GDSF'); - $cache_swap_low = ($settings['cache_swap_low'] ? $settings['cache_swap_low'] : '90'); - $cache_swap_high = ($settings['cache_swap_high'] ? $settings['cache_swap_high'] : '95'); $offline_mode = ($settings['enable_offline'] == 'on' ? 'on' : 'off'); $conf = <<