more cleanups, remove some FIXMEs

git-svn-id: http://www.observium.org/svn/observer/trunk@1983 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-03-28 10:39:55 +00:00
parent 9e5c180708
commit ef6406d4c9
6 changed files with 120 additions and 131 deletions
+7 -7
View File
@@ -237,8 +237,8 @@ A.orange:visited, a.orange, .orange { color: #FF7400; }
width:275px;
}
.page-h2 {
font-size: 14px;
.page-h2 {
font-size: 14px;
font-weight: bold;
vertical-align: top;
}
@@ -267,7 +267,7 @@ A.orange:visited, a.orange, .orange { color: #FF7400; }
}
.tablehead {
font-family: Verdana, arial, sans-serif;
font-family: Verdana, arial, sans-serif;
font-weight: bold;
font-size: 13px;
font-style: normal;
@@ -472,7 +472,7 @@ a.list-device-disabled {
}
body {
margin: 0px; padding: 0px 0px 0px 0px;
margin: 0px; padding: 0px 0px 0px 0px;
background-color: #fff; color: #666;
font: 10pt Verdana;
line-height: 20px;
@@ -608,7 +608,7 @@ p.vspace { padding-top: 3px; padding-bottom: 3px; }
color: #cc0000;
}
.interface-upup, a.interface-upup {
.interface-upup, a.interface-upup {
color: #0000cc;
}
@@ -784,7 +784,7 @@ visibility:visible; position:absolute; top:-69px; t\op:-70px; color:#000; left:1
margin-left: 0;
margin-top: 1px;
margin-bottom: 0px;
font-family: Verdana, arial, sans-serif;
font-family: Verdana, arial, sans-serif;
font-weight: none;
font-size: 12px;
list-style-type: none;
@@ -835,7 +835,7 @@ color: #cc0000;
float: left;
}
.optionicon {
.optionicon {
vertical-align:middle;
margin-top: -4px
}
+92 -99
View File
@@ -1,101 +1,96 @@
<?php
#echo("<pre>");
#print_r($interface);
#echo("</pre>");
# This file prints a table row for each interface
$interface['device_id'] = $device['device_id'];
$interface['hostname'] = $device['hostname'];
$interface['device_id'] = $device['device_id'];
$interface['hostname'] = $device['hostname'];
$if_id = $interface['interface_id'];
$if_id = $interface['interface_id'];
$interface = ifLabel($interface);
$interface = ifLabel($interface);
if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
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 ($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 = ""; }
echo("<tr style=\"background-color: $row_colour; padding: 5px;\" 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']) . "
</span><br /><span class=interface-desc>".$interface['ifAlias']."</span>");
echo("<tr style=\"background-color: $row_colour; padding: 5px;\" 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']) . "
if ($interface['ifAlias']) { echo("<br />"); }
</span><br /><span class=interface-desc>".$interface['ifAlias']."</span>");
if ($interface['ifAlias']) { echo("<br />"); }
unset ($break);
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&amp;query=$ip[ipv4_address]')\">$ip[ipv4_address]/$ip[ipv4_prefixlen]</a>");
$break = ",";
}
$ip6data = mysql_query("SELECT * FROM `ipv6_addresses` WHERE `interface_id` = '" . $interface['interface_id'] . "'");
while ($ip6 = mysql_fetch_Array($ip6data)) {
echo("$break <a class=interface-desc href=\"javascript:popUp('/netcmd.php?cmd=whois&amp;query=".$ip6['ipv6_address']."')\">".Net_IPv6::compress($ip6['ipv6_address'])."/".$ip6['ipv6_prefixlen']."</a>");
$break = ",";
}
unset ($break);
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&amp;query=$ip[ipv4_address]')\">$ip[ipv4_address]/$ip[ipv4_prefixlen]</a>");
$break = ",";
}
$ip6data = mysql_query("SELECT * FROM `ipv6_addresses` WHERE `interface_id` = '" . $interface['interface_id'] . "'");
while ($ip6 = mysql_fetch_Array($ip6data))
{
echo("$break <a class=interface-desc href=\"javascript:popUp('/netcmd.php?cmd=whois&amp;query=".$ip6['ipv6_address']."')\">".Net_IPv6::compress($ip6['ipv6_address'])."/".$ip6['ipv6_prefixlen']."</a>");
$break = ",";
}
}
echo("</span>");
echo("</span>");
$width="120"; $height="40"; $from = $day;
$width="120"; $height="40"; $from = $day;
echo("</td><td width=135>");
echo(formatRates($interface['ifInOctets_rate'] * 8)." <img class='optionicon' src='images/icons/arrow_updown.png' /> ".formatRates($interface['ifOutOctets_rate'] * 8));
echo("<br />");
$interface['graph_type'] = "port_bits";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
echo("</td><td width=135>");
echo(formatRates($interface['ifInOctets_rate'] * 8)." <img class='optionicon' src='images/icons/arrow_updown.png' /> ".formatRates($interface['ifOutOctets_rate'] * 8));
echo("<br />");
$interface['graph_type'] = "port_bits";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
echo("</td><td width=135>");
echo("".formatRates($interface['adslAturChanCurrTxRate']) . "/". formatRates($interface['adslAtucChanCurrTxRate']));
echo("<br />");
$interface['graph_type'] = "port_adsl_speed";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
echo("</td><td width=135>");
echo("".formatRates($interface['adslAturChanCurrTxRate']) . "/". formatRates($interface['adslAtucChanCurrTxRate']));
echo("<br />");
$interface['graph_type'] = "port_adsl_speed";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
echo("</td><td width=135>");
echo("".formatRates($interface['adslAturCurrAttainableRate']) . "/". formatRates($interface['adslAtucCurrAttainableRate']));
echo("<br />");
$interface['graph_type'] = "port_adsl_attainable";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
echo("</td><td width=135>");
echo("".formatRates($interface['adslAturCurrAttainableRate']) . "/". formatRates($interface['adslAtucCurrAttainableRate']));
echo("<br />");
$interface['graph_type'] = "port_adsl_attainable";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
echo("</td><td width=135>");
echo("".$interface['adslAturCurrAtn'] . "dB/". $interface['adslAtucCurrAtn'] . "dB");
echo("<br />");
$interface['graph_type'] = "port_adsl_attenuation";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
echo("</td><td width=135>");
echo("".$interface['adslAturCurrAtn'] . "dB/". $interface['adslAtucCurrAtn'] . "dB");
echo("<br />");
$interface['graph_type'] = "port_adsl_attenuation";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
echo("</td><td width=135>");
echo("".$interface['adslAturCurrSnrMgn'] . "dB/". $interface['adslAtucCurrSnrMgn'] . "dB");
echo("<br />");
$interface['graph_type'] = "port_adsl_snr";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
echo("</td><td width=135>");
echo("".$interface['adslAturCurrOutputPwr'] . "dBm/". $interface['adslAtucCurrOutputPwr'] . "dBm");
echo("<br />");
$interface['graph_type'] = "port_adsl_power";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
echo("</td><td width=135>");
echo("".$interface['adslAturCurrSnrMgn'] . "dB/". $interface['adslAtucCurrSnrMgn'] . "dB");
echo("<br />");
$interface['graph_type'] = "port_adsl_snr";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
echo("</td><td width=135>");
echo("".$interface['adslAturCurrOutputPwr'] . "dBm/". $interface['adslAtucCurrOutputPwr'] . "dBm");
echo("<br />");
$interface['graph_type'] = "port_adsl_power";
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&amp;id=".$interface['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=".$width."&amp;height=".$height."&amp;legend=no&amp;bg=".
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
# if ($interface[ifDuplex] != unknown) { echo("<span class=box-desc>Duplex " . $interface['ifDuplex'] . "</span>"); } else { echo("-"); }
# echo("</td><td width=150>");
# echo($port_adsl['adslLineCoding']."/".$port_adsl['adslLineType']);
# echo("<br />");
@@ -107,46 +102,44 @@
# echo("<br />");
# echo("SNR:".$port_adsl['adslAtucCurrSnrMgn'] . "dB/". $port_adsl['adslAturCurrSnrMgn']. "dB");
echo("</td>");
if ($graph_type == "etherlike")
{
$graph_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/etherlike-". safename($interface['ifIndex']) . ".rrd";
} else {
$graph_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/". safename($interface['ifIndex']) . ".rrd";
}
if ($graph_type == "etherlike")
{
$graph_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/etherlike-". safename($interface['ifIndex']) . ".rrd";
} else {
$graph_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/". safename($interface['ifIndex']) . ".rrd";
}
if ($graph_type && is_file($graph_file)) {
if ($graph_type && is_file($graph_file))
{
$type = $graph_type;
$type = $graph_type;
$daily_traffic = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$from&amp;to=$now&amp;width=210&amp;height=100";
$daily_url = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$from&amp;to=$now&amp;width=500&amp;height=150";
$daily_traffic = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$from&amp;to=$now&amp;width=210&amp;height=100";
$daily_url = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$from&amp;to=$now&amp;width=500&amp;height=150";
$weekly_traffic = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$week&amp;to=$now&amp;width=210&amp;height=100";
$weekly_url = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$week&amp;to=$now&amp;width=500&amp;height=150";
$weekly_traffic = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$week&amp;to=$now&amp;width=210&amp;height=100";
$weekly_url = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$week&amp;to=$now&amp;width=500&amp;height=150";
$monthly_traffic = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$month&amp;to=$now&amp;width=210&amp;height=100";
$monthly_url = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$month&amp;to=$now&amp;width=500&amp;height=150";
$monthly_traffic = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$month&amp;to=$now&amp;width=210&amp;height=100";
$monthly_url = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$month&amp;to=$now&amp;width=500&amp;height=150";
$yearly_traffic = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$year&amp;to=$now&amp;width=210&amp;height=100";
$yearly_url = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$year&amp;to=$now&amp;width=500&amp;height=150";
$yearly_traffic = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$year&amp;to=$now&amp;width=210&amp;height=100";
$yearly_url = "graph.php?port=$if_id&amp;type=" . $graph_type . "&amp;from=$year&amp;to=$now&amp;width=500&amp;height=150";
echo("<tr style='background-color: $bg; padding: 5px;'><td colspan=7>");
echo("<a href='device/" . $interface['device_id'] . "/interface/" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT".$config['overlib_defaults'].");\"
onmouseout=\"return nd();\"> <img src='$daily_traffic' border=0></a>");
onmouseout=\"return nd();\"> <img src='$daily_traffic' border=0></a>");
echo("<a href='device/" . $interface['device_id'] . "/interface/" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT".$config['overlib_defaults'].");\"
onmouseout=\"return nd();\"> <img src='$weekly_traffic' border=0></a>");
onmouseout=\"return nd();\"> <img src='$weekly_traffic' border=0></a>");
echo("<a href='device/" . $interface['device_id'] . "/interface/" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT, WIDTH, 350".$config['overlib_defaults'].");\"
onmouseout=\"return nd();\"> <img src='$monthly_traffic' border=0></a>");
onmouseout=\"return nd();\"> <img src='$monthly_traffic' border=0></a>");
echo("<a href='device/" . $interface['device_id'] . "/interface/" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT, WIDTH, 350".$config['overlib_defaults'].");\"
onmouseout=\"return nd();\"> <img src='$yearly_traffic' border=0></a>");
onmouseout=\"return nd();\"> <img src='$yearly_traffic' border=0></a>");
echo("</td></tr>");
}
}
?>
?>
+5 -8
View File
@@ -2,8 +2,7 @@
if ($_SESSION['userlevel'] < 10)
{
# FIXME generic box?
echo("<span class='alert'>You are not permitted to perform this function</span>");
include("includes/error-no-perm.inc.php");
exit;
}
@@ -17,17 +16,15 @@ if ($_POST['hostname'] && $_POST['community'])
$community = mres($_POST['community']);
$snmpver = mres($_POST['snmpver']);
if ($_POST['port']) { $port = mres($_POST['port']); } else { $port = "161"; }
echo("<p class='messagebox'>");
echo("Adding host $hostname community $community port $port</p>");
print_message("Adding host $hostname community $community port $port");
$result = addHost($hostname, $community, $snmpver, $port);
echo("</p>");
} else {
echo("<p class='errorbox'><b>Error:</b> You don't have the necessary privileges to add hosts.</p>");
print_error("You don't have the necessary privileges to add hosts.");
}
} elseif ($_POST['hostname'] && !$_POST['community']) {
echo("<p class='errorbox'><b>Error:</b> A community string is required.</p>");
print_error("A community string is required.");
} elseif (!$_POST['hostname'] && $_POST['community']) {
echo("<p class='errorbox'><b>Error:</b> A hostname is required.</p>");
print_error("A hostname is required.");
}
?>
+1 -2
View File
@@ -2,8 +2,7 @@
if ($_SESSION['userlevel'] < '10')
{
## FIXME generic "box" include?
echo("<span class='alert'>Insufficient privileges to perform this function.</span>");
include("includes/error-no-perm.inc.php");
}
else
{
+1 -1
View File
@@ -2,7 +2,7 @@
if ($_SESSION['userlevel'] < 10)
{
echo("<span class='alert'>You are not permitted to perform this function</span>");
include("includes/error-no-perm.inc.php");
exit;
}
+14 -14
View File
@@ -2,25 +2,25 @@
if ($_SESSION['userlevel'] < '5')
{
print_error("Insufficient Privileges");
include("includes/error-no-perm.inc.php");
} else {
if ($_POST['delsrv'])
{
if ($_SESSION['userlevel'] > "5") {
include("includes/service-delete.inc.php");
if ($_POST['delsrv'])
{
if ($_SESSION['userlevel'] > "5")
{
include("includes/service-delete.inc.php");
}
}
}
$query = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY hostname");
while ($device = mysql_fetch_array($query))
{
$servicesform .= "<option value='" . $device[service_id] . "'>" . $device['service_id'] . "." . $device['hostname'] . " - " . $device['service_type'] . "</option>";
}
$query = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY hostname");
while ($device = mysql_fetch_array($query))
{
$servicesform .= "<option value='" . $device['service_id'] . "'>" . $device['service_id'] . "." . $device['hostname'] . " - " . $device['service_type'] . "</option>";
}
if ($updated) { print_message("Service Deleted!"); }
if ($updated) { print_message("Service Deleted!"); }
echo("
echo("
<h4>Delete Service</h4>
<form id='addsrv' name='addsrv' method='post' action=''>
<input type=hidden name='delsrv' value='yes'>