From 5384c5f8d643d5a38e2a2b6c09cd539df39dc531 Mon Sep 17 00:00:00 2001 From: PiBa-NL Date: Sat, 3 Aug 2013 18:47:21 +0200 Subject: haproxy-devel fix displaying shared frontends in a grouped manner. +changed names of frontend variables to frontend (instead of backend) --- config/haproxy-devel/haproxy_listeners.php | 156 +++++++++++++++-------------- 1 file changed, 79 insertions(+), 77 deletions(-) diff --git a/config/haproxy-devel/haproxy_listeners.php b/config/haproxy-devel/haproxy_listeners.php index 2a58ac9a..7b6e3d58 100644 --- a/config/haproxy-devel/haproxy_listeners.php +++ b/config/haproxy-devel/haproxy_listeners.php @@ -36,7 +36,7 @@ require_once("certs.inc"); if (!is_array($config['installedpackages']['haproxy']['ha_backends']['item'])) { $config['installedpackages']['haproxy']['ha_backends']['item'] = array(); } -$a_backend = &$config['installedpackages']['haproxy']['ha_backends']['item']; +$a_frontend = &$config['installedpackages']['haproxy']['ha_backends']['item']; if ($_POST) { $pconfig = $_POST; @@ -56,9 +56,9 @@ $id = $_GET['id']; $id = get_frontend_id($id); if ($_GET['act'] == "del") { - if (isset($a_backend[$id])) { + if (isset($a_frontend[$id])) { if (!$input_errors) { - unset($a_backend[$id]); + unset($a_frontend[$id]); write_config(); touch($d_haproxyconfdirty_path); } @@ -114,92 +114,94 @@ include("head.inc"); $b['ipport'] ? 1 : -1; + function sort_sharedfrontends(&$a, &$b) { + // make sure the 'primary frontend' is the first in the array, after that sort by name. if ($a['secondary'] != $b['secondary']) return $a['secondary'] > $b['secondary'] ? 1 : -1; if ($a['name'] != $b['name']) return $a['name'] > $b['name'] ? 1 : -1; return 0; } - foreach($a_backend as &$backend2) { - $backend2['ipport'] = get_frontend_ipport($backend2); + + $a_frontend_grouped = array(); + foreach($a_frontend as &$frontend2) { + $ipport = get_frontend_ipport($frontend2); + $frontend2['ipport'] = $ipport; + $a_frontend_grouped[$ipport][] = $frontend2; } - usort($a_backend,'sort_backends'); + ksort($a_frontend_grouped); $img_cert = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png"; $img_adv = "/themes/{$g['theme']}/images/icons/icon_advanced.gif"; $img_acl = "/themes/{$g['theme']}/images/icons/icon_ts_rule.gif"; - - unset($ipport_previous); - foreach ($a_backend as $backend): - $backendname = $backend['name']; - $textgray = $backend['status'] != 'active' ? " gray" : ""; - if (isset($ipport_previous ) && $backend['ipport'] == $ipport_previous): - ?> -   - - - " ondblclick="document.location='haproxy_listeners_edit.php?id=';"> - - - - '; - } - - $acls = get_frontent_acls($backend); - $isaclset = ""; - foreach ($acls as $acl) { - $isaclset .= " " . $acl['descr']; - } - if ($isaclset) - echo ""; - - $isadvset = ""; - if ($backend['advanced_bind']) $isadvset .= "Advanced bind: {$backend['advanced_bind']}\r\n"; - if ($backend['advanced']) $isadvset .= "advanced settings used\r\n"; - if ($isadvset) - echo ""; - + $last_frontend_shared = false; + foreach ($a_frontend_grouped as $a_frontend) { + usort($a_frontend,'sort_sharedfrontends'); + if (count($a_frontend) > 1 || $last_frontend_shared) { + ?>   1; + foreach ($a_frontend as $frontend) { + $frontendname = $frontend['name']; + $textgray = $frontend['status'] != 'active' ? " gray" : ""; ?> - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - + + " ondblclick="document.location='haproxy_listeners_edit.php?id=';"> + + + + '; + } + + $acls = get_frontent_acls($frontend); + $isaclset = ""; + foreach ($acls as $acl) { + $isaclset .= " " . $acl['descr']; + } + if ($isaclset) + echo ""; + + $isadvset = ""; + if ($frontend['advanced_bind']) $isadvset .= "Advanced bind: {$frontend['advanced_bind']}\r\n"; + if ($frontend['advanced']) $isadvset .= "advanced settings used\r\n"; + if ($isadvset) + echo ""; + + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + -- cgit v1.2.3