code cleanups, remove more dead code

git-svn-id: http://www.observium.org/svn/observer/trunk@1900 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-03-17 11:29:23 +00:00
parent 9f24ca4248
commit aedac10866
6 changed files with 311 additions and 370 deletions

View File

@@ -60,4 +60,5 @@
echo('
</table>');
?>

View File

@@ -1,55 +0,0 @@
<div id="top" style="background: <?php echo($config['header_color']); ?>; height: 5px;">
</div>
<div id="header" style="border: 1px none #ccf;">
<table width="100%" style="padding: 0px; margin:0px;">
<tr>
<td style="padding: 0px; margin:0px; border: none;">
<div id="logo" style="padding: 5px 10px;"><a href="index.php"><img src="<?php echo($config['title_image']); ?>" alt="ObserverNMS Logo" border="0" /></a></div>
</td>
<td align="center"><?php
## WE ARE SVN
# $data = trim(shell_exec("cat " . $config['install_dir'] . "/rrd/version.txt"));
# list($major, $minor, $release) = explode(".", $data);
# if (strstr('-',$config['version'])) { list($cur, $tag) = explode("-", $config['version']); } else { $cur = $config['version']; }
# list($cur_major, $cur_minor, $cur_release) = explode(".", $cur);
# if($major > $cur_major) {
# echo("<a href='http://www.observernms.org'><span class=red>New Version! <br /> <b>$major.$minor.$release</b></span></a>");
# } elseif ($major == $cur_major && $minor > $cur_minor) {
# echo("<a href='http://www.observernms.org'><span class=red>New Version! <br /> <b>$major.$minor.$release</b></span></a>");
# } elseif ($major == $cur_major && $minor == $cur_minor && $release > $cur_release) {
# echo("<a href='http://www.observernms.org'><span class=red>New Version! <br /> <b>$major.$minor.$release</b></span></a>");
# } elseif($major < $cur_major || ($major == $cur_major && $minor < $cur_minor) || ($major == $cur_major && $minor == $cur_minor && $release < $cur_release)) {
# }
?>
</td>
<td align="right" style="margin-right: 10px;">
<div id="topnav" style="float: right;">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"></td>
<td align="right">
<?php
if($_SESSION['authenticated']) {
echo("Logged in as <b>".$_SESSION['username']."</b> (<a href='?logout=yes'>Logout</a>)");
} else {
echo("Not logged in!");
}
if( Net_IPv6::checkIPv6($_SERVER['REMOTE_ADDR'])) { echo(" via <b>IPv6</b>"); } else { echo(" via <b>IPv4</b>"); }
?>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>

View File

@@ -4,11 +4,13 @@
<td align="left"></td>
<td align="right">
<?php
if($_SESSION['authenticated']) {
if ($_SESSION['authenticated'])
{
echo("Logged in as <b>".$_SESSION['username']."</b> (<a href='?logout=yes'>Logout</a>)");
} else {
echo("Not logged in!");
}
# FIXME worksforme, why was this disabled again? -TL
# if (Net_IPv6::checkIPv6($_SERVER['REMOTE_ADDR'])) { echo(" via <b>IPv6</b>"); } else { echo(" via <b>IPv4</b>"); }
?>
</td>
@@ -22,34 +24,16 @@
<td style="padding: 0px; margin:0px; border: none;">
<div id="logo" style="padding: 10px"><a href="index.php"><img src="<?php echo($config['title_image']); ?>" alt="Logo" border="0" /></a></div>
</td>
<td align="center"><?php
## WE ARE SVN
# $data = trim(shell_exec("cat " . $config['install_dir'] . "/rrd/version.txt"));
# list($major, $minor, $release) = explode(".", $data);
# if (strstr('-',$config['version'])) { list($cur, $tag) = explode("-", $config['version']); } else { $cur = $config['version']; }
# list($cur_major, $cur_minor, $cur_release) = explode(".", $cur);
# if($major > $cur_major) {
# echo("<a href='http://www.observernms.org'><span class=red>New Version! <br /> <b>$major.$minor.$release</b></span></a>");
# } elseif ($major == $cur_major && $minor > $cur_minor) {
# echo("<a href='http://www.observernms.org'><span class=red>New Version! <br /> <b>$major.$minor.$release</b></span></a>");
# } elseif ($major == $cur_major && $minor == $cur_minor && $release > $cur_release) {
# echo("<a href='http://www.observernms.org'><span class=red>New Version! <br /> <b>$major.$minor.$release</b></span></a>");
# } elseif($major < $cur_major || ($major == $cur_major && $minor < $cur_minor) || ($major == $cur_major && $minor == $cur_minor && $release < $cur_release)) {
# }
?>
</td>
<td align="right" style="margin-right: 10px;">
<div id="topnav" style="float: right;">
<?php if(isset($_SESSION['authenticated']) && $_SESSION['authenticated']) {
<?php
if (isset($_SESSION['authenticated']) && $_SESSION['authenticated'])
{
include("includes/topnav.inc");
} ?>
}
?>
</div>
</td>
</tr>
</table>
</div>

View File

@@ -18,18 +18,18 @@
$port_adsl_query = mysql_query("SELECT * FROM `ports_adsl` WHERE `interface_id` = '".$interface['interface_id']."'");
$port_adsl = mysql_fetch_assoc($port_adsl_query);
if($interface['ifInErrors_delta'] > 0 || $interface['ifOutErrors_delta'] > 0) {
if ($interface['ifInErrors_delta'] > 0 || $interface['ifOutErrors_delta'] > 0)
{
$error_img = generate_port_link($interface, "<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>", "port_errors");
} else { $error_img = ""; }
if(mysql_result(mysql_query("SELECT count(*) FROM mac_accounting WHERE interface_id = '".$interface['interface_id']."'"),0)){
if (mysql_result(mysql_query("SELECT count(*) FROM mac_accounting WHERE interface_id = '".$interface['interface_id']."'"),0))
{
$mac = "<a href='device/".$interface['device_id']."/interface/".$interface['interface_id']."/macaccounting/'><img src='/images/16/chart_curve.png' align='absmiddle'></a>";
} else { $mac = ""; }
echo("<tr style=\"background-color: $row_colour;\" valign=top onmouseover=\"this.style.backgroundColor='$list_highlight';\" onmouseout=\"this.style.backgroundColor='$row_colour';\" onclick=\"location.href='device/".$device['device_id']."/interface/".$interface['interface_id']."/'\" style='cursor: pointer;'>
<td valign=top width=350>");
echo(" <span class=list-large>
" . generate_port_link($interface, $interface['ifIndex'] . ". ".$interface['label']) . " $error_img $mac
@@ -38,7 +38,8 @@
if ($interface['ifAlias']) { echo("<br />"); }
unset ($break);
if($port_details) {
if ($port_details)
{
$ipdata = mysql_query("SELECT * FROM `ipv4_addresses` WHERE `interface_id` = '" . $interface['interface_id'] . "'");
while ($ip = mysql_fetch_Array($ipdata)) {
echo("$break <a class=interface-desc href=\"javascript:popUp('/netcmd.php?cmd=whois&query=$ip[ipv4_address]')\">$ip[ipv4_address]/$ip[ipv4_prefixlen]</a>");
@@ -55,7 +56,8 @@
echo("</td><td width=100>");
if($port_details) {
if ($port_details)
{
$interface['graph_type'] = "port_bits";
echo(generate_port_link($interface, "<img src='graph.php?type=port_bits&id=".$interface['interface_id']."&from=".$day."&to=".$now."&width=100&height=20&legend=no&bg=".str_replace("#","", $row_colour)."'>"));
$interface['graph_type'] = "port_upkts";
@@ -65,7 +67,9 @@
}
echo("</td><td width=120>");
if($interface['ifOperStatus'] == "up") {
if ($interface['ifOperStatus'] == "up")
{
$interface['in_rate'] = $interface['ifInOctets_rate'] * 8;
$interface['out_rate'] = $interface['ifOutOctets_rate'] * 8;
$in_perc = @round($interface['in_rate']/$interface['ifSpeed']*100);
@@ -82,7 +86,8 @@
if ($interface[ifDuplex] != "unknown") { echo("<span class=box-desc>" . $interface['ifDuplex'] . "</span>"); } else { echo("-"); }
if($device['os'] == "ios" || $device['os'] == "iosxe") {
if ($device['os'] == "ios" || $device['os'] == "iosxe")
{
if ($interface['ifTrunk']) {
echo("<span class=box-desc><span class=red>" . $interface['ifTrunk'] . "</span></span>");
} elseif ($interface['ifVlan']) {
@@ -93,7 +98,8 @@
}
}
if($port_adsl['adslLineCoding']) {
if ($port_adsl['adslLineCoding'])
{
echo("</td><td width=150>");
echo($port_adsl['adslLineCoding']."/".$port_adsl['adslLineType']);
echo("<br />");
@@ -114,13 +120,14 @@
echo("<br />");
if ($interface['ifMtu'] && $interface['ifMtu'] != "") { echo("<span class=box-desc>MTU " . $interface['ifMtu'] . "</span>"); } else { echo("-"); }
}
#}
echo("</td>");
echo("<td width=375 valign=top class=interface-desc>");
if ( strpos($interface['label'], "oopback") === false && !$graph_type) {
if (strpos($interface['label'], "oopback") === false && !$graph_type)
{
$link_query = mysql_query("select * from links AS L, ports AS I, devices AS D WHERE L.local_interface_id = '$if_id' AND L.remote_interface_id = I.interface_id AND I.device_id = D.device_id");
while($link = mysql_fetch_array($link_query)) {
while ($link = mysql_fetch_array($link_query))
{
# echo("<img src='images/16/connect.png' align=absmiddle alt='Directly Connected' /> " . generate_port_link($link, makeshortif($link['label'])) . " on " . generate_device_link($link, shorthost($link['hostname'])) . "</a><br />");
# $br = "<br />";
$int_links[$link['interface_id']] = $link['interface_id'];
@@ -129,18 +136,20 @@ echo("</td>");
unset($br);
if($port_details) { ## Show which other devices are on the same subnet as this interface
if ($port_details)
{ ## Show which other devices are on the same subnet as this interface
$sql = "SELECT `ipv4_network_id` FROM `ipv4_addresses` WHERE `interface_id` = '".$interface['interface_id']."' AND `ipv4_address` NOT LIKE '127.%'";
$nets_query = mysql_query($sql);
while($net = mysql_fetch_array($nets_query)) {
while ($net = mysql_fetch_array($nets_query))
{
$ipv4_network_id = $net['ipv4_network_id'];
$sql = "SELECT I.interface_id FROM ipv4_addresses AS A, ports AS I, devices AS D
WHERE A.interface_id = I.interface_id
AND A.ipv4_network_id = '".$net['ipv4_network_id']."' AND D.device_id = I.device_id
AND D.device_id != '".$device['device_id']."'";
$new_query = mysql_query($sql);
while($new = mysql_fetch_array($new_query)) {
while ($new = mysql_fetch_array($new_query))
{
echo($new['ipv4_network_id']);
$this_ifid = $new['interface_id'];
$this_hostid = $new['device_id'];
@@ -153,14 +162,16 @@ echo("</td>");
$sql = "SELECT ipv6_network_id FROM ipv6_addresses WHERE interface_id = '".$interface['interface_id']."'";
$nets_query = mysql_query($sql);
while($net = mysql_fetch_array($nets_query)) {
while ($net = mysql_fetch_array($nets_query))
{
$ipv6_network_id = $net['ipv6_network_id'];
$sql = "SELECT I.interface_id FROM ipv6_addresses AS A, ports AS I, devices AS D
WHERE A.interface_id = I.interface_id
AND A.ipv6_network_id = '".$net['ipv6_network_id']."' AND D.device_id = I.device_id
AND D.device_id != '".$device['device_id']."' AND A.ipv6_origin != 'linklayer' AND A.ipv6_origin != 'wellknown'";
$new_query = mysql_query($sql);
while($new = mysql_fetch_array($new_query)) {
while ($new = mysql_fetch_array($new_query))
{
echo($new['ipv6_network_id']);
$this_ifid = $new['interface_id'];
$this_hostid = $new['device_id'];
@@ -172,8 +183,8 @@ echo("</td>");
}
}
foreach($int_links as $int_link) {
foreach ($int_links as $int_link)
{
$link_if = mysql_fetch_array(mysql_query("SELECT * from ports AS I, devices AS D WHERE I.device_id = D.device_id and I.interface_id = '".$int_link."'"));
echo("$br");
@@ -187,13 +198,12 @@ echo("</td>");
if ($int_links_v4[$int_link]) { echo(" <b style='color: #00a100'>v4</b>"); }
$br = "<br />";
}
# unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br);
}
$pseudowires = mysql_query("SELECT * FROM `pseudowires` WHERE `interface_id` = '" . $interface['interface_id'] . "'");
while($pseudowire = mysql_fetch_array($pseudowires)) {
while ($pseudowire = mysql_fetch_array($pseudowires))
{
#`interface_id`,`peer_device_id`,`peer_ldp_id`,`cpwVcID`,`cpwOid`
$pw_peer_dev = mysql_fetch_array(mysql_query("SELECT * from `devices` WHERE `device_id` = '" . $pseudowire['peer_device_id'] . "'"));
$pw_peer_int = mysql_fetch_array(mysql_query("SELECT * from `ports` AS I, pseudowires AS P WHERE I.device_id = '".$pseudowire['peer_device_id']."' AND
@@ -205,21 +215,21 @@ echo("</td>");
}
$members = mysql_query("SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = '".$interface['ifIndex']."' and `device_id` = '".$device['device_id']."'");
while($member = mysql_fetch_array($members)) {
while ($member = mysql_fetch_array($members))
{
echo("$br<img src='images/16/brick_link.png' align=absmiddle> <strong>" . generate_port_link($member) . " (PAgP)</strong>");
$br = "<br />";
}
if($interface['pagpGroupIfIndex'] && $interface['pagpGroupIfIndex'] != $interface['ifIndex']) {
if ($interface['pagpGroupIfIndex'] && $interface['pagpGroupIfIndex'] != $interface['ifIndex'])
{
$parent = mysql_fetch_array(mysql_query("SELECT * FROM `ports` WHERE `ifIndex` = '".$interface['pagpGroupIfIndex']."' and `device_id` = '".$device['device_id']."'"));
echo("$br<img src='images/16/bricks.png' align=absmiddle> <strong>" . generate_port_link($parent) . " (PAgP)</strong>");
$br = "<br />";
}
unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br);
echo("</td></tr>");
// If we're showing graphs, generate the graph and print the img tags
@@ -231,8 +241,8 @@ echo("</td>");
$graph_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-". safename($interface['ifIndex']) . ".rrd";
}
if($graph_type && is_file($graph_file)) {
if ($graph_type && is_file($graph_file))
{
$type = $graph_type;
$daily_traffic = "graph.php?id=$if_id&type=" . $graph_type . "&from=$day&to=$now&width=210&height=100";

View File

@@ -8,7 +8,8 @@
$periods = array('day', 'week', 'month', 'year');
foreach($periods as $period) {
foreach ($periods as $period)
{
$graph_array['from'] = $config[$period];
$graph_array_zoom = $graph_array;
$graph_array_zoom['height'] = "150";