本文整理汇总了PHP中get_graph_permissions_sql函数的典型用法代码示例。如果您正苦于以下问题:PHP get_graph_permissions_sql函数的具体用法?PHP get_graph_permissions_sql怎么用?PHP get_graph_permissions_sql使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_graph_permissions_sql函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:caiorasec,项目名称:thold,代码行数:17,代码来源:thold_functions.php
示例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"])) {
//.........这里部分代码省略.........
开发者ID:TFyre,项目名称:cacti_plugin_mikrotik,代码行数:101,代码来源:mikrotik.php
示例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;
}
}
开发者ID:songchin,项目名称:Cacti,代码行数:12,代码来源:auth.php
示例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;
}
//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:html_tree.php
示例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) {
//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:html_tree.php
示例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") {
//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:graph_export.php
示例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"])) {
//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:html_tree.php
示例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>
//.........这里部分代码省略.........
开发者ID:caiorasec,项目名称:thold,代码行数:101,代码来源:notify_lists.php
示例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;
}
}
开发者ID:resmon,项目名称:resmon-cacti,代码行数:18,代码来源:auth.php
示例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
|
请发表评论