From f55a30f744cc5fc871746d499989c64dd6f567b9 Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Wed, 6 Apr 2011 13:54:50 +0000 Subject: [PATCH] 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 --- alerts.php | 2 +- check-errors.php | 2 +- check-services.php | 2 +- cleanup.php | 14 +-- discovery.php | 6 +- generate-iplist.php | 2 +- html/ajax_listports.php | 2 +- html/billing-graph.php | 4 +- html/css/mktree.css | 4 +- .../includes/authentication/http-auth.inc.php | 6 +- html/includes/authentication/ldap.inc.php | 4 +- html/includes/authentication/mysql.inc.php | 4 +- html/includes/graphs/atmvp/auth.inc.php | 10 +- html/includes/graphs/bill/bits.inc.php | 2 +- .../graphs/cisco_entity_sensor.inc.php | 2 +- html/includes/graphs/customer/bits.inc.php | 2 +- html/includes/graphs/device/current.inc.php | 2 +- .../graphs/device/diskio_bits.inc.php | 2 +- .../includes/graphs/device/diskio_ops.inc.php | 2 +- html/includes/graphs/device/fanspeeds.inc.php | 3 +- .../graphs/device/frequencies.inc.php | 4 +- html/includes/graphs/device/humidity.inc.php | 3 +- html/includes/graphs/device/mempools.inc.php | 3 +- .../includes/graphs/device/processors.inc.php | 2 +- html/includes/graphs/device/storage.inc.php | 3 +- .../graphs/device/temperatures.inc.php | 3 +- html/includes/graphs/device/toner.inc.php | 3 +- html/includes/graphs/device/voltages.inc.php | 3 +- html/includes/graphs/diskio/auth.inc.php | 2 +- html/includes/graphs/diskio/ops.inc.php | 2 +- html/includes/graphs/graph.inc.php | 4 +- .../graphs/multiport/bits_separate.inc.php | 2 +- html/includes/graphs/port/fanspeed.inc.php | 2 +- .../includes/graphs/port/mac_acc_bits.inc.php | 2 +- .../includes/graphs/port/mac_acc_pkts.inc.php | 2 +- .../graphs/port/mac_acc_total.inc.php | 8 +- html/includes/graphs/port/pagp_bits.inc.php | 2 +- html/includes/print-interface.inc.php | 24 ++-- html/includes/print-menubar.php | 2 +- html/includes/print-vlan.inc.php | 2 +- html/includes/print-vrf.inc.php | 16 +-- html/map.php | 8 +- html/pages/addsrv.inc.php | 2 +- html/pages/authlog.inc.php | 2 +- html/pages/bgp.inc.php | 4 +- html/pages/bill.inc.php | 6 +- html/pages/bill/actions.inc.php | 17 ++- html/pages/bill/edit.inc.php | 22 ++-- html/pages/bills.inc.php | 2 +- html/pages/customers.inc.php | 4 +- html/pages/delhost.inc.php | 2 +- html/pages/delsrv.inc.php | 2 +- html/pages/deluser.inc.php | 2 +- html/pages/device/apps.inc.php | 4 +- html/pages/device/arp.inc.php | 4 +- html/pages/device/ciscosensors.inc.php | 6 +- html/pages/device/edit/alerts.inc.php | 2 +- html/pages/device/edit/device.inc.php | 2 +- html/pages/device/edit/ipmi.inc.php | 2 +- html/pages/device/edit/ports.inc.php | 9 +- html/pages/device/edit/services.inc.php | 4 +- html/pages/device/entphysical.inc.php | 4 +- html/pages/device/events.inc.php | 2 +- html/pages/device/health/diskio.inc.php | 2 +- html/pages/device/health/mempools.inc.php | 2 +- html/pages/device/health/processors.inc.php | 2 +- html/pages/device/health/sensors.inc.php | 2 +- html/pages/device/health/storage.inc.php | 2 +- html/pages/device/hrdevice.inc.php | 7 +- html/pages/device/overview.inc.php | 6 +- .../device/overview/generic/sensor.inc.php | 2 +- html/pages/device/overview/mempools.inc.php | 2 +- html/pages/device/overview/ports.inc.php | 2 +- html/pages/device/overview/processors.inc.php | 2 +- html/pages/device/overview/storage.inc.php | 2 +- html/pages/device/port/arp.inc.php | 7 +- html/pages/device/port/junose-atm-vp.inc.php | 2 +- html/pages/device/port/macaccounting.inc.php | 8 +- html/pages/device/port/pagp.inc.php | 2 +- html/pages/device/srv.inc.php | 2 +- html/pages/device/syslog.inc.php | 4 +- html/pages/device/vlans.inc.php | 2 +- html/pages/device/vm.inc.php | 2 +- html/pages/device/vrfs.inc.php | 2 +- html/pages/devices.inc.php | 8 +- html/pages/edituser.inc.php | 16 +-- html/pages/eventlog.inc.php | 2 +- html/pages/front/default.php | 41 +++--- html/pages/front/demo.php | 117 +++++++++--------- html/pages/front/example2.php | 36 +++--- html/pages/front/jt.php | 18 +-- html/pages/health/current.inc.php | 2 +- html/pages/health/fanspeeds.inc.php | 2 +- html/pages/health/frequencies.inc.php | 2 +- html/pages/health/humidity.inc.php | 2 +- html/pages/health/memory.inc.php | 2 +- html/pages/health/processors.inc.php | 3 +- html/pages/health/storage.inc.php | 2 +- html/pages/health/temperatures.inc.php | 2 +- html/pages/health/voltages.inc.php | 2 +- html/pages/iftype.inc.php | 4 +- html/pages/inventory.inc.php | 6 +- html/pages/ipv4.inc.php | 4 +- html/pages/ipv6.inc.php | 4 +- html/pages/list.inc.php | 2 +- html/pages/ports/default.inc.php | 65 +++++----- html/pages/preferences.inc.php | 9 +- html/pages/pseudowires.inc.php | 4 +- html/pages/purgeports.inc.php | 9 +- html/pages/services.inc.php | 4 +- html/pages/storage.inc.php | 2 +- html/pages/syslog.inc.php | 6 +- html/pages/vrf.inc.php | 6 +- html/pages/vrfs.inc.php | 6 +- includes/common.php | 2 +- includes/discovery/arp-table.inc.php | 4 +- includes/discovery/bgp-peers.inc.php | 4 +- .../discovery/cisco-mac-accounting.inc.php | 2 +- includes/discovery/cisco-pw.inc.php | 2 +- includes/discovery/cisco-vlans.inc.php | 2 +- includes/discovery/cisco-vrf.inc.php | 6 +- .../discovery/discovery-protocols.inc.php | 8 +- includes/discovery/entity-physical.inc.php | 2 +- includes/discovery/hr-device.inc.php | 2 +- includes/discovery/ipv4-addresses.inc.php | 2 +- includes/discovery/ipv6-addresses.inc.php | 2 +- includes/discovery/junose-atm-vp.inc.php | 2 +- includes/discovery/mempools.inc.php | 2 +- includes/discovery/ports.inc.php | 2 +- includes/discovery/processors.inc.php | 2 +- includes/discovery/q-bridge-mib.inc.php | 2 +- includes/discovery/storage.inc.php | 2 +- includes/discovery/toner.inc.php | 2 +- includes/discovery/ucd-diskio.inc.php | 2 +- includes/discovery/vmware-vminfo.inc.php | 2 +- includes/functions.php | 6 +- includes/polling/applications.inc.php | 2 +- includes/polling/bgp-peers.inc.php | 2 +- includes/polling/cisco-entity-sensors.inc.php | 2 +- includes/polling/current.inc.php | 2 +- includes/polling/fanspeeds.inc.php | 2 +- includes/polling/frequencies.inc.php | 2 +- includes/polling/humidity.inc.php | 2 +- includes/polling/interfaces.inc.php | 4 +- includes/polling/ipmi.inc.php | 2 +- includes/polling/junose-atm-vp.inc.php | 2 +- includes/polling/mempools.inc.php | 2 +- includes/polling/os/vmware.inc.php | 2 +- includes/polling/ports.inc.php | 2 +- includes/polling/processors.inc.php | 2 +- includes/polling/storage.inc.php | 2 +- includes/polling/temperatures.inc.php | 2 +- includes/polling/toner.inc.php | 2 +- includes/polling/ucd-diskio.inc.php | 2 +- includes/polling/voltages.inc.php | 2 +- includes/snmptrap/linkDown.inc.php | 2 +- includes/snmptrap/linkUp.inc.php | 2 +- irc.php | 6 +- poll-billing.php | 4 +- poll-reachability.php | 77 ++++++------ poller.php | 2 +- snmptrap.php | 4 +- upgrade-scripts/fix-events.php | 2 +- 163 files changed, 476 insertions(+), 460 deletions(-) diff --git a/alerts.php b/alerts.php index 6538350f5..07dafc6e1 100755 --- a/alerts.php +++ b/alerts.php @@ -6,7 +6,7 @@ include("config.php"); include("includes/functions.php"); $alert_query = mysql_query("SELECT *, A.id as id FROM `alerts` as A, `devices` as D where A.device_id = D.device_id AND alerted = '0'"); -while ($alert = mysql_fetch_array($alert_query)) +while ($alert = mysql_fetch_assoc($alert_query)) { $id = $alert['id']; $host = $alert['hostname']; diff --git a/check-errors.php b/check-errors.php index f96182444..be8c88628 100755 --- a/check-errors.php +++ b/check-errors.php @@ -13,7 +13,7 @@ $i = '0'; $interface_query = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id $where"); -while ($interface = mysql_fetch_array($interface_query)) +while ($interface = mysql_fetch_assoc($interface_query)) { $errors = $interface['ifInErrors_delta'] + $interface['ifOutErrors_delta']; if ($errors > '1') diff --git a/check-services.php b/check-services.php index 288becd8c..2f5beac70 100755 --- a/check-services.php +++ b/check-services.php @@ -7,7 +7,7 @@ include("includes/functions.php"); $sql = "SELECT * FROM devices AS D, services AS S WHERE S.device_id = D.device_id ORDER by D.device_id DESC"; $query = mysql_query($sql); -while ($service = mysql_fetch_array($query)) +while ($service = mysql_fetch_assoc($query)) { if ($service['status'] = "1") { diff --git a/cleanup.php b/cleanup.php index ebbff1619..bbced96c1 100755 --- a/cleanup.php +++ b/cleanup.php @@ -12,7 +12,7 @@ $query = "SELECT *,A.id as id FROM ipv4_addresses AS A, ports as I, devices as D $data = mysql_query($query); -while ($row = mysql_fetch_array($data)) +while ($row = mysql_fetch_assoc($data)) { $addr = Net_IPv4::parseAddress($row['ipv4_address']."/".$row['ipv4_prefixlen']); $mask = $addr->netmask; @@ -31,7 +31,7 @@ while ($row = mysql_fetch_array($data)) $sql = "SELECT * FROM devices WHERE status = '1'"; $query = mysql_query($sql); -while ($device = mysql_fetch_array($query)) +while ($device = mysql_fetch_assoc($query)) { echo($device['hostname'] . " \n\n"); @@ -51,7 +51,7 @@ while ($device = mysql_fetch_array($query)) $sql = "SELECT * FROM ip6addr AS A, ports AS I, devices as D WHERE A.interface_id = I.interface_id AND I.device_id = '".$device['device_id']."'"; $data = mysql_query($sql); - while ($row = mysql_fetch_array($data)) + while ($row = mysql_fetch_assoc($data)) { echo($row['ipv6_address'] . "\n"); unset($valid); @@ -66,7 +66,7 @@ while ($device = mysql_fetch_array($query)) $query = "SELECT * FROM ports AS I, devices as D WHERE I.device_id = D.device_id AND D.status = '1'"; $data = mysql_query($query); -while ($row = mysql_fetch_array($data)) +while ($row = mysql_fetch_assoc($data)) { $index = $row['ifIndex']; @@ -87,7 +87,7 @@ while ($row = mysql_fetch_array($data)) echo(mysql_result(mysql_query("SELECT COUNT(*) FROM `ports`"), 0) . " ports at start\n"); $interface_query = mysql_query("SELECT interface_id,device_id FROM `ports`"); -while ($interface = mysql_fetch_array($interface_query)) +while ($interface = mysql_fetch_assoc($interface_query)) { $device_id = $interface['device_id']; $interface_id = $interface['interface_id']; @@ -103,7 +103,7 @@ echo(mysql_result(mysql_query("SELECT COUNT(*) FROM `ports`"), 0) . " ports at e echo(mysql_result(mysql_query("SELECT COUNT(id) FROM `links`"), 0) . " links at start\n"); $link_query = mysql_query("SELECT id,local_interface_id,remote_interface_id FROM `links`"); -while ($link = mysql_fetch_array($link_query)) +while ($link = mysql_fetch_assoc($link_query)) { $id = $link['id']; $src = $link['local_interface_id']; @@ -119,7 +119,7 @@ echo(mysql_result(mysql_query("SELECT COUNT(id) FROM `links`"), 0) . " links at echo(mysql_result(mysql_query("SELECT COUNT(adj_id) FROM `adjacencies`"), 0) . " adjacencies at start\n"); $link_query = mysql_query("SELECT * FROM `adjacencies` AS A, `ports` AS I, `devices` AS D, networks AS N WHERE I.interface_id = A.interface_id AND D.device_id = I.device_id AND N.id = A.network_id"); -while ($link = mysql_fetch_array($link_query)) +while ($link = mysql_fetch_assoc($link_query)) { $id = $link['adj_id']; $netid = $link['network_id']; diff --git a/discovery.php b/discovery.php index 04ed2330f..83968c5cd 100755 --- a/discovery.php +++ b/discovery.php @@ -93,7 +93,7 @@ if (file_exists('.svn')) list(,$dbu_rev) = preg_split('/: /',@shell_exec('svn info database-update.sql|grep ^Revision')); $device_query = mysql_query("SELECT revision FROM `dbSchema`"); - if ($rev = @mysql_fetch_array($device_query)) + if ($rev = @mysql_fetch_assoc($device_query)) { $db_rev = $rev['revision']; } @@ -146,7 +146,7 @@ if (file_exists('.svn')) $discovered_devices = 0; $device_query = mysql_query("SELECT * FROM `devices` WHERE status = 1 AND disabled = 0 $where ORDER BY device_id DESC"); -while ($device = mysql_fetch_array($device_query)) +while ($device = mysql_fetch_assoc($device_query)) { $device_start = utime(); // Start counting device poll time @@ -167,7 +167,7 @@ while ($device = mysql_fetch_array($device_query)) #include("includes/discovery/os.inc.php"); - if($options['m']) + if($options['m']) { if(is_file("includes/discovery/".$options['m'].".inc.php")) { diff --git a/generate-iplist.php b/generate-iplist.php index 3f504e2c5..25574a4a9 100755 --- a/generate-iplist.php +++ b/generate-iplist.php @@ -8,7 +8,7 @@ include("includes/functions.php"); $handle = fopen("ips.txt", "w"); $query = mysql_query("SELECT * FROM `ipv4_networks`"); -while ($data = mysql_fetch_array($query)) +while ($data = mysql_fetch_assoc($query)) { $cidr = $data['ipv4_network']; list ($network, $bits) = explode("/", $cidr); diff --git a/html/ajax_listports.php b/html/ajax_listports.php index 148e1f8e9..60e566021 100755 --- a/html/ajax_listports.php +++ b/html/ajax_listports.php @@ -21,7 +21,7 @@ if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; } if (is_numeric($_GET['device_id'])) { $ports = mysql_query("SELECT * FROM ports WHERE device_id = '".$_GET['device_id']."'"); - while ($interface = mysql_fetch_array($ports)) + while ($interface = mysql_fetch_assoc($ports)) { echo("obj.options[obj.options.length] = new Option('".$interface['ifDescr']." - ".$interface['ifAlias']."','".$interface['interface_id']."');\n"); } diff --git a/html/billing-graph.php b/html/billing-graph.php index c908edd5c..33a05cc28 100755 --- a/html/billing-graph.php +++ b/html/billing-graph.php @@ -58,7 +58,7 @@ $rate_95th = $rate_data['rate_95th'] * 1000; $rate_average = $rate_data['rate_average'] * 1000; $bi_q = mysql_query("SELECT * FROM bills WHERE bill_id = $bill_id"); -$bi_a = mysql_fetch_array($bi_q); +$bi_a = mysql_fetch_assoc($bi_q); $bill_name = $bi_a['bill_name']; $countsql = mysql_query("SELECT count(`delta`) FROM `bill_data` WHERE `bill_id` = '$bill_id' AND `timestamp` >= '$datefrom' AND `timestamp` <= '$dateto'"); @@ -84,7 +84,7 @@ $dur = $end - $start; $sql = "SELECT *, UNIX_TIMESTAMP(timestamp) AS formatted_date FROM bill_data WHERE bill_id = $bill_id AND timestamp >= $datefrom AND timestamp <= $dateto ORDER BY timestamp ASC"; $data = mysql_query($sql); -while ($row = mysql_fetch_array($data)) +while ($row = mysql_fetch_assoc($data)) { @$timestamp = $row['formatted_date']; if (!$first) { $first = $timestamp; } diff --git a/html/css/mktree.css b/html/css/mktree.css index 559a55f83..2dfa51517 100644 --- a/html/css/mktree.css +++ b/html/css/mktree.css @@ -1,7 +1,7 @@ /* Put this inside a @media qualifier so Netscape 4 ignores it */ -@media screen, print { +@media screen, print { /* Turn off list bullets */ - ul.mktree li { list-style: none; } + ul.mktree li { list-style: none; } /* Control how "spaced out" the tree is */ ul.mktree, ul.mktree ul , ul.mktree li { margin-left:10px; padding:0px; } /* Provide space for our own "bullet" inside the LI */ diff --git a/html/includes/authentication/http-auth.inc.php b/html/includes/authentication/http-auth.inc.php index 18391fd7e..cf5d352c0 100644 --- a/html/includes/authentication/http-auth.inc.php +++ b/html/includes/authentication/http-auth.inc.php @@ -10,7 +10,7 @@ function authenticate($username,$password) $sql = "SELECT username FROM `users` WHERE `username`='".$_SESSION['username'] . "'";; $query = mysql_query($sql); - $row = @mysql_fetch_array($query); + $row = @mysql_fetch_assoc($query); if ($row['username'] && $row['username'] == $_SESSION['username']) { return 1; @@ -54,14 +54,14 @@ function user_exists($username) function get_userlevel($username) { $sql = "SELECT level FROM `users` WHERE `username`='".mres($username)."'"; - $row = mysql_fetch_array(mysql_query($sql)); + $row = mysql_fetch_assoc(mysql_query($sql)); return $row['level']; } function get_userid($username) { $sql = "SELECT user_id FROM `users` WHERE `username`='".mres($username)."'"; - $row = mysql_fetch_array(mysql_query($sql)); + $row = mysql_fetch_assoc(mysql_query($sql)); return $row['user_id']; } diff --git a/html/includes/authentication/ldap.inc.php b/html/includes/authentication/ldap.inc.php index 7b3de0f5b..f216ff358 100644 --- a/html/includes/authentication/ldap.inc.php +++ b/html/includes/authentication/ldap.inc.php @@ -68,7 +68,7 @@ function get_userlevel($username) { # FIXME should come from LDAP $sql = "SELECT level FROM `users` WHERE `username`='".mres($username)."'"; - $row = mysql_fetch_array(mysql_query($sql)); + $row = mysql_fetch_assoc(mysql_query($sql)); return $row['level']; } @@ -76,7 +76,7 @@ function get_userid($username) { # FIXME should come from LDAP $sql = "SELECT user_id FROM `users` WHERE `username`='".mres($username)."'"; - $row = mysql_fetch_array(mysql_query($sql)); + $row = mysql_fetch_assoc(mysql_query($sql)); return $row['user_id']; } diff --git a/html/includes/authentication/mysql.inc.php b/html/includes/authentication/mysql.inc.php index c4b6c85f8..08b379b8c 100644 --- a/html/includes/authentication/mysql.inc.php +++ b/html/includes/authentication/mysql.inc.php @@ -84,14 +84,14 @@ function user_exists($username) function get_userlevel($username) { $sql = "SELECT level FROM `users` WHERE `username`='".mres($username)."'"; - $row = mysql_fetch_array(mysql_query($sql)); + $row = mysql_fetch_assoc(mysql_query($sql)); return $row['level']; } function get_userid($username) { $sql = "SELECT user_id FROM `users` WHERE `username`='".mres($username)."'"; - $row = mysql_fetch_array(mysql_query($sql)); + $row = mysql_fetch_assoc(mysql_query($sql)); return $row['user_id']; } diff --git a/html/includes/graphs/atmvp/auth.inc.php b/html/includes/graphs/atmvp/auth.inc.php index b3d230aef..37e641401 100644 --- a/html/includes/graphs/atmvp/auth.inc.php +++ b/html/includes/graphs/atmvp/auth.inc.php @@ -1,16 +1,15 @@ +?> \ No newline at end of file diff --git a/html/includes/graphs/bill/bits.inc.php b/html/includes/graphs/bill/bits.inc.php index 944a50709..d7b83c34e 100644 --- a/html/includes/graphs/bill/bits.inc.php +++ b/html/includes/graphs/bill/bits.inc.php @@ -4,7 +4,7 @@ $i = 0; -while ($port = mysql_fetch_array($ports)) +while ($port = mysql_fetch_assoc($ports)) { if (is_file($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd"))) { diff --git a/html/includes/graphs/cisco_entity_sensor.inc.php b/html/includes/graphs/cisco_entity_sensor.inc.php index d01c2ad16..c43368f5c 100644 --- a/html/includes/graphs/cisco_entity_sensor.inc.php +++ b/html/includes/graphs/cisco_entity_sensor.inc.php @@ -1,6 +1,6 @@ VLAN " . $interface['ifVlan'] . ""); } elseif ($interface['ifVrf']) { - $vrf = mysql_fetch_array(mysql_query("SELECT * FROM vrfs WHERE vrf_id = '".$interface['ifVrf']."'")); + $vrf = mysql_fetch_assoc(mysql_query("SELECT * FROM vrfs WHERE vrf_id = '".$interface['ifVrf']."'")); echo("" . $vrf['vrf_name'] . ""); } } @@ -122,7 +122,7 @@ echo(""); 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_assoc($link_query)) { # echo("Directly Connected " . generate_port_link($link, makeshortif($link['label'])) . " on " . generate_device_link($link, shorthost($link['hostname'])) . "
"); # $br = "
"; @@ -136,7 +136,7 @@ if (strpos($interface['label'], "oopback") === false && !$graph_type) { ## 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_assoc($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 @@ -144,7 +144,7 @@ if (strpos($interface['label'], "oopback") === false && !$graph_type) 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_assoc($new_query)) { echo($new['ipv4_network_id']); $this_ifid = $new['interface_id']; @@ -158,7 +158,7 @@ if (strpos($interface['label'], "oopback") === false && !$graph_type) $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_assoc($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 @@ -166,7 +166,7 @@ if (strpos($interface['label'], "oopback") === false && !$graph_type) 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_assoc($new_query)) { echo($new['ipv6_network_id']); $this_ifid = $new['interface_id']; @@ -181,7 +181,7 @@ if (strpos($interface['label'], "oopback") === false && !$graph_type) 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."'")); + $link_if = mysql_fetch_assoc(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"); @@ -198,11 +198,11 @@ if (strpos($interface['label'], "oopback") === false && !$graph_type) } $pseudowires = mysql_query("SELECT * FROM `pseudowires` WHERE `interface_id` = '" . $interface['interface_id'] . "'"); -while ($pseudowire = mysql_fetch_array($pseudowires)) +while ($pseudowire = mysql_fetch_assoc($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 + $pw_peer_dev = mysql_fetch_assoc(mysql_query("SELECT * from `devices` WHERE `device_id` = '" . $pseudowire['peer_device_id'] . "'")); + $pw_peer_int = mysql_fetch_assoc(mysql_query("SELECT * from `ports` AS I, pseudowires AS P WHERE I.device_id = '".$pseudowire['peer_device_id']."' AND P.cpwVcID = '".$pseudowire['cpwVcID']."' AND P.interface_id = I.interface_id")); $pw_peer_int = ifNameDescr($pw_peer_int); @@ -211,7 +211,7 @@ while ($pseudowire = mysql_fetch_array($pseudowires)) } $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 " . generate_port_link($member) . " (PAgP)"); $br = "
"; @@ -219,7 +219,7 @@ while ($member = mysql_fetch_array($members)) 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']."'")); + $parent = mysql_fetch_assoc(mysql_query("SELECT * FROM `ports` WHERE `ifIndex` = '".$interface['pagpGroupIfIndex']."' and `device_id` = '".$device['device_id']."'")); echo("$br " . generate_port_link($parent) . " (PAgP)"); $br = "
"; } diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index abb5e363d..dbb219eba 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -11,7 +11,7 @@ if (isset($config['enable_bgp']) && $config['enable_bgp']) } $query_a = mysql_query("SELECT * FROM `devices`"); -while ($device = mysql_fetch_array($query_a)) +while ($device = mysql_fetch_assoc($query_a)) { $this_alert = 0; if ($device['status'] == 0 && $device['ignore'] == '0') { $this_alert = "1"; } elseif ($device['ignore'] == '0') diff --git a/html/includes/print-vlan.inc.php b/html/includes/print-vlan.inc.php index dd2c2e5a4..46dc191b0 100644 --- a/html/includes/print-vlan.inc.php +++ b/html/includes/print-vlan.inc.php @@ -9,7 +9,7 @@ echo("" . $vlan['vlan_descr'] . ""); echo(""); $ports_query = mysql_query("SELECT * FROM ports WHERE `device_id` = '" . $device['device_id'] . "' AND `ifVlan` = '" . $vlan['vlan_vlan'] . "' "); -while ($port = mysql_fetch_array($ports_query)) +while ($port = mysql_fetch_assoc($ports_query)) { if ($_GET['opta']) { diff --git a/html/includes/print-vrf.inc.php b/html/includes/print-vrf.inc.php index fd806ffd2..d24329b2e 100644 --- a/html/includes/print-vrf.inc.php +++ b/html/includes/print-vrf.inc.php @@ -8,13 +8,14 @@ echo("" . $vrf['mplsVpnVrfDescription'] . ""); echo("" . $vrf['mplsVpnVrfRouteDistinguisher'] . ""); - -echo(""); +echo(''); $ports_query = mysql_query("SELECT * FROM ports WHERE `device_id` = '" . $device['device_id'] . "' AND `ifVrf` = '" . $vrf['vrf_id'] . "' "); -while ($port = mysql_fetch_array($ports_query)) { - if ($_GET['opta']) { - $graph_type = "port_" . $_GET['opta']; - echo("
+while ($port = mysql_fetch_assoc($ports_query)) +{ + if ($_GET['opta']) + { + $graph_type = "port_" . $_GET['opta']; + echo("
".makeshortif($port['ifDescr'])."
".$device['hostname']." - ".$port['ifDescr']."
\ @@ -30,7 +31,8 @@ while ($port = mysql_fetch_array($ports_query)) { $vrf['port_sep'] = ", "; } } + echo(""); echo(""); -?> +?> \ No newline at end of file diff --git a/html/map.php b/html/map.php index 33ac3cbb2..d6bec1fef 100755 --- a/html/map.php +++ b/html/map.php @@ -42,7 +42,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) } else { - while ($device = mysql_fetch_array($deviceresult)) + while ($device = mysql_fetch_assoc($deviceresult)) { if ($device) { @@ -54,7 +54,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) $map .= "\"".$device['hostname']."\" [fontsize=20 fillcolor=\"lightblue\" URL=\"{$config['base_url']}/device/".$device['device_id']."/map/\" shape=box3d]\n"; } - while ($link = mysql_fetch_array($links)) + while ($link = mysql_fetch_assoc($links)) { $local_interface_id = $link['local_interface_id']; $remote_interface_id = $link['remote_interface_id']; @@ -95,10 +95,10 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) $dst = $link['remote_hostname']; } - $sif = ifNameDescr(mysql_fetch_array(mysql_query("SELECT * FROM ports WHERE `interface_id`=" . $link['local_interface_id'])),$device); + $sif = ifNameDescr(mysql_fetch_assoc(mysql_query("SELECT * FROM ports WHERE `interface_id`=" . $link['local_interface_id'])),$device); if ($remote_interface_id) { - $dif = ifNameDescr(mysql_fetch_array(mysql_query("SELECT * FROM ports WHERE `interface_id`=" . $link['remote_interface_id']))); + $dif = ifNameDescr(mysql_fetch_assoc(mysql_query("SELECT * FROM ports WHERE `interface_id`=" . $link['remote_interface_id']))); } else { $dif['label'] = $link['remote_port']; $dif['interface_id'] = $link['remote_hostname'] . $link['remote_port']; diff --git a/html/pages/addsrv.inc.php b/html/pages/addsrv.inc.php index 55454b3a1..04f5ccd37 100644 --- a/html/pages/addsrv.inc.php +++ b/html/pages/addsrv.inc.php @@ -27,7 +27,7 @@ else } $query = mysql_query("SELECT * FROM `devices` ORDER BY `hostname`"); - while ($device = mysql_fetch_array($query)) + while ($device = mysql_fetch_assoc($query)) { $devicesform .= ""; } diff --git a/html/pages/authlog.inc.php b/html/pages/authlog.inc.php index 2eee68337..e8546b3af 100644 --- a/html/pages/authlog.inc.php +++ b/html/pages/authlog.inc.php @@ -7,7 +7,7 @@ if ($_SESSION['userlevel'] == '10') echo(""); - while ($entry = mysql_fetch_array($data)) + while ($entry = mysql_fetch_assoc($data)) { if ($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; } diff --git a/html/pages/bgp.inc.php b/html/pages/bgp.inc.php index 588c75b78..419f62612 100644 --- a/html/pages/bgp.inc.php +++ b/html/pages/bgp.inc.php @@ -21,7 +21,7 @@ else } $peer_query = mysql_query("select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id $where ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier"); - while ($peer = mysql_fetch_array($peer_query)) + while ($peer = mysql_fetch_assoc($peer_query)) { unset($bg_image); @@ -34,7 +34,7 @@ else if ($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') { $peer_type = "Priv eBGP"; } } - $peerhost = mysql_fetch_array(mysql_query("SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = '".$peer['bgpPeerIdentifier']."' AND I.interface_id = A.interface_id AND D.device_id = I.device_id")); + $peerhost = mysql_fetch_assoc(mysql_query("SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = '".$peer['bgpPeerIdentifier']."' AND I.interface_id = A.interface_id AND D.device_id = I.device_id")); if ($peerhost) { $peername = generate_device_link($peerhost, shorthost($peerhost['hostname'])); } else { unset($peername); } diff --git a/html/pages/bill.inc.php b/html/pages/bill.inc.php index d6be6aac8..e572ccb58 100644 --- a/html/pages/bill.inc.php +++ b/html/pages/bill.inc.php @@ -10,7 +10,7 @@ if ($_SESSION['userlevel'] == "10") if (bill_permitted($bill_id)) { $bi_q = mysql_query("SELECT * FROM bills WHERE bill_id = $bill_id"); - $bill_data = mysql_fetch_array($bi_q); + $bill_data = mysql_fetch_assoc($bi_q); $today = str_replace("-", "", mysql_result(mysql_query("SELECT CURDATE()"), 0)); $yesterday = str_replace("-", "", mysql_result(mysql_query("SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)"), 0)); @@ -102,7 +102,7 @@ if (bill_permitted($bill_id)) WHERE B.bill_id = '".$bill_id."' AND P.interface_id = B.port_id AND D.device_id = P.device_id"); - while ($port = mysql_fetch_array($ports)) + while ($port = mysql_fetch_assoc($ports)) { echo(generate_port_link($port) . " on " . generate_device_link($port) . "
"); } @@ -258,4 +258,4 @@ else include("includes/error-no-perm.inc.php"); } -?> +?> \ No newline at end of file diff --git a/html/pages/bill/actions.inc.php b/html/pages/bill/actions.inc.php index 59b2c6536..be80777e1 100644 --- a/html/pages/bill/actions.inc.php +++ b/html/pages/bill/actions.inc.php @@ -1,9 +1,10 @@ Bill Deleted. Redirecting to Bills list."); echo(""); - } - if ($_POST['action'] == "add_bill_port") { mysql_query("INSERT INTO `bill_ports` (`bill_id`, `port_id`) VALUES ('".mres($_POST['bill_id'])."','".mres($_POST['interface_id'])."')"); } if ($_POST['action'] == "delete_bill_port") { mysql_query("DELETE FROM `bill_ports` WHERE `bill_id` = '".mres($bill_id)."' AND `port_id` = '".mres($_POST['interface_id'])."'"); } -if ($_POST['action'] == "update_bill") { +if ($_POST['action'] == "update_bill") +{ mysql_query("UPDATE `bills` SET `bill_name` = '".mres($_POST['bill_name'])."', `bill_day` = '".mres($_POST['bill_day'])."', `bill_gb` = '".mres($_POST['bill_gb'])."', @@ -32,9 +32,8 @@ if ($_POST['action'] == "update_bill") { if (mysql_affected_rows()) { - echo("
Bill Properties Updated
"); + print_message("Bill Properties Updated"); } - } -?> +?> \ No newline at end of file diff --git a/html/pages/bill/edit.inc.php b/html/pages/bill/edit.inc.php index b156ca287..e3eec3fea 100644 --- a/html/pages/bill/edit.inc.php +++ b/html/pages/bill/edit.inc.php @@ -69,11 +69,10 @@ $ports_array = mysql_query("SELECT * FROM `bill_ports` AS B, `ports` AS P, `devi if (mysql_affected_rows()) { - echo("

Billed Ports

"); echo("
"); - while ($port = mysql_fetch_array($ports_array)) + while ($port = mysql_fetch_assoc($ports_array)) { if ($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; } echo(""); @@ -89,9 +88,9 @@ if (mysql_affected_rows()) echo("
"); } - echo("

Add Port

"); +echo("

Add Port

"); - echo("
+echo(" @@ -99,14 +98,15 @@ if (mysql_affected_rows()) +echo(" Interface:
"); diff --git a/html/pages/bills.inc.php b/html/pages/bills.inc.php index f18ee5e96..2f71806b9 100644 --- a/html/pages/bills.inc.php +++ b/html/pages/bills.inc.php @@ -123,7 +123,7 @@ if ($_GET['opta'] == "add") $query = mysql_query($sql); echo(""); $i=1; - while ($bill = mysql_fetch_array($query)) + while ($bill = mysql_fetch_assoc($query)) { #echo("
");
     #print_r($permissions);
diff --git a/html/pages/customers.inc.php b/html/pages/customers.inc.php
index 617883a17..c3638be61 100644
--- a/html/pages/customers.inc.php
+++ b/html/pages/customers.inc.php
@@ -19,7 +19,7 @@ echo("
 
 $i = 1;
 
-while ($customer = mysql_fetch_array($cust_query))
+while ($customer = mysql_fetch_assoc($cust_query))
 {
   $i++;
 
@@ -30,7 +30,7 @@ while ($customer = mysql_fetch_array($cust_query))
 
   if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
 
-  while ($port = mysql_fetch_array($port_query))
+  while ($port = mysql_fetch_assoc($port_query))
   {
     $device = device_by_id_cache($port['device_id']);
 
diff --git a/html/pages/delhost.inc.php b/html/pages/delhost.inc.php
index ae8bdfaff..c0a0d373a 100644
--- a/html/pages/delhost.inc.php
+++ b/html/pages/delhost.inc.php
@@ -22,7 +22,7 @@ if ($_REQUEST['id'])
 
 $query = mysql_query("SELECT * FROM `devices` ORDER BY `hostname`");
 
-while ($data = mysql_fetch_array($query))
+while ($data = mysql_fetch_assoc($query))
 {
   echo("");
 }
diff --git a/html/pages/delsrv.inc.php b/html/pages/delsrv.inc.php
index 67a02517d..023f45ba4 100644
--- a/html/pages/delsrv.inc.php
+++ b/html/pages/delsrv.inc.php
@@ -13,7 +13,7 @@ if ($_SESSION['userlevel'] < '5')
   }
 
   $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))
+  while ($device = mysql_fetch_assoc($query))
   {
     $servicesform .= "";
   }
diff --git a/html/pages/deluser.inc.php b/html/pages/deluser.inc.php
index 077d855e6..f697008b2 100644
--- a/html/pages/deluser.inc.php
+++ b/html/pages/deluser.inc.php
@@ -25,7 +25,7 @@ if ($_SESSION['userlevel'] < '10') { include("includes/error-no-perm.inc.php");
 
     # FIXME v mysql query should be replaced by authmodule
     $userlist = mysql_query("SELECT * FROM `users`");
-    while ($userentry = mysql_fetch_array($userlist))
+    while ($userentry = mysql_fetch_assoc($userlist))
     {
       $i++;
       echo($i . ". " . $userentry['username'] . "
diff --git a/html/pages/device/apps.inc.php b/html/pages/device/apps.inc.php
index ca4345e76..fe7889b7f 100644
--- a/html/pages/device/apps.inc.php
+++ b/html/pages/device/apps.inc.php
@@ -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"))
 {
diff --git a/html/pages/device/arp.inc.php b/html/pages/device/arp.inc.php
index 1f26584fd..4ac34823f 100644
--- a/html/pages/device/arp.inc.php
+++ b/html/pages/device/arp.inc.php
@@ -7,11 +7,11 @@ echo('
'); $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); } diff --git a/html/pages/device/ciscosensors.inc.php b/html/pages/device/ciscosensors.inc.php index 1399814fa..fc3ad9c16 100644 --- a/html/pages/device/ciscosensors.inc.php +++ b/html/pages/device/ciscosensors.inc.php @@ -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("

".$measured['entPhysicalName']." ".$data['entPhysicalName']."

"); diff --git a/html/pages/device/edit/alerts.inc.php b/html/pages/device/edit/alerts.inc.php index e339beeb1..2e9679c11 100644 --- a/html/pages/device/edit/alerts.inc.php +++ b/html/pages/device/edit/alerts.inc.php @@ -17,7 +17,7 @@ if ($_POST['editing']) } else { - include("includes/error-no-perm.inc.php"); + include("includes/error-no-perm.inc.php"); } } diff --git a/html/pages/device/edit/device.inc.php b/html/pages/device/edit/device.inc.php index 7ba7920a1..9054bc5f0 100644 --- a/html/pages/device/edit/device.inc.php +++ b/html/pages/device/edit/device.inc.php @@ -44,7 +44,7 @@ if ($_POST['editing']) } else { - include("includes/error-no-perm.inc.php"); + include("includes/error-no-perm.inc.php"); } } diff --git a/html/pages/device/edit/ipmi.inc.php b/html/pages/device/edit/ipmi.inc.php index 400f95426..0e8011728 100644 --- a/html/pages/device/edit/ipmi.inc.php +++ b/html/pages/device/edit/ipmi.inc.php @@ -17,7 +17,7 @@ if ($_POST['editing']) } else { - include("includes/error-no-perm.inc.php"); + include("includes/error-no-perm.inc.php"); } } diff --git a/html/pages/device/edit/ports.inc.php b/html/pages/device/edit/ports.inc.php index b9aaf529b..ef113b3b2 100644 --- a/html/pages/device/edit/ports.inc.php +++ b/html/pages/device/edit/ports.inc.php @@ -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(""); echo("
"); - echo(" -"); + echo("\n"); $row++; - } echo('
".$port['ifAlias'] . "
'); echo(''); echo('
'); -?> +?> \ No newline at end of file diff --git a/html/pages/device/edit/services.inc.php b/html/pages/device/edit/services.inc.php index 767175dc8..be2957dd7 100644 --- a/html/pages/device/edit/services.inc.php +++ b/html/pages/device/edit/services.inc.php @@ -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 .= ""; } @@ -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 .= ""; } diff --git a/html/pages/device/entphysical.inc.php b/html/pages/device/entphysical.inc.php index 890363c96..5b725c777 100644 --- a/html/pages/device/entphysical.inc.php +++ b/html/pages/device/entphysical.inc.php @@ -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("
  • "); @@ -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); } diff --git a/html/pages/device/events.inc.php b/html/pages/device/events.inc.php index 3e26133e4..fd49738db 100644 --- a/html/pages/device/events.inc.php +++ b/html/pages/device/events.inc.php @@ -4,7 +4,7 @@ $query = "SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `even $data = mysql_query($query); echo(''); -while ($entry = mysql_fetch_array($data)) +while ($entry = mysql_fetch_assoc($data)) { include("includes/print-event.inc.php"); } diff --git a/html/pages/device/health/diskio.inc.php b/html/pages/device/health/diskio.inc.php index 8e5bd6818..e558de469 100644 --- a/html/pages/device/health/diskio.inc.php +++ b/html/pages/device/health/diskio.inc.php @@ -14,7 +14,7 @@ echo('
    '); $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; } diff --git a/html/pages/device/health/mempools.inc.php b/html/pages/device/health/mempools.inc.php index 1d2caf857..440a96763 100644 --- a/html/pages/device/health/mempools.inc.php +++ b/html/pages/device/health/mempools.inc.php @@ -8,7 +8,7 @@ echo("
    "); $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; } diff --git a/html/pages/device/health/processors.inc.php b/html/pages/device/health/processors.inc.php index bc4f668ac..c414acbe6 100644 --- a/html/pages/device/health/processors.inc.php +++ b/html/pages/device/health/processors.inc.php @@ -7,7 +7,7 @@ echo("
    "); $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/"; diff --git a/html/pages/device/health/sensors.inc.php b/html/pages/device/health/sensors.inc.php index 697bccc4f..f71dd6f69 100644 --- a/html/pages/device/health/sensors.inc.php +++ b/html/pages/device/health/sensors.inc.php @@ -7,7 +7,7 @@ echo("
    "); $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; } diff --git a/html/pages/device/health/storage.inc.php b/html/pages/device/health/storage.inc.php index 6cf02b496..b2838c449 100644 --- a/html/pages/device/health/storage.inc.php +++ b/html/pages/device/health/storage.inc.php @@ -16,7 +16,7 @@ echo(" $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; } diff --git a/html/pages/device/hrdevice.inc.php b/html/pages/device/hrdevice.inc.php index c9c43c340..c3de1e9ff 100644 --- a/html/pages/device/hrdevice.inc.php +++ b/html/pages/device/hrdevice.inc.php @@ -3,7 +3,7 @@ echo("
    "); $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(""); @@ -30,8 +30,9 @@ while ($hrdevice = mysql_fetch_array($hrdevices)) echo(''); } 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(""); $graph_array['height'] = "20"; diff --git a/html/pages/device/overview.inc.php b/html/pages/device/overview.inc.php index 84320aa29..8613c44d1 100644 --- a/html/pages/device/overview.inc.php +++ b/html/pages/device/overview.inc.php @@ -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("
    "); echo("

    Recent Syslog

    "); echo("
    ".$hrdevice['hrDeviceIndex']."'.$mini_graph.'".generate_port_link($interface)."
    "); - 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("
    "); echo(""); } @@ -101,7 +101,7 @@ $data = mysql_query($query); echo(""); -while ($entry = mysql_fetch_array($data)) +while ($entry = mysql_fetch_assoc($data)) { include("includes/print-event-short.inc.php"); } diff --git a/html/pages/device/overview/generic/sensor.inc.php b/html/pages/device/overview/generic/sensor.inc.php index 366354a28..1eafc70b3 100644 --- a/html/pages/device/overview/generic/sensor.inc.php +++ b/html/pages/device/overview/generic/sensor.inc.php @@ -9,7 +9,7 @@ if (mysql_num_rows($results)) echo('

    ' . $sensor_type . '

    '); $i = '1'; echo('
    '); - 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; } diff --git a/html/pages/device/overview/mempools.inc.php b/html/pages/device/overview/mempools.inc.php index 9d0be5ed6..516f18d4a 100644 --- a/html/pages/device/overview/mempools.inc.php +++ b/html/pages/device/overview/mempools.inc.php @@ -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); diff --git a/html/pages/device/overview/ports.inc.php b/html/pages/device/overview/ports.inc.php index 9c8b8e4b1..9d7a29438 100644 --- a/html/pages/device/overview/ports.inc.php +++ b/html/pages/device/overview/ports.inc.php @@ -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); diff --git a/html/pages/device/overview/processors.inc.php b/html/pages/device/overview/processors.inc.php index 456803857..d6d09392e 100644 --- a/html/pages/device/overview/processors.inc.php +++ b/html/pages/device/overview/processors.inc.php @@ -12,7 +12,7 @@ if (mysql_result(mysql_query("SELECT count(*) from processors WHERE device_id = echo("
    "); $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; } diff --git a/html/pages/device/overview/storage.inc.php b/html/pages/device/overview/storage.inc.php index 9bda9bf00..4159d183f 100644 --- a/html/pages/device/overview/storage.inc.php +++ b/html/pages/device/overview/storage.inc.php @@ -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; diff --git a/html/pages/device/port/arp.inc.php b/html/pages/device/port/arp.inc.php index bad24bad5..57d023045 100644 --- a/html/pages/device/port/arp.inc.php +++ b/html/pages/device/port/arp.inc.php @@ -6,9 +6,10 @@ $query = mysql_query($sql); echo('
    '); $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('
    '); -?> +?> \ No newline at end of file diff --git a/html/pages/device/port/junose-atm-vp.inc.php b/html/pages/device/port/junose-atm-vp.inc.php index b8b288045..556432b76 100644 --- a/html/pages/device/port/junose-atm-vp.inc.php +++ b/html/pages/device/port/junose-atm-vp.inc.php @@ -8,7 +8,7 @@ if (!$graph_type) { $graph_type = "atmvp_bits"; } echo(''); $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(''); diff --git a/html/pages/device/port/macaccounting.inc.php b/html/pages/device/port/macaccounting.inc.php index a801d7c4e..abca23d68 100644 --- a/html/pages/device/port/macaccounting.inc.php +++ b/html/pages/device/port/macaccounting.inc.php @@ -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) diff --git a/html/pages/device/port/pagp.inc.php b/html/pages/device/port/pagp.inc.php index e199411c5..b9cd00f8d 100644 --- a/html/pages/device/port/pagp.inc.php +++ b/html/pages/device/port/pagp.inc.php @@ -26,7 +26,7 @@ echo(""); $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" . generate_port_link($member) . " (PAgP)"); $br = "
    "; diff --git a/html/pages/device/srv.inc.php b/html/pages/device/srv.inc.php index 8167a644a..91c66ed97 100644 --- a/html/pages/device/srv.inc.php +++ b/html/pages/device/srv.inc.php @@ -5,7 +5,7 @@ if (mysql_result(mysql_query("select count(service_id) from services WHERE devic echo("
    "); $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"); } diff --git a/html/pages/device/syslog.inc.php b/html/pages/device/syslog.inc.php index 4ccc24685..ed2d4603d 100644 --- a/html/pages/device/syslog.inc.php +++ b/html/pages/device/syslog.inc.php @@ -14,7 +14,7 @@ print_optionbar_start('25'); ".$data['program'].""); @@ -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("
    "); -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("
    "); ?> \ No newline at end of file diff --git a/html/pages/device/vlans.inc.php b/html/pages/device/vlans.inc.php index 1da742177..e490a356b 100644 --- a/html/pages/device/vlans.inc.php +++ b/html/pages/device/vlans.inc.php @@ -16,7 +16,7 @@ echo(''); $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++; diff --git a/html/pages/device/vm.inc.php b/html/pages/device/vm.inc.php index d76778b0f..d0ff8fd66 100644 --- a/html/pages/device/vm.inc.php +++ b/html/pages/device/vm.inc.php @@ -5,7 +5,7 @@ echo('
    "); $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++; diff --git a/html/pages/devices.inc.php b/html/pages/devices.inc.php index e3a2f1e86..4c1fa5997 100644 --- a/html/pages/devices.inc.php +++ b/html/pages/devices.inc.php @@ -28,7 +28,7 @@ print_optionbar_start(62); All VersionsAll PlatformsAll Featuresets

    " . $user_data['realname'] . "

    Change...

    "); // Perform actions if requested @@ -61,7 +61,7 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); echo("

    Device Access

    "); $device_perm_data = mysql_query("SELECT * from devices_perms as P, devices as D WHERE `user_id` = '" . $_GET['user_id'] . "' AND D.device_id = P.device_id"); - while ($device_perm = mysql_fetch_array($device_perm_data)) + while ($device_perm = mysql_fetch_assoc($device_perm_data)) { echo("" . $device_perm['hostname'] . "
    "); $access_list[] = $device_perm['device_id']; @@ -79,7 +79,7 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
    ".$interface_perm['hostname']." - ".$interface_perm['ifDescr']."
    ". "" . $interface_perm['ifAlias'] . "
      Select a device"); $device_list = mysql_query("SELECT * FROM `devices` ORDER BY hostname"); - while ($device = mysql_fetch_array($device_list)) + while ($device = mysql_fetch_assoc($device_list)) { unset($done); foreach ($access_list as $ac) { if ($ac == $device['device_id']) { $done = 1; } } @@ -137,7 +137,7 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); $bill_perm_data = mysql_query("SELECT * from bills AS B, bill_perms AS P WHERE P.user_id = '" . $_GET['user_id'] . "' AND P.bill_id = B.bill_id"); - while ($bill_perm = mysql_fetch_array($bill_perm_data)) + while ($bill_perm = mysql_fetch_assoc($bill_perm_data)) { echo("
    ".$bill_perm['bill_name']."  
    "); @@ -157,7 +157,7 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); '); -while ($entry = mysql_fetch_array($data)) +while ($entry = mysql_fetch_assoc($data)) { include("includes/print-event.inc.php"); } diff --git a/html/pages/front/default.php b/html/pages/front/default.php index ccea43db5..854d26938 100644 --- a/html/pages/front/default.php +++ b/html/pages/front/default.php @@ -15,7 +15,7 @@ $sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = } else { $sql = mysql_query("SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '0' AND D.ignore = '0'"); } -while ($device = mysql_fetch_array($sql)){ +while ($device = mysql_fetch_assoc($sql)){ generate_front_box("#ffaaaa", "
    ".generate_device_link($device, shorthost($device['hostname']))."
    Device Down
    @@ -33,7 +33,7 @@ $sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D, devices_perms AS ### These things need to become more generic, and more manageable across different frontpages... rewrite inc :> -while ($interface = mysql_fetch_array($sql)) +while ($interface = mysql_fetch_assoc($sql)) { if (!$interface['deleted']) { @@ -49,7 +49,7 @@ while ($interface = mysql_fetch_array($sql)) /* FIXME service permissions? seem nonexisting now.. */ $sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"); -while ($service = mysql_fetch_array($sql)) +while ($service = mysql_fetch_assoc($sql)) { generate_front_box("#ffaaaa", "
    ".generate_device_link($service, shorthost($service['hostname']))."
    Service Down @@ -66,7 +66,7 @@ if (isset($config['enable_bgp']) && $config['enable_bgp']) } else { $sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND bgpPeerState != 'established' AND bgpPeerState != '' AND B.device_id = D.device_id AND D.ignore = 0"); } - while ($peer = mysql_fetch_array($sql)) + while ($peer = mysql_fetch_assoc($sql)) { generate_front_box("#ffaaaa", "
    ".generate_device_link($peer, shorthost($peer['hostname']))."
    BGP Down @@ -82,7 +82,9 @@ $sql = mysql_query("SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.upti } else { $sql = mysql_query("SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '1' AND D.uptime < '84600' AND D.ignore = 0"); } -while ($device = mysql_fetch_array($sql)){ + +while ($device = mysql_fetch_assoc($sql)) +{ generate_front_box("#aaffaa", "
    ".generate_device_link($device, shorthost($device['hostname']))."
    Device
    Rebooted

    ".formatUptime($device['uptime'], 'short')." @@ -100,7 +102,8 @@ if ($config['enable_syslog']) $sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; $query = mysql_query($sql); echo("
    "); - while ($entry = mysql_fetch_array($query)) { + while ($entry = mysql_fetch_assoc($query)) + { $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); include("includes/print-syslog.inc.php"); } @@ -115,23 +118,23 @@ if ($config['enable_syslog'])

    Recent Eventlog Entries

    "); -if ($_SESSION['userlevel'] == '10') -{ - $query = "SELECT *,DATE_FORMAT(datetime, '%D %b %T') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; -} else { - $query = "SELECT *,DATE_FORMAT(datetime, '%D %b %T') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = - P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; -} + if ($_SESSION['userlevel'] == '10') + { + $query = "SELECT *,DATE_FORMAT(datetime, '%D %b %T') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; + } else { + $query = "SELECT *,DATE_FORMAT(datetime, '%D %b %T') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = + P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; + } -$data = mysql_query($query); + $data = mysql_query($query); -echo("
    "); + echo('
    '); -while ($entry = mysql_fetch_array($data)) { - include("includes/print-event.inc.php"); -} + while ($entry = mysql_fetch_assoc($data)) { + include("includes/print-event.inc.php"); + } -echo("
    "); + echo("
    "); echo(""); ## Close Syslog Div } diff --git a/html/pages/front/demo.php b/html/pages/front/demo.php index bca864397..ae07bf094 100644 --- a/html/pages/front/demo.php +++ b/html/pages/front/demo.php @@ -33,64 +33,68 @@ while ($device = mysql_fetch_array($sql)){ } } -if ($config['warn']['ifdown']) { - -$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"); -while ($interface = mysql_fetch_array($sql)){ - if (port_permitted($interface['interface_id'])) { - echo("
    +if ($config['warn']['ifdown']) +{ + $sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"); + while ($interface = mysql_fetch_array($sql)) + { + if (port_permitted($interface['interface_id'])) + { + echo("
    ".generate_device_link($interface, shorthost($interface['hostname']))."
    Port Down
    ".generate_port_link($interface, makeshortif($interface['ifDescr']))."
    ".truncate($interface['ifAlias'], 15)."
    "); - } -} - + } + } } $sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"); -while ($service = mysql_fetch_array($sql)){ - if (device_permitted($service['device_id'])) { - echo("
    +while ($service = mysql_fetch_array($sql)) +{ + if (device_permitted($service['device_id'])) + { + echo("
    ".generate_device_link($service, shorthost($service['hostname']))."
    Service Down
    ".$service['service_type']."
    ".truncate($interface['ifAlias'], 15)."
    "); - } + } } $sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id"); -while ($peer = mysql_fetch_array($sql)){ - if (device_permitted($peer['device_id'])) { - echo("
    +while ($peer = mysql_fetch_array($sql)) +{ + if (device_permitted($peer['device_id'])) + { + echo("
    ".generate_device_link($peer, shorthost($peer['hostname']))."
    BGP Down
    ".$peer['bgpPeerIdentifier']."
    AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)."
    "); - } + } } $sql = mysql_query("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '84600' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"); -while ($device = mysql_fetch_array($sql)){ - if (device_permitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime") { - echo("
    +while ($device = mysql_fetch_array($sql)) +{ + if (device_permitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime") + { + echo("
    ".generate_device_link($device, shorthost($device['hostname']))."
    Device
    Rebooted

    ".formatUptime($device['attrib_value'])."
    "); - } + } } - echo(" -
    $errorboxes

    Recent Syslog Messages

    - "); $sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from `syslog` ORDER BY seq DESC LIMIT 20"; @@ -101,50 +105,45 @@ while ($entry = mysql_fetch_array($query)) $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); include("includes/print-syslog.inc.php"); } + echo(""); echo("
    - "); - /// this stuff can be customised to show whatever you want.... - - $ports['fileserver'] = "78"; $ports['broadband'] = "228,251,182"; $ports['homeserver'] = "256,245,74"; - echo("
    "); +echo("
    "); - if ($ports['fileserver']) { +if ($ports['fileserver']) +{ + echo("
    "); + echo("
    Central Fileserver
    "); - echo("
    "); - echo("
    Central Fileserver
    "); + $graph_array['height'] = "100"; + $graph_array['width'] = "385"; + $graph_array['to'] = $now; + $graph_array['id'] = $ports['fileserver']; + $graph_array['type'] = "port_bits"; + $graph_array['from'] = $day; + $graph_array['legend'] = "no"; - $graph_array['height'] = "100"; - $graph_array['width'] = "385"; - $graph_array['to'] = $now; - $graph_array['id'] = $ports['fileserver']; - $graph_array['type'] = "port_bits"; - $graph_array['from'] = $day; - $graph_array['legend'] = "no"; + $graph_array['popup_title'] = "Central Fileserver"; - $graph_array['popup_title'] = "Central Fileserver"; - - print_graph_popup($graph_array); - - echo("
    "); - - } + print_graph_popup($graph_array); echo("
    "); +} - echo("
    "); +echo("
    "); - echo(""); +echo("
    "); - echo("
    "); +echo(""); +echo("
    "); - echo("
    "); +echo(""); - - +echo("
    "); ?> diff --git a/html/pages/front/example2.php b/html/pages/front/example2.php index 181b3524c..3429c3ca0 100644 --- a/html/pages/front/example2.php +++ b/html/pages/front/example2.php @@ -11,7 +11,7 @@ $nodes = array(); $sql = mysql_query("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' AND A.attrib_value < '86400'"); -while ($device = mysql_fetch_array($sql)) +while ($device = mysql_fetch_assoc($sql)) { unset($already); $i = 0; @@ -28,7 +28,7 @@ while ($device = mysql_fetch_array($sql)) } $sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"); -while ($device = mysql_fetch_array($sql)){ +while ($device = mysql_fetch_assoc($sql)){ echo("
    ".generate_device_link($device, shorthost($device['hostname']))."
    @@ -39,7 +39,7 @@ while ($device = mysql_fetch_array($sql)){ } $sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"); -while ($interface = mysql_fetch_array($sql)){ +while ($interface = mysql_fetch_assoc($sql)){ echo("
    ".generate_device_link($interface, shorthost($interface['hostname']))."
    @@ -51,7 +51,7 @@ while ($interface = mysql_fetch_array($sql)){ } $sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"); -while ($service = mysql_fetch_array($sql)){ +while ($service = mysql_fetch_assoc($sql)){ echo("
    ".generate_device_link($service, shorthost($service['hostname']))."
    @@ -63,7 +63,7 @@ while ($service = mysql_fetch_array($sql)){ } $sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND B.device_id = D.device_id"); -while ($peer = mysql_fetch_array($sql)){ +while ($peer = mysql_fetch_assoc($sql)){ echo("
    ".generate_device_link($peer, shorthost($peer['hostname']))."
    @@ -75,7 +75,7 @@ while ($peer = mysql_fetch_array($sql)){ } $sql = mysql_query("SELECT * FROM `devices` AS D, devices_attribs AS A WHERE A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value < '84600'"); -while ($device = mysql_fetch_array($sql)){ +while ($device = mysql_fetch_assoc($sql)){ echo("
    ".generate_device_link($device, shorthost($device['hostname']))."
    @@ -96,7 +96,7 @@ echo(" $sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; $query = mysql_query($sql); echo(""); -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("
    "); @@ -108,13 +108,14 @@ echo("
    /// this stuff can be customised to show whatever you want.... -if ($_SESSION['userlevel'] >= '5') { - +if ($_SESSION['userlevel'] >= '5') +{ $sql = "select * from ports as I, devices as D WHERE `ifAlias` like 'L2TP: %' AND I.device_id = D.device_id AND D.hostname LIKE '%"; $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; $query = mysql_query($sql); unset ($seperator); - while ($interface = mysql_fetch_array($query)) { + while ($interface = mysql_fetch_assoc($query)) + { $ports['l2tp'] .= $seperator . $interface['interface_id']; $seperator = ","; } @@ -123,7 +124,8 @@ if ($_SESSION['userlevel'] >= '5') { $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; $query = mysql_query($sql); unset ($seperator); - while ($interface = mysql_fetch_array($query)) { + while ($interface = mysql_fetch_assoc($query)) + { $ports['transit'] .= $seperator . $interface['interface_id']; $seperator = ","; } @@ -132,12 +134,14 @@ if ($_SESSION['userlevel'] >= '5') { $sql .= $config['mydomain'] . "' ORDER BY I.ifAlias"; $query = mysql_query($sql); unset ($seperator); - while ($interface = mysql_fetch_array($query)) { + while ($interface = mysql_fetch_assoc($query)) + { $ports['voip'] .= $seperator . $interface['interface_id']; $seperator = ","; } - if ($ports['transit']) { + if ($ports['transit']) + { echo("', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". "
    Internet Transit
    ". @@ -145,7 +149,8 @@ if ($_SESSION['userlevel'] >= '5') { "&from=".$day."&to=".$now."&width=200&height=100'>
    "); } - if ($ports['l2tp']) { + if ($ports['l2tp']) + { echo("', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". "
    L2TP ADSL
    ". @@ -153,7 +158,8 @@ if ($_SESSION['userlevel'] >= '5') { "&from=".$day."&to=".$now."&width=200&height=100'>
    "); } - if ($ports['voip']) { + if ($ports['voip']) + { echo("', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". "
    VoIP to PSTN
    ". diff --git a/html/pages/front/jt.php b/html/pages/front/jt.php index 408d60d87..4da90a45f 100644 --- a/html/pages/front/jt.php +++ b/html/pages/front/jt.php @@ -8,7 +8,7 @@ $nodes = array(); $sql = mysql_query("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' AND A.attrib_value < '86400'"); -while ($device = mysql_fetch_array($sql)){ +while ($device = mysql_fetch_assoc($sql)){ unset($already); $i = 0; while ($i <= count($nodes)) { @@ -23,7 +23,7 @@ while ($device = mysql_fetch_array($sql)){ $sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"); -while ($device = mysql_fetch_array($sql)){ +while ($device = mysql_fetch_assoc($sql)){ if (device_permitted($device['device_id'])) { echo("
    ".generate_device_link($device, shorthost($device['hostname']))."
    @@ -36,7 +36,7 @@ while ($device = mysql_fetch_array($sql)){ if ($config['warn']['ifdown']) { $sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"); -while ($interface = mysql_fetch_array($sql)){ +while ($interface = mysql_fetch_assoc($sql)){ if (port_permitted($interface['interface_id'])) { echo("
    ".generate_device_link($interface, shorthost($interface['hostname']))."
    @@ -50,7 +50,7 @@ while ($interface = mysql_fetch_array($sql)){ } $sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"); -while ($service = mysql_fetch_array($sql)){ +while ($service = mysql_fetch_assoc($sql)){ if (device_permitted($service['device_id'])) { echo("
    ".generate_device_link($service, shorthost($service['hostname']))."
    @@ -62,7 +62,7 @@ while ($service = mysql_fetch_array($sql)){ } $sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id"); -while ($peer = mysql_fetch_array($sql)){ +while ($peer = mysql_fetch_assoc($sql)){ if (device_permitted($peer['device_id'])) { echo("
    ".generate_device_link($peer, shorthost($peer['hostname']))."
    @@ -74,7 +74,7 @@ while ($peer = mysql_fetch_array($sql)){ } $sql = mysql_query("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '84600' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"); -while ($device = mysql_fetch_array($sql)){ +while ($device = mysql_fetch_assoc($sql)){ if (device_permitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime") { echo("
    ".generate_device_link($device, shorthost($device['hostname']))."
    @@ -96,7 +96,7 @@ echo(" $sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20"; $query = mysql_query($sql); echo(""); -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("
    "); @@ -114,7 +114,7 @@ if ($_SESSION['userlevel'] >= '5') $sql = "select * from ports as I, devices as D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; $query = mysql_query($sql); unset ($seperator); - while ($interface = mysql_fetch_array($query)) { + while ($interface = mysql_fetch_assoc($query)) { $ports['transit'] .= $seperator . $interface['interface_id']; $seperator = ","; } @@ -122,7 +122,7 @@ if ($_SESSION['userlevel'] >= '5') $sql = "select * from ports as I, devices as D WHERE `ifAlias` like 'Peering: %' AND I.device_id = D.device_id ORDER BY I.ifAlias"; $query = mysql_query($sql); unset ($seperator); - while ($interface = mysql_fetch_array($query)) { + while ($interface = mysql_fetch_assoc($query)) { $ports['peering'] .= $seperator . $interface['interface_id']; $seperator = ","; } diff --git a/html/pages/health/current.inc.php b/html/pages/health/current.inc.php index 92387dea9..58cb9777b 100644 --- a/html/pages/health/current.inc.php +++ b/html/pages/health/current.inc.php @@ -27,7 +27,7 @@ echo(' $row = 1; -while ($sensor = mysql_fetch_array($query)) +while ($sensor = mysql_fetch_assoc($query)) { if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } diff --git a/html/pages/health/fanspeeds.inc.php b/html/pages/health/fanspeeds.inc.php index 4c6dae00f..97182d80b 100644 --- a/html/pages/health/fanspeeds.inc.php +++ b/html/pages/health/fanspeeds.inc.php @@ -26,7 +26,7 @@ echo(' $row = 1; -while ($sensor = mysql_fetch_array($query)) +while ($sensor = mysql_fetch_assoc($query)) { if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } diff --git a/html/pages/health/frequencies.inc.php b/html/pages/health/frequencies.inc.php index 68247257c..3dc469308 100644 --- a/html/pages/health/frequencies.inc.php +++ b/html/pages/health/frequencies.inc.php @@ -26,7 +26,7 @@ echo(' $row = 1; -while ($sensor = mysql_fetch_array($query)) +while ($sensor = mysql_fetch_assoc($query)) { if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } diff --git a/html/pages/health/humidity.inc.php b/html/pages/health/humidity.inc.php index c571968f0..f1222bb10 100644 --- a/html/pages/health/humidity.inc.php +++ b/html/pages/health/humidity.inc.php @@ -26,7 +26,7 @@ echo(' $row = 1; -while ($sensor = mysql_fetch_array($query)) +while ($sensor = mysql_fetch_assoc($query)) { if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } diff --git a/html/pages/health/memory.inc.php b/html/pages/health/memory.inc.php index d7b69501e..cd62dd87c 100644 --- a/html/pages/health/memory.inc.php +++ b/html/pages/health/memory.inc.php @@ -6,7 +6,7 @@ echo("
    "); echo(""); $i = '1'; $mempools = mysql_query("SELECT * FROM `mempools` AS M, `devices` as D WHERE D.device_id = M.device_id ORDER BY D.hostname"); -while ($mempool = mysql_fetch_array($mempools)) +while ($mempool = mysql_fetch_assoc($mempools)) { if (device_permitted($mempool['device_id'])) { diff --git a/html/pages/health/processors.inc.php b/html/pages/health/processors.inc.php index d08916468..d2a931918 100644 --- a/html/pages/health/processors.inc.php +++ b/html/pages/health/processors.inc.php @@ -6,7 +6,7 @@ echo("
    "); echo("
    "); $i = '1'; $procs = mysql_query("SELECT * FROM `processors` AS P, `devices` AS D WHERE D.device_id = P.device_id ORDER BY D.hostname"); -while ($proc = mysql_fetch_array($procs)) +while ($proc = mysql_fetch_assoc($procs)) { if (device_permitted($proc['device_id'])) { @@ -14,6 +14,7 @@ while ($proc = mysql_fetch_array($procs)) $device = $proc; + # FIXME should that really be done here? :-) $text_descr = $proc['processor_descr']; $text_descr = str_replace("Routing Processor", "RP", $text_descr); $text_descr = str_replace("Switching Processor", "SP", $text_descr); diff --git a/html/pages/health/storage.inc.php b/html/pages/health/storage.inc.php index 50d2d94d5..b8f4c29ae 100644 --- a/html/pages/health/storage.inc.php +++ b/html/pages/health/storage.inc.php @@ -19,7 +19,7 @@ echo(" $row = 1; -while ($drive = mysql_fetch_array($query)) +while ($drive = mysql_fetch_assoc($query)) { if (device_permitted($drive['device_id'])) { diff --git a/html/pages/health/temperatures.inc.php b/html/pages/health/temperatures.inc.php index 3fbac55ea..08e095154 100644 --- a/html/pages/health/temperatures.inc.php +++ b/html/pages/health/temperatures.inc.php @@ -26,7 +26,7 @@ echo(' $row = 1; -while ($sensor = mysql_fetch_array($query)) +while ($sensor = mysql_fetch_assoc($query)) { if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } diff --git a/html/pages/health/voltages.inc.php b/html/pages/health/voltages.inc.php index b3ac55fbc..d16978106 100644 --- a/html/pages/health/voltages.inc.php +++ b/html/pages/health/voltages.inc.php @@ -26,7 +26,7 @@ echo(' $row = 1; -while ($sensor = mysql_fetch_array($query)) +while ($sensor = mysql_fetch_assoc($query)) { if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } diff --git a/html/pages/iftype.inc.php b/html/pages/iftype.inc.php index 61d2969f5..b39467362 100644 --- a/html/pages/iftype.inc.php +++ b/html/pages/iftype.inc.php @@ -16,7 +16,7 @@ $type_where .= ") "; $sql = "SELECT * FROM `ports` as I, `devices` AS D WHERE $type_where AND I.device_id = D.device_id ORDER BY I.ifAlias"; $query = mysql_query($sql); -while ($interface = mysql_fetch_array($query)) +while ($interface = mysql_fetch_assoc($query)) { $if_list .= $seperator . $interface['interface_id']; $seperator = ","; @@ -40,7 +40,7 @@ if ($if_list) $sql = "select * from ports as I, devices as D WHERE $type_where AND I.device_id = D.device_id ORDER BY I.ifAlias"; $query = mysql_query($sql); - while ($interface = mysql_fetch_array($query)) + while ($interface = mysql_fetch_assoc($query)) { $done = "yes"; unset($class); diff --git a/html/pages/inventory.inc.php b/html/pages/inventory.inc.php index 01655d0f7..1d9da901d 100644 --- a/html/pages/inventory.inc.php +++ b/html/pages/inventory.inc.php @@ -11,7 +11,7 @@ All Devices"); echo(""); -while ($entry = mysql_fetch_array($query)) +while ($entry = mysql_fetch_assoc($query)) { if ($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; } echo("All Devices"); -while ($device = mysql_fetch_array($device_query)) +while ($device = mysql_fetch_assoc($device_query)) { include("includes/hostbox.inc.php"); } diff --git a/html/pages/ports/default.inc.php b/html/pages/ports/default.inc.php index e6c1ac1a8..962e884d0 100644 --- a/html/pages/ports/default.inc.php +++ b/html/pages/ports/default.inc.php @@ -5,14 +5,15 @@
    HostnameDescriptionNamePart NoSerial No
    " . generate_device_link($entry, shortHost($entry['hostname'])) . "" . $entry['entPhysicalDescr'] . diff --git a/html/pages/ipv4.inc.php b/html/pages/ipv4.inc.php index f3477eda5..7a17ba485 100644 --- a/html/pages/ipv4.inc.php +++ b/html/pages/ipv4.inc.php @@ -8,7 +8,7 @@ DeviceInterfaceAddress DeviceInterfaceAddress
    @@ -34,33 +35,35 @@ @@ -124,7 +127,7 @@ echo("
    DeviceInterfaceSpee $row = 1; -while ($interface = mysql_fetch_array($query)) +while ($interface = mysql_fetch_assoc($query)) { if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } diff --git a/html/pages/preferences.inc.php b/html/pages/preferences.inc.php index 8151d8c6e..553a815fe 100644 --- a/html/pages/preferences.inc.php +++ b/html/pages/preferences.inc.php @@ -27,7 +27,6 @@ if ($_POST['action'] == "changepass") include("includes/update-preferences-password.inc.php"); echo("
    "); - echo("
    "); echo("
    "); @@ -37,7 +36,7 @@ if (passwordscanchange()) { echo("
    Change Password
    "); echo($changepass_message); - echo("
    + echo(" @@ -51,11 +50,11 @@ echo("
    Devic if ($_SESSION['userlevel'] == '10') { echo("Global Administrative Access"); } if ($_SESSION['userlevel'] == '5') { echo("Global Viewing Access"); } -if ($_SESSION['userlevel'] == '1') { - +if ($_SESSION['userlevel'] == '1') +{ $perms = mysql_query("SELECT * FROM `devices_perms` AS P, `devices` AS D WHERE `user_id` = '" . $user_id . "' AND P.device_id = D.device_id"); - while ($perm = mysql_fetch_array($perms)) + while ($perm = mysql_fetch_assoc($perms)) { echo("" . $perm['hostname'] . "
    "); $dev_access = 1; diff --git a/html/pages/pseudowires.inc.php b/html/pages/pseudowires.inc.php index cdc56edf4..637b74bc3 100644 --- a/html/pages/pseudowires.inc.php +++ b/html/pages/pseudowires.inc.php @@ -15,7 +15,7 @@ echo("
    Old Password
    New Password
    "); $sql = "SELECT * FROM pseudowires AS P, ports AS I, devices AS D WHERE P.interface_id = I.interface_id AND I.device_id = D.device_id ORDER BY D.hostname,I.ifDescr"; $query = mysql_query($sql); -while ($pw_a = mysql_fetch_array($query)) +while ($pw_a = mysql_fetch_assoc($query)) { $i = 0; while ($i < count($linkdone)) @@ -25,7 +25,7 @@ while ($pw_a = mysql_fetch_array($query)) $i++; } - $pw_b = mysql_fetch_array(mysql_query("SELECT * from `devices` AS D, `ports` AS I, `pseudowires` AS P WHERE D.device_id = '".$pw_a['peer_device_id']."' AND + $pw_b = mysql_fetch_assoc(mysql_query("SELECT * from `devices` AS D, `ports` AS I, `pseudowires` AS P WHERE D.device_id = '".$pw_a['peer_device_id']."' AND D.device_id = I.device_id AND P.cpwVcID = '".$pw_a['cpwVcID']."' AND P.interface_id = I.interface_id")); diff --git a/html/pages/purgeports.inc.php b/html/pages/purgeports.inc.php index 074a12f97..462a17b0a 100644 --- a/html/pages/purgeports.inc.php +++ b/html/pages/purgeports.inc.php @@ -1,9 +1,10 @@ Deleting IPv4 address " . $ipaddr['addr'] . "/" . $ipaddr['cidr']); mysql_query("DELETE FROM addr WHERE id = '".$addr['id']."'"); @@ -11,7 +12,7 @@ function delete_port($interface_id) } $ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `interface_id` = '$interface_id'"); - while ($ip6addr = mysql_fetch_array($ip6addrs)) + while ($ip6addr = mysql_fetch_assoc($ip6addrs)) { echo("
    Deleting IPv6 address " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen']); mysql_query("DELETE FROM ip6addr WHERE ip6_addr_id = '".$ip6addr['ip6_addr_id']."'"); @@ -19,7 +20,7 @@ function delete_port($interface_id) } $ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `interface_id` = '$interface_id'"); - while ($ip6addr = mysql_fetch_array($ip6addrs)) + while ($ip6addr = mysql_fetch_assoc($ip6addrs)) { echo("
    Deleting IPv6 address " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen']); mysql_query("DELETE FROM ip6addr WHERE ip6_addr_id = '".$ip6addr['ip6_addr_id']."'"); @@ -35,7 +36,7 @@ function delete_port($interface_id) } $ports = mysql_query("SELECT * FROM `ports` WHERE `deleted` = '1'"); -while ($port = mysql_fetch_array($ports)) +while ($port = mysql_fetch_assoc($ports)) { echo("
    Deleting port " . $port['interface_id'] . " - " . $port['ifDescr']); delete_port($port['interface_id']); diff --git a/html/pages/services.inc.php b/html/pages/services.inc.php index e81bca24f..f124a9ee9 100644 --- a/html/pages/services.inc.php +++ b/html/pages/services.inc.php @@ -19,12 +19,12 @@ if ($_SESSION['userlevel'] >= '5') $host_sql = "SELECT * FROM devices AS D, services AS S, devices_perms AS P WHERE D.device_id = S.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' $where GROUP BY D.hostname ORDER BY D.hostname"; } $host_query = mysql_query($host_sql); - while ($host_data = mysql_fetch_array($host_query)) + while ($host_data = mysql_fetch_assoc($host_query)) { $device_id = $host_data['device_id']; $device_hostname = $host_data['hostname']; $service_query = mysql_query("SELECT * FROM `services` WHERE `device_id` = '" . $host_data['device_id'] . "' $where"); - while ($service = mysql_fetch_array($service_query)) + while ($service = mysql_fetch_assoc($service_query)) { include("includes/print-service.inc.php"); # $samehost = 1; diff --git a/html/pages/storage.inc.php b/html/pages/storage.inc.php index dae223a7e..5fd63350f 100644 --- a/html/pages/storage.inc.php +++ b/html/pages/storage.inc.php @@ -23,7 +23,7 @@ echo("
    $row = 1; -while ($drive = mysql_fetch_array($query)) +while ($drive = mysql_fetch_assoc($query)) { $skipdrive = 0; diff --git a/html/pages/syslog.inc.php b/html/pages/syslog.inc.php index 81bf05ed1..40c6126c7 100644 --- a/html/pages/syslog.inc.php +++ b/html/pages/syslog.inc.php @@ -14,7 +14,7 @@ All Devices= '5') $query = mysql_query($sql); echo("
    "); -while ($entry = mysql_fetch_array($query)) +while ($entry = mysql_fetch_assoc($query)) { $entry = array_merge($entry, device_by_id_cache($entry['device_id'])); include("includes/print-syslog.inc.php"); diff --git a/html/pages/vrf.inc.php b/html/pages/vrf.inc.php index 2884564dc..287ee14c7 100644 --- a/html/pages/vrf.inc.php +++ b/html/pages/vrf.inc.php @@ -28,7 +28,7 @@ if ($_GET['opta'] == "details" ) echo("
    "); $vrf_query = mysql_query("SELECT * FROM `vrfs` WHERE mplsVpnVrfRouteDistinguisher = '".$device['device_id']."'"); -$vrf = mysql_fetch_array($vrf_query); +$vrf = mysql_fetch_assoc($vrf_query); echo(""); echo(""); echo(""); @@ -38,7 +38,7 @@ echo("
    " . $vrf['vrf_name'] . "" . $vrf['mplsVpnVrfRouteDistinguisher'] . "
    "); $devices = mysql_query("SELECT * FROM `vrfs` AS V, `devices` AS D WHERE `mplsVpnVrfRouteDistinguisher` = '".$vrf['mplsVpnVrfRouteDistinguisher']."' AND D.device_id = V.device_id"); $x=1; -while ($device = mysql_fetch_array($devices)) +while ($device = mysql_fetch_assoc($devices)) { $hostname = $device['hostname']; #if (!is_integer($x/2)) { $device_colour = $list_colour_a; } else { $device_colour = $list_colour_b; } @@ -49,7 +49,7 @@ while ($device = mysql_fetch_array($devices)) unset($seperator); echo(""); $i=1; - while ($interface = mysql_fetch_array($ports)) + while ($interface = mysql_fetch_assoc($ports)) { if (!is_integer($x/2)) { diff --git a/html/pages/vrfs.inc.php b/html/pages/vrfs.inc.php index ff529a7f5..0339625a1 100644 --- a/html/pages/vrfs.inc.php +++ b/html/pages/vrfs.inc.php @@ -15,7 +15,7 @@ if ($_SESSION['userlevel'] >= '5') echo("
    "); $i = "1"; $vrf_query = mysql_query("SELECT * FROM `vrfs` GROUP BY `mplsVpnVrfRouteDistinguisher`"); - while ($vrf = mysql_fetch_array($vrf_query)) + while ($vrf = mysql_fetch_assoc($vrf_query)) { if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } echo(""); @@ -25,7 +25,7 @@ if ($_SESSION['userlevel'] >= '5') echo("
    "); $devices = mysql_query("SELECT * FROM `vrfs` AS V, `devices` AS D WHERE `mplsVpnVrfRouteDistinguisher` = '".$vrf['mplsVpnVrfRouteDistinguisher']."' AND D.device_id = V.device_id"); $x=1; - while ($device = mysql_fetch_array($devices)) + while ($device = mysql_fetch_assoc($devices)) { if (!is_integer($i/2)) { @@ -40,7 +40,7 @@ if ($_SESSION['userlevel'] >= '5') $ports = mysql_query("SELECT * FROM `ports` WHERE `ifVrf` = '".$device['vrf_id']."' and device_id = '".$device['device_id']."'"); unset($seperator); - while ($port = mysql_fetch_array($ports)) + while ($port = mysql_fetch_assoc($ports)) { $port = array_merge ($device, $port); if ($_GET['opta']) diff --git a/includes/common.php b/includes/common.php index e09c14bbe..800677f10 100644 --- a/includes/common.php +++ b/includes/common.php @@ -153,7 +153,7 @@ function getifindexbyid($id) function getifbyid($id) { $sql = mysql_query("SELECT * FROM `ports` WHERE `interface_id` = '$id'"); - $result = @mysql_fetch_array($sql); + $result = @mysql_fetch_assoc($sql); return $result; } diff --git a/includes/discovery/arp-table.inc.php b/includes/discovery/arp-table.inc.php index 2b2d2b94f..7b8737968 100644 --- a/includes/discovery/arp-table.inc.php +++ b/includes/discovery/arp-table.inc.php @@ -13,7 +13,7 @@ foreach (explode("\n", $ipNetToMedia_data) as $data) list($oid, $mac) = explode(" ", $data); list($if, $first, $second, $third, $fourth) = explode(".", $oid); list($m_a, $m_b, $m_c, $m_d, $m_e, $m_f) = explode(":", $mac); - $interface = mysql_fetch_array(mysql_query("SELECT * FROM ports WHERE device_id = '".$device['device_id']."' AND ifIndex = '".$if."'")); + $interface = mysql_fetch_assoc(mysql_query("SELECT * FROM ports WHERE device_id = '".$device['device_id']."' AND ifIndex = '".$if."'")); $ip = $first .".". $second .".". $third .".". $fourth; $m_a = zeropad($m_a);$m_b = zeropad($m_b);$m_c = zeropad($m_c);$m_d = zeropad($m_d);$m_e = zeropad($m_e);$m_f = zeropad($m_f); @@ -51,7 +51,7 @@ foreach (explode("\n", $ipNetToMedia_data) as $data) $sql = "SELECT * from ipv4_mac AS M, ports as I WHERE M.interface_id = I.interface_id and I.device_id = '".$device['device_id']."'"; $query = mysql_query($sql); -while ($entry = mysql_fetch_array($query)) +while ($entry = mysql_fetch_assoc($query)) { $entry_mac = $entry['mac_address']; $entry_if = $entry['interface_id']; diff --git a/includes/discovery/bgp-peers.inc.php b/includes/discovery/bgp-peers.inc.php index 6501ef169..b461c94f9 100755 --- a/includes/discovery/bgp-peers.inc.php +++ b/includes/discovery/bgp-peers.inc.php @@ -159,7 +159,7 @@ if ($config['enable_bgp']) } # os=junos $af_query = mysql_query("SELECT * FROM bgpPeers_cbgp WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '".$peer['ip']."'"); - while ($entry = mysql_fetch_array($af_query)) + while ($entry = mysql_fetch_assoc($af_query)) { $afi = $entry['afi']; $safi = $entry['safi']; @@ -182,7 +182,7 @@ if ($config['enable_bgp']) $sql = "SELECT * FROM bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id AND D.device_id = '".$device['device_id']."'"; $query = mysql_query($sql); - while ($entry = mysql_fetch_array($query)) + while ($entry = mysql_fetch_assoc($query)) { unset($exists); $i = 0; diff --git a/includes/discovery/cisco-mac-accounting.inc.php b/includes/discovery/cisco-mac-accounting.inc.php index 41ad63ea5..e5c382057 100755 --- a/includes/discovery/cisco-mac-accounting.inc.php +++ b/includes/discovery/cisco-mac-accounting.inc.php @@ -13,7 +13,7 @@ if ($device['os_group'] == "ios") list($if, $direction, $a_a, $a_b, $a_c, $a_d, $a_e, $a_f) = explode(".", $oid); $oid = "$a_a.$a_b.$a_c.$a_d.$a_e.$a_f"; unset($interface); - $interface = mysql_fetch_array(mysql_query("SELECT * FROM ports WHERE device_id = '".$device['device_id']."' AND ifIndex = '".$if."'")); + $interface = mysql_fetch_assoc(mysql_query("SELECT * FROM ports WHERE device_id = '".$device['device_id']."' AND ifIndex = '".$if."'")); $ah_a = zeropad(dechex($a_a)); $ah_b = zeropad(dechex($a_b)); $ah_c = zeropad(dechex($a_c)); diff --git a/includes/discovery/cisco-pw.inc.php b/includes/discovery/cisco-pw.inc.php index 42fca0d94..1ef0c16b1 100755 --- a/includes/discovery/cisco-pw.inc.php +++ b/includes/discovery/cisco-pw.inc.php @@ -52,7 +52,7 @@ if ($config['enable_pseudowires'] && $device['os_group'] == "ios") $sql = "SELECT * FROM pseudowires AS P, ports AS I, devices as D WHERE P.interface_id = I.interface_id AND I.device_id = D.device_id AND D.device_id = '".$device['device_id']."'"; $query = mysql_query($sql); - while ($cpw = mysql_fetch_array($query)) + while ($cpw = mysql_fetch_assoc($query)) { unset($exists); $i = 0; diff --git a/includes/discovery/cisco-vlans.inc.php b/includes/discovery/cisco-vlans.inc.php index 2eeec5de4..93a41dd66 100755 --- a/includes/discovery/cisco-vlans.inc.php +++ b/includes/discovery/cisco-vlans.inc.php @@ -42,7 +42,7 @@ if ($device['os_group'] == "ios") } $device_vlans = mysql_query("SELECT * FROM `vlans` WHERE `device_id` = '" . $device['device_id'] . "' AND `vlan_domain` = '" . $vtp_domain . "'"); - while ($dev_vlan = mysql_fetch_array($device_vlans)) + while ($dev_vlan = mysql_fetch_assoc($device_vlans)) { unset($vlan_exists); foreach ($this_vlans as $test_vlan) diff --git a/includes/discovery/cisco-vrf.inc.php b/includes/discovery/cisco-vrf.inc.php index 56e037412..17c1c234c 100755 --- a/includes/discovery/cisco-vrf.inc.php +++ b/includes/discovery/cisco-vrf.inc.php @@ -49,7 +49,7 @@ if ($device['os_group'] == "ios" || $device['os_group'] == "junos" || $device['o echo(" ( "); foreach (explode("\n", $ports) as $if_id) { - $interface = mysql_fetch_array(mysql_query("SELECT * FROM ports WHERE ifIndex = '$if_id' AND device_id = '" . $device['device_id'] . "'")); + $interface = mysql_fetch_assoc(mysql_query("SELECT * FROM ports WHERE ifIndex = '$if_id' AND device_id = '" . $device['device_id'] . "'")); echo(makeshortif($interface['ifDescr']) . " "); mysql_query("UPDATE ports SET ifVrf = '".$vrf_id."' WHERE interface_id = '".$interface['interface_id']."'"); $if = $interface['interface_id']; @@ -61,7 +61,7 @@ if ($device['os_group'] == "ios" || $device['os_group'] == "junos" || $device['o $sql = "SELECT * FROM ports WHERE device_id = '" . $device['device_id'] . "'"; $data = mysql_query($sql); - while ($row = mysql_fetch_array($data)) + while ($row = mysql_fetch_assoc($data)) { $if = $row['interface_id']; $vrf_id = $row['ifVrf']; @@ -81,7 +81,7 @@ if ($device['os_group'] == "ios" || $device['os_group'] == "junos" || $device['o $sql = "SELECT * FROM vrfs WHERE device_id = '" . $device['device_id'] . "'"; $data = mysql_query($sql); - while ($row = mysql_fetch_array($data)) + while ($row = mysql_fetch_assoc($data)) { $vrf_id = $row['vrf_id']; if (!$valid_vrf[$vrf_id]) diff --git a/includes/discovery/discovery-protocols.inc.php b/includes/discovery/discovery-protocols.inc.php index 139585637..afd7b6c40 100755 --- a/includes/discovery/discovery-protocols.inc.php +++ b/includes/discovery/discovery-protocols.inc.php @@ -13,7 +13,7 @@ if ($device['os'] == "ironware") unset($fdp_links); foreach (array_keys($fdp_array) as $key) { - $interface = mysql_fetch_array(mysql_query("SELECT * FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '".$key."'")); + $interface = mysql_fetch_assoc(mysql_query("SELECT * FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '".$key."'")); $fdp_if_array = $fdp_array[$key]; foreach (array_keys($fdp_if_array) as $entry_key) { @@ -40,7 +40,7 @@ if ($cdp_array) unset($cdp_links); foreach (array_keys($cdp_array) as $key) { - $interface = mysql_fetch_array(mysql_query("SELECT * FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '".$key."'")); + $interface = mysql_fetch_assoc(mysql_query("SELECT * FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '".$key."'")); $cdp_if_array = $cdp_array[$key]; foreach (array_keys($cdp_if_array) as $entry_key) { @@ -81,7 +81,7 @@ if ($lldp_array) } else { $ifIndex = $entry_key; } - $interface = mysql_fetch_array(mysql_query("SELECT * FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '".$ifIndex."'")); + $interface = mysql_fetch_assoc(mysql_query("SELECT * FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '".$ifIndex."'")); $lldp_instance = $lldp_if_array[$entry_key]; foreach (array_keys($lldp_instance) as $entry_instance) { @@ -108,7 +108,7 @@ if ($debug) { print_r($link_exists); } $sql = "SELECT * FROM `links` AS L, `ports` AS I WHERE L.local_interface_id = I.interface_id AND I.device_id = '".$device['device_id']."'"; if ($query = mysql_query($sql)) { - while ($test = mysql_fetch_array($query)) + while ($test = mysql_fetch_assoc($query)) { $local_interface_id = $test['local_interface_id']; $remote_hostname = $test['remote_hostname']; diff --git a/includes/discovery/entity-physical.inc.php b/includes/discovery/entity-physical.inc.php index 0f5bf1ff0..bbc5cd9a0 100755 --- a/includes/discovery/entity-physical.inc.php +++ b/includes/discovery/entity-physical.inc.php @@ -78,7 +78,7 @@ $sql = "SELECT * FROM `entPhysical` WHERE `device_id` = '".$device['device_id']."'"; $query = mysql_query($sql); - while ($test = mysql_fetch_array($query)) { + while ($test = mysql_fetch_assoc($query)) { $id = $test['entPhysicalIndex']; if (!$valid[$id]) { echo("-"); diff --git a/includes/discovery/hr-device.inc.php b/includes/discovery/hr-device.inc.php index 671c7edd9..1820cf682 100755 --- a/includes/discovery/hr-device.inc.php +++ b/includes/discovery/hr-device.inc.php @@ -45,7 +45,7 @@ if (is_array($hrDevices)) $sql = "SELECT * FROM `hrDevice` WHERE `device_id` = '".$device['device_id']."'"; $query = mysql_query($sql); -while ($test_hrDevice = mysql_fetch_array($query)) +while ($test_hrDevice = mysql_fetch_assoc($query)) { if (!$valid_hrDevice[$test_hrDevice['hrDeviceIndex']]) { diff --git a/includes/discovery/ipv4-addresses.inc.php b/includes/discovery/ipv4-addresses.inc.php index aa04a8a59..961feebfc 100755 --- a/includes/discovery/ipv4-addresses.inc.php +++ b/includes/discovery/ipv4-addresses.inc.php @@ -42,7 +42,7 @@ foreach (explode("\n", $oids) as $data) $sql = "SELECT * FROM ipv4_addresses AS A, ports AS I WHERE I.device_id = '".$device['device_id']."' AND A.interface_id = I.interface_id"; $data = mysql_query($sql); -while ($row = mysql_fetch_array($data)) +while ($row = mysql_fetch_assoc($data)) { $full_address = $row['ipv4_address'] . "/" . $row['ipv4_prefixlen'] . "|" . $row['ifIndex']; diff --git a/includes/discovery/ipv6-addresses.inc.php b/includes/discovery/ipv6-addresses.inc.php index 61e171647..d0248becc 100644 --- a/includes/discovery/ipv6-addresses.inc.php +++ b/includes/discovery/ipv6-addresses.inc.php @@ -61,7 +61,7 @@ if (!$oids) $sql = "SELECT * FROM ipv6_addresses AS A, ports AS I WHERE I.device_id = '".$device['device_id']."' AND A.interface_id = I.interface_id"; $data = mysql_query($sql); -while ($row = mysql_fetch_array($data)) +while ($row = mysql_fetch_assoc($data)) { $full_address = $row['ipv6_address'] . "/" . $row['ipv6_prefixlen']; $interface_id = $row['interface_id']; diff --git a/includes/discovery/junose-atm-vp.inc.php b/includes/discovery/junose-atm-vp.inc.php index cb363428e..3d11e2efe 100755 --- a/includes/discovery/junose-atm-vp.inc.php +++ b/includes/discovery/junose-atm-vp.inc.php @@ -35,7 +35,7 @@ if ($device['os'] == "junose" && $config['enable_ports_junoseatmvp']) if ($debug) { print_r ($valid_vp); } - while ($test = mysql_fetch_array($query)) + while ($test = mysql_fetch_assoc($query)) { $interface_id = $test['interface_id']; $vp_id = $test['vp_id']; diff --git a/includes/discovery/mempools.inc.php b/includes/discovery/mempools.inc.php index 53d5d4b3d..d15a9ea7a 100755 --- a/includes/discovery/mempools.inc.php +++ b/includes/discovery/mempools.inc.php @@ -11,7 +11,7 @@ $query = mysql_query($sql); if ($debug) { print_r ($valid_mempool); } -while ($test_mempool = mysql_fetch_array($query)) +while ($test_mempool = mysql_fetch_assoc($query)) { $mempool_index = $test_mempool['mempool_index']; $mempool_type = $test_mempool['mempool_type']; diff --git a/includes/discovery/ports.inc.php b/includes/discovery/ports.inc.php index 04cf8f750..cf33c3c69 100755 --- a/includes/discovery/ports.inc.php +++ b/includes/discovery/ports.inc.php @@ -75,7 +75,7 @@ foreach (explode("\n", $ports) as $entry) $sql = "SELECT * FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `deleted` = '0'"; $query = mysql_query($sql); -while ($test_if = mysql_fetch_array($query)) +while ($test_if = mysql_fetch_assoc($query)) { unset($exists); $i = 0; diff --git a/includes/discovery/processors.inc.php b/includes/discovery/processors.inc.php index ddd32c8c9..53d9f1fa0 100755 --- a/includes/discovery/processors.inc.php +++ b/includes/discovery/processors.inc.php @@ -15,7 +15,7 @@ $query = mysql_query($sql); if ($debug) { print_r ($valid_processor); } -while ($test_processor = mysql_fetch_array($query)) +while ($test_processor = mysql_fetch_assoc($query)) { $processor_index = $test_processor['processor_index']; $processor_type = $test_processor['processor_type']; diff --git a/includes/discovery/q-bridge-mib.inc.php b/includes/discovery/q-bridge-mib.inc.php index 39310b248..3c5f8d16e 100644 --- a/includes/discovery/q-bridge-mib.inc.php +++ b/includes/discovery/q-bridge-mib.inc.php @@ -35,7 +35,7 @@ if ($vlanversion == 'version1') } $device_vlans = mysql_query("SELECT * FROM `vlans` WHERE `device_id` = '" . $device['device_id'] . "'"); - while ($dev_vlan = mysql_fetch_array($device_vlans)) + while ($dev_vlan = mysql_fetch_assoc($device_vlans)) { unset($vlan_exists); foreach ($this_vlans as $test_vlan) diff --git a/includes/discovery/storage.inc.php b/includes/discovery/storage.inc.php index d99501046..63ed8d19b 100755 --- a/includes/discovery/storage.inc.php +++ b/includes/discovery/storage.inc.php @@ -11,7 +11,7 @@ $query = mysql_query($sql); if ($debug) { print_r ($valid_storage); } -while ($test_storage = mysql_fetch_array($query)) +while ($test_storage = mysql_fetch_assoc($query)) { $storage_index = $test_storage['storage_index']; $storage_mib = $test_storage['storage_mib']; diff --git a/includes/discovery/toner.inc.php b/includes/discovery/toner.inc.php index eed2e777c..43581100c 100644 --- a/includes/discovery/toner.inc.php +++ b/includes/discovery/toner.inc.php @@ -49,7 +49,7 @@ if ($config['enable_printers']) $sql = "SELECT * FROM toner WHERE device_id = '".$device['device_id']."'"; if ($query = mysql_query($sql)) { - while ($test_toner = mysql_fetch_array($query)) + while ($test_toner = mysql_fetch_assoc($query)) { $toner_index = $test_toner['toner_index']; $toner_type = $test_toner['toner_type']; diff --git a/includes/discovery/ucd-diskio.inc.php b/includes/discovery/ucd-diskio.inc.php index a82e49da3..a872f1956 100644 --- a/includes/discovery/ucd-diskio.inc.php +++ b/includes/discovery/ucd-diskio.inc.php @@ -37,7 +37,7 @@ $query = mysql_query($sql); if ($debug) { print_r ($valid_diskio); } -while ($test = mysql_fetch_array($query)) +while ($test = mysql_fetch_assoc($query)) { if ($debug) { echo($test['diskio_index'] . " -> " . $test['diskio_descr'] . "\n"); } if (!$valid_diskio[$test['diskio_index']]) diff --git a/includes/discovery/vmware-vminfo.inc.php b/includes/discovery/vmware-vminfo.inc.php index a954d53d2..9d372c0fc 100755 --- a/includes/discovery/vmware-vminfo.inc.php +++ b/includes/discovery/vmware-vminfo.inc.php @@ -89,7 +89,7 @@ if ($device['os'] == "vmware") $db_vm_list = mysql_query("SELECT id, vmwVmVMID FROM vmware_vminfo WHERE device_id = '" . $device["device_id"] . "'"); - while ($db_vm = mysql_fetch_array($db_vm_list)) + while ($db_vm = mysql_fetch_assoc($db_vm_list)) { /* * Delete the Virtual Machines that are removed from the host. diff --git a/includes/functions.php b/includes/functions.php index 29b065769..99cc80e98 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -59,7 +59,7 @@ function device_array($device_id) { $sql = "SELECT * FROM `devices` WHERE `device_id` = '".$device_id."'"; $query = mysql_query($sql); - $device = mysql_fetch_array($query); + $device = mysql_fetch_assoc($query); return $device; } @@ -115,7 +115,7 @@ function getImage($host) { global $config; $sql = "SELECT * FROM `devices` WHERE `device_id` = '$host'"; - $data = mysql_fetch_array(mysql_query($sql)); + $data = mysql_fetch_assoc(mysql_query($sql)); $type = strtolower($data['os']); if ($config['os'][$type]['icon'] && file_exists($config['html_dir'] . "/images/os/" . $config['os'][$type]['icon'] . ".png")) { @@ -173,7 +173,7 @@ function delete_device($id) $host = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '$id'"), 0); mysql_query("DELETE FROM `devices` WHERE `device_id` = '$id'"); $int_query = mysql_query("SELECT * FROM `ports` WHERE `device_id` = '$id'"); - while ($int_data = mysql_fetch_array($int_query)) + while ($int_data = mysql_fetch_assoc($int_query)) { $int_if = $int_data['ifDescr']; $int_id = $int_data['interface_id']; diff --git a/includes/polling/applications.inc.php b/includes/polling/applications.inc.php index dcbf7982f..fcd80f0a1 100644 --- a/includes/polling/applications.inc.php +++ b/includes/polling/applications.inc.php @@ -7,7 +7,7 @@ $app_data = mysql_query($sql); if (mysql_affected_rows()) { echo('Applications: '); - while ($app = mysql_fetch_array($app_data)) + while ($app = mysql_fetch_assoc($app_data)) { $app_include = $config['install_dir'].'/includes/polling/applications/'.$app['app_type'].'.inc.php'; if (is_file($app_include)) diff --git a/includes/polling/bgp-peers.inc.php b/includes/polling/bgp-peers.inc.php index 922c29541..ccad3e1d9 100755 --- a/includes/polling/bgp-peers.inc.php +++ b/includes/polling/bgp-peers.inc.php @@ -9,7 +9,7 @@ if (!$config['enable_bgp']) else { $peers = mysql_query("SELECT * FROM bgpPeers WHERE device_id = '" . $device['device_id'] . "'"); - while ($peer = mysql_fetch_array($peers)) + while ($peer = mysql_fetch_assoc($peers)) { ### Poll BGP Peer diff --git a/includes/polling/cisco-entity-sensors.inc.php b/includes/polling/cisco-entity-sensors.inc.php index 66227406c..fb62bc06b 100755 --- a/includes/polling/cisco-entity-sensors.inc.php +++ b/includes/polling/cisco-entity-sensors.inc.php @@ -2,7 +2,7 @@ $query = "SELECT * FROM entPhysical WHERE device_id = '" . $device['device_id'] . "' AND entPhysicalClass = 'sensor'"; $sensors = mysql_query($query); -while ($sensor = mysql_fetch_array($sensors)) +while ($sensor = mysql_fetch_assoc($sensors)) { echo("Checking Entity Sensor " . $sensor['entPhysicalName'] . " - " . $sensor['cempsensorName']); diff --git a/includes/polling/current.inc.php b/includes/polling/current.inc.php index 781a64f41..fbc65cfba 100644 --- a/includes/polling/current.inc.php +++ b/includes/polling/current.inc.php @@ -2,7 +2,7 @@ $query = "SELECT * FROM sensors WHERE sensor_class='current' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'"; $current_data = mysql_query($query); -while ($dbcurrent = mysql_fetch_array($current_data)) +while ($dbcurrent = mysql_fetch_assoc($current_data)) { echo("Checking current " . $dbcurrent['sensor_descr'] . "... "); diff --git a/includes/polling/fanspeeds.inc.php b/includes/polling/fanspeeds.inc.php index 62e00bfaa..9748251b8 100755 --- a/includes/polling/fanspeeds.inc.php +++ b/includes/polling/fanspeeds.inc.php @@ -3,7 +3,7 @@ $query = "SELECT * FROM sensors WHERE sensor_class='fanspeed' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'"; $fan_data = mysql_query($query); -while ($fanspeed = mysql_fetch_array($fan_data)) +while ($fanspeed = mysql_fetch_assoc($fan_data)) { echo("Checking fan " . $fanspeed['sensor_descr'] . "... "); diff --git a/includes/polling/frequencies.inc.php b/includes/polling/frequencies.inc.php index d706c0f36..0cd552eeb 100644 --- a/includes/polling/frequencies.inc.php +++ b/includes/polling/frequencies.inc.php @@ -3,7 +3,7 @@ $query = "SELECT * FROM `sensors` WHERE device_id = '" . $device['device_id'] . "' AND `sensor_class` = 'freq' AND poller_type='snmp'"; $sensor_data = mysql_query($query); -while ($sensor = mysql_fetch_array($sensor_data)) +while ($sensor = mysql_fetch_assoc($sensor_data)) { echo("Checking frequency " . $sensor['sensor_descr'] . "... "); diff --git a/includes/polling/humidity.inc.php b/includes/polling/humidity.inc.php index fc10315f6..cbee183f7 100644 --- a/includes/polling/humidity.inc.php +++ b/includes/polling/humidity.inc.php @@ -2,7 +2,7 @@ $query = "SELECT * FROM sensors WHERE sensor_class='humidity' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'"; $hum_data = mysql_query($query); -while ($humidity = mysql_fetch_array($hum_data)) +while ($humidity = mysql_fetch_assoc($hum_data)) { echo("Checking humidity " . $humidity['sensor_descr'] . "... "); diff --git a/includes/polling/interfaces.inc.php b/includes/polling/interfaces.inc.php index 744d46f1c..da4513917 100644 --- a/includes/polling/interfaces.inc.php +++ b/includes/polling/interfaces.inc.php @@ -16,9 +16,9 @@ if ($device['os_group'] == "ios") { } $interface_query = mysql_query("SELECT * FROM `ports` $where"); -while ($interface = mysql_fetch_array($interface_query)) { +while ($interface = mysql_fetch_assoc($interface_query)) { - if (!$device) { $device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '" . $interface['device_id'] . "'")); } + if (!$device) { $device = mysql_fetch_assoc(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '" . $interface['device_id'] . "'")); } unset($ifAdminStatus, $ifOperStatus, $ifAlias, $ifDescr); diff --git a/includes/polling/ipmi.inc.php b/includes/polling/ipmi.inc.php index 285f924d5..a4d054e04 100644 --- a/includes/polling/ipmi.inc.php +++ b/includes/polling/ipmi.inc.php @@ -19,7 +19,7 @@ if ($ipmi['host'] = get_dev_attrib($device,'ipmi_hostname')) $ipmi_sensor[$desc][$ipmi_unit[$type]]['unit'] = $type; } - while ($ipmisensors = mysql_fetch_array($ipmi_data)) + while ($ipmisensors = mysql_fetch_assoc($ipmi_data)) { echo("Updating IPMI sensor " . $ipmisensors['sensor_descr'] . "... "); diff --git a/includes/polling/junose-atm-vp.inc.php b/includes/polling/junose-atm-vp.inc.php index 10ba1678f..cb415aec3 100755 --- a/includes/polling/junose-atm-vp.inc.php +++ b/includes/polling/junose-atm-vp.inc.php @@ -17,7 +17,7 @@ if (mysql_affected_rows()) echo("Checking JunOSe ATM vps: "); - while ($vp=mysql_fetch_array($vp_data)) + while ($vp = mysql_fetch_assoc($vp_data)) { echo("."); diff --git a/includes/polling/mempools.inc.php b/includes/polling/mempools.inc.php index 131d2f426..dcc894d05 100755 --- a/includes/polling/mempools.inc.php +++ b/includes/polling/mempools.inc.php @@ -2,7 +2,7 @@ $query = "SELECT * FROM mempools WHERE device_id = '" . $device['device_id'] . "'"; $mempool_data = mysql_query($query); -while ($mempool = mysql_fetch_array($mempool_data)) +while ($mempool = mysql_fetch_assoc($mempool_data)) { echo("Mempool ". $mempool['mempool_descr'] . ": "); diff --git a/includes/polling/os/vmware.inc.php b/includes/polling/os/vmware.inc.php index a2107c82c..a715e7434 100644 --- a/includes/polling/os/vmware.inc.php +++ b/includes/polling/os/vmware.inc.php @@ -41,7 +41,7 @@ echo("VMware VM: "); $db_info_list = mysql_query("SELECT id, vmwVmVMID, vmwVmDisplayName, vmwVmGuestOS, vmwVmMemSize, vmwVmCpus, vmwVmState FROM vmware_vminfo WHERE device_id = '" . $device["device_id"] . "'"); -while ($db_info = mysql_fetch_array($db_info_list)) +while ($db_info = mysql_fetch_assoc($db_info_list)) { /* * Fetch the Virtual Machine information. diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index 21831295b..500dbd803 100755 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -102,7 +102,7 @@ if ($debug) { print_r($port_stats); } /// Loop ports in the DB and update where necessary $port_query = mysql_query("SELECT * FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `deleted` = 0"); -while ($port = mysql_fetch_array($port_query)) +while ($port = mysql_fetch_assoc($port_query)) { echo("Port " . $port['ifDescr'] . " "); if ($port_stats[$port['ifIndex']] && $port['disabled'] != "1") diff --git a/includes/polling/processors.inc.php b/includes/polling/processors.inc.php index bb47dd139..732372e8e 100755 --- a/includes/polling/processors.inc.php +++ b/includes/polling/processors.inc.php @@ -2,7 +2,7 @@ $query = "SELECT * FROM processors WHERE device_id = '" . $device['device_id'] . "'"; $proc_data = mysql_query($query); -while ($processor = mysql_fetch_array($proc_data)) +while ($processor = mysql_fetch_assoc($proc_data)) { echo("Processor " . $processor['processor_descr'] . "... "); diff --git a/includes/polling/storage.inc.php b/includes/polling/storage.inc.php index 260801774..afef38523 100755 --- a/includes/polling/storage.inc.php +++ b/includes/polling/storage.inc.php @@ -6,7 +6,7 @@ $storage_cache = array(); $query = "SELECT * FROM storage WHERE device_id = '" . $device['device_id'] . "'"; $storage_data = mysql_query($query); -while ($storage = mysql_fetch_array($storage_data)) +while ($storage = mysql_fetch_assoc($storage_data)) { echo("Storage ".$storage['storage_descr'] . ": "); diff --git a/includes/polling/temperatures.inc.php b/includes/polling/temperatures.inc.php index 919933581..8797062a2 100755 --- a/includes/polling/temperatures.inc.php +++ b/includes/polling/temperatures.inc.php @@ -2,7 +2,7 @@ $query = "SELECT * FROM sensors WHERE sensor_class='temperature' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'"; $temp_data = mysql_query($query); -while ($temperature = mysql_fetch_array($temp_data)) +while ($temperature = mysql_fetch_assoc($temp_data)) { echo("Checking temp " . $temperature['sensor_descr'] . "... "); diff --git a/includes/polling/toner.inc.php b/includes/polling/toner.inc.php index 36f525cc0..450a0963a 100755 --- a/includes/polling/toner.inc.php +++ b/includes/polling/toner.inc.php @@ -5,7 +5,7 @@ if ($config['enable_printers']) $query = "SELECT * FROM toner WHERE device_id = '" . $device['device_id'] . "'"; $toner_data = mysql_query($query); - while ($toner = mysql_fetch_array($toner_data)) + while ($toner = mysql_fetch_assoc($toner_data)) { echo("Checking toner " . $toner['toner_descr'] . "... "); diff --git a/includes/polling/ucd-diskio.inc.php b/includes/polling/ucd-diskio.inc.php index ff833f67a..74dc32c71 100644 --- a/includes/polling/ucd-diskio.inc.php +++ b/includes/polling/ucd-diskio.inc.php @@ -11,7 +11,7 @@ if (mysql_affected_rows()) echo("Checking UCD DiskIO MIB: "); - while ($diskio = mysql_fetch_array($diskio_data)) + while ($diskio = mysql_fetch_assoc($diskio_data)) { $index = $diskio['diskio_index']; diff --git a/includes/polling/voltages.inc.php b/includes/polling/voltages.inc.php index 5f775d650..80a80cb56 100755 --- a/includes/polling/voltages.inc.php +++ b/includes/polling/voltages.inc.php @@ -3,7 +3,7 @@ $query = "SELECT * FROM sensors WHERE sensor_class='voltage' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'"; $volt_data = mysql_query($query); -while ($sensor = mysql_fetch_array($volt_data)) +while ($sensor = mysql_fetch_assoc($volt_data)) { echo("Checking voltage " . $sensor['sensor_descr'] . "... "); diff --git a/includes/snmptrap/linkDown.inc.php b/includes/snmptrap/linkDown.inc.php index ce2f505b2..c6e6bb994 100644 --- a/includes/snmptrap/linkDown.inc.php +++ b/includes/snmptrap/linkDown.inc.php @@ -1,6 +1,6 @@ messageex[1]; - $device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE `hostname` = '".mres($hostname)."'")); + $device = mysql_fetch_assoc(mysql_query("SELECT * FROM `devices` WHERE `hostname` = '".mres($hostname)."'")); if ($device['status'] == 1) { $status = "Up " . formatUptime($device['uptime'] . " "); } else { $status = "Down "; } if ($device['ignore']) { $status = "*Ignored*"; } @@ -29,8 +29,8 @@ class observiumbot $hostname = $data->messageex[1]; $ifname = $data->messageex[2]; - $device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE `hostname` = '".mres($hostname)."'")); - $port = mysql_fetch_Array(mysql_query("SELECT * FROM `ports` WHERE `ifName` = '".$ifname."' OR `ifDescr` = '".$ifname."' AND device_id = '".$device['device_id']."'")); + $device = mysql_fetch_assoc(mysql_query("SELECT * FROM `devices` WHERE `hostname` = '".mres($hostname)."'")); + $port = mysql_fetch_assoc(mysql_query("SELECT * FROM `ports` WHERE `ifName` = '".$ifname."' OR `ifDescr` = '".$ifname."' AND device_id = '".$device['device_id']."'")); $bps_in = formatRates($port['ifInOctets_rate']); $bps_out = formatRates($port['ifOutOctets_rate']); diff --git a/poll-billing.php b/poll-billing.php index b04e10361..3b6740542 100755 --- a/poll-billing.php +++ b/poll-billing.php @@ -12,7 +12,7 @@ $iter = "0"; echo("Starting Polling Session ... \n\n"); $bill_query = mysql_query("select * from bills"); -while ($bill_data = mysql_fetch_array($bill_query)) +while ($bill_data = mysql_fetch_assoc($bill_query)) { echo("Bill : ".$bill_data['bill_name']."\n"); CollectData($bill_data['bill_id']); @@ -23,7 +23,7 @@ function CollectData($bill_id) { $port_query = mysql_query("select * from bill_ports as P, ports as I, devices as D where P.bill_id='$bill_id' AND I.interface_id = P.port_id AND D.device_id = I.device_id"); - while ($port_data = mysql_fetch_array($port_query)) + while ($port_data = mysql_fetch_assoc($port_query)) { unset($port_in_measurement); unset($port_in_delta); diff --git a/poll-reachability.php b/poll-reachability.php index 968db5118..43a505d66 100755 --- a/poll-reachability.php +++ b/poll-reachability.php @@ -7,56 +7,57 @@ include("includes/functions.php"); $device_query = mysql_query("SELECT * FROM `devices` WHERE `device_id` LIKE '%" . $argv[1] . "' AND disabled = '0' ORDER BY `device_id` DESC"); -while ($device = mysql_fetch_array($device_query)) +while ($device = mysql_fetch_assoc($device_query)) { - $port = $device['port']; + $port = $device['port']; - echo($device['hostname']. " "); + echo($device['hostname']. " "); - if (isPingable($device['hostname'])) + if (isPingable($device['hostname'])) + { + $pos = snmp_get($device, "sysDescr.0", "-Oqv", "SNMPv2-MIB"); + echo($device['protocol'].":".$device['hostname'].":".$device['port']." - ".$device['community']." ".$device['snmpver'].": "); + if ($pos == '') { - $pos = snmp_get($device, "sysDescr.0", "-Oqv", "SNMPv2-MIB"); - echo($device['protocol'].":".$device['hostname'].":".$device['port']." - ".$device['community']." ".$device['snmpver'].": "); - if ($pos == '') - { - $status='0'; - } else { - $status='1'; - } + $status='0'; } else { - $status='0'; + $status='1'; } + } else { + $status='0'; + } + + if ($status == '1') + { + echo("Up\n"); + } else { + echo("Down\n"); + } + + if ($status != $device['status']) + { + mysql_query("UPDATE `devices` SET `status`= '$status' WHERE `device_id` = '" . $device['device_id'] . "'"); if ($status == '1') { - echo("Up\n"); + $stat = "Up"; + mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('0', '" . $device['device_id'] . "', 'Device is up\n')"); + if ($config['alerts']['email']['enable']) + { + notify($device, "Device Up: " . $device['hostname'], "Device Up: " . $device['hostname'] . " at " . date($config['timestamp_format'])); + } } else { - echo("Down\n"); + $stat = "Down"; + mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('9', '" . $device['device_id'] . "', 'Device is down\n')"); + if ($config['alerts']['email']['enable']) + { + notify($device, "Device Down: " . $device['hostname'], "Device Down: " . $device['hostname'] . " at " . date($config['timestamp_format'])); + } } - if ($status != $device['status']) - { - mysql_query("UPDATE `devices` SET `status`= '$status' WHERE `device_id` = '" . $device['device_id'] . "'"); - - if ($status == '1') - { - $stat = "Up"; - mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('0', '" . $device['device_id'] . "', 'Device is up\n')"); - if ($config['alerts']['email']['enable']) - { - notify($device, "Device Up: " . $device['hostname'], "Device Up: " . $device['hostname'] . " at " . date($config['timestamp_format'])); - } - } else { - $stat = "Down"; - mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('9', '" . $device['device_id'] . "', 'Device is down\n')"); - if ($config['alerts']['email']['enable']) - { - notify($device, "Device Down: " . $device['hostname'], "Device Down: " . $device['hostname'] . " at " . date($config['timestamp_format'])); - } - } - log_event("Device status changed to $stat", $device, strtolower($stat))); - echo("Status Changed!\n"); - } + log_event("Device status changed to $stat", $device, strtolower($stat))); + echo("Status Changed!\n"); + } } ?> diff --git a/poller.php b/poller.php index 8c38bb957..9b50e77e0 100755 --- a/poller.php +++ b/poller.php @@ -314,7 +314,7 @@ while ($device = mysql_fetch_assoc($device_query)) ### Ideally we should hold graphs for xx days/weeks/polls so that we don't needlessly hide information. $query = mysql_query("SELECT `graph` FROM `device_graphs` WHERE `device_id` = '".$device['device_id']."'"); - while ($graph = mysql_fetch_array($query)) + while ($graph = mysql_fetch_assoc($query)) { if (!isset($graphs[$graph[0]])) { diff --git a/snmptrap.php b/snmptrap.php index ef08b203e..8170b7929 100755 --- a/snmptrap.php +++ b/snmptrap.php @@ -14,11 +14,11 @@ $entry = explode(",", $argv[1]); print_r($entry); -$device = @mysql_fetch_array(mysql_query("SELECT * FROM devices WHERE `hostname` = '".$entry['0']."'")); +$device = @mysql_fetch_assoc(mysql_query("SELECT * FROM devices WHERE `hostname` = '".$entry['0']."'")); if (!$device['device_id']) { - $device = @mysql_fetch_array(mysql_query("SELECT * FROM ipv4_addresses AS A, ports AS I WHERE + $device = @mysql_fetch_assoc(mysql_query("SELECT * FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = '" . $entry['0']."' AND I.interface_id = A.interface_id")); } diff --git a/upgrade-scripts/fix-events.php b/upgrade-scripts/fix-events.php index 3a0396d4f..868cfb091 100755 --- a/upgrade-scripts/fix-events.php +++ b/upgrade-scripts/fix-events.php @@ -5,7 +5,7 @@ mysql_query("ALTER TABLE `eventlog` ADD `event_id` INT NOT NULL AUTO_INCREMENT $s = "SELECT * FROM eventlog"; $q = mysql_query($s); -while ($event = mysql_fetch_array($q)) +while ($event = mysql_fetch_assoc($q)) { if ($event['interface']) {