Exemplo n.º 1
0
function templates()
{
    global $config, $colors, $ds_actions;
    html_start_box('<strong>GPS Templates</strong>', '100%', $colors['header'], '3', 'center', 'gpstemplates.php?action=add');
    html_header_checkbox(array('Host Template', 'Up Image', 'Recovering Image', 'Down Image', 'Is AP'));
    $template_list = db_fetch_assoc('SELECT * FROM gpsmap_templates ORDER BY templateID');
    $i = 0;
    if (sizeof($template_list) > 0) {
        foreach ($template_list as $template) {
            if ($template['AP']) {
                $isAP = "True";
            } else {
                $isAP = "False";
            }
            form_alternate_row_color($colors["alternate"], $colors["light"], $i, 'line' . $template["templateID"]);
            $i++;
            form_selectable_cell($template['templateName'], $template["templateID"]);
            form_selectable_cell($template['upimage'], $template["templateID"]);
            form_selectable_cell($template['recoverimage'], $template["templateID"]);
            form_selectable_cell($template['downimage'], $template["templateID"]);
            form_selectable_cell($isAP, $template["templateID"]);
            form_checkbox_cell($template['templateID'], $template["templateID"]);
            form_end_row();
        }
    } else {
        print "<tr><td><em>No Data Templates</em></td></tr>\n";
    }
    html_end_box(false);
    /* draw the dropdown containing a list of available actions for this form */
    draw_actions_dropdown($ds_actions);
    print "</form>\n";
}
Exemplo n.º 2
0
function draw_edit_form($array) {
	global $colors;

	//print "<pre>";print_r($array);print "</pre>";

	if (sizeof($array) > 0) {
		while (list($top_branch, $top_children) = each($array)) {
			if ($top_branch == "config") {
				$config_array = $top_children;
			}elseif ($top_branch == "fields") {
				$fields_array = $top_children;
			}
		}
	}

	$i = 0;
	if (sizeof($fields_array) > 0) {
		while (list($field_name, $field_array) = each($fields_array)) {
			if ($i == 0) {
				if (!isset($config_array["no_form_tag"])) {
					print "<form method='post' action='" . ((isset($config_array["post_to"])) ? $config_array["post_to"] : basename($_SERVER["PHP_SELF"])) . "'" . ((isset($config_array["form_name"])) ? " name='" . $config_array["form_name"] . "'" : "") . ">\n";
				}
			}

			if ($field_array["method"] == "hidden") {
				form_hidden_box($field_name, $field_array["value"], ((isset($field_array["default"])) ? $field_array["default"] : ""));
			}elseif ($field_array["method"] == "hidden_zero") {
				form_hidden_box($field_name, $field_array["value"], "0");
			}elseif ($field_array["method"] == "spacer") {
				print "<tr bgcolor='" . $colors["header_panel"] . "'><td colspan='2' class='textSubHeaderDark'>" . $field_array["friendly_name"] . "</td></tr>\n";
			}else{
				if (isset($config_array["force_row_color"])) {
					print "<tr bgcolor='#" . $config_array["force_row_color"] . "'>";
				}else{
					form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i);
				}

				print "<td width='" . ((isset($config_array["left_column_width"])) ? $config_array["left_column_width"] : "50%") . "'>\n<font class='textEditTitle'>" . $field_array["friendly_name"] . "</font><br>\n";

				if (isset($field_array["sub_checkbox"])) {
					form_checkbox($field_array["sub_checkbox"]["name"], $field_array["sub_checkbox"]["value"], $field_array["sub_checkbox"]["friendly_name"], "", ((isset($field_array["form_id"])) ? $field_array["form_id"] : ""));
				}

				print ((isset($field_array["description"])) ? $field_array["description"] : "") . "</td>\n";

				print "<td>";

				draw_edit_control($field_name, $field_array);

				print "</td>\n</tr>\n";

				$i++;
			}

			if ($i == sizeof($fields_array)) {
				//print "</form>";
			}
		}
	}
}
Exemplo n.º 3
0
function draw_edit_form($array)
{
    global $colors;
    if (sizeof($array) > 0) {
        while (list($top_branch, $top_children) = each($array)) {
            if ($top_branch == "config") {
                $config_array = $top_children;
            } elseif ($top_branch == "fields") {
                $fields_array = $top_children;
            }
        }
    }
    $i = 0;
    if (sizeof($fields_array) > 0) {
        while (list($field_name, $field_array) = each($fields_array)) {
            if ($i == 0) {
                if (!isset($config_array["no_form_tag"])) {
                    print "<tr style='display:none;'><td><form method='post' autocomplete='off' action='" . (isset($config_array["post_to"]) ? $config_array["post_to"] : basename($_SERVER["PHP_SELF"])) . "'" . (isset($config_array["form_name"]) ? " name='" . $config_array["form_name"] . "'" : "") . (isset($config_array["enctype"]) ? " enctype='" . $config_array["enctype"] . "'" : "") . "></td></tr>\n";
                }
            }
            if ($field_array["method"] == "hidden") {
                form_hidden_box($field_name, $field_array["value"], isset($field_array["default"]) ? $field_array["default"] : "");
            } elseif ($field_array["method"] == "hidden_zero") {
                form_hidden_box($field_name, $field_array["value"], "0");
            } elseif ($field_array["method"] == "spacer") {
                print "<tr id='row_{$field_name}' bgcolor='#" . $colors["header_panel"] . "'><td colspan='2' class='tableSubHeaderColumn'>" . $field_array["friendly_name"] . "</td></tr>\n";
            } else {
                if (isset($config_array["force_row_color"])) {
                    print "<tr id='row_{$field_name}' bgcolor='#" . $config_array["force_row_color"] . "'>";
                } else {
                    form_alternate_row_color($colors["form_alternate1"], $colors["form_alternate2"], $i, 'row_' . $field_name);
                }
                print "<td width='" . (isset($config_array["left_column_width"]) ? $config_array["left_column_width"] : "50%") . "'>\n<font class='textEditTitle'>" . $field_array["friendly_name"] . "</font><br>\n";
                if (isset($field_array["sub_checkbox"])) {
                    form_checkbox($field_array["sub_checkbox"]["name"], $field_array["sub_checkbox"]["value"], $field_array["sub_checkbox"]["friendly_name"], "", isset($check_array["on_change"]) ? $check_array["on_change"] : "", isset($field_array["form_id"]) ? $field_array["form_id"] : "");
                }
                print (isset($field_array["description"]) ? $field_array["description"] : "") . "</td>\n";
                print "<td>";
                draw_edit_control($field_name, $field_array);
                print "</td>\n</tr>\n";
            }
            $i++;
        }
    }
}
Exemplo n.º 4
0
function import()
{
    global $colors, $hash_type_names;
    ?>
	<form method="post" action="templates_import.php" enctype="multipart/form-data">
	<?php 
    if (isset($_SESSION["import_debug_info"]) && is_array($_SESSION["import_debug_info"])) {
        html_start_box("<strong>Import Results</strong>", "100%", "aaaaaa", "3", "center", "");
        print "<tr bgcolor='#" . $colors["form_alternate1"] . "'><td><p class='textArea'>Cacti has imported the following items:</p>";
        while (list($type, $type_array) = each($_SESSION["import_debug_info"])) {
            print "<p><strong>" . $hash_type_names[$type] . "</strong></p>";
            while (list($index, $vals) = each($type_array)) {
                if ($vals["result"] == "success") {
                    $result_text = "<span style='color: green;'>[success]</span>";
                } else {
                    $result_text = "<span style='color: red;'>[fail]</span>";
                }
                if ($vals["type"] == "update") {
                    $type_text = "<span style='color: gray;'>[update]</span>";
                } else {
                    $type_text = "<span style='color: blue;'>[new]</span>";
                }
                print "<span style='font-family: monospace;'>{$result_text} " . $vals["title"] . " {$type_text}</span><br>\n";
                $dep_text = "";
                $there_are_dep_errors = false;
                if (isset($vals["dep"]) && sizeof($vals["dep"]) > 0) {
                    while (list($dep_hash, $dep_status) = each($vals["dep"])) {
                        if ($dep_status == "met") {
                            $dep_status_text = "<span style='color: navy;'>Found Dependency:</span>";
                        } else {
                            $dep_status_text = "<span style='color: red;'>Unmet Dependency:</span>";
                            $there_are_dep_errors = true;
                        }
                        $dep_text .= "<span style='font-family: monospace;'>&nbsp;&nbsp;&nbsp;+ {$dep_status_text} " . hash_to_friendly_name($dep_hash, true) . "</span><br>\n";
                    }
                }
                /* only print out dependency details if they contain errors; otherwise it would get too long */
                if ($there_are_dep_errors == true) {
                    print $dep_text;
                }
            }
        }
        print "</td></tr>";
        html_end_box();
        kill_session_var("import_debug_info");
    }
    html_start_box("<strong>Import Templates</strong>", "100%", $colors["header"], "3", "center", "");
    form_alternate_row_color($colors["form_alternate1"], $colors["form_alternate2"], 0);
    ?>
		<td width="50%">
			<font class="textEditTitle">Import Template from Local File</font><br>
			If the XML file containing template data is located on your local machine, select it here.
		</td>
		<td>
			<input type="file" name="import_file">
		</td>
	</tr>

	<?php 
    form_alternate_row_color($colors["form_alternate1"], $colors["form_alternate2"], 1);
    ?>
		<td width="50%">
			<font class="textEditTitle">Import Template from Text</font><br>
			If you have the XML file containing template data as text, you can paste it into this box to
			import it.
		</td>
		<td>
			<?php 
    form_text_area("import_text", "", "10\t", "50", "");
    ?>
		</td>
	</tr>

	<?php 
    form_alternate_row_color($colors["form_alternate1"], $colors["form_alternate2"], 0);
    ?>
		<td width="50%">
			<font class="textEditTitle">Import RRA Settings</font><br>
			Choose whether to allow Cacti to import custom RRA settings from imported templates or whether to use the defaults for this installation.
		</td>
		<td>
			<?php 
    form_radio_button("import_rra", 1, 1, "Use defaults for this installation (Recommended)", 1);
    echo "<br />";
    form_radio_button("import_rra", 1, 2, "Use custom RRA settings from the template", 1);
    ?>
		</td>
	</tr>

	<?php 
    form_hidden_box("save_component_import", "1", "");
    html_end_box();
    form_save_button("templates_import.php", "save");
}
Exemplo n.º 5
0
function draw_nontemplated_fields_custom_data($data_template_data_id, $field_name_format = "|field|", $header_title = "", $alternate_colors = true, $include_hidden_fields = true, $snmp_query_id = 0) {
	global $colors;

	$data = db_fetch_row("select id,data_input_id,data_template_id,name,local_data_id from data_template_data where id=$data_template_data_id");
	$host_id = db_fetch_cell("select host.id from data_local,host where data_local.host_id=host.id and data_local.id=" . $data["local_data_id"]);
	$template_data = db_fetch_row("select id,data_input_id from data_template_data where data_template_id=" . $data["data_template_id"] . " and local_data_id=0");

	$draw_any_items = false;

	/* get each INPUT field for this data input source */
	$fields = db_fetch_assoc("select * from data_input_fields where data_input_id=" . $data["data_input_id"] . " and input_output='in' order by name");

	/* loop through each field found */
	$i = 0;
	if (sizeof($fields) > 0) {
	foreach ($fields as $field) {
		$data_input_data = db_fetch_row("select * from data_input_data where data_template_data_id=" . $data["id"] . " and data_input_field_id=" . $field["id"]);

		if (sizeof($data_input_data) > 0) {
			$old_value = $data_input_data["value"];
		}else{
			$old_value = "";
		}

		/* if data template then get t_value from template, else always allow user input */
		if (empty($data["data_template_id"])) {
			$can_template = "on";
		}else{
			$can_template = db_fetch_cell("select t_value from data_input_data where data_template_data_id=" . $template_data["id"] . " and data_input_field_id=" . $field["id"]);
		}

		/* find our field name */
		$form_field_name = str_replace("|id|", $field["id"], $field_name_format);

		if ((!empty($host_id)) && (eregi('^' . VALID_HOST_FIELDS . '$', $field["type_code"])) && (empty($can_template))) { /* no host fields */
			if ($include_hidden_fields == true) {
				form_hidden_box($form_field_name, $old_value, "");
			}
		}elseif ((!empty($snmp_query_id)) && (eregi('^(index_type|index_value|output_type)$', $field["type_code"]))) { /* no data query fields */
			if ($include_hidden_fields == true) {
				form_hidden_box($form_field_name, $old_value, "");
			}
		}elseif (empty($can_template)) { /* no templated fields */
			if ($include_hidden_fields == true) {
				form_hidden_box($form_field_name, $old_value, "");
			}
		}else{
			if (($draw_any_items == false) && ($header_title != "")) {
				print "<tr bgcolor='#" . $colors["header_panel"] . "'><td colspan='2' style='font-size: 10px; color: white;'>$header_title</td></tr>\n";
			}

			if ($alternate_colors == true) {
				form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i);
			}else{
				print "<tr bgcolor='#" . $colors["form_alternate1"] . "'>\n";
			}

			print "<td width='50%'><strong>" . $field["name"] . "</strong></td>\n";
			print "<td>";

			draw_custom_data_row($form_field_name, $field["id"], $data["id"], $old_value);

			print "</td>";
			print "</tr>\n";

			$draw_any_items = true;
			$i++;
		}
	}
	}

	return $i;
}
Exemplo n.º 6
0
function ds()
{
    global $colors, $ds_actions;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request("host_id"));
    input_validate_input_number(get_request_var_request("page"));
    /* ==================================================== */
    /* clean up search string */
    if (isset($_REQUEST["filter"])) {
        $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter"));
    }
    /* clean up sort_column string */
    if (isset($_REQUEST["sort_column"])) {
        $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
    }
    /* clean up sort_direction string */
    if (isset($_REQUEST["sort_direction"])) {
        $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
    }
    /* if the user pushed the 'clear' button */
    if (isset($_REQUEST["clear_x"])) {
        kill_session_var("sess_ds_current_page");
        kill_session_var("sess_ds_filter");
        kill_session_var("sess_ds_sort_column");
        kill_session_var("sess_ds_sort_direction");
        kill_session_var("sess_ds_host_id");
        unset($_REQUEST["page"]);
        unset($_REQUEST["filter"]);
        unset($_REQUEST["sort_column"]);
        unset($_REQUEST["sort_direction"]);
        unset($_REQUEST["host_id"]);
    }
    /* remember these search fields in session vars so we don't have to keep passing them around */
    load_current_session_value("page", "sess_ds_current_page", "1");
    load_current_session_value("filter", "sess_ds_filter", "");
    load_current_session_value("sort_column", "sess_ds_sort_column", "name_cache");
    load_current_session_value("sort_direction", "sess_ds_sort_direction", "ASC");
    load_current_session_value("host_id", "sess_ds_host_id", "-1");
    $host = db_fetch_row("select hostname from host where id=" . $_REQUEST["host_id"]);
    html_start_box("<strong>Data Sources</strong> [host: " . (empty($host["hostname"]) ? "No Host" : $host["hostname"]) . "]", "100%", $colors["header"], "3", "center", "data_sources.php?action=ds_edit&host_id=" . $_REQUEST["host_id"]);
    include "./include/html/inc_data_source_filter_table.php";
    html_end_box();
    /* form the 'where' clause for our main sql query */
    if (strlen($_REQUEST["filter"])) {
        $sql_where = "AND (data_template_data.name_cache like '%%" . $_REQUEST["filter"] . "%%'" . " OR data_template.name like '%%" . $_REQUEST["filter"] . "%%'" . " OR data_input.name like '%%" . $_REQUEST["filter"] . "%%')";
    } else {
        $sql_where = "";
    }
    if ($_REQUEST["host_id"] == "-1") {
        /* Show all items */
    } elseif ($_REQUEST["host_id"] == "0") {
        $sql_where .= " AND data_local.host_id=0";
    } elseif (!empty($_REQUEST["host_id"])) {
        $sql_where .= " AND data_local.host_id=" . $_REQUEST["host_id"];
    }
    $total_rows = sizeof(db_fetch_assoc("SELECT\n\t\tdata_local.id\n\t\tFROM (data_local,data_template_data)\n\t\tLEFT JOIN data_input\n\t\tON (data_input.id=data_template_data.data_input_id)\n\t\tLEFT JOIN data_template\n\t\tON (data_local.data_template_id=data_template.id)\n\t\tWHERE data_local.id=data_template_data.local_data_id\n\t\t{$sql_where}"));
    $poller_intervals = array_rekey(db_fetch_assoc("SELECT data_template_data.local_data_id AS id,\n\t\tMin(data_template_data.rrd_step*rra.steps) AS poller_interval\n\t\tFROM data_template\n\t\tINNER JOIN (data_local\n\t\tINNER JOIN ((data_template_data_rra\n\t\tINNER JOIN data_template_data ON data_template_data_rra.data_template_data_id=data_template_data.id)\n\t\tINNER JOIN rra ON data_template_data_rra.rra_id = rra.id) ON data_local.id = data_template_data.local_data_id) ON data_template.id = data_template_data.data_template_id\n\t\t{$sql_where}\n\t\tGROUP BY data_template_data.local_data_id"), "id", "poller_interval");
    $data_sources = db_fetch_assoc("SELECT\n\t\tdata_template_data.local_data_id,\n\t\tdata_template_data.name_cache,\n\t\tdata_template_data.active,\n\t\tdata_input.name as data_input_name,\n\t\tdata_template.name as data_template_name,\n\t\tdata_local.host_id\n\t\tFROM (data_local,data_template_data)\n\t\tLEFT JOIN data_input\n\t\tON (data_input.id=data_template_data.data_input_id)\n\t\tLEFT JOIN data_template\n\t\tON (data_local.data_template_id=data_template.id)\n\t\tWHERE data_local.id=data_template_data.local_data_id\n\t\t{$sql_where}\n\t\tORDER BY " . $_REQUEST['sort_column'] . " " . $_REQUEST['sort_direction'] . " LIMIT " . read_config_option("num_rows_data_source") * ($_REQUEST["page"] - 1) . "," . read_config_option("num_rows_data_source"));
    html_start_box("", "100%", $colors["header"], "3", "center", "");
    /* generate page list */
    $url_page_select = get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, read_config_option("num_rows_data_source"), $total_rows, "data_sources.php?filter=" . $_REQUEST["filter"] . "&host_id=" . $_REQUEST["host_id"]);
    $nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t<td colspan='6'>\n\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td align='left' class='textHeaderDark'>\n\t\t\t\t\t\t\t<strong>&lt;&lt; ";
    if ($_REQUEST["page"] > 1) {
        $nav .= "<a class='linkOverDark' href='data_sources.php?filter=" . $_REQUEST["filter"] . "&host_id=" . $_REQUEST["host_id"] . "&page=" . ($_REQUEST["page"] - 1) . "'>";
    }
    $nav .= "Previous";
    if ($_REQUEST["page"] > 1) {
        $nav .= "</a>";
    }
    $nav .= "</strong>\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\tShowing Rows " . (read_config_option("num_rows_data_source") * ($_REQUEST["page"] - 1) + 1) . " to " . ($total_rows < read_config_option("num_rows_data_source") || $total_rows < read_config_option("num_rows_data_source") * $_REQUEST["page"] ? $total_rows : read_config_option("num_rows_data_source") * $_REQUEST["page"]) . " of {$total_rows} [{$url_page_select}]\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td align='right' class='textHeaderDark'>\n\t\t\t\t\t\t\t<strong>";
    if ($_REQUEST["page"] * read_config_option("num_rows_data_source") < $total_rows) {
        $nav .= "<a class='linkOverDark' href='data_sources.php?filter=" . $_REQUEST["filter"] . "&host_id=" . $_REQUEST["host_id"] . "&page=" . ($_REQUEST["page"] + 1) . "'>";
    }
    $nav .= "Next";
    if ($_REQUEST["page"] * read_config_option("num_rows_data_source") < $total_rows) {
        $nav .= "</a>";
    }
    $nav .= " &gt;&gt;</strong>\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t</td>\n\t\t</tr>\n";
    print $nav;
    $display_text = array("name_cache" => array("Name", "ASC"), "data_input_name" => array("Data Input Method", "ASC"), "nosort" => array("Poller<br>Interval", "ASC"), "active" => array("Active", "ASC"), "data_template_name" => array("Template Name", "ASC"));
    html_header_sort_checkbox($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]);
    $i = 0;
    if (sizeof($data_sources) > 0) {
        foreach ($data_sources as $data_source) {
            $data_template_name = empty($data_source["data_template_name"]) ? "<em>None</em>" : $data_source["data_template_name"];
            $data_input_name = empty($data_source["data_input_name"]) ? "<em>External</em>" : $data_source["data_input_name"];
            $poller_interval = isset($poller_intervals[$data_source["local_data_id"]]) ? $poller_intervals[$data_source["local_data_id"]] : 0;
            form_alternate_row_color($colors["alternate"], $colors["light"], $i, 'line' . $data_source["local_data_id"]);
            $i++;
            form_selectable_cell("<a class='linkEditMain' href='data_sources.php?action=ds_edit&id=" . $data_source["local_data_id"] . "'>" . ($_REQUEST["filter"] != "" ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", title_trim(htmlentities($data_source["name_cache"]), read_config_option("max_title_data_source"))) : title_trim(htmlentities($data_source["name_cache"]), read_config_option("max_title_data_source"))) . "</a>", $data_source["local_data_id"]);
            form_selectable_cell(($_REQUEST["filter"] != "" ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $data_input_name) : $data_input_name) . "</a>", $data_source["local_data_id"]);
            form_selectable_cell(get_poller_interval($poller_interval), $data_source["local_data_id"]);
            form_selectable_cell($data_source['active'], $data_source["local_data_id"]);
            form_selectable_cell(($_REQUEST["filter"] != "" ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $data_source['data_template_name']) : $data_source['data_template_name']) . "</a>", $data_source["local_data_id"]);
            form_checkbox_cell($data_source["name_cache"], $data_source["local_data_id"]);
            form_end_row();
        }
        /* put the nav bar on the bottom as well */
        print $nav;
    } else {
        print "<tr><td><em>No Data Sources</em></td></tr>";
    }
    html_end_box(false);
    /* draw the dropdown containing a list of available actions for this form */
    draw_actions_dropdown($ds_actions);
    print "</form>\n";
}
Exemplo n.º 7
0
function syslog_alerts()
{
    global $colors, $syslog_actions, $config, $message_types, $severities;
    include dirname(__FILE__) . "/config.php";
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request("id"));
    input_validate_input_number(get_request_var_request("page"));
    input_validate_input_number(get_request_var_request("enabled"));
    input_validate_input_number(get_request_var_request("rows"));
    /* ==================================================== */
    /* clean up filter */
    if (isset($_REQUEST["filter"])) {
        $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter"));
    }
    /* clean up sort_column */
    if (isset($_REQUEST["sort_column"])) {
        $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
    }
    /* clean up sort direction */
    if (isset($_REQUEST["sort_direction"])) {
        $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
    }
    /* if the user pushed the 'clear' button */
    if (isset($_REQUEST["clear"])) {
        kill_session_var("sess_syslog_alerts_page");
        kill_session_var("sess_syslog_alerts_rows");
        kill_session_var("sess_syslog_alerts_filter");
        kill_session_var("sess_syslog_alerts_enabled");
        kill_session_var("sess_syslog_alerts_sort_column");
        kill_session_var("sess_syslog_alerts_sort_direction");
        $_REQUEST["page"] = 1;
        unset($_REQUEST["filter"]);
        unset($_REQUEST["enabled"]);
        unset($_REQUEST["rows"]);
        unset($_REQUEST["sort_column"]);
        unset($_REQUEST["sort_direction"]);
    } else {
        /* if any of the settings changed, reset the page number */
        $changed = 0;
        $changed += syslog_check_changed("filter", "sess_syslog_alerts_filter");
        $changed += syslog_check_changed("enabled", "sess_syslog_alerts_enabled");
        $changed += syslog_check_changed("rows", "sess_syslog_alerts_rows");
        $changed += syslog_check_changed("sort_column", "sess_syslog_alerts_sort_column");
        $changed += syslog_check_changed("sort_direction", "sess_syslog_alerts_sort_direction");
        if ($changed) {
            $_REQUEST["page"] = "1";
        }
    }
    /* remember these search fields in session vars so we don't have to keep passing them around */
    load_current_session_value("page", "sess_syslog_alerts_paage", "1");
    load_current_session_value("rows", "sess_syslog_alerts_rows", "-1");
    load_current_session_value("enabled", "sess_syslog_alerts_enabled", "-1");
    load_current_session_value("filter", "sess_syslog_alerts_filter", "");
    load_current_session_value("sort_column", "sess_syslog_alerts_sort_column", "name");
    load_current_session_value("sort_direction", "sess_syslog_alerts_sort_direction", "ASC");
    html_start_box("<strong>Syslog Alert Filters</strong>", "100%", $colors["header"], "3", "center", "syslog_alerts.php?action=edit");
    syslog_filter();
    html_end_box();
    html_start_box("", "100%", $colors["header"], "3", "center", "");
    $sql_where = "";
    if ($_REQUEST["rows"] == "-1") {
        $row_limit = read_config_option("num_rows_syslog");
    } elseif ($_REQUEST["rows"] == -2) {
        $row_limit = 999999;
    } else {
        $row_limit = $_REQUEST["rows"];
    }
    $alerts = syslog_get_alert_records($sql_where, $row_limit);
    $rows_query_string = "SELECT COUNT(*)\n\t\tFROM `" . $syslogdb_default . "`.`syslog_alert`\n\t\t{$sql_where}";
    $total_rows = syslog_db_fetch_cell($rows_query_string);
    ?>
	<script type="text/javascript">
	<!--
	function applyChange(objForm) {
		strURL = '?enabled=' + objForm.enabled.value;
		strURL = strURL + '&filter=' + objForm.filter.value;
		strURL = strURL + '&rows=' + objForm.rows.value;
		document.location = strURL;
	}
	-->
	</script>
	<?php 
    /* generate page list */
    $url_page_select = get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, "syslog_alerts.php?filter=" . $_REQUEST["filter"]);
    if ($total_rows > 0) {
        $nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t\t\t<td colspan='13'>\n\t\t\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td align='left' class='textHeaderDark'>\n\t\t\t\t\t\t\t\t\t<strong>&lt;&lt; ";
        if ($_REQUEST["page"] > 1) {
            $nav .= "<a class='linkOverDark' href='syslog_alerts.php?report=arp&page=" . ($_REQUEST["page"] - 1) . "'>";
        }
        $nav .= "Previous";
        if ($_REQUEST["page"] > 1) {
            $nav .= "</a>";
        }
        $nav .= "</strong>\n\t\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\t\t\tShowing Rows " . ($total_rows == 0 ? "None" : $row_limit * ($_REQUEST["page"] - 1) + 1 . " to " . ($total_rows < $row_limit || $total_rows < $row_limit * $_REQUEST["page"] ? $total_rows : $row_limit * $_REQUEST["page"]) . " of {$total_rows} [{$url_page_select}]") . "\n\t\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t\t<td align='right' class='textHeaderDark'>\n\t\t\t\t\t\t\t\t\t<strong>";
        if ($_REQUEST["page"] * $row_limit < $total_rows) {
            $nav .= "<a class='linkOverDark' href='syslog_alerts.php?report=arp&page=" . ($_REQUEST["page"] + 1) . "'>";
        }
        $nav .= "Next";
        if ($_REQUEST["page"] * $row_limit < $total_rows) {
            $nav .= "</a>";
        }
        $nav .= " &gt;&gt;</strong>\n\t\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
    } else {
        $nav = "<tr bgcolor='#" . $colors["header"] . "' class='noprint'>\n\t\t\t\t\t<td colspan='22'>\n\t\t\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\t\t\tNo Rows Found\n\t\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
    }
    print $nav;
    $display_text = array("name" => array("Alert<br>Name", "ASC"), "severity" => array("<br>Severity", "ASC"), "method" => array("<br>Method", "ASC"), "num" => array("Threshold<br>Count", "ASC"), "enabled" => array("<br>Enabled", "ASC"), "type" => array("Match<br>Type", "ASC"), "message" => array("Search<br>String", "ASC"), "email" => array("E-Mail<br>Addresses", "DESC"), "date" => array("Last<br>Modified", "ASC"), "user" => array("By<br>User", "DESC"));
    html_header_sort_checkbox($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]);
    $i = 0;
    if (sizeof($alerts) > 0) {
        foreach ($alerts as $alert) {
            form_alternate_row_color($colors["alternate"], $colors["light"], $i, 'line' . $alert["id"]);
            $i++;
            form_selectable_cell("<a class='linkEditMain' href='" . $config['url_path'] . "plugins/syslog/syslog_alerts.php?action=edit&id=" . $alert["id"] . "'>" . ($_REQUEST["filter"] != "" ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $alert["name"]) : $alert["name"]) . "</a>", $alert["id"]);
            form_selectable_cell($severities[$alert["severity"]], $alert["id"]);
            form_selectable_cell($alert["method"] == 1 ? "Threshold" : "Individual", $alert["id"]);
            form_selectable_cell($alert["method"] == 1 ? $alert["num"] : "N/A", $alert["id"]);
            form_selectable_cell($alert["enabled"] == "on" ? "Yes" : "No", $alert["id"]);
            form_selectable_cell($message_types[$alert["type"]], $alert["id"]);
            form_selectable_cell(title_trim($alert["message"], 60), $alert["id"]);
            form_selectable_cell(substr_count($alert["email"], ",") ? "Multiple" : $alert["email"], $alert["id"]);
            form_selectable_cell(date("Y-m-d H:i:s", $alert["date"]), $alert["id"]);
            form_selectable_cell($alert["user"], $alert["id"]);
            form_checkbox_cell($alert["name"], $alert["id"]);
            form_end_row();
        }
    } else {
        print "<tr><td colspan='4'><em>No Syslog Alerts Defined</em></td></tr>";
    }
    html_end_box(false);
    /* draw the dropdown containing a list of available actions for this form */
    draw_actions_dropdown($syslog_actions);
}
Exemplo n.º 8
0
function data_query() {
	global $colors;

	html_start_box("<strong>Data Queries</strong>", "98%", $colors["header"], "3", "center", "data_queries.php?action=edit");

	print "<tr bgcolor='#" . $colors["header_panel"] . "'>";
		DrawMatrixHeaderItem("Name",$colors["header_text"],1);
		DrawMatrixHeaderItem("Data Input Method",$colors["header_text"],1);
		DrawMatrixHeaderItem("&nbsp;",$colors["header_text"],1);
	print "</tr>";

	$snmp_queries = db_fetch_assoc("SELECT
			snmp_query.id,
			snmp_query.name,
			data_input.name AS data_input_method
			FROM snmp_query INNER JOIN data_input ON snmp_query.data_input_id = data_input.id
			ORDER BY snmp_query.name");

	$i = 0;
	if (sizeof($snmp_queries) > 0) {
	foreach ($snmp_queries as $snmp_query) {
		form_alternate_row_color($colors["alternate"],$colors["light"],$i); $i++;
			?>
			<td>
				<a class="linkEditMain" href="data_queries.php?action=edit&id=<?php print $snmp_query["id"];?>"><?php print $snmp_query["name"];?></a>
			</td>
			<td>
				<?php print $snmp_query["data_input_method"]; ?>
			</td>
			<td align="right">
				<a href="data_queries.php?action=remove&id=<?php print $snmp_query["id"];?>"><img src="images/delete_icon.gif" width="10" height="10" border="0" alt="Delete"></a>
			</td>
		</tr>
	<?php
	}
	}
	html_end_box();
}
Exemplo n.º 9
0
		<td colspan='3'>
			<table width='100%' cellspacing='0' cellpadding='3' border='0'>
				<tr>
					<?php
					print "<td width='1%' align='right' class='textHeaderDark' style='" . get_checkbox_style() . "'><input type='checkbox' style='margin: 0px;' name='all' title='Select All' onClick='SelectAllGraphs(\"graph_\",this.checked)'></td><td bgcolor='#6D88AD'><strong>Select All</strong></td>\n";
					?>
				</tr>
			</table>
		</td>
	</tr>
	<?php

	$i = 0;
	if (sizeof($graphs) > 0) {
		foreach ($graphs as $graph) {
			form_alternate_row_color("f5f5f5", "ffffff", $i);

			print "<td width='1%'>";
			print "<input type='checkbox' name='graph_" . $graph["local_graph_id"] . "' id='graph_" . $graph["local_graph_id"] . "' value='" . $graph["local_graph_id"] . "'";
			if (isset($graph_list[$graph["local_graph_id"]])) {
				print " checked";
			}
			print ">\n";
			print "</td>\n";

			print "<td><strong><a href='graph.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=all'>" . $graph["title_cache"] . "</a></strong></td>\n";
			print "<td>" . $graph["height"] . "x" . $graph["width"] . "</td>\n";
			print "</tr>";

			$i++;
		}
Exemplo n.º 10
0
function boost_display_run_status()
{
    global $colors, $config, $refresh_interval, $boost_utilities_interval, $boost_refresh_interval, $boost_max_runtime;
    $last_run_time = read_config_option("boost_last_run_time", TRUE);
    $next_run_time = read_config_option("boost_next_run_time", TRUE);
    $rrd_updates = read_config_option("boost_rrd_update_enable", TRUE);
    $boost_server = read_config_option("boost_server_enable", TRUE);
    $boost_cache = read_config_option("boost_png_cache_enable", TRUE);
    $max_records = read_config_option("boost_rrd_update_max_records", TRUE);
    $max_runtime = read_config_option("boost_rrd_update_max_runtime", TRUE);
    $update_interval = read_config_option("boost_rrd_update_interval", TRUE);
    $peak_memory = read_config_option('boost_peak_memory', TRUE);
    $detail_stats = read_config_option('stats_detail_boost', TRUE);
    html_start_box("<strong>Boost Status</strong>", "100%", $colors["header"], "1", "center", "");
    ?>
	<script type="text/javascript">
	<!--
	function applyStatsRefresh(objForm) {
		strURL = '?action=view_boost_status&refresh=' + objForm.refresh[objForm.refresh.selectedIndex].value;
		document.location = strURL;
	}
	-->
	</script>
	<tr bgcolor="<?php 
    print $colors["panel"];
    ?>
">
		<form name="form_boost_utilities_stats" method="post">
		<td>
			<table cellpadding="1" cellspacing="0">
				<tr>
					<td width="120" style="white-space:nowrap;">
						&nbsp;Refresh Interval:
					</td>
					<td width="1">
						<select name="refresh" onChange="applyStatsRefresh(document.form_boost_utilities_stats)">
						<?php 
    foreach ($boost_utilities_interval as $key => $interval) {
        print '<option value="' . $key . '"';
        if ($_REQUEST["refresh"] == $key) {
            print " selected";
        }
        print ">" . $interval . "</option>";
    }
    ?>
					</td>
					<td>
						&nbsp;<input type="submit" value="Refresh">
					</td>
				</tr>
			</table>
		</td>
		</form>
	</tr>
	<?php 
    html_end_box(TRUE);
    html_start_box("", "100%", $colors["header"], "1", "center", "");
    /* get the boost table status */
    $boost_table_status = db_fetch_assoc("SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE table_schema=SCHEMA()\r\n\t\t\t\t\t\tAND (table_name LIKE 'poller_output_boost_arch_%' OR table_name LIKE 'poller_output_boost')");
    $pending_records = 0;
    $arch_records = 0;
    $data_length = 0;
    $engine = "";
    $max_data_length = 0;
    foreach ($boost_table_status as $table) {
        if ($table["TABLE_NAME"] == "poller_output_boost") {
            $pending_records += $table["TABLE_ROWS"];
        } else {
            $arch_records += $table["TABLE_ROWS"];
        }
        $data_length += $table["DATA_LENGTH"];
        $data_length -= $table["DATA_FREE"];
        $engine = $table["ENGINE"];
        $max_data_length = $table["MAX_DATA_LENGTH"];
    }
    $total_records = $pending_records + $arch_records;
    $avg_row_length = intval($data_length / $total_records);
    $total_data_sources = db_fetch_cell("SELECT COUNT(*) FROM poller_item");
    $boost_status = read_config_option("boost_poller_status", TRUE);
    if (strlen($boost_status)) {
        $boost_status_array = explode(":", $boost_status);
        $boost_status_date = $boost_status_array[1];
        if (substr_count($boost_status_array[0], "complete")) {
            $boost_status_text = "Idle";
        } elseif (substr_count($boost_status_array[0], "running")) {
            $boost_status_text = "Running";
        } elseif (substr_count($boost_status_array[0], "overrun")) {
            $boost_status_text = "Overrun Warning";
        } elseif (substr_count($boost_status_array[0], "timeout")) {
            $boost_status_text = "Timed Out";
        } else {
            $boost_status_text = "Other";
        }
    } else {
        $boost_status_text = "Never Run";
        $boost_status_date = "";
    }
    $stats_boost = read_config_option("stats_boost", TRUE);
    if (strlen($stats_boost)) {
        $stats_boost_array = explode(" ", $stats_boost);
        $stats_duration = explode(":", $stats_boost_array[0]);
        $boost_last_run_duration = $stats_duration[1];
        $stats_rrds = explode(":", $stats_boost_array[1]);
        $boost_rrds_updated = $stats_rrds[1];
    } else {
        $boost_last_run_duration = "";
        $boost_rrds_updated = "";
    }
    /* get cache directory size/contents */
    $cache_directory = read_config_option("boost_png_cache_directory", TRUE);
    $directory_contents = array();
    if (is_dir($cache_directory)) {
        if ($handle = @opendir($cache_directory)) {
            /* This is the correct way to loop over the directory. */
            while (FALSE !== ($file = readdir($handle))) {
                $directory_contents[] = $file;
            }
            closedir($handle);
            /* get size of directory */
            $directory_size = 0;
            $cache_files = 0;
            if (sizeof($directory_contents)) {
                /* goto the cache directory */
                chdir($cache_directory);
                /* check and fry as applicable */
                foreach ($directory_contents as $file) {
                    /* only remove jpeg's and png's */
                    if (substr_count(strtolower($file), ".png") || substr_count(strtolower($file), ".jpg")) {
                        $cache_files++;
                        $directory_size += filesize($file);
                    }
                }
            }
            $directory_size = boost_file_size_display($directory_size);
            $cache_files = $cache_files . " Files";
        } else {
            $directory_size = "<strong>WARNING:</strong> Can not open directory";
            $cache_files = "<strong>WARNING:</strong> Unknown";
        }
    } else {
        $directory_size = "<strong>WARNING:</strong> Directory Does NOT Exist!!";
        $cache_files = "<strong>WARNING:</strong> N/A";
    }
    $i = 0;
    /* boost status display */
    html_header(array("Current Boost Status"), 2);
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td><strong>Boost On Demand Updating:</strong></td><td><strong>" . ($rrd_updates == "" ? "Disabled" : $boost_status_text) . "</strong></td>";
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td><strong>Total Data Sources:</strong></td><td>" . $total_data_sources . "</td>";
    if ($total_records > 0) {
        form_alternate_row_color($colors["alternate"], $colors["light"], $i);
        $i++;
        print "<td><strong>Pending Boost Records:</strong></td><td>" . $pending_records . "</td>";
        form_alternate_row_color($colors["alternate"], $colors["light"], $i);
        $i++;
        print "<td><strong>Archived Boost Records:</strong></td><td>" . $arch_records . "</td>";
        form_alternate_row_color($colors["alternate"], $colors["light"], $i);
        $i++;
        print "<td><strong>Total Boost Records:</strong></td><td>" . $total_records . "</td>";
    }
    /* boost status display */
    html_header(array("Boost Storage Statistics"), 2);
    /* describe the table format */
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td><strong>Database Engine:</strong></td><td>" . $engine . "</td>";
    /* tell the user how big the table is */
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td><strong>Current Boost Tables Size:</strong></td><td>" . boost_file_size_display($data_length, 2) . "</td>";
    /* tell the user about the average size/record */
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td><strong>Avg Bytes/Record:</strong></td><td>" . boost_file_size_display($avg_row_length) . "</td>";
    /* tell the user about the average size/record */
    $output_length = read_config_option("boost_max_output_length");
    if (strlen($output_length)) {
        $parts = explode(":", $output_length);
        if (time() - 1200 > $parts[0]) {
            $refresh = TRUE;
        } else {
            $refresh = FALSE;
        }
    } else {
        $refresh = TRUE;
    }
    if ($refresh) {
        if (strcmp($engine, "MEMORY") == 0) {
            $max_length = db_fetch_cell("SELECT MAX(LENGTH(output)) FROM poller_output_boost");
        } else {
            $max_length = "0";
        }
        db_execute("REPLACE INTO settings (name,value) VALUES ('boost_max_output_length', '" . time() . ":" . $max_length . "')");
    } else {
        $max_length = $parts[1];
    }
    if ($max_length != 0) {
        form_alternate_row_color($colors["alternate"], $colors["light"], $i);
        $i++;
        print "<td><strong>Max Record Length:</strong></td><td>" . $max_length . " Bytes</td>";
    }
    /* tell the user about the "Maximum Size" this table can be */
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    if (strcmp($engine, "MEMORY")) {
        $max_table_allowed = "Unlimited";
        $max_table_records = "Unlimited";
    } else {
        $max_table_allowed = boost_file_size_display($max_data_length, 2);
        $max_table_records = round($max_data_length / $avg_row_length, 0);
    }
    print "<td><strong>Max Allowed Boost Table Size:</strong></td><td>" . $max_table_allowed . "</td>";
    /* tell the user about the estimated records that "could" be held in memory */
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td><strong>Estimated Maximum Records:</strong></td><td>" . $max_table_records . " Records</td>";
    /* boost last runtime display */
    html_header(array("Runtime Statistics"), 2);
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td width=200><strong>Last Start Time:</strong></td><td>" . $last_run_time . "</td>";
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td width=200><strong>Last Run Duration:</strong></td><td>";
    print ($boost_last_run_duration > 60 ? (int) ($boost_last_run_duration / 60) . " minutes " : "") . $boost_last_run_duration % 60 . " seconds";
    if ($rrd_updates != "") {
        print " (" . round(100 * $boost_last_run_duration / $update_interval / 60) . "% of update frequency)";
    }
    print "</td>";
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td width=200><strong>RRD Updates:</strong></td><td>" . $boost_rrds_updated . "</td>";
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td width=200><strong>Peak Poller Memory:</strong></td><td>" . (read_config_option('boost_peak_memory') != '' ? round(read_config_option('boost_peak_memory') / 1024 / 1024, 2) . " MBytes" : "N/A") . "</td>";
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td width=200><strong>Detailed Runtime Timers:</strong></td><td>" . ($detail_stats != '' ? $detail_stats : "N/A") . "</td>";
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td width=200><strong>Max Poller Memory Allowed:</strong></td><td>" . (read_config_option('boost_poller_mem_limit') != '' ? read_config_option('boost_poller_mem_limit') . " MBytes" : "N/A") . "</td>";
    /* boost runtime display */
    html_header(array("Run Time Configuration"), 2);
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td width=200><strong>Update Frequency:</strong></td><td><strong>" . ($rrd_updates == "" ? "N/A" : $boost_refresh_interval[$update_interval]) . "</strong></td>";
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td width=200><strong>Next Start Time:</strong></td><td>" . $next_run_time . "</td>";
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td width=200><strong>Maximum Records:</strong></td><td>" . $max_records . " Records</td>";
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td width=200><strong>Maximum Allowed Runtime:</strong></td><td>" . $boost_max_runtime[$max_runtime] . "</td>";
    /* boost runtime display */
    html_header(array("Boost Server Details"), 2);
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td><strong>Server Config Status:</strong></td><td><strong>" . ($boost_server == "" ? "Disabled" : "Enabled") . "</strong></td>";
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td><strong>Multiprocess Server:</td><td>" . (read_config_option("boost_server_multiprocess", TRUE) == "1" ? "Multiple Process" : "Single Process") . "</strong></td>";
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td><strong>Update Timeout:</td><td>" . read_config_option("boost_server_timeout", TRUE) . " Seconds</strong></td>";
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td><strong>Server/Port:</td><td>" . read_config_option("boost_server_hostname", TRUE) . "@" . read_config_option("boost_server_listen_port", TRUE) . "</strong></td>";
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td><strong>Authorized Update Web Servers:</td><td>" . read_config_option("boost_server_clients", TRUE) . "</strong></td>";
    if (strlen(read_config_option("boost_path_rrdupdate")) && read_config_option("boost_server_multiprocess") == 1) {
        form_alternate_row_color($colors["alternate"], $colors["light"], $i);
        $i++;
        print "<td><strong>RRDtool Binary Used:</td><td>" . read_config_option("boost_path_rrdupdate") . "</strong></td>";
    } else {
        form_alternate_row_color($colors["alternate"], $colors["light"], $i);
        $i++;
        print "<td><strong>RRDtool Binary Used:</td><td>" . read_config_option("path_rrdtool") . "</strong></td>";
    }
    /* boost caching */
    html_header(array("Image Caching"), 2);
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td><strong>Image Caching Status:</strong></td><td><strong>" . ($boost_cache == "" ? "Disabled" : "Enabled") . "</strong></td>";
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td><strong>Cache Directory:</strong></td><td>" . $cache_directory . "</td>";
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td><strong>Cached Files:</strong></td><td>" . $cache_files . "</td>";
    form_alternate_row_color($colors["alternate"], $colors["light"], $i);
    $i++;
    print "<td><strong>Cached Files Size:</strong></td><td>" . $directory_size . "</td>";
    html_end_box(TRUE);
}
Exemplo n.º 11
0
function cdef() {
	global $colors;

	html_start_box("<strong>CDEF's</strong>", "98%", $colors["header"], "3", "center", "cdef.php?action=edit");

	print "<tr bgcolor='#" . $colors["header_panel"] . "'>";
		DrawMatrixHeaderItem("Name",$colors["header_text"],1);
		DrawMatrixHeaderItem("&nbsp;",$colors["header_text"],1);
	print "</tr>";

	$cdefs = db_fetch_assoc("select * from cdef order by name");

	$i = 0;
	if (sizeof($cdefs) > 0) {
	foreach ($cdefs as $cdef) {
		form_alternate_row_color($colors["alternate"],$colors["light"],$i); $i++;
			?>
			<td>
				<a class="linkEditMain" href="cdef.php?action=edit&id=<?php print $cdef["id"];?>"><?php print $cdef["name"];?></a>
			</td>
			<td align="right">
				<a href="cdef.php?action=remove&id=<?php print $cdef["id"];?>"><img src="images/delete_icon.gif" width="10" height="10" border="0" alt="Delete"></a>
			</td>
		</tr>
	<?php
	}
	}
	html_end_box();
}
function weathermap_group_editor()
{
	global $colors, $config;

	html_start_box("<strong>Edit Map Groups</strong>", "70%", $colors["header"], "2", "center", "weathermap-cacti-plugin-mgmt.php?action=group_form&id=0");
	html_header(array("", "Group Name", "Settings", "Sort Order", ""));
		
	$groups = db_fetch_assoc("select * from weathermap_groups order by sortorder");

	$n = 0;
	
	if( is_array($groups) )
	{
		if(sizeof($groups)>0)
		{
			foreach( $groups as $group)
			{
				form_alternate_row_color($colors["alternate"],$colors["light"],$n);
				print '<td><a href="weathermap-cacti-plugin-mgmt.php?action=group_form&id='.intval($group['id']).'"><img src="../../images/graph_properties.gif" width="16" height="16" border="0" alt="Rename This Group" title="Rename This Group">Rename</a></td>';
				print "<td>".htmlspecialchars($group['name'])."</td>";

				print "<td>";
			
			print "<a href='?action=map_settings&id=-".$group['id']."'>";
			$setting_count = db_fetch_cell("select count(*) from weathermap_settings where mapid=0 and groupid=".$group['id']);
			if($setting_count > 0)
			{
				print $setting_count." special";
				if($setting_count>1) print "s";
			}
			else
			{
				print "standard";
			}
			print "</a>";
			
			print "</td>";
				
				
				print '<td>';

			print '<a href="weathermap-cacti-plugin-mgmt.php?action=move_group_up&order='.$group['sortorder'].'&id='.$group['id'].'"><img src="../../images/move_up.gif" width="14" height="10" border="0" alt="Move Group Up" title="Move Group Up"></a>';
			print '<a href="weathermap-cacti-plugin-mgmt.php?action=move_group_down&order='.$group['sortorder'].'&id='.$group['id'].'"><img src="../../images/move_down.gif" width="14" height="10" border="0" alt="Move Group Down" title="Move Group Down"></a>';
// print $map['sortorder'];

			print "</td>";
			
				print '<td>';
				if($group['id']>1)
				{
					print '<a href="weathermap-cacti-plugin-mgmt.php?action=groupadmin_delete&id='.intval($group['id']).'"><img src="../../images/delete_icon.gif" width="10" height="10" border="0" alt="Remove this definition from this map"></a>';
				}
				print '</td>';
			
				print "</tr>";
				$n++;
			}
		}
		else
		{
			print "<tr>";
			print "<td colspan=2>No groups are defined.</td>";
			print "</tr>";
		}
	}
	
	html_end_box();
}
Exemplo n.º 13
0
function draw_graph_items_list($item_list, $filename, $url_data, $disable_controls) {
	global $colors, $config;

	include($config["include_path"] . "/config_arrays.php");

	print "<tr bgcolor='#" . $colors["header_panel"] . "'>";
		DrawMatrixHeaderItem("Graph Item",$colors["header_text"],1);
		DrawMatrixHeaderItem("Data Source",$colors["header_text"],1);
		DrawMatrixHeaderItem("Graph Item Type",$colors["header_text"],1);
		DrawMatrixHeaderItem("CF Type",$colors["header_text"],1);
		DrawMatrixHeaderItem("Item Color",$colors["header_text"],4);
	print "</tr>";

	$group_counter = 0; $_graph_type_name = ""; $i = 0;
	$alternate_color_1 = $colors["alternate"]; $alternate_color_2 = $colors["alternate"];

	if (sizeof($item_list) > 0) {
	foreach ($item_list as $item) {
		/* graph grouping display logic */
		$this_row_style = ""; $use_custom_row_color = false; $hard_return = "";

		if ($graph_item_types{$item["graph_type_id"]} != "GPRINT") {
			$this_row_style = "font-weight: bold;"; $use_custom_row_color = true;

			if ($group_counter % 2 == 0) {
				$alternate_color_1 = "EEEEEE";
				$alternate_color_2 = "EEEEEE";
				$custom_row_color = "D5D5D5";
			}else{
				$alternate_color_1 = $colors["alternate"];
				$alternate_color_2 = $colors["alternate"];
				$custom_row_color = "D2D6E7";
			}

			$group_counter++;
		}

		$_graph_type_name = $graph_item_types{$item["graph_type_id"]};

		/* alternating row color */
		if ($use_custom_row_color == false) {
			form_alternate_row_color($alternate_color_1,$alternate_color_2,$i);
		}else{
			print "<tr bgcolor='#$custom_row_color'>";
		}

		print "<td>";
		if ($disable_controls == false) { print "<a href='$filename?action=item_edit&id=" . $item["id"] . "&$url_data'>"; }
		print "<strong>Item # " . ($i+1) . "</strong>";
		if ($disable_controls == false) { print "</a>"; }
		print "</td>\n";

		if (empty($item["data_source_name"])) { $item["data_source_name"] = "No Task"; }

		switch (true) {
		case ereg("(AREA|STACK|GPRINT|LINE[123])", $_graph_type_name):
			$matrix_title = "(" . $item["data_source_name"] . "): " . $item["text_format"];
			break;
		case ereg("(HRULE|VRULE)", $_graph_type_name):
			$matrix_title = "HRULE: " . $item["value"];
			break;
		case ereg("(COMMENT)", $_graph_type_name):
			$matrix_title = "COMMENT: " . $item["text_format"];
			break;
		}

		if ($item["hard_return"] == "on") {
			$hard_return = "<strong><font color=\"#FF0000\">&lt;HR&gt;</font></strong>";
		}

		print "<td style='$this_row_style'>" . htmlspecialchars($matrix_title) . $hard_return . "</td>\n";
		print "<td style='$this_row_style'>" . $graph_item_types{$item["graph_type_id"]} . "</td>\n";
		print "<td style='$this_row_style'>" . $consolidation_functions{$item["consolidation_function_id"]} . "</td>\n";
		print "<td" . ((!empty($item["hex"])) ? " bgcolor='#" . $item["hex"] . "'" : "") . " width='1%'>&nbsp;</td>\n";
		print "<td style='$this_row_style'>" . $item["hex"] . "</td>\n";

		if ($disable_controls == false) {
			print "<td><a href='$filename?action=item_movedown&id=" . $item["id"] . "&$url_data'><img src='images/move_down.gif' border='0' alt='Move Down'></a>
					<a href='$filename?action=item_moveup&id=" . $item["id"] . "&$url_data'><img src='images/move_up.gif' border='0' alt='Move Up'></a></td>\n";
			print "<td align='right'><a href='$filename?action=item_remove&id=" . $item["id"] . "&$url_data'><img src='images/delete_icon.gif' width='10' height='10' border='0' alt='Delete'></a></td>\n";
		}

		print "</tr>";

		$i++;
	}
	}else{
		print "<tr bgcolor='#" . $colors["form_alternate2"] . "'><td colspan='7'><em>No Items</em></td></tr>";
	}
}
Exemplo n.º 14
0
function template() {
	global $colors, $host_actions;

	/* clean up sort_column */
	if (isset($_REQUEST["sort_column"])) {
		$_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
	}

	/* clean up search string */
	if (isset($_REQUEST["sort_direction"])) {
		$_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
	}

	/* remember these search fields in session vars so we don't have to keep passing them around */
	load_current_session_value("sort_column", "sess_host_template_column", "name");
	load_current_session_value("sort_direction", "sess_host_template_sort_direction", "ASC");

	display_output_messages();

	html_start_box("<strong>Host Templates</strong>", "98%", $colors["header"], "3", "center", "host_templates.php?action=edit");

	$display_text = array(
		"name" => array("Template Title", "ASC"));

	html_header_sort_checkbox($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]);

	$host_templates = db_fetch_assoc("SELECT *
		FROM host_template
		ORDER BY " . $_REQUEST['sort_column'] . " " . $_REQUEST['sort_direction']);

	$i = 0;
	if (sizeof($host_templates) > 0) {
	foreach ($host_templates as $host_template) {
		form_alternate_row_color($colors["alternate"],$colors["light"],$i); $i++;
			?>
			<td>
				<a class="linkEditMain" href="host_templates.php?action=edit&id=<?php print $host_template["id"];?>"><?php print $host_template["name"];?></a>
			</td>
			<td style="<?php print get_checkbox_style();?>" width="1%" align="right">
				<input type='checkbox' style='margin: 0px;' name='chk_<?php print $host_template["id"];?>' title="<?php print $host_template["name"];?>">
			</td>
		</tr>
	<?php
	}
	}else{
		print "<tr><td><em>No Host Templates</em></td></tr>\n";
	}
	html_end_box(false);

	/* draw the dropdown containing a list of available actions for this form */
	draw_actions_dropdown($host_actions);

	print "</form>\n";
}
Exemplo n.º 15
0
function templates()
{
    global $colors, $thold_actions, $item_rows;
    template_request_validation();
    ?>
	<script type="text/javascript">
	<!--
	function applyTHoldFilterChange(objForm) {
		strURL = '?rows=' + objForm.rows.value;
		strURL = strURL + '&filter=' + objForm.filter.value;
		document.location = strURL;
	}

	function importTemplate() {
		strURL = '?action=import';
		document.location = strURL;
	}
	-->
	</script>
	<?php 
    html_start_box('<strong>Threshold Templates</strong>', '100%', $colors['header'], '3', 'center', 'thold_templates.php?action=add');
    ?>
	<tr bgcolor='#<?php 
    print $colors["panel"];
    ?>
' class='noprint'>
		<td class='noprint'>
			<form name='listthold' action='thold_templates.php'>
			<table cellpadding='0' cellspacing='0'>
				<tr class='noprint'>
					<td width='20'>
						&nbsp;Search:&nbsp;
					</td>
					<td width='144'>
						<input type='text' name='filter' size='20' value='<?php 
    print $_REQUEST["filter"];
    ?>
'>
					</td>
					<td width='1'>
						&nbsp;Rows:&nbsp;
					</td>
					<td width='1'>
						<select name='rows' onChange='applyTHoldFilterChange(document.listthold)'>
							<option value='-1'<?php 
    if ($_REQUEST["rows"] == "-1") {
        ?>
 selected<?php 
    }
    ?>
>Default</option>
							<?php 
    if (sizeof($item_rows)) {
        foreach ($item_rows as $key => $value) {
            print "<option value='" . $key . "'";
            if ($_REQUEST["rows"] == $key) {
                print " selected";
            }
            print ">" . $value . "</option>\n";
        }
    }
    ?>
						</select>
					</td>
					<td width='1'>
						<input type="submit" value="Go">
					</td>
					<td width='1'>
						<input id="clear" name="clear" type="submit" value="Clear">
					</td>
					<td width='1'>
						<input id="import" name="import" type="button" value="Import" onClick="importTemplate()">
					</td>
				</tr>
			</table>
			</form>
		</td>
	</tr>
	<?php 
    html_end_box();
    $sql_where = '';
    $limit = ' LIMIT ' . $_REQUEST["rows"] * ($_REQUEST['page'] - 1) . "," . $_REQUEST["rows"];
    $order = "ORDER BY " . $_REQUEST['sort_column'] . " " . $_REQUEST['sort_direction'];
    if (strlen($_REQUEST["filter"])) {
        $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " thold_template.name LIKE '%%" . $_REQUEST["filter"] . "%%'";
    }
    define('MAX_DISPLAY_PAGES', 21);
    $total_rows = db_fetch_cell("SELECT count(*) FROM thold_template");
    $template_list = db_fetch_assoc("SELECT * FROM thold_template {$sql_where} {$order} {$limit}");
    if ($total_rows) {
        /* generate page list */
        $url_page_select = get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, $_REQUEST["rows"], $total_rows, "thold_templates.php?tab=thold");
        $nav = "<tr bgcolor='#" . $colors["header"] . "'>\r\n\t\t\t\t<td colspan='10'>\r\n\t\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td align='left' class='textHeaderDark'>\r\n\t\t\t\t\t\t\t\t<strong>&lt;&lt; ";
        if ($_REQUEST["page"] > 1) {
            $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("thold_templates.php?filter=" . $_REQUEST["filter"] . "&page=" . ($_REQUEST["page"] - 1)) . "'>";
        }
        $nav .= "Previous";
        if ($_REQUEST["page"] > 1) {
            $nav .= "</a>";
        }
        $nav .= "</strong>\r\n\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\r\n\t\t\t\t\t\t\t\tShowing Rows " . ($_REQUEST["rows"] * ($_REQUEST["page"] - 1) + 1) . " to " . ($total_rows < read_config_option("num_rows_device") || $total_rows < $_REQUEST["rows"] * $_REQUEST["page"] ? $total_rows : $_REQUEST["rows"] * $_REQUEST["page"]) . " of {$total_rows} [{$url_page_select}]\r\n\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t\t<td align='right' class='textHeaderDark'>\r\n\t\t\t\t\t\t\t\t<strong>";
        if ($_REQUEST["page"] * $_REQUEST["rows"] < $total_rows) {
            $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("thold_templates.php?filter=" . $_REQUEST["filter"] . "&page=" . ($_REQUEST["page"] + 1)) . "'>";
        }
        $nav .= "Next";
        if ($_REQUEST["page"] * $_REQUEST["rows"] < $total_rows) {
            $nav .= "</a>";
        }
        $nav .= " &gt;&gt;</strong>\r\n\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</table>\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\n";
    } else {
        $nav = "<tr bgcolor='#" . $colors["header"] . "'>\r\n\t\t\t\t<td colspan='10'>\r\n\t\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\r\n\t\t\t\t\t\t\t\tNo Rows Found\r\n\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</table>\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\n";
    }
    /* print checkbox form for validation */
    print "<form name='chk' method='post' action='thold_templates.php'>\n";
    html_start_box('', '100%', $colors['header'], '3', 'center', '');
    print $nav;
    html_header_sort_checkbox(array('name' => array('Name', 'ASC'), 'data_template_name' => array('Data Template', 'ASC'), 'data_source_name' => array('DS Name', 'ASC'), 'thold_type' => array('Type', 'ASC'), 'nosort1' => array('High/Up', ''), 'nosort2' => array('Low/Down', ''), 'nosort3' => array('Trigger', ''), 'nosort4' => array('Duration', ''), 'nosort5' => array('Repeat', '')), $_REQUEST['sort_column'], $_REQUEST['sort_direction'], false);
    $i = 0;
    $types = array('High/Low', 'Baseline Deviation', 'Time Based');
    if (sizeof($template_list)) {
        foreach ($template_list as $template) {
            switch ($template['thold_type']) {
                case 0:
                    # hi/lo
                    $value_hi = thold_format_number($template['thold_hi']);
                    $value_lo = thold_format_number($template['thold_low']);
                    $value_trig = $template['thold_fail_trigger'];
                    $value_duration = '';
                    $value_warning_hi = thold_format_number($template['thold_warning_hi']);
                    $value_warning_lo = thold_format_number($template['thold_warning_low']);
                    $value_warning_trig = $template['thold_warning_fail_trigger'];
                    $value_warning_duration = '';
                    break;
                case 1:
                    # baseline
                    $value_hi = $template['bl_pct_up'] . (strlen($template['bl_pct_up']) ? '%' : '-');
                    $value_lo = $template['bl_pct_down'] . (strlen($template['bl_pct_down']) ? '%' : '-');
                    $value_trig = $template['bl_fail_trigger'];
                    $step = db_fetch_cell("SELECT rrd_step \r\n\t\t\t\t\t\tFROM data_template_data \r\n\t\t\t\t\t\tWHERE data_template_id=" . $template['data_template_id'] . "\r\n\t\t\t\t\t\tLIMIT 1");
                    $value_duration = $template['bl_ref_time_range'] / $step;
                    break;
                case 2:
                    #time
                    $value_hi = thold_format_number($template['time_hi']);
                    $value_lo = thold_format_number($template['time_low']);
                    $value_trig = $template['time_fail_trigger'];
                    $value_duration = $template['time_fail_length'];
                    break;
            }
            form_alternate_row_color($colors["alternate"], $colors["light"], $i, 'line' . $template["id"]);
            $i++;
            form_selectable_cell('<a class="linkEditMain" href="' . htmlspecialchars('thold_templates.php?action=edit&id=' . $template['id']) . '">' . ($template['name'] == '' ? $template['data_template_name'] . ' [' . $template['data_source_name'] . ']' : $template['name']) . '</a>', $template["id"]);
            form_selectable_cell($template['data_template_name'], $template["id"]);
            form_selectable_cell($template['data_source_name'], $template["id"]);
            form_selectable_cell($types[$template['thold_type']], $template["id"]);
            form_selectable_cell($value_hi, $template["id"]);
            form_selectable_cell($value_lo, $template["id"]);
            $trigger = plugin_thold_duration_convert($template['data_template_id'], $value_trig, 'alert', 'data_template_id');
            form_selectable_cell(strlen($trigger) ? "<i>" . $trigger . "</i>" : "-", $template["id"]);
            $duration = plugin_thold_duration_convert($template['data_template_id'], $value_duration, 'time', 'data_template_id');
            form_selectable_cell(strlen($duration) ? $duration : "-", $template["id"]);
            form_selectable_cell(plugin_thold_duration_convert($template['data_template_id'], $template['repeat_alert'], 'repeat', 'data_template_id'), $template['id']);
            form_checkbox_cell($template['data_template_name'], $template["id"]);
            form_end_row();
        }
        print $nav;
    } else {
        print "<tr><td><em>No Threshold Templates</em></td></tr>\n";
    }
    html_end_box(false);
    /* draw the dropdown containing a list of available actions for this form */
    draw_actions_dropdown($thold_actions);
    print "</form>\n";
}
Exemplo n.º 16
0
function host()
{
    global $colors, $device_actions, $item_rows;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request("host_template_id"));
    input_validate_input_number(get_request_var_request("page"));
    input_validate_input_number(get_request_var_request("host_status"));
    input_validate_input_number(get_request_var_request("host_rows"));
    /* ==================================================== */
    /* clean up search string */
    if (isset($_REQUEST["filter"])) {
        $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter"));
    }
    /* clean up sort_column */
    if (isset($_REQUEST["sort_column"])) {
        $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
    }
    /* clean up search string */
    if (isset($_REQUEST["sort_direction"])) {
        $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
    }
    /* if the user pushed the 'clear' button */
    if (isset($_REQUEST["clear_x"])) {
        kill_session_var("sess_device_current_page");
        kill_session_var("sess_device_filter");
        kill_session_var("sess_device_host_template_id");
        kill_session_var("sess_host_status");
        kill_session_var("sess_host_rows");
        kill_session_var("sess_host_sort_column");
        kill_session_var("sess_host_sort_direction");
        unset($_REQUEST["page"]);
        unset($_REQUEST["filter"]);
        unset($_REQUEST["host_template_id"]);
        unset($_REQUEST["host_status"]);
        unset($_REQUEST["host_rows"]);
        unset($_REQUEST["sort_column"]);
        unset($_REQUEST["sort_direction"]);
    }
    if (!empty($_SESSION["sess_host_status"]) && !empty($_REQUEST["host_status"])) {
        if ($_SESSION["sess_host_status"] != $_REQUEST["host_status"]) {
            $_REQUEST["page"] = 1;
        }
    }
    /* remember these search fields in session vars so we don't have to keep passing them around */
    load_current_session_value("page", "sess_device_current_page", "1");
    load_current_session_value("filter", "sess_device_filter", "");
    load_current_session_value("host_template_id", "sess_device_host_template_id", "-1");
    load_current_session_value("host_status", "sess_host_status", "-1");
    load_current_session_value("host_rows", "sess_host_rows", read_config_option("num_rows_device"));
    load_current_session_value("sort_column", "sess_host_sort_column", "description");
    load_current_session_value("sort_direction", "sess_host_sort_direction", "ASC");
    /* if the number of rows is -1, set it to the default */
    if ($_REQUEST["host_rows"] == -1) {
        $_REQUEST["host_rows"] = read_config_option("num_rows_device");
    }
    ?>
	<script type="text/javascript">
	<!--

	function applyViewDeviceFilterChange(objForm) {
		strURL = '?host_status=' + objForm.host_status.value;
		strURL = strURL + '&host_template_id=' + objForm.host_template_id.value;
		strURL = strURL + '&host_rows=' + objForm.host_rows.value;
		strURL = strURL + '&filter=' + objForm.filter.value;
		document.location = strURL;
	}

	-->
	</script>
	<?php 
    html_start_box("<strong>Devices</strong>", "100%", $colors["header"], "3", "center", "host.php?action=edit&host_template_id=" . get_request_var_request("host_template_id") . "&host_status=" . get_request_var_request("host_status"));
    ?>
	<tr bgcolor="<?php 
    print $colors["panel"];
    ?>
">
		<form name="form_devices">
		<td>
			<table width="100%" cellpadding="0" cellspacing="0">
				<tr>
					<td nowrap style='white-space: nowrap;' width="50">
						Type:&nbsp;
					</td>
					<td width="1">
						<select name="host_template_id" onChange="applyViewDeviceFilterChange(document.form_devices)">
							<option value="-1"<?php 
    if (get_request_var_request("host_template_id") == "-1") {
        ?>
 selected<?php 
    }
    ?>
>Any</option>
							<option value="0"<?php 
    if (get_request_var_request("host_template_id") == "0") {
        ?>
 selected<?php 
    }
    ?>
>None</option>
							<?php 
    $host_templates = db_fetch_assoc("select id,name from host_template order by name");
    if (sizeof($host_templates) > 0) {
        foreach ($host_templates as $host_template) {
            print "<option value='" . $host_template["id"] . "'";
            if (get_request_var_request("host_template_id") == $host_template["id"]) {
                print " selected";
            }
            print ">" . $host_template["name"] . "</option>\n";
        }
    }
    ?>
						</select>
					</td>
					<td nowrap style='white-space: nowrap;' width="50">
						&nbsp;Status:&nbsp;
					</td>
					<td width="1">
						<select name="host_status" onChange="applyViewDeviceFilterChange(document.form_devices)">
							<option value="-1"<?php 
    if (get_request_var_request("host_status") == "-1") {
        ?>
 selected<?php 
    }
    ?>
>Any</option>
							<option value="-3"<?php 
    if (get_request_var_request("host_status") == "-3") {
        ?>
 selected<?php 
    }
    ?>
>Enabled</option>
							<option value="-2"<?php 
    if (get_request_var_request("host_status") == "-2") {
        ?>
 selected<?php 
    }
    ?>
>Disabled</option>
							<option value="-4"<?php 
    if (get_request_var_request("host_status") == "-4") {
        ?>
 selected<?php 
    }
    ?>
>Not Up</option>
							<option value="3"<?php 
    if (get_request_var_request("host_status") == "3") {
        ?>
 selected<?php 
    }
    ?>
>Up</option>
							<option value="1"<?php 
    if (get_request_var_request("host_status") == "1") {
        ?>
 selected<?php 
    }
    ?>
>Down</option>
							<option value="2"<?php 
    if (get_request_var_request("host_status") == "2") {
        ?>
 selected<?php 
    }
    ?>
>Recovering</option>
							<option value="0"<?php 
    if (get_request_var_request("host_status") == "0") {
        ?>
 selected<?php 
    }
    ?>
>Unknown</option>
						</select>
					</td>
					<td nowrap style='white-space: nowrap;' width="20">
						&nbsp;Search:&nbsp;
					</td>
					<td width="1">
						<input type="text" name="filter" size="20" value="<?php 
    print get_request_var_request("filter");
    ?>
">
					</td>
					<td nowrap style='white-space: nowrap;' width="50">
						&nbsp;Rows per Page:&nbsp;
					</td>
					<td width="1">
						<select name="host_rows" onChange="applyViewDeviceFilterChange(document.form_devices)">
							<option value="-1"<?php 
    if (get_request_var_request("host_rows") == "-1") {
        ?>
 selected<?php 
    }
    ?>
>Default</option>
							<?php 
    if (sizeof($item_rows) > 0) {
        foreach ($item_rows as $key => $value) {
            print "<option value='" . $key . "'";
            if (get_request_var_request("host_rows") == $key) {
                print " selected";
            }
            print ">" . $value . "</option>\n";
        }
    }
    ?>
						</select>
					</td>
					<td nowrap>
						&nbsp;<input type="image" src="images/button_go.gif" alt="Go" border="0" align="absmiddle">
						<input type="image" src="images/button_clear.gif" name="clear" alt="Clear" border="0" align="absmiddle">
					</td>
				</tr>
			</table>
		</td>
		<input type='hidden' name='page' value='1'>
		</form>
	</tr>
	<?php 
    html_end_box();
    /* form the 'where' clause for our main sql query */
    if (strlen(get_request_var_request("filter"))) {
        $sql_where = "where (host.hostname like '%%" . get_request_var_request("filter") . "%%' OR host.description like '%%" . get_request_var_request("filter") . "%%')";
    } else {
        $sql_where = "";
    }
    if (get_request_var_request("host_status") == "-1") {
        /* Show all items */
    } elseif (get_request_var_request("host_status") == "-2") {
        $sql_where .= strlen($sql_where) ? " and host.disabled='on'" : "where host.disabled='on'";
    } elseif (get_request_var_request("host_status") == "-3") {
        $sql_where .= strlen($sql_where) ? " and host.disabled=''" : "where host.disabled=''";
    } elseif (get_request_var_request("host_status") == "-4") {
        $sql_where .= strlen($sql_where) ? " and (host.status!='3' or host.disabled='on')" : "where (host.status!='3' or host.disabled='on')";
    } else {
        $sql_where .= strlen($sql_where) ? " and (host.status=" . get_request_var_request("host_status") . " AND host.disabled = '')" : "where (host.status=" . get_request_var_request("host_status") . " AND host.disabled = '')";
    }
    if (get_request_var_request("host_template_id") == "-1") {
        /* Show all items */
    } elseif (get_request_var_request("host_template_id") == "0") {
        $sql_where .= strlen($sql_where) ? " and host.host_template_id=0" : "where host.host_template_id=0";
    } elseif (!empty($_REQUEST["host_template_id"])) {
        $sql_where .= strlen($sql_where) ? " and host.host_template_id=" . get_request_var_request("host_template_id") : "where host.host_template_id=" . get_request_var_request("host_template_id");
    }
    html_start_box("", "100%", $colors["header"], "3", "center", "");
    $total_rows = db_fetch_cell("select\n\t\tCOUNT(host.id)\n\t\tfrom host\n\t\t{$sql_where}");
    $sortby = get_request_var_request("sort_column");
    if ($sortby == "hostname") {
        $sortby = "INET_ATON(hostname)";
    }
    $host_graphs = array_rekey(db_fetch_assoc("SELECT host_id, count(*) as graphs FROM graph_local GROUP BY host_id"), "host_id", "graphs");
    $host_data_sources = array_rekey(db_fetch_assoc("SELECT host_id, count(*) as data_sources FROM data_local GROUP BY host_id"), "host_id", "data_sources");
    $sql_query = "SELECT *\n\t\tFROM host\n\t\t{$sql_where}\n\t\tORDER BY " . $sortby . " " . get_request_var_request("sort_direction") . "\n\t\tLIMIT " . get_request_var_request("host_rows") * (get_request_var_request("page") - 1) . "," . get_request_var_request("host_rows");
    $hosts = db_fetch_assoc($sql_query);
    /* generate page list */
    $url_page_select = get_page_list(get_request_var_request("page"), MAX_DISPLAY_PAGES, get_request_var_request("host_rows"), $total_rows, "host.php?filter=" . get_request_var_request("filter") . "&host_template_id=" . get_request_var_request("host_template_id") . "&host_status=" . get_request_var_request("host_status"));
    $nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t<td colspan='11'>\n\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td align='left' class='textHeaderDark'>\n\t\t\t\t\t\t\t<strong>&lt;&lt; ";
    if (get_request_var_request("page") > 1) {
        $nav .= "<a class='linkOverDark' href='host.php?filter=" . get_request_var_request("filter") . "&host_template_id=" . get_request_var_request("host_template_id") . "&host_status=" . get_request_var_request("host_status") . "&page=" . (get_request_var_request("page") - 1) . "'>";
    }
    $nav .= "Previous";
    if (get_request_var_request("page") > 1) {
        $nav .= "</a>";
    }
    $nav .= "</strong>\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\tShowing Rows " . (get_request_var_request("host_rows") * (get_request_var_request("page") - 1) + 1) . " to " . ($total_rows < read_config_option("num_rows_device") || $total_rows < get_request_var_request("host_rows") * get_request_var_request("page") ? $total_rows : get_request_var_request("host_rows") * get_request_var_request("page")) . " of {$total_rows} [{$url_page_select}]\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td align='right' class='textHeaderDark'>\n\t\t\t\t\t\t\t<strong>";
    if (get_request_var_request("page") * get_request_var_request("host_rows") < $total_rows) {
        $nav .= "<a class='linkOverDark' href='host.php?filter=" . get_request_var_request("filter") . "&host_template_id=" . get_request_var_request("host_template_id") . "&host_status=" . get_request_var_request("host_status") . "&page=" . (get_request_var_request("page") + 1) . "'>";
    }
    $nav .= "Next";
    if (get_request_var_request("page") * get_request_var_request("host_rows") < $total_rows) {
        $nav .= "</a>";
    }
    $nav .= " &gt;&gt;</strong>\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t</td>\n\t\t</tr>\n";
    print $nav;
    $display_text = array("description" => array("Description", "ASC"), "id" => array("ID", "ASC"), "nosort1" => array("Graphs", "ASC"), "nosort2" => array("Data Sources", "ASC"), "status" => array("Status", "ASC"), "status_event_count" => array("Event Count", "ASC"), "hostname" => array("Hostname", "ASC"), "cur_time" => array("Current (ms)", "DESC"), "avg_time" => array("Average (ms)", "DESC"), "availability" => array("Availability", "ASC"));
    html_header_sort_checkbox($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"));
    $i = 0;
    if (sizeof($hosts) > 0) {
        foreach ($hosts as $host) {
            form_alternate_row_color($colors["alternate"], $colors["light"], $i, 'line' . $host["id"]);
            $i++;
            form_selectable_cell("<a class='linkEditMain' href='host.php?action=edit&id=" . $host["id"] . "'>" . (strlen(get_request_var_request("filter")) ? eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $host["description"]) : $host["description"]) . "</a>", $host["id"], 250);
            form_selectable_cell(round($host["id"], 2), $host["id"]);
            form_selectable_cell(isset($host_graphs[$host["id"]]) ? $host_graphs[$host["id"]] : 0, $host["id"]);
            form_selectable_cell(isset($host_data_sources[$host["id"]]) ? $host_data_sources[$host["id"]] : 0, $host["id"]);
            form_selectable_cell(get_colored_device_status($host["disabled"] == "on" ? true : false, $host["status"]), $host["id"]);
            form_selectable_cell(round($host["status_event_count"], 2), $host["id"]);
            form_selectable_cell(strlen(get_request_var_request("filter")) ? eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $host["hostname"]) : $host["hostname"], $host["id"]);
            form_selectable_cell(round($host["cur_time"], 2), $host["id"]);
            form_selectable_cell(round($host["avg_time"], 2), $host["id"]);
            form_selectable_cell(round($host["availability"], 2), $host["id"]);
            form_checkbox_cell($host["description"], $host["id"]);
            form_end_row();
        }
        /* put the nav bar on the bottom as well */
        print $nav;
    } else {
        print "<tr><td><em>No Hosts</em></td></tr>";
    }
    html_end_box(false);
    /* add a list of tree names to the actions dropdown */
    add_tree_names_to_actions_array();
    /* draw the dropdown containing a list of available actions for this form */
    draw_actions_dropdown($device_actions);
    print "</form>\n";
}
Exemplo n.º 17
0
/** function syslog_statistics()
 *  This function paints a table of summary statistics for syslog
 *  messages by host, facility, priority, and time range.
*/
function syslog_statistics()
{
    global $title, $colors, $rows, $config;
    include dirname(__FILE__) . "/config.php";
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request("rows"));
    input_validate_input_number(get_request_var_request("refresh"));
    input_validate_input_number(get_request_var_request("page"));
    input_validate_input_number(get_request_var_request("timespan"));
    /* ==================================================== */
    /* clean up filter string */
    if (isset($_REQUEST["filter"])) {
        $_REQUEST["filter"] = sanitize_search_string(get_request_var_request("filter"));
    }
    /* clean up facility string */
    if (isset($_REQUEST["facility"])) {
        $_REQUEST["facility"] = sanitize_search_string(get_request_var_request("facility"));
    }
    /* clean up priority string */
    if (isset($_REQUEST["priority"])) {
        $_REQUEST["priority"] = sanitize_search_string(get_request_var_request("priority"));
    }
    /* clean up sort solumn */
    if (isset($_REQUEST["sort_column"])) {
        $_REQUEST["sort_column"] = sanitize_search_string(get_request_var_request("sort_column"));
    }
    /* clean up sort direction */
    if (isset($_REQUEST["sort_direction"])) {
        $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var_request("sort_direction"));
    }
    /* if the user pushed the 'clear' button */
    if (isset($_REQUEST["clear"])) {
        kill_session_var("sess_syslog_stats_timespan");
        kill_session_var("sess_syslog_stats_rows");
        kill_session_var("sess_syslog_stats_refresh");
        kill_session_var("sess_syslog_stats_page");
        kill_session_var("sess_syslog_stats_filter");
        kill_session_var("sess_syslog_stats_facility");
        kill_session_var("sess_syslog_stats_priority");
        kill_session_var("sess_syslog_stats_sort_column");
        kill_session_var("sess_syslog_stats_sort_direction");
        $_REQUEST["page"] = 1;
        unset($_REQUEST["rows"]);
        unset($_REQUEST["timespan"]);
        unset($_REQUEST["refresh"]);
        unset($_REQUEST["page"]);
        unset($_REQUEST["filter"]);
        unset($_REQUEST["facility"]);
        unset($_REQUEST["priority"]);
        unset($_REQUEST["sort_column"]);
        unset($_REQUEST["sort_direction"]);
        $reset_multi = true;
    } else {
        /* if any of the settings changed, reset the page number */
        $changed = 0;
        $changed += syslog_check_changed("timespan", "sess_syslog_stats_timespan");
        $changed += syslog_check_changed("rows", "sess_syslog_stats_rows");
        $changed += syslog_check_changed("refresh", "sess_syslog_stats_refresh");
        $changed += syslog_check_changed("filter", "sess_syslog_stats_filter");
        $changed += syslog_check_changed("facility", "sess_syslog_stats_facility");
        $changed += syslog_check_changed("priority", "sess_syslog_stats_priority");
        $changed += syslog_check_changed("sort_column", "sess_syslog_stats_sort_column");
        $changed += syslog_check_changed("sort_direction", "sess_syslog_stats_sort_direction");
        if ($changed) {
            $_REQUEST["page"] = "1";
        }
        $reset_multi = false;
    }
    /* remember search fields in session vars */
    load_current_session_value("page", "sess_syslog_stats_page", "1");
    load_current_session_value("rows", "sess_syslog_stats_rows", read_config_option("num_rows_syslog"));
    load_current_session_value("refresh", "sess_syslog_stats_refresh", read_config_option("syslog_refresh"));
    load_current_session_value("filter", "sess_syslog_stats_filter", "");
    load_current_session_value("facility", "sess_syslog_stats_facility", "-1");
    load_current_session_value("priority", "sess_syslog_stats_priority", "-1");
    load_current_session_value("sort_column", "sess_syslog_stats_sort_column", "host");
    load_current_session_value("sort_direction", "sess_syslog_stats_sort_direction", "DESC");
    html_start_box("<strong>Syslog Statistics Filter</strong>", "100%", $colors["header"], "3", "center", "");
    syslog_stats_filter();
    html_end_box();
    html_start_box("", "100%", $colors["header"], "3", "center", "");
    $sql_where = "";
    $sql_groupby = "";
    if ($_REQUEST["rows"] == -1) {
        $row_limit = read_config_option("num_rows_syslog");
    } elseif ($_REQUEST["rows"] == -2) {
        $row_limit = 999999;
    } else {
        $row_limit = $_REQUEST["rows"];
    }
    $records = get_stats_records($sql_where, $sql_groupby, $row_limit);
    $rows_query_string = "SELECT COUNT(*)\n\t\tFROM `" . $syslogdb_default . "`.`syslog_statistics` AS ss\n\t\tLEFT JOIN `" . $syslogdb_default . "`.`syslog_facilities` AS sf\n\t\tON ss.facility_id=sf.facility_id\n\t\tLEFT JOIN `" . $syslogdb_default . "`.`syslog_priorities` AS sp\n\t\tON ss.priority_id=sp.priority_id\n\t\tLEFT JOIN `" . $syslogdb_default . "`.`syslog_hosts` AS sh\n\t\tON ss.host_id=sh.host_id\n\t\t{$sql_where}\n\t\t{$sql_groupby}";
    $total_rows = sizeof(syslog_db_fetch_cell($rows_query_string));
    ?>
	<script type="text/javascript">
	<!--
	function applyChange(objForm) {
		strURL = '?facility=' + objForm.facility.value;
		strURL = strURL + '&priority=' + objForm.priority.value;
		strURL = strURL + '&filter=' + objForm.filter.value;
		strURL = strURL + '&rows=' + objForm.rows.value;
		document.location = strURL;
	}
	-->
	</script>
	<?php 
    /* generate page list */
    $url_page_select = get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, "syslog.php?tab=stats&filter=" . $_REQUEST["filter"]);
    if ($total_rows > 0) {
        $nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t\t\t<td colspan='13'>\n\t\t\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td align='left' class='textHeaderDark'>\n\t\t\t\t\t\t\t\t\t<strong>&lt;&lt; ";
        if ($_REQUEST["page"] > 1) {
            $nav .= "<a class='linkOverDark' href='syslog.php?tab=stats&page=" . ($_REQUEST["page"] - 1) . "'>";
        }
        $nav .= "Previous";
        if ($_REQUEST["page"] > 1) {
            $nav .= "</a>";
        }
        $nav .= "</strong>\n\t\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\t\t\tShowing Rows " . ($total_rows == 0 ? "None" : $row_limit * ($_REQUEST["page"] - 1) + 1 . " to " . ($total_rows < $row_limit || $total_rows < $row_limit * $_REQUEST["page"] ? $total_rows : $row_limit * $_REQUEST["page"]) . " of {$total_rows} [{$url_page_select}]") . "\n\t\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t\t<td align='right' class='textHeaderDark'>\n\t\t\t\t\t\t\t\t\t<strong>";
        if ($_REQUEST["page"] * $row_limit < $total_rows) {
            $nav .= "<a class='linkOverDark' href='syslog.php?tab=stats&page=" . ($_REQUEST["page"] + 1) . "'>";
        }
        $nav .= "Next";
        if ($_REQUEST["page"] * $row_limit < $total_rows) {
            $nav .= "</a>";
        }
        $nav .= " &gt;&gt;</strong>\n\t\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
    } else {
        $nav = "<tr bgcolor='#" . $colors["header"] . "' class='noprint'>\n\t\t\t\t\t<td colspan='22'>\n\t\t\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\t\t\tNo Rows Found\n\t\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
    }
    print $nav;
    $display_text = array("host" => array("Host Name", "ASC"), "facility" => array("Facility", "ASC"), "priority" => array("Priority", "ASC"), "records" => array("Records", "DESC"));
    html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]);
    $i = 0;
    if (sizeof($records)) {
        foreach ($records as $r) {
            form_alternate_row_color($colors["alternate"], $colors["light"], $i);
            $i++;
            echo "<td>" . $r["host"] . "</td>";
            echo "<td>" . ($_REQUEST["facility"] != "-2" ? ucfirst($r["facility"]) : "-") . "</td>";
            echo "<td>" . ($_REQUEST["priority"] != "-2" ? ucfirst($r["priority"]) : "-") . "</td>";
            echo "<td>" . $r["records"] . "</td>";
            form_end_row();
        }
    } else {
        print "<tr><td colspan='4'><em>No Syslog Statistics Found</em></td></tr>";
    }
    html_end_box(false);
}
Exemplo n.º 18
0
function template() {
	global $colors, $graph_actions;

	html_start_box("<strong>Graph Templates</strong>", "98%", $colors["header"], "3", "center", "graph_templates.php?action=template_edit");

	html_header_checkbox(array("Template Title"));

	$template_list = db_fetch_assoc("select
		graph_templates.id,graph_templates.name
		from graph_templates
		order by name");

	$i = 0;
	if (sizeof($template_list) > 0) {
	foreach ($template_list as $template) {
		form_alternate_row_color($colors["alternate"],$colors["light"],$i);
			?>
			<td>
				<a class="linkEditMain" href="graph_templates.php?action=template_edit&id=<?php print $template["id"];?>"><?php print $template["name"];?></a>
			</td>
			<td style="<?php print get_checkbox_style();?>" width="1%" align="right">
				<input type='checkbox' style='margin: 0px;' name='chk_<?php print $template["id"];?>' title="<?php print $template["name"];?>">
			</td>
		</tr>
		<?php
		$i++;
	}
	}else{
		print "<tr><td><em>No Graph Templates</em></td></tr>\n";
	}
	html_end_box(false);

	/* draw the dropdown containing a list of available actions for this form */
	draw_actions_dropdown($graph_actions);

	print "</form>\n";
}
Exemplo n.º 19
0
function data_query() {
	global $colors, $dq_actions;

	/* clean up search string */
	if (isset($_REQUEST["filter"])) {
		$_REQUEST["filter"] = sanitize_search_string(get_request_var("filter"));
	}

	/* clean up sort_column */
	if (isset($_REQUEST["sort_column"])) {
		$_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
	}

	/* clean up search string */
	if (isset($_REQUEST["sort_direction"])) {
		$_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
	}

	/* if the user pushed the 'clear' button */
	if (isset($_REQUEST["clear_x"])) {
		kill_session_var("sess_data_queries_filter");
		kill_session_var("sess_data_queries_sort_column");
		kill_session_var("sess_data_queries_sort_direction");

		unset($_REQUEST["page"]);
		unset($_REQUEST["filter"]);
		unset($_REQUEST["sort_column"]);
		unset($_REQUEST["sort_direction"]);
		$_REQUEST["page"] = 1;
	}

	/* remember these search fields in session vars so we don't have to keep passing them around */
	load_current_session_value("sort_column", "sess_data_queries_sort_column", "name");
	load_current_session_value("sort_direction", "sess_data_queries_sort_direction", "ASC");
	load_current_session_value("page", "sess_data_queries_current_page", "1");
	load_current_session_value("filter", "sess_data_queries_filter", "");

	html_start_box("<strong>Data Queries</strong>", "100%", $colors["header"], "3", "center", "data_queries.php?action=edit");

	?>
	<tr bgcolor="<?php print $colors["panel"];?>" class="noprint">
		<form name="form_graph_id" method="get">
		<td class="noprint">
			<table width="100%" cellpadding="0" cellspacing="0">
				<tr class="noprint">
					<td nowrap style='white-space: nowrap;' width="50">
						Search:&nbsp;
					</td>
					<td width="1">
						<input type="text" name="filter" size="40" value="<?php print get_request_var_request("filter");?>">
					</td>
					<td nowrap style='white-space: nowrap;'>
						&nbsp;<input type="image" src="images/button_go.gif" alt="Go" border="0" align="absmiddle">
						<input type="image" src="images/button_clear.gif" name="clear" alt="Clear" border="0" align="absmiddle">
					</td>
				</tr>
			</table>
		</td>
		<input type='hidden' name='page' value='1'>
		</form>
	</tr>
	<?php

	html_end_box();

	html_start_box("", "100%", $colors["header"], "3", "center", "");

	/* form the 'where' clause for our main sql query */
	if (strlen(get_request_var_request("filter"))) {
		$sql_where = "where (snmp_query.name like '%%" . get_request_var_request("filter") . "%%' OR data_input.name like '%%" . get_request_var_request("filter") . "%%')";
	}else{
		$sql_where = "";
	}

	$total_rows = db_fetch_cell("SELECT
		count(*)
		FROM snmp_query INNER JOIN data_input ON (snmp_query.data_input_id=data_input.id)
		$sql_where");

	$snmp_queries = db_fetch_assoc("SELECT
		snmp_query.id,
		snmp_query.name,
		data_input.name AS data_input_method
		FROM snmp_query INNER JOIN data_input ON (snmp_query.data_input_id=data_input.id)
		$sql_where
		ORDER BY " . get_request_var_request("sort_column") . " " . get_request_var_request("sort_direction") . "
		LIMIT " . (read_config_option("num_rows_device")*(get_request_var_request("page")-1)) . "," . read_config_option("num_rows_device"));

	/* generate page list */
	$url_page_select = get_page_list(get_request_var_request("page"), MAX_DISPLAY_PAGES, read_config_option("num_rows_device"), $total_rows, "data_queries.php?filter=" . get_request_var_request("filter"));

	$nav = "<tr bgcolor='#" . $colors["header"] . "'>
			<td colspan='7'>
				<table width='100%' cellspacing='0' cellpadding='0' border='0'>
					<tr>
						<td align='left' class='textHeaderDark'>
							<strong>&lt;&lt; "; if (get_request_var_request("page") > 1) { $nav .= "<a class='linkOverDark' href='data_queries.php?filter=" . get_request_var_request("filter") . "&page=" . (get_request_var_request("page")-1) . "'>"; } $nav .= "Previous"; if (get_request_var_request("page") > 1) { $nav .= "</a>"; } $nav .= "</strong>
						</td>\n
						<td align='center' class='textHeaderDark'>
							Showing Rows " . ((read_config_option("num_rows_device")*(get_request_var_request("page")-1))+1) . " to " . ((($total_rows < read_config_option("num_rows_device")) || ($total_rows < (read_config_option("num_rows_device")*get_request_var_request("page")))) ? $total_rows : (read_config_option("num_rows_device")*get_request_var_request("page"))) . " of $total_rows [$url_page_select]
						</td>\n
						<td align='right' class='textHeaderDark'>
							<strong>"; if ((get_request_var_request("page") * read_config_option("num_rows_device")) < $total_rows) { $nav .= "<a class='linkOverDark' href='data_queries.php?filter=" . get_request_var_request("filter") . "&page=" . (get_request_var_request("page")+1) . "'>"; } $nav .= "Next"; if ((get_request_var_request("page") * read_config_option("num_rows_device")) < $total_rows) { $nav .= "</a>"; } $nav .= " &gt;&gt;</strong>
						</td>\n
					</tr>
				</table>
			</td>
		</tr>\n";

	print $nav;

	$display_text = array(
		"name" => array("Name", "ASC"),
		"data_input_method" => array("Data Input Method", "ASC"));

	html_header_sort_checkbox($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"));

	$i = 0;
	if (sizeof($snmp_queries) > 0) {
		foreach ($snmp_queries as $snmp_query) {
			form_alternate_row_color($colors["alternate"],$colors["light"],$i, 'line' . $snmp_query["id"]); $i++;
			form_selectable_cell("<a class='linkEditMain' href='data_queries.php?action=edit&id=" . $snmp_query["id"] . "'>" . (strlen(get_request_var_request("filter")) ? eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $snmp_query["name"]) : $snmp_query["name"]) . "</a>", $snmp_query["id"]);
			form_selectable_cell((strlen(get_request_var_request("filter")) ? eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $snmp_query["data_input_method"]) : $snmp_query["data_input_method"]), $snmp_query["id"]);
			form_checkbox_cell($snmp_query["name"], $snmp_query["id"]);
			form_end_row();
		}

		print $nav;
	}else{
		print "<tr><td><em>No Data Queries</em></td></tr>";
	}

	html_end_box();

	/* draw the dropdown containing a list of available actions for this form */
	draw_actions_dropdown($dq_actions);
}
Exemplo n.º 20
0
function data_query() {
	global $colors;

	/* clean up sort_column */
	if (isset($_REQUEST["sort_column"])) {
		$_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
	}

	/* clean up search string */
	if (isset($_REQUEST["sort_direction"])) {
		$_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
	}

	/* remember these search fields in session vars so we don't have to keep passing them around */
	load_current_session_value("sort_column", "sess_data_queries_sort_column", "name");
	load_current_session_value("sort_direction", "sess_data_queries_sort_direction", "ASC");

	html_start_box("<strong>Data Queries</strong>", "98%", $colors["header"], "3", "center", "data_queries.php?action=edit");

	$display_text = array(
		"name" => array("Name", "ASC"),
		"data_input_method" => array("Data Input Method", "ASC"));

	html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"], 3);

	$snmp_queries = db_fetch_assoc("SELECT
			snmp_query.id,
			snmp_query.name,
			data_input.name AS data_input_method
			FROM snmp_query INNER JOIN data_input ON (snmp_query.data_input_id = data_input.id)
			ORDER BY " . $_REQUEST['sort_column'] . " " . $_REQUEST['sort_direction']);

	$i = 0;
	if (sizeof($snmp_queries) > 0) {
	foreach ($snmp_queries as $snmp_query) {
		form_alternate_row_color($colors["alternate"],$colors["light"],$i); $i++;
			?>
			<td>
				<a class="linkEditMain" href="data_queries.php?action=edit&id=<?php print $snmp_query["id"];?>"><?php print $snmp_query["name"];?></a>
			</td>
			<td>
				<?php print $snmp_query["data_input_method"]; ?>
			</td>
			<td align="right">
				<a href="data_queries.php?action=remove&id=<?php print $snmp_query["id"];?>"><img src="images/delete_icon.gif" width="10" height="10" border="0" alt="Delete"></a>
			</td>
		</tr>
	<?php
	}
	}
	html_end_box();
}
Exemplo n.º 21
0
function input_edit() {
	global $colors, $consolidation_functions, $graph_item_types, $struct_graph_item, $fields_graph_template_input_edit;

	$header_label = "[edit graph: " . db_fetch_cell("select name from graph_templates where id=" . $_GET["graph_template_id"]) . "]";

	/* get a list of all graph item field names and populate an array for user display */
	while (list($field_name, $field_array) = each($struct_graph_item)) {
		if ($field_array["method"] != "view") {
			$graph_template_items[$field_name] = $field_array["friendly_name"];
		}
	}

	if (!empty($_GET["id"])) {
		$graph_template_input = db_fetch_row("select * from graph_template_input where id=" . $_GET["id"]);
	}

	html_start_box("<strong>Graph Item Inputs</strong> $header_label", "98%", $colors["header"], "3", "center", "");

	draw_edit_form(array(
		"config" => array(),
		"fields" => inject_form_variables($fields_graph_template_input_edit, (isset($graph_template_input) ? $graph_template_input : array()), (isset($graph_template_items) ? $graph_template_items : array()), $_GET)
		));

	if (!(isset($_GET["id"]))) { $_GET["id"] = 0; }

	$item_list = db_fetch_assoc("select
		CONCAT_WS(' - ',data_template_data.name,data_template_rrd.data_source_name) as data_source_name,
		graph_templates_item.text_format,
		graph_templates_item.id as graph_templates_item_id,
		graph_templates_item.graph_type_id,
		graph_templates_item.consolidation_function_id,
		graph_template_input_defs.graph_template_input_id
		from graph_templates_item
		left join graph_template_input_defs on (graph_template_input_defs.graph_template_item_id=graph_templates_item.id and graph_template_input_defs.graph_template_input_id=" . $_GET["id"] . ")
		left join data_template_rrd on graph_templates_item.task_item_id=data_template_rrd.id
		left join data_local on data_template_rrd.local_data_id=data_local.id
		left join data_template_data on data_local.id=data_template_data.local_data_id
		where graph_templates_item.local_graph_id=0
		and graph_templates_item.graph_template_id=" . $_GET["graph_template_id"] . "
		order by graph_templates_item.sequence");

	form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],1); ?>
		<td width="50%">
			<font class="textEditTitle">Associated Graph Items</font><br>
			Select the graph items that you want to accept user input for.
		</td>
		<td>
		<?php
		$i = 0; $any_selected_item = "";
		if (sizeof($item_list) > 0) {
		foreach ($item_list as $item) {
			if ($item["graph_template_input_id"] == "") {
				$old_value = "";
			}else{
				$old_value = "on";
				$any_selected_item = $item["graph_templates_item_id"];
			}

			if ($graph_item_types{$item["graph_type_id"]} == "GPRINT") {
				$start_bold = "";
				$end_bold = "";
			}else{
				$start_bold = "<strong>";
				$end_bold = "</strong>";
			}

			$name = "$start_bold Item #" . ($i+1) . ": " . $graph_item_types{$item["graph_type_id"]} . " (" . $consolidation_functions{$item["consolidation_function_id"]} . ")$end_bold";
			form_checkbox("i_" . $item["graph_templates_item_id"], $old_value, $name,"",$_GET["graph_template_id"],true); print "<br>";

			$i++;
		}
		}else{
			print "<em>No Items</em>";
		}
		?>
		</td>
	</tr>

	<?php
	html_end_box();

	form_hidden_box("any_selected_item", $any_selected_item, "");

	form_save_button("graph_templates.php?action=template_edit&id=" . $_GET["graph_template_id"]);
}
Exemplo n.º 22
0
function user() {
	global $colors, $auth_realms;

	html_start_box("<strong>User Management</strong>", "98%", $colors["header"], "3", "center", "user_admin.php?action=user_edit");

	html_header(array("User Name", "Full Name", "Realm", "Default Graph Policy", "Last Login"), 2);

	$user_list = db_fetch_assoc("select id, user_auth.username, full_name, realm, policy_graphs, DATE_FORMAT(max(time),'%M %e %Y %H:%i:%s') as time from user_auth left join user_log on user_auth.id = user_log.user_id group by id");

	$i = 0;
	if (sizeof($user_list) > 0) {
	foreach ($user_list as $user) {
		form_alternate_row_color($colors["alternate"],$colors["light"],$i);
			?>
			<td>
				<a class="linkEditMain" href="user_admin.php?action=user_edit&id=<?php print $user["id"];?>"><?php print $user["username"];?></a>
			</td>
			<td>
				<?php print $user["full_name"];?>
			</td>
			<td>
				<?php print $auth_realms[$user["realm"]];?>
			</td>
			<td>
				<?php if ($user["policy_graphs"] == "1") { print "ALLOW"; }else{ print "DENY"; }?>
			</td>
			<td>
				<?php print $user["time"];?>
			</td>
			<td align="right">
				<a href="user_admin.php?action=user_remove&id=<?php print $user["id"];?>"><img src="images/delete_icon.gif" width="10" height="10" border="0" alt="Delete"></a>
			</td>
		</tr>
	<?php
	$i++;
	}
	}
	html_end_box();
}
Exemplo n.º 23
0
function host() {
	global $colors, $device_actions;

	/* if the user pushed the 'clear' button */
	if (isset($_REQUEST["clear_x"])) {
		kill_session_var("sess_device_current_page");
		kill_session_var("sess_device_filter");
		kill_session_var("sess_device_host_template_id");

		unset($_REQUEST["page"]);
		unset($_REQUEST["filter"]);
		unset($_REQUEST["host_template_id"]);
	}

	/* remember these search fields in session vars so we don't have to keep passing them around */
	load_current_session_value("page", "sess_device_current_page", "1");
	load_current_session_value("filter", "sess_device_filter", "");
	load_current_session_value("host_template_id", "sess_device_host_template_id", "-1");

	html_start_box("<strong>Devices</strong>", "98%", $colors["header"], "3", "center", "host.php?action=edit&host_template_id=" . $_REQUEST["host_template_id"]);

	include("./include/html/inc_device_filter_table.php");

	html_end_box();

	/* form the 'where' clause for our main sql query */
	$sql_where = "where host.description like '%%" . $_REQUEST["filter"] . "%%'";

	if ($_REQUEST["host_template_id"] == "-1") {
		/* Show all items */
	}elseif ($_REQUEST["host_template_id"] == "0") {
		$sql_where .= " and host.host_template_id=0";
	}elseif (!empty($_REQUEST["host_template_id"])) {
		$sql_where .= " and host.host_template_id=" . $_REQUEST["host_template_id"];
	}

	html_start_box("", "98%", $colors["header"], "3", "center", "");

	$total_rows = db_fetch_cell("select
		COUNT(host.id)
		from host
		$sql_where");

	$hosts = db_fetch_assoc("select
		host.id,
		host.disabled,
		host.status,
		host.hostname,
		host.description,
		host.min_time,
		host.max_time,
		host.cur_time,
		host.avg_time,
		host.availability
		from host
		$sql_where
		order by host.description
		limit " . (read_config_option("num_rows_device")*($_REQUEST["page"]-1)) . "," . read_config_option("num_rows_device"));

	/* generate page list */
	$url_page_select = get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, read_config_option("num_rows_device"), $total_rows, "host.php?filter=" . $_REQUEST["filter"] . "&host_template_id=" . $_REQUEST["host_template_id"]);

	$nav = "<tr bgcolor='#" . $colors["header"] . "'>
			<td colspan='7'>
				<table width='100%' cellspacing='0' cellpadding='0' border='0'>
					<tr>
						<td align='left' class='textHeaderDark'>
							<strong>&lt;&lt; "; if ($_REQUEST["page"] > 1) { $nav .= "<a class='linkOverDark' href='host.php?filter=" . $_REQUEST["filter"] . "&host_template_id=" . $_REQUEST["host_template_id"] . "&page=" . ($_REQUEST["page"]-1) . "'>"; } $nav .= "Previous"; if ($_REQUEST["page"] > 1) { $nav .= "</a>"; } $nav .= "</strong>
						</td>\n
						<td align='center' class='textHeaderDark'>
							Showing Rows " . ((read_config_option("num_rows_device")*($_REQUEST["page"]-1))+1) . " to " . ((($total_rows < read_config_option("num_rows_device")) || ($total_rows < (read_config_option("num_rows_device")*$_REQUEST["page"]))) ? $total_rows : (read_config_option("num_rows_device")*$_REQUEST["page"])) . " of $total_rows [$url_page_select]
						</td>\n
						<td align='right' class='textHeaderDark'>
							<strong>"; if (($_REQUEST["page"] * read_config_option("num_rows_device")) < $total_rows) { $nav .= "<a class='linkOverDark' href='host.php?filter=" . $_REQUEST["filter"] . "&host_template_id=" . $_REQUEST["host_template_id"] . "&page=" . ($_REQUEST["page"]+1) . "'>"; } $nav .= "Next"; if (($_REQUEST["page"] * read_config_option("num_rows_device")) < $total_rows) { $nav .= "</a>"; } $nav .= " &gt;&gt;</strong>
						</td>\n
					</tr>
				</table>
			</td>
		</tr>\n";

	print $nav;

	html_header_checkbox(array("Description", "Status", "Hostname", "Current (ms)", "Average (ms)", "Availability"));

	$i = 0;
	if (sizeof($hosts) > 0) {
		foreach ($hosts as $host) {
			form_alternate_row_color($colors["alternate"],$colors["light"],$i); $i++;
				?>
				<td width=200>
					<a class="linkEditMain" href="host.php?action=edit&id=<?php print $host["id"];?>"><?php print eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $host["description"]);?></a>
				</td>
				<td>
					<?php print get_colored_device_status(($host["disabled"] == "on" ? true : false), $host["status"]);?>
				</td>
				<td>
					<?php print $host["hostname"];?>
				</td>
				<td>
					<?php print round(($host["cur_time"]), 2);?>
				</td>
				<td>
					<?php print round(($host["avg_time"]), 2);?>
				</td>
				<td>
					<?php print round($host["availability"], 2);?>%
				</td>
				<td style="<?php print get_checkbox_style();?>" width="1%" align="right">
					<input type='checkbox' style='margin: 0px;' name='chk_<?php print $host["id"];?>' title="<?php print $host["description"];?>">
				</td>
			</tr>
			<?php
		}

		/* put the nav bar on the bottom as well */
		print $nav;
	}else{
		print "<tr><td><em>No Hosts</em></td></tr>";
	}
	html_end_box(false);

	/* draw the dropdown containing a list of available actions for this form */
	draw_actions_dropdown($device_actions);
}
Exemplo n.º 24
0
function poller() {
	global $colors, $poller_actions, $item_rows;

	/* ================= input validation ================= */
	input_validate_input_number(get_request_var_request("page"));
	input_validate_input_number(get_request_var_request("rows"));
	/* ==================================================== */

	/* clean up search string */
	if (isset($_REQUEST["filter"])) {
		$_REQUEST["filter"] = sanitize_search_string(get_request_var("filter"));
	}

	/* clean up sort_column */
	if (isset($_REQUEST["sort_column"])) {
		$_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
	}

	/* clean up sort_direction string */
	if (isset($_REQUEST["sort_direction"])) {
		$_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
	}

	/* if the user pushed the 'clear' button */
	if (isset($_REQUEST["clear_x"])) {
		kill_session_var("sess_poller_current_page");
		kill_session_var("sess_poller_rows");
		kill_session_var("sess_poller_filter");
		kill_session_var("sess_poller_sort_column");
		kill_session_var("sess_poller_sort_direction");

		unset($_REQUEST["page"]);
		unset($_REQUEST["rows"]);
		unset($_REQUEST["filter"]);
		unset($_REQUEST["sort_column"]);
		unset($_REQUEST["sort_direction"]);
	}

	?>
	<script type="text/javascript">
	<!--
	function applyFilterChange(objForm) {
		strURL = '?rows=' + objForm.rows.value;
		strURL = strURL + '&filter=' + objForm.filter.value;
		document.location = strURL;
	}
	-->
	</script>
	<?php

	/* remember these search fields in session vars so we don't have to keep passing them around */
	load_current_session_value("page", "sess_poller_current_page", "1");
	load_current_session_value("rows", "sess_poller_rows", "-1");
	load_current_session_value("filter", "sess_poller_filter", "");
	load_current_session_value("sort_column", "sess_poller_sort_column", "description");
	load_current_session_value("sort_direction", "sess_poller_sort_direction", "ASC");

	display_output_messages();

	html_start_box("<strong>" . __("Pollers") . "</strong>", "100", $colors["header"], "3", "center", "pollers.php?action=edit", true);
	?>
	<tr class='rowAlternate2'>
		<td>
			<form name="form_pollers" action="pollers.php">
			<table cellpadding="0" cellspacing="3">
				<tr>
					<td class="nw50">
						&nbsp;<?php print __("Search:");?>&nbsp;
					</td>
					<td class="w1">
						<input type="text" name="filter" size="40" value="<?php print $_REQUEST["filter"];?>">
					</td>
					<td class="nw50">
						&nbsp;<?php print __("Rows:");?>&nbsp;
					</td>
					<td class="w1">
						<select name="rows" onChange="applyFilterChange(document.form_pollers)">
							<option value="-1"<?php if (get_request_var_request("rows") == "-1") {?> selected<?php }?>>Default</option>
							<?php
							if (sizeof($item_rows) > 0) {
							foreach ($item_rows as $key => $value) {
								print "<option value='" . $key . "'"; if (get_request_var_request("rows") == $key) { print " selected"; } print ">" . $value . "</option>\n";
							}
							}
							?>
						</select>
					</td>
					<td class="nw120">
						&nbsp;<input type="submit" Value="<?php print __("Go");?>" name="go" align="middle">
						<input type="submit" Value="<?php print __("Clear");?>" name="clear_x" align="middle">
					</td>
				</tr>
			</table>
			<div><input type='hidden' name='page' value='1'></div>
			</form>
		</td>
	</tr>
	<?php
	html_end_box(false);

	/* form the 'where' clause for our main sql query */
	if ($_REQUEST["filter"] != "") {
		$sql_where = "WHERE (p.description LIKE '%%" . $_REQUEST["filter"] . "%%')";
	}else{
		$sql_where = "";
	}

	html_start_box("", "100", $colors["header"], "0", "center", "");

	$total_rows = db_fetch_cell("SELECT
		COUNT(*)
		FROM poller
		$sql_where");

	if (get_request_var_request("rows") == "-1") {
		$rows = read_config_option("num_rows_device");
	}else{
		$rows = get_request_var_request("rows");
	}

	$poller_list = db_fetch_assoc("SELECT p.*,
		sum(CASE WHEN h.poller_id IS NOT NULL THEN 1 ELSE NULL END) AS total_devices
		FROM poller AS p
		LEFT JOIN device AS h ON h.poller_id=p.id
		$sql_where
		GROUP BY p.id
		ORDER BY " . get_request_var_request('sort_column') . " " . get_request_var_request('sort_direction') .
		" LIMIT " . ($rows*(get_request_var_request("page")-1)) . "," . $rows);

	/* generate page list navigation */
	$nav = html_create_nav($_REQUEST["page"], MAX_DISPLAY_PAGES, $rows, $total_rows, 7, "pollers.php");

	print $nav;
	html_end_box(false);

	$display_text = array(
		"description" => array(__("Description"), "ASC"),
		"id" => array(__("ID"), "ASC"),
		"total_devices" => array(__("Devices"), "DESC"),
		"nosort2" => array(__("Poller Items"), "DESC"),
		"hostname" => array(__("Hostname"), "ASC"),
		"nosort1" => array(__("Status"), ""),
		"last_update" => array(__("Last Updated"), "ASC"));

	html_header_sort_checkbox($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"));

	if (sizeof($poller_list) > 0) {
		foreach ($poller_list as $poller) {
			form_alternate_row_color('line' . $poller["id"], true);
			form_selectable_cell("<a class='linkEditMain' href='" . htmlspecialchars("pollers.php?action=edit&id=" . $poller["id"]) . "'>" . (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span class=\"filter\">\\1</span>", $poller["description"]) : $poller["description"]) . "</a>", $poller["id"]);
			form_selectable_cell($poller["id"], $poller["id"]);
			form_selectable_cell($poller["total_devices"], $poller["id"]);
			form_selectable_cell(db_fetch_cell("SELECT count(*) FROM poller_item WHERE poller_id=" . $poller["id"]), $poller["id"]);
			form_selectable_cell($poller["hostname"], $poller["id"]);
			form_selectable_cell(get_colored_poller_status(($poller["disabled"] == CHECKED ? true : false), $poller["last_update"]), $poller["id"]);
			form_selectable_cell($poller["last_update"], $poller["id"]);
			form_checkbox_cell($poller["description"], $poller["id"]);
			form_end_row();
		}

		form_end_table();

		/* put the nav bar on the bottom as well */
		print $nav;
	}else{
		print "<tr><td><em>" . __("No Pollers Defined") . "</em></td></tr>\n";
	}

	print "</table>\n";	# end table of html_header_sort_checkbox

	/* draw the dropdown containing a list of available actions for this form */
	draw_actions_dropdown($poller_actions);
	print "</form>\n";	# end form of html_header_sort_checkbox
}
Exemplo n.º 25
0
function tree() {
	global $colors;

	html_start_box("<strong>Graph Trees</strong>", "100%", $colors["header"], "3", "center", "tree.php?action=edit");

	print "<tr bgcolor='#" . $colors["header_panel"] . "'>";
		DrawMatrixHeaderItem("Name",$colors["header_text"],1);
		DrawMatrixHeaderItem("&nbsp;",$colors["header_text"],1);
	print "</tr>";

	$trees = db_fetch_assoc("SELECT * FROM graph_tree ORDER BY name");

	$i = 0;
	if (sizeof($trees) > 0) {
	foreach ($trees as $tree) {
		form_alternate_row_color($colors["alternate"],$colors["light"],$i); $i++;
			?>
			<td>
				<a class="linkEditMain" href="tree.php?action=edit&id=<?php print $tree["id"];?>"><?php print $tree["name"];?></a>
			</td>
			<td align="right">
				<a href="tree.php?action=remove&id=<?php print $tree["id"];?>"><img src="images/delete_icon.gif" width="10" height="10" border="0" alt="Delete"></a>
			</td>
		</tr>
	<?php
	}
	}else{
		print "<tr><td><em>No Graphs Trees</em></td></tr>\n";
	}
	html_end_box();
}
Exemplo n.º 26
0
function mactrack_view_sites() {
	global $title, $colors, $config, $item_rows;

	/* ================= input validation ================= */
	input_validate_input_number(get_request_var_request("site_id"));
	input_validate_input_number(get_request_var_request("device_id"));
	input_validate_input_number(get_request_var_request("page"));
	input_validate_input_number(get_request_var_request("rows"));
	/* ==================================================== */

	/* clean up search string */
	if (isset($_REQUEST["detail"])) {
		$_REQUEST["detail"] = sanitize_search_string(get_request_var("detail"));
	}

	/* clean up search string */
	if (isset($_REQUEST["filter"])) {
		$_REQUEST["filter"] = sanitize_search_string(get_request_var("filter"));
	}

	/* clean up sort_column */
	if (isset($_REQUEST["sort_column"])) {
		$_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
	}

	/* clean up search string */
	if (isset($_REQUEST["sort_direction"])) {
		$_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
	}

	/* if the user pushed the 'clear' button */
	if (isset($_REQUEST["clear_x"]) || isset($_REQUEST["reset"])) {
		kill_session_var("sess_mactrack_view_sites_current_page");
		kill_session_var("sess_mactrack_view_sites_detail");
		kill_session_var("sess_mactrack_view_sites_device_type_id");
		kill_session_var("sess_mactrack_view_sites_site_id");
		kill_session_var("sess_mactrack_view_sites_filter");
		kill_session_var("sess_mactrack_view_sites_rows");
		kill_session_var("sess_mactrack_view_sites_sort_column");
		kill_session_var("sess_mactrack_view_sites_sort_direction");

		$_REQUEST["page"] = 1;

		if (isset($_REQUEST["clear_x"])) {
			unset($_REQUEST["filter"]);
			unset($_REQUEST["rows"]);
			unset($_REQUEST["device_type_id"]);
			unset($_REQUEST["site_id"]);
			unset($_REQUEST["detail"]);
			unset($_REQUEST["sort_column"]);
			unset($_REQUEST["sort_direction"]);
		}
	}else{
		/* if any of the settings changed, reset the page number */
		$changed = 0;
		$changed += mactrack_check_changed("device_type_id", "sess_mactrack_view_sites_device_type_id");
		$changed += mactrack_check_changed("site_id", "sess_mactrack_view_sites_site_id");
		$changed += mactrack_check_changed("filter", "sess_mactrack_view_sites_filter");
		$changed += mactrack_check_changed("rows", "sess_mactrack_view_sites_rows");
		$changed += mactrack_check_changed("detail", "sess_mactrack_view_sites_detail");

		if ($changed) {
			$_REQUEST["page"] = "1";
		}
	}

	/* remember these search fields in session vars so we don't have to keep passing them around */
	load_current_session_value("page", "sess_mactrack_view_sites_current_page", "1");
	load_current_session_value("detail", "sess_mactrack_view_sites_detail", "false");
	load_current_session_value("device_type_id", "sess_mactrack_view_sites_device_type_id", "-1");
	load_current_session_value("site_id", "sess_mactrack_view_sites_site_id", "-1");
	load_current_session_value("filter", "sess_mactrack_view_sites_filter", "");
	load_current_session_value("rows", "sess_mactrack_view_sites_rows", "-1");
	load_current_session_value("sort_column", "sess_mactrack_view_sites_sort_column", "site_name");
	load_current_session_value("sort_direction", "sess_mactrack_view_sites_sort_direction", "ASC");

	if ($_REQUEST["rows"] == -1) {
		$row_limit = read_config_option("num_rows_mactrack");
	}elseif ($_REQUEST["rows"] == -2) {
		$row_limit = 999999;
	}else{
		$row_limit = $_REQUEST["rows"];
	}

	if (defined("URL_PATH")) {
		$webroot = URL_PATH;
	}else{
		$webroot = $config["url_path"];
	}

	mactrack_tabs();
	mactrack_view_header();
	mactrack_site_filter();
	mactrack_view_footer();
	html_start_box("", "100%", $colors["header"], "3", "center", "");

	$sql_where = "";

	$sites = mactrack_view_get_site_records($sql_where, $row_limit);

	if ($_REQUEST["detail"] == "false") {
		$total_rows = db_fetch_cell("SELECT
			COUNT(mac_track_sites.site_id)
			FROM mac_track_sites
			$sql_where");
	}else{
		$total_rows = sizeof(db_fetch_assoc("SELECT
			mac_track_device_types.device_type_id, mac_track_sites.site_name
			FROM (mac_track_device_types
			RIGHT JOIN mac_track_devices ON (mac_track_device_types.device_type_id = mac_track_devices.device_type_id))
			RIGHT JOIN mac_track_sites ON (mac_track_devices.site_id = mac_track_sites.site_id)
			$sql_where
			GROUP BY mac_track_sites.site_name, mac_track_device_types.device_type_id"));
	}

	/* generate page list */
	$url_page_select = str_replace("&page", "?page", get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, "mactrack_view_sites.php"));

	if (isset($config["base_path"])) {
		if ($total_rows > 0) {
			$nav = "<tr bgcolor='#" . $colors["header"] . "'>
					<td colspan='11'>
						<table width='100%' cellspacing='0' cellpadding='0' border='0'>
							<tr>
								<td align='left' class='textHeaderDark'>
									<strong>&lt;&lt; "; if ($_REQUEST["page"] > 1) { $nav .= "<a class='linkOverDark' href='mactrack_view_sites.php?page=" . ($_REQUEST["page"]-1) . "'>"; } $nav .= "Previous"; if ($_REQUEST["page"] > 1) { $nav .= "</a>"; } $nav .= "</strong>
								</td>\n
								<td align='center' class='textHeaderDark'>
									Showing Rows " . ($total_rows == 0 ? "None" : (($row_limit*($_REQUEST["page"]-1))+1) . " to " . ((($total_rows < $row_limit) || ($total_rows < ($row_limit*$_REQUEST["page"]))) ? $total_rows : ($row_limit*$_REQUEST["page"])) . " of $total_rows [$url_page_select]") . "
								</td>\n
								<td align='right' class='textHeaderDark'>
									<strong>"; if (($_REQUEST["page"] * $row_limit) < $total_rows) { $nav .= "<a class='linkOverDark' href='mactrack_view_sites.php?page=" . ($_REQUEST["page"]+1) . "'>"; } $nav .= "Next"; if (($_REQUEST["page"] * $row_limit) < $total_rows) { $nav .= "</a>"; } $nav .= " &gt;&gt;</strong>
								</td>\n
							</tr>
						</table>
					</td>
				</tr>\n";
		}else{
			$nav = "<tr bgcolor='#" . $colors["header"] . "' class='noprint'>
						<td colspan='22'>
							<table width='100%' cellspacing='0' cellpadding='0' border='0'>
								<tr>
									<td align='center' class='textHeaderDark'>
										No Rows Found
									</td>\n
								</tr>
							</table>
						</td>
					</tr>\n";
		}
	}else{
		$nav = html_create_nav($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, 11, "mactrack_view_sites.php");
	}

	print $nav;

	if ($_REQUEST["detail"] == "false") {
		$display_text = array(
			"nosort" => array("Actions", ""),
			"site_name" => array("Site Name", "ASC"),
			"total_devices" => array("Devices", "DESC"),
			"total_ips" => array("Total IP's", "DESC"),
			"total_user_ports" => array("User Ports", "DESC"),
			"total_oper_ports" => array("User Ports Up", "DESC"),
			"total_macs" => array("MACS Found", "DESC"),
			"total_device_errors" => array("Device Errors", "DESC"));

		html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]);

		$i = 0;
		if (sizeof($sites) > 0) {
			foreach ($sites as $site) {
				form_alternate_row_color($colors["alternate"],$colors["light"],$i,'row_' . $site["site_id"]); $i++;
					?>
					<td width=140>
						<?php
						if (mactrack_authorized(2121)) {
							echo "<a href='" . $webroot . "plugins/mactrack/mactrack_sites.php?action=edit&site_id=" . $site['site_id'] . "' title='Edit Site'><img border='0' src='" . $webroot . "plugins/mactrack/images/edit_object.png'></a>";
							echo "<a href='#'><img id='r_" . $site["site_id"] . "' src='" . $config['url_path'] . "plugins/mactrack/images/rescan_site.gif' alt='' onMouseOver='style.cursor=\"pointer\"' onClick='site_scan(" . $site["site_id"] . ")' title='Rescan Site' border='0'></a>";
						}
						?>
						<a href='<?php print $webroot . "plugins/mactrack/mactrack_view_devices.php?report=devices&reset&site_id=" . $site['site_id'];?>' title='View Devices'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_devices.gif'></a>
						<a href='<?php print $webroot . "plugins/mactrack/mactrack_view_ips.php?report=ips&reset&site_id=" . $site['site_id'];?>' title='View IP Ranges'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_networks.gif'></a>
						<a href='<?php print $webroot . "plugins/mactrack/mactrack_view_arp.php?report=arp&reset&site_id=" . $site['site_id'];?>' title='View IP Addresses'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_ipaddresses.gif'></a>
						<a href='<?php print $webroot . "plugins/mactrack/mactrack_view_macs.php?report=macs&reset&device_id=-1&scan_date=3&site_id=" . $site['site_id'];?>' title='View MAC Addresses'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_macs.gif'></a>
						<a href='<?php print $webroot . "plugins/mactrack/mactrack_view_interfaces.php?report=interfaces&reset&site=" . $site['site_id'];?>' title='View Interfaces'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_interfaces.gif'></a>
					</td>
					<td width=200>
						<?php print "<strong>" . (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $site["site_name"]) : $site["site_name"]) . "</strong>";?>
					</td>
					<td><?php print number_format($site["total_devices"]);?></td>
					<td><?php print number_format($site["total_ips"]);?></td>
					<td><?php print number_format($site["total_user_ports"]);?></td>
					<td><?php print number_format($site["total_oper_ports"]);?></td>
					<td><?php print number_format($site["total_macs"]);?></td>
					<td><?php print ($site["total_device_errors"]);?></td>
				</tr>
				<?php
			}
		}else{
			print "<tr><td colspan='10'><em>No MacTrack Sites</em></td></tr>";
		}

		print $nav;

		html_end_box(false);

		mactrack_display_stats();
	}else{
		$display_text = array(
			"nosort" => array("Actions", ""),
			"site_name" => array("Site Name", "ASC"),
			"vendor" => array("Vendor", "ASC"),
			"description" => array("Device Type", "DESC"),
			"total_devices" => array("Total Devices", "DESC"),
			"sum_ips_total" => array("Total IP's", "DESC"),
			"sum_ports_total" => array("Total User Ports", "DESC"),
			"sum_ports_active" => array("Total Oper Ports", "DESC"),
			"sum_ports_trunk" => array("Total Trunks", "DESC"),
			"sum_macs_active" => array("MACS Found", "DESC"));

		html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]);

		$i = 0;
		if (sizeof($sites) > 0) {
			foreach ($sites as $site) {
				form_alternate_row_color($colors["alternate"],$colors["light"],$i); $i++;
					?>
					<td width=100>
						<?php
						if (mactrack_authorized(2121)) {
							echo "<a href='" . $webroot . "plugins/mactrack/mactrack_sites.php?action=edit&site_id=" . $site['site_id'] . "' title='Edit Site'><img border='0' src='" . $webroot . "plugins/mactrack/images/edit_object.png'></a>";
						}
						?>
						<a href='<?php print $webroot . "plugins/mactrack/mactrack_view_devices.php?report=devices&site_id=" . $site['site_id'] . "&device_type_id=" . $site['device_type_id'];?>&type_id=-1&status=-1&filter=' title='View Devices'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_devices.gif'></a>
						<a href='<?php print $webroot . "plugins/mactrack/mactrack_view_ips.php?report=ips&reset&site_id=" . $site['site_id'];?>' title='View IP Ranges'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_networks.gif'></a>
						<a href='<?php print $webroot . "plugins/mactrack/mactrack_view_macs.php?report=macs&reset&device_id=-1&scan_date=3&site_id=" . $site['site_id'];?>' title='View MAC Addresses'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_macs.gif'></a>
						<a href='<?php print $webroot . "plugins/mactrack/mactrack_view_interfaces.php?report=interfaces&reset&site=" . $site['site_id'];?>' title='View Interfaces'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_interfaces.gif'></a>
					</td>
					<td width=200>
						<?php print "<strong>" . (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $site["site_name"]) : $site["site_name"]) . "</strong>";?>
					</td>
					<td><?php print (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $site["vendor"]) : $site["vendor"]);?></td>
					<td><?php print (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $site["description"]) : $site["description"]);?></td>
					<td><?php print number_format($site["total_devices"]);?></td>
					<td><?php print ($site["device_type"] == "1" ? "N/A" : number_format($site["sum_ips_total"]));?></td>
					<td><?php print ($site["device_type"] == "3" ? "N/A" : number_format($site["sum_ports_total"]));?></td>
					<td><?php print ($site["device_type"] == "3" ? "N/A" : number_format($site["sum_ports_active"]));?></td>
					<td><?php print ($site["device_type"] == "3" ? "N/A" : number_format($site["sum_ports_trunk"]));?></td>
					<td><?php print ($site["device_type"] == "3" ? "N/A" : number_format($site["sum_macs_active"]));?></td>
				</tr>
				<?php
			}
		}else{
			print "<tr><td colspan='10'><em>No MacTrack Sites</em></td></tr>";
		}

		print $nav;

		html_end_box(false);

		mactrack_display_stats();
	}

	print "<div id='response'></div>";
}
Exemplo n.º 27
0
function gprint_presets() {
	global $colors;

	html_start_box("<strong>GPRINT Presets</strong>", "100%", $colors["header"], "3", "center", "gprint_presets.php?action=edit");

	print "	<tr bgcolor='#" . $colors["header_panel"] . "'>
			<td colspan='2' class='textSubHeaderDark'>GPRINT Preset Title</td>
		</tr>";

	$template_list = db_fetch_assoc("select
		graph_templates_gprint.id,
		graph_templates_gprint.name
		from graph_templates_gprint");

	$i = 0;
	if (sizeof($template_list) > 0) {
	foreach ($template_list as $template) {
		form_alternate_row_color($colors["alternate"],$colors["light"],$i);
			?>
			<td>
				<a class="linkEditMain" href="gprint_presets.php?action=edit&id=<?php print $template["id"];?>"><?php print $template["name"];?></a>
			</td>
			<td align="right">
				<a href="gprint_presets.php?action=remove&id=<?php print $template["id"];?>"><img src="images/delete_icon.gif" width="10" height="10" border="0" alt="Delete"></a>
			</td>
		</tr>
		<?php
		$i++;
	}
	}else{
		form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],0); ?>
			<td colspan="2">
				<em>No Items</em>
			</td>
		</tr><?php
	}
	html_end_box();
}
Exemplo n.º 28
0
function utilities_view_poller_cache() {
	global $colors, $poller_actions;

	define("MAX_DISPLAY_PAGES", 21);

	/* ================= input validation ================= */
	input_validate_input_number(get_request_var_request("host_id"));
	input_validate_input_number(get_request_var_request("page"));
	input_validate_input_number(get_request_var_request("poller_action"));
	/* ==================================================== */

	/* clean up search filter */
	if (isset($_REQUEST["filter"])) {
		$_REQUEST["filter"] = sanitize_search_string(get_request_var("filter"));
	}

	/* clean up sort_column */
	if (isset($_REQUEST["sort_column"])) {
		$_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
	}

	/* clean up sort direction */
	if (isset($_REQUEST["sort_direction"])) {
		$_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
	}

	/* if the user pushed the 'clear' button */
	if (isset($_REQUEST["clear_x"])) {
		kill_session_var("sess_poller_current_page");
		kill_session_var("sess_poller_host_id");
		kill_session_var("sess_poller_poller_action");
		kill_session_var("sess_poller_filter");

		unset($_REQUEST["page"]);
		unset($_REQUEST["filter"]);
		unset($_REQUEST["host_id"]);
		unset($_REQUEST["poller_action"]);
	}

	if ((!empty($_SESSION["sess_poller_action"])) && (!empty($_REQUEST["poller_action"]))) {
		if ($_SESSION["sess_poller_poller_action"] != $_REQUEST["poller_action"]) {
			$_REQUEST["page"] = 1;
		}
	}

	/* remember these search fields in session vars so we don't have to keep passing them around */
	load_current_session_value("page", "sess_poller_current_page", "1");
	load_current_session_value("host_id", "sess_poller_host_id", "-1");
	load_current_session_value("poller_action", "sess_poller_poller_action", "-1");
	load_current_session_value("filter", "sess_poller_filter", "");
	load_current_session_value("sort_column", "sess_poller_sort_column", "data_template_data.name_cache");
	load_current_session_value("sort_direction", "sess_poller_sort_direction", "ASC");

	$_REQUEST['page_referrer'] = 'view_poller_cache';
	load_current_session_value('page_referrer', 'page_referrer', 'view_poller_cache');

	?>
	<script type="text/javascript">
	<!--

	function applyPItemFilterChange(objForm) {
		strURL = '?poller_action=' + objForm.poller_action.value;
		strURL = strURL + '&host_id=' + objForm.host_id.value;
		strURL = strURL + '&filter=' + objForm.filter.value;
		strURL = strURL + '&action=view_poller_cache';
		document.location = strURL;
	}

	-->
	</script>
	<?php

	html_start_box("<strong>Poller Cache Items</strong>", "100%", $colors["header"], "3", "center", "");

	?>
	<tr bgcolor="<?php print $colors["panel"];?>">
		<form name="form_pollercache">
		<td>
			<table cellpadding="0" cellspacing="0">
				<tr>
					<td nowrap style='white-space: nowrap;' width="50">
						Host:&nbsp;
					</td>
					<td width="1">
						<select name="host_id" onChange="applyPItemFilterChange(document.form_pollercache)">
							<option value="-1"<?php if (get_request_var_request("host_id") == "-1") {?> selected<?php }?>>Any</option>
							<option value="0"<?php if (get_request_var_request("host_id") == "0") {?> selected<?php }?>>None</option>
							<?php
							$hosts = db_fetch_assoc("select id,description,hostname from host order by description");

							if (sizeof($hosts) > 0) {
							foreach ($hosts as $host) {
								print "<option value='" . $host["id"] . "'"; if (get_request_var_request("host_id") == $host["id"]) { print " selected"; } print ">" . $host["description"] . "</option>\n";
							}
							}
							?>
						</select>
					</td>
					<td nowrap style='white-space: nowrap;' width="50">
						&nbsp;Action:&nbsp;
					</td>
					<td width="1">
						<select name="poller_action" onChange="applyPItemFilterChange(document.form_pollercache)">
							<option value="-1"<?php if (get_request_var_request("poller_action") == '-1') {?> selected<?php }?>>Any</option>
							<option value="0"<?php if (get_request_var_request("poller_action") == '0') {?> selected<?php }?>>SNMP</option>
							<option value="1"<?php if (get_request_var_request("poller_action") == '1') {?> selected<?php }?>>Script</option>
							<option value="2"<?php if (get_request_var_request("poller_action") == '2') {?> selected<?php }?>>Script Server</option>
						</select>
					</td>
					<td nowrap style='white-space: nowrap;' width="50">
						&nbsp;Search:&nbsp;
					</td>
					<td width="1">
						<input type="text" name="filter" size="40" value="<?php print get_request_var_request("filter");?>">
					</td>
					<td nowrap style='white-space: nowrap;'>
						&nbsp;<input type="image" src="images/button_go.gif" name="go" alt="Go" border="0" align="absmiddle">
						<input type="image" src="images/button_clear.gif" name="clear" alt="Clear" border="0" align="absmiddle">
					</td>
				</tr>
			</table>
		</td>
		<input type='hidden' name='page' value='1'>
		<input type='hidden' name='action' value='view_poller_cache'>
		</form>
	</tr>
	<?php

	html_end_box();

	/* form the 'where' clause for our main sql query */
	$sql_where = "WHERE poller_item.local_data_id=data_template_data.local_data_id";

	if (get_request_var_request("poller_action") != "-1") {
		$sql_where .= " AND poller_item.action='" . get_request_var_request("poller_action") . "'";
	}

	if (get_request_var_request("host_id") == "-1") {
		/* Show all items */
	}elseif (get_request_var_request("host_id") == "0") {
		$sql_where .= " AND poller_item.host_id=0";
	}elseif (!empty($_REQUEST["host_id"])) {
		$sql_where .= " AND poller_item.host_id=" . get_request_var_request("host_id");
	}

	if (strlen(get_request_var_request("filter"))) {
		$sql_where .= " AND (data_template_data.name_cache LIKE '%%" . get_request_var_request("filter") . "%%'
			OR host.description LIKE '%%" . get_request_var_request("filter") . "%%'
			OR poller_item.arg1 LIKE '%%" . get_request_var_request("filter") . "%%'
			OR poller_item.hostname LIKE '%%" . get_request_var_request("filter") . "%%'
			OR poller_item.rrd_path  LIKE '%%" . get_request_var_request("filter") . "%%')";
	}

	html_start_box("", "100%", $colors["header"], "3", "center", "");

	$total_rows = db_fetch_cell("SELECT
		COUNT(*)
		FROM data_template_data
		RIGHT JOIN (poller_item
		LEFT JOIN host
		ON poller_item.host_id=host.id)
		ON data_template_data.local_data_id=poller_item.local_data_id
		$sql_where");

	$poller_sql = "SELECT
		poller_item.*,
		data_template_data.name_cache,
		host.description
		FROM data_template_data
		RIGHT JOIN (poller_item
		LEFT JOIN host
		ON poller_item.host_id=host.id)
		ON data_template_data.local_data_id=poller_item.local_data_id
		$sql_where
		ORDER BY " . get_request_var_request("sort_column") . " " . get_request_var_request("sort_direction") . ", action ASC
		LIMIT " . (read_config_option("num_rows_data_source")*(get_request_var_request("page")-1)) . "," . read_config_option("num_rows_data_source");

//	print $poller_sql;

	$poller_cache = db_fetch_assoc($poller_sql);

	/* generate page list */
	$url_page_select = get_page_list(get_request_var_request("page"), MAX_DISPLAY_PAGES, read_config_option("num_rows_data_source"), $total_rows, "utilities.php?action=view_poller_cache&host_id=" . get_request_var_request("host_id") . "&poller_action=" . get_request_var_request("poller_action"));

	$nav = "<tr bgcolor='#" . $colors["header"] . "'>
			<td colspan='7'>
				<table width='100%' cellspacing='0' cellpadding='0' border='0'>
					<tr>
						<td align='left' class='textHeaderDark'>
							<strong>&lt;&lt; "; if (get_request_var_request("page") > 1) { $nav .= "<a class='linkOverDark' href='utilities.php?action=view_poller_cache&host_id=" . get_request_var_request("host_id") . "&poller_action=" . get_request_var_request("poller_action") . "&page=" . (get_request_var_request("page")-1) . "'>"; } $nav .= "Previous"; if (get_request_var_request("page") > 1) { $nav .= "</a>"; } $nav .= "</strong>
						</td>\n
						<td align='center' class='textHeaderDark'>
							Showing Rows " . ((read_config_option("num_rows_data_source")*(get_request_var_request("page")-1))+1) . " to " . ((($total_rows < read_config_option("num_rows_data_source")) || ($total_rows < (read_config_option("num_rows_data_source")*get_request_var_request("page")))) ? $total_rows : (read_config_option("num_rows_data_source")*get_request_var_request("page"))) . " of $total_rows [$url_page_select]
						</td>\n
						<td align='right' class='textHeaderDark'>
							<strong>"; if ((get_request_var_request("page") * read_config_option("num_rows_data_source")) < $total_rows) { $nav .= "<a class='linkOverDark' href='utilities.php?action=view_poller_cache&host_id=" . get_request_var_request("host_id") . "&poller_action=" . get_request_var_request("poller_action") . "&page=" . (get_request_var_request("page")+1) . "'>"; } $nav .= "Next"; if ((get_request_var_request("page") * read_config_option("num_rows_data_source")) < $total_rows) { $nav .= "</a>"; } $nav .= " &gt;&gt;</strong>
						</td>\n
					</tr>
				</table>
			</td>
		</tr>\n";

	print $nav;

	$display_text = array(
		"data_template_data.name_cache" => array("Data Source Name", "ASC"),
		"" => array("Details", "ASC"));

	html_header_sort($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"));

	$i = 0;
	if (sizeof($poller_cache) > 0) {
	foreach ($poller_cache as $item) {
		form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i);
			?>
			<td width="375">
				<a class="linkEditMain" href="data_sources.php?action=ds_edit&id=<?php print $item["local_data_id"];?>"><?php print eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $item["name_cache"]);?></a>
			</td>

			<td>
			<?php
			if ($item["action"] == 0) {
				if ($item["snmp_version"] != 3) {
					$details =
						"SNMP Version: " . $item["snmp_version"] . ", " .
						"Community: " . $item["snmp_community"] . ", " .
						"OID: " . (strlen(get_request_var_request("filter")) ? (eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $item["arg1"])) : $item["arg1"]);
				}else{
					$details =
						"SNMP Version: " . $item["snmp_version"] . ", " .
						"User: "******"snmp_username"] . ", OID: " . $item["arg1"];
				}
			}elseif ($item["action"] == 1) {
					$details = "Script: " . (strlen(get_request_var_request("filter")) ? (eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $item["arg1"])) : $item["arg1"]);
			}else{
					$details = "Script Server: " . (strlen(get_request_var_request("filter")) ? (eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $item["arg1"])) : $item["arg1"]);
			}

			print $details;
			?>
			</td>
		</tr>
		<?php

		form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i);
		?>
			<td>
			</td>
			<td>
				RRD: <?php print $item["rrd_path"];?>
			</td>
		</tr>
		<?php
		$i++;
	}
	}

	html_end_box();
}
Exemplo n.º 29
0
function graph() {
	global $colors, $graph_actions, $item_rows;

	/* ================= input validation ================= */
	input_validate_input_number(get_request_var_request("host_id"));
	input_validate_input_number(get_request_var_request("graph_rows"));
	input_validate_input_number(get_request_var_request("template_id"));
	input_validate_input_number(get_request_var_request("page"));
	/* ==================================================== */

	/* clean up search string */
	if (isset($_REQUEST["filter"])) {
		$_REQUEST["filter"] = sanitize_search_string(get_request_var("filter"));
	}

	/* clean up sort_column string */
	if (isset($_REQUEST["sort_column"])) {
		$_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
	}

	/* clean up sort_direction string */
	if (isset($_REQUEST["sort_direction"])) {
		$_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
	}

	/* if the user pushed the 'clear' button */
	if (isset($_REQUEST["clear_x"])) {
		kill_session_var("sess_graph_current_page");
		kill_session_var("sess_graph_filter");
		kill_session_var("sess_graph_sort_column");
		kill_session_var("sess_graph_sort_direction");
		kill_session_var("sess_graph_host_id");
		kill_session_var("sess_graph_rows");
		kill_session_var("sess_graph_template_id");

		unset($_REQUEST["page"]);
		unset($_REQUEST["filter"]);
		unset($_REQUEST["sort_column"]);
		unset($_REQUEST["sort_direction"]);
		unset($_REQUEST["host_id"]);
		unset($_REQUEST["graph_rows"]);
		unset($_REQUEST["template_id"]);
	}

	/* remember these search fields in session vars so we don't have to keep passing them around */
	load_current_session_value("page", "sess_graph_current_page", "1");
	load_current_session_value("filter", "sess_graph_filter", "");
	load_current_session_value("sort_column", "sess_graph_sort_column", "title_cache");
	load_current_session_value("sort_direction", "sess_graph_sort_direction", "ASC");
	load_current_session_value("host_id", "sess_graph_host_id", "-1");
	load_current_session_value("graph_rows", "sess_graph_rows", read_config_option("num_rows_graph"));
	load_current_session_value("template_id", "sess_graph_template_id", "-1");

	/* if the number of rows is -1, set it to the default */
	if (get_request_var_request("graph_rows") == -1) {
		$_REQUEST["graph_rows"] = read_config_option("num_rows_graph");
	}

	?>
	<script type="text/javascript">
	<!--

	function applyGraphsFilterChange(objForm) {
		strURL = '?host_id=' + objForm.host_id.value;
		strURL = strURL + '&graph_rows=' + objForm.graph_rows.value;
		strURL = strURL + '&filter=' + objForm.filter.value;
		strURL = strURL + '&template_id=' + objForm.template_id.value;
		document.location = strURL;
	}

	-->
	</script>
	<?php

	html_start_box("<strong>Graph Management</strong>", "100%", $colors["header"], "3", "center", "graphs.php?action=graph_edit&host_id=" . get_request_var_request("host_id"));

	?>
	<tr bgcolor="<?php print $colors["panel"];?>">
		<form name="form_graph_id">
		<td>
			<table cellpadding="1" cellspacing="0">
				<tr>
					<td width="50">
						Host:&nbsp;
					</td>
					<td width="1">
						<select name="host_id" onChange="applyGraphsFilterChange(document.form_graph_id)">
							<option value="-1"<?php if (get_request_var_request("host_id") == "-1") {?> selected<?php }?>>Any</option>
							<option value="0"<?php if (get_request_var_request("host_id") == "0") {?> selected<?php }?>>None</option>
							<?php
							if (read_config_option("auth_method") != 0) {
								/* get policy information for the sql where clause */
								$current_user = db_fetch_row("select * from user_auth where id=" . $_SESSION["sess_user_id"]);
								$sql_where = get_graph_permissions_sql($current_user["policy_graphs"], $current_user["policy_hosts"], $current_user["policy_graph_templates"]);

								$hosts = db_fetch_assoc("SELECT DISTINCT host.id, CONCAT_WS('',host.description,' (',host.hostname,')') as name
									FROM (graph_templates_graph,host)
									LEFT JOIN graph_local ON (graph_local.host_id=host.id)
									LEFT JOIN graph_templates ON (graph_templates.id=graph_local.graph_template_id)
									LEFT JOIN user_auth_perms ON ((graph_templates_graph.local_graph_id=user_auth_perms.item_id and user_auth_perms.type=1 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (host.id=user_auth_perms.item_id and user_auth_perms.type=3 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (graph_templates.id=user_auth_perms.item_id and user_auth_perms.type=4 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . "))
									WHERE graph_templates_graph.local_graph_id=graph_local.id
									" . (empty($sql_where) ? "" : "and $sql_where") . "
									ORDER BY name");
							}else{
								$hosts = db_fetch_assoc("SELECT DISTINCT host.id, CONCAT_WS('',host.description,' (',host.hostname,')') as name
									FROM host
									ORDER BY name");
							}

							if (sizeof($hosts) > 0) {
							foreach ($hosts as $host) {
								print "<option value=' " . $host["id"] . "'"; if (get_request_var_request("host_id") == $host["id"]) { print " selected"; } print ">" . title_trim($host["name"], 40) . "</option>\n";
							}
							}
							?>
						</select>
					</td>
					<td width="70">
						&nbsp;Template:&nbsp;
					</td>
					<td width="1">
						<select name="template_id" onChange="applyGraphsFilterChange(document.form_graph_id)">
							<option value="-1"<?php if (get_request_var_request("template_id") == "-1") {?> selected<?php }?>>Any</option>
							<option value="0"<?php if (get_request_var_request("template_id") == "0") {?> selected<?php }?>>None</option>
							<?php
							if (read_config_option("auth_method") != 0) {
								$templates = db_fetch_assoc("SELECT DISTINCT graph_templates.id, graph_templates.name
									FROM (graph_templates_graph,graph_local)
									LEFT JOIN host ON (host.id=graph_local.host_id)
									LEFT JOIN graph_templates ON (graph_templates.id=graph_local.graph_template_id)
									LEFT JOIN user_auth_perms ON ((graph_templates_graph.local_graph_id=user_auth_perms.item_id and user_auth_perms.type=1 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (host.id=user_auth_perms.item_id and user_auth_perms.type=3 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (graph_templates.id=user_auth_perms.item_id and user_auth_perms.type=4 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . "))
									WHERE graph_templates_graph.local_graph_id=graph_local.id
									AND graph_templates.id IS NOT NULL
									" . (empty($sql_where) ? "" : "AND $sql_where") . "
									ORDER BY name");
							}else{
								$templates = db_fetch_assoc("SELECT DISTINCT graph_templates.id, graph_templates.name
									FROM graph_templates
									ORDER BY name");
							}

							if (sizeof($templates) > 0) {
							foreach ($templates as $template) {
								print "<option value=' " . $template["id"] . "'"; if (get_request_var_request("template_id") == $template["id"]) { print " selected"; } print ">" . title_trim($template["name"], 40) . "</option>\n";
							}
							}
							?>
						</select>
					</td>
					<td width="120" nowrap style='white-space: nowrap;'>
						&nbsp;<input type="image" src="images/button_go.gif" alt="Go" border="0" align="absmiddle">
						<input type="image" src="images/button_clear.gif" name="clear" alt="Clear" border="0" align="absmiddle">
					</td>
				</tr>
			</table>
			<table cellpadding="1" cellspacing="0">
				<tr>
					<td width="50">
						&nbsp;Search:&nbsp;
					</td>
					<td>
						<input type="text" name="filter" size="40" value="<?php print get_request_var_request("filter");?>">
					</td>
					<td nowrap style='white-space: nowrap;' width="50">
						Rows per Page:&nbsp;
					</td>
					<td width="1">
						<select name="graph_rows" onChange="applyGraphsFilterChange(document.form_graph_id)">
							<option value="-1"<?php if (get_request_var_request("graph_rows") == "-1") {?> selected<?php }?>>Default</option>
							<?php
							if (sizeof($item_rows) > 0) {
							foreach ($item_rows as $key => $value) {
								print "<option value='" . $key . "'"; if (get_request_var_request("graph_rows") == $key) { print " selected"; } print ">" . $value . "</option>\n";
							}
							}
							?>
						</select>
					</td>
				</tr>
			</table>
		</td>
		<input type='hidden' name='page' value='1'>
		</form>
	</tr>
	<?php

	html_end_box();

	/* form the 'where' clause for our main sql query */
	if (strlen(get_request_var_request("filter"))) {
		$sql_where = "AND (graph_templates_graph.title_cache like '%%" . get_request_var_request("filter") . "%%'" .
			" OR graph_templates.name like '%%" . get_request_var_request("filter") . "%%')";
	}else{
		$sql_where = "";
	}

	if (get_request_var_request("host_id") == "-1") {
		/* Show all items */
	}elseif (get_request_var_request("host_id") == "0") {
		$sql_where .= " AND graph_local.host_id=0";
	}elseif (!empty($_REQUEST["host_id"])) {
		$sql_where .= " AND graph_local.host_id=" . get_request_var_request("host_id");
	}

	if (get_request_var_request("template_id") == "-1") {
		/* Show all items */
	}elseif (get_request_var_request("template_id") == "0") {
		$sql_where .= " AND graph_templates_graph.graph_template_id=0";
	}elseif (!empty($_REQUEST["template_id"])) {
		$sql_where .= " AND graph_templates_graph.graph_template_id=" . get_request_var_request("template_id");
	}

	html_start_box("", "100%", $colors["header"], "3", "center", "");

	$total_rows = db_fetch_cell("SELECT
		COUNT(graph_templates_graph.id)
		FROM (graph_local,graph_templates_graph)
		LEFT JOIN graph_templates ON (graph_local.graph_template_id=graph_templates.id)
		WHERE graph_local.id=graph_templates_graph.local_graph_id
		$sql_where");

	$graph_list = db_fetch_assoc("SELECT
		graph_templates_graph.id,
		graph_templates_graph.local_graph_id,
		graph_templates_graph.height,
		graph_templates_graph.width,
		graph_templates_graph.title_cache,
		graph_templates.name,
		graph_local.host_id
		FROM (graph_local,graph_templates_graph)
		LEFT JOIN graph_templates ON (graph_local.graph_template_id=graph_templates.id)
		WHERE graph_local.id=graph_templates_graph.local_graph_id
		$sql_where
		ORDER BY " . $_REQUEST["sort_column"] . " " . get_request_var_request("sort_direction") .
		" LIMIT " . (get_request_var_request("graph_rows")*(get_request_var_request("page")-1)) . "," . get_request_var_request("graph_rows"));

	/* generate page list */
	$url_page_select = get_page_list(get_request_var_request("page"), MAX_DISPLAY_PAGES, get_request_var_request("graph_rows"), $total_rows, "graphs.php?filter=" . get_request_var_request("filter") . "&host_id=" . get_request_var_request("host_id"));

	$nav = "<tr bgcolor='#" . $colors["header"] . "'>
			<td colspan='5'>
				<table width='100%' cellspacing='0' cellpadding='0' border='0'>
					<tr>
						<td align='left' class='textHeaderDark'>
							<strong>&lt;&lt; "; if (get_request_var_request("page") > 1) { $nav .= "<a class='linkOverDark' href='graphs.php?filter=" . get_request_var_request("filter") . "&host_id=" . get_request_var_request("host_id") . "&page=" . (get_request_var_request("page")-1) . "'>"; } $nav .= "Previous"; if (get_request_var_request("page") > 1) { $nav .= "</a>"; } $nav .= "</strong>
						</td>\n
						<td align='center' class='textHeaderDark'>
							Showing Rows " . ((get_request_var_request("graph_rows")*(get_request_var_request("page")-1))+1) . " to " . ((($total_rows < get_request_var_request("graph_rows")) || ($total_rows < (get_request_var_request("graph_rows")*get_request_var_request("page")))) ? $total_rows : (get_request_var_request("graph_rows")*get_request_var_request("page"))) . " of $total_rows [$url_page_select]
						</td>\n
						<td align='right' class='textHeaderDark'>
							<strong>"; if ((get_request_var_request("page") * get_request_var_request("graph_rows")) < $total_rows) { $nav .= "<a class='linkOverDark' href='graphs.php?filter=" . get_request_var_request("filter") . "&host_id=" . get_request_var_request("host_id") . "&page=" . (get_request_var_request("page")+1) . "'>"; } $nav .= "Next"; if ((get_request_var_request("page") * get_request_var_request("graph_rows")) < $total_rows) { $nav .= "</a>"; } $nav .= " &gt;&gt;</strong>
						</td>\n
					</tr>
				</table>
			</td>
		</tr>\n";

	print $nav;

	$display_text = array(
		"title_cache" => array("Graph Title", "ASC"),
		"local_graph_id" => array("ID", "ASC"),
		"name" => array("Template Name", "ASC"),
		"height" => array("Size", "ASC"));

	html_header_sort_checkbox($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"));

	$i = 0;
	if (sizeof($graph_list) > 0) {
		foreach ($graph_list as $graph) {
			$template_name = ((empty($graph["name"])) ? "<em>None</em>" : $graph["name"]);
			form_alternate_row_color($colors["alternate"], $colors["light"], $i, 'line' . $graph["local_graph_id"]); $i++;
			form_selectable_cell("<a class='linkEditMain' href='graphs.php?action=graph_edit&id=" . $graph["local_graph_id"] . "' title='" . htmlspecialchars($graph["title_cache"]) . "'>" . ((get_request_var_request("filter") != "") ? eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", title_trim($graph["title_cache"], read_config_option("max_title_graph"))) : title_trim($graph["title_cache"], read_config_option("max_title_graph"))) . "</a>", $graph["local_graph_id"]);
			form_selectable_cell($graph["local_graph_id"], $graph["local_graph_id"]);
			form_selectable_cell(((get_request_var_request("filter") != "") ? eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $template_name) : $template_name) . "</a>", $graph["local_graph_id"]);
			form_selectable_cell($graph["height"] . "x" . $graph["width"], $graph["local_graph_id"]);
			form_checkbox_cell($graph["title_cache"], $graph["local_graph_id"]);
			form_end_row();
		}

		/* put the nav bar on the bottom as well */
		print $nav;
	}else{
		print "<tr><td><em>No Graphs Found</em></td></tr>";
	}

	html_end_box(false);

	/* add a list of tree names to the actions dropdown */
	add_tree_names_to_actions_array();

	/* draw the dropdown containing a list of available actions for this form */
	draw_actions_dropdown($graph_actions);

	print "</form>\n";
}
Exemplo n.º 30
0
function template()
{
    global $colors, $graph_actions;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request("page"));
    /* ==================================================== */
    /* clean up search string */
    if (isset($_REQUEST["filter"])) {
        $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter"));
    }
    /* clean up sort_column string */
    if (isset($_REQUEST["sort_column"])) {
        $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
    }
    /* clean up sort_direction string */
    if (isset($_REQUEST["sort_direction"])) {
        $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
    }
    /* if the user pushed the 'clear' button */
    if (isset($_REQUEST["clear_x"])) {
        kill_session_var("sess_graph_template_current_page");
        kill_session_var("sess_graph_template_filter");
        kill_session_var("sess_graph_template_sort_column");
        kill_session_var("sess_graph_template_sort_direction");
        unset($_REQUEST["page"]);
        unset($_REQUEST["filter"]);
        unset($_REQUEST["sort_column"]);
        unset($_REQUEST["sort_direction"]);
    }
    /* remember these search fields in session vars so we don't have to keep passing them around */
    load_current_session_value("page", "sess_graph_template_current_page", "1");
    load_current_session_value("filter", "sess_graph_template_filter", "");
    load_current_session_value("sort_column", "sess_graph_template_sort_column", "name");
    load_current_session_value("sort_direction", "sess_graph_template_sort_direction", "ASC");
    html_start_box("<strong>Graph Templates</strong>", "100%", $colors["header"], "3", "center", "graph_templates.php?action=template_edit");
    ?>
	<tr bgcolor="<?php 
    print $colors["panel"];
    ?>
">
		<form name="form_host_template">
		<td>
			<table width="100%" cellpadding="0" cellspacing="0">
				<tr>
					<td nowrap style='white-space: nowrap;' width="50">
						Search:&nbsp;
					</td>
					<td width="1">
						<input type="text" name="filter" size="40" value="<?php 
    print get_request_var_request("filter");
    ?>
">
					</td>
					<td nowrap style='white-space: nowrap;'>
						&nbsp;<input type="image" src="images/button_go.gif" alt="Go" border="0" align="absmiddle">
						<input type="image" src="images/button_clear.gif" name="clear" alt="Clear" border="0" align="absmiddle">
					</td>
				</tr>
			</table>
		</td>
		<input type='hidden' name='page' value='1'>
		</form>
	</tr>
	<?php 
    html_end_box();
    /* form the 'where' clause for our main sql query */
    $sql_where = "WHERE (graph_templates.name LIKE '%%" . get_request_var_request("filter") . "%%')";
    html_start_box("", "100%", $colors["header"], "3", "center", "");
    $total_rows = db_fetch_cell("SELECT\n\t\tCOUNT(graph_templates.id)\n\t\tFROM graph_templates\n\t\t{$sql_where}");
    $template_list = db_fetch_assoc("SELECT\n\t\tgraph_templates.id,graph_templates.name\n\t\tFROM graph_templates\n\t\t{$sql_where}\n\t\tORDER BY " . get_request_var_request("sort_column") . " " . get_request_var_request("sort_direction") . " LIMIT " . read_config_option("num_rows_device") * (get_request_var_request("page") - 1) . "," . read_config_option("num_rows_device"));
    /* generate page list */
    $url_page_select = get_page_list(get_request_var_request("page"), MAX_DISPLAY_PAGES, read_config_option("num_rows_device"), $total_rows, "graph_templates.php?filter=" . get_request_var_request("filter"));
    $nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t<td colspan='7'>\n\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t<tr>\n\t\t\t\t\t<td align='left' class='textHeaderDark'>\n\t\t\t\t\t\t<strong>&lt;&lt; ";
    if (get_request_var_request("page") > 1) {
        $nav .= "<a class='linkOverDark' href='graph_templates.php?filter=" . get_request_var_request("filter") . "&page=" . (get_request_var_request("page") - 1) . "'>";
    }
    $nav .= "Previous";
    if (get_request_var_request("page") > 1) {
        $nav .= "</a>";
    }
    $nav .= "</strong>\n\t\t\t\t\t</td>\n\n\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\tShowing Rows " . (read_config_option("num_rows_device") * (get_request_var_request("page") - 1) + 1) . " to " . ($total_rows < read_config_option("num_rows_device") || $total_rows < read_config_option("num_rows_device") * get_request_var_request("page") ? $total_rows : read_config_option("num_rows_device") * get_request_var_request("page")) . " of {$total_rows} [{$url_page_select}]\n\t\t\t\t\t</td>\n\n\t\t\t\t\t<td align='right' class='textHeaderDark'>\n\t\t\t\t\t\t<strong>";
    if (get_request_var_request("page") * read_config_option("num_rows_device") < $total_rows) {
        $nav .= "<a class='linkOverDark' href='graph_templates.php?filter=" . get_request_var_request("filter") . "&page=" . (get_request_var_request("page") + 1) . "'>";
    }
    $nav .= "Next";
    if (get_request_var_request("page") * read_config_option("num_rows_device") < $total_rows) {
        $nav .= "</a>";
    }
    $nav .= " &gt;&gt;</strong>\n\t\t\t\t\t</td>\n\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t\t</tr>\n";
    print $nav;
    $display_text = array("name" => array("Template Title", "ASC"));
    html_header_sort_checkbox($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"));
    $i = 0;
    if (sizeof($template_list) > 0) {
        foreach ($template_list as $template) {
            form_alternate_row_color($colors["alternate"], $colors["light"], $i, 'line' . $template["id"]);
            $i++;
            form_selectable_cell("<a class='linkEditMain' href='graph_templates.php?action=template_edit&id=" . $template["id"] . "'>" . (strlen(get_request_var_request("filter")) ? eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $template["name"]) : $template["name"]) . "</a>", $template["id"]);
            form_checkbox_cell($template["name"], $template["id"]);
            form_end_row();
        }
        print $nav;
    } else {
        print "<tr><td><em>No Graph Templates</em></td></tr>\n";
    }
    html_end_box(false);
    /* draw the dropdown containing a list of available actions for this form */
    draw_actions_dropdown($graph_actions);
    print "</form>\n";
}