2011-12-15 22:36:53 +00:00
< ? php
2012-05-16 13:25:50 +00:00
$vlans = dbFetchRows ( " SELECT * FROM `ports_vlans` AS PV, vlans AS V WHERE PV.`port_id` = ' " . $port [ 'port_id' ] . " ' and PV.`device_id` = ' " . $device [ 'device_id' ] . " ' AND V.`vlan_vlan` = PV.vlan AND V.device_id = PV.device_id " );
2011-12-15 22:36:53 +00:00
echo ( '<table border="0" cellspacing="0" cellpadding="5" width="100%">' );
2011-12-15 23:14:50 +00:00
echo ( " <tr><th>VLAN</th><th>Description</th><th>Cost</th><th>Priority</th><th>State</th><th>Other Ports</th></tr> " );
2011-12-15 22:36:53 +00:00
$row = 0 ;
2012-04-06 13:56:23 +00:00
foreach ( $vlans as $vlan )
2011-12-15 22:36:53 +00:00
{
$row ++ ;
if ( is_integer ( $row / 2 )) { $row_colour = $list_colour_a ; } else { $row_colour = $list_colour_b ; }
echo ( '<tr bgcolor="' . $row_colour . '">' );
echo ( " <td width=100 class=list-large> Vlan " . $vlan [ 'vlan' ] . " </td> " );
echo ( " <td width=200 class=box-desc> " . $vlan [ 'vlan_descr' ] . " </td> " );
2012-04-06 13:56:23 +00:00
if ( $vlan [ 'state' ] == " blocking " ) { $class = " red " ; } elseif ( $vlan [ 'state' ] == " forwarding " ) { $class = " green " ; } else { $class = " none " ; }
2011-12-16 14:42:37 +00:00
echo ( " <td> " . $vlan [ 'cost' ] . " </td><td> " . $vlan [ 'priority' ] . " </td><td class= $class > " . $vlan [ 'state' ] . " </td> " );
2011-12-15 22:36:53 +00:00
$vlan_ports = array ();
2012-05-16 13:25:50 +00:00
$otherports = dbFetchRows ( " SELECT * FROM `ports_vlans` AS V, `ports` as P WHERE V.`device_id` = ? AND V.`vlan` = ? AND P.port_id = V.port_id " , array ( $device [ 'device_id' ], $vlan [ 'vlan' ]));
2012-04-06 13:56:23 +00:00
foreach ( $otherports as $otherport )
2011-12-15 22:36:53 +00:00
{
$vlan_ports [ $otherport [ ifIndex ]] = $otherport ;
}
$otherports = dbFetchRows ( " SELECT * FROM ports WHERE `device_id` = ? AND `ifVlan` = ? " , array ( $device [ 'device_id' ], $vlan [ 'vlan' ]));
2012-04-06 13:56:23 +00:00
foreach ( $otherports as $otherport )
2011-12-15 22:36:53 +00:00
{
2011-12-15 23:14:50 +00:00
$vlan_ports [ $otherport [ ifIndex ]] = array_merge ( $otherport , array ( 'untagged' => '1' ));
2011-12-15 22:36:53 +00:00
}
ksort ( $vlan_ports );
echo ( " <td> " );
$vsep = '' ;
2012-04-06 13:56:23 +00:00
foreach ( $vlan_ports as $otherport )
2011-12-15 22:36:53 +00:00
{
echo ( $vsep . generate_port_link ( $otherport , makeshortif ( $otherport [ 'ifDescr' ])));
2012-04-06 13:56:23 +00:00
if ( $otherport [ 'untagged' ]) { echo ( " (U) " ); }
2011-12-15 22:36:53 +00:00
$vsep = " , " ;
}
echo ( " </td> " );
echo ( " </tr> " );
}
echo ( " </table> " );
?>