/* +-------------------------------------------------------------------------+ | Copyright (C) 2002 Ian Berry | | | | 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 rrdtool frontend [php-auth, php-tree, php-form] | +-------------------------------------------------------------------------+ | This code is currently maintained and debugged by Ian Berry, any | | questions or comments regarding this code should be directed to: | | - iberry@raxnet.net | +-------------------------------------------------------------------------+ | - raXnet - http://www.raxnet.net/ | +-------------------------------------------------------------------------+ */?> $section = "Add/Edit Graphs"; include ('include/auth.php'); include_once ('include/form.php'); include_once ('include/functions.php'); switch ($_REQUEST["action"]) { case 'save': $redirect_location = form_save(); header ("Location: $redirect_location"); exit; break; case 'item_movedown': item_movedown(); header ("Location: " . getenv("HTTP_REFERER")); break; case 'item_moveup': item_moveup(); header ("Location: " . getenv("HTTP_REFERER")); break; case 'item_edit': include_once ("include/top_header.php"); item_edit(); include_once ("include/bottom_footer.php"); break; case 'item_remove': item_remove(); header ("Location: " . getenv("HTTP_REFERER")); break; case 'remove': tree_remove(); header ("Location: tree.php"); break; case 'edit': include_once ("include/top_header.php"); tree_edit(); include_once ("include/bottom_footer.php"); break; default: include_once ("include/top_header.php"); tree(); include_once ("include/bottom_footer.php"); break; } /* -------------------------- The Save Function -------------------------- */ function form_save() { if (isset($_POST["save_component_tree"])) { tree_save(); return "tree.php"; }elseif (isset($_POST["save_component_tree_item"])) { item_save(); return "tree.php?action=edit&id=" . $_POST["tree_id"]; } } /* ----------------------- Tree Item Functions ----------------------- */ function item_edit() { global $colors, $cdef_item_types; if (isset($_GET["tree_item_id"])) { $tree_item = db_fetch_row("select * from graph_tree_view_items where id=" . $_GET["tree_item_id"]); }else{ unset($tree_item); } /* bold the active "type" */ if ($tree_item["graph_id"] > 0) { $title = "Tree Item [graph]"; }else{ $title = "Tree Item [graph]"; } start_box($title, "98%", $colors["header"], "3", "center", ""); ?>
end_box(); } function item_moveup() { include_once('include/tree_functions.php'); $order_key = db_fetch_cell("SELECT order_key FROM graph_tree_view_items WHERE id=" . $_GET["tree_item_id"]); if ($order_key > 0) { branch_up($order_key, 'graph_tree_view_items', 'order_key', ''); } } function item_movedown() { include_once('include/tree_functions.php'); $order_key = db_fetch_cell("SELECT order_key FROM graph_tree_view_items WHERE id=" . $_GET["tree_item_id"]); if ($order_key > 0) { branch_down($order_key, 'graph_tree_view_items', 'order_key', ''); } } function item_save() { $save["id"] = $_POST["id"]; $save["tree_id"] = $_POST["tree_id"]; $save["title"] = $_POST["title"]; $save["order_key"] = $_POST["order_key"]; $save["graph_id"] = $_POST["graph_id"]; $save["rra_id"] = $_POST["rra_id"]; if (sql_save($save, "graph_tree_view_items")) { raise_message(1); }else{ raise_message(2); header("Location: " . $_SERVER["HTTP_REFERER"]); exit; } } function item_remove() { global $config; if ((read_config_option("remove_verification") == "on") && ($_GET["confirm"] != "yes")) { include ('include/top_header.php'); DrawConfirmForm("Are You Sure?", "Are you sure you want to delete the item '" . db_fetch_cell("select title from graph_tree_view_items where id=" . $_GET["id"]) . "'?", getenv("HTTP_REFERER"), "tree.php?action=item_remove&id=" . $_GET["id"] . "&tree_id=" . $_GET["tree_id"]); include ('include/bottom_footer.php'); exit; } if ((read_config_option("remove_verification") == "") || ($_GET["confirm"] == "yes")) { db_execute("delete from graph_tree_view_items where id=" . $_GET["id"]); } header("Location: tree.php?action=edit&id=" . $_GET["tree_id"]); exit; } /* --------------------- Tree Functions --------------------- */ function tree_save() { $save["id"] = $_POST["id"]; $save["name"] = $_POST["name"]; if (sql_save($save, "graph_tree_view")) { raise_message(1); }else{ raise_message(2); header("Location: " . $_SERVER["HTTP_REFERER"]); exit; } } function tree_remove() { global $config; if ((read_config_option("remove_verification") == "on") && ($_GET["confirm"] != "yes")) { include ('include/top_header.php'); DrawConfirmForm("Are You Sure?", "Are you sure you want to delete the tree '" . db_fetch_cell("select name from graph_tree_view where id=" . $_GET["id"]) . "'?", getenv("HTTP_REFERER"), "tree.php?action=remove&id=" . $_GET["id"]); include ('include/bottom_footer.php'); exit; } if ((read_config_option("remove_verification") == "") || ($_GET["confirm"] == "yes")) { db_execute("delete from graph_tree_view where id=" . $_GET["id"]); } } function tree_edit() { include_once("include/tree_view_functions.php"); global $colors, $cdef_item_types; start_box("Trees [edit]", "98%", $colors["header"], "3", "center", ""); if (isset($_GET["id"])) { $tree = db_fetch_row("select * from graph_tree_view where id=" . $_GET["id"]); }else{ unset($tree); } ?> end_box(); } function tree() { global $colors; start_box("Graph Trees", "98%", $colors["header"], "3", "center", "tree.php?action=edit"); print "