2010-09-03 13:32:11 +00:00
<? php
echo ( '<div style="padding: 10px;">' );
2011-03-16 23:10:10 +00:00
if ( $_POST [ 'ignoreport' ])
{
if ( $_SESSION [ 'userlevel' ] == '10' )
{
2010-09-03 13:32:11 +00:00
include ( "includes/port-edit.inc.php" );
}
}
2011-03-16 23:10:10 +00:00
if ( $updated && $update_message )
{
2010-09-03 13:32:11 +00:00
print_message ( $update_message );
} elseif ( $update_message ) {
print_error ( $update_message );
}
2011-03-21 12:18:26 +00:00
echo ( "<div style='float: left; width: 100%'>
2010-09-03 13:32:11 +00:00
<form id='ignoreport' name='ignoreport' method='post' action=''>
<input type=hidden name='ignoreport' value='yes'>
2011-03-22 08:15:26 +00:00
<input type=hidden name=device value='" . $device [ 'device_id' ] . "'>" );
2011-03-21 12:18:26 +00:00
echo ( "<table cellpadding=3 cellspacing=0 width=100%>
<tr align=center>
2011-04-02 12:08:08 +00:00
<th width=100>Index</th>
<th width=100>Name</th>
2011-03-21 12:18:26 +00:00
<th width=50>Admin</th>
2011-04-02 12:08:08 +00:00
<th width=100>Oper</th>
<th width=100>Disable</th>
<th width=100>Ignore</th>
2011-03-21 12:18:26 +00:00
<th>Description</th>
2011-04-02 12:08:08 +00:00
</tr>
<tr align=center>
<td><input type='submit' value='Save' title='Save current port disable/ignore settings'/><input type='submit' value='Reset' id='form-reset' title='Reset form to previously-saved settings'/></td>
<td></td>
<td></td>
<td><input type='submit' value='Alerted' id='alerted-toggle' title='Toggle alerting on all currently-alerted ports'/><input type='submit' value='Down' id='down-select' title='Disable alerting on all currently-down ports'/></td>
<td><input type='submit' value='Toggle' id='disable-toggle' title='Toggle polling for all ports'/><input type='submit' value='Select' id='disable-select' title='Disable polling on all ports'/></td>
<td><input type='submit' value='Toggle' id='ignore-toggle' title='Toggle alerting for all ports'/><input type='submit' value='Select' id='ignore-select' title='Disable alerting on all ports'/></td>
<td></td>
2011-03-21 12:18:26 +00:00
</tr>
2011-03-21 10:39:54 +00:00
" );
2011-04-02 12:08:08 +00:00
?>
<script>
2011-09-20 14:37:54 +00:00
$(document).ready(function() {
$('#disable-toggle').click(function(event) {
// invert selection on all disable buttons
event.preventDefault();
$('[name^="disabled_"]').check('toggle');
2011-04-02 12:08:08 +00:00
});
2011-09-20 14:37:54 +00:00
$('#ignore-toggle').click(function(event) {
// invert selection on all ignore buttons
event.preventDefault();
$('[name^="ignore_"]').check('toggle');
2011-04-02 12:08:08 +00:00
});
2011-09-20 14:37:54 +00:00
$('#disable-select').click(function(event) {
// select all disable buttons
event.preventDefault();
$('[name^="disabled_"]').check();
2011-04-02 12:08:08 +00:00
});
2011-09-20 14:37:54 +00:00
$('#ignore-select').click(function(event) {
// select all ignore buttons
event.preventDefault();
$('[name^="ignore_"]').check();
2011-04-02 12:08:08 +00:00
});
2011-09-20 14:37:54 +00:00
$('#down-select').click(function(event) {
// select ignore buttons for all ports which are down
event.preventDefault();
$('[name^="operstatus_"]').each(function() {
var name = $(this).attr('name');
var text = $(this).text();
if (name && text == 'down') {
// get the interface number from the object name
var interface_id = name.split('_')[1];
// find its corresponding checkbox and toggle it
$('[name="ignore_' + interface_id + '"]').check();
}
});
2011-04-02 12:08:08 +00:00
});
2011-09-20 14:37:54 +00:00
$('#alerted-toggle').click(function(event) {
// toggle ignore buttons for all ports which are in class red
event.preventDefault();
$('.red').each(function() {
var name = $(this).attr('name');
if (name) {
// get the interface number from the object name
var interface_id = name.split('_')[1];
// find its corresponding checkbox and toggle it
$('[name="ignore_' + interface_id + '"]').check('toggle');
}
});
2011-04-02 12:08:08 +00:00
});
2011-09-20 14:37:54 +00:00
$('#form-reset').click(function(event) {
// reset objects in the form to their previous values
event.preventDefault();
$('#ignoreport')[0].reset();
2011-04-02 12:08:08 +00:00
});
});
</script>
<?php
2010-09-03 13:32:11 +00:00
2011-03-21 12:18:26 +00:00
$row=1;
2011-05-15 17:20:26 +00:00
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? ORDER BY `ifIndex` ", array($device['device_id'])) as $port)
2011-03-16 23:10:10 +00:00
{
2011-03-21 12:18:26 +00:00
$port = ifLabel($port);
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
echo("<tr bgcolor=$row_colour>");
echo("<td align=center>". $port['ifIndex']."</td>");
echo("<td align=left>".$port['label'] . "</td>");
echo("<td align=right>". $port['ifAdminStatus']."</td>");
2010-09-03 13:32:11 +00:00
2011-03-21 10:39:54 +00:00
# Mark interfaces which are OperDown (but not AdminDown) yet not ignored or disabled, or up yet ignored or disabled
# - as to draw the attention to a possible problem.
2011-03-21 12:18:26 +00:00
$isportbad = ($port['ifOperStatus'] == 'down' && $port['ifAdminStatus'] != 'down') ? 1 : 0;
2011-03-22 08:16:04 +00:00
$dowecare = ($port['ignore'] == 0 && $port['disabled'] == 0) ? $isportbad : !$isportbad;
2011-04-02 12:08:08 +00:00
$outofsync = $dowecare ? " class='red'" : "";
2010-09-03 13:32:11 +00:00
2011-04-02 12:08:08 +00:00
echo("<td align=right><span name='operstatus_".$port['interface_id']."'".$outofsync.">". $port['ifOperStatus']."</span></td>");
2010-09-03 13:32:11 +00:00
2011-03-21 12:18:26 +00:00
echo("<td align=center>");
echo("<input type=checkbox name='disabled_".$port['interface_id']."'".($port['disabled'] ? 'checked' : '').">");
echo("<input type=hidden name='olddis_".$port['interface_id']."' value=".($port['disabled'] ? 1 : 0).">");
2011-03-21 10:39:54 +00:00
echo("</td>");
2011-03-21 12:18:26 +00:00
echo("<td align=center>");
echo("<input type=checkbox name='ignore_".$port['interface_id']."'".($port['ignore'] ? 'checked' : '').">");
echo("<input type=hidden name='oldign_".$port['interface_id']."' value=".($port['ignore'] ? 1 : 0).">");
2010-11-20 14:04:07 +00:00
echo("</td>");
2011-03-21 12:18:26 +00:00
echo("<td align=left>".$port['ifAlias'] . "</td>");
2011-03-21 10:39:54 +00:00
2011-04-06 13:54:50 +00:00
echo("</tr>\n");
2011-03-21 12:18:26 +00:00
$row++;
2010-09-03 13:32:11 +00:00
}
echo('</table>');
echo('</form>');
echo('</div>');
2011-05-15 17:20:26 +00:00
?>