diff options
-rw-r--r-- | usr/local/www/load_balancer_monitor.php | 56 | ||||
-rw-r--r-- | usr/local/www/load_balancer_monitor_edit.php | 86 | ||||
-rw-r--r-- | usr/local/www/load_balancer_pool.php | 77 | ||||
-rw-r--r-- | usr/local/www/load_balancer_pool_edit.php | 110 | ||||
-rw-r--r-- | usr/local/www/load_balancer_relay_action.php | 78 | ||||
-rw-r--r-- | usr/local/www/load_balancer_relay_action_edit.php | 401 | ||||
-rw-r--r-- | usr/local/www/load_balancer_relay_protocol.php | 72 | ||||
-rw-r--r-- | usr/local/www/load_balancer_relay_protocol_edit.php | 83 | ||||
-rw-r--r-- | usr/local/www/load_balancer_setting.php | 136 | ||||
-rw-r--r-- | usr/local/www/load_balancer_virtual_server.php | 66 | ||||
-rw-r--r-- | usr/local/www/load_balancer_virtual_server_edit.php | 271 |
11 files changed, 748 insertions, 688 deletions
diff --git a/usr/local/www/load_balancer_monitor.php b/usr/local/www/load_balancer_monitor.php index 3e72add..3fdf0d5 100644 --- a/usr/local/www/load_balancer_monitor.php +++ b/usr/local/www/load_balancer_monitor.php @@ -101,36 +101,36 @@ include("head.inc"); <?php print_info_box_np(gettext("The load balancer configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));?><br /> <?php endif; ?> <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="load balancer monitor"> - <tr><td class="tabnavtbl"> - <?php - /* active tabs */ - $tab_array = array(); - $tab_array[] = array(gettext("Pools"), false, "load_balancer_pool.php"); - $tab_array[] = array(gettext("Virtual Servers"), false, "load_balancer_virtual_server.php"); - $tab_array[] = array(gettext("Monitors"), true, "load_balancer_monitor.php"); - $tab_array[] = array(gettext("Settings"), false, "load_balancer_setting.php"); - display_top_tabs($tab_array); - ?> - </td></tr> - <tr> - <td> - <div id="mainarea"> + <tr><td class="tabnavtbl"> + <?php + /* active tabs */ + $tab_array = array(); + $tab_array[] = array(gettext("Pools"), false, "load_balancer_pool.php"); + $tab_array[] = array(gettext("Virtual Servers"), false, "load_balancer_virtual_server.php"); + $tab_array[] = array(gettext("Monitors"), true, "load_balancer_monitor.php"); + $tab_array[] = array(gettext("Settings"), false, "load_balancer_setting.php"); + display_top_tabs($tab_array); + ?> + </td></tr> + <tr> + <td> + <div id="mainarea"> <?php - $t = new MainTable(); - $t->edit_uri('load_balancer_monitor_edit.php'); - $t->my_uri('load_balancer_monitor.php'); - $t->add_column(gettext('Name'),'name',20); - $t->add_column(gettext('Type'),'type',10); - $t->add_column(gettext('Description'),'descr',30); - $t->add_button('edit'); - $t->add_button('dup'); - $t->add_button('del'); - $t->add_content_array($a_monitor); - $t->display(); + $t = new MainTable(); + $t->edit_uri('load_balancer_monitor_edit.php'); + $t->my_uri('load_balancer_monitor.php'); + $t->add_column(gettext('Name'),'name',20); + $t->add_column(gettext('Type'),'type',10); + $t->add_column(gettext('Description'),'descr',30); + $t->add_button('edit'); + $t->add_button('dup'); + $t->add_button('del'); + $t->add_content_array($a_monitor); + $t->display(); ?> - </div> - </td> - </tr> + </div> + </td> + </tr> </table> </form> <?php include("fend.inc"); ?> diff --git a/usr/local/www/load_balancer_monitor_edit.php b/usr/local/www/load_balancer_monitor_edit.php index 280244b..b8806e1 100644 --- a/usr/local/www/load_balancer_monitor_edit.php +++ b/usr/local/www/load_balancer_monitor_edit.php @@ -49,10 +49,12 @@ if (!is_array($config['load_balancer']['monitor_type'])) { } $a_monitor = &$config['load_balancer']['monitor_type']; -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_monitor[$id]) { $pconfig['name'] = $a_monitor[$id]['name']; @@ -76,7 +78,7 @@ if ($_POST) { $pconfig = $_POST; /* turn $_POST['http_options_*'] into $pconfig['options'][*] */ - foreach($_POST as $key => $val) { + foreach ($_POST as $key => $val) { if (stristr($key, 'options') !== false) { if (stristr($key, $pconfig['type'].'_') !== false) { $opt = explode('_',$key); @@ -93,17 +95,21 @@ if ($_POST) { do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); /* Ensure that our monitor names are unique */ - for ($i=0; isset($config['load_balancer']['monitor_type'][$i]); $i++) - if (($_POST['name'] == $config['load_balancer']['monitor_type'][$i]['name']) && ($i != $id)) + for ($i=0; isset($config['load_balancer']['monitor_type'][$i]); $i++) { + if (($_POST['name'] == $config['load_balancer']['monitor_type'][$i]['name']) && ($i != $id)) { $input_errors[] = gettext("This monitor name has already been used. Monitor 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."); + } - switch($_POST['type']) { + switch ($_POST['type']) { case 'icmp': { break; } @@ -120,7 +126,7 @@ if ($_POST) { } if (isset($pconfig['options']['code']) && $pconfig['options']['code'] != "") { // Check code - if(!is_rfc2616_code($pconfig['options']['code'])) { + if (!is_rfc2616_code($pconfig['options']['code'])) { $input_errors[] = gettext("HTTP(s) codes must be from RFC2616."); } } @@ -145,15 +151,17 @@ if ($_POST) { if (!$input_errors) { $monent = array(); - if(isset($id) && $a_monitor[$id]) + if (isset($id) && $a_monitor[$id]) { $monent = $a_monitor[$id]; - if($monent['name'] != "") + } + if ($monent['name'] != "") { $changedesc .= " " . sprintf(gettext("modified '%s' monitor:"), $monent['name']); - + } + update_if_changed("name", $monent['name'], $pconfig['name']); update_if_changed("type", $monent['type'], $pconfig['type']); update_if_changed("description", $monent['descr'], $pconfig['descr']); - if($pconfig['type'] == "http" || $pconfig['type'] == "https" ) { + if ($pconfig['type'] == "http" || $pconfig['type'] == "https") { /* log updates, then clear array and reassign - dumb, but easiest way to have a clear array */ update_if_changed("path", $monent['options']['path'], $pconfig['options']['path']); update_if_changed("host", $monent['options']['host'], $pconfig['options']['host']); @@ -163,7 +171,7 @@ if ($_POST) { $monent['options']['host'] = $pconfig['options']['host']; $monent['options']['code'] = $pconfig['options']['code']; } - if($pconfig['type'] == "send" ) { + if ($pconfig['type'] == "send") { /* log updates, then clear array and reassign - dumb, but easiest way to have a clear array */ update_if_changed("send", $monent['options']['send'], $pconfig['options']['send']); update_if_changed("expect", $monent['options']['expect'], $pconfig['options']['expect']); @@ -171,20 +179,22 @@ if ($_POST) { $monent['options']['send'] = $pconfig['options']['send']; $monent['options']['expect'] = $pconfig['options']['expect']; } - if($pconfig['type'] == "tcp" || $pconfig['type'] == "icmp") { + if ($pconfig['type'] == "tcp" || $pconfig['type'] == "icmp") { $monent['options'] = array(); } if (isset($id) && $a_monitor[$id]) { /* modify all pools with this name */ for ($i = 0; isset($config['load_balancer']['lbpool'][$i]); $i++) { - if ($config['load_balancer']['lbpool'][$i]['monitor'] == $a_monitor[$id]['name']) + if ($config['load_balancer']['lbpool'][$i]['monitor'] == $a_monitor[$id]['name']) { $config['load_balancer']['lbpool'][$i]['monitor'] = $monent['name']; + } } $a_monitor[$id] = $monent; - } else + } else { $a_monitor[] = $monent; - + } + if ($changecount > 0) { /* Mark config dirty */ mark_subsystem_dirty('loadbalancer'); @@ -208,8 +218,8 @@ $types = array("icmp" => gettext("ICMP"), "tcp" => gettext("TCP"), "http" => get <?php include("fbegin.inc"); ?> <script type="text/javascript"> //<![CDATA[ -function updateType(t){ - switch(t) { +function updateType(t) { + switch (t) { <?php /* OK, so this is sick using php to generate javascript, but it needed to be done */ foreach ($types as $key => $val) { @@ -231,21 +241,21 @@ function updateType(t){ <?php if ($input_errors) print_input_errors($input_errors); ?> - <form action="load_balancer_monitor_edit.php" method="post" name="iform" id="iform"> +<form action="load_balancer_monitor_edit.php" method="post" name="iform" id="iform"> <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="monitor entry"> - <tr> + <tr> <td colspan="2" valign="top" class="listtopic"><?=gettext("Edit Load Balancer - Monitor entry"); ?></td> - </tr> + </tr> <tr align="left"> <td width="22%" valign="top" class="vncellreq"><?=gettext("Name"); ?></td> <td width="78%" class="vtable" colspan="2"> - <input name="name" type="text" <?if(isset($pconfig['name'])) echo "value=\"" . htmlspecialchars($pconfig['name']) . "\"";?> size="16" maxlength="16" /> + <input name="name" type="text" <?if (isset($pconfig['name'])) echo "value=\"" . htmlspecialchars($pconfig['name']) . "\"";?> size="16" maxlength="16" /> </td> </tr> <tr align="left"> <td width="22%" valign="top" class="vncellreq"><?=gettext("Description"); ?></td> <td width="78%" class="vtable" colspan="2"> - <input name="descr" type="text" <?if(isset($pconfig['descr'])) echo "value=\"" . htmlspecialchars($pconfig['descr']) . "\"";?> size="64" /> + <input name="descr" type="text" <?if (isset($pconfig['descr'])) echo "value=\"" . htmlspecialchars($pconfig['descr']) . "\"";?> size="64" /> </td> </tr> <tr align="left"> @@ -254,7 +264,7 @@ function updateType(t){ <select id="type" name="type"> <? foreach ($types as $key => $val) { - if(isset($pconfig['type']) && $pconfig['type'] == $key) { + if (isset($pconfig['type']) && $pconfig['type'] == $key) { $selected = " selected=\"selected\""; } else { $selected = ""; @@ -265,9 +275,11 @@ function updateType(t){ </select> </td> </tr> - <tr align="left" id="icmp"<?= $pconfig['type'] == "icmp" ? "" : " style=\"display:none;\""?>><td></td> + <tr align="left" id="icmp"<?= $pconfig['type'] == "icmp" ? "" : " style=\"display:none;\""?>> + <td></td> </tr> - <tr align="left" id="tcp"<?= $pconfig['type'] == "tcp" ? "" : " style=\"display:none;\""?>><td></td> + <tr align="left" id="tcp"<?= $pconfig['type'] == "tcp" ? "" : " style=\"display:none;\""?>> + <td></td> </tr> <tr align="left" id="http"<?= $pconfig['type'] == "http" ? "" : " style=\"display:none;\""?>> <td width="22%" valign="top" class="vncellreq"><?=gettext("HTTP"); ?></td> @@ -276,13 +288,13 @@ function updateType(t){ <tr align="left"> <td valign="top" align="right" class="vtable"><?=gettext("Path"); ?></td> <td class="vtable" colspan="2"> - <input name="http_options_path" type="text" <?if(isset($pconfig['options']['path'])) echo "value=\"" . htmlspecialchars($pconfig['options']['path']) . "\"";?> size="64" /> + <input name="http_options_path" type="text" <?if (isset($pconfig['options']['path'])) echo "value=\"" . htmlspecialchars($pconfig['options']['path']) . "\"";?> size="64" /> </td> </tr> <tr align="left"> <td valign="top" align="right" class="vtable"><?=gettext("Host"); ?></td> <td class="vtable" colspan="2"> - <input name="http_options_host" type="text" <?if(isset($pconfig['options']['host'])) echo "value=\"" . htmlspecialchars($pconfig['options']['host']) . "\"";?> size="64" /><br /><?=gettext("Hostname for Host: header if needed."); ?> + <input name="http_options_host" type="text" <?if (isset($pconfig['options']['host'])) echo "value=\"" . htmlspecialchars($pconfig['options']['host']) . "\"";?> size="64" /><br /><?=gettext("Hostname for Host: header if needed."); ?> </td> </tr> <tr align="left"> @@ -295,7 +307,7 @@ function updateType(t){ <tr align="left"> <td width="22%" valign="top" class="vncell">MD5 Page Digest</td> <td width="78%" class="vtable" colspan="2"> - <input name="digest" type="text" <?if(isset($pconfig['digest'])) echo "value=\"" . htmlspecialchars($pconfig['digest']) . "\"";?>size="32"><br /><b>TODO: add fetch functionality here</b> + <input name="digest" type="text" <?if (isset($pconfig['digest'])) echo "value=\"" . htmlspecialchars($pconfig['digest']) . "\"";?>size="32"><br /><b>TODO: add fetch functionality here</b> </td> </tr> --> @@ -309,13 +321,13 @@ function updateType(t){ <tr align="left"> <td valign="top" align="right" class="vtable"><?=gettext("Path"); ?></td> <td class="vtable" colspan="2"> - <input name="https_options_path" type="text" <?if(isset($pconfig['options']['path'])) echo "value=\"" . htmlspecialchars($pconfig['options']['path']) ."\"";?> size="64" /> + <input name="https_options_path" type="text" <?if (isset($pconfig['options']['path'])) echo "value=\"" . htmlspecialchars($pconfig['options']['path']) ."\"";?> size="64" /> </td> </tr> <tr align="left"> <td valign="top" align="right" class="vtable"><?=gettext("Host"); ?></td> <td class="vtable" colspan="2"> - <input name="https_options_host" type="text" <?if(isset($pconfig['options']['host'])) echo "value=\"" . htmlspecialchars($pconfig['options']['host']) . "\"";?> size="64" /><br /><?=gettext("Hostname for Host: header if needed."); ?> + <input name="https_options_host" type="text" <?if (isset($pconfig['options']['host'])) echo "value=\"" . htmlspecialchars($pconfig['options']['host']) . "\"";?> size="64" /><br /><?=gettext("Hostname for Host: header if needed."); ?> </td> </tr> <tr align="left"> @@ -329,7 +341,7 @@ function updateType(t){ <tr align="left"> <td width="22%" valign="top" class="vncellreq">MD5 Page Digest</td> <td width="78%" class="vtable" colspan="2"> - <input name="digest" type="text" <?if(isset($pconfig['digest'])) echo "value=\"" . htmlspecialchars($pconfig['digest']) . "\"";?>size="32"><br /><b>TODO: add fetch functionality here</b> + <input name="digest" type="text" <?if (isset($pconfig['digest'])) echo "value=\"" . htmlspecialchars($pconfig['digest']) . "\"";?>size="32"><br /><b>TODO: add fetch functionality here</b> </td> </tr> --> @@ -343,13 +355,13 @@ function updateType(t){ <tr align="left"> <td valign="top" align="right" class="vtable"><?=gettext("Send string"); ?></td> <td class="vtable" colspan="2"> - <input name="send_options_send" type="text" <?if(isset($pconfig['options']['send'])) echo "value=\"" . htmlspecialchars($pconfig['options']['send']) . "\"";?> size="64" /> + <input name="send_options_send" type="text" <?if (isset($pconfig['options']['send'])) echo "value=\"" . htmlspecialchars($pconfig['options']['send']) . "\"";?> size="64" /> </td> </tr> <tr align="left"> <td valign="top" align="right" class="vtable"><?=gettext("Expect string"); ?></td> <td class="vtable" colspan="2"> - <input name="send_options_expect" type="text" <?if(isset($pconfig['options']['expect'])) echo "value=\"" . htmlspecialchars($pconfig['options']['expect']) . "\"";?> size="64" /> + <input name="send_options_expect" type="text" <?if (isset($pconfig['options']['expect'])) echo "value=\"" . htmlspecialchars($pconfig['options']['expect']) . "\"";?> size="64" /> </td> </tr> </table> @@ -366,7 +378,7 @@ function updateType(t){ </td> </tr> </table> - </form> +</form> <br /> <?php include("fend.inc"); ?> </body> diff --git a/usr/local/www/load_balancer_pool.php b/usr/local/www/load_balancer_pool.php index 46e4e1c..a2e8c54 100644 --- a/usr/local/www/load_balancer_pool.php +++ b/usr/local/www/load_balancer_pool.php @@ -110,45 +110,48 @@ include("head.inc"); <?php 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."), "<br />"));?><br /> <?php endif; ?> <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="load balancer pools"> - <tr><td class="tabnavtbl"> - <?php - /* active tabs */ - $tab_array = array(); - $tab_array[] = array(gettext("Pools"), true, "load_balancer_pool.php"); - $tab_array[] = array(gettext("Virtual Servers"), false, "load_balancer_virtual_server.php"); - $tab_array[] = array(gettext("Monitors"), false, "load_balancer_monitor.php"); - $tab_array[] = array(gettext("Settings"), false, "load_balancer_setting.php"); - display_top_tabs($tab_array); - ?> - </td></tr> - <tr> - <td> - <div id="mainarea"> + <tr><td class="tabnavtbl"> + <?php + /* active tabs */ + $tab_array = array(); + $tab_array[] = array(gettext("Pools"), true, "load_balancer_pool.php"); + $tab_array[] = array(gettext("Virtual Servers"), false, "load_balancer_virtual_server.php"); + $tab_array[] = array(gettext("Monitors"), false, "load_balancer_monitor.php"); + $tab_array[] = array(gettext("Settings"), false, "load_balancer_setting.php"); + display_top_tabs($tab_array); + ?> + </td></tr> + <tr> + <td> + <div id="mainarea"> <?php - $t = new MainTable(); - $t->edit_uri('load_balancer_pool_edit.php'); - $t->my_uri('load_balancer_pool.php'); - $t->add_column(gettext('Name'),'name',10); - $t->add_column(gettext('Mode'),'mode',10); - $t->add_column(gettext('Servers'),'servers',15); - $t->add_column(gettext('Port'),'port',10); - $t->add_column(gettext('Monitor'),'monitor',10); - $t->add_column(gettext('Description'),'descr',25); - $t->add_button('edit'); - $t->add_button('dup'); - $t->add_button('del'); - $t->add_content_array($a_pool); - $t->display(); + $t = new MainTable(); + $t->edit_uri('load_balancer_pool_edit.php'); + $t->my_uri('load_balancer_pool.php'); + $t->add_column(gettext('Name'),'name',10); + $t->add_column(gettext('Mode'),'mode',10); + $t->add_column(gettext('Servers'),'servers',15); + $t->add_column(gettext('Port'),'port',10); + $t->add_column(gettext('Monitor'),'monitor',10); + $t->add_column(gettext('Description'),'descr',25); + $t->add_button('edit'); + $t->add_button('dup'); + $t->add_button('del'); + $t->add_content_array($a_pool); + $t->display(); ?> - - </div> - </td> - </tr> - <tr><td> - <br /><span class="red"><strong><?=gettext("Hint:");?></strong></span><br /> - <?= sprintf(gettext("The Load Balancer in %s 2.0 is for server load balancing, not Multi-WAN. For load balancing or failover for multiple WANs, use "), $g['product_name']);?> - <a href="/system_gateway_groups.php"><?= gettext("Gateway Groups"); ?></a> - </td></tr> + </div> + </td> + </tr> + <tr> + <td> + <br /> + <span class="red"><strong><?=gettext("Hint:");?></strong></span> + <br /> + <?= sprintf(gettext("The Load Balancer in %s 2.0 is for server load balancing, not Multi-WAN. For load balancing or failover for multiple WANs, use "), $g['product_name']);?> + <a href="/system_gateway_groups.php"><?= gettext("Gateway Groups"); ?></a> + </td> + </tr> </table> </form> <?php include("fend.inc"); ?> diff --git a/usr/local/www/load_balancer_pool_edit.php b/usr/local/www/load_balancer_pool_edit.php index 4eaa6f0..572e5b5 100644 --- a/usr/local/www/load_balancer_pool_edit.php +++ b/usr/local/www/load_balancer_pool_edit.php @@ -51,10 +51,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']; @@ -83,63 +85,73 @@ if ($_POST) { 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 (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); } } } $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']); update_if_changed("description", $poolent['descr'], $_POST['descr']); @@ -152,13 +164,15 @@ 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 */ mark_subsystem_dirty('loadbalancer'); @@ -181,11 +195,11 @@ include("head.inc"); <?php include("fbegin.inc"); ?> <script type="text/javascript"> //<![CDATA[ -function clearcombo(){ - for (var i=document.iform.serversSelect.options.length-1; i>=0; i--){ - document.iform.serversSelect.options[i] = null; - } - document.iform.serversSelect.selectedIndex = -1; +function clearcombo() { + for (var i=document.iform.serversSelect.options.length-1; i>=0; i--) { + document.iform.serversSelect.options[i] = null; + } + document.iform.serversSelect.selectedIndex = -1; } //]]> </script> @@ -195,7 +209,7 @@ function clearcombo(){ <?php if ($input_errors) print_input_errors($input_errors); ?> - <form action="load_balancer_pool_edit.php" method="post" name="iform" id="iform"> +<form action="load_balancer_pool_edit.php" method="post" name="iform" id="iform"> <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="load balancer pool entry"> <tr> <td colspan="2" valign="top" class="listtopic"><?=gettext("Add/edit Load Balancer - Pool entry"); ?></td> @@ -203,29 +217,29 @@ function clearcombo(){ <tr align="left"> <td width="22%" valign="top" class="vncellreq"><?=gettext("Name"); ?></td> <td width="78%" class="vtable" colspan="2"> - <input name="name" type="text" <?if(isset($pconfig['name'])) echo "value=\"" . htmlspecialchars($pconfig['name']) . "\"";?> size="16" maxlength="16" /> + <input name="name" type="text" <?if (isset($pconfig['name'])) echo "value=\"" . htmlspecialchars($pconfig['name']) . "\"";?> size="16" maxlength="16" /> </td> </tr> <tr align="left"> <td width="22%" valign="top" class="vncellreq"><?=gettext("Mode"); ?></td> <td width="78%" class="vtable" colspan="2"> <select id="mode" name="mode" onchange="enforceFailover(); checkPoolControls();"> - <option value="loadbalance" <?if(!isset($pconfig['mode']) || ($pconfig['mode'] == "loadbalance")) echo "selected=\"selected\"";?>><?=gettext("Load Balance");?></option> - <option value="failover" <?if($pconfig['mode'] == "failover") echo "selected=\"selected\"";?>><?=gettext("Manual Failover");?></option> + <option value="loadbalance" <?if (!isset($pconfig['mode']) || ($pconfig['mode'] == "loadbalance")) echo "selected=\"selected\"";?>><?=gettext("Load Balance");?></option> + <option value="failover" <?if ($pconfig['mode'] == "failover") echo "selected=\"selected\"";?>><?=gettext("Manual Failover");?></option> </select> </td> </tr> <tr align="left"> <td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td> <td width="78%" class="vtable" colspan="2"> - <input name="descr" type="text" <?if(isset($pconfig['descr'])) echo "value=\"" . htmlspecialchars($pconfig['descr']) . "\"";?> size="64" /> + <input name="descr" type="text" <?if (isset($pconfig['descr'])) echo "value=\"" . htmlspecialchars($pconfig['descr']) . "\"";?> size="64" /> </td> </tr> <tr align="left"> <td width="22%" valign="top" id="monitorport_text" class="vncellreq"><?=gettext("Port"); ?></td> <td width="78%" class="vtable" colspan="2"> - <input class="formfldalias" id="port" name="port" type="text" <?if(isset($pconfig['port'])) echo "value=\"{$pconfig['port']}\"";?> size="16" maxlength="16" /><br /> + <input class="formfldalias" id="port" name="port" type="text" <?if (isset($pconfig['port'])) echo "value=\"{$pconfig['port']}\"";?> size="16" maxlength="16" /><br /> <div id="monitorport_desc"> <?=gettext("This is the port your servers are listening on."); ?><br /> <?=gettext("You may also specify a port alias listed in Firewall -> Aliases here."); ?> @@ -241,7 +255,7 @@ function clearcombo(){ <tr align="left"> <td width="22%" valign="top" id="retry_text" class="vncell"><?=gettext("Retry"); ?></td> <td width="78%" class="vtable" colspan="2"> - <input name="retry" type="text" <?if(isset($pconfig['retry'])) echo "value=\"{$pconfig['retry']}\"";?> size="16" maxlength="16" /><br /> + <input name="retry" type="text" <?if (isset($pconfig['retry'])) echo "value=\"{$pconfig['retry']}\"";?> size="16" maxlength="16" /><br /> <div id="retry_desc"><?=gettext("Optionally specify how many times to retry checking a server before declaring it down."); ?></div> </td> </tr> @@ -254,7 +268,7 @@ function clearcombo(){ <tr align="left"> <td width="22%" valign="top" class="vncellreq"><?=gettext("Monitor"); ?></td> <td width="78%" class="vtable" colspan="2"> - <?php if(count($config['load_balancer']['monitor_type'])): ?> + <?php if (count($config['load_balancer']['monitor_type'])): ?> <select id="monitor" name="monitor"> <?php foreach ($config['load_balancer']['monitor_type'] as $monitor) { @@ -275,7 +289,7 @@ function clearcombo(){ <tr align="left"> <td width="22%" valign="top" class="vncellreq"><?=gettext("Server IP Address"); ?></td> <td width="78%" class="vtable" colspan="2"> - <input name="ipaddr" type="text" size="16" style="float: left;" /> + <input name="ipaddr" type="text" size="16" style="float: left;" /> <input class="formbtn" type="button" name="button1" value="<?=gettext("Add to pool"); ?>" onclick="AddServerToPool(document.iform); enforceFailover(); checkPoolControls();" /><br /> </td> </tr> @@ -292,13 +306,13 @@ function clearcombo(){ <tbody> <tr> <td align="center"> - <b><?=gettext("Pool Disabled"); ?></b> + <b><?=gettext("Pool Disabled"); ?></b> <br/> <select id="serversDisabledSelect" name="serversdisabled[]" multiple="multiple" size="5"> <?php if (is_array($pconfig['serversdisabled'])) { - foreach($pconfig['serversdisabled'] as $svrent) { - if($svrent != '') echo " <option value=\"{$svrent}\">{$svrent}</option>\n"; + foreach ($pconfig['serversdisabled'] as $svrent) { + if ($svrent != '') echo " <option value=\"{$svrent}\">{$svrent}</option>\n"; } } ?> @@ -312,15 +326,15 @@ function clearcombo(){ </td> <td align="center"> - <b><?=gettext("Enabled (default)"); ?></b> + <b><?=gettext("Enabled (default)"); ?></b> <br/> <select id="serversSelect" name="servers[]" multiple="multiple" size="5"> <?php -if (is_array($pconfig['servers'])) { - foreach($pconfig['servers'] as $svrent) { - echo " <option value=\"{$svrent}\">{$svrent}</option>\n"; + if (is_array($pconfig['servers'])) { + foreach ($pconfig['servers'] as $svrent) { + echo " <option value=\"{$svrent}\">{$svrent}</option>\n"; + } } -} ?> </select> <input class="formbtn" type="button" name="removeEnabled" value="<?=gettext("Remove"); ?>" onclick="RemoveServerFromPool(document.iform, 'servers[]');" /> @@ -334,7 +348,7 @@ if (is_array($pconfig['servers'])) { <td width="22%" valign="top"> </td> <td width="78%"> <br /> - <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onclick="AllServers('serversSelect', true); AllServers('serversDisabledSelect', true);" /> + <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onclick="AllServers('serversSelect', true); AllServers('serversDisabledSelect', true);" /> <input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" /> <?php if (isset($id) && $a_pool[$id] && $_GET['act'] != 'dup'): ?> <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" /> @@ -342,7 +356,7 @@ if (is_array($pconfig['servers'])) { </td> </tr> </table> - </form> +</form> <br /> <?php include("fend.inc"); ?> </body> diff --git a/usr/local/www/load_balancer_relay_action.php b/usr/local/www/load_balancer_relay_action.php index bb39846..2d9b21f 100644 --- a/usr/local/www/load_balancer_relay_action.php +++ b/usr/local/www/load_balancer_relay_action.php @@ -70,7 +70,7 @@ if ($_GET['act'] == "del") { /* make sure no relay protocols reference this entry */ if (is_array($config['load_balancer']['lbprotocol'])) { foreach ($config['load_balancer']['lbprotocol'] as $lbp) { - foreach($lbp['lbaction'] as $lba) { + foreach ($lbp['lbaction'] as $lba) { if ($lba['name'] == $a_action[$_GET['id']]['name']) { $input_errors[] = gettext("This entry cannot be deleted because it is still referenced by at least one relay protocol."); break; @@ -90,14 +90,16 @@ if ($_GET['act'] == "del") { } /* Index lbpool array for easy hyperlinking */ -/* for ($i = 0; isset($config['load_balancer']['lbprotocol'][$i]); $i++) { +/* +for ($i = 0; isset($config['load_balancer']['lbprotocol'][$i]); $i++) { for ($o = 0; isset($config['load_balancer']['lbprotocol'][$i]['options'][$o]); o++) { - $a_vs[$i]['options'][$o] = " - $a_vs[$i]['poolname'] = "<a href=\"/load_balancer_pool_edit.php?id={$poodex[$a_vs[$i]['poolname']]}\">{$a_vs[$i]['poolname']}</a>"; - if ($a_vs[$i]['sitedown'] != '') { - $a_vs[$i]['sitedown'] = "<a href=\"/load_balancer_pool_edit.php?id={$poodex[$a_vs[$i]['sitedown']]}\">{$a_vs[$i]['sitedown']}</a>"; - } else { - $a_vs[$i]['sitedown'] = 'none'; + $a_vs[$i]['options'][$o] = " + $a_vs[$i]['poolname'] = "<a href=\"/load_balancer_pool_edit.php?id={$poodex[$a_vs[$i]['poolname']]}\">{$a_vs[$i]['poolname']}</a>"; + if ($a_vs[$i]['sitedown'] != '') { + $a_vs[$i]['sitedown'] = "<a href=\"/load_balancer_pool_edit.php?id={$poodex[$a_vs[$i]['sitedown']]}\">{$a_vs[$i]['sitedown']}</a>"; + } else { + $a_vs[$i]['sitedown'] = 'none'; + } } } */ @@ -117,38 +119,38 @@ include("head.inc"); <?php print_info_box_np(gettext("The load balancer configuration has been changed.<br />You must apply the changes in order for them to take effect."));?><br /> <?php endif; ?> <table width="100%" border="0" cellpadding="0" cellspacing="0"> - <tr><td class="tabnavtbl"> - <?php - /* active tabs */ - $tab_array = array(); - $tab_array[] = array(gettext("Monitors"), false, "load_balancer_monitor.php"); - $tab_array[] = array(gettext("Pools"), false, "load_balancer_pool.php"); - $tab_array[] = array(gettext("Virtual Servers"), false, "load_balancer_virtual_server.php"); - $tab_array[] = array(gettext("Relay Actions"), true, "load_balancer_relay_action.php"); - $tab_array[] = array(gettext("Relay Protocols"), false, "load_balancer_relay_protocol.php"); - display_top_tabs($tab_array); - ?> - </td></tr> - <tr> - <td> - <div id="mainarea"> + <tr><td class="tabnavtbl"> + <?php + /* active tabs */ + $tab_array = array(); + $tab_array[] = array(gettext("Monitors"), false, "load_balancer_monitor.php"); + $tab_array[] = array(gettext("Pools"), false, "load_balancer_pool.php"); + $tab_array[] = array(gettext("Virtual Servers"), false, "load_balancer_virtual_server.php"); + $tab_array[] = array(gettext("Relay Actions"), true, "load_balancer_relay_action.php"); + $tab_array[] = array(gettext("Relay Protocols"), false, "load_balancer_relay_protocol.php"); + display_top_tabs($tab_array); + ?> + </td></tr> + <tr> + <td> + <div id="mainarea"> <? - $t = new MainTable(); - $t->edit_uri('load_balancer_relay_action_edit.php'); - $t->my_uri('load_balancer_relay_action.php'); - $t->add_column(gettext('Name'),'name',20); - $t->add_column(gettext('Type'),'type',10); - $t->add_column(gettext('Options'),'options',30); - $t->add_column(gettext('Description'),'descr',30); - $t->add_button('edit'); - $t->add_button('dup'); - $t->add_button('del'); - $t->add_content_array($a_action); - $t->display(); + $t = new MainTable(); + $t->edit_uri('load_balancer_relay_action_edit.php'); + $t->my_uri('load_balancer_relay_action.php'); + $t->add_column(gettext('Name'),'name',20); + $t->add_column(gettext('Type'),'type',10); + $t->add_column(gettext('Options'),'options',30); + $t->add_column(gettext('Description'),'descr',30); + $t->add_button('edit'); + $t->add_button('dup'); + $t->add_button('del'); + $t->add_content_array($a_action); + $t->display(); ?> - </div> - </td> - </tr> + </div> + </td> + </tr> </table> </form> <?php include("fend.inc"); ?> diff --git a/usr/local/www/load_balancer_relay_action_edit.php b/usr/local/www/load_balancer_relay_action_edit.php index ec83402..55677ec 100644 --- a/usr/local/www/load_balancer_relay_action_edit.php +++ b/usr/local/www/load_balancer_relay_action_edit.php @@ -49,20 +49,22 @@ if (!is_array($config['load_balancer']['lbaction'])) { } $a_action = &$config['load_balancer']['lbaction']; -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_action[$id]) { - $pconfig = array(); + $pconfig = array(); $pconfig = $a_action[$id]; } else { - // XXX - TODO, this isn't sane for this page :) + // XXX - TODO, this isn't sane for this page :) /* Some sane page defaults */ $pconfig['protocol'] = 'http'; $pconfig['direction'] = 'request'; - $pconfig['type'] = 'cookie'; + $pconfig['type'] = 'cookie'; $pconfig['action'] = 'change'; } @@ -102,19 +104,17 @@ $actions['direction']['response']['header'] = $hr_actions; //$action['http']['tcp'] = array(); //$action['http']['ssl'] = array(); - - if ($_POST) { $changecount++; unset($input_errors); $pconfig = $_POST; - // Peel off the action and type from the post and fix $pconfig - $action = explode('_', $pconfig['action']); - $pconfig['action'] = $action[2]; - $pconfig['type'] = $action[1]; - unset($pconfig["type_{$pconfig['direction']}"]); + // Peel off the action and type from the post and fix $pconfig + $action = explode('_', $pconfig['action']); + $pconfig['action'] = $action[2]; + $pconfig['type'] = $action[1]; + unset($pconfig["type_{$pconfig['direction']}"]); /* input validation */ $reqdfields = explode(" ", "name protocol direction action descr"); @@ -123,48 +123,54 @@ if ($_POST) { do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); /* Ensure that our monitor names are unique */ - for ($i=0; isset($config['load_balancer']['lbactions'][$i]); $i++) - if (($_POST['name'] == $config['load_balancer']['lbactions'][$i]['name']) && ($i != $id)) + for ($i=0; isset($config['load_balancer']['lbactions'][$i]); $i++) { + if (($_POST['name'] == $config['load_balancer']['lbactions'][$i]['name']) && ($i != $id)) { $input_errors[] = gettext("This action name has already been used. Action names must be unique."); + } + } - if (strpos($_POST['name'], " ") !== false) + if (strpos($_POST['name'], " ") !== false) { $input_errors[] = gettext("You cannot use spaces in the 'name' field."); + } if (!$input_errors) { $actent = array(); - if(isset($id) && $a_action[$id]) + if (isset($id) && $a_action[$id]) { $actent = $a_action[$id]; - if($actent['name'] != "") + } + if ($actent['name'] != "") { $changedesc .= " " . sprintf(gettext("modified '%s' action:"), $actent['name']); - + } + update_if_changed("name", $actent['name'], $pconfig['name']); update_if_changed("protocol", $actent['protocol'], $pconfig['protocol']); update_if_changed("type", $actent['type'], $pconfig['type']); update_if_changed("direction", $actent['direction'], $pconfig['direction']); update_if_changed("description", $actent['descr'], $pconfig['descr']); - update_if_changed("action", $actent['action'], $pconfig['action']); - switch ($pconfig['action']) { - case "append": - case "change": - case "expect": - case "filter": { - update_if_changed("value", $actent['options']['value'], $pconfig['option_action_value']); - update_if_changed("key", $actent['options']['akey'], $pconfig['option_action_key']); - break; - } - case "hash": - case "log": { - update_if_changed("key", $actent['options']['akey'], $pconfig['option_action_key']); - break; - } - } - + update_if_changed("action", $actent['action'], $pconfig['action']); + switch ($pconfig['action']) { + case "append": + case "change": + case "expect": + case "filter": { + update_if_changed("value", $actent['options']['value'], $pconfig['option_action_value']); + update_if_changed("key", $actent['options']['akey'], $pconfig['option_action_key']); + break; + } + case "hash": + case "log": { + update_if_changed("key", $actent['options']['akey'], $pconfig['option_action_key']); + break; + } + } + if (isset($id) && $a_action[$id]) { -// XXX - TODO +// XXX - TODO /* 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]['protocol'] == $a_protocol[$id]['name']) +// if ($config['load_balancer']['virtual_server'][$i]['protocol'] == $a_protocol[$id]['name']) { // $config['load_balancer']['virtual_server'][$i]['protocol'] = $protent['name']; +// } // } $a_action[$id] = $actent; } else { @@ -185,7 +191,7 @@ $pgtitle = array(gettext("Services"), gettext("Load Balancer"),gettext("Relay Ac $shortcut_section = "relayd"; include("head.inc"); - $types = array("http" => gettext("HTTP"), "tcp" => gettext("TCP"), "dns" => gettext("DNS")); +$types = array("http" => gettext("HTTP"), "tcp" => gettext("TCP"), "dns" => gettext("DNS")); ?> <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> @@ -193,10 +199,10 @@ include("head.inc"); <script type="text/javascript"> function updateProtocol(m) { - // Default to HTTP - if (m == "") { - m = "http"; - } + // Default to HTTP + if (m == "") { + m = "http"; + } switch (m) { case "dns": { jQuery('#type_row').hide(); @@ -228,18 +234,18 @@ function updateProtocol(m) { * based on what's been either preconfigured or "defaults" * This really did have to be done in PHP. */ - if (isset($pconfig['type'])) { - $dtype = $pconfig['type']; - $ddir = $pconfig['direction']; - } else { - $dtype = "cookie"; - $ddir = "request"; - } + if (isset($pconfig['type'])) { + $dtype = $pconfig['type']; + $ddir = $pconfig['direction']; + } else { + $dtype = "cookie"; + $ddir = "request"; + } foreach ($actions['direction'][$ddir] as $type => $tv) { - foreach ($actions['direction'][$ddir][$type] as $action => $av ) { - if($dtype == $type) { + foreach ($actions['direction'][$ddir][$type] as $action => $av) { + if ($dtype == $type) { echo "jQuery('#{$ddir}_{$type}_{$action}').show();"; - } + } } } ?> @@ -250,38 +256,38 @@ function updateProtocol(m) { } function updateDirection(d) { - // Default to request - if (d == "") { - d = "request"; - } - - switch (d) { - case "request": { - jQuery('#type_response').prop('disabled',true); - jQuery('#type_response').hide(); - jQuery('#type_request').prop('disabled',false); - jQuery('#type_request').show(); - break; - } - case "response": { - jQuery('#type_request').prop('disabled',true); - jQuery('#type_request').hide(); - jQuery('#type_response').prop('disabled',false); - jQuery('#type_response').show(); - break; - } - } + // Default to request + if (d == "") { + d = "request"; + } + + switch (d) { + case "request": { + jQuery('#type_response').prop('disabled',true); + jQuery('#type_response').hide(); + jQuery('#type_request').prop('disabled',false); + jQuery('#type_request').show(); + break; + } + case "response": { + jQuery('#type_request').prop('disabled',true); + jQuery('#type_request').hide(); + jQuery('#type_response').prop('disabled',false); + jQuery('#type_response').show(); + break; + } + } } -function updateType(t){ - // Default to action_row - // XXX - does this actually make any sense? - if (t == "") { - t = "action_row"; - } +function updateType(t) { + // Default to action_row + // XXX - does this actually make any sense? + if (t == "") { + t = "action_row"; + } - switch(t) { + switch (t) { <?php /* OK, so this is sick using php to generate javascript, but it needed to be done */ foreach ($types as $key => $val) { @@ -301,89 +307,89 @@ function updateType(t){ function updateAction(a) { - // Default to change - if (a == "") { - a = "change"; - } - switch(a) { - case "append": { - jQuery('#input_action_value').show(); - jQuery('#option_action_value').prop('disabled',false); - jQuery('#input_action_key').show(); - jQuery('#option_action_key').prop('disabled',false); - jQuery('#input_action_id').hide(); - jQuery('#option_action_id').prop('disabled',true); - jQuery('#action_action_value').html(" to "); - jQuery('#action_action_id').html(""); - break; - } - case "change": { - jQuery('#input_action_value').show(); - jQuery('#option_action_value').prop('disabled',false); - jQuery('#input_action_key').show(); - jQuery('#option_action_key').prop('disabled',false); - jQuery('#input_action_id').hide(); - jQuery('#option_action_id').prop('disabled',true); - jQuery('#action_action_value').html(" of "); - jQuery('#action_action_id').html(""); - break; - } - case "expect": { - jQuery('#input_action_value').show(); - jQuery('#option_action_value').prop('disabled',false); - jQuery('#input_action_key').show(); - jQuery('#option_action_key').prop('disabled',false); - jQuery('#input_action_id').hide(); - jQuery('#option_action_id').prop('disabled',true); - jQuery('#action_action_value').html(" from "); - jQuery('#action_action_id').html(""); - break; - } - case "filter": { - jQuery('#input_action_value').show(); - jQuery('#option_action_value').prop('disabled',false); - jQuery('#input_action_key').show(); - jQuery('#option_action_key').prop('disabled',false); - jQuery('#input_action_id').hide(); - jQuery('#option_action_id').prop('disabled',true); - jQuery('#action_action_value').html(" from "); - jQuery('#action_action_id').html(""); - break; - } - case "hash": { - jQuery('#input_action_value').hide(); - jQuery('#option_action_value').prop('disabled',true); - jQuery('#input_action_key').show(); - jQuery('#option_action_key').prop('disabled',false); - jQuery('#input_action_id').hide(); - jQuery('#option_action_id').prop('disabled',true); - jQuery('#action_action_value').html(""); - jQuery('#action_action_id').html(""); - break; - } - case "log": { - jQuery('#input_action_value').hide(); - jQuery('#option_action_value').prop('disabled',true); - jQuery('#input_action_key').show(); - jQuery('#option_action_key').prop('disabled',false); - jQuery('#input_action_id').hide(); - jQuery('#option_action_id').prop('disabled',true); - jQuery('#action_action_value').html(""); - jQuery('#action_action_id').html(""); - break; - } - case "mark": { - jQuery('#input_action_value').show(); - jQuery('#option_action_value').prop('disabled',false); - jQuery('#input_action_key').show(); - jQuery('#option_action_key').prop('disabled',false); - jQuery('#input_action_id').show(); - jQuery('#option_action_id').prop('disabled',false); - jQuery('#action_action_value').html(" from "); - jQuery('#action_action_id').html(" with "); - break; - } - } + // Default to change + if (a == "") { + a = "change"; + } + switch (a) { + case "append": { + jQuery('#input_action_value').show(); + jQuery('#option_action_value').prop('disabled',false); + jQuery('#input_action_key').show(); + jQuery('#option_action_key').prop('disabled',false); + jQuery('#input_action_id').hide(); + jQuery('#option_action_id').prop('disabled',true); + jQuery('#action_action_value').html(" to "); + jQuery('#action_action_id').html(""); + break; + } + case "change": { + jQuery('#input_action_value').show(); + jQuery('#option_action_value').prop('disabled',false); + jQuery('#input_action_key').show(); + jQuery('#option_action_key').prop('disabled',false); + jQuery('#input_action_id').hide(); + jQuery('#option_action_id').prop('disabled',true); + jQuery('#action_action_value').html(" of "); + jQuery('#action_action_id').html(""); + break; + } + case "expect": { + jQuery('#input_action_value').show(); + jQuery('#option_action_value').prop('disabled',false); + jQuery('#input_action_key').show(); + jQuery('#option_action_key').prop('disabled',false); + jQuery('#input_action_id').hide(); + jQuery('#option_action_id').prop('disabled',true); + jQuery('#action_action_value').html(" from "); + jQuery('#action_action_id').html(""); + break; + } + case "filter": { + jQuery('#input_action_value').show(); + jQuery('#option_action_value').prop('disabled',false); + jQuery('#input_action_key').show(); + jQuery('#option_action_key').prop('disabled',false); + jQuery('#input_action_id').hide(); + jQuery('#option_action_id').prop('disabled',true); + jQuery('#action_action_value').html(" from "); + jQuery('#action_action_id').html(""); + break; + } + case "hash": { + jQuery('#input_action_value').hide(); + jQuery('#option_action_value').prop('disabled',true); + jQuery('#input_action_key').show(); + jQuery('#option_action_key').prop('disabled',false); + jQuery('#input_action_id').hide(); + jQuery('#option_action_id').prop('disabled',true); + jQuery('#action_action_value').html(""); + jQuery('#action_action_id').html(""); + break; + } + case "log": { + jQuery('#input_action_value').hide(); + jQuery('#option_action_value').prop('disabled',true); + jQuery('#input_action_key').show(); + jQuery('#option_action_key').prop('disabled',false); + jQuery('#input_action_id').hide(); + jQuery('#option_action_id').prop('disabled',true); + jQuery('#action_action_value').html(""); + jQuery('#action_action_id').html(""); + break; + } + case "mark": { + jQuery('#input_action_value').show(); + jQuery('#option_action_value').prop('disabled',false); + jQuery('#input_action_key').show(); + jQuery('#option_action_key').prop('disabled',false); + jQuery('#input_action_id').show(); + jQuery('#option_action_id').prop('disabled',false); + jQuery('#action_action_value').html(" from "); + jQuery('#action_action_id').html(" with "); + break; + } + } } @@ -393,17 +399,17 @@ function num_options() { jQuery(document).ready(function() { - updateProtocol('<?=htmlspecialchars($pconfig['protocol'])?>'); - updateDirection('<?=htmlspecialchars($pconfig['direction'])?>'); - updateType('<?=htmlspecialchars($pconfig['type'])?>'); - updateAction('<?=htmlspecialchars($pconfig['action'])?>'); + updateProtocol('<?=htmlspecialchars($pconfig['protocol'])?>'); + updateDirection('<?=htmlspecialchars($pconfig['direction'])?>'); + updateType('<?=htmlspecialchars($pconfig['type'])?>'); + updateAction('<?=htmlspecialchars($pconfig['action'])?>'); }); </script> <?php include("fbegin.inc"); ?> <?php if ($input_errors) print_input_errors($input_errors); ?> - <form action="load_balancer_relay_action_edit.php" method="post" name="iform" id="iform"> +<form action="load_balancer_relay_action_edit.php" method="post" name="iform" id="iform"> <table width="100%" border="0" cellpadding="6" cellspacing="0"> <tr> <td colspan="2" valign="top" class="listtopic"><?=gettext("Edit Load Balancer - Relay Action entry"); ?></td> @@ -411,13 +417,13 @@ jQuery(document).ready(function() { <tr align="left" id="name"> <td width="22%" valign="top" class="vncellreq"><?=gettext("Name"); ?></td> <td width="78%" class="vtable" colspan="2"> - <input name="name" type="text" <?if(isset($pconfig['name'])) echo "value=\"{$pconfig['name']}\"";?> size="16" maxlength="16"> + <input name="name" type="text" <?if (isset($pconfig['name'])) echo "value=\"{$pconfig['name']}\"";?> size="16" maxlength="16"> </td> </tr> <tr align="left"> <td width="22%" valign="top" class="vncellreq"><?=gettext("Description"); ?></td> <td width="78%" class="vtable" colspan="2"> - <input name="descr" type="text" <?if(isset($pconfig['descr'])) echo "value=\"{$pconfig['descr']}\"";?>size="64"> + <input name="descr" type="text" <?if (isset($pconfig['descr'])) echo "value=\"{$pconfig['descr']}\"";?>size="64"> </td> </tr> <!-- Protocol --> @@ -427,7 +433,7 @@ jQuery(document).ready(function() { <select id="protocol" name="protocol"> <? foreach ($actions['protocol'] as $key => $val) { - if(isset($pconfig['protocol']) && $pconfig['protocol'] == $key) { + if (isset($pconfig['protocol']) && $pconfig['protocol'] == $key) { $selected = " selected"; } else { $selected = ""; @@ -446,7 +452,7 @@ jQuery(document).ready(function() { <select id="direction" name="direction" style="disabled"> <? foreach ($actions['direction'] as $key => $val) { - if(isset($pconfig['direction']) && $pconfig['direction'] == $key) { + if (isset($pconfig['direction']) && $pconfig['direction'] == $key) { $selected = " selected"; } else { $selected = ""; @@ -455,46 +461,45 @@ jQuery(document).ready(function() { } ?> </select> - </td> </tr> <!-- Type --> - <tr align="left" id="type_row"<?= $pconfig['protocol'] == "http" ? "" : " style=\"display:none;\""?>> + <tr align="left" id="type_row"<?= $pconfig['protocol'] == "http" ? "" : " style=\"display:none;\""?>> <td width="22%" valign="top" class="vncellreq"><?=gettext("Type"); ?></td> <td width="78%" class="vtable" colspan="2"> <? foreach ($actions['direction'] as $dir => $v) { - echo" <select id=\"type_{$dir}\" name=\"type_{$dir}\" style=\"display:none; disabled;\">"; + echo "<select id=\"type_{$dir}\" name=\"type_{$dir}\" style=\"display:none; disabled;\">"; foreach ($actions['direction'][$dir] as $key => $val) { - if(isset($pconfig['type']) && $pconfig['type'] == $key) { + if (isset($pconfig['type']) && $pconfig['type'] == $key) { $selected = " selected"; } else { $selected = ""; } echo "<option value=\"{$key}\" onclick=\"updateDirection('$key');\"{$selected}>{$key}</option>\n"; } + echo "</select>"; } -?> - </select> +?> </td> </tr> <!-- Action --> - <tr align="left" id="action_row"<?= $pconfig['protocol'] == "http" ? "" : " style=\"display:none;\""?>> + <tr align="left" id="action_row"<?= $pconfig['protocol'] == "http" ? "" : " style=\"display:none;\""?>> <td width="22%" valign="top" class="vncellreq"><?=gettext("Action"); ?></td> <td width="78%" class="vtable" colspan="2"> <select id="action" name="action" style=\"display: none;\"> <? foreach ($actions['direction'] as $dir => $dv) { foreach ($actions['direction'][$dir] as $type => $tv) { - foreach ($actions['direction'][$dir][$type] as $action => $av ) { - if(isset($pconfig['action']) && $pconfig['action'] == $action) { + foreach ($actions['direction'][$dir][$type] as $action => $av) { + if (isset($pconfig['action']) && $pconfig['action'] == $action) { + $selected = " selected"; + } else if ($action == "change") { $selected = " selected"; - } else if ($action == "change" ){ - $selected = " selected"; - } else { - $selected = ""; + } else { + $selected = ""; } echo "<option id=\"{$dir}_{$type}_{$action}\" value=\"{$dir}_{$type}_{$action}\" onClick=\"updateAction('$action');\" style=\"display: none;\"{$selected}>{$action}</option>\n"; } @@ -502,14 +507,16 @@ jQuery(document).ready(function() { } ?> </select> -<br /> -<table><tr> -<td><div id="input_action_value"><?=gettext("Value"); ?> <input id="option_action_value" name="option_action_value" type="text" <?if(isset($pconfig['options']['value'])) echo "value=\"{$pconfig['options']['value']}\"";?>size="20"></div></td> -<td><div id="action_action_value"></div></td> -<td><div id="input_action_key"><?=gettext("Key"); ?> <input id="option_action_key" name="option_action_key" type="text" <?if(isset($pconfig['options']['akey'])) echo "value=\"{$pconfig['options']['akey']}\"";?>size="20"></div></td> -<td><div id="action_action_id"></div></td> -<td><div id="input_action_id"><?=gettext("ID"); ?> <input id="option_action_id" name="option_action_id" type="text" <?if(isset($pconfig['options']['id'])) echo "value=\"{$pconfig['options']['id']}\"";?>size="20"></div></td> -</tr></table> + <br /> + <table> + <tr> + <td><div id="input_action_value"><?=gettext("Value"); ?> <input id="option_action_value" name="option_action_value" type="text" <?if (isset($pconfig['options']['value'])) echo "value=\"{$pconfig['options']['value']}\"";?>size="20"></div></td> + <td><div id="action_action_value"></div></td> + <td><div id="input_action_key"><?=gettext("Key"); ?> <input id="option_action_key" name="option_action_key" type="text" <?if (isset($pconfig['options']['akey'])) echo "value=\"{$pconfig['options']['akey']}\"";?>size="20"></div></td> + <td><div id="action_action_id"></div></td> + <td><div id="input_action_id"><?=gettext("ID"); ?> <input id="option_action_id" name="option_action_id" type="text" <?if (isset($pconfig['options']['id'])) echo "value=\"{$pconfig['options']['id']}\"";?>size="20"></div></td> + </tr> + </table> </td> </tr> <tr align="left" id="tcp_options_row"<?= $pconfig['protocol'] == "tcp" ? "" : " style=\"display:none;\""?>> @@ -520,7 +527,7 @@ jQuery(document).ready(function() { <!-- XXX TODO > <? foreach ($types as $key => $val) { - if(isset($pconfig['protocol']) && $pconfig['protocol'] == $key) { + if (isset($pconfig['protocol']) && $pconfig['protocol'] == $key) { $selected = " selected"; } else { $selected = ""; @@ -528,8 +535,8 @@ jQuery(document).ready(function() { echo "<option value=\"{$key}\" onclick=\"updateType('{$key}');\"{$selected}>{$val}</option>\n"; } ?> - </select> < XXX TODO --> + </select> </td> </tr> <tr align="left" id="ssl_options_row"<?= $pconfig['protocol'] == "http" ? "" : " style=\"display:none;\""?>> @@ -540,7 +547,7 @@ jQuery(document).ready(function() { <select id="options" name="options"> <? foreach ($types as $key => $val) { - if(isset($pconfig['protocol']) && $pconfig['protocol'] == $key) { + if (isset($pconfig['protocol']) && $pconfig['protocol'] == $key) { $selected = " selected"; } else { $selected = ""; @@ -563,7 +570,7 @@ jQuery(document).ready(function() { </td> </tr> </table> - </form> +</form> <br /> <?php include("fend.inc"); ?> </body> diff --git a/usr/local/www/load_balancer_relay_protocol.php b/usr/local/www/load_balancer_relay_protocol.php index 845b444..23f5f3f 100644 --- a/usr/local/www/load_balancer_relay_protocol.php +++ b/usr/local/www/load_balancer_relay_protocol.php @@ -86,14 +86,16 @@ if ($_GET['act'] == "del") { } /* Index lbpool array for easy hyperlinking */ -/* for ($i = 0; isset($config['load_balancer']['lbprotocol'][$i]); $i++) { +/* +for ($i = 0; isset($config['load_balancer']['lbprotocol'][$i]); $i++) { for ($o = 0; isset($config['load_balancer']['lbprotocol'][$i]['options'][$o]); o++) { - $a_vs[$i]['options'][$o] = " - $a_vs[$i]['poolname'] = "<a href=\"/load_balancer_pool_edit.php?id={$poodex[$a_vs[$i]['poolname']]}\">{$a_vs[$i]['poolname']}</a>"; - if ($a_vs[$i]['sitedown'] != '') { - $a_vs[$i]['sitedown'] = "<a href=\"/load_balancer_pool_edit.php?id={$poodex[$a_vs[$i]['sitedown']]}\">{$a_vs[$i]['sitedown']}</a>"; - } else { - $a_vs[$i]['sitedown'] = 'none'; + $a_vs[$i]['options'][$o] = " + $a_vs[$i]['poolname'] = "<a href=\"/load_balancer_pool_edit.php?id={$poodex[$a_vs[$i]['poolname']]}\">{$a_vs[$i]['poolname']}</a>"; + if ($a_vs[$i]['sitedown'] != '') { + $a_vs[$i]['sitedown'] = "<a href=\"/load_balancer_pool_edit.php?id={$poodex[$a_vs[$i]['sitedown']]}\">{$a_vs[$i]['sitedown']}</a>"; + } else { + $a_vs[$i]['sitedown'] = 'none'; + } } } */ @@ -113,36 +115,36 @@ include("head.inc"); <?php print_info_box_np(gettext("The load balancer configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));?><br /> <?php endif; ?> <table width="100%" border="0" cellpadding="0" cellspacing="0"> - <tr><td class="tabnavtbl"> - <?php - /* active tabs */ - $tab_array = array(); - $tab_array[] = array(gettext("Monitors"), false, "load_balancer_monitor.php"); - $tab_array[] = array(gettext("Pools"), false, "load_balancer_pool.php"); - $tab_array[] = array(gettext("Virtual Servers"), false, "load_balancer_virtual_server.php"); - display_top_tabs($tab_array); - ?> - </td></tr> - <tr> - <td> - <div id="mainarea"> + <tr><td class="tabnavtbl"> + <?php + /* active tabs */ + $tab_array = array(); + $tab_array[] = array(gettext("Monitors"), false, "load_balancer_monitor.php"); + $tab_array[] = array(gettext("Pools"), false, "load_balancer_pool.php"); + $tab_array[] = array(gettext("Virtual Servers"), false, "load_balancer_virtual_server.php"); + display_top_tabs($tab_array); + ?> + </td></tr> + <tr> + <td> + <div id="mainarea"> <? - $t = new MainTable(); - $t->edit_uri('load_balancer_relay_protocol_edit.php'); - $t->my_uri('load_balancer_relay_protocol.php'); - $t->add_column(gettext('Name'),'name',20); - $t->add_column(gettext('Type'),'type',10); - $t->add_column(gettext('Options'),'options',30); - $t->add_column(gettext('Description'),'descr',30); - $t->add_button('edit'); - $t->add_button('dup'); - $t->add_button('del'); - $t->add_content_array($a_protocol); - $t->display(); + $t = new MainTable(); + $t->edit_uri('load_balancer_relay_protocol_edit.php'); + $t->my_uri('load_balancer_relay_protocol.php'); + $t->add_column(gettext('Name'),'name',20); + $t->add_column(gettext('Type'),'type',10); + $t->add_column(gettext('Options'),'options',30); + $t->add_column(gettext('Description'),'descr',30); + $t->add_button('edit'); + $t->add_button('dup'); + $t->add_button('del'); + $t->add_content_array($a_protocol); + $t->display(); ?> - </div> - </td> - </tr> + </div> + </td> + </tr> </table> </form> <?php include("fend.inc"); ?> diff --git a/usr/local/www/load_balancer_relay_protocol_edit.php b/usr/local/www/load_balancer_relay_protocol_edit.php index c9864c2..429a3b0 100644 --- a/usr/local/www/load_balancer_relay_protocol_edit.php +++ b/usr/local/www/load_balancer_relay_protocol_edit.php @@ -49,10 +49,12 @@ if (!is_array($config['load_balancer']['lbprotocol'])) { } $a_protocol = &$config['load_balancer']['lbprotocol']; -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_protocol[$id]) { $pconfig = $a_protocol[$id]; @@ -68,15 +70,12 @@ if (isset($id) && $a_protocol[$id]) { $changedesc = gettext("Load Balancer: Relay Protocol:") . " "; $changecount = 0; - - if ($_POST) { $changecount++; unset($input_errors); $pconfig = $_POST; - /* input validation */ $reqdfields = explode(" ", "name type descr"); $reqdfieldsn = array(gettext("Name"),gettext("Type"),gettext("Description")); @@ -84,14 +83,17 @@ if ($_POST) { do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); /* Ensure that our monitor names are unique */ - for ($i=0; isset($config['load_balancer']['lbprotocol'][$i]); $i++) - if (($_POST['name'] == $config['load_balancer']['lbprotocol'][$i]['name']) && ($i != $id)) + for ($i=0; isset($config['load_balancer']['lbprotocol'][$i]); $i++) { + if (($_POST['name'] == $config['load_balancer']['lbprotocol'][$i]['name']) && ($i != $id)) { $input_errors[] = gettext("This protocol name has already been used. Protocol names must be unique."); + } + } - if (strpos($_POST['name'], " ") !== false) + if (strpos($_POST['name'], " ") !== false) { $input_errors[] = gettext("You cannot use spaces in the 'name' field."); + } - switch($_POST['type']) { + switch ($_POST['type']) { case 'tcp': case 'http': case 'https': @@ -102,11 +104,13 @@ if ($_POST) { if (!$input_errors) { $protent = array(); - if(isset($id) && $a_protocol[$id]) + if (isset($id) && $a_protocol[$id]) { $protent = $a_protocol[$id]; - if($protent['name'] != "") + } + if ($protent['name'] != "") { $changedesc .= " " . sprintf(gettext("modified '%s' load balancing protocol:"), $protent['name']); - + } + update_if_changed(gettext("name"), $protent['name'], $pconfig['name']); update_if_changed(gettext("type"), $protent['type'], $pconfig['type']); update_if_changed(gettext("description"), $protent['descr'], $pconfig['descr']); @@ -117,15 +121,16 @@ if ($_POST) { /* 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]['protocol'] == $a_protocol[$id]['name']) + if ($config['load_balancer']['virtual_server'][$i]['protocol'] == $a_protocol[$id]['name']) { $config['load_balancer']['virtual_server'][$i]['protocol'] = $protent['name']; + } } -*/ +*/ $a_protocol[$id] = $protent; } else { $a_protocol[] = $protent; - } - + } + if ($changecount > 0) { /* Mark config dirty */ mark_subsystem_dirty('loadbalancer'); @@ -146,8 +151,8 @@ $types = array("http" => gettext("HTTP"), "tcp" => gettext("TCP"), "dns" => gett ?> <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> <script type="text/javascript"> -function updateType(t){ - switch(t) { +function updateType(t) { + switch (t) { <?php /* OK, so this is sick using php to generate javascript, but it needed to be done */ foreach ($types as $key => $val) { @@ -170,24 +175,24 @@ function num_options() { } /* -jQuery(document).ready(function(){ - $$('.action').each(function(action) { - new Draggable(action, {revert: true, ghosting: true}); - }); - Droppables.add('actions', { - accept: 'action', onDrop: function(action) { - var new_action = new Element('li'); - new Draggable(new_action, {revert: true}); - $('action_list').appendChild(new_action); - } - }); +jQuery(document).ready(function() { + $$('.action').each(function(action) { + new Draggable(action, {revert: true, ghosting: true}); + }); + Droppables.add('actions', { + accept: 'action', onDrop: function(action) { + var new_action = new Element('li'); + new Draggable(new_action, {revert: true}); + $('action_list').appendChild(new_action); + } + }); }); */ </script> <?php include("fbegin.inc"); ?> <?php if ($input_errors) print_input_errors($input_errors); ?> - <form action="load_balancer_relay_protocol_edit.php" method="post" name="iform" id="iform"> +<form action="load_balancer_relay_protocol_edit.php" method="post" name="iform" id="iform"> <table width="100%" border="0" cellpadding="6" cellspacing="0"> <tr> <td colspan="2" valign="top" class="listtopic"><?=gettext("Edit Load Balancer - Relay Protocol entry"); ?></td> @@ -195,7 +200,7 @@ jQuery(document).ready(function(){ <tr align="left"> <td width="22%" valign="top" class="vncellreq"><?=gettext("Name"); ?></td> <td width="78%" class="vtable" colspan="2"> - <input name="name" type="text" <?if(isset($pconfig['name'])) echo "value=\"{$pconfig['name']}\"";?> size="16" maxlength="16"> + <input name="name" type="text" <?if (isset($pconfig['name'])) echo "value=\"{$pconfig['name']}\"";?> size="16" maxlength="16"> </td> </tr> <tr align="left"> @@ -204,7 +209,7 @@ jQuery(document).ready(function(){ <select id="type" name="type"> <? foreach ($types as $key => $val) { - if(isset($pconfig['type']) && $pconfig['type'] == $key) { + if (isset($pconfig['type']) && $pconfig['type'] == $key) { $selected = " selected"; } else { $selected = ""; @@ -218,7 +223,7 @@ jQuery(document).ready(function(){ <tr align="left"> <td width="22%" valign="top" class="vncellreq"><?=gettext("Description"); ?></td> <td width="78%" class="vtable" colspan="2"> - <input name="descr" type="text" <?if(isset($pconfig['descr'])) echo "value=\"{$pconfig['descr']}\"";?>size="64"> + <input name="descr" type="text" <?if (isset($pconfig['descr'])) echo "value=\"{$pconfig['descr']}\"";?>size="64"> </td> </tr> <tr> @@ -240,12 +245,12 @@ jQuery(document).ready(function(){ <select id="available_action" name="available_action[]" multiple="true" size="5"> <?php if (is_array($config['load_balancer']['lbaction'])) { - foreach($config['load_balancer']['lbaction'] as $actent) { - if($actent != '') echo " <option value=\"{$actent['name']}\">{$actent['name']}</option>\n"; + foreach ($config['load_balancer']['lbaction'] as $actent) { + if ($actent != '') echo " <option value=\"{$actent['name']}\">{$actent['name']}</option>\n"; } } -echo "</select>"; ?> + </select> <br /> </td> <td valign="middle"> @@ -262,12 +267,12 @@ echo "</select>"; <select id="lbaction" name="lbaction[]" multiple="true" size="5"> <?php if (is_array($pconfig['lbaction'])) { - foreach($pconfig['lbaction'] as $actent) { + foreach ($pconfig['lbaction'] as $actent) { echo " <option value=\"{$actent}\">{$actent}</option>\n"; } } -echo "</select>"; ?> + </select> <br /> </td> </tr> @@ -286,7 +291,7 @@ echo "</select>"; </td> </tr> </table> - </form> +</form> <br /> <?php include("fend.inc"); ?> </body> diff --git a/usr/local/www/load_balancer_setting.php b/usr/local/www/load_balancer_setting.php index b91570f..e48e38e 100644 --- a/usr/local/www/load_balancer_setting.php +++ b/usr/local/www/load_balancer_setting.php @@ -55,27 +55,27 @@ $lbsetting = &$config['load_balancer']['setting']; if ($_POST) { - if ($_POST['apply']) { - $retval = 0; - $retval |= filter_configure(); - $retval |= relayd_configure(); - - $savemsg = get_std_save_message($retval); - clear_subsystem_dirty('loadbalancer'); - } else { + if ($_POST['apply']) { + $retval = 0; + $retval |= filter_configure(); + $retval |= relayd_configure(); + + $savemsg = get_std_save_message($retval); + clear_subsystem_dirty('loadbalancer'); + } else { unset($input_errors); $pconfig = $_POST; - + /* input validation */ if ($_POST['timeout'] && !is_numeric($_POST['timeout'])) { $input_errors[] = gettext("Timeout must be a numeric value"); } - if ($_POST['interval'] && !is_numeric($_POST['interval'])) { + if ($_POST['interval'] && !is_numeric($_POST['interval'])) { $input_errors[] = gettext("Interval must be a numeric value"); - } + } - if ($_POST['prefork']) { + if ($_POST['prefork']) { if (!is_numeric($_POST['prefork'])) { $input_errors[] = gettext("Prefork must be a numeric value"); } else { @@ -91,8 +91,8 @@ if ($_POST) { $lbsetting['interval'] = $_POST['interval']; $lbsetting['prefork'] = $_POST['prefork']; - write_config(); - mark_subsystem_dirty('loadbalancer'); + write_config(); + mark_subsystem_dirty('loadbalancer'); } } } @@ -112,60 +112,60 @@ include("head.inc"); <?php print_info_box_np(gettext("The load balancer configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));?><br /> <?php endif; ?> <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="load balancer settings"> - <tr> - <td class="tabnavtbl"> - <?php - /* active tabs */ - $tab_array = array(); - $tab_array[] = array(gettext("Pools"), false, "load_balancer_pool.php"); - $tab_array[] = array(gettext("Virtual Servers"), false, "load_balancer_virtual_server.php"); - $tab_array[] = array(gettext("Monitors"), false, "load_balancer_monitor.php"); - $tab_array[] = array(gettext("Settings"), true, "load_balancer_setting.php"); - display_top_tabs($tab_array); - ?> - </td> - </tr> - <tr> - <td id="mainarea"> - <div class="tabcont"> - <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area"> - <tr> - <td colspan="2" valign="top" class="listtopic"><?=gettext("Relayd global settings"); ?></td> - </tr> - <tr> - <td width="22%" valign="top" class="vncell"><?=gettext("timeout") ; ?></td> - <td width="78%" class="vtable"> - <input name="timeout" id="timeout" value="<?php if ($lbsetting['timeout'] <> "") echo $lbsetting['timeout']; ?>" class="formfld unknown" /> - <br /> - <?=gettext("Set the global timeout in milliseconds for checks. Leave blank to use the default value of 1000 ms "); ?> - </td> - </tr> - <tr> - <td width="22%" valign="top" class="vncell"><?=gettext("interval") ; ?></td> - <td width="78%" class="vtable"> - <input name="interval" id="interval" value="<?php if ($lbsetting['interval'] <> "") echo $lbsetting['interval']; ?>" class="formfld unknown" /> - <br /> - <?=gettext("Set the interval in seconds at which the member of a pool will be checked. Leave blank to use the default interval of 10 seconds"); ?> - </td> - </tr> - <tr> - <td width="22%" valign="top" class="vncell"><?=gettext("prefork") ; ?></td> - <td width="78%" class="vtable"> - <input name="prefork" id="prefork" value="<?php if ($lbsetting['prefork'] <> "") echo $lbsetting['prefork']; ?>" class="formfld unknown" /> - <br /> - <?=gettext("Number of processes used by relayd for dns protocol. Leave blank to use the default value of 5 processes"); ?> - </td> - </tr> - <tr> - <td width="22%" valign="top"> </td> - <td width="78%"> - <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" /> - </td> - </tr> - </table> - </div> - </td> - </tr> + <tr> + <td class="tabnavtbl"> +<?php + /* active tabs */ + $tab_array = array(); + $tab_array[] = array(gettext("Pools"), false, "load_balancer_pool.php"); + $tab_array[] = array(gettext("Virtual Servers"), false, "load_balancer_virtual_server.php"); + $tab_array[] = array(gettext("Monitors"), false, "load_balancer_monitor.php"); + $tab_array[] = array(gettext("Settings"), true, "load_balancer_setting.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td id="mainarea"> + <div class="tabcont"> + <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area"> + <tr> + <td colspan="2" valign="top" class="listtopic"><?=gettext("Relayd global settings"); ?></td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("timeout") ; ?></td> + <td width="78%" class="vtable"> + <input name="timeout" id="timeout" value="<?php if ($lbsetting['timeout'] <> "") echo $lbsetting['timeout']; ?>" class="formfld unknown" /> + <br /> + <?=gettext("Set the global timeout in milliseconds for checks. Leave blank to use the default value of 1000 ms "); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("interval") ; ?></td> + <td width="78%" class="vtable"> + <input name="interval" id="interval" value="<?php if ($lbsetting['interval'] <> "") echo $lbsetting['interval']; ?>" class="formfld unknown" /> + <br /> + <?=gettext("Set the interval in seconds at which the member of a pool will be checked. Leave blank to use the default interval of 10 seconds"); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("prefork") ; ?></td> + <td width="78%" class="vtable"> + <input name="prefork" id="prefork" value="<?php if ($lbsetting['prefork'] <> "") echo $lbsetting['prefork']; ?>" class="formfld unknown" /> + <br /> + <?=gettext("Number of processes used by relayd for dns protocol. Leave blank to use the default value of 5 processes"); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" /> + </td> + </tr> + </table> + </div> + </td> + </tr> </table> </form> <?php include("fend.inc"); ?> diff --git a/usr/local/www/load_balancer_virtual_server.php b/usr/local/www/load_balancer_virtual_server.php index 04a4d7b..e68c32c 100644 --- a/usr/local/www/load_balancer_virtual_server.php +++ b/usr/local/www/load_balancer_virtual_server.php @@ -86,7 +86,7 @@ for ($i = 0; isset($config['load_balancer']['lbpool'][$i]); $i++) { $poodex[$config['load_balancer']['lbpool'][$i]['name']] = $i; } for ($i = 0; isset($config['load_balancer']['virtual_server'][$i]); $i++) { - if($a_vs[$i]) { + if ($a_vs[$i]) { $a_vs[$i]['poolname'] = "<a href=\"/load_balancer_pool_edit.php?id={$poodex[$a_vs[$i]['poolname']]}\">" . htmlspecialchars($a_vs[$i]['poolname']) . "</a>"; if ($a_vs[$i]['sitedown'] != '') { $a_vs[$i]['sitedown'] = "<a href=\"/load_balancer_pool_edit.php?id={$poodex[$a_vs[$i]['sitedown']]}\">" . htmlspecialchars($a_vs[$i]['sitedown']) . "</a>"; @@ -111,40 +111,40 @@ include("head.inc"); <?php print_info_box_np(gettext("The virtual server configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));?><br /> <?php endif; ?> <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="load balancer virtual server"> - <tr><td class="tabnavtbl"> - <?php - /* active tabs */ - $tab_array = array(); - $tab_array[] = array(gettext("Pools"), false, "load_balancer_pool.php"); - $tab_array[] = array(gettext("Virtual Servers"), true, "load_balancer_virtual_server.php"); - $tab_array[] = array(gettext("Monitors"), false, "load_balancer_monitor.php"); - $tab_array[] = array(gettext("Settings"), false, "load_balancer_setting.php"); - display_top_tabs($tab_array); - ?> - </td></tr> - <tr> - <td> - <div id="mainarea"> + <tr><td class="tabnavtbl"> <?php - $t = new MainTable(); - $t->edit_uri('load_balancer_virtual_server_edit.php'); - $t->my_uri('load_balancer_virtual_server.php'); - $t->add_column(gettext('Name'),'name',10); - $t->add_column(gettext('Protocol'),'relay_protocol',10); - $t->add_column(gettext('IP Address'),'ipaddr',15); - $t->add_column(gettext('Port'),'port',10); - $t->add_column(gettext('Pool'),'poolname',15); - $t->add_column(gettext('Fall Back Pool'),'sitedown',15); - $t->add_column(gettext('Description'),'descr',30); - $t->add_button('edit'); - $t->add_button('dup'); - $t->add_button('del'); - $t->add_content_array($a_vs); - $t->display(); + /* active tabs */ + $tab_array = array(); + $tab_array[] = array(gettext("Pools"), false, "load_balancer_pool.php"); + $tab_array[] = array(gettext("Virtual Servers"), true, "load_balancer_virtual_server.php"); + $tab_array[] = array(gettext("Monitors"), false, "load_balancer_monitor.php"); + $tab_array[] = array(gettext("Settings"), false, "load_balancer_setting.php"); + display_top_tabs($tab_array); ?> - </div> - </td> - </tr> + </td></tr> + <tr> + <td> + <div id="mainarea"> +<?php + $t = new MainTable(); + $t->edit_uri('load_balancer_virtual_server_edit.php'); + $t->my_uri('load_balancer_virtual_server.php'); + $t->add_column(gettext('Name'),'name',10); + $t->add_column(gettext('Protocol'),'relay_protocol',10); + $t->add_column(gettext('IP Address'),'ipaddr',15); + $t->add_column(gettext('Port'),'port',10); + $t->add_column(gettext('Pool'),'poolname',15); + $t->add_column(gettext('Fall Back Pool'),'sitedown',15); + $t->add_column(gettext('Description'),'descr',30); + $t->add_button('edit'); + $t->add_button('dup'); + $t->add_button('del'); + $t->add_content_array($a_vs); + $t->display(); +?> + </div> + </td> + </tr> </table> </form> <?php include("fend.inc"); ?> diff --git a/usr/local/www/load_balancer_virtual_server_edit.php b/usr/local/www/load_balancer_virtual_server_edit.php index 102b520..a6cea52 100644 --- a/usr/local/www/load_balancer_virtual_server_edit.php +++ b/usr/local/www/load_balancer_virtual_server_edit.php @@ -46,14 +46,16 @@ require("guiconfig.inc"); $referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/load_balancer_virtual_server.php'); if (!is_array($config['load_balancer']['virtual_server'])) { - $config['load_balancer']['virtual_server'] = array(); + $config['load_balancer']['virtual_server'] = array(); } $a_vs = &$config['load_balancer']['virtual_server']; -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_vs[$id]) { $pconfig = $a_vs[$id]; @@ -70,50 +72,59 @@ if ($_POST) { $pconfig = $_POST; /* input validation */ - switch($pconfig['mode']) { - case "redirect": { - $reqdfields = explode(" ", "ipaddr name mode"); - $reqdfieldsn = array(gettext("IP Address"),gettext("Name"),gettext("Mode")); - break; - } - case "relay": { - $reqdfields = explode(" ", "ipaddr name mode relay_protocol"); - $reqdfieldsn = array(gettext("IP Address"),gettext("Name"),gettext("Relay Protocol")); - break; - } - } + switch ($pconfig['mode']) { + case "redirect": { + $reqdfields = explode(" ", "ipaddr name mode"); + $reqdfieldsn = array(gettext("IP Address"),gettext("Name"),gettext("Mode")); + break; + } + case "relay": { + $reqdfields = explode(" ", "ipaddr name mode relay_protocol"); + $reqdfieldsn = array(gettext("IP Address"),gettext("Name"),gettext("Relay Protocol")); + break; + } + } do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); - for ($i=0; isset($config['load_balancer']['virtual_server'][$i]); $i++) - if (($_POST['name'] == $config['load_balancer']['virtual_server'][$i]['name']) && ($i != $id)) + for ($i=0; isset($config['load_balancer']['virtual_server'][$i]); $i++) { + if (($_POST['name'] == $config['load_balancer']['virtual_server'][$i]['name']) && ($i != $id)) { $input_errors[] = gettext("This virtual server name has already been used. Virtual server 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']) > 32) + if (strlen($_POST['name']) > 32) { $input_errors[] = gettext("The 'name' field must be 32 characters or less."); + } - if ($_POST['port'] != "" && !is_portoralias($_POST['port'])) + if ($_POST['port'] != "" && !is_portoralias($_POST['port'])) { $input_errors[] = gettext("The port must be an integer between 1 and 65535, a port alias, or left blank."); + } - if (!is_ipaddroralias($_POST['ipaddr']) && !is_subnetv4($_POST['ipaddr'])) + if (!is_ipaddroralias($_POST['ipaddr']) && !is_subnetv4($_POST['ipaddr'])) { $input_errors[] = sprintf(gettext("%s is not a valid IP address, IPv4 subnet, or alias."), $_POST['ipaddr']); - else if (is_subnetv4($_POST['ipaddr']) && subnet_size($_POST['ipaddr']) > 64) + } else if (is_subnetv4($_POST['ipaddr']) && subnet_size($_POST['ipaddr']) > 64) { $input_errors[] = sprintf(gettext("%s is a subnet containing more than 64 IP addresses."), $_POST['ipaddr']); + } - if ((strtolower($_POST['relay_protocol']) == "dns") && !empty($_POST['sitedown'])) + if ((strtolower($_POST['relay_protocol']) == "dns") && !empty($_POST['sitedown'])) { $input_errors[] = gettext("You cannot select a Fall Back Pool when using the DNS relay protocol."); + } if (!$input_errors) { $vsent = array(); - if(isset($id) && $a_vs[$id]) + if (isset($id) && $a_vs[$id]) { $vsent = $a_vs[$id]; - if($vsent['name'] != "") + } + if ($vsent['name'] != "") { $changedesc .= " " . sprintf(gettext("modified '%s' vs:"), $vsent['name']); - else + } else { $changedesc .= " " . sprintf(gettext("created '%s' vs:"), $_POST['name']); + } update_if_changed("name", $vsent['name'], $_POST['name']); update_if_changed("descr", $vsent['descr'], $_POST['descr']); @@ -124,8 +135,9 @@ if ($_POST) { update_if_changed("mode", $vsent['mode'], $_POST['mode']); update_if_changed("relay protocol", $vsent['relay_protocol'], $_POST['relay_protocol']); - if($_POST['sitedown'] == "") + if ($_POST['sitedown'] == "") { unset($vsent['sitedown']); + } if (isset($id) && $a_vs[$id]) { if ($a_vs[$id]['name'] != $_POST['name']) { @@ -133,8 +145,9 @@ if ($_POST) { cleanup_lb_mark_anchor($a_vs[$id]['name']); } $a_vs[$id] = $vsent; - } else + } else { $a_vs[] = $vsent; + } if ($changecount > 0) { /* Mark virtual server dirty */ @@ -160,136 +173,138 @@ include("head.inc"); <script type="text/javascript" src="/javascript/suggestions.js"></script> <?php if ($input_errors) print_input_errors($input_errors); ?> - <form action="load_balancer_virtual_server_edit.php" method="post" name="iform" id="iform"> - <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="load balancer server entry"> - <tr> - <td colspan="3" valign="top" class="listtopic"><?=gettext("Edit Load Balancer - Virtual Server entry"); ?></td> - </tr> - <tr align="left"> - <td width="22%" valign="top" class="vncellreq"><?=gettext("Name"); ?></td> - <td width="78%" class="vtable" colspan="2"> - <input name="name" type="text" <?if(isset($pconfig['name'])) echo "value=\"" . htmlspecialchars($pconfig['name']) . "\"";?> size="32" maxlength="32" /> - </td> - </tr> - <tr align="left"> - <td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td> - <td width="78%" class="vtable" colspan="2"> - <input name="descr" type="text" <?if(isset($pconfig['descr'])) echo "value=\"" . htmlspecialchars($pconfig['descr']) . "\"";?> size="64" /> - </td> - </tr> - <tr align="left"> - <td width="22%" valign="top" class="vncellreq"><?=gettext("IP Address"); ?></td> - <td width="78%" class="vtable" colspan="2"> - <input class="formfldalias" id="ipaddr" name="ipaddr" type="text" <?if(isset($pconfig['ipaddr'])) echo "value=\"" . htmlspecialchars($pconfig['ipaddr']) . "\"";?> size="39" maxlength="39" /> - <br /><?=gettext("This is normally the WAN IP address that you would like the server to listen on. All connections to this IP and port will be forwarded to the pool cluster."); ?> - <br /><?=gettext("You may also specify a host alias listed in Firewall -> Aliases here."); ?> - <script type="text/javascript"> +<form action="load_balancer_virtual_server_edit.php" method="post" name="iform" id="iform"> + <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="load balancer server entry"> + <tr> + <td colspan="3" valign="top" class="listtopic"><?=gettext("Edit Load Balancer - Virtual Server entry"); ?></td> + </tr> + <tr align="left"> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Name"); ?></td> + <td width="78%" class="vtable" colspan="2"> + <input name="name" type="text" <?if (isset($pconfig['name'])) echo "value=\"" . htmlspecialchars($pconfig['name']) . "\"";?> size="32" maxlength="32" /> + </td> + </tr> + <tr align="left"> + <td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td> + <td width="78%" class="vtable" colspan="2"> + <input name="descr" type="text" <?if (isset($pconfig['descr'])) echo "value=\"" . htmlspecialchars($pconfig['descr']) . "\"";?> size="64" /> + </td> + </tr> + <tr align="left"> + <td width="22%" valign="top" class="vncellreq"><?=gettext("IP Address"); ?></td> + <td width="78%" class="vtable" colspan="2"> + <input class="formfldalias" id="ipaddr" name="ipaddr" type="text" <?if (isset($pconfig['ipaddr'])) echo "value=\"" . htmlspecialchars($pconfig['ipaddr']) . "\"";?> size="39" maxlength="39" /> + <br /><?=gettext("This is normally the WAN IP address that you would like the server to listen on. All connections to this IP and port will be forwarded to the pool cluster."); ?> + <br /><?=gettext("You may also specify a host alias listed in Firewall -> Aliases here."); ?> + <script type="text/javascript"> //<![CDATA[ var host_aliases = <?= json_encode(get_alias_list(array("host", "network", "url", "urltable"))) ?>; var oTextbox1 = new AutoSuggestControl(document.getElementById("ipaddr"), new StateSuggestions(host_aliases)); //]]> - </script> - </td> - </tr> - <tr align="left"> - <td width="22%" valign="top" class="vncell"><?=gettext("Port"); ?></td> - <td width="78%" class="vtable" colspan="2"> - <input class="formfldalias" name="port" id="port" type="text" <?if(isset($pconfig['port'])) echo "value=\"" . htmlspecialchars($pconfig['port']) . "\"";?> size="16" maxlength="16" /> - <br /><?=gettext("This is the port that the clients will connect to. All connections to this port will be forwarded to the pool cluster."); ?> - <br /><?=gettext("If left blank, listening ports from the pool will be used."); ?> - <br /><?=gettext("You may also specify a port alias listed in Firewall -> Aliases here."); ?> - <script type="text/javascript"> + </script> + </td> + </tr> + <tr align="left"> + <td width="22%" valign="top" class="vncell"><?=gettext("Port"); ?></td> + <td width="78%" class="vtable" colspan="2"> + <input class="formfldalias" name="port" id="port" type="text" <?if (isset($pconfig['port'])) echo "value=\"" . htmlspecialchars($pconfig['port']) . "\"";?> size="16" maxlength="16" /> + <br /><?=gettext("This is the port that the clients will connect to. All connections to this port will be forwarded to the pool cluster."); ?> + <br /><?=gettext("If left blank, listening ports from the pool will be used."); ?> + <br /><?=gettext("You may also specify a port alias listed in Firewall -> Aliases here."); ?> + <script type="text/javascript"> //<![CDATA[ var port_aliases = <?= json_encode(get_alias_list(array("port", "url_ports", "urltable_ports"))) ?>; var oTextbox2 = new AutoSuggestControl(document.getElementById("port"), new StateSuggestions(port_aliases)); //]]> - </script> - </td> - </tr> - <tr align="left"> - <td width="22%" valign="top" class="vncellreq"><?=gettext("Virtual Server Pool"); ?></td> - <td width="78%" class="vtable" colspan="2"> - <?php if(count($config['load_balancer']['lbpool']) == 0): ?> + </script> + </td> + </tr> + <tr align="left"> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Virtual Server Pool"); ?></td> + <td width="78%" class="vtable" colspan="2"> + <?php if (count($config['load_balancer']['lbpool']) == 0): ?> <b><?=gettext("NOTE:"); ?></b> <?=gettext("Please add a pool on the Pools tab to use this feature."); ?> <?php else: ?> <select id="poolname" name="poolname"> <?php for ($i = 0; isset($config['load_balancer']['lbpool'][$i]); $i++) { $selected = ""; - if ( $config['load_balancer']['lbpool'][$i]['name'] == $pconfig['poolname'] ) + if ($config['load_balancer']['lbpool'][$i]['name'] == $pconfig['poolname']) { $selected = " selected=\"selected\""; + } echo "<option value=\"" . htmlspecialchars($config['load_balancer']['lbpool'][$i]['name']) . "\"{$selected}>{$config['load_balancer']['lbpool'][$i]['name']}</option>"; } ?> </select> <?php endif; ?> - </td> - </tr> - <tr align="left"> - <td width="22%" valign="top" class="vncellreq"><?=gettext("Fall Back Pool"); ?></td> - <td width="78%" class="vtable" colspan="2"> - <?php if(count($config['load_balancer']['lbpool']) == 0): ?> - <b><?=gettext("NOTE:"); ?></b> <?=gettext("Please add a pool on the Pools tab to use this feature."); ?> - <?php else: ?> - <select id="sitedown" name="sitedown"> - <option value=""<?=htmlspecialchars($pconfig['sitedown']) == '' ? ' selected' : ''?>><?=gettext("none"); ?></option> - <?php - for ($i = 0; isset($config['load_balancer']['lbpool'][$i]); $i++) { - $selected = ""; - if ( $config['load_balancer']['lbpool'][$i]['name'] == $pconfig['sitedown'] ) - $selected = " selected=\"selected\""; - echo "<option value=\"" . htmlspecialchars($config['load_balancer']['lbpool'][$i]['name']) . "\"{$selected}>{$config['load_balancer']['lbpool'][$i]['name']}</option>"; - } - ?> - </select> + </td> + </tr> + <tr align="left"> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Fall Back Pool"); ?></td> + <td width="78%" class="vtable" colspan="2"> + <?php if (count($config['load_balancer']['lbpool']) == 0): ?> + <b><?=gettext("NOTE:"); ?></b> <?=gettext("Please add a pool on the Pools tab to use this feature."); ?> + <?php else: ?> + <select id="sitedown" name="sitedown"> + <option value=""<?=htmlspecialchars($pconfig['sitedown']) == '' ? ' selected' : ''?>><?=gettext("none"); ?></option> + <?php + for ($i = 0; isset($config['load_balancer']['lbpool'][$i]); $i++) { + $selected = ""; + if ($config['load_balancer']['lbpool'][$i]['name'] == $pconfig['sitedown']) { + $selected = " selected=\"selected\""; + } + echo "<option value=\"" . htmlspecialchars($config['load_balancer']['lbpool'][$i]['name']) . "\"{$selected}>{$config['load_balancer']['lbpool'][$i]['name']}</option>"; + } + ?> + </select> <br /><?=gettext("The server pool to which clients will be redirected if *ALL* servers in the Virtual Server Pool are offline."); ?> <br /><?=gettext("This option is NOT compatible with the DNS relay protocol."); ?> - <?php endif; ?> - </td> - </tr> - <tr style="display:none;"><td><input type="hidden" name="mode" value="redirect_mode" /></td></tr> + <?php endif; ?> + </td> + </tr> + <tr style="display:none;"><td><input type="hidden" name="mode" value="redirect_mode" /></td></tr> <!-- - <tr align="left"> - <td width="22%" valign="top" class="vncellreq">Mode</td> - <td width="78%" class="vtable" colspan="2"> - <input id="redirect_mode" type="radio" name="mode" value="redirect"<?=htmlspecialchars($pconfig['mode']) == 'redirect' ? ' checked="checked"': ''?> /> Redirect - <input id="relay_mode" type="radio" name="mode" value="relay"<?=htmlspecialchars($pconfig['mode']) == 'relay' ? ' checked="checked"': ''?> /> Relay - - <br /> - </td> - </tr> + <tr align="left"> + <td width="22%" valign="top" class="vncellreq">Mode</td> + <td width="78%" class="vtable" colspan="2"> + <input id="redirect_mode" type="radio" name="mode" value="redirect"<?=htmlspecialchars($pconfig['mode']) == 'redirect' ? ' checked="checked"': ''?> /> Redirect + <input id="relay_mode" type="radio" name="mode" value="relay"<?=htmlspecialchars($pconfig['mode']) == 'relay' ? ' checked="checked"': ''?> /> Relay + <br /> + </td> + </tr> --> <tr id="relay" align="left"> <td width="22%" valign="top" class="vncellreq"><?=gettext("Relay Protocol"); ?></td> <td width="78%" class="vtable" colspan="2"> - <select id="relay_protocol" name="relay_protocol"> - <?php - $lb_def_protos = array("tcp", "dns"); - foreach ($lb_def_protos as $lb_proto) { - $selected = ""; - if ( $pconfig['relay_protocol'] == $lb_proto ) - $selected = " selected=\"selected\""; - echo "<option value=\"{$lb_proto}\"{$selected}>{$lb_proto}</option>"; - } - ?> - </select> - <br /> + <select id="relay_protocol" name="relay_protocol"> + <?php + $lb_def_protos = array("tcp", "dns"); + foreach ($lb_def_protos as $lb_proto) { + $selected = ""; + if ($pconfig['relay_protocol'] == $lb_proto) { + $selected = " selected=\"selected\""; + } + echo "<option value=\"{$lb_proto}\"{$selected}>{$lb_proto}</option>"; + } + ?> + </select> + <br /> </td> </tr> - <tr align="left"> - <td width="22%" valign="top"> </td> - <td align="left" valign="bottom" width="78%"> - <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Submit"); ?>" /> - <input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" /> - <?php if (isset($id) && $a_vs[$id] && $_GET['act'] != 'dup'): ?> + <tr align="left"> + <td width="22%" valign="top"> </td> + <td align="left" valign="bottom" width="78%"> + <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Submit"); ?>" /> + <input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" /> + <?php if (isset($id) && $a_vs[$id] && $_GET['act'] != 'dup'): ?> <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" /> - <?php endif; ?> - </td> - </tr> - </table> - </form> - <br /> - <span class="red"><strong><?=gettext("Note:"); ?></strong></span> <?=gettext("Don't forget to add a firewall rule for the virtual server/pool after you're finished setting it up."); ?> + <?php endif; ?> + </td> + </tr> + </table> +</form> +<br /> +<span class="red"><strong><?=gettext("Note:"); ?></strong></span> <?=gettext("Don't forget to add a firewall rule for the virtual server/pool after you're finished setting it up."); ?> <?php include("fend.inc"); ?> </body> </html> |