/* +-------------------------------------------------------------------------+ | 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'); header("Cache-control: no-cache"); include_once ("include/functions.php"); include_once ("include/cdef_functions.php"); include_once ("include/config_arrays.php"); include_once ('include/form.php'); if (isset($form[action])) { $action = $form[action]; } else { $action = $args[action]; } if (isset($form[ID])) { $id = $form[ID]; } else { $id = $args[id]; } switch ($action) { case 'save': $redirect_location = form_save(); header ("Location: $redirect_location"); exit; break; case 'remove': host_remove(); header ("Location: host.php"); break; case 'edit': include_once ("include/top_header.php"); host_edit(); include_once ("include/bottom_footer.php"); break; default: include_once ("include/top_header.php"); host(); include_once ("include/bottom_footer.php"); break; } /* -------------------------- The Save Function -------------------------- */ function form_save() { global $form; if (isset($form[save_component_host])) { host_save(); return "host.php"; } } /* --------------------- CDEF Functions --------------------- */ function host_remove() { global $args, $config; if (($config["remove_verification"]["value"] == "on") && ($args[confirm] != "yes")) { include ('include/top_header.php'); DrawConfirmForm("Are You Sure?", "Are you sure you want to delete the host '" . db_fetch_cell("select description from host where id=$args[id]") . "'?", getenv("HTTP_REFERER"), "host.php?action=remove&id=$args[id]"); include ('include/bottom_footer.php'); exit; } if (($config["remove_verification"]["value"] == "") || ($args[confirm] == "yes")) { db_execute("delete from host where id=$args[id]"); } } function host_save() { global $form; $save["id"] = $form["id"]; $save["host_template_id"] = $form["host_template_id"]; $save["description"] = $form["description"]; $save["hostname"] = $form["hostname"]; $save["management_ip"] = $form["management_ip"]; $save["snmp_community"] = $form["snmp_community"]; $save["snmp_version"] = $form["snmp_version"]; $save["snmp_username"] = $form["snmp_username"]; $save["snmp_password"] = $form["snmp_password"]; if (sql_save($save, "host")) { raise_message(1); }else{ raise_message(2); header("Location: " . $_SERVER["HTTP_REFERER"]); exit; } } function host_edit() { global $args, $colors, $snmp_versions; display_output_messages(); start_box("Polling Hosts [edit]", "", ""); if (isset($args[id])) { $host = db_fetch_row("select * from host where id=$args[id]"); }else{ unset($host); } ?>
end_box(); } function host() { global $colors; display_output_messages(); start_box("Polling Hosts", "", "host.php?action=edit"); print "