本文整理汇总了PHP中tree_tier函数的典型用法代码示例。如果您正苦于以下问题:PHP tree_tier函数的具体用法?PHP tree_tier怎么用?PHP tree_tier使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tree_tier函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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"] . "))";
if ($current_user["policy_hosts"] == "1") {
$sql_where = "AND !(user_auth_perms.user_id IS NOT NULL AND graph_tree_items.host_id>0)";
} elseif ($current_user["policy_hosts"] == "2") {
$sql_where = "AND !(user_auth_perms.user_id IS NULL AND graph_tree_items.host_id>0)";
}
if (sizeof($tree_list) > 0) {
foreach ($tree_list as $tree) {
if (read_config_option("export_tree_isolation") == "on" && $tree_id == $tree["id"] || read_config_option("export_tree_isolation") == "off") {
$i++;
$hier_sql = "SELECT DISTINCT\n\t\t\t\t\tgraph_tree_items.id,\n\t\t\t\t\tgraph_tree_items.title,\n\t\t\t\t\tgraph_tree_items.order_key,\n\t\t\t\t\tgraph_tree_items.host_id,\n\t\t\t\t\tgraph_tree_items.host_grouping_type,\n\t\t\t\t\thost.description as hostname\n\t\t\t\t\tFROM (graph_tree_items, graph_templates_graph)\n\t\t\t\t\tLEFT JOIN host ON (host.id=graph_tree_items.host_id)\n\t\t\t\t\tLEFT JOIN graph_templates ON (graph_templates_graph.graph_template_id=graph_templates.id)\n\t\t\t\t\t{$sql_join}\n\t\t\t\t\tWHERE graph_tree_items.graph_tree_id=" . $tree["id"] . "\n\t\t\t\t\t{$sql_where}\n\t\t\t\t\tAND graph_tree_items.local_graph_id = 0\n\t\t\t\t\tORDER BY graph_tree_items.order_key";
$hierarchy = db_fetch_assoc($hier_sql);
$dhtml_tree_id = 0;
if (sizeof($hierarchy) > 0) {
foreach ($hierarchy 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> " . $leaf["hostname"] . "\", \"" . 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\n\t\t\t\t\t\t\t\t\tgraph_templates.id,\n\t\t\t\t\t\t\t\t\tgraph_templates.name,\n\t\t\t\t\t\t\t\t\tgraph_templates_graph.local_graph_id,\n\t\t\t\t\t\t\t\t\tgraph_templates_graph.title_cache\n\t\t\t\t\t\t\t\t\tFROM (graph_local,graph_templates,graph_templates_graph)\n\t\t\t\t\t\t\t\t\tWHERE graph_local.id=graph_templates_graph.local_graph_id\n\t\t\t\t\t\t\t\t\tAND graph_templates_graph.graph_template_id=graph_templates.id\n\t\t\t\t\t\t\t\t\tAND graph_local.host_id=" . $leaf["host_id"] . "\n\t\t\t\t\t\t\t\t\tAND graph_templates_graph.export='on'\n\t\t\t\t\t\t\t\t\tGROUP BY graph_templates.id\n\t\t\t\t\t\t\t\t\tORDER 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\n\t\t\t\t\t\t\t\t\tsnmp_query.id,\n\t\t\t\t\t\t\t\t\tsnmp_query.name\n\t\t\t\t\t\t\t\t\tFROM (graph_local,snmp_query)\n\t\t\t\t\t\t\t\t\tWHERE graph_local.snmp_query_id=snmp_query.id\n\t\t\t\t\t\t\t\t\tAND graph_local.host_id=" . $leaf["host_id"] . "\n\t\t\t\t\t\t\t\t\tGROUP BY snmp_query.id\n\t\t\t\t\t\t\t\t\tORDER 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";
/* fetch a list of field names that are sorted by the preferred sort field */
$sort_field_data = get_formatted_data_query_indexes($leaf["host_id"], $data_query["id"]);
if ($data_query["id"] > 0) {
while (list($snmp_index, $sort_field_value) = each($sort_field_data)) {
$i++;
$dhtml_tree[$i] = "ou" . ($tier + 2) . " = insFld(ou" . ($tier + 1) . ", gFld(\" " . $sort_field_value . "\", \"" . clean_up_export_name($leaf["hostname"] . "_dqi_" . $leaf["title"] . "_" . $leaf["id"]) . "_" . $data_query["id"] . "_" . $snmp_index . ".html\"))\n";
}
}
}
}
}
}
}
} else {
$dhtml_tree[$i] = "ou" . $tier . " = insFld(ou" . ($tier - 1) . ", gFld(\"" . $leaf["title"] . "\", \"" . clean_up_export_name(get_tree_name($tree["id"]) . "_" . $leaf["title"] . "_" . $leaf["id"]) . "_leaf.html\"))\n";
}
}
} else {
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";
$i++;
}
}
}
}
}
return $dhtml_tree;
}
开发者ID:songchin,项目名称:Cacti,代码行数:83,代码来源:graph_export.php
示例2: db_fetch_assoc
<?php
$no_http_headers = true;
include "../include/global.php";
include "../lib/tree.php";
$trees = db_fetch_assoc("select id from graph_tree");
if (sizeof($trees) > 0) {
foreach ($trees as $tree) {
$tree_items = db_fetch_assoc("select \n\t\t\tgraph_tree_items.id,\n\t\t\tgraph_tree_items.order_key\n\t\t\tfrom graph_tree_items\n\t\t\twhere graph_tree_items.graph_tree_id='" . $tree["id"] . "'\n\t\t\torder by graph_tree_items.order_key");
if (sizeof($tree_items) > 0) {
$_tier = 0;
foreach ($tree_items as $tree_item) {
$tier = tree_tier($tree_item["order_key"], 2);
/* back off */
if ($tier < $_tier) {
for ($i = $_tier; $i > $tier; $i--) {
print "reset ctr = {$i}\n";
$tier_counter[$i] = 0;
}
}
/* we key tier==0 off of '1' and tier>0 off of '0' */
if (!isset($tier_counter[$tier])) {
$tier_counter[$tier] = 1;
} else {
$tier_counter[$tier]++;
}
$search_key = preg_replace("/0+\$/", "", $tree_item["order_key"]);
if (strlen($search_key) % 2 != 0) {
$search_key .= "0";
}
$new_search_key = "";
开发者ID:songchin,项目名称:Cacti,代码行数:31,代码来源:update_to_3_keys.php
示例3: 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
示例4: create_dhtml_tree_export
function create_dhtml_tree_export($tree_id)
{
/* record start time */
list($micro, $seconds) = explode(" ", microtime());
$start = $seconds + $micro;
$search_key = "";
$dhtml_tree = array();
$dhtml_tree[0] = $start;
$dhtml_tree[1] = read_graph_config_option("expand_hosts");
$i = 1;
$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"] . "))";
if ($current_user["policy_hosts"] == "1") {
$sql_where = "AND !(user_auth_perms.user_id IS NOT NULL AND graph_tree_items.host_id>0)";
} elseif ($current_user["policy_hosts"] == "2") {
$sql_where = "AND !(user_auth_perms.user_id IS NULL AND graph_tree_items.host_id>0)";
}
if (sizeof($tree_list) > 0) {
foreach ($tree_list as $tree) {
if (read_config_option("export_tree_isolation") == "on" && $tree_id == $tree["id"] || read_config_option("export_tree_isolation") == "off") {
$hier_sql = "SELECT DISTINCT\n\t\t\t\t\tgraph_tree_items.id,\n\t\t\t\t\tgraph_tree_items.title,\n\t\t\t\t\tgraph_tree_items.order_key,\n\t\t\t\t\tgraph_tree_items.host_id,\n\t\t\t\t\tgraph_tree_items.host_grouping_type,\n\t\t\t\t\thost.description as hostname\n\t\t\t\t\tFROM (graph_tree_items, graph_templates_graph)\n\t\t\t\t\tLEFT JOIN host ON (host.id=graph_tree_items.host_id)\n\t\t\t\t\tLEFT JOIN graph_templates ON (graph_templates_graph.graph_template_id=graph_templates.id)\n\t\t\t\t\t{$sql_join}\n\t\t\t\t\tWHERE graph_tree_items.graph_tree_id=" . $tree["id"] . "\n\t\t\t\t\t{$sql_where}\n\t\t\t\t\tAND graph_tree_items.local_graph_id = 0\n\t\t\t\t\tORDER BY graph_tree_items.order_key";
$hierarchy = db_fetch_assoc($hier_sql);
$dhtml_tree_id = 0;
if (sizeof($hierarchy) > 0) {
$last_tier = 1;
$openli = false;
$lasthost = false;
$opentree = false;
foreach ($hierarchy as $leaf) {
if ($dhtml_tree_id != $tree["id"]) {
if ($opentree) {
$i++;
$dhtml_tree[$i] = "\t\t\t</ul>\n\t\t</li>\n\t</ul>\n";
}
$i++;
$clean_id = clean_up_export_name(get_tree_name($tree["id"]) . "_" . $tree['id']);
$dhtml_tree[$i] = "\t<ul>\n\t\t<li id='{$clean_id}'><a href='" . $clean_id . ".html'>" . get_tree_name($tree["id"]) . "</a>\n\t\t\t<ul>\n";
$opentree = true;
}
$dhtml_tree_id = $tree["id"];
$tier = tree_tier($leaf["order_key"]);
if ($leaf["host_id"] > 0) {
//It's a host
if ($tier > $last_tier) {
$i++;
$dhtml_tree[$i] = "\t\t\t<ul>\n";
} elseif ($tier < $last_tier) {
if (!$lasthost) {
$i++;
$dhtml_tree[$i] = "\t\t\t\t</li>\n";
}
for ($x = $tier; $x < $last_tier; $x++) {
$i++;
$dhtml_tree[$i] = "\t\t\t</ul>\n\t\t\t\t</li>\n";
$openli = false;
}
} elseif ($openli && !$lasthost) {
$i++;
$dhtml_tree[$i] = "\t\t\t\t</li>\n";
$openli = false;
}
$last_tier = $tier;
$lasthost = true;
$i++;
$clean_id = clean_up_export_name($leaf["hostname"] . "_" . $leaf["id"]);
$dhtml_tree[$i] = "\t\t\t\t<li id='{$clean_id}' data-jstree='{ \"icon\" : \"./server.png\" }'><a href=\"" . $clean_id . ".html\">Host: " . htmlspecialchars($leaf["hostname"]) . "</a>\n";
if (read_config_option("export_tree_expand_hosts") == "on") {
$i++;
$dhtml_tree[$i] = "\t\t\t\t\t<ul>\n";
if ($leaf["host_grouping_type"] == HOST_GROUPING_GRAPH_TEMPLATE) {
$graph_templates = db_fetch_assoc("SELECT\n\t\t\t\t\t\t\t\t\tgraph_templates.id,\n\t\t\t\t\t\t\t\t\tgraph_templates.name,\n\t\t\t\t\t\t\t\t\tgraph_templates_graph.local_graph_id,\n\t\t\t\t\t\t\t\t\tgraph_templates_graph.title_cache\n\t\t\t\t\t\t\t\t\tFROM (graph_local,graph_templates,graph_templates_graph)\n\t\t\t\t\t\t\t\t\tWHERE graph_local.id=graph_templates_graph.local_graph_id\n\t\t\t\t\t\t\t\t\tAND graph_templates_graph.graph_template_id=graph_templates.id\n\t\t\t\t\t\t\t\t\tAND graph_local.host_id=" . $leaf["host_id"] . "\n\t\t\t\t\t\t\t\t\tAND graph_templates_graph.export='on'\n\t\t\t\t\t\t\t\t\tGROUP BY graph_templates.id\n\t\t\t\t\t\t\t\t\tORDER BY graph_templates.name");
if (sizeof($graph_templates) > 0) {
foreach ($graph_templates as $graph_template) {
$i++;
$clean_id = clean_up_export_name($leaf["hostname"] . "_gt_" . $leaf["id"] . "_" . $graph_template["id"]);
$dhtml_tree[$i] = "\t\t\t\t\t\t<li id='" . $clean_id . "' data-jstree='{ \"icon\" : \"./server_chart.png\" }'><a href=\"" . $clean_id . ".html\">" . htmlspecialchars($graph_template["name"]) . "</a></li>\n";
}
}
} else {
if ($leaf["host_grouping_type"] == HOST_GROUPING_DATA_QUERY_INDEX) {
$data_queries = db_fetch_assoc("SELECT\n\t\t\t\t\t\t\t\t\tsnmp_query.id,\n\t\t\t\t\t\t\t\t\tsnmp_query.name\n\t\t\t\t\t\t\t\t\tFROM (graph_local,snmp_query)\n\t\t\t\t\t\t\t\t\tWHERE graph_local.snmp_query_id=snmp_query.id\n\t\t\t\t\t\t\t\t\tAND graph_local.host_id=" . $leaf["host_id"] . "\n\t\t\t\t\t\t\t\t\tGROUP BY snmp_query.id\n\t\t\t\t\t\t\t\t\tORDER BY snmp_query.name");
array_push($data_queries, array("id" => "0", "name" => "Non Query Based"));
if (sizeof($data_queries) > 0) {
foreach ($data_queries as $data_query) {
$i++;
$clean_id = clean_up_export_name($leaf["hostname"] . "_dq_" . $leaf["title"] . "_" . $leaf["id"] . "_" . $data_query["id"]);
if ($data_query['name'] != 'Non Query Based') {
$dhtml_tree[$i] = "\t\t\t\t\t\t<li id='" . $clean_id . "' data-jstree='{ \"icon\" : \"./server_dataquery.png\" }'><a href=\"" . $clean_id . ".html\">" . htmlspecialchars($data_query["name"]) . "</a>\n";
} else {
$dhtml_tree[$i] = "\t\t\t\t\t\t<li id='" . $clean_id . "' data-jstree='{ \"icon\" : \"./server_chart.png\" }'><a href=\"" . $clean_id . ".html\">" . htmlspecialchars($data_query["name"]) . "</a>\n";
}
/* fetch a list of field names that are sorted by the preferred sort field */
$sort_field_data = get_formatted_data_query_indexes($leaf["host_id"], $data_query["id"]);
if ($data_query["id"] > 0) {
$i++;
$dhtml_tree[$i] = "\t\t\t\t\t\t\t<ul>\n";
while (list($snmp_index, $sort_field_value) = each($sort_field_data)) {
$i++;
//.........这里部分代码省略.........
开发者ID:teddywen,项目名称:cacti,代码行数:101,代码来源:graph_export.php
示例5: 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"));
//.........这里部分代码省略.........
开发者ID:resmon,项目名称:resmon-cacti,代码行数:101,代码来源:html_tree.php
示例6: upgrade_to_0_8_6
function upgrade_to_0_8_6()
{
include "../lib/data_query.php";
include "../lib/tree.php";
include "../lib/import.php";
include "../lib/poller.php";
db_install_execute("0.8.6", "DROP TABLE `snmp_query_field`;");
db_install_execute("0.8.6", "DROP TABLE `data_input_data_cache`;");
db_install_execute("0.8.6", "DROP TABLE `data_input_data_fcache`;");
/* distributed poller support */
db_install_execute("0.8.6", "CREATE TABLE `poller` (`id` smallint(5) unsigned NOT NULL auto_increment, `hostname` varchar(250) NOT NULL default '', `ip_address` int(11) unsigned NOT NULL default '0', `last_update` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`)) TYPE=MyISAM;");
db_install_execute("0.8.6", "CREATE TABLE `poller_command` (`poller_id` smallint(5) unsigned NOT NULL default '0', `time` datetime NOT NULL default '0000-00-00 00:00:00', `action` tinyint(3) unsigned NOT NULL default '0', `command` varchar(200) NOT NULL default '', PRIMARY KEY (`poller_id`,`action`,`command`)) TYPE=MyISAM;");
db_install_execute("0.8.6", "CREATE TABLE `poller_item` (`local_data_id` mediumint(8) unsigned NOT NULL default '0', `poller_id` smallint(5) unsigned NOT NULL default '0', `host_id` mediumint(8) NOT NULL default '0', `action` tinyint(2) unsigned NOT NULL default '1', `hostname` varchar(250) NOT NULL default '', `snmp_community` varchar(100) NOT NULL default '', `snmp_version` tinyint(1) unsigned NOT NULL default '0', `snmp_username` varchar(50) NOT NULL default '', `snmp_password` varchar(50) NOT NULL default '', `snmp_port` mediumint(5) unsigned NOT NULL default '161', `snmp_timeout` mediumint(8) unsigned NOT NULL default '0', `rrd_name` varchar(19) NOT NULL default '', `rrd_path` varchar(255) NOT NULL default '', `rrd_num` tinyint(2) unsigned NOT NULL default '0', `arg1` varchar(255) default NULL, `arg2` varchar(255) default NULL, `arg3` varchar(255) default NULL, PRIMARY KEY (`local_data_id`,`rrd_name`), KEY `local_data_id` (`local_data_id`), KEY `host_id` (`host_id`)) TYPE=MyISAM;");
db_install_execute("0.8.6", "CREATE TABLE `poller_output` (`local_data_id` mediumint(8) unsigned NOT NULL default '0', `rrd_name` varchar(19) NOT NULL default '', `time` datetime NOT NULL default '0000-00-00 00:00:00', `output` text NOT NULL, PRIMARY KEY (`local_data_id`,`rrd_name`,`time`)) TYPE=MyISAM;");
db_install_execute("0.8.6", "CREATE TABLE `poller_reindex` (`host_id` mediumint(8) unsigned NOT NULL default '0', `data_query_id` mediumint(8) unsigned NOT NULL default '0', `action` tinyint(3) unsigned NOT NULL default '0', `op` char(1) NOT NULL default '', `assert_value` varchar(100) NOT NULL default '', `arg1` varchar(100) NOT NULL default '', PRIMARY KEY (`host_id`,`data_query_id`,`arg1`)) TYPE=MyISAM;");
db_install_execute("0.8.6", "CREATE TABLE `poller_time` (`id` mediumint(8) unsigned NOT NULL auto_increment, `poller_id` smallint(5) unsigned NOT NULL default '0', `start_time` datetime NOT NULL default '0000-00-00 00:00:00', `end_time` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`)) TYPE=MyISAM;");
db_install_execute("0.8.6", "ALTER TABLE `graph_tree_items` ADD `host_grouping_type` TINYINT( 3 ) UNSIGNED DEFAULT '1' NOT NULL, ADD `sort_children_type` TINYINT( 3 ) UNSIGNED DEFAULT '1' NOT NULL;");
db_install_execute("0.8.6", "ALTER TABLE `host_snmp_query` ADD `sort_field` VARCHAR( 50 ) NOT NULL, ADD `title_format` VARCHAR( 50 ) NOT NULL, ADD `reindex_method` TINYINT( 3 ) UNSIGNED DEFAULT '1' NOT NULL;");
db_install_execute("0.8.6", "ALTER TABLE `graph_tree` CHANGE `user_id` `sort_type` TINYINT( 3 ) UNSIGNED DEFAULT '1' NOT NULL;");
db_install_execute("0.8.6", "ALTER TABLE `graph_tree_items` CHANGE `order_key` `order_key` VARCHAR( 100 ) DEFAULT '0' NOT NULL;");
db_install_execute("0.8.6", "ALTER TABLE `host` ADD `status_event_count` mediumint(8) unsigned NOT NULL default '0', ADD `status_fail_date` datetime NOT NULL default '0000-00-00 00:00:00', ADD `status_rec_date` datetime NOT NULL default '0000-00-00 00:00:00', ADD `status_last_error` varchar(50) default '', ADD `min_time` decimal(7,5) default '9.99999', ADD `max_time` decimal(7,5) default '0.00000', ADD `cur_time` decimal(7,5) default '0.00000', ADD `avg_time` decimal(7,5) default '0.00000', ADD `total_polls` int(12) unsigned default '0', ADD `failed_polls` int(12) unsigned default '0', ADD `availability` decimal(7,5) default '100.000' NOT NULL;");
db_install_execute("0.8.6", "UPDATE snmp_query_graph_rrd_sv set text = REPLACE(text,' (In)','') where snmp_query_graph_id = 2;");
db_install_execute("0.8.6", "UPDATE graph_tree set sort_type = '1';");
/* update the sort cache */
$host_snmp_query = db_fetch_assoc("select host_id,snmp_query_id from host_snmp_query");
if (sizeof($host_snmp_query) > 0) {
foreach ($host_snmp_query as $item) {
update_data_query_sort_cache($item["host_id"], $item["snmp_query_id"]);
update_reindex_cache($item["host_id"], $item["snmp_query_id"]);
}
}
/* script query data input methods */
$xml_data = "<cacti>\n\t\t\t<hash_030003332111d8b54ac8ce939af87a7eac0c06>\n\t\t\t\t<name>Get Script Server Data (Indexed)</name>\n\t\t\t\t<type_id>6</type_id>\n\t\t\t\t<input_string></input_string>\n\t\t\t\t<fields>\n\t\t\t\t\t<hash_070003172b4b0eacee4948c6479f587b62e512>\n\t\t\t\t\t\t<name>Index Type</name>\n\t\t\t\t\t\t<update_rra></update_rra>\n\t\t\t\t\t\t<regexp_match></regexp_match>\n\t\t\t\t\t\t<allow_nulls></allow_nulls>\n\t\t\t\t\t\t<type_code>index_type</type_code>\n\t\t\t\t\t\t<input_output>in</input_output>\n\t\t\t\t\t\t<data_name>index_type</data_name>\n\t\t\t\t\t</hash_070003172b4b0eacee4948c6479f587b62e512>\n\t\t\t\t\t<hash_07000330fb5d5bcf3d66bb5abe88596f357c26>\n\t\t\t\t\t\t<name>Index Value</name>\n\t\t\t\t\t\t<update_rra></update_rra>\n\t\t\t\t\t\t<regexp_match></regexp_match>\n\t\t\t\t\t\t<allow_nulls></allow_nulls>\n\t\t\t\t\t\t<type_code>index_value</type_code>\n\t\t\t\t\t\t<input_output>in</input_output>\n\t\t\t\t\t\t<data_name>index_value</data_name>\n\t\t\t\t\t</hash_07000330fb5d5bcf3d66bb5abe88596f357c26>\n\t\t\t\t\t<hash_07000331112c85ae4ff821d3b288336288818c>\n\t\t\t\t\t\t<name>Output Type ID</name>\n\t\t\t\t\t\t<update_rra></update_rra>\n\t\t\t\t\t\t<regexp_match></regexp_match>\n\t\t\t\t\t\t<allow_nulls></allow_nulls>\n\t\t\t\t\t\t<type_code>output_type</type_code>\n\t\t\t\t\t\t<input_output>in</input_output>\n\t\t\t\t\t\t<data_name>output_type</data_name>\n\t\t\t\t\t</hash_07000331112c85ae4ff821d3b288336288818c>\n\t\t\t\t\t<hash_0700035be8fa85472d89c621790b43510b5043>\n\t\t\t\t\t\t<name>Output Value</name>\n\t\t\t\t\t\t<update_rra>on</update_rra>\n\t\t\t\t\t\t<regexp_match></regexp_match>\n\t\t\t\t\t\t<allow_nulls></allow_nulls>\n\t\t\t\t\t\t<type_code></type_code>\n\t\t\t\t\t\t<input_output>out</input_output>\n\t\t\t\t\t\t<data_name>output</data_name>\n\t\t\t\t\t</hash_0700035be8fa85472d89c621790b43510b5043>\n\t\t\t\t</fields>\n\t\t\t</hash_030003332111d8b54ac8ce939af87a7eac0c06>\n\t\t</cacti>";
import_xml_data($xml_data);
/* update trees to three characters per tier */
$trees = db_fetch_assoc("select id from graph_tree");
if (sizeof($trees) > 0) {
foreach ($trees as $tree) {
$tree_items = db_fetch_assoc("select\n\t\t\t\tgraph_tree_items.id,\n\t\t\t\tgraph_tree_items.order_key\n\t\t\t\tfrom graph_tree_items\n\t\t\t\twhere graph_tree_items.graph_tree_id='" . $tree["id"] . "'\n\t\t\t\torder by graph_tree_items.order_key");
if (sizeof($tree_items) > 0) {
$_tier = 0;
/* only do the upgrade once */
if ($tree_items[0]["order_key"] == "001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") {
return;
}
foreach ($tree_items as $tree_item) {
$tier = tree_tier($tree_item["order_key"], 2);
/* back off */
if ($tier < $_tier) {
for ($i = $_tier; $i > $tier; $i--) {
$tier_counter[$i] = 0;
}
}
/* we key tier==0 off of '1' and tier>0 off of '0' */
if (!isset($tier_counter[$tier])) {
$tier_counter[$tier] = 1;
} else {
$tier_counter[$tier]++;
}
$search_key = preg_replace("/0+\$/", "", $tree_item["order_key"]);
if (strlen($search_key) % 2 != 0) {
$search_key .= "0";
}
$new_search_key = "";
for ($i = 1; $i < $tier; $i++) {
$new_search_key .= str_pad(strval($tier_counter[$i]), 3, '0', STR_PAD_LEFT);
}
/* build the new order key string */
$key = str_pad($new_search_key . str_pad(strval($tier_counter[$tier]), 3, '0', STR_PAD_LEFT), 90, '0', STR_PAD_RIGHT);
db_execute("update graph_tree_items set order_key='{$key}' where id=" . $tree_item["id"]);
$_tier = $tier;
}
}
}
}
}
开发者ID:songchin,项目名称:Cacti,代码行数:76,代码来源:0_8_5a_to_0_8_6.php
示例7: item_remove
function item_remove()
{
/* ================= input validation ================= */
input_validate_input_number(get_request_var("id"));
input_validate_input_number(get_request_var("tree_id"));
/* ==================================================== */
/* modify for multi user start */
if (!check_tree_item($_GET["id"])) {
access_denied();
}
/* modify for multi user end */
if (read_config_option("deletion_verification") == "on" && !isset($_GET["confirm"])) {
$graph_tree_item = db_fetch_row("select title,local_graph_id,host_id from graph_tree_items where id=" . $_GET["id"]);
if (!empty($graph_tree_item["local_graph_id"])) {
$text = "Are you sure you want to delete the graph item <strong>'" . db_fetch_cell("select title_cache from graph_templates_graph where local_graph_id=" . $graph_tree_item["local_graph_id"]) . "'</strong>?";
} elseif ($graph_tree_item["title"] != "") {
$text = "Are you sure you want to delete the header item <strong>'" . $graph_tree_item["title"] . "'</strong>?";
} elseif (!empty($graph_tree_item["host_id"])) {
$text = "Are you sure you want to delete the host item <strong>'" . db_fetch_cell("select CONCAT_WS('',description,' (',hostname,')') as hostname from host where id=" . $graph_tree_item["host_id"]) . "'</strong>?";
}
include "./include/top_header.php";
form_confirm("Are You Sure?", $text, htmlspecialchars("tree.php?action=edit&id=" . $_GET["tree_id"]), htmlspecialchars("tree.php?action=item_remove&id=" . $_GET["id"] . "&tree_id=" . $_GET["tree_id"]));
include "./include/bottom_footer.php";
exit;
}
if (read_config_option("deletion_verification") == "" || isset($_GET["confirm"])) {
/* modify for multi user start */
if ($_SESSION["permission"] < ACCESS_ADMINISTRATOR) {
$tree_item = db_fetch_row("SELECT graph_tree_id,local_graph_id,title,host_id,order_key FROM graph_tree_items WHERE id = '" . $_GET["id"] . "'");
// public graph
if ($tree_item["graph_tree_id"] == $_SESSION["public_tree_id"] && $tree_item["local_graph_id"] > 0) {
db_execute("DELETE FROM user_auth_perms WHERE user_id = '" . $_SESSION["sess_user_id"] . "' AND item_id = '" . $tree_item["local_graph_id"] . "' AND type = '1'");
// remove all reference favorites graph
$rows = db_fetch_assoc("SELECT graph_tree_items.id FROM graph_tree_items WHERE graph_tree_id != '" . $_SESSION["private_tree_id"] . "' AND local_graph_id = '" . $tree_item["local_graph_id"] . "'");
foreach ($rows as $row) {
delete_branch($row["id"]);
}
// private device (re-entry host tree_item)
} elseif ($tree_item["graph_tree_id"] == $_SESSION["private_tree_id"] && $tree_item["host_id"] > 0) {
exec("php ./cli/add_tree.php --type=node --node-type=host --tree-id=" . $_SESSION["private_tree_id"] . " --host-id=" . $tree_item["host_id"] . " --host-group-style=1");
// private header (re-entry host tree_item)
} elseif ($tree_item["graph_tree_id"] == $_SESSION["private_tree_id"] && $tree_item["title"] != "") {
$tier = tree_tier($tree_item["order_key"]);
$order_key = substr($tree_item["order_key"], 0, $tier * CHARS_PER_TIER);
$rows = db_fetch_assoc("SELECT host_id FROM graph_tree_items WHERE graph_tree_id = '" . $_SESSION["private_tree_id"] . "' AND host_id > 0 AND order_key LIKE '" . $order_key . "%'");
foreach ($rows as $row) {
exec("php ./cli/add_tree.php --type=node --node-type=host --tree-id=" . $_SESSION["private_tree_id"] . " --host-id=" . $row["host_id"] . " --host-group-style=1");
}
}
}
/* modify for multi user end */
delete_branch($_GET["id"]);
}
/* clear graph tree cache on save - affects current user only, other users should see changes in <5 minutes */
if (isset($_SESSION['dhtml_tree'])) {
unset($_SESSION['dhtml_tree']);
}
header("Location: tree.php?action=edit&id=" . $_GET["tree_id"]);
exit;
}
开发者ID:resmon,项目名称:resmon-cacti,代码行数:60,代码来源:tree.php
示例8: 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) WHER
|
请发表评论