0) { foreach ($graph_templates as $graph_template) { if (!isset($_POST{"gt_" . $graph_template["id"]})) { /* this graph template does not exist as a POST var, therefore it is a stale entry. get rid of it. */ db_execute("delete from host_template_graph where graph_template_id=" . $graph_template["id"] . " and host_template_id=$host_template_id"); db_execute("delete from host_template_graph_sv where graph_template_id=" . $graph_template["id"] . " and host_template_id=$host_template_id"); db_execute("delete from host_template_data_sv where graph_template_id=" . $graph_template["id"] . " and host_template_id=$host_template_id"); } } } while (list($var, $val) = each($_POST)) { if (eregi("^gt_", $var)) { db_execute ("replace into host_template_graph (host_template_id,graph_template_id) values($host_template_id," . substr($var, 3) . ")"); }elseif (eregi("^sq_", $var)) { db_execute ("replace into host_template_snmp_query (host_template_id,snmp_query_id) values($host_template_id," . substr($var, 3) . ")"); }elseif ((eregi("^svds_([0-9]+)_([0-9]+)_x", $var, $matches)) && (!empty($_POST{"svds_" . $matches[1] . "_" . $matches[2] . "_text"})) && (!empty($_POST{"svds_" . $matches[1] . "_" . $matches[2] . "_field"}))) { /* suggested values -- data templates */ db_execute("insert into host_template_data_sv (host_template_id,data_template_id,graph_template_id,field_name,text) values (" . $_POST["id"] . "," . $matches[2] . "," . $matches[1] . ",'" . $_POST{"svds_" . $matches[1] . "_" . $matches[2] . "_field"} . "','" . $_POST{"svds_" . $matches[1] . "_" . $matches[2] . "_text"} . "')"); $redirect_back = true; clear_messages(); }elseif ((eregi("^svg_([0-9]+)_x", $var, $matches)) && (!empty($_POST{"svg_" . $matches[1] . "_text"})) && (!empty($_POST{"svg_" . $matches[1] . "_field"}))) { /* suggested values -- graph templates */ db_execute("insert into host_template_graph_sv (host_template_id,graph_template_id,field_name,text) values (" . $_POST["id"] . "," . $matches[1] . ",'" . $_POST{"svg_" . $matches[1] . "_field"} . "','" . $_POST{"svg_" . $matches[1] . "_text"} . "')"); $redirect_back = true; clear_messages(); } } }else{ raise_message(2); } } if ((is_error_message()) || (empty($_POST["id"])) || ($redirect_back == true)) { header ("Location: host_templates.php?action=edit&id=" . (empty($host_template_id) ? $_POST["id"] : $host_template_id)); }else{ header ("Location: host_templates.php"); } } } /* --------------------- Template Functions --------------------- */ function template_item_remove_gsv() { db_execute("delete from host_template_graph_sv where host_template_id=" . $_GET["host_template_id"] . " and graph_template_id=" . $_GET["graph_template_id"] . " and field_name='" . $_GET["field_name"] . "'"); } function template_item_remove_dssv() { db_execute("delete from host_template_data_sv where host_template_id=" . $_GET["host_template_id"] . " and data_template_id=" . $_GET["data_template_id"] . " and graph_template_id=" . $_GET["graph_template_id"] . " and field_name='" . $_GET["field_name"] . "'"); } function template_remove() { if ((read_config_option("remove_verification") == "on") && (!isset($_GET["confirm"]))) { include ('include/top_header.php'); form_confirm("Are You Sure?", "Are you sure you want to delete the host template '" . db_fetch_cell("select name from host_template where id=" . $_GET["id"]) . "'?", $_SERVER["HTTP_REFERER"], "host_templates.php?action=remove&id=" . $_GET["id"]); include ('include/bottom_footer.php'); exit; } if ((read_config_option("remove_verification") == "") || (isset($_GET["confirm"]))) { db_execute("delete from host_template where id=" . $_GET["id"]); db_execute("delete from host_template_snmp_query where host_template_id=" . $_GET["id"]); db_execute("delete from host_template_graph_template where host_template_id=" . $_GET["id"]); db_execute("delete from host_template_data_template where host_template_id=" . $_GET["id"]); } } function template_edit() { global $colors; display_output_messages(); if (!empty($_GET["id"])) { $host_template = db_fetch_row("select * from host_template where id=" . $_GET["id"]); $header_label = "[edit: " . $host_template["name"] . "]"; }else{ $header_label = "[new]"; $_GET["id"] = 0; } start_box("Host Templates $header_label", "98%", $colors["header"], "3", "center", ""); ?>
Name
A useful name for this host template. Associated Graph Templates
Select one or more graph templates to associate with this host template.
0) { foreach($graph_templates as $graph_template) { $column1 = floor((sizeof($graph_templates) / 2) + (sizeof($graph_templates) % 2)); if (empty($graph_template["host_template_id"])) { $old_value = ""; }else{ $old_value = "on"; } if ($i == $column1) { print ""; } form_base_checkbox("gt_".$graph_template["id"], $old_value, $graph_template["name"], "",$_GET["id"],true); $i++; } } ?>
Associated SNMP Queries
Select one or more SNMP queries to associate with this host template.
0) { foreach($snmp_queries as $snmp_query) { $column1 = floor((sizeof($snmp_queries) / 2) + (sizeof($snmp_queries) % 2)); if (empty($snmp_query["host_template_id"])) { $old_value = ""; }else{ $old_value = "on"; } if ($i == $column1) { print ""; } form_base_checkbox("sq_".$snmp_query["id"], $old_value, $snmp_query["name"], "",$_GET["id"],true); $i++; } } ?>
0) { foreach($graph_templates as $graph_template) { if (!empty($graph_template["host_template_id"])) { $data_templates = db_fetch_assoc("select data_template.id, data_template.name from data_template, data_template_rrd, 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_rrd.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"); start_box("Suggested Values - " . $graph_template["name"], "98%", $colors["header"], "3", "center", ""); /* suggested values for data templates */ if (sizeof($data_templates) > 0) { foreach ($data_templates as $data_template) { $suggested_values = db_fetch_assoc("select text, field_name from host_template_data_sv where host_template_id=" . $_GET["id"] . " and graph_template_id=" . $graph_template["id"] . " and data_template_id=" . $data_template["id"] . " order by field_name"); print " Data Template - " . $data_template["name"] . " "; $i = 0; if (sizeof($suggested_values) > 0) { foreach ($suggested_values as $suggested_value) { form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i); $i++; ?>
&field_name=&graph_template_id=&data_template_id=">Delete 
__text" size="30">  Field Name: __field" size="15">  _" alt="Add" align="absmiddle">
Graph Template - " . $graph_template["name"] . " "; $i = 0; if (sizeof($suggested_values) > 0) { foreach ($suggested_values as $suggested_value) { form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i); $i++; ?>
&graph_template_id=&field_name=">Delete 
_text" size="30">  Field Name: _field" size="15">  " alt="Add" align="absmiddle">
Host Templates", "98%", $colors["header"], "3", "center", "host_templates.php?action=edit"); print ""; DrawMatrixHeaderItem("Template Title",$colors["header_text"],1); DrawMatrixHeaderItem(" ",$colors["header_text"],1); print ""; $host_templates = db_fetch_assoc("select * from host_template order by name"); $i = 0; if (sizeof($host_templates) > 0) { foreach ($host_templates as $host_template) { form_alternate_row_color($colors["alternate"],$colors["light"],$i); $i++; ?> "> ">Delete  No Host Templates\n"; } end_box(); } ?>