Example #1
0
		header("Location: data_queries.php?action=item_edit&id=" . $_GET["snmp_query_graph_id"] . "&snmp_query_id=" . $_GET["snmp_query_id"]);
		break;
	case 'item_remove':
		data_query_item_remove();

		header("Location: data_queries.php?action=edit&id=" . $_GET["snmp_query_id"]);
		break;
	case 'item_edit':
		include_once("./include/top_header.php");

		data_query_item_edit();

		include_once("./include/bottom_footer.php");
		break;
	case 'remove':
		data_query_remove();

		header ("Location: data_queries.php");
		break;
	case 'edit':
		include_once("./include/top_header.php");

		data_query_edit();

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

		data_query();
Example #2
0
function form_actions() {
	global $colors, $dq_actions;

	/* if we are to save this form, instead of display it */
	if (isset($_POST["selected_items"])) {
		$selected_items = unserialize(stripslashes($_POST["selected_items"]));

		if ($_POST["drp_action"] == "1") { /* delete */
			for ($i=0;($i<count($selected_items));$i++) {
				/* ================= input validation ================= */
				input_validate_input_number($selected_items[$i]);
				/* ==================================================== */

				 data_query_remove($selected_items[$i]);
			}
		}

		header("Location: data_queries.php");
		exit;
	}

	/* setup some variables */
	$dq_list = ""; $i = 0;

	/* loop through each of the data queries and process them */
	while (list($var,$val) = each($_POST)) {
		if (ereg("^chk_([0-9]+)$", $var, $matches)) {
			/* ================= input validation ================= */
			input_validate_input_number($matches[1]);
			/* ==================================================== */

			$dq_list .= "<li>" . db_fetch_cell("SELECT snmp_query.name FROM snmp_query WHERE id='" . $matches[1] . "'") . "<br>";
			$dq_array[$i] = $matches[1];
		}

		$i++;
	}

	include_once("./include/top_header.php");

	html_start_box("<strong>" . $dq_actions{$_POST["drp_action"]} . "</strong>", "60%", $colors["header_panel"], "3", "center", "");

	print "<form action='data_queries.php' method='post'>\n";

	if ($_POST["drp_action"] == "1") { /* delete */
		$graphs = array();

		print "
			<tr>
				<td class='textArea' bgcolor='#" . $colors["form_alternate1"]. "'>
					<p>Are you sure you want to delete the following data queries?</p>
					<p>$dq_list</p>
				</td>
			</tr>\n";
	}

	if (!isset($dq_array)) {
		print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one data query.</span></td></tr>\n";
		$save_html = "";
	}else{
		$save_html = "<input type='image' src='images/button_yes.gif' alt='Save' align='absmiddle'>";
	}

	print "	<tr>
			<td align='right' bgcolor='#eaeaea'>
				<input type='hidden' name='action' value='actions'>
				<input type='hidden' name='selected_items' value='" . (isset($dq_array) ? serialize($dq_array) : '') . "'>
				<input type='hidden' name='drp_action' value='" . $_POST["drp_action"] . "'>
				<a href='data_queries.php'><img src='images/button_no.gif' alt='Cancel' align='absmiddle' border='0'></a>
				$save_html
			</td>
		</tr>
		";

	html_end_box();

	include_once("./include/bottom_footer.php");
}
Example #3
0
function form_actions()
{
    global $dq_actions;
    /* ================= input validation ================= */
    input_validate_input_regex(get_request_var_post('drp_action'), '^([a-zA-Z0-9_]+)$');
    /* ==================================================== */
    /* if we are to save this form, instead of display it */
    if (isset($_POST['selected_items'])) {
        $selected_items = unserialize(stripslashes($_POST['selected_items']));
        if ($_POST['drp_action'] == '1') {
            /* delete */
            for ($i = 0; $i < count($selected_items); $i++) {
                /* ================= input validation ================= */
                input_validate_input_number($selected_items[$i]);
                /* ==================================================== */
                data_query_remove($selected_items[$i]);
            }
        }
        header('Location: data_queries.php');
        exit;
    }
    /* setup some variables */
    $dq_list = '';
    $i = 0;
    /* loop through each of the data queries and process them */
    while (list($var, $val) = each($_POST)) {
        if (preg_match('/^chk_([0-9]+)$/', $var, $matches)) {
            /* ================= input validation ================= */
            input_validate_input_number($matches[1]);
            /* ==================================================== */
            $dq_list .= '<li>' . htmlspecialchars(db_fetch_cell_prepared('SELECT snmp_query.name FROM snmp_query WHERE id = ?', array($matches[1]))) . '<br>';
            $dq_array[$i] = $matches[1];
            $i++;
        }
    }
    top_header();
    html_start_box('<strong>' . $dq_actions[$_POST['drp_action']] . '</strong>', '60%', '', '3', 'center', '');
    print "<form action='data_queries.php' method='post'>\n";
    if (isset($dq_array) && sizeof($dq_array)) {
        if ($_POST['drp_action'] == '1') {
            /* delete */
            $graphs = array();
            print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea' class='odd'>\n\t\t\t\t\t\t<p>When you click \"Continue\" the following Data Querie(s) will be deleted.</p>\n\t\t\t\t\t\t<p><ul>{$dq_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
        }
        $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Delete Data Querie(s)'>";
    } else {
        print "<tr><td class='odd'><span class='textError'>You must select at least one data query.</span></td></tr>\n";
        $save_html = "<input type='button' value='Return' onClick='window.history.back()'>";
    }
    print "\t<tr>\n\t\t\t<td align='right' class='saveRow'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($dq_array) ? serialize($dq_array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . $_POST['drp_action'] . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n\t\t";
    html_end_box();
    bottom_footer();
}
Example #4
0
function form_actions()
{
    global $colors, $dq_actions;
    /* if we are to save this form, instead of display it */
    if (isset($_POST["selected_items"])) {
        $selected_items = unserialize(stripslashes($_POST["selected_items"]));
        if ($_POST["drp_action"] == "1") {
            /* delete */
            for ($i = 0; $i < count($selected_items); $i++) {
                /* ================= input validation ================= */
                input_validate_input_number($selected_items[$i]);
                /* ==================================================== */
                data_query_remove($selected_items[$i]);
            }
        }
        header("Location: data_queries.php");
        exit;
    }
    /* setup some variables */
    $dq_list = "";
    $i = 0;
    /* loop through each of the data queries and process them */
    while (list($var, $val) = each($_POST)) {
        if (preg_match("/^chk_([0-9]+)\$/", $var, $matches)) {
            /* ================= input validation ================= */
            input_validate_input_number($matches[1]);
            /* ==================================================== */
            $dq_list .= "<li>" . htmlspecialchars(db_fetch_cell("SELECT snmp_query.name FROM snmp_query WHERE id='" . $matches[1] . "'")) . "<br>";
            $dq_array[$i] = $matches[1];
            $i++;
        }
    }
    include_once "./include/top_header.php";
    html_start_box("<strong>" . $dq_actions[$_POST["drp_action"]] . "</strong>", "60%", $colors["header_panel"], "3", "center", "");
    print "<form action='data_queries.php' method='post'>\n";
    if (isset($dq_array) && sizeof($dq_array)) {
        if ($_POST["drp_action"] == "1") {
            /* delete */
            $graphs = array();
            print "\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>\r\n\t\t\t\t\t\t<p>When you click \"Continue\" the following Data Querie(s) will be deleted.</p>\r\n\t\t\t\t\t\t<p><ul>{$dq_list}</ul></p>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\n";
        }
        $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Delete Data Querie(s)'>";
    } else {
        print "<tr><td bgcolor='#" . $colors["form_alternate1"] . "'><span class='textError'>You must select at least one data query.</span></td></tr>\n";
        $save_html = "<input type='button' value='Return' onClick='window.history.back()'>";
    }
    print "\t<tr>\r\n\t\t\t<td align='right' bgcolor='#eaeaea'>\r\n\t\t\t\t<input type='hidden' name='action' value='actions'>\r\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($dq_array) ? serialize($dq_array) : '') . "'>\r\n\t\t\t\t<input type='hidden' name='drp_action' value='" . $_POST["drp_action"] . "'>\r\n\t\t\t\t{$save_html}\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t\t";
    html_end_box();
    include_once "./include/bottom_footer.php";
}
Example #5
0
function form_actions() {
	global $colors, $dq_actions;

	/* if we are to save this form, instead of display it */
	if (isset($_POST["selected_items"])) {
		$selected_items = unserialize(stripslashes($_POST["selected_items"]));

		if (get_request_var_post("drp_action") === "1") { /* delete */
			/* do a referential integrity check */
			if (sizeof($selected_items)) {
			foreach($selected_items as $query_id) {
				/* ================= input validation ================= */
				input_validate_input_number($query_id);
				/* ==================================================== */

				$graph_templates = db_fetch_assoc("SELECT DISTINCT graph_template_id AS id FROM snmp_query_graph WHERE snmp_query_id=$query_id");

				$in_clause = "";
				if (sizeof($graph_templates)) {
				foreach($graph_templates as $graph_template) {
					$in_clause .= (strlen($in_clause) ? ", ":"") . $graph_template["id"];
				}
				}

				if (sizeof(db_fetch_assoc("SELECT * FROM graph_templates_graph WHERE graph_template_id IN($in_clause) LIMIT 1"))) {
					$bad_ids[] = $query_id;
				}else{
					$query_ids[] = $query_id;
				}
			}
			}

			if (isset($bad_ids)) {
				$message = "";
				foreach($bad_ids as $query_id) {
					$message .= (strlen($message) ? "<br>":"") . "<i>Data Query " . $query_id . " is in use and can not be removed</i>\n";
				}

				$_SESSION['sess_message_dt_ref_int'] = array('message' => "<font size=-2>$message</font>", 'type' => 'info');

				raise_message('dt_ref_int');
			}

			if (isset($query_ids)) {
				foreach($query_ids as $query_id) {
					/* ================= input validation ================= */
					input_validate_input_number($query_id);
					/* ==================================================== */

					 data_query_remove($query_id);
				}
			}
		}

		header("Location: data_queries.php");
		exit;
	}

	/* setup some variables */
	$dq_list = ""; $i = 0; $dq_array = array();

	/* loop through each of the data queries and process them */
	while (list($var,$val) = each($_POST)) {
		if (preg_match("/^chk_([0-9]+)$/", $var, $matches)) {
			/* ================= input validation ================= */
			input_validate_input_number($matches[1]);
			/* ==================================================== */

			$dq_list .= "<li>" . db_fetch_cell("SELECT snmp_query.name FROM snmp_query WHERE id='" . $matches[1] . "'") . "<br>";
			$dq_array[$i] = $matches[1];
		}

		$i++;
	}

	include_once(CACTI_BASE_PATH . "/include/top_header.php");

	html_start_box("<strong>" . $dq_actions{get_request_var_post("drp_action")} . "</strong>", "60", $colors["header_panel"], "3", "center", "");

	print "<form action='data_queries.php' method='post'>\n";

	if (sizeof($dq_array)) {
		if (get_request_var_post("drp_action") === ACTION_NONE) { /* NONE */
			print "	<tr>
						<td class='textArea'>
							<p>" . __("You did not select a valid action. Please select 'Return' to return to the previous menu.") . "</p>
						</td>
					</tr>\n";
		}elseif (get_request_var_post("drp_action") === "1") { /* delete */
			$graphs = array();

			print "
				<tr>
					<td class='textArea'>
						<p>" . __("Are you sure you want to delete the following data queries?") . "</p>
						<p><ul>$dq_list</ul></p>
					</td>
				</tr>\n";
		}
	} else {
		print "	<tr>
				<td class='textArea'>
					<p>" . __("You must first select a Data Query.  Please select 'Return' to return to the previous menu.") . "</p>
				</td>
			</tr>\n";
	}

	if (!sizeof($dq_array) || get_request_var_post("drp_action") === ACTION_NONE) {
		form_return_button_alt();
	}else{
		form_yesno_button_alt(serialize($dq_array), get_request_var_post("drp_action"));
	}

	html_end_box();

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