Commit 27a06305 authored by Franco Fichtner's avatar Franco Fichtner

system/gateway: style sweep

parent d32c7402
......@@ -50,11 +50,9 @@ $a_gateways = &$config['gateways']['gateway_item'];
$changedesc = gettext("Gateway Groups") . ": ";
if ($_POST) {
$pconfig = $_POST;
if ($_POST['apply']) {
$retval = 0;
$retval = system_routing_configure();
......@@ -67,8 +65,9 @@ if ($_POST) {
setup_gateways_monitor();
$savemsg = get_std_save_message($retval);
if ($retval == 0)
if ($retval == 0) {
clear_subsystem_dirty('staticroutes');
}
foreach ($a_gateway_groups as $gateway_group) {
$gw_subsystem = 'gwgroup.' . $gateway_group['name'];
......@@ -84,9 +83,10 @@ if ($_GET['act'] == "del") {
if ($a_gateway_groups[$_GET['id']]) {
$changedesc .= gettext("removed gateway group") . " {$_GET['id']}";
foreach ($config['filter']['rule'] as $idx => $rule) {
if ($rule['gateway'] == $a_gateway_groups[$_GET['id']]['name'])
if ($rule['gateway'] == $a_gateway_groups[$_GET['id']]['name']) {
unset($config['filter']['rule'][$idx]['gateway']);
}
}
unset($a_gateway_groups[$_GET['id']]);
write_config($changedesc);
mark_subsystem_dirty('staticroutes');
......@@ -114,10 +114,14 @@ $main_buttons = array(
<div class="container-fluid">
<div class="row">
<?php if ($savemsg) print_info_box($savemsg); ?>
<?php if (is_subsystem_dirty('staticroutes')): ?><br/>
<?php if ($savemsg) {
print_info_box($savemsg);
} ?>
<?php if (is_subsystem_dirty('staticroutes')) :
?><br/>
<?php print_info_box_np(sprintf(gettext("The gateway configuration has been changed.%sYou must apply the changes in order for them to take effect."), "<br />"));?><br /><br />
<?php endif; ?>
<?php
endif; ?>
<section class="col-xs-12">
......@@ -144,7 +148,8 @@ $main_buttons = array(
</tr>
</thead>
<tbody>
<?php $i = 0; foreach ($a_gateway_groups as $gateway_group): ?>
<?php $i = 0; foreach ($a_gateway_groups as $gateway_group) :
?>
<tr>
<td class="listlr" ondblclick="document.location='system_gateway_groups_edit.php?id=<?=$i;?>';">
<?php
......@@ -153,7 +158,7 @@ $main_buttons = array(
</td>
<td class="listr" ondblclick="document.location='system_gateway_groups_edit.php?id=<?=$i;?>';">
<?php
foreach($gateway_group['item'] as $item) {
foreach ($gateway_group['item'] as $item) {
$itemsplit = explode("|", $item);
echo htmlspecialchars(strtoupper($itemsplit[0])) . "<br />\n";
}
......@@ -161,7 +166,7 @@ $main_buttons = array(
</td>
<td class="listr" ondblclick="document.location='system_gateway_groups_edit.php?id=<?=$i;?>';">
<?php
foreach($gateway_group['item'] as $item) {
foreach ($gateway_group['item'] as $item) {
$itemsplit = explode("|", $item);
echo "Tier ". htmlspecialchars($itemsplit[1]) . "<br />\n";
}
......@@ -174,7 +179,8 @@ $main_buttons = array(
<table border="0" cellspacing="0" cellpadding="1" summary="edit">
<tr>
<td><a href="system_gateway_groups_edit.php?id=<?=$i;?>" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a></td>
<td><a href="system_gateway_groups.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this gateway group?");?>')" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-remove"></span></a></td>
<td><a href="system_gateway_groups.php?act=del&amp;id=<?=$i;
?>" onclick="return confirm('<?=gettext("Do you really want to delete this gateway group?");?>')" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-remove"></span></a></td>
</tr>
<tr>
<td width="17"></td>
......@@ -183,12 +189,15 @@ $main_buttons = array(
</table>
</td>
</tr>
<?php $i++; endforeach; ?>
<?php $i++;
endforeach; ?>
<tr style="display:none;"><td></td></tr>
</tbody>
</table>
</div>
<p><b><?=gettext("Note:");?></b> <?=gettext("Remember to use these Gateway Groups in firewall rules in order to enable load balancing, failover, or policy-based routing. Without rules directing traffic into the Gateway Groups, they will not be used.");?></p>
<p><b><?=gettext("Note:");
?></b> <?=gettext("Remember to use these Gateway Groups in firewall rules in order to enable load balancing, failover, or policy-based routing. Without rules directing traffic into the Gateway Groups, they will not be used.");?></p>
</form>
</div>
......@@ -199,4 +208,4 @@ $main_buttons = array(
</section>
<?php include("foot.inc"); ?>
<?php include("foot.inc");
......@@ -49,13 +49,16 @@ $categories = array('down' => gettext("Member Down"),
'downlatency' => gettext("High Latency"),
'downlosslatency' => gettext("Packet Loss or High Latency"));
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($_GET['dup']) && is_numericint($_GET['dup']))
if (isset($_GET['dup']) && is_numericint($_GET['dup'])) {
$id = $_GET['dup'];
}
if (isset($id) && $a_gateway_groups[$id]) {
$pconfig['name'] = $a_gateway_groups[$id]['name'];
......@@ -64,11 +67,11 @@ if (isset($id) && $a_gateway_groups[$id]) {
$pconfig['trigger'] = $a_gateway_groups[$id]['trigger'];
}
if (isset($_GET['dup']) && is_numericint($_GET['dup']))
if (isset($_GET['dup']) && is_numericint($_GET['dup'])) {
unset($id);
}
if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
......@@ -87,11 +90,12 @@ if ($_POST) {
if (isset($_POST['name'])) {
/* check for overlaps */
if(is_array($a_gateway_groups)) {
if (is_array($a_gateway_groups)) {
foreach ($a_gateway_groups as $gateway_group) {
if (isset($id) && ($a_gateway_groups[$id]) && ($a_gateway_groups[$id] === $gateway_group)) {
if ($gateway_group['name'] != $_POST['name'])
if ($gateway_group['name'] != $_POST['name']) {
$input_errors[] = gettext("Changing name on a gateway group is not allowed.");
}
continue;
}
......@@ -105,19 +109,21 @@ if ($_POST) {
/* Build list of items in group with priority */
$pconfig['item'] = array();
foreach($a_gateways as $gwname => $gateway) {
if($_POST[$gwname] > 0) {
foreach ($a_gateways as $gwname => $gateway) {
if ($_POST[$gwname] > 0) {
$vipname = "{$gwname}_vip";
/* we have a priority above 0 (disabled), add item to list */
$pconfig['item'][] = "{$gwname}|{$_POST[$gwname]}|{$_POST[$vipname]}";
}
/* check for overlaps */
if ($_POST['name'] == $gwname)
if ($_POST['name'] == $gwname) {
$input_errors[] = sprintf(gettext('A gateway group cannot have the same name with a gateway "%s" please choose another name.'), $_POST['name']);
}
}
if(count($pconfig['item']) == 0)
if (count($pconfig['item']) == 0) {
$input_errors[] = gettext("No gateway(s) have been selected to be used in this group");
}
if (!$input_errors) {
$gateway_group = array();
......@@ -126,10 +132,11 @@ if ($_POST) {
$gateway_group['trigger'] = $_POST['trigger'];
$gateway_group['descr'] = $_POST['descr'];
if (isset($id) && $a_gateway_groups[$id])
if (isset($id) && $a_gateway_groups[$id]) {
$a_gateway_groups[$id] = $gateway_group;
else
} else {
$a_gateway_groups[] = $gateway_group;
}
mark_subsystem_dirty('staticroutes');
mark_subsystem_dirty('gwgroup.' . $gateway_group['name']);
......@@ -144,7 +151,8 @@ if ($_POST) {
$pgtitle = array(gettext("System"),gettext("Gateways"),gettext("Edit gateway group"));
$shortcut_section = "gateway-groups";
function build_gateway_protocol_map (&$a_gateways) {
function build_gateway_protocol_map (&$a_gateways)
{
$result = array();
foreach ($a_gateways as $gwname => $gateway) {
$result[$gwname] = $gateway['ipprotocol'];
......@@ -217,7 +225,9 @@ jQuery(function ($) {
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
<?php if ($input_errors) print_input_errors($input_errors); ?>
<?php if ($input_errors) {
print_input_errors($input_errors);
} ?>
<div id="inputerrors"></div>
<section class="col-xs-12">
......@@ -246,18 +256,19 @@ jQuery(function ($) {
<td class="listhdrr">Description</td>
</tr>
<?php
foreach($a_gateways as $gwname => $gateway) {
if(!empty($pconfig['item'])) {
foreach ($a_gateways as $gwname => $gateway) {
if (!empty($pconfig['item'])) {
$af = explode("|", $pconfig['item'][0]);
$family = $a_gateways[$af[0]]['ipprotocol'];
if($gateway['ipprotocol'] != $family)
if ($gateway['ipprotocol'] != $family) {
continue;
}
}
$interface = $gateway['friendlyiface'];
$selected = array();
foreach((array)$pconfig['item'] as $item) {
foreach ((array)$pconfig['item'] as $item) {
$itemsplit = explode("|", $item);
if($itemsplit[0] == $gwname) {
if ($itemsplit[0] == $gwname) {
$selected[$itemsplit[1]] = "selected=\"selected\"";
break;
} else {
......@@ -280,9 +291,9 @@ jQuery(function ($) {
echo "</td>";
$selected = array();
foreach((array)$pconfig['item'] as $item) {
foreach ((array)$pconfig['item'] as $item) {
$itemsplit = explode("|", $item);
if($itemsplit[0] == $gwname) {
if ($itemsplit[0] == $gwname) {
$selected[$itemsplit[2]] = "selected=\"selected\"";
break;
} else {
......@@ -292,14 +303,17 @@ jQuery(function ($) {
echo "<td class='listr'>";
echo "<select name='{$gwname}_vip' class='gateway_vip_selector formfldselect selectpicker' data-style='btn-default' data-width='auto' id='{$gwname}_vip'>\n";
echo "<option value='address' {$selected['address']} >" . gettext("Interface Address") . "</option>\n";
foreach($carplist as $vip => $address) {
foreach ($carplist as $vip => $address) {
echo "<!-- $vip - $address - $interface -->\n";
if(!preg_match("/^{$interface}_/i", $vip))
if (!preg_match("/^{$interface}_/i", $vip)) {
continue;
if(($gateway['ipprotocol'] == "inet") && (!is_ipaddrv4($address)))
}
if (($gateway['ipprotocol'] == "inet") && (!is_ipaddrv4($address))) {
continue;
if(($gateway['ipprotocol'] == "inet6") && (!is_ipaddrv6($address)))
}
if (($gateway['ipprotocol'] == "inet6") && (!is_ipaddrv6($address))) {
continue;
}
echo "<option value='{$vip}' $selected[$vip] >$vip - $address</option>\n";
}
echo "</select></td>";
......@@ -326,7 +340,9 @@ jQuery(function ($) {
<?php
foreach ($categories as $category => $categoryd) {
echo "<option value=\"$category\"";
if ($category == $pconfig['trigger']) echo " selected=\"selected\"";
if ($category == $pconfig['trigger']) {
echo " selected=\"selected\"";
}
echo ">" . htmlspecialchars($categoryd) . "</option>\n";
}
?>
......@@ -345,10 +361,13 @@ jQuery(function ($) {
<td width="22%" valign="top">&nbsp;</td>
<td width="78%">
<input name="Submit" type="submit" class="btn btn-primary formbtn" value="<?=gettext("Save");?>" />
<input type="button" class="btn btn-default formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
<?php if (isset($id) && $a_gateway_groups[$id]): ?>
<input type="button" class="btn btn-default formbtn" value="<?=gettext("Cancel");
?>" onclick="window.location.href='<?=$referer;?>'" />
<?php if (isset($id) && $a_gateway_groups[$id]) :
?>
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
<?php endif; ?>
<?php
endif; ?>
</td>
</tr>
</table>
......
......@@ -50,11 +50,9 @@ if (!is_array($config['gateways']['gateway_item'])) {
$a_gateway_item = &$config['gateways']['gateway_item'];
if ($_POST) {
$pconfig = $_POST;
if ($_POST['apply']) {
$retval = 0;
$retval = system_routing_configure();
......@@ -63,16 +61,19 @@ if ($_POST) {
setup_gateways_monitor();
$savemsg = get_std_save_message($retval);
if ($retval == 0)
if ($retval == 0) {
clear_subsystem_dirty('staticroutes');
}
}
}
function can_delete_gateway_item($id) {
function can_delete_gateway_item($id)
{
global $config, $input_errors, $a_gateways;
if (!isset($a_gateways[$id]))
if (!isset($a_gateways[$id])) {
return false;
}
if (is_array($config['gateways']['gateway_group'])) {
foreach ($config['gateways']['gateway_group'] as $group) {
......@@ -95,31 +96,36 @@ function can_delete_gateway_item($id) {
}
}
if (isset($input_errors))
if (isset($input_errors)) {
return false;
}
return true;
}
function delete_gateway_item($id) {
function delete_gateway_item($id)
{
global $config, $a_gateways;
if (!isset($a_gateways[$id]))
if (!isset($a_gateways[$id])) {
return;
}
/* NOTE: Cleanup static routes for the monitor ip if any */
if (!empty($a_gateways[$id]['monitor']) &&
$a_gateways[$id]['monitor'] != "dynamic" &&
is_ipaddr($a_gateways[$id]['monitor']) &&
$a_gateways[$id]['gateway'] != $a_gateways[$id]['monitor']) {
if (is_ipaddrv4($a_gateways[$id]['monitor']))
if (is_ipaddrv4($a_gateways[$id]['monitor'])) {
mwexec("/sbin/route delete " . escapeshellarg($a_gateways[$id]['monitor']));
else
} else {
mwexec("/sbin/route delete -inet6 " . escapeshellarg($a_gateways[$id]['monitor']));
}
}
if ($config['interfaces'][$a_gateways[$id]['friendlyiface']]['gateway'] == $a_gateways[$id]['name'])
if ($config['interfaces'][$a_gateways[$id]['friendlyiface']]['gateway'] == $a_gateways[$id]['name']) {
unset($config['interfaces'][$a_gateways[$id]['friendlyiface']]['gateway']);
}
unset($config['gateways']['gateway_item'][$a_gateways[$id]['attribute']]);
}
......@@ -138,9 +144,11 @@ if ($_GET['act'] == "del") {
if (isset($_POST['del_x'])) {
/* delete selected items */
if (is_array($_POST['rule']) && count($_POST['rule'])) {
foreach ($_POST['rule'] as $rulei)
if(!can_delete_gateway_item($rulei))
foreach ($_POST['rule'] as $rulei) {
if (!can_delete_gateway_item($rulei)) {
break;
}
}
if (!isset($input_errors)) {
$items_deleted = "";
......@@ -157,16 +165,18 @@ if (isset($_POST['del_x'])) {
}
}
} else if ($_GET['act'] == "toggle" && $a_gateways[$_GET['id']]) {
} elseif ($_GET['act'] == "toggle" && $a_gateways[$_GET['id']]) {
$realid = $a_gateways[$_GET['id']]['attribute'];
if(isset($a_gateway_item[$realid]['disabled']))
if (isset($a_gateway_item[$realid]['disabled'])) {
unset($a_gateway_item[$realid]['disabled']);
else
} else {
$a_gateway_item[$realid]['disabled'] = true;
}
if (write_config("Gateways: enable/disable"))
if (write_config("Gateways: enable/disable")) {
mark_subsystem_dirty('staticroutes');
}
header("Location: system_gateways.php");
exit;
......@@ -195,9 +205,15 @@ $main_buttons = array(
<div class="row">
<?php
if ($input_errors) print_input_errors($input_errors);
if ($savemsg) print_info_box($savemsg);
if (is_subsystem_dirty('staticroutes')) print_info_box_np(gettext("The gateway configuration has been changed.") . "<br />" . gettext("You must apply the changes in order for them to take effect."));
if ($input_errors) {
print_input_errors($input_errors);
}
if ($savemsg) {
print_info_box($savemsg);
}
if (is_subsystem_dirty('staticroutes')) {
print_info_box_np(gettext("The gateway configuration has been changed.") . "<br />" . gettext("You must apply the changes in order for them to take effect."));
}
?>
<section class="col-xs-12">
......@@ -228,7 +244,7 @@ $main_buttons = array(
<?php
$textse = "</span>";
$i = 0;
foreach ($a_gateways as $gateway):
foreach ($a_gateways as $gateway) :
if (isset($gateway['disabled']) || isset($gateway['inactive'])) {
$textss = "<span class=\"text-muted\">";
$iconfn = "glyphicon glyphicon-play text-muted";
......@@ -241,11 +257,13 @@ $main_buttons = array(
<td class="listt">
<?php
if (is_numeric($gateway['attribute'])):
if (is_numeric($gateway['attribute'])) :
?>
<input type="checkbox" id="frc<?=$i;?>" name="rule[]" value="<?=$i;?>" onclick="fr_bgcolor('<?=$i;?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;" />
<input type="checkbox" id="frc<?=$i;
?>" name="rule[]" value="<?=$i;
?>" onclick="fr_bgcolor('<?=$i;?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;" />
<?php
else:
else :
?>
&nbsp;
<?php
......@@ -254,49 +272,60 @@ $main_buttons = array(
</td>
<td class="listt" align="center">
<?php
if (isset($gateway['inactive'])):
if (isset($gateway['inactive'])) :
?>
<span class="glyphicon glyphicon-remove text-muted" data-toggle="tooltip" data-placement="left" title="<?=gettext("This gateway is inactive because interface is missing");?>"></span>
<?php
elseif (is_numeric($gateway['attribute'])):
elseif (is_numeric($gateway['attribute'])) :
?>
<a href="?act=toggle&amp;id=<?=$i;?>" data-toggle="tooltip" data-placement="left" title="<?=gettext("click to toggle enabled/disabled status");?>" >
<a href="?act=toggle&amp;id=<?=$i;
?>" data-toggle="tooltip" data-placement="left" title="<?=gettext("click to toggle enabled/disabled status");?>" >
<span class="glyphicon <?php echo $iconfn;?>"></span>
</a>
<?php
else:
else :
?>
<span class="glyphicon <?php echo $iconfn;?>" data-toggle="tooltip" data-placement="left" title="<?=gettext("click to toggle enabled/disabled status");?>"></span>
<span class="glyphicon <?php echo $iconfn;
?>" data-toggle="tooltip" data-placement="left" title="<?=gettext("click to toggle enabled/disabled status");?>"></span>
<?php
endif;
?>
</td>
<td class="listlr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
<td class="listlr" onclick="fr_toggle(<?=$i;
?>)" id="frd<?=$i;
?>" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
<?php
echo $textss;
echo $gateway['name'];
if(isset($gateway['defaultgw']))
if (isset($gateway['defaultgw'])) {
echo " <strong>(default)</strong>";
}
echo $textse;
?>
</td>
<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
<td class="listr" onclick="fr_toggle(<?=$i;
?>)" id="frd<?=$i;
?>" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
<?php
echo $textss;
echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($gateway['friendlyiface']));
echo $textse;
?>
</td>
<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
<td class="listr" onclick="fr_toggle(<?=$i;
?>)" id="frd<?=$i;
?>" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
<?php
echo $textss;
echo $gateway['gateway'] . " ";
echo $textse;
?>
</td>
<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
<td class="listr" onclick="fr_toggle(<?=$i;
?>)" id="frd<?=$i;
?>" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
<?php
echo $textss;
echo htmlspecialchars($gateway['monitor']) . " ";
......@@ -304,13 +333,15 @@ $main_buttons = array(
?>
</td>
<?php
if (is_numeric($gateway['attribute'])):
if (is_numeric($gateway['attribute'])) :
?>
<td class="listbg" onclick="fr_toggle(<?=$i;?>)" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
<td class="listbg" onclick="fr_toggle(<?=$i;
?>)" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
<?php
else:
else :
?>
<td class="listbgns" onclick="fr_toggle(<?=$i;?>)" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
<td class="listbgns" onclick="fr_toggle(<?=$i;
?>)" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
<?php
endif;
echo $textss;
......@@ -320,15 +351,18 @@ $main_buttons = array(
</td>
<td valign="middle" class="list nowrap">
<a href="system_gateways_edit.php?id=<?=$i;?>" class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="left" title="<?=gettext("Edit Gateway");?>">
<a href="system_gateways_edit.php?id=<?=$i;
?>" class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="left" title="<?=gettext("Edit Gateway");?>">
<span class="glyphicon glyphicon-pencil"></span>
</a>
<?php
if (is_numeric($gateway['attribute'])):
if (is_numeric($gateway['attribute'])) :
?>
<a href="system_gateways.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this gateway?"); ?>')" class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="left" title="<?=gettext("Delete Gateway");?>">
<a href="system_gateways.php?act=del&amp;id=<?=$i;
?>" onclick="return confirm('<?=gettext("Do you really want to delete this gateway?");
?>')" class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="left" title="<?=gettext("Delete Gateway");?>">
<span class="glyphicon glyphicon-remove"></span>
</a>
......@@ -336,7 +370,8 @@ $main_buttons = array(
endif;
?>
<a href="system_gateways_edit.php?dup=<?=$i;?>" class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="left" title="<?=gettext("Add Gateway based on this one");?>">
<a href="system_gateways_edit.php?dup=<?=$i;
?>" class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="left" title="<?=gettext("Add Gateway based on this one");?>">
<span class="glyphicon glyphicon-plus"></span>
</a>
</td>
......@@ -352,8 +387,7 @@ $main_buttons = array(
<tr>
<td>
<?php
if ($i > 0):
if ($i > 0) :
?>
<button type="submit" name="del_x" class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="left"
title="<?=gettext("delete selected items");?>"
......@@ -381,4 +415,4 @@ $main_buttons = array(
</div>
</section>
<?php include("foot.inc"); ?>
<?php include("foot.inc");
......@@ -32,7 +32,7 @@ $referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/syste
$a_gateways = return_gateways_array(true, false, true);
$a_gateways_arr = array();
foreach($a_gateways as $gw) {
foreach ($a_gateways as $gw) {
$a_gateways_arr[] = $gw;
}
$a_gateways = $a_gateways_arr;
......@@ -48,13 +48,16 @@ if (!is_array($config['gateways']['gateway_item'])) {
$a_gateway_item = &$config['gateways']['gateway_item'];
$apinger_default = return_apinger_defaults();
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($_GET['dup']) && is_numericint($_GET['dup']))
if (isset($_GET['dup']) && is_numericint($_GET['dup'])) {
$id = $_GET['dup'];
}
if (isset($id) && $a_gateways[$id]) {
$pconfig = array();
......@@ -70,8 +73,9 @@ if (isset($id) && $a_gateways[$id]) {
$pconfig['interface'] = $a_gateways[$id]['interface'];
$pconfig['friendlyiface'] = $a_gateways[$id]['friendlyiface'];
$pconfig['ipprotocol'] = $a_gateways[$id]['ipprotocol'];
if (isset($a_gateways[$id]['dynamic']))
if (isset($a_gateways[$id]['dynamic'])) {
$pconfig['dynamic'] = true;
}
$pconfig['gateway'] = $a_gateways[$id]['gateway'];
$pconfig['defaultgw'] = isset($a_gateways[$id]['defaultgw']);
$pconfig['force_down'] = isset($a_gateways[$id]['force_down']);
......@@ -92,11 +96,11 @@ if (isset($_GET['dup']) && is_numericint($_GET['dup'])) {
unset($pconfig['attribute']);
}
if (isset($id) && $a_gateways[$id])
if (isset($id) && $a_gateways[$id]) {
$realid = $a_gateways[$id]['attribute'];
}
if ($_POST) {
unset($input_errors);
/* input validation */
......@@ -117,89 +121,98 @@ if ($_POST) {
}
if ($_POST['gateway'] && (is_ipaddr($_POST['gateway'])) && !$_REQUEST['isAjax']) {
if(is_ipaddrv4($_POST['gateway'])) {
if (is_ipaddrv4($_POST['gateway'])) {
$parent_ip = get_interface_ip($_POST['interface']);
$parent_sn = get_interface_subnet($_POST['interface']);
if(empty($parent_ip) || empty($parent_sn)) {
if (empty($parent_ip) || empty($parent_sn)) {
$input_errors[] = gettext("Cannot add IPv4 Gateway Address because no IPv4 address could be found on the interface.");
} else {
$subnets = array(gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn);
$vips = link_interface_to_vips($_POST['interface']);
if (is_array($vips))
foreach($vips as $vip) {
if (!is_ipaddrv4($vip['subnet']))
if (is_array($vips)) {
foreach ($vips as $vip) {
if (!is_ipaddrv4($vip['subnet'])) {
continue;
}
$subnets[] = gen_subnet($vip['subnet'], $vip['subnet_bits']) . "/" . $vip['subnet_bits'];
}
}
$found = false;
foreach($subnets as $subnet)
if(ip_in_subnet($_POST['gateway'], $subnet)) {
foreach ($subnets as $subnet) {
if (ip_in_subnet($_POST['gateway'], $subnet)) {
$found = true;
break;
}
}
if ($found === false)
if ($found === false) {
$input_errors[] = sprintf(gettext("The gateway address %1\$s does not lie within one of the chosen interface's subnets."), $_POST['gateway']);
}
}
else if(is_ipaddrv6($_POST['gateway'])) {
} elseif (is_ipaddrv6($_POST['gateway'])) {
/* do not do a subnet match on a link local address, it's valid */
if(!is_linklocal($_POST['gateway'])) {
if (!is_linklocal($_POST['gateway'])) {
$parent_ip = get_interface_ipv6($_POST['interface']);
$parent_sn = get_interface_subnetv6($_POST['interface']);
if(empty($parent_ip) || empty($parent_sn)) {
if (empty($parent_ip) || empty($parent_sn)) {
$input_errors[] = gettext("Cannot add IPv6 Gateway Address because no IPv6 address could be found on the interface.");
} else {
$subnets = array(gen_subnetv6($parent_ip, $parent_sn) . "/" . $parent_sn);
$vips = link_interface_to_vips($_POST['interface']);
if (is_array($vips))
foreach($vips as $vip) {
if (!is_ipaddrv6($vip['subnet']))
if (is_array($vips)) {
foreach ($vips as $vip) {
if (!is_ipaddrv6($vip['subnet'])) {
continue;
}
$subnets[] = gen_subnetv6($vip['subnet'], $vip['subnet_bits']) . "/" . $vip['subnet_bits'];
}
}
$found = false;
foreach($subnets as $subnet)
if(ip_in_subnet($_POST['gateway'], $subnet)) {
foreach ($subnets as $subnet) {
if (ip_in_subnet($_POST['gateway'], $subnet)) {
$found = true;
break;
}
}
if ($found === false)
if ($found === false) {
$input_errors[] = sprintf(gettext("The gateway address %1\$s does not lie within one of the chosen interface's subnets."), $_POST['gateway']);
}
}
}
}
if (!empty($config['interfaces'][$_POST['interface']]['ipaddr'])) {
if (is_ipaddr($config['interfaces'][$_POST['interface']]['ipaddr']) && (empty($_POST['gateway']) || $_POST['gateway'] == "dynamic"))
if (is_ipaddr($config['interfaces'][$_POST['interface']]['ipaddr']) && (empty($_POST['gateway']) || $_POST['gateway'] == "dynamic")) {
$input_errors[] = gettext("Dynamic gateway values cannot be specified for interfaces with a static IPv4 configuration.");
}
}
if (!empty($config['interfaces'][$_POST['interface']]['ipaddrv6'])) {
if (is_ipaddr($config['interfaces'][$_POST['interface']]['ipaddrv6']) && (empty($_POST['gateway']) || $_POST['gateway'] == "dynamic"))
if (is_ipaddr($config['interfaces'][$_POST['interface']]['ipaddrv6']) && (empty($_POST['gateway']) || $_POST['gateway'] == "dynamic")) {
$input_errors[] = gettext("Dynamic gateway values cannot be specified for interfaces with a static IPv6 configuration.");
}
}
}
if (($_POST['monitor'] <> "") && !is_ipaddr($_POST['monitor']) && $_POST['monitor'] != "dynamic") {
$input_errors[] = gettext("A valid monitor IP address must be specified.");
}
/* only allow correct IPv4 and IPv6 gateway addresses */
if (($_POST['gateway'] <> "") && is_ipaddr($_POST['gateway']) && $_POST['gateway'] != "dynamic") {
if(is_ipaddrv6($_POST['gateway']) && ($_POST['ipprotocol'] == "inet")) {
if (is_ipaddrv6($_POST['gateway']) && ($_POST['ipprotocol'] == "inet")) {
$input_errors[] = gettext("The IPv6 gateway address '{$_POST['gateway']}' can not be used as a IPv4 gateway'.");
}
if(is_ipaddrv4($_POST['gateway']) && ($_POST['ipprotocol'] == "inet6")) {
if (is_ipaddrv4($_POST['gateway']) && ($_POST['ipprotocol'] == "inet6")) {
$input_errors[] = gettext("The IPv4 gateway address '{$_POST['gateway']}' can not be used as a IPv6 gateway'.");
}
}
/* only allow correct IPv4 and IPv6 monitor addresses */
if (($_POST['monitor'] <> "") && is_ipaddr($_POST['monitor']) && $_POST['monitor'] != "dynamic") {
if(is_ipaddrv6($_POST['monitor']) && ($_POST['ipprotocol'] == "inet")) {
if (is_ipaddrv6($_POST['monitor']) && ($_POST['ipprotocol'] == "inet")) {
$input_errors[] = gettext("The IPv6 monitor address '{$_POST['monitor']}' can not be used on a IPv4 gateway'.");
}
if(is_ipaddrv4($_POST['monitor']) && ($_POST['ipprotocol'] == "inet6")) {
if (is_ipaddrv4($_POST['monitor']) && ($_POST['ipprotocol'] == "inet6")) {
$input_errors[] = gettext("The IPv4 monitor address '{$_POST['monitor']}' can not be used on a IPv6 gateway'.");
}
}
......@@ -208,23 +221,24 @@ if ($_POST) {
/* check for overlaps */
foreach ($a_gateways as $gateway) {
if (isset($id) && ($a_gateways[$id]) && ($a_gateways[$id] === $gateway)) {
if ($gateway['name'] != $_POST['name'])
if ($gateway['name'] != $_POST['name']) {
$input_errors[] = gettext("Changing name on a gateway is not allowed.");
}
continue;
}
if($_POST['name'] <> "") {
if ($_POST['name'] <> "") {
if (($gateway['name'] <> "") && ($_POST['name'] == $gateway['name']) && ($gateway['attribute'] !== "system")) {
$input_errors[] = sprintf(gettext('The gateway name "%s" already exists.'), $_POST['name']);
break;
}
}
if(is_ipaddr($_POST['gateway'])) {
if (is_ipaddr($_POST['gateway'])) {
if (($gateway['gateway'] <> "") && ($_POST['gateway'] == $gateway['gateway']) && ($gateway['attribute'] !== "system")) {
$input_errors[] = sprintf(gettext('The gateway IP address "%s" already exists.'), $_POST['gateway']);
break;
}
}
if(is_ipaddr($_POST['monitor'])) {
if (is_ipaddr($_POST['monitor'])) {
if (($gateway['monitor'] <> "") && ($_POST['monitor'] == $gateway['monitor']) && ($gateway['attribute'] !== "system")) {
$input_errors[] = sprintf(gettext('The monitor IP address "%s" is already in use. You must choose a different monitor IP.'), $_POST['monitor']);
break;
......@@ -234,7 +248,7 @@ if ($_POST) {
}
/* input validation of apinger advanced parameters */
if($_POST['latencylow']) {
if ($_POST['latencylow']) {
if (! is_numeric($_POST['latencylow'])) {
$input_errors[] = gettext("The low latency threshold needs to be a numeric value.");
} else {
......@@ -244,7 +258,7 @@ if ($_POST) {
}
}
if($_POST['latencyhigh']) {
if ($_POST['latencyhigh']) {
if (! is_numeric($_POST['latencyhigh'])) {
$input_errors[] = gettext("The high latency threshold needs to be a numeric value.");
} else {
......@@ -254,7 +268,7 @@ if ($_POST) {
}
}
if($_POST['losslow']) {
if ($_POST['losslow']) {
if (! is_numeric($_POST['losslow'])) {
$input_errors[] = gettext("The low Packet Loss threshold needs to be a numeric value.");
} else {
......@@ -267,7 +281,7 @@ if ($_POST) {
}
}
if($_POST['losshigh']) {
if ($_POST['losshigh']) {
if (! is_numeric($_POST['losshigh'])) {
$input_errors[] = gettext("The high Packet Loss threshold needs to be a numeric value.");
} else {
......@@ -280,53 +294,53 @@ if ($_POST) {
}
}
if(($_POST['latencylow']) && ($_POST['latencyhigh'])) {
if (($_POST['latencylow']) && ($_POST['latencyhigh'])) {
if ((is_numeric($_POST['latencylow'])) && (is_numeric($_POST['latencyhigh']))) {
if(($_POST['latencylow'] > $_POST['latencyhigh'])) {
if (($_POST['latencylow'] > $_POST['latencyhigh'])) {
$input_errors[] = gettext("The high latency threshold needs to be higher than the low latency threshold");
}
}
} else {
if($_POST['latencylow']){
if ($_POST['latencylow']) {
if (is_numeric($_POST['latencylow'])) {
if($_POST['latencylow'] > $apinger_default['latencyhigh']) {
if ($_POST['latencylow'] > $apinger_default['latencyhigh']) {
$input_errors[] = gettext(sprintf("The low latency threshold needs to be less than the default high latency threshold (%d)", $apinger_default['latencyhigh']));
}
}
}
if($_POST['latencyhigh']){
if ($_POST['latencyhigh']) {
if (is_numeric($_POST['latencyhigh'])) {
if($_POST['latencyhigh'] < $apinger_default['latencylow']) {
if ($_POST['latencyhigh'] < $apinger_default['latencylow']) {
$input_errors[] = gettext(sprintf("The high latency threshold needs to be higher than the default low latency threshold (%d)", $apinger_default['latencylow']));
}
}
}
}
if(($_POST['losslow']) && ($_POST['losshigh'])){
if (($_POST['losslow']) && ($_POST['losshigh'])) {
if ((is_numeric($_POST['losslow'])) && (is_numeric($_POST['losshigh']))) {
if($_POST['losslow'] > $_POST['losshigh']) {
if ($_POST['losslow'] > $_POST['losshigh']) {
$input_errors[] = gettext("The high Packet Loss threshold needs to be higher than the low Packet Loss threshold");
}
}
} else {
if($_POST['losslow']){
if ($_POST['losslow']) {
if (is_numeric($_POST['losslow'])) {
if($_POST['losslow'] > $apinger_default['losshigh']) {
if ($_POST['losslow'] > $apinger_default['losshigh']) {
$input_errors[] = gettext(sprintf("The low Packet Loss threshold needs to be less than the default high Packet Loss threshold (%d)", $apinger_default['losshigh']));
}
}
}
if($_POST['losshigh']){
if ($_POST['losshigh']) {
if (is_numeric($_POST['losshigh'])) {
if($_POST['losshigh'] < $apinger_default['losslow']) {
if ($_POST['losshigh'] < $apinger_default['losslow']) {
$input_errors[] = gettext(sprintf("The high Packet Loss threshold needs to be higher than the default low Packet Loss threshold (%d)", $apinger_default['losslow']));
}
}
}
}
if($_POST['interval']) {
if ($_POST['interval']) {
if (! is_numeric($_POST['interval'])) {
$input_errors[] = gettext("The probe interval needs to be a numeric value.");
} else {
......@@ -336,7 +350,7 @@ if ($_POST) {
}
}
if($_POST['down']) {
if ($_POST['down']) {
if (! is_numeric($_POST['down'])) {
$input_errors[] = gettext("The down time setting needs to be a numeric value.");
} else {
......@@ -346,30 +360,30 @@ if ($_POST) {
}
}
if(($_POST['interval']) && ($_POST['down'])){
if (($_POST['interval']) && ($_POST['down'])) {
if ((is_numeric($_POST['interval'])) && (is_numeric($_POST['down']))) {
if($_POST['interval'] > $_POST['down']) {
if ($_POST['interval'] > $_POST['down']) {
$input_errors[] = gettext("The probe interval needs to be less than the down time setting.");
}
}
} else {
if($_POST['interval']){
if ($_POST['interval']) {
if (is_numeric($_POST['interval'])) {
if($_POST['interval'] > $apinger_default['down']) {
if ($_POST['interval'] > $apinger_default['down']) {
$input_errors[] = gettext(sprintf("The probe interval needs to be less than the default down time setting (%d)", $apinger_default['down']));
}
}
}
if($_POST['down']){
if ($_POST['down']) {
if (is_numeric($_POST['down'])) {
if($_POST['down'] < $apinger_default['interval']) {
if ($_POST['down'] < $apinger_default['interval']) {
$input_errors[] = gettext(sprintf("The down time setting needs to be higher than the default probe interval (%d)", $apinger_default['interval']));
}
}
}
}
if($_POST['avg_delay_samples']) {
if ($_POST['avg_delay_samples']) {
if (! is_numeric($_POST['avg_delay_samples'])) {
$input_errors[] = gettext("The average delay replies qty needs to be a numeric value.");
} else {
......@@ -379,7 +393,7 @@ if ($_POST) {
}
}
if($_POST['avg_loss_samples']) {
if ($_POST['avg_loss_samples']) {
if (! is_numeric($_POST['avg_loss_samples'])) {
$input_errors[] = gettext("The average packet loss probes qty needs to be a numeric value.");
} else {
......@@ -389,7 +403,7 @@ if ($_POST) {
}
}
if($_POST['avg_loss_delay_samples']) {
if ($_POST['avg_loss_delay_samples']) {
if (! is_numeric($_POST['avg_loss_delay_samples'])) {
$input_errors[] = gettext("The lost probe delay needs to be a numeric value.");
} else {
......@@ -403,93 +417,111 @@ if ($_POST) {
$reloadif = "";
$gateway = array();
if (empty($_POST['interface']))
if (empty($_POST['interface'])) {
$gateway['interface'] = $pconfig['friendlyiface'];
else
} else {
$gateway['interface'] = $_POST['interface'];
if (is_ipaddr($_POST['gateway']))
}
if (is_ipaddr($_POST['gateway'])) {
$gateway['gateway'] = $_POST['gateway'];
else
} else {
$gateway['gateway'] = "dynamic";
}
$gateway['name'] = $_POST['name'];
$gateway['weight'] = $_POST['weight'];
$gateway['ipprotocol'] = $_POST['ipprotocol'];
$gateway['interval'] = $_POST['interval'];
$gateway['avg_delay_samples'] = $_POST['avg_delay_samples'];
if ($_POST['avg_delay_samples_calculated'] == "yes" || $_POST['avg_delay_samples_calculated'] == "on")
if ($_POST['avg_delay_samples_calculated'] == "yes" || $_POST['avg_delay_samples_calculated'] == "on") {
$gateway['avg_delay_samples_calculated'] = true;
}
$gateway['avg_loss_samples'] = $_POST['avg_loss_samples'];
if ($_POST['avg_loss_samples_calculated'] == "yes" || $_POST['avg_loss_samples_calculated'] == "on")
if ($_POST['avg_loss_samples_calculated'] == "yes" || $_POST['avg_loss_samples_calculated'] == "on") {
$gateway['avg_loss_samples_calculated'] = true;
}
$gateway['avg_loss_delay_samples'] = $_POST['avg_loss_delay_samples'];
if ($_POST['avg_loss_delay_samples_calculated'] == "yes" || $_POST['avg_loss_delay_samples_calculated'] == "on")
if ($_POST['avg_loss_delay_samples_calculated'] == "yes" || $_POST['avg_loss_delay_samples_calculated'] == "on") {
$gateway['avg_loss_delay_samples_calculated'] = true;
}
$gateway['descr'] = $_POST['descr'];
if ($_POST['monitor_disable'] == "yes")
if ($_POST['monitor_disable'] == "yes") {
$gateway['monitor_disable'] = true;
if ($_POST['force_down'] == "yes")
}
if ($_POST['force_down'] == "yes") {
$gateway['force_down'] = true;
if (is_ipaddr($_POST['monitor']))
}
if (is_ipaddr($_POST['monitor'])) {
$gateway['monitor'] = $_POST['monitor'];
}
/* NOTE: If monitor ip is changed need to cleanup the old static route */
if ($_POST['monitor'] != "dynamic" && !empty($a_gateway_item[$realid]) && is_ipaddr($a_gateway_item[$realid]['monitor']) &&
$_POST['monitor'] != $a_gateway_item[$realid]['monitor'] && $gateway['gateway'] != $a_gateway_item[$realid]['monitor']) {
if (is_ipaddrv4($a_gateway_item[$realid]['monitor']))
if (is_ipaddrv4($a_gateway_item[$realid]['monitor'])) {
mwexec("/sbin/route delete " . escapeshellarg($a_gateway_item[$realid]['monitor']));
else
} else {
mwexec("/sbin/route delete -inet6 " . escapeshellarg($a_gateway_item[$realid]['monitor']));
}
}
if ($_POST['defaultgw'] == "yes" || $_POST['defaultgw'] == "on") {
$i = 0;
/* remove the default gateway bits for all gateways with the same address family */
foreach($a_gateway_item as $gw) {
foreach ($a_gateway_item as $gw) {
if ($gateway['ipprotocol'] == $gw['ipprotocol']) {
unset($config['gateways']['gateway_item'][$i]['defaultgw']);
if ($gw['interface'] != $_POST['interface'] && $gw['defaultgw'])
if ($gw['interface'] != $_POST['interface'] && $gw['defaultgw']) {
$reloadif = $gw['interface'];
}
}
$i++;
}
$gateway['defaultgw'] = true;
}
if ($_POST['latencylow'])
if ($_POST['latencylow']) {
$gateway['latencylow'] = $_POST['latencylow'];
if ($_POST['latencyhigh'])
}
if ($_POST['latencyhigh']) {
$gateway['latencyhigh'] = $_POST['latencyhigh'];
if ($_POST['losslow'])
}
if ($_POST['losslow']) {
$gateway['losslow'] = $_POST['losslow'];
if ($_POST['losshigh'])
}
if ($_POST['losshigh']) {
$gateway['losshigh'] = $_POST['losshigh'];
if ($_POST['down'])
}
if ($_POST['down']) {
$gateway['down'] = $_POST['down'];
}
if(isset($_POST['disabled']))
if (isset($_POST['disabled'])) {
$gateway['disabled'] = true;
else
} else {
unset($gateway['disabled']);
}
/* when saving the manual gateway we use the attribute which has the corresponding id */
if (isset($realid) && $a_gateway_item[$realid])
if (isset($realid) && $a_gateway_item[$realid]) {
$a_gateway_item[$realid] = $gateway;
else
} else {
$a_gateway_item[] = $gateway;
}
mark_subsystem_dirty('staticroutes');
write_config();
if($_REQUEST['isAjax']) {
if ($_REQUEST['isAjax']) {
echo $_POST['name'];
exit;
} else if (!empty($reloadif))
} elseif (!empty($reloadif)) {
configd_run("interface reconfigure {$reloadif}");
}
header("Location: system_gateways.php");
exit;
......@@ -504,9 +536,10 @@ if ($_POST) {
}
$pconfig = $_POST;
if (empty($_POST['friendlyiface']))
if (empty($_POST['friendlyiface'])) {
$pconfig['friendlyiface'] = $_POST['interface'];
}
}
}
......@@ -624,7 +657,9 @@ function enable_change() {
<div class="container-fluid">
<div class="row">
<?php if ($input_errors) print_input_errors($input_errors); ?>
<?php if ($input_errors) {
print_input_errors($input_errors);
} ?>
<div id="inputerrors"></div>
......@@ -641,7 +676,7 @@ function enable_change() {
<form action="system_gateways_edit.php" method="post" name="iform" id="iform">
<?php
/* If this is a system gateway we need this var */
if(($pconfig['attribute'] == "system") || is_numeric($pconfig['attribute'])) {
if (($pconfig['attribute'] == "system") || is_numeric($pconfig['attribute'])) {
echo "<input type='hidden' name='attribute' id='attribute' value=\"" . htmlspecialchars($pconfig['attribute']) . "\" />\n";
}
echo "<input type='hidden' name='friendlyiface' id='friendlyiface' value=\"" . htmlspecialchars($pconfig['friendlyiface']) . "\" />\n";
......@@ -651,7 +686,9 @@ function enable_change() {
<tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled");?></td>
<td width="78%" class="vtable">
<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked=\"checked\""; ?> />
<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) {
echo "checked=\"checked\"";
} ?> />
<strong><?=gettext("Disable this gateway");?></strong><br />
<span class="vexpl"><?=gettext("Set this option to disable this gateway without removing it from the list.");?></span>
</td>
......@@ -664,8 +701,9 @@ function enable_change() {
$interfaces = get_configured_interface_with_descr(false, true);
foreach ($interfaces as $iface => $ifacename) {
echo "<option value=\"{$iface}\"";
if ($iface == $pconfig['friendlyiface'])
if ($iface == $pconfig['friendlyiface']) {
echo " selected='selected'";
}
echo ">" . htmlspecialchars($ifacename) . "</option>";
}
?>
......@@ -681,8 +719,9 @@ function enable_change() {
$options = array("inet" => "IPv4", "inet6" => "IPv6");
foreach ($options as $name => $string) {
echo "<option value=\"{$name}\"";
if ($name == $pconfig['ipprotocol'])
if ($name == $pconfig['ipprotocol']) {
echo " selected='selected'";
}
echo ">" . htmlspecialchars($string) . "</option>\n";
}
?>
......@@ -700,14 +739,21 @@ function enable_change() {
<tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Gateway"); ?></td>
<td width="78%" class="vtable">
<input name="gateway" type="text" class="formfld host" id="gateway" size="28" value="<?php if ($pconfig['dynamic']) echo "dynamic"; else echo htmlspecialchars($pconfig['gateway']); ?>" />
<input name="gateway" type="text" class="formfld host" id="gateway" size="28" value="<?php if ($pconfig['dynamic']) {
echo "dynamic";
} else {
echo htmlspecialchars($pconfig['gateway']);
} ?>" />
<br /><span class="vexpl"><?=gettext("Gateway IP address"); ?></span>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Default Gateway"); ?></td>
<td width="78%" class="vtable">
<input name="defaultgw" type="checkbox" id="defaultgw" value="yes" <?php if ($pconfig['defaultgw'] == true) echo "checked=\"checked\""; ?> />
<input name="defaultgw" type="checkbox" id="defaultgw" value="yes" <?php if ($pconfig['defaultgw'] == true) {
echo "checked=\"checked\"";
} ?> />
<strong><?=gettext("Default Gateway"); ?></strong><br />
<?=gettext("This will select the above gateway as the default gateway"); ?>
</td>
......@@ -715,7 +761,9 @@ function enable_change() {
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Disable Gateway Monitoring"); ?></td>
<td width="78%" class="vtable">
<input name="monitor_disable" type="checkbox" id="monitor_disable" value="yes" <?php if ($pconfig['monitor_disable'] == true) echo "checked=\"checked\""; ?> onclick="monitor_change()" />
<input name="monitor_disable" type="checkbox" id="monitor_disable" value="yes" <?php if ($pconfig['monitor_disable'] == true) {
echo "checked=\"checked\"";
} ?> onclick="monitor_change()" />
<strong><?=gettext("Disable Gateway Monitoring"); ?></strong><br />
<?=gettext("This will consider this gateway as always being up"); ?>
</td>
......@@ -724,10 +772,11 @@ function enable_change() {
<td width="22%" valign="top" class="vncell"><?=gettext("Monitor IP"); ?></td>
<td width="78%" class="vtable">
<?php
if ($pconfig['gateway'] == $pconfig['monitor'])
if ($pconfig['gateway'] == $pconfig['monitor']) {
$monitor = "";
else
} else {
$monitor = htmlspecialchars($pconfig['monitor']);
}
?>
<input name="monitor" type="text" id="monitor" value="<?php echo htmlspecialchars($monitor); ?>" size="28" />
<strong><?=gettext("Alternative monitor IP"); ?></strong> <br />
......@@ -740,7 +789,9 @@ function enable_change() {
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Mark Gateway as Down"); ?></td>
<td width="78%" class="vtable">
<input name="force_down" type="checkbox" id="force_down" value="yes" <?php if ($pconfig['force_down'] == true) echo "checked=\"checked\""; ?> />
<input name="force_down" type="checkbox" id="force_down" value="yes" <?php if ($pconfig['force_down'] == true) {
echo "checked=\"checked\"";
} ?> />
<strong><?=gettext("Mark Gateway as Down"); ?></strong><br />
<?=gettext("This will force this gateway to be considered Down"); ?>
</td>
......@@ -749,10 +800,14 @@ function enable_change() {
<td width="22%" valign="top" class="vncell"><?=gettext("Advanced");?></td>
<td width="78%" class="vtable">
<?php $showbutton = (!empty($pconfig['latencylow']) || !empty($pconfig['latencyhigh']) || !empty($pconfig['losslow']) || !empty($pconfig['losshigh']) || (isset($pconfig['weight']) && $pconfig['weight'] > 1) || (isset($pconfig['interval']) && ($pconfig['interval'] > $apinger_default['interval'])) || (isset($pconfig['down']) && !($pconfig['down'] == $apinger_default['down']))); ?>
<div id="showadvgatewaybox" <?php if ($showbutton) echo "style='display:none'"; ?>>
<div id="showadvgatewaybox" <?php if ($showbutton) {
echo "style='display:none'";
} ?>>
<input type="button" onclick="show_advanced_gateway()" value="Advanced" class="btn btn-default btn-xs"/><?=gettext(" - Show advanced option"); ?>
</div>
<div id="showgatewayadv" <?php if (!$showbutton) echo "style='display:none'"; ?>>
<div id="showgatewayadv" <?php if (!$showbutton) {
echo "style='display:none'";
} ?>>
<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6" summary="advanced options">
<tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Weight");?></td>
......@@ -761,8 +816,9 @@ function enable_change() {
<?php
for ($i = 1; $i < 6; $i++) {
$selected = "";
if ($pconfig['weight'] == $i)
if ($pconfig['weight'] == $i) {
$selected = "selected='selected'";
}
echo "<option value='{$i}' {$selected} >{$i}</option>";
}
?>
......@@ -818,7 +874,9 @@ function enable_change() {
<td width="78%" class="vtable">
<input name="avg_delay_samples" type="text" class="formfld unknown" id="avg_delay_samples" size="2"
value="<?=htmlspecialchars($pconfig['avg_delay_samples']);?>" onchange="samples_change(document.iform.avg_delay_samples_calculated, this)" />
<input name="avg_delay_samples_calculated" type="checkbox" id="avg_delay_samples_calculated" value="yes" <?php if ($pconfig['avg_delay_samples_calculated'] == true) echo "checked=\"checked\""; ?> onclick="calculated_change(this, document.iform.avg_delay_samples)" />
<input name="avg_delay_samples_calculated" type="checkbox" id="avg_delay_samples_calculated" value="yes" <?php if ($pconfig['avg_delay_samples_calculated'] == true) {
echo "checked=\"checked\"";
} ?> onclick="calculated_change(this, document.iform.avg_delay_samples)" />
<?=gettext("Use calculated value."); ?>
<br /><span class="vexpl"><?=gettext(sprintf("How many replies should be used to compute average delay for controlling \"delay\" alarms? Default is %d.", $apinger_default['avg_delay_samples']));?><br /><br /></span>
</td>
......@@ -828,7 +886,9 @@ function enable_change() {
<td width="78%" class="vtable">
<input name="avg_loss_samples" type="text" class="formfld unknown" id="avg_loss_samples" size="2"
value="<?=htmlspecialchars($pconfig['avg_loss_samples']);?>" onchange="samples_change(document.iform.avg_loss_samples_calculated, this)" />
<input name="avg_loss_samples_calculated" type="checkbox" id="avg_loss_samples_calculated" value="yes" <?php if ($pconfig['avg_loss_samples_calculated'] == true) echo "checked=\"checked\""; ?> onclick="calculated_change(this, document.iform.avg_loss_samples)" />
<input name="avg_loss_samples_calculated" type="checkbox" id="avg_loss_samples_calculated" value="yes" <?php if ($pconfig['avg_loss_samples_calculated'] == true) {
echo "checked=\"checked\"";
} ?> onclick="calculated_change(this, document.iform.avg_loss_samples)" />
<?=gettext("Use calculated value."); ?>
<br /><span class="vexpl"><?=gettext(sprintf("How many probes should be useds to compute average packet loss? Default is %d.", $apinger_default['avg_loss_samples']));?><br /><br /></span>
</td>
......@@ -838,7 +898,9 @@ function enable_change() {
<td width="78%" class="vtable">
<input name="avg_loss_delay_samples" type="text" class="formfld unknown" id="avg_loss_delay_samples" size="2"
value="<?=htmlspecialchars($pconfig['avg_loss_delay_samples']);?>" onchange="samples_change(document.iform.avg_loss_delay_samples_calculated, this)" />
<input name="avg_loss_delay_samples_calculated" type="checkbox" id="avg_loss_delay_samples_calculated" value="yes" <?php if ($pconfig['avg_loss_delay_samples_calculated'] == true) echo "checked=\"checked\""; ?> onclick="calculated_change(this, document.iform.avg_loss_delay_samples)" />
<input name="avg_loss_delay_samples_calculated" type="checkbox" id="avg_loss_delay_samples_calculated" value="yes" <?php if ($pconfig['avg_loss_delay_samples_calculated'] == true) {
echo "checked=\"checked\"";
} ?> onclick="calculated_change(this, document.iform.avg_loss_delay_samples)" />
<?=gettext("Use calculated value."); ?>
<br /><span class="vexpl"><?=gettext(sprintf("The delay (in qty of probe samples) after which loss is computed. Without this, delays longer than the probe interval would be treated as packet loss. Default is %d.", $apinger_default['avg_loss_delay_samples']));?><br /><br /></span>
</td>
......@@ -864,10 +926,13 @@ function enable_change() {
<td width="22%" valign="top">&nbsp;</td>
<td width="78%">
<input name="Submit" type="submit" class="btn btn-primary" value="<?=gettext("Save");?>" onclick="enable_change()" />
<input type="button" class="btn btn-default" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
<?php if (isset($id) && $a_gateways[$id]): ?>
<input type="button" class="btn btn-default" value="<?=gettext("Cancel");
?>" onclick="window.location.href='<?=$referer;?>'" />
<?php if (isset($id) && $a_gateways[$id]) :
?>
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
<?php endif; ?>
<?php
endif; ?>
</td>
</tr>
</table>
......@@ -885,4 +950,4 @@ monitor_change();
calculate_state_change();
//]]>
</script>
<?php include("foot.inc"); ?>
<?php include("foot.inc");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment