Beruflich Dokumente
Kultur Dokumente
php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2007 The Cacti Group
|
|
|
| This program is free software; you can redistribute it and/or
|
| modify it under the terms of the GNU General Public License
|
| as published by the Free Software Foundation; either version 2
|
| of the License, or (at your option) any later version.
|
|
|
| This program is distributed in the hope that it will be useful,
|
| but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| GNU General Public License for more details.
|
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDTool-based Graphing Solution
|
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/
|
+-------------------------------------------------------------------------+
*/
chdir('../../');
include("./include/auth.php");
include_once("./lib/utility.php");
$host_actions = array(
1 => "Delete"
);
/* set default action */
if (!isset($_REQUEST["action"])) { $_REQUEST["action"] = ""; }
switch ($_REQUEST["action"]) {
case 'save':
form_save();
break;
case 'actions':
form_actions();
break;
case 'edit':
include_once("./include/top_header.php");
template_edit();
include_once("./include/bottom_footer.php");
break;
default:
include_once("./include/top_header.php");
template();
include_once("./include/bottom_footer.php");
break;
}
</td>
</tr>
";
html_end_box();
include_once("./include/bottom_footer.php");
}
/* --------------------Template Functions
--------------------- */
function discover_get_tree_headers() {
$headers = array();
$trees = db_fetch_assoc("SELECT id, name FROM graph_tree ORDER by ID");
foreach ($trees as $tree) {
$headers[($tree['id'] + 1000000)] = $tree['name'];
$items = db_fetch_assoc("SELECT id, title, order_key FROM graph_
tree_items WHERE graph_tree_id = " . $tree['id'] . " AND host_id = 0 ORDER BY or
der_key");
foreach ($items as $item) {
$order_key = $item['order_key'];
$len = strlen($order_key);
$spaces = '';
for ($a = 0; $a < $len; $a=$a+3) {
$n = substr($order_key, $a, 3);
if ($n != '000') {
$spaces .= '--';
} else {
$a = $len;
}
}
$headers[$item['id']] = $spaces . $item['title'];
}
}
return $headers;
}
function template_edit() {
global $colors, $snmp_versions;
$host_template_names = db_fetch_assoc("SELECT id, name FROM host_templat
e");
$template_names = array();
if (sizeof($host_template_names) > 0) {
foreach ($host_template_names as $ht) {
$template_names[$ht['id']] = $ht['name'];
}
}
$fields_discover_template_edit = array(
"host_template" => array(
"method" => "drop_array",
"friendly_name" => "Host Template",
"description" => "Select a Host Template that Devices wi
ll be matched to.",
"value" => "|arg1:host_template|",
));
html_end_box();
form_save_button("discover_template.php");
}
function template() {
global $colors, $host_actions;
/* clean up sort_column */
if (isset($_REQUEST["sort_column"])) {
$_REQUEST["sort_column"] = sanitize_search_string(get_request_va
r("sort_column"));
}
/* clean up search string */
if (isset($_REQUEST["sort_direction"])) {
$_REQUEST["sort_direction"] = sanitize_search_string(get_request
_var("sort_direction"));
}
/* remember these search fields in session vars so we don't have to keep
passing them around */
load_current_session_value("sort_column", "sess_discover_template_column
", "name");
load_current_session_value("sort_direction", "sess_discover_template_sor
t_direction", "ASC");
display_output_messages();
html_start_box("<strong>Network Discovery Templates</strong>", "100%", $
colors["header"], "3", "center", "discover_template.php?action=edit");
$display_text = array(
"name" => array("Template Title", "ASC"),
"sysdescr" => array("System Description", "ASC"));
html_header_sort_checkbox($display_text, $_REQUEST["sort_column"], $_REQ
UEST["sort_direction"]);
$dts = db_fetch_assoc("SELECT plugin_discover_template.*, host_template.
name
FROM plugin_discover_template LEFT JOIN host_template on (host_t
emplate.id = plugin_discover_template.host_template)
ORDER BY " . $_REQUEST['sort_column'] . " " . $_REQUEST['sort_di
rection']);
$i = 0;
if (sizeof($dts)) {
foreach ($dts as $dt) {
form_alternate_row_color($colors["alternate"], $colors["
light"], $i, "line" . $dt["id"]); $i++;
form_selectable_cell('<a class="linkEditMain" href="disc
over_template.php?action=edit&id=' . $dt["id"] . '">' . $dt['name'] . '</a>', $d
t["id"]);
form_selectable_cell($dt["sysdescr"], $dt["id"]);
form_checkbox_cell($dt["sysdescr"], $dt["id"]);
form_end_row();
}
}else{
print "<tr><td><em>No Templates</em></td></tr>\n";
}
html_end_box(false);
/* draw the dropdown containing a list of available actions for this for
m */
draw_actions_dropdown($host_actions);
print "</form>\n";
}
?>