mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
more db*
git-svn-id: http://www.observium.org/svn/observer/trunk@2322 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -27,7 +27,7 @@ foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' GRO
|
||||
|
||||
if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
|
||||
|
||||
while ($port = mysql_fetch_assoc($port_query))
|
||||
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' AND `port_descr_descr` = ?", array($customer['port_descr_descr'])) as $port)
|
||||
{
|
||||
$device = device_by_id_cache($port['device_id']);
|
||||
|
||||
|
||||
@@ -20,9 +20,7 @@ if ($_REQUEST['id'])
|
||||
|
||||
<?php
|
||||
|
||||
$query = mysql_query("SELECT * FROM `devices` ORDER BY `hostname`");
|
||||
|
||||
while ($data = mysql_fetch_assoc($query))
|
||||
foreach (dbFetchRows("SELECT * FROM `devices` ORDER BY `hostname`") as $data)
|
||||
{
|
||||
echo("<option value='".$data['device_id']."'>".$data['hostname']."</option>");
|
||||
}
|
||||
|
||||
@@ -12,8 +12,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_assoc($query))
|
||||
foreach (dbFetchRows("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY hostname") as $device)
|
||||
{
|
||||
$servicesform .= "<option value='" . $device['service_id'] . "'>" . $device['service_id'] . "." . $device['hostname'] . " - " . $device['service_type'] . "</option>";
|
||||
}
|
||||
@@ -41,4 +40,4 @@ if ($_SESSION['userlevel'] < '5')
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -10,11 +10,11 @@ if ($_SESSION['userlevel'] < '10') { include("includes/error-no-perm.inc.php");
|
||||
{
|
||||
if ($_GET['action'] == "del")
|
||||
{
|
||||
$delete_username = mysql_result(mysql_query("SELECT username FROM users WHERE user_id = '" . mres($_GET['user_id']) . "'"),0);
|
||||
$delete_username = dbFetchCell("SELECT username FROM users WHERE user_id = ?", array($_GET['user_id']));
|
||||
|
||||
if ($_GET['confirm'] == "yes")
|
||||
{
|
||||
mysql_query("DELETE FROM `devices_perms` WHERE `user_id` = '" . mres($_GET['user_id']) . "'");
|
||||
dbDelete('devices_perms', "`user_id` = ?", array($_GET['user_id']));
|
||||
if (deluser($_GET['user_id'])) { echo("<span class=info>User '$delete_username' deleted!</span>"); }
|
||||
}
|
||||
else
|
||||
@@ -24,8 +24,8 @@ 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_assoc($userlist))
|
||||
$userlist = dbFetchRows("SELECT * FROM `users`");
|
||||
foreach ($userlist as $userentry)
|
||||
{
|
||||
$i++;
|
||||
echo($i . ". " . $userentry['username'] . "
|
||||
|
||||
+23
-26
@@ -14,44 +14,44 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
|
||||
|
||||
if ($_GET['action'] == "deldevperm")
|
||||
{
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0))
|
||||
if (dbFetchCell("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?", array($_GET['device_id'] ,$_GET['user_id'])))
|
||||
{
|
||||
mysql_query("DELETE FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
|
||||
dbDelete('devices_perms', "`device_id` = ? AND `user_id` = ?", array($_GET['device_id'], $_GET['user_id']));
|
||||
}
|
||||
}
|
||||
if ($_GET['action'] == "adddevperm")
|
||||
{
|
||||
if (!mysql_result(mysql_query("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0))
|
||||
if (!dbFetchCell("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = ? AND `user_id` = ?", array($_GET['device_id'] ,$_GET['user_id'])))
|
||||
{
|
||||
mysql_query("INSERT INTO devices_perms (`device_id`, `user_id`) VALUES ('" . $_GET['device_id'] . "', '" . $_GET['user_id'] . "')");
|
||||
dbInsert(array('device_id' => $_GET['device_id'], 'user_id' => $_GET['user_id']), 'devices_perms');
|
||||
}
|
||||
}
|
||||
if ($_GET['action'] == "delifperm")
|
||||
{
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0))
|
||||
if (dbFetchCell("SELECT COUNT(*) FROM ports_perms WHERE `interface_id` = ? AND `user_id` = ?", array($_GET['interface_id'], $_GET['user_id'])))
|
||||
{
|
||||
mysql_query("DELETE FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
|
||||
dbDelete('ports_perms', "`interface_id` = ? AND `user_id` = ?", array($_GET['interface_id'], $_GET['user_id']));
|
||||
}
|
||||
}
|
||||
if ($_GET['action'] == "addifperm")
|
||||
{
|
||||
if (!mysql_result(mysql_query("SELECT COUNT(*) FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0))
|
||||
if (!dbFetchCell("SELECT COUNT(*) FROM ports_perms WHERE `interface_id` = ? AND `user_id` = ?", array($_GET['interface_id'], $_GET['user_id'])))
|
||||
{
|
||||
mysql_query("INSERT INTO ports_perms (`interface_id`, `user_id`) VALUES ('" . $_GET['interface_id'] . "', '" . $_GET['user_id'] . "')");
|
||||
dbInsert(array('interface_id' => $_GET['interface_id'], 'user_id' => $_GET['user_id']), 'ports_perms');
|
||||
}
|
||||
}
|
||||
if ($_GET['action'] == "delbillperm")
|
||||
{
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0))
|
||||
if (dbFetchCell("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?", array($_GET['bill_id'], $_GET['user_id'])))
|
||||
{
|
||||
mysql_query("DELETE FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
|
||||
dbDelete('bill_perms', "`bill_id` = ? AND `user_id` = ?", array($_GET['bill_id'], $_GET['user_id']));
|
||||
}
|
||||
}
|
||||
if ($_GET['action'] == "addbillperm")
|
||||
{
|
||||
if (!mysql_result(mysql_query("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0))
|
||||
if (!dbFetchCell("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = ? AND `user_id` = ?", array($_GET['bill_id'], $_GET['user_id'])))
|
||||
{
|
||||
mysql_query("INSERT INTO bill_perms (`bill_id`, `user_id`) VALUES ('" . $_GET['bill_id'] . "', '" . $_GET['user_id'] . "')");
|
||||
dbInsert(array('bill_id' => $_GET['bill_id'], 'user_id' => $_GET['user_id']), 'bill_perms');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,8 +60,8 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
|
||||
// Display devices this users has access to
|
||||
echo("<h3>Device Access</h3>");
|
||||
|
||||
$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_assoc($device_perm_data))
|
||||
$device_perms = dbFetchRows("SELECT * from devices_perms as P, devices as D WHERE `user_id` = ? AND D.device_id = P.device_id", array($_GET['user_id']));
|
||||
foreach ($device_perms as $device_perm)
|
||||
{
|
||||
echo("<strong>" . $device_perm['hostname'] . " <a href='?page=edituser&action=deldevperm&user_id=" . $_GET['user_id'] . "&device_id=" . $device_perm['device_id'] . "'><img src='images/16/cross.png' align=absmiddle border=0></a></strong><br />");
|
||||
$access_list[] = $device_perm['device_id'];
|
||||
@@ -78,8 +78,8 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
|
||||
<input type='hidden' value='adddevperm' name='action'>
|
||||
<select name='device_id' class=selector>");
|
||||
|
||||
$device_list = mysql_query("SELECT * FROM `devices` ORDER BY hostname");
|
||||
while ($device = mysql_fetch_assoc($device_list))
|
||||
$devices = dbFetchRows("SELECT * FROM `devices` ORDER BY hostname");
|
||||
foreach ($devices as $device)
|
||||
{
|
||||
unset($done);
|
||||
foreach ($access_list as $ac) { if ($ac == $device['device_id']) { $done = 1; } }
|
||||
@@ -94,10 +94,9 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
|
||||
echo("</td><td valign=top width=33%>");
|
||||
echo("<h3>Interface Access</h3>");
|
||||
|
||||
$interface_perm_data = mysql_query("SELECT * from ports_perms as P, ports as I, devices as D WHERE `user_id` = '" . $_GET['user_id'] .
|
||||
"' AND I.interface_id = P.interface_id AND D.device_id = I.device_id");
|
||||
$interface_perms = dbFetchRows("SELECT * from ports_perms as P, ports as I, devices as D WHERE `user_id` = ? AND I.interface_id = P.interface_id AND D.device_id = I.device_id", array($_GET['user_id']));
|
||||
|
||||
while ($interface_perm = mysql_fetch_assoc($interface_perm_data))
|
||||
foreach ($interface_perms as $interface_perm)
|
||||
{
|
||||
echo("<table><tr><td><strong>".$interface_perm['hostname']." - ".$interface_perm['ifDescr']."</strong><br />".
|
||||
"" . $interface_perm['ifAlias'] . "</td><td width=50> <a href='?page=edituser&action=delifperm&user_id=" . $_GET['user_id'] .
|
||||
@@ -118,8 +117,7 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
|
||||
<td><select id='device' class='selector' name='device' onchange='getInterfaceList(this)'>
|
||||
<option value=''>Select a device</option>");
|
||||
|
||||
$device_list = mysql_query("SELECT * FROM `devices` ORDER BY hostname");
|
||||
while ($device = mysql_fetch_assoc($device_list))
|
||||
foreach ($devices as $device)
|
||||
{
|
||||
unset($done);
|
||||
foreach ($access_list as $ac) { if ($ac == $device['device_id']) { $done = 1; } }
|
||||
@@ -134,10 +132,9 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
|
||||
echo("</td><td valign=top width=33%>");
|
||||
echo("<h3>Bill Access</h3>");
|
||||
|
||||
$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");
|
||||
$bill_perms = dbFetchRows("SELECT * from bills AS B, bill_perms AS P WHERE P.user_id = ? AND P.bill_id = B.bill_id", array($_GET['user_id']));
|
||||
|
||||
while ($bill_perm = mysql_fetch_assoc($bill_perm_data))
|
||||
foreach ($bill_perms as $bill_perm)
|
||||
{
|
||||
echo("<table><tr><td><strong>".$bill_perm['bill_name']."</strong></td><td width=50> <a href='?page=edituser&action=delbillperm&user_id=" .
|
||||
$_GET['user_id'] . "&bill_id=" . $bill_perm['bill_id'] . "'><img src='images/16/cross.png' align=absmiddle border=0></a></td></tr></table>");
|
||||
@@ -156,8 +153,8 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
|
||||
<input type='hidden' value='addbillperm' name='action'>
|
||||
<select name='bill_id' class=selector>");
|
||||
|
||||
$bills = mysql_query("SELECT * FROM `bills` ORDER BY `bill_name`");
|
||||
while ($bill = mysql_fetch_assoc($bills))
|
||||
$bills dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_name`");
|
||||
foreach ($bills as $bill)
|
||||
{
|
||||
unset($done);
|
||||
foreach ($bill_access_list as $ac) { if ($ac == $bill['bill_id']) { $done = 1; } }
|
||||
|
||||
Reference in New Issue
Block a user