From b128b22a7fb0fb855e362ef3705e4d3a703abe1e Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Wed, 6 May 2015 14:02:37 -0300 Subject: Simplify logic --- config/squid3/34/squid.inc | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/config/squid3/34/squid.inc b/config/squid3/34/squid.inc index f5cd1c31..b53ec37a 100755 --- a/config/squid3/34/squid.inc +++ b/config/squid3/34/squid.inc @@ -516,23 +516,24 @@ function squid_validate_general($post, &$input_errors) { } function squid_validate_upstream($post, &$input_errors) { - if ($post['enabled'] == 'on') { - $addr = trim($post['proxyaddr']); - if (empty($addr)) { - $input_errors[] = 'The field \'Hostname\' is required'; - } else { - if (!is_ipaddr($addr) && !is_domain($addr)) - $input_errors[] = 'You must enter a valid IP address or host name in the \'Proxy hostname\' field'; - } + if ($post['enabled'] != 'on') + return; - foreach (array('proxyport' => 'TCP port', 'icpport' => 'ICP port') as $field => $name) { - $port = trim($post[$field]); - if (empty($port)) { - $input_errors[] = "The field '$name' is required"; - } else { - if (!is_port($port)) - $input_errors[] = "The field '$name' must contain a valid port number, between 0 and 65535"; - } + $addr = trim($post['proxyaddr']); + if (empty($addr)) { + $input_errors[] = 'The field \'Hostname\' is required'; + } else { + if (!is_ipaddr($addr) && !is_domain($addr)) + $input_errors[] = 'You must enter a valid IP address or host name in the \'Proxy hostname\' field'; + } + + foreach (array('proxyport' => 'TCP port', 'icpport' => 'ICP port') as $field => $name) { + $port = trim($post[$field]); + if (empty($port)) { + $input_errors[] = "The field '$name' is required"; + } else { + if (!is_port($port)) + $input_errors[] = "The field '$name' must contain a valid port number, between 0 and 65535"; } } } -- cgit v1.2.3