update html/includes/functions to db*()

git-svn-id: http://www.observium.org/svn/observer/trunk@2287 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2011-05-12 20:16:03 +00:00
parent e50c84d396
commit f04a88ed90

View File

@@ -116,18 +116,15 @@ function print_graph_popup($graph_array)
function permissions_cache($user_id) function permissions_cache($user_id)
{ {
$permissions = array(); $permissions = array();
$query = mysql_query("SELECT * FROM devices_perms WHERE user_id = '".$user_id."'"); foreach (dbFetchRows("SELECT * FROM devices_perms WHERE user_id = '".$user_id."'") as $device)
while ($device = mysql_fetch_assoc($query))
{ {
$permissions['device'][$device['device_id']] = 1; $permissions['device'][$device['device_id']] = 1;
} }
$query = mysql_query("SELECT * FROM ports_perms WHERE user_id = '".$user_id."'"); foreach (dbFetchRows("SELECT * FROM ports_perms WHERE user_id = '".$user_id."'") as $port)
while ($port = mysql_fetch_assoc($query))
{ {
$permissions['port'][$port['interface_id']] = 1; $permissions['port'][$port['interface_id']] = 1;
} }
$query = mysql_query("SELECT * FROM bill_perms WHERE user_id = '".$user_id."'"); foreach (dbFetchRows("SELECT * FROM bill_perms WHERE user_id = '".$user_id."'") as $bill)
while ($bill = mysql_fetch_assoc($query))
{ {
$permissions['bill'][$bill['bill_id']] = 1; $permissions['bill'][$bill['bill_id']] = 1;
} }
@@ -366,8 +363,8 @@ function devclass($device)
function getlocations() function getlocations()
{ {
# Fetch override locations, not through get_dev_attrib, this would be a huge number of queries # Fetch override locations, not through get_dev_attrib, this would be a huge number of queries
$result = mysql_query("SELECT attrib_type,attrib_value,device_id FROM devices_attribs WHERE attrib_type LIKE 'override_sysLocation%' ORDER BY attrib_type"); $rows = dbFetchRows("SELECT attrib_type,attrib_value,device_id FROM devices_attribs WHERE attrib_type LIKE 'override_sysLocation%' ORDER BY attrib_type");
while ($row = mysql_fetch_assoc($result)) foreach ($rows as $row)
{ {
if ($row['attrib_type'] == 'override_sysLocation_bool' && $row['attrib_value'] == 1) if ($row['attrib_type'] == 'override_sysLocation_bool' && $row['attrib_value'] == 1)
{ {
@@ -383,12 +380,12 @@ function getlocations()
# Fetch regular locations # Fetch regular locations
if ($_SESSION['userlevel'] >= '5') if ($_SESSION['userlevel'] >= '5')
{ {
$result = mysql_query("SELECT D.device_id,location FROM devices AS D GROUP BY location ORDER BY location"); $rows = dbFetchRows("SELECT D.device_id,location FROM devices AS D GROUP BY location ORDER BY location");
} else { } else {
$result = mysql_query("SELECT D.device_id,location FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' GROUP BY location ORDER BY location"); $rows = dbFetchRows("SELECT D.device_id,location FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? GROUP BY location ORDER BY location", array($_SESSION['user_id']));
} }
while ($row = mysql_fetch_assoc($result)) foreach ($rows as $row)
{ {
# Only add it as a location if it wasn't overridden (and not already there) # Only add it as a location if it wasn't overridden (and not already there)
if ($row['location'] != '' && !$ignore_dev_location[$row['device_id']]) if ($row['location'] != '' && !$ignore_dev_location[$row['device_id']])