Apply "Squiz" code style on old (pre-2014) files

This commit is contained in:
Job Snijders
2015-07-10 13:36:21 +02:00
parent e4f4eb44dc
commit ebd0f6fc35
539 changed files with 13591 additions and 13223 deletions

View File

@@ -2,107 +2,133 @@
print_optionbar_start();
$link_array = array('page' => 'device',
'device' => $device['device_id'],
'tab' => 'routing',
'proto' => 'cef');
$link_array = array(
'page' => 'device',
'device' => $device['device_id'],
'tab' => 'routing',
'proto' => 'cef',
);
if(!isset($vars['view'])) { $vars['view'] = "basic"; }
if (!isset($vars['view'])) {
$vars['view'] = 'basic';
}
echo('<span style="font-weight: bold;">CEF</span> &#187; ');
echo '<span style="font-weight: bold;">CEF</span> &#187; ';
if ($vars['view'] == "basic") { echo("<span class='pagemenu-selected'>"); }
echo(generate_link("Basic", $link_array,array('view'=>'basic')));
if ($vars['view'] == "basic") { echo("</span>"); }
if ($vars['view'] == 'basic') {
echo "<span class='pagemenu-selected'>";
}
echo(" | ");
echo generate_link('Basic', $link_array, array('view' => 'basic'));
if ($vars['view'] == 'basic') {
echo '</span>';
}
if ($vars['view'] == "graphs") { echo("<span class='pagemenu-selected'>"); }
echo(generate_link("Graphs", $link_array,array('view'=>'graphs')));
if ($vars['view'] == "graphs") { echo("</span>"); }
echo ' | ';
if ($vars['view'] == 'graphs') {
echo "<span class='pagemenu-selected'>";
}
echo generate_link('Graphs', $link_array, array('view' => 'graphs'));
if ($vars['view'] == 'graphs') {
echo '</span>';
}
print_optionbar_end();
echo('<div id="content">
<table border="0" cellspacing="0" cellpadding="5" width="100%">');
echo '<div id="content">
<table border="0" cellspacing="0" cellpadding="5" width="100%">';
echo('<tr><th><a title="Physical hardware entity">Entity</a></th>
<th><a title="Address Family">AFI</a></th>
<th><a title="CEF Switching Path">Path</a></th>
<th><a title="Number of packets dropped.">Drop</a></th>
<th><a title="Number of packets that could not be switched in the normal path and were punted to the next-fastest switching vector.">Punt</a></th>
<th><a title="Number of packets that could not be switched in the normal path and were punted to the host.<br />For switch paths other than a centralized turbo switch path, punt and punt2host function the same way. With punt2host from a centralized turbo switch path (PAS and RSP), punt will punt the packet to LES, but punt2host will bypass LES and punt directly to process switching.">Punt2Host</a></th>
</tr>');
echo '<tr><th><a title="Physical hardware entity">Entity</a></th>
<th><a title="Address Family">AFI</a></th>
<th><a title="CEF Switching Path">Path</a></th>
<th><a title="Number of packets dropped.">Drop</a></th>
<th><a title="Number of packets that could not be switched in the normal path and were punted to the next-fastest switching vector.">Punt</a></th>
<th><a title="Number of packets that could not be switched in the normal path and were punted to the host.<br />For switch paths other than a centralized turbo switch path, punt and punt2host function the same way. With punt2host from a centralized turbo switch path (PAS and RSP), punt will punt the packet to LES, but punt2host will bypass LES and punt directly to process switching.">Punt2Host</a></th>
</tr>';
$i=0;
$i = 0;
foreach (dbFetchRows("SELECT * FROM `cef_switching` WHERE `device_id` = ? ORDER BY `entPhysicalIndex`, `afi`, `cef_index`", array($device['device_id'])) as $cef)
{
foreach (dbFetchRows('SELECT * FROM `cef_switching` WHERE `device_id` = ? ORDER BY `entPhysicalIndex`, `afi`, `cef_index`', array($device['device_id'])) as $cef) {
$entity = dbFetchRow('SELECT * FROM `entPhysical` WHERE device_id = ? AND `entPhysicalIndex` = ?', array($device['device_id'], $cef['entPhysicalIndex']));
$entity = dbFetchRow("SELECT * FROM `entPhysical` WHERE device_id = ? AND `entPhysicalIndex` = ?", array($device['device_id'], $cef['entPhysicalIndex']));
if (!is_integer($i / 2)) {
$bg_colour = $list_colour_a;
}
else {
$bg_colour = $list_colour_b;
}
if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
$interval = ($cef['updated'] - $cef['updated_prev']);
$interval = $cef['updated'] - $cef['updated_prev'];
if (!$entity['entPhysicalModelName'] && $entity['entPhysicalContainedIn']) {
$parent_entity = dbFetchRow('SELECT * FROM `entPhysical` WHERE device_id = ? AND `entPhysicalIndex` = ?', array($device['device_id'], $entity['entPhysicalContainedIn']));
$entity_descr = $entity['entPhysicalName'].' ('.$parent_entity['entPhysicalModelName'].')';
}
else {
$entity_descr = $entity['entPhysicalName'].' ('.$entity['entPhysicalModelName'].')';
}
if (!$entity['entPhysicalModelName'] && $entity['entPhysicalContainedIn'])
{
$parent_entity = dbFetchRow("SELECT * FROM `entPhysical` WHERE device_id = ? AND `entPhysicalIndex` = ?", array($device['device_id'], $entity['entPhysicalContainedIn']));
$entity_descr = $entity['entPhysicalName'] . " (" . $parent_entity['entPhysicalModelName'] .")";
} else {
$entity_descr = $entity['entPhysicalName'] . " (" . $entity['entPhysicalModelName'] .")";
}
echo "<tr bgcolor=$bg_colour><td>".$entity_descr.'</td>
<td>'.$cef['afi'].'</td>
<td>';
echo("<tr bgcolor=$bg_colour><td>".$entity_descr."</td>
<td>".$cef['afi']."</td>
<td>");
switch ($cef['cef_path']) {
case 'RP RIB':
echo '<a title="Process switching with CEF assistance.">RP RIB</a>';
break;
case 'RP LES':
echo '<a title="Low-end switching. Centralized CEF switch path.">RP LES</a>';
break;
case 'RP PAS':
echo '<a title="CEF turbo switch path.">RP PAS</a>';
break;
switch ($cef['cef_path']) {
case "RP RIB":
echo '<a title="Process switching with CEF assistance.">RP RIB</a>';
break;
case "RP LES":
echo '<a title="Low-end switching. Centralized CEF switch path.">RP LES</a>';
break;
case "RP PAS":
echo '<a title="CEF turbo switch path.">RP PAS</a>';
break;
default:
echo $cef['cef_path'];
}
echo $cef['cef_path'];
}
echo("</td>");
echo("<td>".format_si($cef['drop']));
if ($cef['drop'] > $cef['drop_prev']) { echo(" <span style='color:red;'>(".round(($cef['drop']-$cef['drop_prev'])/$interval,2)."/sec)</span>"); }
echo("</td>");
echo("<td>".format_si($cef['punt']));
if ($cef['punt'] > $cef['punt_prev']) { echo(" <span style='color:red;'>(".round(($cef['punt']-$cef['punt_prev'])/$interval,2)."/sec)</span>"); }
echo("</td>");
echo("<td>".format_si($cef['punt2host']));
if ($cef['punt2host'] > $cef['punt2host_prev']) { echo(" <span style='color:red;'>(".round(($cef['punt2host']-$cef['punt2host_prev'])/$interval,2)."/sec)</span>"); }
echo("</td>");
echo '</td>';
echo '<td>'.format_si($cef['drop']);
if ($cef['drop'] > $cef['drop_prev']) {
echo (" <span style='color:red;'>(".round((($cef['drop'] - $cef['drop_prev']) / $interval), 2).'/sec)</span>');
}
echo("</tr>
");
echo '</td>';
echo '<td>'.format_si($cef['punt']);
if ($cef['punt'] > $cef['punt_prev']) {
echo (" <span style='color:red;'>(".round((($cef['punt'] - $cef['punt_prev']) / $interval), 2).'/sec)</span>');
}
if ($vars['view'] == "graphs")
{
$graph_array['height'] = "100";
$graph_array['width'] = "215";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $cef['cef_switching_id'];
$graph_array['type'] = "cefswitching_graph";
echo '</td>';
echo '<td>'.format_si($cef['punt2host']);
if ($cef['punt2host'] > $cef['punt2host_prev']) {
echo (" <span style='color:red;'>(".round((($cef['punt2host'] - $cef['punt2host_prev']) / $interval), 2).'/sec)</span>');
}
echo("<tr bgcolor='$bg_colour'><td colspan=6>");
echo '</td>';
include("includes/print-graphrow.inc.php");
echo '</tr>
';
echo("</td></tr>");
}
if ($vars['view'] == 'graphs') {
$graph_array['height'] = '100';
$graph_array['width'] = '215';
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $cef['cef_switching_id'];
$graph_array['type'] = 'cefswitching_graph';
$i++;
echo "<tr bgcolor='$bg_colour'><td colspan=6>";
include 'includes/print-graphrow.inc.php';
echo '</td></tr>';
}
$i++;
}
echo("</table></div>");
?>
echo '</table></div>';

View File

@@ -1,93 +1,114 @@
<?php
$link_array = array('page' => 'device',
'device' => $device['device_id'],
'tab' => 'routing',
'proto' => 'ipsec_tunnels');
$link_array = array(
'page' => 'device',
'device' => $device['device_id'],
'tab' => 'routing',
'proto' => 'ipsec_tunnels',
);
print_optionbar_start();
echo("<span style='font-weight: bold;'>IPSEC Tunnels</span> &#187; ");
echo "<span style='font-weight: bold;'>IPSEC Tunnels</span> &#187; ";
$menu_options = array('basic' => 'Basic',
);
$menu_options = array('basic' => 'Basic');
if(!isset($vars['view'])) { $vars['view'] = "basic"; }
echo("<span style='font-weight: bold;'>VRFs</span> &#187; ");
$menu_options = array('basic' => 'Basic',
# 'detail' => 'Detail',
);
if (!$_GET['opta']) { $_GET['opta'] = "basic"; }
$sep = "";
foreach ($menu_options as $option => $text)
{
if ($vars['view'] == $option) { echo("<span class='pagemenu-selected'>"); }
echo(generate_link($text, $link_array,array('view'=>$option)));
if ($vars['view'] == $option) { echo("</span>"); }
echo(" | ");
if (!isset($vars['view'])) {
$vars['view'] = 'basic';
}
echo(' Graphs: ');
echo "<span style='font-weight: bold;'>VRFs</span> &#187; ";
$graph_types = array("bits" => "Bits",
"pkts" => "Packets");
$menu_options = array('basic' => 'Basic',
// 'detail' => 'Detail',
);
foreach ($graph_types as $type => $descr)
{
echo("$type_sep");
if ($vars['graph'] == $type) { echo("<span class='pagemenu-selected'>"); }
echo(generate_link($descr, $link_array,array('view'=>'graphs','graph'=>$type)));
if ($vars['graph'] == $type) { echo("</span>"); }
if (!$_GET['opta']) {
$_GET['opta'] = 'basic';
}
$type_sep = " | ";
$sep = '';
foreach ($menu_options as $option => $text) {
if ($vars['view'] == $option) {
echo "<span class='pagemenu-selected'>";
}
echo generate_link($text, $link_array, array('view' => $option));
if ($vars['view'] == $option) {
echo '</span>';
}
echo ' | ';
}
echo ' Graphs: ';
$graph_types = array(
'bits' => 'Bits',
'pkts' => 'Packets',
);
foreach ($graph_types as $type => $descr) {
echo "$type_sep";
if ($vars['graph'] == $type) {
echo "<span class='pagemenu-selected'>";
}
echo generate_link($descr, $link_array, array('view' => 'graphs', 'graph' => $type));
if ($vars['graph'] == $type) {
echo '</span>';
}
$type_sep = ' | ';
}
print_optionbar_end();
echo("<div style='margin: 5px;'><table border=0 cellspacing=0 cellpadding=0 width=100%>");
$i = "0";
foreach (dbFetchRows("SELECT * FROM `ipsec_tunnels` WHERE `device_id` = ? ORDER BY `peer_addr`", array($device['device_id'])) as $tunnel)
{
echo "<div style='margin: 5px;'><table border=0 cellspacing=0 cellpadding=0 width=100%>";
$i = '0';
foreach (dbFetchRows('SELECT * FROM `ipsec_tunnels` WHERE `device_id` = ? ORDER BY `peer_addr`', array($device['device_id'])) as $tunnel) {
if (is_integer($i / 2)) {
$bg_colour = $list_colour_a;
}
else {
$bg_colour = $list_colour_b;
}
if (is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
if ($tunnel['tunnel_status'] == 'active') {
$tunnel_class = 'green';
}
else {
$tunnel_class = 'red';
}
if($tunnel['tunnel_status'] == "active") { $tunnel_class="green"; } else { $tunnel_class="red"; }
echo "<tr bgcolor='$bg_colour'>";
echo '<td width=320 class=list-large>'.$tunnel['local_addr'].' &#187; '.$tunnel['peer_addr'].'</a></td>';
echo '<td width=150 class=box-desc>'.$tunnel['tunnel_name'].'</td>';
echo "<td width=100 class=list-large><span class='".$tunnel_class."'>".$tunnel['tunnel_status'].'</span></td>';
echo '</tr>';
if (isset($vars['graph'])) {
echo '<tr class="list-bold">';
echo '<td colspan = 3>';
$graph_type = 'ipsectunnel_'.$vars['graph'];
echo("<tr bgcolor='$bg_colour'>");
echo("<td width=320 class=list-large>" . $tunnel['local_addr'] . " &#187; " . $tunnel['peer_addr'] . "</a></td>");
echo("<td width=150 class=box-desc>" . $tunnel['tunnel_name'] . "</td>");
echo("<td width=100 class=list-large><span class='".$tunnel_class."'>" . $tunnel['tunnel_status'] . "</span></td>");
echo("</tr>");
if (isset($vars['graph']))
{
echo('<tr class="list-bold">');
echo("<td colspan = 3>");
$graph_type = "ipsectunnel_" . $vars['graph'];
$graph_array['height'] = '100';
$graph_array['width'] = '215';
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $tunnel['tunnel_id'];
$graph_array['type'] = $graph_type;
$graph_array['height'] = "100";
$graph_array['width'] = "215";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $tunnel['tunnel_id'];
$graph_array['type'] = $graph_type;
include 'includes/print-graphrow.inc.php';
include("includes/print-graphrow.inc.php");
echo("
echo '
</td>
</tr>");
}
</tr>';
}
echo("</td>");
echo("</tr>");
echo '</td>';
echo '</tr>';
$i++;
}
$i++;
}//end foreach
echo("</table></div>");
?>
echo '</table></div>';

View File

@@ -1,148 +1,193 @@
<?php
$i_i = "0";
$i_i = '0';
echo('<table width=100% border=0 cellpadding=5>');
echo '<table width=100% border=0 cellpadding=5>';
// Loop Instances
foreach (dbFetchRows("SELECT * FROM `ospf_instances` WHERE `device_id` = ?", array($device['device_id'])) as $instance)
{
if (!is_integer($i_i/2)) { $instance_bg = $list_colour_a; } else { $instance_bg = $list_colour_b; }
$area_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = ?", array($device['device_id']));
$port_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ?", array($device['device_id']));
$port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = ?", array($device['device_id']));
$nbr_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_nbrs` WHERE `device_id` = ?", array($device['device_id']));
$query = "SELECT * FROM ipv4_addresses AS A, ports AS I WHERE ";
$query .= "(A.ipv4_address = ? AND I.port_id = A.port_id)";
$query .= " AND I.device_id = ?";
$ipv4_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'], $device['device_id']));
if ($instance['ospfAdminStat'] == "enabled") { $enabled = '<span style="color: #00aa00">enabled</span>'; } else { $enabled = '<span style="color: #aaaaaa">disabled</span>'; }
if ($instance['ospfAreaBdrRtrStatus'] == "true") { $abr = '<span style="color: #00aa00">yes</span>'; } else { $abr = '<span style="color: #aaaaaa">no</span>'; }
if ($instance['ospfASBdrRtrStatus'] == "true") { $asbr = '<span style="color: #00aa00">yes</span>'; } else { $asbr = '<span style="color: #aaaaaa">no</span>'; }
echo('<tr><th>Router Id</th><th>Status</th><th>ABR</th><th>ASBR</th><th>Areas</th><th>Ports</th><th>Neighbours</th></tr>');
echo('<tr bgcolor="'.$instance_bg.'">');
echo(' <td class="list-large">'.$instance['ospfRouterId'] . '</td>');
echo(' <td>' . $enabled . '</td>');
echo(' <td>' . $abr . '</td>');
echo(' <td>' . $asbr . '</td>');
echo(' <td>' . $area_count . '</td>');
echo(' <td>' . $port_count . '('.$port_count_enabled.')</td>');
echo(' <td>' . $nbr_count . '</td>');
echo('</tr>');
echo('<tr bgcolor="'.$instance_bg.'">');
echo('<td colspan=7>');
echo('<table width=100% border=0 cellpadding=5>');
echo('<tr><th></th><th>Area Id</th><th>Status</th><th>Ports</th></tr>');
///# Loop Areas
$i_a = 0;
foreach (dbFetchRows("SELECT * FROM `ospf_areas` WHERE `device_id` = ?", array($device['device_id'])) as $area)
{
if (!is_integer($i_a/2)) { $area_bg = $list_colour_b_a; } else { $area_bg = $list_colour_b_b; }
$area_port_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ? AND `ospfIfAreaId` = ?", array($device['device_id'], $area['ospfAreaId']));
$area_port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = ? AND `ospfIfAreaId` = ?", array($device['device_id'], $area['ospfAreaId']));
echo('<tr bgcolor="'.$area_bg.'">');
echo(' <td width=5></td>');
echo(' <td class="list-large">'.$area['ospfAreaId'] . '</td>');
echo(' <td>' . $enabled . '</td>');
echo(' <td>' . $area_port_count . '('.$area_port_count_enabled.')</td>');
echo('</tr>');
echo('<tr bgcolor="'.$area_bg.'">');
echo('<td colspan=7>');
echo('<table width=100% border=0 cellpadding=5>');
echo('<tr><th></th><th>Port</th><th>Status</th><th>Port Type</th><th>Port State</th></tr>');
///# Loop Ports
$i_p = $i_a + 1;
$p_sql = "SELECT * FROM `ospf_ports` AS O, `ports` AS P WHERE O.`ospfIfAdminStat` = 'enabled' AND O.`device_id` = ? AND O.`ospfIfAreaId` = ? AND P.port_id = O.port_id";
foreach (dbFetchRows($p_sql, array($device['device_id'], $area['ospfAreaId'])) as $ospfport)
{
if (!is_integer($i_a/2))
{
if (!is_integer($i_p/2)) { $port_bg = $list_colour_b_b; } else { $port_bg = $list_colour_b_a; }
} else {
if (!is_integer($i_p/2)) { $port_bg = $list_colour_a_b; } else { $port_bg = $list_colour_a_a; }
}
if ($ospfport['ospfIfAdminStat'] == "enabled")
{
$port_enabled = '<span style="color: #00aa00">enabled</span>';
} else {
$port_enabled = '<span style="color: #aaaaaa">disabled</span>';
}
echo('<tr bgcolor="'.$port_bg.'">');
echo(' <td width=15></td>');
echo(' <td><strong>'. generate_port_link($ospfport) . '</strong></td>');
echo(' <td>' . $port_enabled . '</td>');
echo(' <td>' . $ospfport['ospfIfType'] . '</td>');
echo(' <td>' . $ospfport['ospfIfState'] . '</td>');
echo('</tr>');
$i_p++;
foreach (dbFetchRows('SELECT * FROM `ospf_instances` WHERE `device_id` = ?', array($device['device_id'])) as $instance) {
if (!is_integer($i_i / 2)) {
$instance_bg = $list_colour_a;
}
else {
$instance_bg = $list_colour_b;
}
echo('</table>');
echo('</td>');
echo('</tr>');
$area_count = dbFetchCell('SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = ?', array($device['device_id']));
$port_count = dbFetchCell('SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ?', array($device['device_id']));
$port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = ?", array($device['device_id']));
$nbr_count = dbFetchCell('SELECT COUNT(*) FROM `ospf_nbrs` WHERE `device_id` = ?', array($device['device_id']));
$i_a++;
} // End loop areas
$query = 'SELECT * FROM ipv4_addresses AS A, ports AS I WHERE ';
$query .= '(A.ipv4_address = ? AND I.port_id = A.port_id)';
$query .= ' AND I.device_id = ?';
$ipv4_host = dbFetchRow($query, array($peer['bgpPeerIdentifier'], $device['device_id']));
echo('<tr bgcolor="#ffffff"><th></th><th>Router Id</th><th>Device</th><th>IP Address</th><th>Status</th></tr>');
// Loop Neigbours
$i_n = 1;
foreach (dbFetchRows("SELECT * FROM `ospf_nbrs` WHERE `device_id` = ?", array($device['device_id'])) as $nbr)
{
if (!is_integer($i_n/2)) { $nbr_bg = $list_colour_b_a; } else { $nbr_bg = $list_colour_b_b; }
$host = @dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ?
AND I.port_id = A.port_id AND D.device_id = I.device_id", array($nbr['ospfNbrRtrId']));
if (is_array($host)) { $rtr_id = generate_device_link($host); } else { $rtr_id = "unknown"; }
echo('<tr bgcolor="'.$nbr_bg.'">');
echo(' <td width=5></td>');
echo(' <td><span class="list-large">' . $nbr['ospfNbrRtrId'] . '</span></td>');
echo(' <td>' . $rtr_id . '</td>');
echo(' <td>' . $nbr['ospfNbrIpAddr'] . '</td>');
echo(' <td>');
switch ($nbr['ospfNbrState'])
{
case 'full':
echo('<span class=green>'.$nbr['ospfNbrState'].'</span>');
break;
case 'down':
echo('<span class=red>'.$nbr['ospfNbrState'].'</span>');
break;
default:
echo('<span class=blue>'.$nbr['ospfNbrState'].'</span>');
break;
if ($instance['ospfAdminStat'] == 'enabled') {
$enabled = '<span style="color: #00aa00">enabled</span>';
}
else {
$enabled = '<span style="color: #aaaaaa">disabled</span>';
}
echo('</td>');
echo('</tr>');
$i_n++;
if ($instance['ospfAreaBdrRtrStatus'] == 'true') {
$abr = '<span style="color: #00aa00">yes</span>';
}
else {
$abr = '<span style="color: #aaaaaa">no</span>';
}
}
if ($instance['ospfASBdrRtrStatus'] == 'true') {
$asbr = '<span style="color: #00aa00">yes</span>';
}
else {
$asbr = '<span style="color: #aaaaaa">no</span>';
}
echo('</table>');
echo('</td>');
echo('</tr>');
echo '<tr><th>Router Id</th><th>Status</th><th>ABR</th><th>ASBR</th><th>Areas</th><th>Ports</th><th>Neighbours</th></tr>';
echo '<tr bgcolor="'.$instance_bg.'">';
echo ' <td class="list-large">'.$instance['ospfRouterId'].'</td>';
echo ' <td>'.$enabled.'</td>';
echo ' <td>'.$abr.'</td>';
echo ' <td>'.$asbr.'</td>';
echo ' <td>'.$area_count.'</td>';
echo ' <td>'.$port_count.'('.$port_count_enabled.')</td>';
echo ' <td>'.$nbr_count.'</td>';
echo '</tr>';
$i_i++;
} // End loop instances
echo '<tr bgcolor="'.$instance_bg.'">';
echo '<td colspan=7>';
echo '<table width=100% border=0 cellpadding=5>';
echo '<tr><th></th><th>Area Id</th><th>Status</th><th>Ports</th></tr>';
echo('</table>');
// # Loop Areas
$i_a = 0;
foreach (dbFetchRows('SELECT * FROM `ospf_areas` WHERE `device_id` = ?', array($device['device_id'])) as $area) {
if (!is_integer($i_a / 2)) {
$area_bg = $list_colour_b_a;
}
else {
$area_bg = $list_colour_b_b;
}
?>
$area_port_count = dbFetchCell('SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ? AND `ospfIfAreaId` = ?', array($device['device_id'], $area['ospfAreaId']));
$area_port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = ? AND `ospfIfAreaId` = ?", array($device['device_id'], $area['ospfAreaId']));
echo '<tr bgcolor="'.$area_bg.'">';
echo ' <td width=5></td>';
echo ' <td class="list-large">'.$area['ospfAreaId'].'</td>';
echo ' <td>'.$enabled.'</td>';
echo ' <td>'.$area_port_count.'('.$area_port_count_enabled.')</td>';
echo '</tr>';
echo '<tr bgcolor="'.$area_bg.'">';
echo '<td colspan=7>';
echo '<table width=100% border=0 cellpadding=5>';
echo '<tr><th></th><th>Port</th><th>Status</th><th>Port Type</th><th>Port State</th></tr>';
// # Loop Ports
$i_p = ($i_a + 1);
$p_sql = "SELECT * FROM `ospf_ports` AS O, `ports` AS P WHERE O.`ospfIfAdminStat` = 'enabled' AND O.`device_id` = ? AND O.`ospfIfAreaId` = ? AND P.port_id = O.port_id";
foreach (dbFetchRows($p_sql, array($device['device_id'], $area['ospfAreaId'])) as $ospfport)
{
if (!is_integer($i_a / 2)) {
if (!is_integer($i_p / 2)) {
$port_bg = $list_colour_b_b;
}
else {
$port_bg = $list_colour_b_a;
}
}
else {
if (!is_integer($i_p / 2)) {
$port_bg = $list_colour_a_b;
}
else {
$port_bg = $list_colour_a_a;
}
}
if ($ospfport['ospfIfAdminStat'] == 'enabled') {
$port_enabled = '<span style="color: #00aa00">enabled</span>';
}
else {
$port_enabled = '<span style="color: #aaaaaa">disabled</span>';
}
echo '<tr bgcolor="'.$port_bg.'">';
echo ' <td width=15></td>';
echo ' <td><strong>'.generate_port_link($ospfport).'</strong></td>';
echo ' <td>'.$port_enabled.'</td>';
echo ' <td>'.$ospfport['ospfIfType'].'</td>';
echo ' <td>'.$ospfport['ospfIfState'].'</td>';
echo '</tr>';
$i_p++;
}//end foreach
echo '</table>';
echo '</td>';
echo '</tr>';
$i_a++;
} //end foreach
echo '<tr bgcolor="#ffffff"><th></th><th>Router Id</th><th>Device</th><th>IP Address</th><th>Status</th></tr>';
// Loop Neigbours
$i_n = 1;
foreach (dbFetchRows('SELECT * FROM `ospf_nbrs` WHERE `device_id` = ?', array($device['device_id'])) as $nbr) {
if (!is_integer($i_n / 2)) {
$nbr_bg = $list_colour_b_a;
}
else {
$nbr_bg = $list_colour_b_b;
}
$host = @dbFetchRow(
'SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ?
AND I.port_id = A.port_id AND D.device_id = I.device_id',
array($nbr['ospfNbrRtrId'])
);
if (is_array($host)) {
$rtr_id = generate_device_link($host);
}
else {
$rtr_id = 'unknown';
}
echo '<tr bgcolor="'.$nbr_bg.'">';
echo ' <td width=5></td>';
echo ' <td><span class="list-large">'.$nbr['ospfNbrRtrId'].'</span></td>';
echo ' <td>'.$rtr_id.'</td>';
echo ' <td>'.$nbr['ospfNbrIpAddr'].'</td>';
echo ' <td>';
switch ($nbr['ospfNbrState']) {
case 'full':
echo '<span class=green>'.$nbr['ospfNbrState'].'</span>';
break;
case 'down':
echo '<span class=red>'.$nbr['ospfNbrState'].'</span>';
break;
default:
echo '<span class=blue>'.$nbr['ospfNbrState'].'</span>';
break;
}
echo '</td>';
echo '</tr>';
$i_n++;
}//end foreach
echo '</table>';
echo '</td>';
echo '</tr>';
$i_i++;
} //end foreach
echo '</table>';

View File

@@ -1,64 +1,77 @@
<?php
$link_array = array('page' => 'device',
'device' => $device['device_id'],
'tab' => 'routing',
'proto' => 'vrf');
$link_array = array(
'page' => 'device',
'device' => $device['device_id'],
'tab' => 'routing',
'proto' => 'vrf',
);
#echo(generate_link("Basic", $link_array,array('view'=>'basic')));
if(!isset($vars['view'])) { $vars['view'] = "basic"; }
// echo(generate_link("Basic", $link_array,array('view'=>'basic')));
if (!isset($vars['view'])) {
$vars['view'] = 'basic';
}
print_optionbar_start();
echo("<span style='font-weight: bold;'>VRFs</span> &#187; ");
echo "<span style='font-weight: bold;'>VRFs</span> &#187; ";
$menu_options = array('basic' => 'Basic',
# 'detail' => 'Detail',
);
// 'detail' => 'Detail',
);
if (!$_GET['opta']) { $_GET['opta'] = "basic"; }
if (!$_GET['opta']) {
$_GET['opta'] = 'basic';
}
$sep = "";
foreach ($menu_options as $option => $text)
{
if ($vars['view'] == $option) { echo("<span class='pagemenu-selected'>"); }
echo(generate_link($text, $link_array,array('view'=>$option)));
if ($vars['view'] == $option) { echo("</span>"); }
echo(" | ");
$sep = '';
foreach ($menu_options as $option => $text) {
if ($vars['view'] == $option) {
echo "<span class='pagemenu-selected'>";
}
echo generate_link($text, $link_array, array('view' => $option));
if ($vars['view'] == $option) {
echo '</span>';
}
echo ' | ';
}
unset($sep);
echo(' Graphs: ');
echo ' Graphs: ';
$graph_types = array("bits" => "Bits",
"upkts" => "Unicast Packets",
"nupkts" => "Non-Unicast Packets",
"errors" => "Errors",
"etherlike" => "Etherlike");
$graph_types = array(
'bits' => 'Bits',
'upkts' => 'Unicast Packets',
'nupkts' => 'Non-Unicast Packets',
'errors' => 'Errors',
'etherlike' => 'Etherlike',
);
foreach ($graph_types as $type => $descr)
{
echo("$type_sep");
if ($vars['graph'] == $type) { echo("<span class='pagemenu-selected'>"); }
echo(generate_link($descr, $link_array,array('view'=>'graphs','graph'=>$type)));
if ($vars['graph'] == $type) { echo("</span>"); }
foreach ($graph_types as $type => $descr) {
echo "$type_sep";
if ($vars['graph'] == $type) {
echo "<span class='pagemenu-selected'>";
}
$type_sep = " | ";
echo generate_link($descr, $link_array, array('view' => 'graphs', 'graph' => $type));
if ($vars['graph'] == $type) {
echo '</span>';
}
$type_sep = ' | ';
}
print_optionbar_end();
echo("<div style='margin: 5px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$i = "0";
foreach (dbFetchRows("SELECT * FROM `vrfs` WHERE `device_id` = ? ORDER BY `vrf_name`", array($device['device_id'])) as $vrf)
{
include("includes/print-vrf.inc.php");
echo "<div style='margin: 5px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>";
$i = '0';
foreach (dbFetchRows('SELECT * FROM `vrfs` WHERE `device_id` = ? ORDER BY `vrf_name`', array($device['device_id'])) as $vrf) {
include 'includes/print-vrf.inc.php';
$i++;
$i++;
}
echo("</table></div>");
?>
echo '</table></div>';