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", ""); ?>