2010-04-24 22:43:25 +00:00
< ? php print_optionbar_start ( 50 ); ?>
< table style = " text-align: left; " cellpadding = 0 cellspacing = 5 class = devicetable width = 100 %>
< tr style = 'padding: 0px;' >
< form method = 'post' action = '' >
< td width = '200' >
< select name = 'device_id' id = 'device_id' >
< option value = '' > All Devices </ option >
2011-04-06 13:54:50 +00:00
< ? php
2011-05-20 14:27:53 +00:00
foreach ( dbFetchRows ( " SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname` " ) as $data )
2011-04-06 13:54:50 +00:00
{
echo ( " <option value=' " . $data [ 'device_id' ] . " ' " );
if ( $data [ 'device_id' ] == $_POST [ 'device_id' ]) { echo ( " selected " ); }
echo ( " > " . $data [ 'hostname' ] . " </option> " );
}
?>
2010-04-24 22:43:25 +00:00
</ select >
</ td >
< td width = '150' >
< select name = 'state' id = 'state' >
< option value = '' > All States </ option >
2011-03-17 00:09:20 +00:00
< option value = 'up' < ? php if ( $_POST [ 'state' ] == " up " ) { echo ( " selected " ); } ?> >Up</option>
< option value = 'down' < ? php if ( $_POST [ 'state' ] == " down " ) { echo ( " selected " ); } ?> >Down</option>
< option value = 'admindown' < ? php if ( $_POST [ 'state' ] == " admindown " ) { echo ( " selected " ); } ?> >Shutdown</option>
< option value = 'errors' < ? php if ( $_POST [ 'state' ] == " errors " ) { echo ( " selected " ); } ?> >Errors</option>
< option value = 'ignored' < ? php if ( $_POST [ 'state' ] == " ignored " ) { echo ( " selected " ); } ?> >Ignored</option>
< option value = 'ethernet' < ? php if ( $_POST [ 'state' ] == " ethernet " ) { echo ( " selected " ); } ?> >Ethernet</option>
< option value = 'l2vlan' < ? php if ( $_POST [ 'state' ] == " l2vlan " ) { echo ( " selected " ); } ?> >L2 VLAN</option>
< option value = 'sonet' < ? php if ( $_POST [ 'state' ] == " sonet " ) { echo ( " selected " ); } ?> >SONET</option>
< option value = 'propvirtual' < ? php if ( $_POST [ 'state' ] == " propvirtual " ) { echo ( " selected " ); } ?> >Virtual</option>
< option value = 'ppp' < ? php if ( $_POST [ 'state' ] == " ppp " ) { echo ( " selected " ); } ?> >PPP</option>
< option value = 'loopback' < ? php if ( $_POST [ 'state' ] == " loopback " ) { echo ( " selected " ); } ?> >Loopback</option>
2010-04-24 22:43:25 +00:00
</ select >
</ td >
< td width = 110 >
< select name = 'ifSpeed' id = 'ifSpeed' >
< option value = '' > All Speeds </ option >
2011-04-06 13:54:50 +00:00
< ? php
2011-05-16 09:38:44 +00:00
foreach ( dbFetchRows ( " SELECT `ifSpeed` FROM `ports` GROUP BY `ifSpeed` ORDER BY `ifSpeed` " ) as $data )
2011-04-06 13:54:50 +00:00
{
if ( $data [ 'ifSpeed' ])
{
echo ( " <option value=' " . $data [ 'ifSpeed' ] . " ' " );
if ( $data [ 'ifSpeed' ] == $_POST [ 'ifSpeed' ]) { echo ( " selected " ); }
echo ( " > " . humanspeed ( $data [ 'ifSpeed' ]) . " </option> " );
}
}
?>
2010-04-24 22:43:25 +00:00
</ select >
</ td >
< td width = 200 >
< select name = 'ifType' id = 'ifType' >
< option value = '' > All Media </ option >
2011-04-06 13:54:50 +00:00
< ? php
2011-05-16 09:38:44 +00:00
foreach ( dbFetchRows ( " SELECT `ifType` FROM `ports` GROUP BY `ifType` ORDER BY `ifType` " ) as $data )
2011-04-06 13:54:50 +00:00
{
if ( $data [ 'ifType' ])
{
echo ( " <option value=' " . $data [ 'ifType' ] . " ' " );
if ( $data [ 'ifType' ] == $_POST [ 'ifType' ]) { echo ( " selected " ); }
echo ( " > " . $data [ 'ifType' ] . " </option> " );
}
}
?>
2010-04-24 22:43:25 +00:00
</ select >
</ td >
< td >
2011-03-26 19:28:39 +00:00
< input type = " text " name = " ifAlias " id = " ifAlias " size = 40 value = " <?php echo( $_POST['ifAlias'] ); ?> " />
2011-03-17 00:09:20 +00:00
Deleted < input type = checkbox id = " deleted " name = " deleted " value = 1 < ? php if ( $_POST [ 'deleted' ]) { echo ( " checked " ); } ?> ></input>
2010-04-24 22:43:25 +00:00
</ td >
< td style = " text-align: right; " >
< input style = " align:right; " type = submit class = submit value = Search ></ div >
</ td >
</ form >
</ tr >
</ table >
< ? php print_optionbar_end (); ?>
2011-03-19 01:43:13 +00:00
< table cellpadding = 3 cellspacing = 0 class = " devicetable sortable " width = 100 %>
2010-04-24 22:43:25 +00:00
< ? php
#if ($_SESSION['userlevel'] >= '5') {
# $sql = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id ORDER BY D.hostname, I.ifDescr";
#} else {
# $sql = "SELECT * FROM `ports` AS I, `devices` AS D, `devices_perms` AS P WHERE I.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, I.ifDescr";
#}
2011-05-16 09:38:44 +00:00
$param = array ();
2011-03-25 15:47:42 +00:00
# FIXME block below is not totally used, at least the iftype stuff is bogus?
2011-03-17 00:09:20 +00:00
if ( $_GET [ 'opta' ] == " down " || $_GET [ 'type' ] == " down " || $_POST [ 'state' ] == " down " )
{
$where .= " AND I.ifAdminStatus = 'up' AND I.ifOperStatus = 'down' AND I.ignore = '0' " ;
2010-04-24 22:43:25 +00:00
} elseif ( $_GET [ 'opta' ] == " admindown " || $_GET [ 'type' ] == " admindown " || $_POST [ 'state' ] == " admindown " ) {
$where .= " AND I.ifAdminStatus = 'down' " ;
} elseif ( $_GET [ 'opta' ] == " errors " || $_GET [ 'type' ] == " errors " || $_POST [ 'state' ] == " errors " ) {
2011-03-18 11:27:52 +00:00
$where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0') " ;
2010-04-24 22:43:25 +00:00
} elseif ( $_GET [ 'type' ] == " up " || $_POST [ 'state' ] == " up " ) {
$where .= " AND I.ifOperStatus = 'up' " ;
} elseif ( $_GET [ 'opta' ] == " ignored " || $_GET [ 'type' ] == " ignored " || $_POST [ 'state' ] == " ignored " ) {
$where .= " AND I.ignore = '1' " ;
} elseif ( $_GET [ 'type' ] == " l2vlan " || $_POST [ 'state' ] == " l2vlan " ) {
$where .= " AND I.ifType = 'l2vlan' " ;
} elseif ( $_GET [ 'type' ] == " ethernet " || $_POST [ 'state' ] == " ethernet " ) {
$where .= " AND I.ifType = 'ethernetCsmacd' " ;
} elseif ( $_GET [ 'type' ] == " loopback " || $_POST [ 'state' ] == " loopback " ) {
$where .= " AND I.ifType = 'softwareLoopback' " ;
} elseif ( $_GET [ 'typee' ] == " sonet " || $_POST [ 'state' ] == " sonet " ) {
$where .= " AND I.ifType = 'sonet' " ;
} elseif ( $_POST [ 'state' ] == " propvirtual " ) {
$where .= " AND I.ifType = 'propVirtual' " ;
} elseif ( $_POST [ 'state' ] == " ppp " ) {
$where .= " AND I.ifType = 'ppp' " ;
}
2011-05-16 09:38:44 +00:00
if ( is_numeric ( $_POST [ 'device_id' ]))
{
$where .= " AND I.device_id = ? " ;
$param [] = $_POST [ 'device_id' ];
}
if ( $_POST [ 'ifType' ])
{
$where .= " AND I.ifType = ? " ;
$param [] = $_POST [ 'ifType' ];
}
if ( is_numeric ( $_POST [ 'ifSpeed' ]))
{
$where .= " AND I.ifSpeed = ? " ;
$param [] = $_POST [ 'ifSpeed' ];
}
if ( $_POST [ 'ifAlias' ]) {
$where .= " AND I.ifAlias LIKE ? " ;
$param [] = " % " . $_POST [ 'ifAlias' ] . " % " ;
}
2011-03-17 00:09:20 +00:00
if ( $_POST [ 'deleted' ] || $_GET [ 'type' ] == " deleted " ) { $where .= " AND I.deleted = '1' " ; }
2010-04-24 22:43:25 +00:00
2011-05-16 09:38:44 +00:00
$query = " SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id " . $where . " ORDER BY D.hostname, I.ifIndex " ;
2010-04-24 22:43:25 +00:00
echo ( " <tr class=tablehead><td></td><th>Device</a></th><th>Interface</th><th>Speed</th><th>Media</th><th>Description</th></tr> " );
$row = 1 ;
2011-05-16 09:38:44 +00:00
foreach ( dbFetchRows ( $query , $param ) as $interface )
2011-03-17 00:09:20 +00:00
{
if ( is_integer ( $row / 2 )) { $row_colour = $list_colour_a ; } else { $row_colour = $list_colour_b ; }
2010-04-24 22:43:25 +00:00
$speed = humanspeed ( $interface [ 'ifSpeed' ]);
$type = humanmedia ( $interface [ 'ifType' ]);
2011-03-17 00:09:20 +00:00
if ( $interface [ 'in_errors' ] > 0 || $interface [ 'out_errors' ] > 0 )
{
2010-08-02 22:09:52 +00:00
$error_img = generate_port_link ( $interface , " <img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0> " , errors );
2010-04-24 22:43:25 +00:00
} else { $error_img = " " ; }
2011-03-17 00:09:20 +00:00
if ( port_permitted ( $interface [ 'interface_id' ], $interface [ 'device_id' ]))
2010-04-24 22:43:25 +00:00
{
$interface = ifLabel ( $interface , $device );
echo ( " <tr bgcolor= $row_colour >
< td width = 5 ></ td >
2010-08-02 22:09:52 +00:00
< td width = 200 class = list - bold > " . generate_device_link( $interface ) . " </ td >
< td width = 150 class = list - bold > " . generate_port_link( $interface ) . " $error_img </ td >
2010-04-24 22:43:25 +00:00
< td width = 110 > $speed </ td >
< td width = 200 > $type </ td >
< td > " . $interface['ifAlias'] . " </ td >
</ tr > \n " );
$row ++ ;
}
}
echo ( " </table> " );
2011-03-19 01:43:13 +00:00
?>