本文整理汇总了PHP中get_graph_permissions_sql函数的典型用法代码示例。如果您正苦于以下问题:PHP get_graph_permissions_sql函数的具体用法?PHP get_graph_permissions_sql怎么用?PHP get_graph_permissions_sql使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_graph_permissions_sql函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: thold_user_auth_threshold
function thold_user_auth_threshold($rra)
{
$current_user = db_fetch_row("select policy_graphs,policy_hosts,policy_graph_templates from user_auth where id=" . $_SESSION["sess_user_id"]);
$sql_where = 'WHERE ' . get_graph_permissions_sql($current_user['policy_graphs'], $current_user['policy_hosts'], $current_user['policy_graph_templates']);
$graphs = db_fetch_assoc('SELECT DISTINCT graph_templates_graph.local_graph_id
FROM data_template_rrd
LEFT JOIN graph_templates_item ON graph_templates_item.task_item_id = data_template_rrd.id
LEFT JOIN graph_local ON (graph_local.id=graph_templates_item.local_graph_id)
LEFT JOIN host ON graph_local.host_id = host.id
LEFT JOIN graph_templates_graph ON graph_templates_graph.local_graph_id = graph_local.id
LEFT JOIN graph_templates ON (graph_templates.id=graph_templates_graph.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'] . "))\r\n\t\t{$sql_where}\r\n\t\tAND data_template_rrd.local_data_id = {$rra}");
if (!empty($graphs)) {
return true;
}
return false;
}
示例2: mikrotik_view_graphs
function mikrotik_view_graphs()
{
global $current_user, $colors, $config;
if (file_exists("./lib/timespan_settings.php")) {
include "./lib/timespan_settings.php";
} else {
include "./include/html/inc_timespan_settings.php";
}
/* ================= input validation ================= */
input_validate_input_number(get_request_var("rra_id"));
input_validate_input_number(get_request_var("host"));
input_validate_input_number(get_request_var("cols"));
input_validate_input_regex(get_request_var_request('graph_list'), "^([\\,0-9]+)\$");
input_validate_input_regex(get_request_var_request('graph_add'), "^([\\,0-9]+)\$");
input_validate_input_regex(get_request_var_request('graph_remove'), "^([\\,0-9]+)\$");
/* ==================================================== */
define("ROWS_PER_PAGE", read_graph_config_option("preview_graphs_per_page"));
/* ================= input validation ================= */
input_validate_input_number(get_request_var_request("graph_template_id"));
input_validate_input_number(get_request_var_request("page"));
/* ==================================================== */
/* clean up search string */
if (isset($_REQUEST["filter"])) {
$_REQUEST["filter"] = sanitize_search_string(get_request_var_request("filter"));
}
/* clean up styl string */
if (isset($_REQUEST["style"])) {
$_REQUEST["style"] = sanitize_search_string(get_request_var_request("style"));
}
/* clean up styl string */
if (isset($_REQUEST["thumb"])) {
$_REQUEST["thumb"] = sanitize_search_string(get_request_var_request("thumb"));
}
$sql_or = "";
$sql_where = "";
$sql_join = "";
/* if the user pushed the 'clear' button */
if (isset($_REQUEST["reset"])) {
kill_session_var("sess_mikrotik_graph_current_page");
kill_session_var("sess_mikrotik_graph_filter");
kill_session_var("sess_mikrotik_graph_host");
kill_session_var("sess_mikrotik_graph_cols");
kill_session_var("sess_mikrotik_graph_thumb");
kill_session_var("sess_mikrotik_graph_add");
kill_session_var("sess_mikrotik_graph_style");
kill_session_var("sess_mikrotik_graph_graph_template");
} elseif (isset($_REQUEST["clear"])) {
kill_session_var("sess_mikrotik_graph_current_page");
kill_session_var("sess_mikrotik_graph_filter");
kill_session_var("sess_mikrotik_graph_host");
kill_session_var("sess_mikrotik_graph_cols");
kill_session_var("sess_mikrotik_graph_thumb");
kill_session_var("sess_mikrotik_graph_add");
kill_session_var("sess_mikrotik_graph_style");
kill_session_var("sess_mikrotik_graph_graph_template");
unset($_REQUEST["page"]);
unset($_REQUEST["filter"]);
unset($_REQUEST["host"]);
unset($_REQUEST["cols"]);
unset($_REQUEST["thumb"]);
unset($_REQUEST["graph_template_id"]);
unset($_REQUEST["graph_list"]);
unset($_REQUEST["graph_add"]);
unset($_REQUEST["style"]);
unset($_REQUEST["graph_remove"]);
} else {
/* if any of the settings changed, reset the page number */
$changed = false;
$changed += mikrotik_check_changed("fitler", "sess_mikrotik_graph_filter");
$changed += mikrotik_check_changed("host", "sess_mikrotik_graph_host");
$changed += mikrotik_check_changed("style", "sess_mikrotik_graph_style");
$changed += mikrotik_check_changed("graph_add", "sess_mikrotik_graph_add");
$changed += mikrotik_check_changed("graph_template_id", "sess_mikrotik_graph_graph_template");
if ($changed) {
$_REQUEST["page"] = "1";
$_REQUEST["style"] = "";
$_REQUEST["graph_add"] = "";
}
}
load_current_session_value("graph_template_id", "sess_mikrotik_graph_graph_template", "0");
load_current_session_value("host", "sess_mikrotik_graph_host", "0");
load_current_session_value("cols", "sess_mikrotik_graph_cols", "2");
load_current_session_value("thumb", "sess_mikrotik_graph_thumb", "true");
load_current_session_value("graph_add", "sess_mikrotik_graph_add", "");
load_current_session_value("style", "sess_mikrotik_graph_style", "");
load_current_session_value("filter", "sess_mikrotik_graph_filter", "");
load_current_session_value("page", "sess_mikrotik_graph_current_page", "1");
if ($_REQUEST["graph_add"] != "") {
$_REQUEST["style"] = "selective";
}
/* graph permissions */
if (read_config_option("auth_method") != 0) {
$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)\n\t\t\tLEFT JOIN graph_templates\n\t\t\tON (graph_templates.id=graph_local.graph_template_id)\n\t\t\tLEFT JOIN user_auth_perms\n\t\t\tON ((graph_templates_graph.local_graph_id=user_auth_perms.item_id\n\t\t\tAND user_auth_perms.type=1\n\t\t\tAND user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ")\n\t\t\tOR (host.id=user_auth_perms.item_id AND user_auth_perms.type=3 AND user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ")\n\t\t\tOR (graph_templates.id=user_auth_perms.item_id AND user_auth_perms.type=4 AND user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . "))";
} else {
$sql_where = "";
$sql_join = "";
}
/* the user select a bunch of graphs of the 'list' view and wants them dsplayed here */
if (isset($_REQUEST["style"])) {
//.........这里部分代码省略.........
示例3: is_graph_allowed
function is_graph_allowed($local_graph_id)
{
$current_user = db_fetch_row("select policy_graphs,policy_hosts,policy_graph_templates from user_auth where id=" . $_SESSION["sess_user_id"]);
/* 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\n\t\tgraph_templates_graph.local_graph_id\n\t\tfrom (graph_templates_graph,graph_local)\n\t\tleft join host on (host.id=graph_local.host_id)\n\t\tleft join graph_templates on (graph_templates.id=graph_local.graph_template_id)\n\t\tleft 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"] . "))\n\t\twhere graph_templates_graph.local_graph_id=graph_local.id\n\t\t" . (empty($sql_where) ? "" : "and {$sql_where}") . "\n\t\tand graph_templates_graph.local_graph_id={$local_graph_id}\n\t\tgroup by graph_templates_graph.local_graph_id");
if (sizeof($graphs) > 0) {
return true;
} else {
return false;
}
}
示例4: get_graph_tree_content
function get_graph_tree_content($tree_id, $leaf_id, $device_group_data) {
global $current_user, $colors, $config, $graphs_per_page;
include(CACTI_BASE_PATH . "/include/global_arrays.php");
require(CACTI_BASE_PATH . "/include/graph_tree/graph_tree_arrays.php");
include_once(CACTI_BASE_PATH . "/lib/data_query.php");
include_once(CACTI_BASE_PATH . "/lib/tree.php");
include_once(CACTI_BASE_PATH . "/lib/html_utility.php");
include_once(CACTI_BASE_PATH . "/lib/graph/graph_view_form.php");
define("MAX_DISPLAY_PAGES", 21);
if (empty($tree_id)) { return; }
$sql_where = "";
$sql_join = "";
$title = "";
$title_delimeter = "";
$search_key = "";
$leaf = db_fetch_row("SELECT order_key, title, device_id, device_grouping_type
FROM graph_tree_items
WHERE id=$leaf_id");
$leaf_type = get_tree_item_type($leaf_id);
/* get the "starting leaf" if the user clicked on a specific branch */
if (!empty($leaf_id)) {
$search_key = substr($leaf["order_key"], 0, (tree_tier($leaf["order_key"]) * CHARS_PER_TIER));
}
/* graph permissions */
if (read_config_option("auth_method") != 0) {
/* get policy information for the sql where clause */
$sql_where = get_graph_permissions_sql($current_user["policy_graphs"], $current_user["policy_devices"], $current_user["policy_graph_templates"]);
$sql_where = (empty($sql_where) ? "" : "AND $sql_where");
$sql_join = "
LEFT JOIN device ON (device.id=graph_local.device_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 (device.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"] . "))";
}
/* get information for the headers */
if (!empty($tree_id)) { $tree_name = db_fetch_cell("SELECT name FROM graph_tree WHERE id=$tree_id"); }
if (!empty($leaf_id)) { $leaf_name = $leaf["title"]; }
if (!empty($leaf_id)) { $device_name = db_fetch_cell("SELECT device.description FROM (graph_tree_items,device) WHERE graph_tree_items.device_id=device.id AND graph_tree_items.id=$leaf_id"); }
$device_group_data_array = $device_group_data;
if ($device_group_data_array[0] == "gt") {
$device_group_data_name = "Graph Template: " . db_fetch_cell("select name from graph_templates where id=" . $device_group_data_array[1]);
$graph_template_id = $device_group_data_array[1];
}elseif ($device_group_data_array[0] == "dq") {
$device_group_data_name = "Graph Template: " . (empty($device_group_data_array[1]) ? "Non Query Based" : db_fetch_cell("select name from snmp_query where id=" . $device_group_data_array[1]));
$data_query_id = $device_group_data_array[1];
}elseif ($device_group_data_array[0] == "dqi") {
$device_group_data_name = "Graph Template: " . (empty($device_group_data_array[1]) ? "Non Query Based" : db_fetch_cell("select name from snmp_query where id=" . $device_group_data_array[1])) . "-> " . (empty($device_group_data_array[2]) ? "Template Based" : get_formatted_data_query_index($leaf["device_id"], $device_group_data_array[1], $device_group_data_array[2]));
$data_query_id = $device_group_data_array[1];
$data_query_index = $device_group_data_array[2];
}
if (!empty($tree_name)) { $title .= $title_delimeter . "<strong>Tree:</strong> $tree_name"; $title_delimeter = "-> "; }
if (!empty($leaf_name)) { $title .= $title_delimeter . "<strong.Leaf:</strong> $leaf_name"; $title_delimeter = "-> "; }
if (!empty($device_name)) { $title .= $title_delimeter . "<strong>Host:</strong> $device_name"; $title_delimeter = "-> "; }
if (!empty($device_group_data_name)) { $title .= $title_delimeter . " $device_group_data_name"; $title_delimeter = "-> "; }
/* ================= input validation ================= */
input_validate_input_number(get_request_var_request("graphs"));
input_validate_input_number(get_request_var_request("page"));
/* ==================================================== */
/* if the user pushed the 'clear' button */
if (isset($_REQUEST["clear_filter"])) {
kill_session_var("sess_graph_view_graphs");
kill_session_var("sess_graph_view_filter");
kill_session_var("sess_graph_view_page");
unset($_REQUEST["graphs"]);
unset($_REQUEST["filter"]);
unset($_REQUEST["page"]);
$changed = true;
}else{
/* if any of the settings changed, reset the page number */
$changed = 0;
$changed += check_changed("graphs", "sess_graph_view_graphs");
$changed += check_changed("filter", "sess_graph_view_filter");
$changed += check_changed("action", "sess_graph_view_action");
}
if (isset($_SESSION["sess_graph_view_tree_id"])) {
if ($_SESSION["sess_graph_view_tree_id"] != $tree_id) {
$changed += 1;
}
}
$_SESSION["sess_graph_view_tree_id"] = $tree_id;
if (isset($_SESSION["sess_graph_view_leaf_id"])) {
if ($_SESSION["sess_graph_view_leaf_id"] != $leaf_id) {
$changed += 1;
}
//.........这里部分代码省略.........
示例5: grow_right_pane_tree
function grow_right_pane_tree($tree_id, $leaf_id, $host_group_data) {
global $current_user, $colors, $config;
include($config["include_path"] . "/config_arrays.php");
include_once($config["library_path"] . "/data_query.php");
include_once($config["library_path"] . "/tree.php");
include_once($config["library_path"] . "/html_utility.php");
if (empty($tree_id)) { return; }
$sql_where = "";
$sql_join = "";
$title = "";
$title_delimeter = "";
$search_key = "";
$leaf = db_fetch_row("select order_key,title,host_id,host_grouping_type from graph_tree_items where id=$leaf_id");
$leaf_type = get_tree_item_type($leaf_id);
/* get the "starting leaf" if the user clicked on a specific branch */
if (!empty($leaf_id)) {
$search_key = substr($leaf["order_key"], 0, (tree_tier($leaf["order_key"]) * CHARS_PER_TIER));
}
/* 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"]);
$sql_where = (empty($sql_where) ? "" : "and $sql_where");
$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"] . "))";
}
/* get information for the headers */
if (!empty($tree_id)) { $tree_name = db_fetch_cell("select name from graph_tree where id=$tree_id"); }
if (!empty($leaf_id)) { $leaf_name = $leaf["title"]; }
if (!empty($leaf_id)) { $host_name = db_fetch_cell("select host.description from (graph_tree_items,host) where graph_tree_items.host_id=host.id and graph_tree_items.id=$leaf_id"); }
$host_group_data_array = explode(":", $host_group_data);
if ($host_group_data_array[0] == "graph_template") {
$host_group_data_name = "<strong>Graph Template:</strong> " . db_fetch_cell("select name from graph_templates where id=" . $host_group_data_array[1]);
$graph_template_id = $host_group_data_array[1];
}elseif ($host_group_data_array[0] == "data_query") {
$host_group_data_name = "<strong>Data Query:</strong> " . (empty($host_group_data_array[1]) ? "(Non Indexed)" : db_fetch_cell("select name from snmp_query where id=" . $host_group_data_array[1]));
$data_query_id = $host_group_data_array[1];
}elseif ($host_group_data_array[0] == "data_query_index") {
$host_group_data_name = "<strong>Data Query:</strong> " . (empty($host_group_data_array[1]) ? "(Non Indexed) " : db_fetch_cell("select name from snmp_query where id=" . $host_group_data_array[1])) . "-> " . (empty($host_group_data_array[2]) ? "Unknown Index" : get_formatted_data_query_index($leaf["host_id"], $host_group_data_array[1], $host_group_data_array[2]));
$data_query_id = $host_group_data_array[1];
$data_query_index = $host_group_data_array[2];
}
if (!empty($tree_name)) { $title .= $title_delimeter . "<strong>Tree:</strong> $tree_name"; $title_delimeter = "-> "; }
if (!empty($leaf_name)) { $title .= $title_delimeter . "<strong>Leaf:</strong> $leaf_name"; $title_delimeter = "-> "; }
if (!empty($host_name)) { $title .= $title_delimeter . "<strong>Host:</strong> $host_name"; $title_delimeter = "-> "; }
if (!empty($host_group_data_name)) { $title .= $title_delimeter . " $host_group_data_name"; $title_delimeter = "-> "; }
print "<table width='98%' align='center' cellpadding='3'>";
/* include time span selector */
if (read_graph_config_option("timespan_sel") == "on") {
html_graph_start_box(3, false);
include("./include/html/inc_timespan_selector.php");
html_graph_end_box();
print "<br>";
}
/* start graph display */
html_graph_start_box(3, false);
print "<tr bgcolor='#" . $colors["header_panel"] . "'><td width='390' colspan='3' class='textHeaderDark'>$title</td></tr>";
if (($leaf_type == "header") || (empty($leaf_id))) {
$heirarchy = db_fetch_assoc("select
graph_tree_items.id,
graph_tree_items.title,
graph_tree_items.local_graph_id,
graph_tree_items.rra_id,
graph_tree_items.order_key,
graph_templates_graph.title_cache as title_cache
from (graph_tree_items,graph_local)
left join graph_templates_graph on (graph_tree_items.local_graph_id=graph_templates_graph.local_graph_id and graph_tree_items.local_graph_id>0)
$sql_join
where graph_tree_items.graph_tree_id=$tree_id
and graph_local.id=graph_templates_graph.local_graph_id
and graph_tree_items.order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'
and graph_tree_items.local_graph_id>0
$sql_where
group by graph_tree_items.id
order by graph_tree_items.order_key");
if (read_graph_config_option("thumbnail_section_tree_2") == "on") {
html_graph_thumbnail_area($heirarchy, "", "view_type=tree&graph_start=" . get_current_graph_start() . "&graph_end=" . get_current_graph_end());
}else{
html_graph_area($heirarchy, "", "view_type=tree&graph_start=" . get_current_graph_start() . "&graph_end=" . get_current_graph_end());
}
}elseif ($leaf_type == "host") {
/* graph template grouping */
if ($leaf["host_grouping_type"] == HOST_GROUPING_GRAPH_TEMPLATE) {
//.........这里部分代码省略.........
示例6: export_tree_graphs_and_graph_html
function export_tree_graphs_and_graph_html($path, $tree_id)
{
global $colors, $config;
include_once $config["library_path"] . "/tree.php";
include_once $config["library_path"] . "/data_query.php";
/* start the count of graphs */
$total_graphs_created = 0;
$exported_files = array();
$cacti_export_path = read_config_option("path_html_export");
/* auth check for hosts on the trees */
$current_user = db_fetch_row("SELECT * FROM user_auth WHERE id=" . read_config_option("export_user_id"));
if (!export_is_tree_allowed($tree_id)) {
return 0;
}
$sql_join = "LEFT JOIN graph_local ON (graph_templates_graph.local_graph_id=graph_local.id)\n\t\tLEFT JOIN graph_templates ON (graph_templates.id=graph_local.graph_template_id)\n\t\tLEFT JOIN host ON (host.id=graph_local.host_id)\n\t\tLEFT 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=" . $current_user["id"] . ") OR (host.id=user_auth_perms.item_id AND user_auth_perms.type=3 AND user_auth_perms.user_id=" . $current_user["id"] . ") OR (graph_templates.id=user_auth_perms.item_id AND user_auth_perms.type=4 AND user_auth_perms.user_id=" . $current_user["id"] . "))";
$sql_where = get_graph_permissions_sql($current_user["policy_graphs"], $current_user["policy_hosts"], $current_user["policy_graph_templates"]);
$sql_where = empty($sql_where) ? "" : "AND {$sql_where}";
$graphs = array();
if ($tree_id == 0) {
$hosts = db_fetch_assoc("SELECT DISTINCT host_id FROM graph_tree_items");
} else {
$hosts = db_fetch_assoc("SELECT DISTINCT host_id FROM graph_tree_items WHERE graph_tree_id=" . $tree_id);
}
/* get a list of host graphs first */
if (sizeof($hosts)) {
foreach ($hosts as $host) {
$hosts_sql = "SELECT DISTINCT\n\t\t\tgraph_templates_graph.id,\n\t\t\tgraph_templates_graph.local_graph_id,\n\t\t\tgraph_templates_graph.height,\n\t\t\tgraph_templates_graph.width,\n\t\t\tgraph_templates_graph.title_cache,\n\t\t\tgraph_templates.name,\n\t\t\tgraph_local.host_id\n\t\t\tFROM (graph_tree_items, graph_templates_graph)\n\t\t\t{$sql_join}\n\t\t\tWHERE ((graph_templates_graph.local_graph_id<>0)\n\t\t\t{$sql_where}\n\t\t\tAND (graph_local.host_id=" . $host["host_id"] . ")\n\t\t\tAND (graph_templates_graph.export='on'))\n\t\t\tORDER BY graph_templates_graph.title_cache";
$host_graphs = db_fetch_assoc($hosts_sql);
if (sizeof($host_graphs)) {
if (sizeof($graphs)) {
$graphs = array_merge($host_graphs, $graphs);
} else {
$graphs = $host_graphs;
}
}
}
}
/* now get the list of graphs placed within the tree */
if ($tree_id == 0) {
$sql_where = "WHERE graph_templates_graph.local_graph_id!=0\n\t\t\t{$sql_where}\n\t\t\tAND graph_templates_graph.export='on'";
} else {
$sql_where = "WHERE graph_tree_items.graph_tree_id =" . $tree_id . "\n\t\t\t{$sql_where}\n\t\t\tAND graph_templates_graph.local_graph_id!=0\n\t\t\tAND graph_templates_graph.export='on'";
}
$non_host_sql = "SELECT\n\t\tgraph_templates_graph.id,\n\t\tgraph_templates_graph.local_graph_id,\n\t\tgraph_templates_graph.height,\n\t\tgraph_templates_graph.width,\n\t\tgraph_templates_graph.title_cache,\n\t\tgraph_templates.name,\n\t\tgraph_local.host_id,\n\t\tgraph_tree_items.id AS gtid\n\t\tFROM (graph_tree_items, graph_templates_graph)\n\t\t{$sql_join}\n\t\t{$sql_where}\n\t\tAND graph_tree_items.local_graph_id = graph_templates_graph.local_graph_id\n\t\tAND graph_templates_graph.export='on'\n\t\tORDER BY graph_templates_graph.title_cache";
$non_host_graphs = db_fetch_assoc($non_host_sql);
if (sizeof($non_host_graphs)) {
if (sizeof($graphs)) {
$graphs = array_merge($non_host_graphs, $graphs);
} else {
$graphs = $non_host_graphs;
}
}
/* open a pipe to rrdtool for writing */
$rrdtool_pipe = rrd_init();
/* for each graph... */
$i = 0;
if (sizeof($graphs) > 0) {
foreach ($graphs as $graph) {
$rras = get_associated_rras($graph["local_graph_id"]);
/* settings for preview graphs */
$graph_data_array["graph_height"] = read_config_option("export_default_height");
$graph_data_array["graph_width"] = read_config_option("export_default_width");
$graph_data_array["graph_nolegend"] = true;
$graph_data_array["export"] = true;
if (read_config_option("export_tree_isolation") == "on") {
$graph_data_array["export_filename"] = "/" . $path . "/graphs/thumb_" . $graph["local_graph_id"] . ".png";
$export_filename = $cacti_export_path . "/" . $path . "/graphs/thumb_" . $graph["local_graph_id"] . ".png";
} else {
$graph_data_array["export_filename"] = "/graphs/thumb_" . $graph["local_graph_id"] . ".png";
$export_filename = $cacti_export_path . "/graphs/thumb_" . $graph["local_graph_id"] . ".png";
}
if (!array_search($export_filename, $exported_files)) {
/* add the graph to the exported list */
array_push($exported_files, $export_filename);
export_log("Creating Graph '" . $cacti_export_path . $graph_data_array["export_filename"] . "'");
/* generate the graph */
rrdtool_function_graph($graph["local_graph_id"], 0, $graph_data_array, $rrdtool_pipe);
$total_graphs_created++;
/* generate html files for each graph */
if (read_config_option("export_tree_isolation") == "on") {
export_log("Creating File '" . $cacti_export_path . "/" . $path . "/graph_" . $graph["local_graph_id"] . ".html'");
$fp_graph_index = fopen($cacti_export_path . "/" . $path . "/graph_" . $graph["local_graph_id"] . ".html", "w");
} else {
export_log("Creating File '" . $cacti_export_path . "/graph_" . $graph["local_graph_id"] . ".html'");
$fp_graph_index = fopen($cacti_export_path . "/graph_" . $graph["local_graph_id"] . ".html", "w");
}
fwrite($fp_graph_index, HTML_HEADER_TREE);
/* write the code for the tree at the left */
draw_html_left_tree($fp_graph_index, $tree_id);
fwrite($fp_graph_index, HTML_GRAPH_HEADER_ONE_TREE);
fwrite($fp_graph_index, "<strong>Graph - " . $graph["title_cache"] . "</strong></td></tr>");
fwrite($fp_graph_index, HTML_GRAPH_HEADER_TWO_TREE);
fwrite($fp_graph_index, "<td>");
/* reset vars for actual graph image creation */
reset($rras);
unset($graph_data_array);
/* generate graphs for each rra */
foreach ($rras as $rra) {
$graph_data_array["export"] = true;
if (read_config_option("export_tree_isolation") == "on") {
//.........这里部分代码省略.........
示例7: grow_right_pane_tree
function grow_right_pane_tree($tree_id, $leaf_id, $host_group_data) {
global $current_user, $colors, $config, $graphs_per_page, $graph_timeshifts;
include($config["include_path"] . "/global_arrays.php");
include_once($config["library_path"] . "/data_query.php");
include_once($config["library_path"] . "/tree.php");
include_once($config["library_path"] . "/html_utility.php");
define("MAX_DISPLAY_PAGES", 21);
if (empty($tree_id)) { return; }
$sql_where = "";
$sql_join = "";
$title = "";
$title_delimeter = "";
$search_key = "";
$leaf = db_fetch_row("SELECT order_key, title, host_id, host_grouping_type
FROM graph_tree_items
WHERE id=$leaf_id");
$leaf_type = get_tree_item_type($leaf_id);
/* get the "starting leaf" if the user clicked on a specific branch */
if (!empty($leaf_id)) {
$search_key = substr($leaf["order_key"], 0, (tree_tier($leaf["order_key"]) * CHARS_PER_TIER));
}
/* graph permissions */
if (read_config_option("auth_method") != 0) {
/* 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"]);
$sql_where = (empty($sql_where) ? "" : "AND $sql_where");
$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"] . "))";
}
/* get information for the headers */
if (!empty($tree_id)) { $tree_name = db_fetch_cell("SELECT name FROM graph_tree WHERE id=$tree_id"); }
if (!empty($leaf_id)) { $leaf_name = $leaf["title"]; }
if (!empty($leaf_id)) { $host_name = db_fetch_cell("SELECT host.description FROM (graph_tree_items,host) WHERE graph_tree_items.host_id=host.id AND graph_tree_items.id=$leaf_id"); }
$host_group_data_array = explode(":", $host_group_data);
if ($host_group_data_array[0] == "graph_template") {
$host_group_data_name = "<strong>Graph Template:</strong> " . db_fetch_cell("select name from graph_templates where id=" . $host_group_data_array[1]);
$graph_template_id = $host_group_data_array[1];
}elseif ($host_group_data_array[0] == "data_query") {
$host_group_data_name = "<strong>Graph Template:</strong> " . (empty($host_group_data_array[1]) ? "Non Query Based" : db_fetch_cell("select name from snmp_query where id=" . $host_group_data_array[1]));
$data_query_id = $host_group_data_array[1];
}elseif ($host_group_data_array[0] == "data_query_index") {
$host_group_data_name = "<strong>Graph Template:</strong> " . (empty($host_group_data_array[1]) ? "Non Query Based" : db_fetch_cell("select name from snmp_query where id=" . $host_group_data_array[1])) . "-> " . (empty($host_group_data_array[2]) ? "Template Based" : get_formatted_data_query_index($leaf["host_id"], $host_group_data_array[1], $host_group_data_array[2]));
$data_query_id = $host_group_data_array[1];
$data_query_index = $host_group_data_array[2];
}
if (!empty($tree_name)) { $title .= $title_delimeter . "<strong>Tree:</strong> $tree_name"; $title_delimeter = "-> "; }
if (!empty($leaf_name)) { $title .= $title_delimeter . "<strong>Leaf:</strong> $leaf_name"; $title_delimeter = "-> "; }
if (!empty($host_name)) { $title .= $title_delimeter . "<strong>Host:</strong> $host_name"; $title_delimeter = "-> "; }
if (!empty($host_group_data_name)) { $title .= $title_delimeter . " $host_group_data_name"; $title_delimeter = "-> "; }
if (isset($_REQUEST["tree_id"])) {
$nodeid = "tree_" . get_request_var_request("tree_id");
}
if (isset($_REQUEST["leaf_id"])) {
$nodeid .= "_leaf_" . get_request_var_request("leaf_id");
}
if (isset($_REQUEST["host_group_data"])) {
$type_id = explode(":", get_request_var_request("host_group_data"));
if ($type_id[0] == "graph_template") {
$nodeid .= "_hgd_gt_" . $type_id[1];
}elseif ($type_id[0] == "data_query") {
$nodeid .= "_hgd_dq_" . $type_id[1];
}else{
$nodeid .= "_hgd_dqi" . $type_id[1] . "_" . $type_id[2];
}
}
print "<script type=\"text/javascript\">\n";
print "<!--\n";
print "myNode = findObj(\"$nodeid\")\n";
print "myNode.forceOpeningOfAncestorFolders();\n";
print "highlightObjLink(myNode)\n";
print "//-->\n";
print "</script>";
print "<table width='100%' align='center' cellpadding='3'>";
/* ================= input validation ================= */
input_validate_input_number(get_request_var_post("graphs"));
input_validate_input_number(get_request_var_post("page"));
/* ==================================================== */
/* clean up search string */
if (isset($_REQUEST["filter"])) {
//.........这里部分代码省略.........
示例8: tholds
function tholds($header_label)
{
global $colors, $thold_bgcolors, $item_rows, $config;
$thold_actions = array(1 => 'Associate', 2 => 'Disassociate');
thold_request_validation();
$statefilter = '';
if (isset($_REQUEST['state'])) {
if ($_REQUEST['state'] == '-1') {
$statefilter = '';
} else {
if ($_REQUEST['state'] == '0') {
$statefilter = "thold_data.thold_enabled='off'";
}
if ($_REQUEST['state'] == '2') {
$statefilter = "thold_data.thold_enabled='on'";
}
if ($_REQUEST['state'] == '1') {
$statefilter = 'thold_data.thold_alert!=0 OR thold_data.bl_alert>0';
}
if ($_REQUEST['state'] == '3') {
$statefilter = '(thold_data.thold_alert!=0 AND thold_data.thold_fail_count >= thold_data.thold_fail_trigger) OR (thold_data.bl_alert>0 AND thold_data.bl_fail_count >= thold_data.bl_fail_trigger)';
}
}
}
$alert_num_rows = read_config_option('alert_num_rows');
if ($alert_num_rows < 1 || $alert_num_rows > 5000) {
db_execute("REPLACE INTO settings VALUES ('alert_num_rows', 30)");
/* pull it again so it updates the cache */
$alert_num_rows = read_config_option('alert_num_rows', true);
}
$sql_where = "WHERE template_enabled='off'";
$sort = $_REQUEST['sort_column'];
$limit = ' LIMIT ' . $alert_num_rows * ($_REQUEST['page'] - 1) . ",{$alert_num_rows}";
if (!empty($_REQUEST['template']) && $_REQUEST['template'] != 'ALL') {
$sql_where .= (!strlen($sql_where) ? 'WHERE ' : ' AND ') . "thold_data.data_template = " . $_REQUEST['template'];
}
if (strlen($_REQUEST['filter'])) {
$sql_where .= (!strlen($sql_where) ? 'WHERE ' : ' AND ') . "thold_data.name LIKE '%" . $_REQUEST['filter'] . "%'";
}
if ($statefilter != '') {
$sql_where .= (!strlen($sql_where) ? 'WHERE ' : ' AND ') . "{$statefilter}";
}
if ($_REQUEST["associated"] == 'true') {
$sql_where .= (!strlen($sql_where) ? 'WHERE ' : ' AND ') . "(notify_warning=" . get_request_var_request('id') . " OR notify_alert=" . get_request_var_request('id') . ")";
}
$current_user = db_fetch_row('SELECT * FROM user_auth WHERE id=' . $_SESSION['sess_user_id']);
$sql_where .= (!strlen($sql_where) ? 'WHERE ' : ' AND ') . get_graph_permissions_sql($current_user['policy_graphs'], $current_user['policy_hosts'], $current_user['policy_graph_templates']);
$sql = "SELECT * FROM thold_data\n\t\tLEFT JOIN user_auth_perms \n\t\tON ((thold_data.graph_id=user_auth_perms.item_id \n\t\tAND user_auth_perms.type=1 \n\t\tAND user_auth_perms.user_id=" . $_SESSION['sess_user_id'] . ") \n\t\tOR (thold_data.host_id=user_auth_perms.item_id \n\t\tAND user_auth_perms.type=3 \n\t\tAND user_auth_perms.user_id=" . $_SESSION['sess_user_id'] . ") \n\t\tOR (thold_data.graph_template=user_auth_perms.item_id \n\t\tAND user_auth_perms.type=4 \n\t\tAND user_auth_perms.user_id=" . $_SESSION['sess_user_id'] . "))\n\t\t{$sql_where}\n\t\tORDER BY {$sort} " . $_REQUEST['sort_direction'] . $limit;
$result = db_fetch_assoc($sql);
$data_templates = db_fetch_assoc("SELECT DISTINCT data_template.id, data_template.name\n\t\tFROM data_template\n\t\tINNER JOIN thold_data ON (thold_data.data_template = data_template.id)\n\t\tORDER BY data_template.name");
?>
<script type="text/javascript">
<!--
function applyTHoldFilterChange(objForm) {
strURL = '?action=edit&tab=tholds&id=<?php
print get_request_var_request('id');
?>
'
strURL = strURL + '&associated=' + objForm.associated.checked;
strURL = strURL + '&state=' + objForm.state.value;
strURL = strURL + '&rows=' + objForm.rows.value;
strURL = strURL + '&template=' + objForm.template.value;
strURL = strURL + '&filter=' + objForm.filter.value;
document.location = strURL;
}
function clearTHoldFilterChange(objForm) {
strURL = '?action=edit&tab=tholds&id=<?php
print get_request_var_request('id');
?>
&clearf=true'
document.location = strURL;
}
-->
</script>
<?php
html_start_box('<strong>Associated Thresholds</strong> ' . htmlspecialchars($header_label), '100%', $colors['header'], '3', 'center', '');
?>
<tr bgcolor='#<?php
print $colors["panel"];
?>
' class='noprint'>
<td class='noprint'>
<form name="listthold" method="get" action="notify_lists.php">
<table cellpadding='0' cellspacing='0'>
<tr class='noprint'>
<td width='1'>
Template:
</td>
<td width='1'>
<select name='template' onChange='applyTHoldFilterChange(document.listthold)'>
<option value='ALL'>Any</option>
<?php
foreach ($data_templates as $row) {
echo "<option value='" . $row['id'] . "'" . (isset($_REQUEST['template']) && $row['id'] == $_REQUEST['template'] ? ' selected' : '') . '>' . $row['name'] . '</option>';
}
?>
</select>
</td>
//.........这里部分代码省略.........
示例9: is_graph_allowed
function is_graph_allowed($local_graph_id)
{
$current_user = db_fetch_row("select policy_graphs,policy_hosts,policy_graph_templates from user_auth where id=" . $_SESSION["sess_user_id"]);
/* get policy information for the sql where clause */
/* modify for multi user start */
if ($_SESSION["permission"] <= ACCESS_ADMINISTRATOR && strstr($_SERVER["HTTP_REFERER"], $_SERVER["SERVER_NAME"]) && check_graph($local_graph_id)) {
$graphs = TRUE;
} else {
$sql_where = get_graph_permissions_sql($current_user["policy_graphs"], $current_user["policy_hosts"], $current_user["policy_graph_templates"]);
$graphs = db_fetch_assoc("select\r\n\t\tgraph_templates_graph.local_graph_id\r\n\t\tfrom (graph_templates_graph,graph_local)\r\n\t\tleft join host on (host.id=graph_local.host_id)\r\n\t\tleft join graph_templates on (graph_templates.id=graph_local.graph_template_id)\r\n\t\tleft 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"] . "))\r\n\t\twhere graph_templates_graph.local_graph_id=graph_local.id\r\n\t\t" . (empty($sql_where) ? "" : "and {$sql_where}") . "\r\n\t\tand graph_templates_graph.local_graph_id={$local_graph_id}\r\n\t\tgroup by graph_templates_graph.local_graph_id");
}
/* modify for multi user end */
if (sizeof($graphs) > 0) {
return true;
} else {
return false;
}
}
示例10: grow_right_pane_tree
function grow_right_pane_tree($tree_id, $leaf_id, $host_group_data)
{
global $current_user, $config, $graphs_per_page, $graph_timeshifts;
include $config['include_path'] . '/global_arrays.php';
include_once $config['library_path'] . '/data_query.php';
include_once $config['library_path'] . '/tree.php';
include_once $config['library_path'] . '/html_utility.php';
if (empty($tree_id)) {
return;
}
if (empty($leaf_id)) {
$leaf_id = 0;
}
$sql_where = '';
$sql_join = '';
$title = '';
$title_delimeter = '';
$search_key = '';
$leaf = db_fetch_row("SELECT order_key, title, host_id, host_grouping_type\n\t\tFROM graph_tree_items\n\t\tWHERE id={$leaf_id}");
$leaf_type = get_tree_item_type($leaf_id);
/* get the "starting leaf" if the user clicked on a specific branch */
if (!empty($leaf_id)) {
$search_key = substr($leaf['order_key'], 0, tree_tier($leaf['order_key']) * CHARS_PER_TIER);
}
/* graph permissions */
if (read_config_option('auth_method') != 0) {
/* 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']);
$sql_where = empty($sql_where) ? '' : "AND {$sql_where}";
$sql_join = "\n\t\t\tLEFT JOIN host ON (host.id=graph_local.host_id)\n\t\t\tLEFT JOIN graph_templates ON (graph_templates.id=graph_local.graph_template_id)\n\t\t\tLEFT 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'] . '))';
}
/* get information for the headers */
if (!empty($tree_id)) {
$tree_name = db_fetch_cell("SELECT name FROM graph_tree WHERE id={$tree_id}");
}
if (!empty($leaf_id)) {
$leaf_name = $leaf['title'];
}
if (!empty($leaf_id)) {
$host_name = db_fetch_cell("SELECT host.description FROM (graph_tree_items,host) WHERE graph_tree_items.host_id=host.id AND graph_tree_items.id={$leaf_id}");
}
$host_group_data_array = explode(':', $host_group_data);
if ($host_group_data_array[0] == 'graph_template') {
$host_group_data_name = '<strong>Graph Template:</strong> ' . db_fetch_cell('select name from graph_templates where id=' . $host_group_data_array[1]);
$graph_template_id = $host_group_data_array[1];
} elseif ($host_group_data_array[0] == 'data_query') {
$host_group_data_name = '<strong>Graph Template:</strong> ' . (empty($host_group_data_array[1]) ? 'Non Query Based' : db_fetch_cell('select name from snmp_query where id=' . $host_group_data_array[1]));
$data_query_id = $host_group_data_array[1];
} elseif ($host_group_data_array[0] == 'data_query_index') {
$host_group_data_name = '<strong>Graph Template:</strong> ' . (empty($host_group_data_array[1]) ? 'Non Query Based' : db_fetch_cell('select name from snmp_query where id=' . $host_group_data_array[1])) . '-> ' . (empty($host_group_data_array[2]) ? 'Template Based' : get_formatted_data_query_index($leaf['host_id'], $host_group_data_array[1], $host_group_data_array[2]));
$data_query_id = $host_group_data_array[1];
$data_query_index = $host_group_data_array[2];
}
if (!empty($tree_name)) {
$title .= $title_delimeter . '<strong>Tree:</strong>' . htmlspecialchars($tree_name, ENT_QUOTES);
$title_delimeter = '-> ';
}
if (!empty($leaf_name)) {
$title .= $title_delimeter . '<strong>Leaf:</strong>' . htmlspecialchars($leaf_name, ENT_QUOTES);
$title_delimeter = '-> ';
}
if (!empty($host_name)) {
$title .= $title_delimeter . '<strong>Host:</strong>' . htmlspecialchars($host_name, ENT_QUOTES);
$title_delimeter = '-> ';
}
if (!empty($host_group_data_name)) {
$title .= $title_delimeter . " {$host_group_data_name}";
$title_delimeter = '-> ';
}
validate_tree_vars($tree_id, $leaf_id, $host_group_data);
html_start_box('<strong>Graph Filters</strong>' . (strlen(get_request_var_request('filter')) ? " [ Filter '" . htmlspecialchars(get_request_var_request('filter')) . "' Applied ]" : ''), '100%', "", '2', 'center', '');
/* include time span selector */
if (read_graph_config_option('timespan_sel') == 'on') {
?>
<tr class='even noprint'>
<td class='noprint'>
<form style='margin:0px;padding:0px;' name='form_timespan_selector' method='post' action='graph_view.php'>
<table cellpadding='1' cellspacing='0'>
<tr>
<td width='55'>
Presets:
</td>
<td>
<select id='predefined_timespan' name='predefined_timespan' onChange='spanTime()'>
<?php
if (isset($_SESSION['custom'])) {
$graph_timespans[GT_CUSTOM] = 'Custom';
$start_val = 0;
$end_val = sizeof($graph_timespans);
} else {
if (isset($graph_timespans[GT_CUSTOM])) {
asort($graph_timespans);
array_shift($graph_timespans);
}
$start_val = 1;
$end_val = sizeof($graph_timespans) + 1;
}
if (sizeof($graph_timespans) > 0) {
for ($value = $start_val; $value < $end_val; $value++) {
print "<option value='{$value}'";
//.........这里部分代码省略.........
示例11: reports_expand_tree
/**
* expand a tree for including into report
* @param array $report - parameters for this report mail report
* @param int $item - current graph item
* @param int $output - type of output
* @param bool $format_ok - use css styling
* @param bool $nested - nested tree?
* @return string - html
*/
function reports_expand_tree($report, $item, $output, $format_ok, $nested = false)
{
global $colors, $config, $alignment;
include $config["include_path"] . "/global_arrays.php";
include_once $config["library_path"] . "/data_query.php";
include_once $config["library_path"] . "/tree.php";
include_once $config["library_path"] . "/html_tree.php";
include_once $config["library_path"] . "/html_utility.php";
$tree_id = $item["tree_id"];
$leaf_id = $item["branch_id"];
$time = time();
# get config option for first-day-of-the-week
$first_weekdayid = read_graph_config_option("first_weekdayid");
/* check if we have enough data */
if (isset($_SESSION["sess_current_user"])) {
$current_user = db_fetch_row("SELECT * FROM user_auth WHERE id=" . $_SESSION["sess_user_id"]);
} else {
$current_user = db_fetch_row("SELECT * FROM user_auth WHERE id=" . $report["user_id"]);
}
/*todo*/
$host_group_data = "";
$timespan = array();
# get start/end time-since-epoch for actual time (now()) and given current-session-timespan
get_timespan($timespan, $time, $item["timespan"], $first_weekdayid);
if (empty($tree_id)) {
return;
}
$sql_where = "";
$sql_join = "";
$title = "";
$title_delimeter = "";
$search_key = "";
$outstr = "";
$leaf = db_fetch_row("SELECT order_key, title, host_id, host_grouping_type FROM graph_tree_items WHERE id={$leaf_id}");
$leaf_type = get_tree_item_type($leaf_id);
/* get the "starting leaf" if the user clicked on a specific branch */
if (!empty($leaf_id)) {
$search_key = substr($leaf["order_key"], 0, tree_tier($leaf["order_key"]) * CHARS_PER_TIER);
}
/* graph permissions */
if (read_config_option("auth_method") != 0) {
/* 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"]);
$sql_where = empty($sql_where) ? "" : "AND {$sql_where}";
$sql_join = "\n\t\t\tLEFT JOIN host ON (host.id=graph_local.host_id)\n\t\t\tLEFT JOIN graph_templates ON (graph_templates.id=graph_local.graph_template_id)\n\t\t\tLEFT 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=" . $current_user["id"] . ") OR (host.id=user_auth_perms.item_id AND user_auth_perms.type=3 and user_auth_perms.user_id=" . $current_user["id"] . ") OR (graph_templates.id=user_auth_perms.item_id AND user_auth_perms.type=4 AND user_auth_perms.user_id=" . $current_user["id"] . "))";
}
/* get information for the headers */
if (!empty($tree_id)) {
$tree_name = db_fetch_cell("SELECT name FROM graph_tree WHERE id={$tree_id}");
}
if (!empty($leaf_id)) {
$leaf_name = $leaf["title"];
}
if (!empty($leaf_id)) {
$host_name = db_fetch_cell("SELECT host.description FROM (graph_tree_items,host) WHERE graph_tree_items.host_id=host.id AND graph_tree_items.id={$leaf_id}");
}
$host_group_data_array = explode(":", $host_group_data);
if ($host_group_data_array[0] == "graph_template") {
$host_group_data_name = "<strong>Graph Template:</strong> " . db_fetch_cell("SELECT name FROM graph_templates WHERE id=" . $host_group_data_array[1]) . "</td></tr>";
$graph_template_id = $host_group_data_array[1];
} elseif ($host_group_data_array[0] == "data_query") {
$host_group_data_name = "<strong>Graph Template:</strong> " . (empty($host_group_data_array[1]) ? "Non Query Based" : db_fetch_cell("SELECT name FROM snmp_query WHERE id=" . $host_group_data_array[1])) . "</td></tr>";
$data_query_id = $host_group_data_array[1];
} elseif ($host_group_data_array[0] == "data_query_index") {
$host_group_data_name = "<strong>Graph Template:</strong> " . (empty($host_group_data_array[1]) ? "Non Query Based" : db_fetch_cell("SELECT name FROM snmp_query WHERE id=" . $host_group_data_array[1])) . "-> " . (empty($host_group_data_array[2]) ? "Template Based" : get_formatted_data_query_index($leaf["host_id"], $host_group_data_array[1], $host_group_data_array[2])) . "</td></tr>";
$data_query_id = $host_group_data_array[1];
$data_query_index = $host_group_data_array[2];
}
if (!empty($tree_name) && empty($leaf_name) && empty($host_name) && !$nested) {
$title .= $title_delimeter . "<strong>Tree:</strong> {$tree_name}";
$title_delimeter = "-> ";
} elseif (!empty($leaf_name)) {
$title .= $title_delimeter . "<strong>Leaf:</strong> {$leaf_name}";
$title_delimeter = "-> ";
} elseif (!empty($host_name)) {
$title .= $title_delimeter . "<strong>Host:</strong> {$host_name}";
$title_delimeter = "-> ";
} elseif (!empty($host_group_data_name)) {
$title .= $title_delimeter . " {$host_group_data_name}";
$title_delimeter = "-> ";
}
if (isset($_REQUEST["tree_id"])) {
$nodeid = "tree_" . $_REQUEST["tree_id"];
}
if (isset($_REQUEST["leaf_id"])) {
$nodeid .= "_leaf" . $_REQUEST["leaf_id"];
}
/* start graph display */
if (strlen($title)) {
$outstr .= "\t\t<tr class='text_row'>\n";
if ($format_ok) {
//.........这里部分代码省略.........
示例12: create_dhtml_tree_export
function create_dhtml_tree_export($tree_id) {
/* record start time */
list($micro,$seconds) = split(" ", microtime());
$start = $seconds + $micro;
$search_key = "";
$dhtml_tree = array();
$dhtml_tree[0] = $start;
$dhtml_tree[1] = read_graph_config_option("expand_hosts");
$dhtml_tree[2] = "foldersTree = gFld(\"\", \"\")\n";
$i = 2;
$tree_list = get_graph_tree_array_export();
/* auth check for hosts on the trees */
$current_user = db_fetch_row("SELECT * FROM user_auth WHERE id=" . read_config_option("export_user_id"));
$sql_join = "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=" . $current_user["id"] . ") OR (host.id=user_auth_perms.item_id AND user_auth_perms.type=3 AND user_auth_perms.user_id=" . $current_user["id"] . ") OR (graph_templates.id=user_auth_perms.item_id AND user_auth_perms.type=4 AND user_auth_perms.user_id=" . $current_user["id"] . "))";
// $sql_join = "LEFT JOIN user_auth_perms ON (host.id=user_auth_perms.item_id AND user_auth_perms.type=3 AND user_auth_perms.user_id=" . $current_user["id"] . ")";
$sql_where = get_graph_permissions_sql($current_user["policy_graphs"], $current_user["policy_hosts"], $current_user["policy_graph_templates"]);
$sql_where = (empty($sql_where) ? "" : "AND $sql_where");
if (sizeof($tree_list) > 0) {
foreach ($tree_list as $tree) {
$i++;
$heir_sql = "SELECT
graph_tree_items.id,
graph_tree_items.title,
graph_tree_items.order_key,
graph_tree_items.host_id,
graph_tree_items.host_grouping_type,
host.description as hostname
FROM graph_tree_items
LEFT JOIN host ON (host.id=graph_tree_items.host_id)
LEFT JOIN graph_templates ON (graph_templates_graph.graph_template_id=graph_templates.id)
$sql_join
WHERE graph_tree_items.graph_tree_id=" . $tree["id"] . "
$sql_where
AND graph_tree_items.local_graph_id = 0
ORDER BY graph_tree_items.order_key";
$heirarchy = db_fetch_assoc($heir_sql);
$dhtml_tree_id = 0;
if (sizeof($heirarchy) > 0) {
foreach ($heirarchy as $leaf) {
if ($dhtml_tree_id <> $tree["id"]) {
$dhtml_tree[$i] = "ou0 = insFld(foldersTree, gFld(\"" . get_tree_name($tree["id"]) . "\", \"" . clean_up_export_name(get_tree_name($tree["id"])) . "_leaf.html\"))\n";
}
$dhtml_tree_id = $tree["id"];
$i++;
$tier = tree_tier($leaf["order_key"]);
if ($leaf["host_id"] > 0) { //It's a host
$dhtml_tree[$i] = "ou" . ($tier) . " = insFld(ou" . ($tier-1) . ", gFld(\"<strong>Host:</strong> " . htmlentities($leaf["hostname"], ENT_QUOTES) . "\", \"" . clean_up_export_name($leaf["hostname"] . "_" . $leaf["id"]) . ".html\"))\n";
if (read_config_option("export_tree_expand_hosts") == "on") {
if ($leaf["host_grouping_type"] == HOST_GROUPING_GRAPH_TEMPLATE) {
$graph_templates = db_fetch_assoc("SELECT
graph_templates.id,
graph_templates.name,
graph_templates_graph.local_graph_id,
graph_templates_graph.title_cache
FROM (graph_local,graph_templates,graph_templates_graph)
WHERE graph_local.id=graph_templates_graph.local_graph_id
AND graph_templates_graph.graph_template_id=graph_templates.id
AND graph_local.host_id=" . $leaf["host_id"] . "
GROUP BY graph_templates.id
ORDER BY graph_templates.name");
if (sizeof($graph_templates) > 0) {
foreach ($graph_templates as $graph_template) {
$i++;
$dhtml_tree[$i] = "ou" . ($tier+1) . " = insFld(ou" . ($tier) . ", gFld(\" " . $graph_template["name"] . "\", \"" . clean_up_export_name($leaf["hostname"] . "_gt_" . $leaf["id"]) . "_" . $graph_template["id"] . ".html\"))\n";
}
}
}else if ($leaf["host_grouping_type"] == HOST_GROUPING_DATA_QUERY_INDEX) {
$data_queries = db_fetch_assoc("SELECT
snmp_query.id,
snmp_query.name
FROM (graph_local,snmp_query)
WHERE graph_local.snmp_query_id=snmp_query.id
AND graph_local.host_id=" . $leaf["host_id"] . "
GROUP BY snmp_query.id
ORDER BY snmp_query.name");
array_push($data_queries, array(
"id" => "0",
"name" => "Graph Template Based"
));
if (sizeof($data_queries) > 0) {
foreach ($data_queries as $data_query) {
$i++;
$dhtml_tree[$i] = "ou" . ($tier+1) . " = insFld(ou" . ($tier) . ", gFld(\" " . $data_query["name"] . "\", \"" . clean_up_export_name($leaf["hostname"] . "_dq_" . $leaf["title"] . "_" . $leaf["id"]) . "_" . $data_query["id"] . ".html\"))\n";
//.........这里部分代码省略.........
示例13: list_tholds
function list_tholds()
{
global $colors, $thold_bgcolors, $config, $hostid;
$thold_actions = array(1 => 'Delete', 2 => 'Disable', 3 => 'Enable', 4 => 'Reapply Suggested Names');
thold_request_validation();
$statefilter = '';
if (isset($_REQUEST['state'])) {
if ($_REQUEST['state'] == '-1') {
$statefilter = '';
} else {
if ($_REQUEST['state'] == '0') {
$statefilter = "thold_data.thold_enabled='off'";
}
if ($_REQUEST['state'] == '2') {
$statefilter = "thold_data.thold_enabled='on'";
}
if ($_REQUEST['state'] == '1') {
$statefilter = '(thold_data.thold_alert!=0 OR thold_data.bl_alert>0)';
}
if ($_REQUEST['state'] == '3') {
$statefilter = '((thold_data.thold_alert!=0 AND thold_data.thold_fail_count >= thold_data.thold_fail_trigger) OR (thold_data.bl_alert>0 AND thold_data.bl_fail_count >= thold_data.bl_fail_trigger))';
}
}
}
$alert_num_rows = read_config_option('alert_num_rows');
if ($alert_num_rows < 1 || $alert_num_rows > 999) {
db_execute("REPLACE INTO settings VALUES ('alert_num_rows', 30)");
/* pull it again so it updates the cache */
$alert_num_rows = read_config_option('alert_num_rows', true);
}
include $config['include_path'] . '/top_header.php';
$sql_where = '';
$sort = $_REQUEST['sort_column'];
$limit = ' LIMIT ' . $alert_num_rows * ($_REQUEST['page'] - 1) . ",{$alert_num_rows}";
if (!empty($_REQUEST['hostid']) && $_REQUEST['hostid'] != 'ALL') {
$sql_where .= (!strlen($sql_where) ? 'WHERE ' : ' AND ') . "thold_data.host_id = " . $_REQUEST['hostid'];
}
if (!empty($_REQUEST['template']) && $_REQUEST['template'] != 'ALL') {
$sql_where .= (!strlen($sql_where) ? 'WHERE ' : ' AND ') . "thold_data.data_template = " . $_REQUEST['template'];
}
if ($statefilter != '') {
$sql_where .= (!strlen($sql_where) ? 'WHERE ' : ' AND ') . "{$statefilter}";
}
/* modify for multi user start */
if ($_SESSION["permission"] < ACCESS_ADMINISTRATOR) {
$sql = "\r\n SELECT thold_data.* FROM thold_data\r\n INNER JOIN user_auth_perms ON thold_data.host_id = user_auth_perms.item_id AND user_auth_perms.user_id = '" . $_SESSION["sess_user_id"] . "' AND user_auth_perms.type = '3'\r\n {$sql_where}\r\n ORDER BY {$sort} " . $_REQUEST['sort_direction'] . $limit;
} else {
$current_user = db_fetch_row('SELECT * FROM user_auth WHERE id=' . $_SESSION['sess_user_id']);
$sql_where .= (!strlen($sql_where) ? 'WHERE ' : ' AND ') . get_graph_permissions_sql($current_user['policy_graphs'], $current_user['policy_hosts'], $current_user['policy_graph_templates']);
$sql = "SELECT * FROM thold_data\r\n\t\tLEFT JOIN user_auth_perms on ((thold_data.graph_id=user_auth_perms.item_id and user_auth_perms.type=1 and user_auth_perms.user_id=" . $_SESSION['sess_user_id'] . ") OR (thold_data.host_id=user_auth_perms.item_id and user_auth_perms.type=3 and user_auth_perms.user_id=" . $_SESSION['sess_user_id'] . ") OR (thold_data.graph_template=user_auth_perms.item_id and user_auth_perms.type=4 and user_auth_perms.user_id=" . $_SESSION['sess_user_id'] . "))\r\n\t\t{$sql_where}\r\n\t\tORDER BY {$sort} " . $_REQUEST['sort_direction'] . $limit;
}
/* modify for multi user end */
$result = db_fetch_assoc($sql);
/* modify for multi user start */
if ($_SESSION["permission"] < ACCESS_ADMINISTRATOR) {
$hostresult = db_fetch_assoc("\r\n SELECT host.id, host.description, host.hostname FROM host \r\n INNER JOIN thold_data ON host.id = thold_data.host_id \r\n INNER JOIN user_auth_perms ON host.id = user_auth_perms.item_id AND user_auth_perms.user_id = '" . $_SESSION["sess_user_id"] . "' AND user_auth_perms.type = '3'");
$data_templates = db_fetch_assoc("\r\n SELECT DISTINCT data_template.id, data_template.name FROM data_template\r\n INNER JOIN thold_data ON thold_data.data_template = data_template.id\r\n INNER JOIN host ON thold_data.host_id = host.id\r\n INNER JOIN user_auth_perms ON host.id = user_auth_perms.item_id AND user_auth_perms.user_id = '" . $_SESSION["sess_user_id"] . "' AND user_auth_perms.type = '3'\r\n ORDER BY data_template.name");
} else {
$sql_where_hid = 'WHERE ' . get_graph_permissions_sql($current_user['policy_graphs'], $current_user['policy_hosts'], $current_user['policy_graph_templates']);
$hostresult = db_fetch_assoc("SELECT DISTINCT host.id, host.description, host.hostname\r\n\t\tFROM host\r\n\t\tINNER JOIN thold_data ON (host.id = thold_data.host_id)\r\n\t\tLEFT JOIN user_auth_perms on (thold_data.host_id=user_auth_perms.item_id and user_auth_perms.type=3 and user_auth_perms.user_id=" . $_SESSION['sess_user_id'] . ")\r\n\t\t{$sql_where_hid}\r\n\t\tORDER BY description");
$data_templates = db_fetch_assoc("SELECT DISTINCT data_template.id, data_template.name\r\n\t\tFROM data_template\r\n\t\tINNER JOIN thold_data ON (thold_data.data_template = data_template.id)\r\n\t\tORDER BY data_template.name");
}
/* modify for multi user end */
?>
<script type="text/javascript">
<!--
function applyTHoldFilterChange(objForm) {
strURL = '?hostid=' + objForm.hostid.value;
strURL = strURL + '&state=' + objForm.state.value;
strURL = strURL + '&template=' + objForm.template.value;
document.location = strURL;
}
-->
</script>
<?php
/* modify for multi user start */
if (check_resource_count(RESOURCE_THOLD) == TRUE) {
html_start_box('<strong>Threshold Management</strong>', '100%', $colors['header'], '3', 'center', 'thold_add.php');
} else {
html_start_box('<strong>Threshold Management</strong>', '100%', $colors['header'], '3', 'center', '');
}
/* modify for multi user end */
?>
<tr bgcolor='#<?php
print $colors["panel"];
?>
' class='noprint'>
<td class='noprint'>
<form name='listthold' action='listthold.php' method='post'>
<table cellpadding='0' cellspacing='0'>
<tr class='noprint'>
<td width='1'>
Host:
</td>
<td width='1'>
<select name='hostid' onChange='applyTHoldFilterChange(document.listthold)'>
<option value='ALL'>Any</option>
<?php
foreach ($hostresult as $row) {
echo "<option value='" . $row['id'] . "'" . (isset($_REQUEST['hostid']) && $row['id'] == $_REQUEST['hostid'] ? ' selected' : '') . '>' . $row['description'] . ' - (' . $row['hostname'] . ')' . '</option>';
//.........这里部分代码省略.........
示例14: grow_right_pane_tree
function grow_right_pane_tree($tree_id, $leaf_id, $host_group_data)
{
global $current_user, $colors, $config, $graphs_per_page, $graph_timeshifts;
include $config["include_path"] . "/global_arrays.php";
include_once $config["library_path"] . "/data_query.php";
include_once $config["library_path"] . "/tree.php";
include_once $config["library_path"] . "/html_utility.php";
define("MAX_DISPLAY_PAGES", 21);
if (empty($tree_id)) {
return;
}
$sql_where = "";
$sql_join = "";
$title = "";
$title_delimeter = "";
$search_key = "";
$leaf = db_fetch_row("SELECT order_key, title, host_id, host_grouping_type\r\n\t\t\t\t\tFROM graph_tree_items\r\n\t\t\t\t\tWHERE id={$leaf_id}");
$leaf_type = get_tree_item_type($leaf_id);
/* get the "starting leaf" if the user clicked on a specific branch */
if (!empty($leaf_id)) {
$search_key = substr($leaf["order_key"], 0, tree_tier($leaf["order_key"]) * CHARS_PER_TIER);
}
/* graph permissions */
if (read_config_option("auth_method") != 0) {
/* 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"]);
$sql_where = empty($sql_where) ? "" : "AND {$sql_where}";
/* modify for multi user start */
if ($_SESSION["permission"] <= ACCESS_ADMINISTRATOR && $tree_id == $_SESSION["public_tree_id"]) {
$sql_join = "\r\n LEFT JOIN (SELECT local_graph_id ,COUNT(local_graph_id) AS count FROM graph_tree_items WHERE local_graph_id != '0' GROUP BY local_graph_id) AS gti ON graph_tree_items.local_graph_id = gti.local_graph_id \r\n LEFT JOIN host ON (host.id=graph_local.host_id)\r\n LEFT JOIN graph_templates ON (graph_templates.id=graph_local.graph_template_id)\r\n LEFT JOIN user_auth_perms ON (graph_templates_graph.local_graph_id=user_auth_perms.item_id AND user_auth_perms.type=1)";
$sql_order = "gti.count DESC";
} else {
$sql_join = "\r\n\t\t\tLEFT JOIN host ON (host.id=graph_local.host_id)\r\n\t\t\tLEFT JOIN graph_templates ON (graph_templates.id=graph_local.graph_template_id)\r\n\t\t\tLEFT 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"] . "))";
$sql_order = "graph_tree_items.order_key";
}
/* modify for multi user end */
}
/* get information for the headers */
if (!empty($tree_id)) {
$tree_name = db_fetch_cell("SELECT name FROM graph_tree WHERE id={$tree_id}");
}
if (!empty($leaf_id)) {
$leaf_name = $leaf["title"];
}
if (!empty($leaf_id)) {
$host_name = db_fetch_cell("SELECT host.description FROM (graph_tree_items,host) WHERE graph_tree_items.host_id=host.id AND graph_tree_items.id={$leaf_id}");
}
$host_group_data_array = explode(":", $host_group_data);
if ($host_group_data_array[0] == "graph_template") {
$host_group_data_name = "<strong>Graph Template:</strong> " . db_fetch_cell("select name from graph_templates where id=" . $host_group_data_array[1]);
$graph_template_id = $host_group_data_array[1];
} elseif ($host_group_data_array[0] == "data_query") {
$host_group_data_name = "<strong>Graph Template:</strong> " . (empty($host_group_data_array[1]) ? "Non Query Based" : db_fetch_cell("select name from snmp_query where id=" . $host_group_data_array[1]));
$data_query_id = $host_group_data_array[1];
} elseif ($host_group_data_array[0] == "data_query_index") {
$host_group_data_name = "<strong>Graph Template:</strong> " . (empty($host_group_data_array[1]) ? "Non Query Based" : db_fetch_cell("select name from snmp_query where id=" . $host_group_data_array[1])) . "-> " . (empty($host_group_data_array[2]) ? "Template Based" : get_formatted_data_query_index($leaf["host_id"], $host_group_data_array[1], $host_group_data_array[2]));
$data_query_id = $host_group_data_array[1];
$data_query_index = $host_group_data_array[2];
}
if (!empty($tree_name)) {
$title .= $title_delimeter . "<strong>Tree:</strong>" . htmlspecialchars($tree_name);
$title_delimeter = "-> ";
}
if (!empty($leaf_name)) {
$title .= $title_delimeter . "<strong>Leaf:</strong>" . htmlspecialchars($leaf_name);
$title_delimeter = "-> ";
}
if (!empty($host_name)) {
$title .= $title_delimeter . "<strong>Host:</strong>" . htmlspecialchars($host_name);
$title_delimeter = "-> ";
}
if (!empty($host_group_data_name)) {
$title .= $title_delimeter . " {$host_group_data_name}";
$title_delimeter = "-> ";
}
if (isset($_REQUEST["tree_id"])) {
$nodeid = "tree_" . get_request_var_request("tree_id");
}
if (isset($_REQUEST["leaf_id"])) {
$nodeid .= "_leaf_" . get_request_var_request("leaf_id");
}
if (isset($_REQUEST["host_group_data"])) {
$type_id = explode(":", get_request_var_request("host_group_data"));
if ($type_id[0] == "graph_template") {
$nodeid .= "_hgd_gt_" . $type_id[1];
} elseif ($type_id[0] == "data_query") {
$nodeid .= "_hgd_dq_" . $type_id[1];
} else {
$nodeid .= "_hgd_dqi" . $type_id[1] . "_" . $type_id[2];
}
}
print "<script type=\"text/javascript\">\n";
print "<!--\n";
print "myNode = findObj(\"{$nodeid}\")\n";
print "myNode.forceOpeningOfAncestorFolders();\n";
print "highlightObjLink(myNode)\n";
print "//-->\n";
print "</script>";
/* ================= input validation ================= */
input_validate_input_number(get_request_var_post("graphs"));
//.........这里部分代码省略.........
示例15: get_graph_preview_content
function get_graph_preview_content () {
global $colors;
require_once(CACTI_BASE_PATH . "/include/auth/auth_constants.php");
/* Make sure nothing is cached */
header("Cache-Control: must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Expires: ". gmdate("D, d M Y H:i:s", mktime(date("H"), date("i"), date("s"), date("m")-1, date("d"), date("Y")))." GMT");
header("Last-Modified: ". gmdate("D, d M Y H:i:s")." GMT");
$current_user = db_fetch_row("SELECT * FROM user_auth WHERE id=" . $_SESSION["sess_user_id"]);
define("MAX_DISPLAY_PAGES", 21);
/* ================= input validation ================= */
input_validate_input_number(get_request_var("graphs"));
input_validate_input_number(get_request_var_request("device_id"));
input_validate_input_number(get_request_var_request("graph_template_id"));
input_validate_input_number(get_request_var_request("page"));
/* ==================================================== */
/* clean up search string */
if (isset($_REQUEST["filter"])) {
$_REQUEST["filter"] = sanitize_search_string(get_request_var_request("filter"));
}
/* clean up search string */
if (isset($_REQUEST["thumbnails"])) {
$_REQUEST["thumbnails"] = sanitize_search_string(get_request_var_request("thumbnails"));
}
$sql_or = ""; $sql_where = ""; $sql_join = "";
if ((read_config_option("auth_method") != 0) && (empty($current_user["show_preview"]))) {
print "<strong><font size='+1' color='FF0000'>" . __("YOU DO NOT HAVE RIGHTS FOR PREVIEW VIEW") . "</font></strong>"; exit;
}
/* if the user pushed the 'clear' button */
if (isset($_REQUEST["clear_filter"])) {
kill_session_var("sess_graph_view_current_page");
kill_session_var("sess_graph_view_filter");
kill_session_var("sess_graph_view_graph_template");
kill_session_var("sess_graph_view_device");
kill_session_var("sess_graph_view_graphs");
kill_session_var("sess_graph_view_thumbnails");
kill_session_var("sess_graph_view_list_graph_list");
kill_session_var("sess_graph_view_list_graph_add");
kill_session_var("sess_graph_view_list_graph_remove");
unset($_REQUEST["page"]);
unset($_REQUEST["filter"]);
unset($_REQUEST["device_id"]);
unset($_REQUEST["graphs"]);
unset($_REQUEST["thumbnails"]);
unset($_REQUEST["graph_template_id"]);
unset($_REQUEST["graph_list"]);
unset($_REQUEST["graph_add"]);
unset($_REQUEST["graph_remove"]);
}
/* save selected graphs into url, for backward compatibility */
if (!empty($_REQUEST["graph_list"])) {
foreach (explode(",",get_request_var_request("graph_list")) as $item) {
$graph_list[$item] = 1;
}
}else{
$graph_list = array();
}
load_current_session_value("device_id", "sess_graph_view_device", "0");
load_current_session_value("graph_template_id", "sess_graph_view_graph_template", "0");
load_current_session_value("filter", "sess_graph_view_filter", "");
load_current_session_value("page", "sess_graph_view_current_page", "1");
load_current_session_value("thumbnails", "sess_graph_view_thumbnails", CHECKED);
load_current_session_value("graphs", "sess_graph_view_graphs", read_graph_config_option("preview_graphs_per_page"));
load_current_session_value("graph_list", "sess_graph_view_list_graph_list", "");
load_current_session_value("graph_add", "sess_graph_view_list_graph_add", "");
load_current_session_value("graph_remove", "sess_graph_view_list_graph_remove", "");
/* graph permissions */
if (read_config_option("auth_method") != 0) {
$sql_where = "where " . get_graph_permissions_sql($current_user["policy_graphs"], $current_user["policy_devices"], $current_user["policy_graph_templates"]);
$sql_join = "left join device on (device.id=graph_local.device_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=" . PERM_GRAPHS . " and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (device.id=user_auth_perms.item_id and user_auth_perms.type=" . PERM_DEVICES . " and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (graph_templates.id=user_auth_perms.item_id and user_auth_perms.type=" . PERM_GRAPH_TEMPLATES . " and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . "))";
}else{
$sql_where = "";
$sql_join = "";
}
/* the user select a bunch of graphs of the 'list' view and wants them dsplayed here */
if (isset($_REQUEST["list"])) {
if (is_array(get_request_var_request("graph_list"))) {
$graph_list = $_REQUEST["graph_list"];
}
if (!empty($_REQUEST["graph_add"])) {
foreach (explode(",",get_request_var_request("graph_add")) as $item) {
$graph_list[$item] = 1;
//.........这里部分代码省略.........