/", $_POST["input_string"], $matches)) { $j = 0; for ($i=0; ($i < count($matches[1])); $i++) { if (in_array($matches[1][$i], $registered_cacti_names) == false) { $j++; db_execute("update data_input_fields set sequence=$j where data_input_id=" . $_POST["id"] . " and input_output='in' and data_name='" . $matches[1][$i] . "'"); } } } if (preg_match_all("/<([_a-zA-Z0-9]+)>/", $_POST["output_string"], $matches)) { $j = 0; for ($i=0; ($i < count($matches[1])); $i++) { if (in_array($matches[1][$i], $registered_cacti_names) == false) { $j++; db_execute("update data_input_fields set sequence=$j where data_input_id=" . $_POST["id"] . " and input_output='out' and data_name='" . $matches[1][$i] . "'"); } } } } }else{ raise_message(2); } } if ((is_error_message()) || (empty($_POST["id"]))) { header ("Location: data_input.php?action=edit&id=" . (empty($data_input_id) ? $_POST["id"] : $data_input_id)); }else{ header ("Location: data_input.php"); } }elseif (isset($_POST["save_component_field"])) { $save["id"] = $_POST["id"]; $save["data_input_id"] = $_POST["data_input_id"]; $save["name"] = form_input_validate($_POST["name"], "name", "", false, 3); $save["data_name"] = form_input_validate($_POST["data_name"], "data_name", "", true, 3); $save["input_output"] = $_POST["input_output"]; $save["update_rra"] = form_input_validate((isset($_POST["update_rra"]) ? $_POST["update_rra"] : ""), "update_rra", "", true, 3); $save["sequence"] = $_POST["sequence"]; $save["type_code"] = form_input_validate((isset($_POST["type_code"]) ? $_POST["type_code"] : ""), "type_code", "", true, 3); $save["regexp_match"] = form_input_validate((isset($_POST["regexp_match"]) ? $_POST["regexp_match"] : ""), "regexp_match", "", true, 3); $save["allow_nulls"] = form_input_validate((isset($_POST["allow_nulls"]) ? $_POST["allow_nulls"] : ""), "allow_nulls", "", true, 3); if (!is_error_message()) { $data_input_field_id = sql_save($save, "data_input_fields"); if ($data_input_field_id) { raise_message(1); if (!empty($data_input_field_id)) { if (preg_match_all("/<([_a-zA-Z0-9]+)>/", db_fetch_cell("select " . $_POST["input_output"] . "put_string from data_input where id=" . $_POST["data_input_id"]), $matches)) { $j = 0; for ($i=0; ($i < count($matches[1])); $i++) { if (in_array($matches[1][$i], $registered_cacti_names) == false) { $j++; if ($matches[1][$i] == $_POST["data_name"]) { db_execute("update data_input_fields set sequence=$j where data_input_id=" . $_POST["data_input_id"] . " and input_output='" . $_POST["input_output"]. "' and data_name='" . $matches[1][$i] . "'"); } } } } } }else{ raise_message(2); } } if (is_error_message()) { header ("Location: data_input.php?action=field_edit&data_input_id=" . $_POST["data_input_id"] . "&id=" . (empty($data_input_field_id) ? $_POST["id"] : $data_input_field_id) . (!empty($_POST["input_output"]) ? "&type=" . $_POST["input_output"] : "")); }else{ header ("Location: data_input.php?action=edit&id=" . $_POST["data_input_id"]); } } } /* -------------------------- CDEF Item Functions -------------------------- */ function field_remove() { global $registered_cacti_names; 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 field '" . db_fetch_cell("select name from data_input_fields where id=" . $_GET["id"]) . "'?", $_SERVER["HTTP_REFERER"], "data_input.php?action=field_remove&id=" . $_GET["id"] . "&data_input_id=" . $_GET["data_input_id"]); include ('include/bottom_footer.php'); exit; } if ((read_config_option("remove_verification") == "") || (isset($_GET["confirm"]))) { /* get information about the field we're going to delete so we can re-order the seqs */ $field = db_fetch_row("select input_output,data_input_id from data_input_fields where id=" . $_GET["id"]); db_execute("delete from data_input_fields where id=" . $_GET["id"]); db_execute("delete from data_input_data where data_input_field_id=" . $_GET["id"]); /* when a field is deleted; we need to re-order the field sequences */ if (preg_match_all("/<([_a-zA-Z0-9]+)>/", db_fetch_cell("select " . $field["input_output"] . "put_string from data_input where id=" . $field["data_input_id"]), $matches)) { $j = 0; for ($i=0; ($i < count($matches[1])); $i++) { if (in_array($matches[1][$i], $registered_cacti_names) == false) { $j++; db_execute("update data_input_fields set sequence=$j where data_input_id=" . $field["data_input_id"] . " and input_output='" . $field["input_output"]. "' and data_name='" . $matches[1][$i] . "'"); } } } } } function field_edit() { global $colors, $registered_cacti_names; if (!empty($_GET["id"])) { $field = db_fetch_row("select * from data_input_fields where id=" . $_GET["id"]); } if (!empty($_GET["type"])) { $current_field_type = $_GET["type"]; }else{ $current_field_type = $field["input_output"]; } if ($current_field_type == "out") { $header_name = "Output"; }elseif ($current_field_type == "in") { $header_name = "Input"; } $data_input = db_fetch_row("select type_id,name from data_input where id=" . $_GET["data_input_id"]); /* obtain a list of available fields for this given field type (input/output) */ if (preg_match_all("/<([_a-zA-Z0-9]+)>/", db_fetch_cell("select $current_field_type" . "put_string from data_input where id=" . ($_GET["data_input_id"] ? $_GET["data_input_id"] : $field["data_input_id"])), $matches)) { for ($i=0; ($i < count($matches[1])); $i++) { if (in_array($matches[1][$i], $registered_cacti_names) == false) { $current_field_name = $matches[1][$i]; $array_field_names[$current_field_name] = $current_field_name; } } } start_box("$header_name Fields [edit: " . $data_input["name"] . "]", "98%", $colors["header"], "3", "center", ""); ?>