some formatting cleanups, introduce some more FIXMEs to look at, plus replace mysql_fetch_array by mysql_fetch_assoc, for great justice

git-svn-id: http://www.observium.org/svn/observer/trunk@2029 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-04-06 13:54:50 +00:00
parent 51e242b896
commit f55a30f744
163 changed files with 476 additions and 460 deletions
+2 -2
View File
@@ -6,7 +6,7 @@ print_optionbar_start();
unset($sep);
while ($app = mysql_fetch_array($query))
while ($app = mysql_fetch_assoc($query))
{
echo($sep);
@@ -26,7 +26,7 @@ while ($app = mysql_fetch_array($query))
print_optionbar_end();
$app = mysql_fetch_array(mysql_query("SELECT * FROM `applications` WHERE `device_id` = '".$device['device_id']."' AND `app_type` = '".$_GET['opta']."'"));
$app = mysql_fetch_assoc(mysql_query("SELECT * FROM `applications` WHERE `device_id` = '".$device['device_id']."' AND `app_type` = '".$_GET['opta']."'"));
if (is_file("pages/device/apps/".mres($_GET['opta']).".inc.php"))
{
+2 -2
View File
@@ -7,11 +7,11 @@ echo('<table border="0" cellspacing="0" cellpadding="5" width="100%">');
$i = "1";
while ($arp = mysql_fetch_array($query))
while ($arp = mysql_fetch_assoc($query))
{
if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
$arp_host = mysql_fetch_array(mysql_query("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = '".$arp['ipv4_address']."' AND I.interface_id = A.interface_id AND D.device_id = I.device_id"));
$arp_host = mysql_fetch_assoc(mysql_query("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = '".$arp['ipv4_address']."' AND I.interface_id = A.interface_id AND D.device_id = I.device_id"));
if ($arp_host) { $arp_name = generate_device_link($arp_host); } else { unset($arp_name); }
if ($arp_host) { $arp_if = generate_port_link($arp_host); } else { unset($arp_if); }
+3 -3
View File
@@ -4,7 +4,7 @@ print_optionbar_start();
unset ($sep);
$query = mysql_query("SELECT `entSensorType` FROM `entPhysical` WHERE device_id = '".$device['device_id']."' AND entSensorType != '' AND entSensorType NOT LIKE 'No%' GROUP BY `entSensorType` ORDER BY `entSensorType`");
while ($data = mysql_fetch_array($query))
while ($data = mysql_fetch_assoc($query))
{
$type = $data['entSensorType'];
if (!$_GET['opta']) { $_GET['opta'] = $type; }
@@ -20,11 +20,11 @@ unset ($sep);
print_optionbar_end();
$query = mysql_query("SELECT * FROM `entPhysical` WHERE device_id = '".$device['device_id']."' and entSensorType = '".$_GET['opta']."' ORDER BY `entPhysicalName`");
while ($data = mysql_fetch_array($query))
while ($data = mysql_fetch_assoc($query))
{
if ($data['entSensorMeasuredEntity'])
{
$measured = mysql_fetch_array(mysql_query("SELECT * FROM entPhysical WHERE device_id = '".$device['device_id']."' AND entPhysicalIndex = '".$data['entSensorMeasuredEntity']."'"));
$measured = mysql_fetch_assoc(mysql_query("SELECT * FROM entPhysical WHERE device_id = '".$device['device_id']."' AND entPhysicalIndex = '".$data['entSensorMeasuredEntity']."'"));
}
echo("<div><h3>".$measured['entPhysicalName']." ".$data['entPhysicalName']."</h3>");
+1 -1
View File
@@ -17,7 +17,7 @@ if ($_POST['editing'])
}
else
{
include("includes/error-no-perm.inc.php");
include("includes/error-no-perm.inc.php");
}
}
+1 -1
View File
@@ -44,7 +44,7 @@ if ($_POST['editing'])
}
else
{
include("includes/error-no-perm.inc.php");
include("includes/error-no-perm.inc.php");
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ if ($_POST['editing'])
}
else
{
include("includes/error-no-perm.inc.php");
include("includes/error-no-perm.inc.php");
}
}
+3 -6
View File
@@ -106,9 +106,8 @@ $(document).ready(function(){
$row=1;
$query = mysql_query("SELECT * FROM `ports` WHERE device_id='".$device['device_id']."' ORDER BY `ifIndex` ");
while ($port = mysql_fetch_array($query))
while ($port = mysql_fetch_assoc($query))
{
$port = ifLabel($port);
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
@@ -137,15 +136,13 @@ while ($port = mysql_fetch_array($query))
echo("</td>");
echo("<td align=left>".$port['ifAlias'] . "</td>");
echo("</tr>
");
echo("</tr>\n");
$row++;
}
echo('</table>');
echo('</form>');
echo('</div>');
?>
?>
+2 -2
View File
@@ -28,7 +28,7 @@ if ($handle = opendir($config['install_dir'] . "/includes/services/"))
}
$query = mysql_query("SELECT * FROM `devices` ORDER BY `hostname`");
while ($device = mysql_fetch_array($query))
while ($device = mysql_fetch_assoc($query))
{
$devicesform .= "<option value='" . $device['device_id'] . "'>" . $device['hostname'] . "</option>";
}
@@ -39,7 +39,7 @@ if (mysql_result(mysql_query("SELECT COUNT(*) from `services` WHERE `device_id`
{
$i = "1";
$service_query = mysql_query("select * from services WHERE device_id = '".$device['device_id']."' ORDER BY service_type");
while ($service = mysql_fetch_array($service_query))
while ($service = mysql_fetch_assoc($service_query))
{
$existform .= "<option value='" . $service['service_id'] . "'>" . $service['service_type'] . "</option>";
}
+2 -2
View File
@@ -5,7 +5,7 @@ function printEntPhysical($ent, $level, $class)
global $device;
$query = mysql_query("SELECT * FROM `entPhysical` WHERE device_id = '".$device['device_id']."' AND entPhysicalContainedIn = '".$ent."' ORDER BY entPhysicalContainedIn,entPhysicalIndex");
while ($ent = mysql_fetch_array($query))
while ($ent = mysql_fetch_assoc($query))
{
echo("
<li class='$class'>");
@@ -27,7 +27,7 @@ function printEntPhysical($ent, $level, $class)
if ($ent['ifIndex'])
{
$interface = mysql_fetch_array(mysql_query("SELECT * FROM `ports` WHERE ifIndex = '".$ent['ifIndex']."' AND device_id = '".$device['device_id']."'"));
$interface = mysql_fetch_assoc(mysql_query("SELECT * FROM `ports` WHERE ifIndex = '".$ent['ifIndex']."' AND device_id = '".$device['device_id']."'"));
$ent['entPhysicalName'] = generate_port_link($interface);
}
+1 -1
View File
@@ -4,7 +4,7 @@ $query = "SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `even
$data = mysql_query($query);
echo('<table cellspacing="0" cellpadding="2" width="100%">');
while ($entry = mysql_fetch_array($data))
while ($entry = mysql_fetch_assoc($data))
{
include("includes/print-event.inc.php");
}
+1 -1
View File
@@ -14,7 +14,7 @@ echo('<table cellspacing="0" cellpadding="5" width="100%">');
$row = 1;
while ($drive = mysql_fetch_array($query))
while ($drive = mysql_fetch_assoc($query))
{
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
+1 -1
View File
@@ -8,7 +8,7 @@ echo("<table width=100% cellpadding=6 cellspacing=0>");
$i = '1';
$mempools = mysql_query("SELECT * FROM `mempools` WHERE device_id = '" . $device['device_id'] . "'");
while ($mempool = mysql_fetch_array($mempools))
while ($mempool = mysql_fetch_assoc($mempools))
{
if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
+1 -1
View File
@@ -7,7 +7,7 @@ echo("<table width=100% cellpadding=6 cellspacing=0>");
$i = '1';
$procs = mysql_query("SELECT * FROM `processors` WHERE device_id = '" . $device['device_id'] . "'");
while ($proc = mysql_fetch_array($procs))
while ($proc = mysql_fetch_assoc($procs))
{
$proc_url = "device/".$device['device_id']."/health/processors/";
+1 -1
View File
@@ -7,7 +7,7 @@ echo("<table cellspacing=0 cellpadding=5 width=100%>");
$row = 1;
while ($temp = mysql_fetch_array($query))
while ($temp = mysql_fetch_assoc($query))
{
if (!is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
+1 -1
View File
@@ -16,7 +16,7 @@ echo("<tr class=tablehead>
$row = 1;
while ($drive = mysql_fetch_array($query))
while ($drive = mysql_fetch_assoc($query))
{
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
+4 -3
View File
@@ -3,7 +3,7 @@
echo("<table width=100%>");
$hrdevices = mysql_query("SELECT * FROM `hrDevice` WHERE `device_id` = '".$device['device_id']."' ORDER BY `hrDeviceIndex`");
while ($hrdevice = mysql_fetch_array($hrdevices))
while ($hrdevice = mysql_fetch_assoc($hrdevices))
{
echo("<tr><td>".$hrdevice['hrDeviceIndex']."</td>");
@@ -30,8 +30,9 @@ while ($hrdevice = mysql_fetch_array($hrdevices))
echo('<td>'.$mini_graph.'</td>');
} elseif ($hrdevice['hrDeviceType'] == "hrDeviceNetwork") {
$int = str_replace("network interface ", "", $hrdevice['hrDeviceDescr']);
$interface = mysql_fetch_array(mysql_query("SELECT * FROM ports WHERE device_id = '".$device['device_id']."' AND ifDescr = '".$int."'"));
if ($interface['ifIndex']) {
$interface = mysql_fetch_assoc(mysql_query("SELECT * FROM ports WHERE device_id = '".$device['device_id']."' AND ifDescr = '".$int."'"));
if ($interface['ifIndex'])
{
echo("<td>".generate_port_link($interface)."</td>");
$graph_array['height'] = "20";
+3 -3
View File
@@ -45,7 +45,7 @@ if ($services['total'])
$sql = "SELECT * FROM services WHERE device_id = '" . $device['device_id'] . "' ORDER BY service_type";
$query = mysql_query($sql);
while ($data = mysql_fetch_array($query))
while ($data = mysql_fetch_assoc($query))
{
if ($data[service_status] == "0" && $data[service_ignore] == "1") { $status = "grey"; }
if ($data[service_status] == "1" && $data[service_ignore] == "1") { $status = "green"; }
@@ -68,7 +68,7 @@ if (mysql_affected_rows() > "0")
echo("<div style='background-color: #eeeeee; margin: 5px; padding: 5px;'>");
echo("<p style='padding: 0px 5px 5px;' class=sectionhead><img align='absmiddle' src='".$device['base_url']."/images/16/printer.png'> Recent Syslog</p>");
echo("<table cellspacing=0 cellpadding=2 width=100%>");
while ($entry = mysql_fetch_array($query)) { include("includes/print-syslog.inc.php"); }
while ($entry = mysql_fetch_assoc($query)) { include("includes/print-syslog.inc.php"); }
echo("</table>");
echo("</div>");
}
@@ -101,7 +101,7 @@ $data = mysql_query($query);
echo("<table cellspacing=0 cellpadding=2 width=100%>");
while ($entry = mysql_fetch_array($data))
while ($entry = mysql_fetch_assoc($data))
{
include("includes/print-event-short.inc.php");
}
@@ -9,7 +9,7 @@ if (mysql_num_rows($results))
echo('<p style="padding: 0px 5px 5px;" class="sectionhead"><a class="sectionhead" href="device/'.$device['device_id'].'/health/' . strtolower($sensor_type) . '/"><img align="absmiddle" src="'.$config['base_url'].'/images/icons/' . strtolower($sensor_type) . '.png"> ' . $sensor_type . '</a></p>');
$i = '1';
echo('<table width="100%" valign="top">');
while ($sensor = mysql_fetch_array($results))
while ($sensor = mysql_fetch_assoc($results))
{
if (is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
+1 -1
View File
@@ -12,7 +12,7 @@ if (mysql_result(mysql_query("SELECT count(*) from mempools WHERE device_id = '"
$mempool_rows = '1';
$mempools = mysql_query("SELECT * FROM `mempools` WHERE device_id = '" . $device['device_id'] . "'");
while ($mempool = mysql_fetch_array($mempools))
while ($mempool = mysql_fetch_assoc($mempools))
{
if (is_integer($mempool_rows/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$perc = round($mempool['mempool_used'] / ($mempool['mempool_total']) * 100,2);
+1 -1
View File
@@ -48,7 +48,7 @@ if ($ports['total'])
$query = mysql_query($sql);
$ifsep = "";
while ($data = mysql_fetch_array($query))
while ($data = mysql_fetch_assoc($query))
{
$data = ifNameDescr($data);
$data = array_merge($data, $device);
@@ -12,7 +12,7 @@ if (mysql_result(mysql_query("SELECT count(*) from processors WHERE device_id =
echo("<table width=100% cellspacing=0 cellpadding=5>");
$i = '1';
$procs = mysql_query("SELECT * FROM `processors` WHERE device_id = '" . $device['device_id'] . "' ORDER BY processor_descr ASC");
while ($proc = mysql_fetch_array($procs))
while ($proc = mysql_fetch_assoc($procs))
{
if (is_integer($processor_rows/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
+1 -1
View File
@@ -12,7 +12,7 @@ if (mysql_result(mysql_query("SELECT count(storage_id) from storage WHERE device
$drive_rows = '0';
$drives = mysql_query("SELECT * FROM `storage` WHERE device_id = '" . $device['device_id'] . "' ORDER BY storage_descr ASC");
while ($drive = mysql_fetch_array($drives))
while ($drive = mysql_fetch_assoc($drives))
{
$skipdrive = 0;
+4 -3
View File
@@ -6,9 +6,10 @@ $query = mysql_query($sql);
echo('<table border="0" cellspacing="0" cellpadding="5" width="100%">');
$i = "1";
while ($arp = mysql_fetch_array($query)) {
while ($arp = mysql_fetch_assoc($query))
{
if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
$arp_host = mysql_fetch_array(mysql_query("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = '".$arp['ipv4_address']."' AND I.interface_id = A.interface_id AND D.device_id = I.device_id"));
$arp_host = mysql_fetch_assoc(mysql_query("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = '".$arp['ipv4_address']."' AND I.interface_id = A.interface_id AND D.device_id = I.device_id"));
if ($arp_host) { $arp_name = generate_device_link($arp_host); } else { unset($arp_name); }
if ($arp_host) { $arp_if = generate_port_link($arp_host); } else { unset($arp_if); }
@@ -28,4 +29,4 @@ while ($arp = mysql_fetch_array($query)) {
echo('</table>');
?>
?>
+1 -1
View File
@@ -8,7 +8,7 @@ if (!$graph_type) { $graph_type = "atmvp_bits"; }
echo('<table cellspacing="0" cellpadding="5" border="0">');
$vps = mysql_query("SELECT * FROM juniAtmVp WHERE interface_id = '".$interface['interface_id']."'");
while ($vp = mysql_fetch_array($vps))
while ($vp = mysql_fetch_assoc($vps))
{
if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
echo('<tr bgcolor="'.$row_colour.'">');
+4 -4
View File
@@ -127,20 +127,20 @@ if ($_GET['optd'] == "top10")
`ports` AS I, `devices` AS D WHERE M.interface_id = '".$interface['interface_id']."' AND I.interface_id = M.interface_id
AND I.device_id = D.device_id ORDER BY bps DESC");
while ($acc = mysql_fetch_array($query))
while ($acc = mysql_fetch_assoc($query))
{
if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$addy = mysql_fetch_array(mysql_query("SELECT * FROM ipv4_mac where mac_address = '".$acc['mac']."'"));
$addy = mysql_fetch_assoc(mysql_query("SELECT * FROM ipv4_mac where mac_address = '".$acc['mac']."'"));
$name = gethostbyaddr($addy['ipv4_address']);
$arp_host = mysql_fetch_array(mysql_query("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = '".$addy['ipv4_address']."' AND I.interface_id = A.interface_id AND D.device_id = I.device_id"));
$arp_host = mysql_fetch_assoc(mysql_query("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = '".$addy['ipv4_address']."' AND I.interface_id = A.interface_id AND D.device_id = I.device_id"));
if ($arp_host) { $arp_name = generate_device_link($arp_host); $arp_name .= " ".generate_port_link($arp_host); } else { unset($arp_if); }
if ($name == $addy['ipv4_address']) { unset ($name); }
if (mysql_result(mysql_query("SELECT count(*) FROM bgpPeers WHERE device_id = '".$acc['device_id']."' AND bgpPeerIdentifier = '".$addy['ipv4_address']."'"),0))
{
$peer_query = mysql_query("SELECT * FROM bgpPeers WHERE device_id = '".$acc['device_id']."' AND bgpPeerIdentifier = '".$addy['ipv4_address']."'");
$peer_info = mysql_fetch_array($peer_query);
$peer_info = mysql_fetch_assoc($peer_query);
} else { unset ($peer_info); }
if ($peer_info)
+1 -1
View File
@@ -26,7 +26,7 @@ echo("<a href='/device/".$device['device_id']."/interface/".$interface['interfac
<img src='$yearly_traffic' border=0></a>");
$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_assoc($members))
{
echo("$br<img src='images/16/brick_link.png' align=absmiddle> <strong>" . generate_port_link($member) . " (PAgP)</strong>");
$br = "<br />";
+1 -1
View File
@@ -5,7 +5,7 @@ if (mysql_result(mysql_query("select count(service_id) from services WHERE devic
echo("<div style='margin: 5px;'><table cellpadding=7 border=0 cellspacing=0 width=100%>");
$i = "1";
$service_query = mysql_query("select * from services WHERE device_id = '".$device['device_id']."' ORDER BY service_type");
while ($service = mysql_fetch_array($service_query))
while ($service = mysql_fetch_assoc($service_query))
{
include("includes/print-service.inc.php");
}
+2 -2
View File
@@ -14,7 +14,7 @@ print_optionbar_start('25');
<option value="">All Programs</option>
<?php
$query = mysql_query("SELECT `program` FROM `syslog` WHERE device_id = '" . $device['device_id'] . "' GROUP BY `program` ORDER BY `program`");
while ($data = mysql_fetch_array($query)) {
while ($data = mysql_fetch_assoc($query)) {
echo("<option value='".$data['program']."'");
if ($data['program'] == $_POST['program']) { echo("selected"); }
echo(">".$data['program']."</option>");
@@ -43,7 +43,7 @@ $sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog WHERE
$sql .= " ORDER BY timestamp DESC LIMIT 1000";
$query = mysql_query($sql);
echo("<table cellspacing=0 cellpadding=2 width=100%>");
while ($entry = mysql_fetch_array($query)) { include("includes/print-syslog.inc.php"); }
while ($entry = mysql_fetch_assoc($query)) { include("includes/print-syslog.inc.php"); }
echo("</table>");
?>
+1 -1
View File
@@ -16,7 +16,7 @@ echo('<table border="0" cellspacing="0" cellpadding="5" width="100%">');
$i = "1";
$vlan_query = mysql_query("select * from vlans WHERE device_id = '".$device['device_id']."' ORDER BY 'vlan_vlan'");
while ($vlan = mysql_fetch_array($vlan_query))
while ($vlan = mysql_fetch_assoc($vlan_query))
{
include("includes/print-vlan.inc.php");
$i++;
+1 -1
View File
@@ -5,7 +5,7 @@ echo('<table border="0" cellspacing="0" cellpadding="5" width="100%" class="sort
$i = "1";
$vm_query = mysql_query("SELECT id, vmwVmVMID, vmwVmDisplayName, vmwVmGuestOS, vmwVmMemSize, vmwVmCpus, vmwVmState FROM vmware_vminfo WHERE device_id = '".$device['device_id']."' ORDER BY vmwVmDisplayName");
while ($vm = mysql_fetch_array($vm_query))
while ($vm = mysql_fetch_assoc($vm_query))
{
include("includes/print-vm.inc.php");
$i++;
+1 -1
View File
@@ -14,7 +14,7 @@ print_optionbar_end();
echo("<div style='margin: 5px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$i = "0";
$vrf_query = mysql_query("select * from vrfs WHERE device_id = '".$device['device_id']."' ORDER BY 'vrf_name'");
while ($vrf = mysql_fetch_array($vrf_query))
while ($vrf = mysql_fetch_assoc($vrf_query))
{
include("includes/print-vrf.inc.php");
$i++;