/*
+-------------------------------------------------------------------------+
| Copyright (C) 2002 Ian Berry |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| cacti: the rrdtool frontend [php-auth, php-tree, php-form] |
+-------------------------------------------------------------------------+
| This code is currently maintained and debugged by Ian Berry, any |
| questions or comments regarding this code should be directed to: |
| - iberry@raxnet.net |
+-------------------------------------------------------------------------+
| - raXnet - http://www.raxnet.net/ |
+-------------------------------------------------------------------------+
*/?>
include_once ("include/rrd_functions.php");
include_once ("include/functions.php");
include ("include/top_graph_header.php");
//if (isset($args[hide]) == true) {
/* find out if the current user has rights here */
// $graph_settings = db_fetch_cell("select graph_settings from user where id=$user_id");
/* only update expand/contract info is this user has rights to keep their own settings */
// if ($graph_settings == "on") {
// db_execute("delete from settings_viewing_tree where treeitemid=$args[branch_id] and userid=$user_id");
// db_execute("insert into settings_viewing_tree (treeitemid,userid,status) values ($args[branch_id],$user_id,$args[hide])");
// }
//}
switch ($action) {
case 'tree':
include_once ('include/tree_view_functions.php');
if ($current_user["show_tree"] == "") {
print "YOU DO NOT HAVE RIGHTS FOR TREE VIEW"; exit;
}
/* if cacti's builtin authentication is turned on then make sure to take
graph permissions into account here. if a user does not have rights to a
particular graph; do not show it. they will get an access denied message
if they try and view the graph directly. */
if (read_config_option("global_auth") == "on") {
/* take tree permissions into account here, if the user does not have permission
give an "access denied" message */
$user_auth = db_fetch_row("select user_id from user_auth_tree where tree_id=" . $_SESSION["sess_view_tree_id"] . " and user_id=" . $_SESSION["sess_user_id"]);
if ($current_user["graph_policy"] == "1") {
if (sizeof($user_auth) > 0) { $access_denied = true; }
}elseif ($current_user["graph_policy"] == "2") {
if (sizeof($user_auth) == 0) { $access_denied = true; }
}
if ($access_denied == true) {
print "ACCESS DENIED"; exit;
}
}
print "
\n";
grow_graph_tree($_SESSION["sess_view_tree_id"], $start_branch, $user_id, $tree_parameters);
break;
case 'preview':
if ($current_user["show_preview"] == "") {
print "YOU DO NOT HAVE RIGHTS FOR PREVIEW VIEW"; exit;
}
/* graph permissions */
if (read_config_option("global_auth") == "on") {
if ($current_user["graph_policy"] == "1") {
$sql_where = "where user_auth_graph.user_id is null";
}elseif ($current_user["graph_policy"] == "2") {
$sql_where = "where user_auth_graph.user_id is not null";
}
$graphs = db_fetch_assoc("select
graph_templates_graph.local_graph_id,
graph_templates_graph.title
from graph_templates_graph
left join user_auth_graph on (graph_templates_graph.local_graph_id=user_auth_graph.local_graph_id and user_auth_graph.user_id=" . $_SESSION["sess_user_id"] . ")
$sql_where
and graph_templates_graph.local_graph_id > 0
order by graph_templates_graph.title");
}else{
$graphs = db_fetch_assoc("select
local_graph_id,title
from graph_templates_graph
where local_graph_id > 0
order by title");
}
print "";
if (sizeof($graphs) > 0) {
foreach ($graphs as $graph) {
print "![" . $graph["title"] . "](graph_image.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=" . read_graph_config_option("default_rra_id") . "&graph_start=-" . read_graph_config_option("timespan") . "&graph_height=" . read_graph_config_option("default_height") . "&graph_width=" . read_graph_config_option("default_width") . "&graph_nolegend=true) | \n";
$i++;
$k++;
if (($i == read_graph_config_option("num_columns")) && ($k < sizeof($graphs))) {
$i = 0;
print "
| |
\n";
}
}
}
print "
";
break;
case 'list':
if ($current_user["show_list"] == "") {
print "YOU DO NOT HAVE RIGHTS FOR LIST VIEW"; exit;
}
/* graph permissions */
if (read_config_option("global_auth") == "on") {
if ($current_user["graph_policy"] == "1") {
$sql_where = "where user_auth_graph.user_id is null";
}elseif ($current_user["graph_policy"] == "2") {
$sql_where = "where user_auth_graph.user_id is not null";
}
$graphs = db_fetch_assoc("select
graph_templates_graph.local_graph_id,
graph_templates_graph.title
from graph_templates_graph
left join user_auth_graph on (graph_templates_graph.local_graph_id=user_auth_graph.local_graph_id and user_auth_graph.user_id=" . $_SESSION["sess_user_id"] . ")
$sql_where
and graph_templates_graph.local_graph_id > 0
order by graph_templates_graph.title");
}else{
$graphs = db_fetch_assoc("select
local_graph_id,title
from graph_templates_graph
where local_graph_id > 0
order by title");
}
print "";
break;
}
print "";print $_SESSION["sess_debug_buffer"];print "
";session_unregister("sess_debug_buffer");
include_once ("include/bottom_footer.php");