function form_save() { /* save the poller */ if (isset($_POST["save_component_poller"])) { $save["id"] = $_POST["id"]; $save["disabled"] = form_input_validate((isset($_POST["disabled"]) ? get_request_var_post("disabled"):""), "disabled", "", true, 3); $save["description"] = form_input_validate(get_request_var_post("description"), "description", "", false, 3); $save["hostname"] = form_input_validate(get_request_var_post("hostname"), "hostname", "", true, 3); $save["ip_address"] = form_input_validate(get_request_var_post("ip_address"), "ip_address", "", true, 3); if (!is_error_message()) { $poller_id = sql_save($save, "poller"); if ($poller_id) { raise_message(1); }else{ raise_message(2); } } if (is_error_message()) { header("Location: pollers.php?action=edit&id=" . (empty($poller_id) ? $_POST["id"] : $poller_id)); }else{ header("Location: pollers.php"); } exit; } }
function form_save() { if (isset($_POST["save_component_rra"])) { $save["id"] = $_POST["id"]; $save["hash"] = get_hash_round_robin_archive($_POST["id"]); $save["name"] = form_input_validate($_POST["name"], "name", "", false, 3); $save["x_files_factor"] = form_input_validate($_POST["x_files_factor"], "x_files_factor", "^[0-9]+(\\.[0-9])?\$", false, 3); $save["steps"] = form_input_validate($_POST["steps"], "steps", "^[0-9]*\$", false, 3); $save["rows"] = form_input_validate($_POST["rows"], "rows", "^[0-9]*\$", false, 3); $save["timespan"] = form_input_validate($_POST["timespan"], "timespan", "^[0-9]*\$", false, 3); if (!is_error_message()) { $rra_id = sql_save($save, "rra"); if ($rra_id) { raise_message(1); db_execute("delete from rra_cf where rra_id={$rra_id}"); if (isset($_POST["consolidation_function_id"])) { for ($i = 0; $i < count($_POST["consolidation_function_id"]); $i++) { /* ================= input validation ================= */ input_validate_input_number($_POST["consolidation_function_id"][$i]); /* ==================================================== */ db_execute("insert into rra_cf (rra_id,consolidation_function_id)\n\t\t\t\t\t\t\tvalues ({$rra_id}," . $_POST["consolidation_function_id"][$i] . ")"); } } } else { raise_message(2); } } if (is_error_message()) { header("Location: rra.php?action=edit&id=" . (empty($rra_id) ? $_POST["id"] : $rra_id)); } else { header("Location: rra.php"); } } }
function form_save() { /* ================= input validation ================= */ input_validate_input_number(get_request_var_post('host_template_id')); input_validate_input_number(get_request_var_post('snmp_query_id')); input_validate_input_number(get_request_var_post('graph_template_id')); /* ==================================================== */ if (isset($_POST['save_component_template'])) { $redirect_back = false; $save['id'] = $_POST['id']; $save['hash'] = get_hash_host_template($_POST['id']); $save['name'] = form_input_validate($_POST['name'], 'name', '', false, 3); if (!is_error_message()) { $host_template_id = sql_save($save, 'host_template'); if ($host_template_id) { raise_message(1); if (isset($_POST['add_gt_x'])) { db_execute_prepared('REPLACE INTO host_template_graph (host_template_id, graph_template_id) VALUES (?, ?)', array($host_template_id, $_POST['graph_template_id'])); $redirect_back = true; } elseif (isset($_POST['add_dq_x'])) { db_execute_prepared('REPLACE INTO host_template_snmp_query (host_template_id, snmp_query_id) VALUES (?, ?)', array($host_template_id, $_POST['snmp_query_id'])); $redirect_back = true; } } else { raise_message(2); } } header('Location: host_templates.php?action=edit&id=' . (empty($host_template_id) ? $_POST['id'] : $host_template_id)); } }
function form_save() { if (isset($_POST["save_component_gprint_presets"])) { $save["id"] = $_POST["id"]; $save["hash"] = get_hash_gprint($_POST["id"]); $save["name"] = form_input_validate($_POST["name"], "name", "", false, 3); $save["gprint_text"] = form_input_validate($_POST["gprint_text"], "gprint_text", "", false, 3); if (!is_error_message()) { $gprint_preset_id = sql_save($save, "graph_templates_gprint"); if ($gprint_preset_id) { raise_message(1); }else{ raise_message(2); } } if (is_error_message()) { header("Location: gprint_presets.php?action=edit&id=" . (empty($gprint_preset_id) ? $_POST["id"] : $gprint_preset_id)); exit; }else{ header("Location: gprint_presets.php"); exit; } } }
function form_save() { if (isset($_POST["save_component_template"])) { $redirect_back = false; $save["id"] = $_POST["id"]; $save["hash"] = get_hash_host_template($_POST["id"]); $save["name"] = form_input_validate($_POST["name"], "name", "", false, 3); if (!is_error_message()) { $host_template_id = sql_save($save, "host_template"); if ($host_template_id) { raise_message(1); if (isset($_POST["add_gt_x"])) { db_execute("replace into host_template_graph (host_template_id,graph_template_id) values($host_template_id," . $_POST["graph_template_id"] . ")"); $redirect_back = true; }elseif (isset($_POST["add_dq_x"])) { db_execute("replace into host_template_snmp_query (host_template_id,snmp_query_id) values($host_template_id," . $_POST["snmp_query_id"] . ")"); $redirect_back = true; } }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"); } } }
function form_save() { /* modify for multi user start */ /* ================= input validation ================= */ input_validate_input_number(get_request_var_post("id")); /* ==================================================== */ if (!check_notification($_REQUEST['id'])) { access_denied(); } /* modify for multi user end */ if (isset($_POST["save_component"])) { $save["id"] = $_POST["id"]; $save["name"] = form_input_validate($_POST["name"], "name", "", false, 3); $save["description"] = form_input_validate($_POST["description"], "description", "", false, 3); $save["emails"] = form_input_validate($_POST["emails"], "emails", "", false, 3); if (!is_error_message()) { $id = sql_save($save, "plugin_notification_lists"); if ($id) { raise_message(1); } else { raise_message(2); } } } header("Location: notify_lists.php?action=edit&id=" . (empty($id) ? $_POST["id"] : $id)); }
function api_package_field_validate(&$_fields_package, $package_field_name_format = "|field|") { require_once(CACTI_BASE_PATH . "/lib/package/package_info.php"); if (sizeof($_fields_package) == 0) { return array(); } /* array containing errored fields */ $error_fields = array(); /* get a complete field list */ $fields_package = api_package_form_list(); /* base fields */ while (list($_field_name, $_field_array) = each($fields_package)) { if ((isset($_fields_package[$_field_name])) && (isset($_field_array["validate_regexp"])) && (isset($_field_array["validate_empty"]))) { $form_field_name = str_replace("|field|", $_field_name, $package_field_name_format); if (!form_input_validate($_fields_package[$_field_name], $form_field_name, $_field_array["validate_regexp"], $_field_array["validate_empty"])) { $error_fields[] = $form_field_name; } } } return $error_fields; }
function form_save() { /* clear graph tree cache on save - affects current user only, other users should see changes in <5 minutes */ if (isset($_SESSION['dhtml_tree'])) { unset($_SESSION['dhtml_tree']); } if (isset($_POST["save_component_tree"])) { $save["id"] = $_POST["id"]; $save["name"] = form_input_validate($_POST["name"], "name", "", false, 3); $save["sort_type"] = form_input_validate($_POST["sort_type"], "sort_type", "", true, 3); if (!is_error_message()) { $tree_id = sql_save($save, "graph_tree"); if ($tree_id) { raise_message(1); /* sort the tree using the algorithm chosen by the user */ sort_tree(SORT_TYPE_TREE, $tree_id, $_POST["sort_type"]); } else { raise_message(2); } } if (is_error_message() || empty($_POST["id"])) { header("Location: tree.php?action=edit&id=" . (empty($tree_id) ? $_POST["id"] : $tree_id)); } else { header("Location: tree.php"); } } elseif (isset($_POST["save_component_tree_item"])) { $tree_item_id = api_tree_item_save($_POST["id"], $_POST["graph_tree_id"], $_POST["type"], $_POST["parent_item_id"], isset($_POST["title"]) ? $_POST["title"] : "", isset($_POST["local_graph_id"]) ? $_POST["local_graph_id"] : "0", isset($_POST["rra_id"]) ? $_POST["rra_id"] : "0", isset($_POST["host_id"]) ? $_POST["host_id"] : "0", isset($_POST["host_grouping_type"]) ? $_POST["host_grouping_type"] : "1", isset($_POST["sort_children_type"]) ? $_POST["sort_children_type"] : "1", isset($_POST["propagate_changes"]) ? true : false); if (is_error_message()) { header("Location: tree.php?action=item_edit&tree_item_id=" . (empty($tree_item_id) ? $_POST["id"] : $tree_item_id) . "&tree_id=" . $_POST["graph_tree_id"] . "&parent_id=" . $_POST["parent_item_id"]); } else { header("Location: tree.php?action=edit&id=" . $_POST["graph_tree_id"]); } } }
function xaxis_form_save() { if (isset($_POST["save_component_xaxis"])) { $save["id"] = $_POST["id"]; $save["hash"] = get_hash_xaxis($_POST["id"]); $save["name"] = form_input_validate($_POST["name"], "name", "", false, 3); if (!is_error_message()) { $xaxis_id = sql_save($save, "graph_templates_xaxis"); if ($xaxis_id) { raise_message(1); }else{ raise_message(2); } } if ((is_error_message()) || (empty($_POST["id"]))) { header("Location: xaxis_presets.php?action=edit&id=" . (empty($xaxis_id) ? $_POST["id"] : $xaxis_id)); }else{ header("Location: xaxis_presets.php"); } exit; } if ((isset($_POST["save_component_item"]))) { $save["id"] = $_POST["id"]; $save["hash"] = get_hash_xaxis($_POST["id"], "xaxis_item"); $save["item_name"] = form_input_validate($_POST["item_name"], "item_name", "", true, 3); $save["xaxis_id"] = form_input_validate($_POST["xaxis_id"], "xaxis_id", "^[0-9]+$", false, 3); $save["timespan"] = form_input_validate($_POST["timespan"], "timespan", "^[0-9]+$", false, 3); $save["gtm"] = form_input_validate($_POST["gtm"], "gtm", "", false, 3); $save["gst"] = form_input_validate($_POST["gst"], "gst", "^[0-9]+$", false, 3); $save["mtm"] = form_input_validate($_POST["mtm"], "mtm", "", false, 3); $save["mst"] = form_input_validate($_POST["mst"], "mst", "^[0-9]+$", false, 3); $save["ltm"] = form_input_validate($_POST["ltm"], "ltm", "", false, 3); $save["lst"] = form_input_validate($_POST["lst"], "lst", "^[0-9]+$", false, 3); $save["lpr"] = form_input_validate($_POST["lpr"], "lpr", "^[0-9]+$", false, 3); $save["lfm"] = form_input_validate($_POST["lfm"], "lfm", "", true, 3); if (!is_error_message()) { $xaxis_item_id = sql_save($save, "graph_templates_xaxis_items"); if ($xaxis_item_id) { raise_message(1); }else{ raise_message(2); } } if ((is_error_message()) || (empty($_POST["id"]))) { header("Location: xaxis_presets.php?action=item_edit&xaxis_id=" . $_POST["xaxis_id"] . "&id=" . (empty($xaxis_item_id) ? $_POST["id"] : $xaxis_item_id)); }else{ header("Location: xaxis_presets.php?action=edit&id=" . (!empty($_POST["xaxis_id"]) ? $_POST["xaxis_id"] : 0)); } exit; } }
function form_save() { if (isset($_POST["save_component_input"]) && !is_error_message()) { $graph_input_values = array(); $selected_graph_items = array(); $save["id"] = $_POST["graph_template_input_id"]; $save["hash"] = get_hash_graph_template($_POST["graph_template_input_id"], "graph_template_input"); $save["graph_template_id"] = $_POST["graph_template_id"]; $save["name"] = form_input_validate($_POST["name"], "name", "", false, 3); $save["description"] = form_input_validate($_POST["description"], "description", "", true, 3); $save["column_name"] = form_input_validate($_POST["column_name"], "column_name", "", true, 3); if (!is_error_message()) { $graph_template_input_id = sql_save($save, "graph_template_input"); if ($graph_template_input_id) { raise_message(1); /* list all graph items from the db so we can compare them with the current form */ $db_selected_graph_item = array_rekey(db_fetch_assoc("select graph_template_item_id from graph_template_input_defs where graph_template_input_id={$graph_template_input_id}"), "graph_template_item_id", "graph_template_item_id"); /* list all select graph items for use down below */ while (list($var, $val) = each($_POST)) { if (preg_match("/^i_(\\d+)\$/", $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ $selected_graph_items[$matches[1]] = $matches[1]; if (isset($db_selected_graph_item[$matches[1]])) { /* is selected and exists in the db; old item */ $old_members[$matches[1]] = $matches[1]; } else { /* is selected and does not exist the db; new item */ $new_members[$matches[1]] = $matches[1]; } } } if (isset($new_members) && sizeof($new_members) > 0) { while (list($item_id, $item_id) = each($new_members)) { push_out_graph_input($graph_template_input_id, $item_id, isset($new_members) ? $new_members : array()); } } db_execute("delete from graph_template_input_defs where graph_template_input_id={$graph_template_input_id}"); if (sizeof($selected_graph_items) > 0) { foreach ($selected_graph_items as $graph_template_item_id) { db_execute("insert into graph_template_input_defs (graph_template_input_id,graph_template_item_id)\n\t\t\t\t\t\tvalues ({$graph_template_input_id},{$graph_template_item_id})"); } } } else { raise_message(2); } } if (is_error_message()) { header("Location: graph_templates_inputs.php?action=input_edit&graph_template_input_id=" . (empty($graph_template_input_id) ? $_POST["graph_template_input_id"] : $graph_template_input_id) . "&graph_template_id=" . $_POST["graph_template_id"]); exit; } else { header("Location: graph_templates.php?action=template_edit&id=" . $_POST["graph_template_id"]); exit; } } }
function api_mactrack_device_save($device_id, $host_id, $site_id, $hostname, $device_name, $scan_type, $snmp_options, $snmp_readstring, $snmp_version, $snmp_username, $snmp_password, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_port, $snmp_timeout, $snmp_retries, $max_oids, $ignorePorts, $notes, $user_name, $user_password, $term_type, $private_key_path, $disabled) { global $config; include_once($config["base_path"] . "/plugins/mactrack/lib/mactrack_functions.php"); $save["device_id"] = $device_id; $save["host_id"] = $host_id; $save["site_id"] = $site_id; $save["hostname"] = form_input_validate($hostname, "hostname", "", false, 3); $save["device_name"] = form_input_validate($device_name, "device_name", "", false, 3); $save["notes"] = form_input_validate($notes, "notes", "", true, 3); $save["scan_type"] = form_input_validate($scan_type, "scan_type", "", false, 3); $save["snmp_options"] = form_input_validate($snmp_options, "snmp_options", "^[0-9]+$", true, 3); $save["snmp_readstring"] = form_input_validate($snmp_readstring, "snmp_readstring", "", true, 3); # for SNMP V3, this is optional $save["snmp_version"] = form_input_validate($snmp_version, "snmp_version", "", false, 3); $save["snmp_username"] = form_input_validate($snmp_username, "snmp_username", "", true, 3); $save["snmp_password"] = form_input_validate($snmp_password, "snmp_password", "", true, 3); $save["snmp_auth_protocol"] = form_input_validate($snmp_auth_protocol, "snmp_auth_protocol", "", true, 3); $save["snmp_priv_passphrase"] = form_input_validate($snmp_priv_passphrase, "snmp_priv_passphrase", "", true, 3); $save["snmp_priv_protocol"] = form_input_validate($snmp_priv_protocol, "snmp_priv_protocol", "", true, 3); $save["snmp_context"] = form_input_validate($snmp_context, "snmp_context", "", true, 3); $save["snmp_port"] = form_input_validate($snmp_port, "snmp_port", "^[0-9]+$", false, 3); $save["snmp_timeout"] = form_input_validate($snmp_timeout, "snmp_timeout", "^[0-9]+$", false, 3); $save["snmp_retries"] = form_input_validate($snmp_retries, "snmp_retries", "^[0-9]+$", false, 3); $save["max_oids"] = form_input_validate($max_oids, "max_oids", "^[0-9]+$", false, 3); $save["user_name"] = form_input_validate($user_name, "user_name", "", true, 3); $save["user_password"] = form_input_validate($user_password, "user_password", "", true, 3); $save["ignorePorts"] = form_input_validate($ignorePorts, "ignorePorts", "", true, 3); $save["term_type"] = form_input_validate($term_type, "term_type", "", true, 3); $save["private_key_path"] = form_input_validate($private_key_path, "private_key_path", "", true, 3); $save["disabled"] = form_input_validate($disabled, "disabled", "", true, 3); $device_id = 0; if (!is_error_message()) { $device_id = sql_save($save, "mac_track_devices", "device_id"); if ($device_id) { raise_message(1); sync_mactrack_to_cacti($save); }else{ raise_message(2); mactrack_debug("ERROR: Cacti Device: ($device_id/$host_id): $hostname, error on save: " . serialize($save)); } } else { mactrack_debug("ERROR: Cacti Device: ($device_id/$host_id): $hostname, error on verify: " . serialize($save)); } return $device_id; }
function api_device_save($id, $host_template_id, $description, $hostname, $snmp_community, $snmp_version, $snmp_username, $snmp_password, $snmp_port, $snmp_timeout, $disabled) { /* fetch some cache variables */ if (empty($id)) { $_host_template_id = 0; } else { $_host_template_id = db_fetch_cell("select host_template_id from host where id={$id}"); } $save["id"] = $id; $save["host_template_id"] = form_input_validate($host_template_id, "host_template_id", "^[0-9]+\$", false, 3); $save["description"] = form_input_validate($description, "description", "", false, 3); $save["hostname"] = form_input_validate($hostname, "hostname", "", false, 3); $save["snmp_community"] = form_input_validate($snmp_community, "snmp_community", "", true, 3); $save["snmp_version"] = form_input_validate($snmp_version, "snmp_version", "", true, 3); $save["snmp_username"] = form_input_validate($snmp_username, "snmp_username", "", true, 3); $save["snmp_password"] = form_input_validate($snmp_password, "snmp_password", "", true, 3); $save["snmp_port"] = form_input_validate($snmp_port, "snmp_port", "^[0-9]+\$", false, 3); $save["snmp_timeout"] = form_input_validate($snmp_timeout, "snmp_timeout", "^[0-9]+\$", false, 3); $save["disabled"] = form_input_validate($disabled, "disabled", "", true, 3); $host_id = 0; if (!is_error_message()) { $host_id = sql_save($save, "host"); if ($host_id) { raise_message(1); /* push out relavant fields to data sources using this host */ push_out_host($host_id, 0); /* the host substitution cache is now stale; purge it */ kill_session_var("sess_host_cache_array"); /* update title cache for graph and data source */ update_data_source_title_cache_from_host($host_id); update_graph_title_cache_from_host($host_id); } else { raise_message(2); } /* if the user changes the host template, add each snmp query associated with it */ if ($host_template_id != $_host_template_id && !empty($host_template_id)) { $snmp_queries = db_fetch_assoc("select snmp_query_id from host_template_snmp_query where host_template_id={$host_template_id}"); if (sizeof($snmp_queries) > 0) { foreach ($snmp_queries as $snmp_query) { db_execute("replace into host_snmp_query (host_id,snmp_query_id,reindex_method) values ({$host_id}," . $snmp_query["snmp_query_id"] . "," . DATA_QUERY_AUTOINDEX_BACKWARDS_UPTIME . ")"); /* recache snmp data */ run_data_query($host_id, $snmp_query["snmp_query_id"]); } } $graph_templates = db_fetch_assoc("select graph_template_id from host_template_graph where host_template_id={$host_template_id}"); if (sizeof($graph_templates) > 0) { foreach ($graph_templates as $graph_template) { db_execute("replace into host_graph (host_id,graph_template_id) values ({$host_id}," . $graph_template["graph_template_id"] . ")"); } } } } return $host_id; }
/** * data_template_item_save - save data to table data_template_rrd */ function data_template_item_save() { require_once(CACTI_BASE_PATH . "/include/data_source/data_source_constants.php"); if (isset($_POST["save_component_item"])) { /* ================= input validation ================= */ input_validate_input_number(get_request_var_post("data_template_id")); /* ==================================================== */ /* save: data_template_rrd */ $save["id"] = $_POST["data_template_rrd_id"]; $save["hash"] = get_hash_data_template($_POST["data_template_rrd_id"], "data_template_item"); $save["local_data_template_rrd_id"] = 0; $save["local_data_id"] = 0; $save["data_template_id"] = $_POST["data_template_id"]; $save["t_rrd_maximum"] = form_input_validate((isset($_POST["t_rrd_maximum"]) ? $_POST["t_rrd_maximum"] : ""), "t_rrd_maximum", "", true, 3); $save["rrd_maximum"] = form_input_validate($_POST["rrd_maximum"], "rrd_maximum", "^(-?([0-9]+(\.[0-9]*)?|[0-9]*\.[0-9]+)([eE][+\-]?[0-9]+)?)|U$", (isset($_POST["t_rrd_maximum"]) ? true : false), 3); $save["t_rrd_minimum"] = form_input_validate((isset($_POST["t_rrd_minimum"]) ? $_POST["t_rrd_minimum"] : ""), "t_rrd_minimum", "", true, 3); $save["rrd_minimum"] = form_input_validate($_POST["rrd_minimum"], "rrd_minimum", "^(-?([0-9]+(\.[0-9]*)?|[0-9]*\.[0-9]+)([eE][+\-]?[0-9]+)?)|U$", (isset($_POST["t_rrd_minimum"]) ? true : false), 3); $save["t_rrd_compute_rpn"] = form_input_validate((isset($_POST["t_rrd_compute_rpn"]) ? $_POST["t_rrd_compute_rpn"] : ""), "t_rrd_compute_rpn", "", true, 3); /* rrd_compute_rpn requires input only for COMPUTE data source type */ $save["rrd_compute_rpn"] = form_input_validate($_POST["rrd_compute_rpn"], "rrd_compute_rpn", "", ((isset($_POST["t_rrd_compute_rpn"]) || ($_POST["data_source_type_id"] != DATA_SOURCE_TYPE_COMPUTE)) ? true : false), 3); $save["t_rrd_heartbeat"] = form_input_validate((isset($_POST["t_rrd_heartbeat"]) ? $_POST["t_rrd_heartbeat"] : ""), "t_rrd_heartbeat", "", true, 3); $save["rrd_heartbeat"] = form_input_validate($_POST["rrd_heartbeat"], "rrd_heartbeat", "^[0-9]+$", (isset($_POST["t_rrd_heartbeat"]) ? true : false), 3); $save["t_data_source_type_id"] = form_input_validate((isset($_POST["t_data_source_type_id"]) ? $_POST["t_data_source_type_id"] : ""), "t_data_source_type_id", "", true, 3); $save["data_source_type_id"] = form_input_validate($_POST["data_source_type_id"], "data_source_type_id", "", true, 3); $save["t_data_source_name"] = form_input_validate((isset($_POST["t_data_source_name"]) ? $_POST["t_data_source_name"] : ""), "t_data_source_name", "", true, 3); $save["data_source_name"] = form_input_validate($_POST["data_source_name"], "data_source_name", "^[a-zA-Z0-9_]{1,19}$", (isset($_POST["t_data_source_name"]) ? true : false), 3); $save["t_data_input_field_id"] = form_input_validate((isset($_POST["t_data_input_field_id"]) ? $_POST["t_data_input_field_id"] : ""), "t_data_input_field_id", "", true, 3); $save["data_input_field_id"] = form_input_validate((isset($_POST["data_input_field_id"]) ? $_POST["data_input_field_id"] : "0"), "data_input_field_id", "", true, 3); if (!is_error_message()) { $data_template_rrd_id = sql_save($save, "data_template_rrd"); if ($data_template_rrd_id) { raise_message(1); push_out_data_source_item($data_template_rrd_id); }else{ raise_message(2); } } if (is_error_message()) { header("Location: data_templates_items.php?action=item_edit&item_id=" . (empty($data_template_rrd_id) ? $_POST["data_template_rrd_id"] : $data_template_rrd_id) . "&id=" . $_POST["data_template_id"]); }else{ header("Location: data_templates.php?action=template_edit&id=" . $_POST["data_template_id"]); } } }
function form_save() { if (isset($_POST["save_component_item"])) { global $graph_item_types; $items[0] = array(); if ($graph_item_types[$_POST["graph_type_id"]] == "LEGEND") { /* this can be a major time saver when creating lots of graphs with the typical GPRINT LAST/AVERAGE/MAX legends */ $items = array(0 => array("color_id" => "0", "graph_type_id" => "9", "consolidation_function_id" => "4", "text_format" => "Current:", "hard_return" => ""), 1 => array("color_id" => "0", "graph_type_id" => "9", "consolidation_function_id" => "1", "text_format" => "Average:", "hard_return" => ""), 2 => array("color_id" => "0", "graph_type_id" => "9", "consolidation_function_id" => "3", "text_format" => "Maximum:", "hard_return" => "on")); } foreach ($items as $item) { /* generate a new sequence if needed */ if (empty($_POST["sequence"])) { $_POST["sequence"] = get_sequence($_POST["sequence"], "sequence", "graph_templates_item", "local_graph_id=" . $_POST["local_graph_id"]); } $save["id"] = $_POST["graph_template_item_id"]; $save["graph_template_id"] = $_POST["graph_template_id"]; $save["local_graph_template_item_id"] = $_POST["local_graph_template_item_id"]; $save["local_graph_id"] = $_POST["local_graph_id"]; $save["task_item_id"] = form_input_validate($_POST["task_item_id"], "task_item_id", "", true, 3); $save["color_id"] = form_input_validate(isset($item["color_id"]) ? $item["color_id"] : $_POST["color_id"], "color_id", "", true, 3); $save["graph_type_id"] = form_input_validate(isset($item["graph_type_id"]) ? $item["graph_type_id"] : $_POST["graph_type_id"], "graph_type_id", "", true, 3); $save["cdef_id"] = form_input_validate($_POST["cdef_id"], "cdef_id", "", true, 3); $save["consolidation_function_id"] = form_input_validate(isset($item["consolidation_function_id"]) ? $item["consolidation_function_id"] : $_POST["consolidation_function_id"], "consolidation_function_id", "", true, 3); $save["text_format"] = form_input_validate(isset($item["text_format"]) ? $item["text_format"] : $_POST["text_format"], "text_format", "", true, 3); $save["value"] = form_input_validate($_POST["value"], "value", "", true, 3); $save["hard_return"] = form_input_validate(isset($item["hard_return"]) ? $item["hard_return"] : (isset($_POST["hard_return"]) ? $_POST["hard_return"] : ""), "hard_return", "", true, 3); $save["gprint_id"] = form_input_validate($_POST["gprint_id"], "gprint_id", "", true, 3); $save["sequence"] = $_POST["sequence"]; if (!is_error_message()) { $graph_template_item_id = sql_save($save, "graph_templates_item"); if ($graph_template_item_id) { raise_message(1); } else { raise_message(2); } } $_POST["sequence"] = 0; } if (is_error_message()) { header("Location: graphs.php?action=item_edit&graph_template_item_id=" . (empty($graph_template_item_id) ? $_POST["graph_template_item_id"] : $graph_template_item_id) . "&id=" . $_POST["local_graph_id"]); exit; } else { header("Location: graphs.php?action=graph_edit&id=" . $_POST["local_graph_id"]); exit; } } }
function form_save() { if (isset_request_var('save_component')) { $save['id'] = get_filter_request_var('id'); $save['name'] = form_input_validate(get_nfilter_request_var('name'), 'name', '', false, 3); $save['description'] = form_input_validate(get_nfilter_request_var('description'), 'description', '', false, 3); $save['emails'] = form_input_validate(get_nfilter_request_var('emails'), 'emails', '', false, 3); if (!is_error_message()) { $id = sql_save($save, 'plugin_notification_lists'); if ($id) { raise_message(1); } else { raise_message(2); } } } header('Location: notify_lists.php?header=false&action=edit&id=' . (empty($id) ? get_request_var('id') : $id)); }
function form_save() { if (isset($_POST["save_component"])) { $save["id"] = $_POST["id"]; $save["name"] = form_input_validate($_POST["name"], "name", "", false, 3); $save["description"] = form_input_validate($_POST["description"], "description", "", false, 3); $save["emails"] = form_input_validate($_POST["emails"], "emails", "", false, 3); if (!is_error_message()) { $id = sql_save($save, "plugin_notification_lists"); if ($id) { raise_message(1); } else { raise_message(2); } } } header("Location: notify_lists.php?action=edit&id=" . (empty($id) ? $_POST["id"] : $id)); }
function api_rra_template_save($id, $name, $description) { $save["id"] = $id; $save["name"] = form_input_validate($name, "name", "", true, 3); $save["description"] = form_input_validate($description, "description", "", false, 3); $rra_template_id = 0; if (!is_error_message()) { $rra_template_id = sql_save($save, "rra_template"); if ($rra_template_id) { raise_message(1); }else{ raise_message(2); } } return $rra_template_id; }
function flowview_save_filter() { global $config, $colors; include $config['base_path'] . '/plugins/flowview/variables.php'; include $config['base_path'] . '/plugins/flowview/arrays.php'; if (isset($_POST['new_query']) && $_POST['new_query'] != '') { $queryname = $_POST['new_query']; $save['id'] = ''; $save['name'] = form_input_validate($queryname, "queryname", "", false, 3); } else { $save['id'] = $_POST['query']; } $save['device'] = $device; $save['startdate'] = $start_date; $save['starttime'] = $start_time; $save['enddate'] = $end_date; $save['endtime'] = $end_time; $save['tosfields'] = $tos_fields; $save['tcpflags'] = $tcp_flags; $save['protocols'] = $protocols; $save['sourceip'] = $source_address; $save['sourceport'] = $source_port; $save['sourceinterface'] = $source_if; $save['sourceas'] = $source_as; $save['destip'] = $dest_address; $save['destport'] = $dest_port; $save['destinterface'] = $dest_if; $save['destas'] = $dest_as; $save['statistics'] = $stat_report; $save['printed'] = $print_report; $save['includeif'] = $flow_select; $save['sortfield'] = $sort_field; $save['cutofflines'] = $cutoff_lines; $save['cutoffoctets'] = $cutoff_octets; $save['resolve'] = $resolve_addresses; $id = sql_save($save, 'plugin_flowview_queries', 'id', true); if (is_error_message() || $id == '') { print "error"; } else { print $id; } }
function form_save() { if (isset($_POST['save_component_color'])) { $save['id'] = $_POST['id']; $save['hex'] = form_input_validate($_POST['hex'], 'hex', '^[a-fA-F0-9]+$', false, 3); if (!is_error_message()) { $color_id = sql_save($save, 'colors'); if ($color_id) { raise_message(1); } else { raise_message(2); } } if (is_error_message()) { header('Location: color.php?action=edit&id=' . (empty($color_id) ? $_POST['id'] : $color_id)); } else { header('Location: color.php'); } } }
function api_poller_save($poller_id, $active, $hostname, $description) { $save["id"] = $poller_id; $save["name"] = form_input_validate($description, "name", "", true, 3); $save["hostname"] = form_input_validate($hostname, "hostname", "", true, 3); $save["active"] = form_input_validate($active, "active", "", true, 3); $poller_id = 0; if (!is_error_message()) { $poller_id = sql_save($save, "poller"); if ($poller_id) { raise_message(1); }else{ raise_message(2); } } return $poller_id; }
function form_save() { if (isset($_POST["save_component_color"])) { $save["id"] = $_POST["id"]; $save["hex"] = form_input_validate($_POST["hex"], "hex", "^[a-fA-F0-9]+\$", false, 3); if (!is_error_message()) { $color_id = sql_save($save, "colors"); if ($color_id) { raise_message(1); } else { raise_message(2); } } if (is_error_message()) { header("Location: color.php?action=edit&id=" . (empty($color_id) ? $_POST["id"] : $color_id)); } else { header("Location: color.php"); } } }
function form_save() { if (isset($_POST["save_component_color"])) { $save["id"] = $_POST["id"]; $save["hex"] = form_input_validate($_POST["hex"], "hex", "^[a-fA-F0-9]+$", false, 3); if (!is_error_message()) { $color_id = sql_save($save, "colors"); if ($color_id) { raise_message(1); }else{ raise_message(2); } } if (is_error_message()) { header("Location: color.php?action=edit&id=" . (empty($color_id) ? $_POST["id"] : $color_id)); }else{ header("Location: color.php"); } } if (isset($_POST["save_component_import"])) { if (($_FILES["import_file"]["tmp_name"] != "none") && ($_FILES["import_file"]["tmp_name"] != "")) { /* file upload */ $csv_data = file($_FILES["import_file"]["tmp_name"]); /* obtain debug information if it's set */ $debug_data = import_processor($csv_data); if(sizeof($debug_data) > 0) { $_SESSION["import_debug_info"] = $debug_data; } }else{ header("Location: color.php?import_x"); } header("Location: color.php?import_x"); } exit; }
function gpsmap_api_device_save($save) { if (isset($_POST['GPScoverage'])) { $save['GPScoverage'] = "on"; } else { $save['GPScoverage'] = "off"; } if (isset($_POST['latitude'])) { $save['latitude'] = form_input_validate($_POST['latitude'], 'latitude', '', true, 3); } else { $save['latitude'] = form_input_validate('', 'latitude', '', true, 3); } if (isset($_POST['longitude'])) { $save['longitude'] = form_input_validate($_POST['longitude'], 'longitude', '', true, 3); } else { $save['longitude'] = form_input_validate('', 'longitude', '', true, 3); } if (isset($_POST['start'])) { $save['start'] = form_input_validate($_POST['start'], 'start', '', true, 3); } else { $save['start'] = form_input_validate('', 'start', '', true, 3); } if (isset($_POST['stop'])) { $save['stop'] = form_input_validate($_POST['stop'], 'stop', '', true, 3); } else { $save['stop'] = form_input_validate('', 'stop', '', true, 3); } if (isset($_POST['rdistance'])) { $save['rdistance'] = form_input_validate($_POST['rdistance'], 'distance', '', true, 3); } else { $save['rdistance'] = form_input_validate('', 'rdistance', '', true, 3); } if (isset($_POST['groupnum'])) { $save['groupnum'] = form_input_validate($_POST['groupnum'], 'groupnum', '', true, 3); } else { $save['groupnum'] = form_input_validate('', 'groupnum', '', true, 3); } return $save; }
function form_save() { if (isset($_POST['save_component_rra'])) { $save['id'] = $_POST['id']; $save['hash'] = get_hash_round_robin_archive($_POST['id']); $save['name'] = form_input_validate($_POST['name'], 'name', '', false, 3); $dummy = form_input_validate(count($_POST['consolidation_function_id']), 'consolidation_function_id', '^[0-9]*$', false, 3); $save['x_files_factor'] = form_input_validate($_POST['x_files_factor'], 'x_files_factor', "^[01]?(\\.[0-9]+)?\$", false, 3); $save['steps'] = form_input_validate($_POST['steps'], 'steps', '^[0-9]*$', false, 3); $save['rows'] = form_input_validate($_POST['rows'], 'rows', '^[0-9]*$', false, 3); $save['timespan'] = form_input_validate($_POST['timespan'], 'timespan', '^[0-9]*$', false, 3); if (!is_error_message()) { $rra_id = sql_save($save, 'rra'); if ($rra_id) { raise_message(1); db_execute_prepared('DELETE FROM rra_cf WHERE rra_id = ?', array($rra_id)); if (isset($_POST['consolidation_function_id'])) { for ($i = 0; $i < count($_POST['consolidation_function_id']); $i++) { /* ================= input validation ================= */ input_validate_input_number($_POST['consolidation_function_id'][$i]); /* ==================================================== */ db_execute_prepared('INSERT INTO rra_cf (rra_id, consolidation_function_id) VALUES (?, ?)', array($rra_id, $_POST['consolidation_function_id'][$i])); } } else { raise_message(2); } } else { raise_message(2); } } if (is_error_message()) { header('Location: rra.php?action=edit&id=' . (empty($rra_id) ? $_POST['id'] : $rra_id)); } else { header('Location: rra.php'); } exit; } }
function save() { $save = array(); $save["id"] = array("type" => DB_TYPE_INTEGER, "value" => $_SESSION["sess_user_id"]); $save["current_theme"] = array("type" => DB_TYPE_STRING, "value" => form_input_validate($_POST["current_theme"], "current_theme", "", true, 3)); if (!is_error_message()) { $user_id = api_user_save($save); if ($user_id) { /* user saved */ raise_message(1); /* reset local settings cache so the user sees the new settings */ kill_session_var("sess_current_theme"); }else{ /* error saving */ raise_message(2); } } header("Location: user_settings.php"); }
function api_data_preset_rra_item_field_validate(&$_fields_data_preset_rra_item, $data_preset_rra_item_field_name_format) { require_once(CACTI_BASE_PATH . "/include/data_preset/data_preset_rra_constants.php"); require_once(CACTI_BASE_PATH . "/lib/data_preset/data_preset_rra_info.php"); if (sizeof($_fields_data_preset_rra_item) == 0) { return array(); } /* array containing errored fields */ $error_fields = array(); /* get a complete field list */ $fields_data_preset_rra_item = api_data_preset_rra_item_form_list(); /* only certain fields are displayed on the form depending on the selected consolidation function */ if (isset($_fields_data_preset_rra_item["consolidation_function"])) { $invisible_fields = array_diff(array_keys($fields_data_preset_rra_item), api_data_preset_rra_item_visible_field_list($_fields_data_preset_rra_item["consolidation_function"])); foreach ($invisible_fields as $field_name) { unset($_fields_data_preset_rra_item[$field_name]); } } /* base fields */ while (list($_field_name, $_field_array) = each($fields_data_preset_rra_item)) { if ((isset($_fields_data_preset_rra_item[$_field_name])) && (isset($_field_array["validate_regexp"])) && (isset($_field_array["validate_empty"]))) { $form_field_name = str_replace("|field|", $_field_name, $data_preset_rra_item_field_name_format); if (!form_input_validate($_fields_data_preset_rra_item[$_field_name], $form_field_name, $_field_array["validate_regexp"], $_field_array["validate_empty"])) { $error_fields[] = $form_field_name; } } } return $error_fields; }
function validate_data_query_field_fields(&$_fields_data_query_field, $data_query_field_field_name_format) { require_once(CACTI_BASE_PATH . "/lib/data_query/data_query_info.php"); if (sizeof($_fields_data_query_field) == 0) { return array(); } /* array containing errored fields */ $error_fields = array(); /* get a complete field list */ $fields_data_query_fields = api_data_query_field_form_list(); /* if enough field values are available, additional validation checks can be made */ if ((isset($_fields_data_query_field["method_type"])) && (isset($_fields_data_query_field["method_value"])) && ($_fields_data_query_field["method_type"] == DATA_QUERY_FIELD_METHOD_VALUE_PARSE)) { $fields_data_query_fields["method_value"]["validate_empty"] = false; }else if ((isset($_fields_data_query_field["method_type"])) && (isset($_fields_data_query_field["method_value"])) && ($_fields_data_query_field["method_type"] == DATA_QUERY_FIELD_METHOD_OID_OCTET)) { $fields_data_query_fields["method_value"]["validate_empty"] = false; $fields_data_query_fields["method_value"]["validate_regexp"] = "^[0-9]+$"; }else if ((isset($_fields_data_query_field["method_type"])) && (isset($_fields_data_query_field["method_value"])) && ($_fields_data_query_field["method_type"] == DATA_QUERY_FIELD_METHOD_OID_PARSE)) { $fields_data_query_fields["method_value"]["validate_empty"] = false; } /* base fields */ while (list($_field_name, $_field_array) = each($fields_data_query_fields)) { if ((isset($_fields_data_query_field[$_field_name])) && (isset($_field_array["validate_regexp"])) && (isset($_field_array["validate_empty"]))) { $form_field_name = str_replace("|field|", $_field_name, $data_query_field_field_name_format); if (!form_input_validate($_fields_data_query_field[$_field_name], $form_field_name, $_field_array["validate_regexp"], $_field_array["validate_empty"])) { $error_fields[] = $form_field_name; } } } return $error_fields; }
function form_save() { if (isset($_POST['save_component_gprint_presets'])) { $save['id'] = $_POST['id']; $save['hash'] = get_hash_gprint($_POST['id']); $save['name'] = form_input_validate($_POST['name'], 'name', '', false, 3); $save['gprint_text'] = form_input_validate($_POST['gprint_text'], 'gprint_text', '', false, 3); if (!is_error_message()) { $gprint_preset_id = sql_save($save, 'graph_templates_gprint'); if ($gprint_preset_id) { raise_message(1); } else { raise_message(2); } } if (is_error_message()) { header('Location: gprint_presets.php?action=edit&id=' . (empty($gprint_preset_id) ? $_POST['id'] : $gprint_preset_id)); exit; } else { header('Location: gprint_presets.php'); exit; } } }
function event_validate (&$_fields_event, $event_field_name_format = "|field|") { if (sizeof($_fields_event) == 0) { return array(); } /* array containing errored fields */ $error_fields = array(); /* get a complete field list */ $fields_event = event_list_form(); /* base fields */ while (list($_field_name, $_field_array) = each($fields_event)) { if ((isset($_fields_event[$_field_name])) && (isset($_field_array["validate_regexp"])) && (isset($_field_array["validate_empty"]))) { $form_field_name = str_replace("|field|", $_field_name, $event_field_name_format); if (!form_input_validate($_fields_event[$_field_name], $form_field_name, $_field_array["validate_regexp"], $_field_array["validate_empty"])) { $error_fields[] = $form_field_name; } } } return $error_fields; }
function form_save() { if ((isset($_POST["save_component_graph_new"])) && (!empty($_POST["graph_template_id"]))) { /* ================= input validation ================= */ input_validate_input_number(get_request_var_post("graph_template_id")); /* ==================================================== */ $save["id"] = $_POST["local_graph_id"]; $save["graph_template_id"] = $_POST["graph_template_id"]; $save["host_id"] = $_POST["host_id"]; $local_graph_id = sql_save($save, "graph_local"); change_graph_template($local_graph_id, $_POST["graph_template_id"], true); /* update the title cache */ update_graph_title_cache($local_graph_id); } if (isset($_POST["save_component_graph"])) { /* ================= input validation ================= */ input_validate_input_number(get_request_var_post("graph_template_id")); input_validate_input_number(get_request_var_post("_graph_template_id")); /* ==================================================== */ $save1["id"] = $_POST["local_graph_id"]; $save1["host_id"] = $_POST["host_id"]; $save1["graph_template_id"] = $_POST["graph_template_id"]; $save2["id"] = $_POST["graph_template_graph_id"]; $save2["local_graph_template_graph_id"] = $_POST["local_graph_template_graph_id"]; $save2["graph_template_id"] = $_POST["graph_template_id"]; $save2["image_format_id"] = form_input_validate($_POST["image_format_id"], "image_format_id", "", true, 3); $save2["title"] = form_input_validate($_POST["title"], "title", "", false, 3); $save2["height"] = form_input_validate($_POST["height"], "height", "^[0-9]+$", false, 3); $save2["width"] = form_input_validate($_POST["width"], "width", "^[0-9]+$", false, 3); $save2["upper_limit"] = form_input_validate($_POST["upper_limit"], "upper_limit", "^(-?([0-9]+(\.[0-9]*)?|[0-9]*\.[0-9]+)([eE][+\-]?[0-9]+)?)|U$", false, 3); $save2["lower_limit"] = form_input_validate($_POST["lower_limit"], "lower_limit", "^(-?([0-9]+(\.[0-9]*)?|[0-9]*\.[0-9]+)([eE][+\-]?[0-9]+)?)|U$", false, 3); $save2["vertical_label"] = form_input_validate($_POST["vertical_label"], "vertical_label", "", true, 3); $save2["slope_mode"] = form_input_validate((isset($_POST["slope_mode"]) ? $_POST["slope_mode"] : ""), "slope_mode", "", true, 3); $save2["auto_scale"] = form_input_validate((isset($_POST["auto_scale"]) ? $_POST["auto_scale"] : ""), "auto_scale", "", true, 3); $save2["auto_scale_opts"] = form_input_validate($_POST["auto_scale_opts"], "auto_scale_opts", "", true, 3); $save2["auto_scale_log"] = form_input_validate((isset($_POST["auto_scale_log"]) ? $_POST["auto_scale_log"] : ""), "auto_scale_log", "", true, 3); $save2["scale_log_units"] = form_input_validate((isset($_POST["scale_log_units"]) ? $_POST["scale_log_units"] : ""), "scale_log_units", "", true, 3); $save2["auto_scale_rigid"] = form_input_validate((isset($_POST["auto_scale_rigid"]) ? $_POST["auto_scale_rigid"] : ""), "auto_scale_rigid", "", true, 3); $save2["auto_padding"] = form_input_validate((isset($_POST["auto_padding"]) ? $_POST["auto_padding"] : ""), "auto_padding", "", true, 3); $save2["base_value"] = form_input_validate($_POST["base_value"], "base_value", "^[0-9]+$", false, 3); $save2["export"] = form_input_validate((isset($_POST["export"]) ? $_POST["export"] : ""), "export", "", true, 3); $save2["unit_value"] = form_input_validate($_POST["unit_value"], "unit_value", "", true, 3); $save2["unit_exponent_value"] = form_input_validate($_POST["unit_exponent_value"], "unit_exponent_value", "^-?[0-9]+$", true, 3); if (!is_error_message()) { $local_graph_id = sql_save($save1, "graph_local"); } if (!is_error_message()) { $save2["local_graph_id"] = $local_graph_id; $graph_templates_graph_id = sql_save($save2, "graph_templates_graph"); if ($graph_templates_graph_id) { raise_message(1); /* if template information chanegd, update all necessary template information */ if ($_POST["graph_template_id"] != $_POST["_graph_template_id"]) { /* check to see if the number of graph items differs, if it does; we need user input */ if ((!empty($_POST["graph_template_id"])) && (!empty($_POST["local_graph_id"])) && (sizeof(db_fetch_assoc("select id from graph_templates_item where local_graph_id=$local_graph_id")) != sizeof(db_fetch_assoc("select id from graph_templates_item where local_graph_id=0 and graph_template_id=" . $_POST["graph_template_id"])))) { /* set the template back, since the user may choose not to go through with the change at this point */ db_execute("update graph_local set graph_template_id=" . $_POST["_graph_template_id"] . " where id=$local_graph_id"); db_execute("update graph_templates_graph set graph_template_id=" . $_POST["_graph_template_id"] . " where local_graph_id=$local_graph_id"); header("Location: graphs.php?action=graph_diff&id=$local_graph_id&graph_template_id=" . $_POST["graph_template_id"]); exit; } } }else{ raise_message(2); } /* update the title cache */ update_graph_title_cache($local_graph_id); } if ((!is_error_message()) && ($_POST["graph_template_id"] != $_POST["_graph_template_id"])) { change_graph_template($local_graph_id, $_POST["graph_template_id"], true); }elseif (!empty($_POST["graph_template_id"])) { update_graph_data_query_cache($local_graph_id); } } if (isset($_POST["save_component_input"])) { /* ================= input validation ================= */ input_validate_input_number(get_request_var_post("local_graph_id")); /* ==================================================== */ /* first; get the current graph template id */ $graph_template_id = db_fetch_cell("select graph_template_id from graph_local where id=" . $_POST["local_graph_id"]); /* get all inputs that go along with this graph template */ $input_list = db_fetch_assoc("select id,column_name from graph_template_input where graph_template_id=$graph_template_id"); if (sizeof($input_list) > 0) { foreach ($input_list as $input) { /* we need to find out which graph items will be affected by saving this particular item */ $item_list = db_fetch_assoc("select graph_templates_item.id from (graph_template_input_defs,graph_templates_item) where graph_template_input_defs.graph_template_item_id=graph_templates_item.local_graph_template_item_id and graph_templates_item.local_graph_id=" . $_POST["local_graph_id"] . " and graph_template_input_defs.graph_template_input_id=" . $input["id"]); /* loop through each item affected and update column data */ if (sizeof($item_list) > 0) { foreach ($item_list as $item) { /* if we are changing templates, the POST vars we are searching for here will not exist. this is because the db and form are out of sync here, but it is ok to just skip over saving the inputs in this case. */ if (isset($_POST{$input["column_name"] . "_" . $input["id"]})) { db_execute("update graph_templates_item set " . $input["column_name"] . "='" . $_POST{$input["column_name"] . "_" . $input["id"]} . "' where id=" . $item["id"]); } } } } } } if (isset($_POST["save_component_graph_diff"])) { if ($_POST["type"] == "1") { $intrusive = true; }elseif ($_POST["type"] == "2") { $intrusive = false; } change_graph_template($_POST["local_graph_id"], $_POST["graph_template_id"], $intrusive); } if ((isset($_POST["save_component_graph_new"])) && (empty($_POST["graph_template_id"]))) { header("Location: graphs.php?action=graph_edit&host_id=" . $_POST["host_id"] . "&new=1"); }elseif ((is_error_message()) || (empty($_POST["local_graph_id"])) || (isset($_POST["save_component_graph_diff"])) || ($_POST["graph_template_id"] != $_POST["_graph_template_id"]) || ($_POST["host_id"] != $_POST["_host_id"])) { header("Location: graphs.php?action=graph_edit&id=" . (empty($local_graph_id) ? $_POST["local_graph_id"] : $local_graph_id) . (isset($_POST["host_id"]) ? "&host_id=" . $_POST["host_id"] : "")); }else{ header("Location: graphs.php"); } }