mirror of
https://github.com/librenms/librenms.git
synced 2024-09-23 03:18:54 +00:00
added permissions cache
git-svn-id: http://www.observium.org/svn/observer/trunk@1073 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
parent
ef30ca249d
commit
464f495e29
@ -1,5 +1,18 @@
|
||||
<?php
|
||||
|
||||
function permissions_cache($user_id) {
|
||||
$permissions = array();
|
||||
$query = mysql_query("SELECT * FROM devices_perms WHERE user_id = '".$user_id."'");
|
||||
while($device = mysql_fetch_assoc($query)) {
|
||||
$permissions['device'][$device[device_id]] = 1;
|
||||
}
|
||||
$query = mysql_query("SELECT * FROM ports_perms WHERE user_id = '".$user_id."'");
|
||||
while($port = mysql_fetch_assoc($query)) {
|
||||
$permissions['port'][$port[interface_id]] = 1;
|
||||
}
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
function print_graph_tag ($args)
|
||||
{
|
||||
echo generate_graph_tag ($args);
|
||||
|
@ -17,8 +17,11 @@ if($debug) {
|
||||
include("../includes/functions.php");
|
||||
include("includes/functions.inc.php");
|
||||
include("includes/authenticate.inc.php");
|
||||
$start = utime();
|
||||
if($_SESSION['authenticated']) {
|
||||
$permissions = permissions_cache($_SESSION['user_id']);
|
||||
}
|
||||
|
||||
$start = utime();
|
||||
$now = time();
|
||||
$day = time() - (24 * 60 * 60);
|
||||
$twoday = time() - (2 * 24 * 60 * 60);
|
||||
|
@ -11,21 +11,21 @@ if($_SESSION['userlevel'] >= '5') {
|
||||
$device_query = mysql_query($sql);
|
||||
while($device = mysql_fetch_array($device_query)) {
|
||||
|
||||
if(!isset($bg) || $bg == "#ffffff") { $bg = "#eeeeee"; } else { $bg="#ffffff"; }
|
||||
if(!isset($bg) || $bg == "#ffffff") { $bg = "#eeeeee"; } else { $bg="#ffffff"; }
|
||||
|
||||
if($_SESSION['userlevel'] == '10') {
|
||||
$num = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "'"),0);
|
||||
$net = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "' AND type = 'network'"),0);
|
||||
$srv = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "' AND type = 'server'"),0);
|
||||
$fwl = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "' AND type = 'firewall'"),0);
|
||||
$hostalerts = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "' AND status = '0'"),0);
|
||||
} else {
|
||||
$num = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $device['location'] . "'"),0);
|
||||
$net = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $device['location'] . "' AND D.type = 'network'"),0);
|
||||
$srv = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $device['location'] . "' AND type = 'server'"),0);
|
||||
$fwl = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $device['location'] . "' AND type = 'firewall'"),0);
|
||||
$hostalerts = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE location = '" . $device['location'] . "' AND status = '0'"),0);
|
||||
}
|
||||
if($_SESSION['userlevel'] == '10') {
|
||||
$num = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "'"),0);
|
||||
$net = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "' AND type = 'network'"),0);
|
||||
$srv = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "' AND type = 'server'"),0);
|
||||
$fwl = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "' AND type = 'firewall'"),0);
|
||||
$hostalerts = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "' AND status = '0'"),0);
|
||||
} else {
|
||||
$num = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $device['location'] . "'"),0);
|
||||
$net = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $device['location'] . "' AND D.type = 'network'"),0);
|
||||
$srv = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $device['location'] . "' AND type = 'server'"),0);
|
||||
$fwl = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $device['location'] . "' AND type = 'firewall'"),0);
|
||||
$hostalerts = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE location = '" . $device['location'] . "' AND status = '0'"),0);
|
||||
}
|
||||
|
||||
if($hostalerts) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user