From f8384e0d17aa7174eb016c2129582ec39fe3ff66 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Thu, 12 May 2011 11:17:08 +0000 Subject: [PATCH] more dbFacile git-svn-id: http://www.observium.org/svn/observer/trunk@2277 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/pages/device.inc.php | 53 +++++++++++---------------------------- 1 file changed, 15 insertions(+), 38 deletions(-) diff --git a/html/pages/device.inc.php b/html/pages/device.inc.php index 77ee127753..1fa3dfe54b 100644 --- a/html/pages/device.inc.php +++ b/html/pages/device.inc.php @@ -52,11 +52,11 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id']) '); - $health = mysql_result(mysql_query("select count(*) from storage WHERE device_id = '" . $device['device_id'] . "'"), 0) + - mysql_result(mysql_query("select count(sensor_id) from sensors WHERE device_id = '" . $device['device_id'] . "'"), 0) + - mysql_result(mysql_query("select count(*) from cempMemPool WHERE device_id = '" . $device['device_id'] . "'"), 0) + - mysql_result(mysql_query("select count(*) from cpmCPU WHERE device_id = '" . $device['device_id'] . "'"), 0) + - mysql_result(mysql_query("select count(*) from processors WHERE device_id = '" . $device['device_id'] . "'"), 0); + $health = dbFetchCell("select count(*) from storage WHERE device_id = '" . $device['device_id'] . "'") + + dbFetchCell("select count(sensor_id) from sensors WHERE device_id = '" . $device['device_id'] . "'") + + dbFetchCell("select count(*) from cempMemPool WHERE device_id = '" . $device['device_id'] . "'") + + dbFetchCell("select count(*) from cpmCPU WHERE device_id = '" . $device['device_id'] . "'") + + dbFetchCell("select count(*) from processors WHERE device_id = '" . $device['device_id'] . "'"); if ($health) { @@ -67,7 +67,7 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id']) '); } - if (@mysql_result(mysql_query("select count(app_id) from applications WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') + if (@dbFetchCell("select count(app_id) from applications WHERE device_id = '" . $device['device_id'] . "'") > '0') { echo('
  • @@ -85,7 +85,7 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
  • '); } - if (@mysql_result(mysql_query("select count(interface_id) from ports WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') + if (@dbFetchCell("select count(interface_id) from ports WHERE device_id = '" . $device['device_id'] . "'") > '0') { echo('
  • @@ -94,7 +94,7 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
  • '); } - if (@mysql_result(mysql_query("select count(vlan_id) from vlans WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') + if (@dbFetchCell("select count(vlan_id) from vlans WHERE device_id = '" . $device['device_id'] . "'") > '0') { echo('
  • @@ -103,7 +103,7 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
  • '); } - if (@mysql_result(mysql_query("SELECT COUNT(id) FROM vminfo WHERE device_id = '" . $device["device_id"] . "'"), 0) > '0') + if (@dbFetchCell("SELECT COUNT(id) FROM vminfo WHERE device_id = '" . $device["device_id"] . "'") > '0') { echo('
  • @@ -112,17 +112,6 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
  • '); } -# if (@mysql_result(mysql_query("select count(*) from vrfs WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') -# { -# echo('
  • -# -# VRFs -# -#
  • '); -# } - - - if ($config['enable_bgp'] && $device['bgpLocalAs']) { $bgp_menu = '
  • @@ -134,7 +123,7 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id']) if ($config['enable_ospf']) { - $ospf_count = mysql_result(mysql_query("select count(*) from ospf_instances WHERE device_id = '" . $device['device_id'] . "'"), 0); + $ospf_count = dbFetchCell("select count(*) from ospf_instances WHERE device_id = '" . $device['device_id'] . "'"); if ($ospf_count) { $ospf_menu = 1; } } @@ -147,19 +136,7 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
  • '); } -# $cef_query = mysql_query("SELECT COUNT(*) FROM `cef_switching` WHERE `device_id` = '".$device['device_id']."'"); -# $cef_count = mysql_result($cef_query,0); - -# if ($cef_count) -# { -# echo('
  • -# -# CEF -# -#
  • '); -# } - - if ($_SESSION['userlevel'] >= "5" && mysql_result(mysql_query("SELECT count(*) FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.interface_id = L.local_interface_id"),0)) + if ($_SESSION['userlevel'] >= "5" && dbFetchCell("SELECT count(*) FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.interface_id = L.local_interface_id")) { $discovery_links = TRUE; echo('
  • @@ -169,7 +146,7 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
  • '); } - if ($config['enable_inventory'] && @mysql_result(mysql_query("SELECT * FROM `entPhysical` WHERE device_id = '".$device['device_id']."'"), 0) > '0') + if ($config['enable_inventory'] && @dbFetchCell("SELECT * FROM `entPhysical` WHERE device_id = '".$device['device_id']."'") > '0') { echo('
  • @@ -177,7 +154,7 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
  • '); } - elseif (device_permitted($device['device_id']) && $config['enable_inventory'] && @mysql_result(mysql_query("SELECT * FROM `hrDevice` WHERE device_id = '".$device['device_id']."'"), 0) > '0') + elseif (device_permitted($device['device_id']) && $config['enable_inventory'] && @dbFetchCell("SELECT * FROM `hrDevice` WHERE device_id = '".$device['device_id']."'") > '0') { echo('
  • @@ -186,7 +163,7 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
  • '); } - if (mysql_result(mysql_query("select count(service_id) from services WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') + if (dbFetchCell("select count(service_id) from services WHERE device_id = '" . $device['device_id'] . "'") > '0') { echo('
  • @@ -195,7 +172,7 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
  • '); } - if (@mysql_result(mysql_query("select count(toner_id) from toner WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') + if (@dbFetchCell("select count(toner_id) from toner WHERE device_id = '" . $device['device_id'] . "'") > '0') { echo('