2010-02-07 14:17:02 +00:00
< ? php print_optionbar_start ( 28 ); ?>
2009-08-12 15:01:01 +00:00
< table cellpadding = 0 cellspacing = 0 class = devicetable width = 100 %>
< tr >
2009-08-05 16:05:14 +00:00
< form method = 'post' action = '' >
2009-08-12 15:01:01 +00:00
< td width = '200' style = " padding: 1px; " >
2009-08-05 16:05:14 +00:00
< select name = 'device_id' id = 'device_id' >
< option value = '' > All Devices </ option >
< ? php
$query = mysql_query ( " SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hostname` ORDER BY `hostname` " );
while ( $data = mysql_fetch_array ( $query )) {
echo ( " <option value=' " . $data [ 'device_id' ] . " ' " );
if ( $data [ 'device_id' ] == $_POST [ 'device_id' ]) { echo ( " selected " ); }
echo ( " > " . $data [ 'hostname' ] . " </option> " );
}
?>
</ select >
</ td >
2009-08-12 15:01:01 +00:00
< td width = '200' style = " padding: 1px; " >
2009-08-05 16:05:14 +00:00
< select name = 'interface' id = 'interface' >
< option value = '' > All Interfaces </ option >
< option value = 'Loopback%' < ? php if ( $_POST [ 'interface' ] == " Loopback% " ){ echo ( " selected " );} ?> >Loopbacks</option>
< option value = 'Vlan%' < ? php if ( $_POST [ 'interface' ] == " Vlan% " ){ echo ( " selected " );} ?> >VLANs</option>
</ select >
</ td >
< td >
</ td >
< td width = 400 >
< input type = " text " name = " address " id = " address " size = 40 value = " <?php echo( $_POST['address'] ); ?> " />
2010-02-07 14:17:02 +00:00
< input style = " align:right; " type = submit class = submit value = Search ></ div >
2009-08-05 16:05:14 +00:00
</ td >
</ form >
</ tr >
</ table >
< ? php
2010-02-07 14:17:02 +00:00
print_optionbar_end ();
2009-10-12 09:48:40 +00:00
echo ( " <table width=100% cellspacing=0 cellpadding=2> " );
2009-08-05 16:05:14 +00:00
if ( $_POST [ 'device_id' ]) { $where .= " AND I.device_id = ' " . $_POST [ 'device_id' ] . " ' " ; }
if ( $_POST [ 'interface' ]) { $where .= " AND I.ifDescr LIKE ' " . $_POST [ 'interface' ] . " ' " ; }
2010-02-20 17:22:22 +00:00
$sql = " SELECT * FROM `ipv4_addresses` AS A, `ports` AS I, `devices` AS D, `ipv4_networks` AS N WHERE I.interface_id = A.interface_id AND I.device_id = D.device_id AND N.ipv4_network_id = A.ipv4_network_id $where ORDER BY A.ipv4_address " ;
2009-08-05 16:05:14 +00:00
$query = mysql_query ( $sql );
2009-10-12 09:48:40 +00:00
echo ( " <tr class=tablehead><th>Device</a></th><th>Interface</th><th>Address</th><th>Description</th></tr> " );
2009-08-05 16:05:14 +00:00
$row = 1 ;
while ( $interface = mysql_fetch_array ( $query )) {
if ( $_POST [ 'address' ]) {
list ( $addy , $mask ) = explode ( " / " , $_POST [ 'address' ]);
2009-08-11 16:24:50 +00:00
if ( ! $mask ) { $mask = " 32 " ; }
2009-08-05 16:05:14 +00:00
if ( ! match_network ( $addy . " / " . $mask , $interface [ 'ipv4_address' ] )) { $ignore = 1 ; }
}
2009-10-12 09:48:40 +00:00
if ( ! $ignore ) {
2009-08-05 16:05:14 +00:00
if ( is_integer ( $row / 2 )) { $row_colour = $list_colour_a ; } else { $row_colour = $list_colour_b ; }
$speed = humanspeed ( $interface [ 'ifSpeed' ]);
$type = humanmedia ( $interface [ 'ifType' ]);
2009-10-12 09:48:40 +00:00
list ( $prefix , $length ) = explode ( " / " , $interface [ 'ipv4_network' ]);
2009-08-05 16:05:14 +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 );
2009-08-05 16:05:14 +00:00
} else { $error_img = " " ; }
2010-08-01 14:17:06 +00:00
if ( port_permitted ( $interface [ 'interface_id' ]) )
2009-08-05 16:05:14 +00:00
{
2010-01-03 20:13:10 +00:00
echo ( '<tr bgcolor="' . $row_colour . ' " >
2010-08-02 22:09:52 +00:00
< td class = " list-bold " > ' . generate_device_link($interface) . ' </ td >
< td class = " list-bold " > ' . generate_port_link($interface, makeshortif(fixifname($interface[' ifDescr ']))) . ' ' . $error_img . ' </ td >
2010-01-03 20:13:10 +00:00
< td > ' . $interface[' ipv4_address '] . ' / '.$length.' </ td >
< td > ' . $interface[' ifAlias ' ] . " </td>
2009-08-05 16:05:14 +00:00
</ tr > \n " );
$row ++ ;
}
}
unset ( $ignore );
}
echo ( " </table> " );
?>