예제 #1
0
function host_new_graphs($selected_graphs = "", $map_id_to_index = "")
{
    global $colors;
    if (!is_array($selected_graphs)) {
        $selected_graphs = array();
        $map_id_to_index = array();
        /* summarize the 'create graph from host template/snmp index' stuff into an array */
        while (list($name, $value) = each($_POST)) {
            if (substr($name, 0, 3) == "cg_" && $name != "cg_g") {
                $matches = explode("_", $name);
                /* uniquely identify this yet to be created graph */
                $uniq_id = md5("gt" . $matches[1]);
                $map_id_to_index["gt"][$matches[1]][] = $uniq_id;
                $selected_graphs[$uniq_id]["graph_template_id"] = $matches[1];
            } else {
                if (substr($name, 0, 3) == "sg_") {
                    $matches = explode("_", $name);
                    /* uniquely identify this yet to be created graph */
                    $uniq_id = md5("dq" . $matches[1] . $matches[2]);
                    $map_id_to_index["dq"][$matches[1]][] = $uniq_id;
                    $selected_graphs[$uniq_id]["graph_template_id"] = $_POST["sgg_" . $matches[1]];
                    $selected_graphs[$uniq_id]["custom_data"]["all_dq"]["data_query_id"] = $matches[1];
                    $selected_graphs[$uniq_id]["custom_data"]["all_dq"]["data_query_index"] = $matches[2];
                } else {
                    if ($name == "cg_g" && !empty($value)) {
                        /* uniquely identify this yet to be created graph */
                        $uniq_id = md5("gt" . $_POST["cg_g"]);
                        $map_id_to_index["gt"][$_POST["cg_g"]][] = $uniq_id;
                        $selected_graphs[$uniq_id]["graph_template_id"] = $_POST["cg_g"];
                    }
                }
            }
        }
    }
    /* we use object buffering on this page to allow redirection to another page if no
    	fields are actually drawn */
    ob_start();
    require_once CACTI_BASE_PATH . "/include/top_header.php";
    print "<form method='post' action='graphs_new.php'>\n";
    $num_output_fields = 0;
    $data_query_id = 0;
    $graph_template_id = 0;
    foreach ($map_id_to_index as $form_type => $form_type_array) {
        foreach ($form_type_array as $form_type_index => $form_type_index_array) {
            if ($form_type == "gt") {
                $graph_template_id = $form_type_index;
                $data_query_id = 0;
                html_start_box("<strong>Create Graph from '" . db_fetch_cell("select template_name from graph_template where id = {$graph_template_id}") . "'", "98%", $colors["header_background"], "3", "center", "");
            } else {
                if ($form_type == "dq") {
                    /* one graph_template_id per data query, at a time */
                    $arr_values = array_values($form_type_index_array);
                    $graph_template_id = $selected_graphs[$arr_values[0]]["graph_template_id"];
                    $data_query_id = $form_type_index;
                    $num_graphs = sizeof($form_type_index_array);
                    /* DRAW: Data Query */
                    html_start_box("<strong>" . _("Create") . " {$num_graphs} " . _("Graph") . ($num_graphs > 1 ? "s" : "") . " from '" . api_data_query_name_get($data_query_id) . "'", "98%", $colors["header_background"], "3", "center", "");
                }
            }
            /* get information about this graph template */
            $graph_template = db_fetch_row("select * from graph_template where id = {$graph_template_id}");
            $num_output_fields += draw_nontemplated_fields_graph($graph_template_id, $graph_template, "g_{$data_query_id}" . "_" . $graph_template_id . "_|field|", "<strong>Graph</strong> [Template: " . $graph_template["template_name"] . "]", false);
            $num_output_fields += draw_nontemplated_fields_graph_item($graph_template_id, array_rekey(db_fetch_assoc("select * from graph_template_item where graph_template_id = {$graph_template_id}"), "id", array("id", "data_template_item_id", "color", "graph_item_type", "cdef", "consolidation_function", "gprint_format", "legend_format", "legend_value", "hard_return")), "gi_" . $data_query_id . "_" . $graph_template_id . "_|id|_|field|", "<strong>" . _("Graph Items") . "</strong> [" . _("Template: ") . $graph_template["template_name"] . "]", false);
            /* get information about each data template referenced by this graph template */
            $data_templates = db_fetch_assoc("select distinct\n\t\t\t\tdata_template.*\n\t\t\t\tfrom data_template,data_template_item,graph_template_item\n\t\t\t\twhere graph_template_item.data_template_item_id=data_template_item.id\n\t\t\t\tand data_template_item.data_template_id=data_template.id\n\t\t\t\tand graph_template_item.graph_template_id = {$graph_template_id}");
            /* DRAW: Data Sources */
            if (sizeof($data_templates) > 0) {
                foreach ($data_templates as $data_template) {
                    $num_output_fields += draw_nontemplated_fields_data_source($data_template["id"], $data_template, "d_" . $data_query_id . "_" . $graph_template_id . "_" . $data_template["id"] . "_|field|", true);
                    $num_output_fields += draw_nontemplated_fields_data_source_item($data_template["id"], db_fetch_assoc("select * from data_template_item where data_template_id = " . $data_template["id"] . " order by data_source_name"), "di_" . $data_query_id . "_" . $graph_template_id . "_" . $data_template["id"] . "_|id|_|field|", true);
                    $num_output_fields += draw_nontemplated_fields_data_input($data_template["id"], array_rekey(db_fetch_assoc("select name,value from data_template_field where data_template_id = " . $data_template["id"]), "name", array("value")), "c_" . $data_query_id . "_" . $graph_template_id . "_" . $data_template["id"] . "_|field|", "<strong>" . _("Custom Data") . "</strong> [" . _("Template: ") . $data_template["template_name"] . "]", false);
                }
            }
            html_end_box();
        }
    }
    /* no fields were actually drawn on the form; just save without prompting the user */
    if ($num_output_fields == 0) {
        ob_end_clean();
        /* since the user didn't actually click "Create" to POST the data; we have to
        		pretend like they did here */
        $_POST["host_id"] = $_POST["host_id"];
        $_POST["save_component_new_graphs"] = "1";
        $_POST["selected_graphs_array"] = addslashes(serialize($selected_graphs));
        $_POST["map_id_to_index_array"] = addslashes(serialize($map_id_to_index));
        host_new_graphs_save();
        header("Location: graphs_new.php?host_id=" . $_POST["host_id"]);
        exit;
    }
    /* flush the current output buffer to the browser */
    ob_end_flush();
    form_hidden_box("host_id", $_POST["host_id"], "0");
    form_hidden_box("save_component_new_graphs", "1", "");
    form_hidden_box("selected_graphs_array", serialize($selected_graphs), "");
    form_hidden_box("map_id_to_index_array", serialize($map_id_to_index), "");
    form_save_button("graphs_new.php?host_id=" . $_POST["host_id"]);
    require_once CACTI_BASE_PATH . "/include/bottom_footer.php";
}
예제 #2
0
function ds_edit()
{
    global $colors, $data_source_types;
    $host_id = 0;
    if (!empty($_GET["id"])) {
        $data_source = db_fetch_row("select * from data_source where id = " . $_GET["id"]);
        $data_source_items = db_fetch_assoc("select * from data_source_item where data_source_id = " . $_GET["id"]);
        if (!empty($data_source["data_template_id"])) {
            $data_template = db_fetch_row("select id,name from data_template where id='" . $data_source["data_template_id"] . "'");
        }
        $header_label = _("[edit: ") . api_data_source_title_get($_GET["id"]) . "]";
        /* get a list of all data input type fields for this data template */
        $data_input_type_fields = array_rekey(db_fetch_assoc("select name,value from data_source_field where data_source_id = " . $data_source["id"]), "name", array("value"));
    } else {
        $header_label = _("[new]");
        $data_input_type_fields = array();
    }
    /* handle debug mode */
    if (isset($_GET["debug"])) {
        if ($_GET["debug"] == "0") {
            kill_session_var("ds_debug_mode");
        } elseif ($_GET["debug"] == "1") {
            $_SESSION["ds_debug_mode"] = true;
        }
    }
    if (!empty($_GET["id"])) {
        ?>
		<table width="98%" align="center">
			<tr>
				<td class="textInfo" colspan="2" valign="top">
					<?php 
        print api_data_source_title_get($_GET["id"]);
        ?>
				</td>
				<td class="textInfo" align="right" valign="top">
					<span style="color: #c16921;">*<a href='data_sources.php?action=edit&id=<?php 
        print isset($_GET["id"]) ? $_GET["id"] : 0;
        ?>
&debug=<?php 
        print isset($_SESSION["ds_debug_mode"]) ? "0" : "1";
        ?>
'>Turn <strong><?php 
        print isset($_SESSION["ds_debug_mode"]) ? "Off" : "On";
        ?>
</strong> Data Source Debug Mode.</a>
				</td>
			</tr>
		</table>
		<br>
		<?php 
    }
    form_start("data_sources.php", "form_data_source");
    /* ==================== Box: Device/Template Selection ==================== */
    html_start_box("<strong>" . _("Device/Template Selection") . "</strong> {$header_label}");
    _data_source_field__data_template_id("data_template_id", isset($data_source) ? $data_source["data_template_id"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]);
    _data_source_field__host_id("host_id", isset($data_source) ? $data_source["host_id"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]);
    html_end_box();
    /* ==================== Box: Supplemental Template Data ==================== */
    /* only display the "inputs" area if we are using a data template for this data source */
    if (!empty($data_source["data_template_id"])) {
        ob_start();
        html_start_box("<strong>" . _("Supplemental Template Data") . "</strong>");
        $num_output_fields = draw_nontemplated_fields_data_input($data_source["data_template_id"], $data_input_type_fields, "dif_|field|", "<strong>" . _("Data Input") . "</strong>", true);
        if ($data_source["data_input_type"] == DATA_INPUT_TYPE_DATA_QUERY) {
            _data_source_input_field__data_query_hdr();
            _data_source_input_field__data_query_field_name("dif_data_query_field_name", $data_input_type_fields["data_query_id"]["value"], isset($data_input_type_fields["data_query_field_name"]["value"]) ? $data_input_type_fields["data_query_field_name"]["value"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]);
            _data_source_input_field__data_query_field_value("dif_data_query_field_value", isset($data_input_type_fields["data_query_field_name"]["value"]) ? $data_input_type_fields["data_query_field_value"]["value"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]);
            $num_output_fields += 2;
        }
        $num_output_fields += draw_nontemplated_fields_data_source($data_source["data_template_id"], $data_source, "ds||field|", "<strong>" . _("Data Source Fields") . "</strong>", true, true);
        $num_output_fields += draw_nontemplated_fields_data_source_item($data_source["data_template_id"], db_fetch_assoc("select * from data_source_item where data_source_id = " . $data_source["id"] . " order by data_source_name"), "dsi||field|||id|", "<strong>" . _("Data Source Item Fields") . "</strong>", true, true);
        html_end_box();
        if ($num_output_fields == 0) {
            ob_end_clean();
        } else {
            ob_end_flush();
        }
    }
    if (empty($data_source["data_template_id"]) && (isset($_GET["id"]) && is_numeric($_GET["id"]) || isset($_GET["host_id"]) && isset($_GET["data_template_id"]))) {
        /* determine current value for 'data_input_type' */
        if (isset($_GET["data_input_type"])) {
            $_data_input_type = $_GET["data_input_type"];
        } else {
            if (isset($data_source["data_input_type"])) {
                $_data_input_type = $data_source["data_input_type"];
            } else {
                $_data_input_type = DATA_INPUT_TYPE_SCRIPT;
            }
        }
        /* ==================== Box: Data Input ==================== */
        html_start_box("<strong>" . _("Data Input") . "</strong>");
        _data_source_input_field__data_input_type("data_input_type", false, $_data_input_type, empty($_GET["id"]) ? 0 : $_GET["id"]);
        /* grab the appropriate data input type form array */
        if ($_data_input_type == DATA_INPUT_TYPE_SCRIPT) {
            $scripts = api_script_list();
            if (sizeof($scripts) > 0) {
                /* determine current value for 'script_id' */
                if (isset($_GET["script_id"]) && is_numeric($_GET["script_id"])) {
                    $_script_id = $_GET["script_id"];
                } else {
                    if (isset($data_input_type_fields["script_id"])) {
                        $_script_id = $data_input_type_fields["script_id"]["value"];
                    } else {
                        /* default to the first item in the script list */
                        $_script_id = $scripts[0]["id"];
                    }
                }
                field_row_header(_("External Script"));
                _data_source_input_field__script_id("dif_script_id", "data_sources.php?action=edit" . (!empty($_GET["id"]) ? "&id=" . $_GET["id"] : "") . "&data_template_id=" . (isset($_GET["data_template_id"]) ? $_GET["data_template_id"] : (isset($data_source) ? $data_source["data_template_id"] : 0)) . "&host_id=" . (isset($_GET["host_id"]) ? $_GET["host_id"] : (isset($data_source) ? $data_source["host_id"] : 0)) . "&data_input_type={$_data_input_type}&script_id=|dropdown_value|", $_script_id);
                /* get each INPUT field for this script */
                $script_input_fields = db_fetch_assoc("select * from data_input_fields where data_input_id = {$_script_id} and input_output='in' order by name");
                if (sizeof($script_input_fields) > 0) {
                    field_row_header(_("Custom Input Fields"));
                    foreach ($script_input_fields as $field) {
                        _data_source_input_field__script("dif_" . $field["data_name"], $field["name"], false, isset($data_input_type_fields[$field["data_name"]]) ? $data_input_type_fields[$field["data_name"]]["value"] : "", "", "", isset($_GET["id"]) ? $_GET["id"] : 0);
                    }
                }
            }
        } else {
            if ($_data_input_type == DATA_INPUT_TYPE_DATA_QUERY) {
                /* determine current value for 'data_query_id' */
                if (isset($_GET["data_query_id"]) && is_numeric($_GET["data_query_id"])) {
                    $_data_query_id = $_GET["data_query_id"];
                } else {
                    if (isset($data_input_type_fields["data_query_id"])) {
                        $_data_query_id = $data_input_type_fields["data_query_id"]["value"];
                    } else {
                        /* default to the first item in the data query list */
                        $_data_query_id = $data_queries[0]["id"];
                    }
                }
                field_row_header(_("Data Query"));
                _data_source_input_field__data_query_id("dif_data_query_id", "data_sources.php?action=edit" . (!empty($_GET["id"]) ? "&id=" . $_GET["id"] : "") . "&data_template_id=" . (isset($_GET["data_template_id"]) ? $_GET["data_template_id"] : (isset($data_source) ? $data_source["data_template_id"] : 0)) . "&host_id=" . (isset($_GET["host_id"]) ? $_GET["host_id"] : (isset($data_source) ? $data_source["host_id"] : 0)) . "&data_input_type={$_data_input_type}&data_query_id=|dropdown_value|", $_data_query_id);
            } else {
                if ($_data_input_type == DATA_INPUT_TYPE_SNMP) {
                    _data_source_input_field__device_hdr_generic();
                    _data_source_input_field__device_snmp_port("dif_snmp_port", false, isset($data_input_type_fields["snmp_port"]) ? $data_input_type_fields["snmp_port"]["value"] : "", isset($_GET["id"]) ? $_GET["id"] : 0);
                    _data_source_input_field__device_snmp_timeout("dif_snmp_timeout", false, isset($data_input_type_fields["snmp_timeout"]) ? $data_input_type_fields["snmp_timeout"]["value"] : "", isset($_GET["id"]) ? $_GET["id"] : 0);
                    _data_source_input_field__device_snmp_version("dif_snmp_version", false, isset($data_input_type_fields["snmp_version"]) ? $data_input_type_fields["snmp_version"]["value"] : "", isset($_GET["id"]) ? $_GET["id"] : 0);
                    _data_source_input_field__device_hdr_snmpv12();
                    _data_source_input_field__device_snmp_community("dif_snmp_community", false, isset($data_input_type_fields["snmp_community"]) ? $data_input_type_fields["snmp_community"]["value"] : "", isset($_GET["id"]) ? $_GET["id"] : 0);
                    _data_source_input_field__device_hdr_snmpv3();
                    _data_source_input_field__device_snmpv3_auth_username("dif_snmpv3_auth_username", false, isset($data_input_type_fields["snmpv3_auth_username"]) ? $data_input_type_fields["snmpv3_auth_username"]["value"] : "", isset($_GET["id"]) ? $_GET["id"] : 0);
                    _data_source_input_field__device_snmpv3_auth_password("dif_snmpv3_auth_password", false, isset($data_input_type_fields["snmpv3_auth_password"]) ? $data_input_type_fields["snmpv3_auth_password"]["value"] : "", isset($_GET["id"]) ? $_GET["id"] : 0);
                    _data_source_input_field__device_snmpv3_auth_protocol("dif_snmpv3_auth_protocol", false, isset($data_input_type_fields["snmpv3_auth_protocol"]) ? $data_input_type_fields["snmpv3_auth_protocol"]["value"] : "", isset($_GET["id"]) ? $_GET["id"] : 0);
                    _data_source_input_field__device_snmpv3_priv_passphrase("dif_snmpv3_priv_passphrase", false, isset($data_input_type_fields["snmpv3_priv_passphrase"]) ? $data_input_type_fields["snmpv3_priv_passphrase"]["value"] : "", isset($_GET["id"]) ? $_GET["id"] : 0);
                    _data_source_input_field__device_snmpv3_priv_protocol("dif_snmpv3_priv_protocol", false, isset($data_input_type_fields["snmpv3_priv_protocol"]) ? $data_input_type_fields["snmpv3_priv_protocol"]["value"] : "", isset($_GET["id"]) ? $_GET["id"] : 0);
                }
            }
        }
        html_end_box();
        /* ==================== Box: Data Source ==================== */
        if (empty($_GET["id"])) {
            $rra_items = array();
        } else {
            $rra_items = api_data_source_rra_item_list($data_source["id"]);
        }
        html_start_box("<strong>" . _("Data Source") . "</strong>");
        _data_source_field__name("ds|name", false, empty($_GET["id"]) ? 0 : $_GET["id"]);
        _data_source_field__rra("preset_rra_id", false, isset($data_source["preset_rra_id"]) ? $data_source["preset_rra_id"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]);
        _data_source_field__polling_interval("ds|polling_interval", false, isset($data_source["polling_interval"]) ? $data_source["polling_interval"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]);
        _data_source_field__active("ds|active", false, isset($data_source["active"]) ? $data_source["active"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]);
        html_end_box();
        /* ==================== Box: Data Source Item ==================== */
        html_start_box("<strong>" . _("Data Source Item") . "</strong>", empty($_GET["id"]) ? "" : "javascript:document.forms[0].action.value='item_add';submit_redirect(0, '" . htmlspecialchars("data_sources.php?action=item_add&id=" . $_GET["id"]) . "', '')");
        /* the user clicked the "add item" link. we need to make sure they get redirected back to
         * this page if an error occurs */
        if ($_GET["action"] == "item_add") {
            form_hidden_box("redirect_item_add", "x", "");
        }
        /* this allows a "blank" data template item to be displayed when the user wants to create
         * a new one */
        if (!isset($data_source_items) || sizeof($data_source_items) == 0 || $_GET["action"] == "item_add") {
            if (isset($data_source_items)) {
                $next_index = sizeof($data_source_items);
            } else {
                $next_index = 0;
            }
            $data_source_items[$next_index] = array();
        }
        if (sizeof($data_source_items) > 0) {
            if ($_data_input_type == DATA_INPUT_TYPE_SCRIPT) {
                $script_output_fields = db_fetch_assoc("select * from data_input_fields where data_input_id = {$_script_id} and input_output='out' order by name");
                $field_input_description = _("Script Output Field");
            } else {
                if ($_data_input_type == DATA_INPUT_TYPE_DATA_QUERY) {
                    $field_list = api_data_query_field_list($_data_query_id, DATA_QUERY_FIELD_TYPE_OUTPUT);
                    $data_query_output_fields = array();
                    if (sizeof($field_list) > 0) {
                        foreach ($field_list as $field) {
                            $data_query_output_fields[$field["name"]] = $field["name"] . " (" . $field["name_desc"] . ")";
                        }
                    }
                    $field_input_description = _("Data Query Output Field");
                } else {
                    if ($_data_input_type == DATA_INPUT_TYPE_SNMP) {
                        $field_input_description = _("SNMP OID");
                    }
                }
            }
            foreach ($data_source_items as $item) {
                if ($_data_input_type != DATA_INPUT_TYPE_NONE) {
                    ?>
					<tr bgcolor="<?php 
                    print $colors["header_panel_background"];
                    ?>
">
						<td class='textSubHeaderDark' colspan="2">
							<?php 
                    print isset($item["data_source_name"]) ? $item["data_source_name"] : "(" . _("New Data Source Item") . ")";
                    ?>
						</td>
						<td class='textSubHeaderDark' align='right'>
							<?php 
                    if (isset($item["id"]) && sizeof($data_source_items) > 1) {
                        print "[<a href='data_sources.php?action=item_remove&id=" . $item["id"] . "&data_source_id=" . $item["data_source_id"] . "' class='linkOverDark'>remove</a>]\n";
                    }
                    ?>
						</td>
					</tr>
					<tr bgcolor="#e1e1e1">
						<td width="50%" style="border-bottom: 1px solid #a1a1a1;">
							<font class='textEditTitle'>Field Input: <?php 
                    print $field_input_description;
                    ?>
</font><br>
						</td>
						<td style="border-bottom: 1px solid #a1a1a1;" colspan="2">
							<?php 
                    if ($_data_input_type == DATA_INPUT_TYPE_SCRIPT) {
                        form_dropdown("dsi|field_input_value|" . (isset($item["id"]) ? $item["id"] : "0"), $script_output_fields, "name", "data_name", isset($item["field_input_value"]) ? $item["field_input_value"] : "", "", "");
                    } else {
                        if ($_data_input_type == DATA_INPUT_TYPE_DATA_QUERY) {
                            form_dropdown("dsi|field_input_value|" . (isset($item["id"]) ? $item["id"] : "0"), $data_query_output_fields, "", "", isset($item["field_input_value"]) ? $item["field_input_value"] : "", "", "");
                        } else {
                            if ($_data_input_type == DATA_INPUT_TYPE_SNMP) {
                                form_text_box("dsi|field_input_value|" . (isset($item["id"]) ? $item["id"] : "0"), isset($item["field_input_value"]) ? $item["field_input_value"] : "", "", "100", 40, "text", 0);
                            }
                        }
                    }
                    ?>
						</td>
					</tr>
					<?php 
                }
                $_field_id = isset($item["id"]) ? $item["id"] : 0;
                field_reset_row_color();
                field_increment_row_color();
                _data_source_item_field__data_source_name("dsi|data_source_name|{$_field_id}", false, isset($item["data_source_name"]) ? $item["data_source_name"] : "", $_field_id);
                _data_source_item_field__rrd_minimum("dsi|rrd_minimum|{$_field_id}", false, isset($item["rrd_minimum"]) ? $item["rrd_minimum"] : "", $_field_id, "dsi|t_rrd_minimum|{$_field_id}");
                _data_source_item_field__rrd_maximum("dsi|rrd_maximum|{$_field_id}", false, isset($item["rrd_maximum"]) ? $item["rrd_maximum"] : "", $_field_id, "dsi|t_rrd_maximum|{$_field_id}");
                _data_source_item_field__data_source_type("dsi|data_source_type|{$_field_id}", false, isset($item["data_source_type"]) ? $item["data_source_type"] : "", $_field_id, "dsi|t_data_source_type|{$_field_id}");
                _data_source_item_field__rrd_heartbeat("dsi|rrd_heartbeat|{$_field_id}", false, isset($item["rrd_heartbeat"]) ? $item["rrd_heartbeat"] : "", $_field_id, "dsi|t_rrd_heartbeat|{$_field_id}");
            }
        }
        html_end_box();
    }
    /* display the debug mode box if the user wants it */
    if (isset($_SESSION["ds_debug_mode"]) && isset($_GET["id"])) {
        html_start_box("<strong>Data Source Debug</strong>", "98%", $colors["header_background"], "3", "center", "");
        print "<tr><td bgcolor=#'" . $colors["messagebar_background"] . "' <pre>" . rrdtool_function_create($_GET["id"], true, array()) . "</pre></td></tr>";
        html_end_box();
    }
    if (isset($_GET["id"]) || isset($_GET["host_id"]) && isset($_GET["data_template_id"])) {
        form_hidden_box("action_post", "data_source_edit");
    } else {
        form_hidden_box("action_post", "data_source_add");
    }
    form_hidden_box("data_source_id", get_get_var_number("id"));
    form_save_button("data_sources.php");
}