本文整理汇总了PHP中draw_nontemplated_fields_custom_data函数的典型用法代码示例。如果您正苦于以下问题:PHP draw_nontemplated_fields_custom_data函数的具体用法?PHP draw_nontemplated_fields_custom_data怎么用?PHP draw_nontemplated_fields_custom_data使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了draw_nontemplated_fields_custom_data函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: host_new_graphs
function host_new_graphs($host_id, $host_template_id, $selected_graphs_array)
{
/* we use object buffering on this page to allow redirection to another page if no
fields are actually drawn */
ob_start();
top_header();
print "<form method='post' action='graphs_new.php'>\n";
$snmp_query_id = 0;
$num_output_fields = array();
while (list($form_type, $form_array) = each($selected_graphs_array)) {
while (list($form_id1, $form_array2) = each($form_array)) {
if ($form_type == 'cg') {
$graph_template_id = $form_id1;
html_start_box("<strong>Create Graph from '" . db_fetch_cell_prepared('SELECT name FROM graph_templates WHERE id = ?', array($graph_template_id)) . "'", '100%', '', '3', 'center', '');
} elseif ($form_type == 'sg') {
while (list($form_id2, $form_array3) = each($form_array2)) {
/* ================= input validation ================= */
input_validate_input_number($snmp_query_id);
/* ==================================================== */
$snmp_query_id = $form_id1;
$snmp_query_graph_id = $form_id2;
$num_graphs = sizeof($form_array3);
$snmp_query = db_fetch_row_prepared('SELECT
snmp_query.name,
snmp_query.xml_path
FROM snmp_query
WHERE snmp_query.id = ?', array($snmp_query_id));
$graph_template_id = db_fetch_cell_prepared('SELECT graph_template_id FROM snmp_query_graph WHERE id = ?', array($snmp_query_graph_id));
}
/* DRAW: Data Query */
html_start_box("<strong>Create {$num_graphs} Graph" . ($num_graphs > 1 ? 's' : '') . " from '" . db_fetch_cell_prepared('SELECT name FROM snmp_query WHERE id = ?', array($snmp_query_id)) . "'", '100%', '', '3', 'center', '');
}
/* ================= input validation ================= */
input_validate_input_number($graph_template_id);
/* ==================================================== */
$data_templates = db_fetch_assoc_prepared('SELECT
data_template.name AS data_template_name,
data_template_rrd.data_source_name,
data_template_data.*
FROM (data_template, data_template_rrd, data_template_data, graph_templates_item)
WHERE graph_templates_item.task_item_id = data_template_rrd.id
AND data_template_rrd.data_template_id = data_template.id
AND data_template_data.data_template_id = data_template.id
AND data_template_rrd.local_data_id = 0
AND data_template_data.local_data_id = 0
AND graph_templates_item.local_graph_id = 0
AND graph_templates_item.graph_template_id = ?
GROUP BY data_template.id
ORDER BY data_template.name', array($graph_template_id));
$graph_template = db_fetch_row_prepared('SELECT
graph_templates.name AS graph_template_name,
graph_templates_graph.*
FROM (graph_templates, graph_templates_graph)
WHERE graph_templates.id = graph_templates_graph.graph_template_id
AND graph_templates.id = ?
AND graph_templates_graph.local_graph_id = 0', array($graph_template_id));
$graph_template_name = db_fetch_cell_prepared('SELECT name FROM graph_templates WHERE id = ?', array($graph_template_id));
array_push($num_output_fields, draw_nontemplated_fields_graph($graph_template_id, $graph_template, "g_{$snmp_query_id}" . '_' . $graph_template_id . '_|field|', '<strong>Graph</strong> [Template: ' . $graph_template['graph_template_name'] . ']', false, false, isset($snmp_query_graph_id) ? $snmp_query_graph_id : 0));
array_push($num_output_fields, draw_nontemplated_fields_graph_item($graph_template_id, 0, 'gi_' . $snmp_query_id . '_' . $graph_template_id . '_|id|_|field|', '<strong>Graph Items</strong> [Template: ' . $graph_template_name . ']', false));
/* DRAW: Data Sources */
if (sizeof($data_templates) > 0) {
foreach ($data_templates as $data_template) {
array_push($num_output_fields, draw_nontemplated_fields_data_source($data_template['data_template_id'], 0, $data_template, 'd_' . $snmp_query_id . '_' . $graph_template_id . '_' . $data_template['data_template_id'] . '_|field|', '<strong>Data Source</strong> [Template: ' . $data_template['data_template_name'] . ']', false, false, isset($snmp_query_graph_id) ? $snmp_query_graph_id : 0));
$data_template_items = db_fetch_assoc_prepared('SELECT
data_template_rrd.*
FROM data_template_rrd
WHERE data_template_rrd.data_template_id = ?
AND local_data_id = 0', array($data_template['data_template_id']));
array_push($num_output_fields, draw_nontemplated_fields_data_source_item($data_template['data_template_id'], $data_template_items, 'di_' . $snmp_query_id . '_' . $graph_template_id . '_' . $data_template['data_template_id'] . '_|id|_|field|', '', false, false, false, isset($snmp_query_graph_id) ? $snmp_query_graph_id : 0));
array_push($num_output_fields, draw_nontemplated_fields_custom_data($data_template['id'], 'c_' . $snmp_query_id . '_' . $graph_template_id . '_' . $data_template['data_template_id'] . '_|id|', '<strong>Custom Data</strong> [Template: ' . $data_template['data_template_name'] . ']', false, false, $snmp_query_id));
}
}
html_end_box();
}
}
/* no fields were actually drawn on the form; just save without prompting the user */
if (array_sum($num_output_fields) == 0) {
ob_end_clean();
/* since the user didn't actually click "Create" to POST the data; we have to
pretend like they did here */
$_POST['host_template_id'] = $host_template_id;
$_POST['host_id'] = $host_id;
$_POST['save_component_new_graphs'] = '1';
$_POST['selected_graphs_array'] = serialize($selected_graphs_array);
host_new_graphs_save();
header('Location: graphs_new.php?host_id=' . $_POST['host_id']);
exit;
}
/* flush the current output buffer to the browser */
ob_end_flush();
form_hidden_box('host_template_id', $host_template_id, '0');
form_hidden_box('host_id', $host_id, '0');
form_hidden_box('save_component_new_graphs', '1', '');
print "<input type='hidden' name='selected_graphs_array' value='" . serialize($selected_graphs_array) . "'>\n";
if (!substr_count($_SERVER['HTTP_REFERER'], 'graphs_new')) {
$_REQUEST['returnto'] = basename($_SERVER['HTTP_REFERER']);
}
load_current_session_value('returnto', 'sess_graphs_new_returnto', '');
form_save_button($_REQUEST['returnto']);
bottom_footer();
//.........这里部分代码省略.........
示例2: ds_edit
function ds_edit()
{
global $colors, $struct_data_source, $struct_data_source_item, $data_source_types;
/* ================= input validation ================= */
input_validate_input_number(get_request_var("id"));
/* ==================================================== */
$use_data_template = true;
$host_id = 0;
if (!empty($_GET["id"])) {
$data_local = db_fetch_row("select host_id,data_template_id from data_local where id='" . $_GET["id"] . "'");
$data = db_fetch_row("select * from data_template_data where local_data_id='" . $_GET["id"] . "'");
if (isset($data_local["data_template_id"]) && $data_local["data_template_id"] >= 0) {
$data_template = db_fetch_row("select id,name from data_template where id='" . $data_local["data_template_id"] . "'");
$data_template_data = db_fetch_row("select * from data_template_data where data_template_id='" . $data_local["data_template_id"] . "' and local_data_id=0");
} else {
$_SESSION["sess_messages"] = 'Data Source "' . $_GET["id"] . '" does not exist.';
header("Location: data_sources.php");
exit;
}
$header_label = "[edit: " . get_data_source_title($_GET["id"]) . "]";
if (empty($data_local["data_template_id"])) {
$use_data_template = false;
}
} else {
$header_label = "[new]";
$use_data_template = false;
}
/* handle debug mode */
if (isset($_GET["debug"])) {
if ($_GET["debug"] == "0") {
kill_session_var("ds_debug_mode");
} elseif ($_GET["debug"] == "1") {
$_SESSION["ds_debug_mode"] = true;
}
}
include_once "./include/top_header.php";
if (!empty($_GET["id"])) {
?>
<table width="100%" align="center">
<tr>
<td class="textInfo" colspan="2" valign="top">
<?php
print get_data_source_title($_GET["id"]);
?>
</td>
<td class="textInfo" align="right" valign="top">
<span style="color: #c16921;">*<a href='data_sources.php?action=ds_edit&id=<?php
print isset($_GET["id"]) ? $_GET["id"] : 0;
?>
&debug=<?php
print isset($_SESSION["ds_debug_mode"]) ? "0" : "1";
?>
'>Turn <strong><?php
print isset($_SESSION["ds_debug_mode"]) ? "Off" : "On";
?>
</strong> Data Source Debug Mode.</a>
</td>
</tr>
</table>
<br>
<?php
}
html_start_box("<strong>Data Template Selection</strong> {$header_label}", "100%", $colors["header"], "3", "center", "");
$form_array = array("data_template_id" => array("method" => "drop_sql", "friendly_name" => "Selected Data Template", "description" => "The name given to this data template.", "value" => isset($data_template) ? $data_template["id"] : "0", "none_value" => "None", "sql" => "select id,name from data_template order by name"), "host_id" => array("method" => "drop_sql", "friendly_name" => "Host", "description" => "Choose the host that this graph belongs to.", "value" => isset($_GET["host_id"]) ? $_GET["host_id"] : $data_local["host_id"], "none_value" => "None", "sql" => "select id,CONCAT_WS('',description,' (',hostname,')') as name from host order by description,hostname"), "_data_template_id" => array("method" => "hidden", "value" => isset($data_template) ? $data_template["id"] : "0"), "_host_id" => array("method" => "hidden", "value" => empty($data_local["host_id"]) ? isset($_GET["host_id"]) ? $_GET["host_id"] : "0" : $data_local["host_id"]), "_data_input_id" => array("method" => "hidden", "value" => isset($data["data_input_id"]) ? $data["data_input_id"] : "0"), "data_template_data_id" => array("method" => "hidden", "value" => isset($data) ? $data["id"] : "0"), "local_data_template_data_id" => array("method" => "hidden", "value" => isset($data) ? $data["local_data_template_data_id"] : "0"), "local_data_id" => array("method" => "hidden", "value" => isset($data) ? $data["local_data_id"] : "0"));
draw_edit_form(array("config" => array(), "fields" => $form_array));
html_end_box();
/* only display the "inputs" area if we are using a data template for this data source */
if (!empty($data["data_template_id"])) {
$template_data_rrds = db_fetch_assoc("select * from data_template_rrd where local_data_id=" . $_GET["id"] . " order by data_source_name");
html_start_box("<strong>Supplemental Data Template Data</strong>", "100%", $colors["header"], "3", "center", "");
draw_nontemplated_fields_data_source($data["data_template_id"], $data["local_data_id"], $data, "|field|", "<strong>Data Source Fields</strong>", true, true, 0);
draw_nontemplated_fields_data_source_item($data["data_template_id"], $template_data_rrds, "|field|_|id|", "<strong>Data Source Item Fields</strong>", true, true, true, 0);
draw_nontemplated_fields_custom_data($data["id"], "value_|id|", "<strong>Custom Data</strong>", true, true, 0);
form_hidden_box("save_component_data", "1", "");
html_end_box();
}
if ((isset($_GET["id"]) || isset($_GET["new"])) && empty($data["data_template_id"])) {
html_start_box("<strong>Data Source</strong>", "100%", $colors["header"], "3", "center", "");
$form_array = array();
while (list($field_name, $field_array) = each($struct_data_source)) {
$form_array += array($field_name => $struct_data_source[$field_name]);
if (!($use_data_template == false || !empty($data_template_data["t_" . $field_name]) || $field_array["flags"] == "NOTEMPLATE")) {
$form_array[$field_name]["description"] = "";
}
$form_array[$field_name]["value"] = isset($data[$field_name]) ? $data[$field_name] : "";
$form_array[$field_name]["form_id"] = empty($data["id"]) ? "0" : $data["id"];
if (!($use_data_template == false || !empty($data_template_data["t_" . $field_name]) || $field_array["flags"] == "NOTEMPLATE")) {
$form_array[$field_name]["method"] = "template_" . $form_array[$field_name]["method"];
}
}
draw_edit_form(array("config" => array("no_form_tag" => true), "fields" => inject_form_variables($form_array, isset($data) ? $data : array())));
html_end_box();
/* fetch ALL rrd's for this data source */
if (!empty($_GET["id"])) {
$template_data_rrds = db_fetch_assoc("select id,data_source_name from data_template_rrd where local_data_id=" . $_GET["id"] . " order by data_source_name");
}
/* select the first "rrd" of this data source by default */
if (empty($_GET["view_rrd"])) {
$_GET["view_rrd"] = isset($template_data_rrds[0]["id"]) ? $template_data_rrds[0]["id"] : "0";
}
//.........这里部分代码省略.........
示例3: host_new_graphs
function host_new_graphs($host_id, $host_template_id, $selected_graphs_array)
{
/* we use object buffering on this page to allow redirection to another page if no
fields are actually drawn */
ob_start();
include_once "./include/top_header.php";
print "<form method='post' action='graphs_new.php'>\n";
$snmp_query_id = 0;
$num_output_fields = array();
while (list($form_type, $form_array) = each($selected_graphs_array)) {
while (list($form_id1, $form_array2) = each($form_array)) {
if ($form_type == "cg") {
$graph_template_id = $form_id1;
html_start_box("<strong>Create Graph from '" . db_fetch_cell("select name from graph_templates where id={$graph_template_id}") . "'", "100%", "", "3", "center", "");
} elseif ($form_type == "sg") {
while (list($form_id2, $form_array3) = each($form_array2)) {
/* ================= input validation ================= */
input_validate_input_number($snmp_query_id);
/* ==================================================== */
$snmp_query_id = $form_id1;
$snmp_query_graph_id = $form_id2;
$num_graphs = sizeof($form_array3);
$snmp_query = db_fetch_row("select\n\t\t\t\t\t\tsnmp_query.name,\n\t\t\t\t\t\tsnmp_query.xml_path\n\t\t\t\t\t\tfrom snmp_query\n\t\t\t\t\t\twhere snmp_query.id={$snmp_query_id}");
$graph_template_id = db_fetch_cell("select graph_template_id from snmp_query_graph where id={$snmp_query_graph_id}");
}
/* DRAW: Data Query */
html_start_box("<strong>Create {$num_graphs} Graph" . ($num_graphs > 1 ? "s" : "") . " from '" . db_fetch_cell("select name from snmp_query where id={$snmp_query_id}") . "'", "100%", "", "3", "center", "");
}
/* ================= input validation ================= */
input_validate_input_number($graph_template_id);
/* ==================================================== */
$data_templates = db_fetch_assoc("select\n\t\t\t\tdata_template.name as data_template_name,\n\t\t\t\tdata_template_rrd.data_source_name,\n\t\t\t\tdata_template_data.*\n\t\t\t\tfrom (data_template, data_template_rrd, data_template_data, graph_templates_item)\n\t\t\t\twhere graph_templates_item.task_item_id=data_template_rrd.id\n\t\t\t\tand data_template_rrd.data_template_id=data_template.id\n\t\t\t\tand data_template_data.data_template_id=data_template.id\n\t\t\t\tand data_template_rrd.local_data_id=0\n\t\t\t\tand data_template_data.local_data_id=0\n\t\t\t\tand graph_templates_item.local_graph_id=0\n\t\t\t\tand graph_templates_item.graph_template_id=" . $graph_template_id . "\n\t\t\t\tgroup by data_template.id\n\t\t\t\torder by data_template.name");
$graph_template = db_fetch_row("select\n\t\t\t\tgraph_templates.name as graph_template_name,\n\t\t\t\tgraph_templates_graph.*\n\t\t\t\tfrom (graph_templates, graph_templates_graph)\n\t\t\t\twhere graph_templates.id=graph_templates_graph.graph_template_id\n\t\t\t\tand graph_templates.id=" . $graph_template_id . "\n\t\t\t\tand graph_templates_graph.local_graph_id=0");
$graph_template_name = db_fetch_cell("select name from graph_templates where id=" . $graph_template_id);
array_push($num_output_fields, draw_nontemplated_fields_graph($graph_template_id, $graph_template, "g_{$snmp_query_id}" . "_" . $graph_template_id . "_|field|", "<strong>Graph</strong> [Template: " . $graph_template["graph_template_name"] . "]", false, false, isset($snmp_query_graph_id) ? $snmp_query_graph_id : 0));
array_push($num_output_fields, draw_nontemplated_fields_graph_item($graph_template_id, 0, "gi_" . $snmp_query_id . "_" . $graph_template_id . "_|id|_|field|", "<strong>Graph Items</strong> [Template: " . $graph_template_name . "]", false));
/* DRAW: Data Sources */
if (sizeof($data_templates) > 0) {
foreach ($data_templates as $data_template) {
array_push($num_output_fields, draw_nontemplated_fields_data_source($data_template["data_template_id"], 0, $data_template, "d_" . $snmp_query_id . "_" . $graph_template_id . "_" . $data_template["data_template_id"] . "_|field|", "<strong>Data Source</strong> [Template: " . $data_template["data_template_name"] . "]", false, false, isset($snmp_query_graph_id) ? $snmp_query_graph_id : 0));
$data_template_items = db_fetch_assoc("select\n\t\t\t\t\tdata_template_rrd.*\n\t\t\t\t\tfrom data_template_rrd\n\t\t\t\t\twhere data_template_rrd.data_template_id=" . $data_template["data_template_id"] . "\n\t\t\t\t\tand local_data_id=0");
array_push($num_output_fields, draw_nontemplated_fields_data_source_item($data_template["data_template_id"], $data_template_items, "di_" . $snmp_query_id . "_" . $graph_template_id . "_" . $data_template["data_template_id"] . "_|id|_|field|", "", false, false, false, isset($snmp_query_graph_id) ? $snmp_query_graph_id : 0));
array_push($num_output_fields, draw_nontemplated_fields_custom_data($data_template["id"], "c_" . $snmp_query_id . "_" . $graph_template_id . "_" . $data_template["data_template_id"] . "_|id|", "<strong>Custom Data</strong> [Template: " . $data_template["data_template_name"] . "]", false, false, $snmp_query_id));
}
}
html_end_box();
}
}
/* no fields were actually drawn on the form; just save without prompting the user */
if (array_sum($num_output_fields) == 0) {
ob_end_clean();
/* since the user didn't actually click "Create" to POST the data; we have to
pretend like they did here */
$_POST["host_template_id"] = $host_template_id;
$_POST["host_id"] = $host_id;
$_POST["save_component_new_graphs"] = "1";
$_POST["selected_graphs_array"] = serialize($selected_graphs_array);
host_new_graphs_save();
header("Location: graphs_new.php?host_id=" . $_POST["host_id"]);
exit;
}
/* flush the current output buffer to the browser */
ob_end_flush();
form_hidden_box("host_template_id", $host_template_id, "0");
form_hidden_box("host_id", $host_id, "0");
form_hidden_box("save_component_new_graphs", "1", "");
print "<input type='hidden' name='selected_graphs_array' value='" . serialize($selected_graphs_array) . "'>\n";
if (!substr_count($_SERVER["HTTP_REFERER"], "graphs_new")) {
$_REQUEST["returnto"] = basename($_SERVER["HTTP_REFERER"]);
}
load_current_session_value("returnto", "sess_graphs_new_returnto", "");
form_save_button($_REQUEST["returnto"]);
include_once "./include/bottom_footer.php";
}
示例4: data_source_edit
//.........这里部分代码省略.........
$header_items = array(__("Field"), __("Value"));
print "<tr><td>";
html_header($header_items, 1, true, 'template');
$form_array = fields_data_source_form_list();
$form_array["data_template_id"]["id"] = (isset($data_template["id"]) ? $data_template["id"] : "0");
$form_array["data_template_id"]["name"] = db_fetch_cell("SELECT name FROM data_template WHERE id=" . $form_array["data_template_id"]["id"]);
$form_array["device_id"]["id"] = (isset($_GET["device_id"]) ? $_GET["device_id"] : $data_local["device_id"]);
$form_array["device_id"]["name"] = db_fetch_cell("SELECT CONCAT_WS('',description,' (',hostname,')') FROM device WHERE id=" . $form_array["device_id"]["id"]);
draw_edit_form(
array(
"config" => array(),
"fields" => $form_array
)
);
print "</table></td></tr>"; /* end of html_header */
html_end_box();
form_hidden_box("hidden_data_template_id", (isset($data_template["id"]) ? $data_template["id"] : "0"), "");
form_hidden_box("hidden_device_id", (empty($data_local["device_id"]) ? (isset($_GET["device_id"]) ? $_GET["device_id"] : "0") : $data_local["device_id"]), "");
form_hidden_box("hidden_data_input_id", (isset($data["data_input_id"]) ? $data["data_input_id"] : "0"), "");
form_hidden_box("data_template_data_id", (isset($data) ? $data["id"] : "0"), "");
form_hidden_box("local_data_template_data_id", (isset($data) ? $data["local_data_template_data_id"] : "0"), "");
form_hidden_box("local_data_id", (isset($data) ? $data["local_data_id"] : "0"), "");
/* only display the "inputs" area if we are using a data template for this data source */
if (!empty($data["data_template_id"])) {
html_start_box("<strong>" . __("Supplemental Data Source Template Data") . "</strong>", "100", $colors["header"], 0, "center", "");
draw_nontemplated_fields_data_source($data["data_template_id"], $data["local_data_id"], $data, "|field|", "<strong>" . __("Data Source Fields") . "</strong>", true, true, 0);
draw_nontemplated_fields_data_source_item($data["data_template_id"], $data_source_items, "|field|_|id|", "<strong>" . __("Data Source Item Fields") . "</strong>", true, true, true, 0);
draw_nontemplated_fields_custom_data($data["id"], "value_|id|", "<strong>" . __("Custom Data") . "</strong>", true, true, 0);
html_end_box();
form_hidden_box("save_component_data","1","");
}
if (((isset($_GET["id"])) || (isset($_GET["new"]))) && (empty($data["data_template_id"]))) {
html_start_box("<strong>" . __("Data Source") . "</strong>", "100", $colors["header"], "3", "center", "");
$form_array = array();
$struct_data_source = data_source_form_list();
while (list($field_name, $field_array) = each($struct_data_source)) {
$form_array += array($field_name => $struct_data_source[$field_name]);
$form_array[$field_name]["value"] = (isset($data[$field_name]) ? $data[$field_name] : "");
$form_array[$field_name]["form_id"] = (empty($data["id"]) ? "0" : $data["id"]);
if (!(($use_data_template == false) || (!empty($data_template_data{"t_" . $field_name})) || ($field_array["flags"] == "NOTEMPLATE"))) {
$form_array[$field_name]["method"] = "template_" . $form_array[$field_name]["method"];
}
}
draw_edit_form(
array(
"config" => array("no_form_tag" => true),
"fields" => inject_form_variables($form_array, (isset($data) ? $data : array()))
)
);
html_end_box();
示例5: device_new_graphs
function device_new_graphs($device_id, $device_template_id, $selected_graphs_array) {
global $colors;
if (substr_count($_SERVER["REQUEST_URI"], "/devices.php")) {
$file = "devices.php?action=edit&tab=newgraphs&id=" . $_REQUEST["device_id"];
$file2 = "devices.php";
}else{
$file = "graphs_new.php?device_id=". $_REQUEST["device_id"];
$file2 = "graphs_new.php";
}
/* we use object buffering on this page to allow redirection to another page if no
fields are actually drawn */
ob_start();
include_once(CACTI_BASE_PATH . "/include/top_header.php");
print "<form action='" . $file2 . "' method='post'>\n";
$snmp_query_id = 0;
$num_output_fields = array();
while (list($form_type, $form_array) = each($selected_graphs_array)) {
while (list($form_id1, $form_array2) = each($form_array)) {
if ($form_type == "cg") {
$graph_template_id = $form_id1;
html_start_box("<strong>" . __("Create Graph from '%s'", db_fetch_cell("select name from graph_templates where id=$graph_template_id")), "100", $colors["header"], "3", "center", "");
}elseif ($form_type == "sg") {
while (list($form_id2, $form_array3) = each($form_array2)) {
/* ================= input validation ================= */
input_validate_input_number($snmp_query_id);
/* ==================================================== */
$snmp_query_id = $form_id1;
$snmp_query_graph_id = $form_id2;
$num_graphs = sizeof($form_array3);
$snmp_query = db_fetch_row("select
snmp_query.name,
snmp_query.xml_path
from snmp_query
where snmp_query.id=$snmp_query_id");
$graph_template_id = db_fetch_cell("select graph_template_id from snmp_query_graph where id=$snmp_query_graph_id");
}
/* DRAW: Data Query */
html_start_box("<strong>Create $num_graphs Graph" . (($num_graphs>1) ? "s" : "") . " from '" . db_fetch_cell("select name from snmp_query where id=$snmp_query_id") . "'", "100", $colors["header"], "3", "center", "");
}
/* ================= input validation ================= */
input_validate_input_number($graph_template_id);
/* ==================================================== */
$data_templates = db_fetch_assoc("select
data_template.name as data_template_name,
data_template_rrd.data_source_name,
data_template_data.*
from (data_template, data_template_rrd, data_template_data, graph_templates_item)
where graph_templates_item.task_item_id=data_template_rrd.id
and data_template_rrd.data_template_id=data_template.id
and data_template_data.data_template_id=data_template.id
and data_template_rrd.local_data_id=0
and data_template_data.local_data_id=0
and graph_templates_item.local_graph_id=0
and graph_templates_item.graph_template_id=" . $graph_template_id . "
group by data_template.id
order by data_template.name");
$graph_template = db_fetch_row("select
graph_templates.name as graph_template_name,
graph_templates_graph.*
from (graph_templates, graph_templates_graph)
where graph_templates.id=graph_templates_graph.graph_template_id
and graph_templates.id=" . $graph_template_id . "
and graph_templates_graph.local_graph_id=0");
$graph_template_name = db_fetch_cell("select name from graph_templates where id=" . $graph_template_id);
array_push($num_output_fields, draw_nontemplated_fields_graph($graph_template_id, $graph_template, "g_$snmp_query_id" . "_" . $graph_template_id . "_|field|", "<strong>Graph</strong> [Template: " . $graph_template["graph_template_name"] . "]", false, false, (isset($snmp_query_graph_id) ? $snmp_query_graph_id : 0)));
array_push($num_output_fields, draw_nontemplated_fields_graph_item($graph_template_id, 0, "gi_" . $snmp_query_id . "_" . $graph_template_id . "_|id|_|field|", "<strong>Graph Items</strong> [Template: " . $graph_template_name . "]", false));
/* DRAW: Data Sources */
if (sizeof($data_templates) > 0) {
foreach ($data_templates as $data_template) {
array_push($num_output_fields, draw_nontemplated_fields_data_source($data_template["data_template_id"], 0, $data_template, "d_" . $snmp_query_id . "_" . $graph_template_id . "_" . $data_template["data_template_id"] . "_|field|", "<strong>Data Source</strong> [Template: " . $data_template["data_template_name"] . "]", false, false, (isset($snmp_query_graph_id) ? $snmp_query_graph_id : 0)));
$data_template_items = db_fetch_assoc("select
data_template_rrd.*
from data_template_rrd
where data_template_rrd.data_template_id=" . $data_template["data_template_id"] . "
and local_data_id=0");
array_push($num_output_fields, draw_nontemplated_fields_data_source_item($data_template["data_template_id"], $data_template_items, "di_" . $snmp_query_id . "_" . $graph_template_id . "_" . $data_template["data_template_id"] . "_|id|_|field|", "", false, false, false, (isset($snmp_query_graph_id) ? $snmp_query_graph_id : 0)));
array_push($num_output_fields, draw_nontemplated_fields_custom_data($data_template["id"], "c_" . $snmp_query_id . "_" . $graph_template_id . "_" . $data_template["data_template_id"] . "_|id|", "<strong>Custom Data</strong> [Template: " . $data_template["data_template_name"] . "]", false, false, $snmp_query_id));
}
}
html_end_box();
}
//.........这里部分代码省略.........
示例6: ds_edit
function ds_edit()
{
global $struct_data_source, $struct_data_source_item, $data_source_types;
/* ================= input validation ================= */
input_validate_input_number(get_request_var_request('id'));
input_validate_input_number(get_request_var_request('host_id'));
/* ==================================================== */
api_plugin_hook('data_source_edit_top');
$use_data_template = true;
$host_id = 0;
if (!empty($_REQUEST['id'])) {
$data_local = db_fetch_row_prepared('SELECT host_id, data_template_id FROM data_local WHERE id = ?', array($_REQUEST['id']));
$data = db_fetch_row_prepared('SELECT * FROM data_template_data WHERE local_data_id = ?', array($_REQUEST['id']));
if (isset($data_local['data_template_id']) && $data_local['data_template_id'] >= 0) {
$data_template = db_fetch_row_prepared('SELECT id, name FROM data_template WHERE id = ?', array($data_local['data_template_id']));
$data_template_data = db_fetch_row_prepared('SELECT * FROM data_template_data WHERE data_template_id = ? AND local_data_id = 0', array($data_local['data_template_id']));
} else {
$_SESSION['sess_messages'] = 'Data Source "' . $_REQUEST['id'] . '" does not exist.';
header('Location: data_sources.php');
exit;
}
$header_label = '[edit: ' . htmlspecialchars(get_data_source_title($_REQUEST['id'])) . ']';
if (empty($data_local['data_template_id'])) {
$use_data_template = false;
}
} else {
$header_label = '[new]';
$use_data_template = false;
}
/* handle debug mode */
if (isset($_REQUEST['debug'])) {
if ($_REQUEST['debug'] == '0') {
kill_session_var('ds_debug_mode');
} elseif ($_REQUEST['debug'] == '1') {
$_SESSION['ds_debug_mode'] = true;
}
}
top_header();
if (!empty($_REQUEST['id'])) {
?>
<table width='100%' align='center'>
<tr>
<td class='textInfo' colspan='2' valign='top'>
<?php
print htmlspecialchars(get_data_source_title($_REQUEST['id']));
?>
</td>
<td class='textInfo' align='right' valign='top'>
<span class='linkMarker'>*<a href='<?php
print htmlspecialchars('data_sources.php?action=ds_edit&id=' . (isset($_REQUEST['id']) ? $_REQUEST['id'] : '0'));
?>
&debug=<?php
print isset($_SESSION['ds_debug_mode']) ? '0' : '1';
?>
'>Turn <strong><?php
print isset($_SESSION['ds_debug_mode']) ? 'Off' : 'On';
?>
</strong> Data Source Debug Mode.</a><br>
<?php
if (!empty($data_template['id'])) {
?>
<span class='linkMarker'>*<a href='<?php
print htmlspecialchars('data_templates.php?action=template_edit&id=' . (isset($data_template['id']) ? $data_template['id'] : '0'));
?>
'>Edit Data Template.</a><br><?php
}
if (!empty($_REQUEST['host_id']) || !empty($data_local['host_id'])) {
?>
<span class='linkMarker'>*<a href='<?php
print htmlspecialchars('host.php?action=edit&id=' . (isset($_REQUEST['host_id']) ? $_REQUEST['host_id'] : $data_local['host_id']));
?>
'>Edit Device.</a><br><?php
}
?>
</td>
</tr>
</table>
<br>
<?php
}
html_start_box("<strong>Data Template Selection</strong> {$header_label}", '100%', '', '3', 'center', '');
$form_array = array('data_template_id' => array('method' => 'drop_sql', 'friendly_name' => 'Selected Data Template', 'description' => 'The name given to this data template.', 'value' => isset($data_template) ? $data_template['id'] : '0', 'none_value' => 'None', 'sql' => 'SELECT id,name FROM data_template order by name'), 'host_id' => array('method' => 'drop_sql', 'friendly_name' => 'Device', 'description' => 'Choose the host that this graph belongs to.', 'value' => isset($_REQUEST['host_id']) ? $_REQUEST['host_id'] : $data_local['host_id'], 'none_value' => 'None', 'sql' => "SELECT id,CONCAT_WS('',description,' (',hostname,')') as name FROM host order by description,hostname"), '_data_template_id' => array('method' => 'hidden', 'value' => isset($data_template) ? $data_template['id'] : '0'), '_host_id' => array('method' => 'hidden', 'value' => empty($data_local['host_id']) ? isset($_REQUEST['host_id']) ? $_REQUEST['host_id'] : '0' : $data_local['host_id']), '_data_input_id' => array('method' => 'hidden', 'value' => isset($data['data_input_id']) ? $data['data_input_id'] : '0'), 'data_template_data_id' => array('method' => 'hidden', 'value' => isset($data) ? $data['id'] : '0'), 'local_data_template_data_id' => array('method' => 'hidden', 'value' => isset($data) ? $data['local_data_template_data_id'] : '0'), 'local_data_id' => array('method' => 'hidden', 'value' => isset($data) ? $data['local_data_id'] : '0'));
draw_edit_form(array('config' => array(), 'fields' => $form_array));
html_end_box();
/* only display the "inputs" area if we are using a data template for this data source */
if (!empty($data['data_template_id'])) {
$template_data_rrds = db_fetch_assoc_prepared('SELECT * FROM data_template_rrd WHERE local_data_id = ? ORDER BY data_source_name', array($_REQUEST['id']));
html_start_box('<strong>Supplemental Data Template Data</strong>', '100%', '', '3', 'center', '');
draw_nontemplated_fields_data_source($data['data_template_id'], $data['local_data_id'], $data, '|field|', '<strong>Data Source Fields</strong>', true, true, 0);
draw_nontemplated_fields_data_source_item($data['data_template_id'], $template_data_rrds, '|field|_|id|', '<strong>Data Source Item Fields</strong>', true, true, true, 0);
draw_nontemplated_fields_custom_data($data['id'], 'value_|id|', '<strong>Custom Data</strong>', true, true, 0);
form_hidden_box('save_component_data', '1', '');
html_end_box();
}
if ((isset($_REQUEST['id']) || isset($_REQUEST['new'])) && empty($data['data_template_id'])) {
html_start_box('<strong>Data Source</strong>', '100%', '', '3', 'center', '');
$form_array = array();
while (list($field_name, $field_array) = each($struct_data_source)) {
$form_array += array($field_name => $struct_data_source[$field_name]);
if (!($use_data_template == false || !empty($data_template_data['t_' . $field_name]) || $field_array['flags'] == 'NOTEMPLATE')) {
//.........这里部分代码省略.........