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. */ $access_denied = false; $tree_parameters = array(); $tree_dropdown_html = draw_tree_dropdown((isset($_GET["tree_id"]) ? $_GET["tree_id"] : "0")); /* don't even print the table if there is not >1 tree */ if ((!empty($tree_dropdown_html)) && (read_graph_config_option("default_tree_view_mode") == "1")) { print "
$tree_dropdown_html
\n"; } if (isset($_SESSION["sess_view_tree_id"])) { 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 */ $access_denied = !(is_tree_allowed($_SESSION["sess_view_tree_id"])); if ($access_denied == true) { print "ACCESS DENIED"; exit; } } if (read_graph_config_option("default_tree_view_mode") == "1") { grow_graph_tree($_SESSION["sess_view_tree_id"], (!empty($start_branch) ? $start_branch : 0), isset($_SESSION["sess_user_id"]) ? $_SESSION["sess_user_id"] : 0, $tree_parameters); }elseif (read_graph_config_option("default_tree_view_mode") == "2") { grow_right_pane_tree((isset($_GET["tree_id"]) ? $_GET["tree_id"] : 0), (isset($_GET["leaf_id"]) ? $_GET["leaf_id"] : 0), (isset($_GET["graph_template_id"]) ? $_GET["graph_template_id"] : 0)); } } print "

"; break; case 'preview': define("ROWS_PER_PAGE", read_graph_config_option("num_graphs_per_page")); $sql_or = ""; $sql_where = ""; $sql_join = ""; if ((read_config_option("global_auth") == "on") && (empty($current_user["show_preview"]))) { print "YOU DO NOT HAVE RIGHTS FOR PREVIEW VIEW"; exit; } if (isset($_REQUEST["host_id"])) { $_SESSION["sess_graph_view_host"] = $_REQUEST["host_id"]; $_REQUEST["page"] = "1"; }elseif (isset($_SESSION["sess_graph_view_host"])) { $_REQUEST["host_id"] = $_SESSION["sess_graph_view_host"]; }else{ $_REQUEST["host_id"] = "0"; /* default value */ } if (isset($_REQUEST["filter"])) { $_SESSION["sess_graph_view_filter"] = $_REQUEST["filter"]; $_REQUEST["page"] = "1"; }elseif (isset($_SESSION["sess_graph_view_filter"])) { $_REQUEST["filter"] = $_SESSION["sess_graph_view_filter"]; }else{ $_REQUEST["filter"] = ""; /* default value */ } /* restore the page num from the session var if it is currently stored */ if (isset($_REQUEST["page"])) { $_SESSION["sess_graph_view_current_page"] = $_REQUEST["page"]; }elseif (isset($_SESSION["sess_graph_view_current_page"])) { $_REQUEST["page"] = $_SESSION["sess_graph_view_current_page"]; }else{ $_REQUEST["page"] = "1"; /* default value */ } /* graph permissions */ if (read_config_option("global_auth") == "on") { $sql_where = "where " . get_graph_permissions_sql($current_user["policy_graphs"], $current_user["policy_hosts"], $current_user["policy_graph_templates"]); $sql_join = "left join host on host.id=graph_local.host_id left join graph_templates on graph_templates.id=graph_local.graph_template_id left join user_auth_perms on ((graph_templates_graph.local_graph_id=user_auth_perms.item_id and user_auth_perms.type=1 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (host.id=user_auth_perms.item_id and user_auth_perms.type=3 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (graph_templates.id=user_auth_perms.item_id and user_auth_perms.type=4 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . "))"; } /* the user select a bunch of graphs of the 'list' view and wants them dsplayed here */ if (isset($_GET["style"])) { if ($_GET["style"] == "selective") { $i = 0; while (list($var, $val) = each($_GET)) { if (ereg('^graph_([0-9]+)$', $var, $matches)) { $graph_array[$i] = $matches[1]; $i++; } } if ((isset($graph_array)) && (sizeof($graph_array) > 0)) { /* build sql string including each graph the user checked */ $sql_or = "and " . array_to_sql_or($graph_array, "graph_templates_graph.local_graph_id"); /* clear the filter vars so they don't affect our results */ $_REQUEST["filter"] = ""; $_REQUEST["host_id"] = "0"; $set_rra_id = $_GET["rra_id"]; } } } $sql_base = "from graph_templates_graph,graph_local $sql_join $sql_where " . (empty($sql_where) ? "where" : "and") . " graph_templates_graph.local_graph_id > 0 and graph_templates_graph.local_graph_id=graph_local.id and graph_templates_graph.title like '%%" . $_REQUEST["filter"] . "%%' " . (empty($_REQUEST["host_id"]) ? "" : " and graph_local.host_id=" . $_REQUEST["host_id"]) . " $sql_or"; $total_rows = count(db_fetch_assoc("select graph_templates_graph.local_graph_id $sql_base")); $graphs = db_fetch_assoc("select graph_templates_graph.local_graph_id, graph_templates_graph.title_cache $sql_base group by graph_templates_graph.local_graph_id order by graph_templates_graph.title_cache limit " . (ROWS_PER_PAGE*($_REQUEST["page"]-1)) . "," . ROWS_PER_PAGE); print "
"; ?> "> ", basename($_SERVER["PHP_SELF"]) . "?" . $_SERVER["QUERY_STRING"]); }else{ $nav_url = basename($_SERVER["PHP_SELF"]) . "?" . $_SERVER["QUERY_STRING"] . "&page="; } $nav_url = ereg_replace("((\?|&)host_id=[0-9]+|(\?|&)filter=[a-zA-Z0-9]*)", "", $nav_url); print "
Filter by host:  ">  

\n "; $i = 0; $k = 0; if (sizeof($graphs) > 0) { foreach ($graphs as $graph) { print "\n"; $i++; $k++; if (($i == read_graph_config_option("num_columns")) && ($k < count($graphs))) { $i = 0; print ""; } } }else{ print ""; } print "
\n \n \n
<< "; if ($_REQUEST["page"] > 1) { print ""; } print "Previous"; if ($_REQUEST["page"] > 1) { print ""; } print " Showing Rows " . ((ROWS_PER_PAGE*($_REQUEST["page"]-1))+1) . " to " . ((($total_rows < ROWS_PER_PAGE) || ($total_rows < (ROWS_PER_PAGE*$_REQUEST["page"]))) ? $total_rows : (ROWS_PER_PAGE*$_REQUEST["page"])) . " of $total_rows "; if (($_REQUEST["page"] * ROWS_PER_PAGE) < $total_rows) { print ""; } print "Next"; if (($_REQUEST["page"] * ROWS_PER_PAGE) < $total_rows) { print ""; } print " >>
" . $graph["title_cache"] . "
No Graphs Found.
"; print "

"; break; case 'list': if ((read_config_option("global_auth") == "on") && (empty($current_user["show_list"]))) { print "YOU DO NOT HAVE RIGHTS FOR LIST VIEW"; exit; } /* graph permissions */ if (read_config_option("global_auth") == "on") { /* get policy information for the sql where clause */ $sql_where = get_graph_permissions_sql($current_user["policy_graphs"], $current_user["policy_hosts"], $current_user["policy_graph_templates"]); $graphs = db_fetch_assoc("select graph_templates_graph.local_graph_id, graph_templates_graph.title_cache, graph_templates_graph.height, graph_templates_graph.width from graph_templates_graph,graph_local left join host on host.id=graph_local.host_id left join graph_templates on graph_templates.id=graph_local.graph_template_id left join user_auth_perms on ((graph_templates_graph.local_graph_id=user_auth_perms.item_id and user_auth_perms.type=1 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (host.id=user_auth_perms.item_id and user_auth_perms.type=3 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (graph_templates.id=user_auth_perms.item_id and user_auth_perms.type=4 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ")) where graph_templates_graph.local_graph_id=graph_local.id and graph_templates_graph.local_graph_id>0 " . (empty($sql_where) ? "" : "and $sql_where") . " group by graph_templates_graph.local_graph_id order by graph_templates_graph.title_cache"); }else{ $graphs = db_fetch_assoc("select local_graph_id,title_cache,height,width from graph_templates_graph where local_graph_id > 0 order by title_cache"); } print "
\n"; print "
"; print ""; $i = 0; if (sizeof($graphs) > 0) { foreach ($graphs as $graph) { form_alternate_row_color("f5f5f5", "ffffff", $i); print ""; print "\n"; print "\n"; print ""; $i++; } } print "
Displaying " . sizeof($graphs) . " Graph" . ((sizeof($graphs) == 1) ? "" : "s") . "
"; form_checkbox("graph_" . $graph["local_graph_id"], "", "", "", 0); print "" . $graph["title_cache"] . "" . $graph["height"] . "x" . $graph["width"] . "
  "; form_dropdown("rra_id", db_fetch_assoc("select id,name,(rra.rows*rra.steps) as rra_order from rra order by rra_order,name"), "name", "id", "1", "", ""); print "


\n \n \n
\n"; break; } //print "
";print $_SESSION["sess_debug_buffer"];print "
";session_unregister("sess_debug_buffer"); include_once("./include/bottom_footer.php");