From 12745e51a69c8bd5850c94f6063732f49512f53d Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Tue, 15 Dec 2015 17:04:23 +0545 Subject: Code style l --- src/usr/local/www/license.php | 2 +- src/usr/local/www/load_balancer_monitor.php | 13 ++-- src/usr/local/www/load_balancer_monitor_edit.php | 14 ++-- src/usr/local/www/load_balancer_pool.php | 13 ++-- src/usr/local/www/load_balancer_pool_edit.php | 91 +++++++++++++--------- src/usr/local/www/load_balancer_setting.php | 11 ++- src/usr/local/www/load_balancer_virtual_server.php | 13 ++-- .../www/load_balancer_virtual_server_edit.php | 5 +- 8 files changed, 97 insertions(+), 65 deletions(-) (limited to 'src/usr/local') diff --git a/src/usr/local/www/license.php b/src/usr/local/www/license.php index a450779..1233d83 100644 --- a/src/usr/local/www/license.php +++ b/src/usr/local/www/license.php @@ -115,7 +115,7 @@ include("head.inc");
. + "software packages for their efforts"), $g['product_name'])?>.

FreeBSD (http://www.freebsd.org)
diff --git a/src/usr/local/www/load_balancer_monitor.php b/src/usr/local/www/load_balancer_monitor.php index f911234..e007e18 100644 --- a/src/usr/local/www/load_balancer_monitor.php +++ b/src/usr/local/www/load_balancer_monitor.php @@ -107,19 +107,22 @@ if ($_GET['act'] == "del") { } } -$pgtitle = array(gettext("Services"),gettext("Load Balancer"),gettext("Monitor")); +$pgtitle = array(gettext("Services"), gettext("Load Balancer"), gettext("Monitor")); $shortcut_section = "relayd"; include("head.inc"); -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} -if ($savemsg) +if ($savemsg) { print_info_box($savemsg, 'success'); +} -if (is_subsystem_dirty('loadbalancer')) +if (is_subsystem_dirty('loadbalancer')) { print_info_box_np(gettext("The load balancer configuration has been changed") . ".
" . gettext("You must apply the changes in order for them to take effect.")); +} /* active tabs */ $tab_array = array(); @@ -146,7 +149,7 @@ display_top_tabs($tab_array); diff --git a/src/usr/local/www/load_balancer_monitor_edit.php b/src/usr/local/www/load_balancer_monitor_edit.php index 5cd870a..0786239 100644 --- a/src/usr/local/www/load_balancer_monitor_edit.php +++ b/src/usr/local/www/load_balancer_monitor_edit.php @@ -242,19 +242,20 @@ $types = array("icmp" => gettext("ICMP"), "tcp" => gettext("TCP"), "http" => get " . htmlspecialchars($a_pool[$i]['monitor']) . ""; } -$pgtitle = array(gettext("Services"), gettext("Load Balancer"),gettext("Pool")); +$pgtitle = array(gettext("Services"), gettext("Load Balancer"), gettext("Pool")); $shortcut_section = "relayd"; include("head.inc"); -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); +} -if ($savemsg) +if ($savemsg) { print_info_box($savemsg); +} -if (is_subsystem_dirty('loadbalancer')) +if (is_subsystem_dirty('loadbalancer')) { print_info_box_np(sprintf(gettext("The load balancer configuration has been changed%sYou must apply the changes in order for them to take effect."), "
")); +} /* active tabs */ $tab_array = array(); @@ -164,7 +167,7 @@ display_top_tabs($tab_array); diff --git a/src/usr/local/www/load_balancer_pool_edit.php b/src/usr/local/www/load_balancer_pool_edit.php index 9d5c98b..6c6996a 100644 --- a/src/usr/local/www/load_balancer_pool_edit.php +++ b/src/usr/local/www/load_balancer_pool_edit.php @@ -76,10 +76,12 @@ if (!is_array($config['load_balancer']['lbpool'])) { $a_pool = &$config['load_balancer']['lbpool']; -if (is_numericint($_GET['id'])) +if (is_numericint($_GET['id'])) { $id = $_GET['id']; -if (isset($_POST['id']) && is_numericint($_POST['id'])) +} +if (isset($_POST['id']) && is_numericint($_POST['id'])) { $id = $_POST['id']; +} if (isset($id) && $a_pool[$id]) { $pconfig['name'] = $a_pool[$id]['name']; @@ -105,55 +107,61 @@ if ($_POST) { /* input validation */ $reqdfields = explode(" ", "name mode port monitor servers"); - $reqdfieldsn = array(gettext("Name"),gettext("Mode"),gettext("Port"),gettext("Monitor"),gettext("Server List")); + $reqdfieldsn = array(gettext("Name"), gettext("Mode"), gettext("Port"), gettext("Monitor"), gettext("Server List")); do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); /* Ensure that our pool names are unique */ - for ($i=0; isset($config['load_balancer']['lbpool'][$i]); $i++) - if (($_POST['name'] == $config['load_balancer']['lbpool'][$i]['name']) && ($i != $id)) + for ($i=0; isset($config['load_balancer']['lbpool'][$i]); $i++) { + if (($_POST['name'] == $config['load_balancer']['lbpool'][$i]['name']) && ($i != $id)) { $input_errors[] = gettext("This pool name has already been used. Pool names must be unique."); + } + } - if (preg_match('/[ \/]/', $_POST['name'])) + if (preg_match('/[ \/]/', $_POST['name'])) { $input_errors[] = gettext("You cannot use spaces or slashes in the 'name' field."); + } - if (strlen($_POST['name']) > 16) + if (strlen($_POST['name']) > 16) { $input_errors[] = gettext("The 'name' field must be 16 characters or less."); + } - if (in_array($_POST['name'], $reserved_table_names)) + if (in_array($_POST['name'], $reserved_table_names)) { $input_errors[] = sprintf(gettext("The name '%s' is a reserved word and cannot be used."), $_POST['name']); + } - if (is_alias($_POST['name'])) + if (is_alias($_POST['name'])) { $input_errors[] = sprintf(gettext("Sorry, an alias is already named %s."), $_POST['name']); + } - if (!is_portoralias($_POST['port'])) + if (!is_portoralias($_POST['port'])) { $input_errors[] = gettext("The port must be an integer between 1 and 65535, or a port alias."); + } // May as well use is_port as we want a positive integer and such. - if (!empty($_POST['retry']) && !is_port($_POST['retry'])) + if (!empty($_POST['retry']) && !is_port($_POST['retry'])) { $input_errors[] = gettext("The retry value must be an integer between 1 and 65535."); + } if (!in_array($_POST['mode'], $allowed_modes)) { $input_errors[] = gettext("The submitted mode is not valid."); } if (is_array($_POST['servers'])) { - foreach($pconfig['servers'] as $svrent) { + foreach ($pconfig['servers'] as $svrent) { if (!is_ipaddr($svrent) && !is_subnetv4($svrent)) { $input_errors[] = sprintf(gettext("%s is not a valid IP address or IPv4 subnet (in \"enabled\" list)."), $svrent); - } - else if (is_subnetv4($svrent) && subnet_size($svrent) > 64) { + } else if (is_subnetv4($svrent) && subnet_size($svrent) > 64) { $input_errors[] = sprintf(gettext("%s is a subnet containing more than 64 IP addresses (in \"enabled\" list)."), $svrent); } } } if (is_array($_POST['serversdisabled'])) { - foreach($pconfig['serversdisabled'] as $svrent) { + foreach ($pconfig['serversdisabled'] as $svrent) { if (!is_ipaddr($svrent) && !is_subnetv4($svrent)) { $input_errors[] = sprintf(gettext("%s is not a valid IP address or IPv4 subnet (in \"disabled\" list)."), $svrent); - } - else if (is_subnetv4($svrent) && subnet_size($svrent) > 64) { + } else if (is_subnetv4($svrent) && subnet_size($svrent) > 64) { $input_errors[] = sprintf(gettext("%s is a subnet containing more than 64 IP addresses (in \"disabled\" list)."), $svrent); } } @@ -161,19 +169,23 @@ if ($_POST) { $m = array(); - for ($i=0; isset($config['load_balancer']['monitor_type'][$i]); $i++) + for ($i=0; isset($config['load_balancer']['monitor_type'][$i]); $i++) { $m[$config['load_balancer']['monitor_type'][$i]['name']] = $config['load_balancer']['monitor_type'][$i]; + } - if (!isset($m[$_POST['monitor']])) + if (!isset($m[$_POST['monitor']])) { $input_errors[] = gettext("Invalid monitor chosen."); + } if (!$input_errors) { $poolent = array(); - if(isset($id) && $a_pool[$id]) + if (isset($id) && $a_pool[$id]) { $poolent = $a_pool[$id]; + } - if($poolent['name'] != "") + if ($poolent['name'] != "") { $changedesc .= sprintf(gettext(" modified '%s' pool:"), $poolent['name']); + } update_if_changed("name", $poolent['name'], $_POST['name']); update_if_changed("mode", $poolent['mode'], $_POST['mode']); @@ -187,12 +199,14 @@ if ($_POST) { if (isset($id) && $a_pool[$id]) { /* modify all virtual servers with this name */ for ($i = 0; isset($config['load_balancer']['virtual_server'][$i]); $i++) { - if ($config['load_balancer']['virtual_server'][$i]['lbpool'] == $a_pool[$id]['name']) + if ($config['load_balancer']['virtual_server'][$i]['lbpool'] == $a_pool[$id]['name']) { $config['load_balancer']['virtual_server'][$i]['lbpool'] = $poolent['name']; + } } $a_pool[$id] = $poolent; - } else + } else { $a_pool[] = $poolent; + } if ($changecount > 0) { /* Mark pool dirty */ @@ -205,7 +219,7 @@ if ($_POST) { } } -$pgtitle = array(gettext("Services"), gettext("Load Balancer"),gettext("Pool"),gettext("Edit")); +$pgtitle = array(gettext("Services"), gettext("Load Balancer"), gettext("Pool"), gettext("Edit")); $shortcut_section = "relayd"; include("head.inc"); @@ -213,7 +227,7 @@ include("head.inc"); addInput(new Form_Select( 'monitor', 'Monitor', @@ -417,8 +433,9 @@ $list = array(); if (is_array($pconfig['serversdisabled'])) { foreach ($pconfig['serversdisabled'] as $svrent) { - if ($svrent != '') + if ($svrent != '') { $list[$svrent] = $svrent; + } } } @@ -483,7 +500,7 @@ print($form); ?>