Example #1
0
function device_edit() {
	global $colors;

	/* ================= input validation ================= */
	input_validate_input_number(get_request_var("id"));
	input_validate_input_number(get_request_var("device_id"));
	/* ==================================================== */

	display_output_messages();

	$device_tabs = array(
		"general" => __("General"),
		"newgraphs" => __("New Graphs"),
		"graphs" => __("Graphs"),
		"datasources" => __("Data Sources")
	);

	if (!empty($_REQUEST["id"])) {
		$device         = db_fetch_row("select * from device where id=" . $_REQUEST["id"]);
		$device_text    = "<strong>" . $device["description"] . "(" . $device["hostname"] . ")</strong>";
		$header_label = __("[edit: ") . $device["description"] . "]";
	}elseif (!empty($_GET["device_id"])) {
		$_REQUEST["id"]   = $_REQUEST["device_id"];
		$device         = db_fetch_row("select * from device where id=" . $_REQUEST["id"]);
		$device_text    = "<strong>" . $device["description"] . "(" . $device["hostname"] . ")</strong>";
		$header_label = __("[edit: ") . $device["description"] . "]";
	}else{
		$header_label = __("[new]");
		$device_text    = __("New Device");
		$device         = "";
	}

	/* set the default settings category */
	if (!isset($_REQUEST["tab"])) {
		/* there is no selected tab; select the first one */
		$current_tab = array_keys($device_tabs);
		$current_tab = $current_tab[0];
	}else{
		$current_tab = $_REQUEST["tab"];
	}

	/* draw the categories tabs on the top of the page */
	print "<table width='100%' cellspacing='0' cellpadding='0' align='center'><tr>";
	print "<td><div class='tabs'>";

	if (sizeof($device_tabs) > 0) {
	foreach (array_keys($device_tabs) as $tab_short_name) {
		print "<div class='tabDefault'><a " . (($tab_short_name == $current_tab) ? "class='tabSelected'" : "class='tabDefault'") . " href='" . htmlspecialchars("devices.php?action=edit" . (isset($_REQUEST['id']) ? "&id=" . $_REQUEST['id'] . "&device_id=" . $_REQUEST['id']: "") . "&tab=$tab_short_name") . "'>$device_tabs[$tab_short_name]</a></div>";

		if (!isset($_REQUEST["id"])) break;
	}
	}
	print "</div></td></tr></table>";

	if (!isset($_REQUEST["tab"])) {
		$_REQUEST["tab"] = "general";
	}

	switch (get_request_var_request("tab")) {
		case "newgraphs":
			include_once(CACTI_BASE_PATH . "/lib/graph/graphs_new_form.php");
			include_once(CACTI_BASE_PATH . "/lib/data_query.php");
			include_once(CACTI_BASE_PATH . "/lib/utility.php");
			include_once(CACTI_BASE_PATH . "/lib/sort.php");
			include_once(CACTI_BASE_PATH . "/lib/html_form_template.php");
			include_once(CACTI_BASE_PATH . "/lib/template.php");

			graphs_new();

			break;
		case "datasources":
			include_once(CACTI_BASE_PATH . "/lib/data_source/data_source_form.php");
			include_once(CACTI_BASE_PATH . "/lib/utility.php");
			include_once(CACTI_BASE_PATH . "/lib/api_graph.php");
			include_once(CACTI_BASE_PATH . "/lib/api_data_source.php");
			include_once(CACTI_BASE_PATH . "/lib/template.php");
			include_once(CACTI_BASE_PATH . "/lib/html_form_template.php");
			include_once(CACTI_BASE_PATH . "/lib/rrd.php");
			include_once(CACTI_BASE_PATH . "/lib/data_query.php");

			data_source();

			break;
		case "graphs":
			include_once(CACTI_BASE_PATH . "/lib/graph/graphs_form.php");
			include_once(CACTI_BASE_PATH . "/lib/utility.php");
			include_once(CACTI_BASE_PATH . "/lib/api_graph.php");
			include_once(CACTI_BASE_PATH . "/lib/api_tree.php");
			include_once(CACTI_BASE_PATH . "/lib/api_data_source.php");
			include_once(CACTI_BASE_PATH . "/lib/template.php");
			include_once(CACTI_BASE_PATH . "/lib/html_tree.php");
			include_once(CACTI_BASE_PATH . "/lib/html_form_template.php");
			include_once(CACTI_BASE_PATH . "/lib/rrd.php");
			include_once(CACTI_BASE_PATH . "/lib/data_query.php");

			graph();

			break;
		default:
			device_display_general($device, $device_text);

			break;
	}
}
Example #2
0
/**
 * data_source_template_edit	- edit the data template
 */
function data_source_template_edit() {
	/* ================= input validation ================= */
	input_validate_input_number(get_request_var("id"));
	input_validate_input_number(get_request_var("view_rrd"));
	/* ==================================================== */

	display_output_messages();

	$data_template_tabs = array(
		"general" 		=> __("General"),
		"items" 		=> __("Items"),
		"datasources" 	=> __("Data Sources")
	);

	if (!empty($_GET["id"])) {
		$data_template = db_fetch_row("SELECT * FROM data_template WHERE id=" . $_REQUEST["id"]);
		$header_label = __("[edit: ") . $data_template["name"] . "]";
	}else{
		$data_template = array();
		$header_label = __("[new]");
	}

	/* set the default settings category */
	if (!isset($_REQUEST["tab"])) {
		/* there is no selected tab; select the first one */
		$current_tab = array_keys($data_template_tabs);
		$current_tab = $current_tab[0];
	}else{
		$current_tab = $_REQUEST["tab"];
	}

	/* draw the categories tabs on the top of the page */
	print "<table width='100%' cellspacing='0' cellpadding='0' align='center'><tr>";
	print "<td><div class='tabs'>";

	if (sizeof($data_template_tabs) > 0) {
		foreach (array_keys($data_template_tabs) as $tab_short_name) {
			print "<div class='tabDefault'><a " . (($tab_short_name == $current_tab) ? "class='tabSelected'" : "class='tabDefault'") . " href='" . htmlspecialchars("data_templates.php?action=template_edit" . (isset($_REQUEST['id']) ? "&id=" . $_REQUEST['id'] . "&template_id=" . $_REQUEST['id']: "") . "&filter=&device_id=-1&tab=$tab_short_name") . "'>$data_template_tabs[$tab_short_name]</a></div>";

			if (!isset($_REQUEST["id"])) break;
		}
	}
	print "</div></td></tr></table>";

	if (!isset($_REQUEST["tab"])) {
		$_REQUEST["tab"] = "general";
	}

	switch (get_request_var_request("tab")) {
		case "datasources":
			include_once(CACTI_BASE_PATH . "/lib/data_source/data_source_form.php");
			include_once(CACTI_BASE_PATH . "/lib/utility.php");
			include_once(CACTI_BASE_PATH . "/lib/api_graph.php");
			include_once(CACTI_BASE_PATH . "/lib/api_data_source.php");
			include_once(CACTI_BASE_PATH . "/lib/template.php");
			include_once(CACTI_BASE_PATH . "/lib/html_form_template.php");
			include_once(CACTI_BASE_PATH . "/lib/rrd.php");
			include_once(CACTI_BASE_PATH . "/lib/data_query.php");

			data_source();

			break;

		case "items":
			/* graph item list goes here */
			if (!empty($_GET["id"])) {
				data_template_display_items();
			}

			break;
		default:
			data_source_template_display_general($data_template, $header_label);

			break;
	}
}
Example #3
0
		break;
	case 'data_source_data_edit':
		include_once(CACTI_BASE_PATH . "/include/top_header.php");

		data_source_data_edit();

		include_once(CACTI_BASE_PATH . "/include/bottom_footer.php");
		break;
	case 'ds_remove':
		ds_remove();

		header ("Location: data_sources.php");
		break;
	case 'data_source_edit':
		data_source_edit();

		break;

	case 'data_source_toggle_status':
		data_source_toggle_status();

		break;
	default:
		include_once(CACTI_BASE_PATH . "/include/top_header.php");

		data_source();

		include_once(CACTI_BASE_PATH . "/include/bottom_footer.php");
		break;
}