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";
}
Exemple #2
0
function graph() {
	global $colors, $graph_actions;

	/* 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_host_id");

		unset($_REQUEST["page"]);
		unset($_REQUEST["filter"]);
		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_graph_current_page", "1");
	load_current_session_value("filter", "sess_graph_filter", "");
	load_current_session_value("host_id", "sess_graph_host_id", "-1");

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

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

	html_end_box();

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

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

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

	$total_rows = db_fetch_cell("select
		COUNT(graph_templates_graph.id)
		from graph_local,graph_templates_graph
		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 graph_templates_graph.title_cache,graph_local.host_id
		limit " . (read_config_option("num_rows_graph")*($_REQUEST["page"]-1)) . "," . read_config_option("num_rows_graph"));

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

	$nav = "<tr bgcolor='#" . $colors["header"] . "'>
			<td colspan='4'>
				<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='graphs.php?filter=" . $_REQUEST["filter"] . "&host_id=" . $_REQUEST["host_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_graph")*($_REQUEST["page"]-1))+1) . " to " . ((($total_rows < read_config_option("num_rows_graph")) || ($total_rows < (read_config_option("num_rows_graph")*$_REQUEST["page"]))) ? $total_rows : (read_config_option("num_rows_graph")*$_REQUEST["page"])) . " of $total_rows [$url_page_select]
						</td>\n
						<td align='right' class='textHeaderDark'>
							<strong>"; if (($_REQUEST["page"] * read_config_option("num_rows_graph")) < $total_rows) { $nav .= "<a class='linkOverDark' href='graphs.php?filter=" . $_REQUEST["filter"] . "&host_id=" . $_REQUEST["host_id"] . "&page=" . ($_REQUEST["page"]+1) . "'>"; } $nav .= "Next"; if (($_REQUEST["page"] * read_config_option("num_rows_graph")) < $total_rows) { $nav .= "</a>"; } $nav .= " &gt;&gt;</strong>
						</td>\n
					</tr>
				</table>
			</td>
		</tr>\n";

	print $nav;

	html_header_checkbox(array("Graph Title", "Template Name", "Size"));

	$i = 0;
	if (sizeof($graph_list) > 0) {
		foreach ($graph_list as $graph) {
			form_alternate_row_color($colors["alternate"],$colors["light"],$i); $i++;
				?>
				<td>
					<a class="linkEditMain" href="graphs.php?action=graph_edit&id=<?php print $graph["local_graph_id"];?>"><?php print eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", title_trim($graph["title_cache"], read_config_option("max_title_graph")));?></a>
				</td>
				<td>
					<?php print ((empty($graph["name"])) ? "<em>None</em>" : $graph["name"]); ?>
				</td>
				<td>
					<?php print $graph["height"];?>x<?php print $graph["width"];?>
				</td>
				<td style="<?php print get_checkbox_style();?>" width="1%" align="right">
					<input type='checkbox' style='margin: 0px;' name='chk_<?php print $graph["local_graph_id"];?>' title="<?php print $graph["title_cache"];?>">
				</td>
			</tr>
			<?php
		}

		/* 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";
}
Exemple #3
0
function tholds_old()
{
    global $colors, $assoc_actions, $item_rows;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request("host_template_id"));
    input_validate_input_number(get_request_var_request("rows"));
    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_request("filter"));
    }
    /* clean up associated string */
    if (isset($_REQUEST["associated"])) {
        $_REQUEST["associated"] = sanitize_search_string(get_request_var_request("associated"));
    }
    /* if the user pushed the 'clear' button */
    if (isset($_REQUEST["clearf"])) {
        kill_session_var("sess_nlh_current_page");
        kill_session_var("sess_nlh_filter");
        kill_session_var("sess_nlh_host_template_id");
        kill_session_var("sess_nlh_rows");
        kill_session_var("sess_nlh_associated");
        unset($_REQUEST["page"]);
        unset($_REQUEST["filter"]);
        unset($_REQUEST["associated"]);
        unset($_REQUEST["host_template_id"]);
        unset($_REQUEST["rows"]);
    }
    /* remember these search fields in session vars so we don't have to keep passing them around */
    load_current_session_value("page", "sess_nlh_current_page", "1");
    load_current_session_value("filter", "sess_nlh_filter", "");
    load_current_session_value("associated", "sess_nlh_associated", "true");
    load_current_session_value("host_template_id", "sess_nlh_host_template_id", "-1");
    load_current_session_value("rows", "sess_nlh_rows", read_config_option("num_rows_device"));
    /* if the number of rows is -1, set it to the default */
    if ($_REQUEST["rows"] == -1) {
        $_REQUEST["rows"] = read_config_option("num_rows_device");
    }
    ?>
	<script type="text/javascript">
	<!--

	function applyViewDeviceFilterChange(objForm) {
		strURL = '?action=edit&id=<?php 
    print get_request_var_request('id');
    ?>
&rows=' + objForm.rows.value;
		strURL = strURL + '&host_template_id=' + objForm.host_template_id.value;
		strURL = strURL + '&associated=' + objForm.associated.checked;
		strURL = strURL + '&filter=' + objForm.filter.value;
		document.location = strURL;
	}

	function clearViewDeviceFilterChange(objForm) {
		strURL = '?action=edit&id=<?php 
    print get_request_var_request('id');
    ?>
&clearf=true'
		document.location = strURL;
	}

	-->
	</script>
	<?php 
    html_start_box("<strong>Associated Devices</strong>", "100%", $colors["header"], "3", "center", "");
    ?>
	<tr bgcolor="#<?php 
    print $colors["panel"];
    ?>
">
		<td>
		<form name="form_devices" method="post" action="notify_lists.php">
			<table cellpadding="0" cellspacing="0">
				<tr>
					<td nowrap style='white-space: nowrap;' width="50">
						&nbsp;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 ">" . htmlspecialchars($host_template["name"]) . "</option>\n";
        }
    }
    ?>
						</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 htmlspecialchars(get_request_var_request("filter"));
    ?>
" onChange="applyViewDeviceFilterChange(document.form_devices)">
					</td>
					<td nowrap style='white-space: nowrap;' width="50">
						&nbsp;Rows:&nbsp;
					</td>
					<td width="1">
						<select name="rows" onChange="applyViewDeviceFilterChange(document.form_devices)">
							<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 ">" . htmlspecialchars($value) . "</option>\n";
        }
    }
    ?>
						</select>
					</td>
					<td>
						<input type='checkbox' name='associated' id='associated' onChange='applyViewDeviceFilterChange(document.form_devices)' <?php 
    print $_REQUEST['associated'] == 'true' || $_REQUEST['associated'] == 'on' ? 'checked' : '';
    ?>
>
					</td>
					<td>
						<label for='associated'>Associated</label>
					</td>
					<td nowrap>
						&nbsp;<input type="button" value="Go" onClick='applyViewDeviceFilterChange(document.form_devices)' title="Set/Refresh Filters">
					</td>
					<td nowrap>
						<input type="button" name="clearf" value="Clear" onClick='clearViewDeviceFilterChange(document.form_devices)' title="Clear Filters">
					</td>
				</tr>
			</table>
			<input type='hidden' name='page' value='1'>
			<input type='hidden' name='tab' value='hosts'>
			<input type='hidden' name='action' value='edit'>
			<input type='hidden' name='id' value='<?php 
    print get_request_var_request('id');
    ?>
'>
		</form>
		</td>
	</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_template_id") == "-1") {
        /* Show all items */
    } elseif (get_request_var_request("host_template_id") == "0") {
        $sql_where .= (strlen($sql_where) ? " AND " : "WHERE ") . " host.host_template_id=0";
    } elseif (!empty($_REQUEST["host_template_id"])) {
        $sql_where .= (strlen($sql_where) ? " AND " : "WHERE ") . " host.host_template_id=" . get_request_var_request("host_template_id");
    }
    if (get_request_var_request("associated") == "false") {
        /* Show all items */
    } else {
        $sql_where .= (strlen($sql_where) ? " AND " : "WHERE ") . " (host.thold_send_email>1 AND host.thold_host_email=" . get_request_var_request("id") . ")";
    }
    /* print checkbox form for validation */
    print "<form name='chk' method='post' action='notify_lists.php?action=edit&tab=hosts&id=" . get_request_var_request("id") . "'>\n";
    html_start_box("", "100%", $colors["header"], "3", "center", "");
    $total_rows = db_fetch_cell("SELECT\n\t\tCOUNT(*)\n\t\tFROM host\n\t\t{$sql_where}");
    $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 {$sql_where} \n\t\tLIMIT " . get_request_var_request("rows") * (get_request_var_request("page") - 1) . "," . get_request_var_request("rows");
    $hosts = db_fetch_assoc($sql_query);
    /* generate page list */
    if ($total_rows > 0) {
        $url_page_select = get_page_list(get_request_var_request("page"), MAX_DISPLAY_PAGES, get_request_var_request("rows"), $total_rows, "notify_lists.php?action=edit&tab=hosts&id=" . get_request_var_request('id'));
        $nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t\t<td colspan='8'>\n\t\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align='left' class='textHeaderDark'>\n\t\t\t\t\t\t\t\t<strong>&lt;&lt; ";
        if (get_request_var_request("page") > 1) {
            $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("notify_lists.php?action=edit&id=" . get_request_var_request("id") . "&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\t</td>\n\n\t\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\t\tShowing Rows " . (get_request_var_request("rows") * (get_request_var_request("page") - 1) + 1) . " to " . ($total_rows < read_config_option("num_rows_device") || $total_rows < get_request_var_request("rows") * get_request_var_request("page") ? $total_rows : get_request_var_request("rows") * get_request_var_request("page")) . " of {$total_rows} [{$url_page_select}]\n\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t<td align='right' class='textHeaderDark'>\n\t\t\t\t\t\t\t\t\t\t<strong>";
        if (get_request_var_request("page") * get_request_var_request("rows") < $total_rows) {
            $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("notify_lists.php?action=edit&id=" . get_request_var_request("id") . "&page=" . (get_request_var_request("page") + 1)) . "'>";
        }
        $nav .= "Next";
        if (get_request_var_request("page") * get_request_var_request("rows") < $total_rows) {
            $nav .= "</a>";
        }
        $nav .= " &gt;&gt;</strong>\n\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t</td>\n\t\t\t</tr>\n";
    } else {
        $nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t\t<td colspan='8'>\n\t\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\t\tNo Rows Found\n\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t</td>\n\t\t\t</tr>\n";
    }
    print $nav;
    $display_text = array("Description", "ID", "Associated Lists", "Graphs", "Data Sources", "Status", "Hostname");
    html_header_checkbox($display_text);
    $i = 0;
    if (sizeof($hosts)) {
        foreach ($hosts as $host) {
            form_alternate_row_color($colors["alternate"], $colors["light"], $i, 'line' . $host["id"]);
            $i++;
            form_selectable_cell(strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter")) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", htmlspecialchars($host["description"])) : htmlspecialchars($host["description"]), $host["id"], 250);
            form_selectable_cell(round($host["id"], 2), $host["id"]);
            if ($host['thold_send_email'] == 0) {
                form_selectable_cell('<span style="color:blue;font-weight:bold;">Disabled</span>', $host['id']);
            } elseif ($host['thold_send_email'] == 1) {
                form_selectable_cell('<span style="color:purple;font-weight:bold;">Global List</span>', $host['id']);
            } elseif ($host['thold_host_email'] == get_request_var_request('id')) {
                if ($host['thold_send_email'] == 2) {
                    form_selectable_cell('<span style="color:green;font-weight:bold;">Current List Only</span>', $host['id']);
                } else {
                    form_selectable_cell('<span style="color:green;font-weight:bold;">Current and Global List(s)</span>', $host['id']);
                }
            } elseif ($host['thold_host_email'] == '0') {
                form_selectable_cell('<span style="color:green;font-weight:bold;">None</span>', $host['id']);
            } else {
                form_selectable_cell('<span style="color:red;font-weight:bold;">' . db_fetch_cell("SELECT name FROM plugin_notification_lists WHERE id=" . get_request_var_request('id')) . '</span>', $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(strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter")) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", htmlspecialchars($host["hostname"])) : htmlspecialchars($host["hostname"]), $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 Associated Hosts Found</em></td></tr>";
    }
    html_end_box(false);
    form_hidden_box("action", "edit");
    form_hidden_box("id", get_request_var_request("id"));
    form_hidden_box("save_associate", "1");
    /* draw the dropdown containing a list of available actions for this form */
    draw_actions_dropdown($assoc_actions);
    print "</form>\n";
}
Exemple #4
0
function template() {
	global $colors, $ds_actions;

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

	html_header_checkbox(array("Template Name", "Data Input Method", "Status"));

	$template_list = db_fetch_assoc("select
		data_template.id,
		data_template.name,
		data_input.name as data_input_method,
		data_template_data.active as active
		from data_template,data_template_data
		left join data_input on data_template_data.data_input_id = data_input.id
		where data_template.id = data_template_data.data_template_id
		and data_template_data.local_data_id = 0
		order by data_template.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="data_templates.php?action=template_edit&id=<?php print $template["id"];?>"><?php print $template["name"];?></a>
			</td>
			<td>
				<?php print (empty($template["data_input_method"]) ? "<em>None</em>": $template["data_input_method"]);?>
			</td>
			<td>
				<?php if ($template["active"] == "on") print "Active"; else print "Disabled";?>
			</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 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";
}
Exemple #5
0
function graph_perms_edit($tab, $header_label)
{
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request('id'));
    /* ==================================================== */
    $sql_where = '';
    $sql_join = '';
    $limit = '';
    $sql_having = '';
    $policy_array = array(1 => 'Allow', 2 => 'Deny');
    if (!empty($_REQUEST['id'])) {
        $policy = db_fetch_row_prepared('SELECT policy_graphs, policy_trees, policy_hosts, policy_graph_templates 
			FROM user_auth 
			WHERE id = ?', array(get_request_var_request('id')));
    } else {
        $policy = array('policy_graphs' => '1', 'policy_trees' => '1', 'policy_hosts' => '1', 'policy_graph_templates' => '1');
    }
    switch ($tab) {
        case 'permsg':
            process_graph_request_vars();
            graph_filter($header_label);
            /* print checkbox form for validation */
            print "<form name='policy' method='post' action='user_admin.php'>\n";
            /* box: device permissions */
            html_start_box('<strong>Default Graph Policy</strong>', '100%', '', '3', 'center', '');
            ?>
		<tr class='even'>
			<td><table cellspacing="0" cellpadding="2"><tr>
			<td style="white-space:nowrap;" width="120">Default Graph Policy for this User</td>
			<td width="10"> 
				<?php 
            form_dropdown('policy_graphs', $policy_array, '', '', $policy['policy_graphs'], '', '');
            ?>
			</td>
			<td>
				<input type="submit" name="update_policy" value="Update">
				<input type="hidden" name="tab" value="<?php 
            print $tab;
            ?>
">
				<input type="hidden" name="id" value="<?php 
            print get_request_var_request('id');
            ?>
">
			</td>
			</tr></table></td>
		</tr>
		<?php 
            html_end_box();
            print "</form>\n";
            /* if the number of rows is -1, set it to the default */
            if ($_REQUEST['rows'] == -1) {
                $rows = read_config_option('num_rows_table');
            } else {
                $rows = $_REQUEST['rows'];
            }
            /* print checkbox form for validation */
            print "<form name='chk' method='post' action='" . htmlspecialchars('user_admin.php?action=user_edit&tab=permsg&id=' . get_request_var_request('id')) . "'>\n";
            html_start_box('', '100%', '', '3', 'center', '');
            $user = $_SESSION['sess_user_id'];
            if (read_config_option('graph_auth_method') == 1) {
                $sql_operator = 'OR';
            } else {
                $sql_operator = 'AND';
            }
            $limit = 'LIMIT ' . $rows * (get_request_var_request('page') - 1) . ',' . $rows;
            /* get policies for all groups and user */
            $policies = db_fetch_assoc_prepared("SELECT uag.id, 'group' AS type, uag.name, \n\t\t\tpolicy_graphs, policy_hosts, policy_graph_templates \n\t\t\tFROM user_auth_group AS uag\n\t\t\tINNER JOIN user_auth_group_members AS uagm\n\t\t\tON uag.id = uagm.group_id\n\t\t\tWHERE uag.enabled = 'on' AND uagm.user_id = ?", array($user));
            $policies[] = db_fetch_row_prepared("SELECT id, 'user' AS type, 'user' AS name, \n\t\t\tpolicy_graphs, policy_hosts, policy_graph_templates \n\t\t\tFROM user_auth WHERE id = ?", array($user));
            /* form the 'where' clause for our main sql query */
            if (strlen(get_request_var_request('filter'))) {
                $sql_where = "WHERE (gtg.title_cache LIKE '%%" . get_request_var_request('filter') . "%%' AND gtg.local_graph_id > 0)";
            } else {
                $sql_where = 'WHERE (gtg.local_graph_id > 0)';
            }
            if (get_request_var_request('graph_template_id') == '-1') {
                /* Show all items */
            } elseif (get_request_var_request('graph_template_id') == '0') {
                $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' gtg.graph_template_id=0';
            } elseif (!empty($_REQUEST['graph_template_id'])) {
                $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' gtg.graph_template_id=' . get_request_var_request('graph_template_id');
            }
            $i = 1;
            $user_perm = '';
            $sql_select = '';
            foreach ($policies as $policy) {
                if ($policy['type'] == 'user' && $user_perm == '') {
                    $user_perm = $i;
                }
                if (get_request_var_request('associated') == 'false') {
                    if ($policy['policy_graphs'] == 1) {
                        $sql_having .= (strlen($sql_having) ? ' OR' : '') . " (user{$i} IS NULL";
                    } else {
                        $sql_having .= (strlen($sql_having) ? ' OR' : '') . " (user{$i}=" . $policy['id'];
                    }
                }
                $sql_join .= 'LEFT JOIN user_auth_' . ($policy['type'] == 'user' ? '' : 'group_') . "perms AS uap{$i} ON (gl.id=uap{$i}.item_id AND uap{$i}.type=1) ";
                $sql_select .= (strlen($sql_select) ? ', ' : '') . "uap{$i}." . $policy['type'] . "_id AS user{$i}";
                $i++;
                if (get_request_var_request('associated') == 'false') {
                    if ($policy['policy_hosts'] == 1) {
                        $sql_having .= " OR (user{$i} IS NULL";
                    } else {
                        $sql_having .= " OR (user{$i}=" . $policy['id'];
                    }
                }
                $sql_join .= 'LEFT JOIN user_auth_' . ($policy['type'] == 'user' ? '' : 'group_') . "perms AS uap{$i} ON (gl.host_id=uap{$i}.item_id AND uap{$i}.type=3) ";
                $sql_select .= (strlen($sql_select) ? ', ' : '') . "uap{$i}." . $policy['type'] . "_id AS user{$i}";
                $i++;
                if (get_request_var_request('associated') == 'false') {
                    if ($policy['policy_graph_templates'] == 1) {
                        $sql_having .= " {$sql_operator} user{$i} IS NULL))";
                    } else {
                        $sql_having .= " {$sql_operator} user{$i}=" . $policy['id'] . '))';
                    }
                }
                $sql_join .= 'LEFT JOIN user_auth_' . ($policy['type'] == 'user' ? '' : 'group_') . "perms AS uap{$i} ON (gl.graph_template_id=uap{$i}.item_id AND uap{$i}.type=4) ";
                $sql_select .= (strlen($sql_select) ? ', ' : '') . "uap{$i}." . $policy['type'] . "_id AS user{$i}";
                $i++;
            }
            if (strlen($sql_having)) {
                $sql_having = 'HAVING ' . $sql_having;
            }
            $graphs = db_fetch_assoc("SELECT gtg.local_graph_id, h.description, gt.name AS template_name, \n\t\t\tgtg.title_cache, gtg.width, gtg.height, gl.snmp_index, gl.snmp_query_id,\n\t\t\t{$sql_select}\n\t\t\tFROM graph_templates_graph AS gtg \n\t\t\tINNER JOIN graph_local AS gl \n\t\t\tON gl.id = gtg.local_graph_id \n\t\t\tLEFT JOIN graph_templates AS gt \n\t\t\tON gt.id = gl.graph_template_id \n\t\t\tLEFT JOIN host AS h \n\t\t\tON h.id = gl.host_id \n\t\t\t{$sql_join}\n\t\t\t{$sql_where}\n\t\t\t{$sql_having}\n\t\t\tORDER BY gtg.title_cache\n\t\t\t{$limit}");
            $total_rows = db_fetch_cell("SELECT COUNT(*)\n\t\t\tFROM (\n\t\t\t\tSELECT {$sql_select}\n\t\t\t\tFROM graph_templates_graph AS gtg \n\t\t\t\tINNER JOIN graph_local AS gl \n\t\t\t\tON gl.id = gtg.local_graph_id \n\t\t\t\tLEFT JOIN graph_templates AS gt \n\t\t\t\tON gt.id = gl.graph_template_id \n\t\t\t\tLEFT JOIN host AS h \n\t\t\t\tON h.id = gl.host_id \n\t\t\t\t{$sql_join}\n\t\t\t\t{$sql_where}\n\t\t\t\t{$sql_having}\n\t\t\t) AS rows");
            //print '<pre>';print_r($graphs);print '</pre>';
            $nav = html_nav_bar('user_admin.php?action=user_edit&tab=permsg&id=' . get_request_var_request('id'), MAX_DISPLAY_PAGES, get_request_var_request('page'), $rows, $total_rows, 11, 'Graphs', 'page', 'main');
            print $nav;
            $display_text = array('Graph Title', 'ID', 'Effective Policy');
            html_header_checkbox($display_text, false);
            if (sizeof($graphs)) {
                foreach ($graphs as $g) {
                    form_alternate_row('line' . $g['local_graph_id'], true);
                    form_selectable_cell(strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($g['title_cache'])) : htmlspecialchars($g['title_cache']), $g['local_graph_id']);
                    form_selectable_cell($g['local_graph_id'], $g['local_graph_id']);
                    form_selectable_cell(get_permission_string($g, $policies), $g['local_graph_id']);
                    form_checkbox_cell($g['title_cache'], $g['local_graph_id']);
                    form_end_row();
                }
                /* put the nav bar on the bottom as well */
                print $nav;
            } else {
                print '<tr><td><em>No Matching Graphs Found</em></td></tr>';
            }
            html_end_box(false);
            form_hidden_box('action', 'user_edit', '');
            form_hidden_box('tab', $tab, '');
            form_hidden_box('id', get_request_var_request('id'), '');
            form_hidden_box('associate_graph', '1', '');
            if ($policy['policy_graphs'] == 1) {
                $assoc_actions = array(1 => 'Revoke Access', 2 => 'Grant Access');
            } else {
                $assoc_actions = array(1 => 'Grant Access', 2 => 'Revoke Access');
            }
            /* draw the dropdown containing a list of available actions for this form */
            draw_actions_dropdown($assoc_actions);
            print '</form>';
            break;
        case 'permsgr':
            process_group_request_vars();
            group_filter($header_label);
            /* if the number of rows is -1, set it to the default */
            if ($_REQUEST['rows'] == -1) {
                $rows = read_config_option('num_rows_table');
            } else {
                $rows = $_REQUEST['rows'];
            }
            /* form the 'where' clause for our main sql query */
            /* form the 'where' clause for our main sql query */
            if (strlen(get_request_var_request('filter'))) {
                $sql_where = "WHERE ((uag.name LIKE '%" . get_request_var_request('filter') . "%') OR (uag.description LIKE '%" . get_request_var_request('filter') . "%'))";
            } else {
                $sql_where = '';
            }
            if (get_request_var_request('associated') != 'false') {
                /* Show all items */
            } else {
                $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' uagm.user_id=' . get_request_var_request('id', 0);
            }
            /* print checkbox form for validation */
            print "<form name='chk' method='post' action='" . htmlspecialchars('user_admin.php?action=user_edit&tab=permsd&id=' . get_request_var_request('id')) . "'>\n";
            html_start_box('', '100%', '', '3', 'center', '');
            $total_rows = db_fetch_cell("SELECT\n\t\t\tCOUNT(uag.id)\n\t\t\tFROM user_auth_group AS uag\n\t\t\tLEFT JOIN user_auth_group_members AS uagm\n\t\t\tON uag.id = uagm.group_id\n\t\t\t{$sql_where}");
            $sql_query = "SELECT uag.*, uagm.user_id\n\t\t\tFROM user_auth_group AS uag\n\t\t\tLEFT JOIN user_auth_group_members AS uagm\n\t\t\tON uag.id = uagm.group_id\n\t\t\t{$sql_where} \n\t\t\tORDER BY name\n\t\t\tLIMIT " . $rows * (get_request_var_request('page') - 1) . ',' . $rows;
            $groups = db_fetch_assoc($sql_query);
            $nav = html_nav_bar('user_admin.php?action=user_edit&tab=permsgr&id=' . get_request_var_request('id'), MAX_DISPLAY_PAGES, get_request_var_request('page'), $rows, $total_rows, 11, 'Devices', 'page', 'main');
            print $nav;
            $display_text = array('Name', 'Description', 'Member', 'ID', 'Policies (Graph/Device/Template)', 'Enabled');
            html_header_checkbox($display_text, false);
            if (sizeof($groups)) {
                foreach ($groups as $g) {
                    form_alternate_row('line' . $g['id'], true);
                    form_selectable_cell("<a class='linkEditMain' href='user_group_admin.php?action=edit&id=" . $g['id'] . "'>" . (strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($g['name'])) : htmlspecialchars($g['name'])) . '</a>', $g['id']);
                    form_selectable_cell(strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($g['description'])) : htmlspecialchars($g['description']), $g['id']);
                    form_selectable_cell($g['user_id'] > 0 ? 'Member' : 'Non Member', $g['id']);
                    form_selectable_cell($g['id'], $g['id']);
                    form_selectable_cell(($g['policy_graphs'] == 1 ? 'ALLOW' : 'DENY') . '/' . ($g['policy_hosts'] == 1 ? 'ALLOW' : 'DENY') . '/' . ($g['policy_graph_templates'] == 1 ? 'ALLOW' : 'DENY'), $g['id']);
                    form_selectable_cell($g['enabled'] == 'on' ? 'Enabled' : 'Disabled', $g['id']);
                    form_checkbox_cell($g['name'], $g['id']);
                    form_end_row();
                }
                /* put the nav bar on the bottom as well */
                print $nav;
            } else {
                print '<tr><td><em>No Matching User Groups Found</em></td></tr>';
            }
            html_end_box(false);
            form_hidden_box('action', 'user_edit', '');
            form_hidden_box('tab', $tab, '');
            form_hidden_box('id', get_request_var_request('id'), '');
            form_hidden_box('associate_groups', '1', '');
            $assoc_actions = array(1 => 'Assign Membership', 2 => 'Remove Membership');
            /* draw the dropdown containing a list of available actions for this form */
            draw_actions_dropdown($assoc_actions);
            print '</form>';
            break;
        case 'permsd':
            process_device_request_vars();
            device_filter($header_label);
            /* print checkbox form for validation */
            print "<form name='policy' method='post' action='user_admin.php'>\n";
            /* box: device permissions */
            html_start_box('<strong>Default Device Policy</strong>', '100%', '', '3', 'center', '');
            ?>
		<tr class='even'>
			<td><table cellspacing="0" cellpadding="2"><tr>
			<td style="white-space:nowrap;" width="120">Default Device Policy for this User</td>
			<td width="10"> 
				<?php 
            form_dropdown('policy_hosts', $policy_array, '', '', $policy['policy_hosts'], '', '');
            ?>
			</td>
			<td>
				<input type="submit" name="update_policy" value="Update">
				<input type="hidden" name="tab" value="<?php 
            print $tab;
            ?>
">
				<input type="hidden" name="id" value="<?php 
            print get_request_var_request('id');
            ?>
">
			</td>
			</tr></table></td>
		</tr>
		<?php 
            html_end_box();
            print "</form>\n";
            /* if the number of rows is -1, set it to the default */
            if ($_REQUEST['rows'] == -1) {
                $rows = read_config_option('num_rows_table');
            } else {
                $rows = $_REQUEST['rows'];
            }
            /* form the 'where' clause for our main sql query */
            /* 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_template_id') == '-1') {
                /* Show all items */
            } elseif (get_request_var_request('host_template_id') == '0') {
                $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' host.host_template_id=0';
            } elseif (!empty($_REQUEST['host_template_id'])) {
                $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' host.host_template_id=' . get_request_var_request('host_template_id');
            }
            if (get_request_var_request('associated') == 'false') {
                /* Show all items */
            } else {
                $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' user_auth_perms.user_id=' . get_request_var_request('id', 0);
            }
            /* print checkbox form for validation */
            print "<form name='chk' method='post' action='" . htmlspecialchars('user_admin.php?action=user_edit&tab=permsd&id=' . get_request_var_request('id')) . "'>\n";
            html_start_box('', '100%', '', '3', 'center', '');
            $total_rows = db_fetch_cell("SELECT\n\t\t\tCOUNT(host.id)\n\t\t\tFROM host\n\t\t\tLEFT JOIN user_auth_perms \n\t\t\tON (host.id = user_auth_perms.item_id AND user_auth_perms.type = 3)\n\t\t\t{$sql_where}");
            $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 host.*, user_auth_perms.user_id\n\t\t\tFROM host \n\t\t\tLEFT JOIN user_auth_perms \n\t\t\tON (host.id = user_auth_perms.item_id AND user_auth_perms.type = 3)\n\t\t\t{$sql_where} \n\t\t\tORDER BY description\n\t\t\tLIMIT " . $rows * (get_request_var_request('page') - 1) . ',' . $rows;
            $hosts = db_fetch_assoc($sql_query);
            $nav = html_nav_bar('user_admin.php?action=user_edit&tab=permsd&id=' . get_request_var_request('id'), MAX_DISPLAY_PAGES, get_request_var_request('page'), $rows, $total_rows, 11, 'Devices', 'page', 'main');
            print $nav;
            $display_text = array('Description', 'ID', 'Effective Policy', 'Graphs', 'Data Sources', 'Status', 'Hostname');
            html_header_checkbox($display_text, false);
            if (sizeof($hosts)) {
                foreach ($hosts as $host) {
                    form_alternate_row('line' . $host['id'], true);
                    form_selectable_cell(strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($host['description'])) : htmlspecialchars($host['description']), $host['id']);
                    form_selectable_cell(round($host['id'], 2), $host['id']);
                    if (empty($host['user_id']) || $host['user_id'] == NULL) {
                        if ($policy['policy_hosts'] == 1) {
                            form_selectable_cell('<span style="color:green;font-weight:bold;">Access Granted</span>', $host['id']);
                        } else {
                            form_selectable_cell('<span style="color:red;font-weight:bold;">Access Restricted</span>', $host['id']);
                        }
                    } else {
                        if ($policy['policy_hosts'] == 1) {
                            form_selectable_cell('<span style="color:red;font-weight:bold;">Access Restricted</span>', $host['id']);
                        } else {
                            form_selectable_cell('<span style="color:green;font-weight:bold;">Access Granted</span>', $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(strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($host['hostname'])) : htmlspecialchars($host['hostname']), $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 Matching Devices Found</em></td></tr>';
            }
            html_end_box(false);
            form_hidden_box('action', 'user_edit', '');
            form_hidden_box('tab', $tab, '');
            form_hidden_box('id', get_request_var_request('id'), '');
            form_hidden_box('associate_host', '1', '');
            if ($policy['policy_hosts'] == 1) {
                $assoc_actions = array(1 => 'Revoke Access', 2 => 'Grant Access');
            } else {
                $assoc_actions = array(1 => 'Grant Access', 2 => 'Revoke Access');
            }
            /* draw the dropdown containing a list of available actions for this form */
            draw_actions_dropdown($assoc_actions);
            print '</form>';
            break;
        case 'permste':
            process_template_request_vars();
            template_filter($header_label);
            /* print checkbox form for validation */
            print "<form name='policy' method='post' action='user_admin.php'>\n";
            /* box: device permissions */
            html_start_box('<strong>Default Graph Template Policy</strong>', '100%', '', '3', 'center', '');
            ?>
		<tr class='even'>
			<td><table cellspacing="0" cellpadding="2"><tr>
			<td style="white-space:nowrap;" width="120">Default Graph Template Policy for this User</td>
			<td width="10"> 
				<?php 
            form_dropdown('policy_graph_templates', $policy_array, '', '', $policy['policy_graph_templates'], '', '');
            ?>
			</td>
			<td>
				<input type="submit" name="update_policy" value="Update">
				<input type="hidden" name="tab" value="<?php 
            print $tab;
            ?>
">
				<input type="hidden" name="id" value="<?php 
            print get_request_var_request('id');
            ?>
">
			</td>
			</tr></table></td>
		</tr>
		<?php 
            html_end_box();
            print "</form>\n";
            /* if the number of rows is -1, set it to the default */
            if ($_REQUEST['rows'] == -1) {
                $rows = read_config_option('num_rows_table');
            } else {
                $rows = $_REQUEST['rows'];
            }
            /* form the 'where' clause for our main sql query */
            if (strlen(get_request_var_request('filter'))) {
                $sql_where = "WHERE (gt.name LIKE '%%" . get_request_var_request('filter') . "%%')";
            } else {
                $sql_where = '';
            }
            if (get_request_var_request('associated') == 'false') {
                /* Show all items */
            } else {
                $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' (user_auth_perms.type=4 AND user_auth_perms.user_id=' . get_request_var_request('id', 0) . ')';
            }
            /* print checkbox form for validation */
            print "<form name='chk' method='post' action='" . htmlspecialchars('user_admin.php?action=user_edit&tab=permste&id=' . get_request_var_request('id')) . "'>\n";
            html_start_box('', '100%', '', '3', 'center', '');
            $total_rows = db_fetch_cell("SELECT\n\t\t\tCOUNT(gt.id)\n\t\t\tFROM graph_templates AS gt\n\t\t\tINNER JOIN graph_local AS gl\n\t\t\tON gt.id = gl.graph_template_id\n\t\t\tLEFT JOIN user_auth_perms \n\t\t\tON (gt.id = user_auth_perms.item_id AND user_auth_perms.type = 4)\n\t\t\t{$sql_where}\n\t\t\tGROUP BY gl.graph_template_id");
            $sql_query = "SELECT gt.id, gt.name, count(*) AS totals, user_auth_perms.user_id\n\t\t\tFROM graph_templates AS gt\n\t\t\tINNER JOIN graph_local AS gl\n\t\t\tON gt.id = gl.graph_template_id\n\t\t\tLEFT JOIN user_auth_perms \n\t\t\tON (gt.id = user_auth_perms.item_id AND user_auth_perms.type = 4)\n\t\t\t{$sql_where} \n\t\t\tGROUP BY gl.graph_template_id\n\t\t\tORDER BY name\n\t\t\tLIMIT " . $rows * (get_request_var_request('page') - 1) . ',' . $rows;
            $graphs = db_fetch_assoc($sql_query);
            $nav = html_nav_bar('user_admin.php?action=user_edit&tab=permste&id=' . get_request_var_request('id'), MAX_DISPLAY_PAGES, get_request_var_request('page'), $rows, $total_rows, 11, 'Graph Templates', 'page', 'main');
            print $nav;
            $display_text = array('Template Name', 'ID', 'Effective Policy', 'Total Graphs');
            html_header_checkbox($display_text, false);
            if (sizeof($graphs)) {
                foreach ($graphs as $g) {
                    form_alternate_row('line' . $g['id'], true);
                    form_selectable_cell(strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($g['name'])) : htmlspecialchars($g['name']), $g['id']);
                    form_selectable_cell($g['id'], $g['id']);
                    if (empty($g['user_id']) || $g['user_id'] == NULL) {
                        if ($policy['policy_graph_templates'] == 1) {
                            form_selectable_cell('<span style="color:green;font-weight:bold;">Access Granted</span>', $g['id']);
                        } else {
                            form_selectable_cell('<span style="color:red;font-weight:bold;">Access Restricted</span>', $g['id']);
                        }
                    } else {
                        if ($policy['policy_graph_templates'] == 1) {
                            form_selectable_cell('<span style="color:red;font-weight:bold;">Access Restricted</span>', $g['id']);
                        } else {
                            form_selectable_cell('<span style="color:green;font-weight:bold;">Access Granted</span>', $g['id']);
                        }
                    }
                    form_selectable_cell($g['totals'], $g['id']);
                    form_checkbox_cell($g['name'], $g['id']);
                    form_end_row();
                }
                /* put the nav bar on the bottom as well */
                print $nav;
            } else {
                print '<tr><td><em>No Matching Graph Templates Found</em></td></tr>';
            }
            html_end_box(false);
            form_hidden_box('action', 'user_edit', '');
            form_hidden_box('tab', $tab, '');
            form_hidden_box('id', get_request_var_request('id'), '');
            form_hidden_box('associate_template', '1', '');
            if ($policy['policy_graph_templates'] == 1) {
                $assoc_actions = array(1 => 'Revoke Access', 2 => 'Grant Access');
            } else {
                $assoc_actions = array(1 => 'Grant Access', 2 => 'Revoke Access');
            }
            /* draw the dropdown containing a list of available actions for this form */
            draw_actions_dropdown($assoc_actions);
            print '</form>';
            break;
        case 'permstr':
            process_tree_request_vars();
            tree_filter($header_label);
            /* print checkbox form for validation */
            print "<form name='policy' method='post' action='user_admin.php'>\n";
            /* box: device permissions */
            html_start_box('<strong>Default Tree Policy</strong>', '100%', '', '3', 'center', '');
            ?>
		<tr class='even'>
			<td><table cellspacing="0" cellpadding="2"><tr>
			<td style="white-space:nowrap;" width="120">Default Tree Policy for this User</td>
			<td width="10"> 
				<?php 
            form_dropdown('policy_trees', $policy_array, '', '', $policy['policy_trees'], '', '');
            ?>
			</td>
			<td>
				<input type="submit" name="update_policy" value="Update">
				<input type="hidden" name="tab" value="<?php 
            print $tab;
            ?>
">
				<input type="hidden" name="id" value="<?php 
            print get_request_var_request('id');
            ?>
">
			</td>
			</tr></table></td>
		</tr>
		<?php 
            html_end_box();
            print "</form>\n";
            /* if the number of rows is -1, set it to the default */
            if ($_REQUEST['rows'] == -1) {
                $rows = read_config_option('num_rows_table');
            } else {
                $rows = $_REQUEST['rows'];
            }
            /* form the 'where' clause for our main sql query */
            if (strlen(get_request_var_request('filter'))) {
                $sql_where = "WHERE (gt.name LIKE '%%" . get_request_var_request('filter') . "%%')";
            } else {
                $sql_where = '';
            }
            if (get_request_var_request('associated') == 'false') {
                /* showing all rows */
            } else {
                $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' (user_auth_perms.type=2 AND user_auth_perms.user_id=' . get_request_var_request('id', 0) . ')';
            }
            /* print checkbox form for validation */
            print "<form name='chk' method='post' action='" . htmlspecialchars('user_admin.php?action=user_edit&tab=permstr&id=' . get_request_var_request('id')) . "'>\n";
            html_start_box('', '100%', '', '3', 'center', '');
            $total_rows = db_fetch_cell("SELECT\n\t\t\tCOUNT(gt.id)\n\t\t\tFROM graph_tree AS gt\n\t\t\tLEFT JOIN user_auth_perms \n\t\t\tON (gt.id = user_auth_perms.item_id AND user_auth_perms.type = 2)\n\t\t\t{$sql_where}");
            $sql_query = "SELECT gt.id, gt.name, user_auth_perms.user_id\n\t\t\tFROM graph_tree AS gt\n\t\t\tLEFT JOIN user_auth_perms \n\t\t\tON (gt.id = user_auth_perms.item_id AND user_auth_perms.type = 2)\n\t\t\t{$sql_where} \n\t\t\tORDER BY name\n\t\t\tLIMIT " . $rows * (get_request_var_request('page') - 1) . ',' . $rows;
            $trees = db_fetch_assoc($sql_query);
            $nav = html_nav_bar('user_admin.php?action=user_edit&tab=permstr&id=' . get_request_var_request('id'), MAX_DISPLAY_PAGES, get_request_var_request('page'), $rows, $total_rows, 11, 'Trees', 'page', 'main');
            print $nav;
            $display_text = array('Tree Name', 'ID', 'Effective Policy');
            html_header_checkbox($display_text, false);
            if (sizeof($trees)) {
                foreach ($trees as $t) {
                    form_alternate_row('line' . $t['id'], true);
                    form_selectable_cell(strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($t['name'])) : htmlspecialchars($t['name']), $t['id']);
                    form_selectable_cell($t['id'], $t['id']);
                    if (empty($t['user_id']) || $t['user_id'] == NULL) {
                        if ($policy['policy_graphs'] == 1) {
                            form_selectable_cell('<span style="color:green;font-weight:bold;">Access Granted</span>', $t['id']);
                        } else {
                            form_selectable_cell('<span style="color:red;font-weight:bold;">Access Restricted</span>', $t['id']);
                        }
                    } else {
                        if ($policy['policy_graphs'] == 1) {
                            form_selectable_cell('<span style="color:red;font-weight:bold;">Access Restricted</span>', $t['id']);
                        } else {
                            form_selectable_cell('<span style="color:green;font-weight:bold;">Access Granted</span>', $t['id']);
                        }
                    }
                    form_checkbox_cell($t['name'], $t['id']);
                    form_end_row();
                }
                /* put the nav bar on the bottom as well */
                print $nav;
            } else {
                print '<tr><td><em>No Matching Trees Found</em></td></tr>';
            }
            html_end_box(false);
            form_hidden_box('action', 'user_edit', '');
            form_hidden_box('tab', $tab, '');
            form_hidden_box('id', get_request_var_request('id'), '');
            form_hidden_box('associate_tree', '1', '');
            if ($policy['policy_graph_templates'] == 1) {
                $assoc_actions = array(1 => 'Revoke Access', 2 => 'Grant Access');
            } else {
                $assoc_actions = array(1 => 'Grant Access', 2 => 'Revoke Access');
            }
            /* draw the dropdown containing a list of available actions for this form */
            draw_actions_dropdown($assoc_actions);
            print '</form>';
            break;
    }
}
Exemple #6
0
function template()
{
    $menu_items = array("remove" => "Remove", "duplicate" => "Duplicate");
    $filter_array = array();
    /* search field: filter (searches template name) */
    if (isset_get_var("search_filter")) {
        $filter_array["template_name"] = get_get_var("search_filter");
    }
    /* get a list of all data templates on this page */
    $data_templates = api_data_template_list($filter_array);
    /* get a list of data input types for display in the data sources list */
    $data_input_types = api_data_source_input_type_list();
    form_start("data_templates.php");
    $box_id = "1";
    html_start_box("<strong>" . _("Data Templates") . "</strong>", "data_templates.php?action=edit");
    html_header_checkbox(array(_("Template Name"), _("Data Input Type"), _("Status")), $box_id);
    $i = 0;
    if (sizeof($data_templates) > 0) {
        foreach ($data_templates as $data_template) {
            ?>
			<tr class="item" id="box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $data_template["id"];
            ?>
" onClick="display_row_select('<?php 
            echo $box_id;
            ?>
',document.forms[0],'box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $data_template["id"];
            ?>
', 'box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $data_template["id"];
            ?>
')" onMouseOver="display_row_hover('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $data_template["id"];
            ?>
')" onMouseOut="display_row_clear('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $data_template["id"];
            ?>
')">
				<td class="title">
					<a onClick="display_row_block('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $data_template["id"];
            ?>
')" href="data_templates.php?action=edit&id=<?php 
            echo $data_template["id"];
            ?>
"><span id="box-<?php 
            echo $box_id;
            ?>
-text-<?php 
            echo $data_template["id"];
            ?>
"><?php 
            echo html_highlight_words(get_get_var("search_filter"), $data_template["template_name"]);
            ?>
</span></a>
				</td>
				<td>
					<?php 
            echo $data_input_types[$data_template["data_input_type"]];
            ?>
				</td>
				<td>
					<?php 
            if ($data_template["active"] == "1") {
                echo _("Active");
            } else {
                echo _("Disabled");
            }
            ?>
				</td>
				<td class="checkbox" align="center">
					<input type='checkbox' name='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $data_template["id"];
            ?>
' id='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $data_template["id"];
            ?>
' title="<?php 
            echo $data_template["template_name"];
            ?>
">
				</td>
			</tr>
			<?php 
        }
    } else {
        ?>
		<tr class="empty">
			<td colspan="6">
				No data templates found.
			</td>
		</tr>
		<?php 
    }
    html_box_toolbar_draw($box_id, "0", "3", HTML_BOX_SEARCH_NO_ICON);
    html_end_box(false);
    html_box_actions_menu_draw($box_id, "0", $menu_items);
    html_box_actions_area_create($box_id);
    form_hidden_box("action_post", "data_template_list");
    form_end();
    ?>

	<script language="JavaScript">
	<!--
	function action_area_handle_type(box_id, type, parent_div, parent_form) {
		if (type == 'remove') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to remove these data templates?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Remove Data Template');
			action_area_update_submit_caption(box_id, 'Remove');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'duplicate') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to duplicate these data templates?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));
			parent_div.appendChild(action_area_generate_input('text', 'box-' + box_id + '-action-area-txt1', ''));

			action_area_update_header_caption(box_id, 'Duplicate Data Templates');
			action_area_update_submit_caption(box_id, 'Duplicate');
			action_area_update_selected_rows(box_id, parent_form);
		}
	}
	-->
	</script>

	<?php 
}
Exemple #7
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);
}
Exemple #8
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";
}
Exemple #9
0
function user() {
	global $user_actions, $colors, $auth_realms;

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

	html_header_checkbox(array(_("User Name"), _("Full Name"), _("Status"),_("Realm"), _("Default Graph Policy"), _("Last Login"), _("Last Login From"),_("Last Password Change")));

	$user_list = api_user_list( array( "1" => "username" ) );

	$i = 0;
	if (sizeof($user_list) > 0) {
	foreach ($user_list as $user_list_values) {
		$user = api_user_info( array( "id" => $user_list_values["id"] ) );
		form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$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 if ($user["enabled"] == "1") { print _("Enabled"); }else{ print _("Disabled"); }?>
			</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["last_login_formatted"];?>
			</td>
			<td>
				<?php print $user["last_login_ip"];?>
			</td>
			<td>
				<?php
				if ($user["realm"] != "0") {
					print _("N/A");
				}else{
					if ($user["password_change_last"] == "0000-00-00 00:00:00") {
						print _("Never");
					}else{
						print $user["password_change_last_formatted"];
					}
				} ?>
			</td>


			<td style="<?php print get_checkbox_style();?>" width="1%" align="right">
				<input type='checkbox' style='margin: 0px;' name='chk_<?php print $user["id"];?>' title="<?php print $user["username"];?>">
			</td>
		</tr>
	<?php
	$i++;
	}
	}
	html_end_box(false);

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

}
Exemple #10
0
function host()
{
    $current_page = get_get_var_number("page", "1");
    $menu_items = array("remove" => "Remove", "duplicate" => "Duplicate", "enable" => "Enable", "disable" => "Disable", "clear_stats" => "Clear Statistics", "change_snmp_opts" => "Change SNMP Options", "change_avail_opts" => "Change Availability Options", "change_poller" => "Change Poller");
    $filter_array = array();
    /* search field: device template */
    if (isset_get_var("search_device_template")) {
        $filter_array["=host_template_id"] = get_get_var("search_device_template");
    }
    /* search field: device status */
    if (isset_get_var("search_status")) {
        $filter_array["=status"] = get_get_var("search_status");
    }
    /* search field: filter (searches device description and hostname) */
    if (isset_get_var("search_filter")) {
        $filter_array["%filter"] = array("hostname" => get_get_var("search_filter"), "description" => get_get_var("search_filter"));
    }
    /* get a list of all devices on this page */
    $devices = api_device_list($filter_array, "description", "asc", read_config_option("num_rows_device") * ($current_page - 1), read_config_option("num_rows_device"));
    /* get the total number of devices on all pages */
    $total_rows = api_device_total_get($filter_array);
    /* generate page list */
    $url_string = build_get_url_string(array("search_device_template", "search_status", "search_filter"));
    $url_page_select = get_page_list($current_page, MAX_DISPLAY_PAGES, read_config_option("num_rows_device"), $total_rows, "devices.php" . $url_string . ($url_string == "" ? "?" : "&") . "page=|PAGE_NUM|");
    form_start("devices.php");
    $box_id = "1";
    html_start_box("<strong>" . _("Devices") . "</strong>", "devices.php?action=edit", $url_page_select);
    html_header_checkbox(array(_("Description"), _("Status"), _("Hostname"), _("Current (ms)"), _("Average (ms)"), _("Availability")), $box_id);
    $i = 0;
    if (sizeof($devices) > 0) {
        foreach ($devices as $host) {
            ?>
			<tr class="item" id="box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $host["id"];
            ?>
" onClick="display_row_select('<?php 
            echo $box_id;
            ?>
',document.forms[0],'box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $host["id"];
            ?>
', 'box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $host["id"];
            ?>
')" onMouseOver="display_row_hover('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $host["id"];
            ?>
')" onMouseOut="display_row_clear('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $host["id"];
            ?>
')">
				<td class="title">
					<a onClick="display_row_block('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $host["id"];
            ?>
')" href="devices.php?action=edit&id=<?php 
            echo $host["id"];
            ?>
"><span id="box-<?php 
            echo $box_id;
            ?>
-text-<?php 
            echo $host["id"];
            ?>
"><?php 
            echo html_highlight_words(get_get_var("search_filter"), $host["description"]);
            ?>
</span></a>
				</td>
				<td>
					<?php 
            echo get_colored_device_status($host["disabled"] == "on" ? true : false, $host["status"]);
            ?>
				</td>
				<td>
					<?php 
            echo html_highlight_words(get_get_var("search_filter"), $host["hostname"]);
            ?>
				</td>
				<td>
					<?php 
            echo round($host["cur_time"], 2);
            ?>
				</td>
				<td>
					<?php 
            echo round($host["avg_time"], 2);
            ?>
				</td>
				<td>
					<?php 
            echo round($host["availability"], 2);
            ?>
%
				</td>
				<td class="checkbox" align="center">
					<input type='checkbox' name='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $host["id"];
            ?>
' id='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $host["id"];
            ?>
' title="<?php 
            echo $host["description"];
            ?>
">
				</td>
			</tr>
			<?php 
        }
    } else {
        ?>
		<tr class="empty">
			<td colspan="6">
				No devices found.
			</td>
		</tr>
		<?php 
    }
    html_box_toolbar_draw($box_id, "0", "6", sizeof($filter_array) == 0 ? HTML_BOX_SEARCH_INACTIVE : HTML_BOX_SEARCH_ACTIVE, $url_page_select);
    html_end_box(false);
    html_box_actions_menu_draw($box_id, "0", $menu_items);
    html_box_actions_area_create($box_id);
    form_hidden_box("action_post", "device_list");
    form_end();
    /* fill in the list of available device templates for the search dropdown */
    $search_device_templates = array();
    $search_device_templates["-1"] = "Any";
    $search_device_templates["0"] = "None";
    $search_device_templates += array_rekey(api_device_template_list(), "id", "name");
    /* fill in the list of available host status types for the search dropdown */
    $search_host_status_types = array();
    $search_host_status_types["-1"] = "Any";
    $search_host_status_types["-2"] = "Disabled";
    $search_host_status_types += api_device_status_type_list();
    ?>

	<script language="JavaScript">
	<!--
	function action_area_handle_type(box_id, type, parent_div, parent_form) {
		if (type == 'remove') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to remove these devices?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			parent_div.appendChild(action_area_generate_input('radio', 'box-' + box_id + '-remove_type', '1'));
			parent_div.appendChild(document.createTextNode('Leave all graphs and data sources untouched. Data sources will be disabled however.'));
			parent_div.appendChild(action_area_generate_break());

			_elm_rt_input = action_area_generate_input('radio', 'box-' + box_id + '-remove_type', '2');
			_elm_rt_input.checked = true;
			parent_div.appendChild(_elm_rt_input);
			parent_div.appendChild(document.createTextNode("Delete all associated graphs and data sources."));

			action_area_update_header_caption(box_id, 'Remove Device');
			action_area_update_submit_caption(box_id, 'Remove');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'duplicate') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to duplicate these devices?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));
			parent_div.appendChild(action_area_generate_input('text', 'box-' + box_id + '-action-area-txt1', ''));

			action_area_update_header_caption(box_id, 'Duplicate Devices');
			action_area_update_submit_caption(box_id, 'Duplicate');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'enable') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to enable these devices?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Enable Devices');
			action_area_update_submit_caption(box_id, 'Enable');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'disable') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to disable these devices?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Disable Devices');
			action_area_update_submit_caption(box_id, 'Disable');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'clear_stats') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to clear polling statistics for these devices?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Clear Polling Statistics');
			action_area_update_submit_caption(box_id, 'Clear');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'search') {
			_elm_dt_input = action_area_generate_select('box-' + box_id + '-search_device_template');
			<?php 
    echo get_js_dropdown_code('_elm_dt_input', $search_device_templates, isset_get_var("search_device_template") ? get_get_var("search_device_template") : "-1");
    ?>

			_elm_ds_input = action_area_generate_select('box-' + box_id + '-search_status');
			<?php 
    echo get_js_dropdown_code('_elm_ds_input', $search_host_status_types, isset_get_var("search_status") ? get_get_var("search_status") : "-1");
    ?>

			_elm_ht_input = action_area_generate_input('text', 'box-' + box_id + '-search_filter', '<?php 
    echo get_get_var("search_filter");
    ?>
');
			_elm_ht_input.size = '30';

			parent_div.appendChild(action_area_generate_search_field(_elm_dt_input, 'Device Template', true, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_ds_input, 'Device Status', false, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_ht_input, 'Filter', false, true));

			action_area_update_header_caption(box_id, 'Search');
			action_area_update_submit_caption(box_id, 'Search');
		}
	}
	-->
	</script>

	<?php 
}
Exemple #11
0
function view_users()
{
    $current_page = get_get_var_number("page", "1");
    /* setup action menu */
    $menu_items = array("remove" => "Remove", "duplicate" => "Duplicate", "enable" => "Enable", "disable" => "Disable", "passwdexpire" => "Password Expire");
    /* search field: filter (searchs device description and hostname) */
    $filter_array = array();
    $filter_url = "";
    if (isset_get_var("search_filter")) {
        $filter_array["name"] = get_get_var("search_filter");
        $filter_url .= ($filter_url == "" ? "" : "&") . "search_filter=" . urlencode(get_get_var("search_filter"));
    }
    if (isset_get_var("search_name")) {
        $filter_array["name"] = get_get_var("search_name");
        $filter_url .= ($filter_url == "" ? "" : "&") . "search_name=" . urlencode(get_get_var("search_name"));
    }
    if (isset_get_var("search_description")) {
        $filter_array["description"] = get_get_var("search_description");
        $filter_url .= ($filter_url == "" ? "" : "&") . "search_description=" . urlencode(get_get_var("search_description"));
    }
    if (isset_get_var("search_enabled")) {
        $filter_array["enabled"] = get_get_var("search_enabled");
        $filter_url .= ($filter_url == "" ? "" : "&") . "search_enabled=" . urlencode(get_get_var("search_enabled"));
    }
    /* get log entires */
    $users = api_auth_control_list(AUTH_CONTROL_OBJECT_TYPE_USER, $filter_array, read_config_option("num_rows_page"), read_config_option("num_rows_page") * ($current_page - 1));
    $total_rows = api_auth_control_total_get($filter_array);
    /* generate page list */
    $url_string = build_get_url_string(array("search_filter", "search_name", "search_description"));
    $url_page_select = get_page_list($current_page, MAX_DISPLAY_PAGES, read_config_option("num_rows_page"), $total_rows, "auth_user.php" . $url_string . ($url_string == "" ? "?" : "&") . "page=|PAGE_NUM|");
    /* Output html */
    $box_id = 1;
    form_start("auth_user.php");
    html_start_box("<strong>" . _("Users") . "</strong>", "auth_user.php?action=add", $url_page_select);
    html_header_checkbox(array(_("Username"), _("Full Name"), _("Enabled"), _("Last Login"), _("Last Login IP")), $box_id);
    $i = 0;
    if (is_array($users) && sizeof($users) > 0) {
        foreach ($users as $user) {
            $user_info = api_auth_control_get(AUTH_CONTROL_OBJECT_TYPE_USER, $user["id"]);
            ?>
			<tr class="item" id="box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $user["id"];
            ?>
" onClick="display_row_select('<?php 
            echo $box_id;
            ?>
',document.forms[0],'box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $user["id"];
            ?>
', 'box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $user["id"];
            ?>
')" onMouseOver="display_row_hover('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $user["id"];
            ?>
')" onMouseOut="display_row_clear('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $user["id"];
            ?>
')">
				<td class="title">
					<a  onClick="display_row_block('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $user["id"];
            ?>
')" href="auth_user.php?action=edit&id=<?php 
            echo $user["id"];
            ?>
"><span id="box-<?php 
            echo $box_id;
            ?>
-text-<?php 
            echo $user["id"];
            ?>
"><?php 
            echo html_highlight_words(get_get_var("search_filter"), $user["name"]);
            ?>
</span></a>
				</td>
				<td>
					<?php 
            echo $user["description"];
            ?>
				</td>
				<td>
					<?php 
            if ($user_info["enabled"] == 1) {
                echo "Yes";
            } else {
                echo "No";
            }
            ?>
				</td>
				<td>
					<?php 
            if ($user_info["last_login"] == "0000-00-00 00:00:00" || $user_info["last_login"] == "") {
                echo "N/A";
            } else {
                echo $user["last_login"];
            }
            ?>
				</td>
				<td>
					<?php 
            if ($user_info["last_login_ip"] == "") {
                echo "N/A";
            } else {
                echo $user_info["last_login_ip"];
            }
            ?>
				</td>
				<td class="checkbox" align="center">
					<input type='checkbox' name='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $user["id"];
            ?>
' id='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $user["id"];
            ?>
' title="<?php 
            echo $user["name"];
            ?>
">
				</td>
			</tr>

			<?php 
        }
    } else {
        ?>
		<tr class="empty">
			<td colspan="6">
				No Users Found.
			</td>
		</tr>
		<?php 
    }
    html_box_toolbar_draw($box_id, "0", "5", sizeof($filter_array) == 0 ? HTML_BOX_SEARCH_INACTIVE : HTML_BOX_SEARCH_ACTIVE, $url_page_select, 1);
    html_end_box(false);
    html_box_actions_menu_draw($box_id, "0", $menu_items, 250);
    html_box_actions_area_create($box_id);
    form_hidden_box("action_post", "auth_user_list");
    form_end();
    /* fill in the list of available host status types for the search dropdown */
    $search_auth_enabled = array();
    $search_auth_enabled["-1"] = "Any";
    $search_auth_enabled["1"] = "Enabled";
    $search_auth_enabled["0"] = "Disabled";
    ?>

	<script language="JavaScript">
	<!--
	function action_area_handle_type(box_id, type, parent_div, parent_form) {
		if (type == 'remove') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to remove these users?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			parent_div.appendChild(action_area_generate_break());

			action_area_update_header_caption(box_id, 'Remove User');
			action_area_update_submit_caption(box_id, 'Remove');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'duplicate') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to duplicate these users?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));
			parent_div.appendChild(action_area_generate_input('text', 'box-' + box_id + '-action-area-txt1', ''));

			action_area_update_header_caption(box_id, 'Duplicate User');
			action_area_update_submit_caption(box_id, 'Duplicate');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'enable') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to enable these users?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Enable Users');
			action_area_update_submit_caption(box_id, 'Enable');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'disable') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to disable these users?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Disable Users');
			action_area_update_submit_caption(box_id, 'Disable');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'passwdexpire') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to set the password expire interval for these users?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));




			action_area_update_header_caption(box_id, 'Set');
			action_area_update_submit_caption(box_id, 'Clear');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'search') {

                        _elm_ds_input = action_area_generate_select('box-' + box_id + '-search_status');
                        <?php 
    echo get_js_dropdown_code('_elm_ds_input', $search_auth_enabled, isset_get_var("search_enabled") ? get_get_var("search_enabled") : "-1");
    ?>

                        _elm_ht_input = action_area_generate_input('text', 'box-' + box_id + '-search_filter', '<?php 
    echo get_get_var("search_filter");
    ?>
');
                        _elm_ht_input.size = '30';

                        parent_div.appendChild(action_area_generate_search_field(_elm_ds_input, 'Enabled', false, false));
                        parent_div.appendChild(action_area_generate_search_field(_elm_ht_input, 'Filter', false, true));

                        action_area_update_header_caption(box_id, 'Search');
                        action_area_update_submit_caption(box_id, 'Search');

		}

	}
	-->
	</script>

	<?php 
}
Exemple #12
0
function template()
{
    global $colors, $host_actions;
    display_output_messages();
    html_start_box("<strong>" . _("Device Templates") . "</strong>", "98%", $colors["header_background"], "3", "center", "device_templates.php?action=edit");
    html_header_checkbox(array("Template Title"));
    $host_templates = db_fetch_assoc("select * from host_template order by name");
    $i = 0;
    if (sizeof($host_templates) > 0) {
        foreach ($host_templates as $host_template) {
            form_alternate_row_color($colors["form_alternate1"], $colors["form_alternate2"], $i);
            $i++;
            ?>
			<td>
				<a class="linkEditMain" href="device_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 bgcolor='#" . $colors["form_alternate1"] . "' colspan=7><em>" . _("No Device Templates") . "</em></td></tr>";
    }
    html_end_box(false);
    /* draw the dropdown containing a list of available actions for this form */
    draw_actions_dropdown($host_actions);
    print "</form>\n";
}
Exemple #13
0
function manager_notifications($id)
{
    global $colors;
    $mibs = db_fetch_assoc("SELECT DISTINCT mib FROM snmpagent_cache");
    $registered_mibs = array();
    if ($mibs && $mibs > 0) {
        foreach ($mibs as $mib) {
            $registered_mibs[] = $mib["mib"];
        }
    }
    /* ================= input validation ================= */
    if (!$id | !is_numeric($id)) {
        die_html_input_error();
    }
    if (!in_array(get_request_var_request("mib"), $registered_mibs) && get_request_var_request("mib") != '-1' && get_request_var_request("mib") != "") {
        die_html_input_error();
    }
    input_validate_input_number(get_request_var_request("page"));
    /* ==================================================== */
    /* clean up search filter */
    if (isset($_REQUEST["filter"])) {
        $_REQUEST["filter"] = sanitize_search_string(get_request_var_request("filter"));
    }
    /* if the user pushed the 'clear' button */
    if (isset($_REQUEST["clear_x"])) {
        kill_session_var("sess_snmpagent__manager_notifications_cache_mib");
        kill_session_var("sess_snmpagent__manager_notifications_cache_current_page");
        kill_session_var("sess_snmpagent__manager_notifications_cache_filter");
        unset($_REQUEST["mib"]);
        unset($_REQUEST["page"]);
        unset($_REQUEST["filter"]);
    }
    /* reset the current page if the user changed the mib filter*/
    if (isset($_SESSION["sess_snmpagent__manager_notifications_cache_mib"]) && get_request_var_request("mib") != $_SESSION["sess_snmpagent__manager_notifications_cache_mib"]) {
        kill_session_var("sess_snmpagent__manager_notifications_cache_current_page");
        unset($_REQUEST["page"]);
    }
    /* remember these search fields in session vars so we don't have to keep passing them around */
    load_current_session_value("page", "sess_snmpagent__manager_notifications_cache_current_page", "1");
    load_current_session_value("mib", "sess_snmpagent__manager_notifications_cache_mib", "-1");
    load_current_session_value("filter", "sess_snmpagent__manager_notifications_cache_filter", "");
    ?>
		<script type="text/javascript">
<!--

	function applyFilter() {
		strURL = 'managers.php?action=edit&tab=notifications&id=<?php 
    echo $id;
    ?>
&filter=' + $('#filter').val();
		strURL = strURL + '&mib=' + $('#mib').val();
		strURL = strURL + '&filter=' + $('#filter').val();
		strURL = strURL + '&page=' + $('#page').val();
		strURL = strURL + '&header=false';
		
		$.get(strURL, function(data) {
			$('#main').html(data);
			applySkin();
		});
}

	function clearFilter() {
		strURL = 'managers.php?action=edit&tab=notifications&id=<?php 
    echo $id;
    ?>
&clear_x=1&header=false';
		$.get(strURL, function(data) {
			$('#main').html(data);
			applySkin();
		});
	}

	$(function(data) {
		$('#refresh').click(function() {
			applyFilter();
		});

		$('#clear').click(function() {
			clearFilter();
		});

		$('#form_snmpagent_managers').submit(function(event) {
			event.preventDefault();
			applyFilter();
		});
	});

-->
</script>
		<?php 
    $rows = read_config_option('num_rows_table');
    ?>
	<tr class='even noprint'>
			<td>
			<form id='form_snmpagent_managers' name="form_snmpagent_managers" action="managers.php">
				<table cellpadding="2" cellspacing="0">
					<tr>
						<td>
							MIB:
						</td>
						<td>
							<select id="mib" name="mib" onChange="applyFilter()">
								<option value="-1"<?php 
    if (get_request_var_request("mib") == "-1") {
        ?>
 selected<?php 
    }
    ?>
>Any</option>
								<?php 
    if (sizeof($mibs) > 0) {
        foreach ($mibs as $mib) {
            print "<option value='" . $mib["mib"] . "'";
            if (get_request_var_request("mib") == $mib["mib"]) {
                print " selected";
            }
            print ">" . $mib["mib"] . "</option>\n";
        }
    }
    ?>
							</select>
						</td>
						<td>
							Search:
						</td>
						<td>
							<input id='filter' type="text" name="filter" size="25" value="<?php 
    print htmlspecialchars(get_request_var_request("filter"));
    ?>
" onChange='applyFilter()'>
						</td>
						<td>
							<input type="button" id='refresh' value="Go" title="Set/Refresh Filters">
						</td>
						<td>
							<input type="button" id='clear' name="clear_x" value="Clear" title="Clear Filters">
						</td>
					</tr>
				</table>
				<input type='hidden' id='page' name='page' value='1'>
				
			</form>
			</td>
		</tr>
		<?php 
    html_end_box();
    $sql_where = " AND `kind` = 'Notification'";
    /* filter by host */
    if (get_request_var_request("mib") == "-1") {
        /* Show all items */
    } elseif (!empty($_REQUEST["mib"])) {
        $sql_where .= " AND snmpagent_cache.mib='" . get_request_var_request("mib") . "'";
    }
    /* filter by search string */
    if (get_request_var_request("filter") != "") {
        $sql_where .= " AND (`oid` LIKE '%%" . get_request_var_request("filter") . "%%'\n\t\t\tOR `name` LIKE '%%" . get_request_var_request("filter") . "%%'\n\t\t\tOR `mib` LIKE '%%" . get_request_var_request("filter") . "%%')";
    }
    $sql_where .= ' ORDER by `oid`';
    /* print checkbox form for validation */
    print "<form name='chk' method='post' action='managers.php'>\n";
    html_start_box("", "100%", $colors["header"], "3", "center", "");
    $rows = read_config_option('num_rows_table');
    $total_rows = db_fetch_cell("SELECT COUNT(*) FROM snmpagent_cache WHERE 1 {$sql_where}");
    $snmp_cache_sql = "SELECT * FROM snmpagent_cache WHERE 1 {$sql_where} LIMIT " . $rows * (get_request_var_request("page") - 1) . "," . $rows;
    $snmp_cache = db_fetch_assoc($snmp_cache_sql);
    $registered_notifications = db_fetch_assoc("SELECT notification, mib from snmpagent_managers_notifications WHERE manager_id = {$id}");
    $notifications = array();
    if ($registered_notifications && sizeof($registered_notifications) > 0) {
        foreach ($registered_notifications as $registered_notification) {
            $notifications[$registered_notification["mib"]][$registered_notification["notification"]] = 1;
        }
    }
    /* generate page list */
    $nav = html_nav_bar("managers.php?action=edit&id=" . $id . "&tab=notifications&mib=" . get_request_var_request("mib") . "&filter=" . get_request_var_request("filter"), MAX_DISPLAY_PAGES, get_request_var_request("page"), $rows, $total_rows, 11, '', 'page', 'main');
    print $nav;
    html_header_checkbox(array("Name", "OID", "MIB", "Kind", "Max-Access", "Monitored"), true, "managers.php?action=edit&tab=notifications&id=" . $id);
    if (sizeof($snmp_cache) > 0) {
        foreach ($snmp_cache as $item) {
            $row_id = $item["mib"] . '__' . $item["name"];
            $oid = strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter"), "/") . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $item["oid"]) : $item["oid"];
            $name = strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter"), "/") . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $item["name"]) : $item["name"];
            $mib = strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter"), "/") . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $item["mib"]) : $item["mib"];
            form_alternate_row('line' . $row_id, false);
            if ($item["description"]) {
                print '<td><a href="#" title="<div class=\'header\'>' . $name . '</div><div class=\'content preformatted\'>' . $item["description"] . '</div>" class="tooltip">' . $name . '</a></td>';
            } else {
                form_selectable_cell($name, $row_id);
            }
            form_selectable_cell($oid, $row_id);
            form_selectable_cell($mib, $row_id);
            form_selectable_cell($item["kind"], $row_id);
            form_selectable_cell($item["max-access"], $row_id);
            form_selectable_cell(isset($notifications[$item["mib"]]) && isset($notifications[$item["mib"]][$item["name"]]) ? "Enabled" : "Disabled", $row_id);
            form_checkbox_cell($item["oid"], $row_id);
            form_end_row();
        }
        print $nav;
    } else {
        print "<tr><td><em>No SNMP Notifications</em></td></tr>";
    }
    ?>
	<input type='hidden' name='page' value='1'>
	<input type='hidden' name='action' value='edit'>
	<input type='hidden' name='tab' value='notifications'>
	<input type='hidden' name='id' value='<?php 
    print $_REQUEST["id"];
    ?>
'>
	<?php 
}
Exemple #14
0
function view_rra() {
	$menu_items = array(
		"remove" => "Remove",
		"duplicate" => "Duplicate"
		);

	$rras = api_data_preset_rra_list();

	form_start("presets_rra.php");

	$box_id = "1";
	html_start_box("<strong>" . _("RRA Presets") . "</strong>", "presets_rra.php?action=edit", "", "", false);
	html_header_checkbox(array(_("Name")), $box_id);

	if (sizeof($rras) > 0) {
		foreach ($rras as $rra) {
			?>
			<tr class="item" id="box-<?php echo $box_id;?>-row-<?php echo $rra["id"];?>" onClick="display_row_select('<?php echo $box_id;?>',document.forms[0],'box-<?php echo $box_id;?>-row-<?php echo $rra["id"];?>', 'box-<?php echo $box_id;?>-chk-<?php echo $rra["id"];?>')" onMouseOver="display_row_hover('box-<?php echo $box_id;?>-row-<?php echo $rra["id"];?>')" onMouseOut="display_row_clear('box-<?php echo $box_id;?>-row-<?php echo $rra["id"];?>')">
				<td class="title">
					<a onClick="display_row_block('box-<?php echo $box_id;?>-row-<?php echo $rra["id"];?>')" href="presets_rra.php?action=edit&id=<?php echo $rra["id"];?>"><span id="box-<?php echo $box_id;?>-text-<?php echo $rra["id"];?>"><?php echo $rra["name"];?></span></a>
				</td>
				<td class="checkbox" align="center">
					<input type='checkbox' name='box-<?php echo $box_id;?>-chk-<?php echo $rra["id"];?>' id='box-<?php echo $box_id;?>-chk-<?php echo $rra["id"];?>' title="<?php echo $rra["name"];?>">
				</td>
			</tr>
			<?php
		}

		html_box_toolbar_draw($box_id, "0", "1");
	}else{
		?>
		<tr class="empty">
			<td colspan="1">
				No RRA presets found.
			</td>
		</tr>
		<?php
	}

	html_end_box(false);

	html_box_actions_menu_draw($box_id, "0", $menu_items);
	html_box_actions_area_create($box_id);

	form_end();
	?>

	<script language="JavaScript">
	<!--
	function action_area_handle_type(box_id, type, parent_div, parent_form) {
		if (type == 'remove') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to remove these RRA presets?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Remove RRA Presets');
			action_area_update_submit_caption(box_id, 'Remove');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'duplicate') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to duplicate these RRA presets?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));
			parent_div.appendChild(action_area_generate_input('text', 'box-' + box_id + '-action-area-txt1', ''));

			action_area_update_header_caption(box_id, 'Duplicate RRA Presets');
			action_area_update_submit_caption(box_id, 'Duplicate');
			action_area_update_selected_rows(box_id, parent_form);
		}
	}
	-->
	</script>

	<?php
}
Exemple #15
0
            $sql_where = '';
            $sql_join = '';
        }
        $sql_base = "from (graph_templates_graph,graph_local)\n\t\t{$sql_join}\n\t\t{$sql_where}\n\t\t" . (empty($sql_where) ? 'where' : 'and') . " graph_templates_graph.local_graph_id > 0\n\t\tand graph_templates_graph.local_graph_id=graph_local.id\n\t\tand graph_templates_graph.title_cache like '%" . $_REQUEST['filter'] . "%'\n\t\t" . (empty($_REQUEST['host_id']) ? '' : ' and graph_local.host_id=' . $_REQUEST['host_id']) . '
		' . (empty($_REQUEST['graph_template_id']) ? '' : ' and graph_local.graph_template_id=' . $_REQUEST['graph_template_id']);
        $total_rows = count(db_fetch_assoc("select\n\t\tgraph_templates_graph.local_graph_id\n\t\t{$sql_base}"));
        $graphs = db_fetch_assoc("select\n\t\tgraph_templates_graph.local_graph_id,\n\t\thost.description,\n\t\tgraph_templates.name AS template_name,\n\t\tgraph_templates_graph.title_cache,\n\t\tgraph_templates_graph.height,\n\t\tgraph_templates_graph.width\n\t\t{$sql_base}\n\t\tgroup by graph_templates_graph.local_graph_id\n\t\torder by graph_templates_graph.title_cache\n\t\tlimit " . $_REQUEST['rows'] * ($_REQUEST['page'] - 1) . ',' . $_REQUEST['rows']);
        ?>

	<form name='chk' id='chk' action='graph_view.php' method='get' onSubmit='form_graph(document.chk,document.chk)'>

	<?php 
        html_start_box('', '100%', '', '3', 'center', '');
        $nav = html_nav_bar("graph_view.php?action=list", MAX_DISPLAY_PAGES, get_request_var_request("page"), get_request_var_request("rows"), $total_rows, 5, "Graphs");
        print $nav;
        html_header_checkbox(array('Graph Title', 'Host', 'Graph Template', 'Graph Size'), false);
        $i = 0;
        if (sizeof($graphs)) {
            foreach ($graphs as $graph) {
                form_alternate_row('line' . $graph['local_graph_id'], true);
                form_selectable_cell("<strong><a href='" . htmlspecialchars('graph.php?local_graph_id=' . $graph['local_graph_id'] . '&rra_id=all') . "'>" . htmlspecialchars($graph['title_cache']) . '</a></strong>', $graph['local_graph_id'], '30%');
                form_selectable_cell($graph['description'], $graph['local_graph_id']);
                form_selectable_cell($graph['template_name'], $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();
            }
            print $nav;
        }
        html_end_box();
        ?>
Exemple #16
0
function data_query()
{
    global $data_query_input_types;
    $menu_items = array("remove" => "Remove", "duplicate" => "Duplicate");
    $data_queries = api_data_query_list();
    form_start("data_queries.php");
    $box_id = "1";
    html_start_box("<strong>" . _("Data Queries") . "</strong>", "data_queries.php?action=edit");
    html_header_checkbox(array(_("Name"), _("Input Type")), $box_id);
    if (sizeof($data_queries) > 0) {
        foreach ($data_queries as $data_query) {
            ?>
			<tr class="item" id="box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $data_query["id"];
            ?>
" onClick="display_row_select('<?php 
            echo $box_id;
            ?>
',document.forms[0],'box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $data_query["id"];
            ?>
', 'box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $data_query["id"];
            ?>
')" onMouseOver="display_row_hover('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $data_query["id"];
            ?>
')" onMouseOut="display_row_clear('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $data_query["id"];
            ?>
')">
				<td class="title">
					<a class="linkEditMain" onClick="display_row_block('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $data_query["id"];
            ?>
')" href="data_queries.php?action=edit&id=<?php 
            echo $data_query["id"];
            ?>
"><span id="box-<?php 
            echo $box_id;
            ?>
-text-<?php 
            echo $data_query["id"];
            ?>
"><?php 
            echo $data_query["name"];
            ?>
</span></a>
				</td>
				<td>
					<?php 
            echo $data_query_input_types[$data_query["input_type"]];
            ?>
				</td>
				<td class="checkbox" width="1%" align="center">
					<input type='checkbox' name='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $data_query["id"];
            ?>
' id='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $data_query["id"];
            ?>
' title="<?php 
            echo $data_query["name"];
            ?>
">
				</td>
			</tr>
			<?php 
        }
        html_box_toolbar_draw($box_id, "0", "2");
    } else {
        ?>
		<tr class="empty">
			<td colspan="2">
				No data queries found.
			</td>
		</tr>
		<?php 
    }
    html_end_box(false);
    html_box_actions_menu_draw($box_id, "0", $menu_items);
    html_box_actions_area_create($box_id);
    form_end();
    ?>

	<script language="JavaScript">
	<!--
	function action_area_handle_type(box_id, type, parent_div, parent_form) {
		if (type == 'remove') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to remove these data queries?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Remove Data Queries');
			action_area_update_submit_caption(box_id, 'Remove');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'duplicate') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to duplicate these data queries?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));
			parent_div.appendChild(action_area_generate_input('text', 'box-' + box_id + '-action-area-txt1', ''));

			action_area_update_header_caption(box_id, 'Duplicate Data Queries');
			action_area_update_submit_caption(box_id, 'Duplicate');
			action_area_update_selected_rows(box_id, parent_form);
		}
	}
	-->
	</script>

	<?php 
    require_once CACTI_BASE_PATH . "/include/bottom_footer.php";
}
Exemple #17
0
        } else {
            $sql_where = "";
            $sql_join = "";
        }
        $sql_base = "from (graph_templates_graph,graph_local)\r\n\t\t{$sql_join}\r\n\t\t{$sql_where}\r\n\t\t" . (empty($sql_where) ? "where" : "and") . " graph_templates_graph.local_graph_id > 0\r\n\t\tand graph_templates_graph.local_graph_id=graph_local.id\r\n\t\tand graph_templates_graph.title_cache like '%" . $_REQUEST["filter"] . "%'\r\n\t\t" . (empty($_REQUEST["host_id"]) ? "" : " and graph_local.host_id=" . $_REQUEST["host_id"]) . "\r\n\t\t" . (empty($_REQUEST["graph_template_id"]) ? "" : " and graph_local.graph_template_id=" . $_REQUEST["graph_template_id"]);
        $total_rows = count(db_fetch_assoc("select\r\n\t\tgraph_templates_graph.local_graph_id\r\n\t\t{$sql_base}"));
        $graphs = db_fetch_assoc("select\r\n\t\tgraph_templates_graph.local_graph_id,\r\n\t\tgraph_templates_graph.title_cache,\r\n\t\tgraph_templates_graph.height,\r\n\t\tgraph_templates_graph.width\r\n\t\t{$sql_base}\r\n\t\tgroup by graph_templates_graph.local_graph_id\r\n\t\torder by graph_templates_graph.title_cache\r\n\t\tlimit " . $_REQUEST["rows"] * ($_REQUEST["page"] - 1) . "," . $_REQUEST["rows"]);
        ?>

	<form name='chk' id='chk' action='graph_view.php' method='get' onSubmit='form_graph(document.chk,document.chk)'>

	<?php 
        $nav = "<tr bgcolor='#" . $colors["header"] . "'>\r\n\t\t<td colspan='3'>\r\n\t\t\t<table width='100%' cellspacing='0' cellpadding='3' border='0'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td align='left' class='textHeaderDark'>\r\n\t\t\t\t\t\t<strong>&lt;&lt; " . (get_request_var_request("page") > 1 ? "<a class='linkOverDark' href='" . htmlspecialchars(str_replace("<PAGE>", get_request_var_request("page") - 1, $nav_url)) . "' onClick='return url_go(url_graph(\"" . str_replace("<PAGE>", get_request_var_request("page") - 1, $nav_url) . "\"))'>" : "") . "Previous" . (get_request_var_request("page") > 1 ? "</a>" : "") . "</strong>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t\t<td align='center' class='textHeaderDark'>\r\n\t\t\t\t\t\tShowing Rows " . ($_REQUEST["rows"] * (get_request_var_request("page") - 1) + 1) . " to " . ($total_rows < $_REQUEST["rows"] || $total_rows < $_REQUEST["rows"] * get_request_var_request("page") ? $total_rows : $_REQUEST["rows"] * get_request_var_request("page")) . " of " . $total_rows . "\r\n\t\t\t\t\t</td>\r\n\t\t\t\t\t<td align='right' class='textHeaderDark'>\r\n\t\t\t\t\t\t<strong>" . (get_request_var_request("page") * $_REQUEST["rows"] < $total_rows ? "<a class='linkOverDark' href='" . htmlspecialchars(str_replace("<PAGE>", get_request_var_request("page") + 1, $nav_url)) . "' onClick='return url_go(url_graph(\"" . str_replace("<PAGE>", get_request_var_request("page") + 1, $nav_url) . "\"))'>" : "") . "Next" . (get_request_var_request("page") * $_REQUEST["rows"] < $total_rows ? "</a>" : "") . " &gt;&gt;</strong>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\t\t</td>\r\n\t</tr>";
        html_start_box("", "100%", $colors["header"], "1", "center", "");
        print $nav;
        html_header_checkbox(array("Graph Title", "Graph Size"), false);
        $i = 0;
        if (sizeof($graphs)) {
            foreach ($graphs as $graph) {
                form_alternate_row_color($colors["alternate"], $colors["light"], $i, 'line' . $graph["local_graph_id"]);
                $i++;
                form_selectable_cell("<strong><a href='" . htmlspecialchars("graph.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=all") . "'>" . htmlspecialchars($graph["title_cache"]) . "</a></strong>", $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();
            }
        }
        print $nav;
        html_end_box();
        ?>
	<table align='right'>
Exemple #18
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"));
	}

	/* 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_host_id");

		unset($_REQUEST["page"]);
		unset($_REQUEST["filter"]);
		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("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"]) . "]", "98%", $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 */
	$sql_where = "and data_template_data.name_cache like '%%" . $_REQUEST["filter"] . "%%'";

	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
		data_local.id
		from data_local,data_template_data
		where data_local.id=data_template_data.local_data_id
		$sql_where"));
	$data_sources = db_fetch_assoc("select
		data_template_data.local_data_id,
		data_template_data.name_cache,
		data_template_data.active,
		data_input.name as data_input_name,
		data_template.name as data_template_name,
		data_local.host_id
		from data_local,data_template_data
		left join data_input
		on data_input.id=data_template_data.data_input_id
		left join data_template
		on data_local.data_template_id=data_template.id
		where data_local.id=data_template_data.local_data_id
		$sql_where
		order by data_template_data.name_cache,data_local.host_id
		limit " . (read_config_option("num_rows_data_source")*($_REQUEST["page"]-1)) . "," . read_config_option("num_rows_data_source"));

	html_start_box("", "98%", $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"] . "'>
			<td colspan='5'>
				<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='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>
						</td>\n
						<td align='center' class='textHeaderDark'>
							Showing 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]
						</td>\n
						<td align='right' class='textHeaderDark'>
							<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>
						</td>\n
					</tr>
				</table>
			</td>
		</tr>\n";

	print $nav;

	html_header_checkbox(array("Name", "Data Input Method", "Active", "Template Name"));

	$i = 0;
	if (sizeof($data_sources) > 0) {
		foreach ($data_sources as $data_source) {
			form_alternate_row_color($colors["alternate"],$colors["light"],$i); $i++;
				?>
				<td>
					<a class='linkEditMain' href='data_sources.php?action=ds_edit&id=<?php print $data_source["local_data_id"];?>' title='<?php print $data_source["name_cache"];?>'><?php if ($_REQUEST["filter"] != "") { print eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", title_trim($data_source["name_cache"], read_config_option("max_title_data_source"))); }else{ print title_trim($data_source["name_cache"], read_config_option("max_title_data_source")); } ?></a>
				</td>
				<td>
					<?php print $data_source["data_input_name"];?>
				</td>
				<td>
					<?php print (($data_source["active"] == "on") ? "Yes" : "<span style='color: red;'>No</span>");?>
				</td>
				<td>
					<?php print ((empty($data_source["data_template_name"])) ? "<em>None</em>" : $data_source["data_template_name"]);?>
				</td>
				<td style="<?php print get_checkbox_style();?>" width="1%" align="right">
					<input type='checkbox' style='margin: 0px;' name='chk_<?php print $data_source["local_data_id"];?>' title="<?php print $data_source["name_cache"];?>">
				</td>
			</tr>
			<?php
		}

		/* 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";
}
Exemple #19
0
function graph()
{
    $current_page = get_get_var_number("page", "1");
    $menu_items = array("remove" => "Remove", "duplicate" => "Duplicate", "change_graph_template" => "Change Graph Template", "change_host" => "Change Host", "convert_graph_template" => "Convert to Graph Template", "place_tree" => "Place on Tree");
    $filter_array = array();
    /* search field: device template */
    if (isset_get_var("search_device")) {
        $filter_array["host_id"] = get_get_var("search_device");
    }
    /* search field: filter (searches data source name) */
    if (isset_get_var("search_filter")) {
        $filter_array["filter"] = array("title_cache|title" => get_get_var("search_filter"));
    }
    /* get a list of all graphs on this page */
    $graphs = api_graph_list($filter_array, $current_page, read_config_option("num_rows_data_source"));
    /* get the total number of graphs on all pages */
    $total_rows = api_graph_total_get($filter_array);
    /* generate page list */
    $url_string = build_get_url_string(array("search_device", "search_filter"));
    $url_page_select = get_page_list($current_page, MAX_DISPLAY_PAGES, read_config_option("num_rows_graph"), $total_rows, "graphs.php" . $url_string . ($url_string == "" ? "?" : "&") . "page=|PAGE_NUM|");
    form_start("graphs.php");
    $box_id = "1";
    html_start_box("<strong>" . _("Graphs") . "</strong>", "graphs.php?action=edit", $url_page_select);
    html_header_checkbox(array(_("Graph Title"), _("Template Name"), _("Size")), $box_id);
    $i = 0;
    if (sizeof($graphs) > 0) {
        foreach ($graphs as $graph) {
            ?>
			<tr class="item" id="box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $graph["id"];
            ?>
" onClick="display_row_select('<?php 
            echo $box_id;
            ?>
',document.forms[0],'box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $graph["id"];
            ?>
', 'box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $graph["id"];
            ?>
')" onMouseOver="display_row_hover('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $graph["id"];
            ?>
')" onMouseOut="display_row_clear('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $graph["id"];
            ?>
')">
				<td class="title">
					<a onClick="display_row_block('box-<?php 
            echo $box_id;
            ?>
-row-<?php 
            echo $graph["id"];
            ?>
')" href="graphs.php?action=edit&id=<?php 
            echo $graph["id"];
            ?>
"><span id="box-<?php 
            echo $box_id;
            ?>
-text-<?php 
            echo $graph["id"];
            ?>
"><?php 
            echo html_highlight_words(get_get_var("search_filter"), $graph["title_cache"]);
            ?>
</span></a>
				</td>
				<td>
					<?php 
            echo empty($graph["template_name"]) ? "<em>" . _("None") . "</em>" : $graph["template_name"];
            ?>
				</td>
				<td>
					<?php 
            echo $graph["height"];
            ?>
x<?php 
            echo $graph["width"];
            ?>
				</td>
				<td class="checkbox" align="center">
					<input type='checkbox' name='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $graph["id"];
            ?>
' id='box-<?php 
            echo $box_id;
            ?>
-chk-<?php 
            echo $graph["id"];
            ?>
' title="<?php 
            echo $graph["title_cache"];
            ?>
">
				</td>
			</tr>
			<?php 
        }
    } else {
        ?>
		<tr class="empty">
			<td colspan="6">
				No graphs found.
			</td>
		</tr>
		<?php 
    }
    html_box_toolbar_draw($box_id, "0", "3", sizeof($filter_array) == 0 ? HTML_BOX_SEARCH_INACTIVE : HTML_BOX_SEARCH_ACTIVE, $url_page_select);
    html_end_box(false);
    html_box_actions_menu_draw($box_id, "0", $menu_items);
    html_box_actions_area_create($box_id);
    form_hidden_box("action_post", "graph_list");
    form_end();
    /* pre-cache the device list since we need it in more than one place below */
    $device_list = array_rekey(api_device_list(), "id", "description");
    /* fill in the list of available devices for the search dropdown */
    $search_devices = array();
    $search_devices["-1"] = "Any";
    $search_devices["0"] = "None";
    $search_devices += $device_list;
    /* fill in the list of available devices for the change host dropdown */
    $change_host_list = array();
    $change_host_list["0"] = "None";
    $change_host_list += $device_list;
    ?>

	<script language="JavaScript">
	<!--
	function action_area_handle_type(box_id, type, parent_div, parent_form) {
		if (type == 'remove') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to remove these graphs?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Remove Graph');
			action_area_update_submit_caption(box_id, 'Remove');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'duplicate') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to duplicate these graphs?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));
			parent_div.appendChild(action_area_generate_input('text', 'box-' + box_id + '-action-area-txt1', ''));

			action_area_update_header_caption(box_id, 'Duplicate Graph');
			action_area_update_submit_caption(box_id, 'Duplicate');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'search') {
			_elm_dt_input = action_area_generate_select('box-' + box_id + '-search_device');
			<?php 
    echo get_js_dropdown_code('_elm_dt_input', $search_devices, isset_get_var("search_device") ? get_get_var("search_device") : "-1");
    ?>

			_elm_ht_input = action_area_generate_input('text', 'box-' + box_id + '-search_filter', '<?php 
    echo get_get_var("search_filter");
    ?>
');
			_elm_ht_input.size = '30';

			parent_div.appendChild(action_area_generate_search_field(_elm_dt_input, 'Device', true, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_ht_input, 'Filter', false, true));

			action_area_update_header_caption(box_id, 'Search');
			action_area_update_submit_caption(box_id, 'Search');
		}else if (type == 'change_host') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to change the host for these graphs?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			_elm_dt_input = action_area_generate_select('box-' + box_id + '-change_device');
			<?php 
    echo get_js_dropdown_code('_elm_dt_input', $change_host_list, "0");
    ?>

			parent_div.appendChild(action_area_generate_search_field(_elm_dt_input, 'New Device', true, true));

			action_area_update_header_caption(box_id, 'Change Host');
			action_area_update_submit_caption(box_id, 'Change');
			action_area_update_selected_rows(box_id, parent_form);
		}
	}
	-->
	</script>

	<?php 
}
Exemple #20
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"));
	}

	/* 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");

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

	/* 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", "");

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

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

	html_end_box();

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

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

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

	$template_list = db_fetch_assoc("select
		graph_templates.id,graph_templates.name
		from graph_templates
		$sql_where
		order by name
		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, "graph_templates.php?filter=" . $_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 ($_REQUEST["page"] > 1) { $nav .= "<a class='linkOverDark' href='graph_templates.php?filter=" . $_REQUEST["filter"] . "&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='graph_templates.php?filter=" . $_REQUEST["filter"] . "&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("Template Title"));

	$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 eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $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++;
		}
		/* put the nav bar on the bottom as well */
		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";
}
Exemple #21
0
function webseer_urls($header_label)
{
    global $assoc_actions, $item_rows;
    /* ================= input validation and session storage ================= */
    $filters = array('rows' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'page' => array('filter' => FILTER_VALIDATE_INT, 'default' => '1'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'associated' => array('filter' => FILTER_CALLBACK, 'default' => 'true', 'options' => array('options' => 'sanitize_search_string')));
    validate_store_request_vars($filters, 'sess_maint_ws');
    /* ================= input validation ================= */
    /* if the number of rows is -1, set it to the default */
    if (get_request_var('rows') == '-1') {
        $rows = read_config_option('num_rows_table');
    } else {
        $rows = get_request_var('rows');
    }
    ?>
	<script type='text/javascript'>
	function applyFilter() {
		strURL  = 'maint.php?tab=webseer&action=edit&id=<?php 
    print get_request_var('id');
    ?>
';
		strURL += '&rows=' + $('#rows').val();
		strURL += '&associated=' + $('#associated').is(':checked');
		strURL += '&filter=' + $('#filter').val();
		strURL += '&header=false';
		loadPageNoHeader(strURL);
	}

	function clearFilter() {
		strURL = 'maint.php?tab=webseer&action=edit&id=<?php 
    print get_request_var('id');
    ?>
&clear=true&header=false';
		loadPageNoHeader(strURL);
	}
	</script>
	<?php 
    html_start_box(__('Associated Web URL\'s ') . htmlspecialchars($header_label), '100%', '', '3', 'center', '');
    ?>
	<tr class='even'>
		<td>
		<form name='form_devices' method='post' action='maint.php?action=edit&tab=webseer'>
			<table class='filterTable'>
				<tr>
					<td>
						<?php 
    print __('Search');
    ?>
					</td>
					<td>
						<input type='text' id='filter' size='25' value='<?php 
    print htmlspecialchars(get_request_var('filter'));
    ?>
' onChange='applyFilter()'>
					</td>
					<td>
						<?php 
    print __('Rules');
    ?>
					</td>
					<td>
						<select id='rows' onChange='applyFilter()'>
							<option value='-1'<?php 
    if (get_request_var('rows') == '-1') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('Default');
    ?>
</option>
							<?php 
    if (sizeof($item_rows) > 0) {
        foreach ($item_rows as $key => $value) {
            print "<option value='" . $key . "'";
            if (get_request_var('rows') == $key) {
                print ' selected';
            }
            print '>' . htmlspecialchars($value) . "</option>\n";
        }
    }
    ?>
						</select>
					</td>
					<td>
						<input type='checkbox' id='associated' onChange='applyFilter()' <?php 
    print get_request_var('associated') == 'true' || get_request_var('associated') == 'on' ? 'checked' : '';
    ?>
>
					</td>
					<td>
						<label for='associated'><?php 
    print __('Associated');
    ?>
</label>
					</td>
					<td>
						<input type='button' value='<?php 
    print __('Go');
    ?>
' onClick='applyFilter()' title='<?php 
    print __('Set/Refresh Filters');
    ?>
'>
					</td>
					<td>
						<input type='button' name='clear' value='<?php 
    print __('Clear');
    ?>
' onClick='clearFilter()' title='<?php 
    print __('Clear Filters');
    ?>
'>
					</td>
				</tr>
			</table>
			<input type='hidden' name='page' value='<?php 
    print get_request_var('page');
    ?>
'>
			<input type='hidden' name='id' value='<?php 
    print get_request_var('id');
    ?>
'>
		</form>
		</td>
	</tr>
	<?php 
    html_end_box();
    /* form the 'where' clause for our main sql query */
    if (strlen(get_request_var('filter'))) {
        $sql_where = "WHERE ((u.url LIKE '%" . get_request_var('filter') . "%') \n\t\t\tOR (u.display_name LIKE '%" . get_request_var('filter') . "%') \n\t\t\tOR (u.ip LIKE '%" . get_request_var('filter') . "%'))";
    } else {
        $sql_where = '';
    }
    if (get_request_var('associated') == 'false') {
        $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' (pmh.type=2 OR pmh.type IS NULL)';
    } else {
        $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' pmh.type=2 AND pmh.schedule=' . get_request_var('id');
    }
    $total_rows = db_fetch_cell("SELECT\n\t\tCOUNT(*)\n\t\tFROM plugin_webseer_urls AS u\n\t\tLEFT JOIN plugin_maint_hosts AS pmh\n\t\tON u.id=pmh.host\n\t\t{$sql_where}");
    $sql_query = "SELECT u.*, pmh.host AS associated, pmh.type AS maint_type\n\t\tFROM plugin_webseer_urls AS u\n\t\tLEFT JOIN plugin_maint_hosts AS pmh\n\t\tON u.id=pmh.host\n\t\t{$sql_where} \n\t\tLIMIT " . $rows * (get_request_var('page') - 1) . ',' . $rows;
    $urls = db_fetch_assoc($sql_query);
    $nav = html_nav_bar('notify_lists.php?action=edit&id=' . get_request_var('id'), MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 13, __('Lists'), 'page', 'main');
    form_start('maint.php', 'chk');
    print $nav;
    html_start_box('', '100%', '', '3', 'center', '');
    $display_text = array(__('Description'), __('ID'), __('Associated Schedules'), __('Enabled'), __('Hostname'), __('URL'));
    html_header_checkbox($display_text);
    if (sizeof($urls)) {
        foreach ($urls as $url) {
            form_alternate_row('line' . $url['id']);
            form_selectable_cell(strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($url['display_name'])) : htmlspecialchars($url['display_name']), $url['id'], 250);
            form_selectable_cell(round($url['id'], 2), $url['id']);
            if ($url['associated'] != '' && $url['maint_type'] == '2') {
                form_selectable_cell('<span class="deviceUp">' . __('Current Schedule') . '</span>', $url['id']);
            } else {
                if (sizeof($lists = db_fetch_assoc('SELECT name FROM plugin_maint_schedules INNER JOIN plugin_maint_hosts ON plugin_maint_schedules.id=plugin_maint_hosts.schedule WHERE type=2 AND host=' . $url['id']))) {
                    $names = '';
                    foreach ($lists['name'] as $name) {
                        $names .= (strlen($names) ? ', ' : '') . "<span class='deviceRecovering'>{$name}</span>";
                    }
                    form_selectable_cell($names, $url['id']);
                } else {
                    form_selectable_cell('<span class="deviceUnknown">' . __('No Schedules') . '</span>', $url['id']);
                }
            }
            form_selectable_cell($url['enabled'] == 'on' ? __('Enabled') : __('Disabled'), $url['id']);
            if (empty($url['ip'])) {
                $url['ip'] = __('USING DNS');
            }
            form_selectable_cell(strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", '<i>' . htmlspecialchars($url['ip'])) . '</i>' : '<i>' . htmlspecialchars($url['ip']) . '</i>', $url['id']);
            form_selectable_cell(strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($url['url'])) : htmlspecialchars($url['url']), $url['id']);
            form_checkbox_cell($url['display_name'], $url['id']);
            form_end_row();
        }
    } else {
        print "<tr><td><em>" . __('No Associated WebSeer URL\'s Found') . "</em></td></tr>";
    }
    html_end_box(false);
    if (sizeof($urls)) {
        print $nav;
    }
    form_hidden_box('id', get_request_var('id'), '');
    form_hidden_box('save_webseer', '1', '');
    /* draw the dropdown containing a list of available actions for this form */
    draw_actions_dropdown($assoc_actions);
    form_end();
}
Exemple #22
0
function hosts($header_label)
{
    global $assoc_actions, $item_rows;
    /* ================= input validation and session storage ================= */
    $filters = array('rows' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'page' => array('filter' => FILTER_VALIDATE_INT, 'default' => '1'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'sort_column' => array('filter' => FILTER_CALLBACK, 'default' => 'description', 'options' => array('options' => 'sanitize_search_string')), 'sort_direction' => array('filter' => FILTER_CALLBACK, 'default' => 'ASC', 'options' => array('options' => 'sanitize_search_string')), 'associated' => array('filter' => FILTER_CALLBACK, 'default' => 'true', 'options' => array('options' => 'sanitize_search_string')), 'host_template_id' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'));
    validate_store_request_vars($filters, 'sess_nlh');
    /* ================= input validation ================= */
    /* if the number of rows is -1, set it to the default */
    if (get_request_var('rows') == -1) {
        $rows = read_config_option('num_rows_table');
    } else {
        $rows = get_request_var('rows');
    }
    html_start_box(__('Associated Devices') . ' ' . htmlspecialchars($header_label), '100%', '', '3', 'center', '');
    ?>
	<tr class='even'>
		<td>
		<form id='form_devices' method='post' action='notify_lists.php'>
			<table class='filterTable'>
				<tr>
					<td>
						<?php 
    print __('Search');
    ?>
					</td>
					<td>
						<input type='text' id='filter' size='25' value='<?php 
    print htmlspecialchars(get_request_var('filter'));
    ?>
' onChange='applyFilter()'>
					</td>
					<td>
						<?php 
    print __('Type');
    ?>
					</td>
					<td>
						<select id='host_template_id' onChange='applyFilter()'>
							<option value='-1'<?php 
    if (get_request_var('host_template_id') == '-1') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('Any');
    ?>
</option>
							<option value='0'<?php 
    if (get_request_var('host_template_id') == '0') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('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('host_template_id') == $host_template['id']) {
                print ' selected';
            }
            print '>' . htmlspecialchars($host_template['name']) . "</option>\n";
        }
    }
    ?>
						</select>
					</td>
					<td>
						<?php 
    print __('Devices');
    ?>
					</td>
					<td>
						<select id='rows' onChange='applyFilter()'>
							<option value='-1'<?php 
    if (get_request_var('rows') == '-1') {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print __('Default');
    ?>
</option>
							<?php 
    if (sizeof($item_rows) > 0) {
        foreach ($item_rows as $key => $value) {
            print "<option value='" . $key . "'";
            if (get_request_var('rows') == $key) {
                print ' selected';
            }
            print '>' . htmlspecialchars($value) . "</option>\n";
        }
    }
    ?>
						</select>
					</td>
					<td>
						<input type='checkbox' id='associated' onChange='applyFilter()' <?php 
    print get_request_var('associated') == 'true' || get_request_var('associated') == 'on' ? 'checked' : '';
    ?>
>
					</td>
					<td>
						<label for='associated'><?php 
    print __('Associated');
    ?>
</label>
					</td>
					<td>
						<input type='button' value='<?php 
    print __('Go');
    ?>
' onClick='applyFilter()' title='<?php 
    print __('Set/Refresh Filters');
    ?>
'>
					</td>
					<td nowrap>
						<input type='button' name='clearf' value='<?php 
    print __('Clear');
    ?>
' onClick='clearFilter()' title='<?php 
    print __('Clear Filters');
    ?>
'>
					</td>
				</tr>
			</table>
			<input type='hidden' id='page' value='<?php 
    print get_filter_request_var('page');
    ?>
'>
			<input type='hidden' name='action' value='edit'>
			<input type='hidden' id='id' value='<?php 
    print get_filter_request_var('id');
    ?>
'>
		</form>
		<script type='text/javascript'>

		function applyFilter() {
			strURL  = '?header=false&action=edit&id=<?php 
    print get_request_var('id');
    ?>
'
			strURL += '&rows=' + $('#rows').val();
			strURL += '&host_template_id=' + $('#host_template_id').val();
			strURL += '&associated=' + $('#associated').is(':checked');
			strURL += '&filter=' + $('#filter').val();
			loadPageNoHeader(strURL);
		}

		function clearFilter() {
			strURL = 'notify_lists.php?header=false&action=edit&id=<?php 
    print get_request_var('id');
    ?>
&clearf=true'
			loadPageNoHeader(strURL);
		}

		$(function() {
			$('#form_devices').submit(function(event) {
				event.preventDefault();
				applyFilter();
			});
		});
	
		</script>
		</td>
	</tr>
	<?php 
    html_end_box();
    /* form the 'where' clause for our main sql query */
    if (strlen(get_request_var('filter'))) {
        $sql_where = "WHERE (host.hostname LIKE '%" . get_request_var('filter') . "%' OR host.description LIKE '%" . get_request_var('filter') . "%')";
    } else {
        $sql_where = '';
    }
    if (get_request_var('host_template_id') == '-1') {
        /* Show all items */
    } elseif (get_request_var('host_template_id') == '0') {
        $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' host.host_template_id=0';
    } elseif (!isempty_request_var('host_template_id')) {
        $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' host.host_template_id=' . get_request_var('host_template_id');
    }
    if (get_request_var('associated') == 'false') {
        /* Show all items */
    } else {
        $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' (host.thold_send_email>1 AND host.thold_host_email=' . get_request_var('id') . ')';
    }
    $total_rows = db_fetch_cell("select\n\t\tCOUNT(host.id)\n\t\tfrom host\n\t\t{$sql_where}");
    $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 {$sql_where}\n\t\tLIMIT " . $rows * (get_request_var('page') - 1) . ',' . $rows;
    $hosts = db_fetch_assoc($sql_query);
    $nav = html_nav_bar('notify_lists.php?action=edit&id=' . get_request_var('id'), MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 10, __('Devices'), 'page', 'main');
    form_start('notify_lists.php', 'chk');
    print $nav;
    html_start_box('', '100%', '', '3', 'center', '');
    $display_text = array(__('Description'), __('ID'), __('Associated Lists'), __('Graphs'), __('Data Sources'), __('Status'), __('Hostname'));
    html_header_checkbox($display_text);
    if (sizeof($hosts)) {
        foreach ($hosts as $host) {
            form_alternate_row('line' . $host['id'], true);
            form_selectable_cell(filter_value($host['description'], get_request_var('filter')), $host['id'], 250);
            form_selectable_cell(round($host['id'], 2), $host['id']);
            if ($host['thold_send_email'] == 0) {
                form_selectable_cell('<span style="color:blue;font-weight:bold;">' . __('Disabled') . '</span>', $host['id']);
            } elseif ($host['thold_send_email'] == 1) {
                form_selectable_cell('<span style="color:purple;font-weight:bold;">' . __('Global List') . '</span>', $host['id']);
            } elseif ($host['thold_host_email'] == get_request_var('id')) {
                if ($host['thold_send_email'] == 2) {
                    form_selectable_cell('<span style="color:green;font-weight:bold;">' . __('Current List Only') . '</span>', $host['id']);
                } else {
                    form_selectable_cell('<span style="color:green;font-weight:bold;">' . __('Current and Global List(s)') . '</span>', $host['id']);
                }
            } elseif ($host['thold_host_email'] == '0') {
                form_selectable_cell('<span style="color:green;font-weight:bold;">' . __('None') . '</span>', $host['id']);
            } else {
                form_selectable_cell('<span style="color:red;font-weight:bold;">' . db_fetch_cell('SELECT name FROM plugin_notification_lists WHERE id=' . get_request_var('id')) . '</span>', $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(filter_value($host['hostname'], get_request_var('filter')), $host['id']);
            form_checkbox_cell($host['description'], $host['id']);
            form_end_row();
        }
    } else {
        print '<tr><td><em>' . __('No Associated Devices Found') . '</em></td></tr>';
    }
    html_end_box(false);
    if (sizeof($hosts)) {
        print $nav;
    }
    form_hidden_box('tab', 'hosts', '');
    form_hidden_box('id', get_request_var('id'), '');
    form_hidden_box('save_associate', '1', '');
    draw_actions_dropdown($assoc_actions);
    form_end();
}
Exemple #23
0
function package() {
	$menu_items = array(
		"remove" => "Remove",
		"duplicate" => "Duplicate"
		);

	$filter_array = array();

	/* search field: filter (searches package name) */
	if (isset_get_var("search_filter")) {
		$filter_array["name"] = get_get_var("search_filter");
	}

	/* get a list of all packages on this page */
	$packages = api_package_list($filter_array);

	form_start("packages.php");

	$box_id = "1";
	html_start_box("<strong>" . _("Template Packages") . "</strong>", "packages.php?action=new");
	html_header_checkbox(array(_("Name"), _("Author"), _("Category")), $box_id);

	$i = 0;
	if (sizeof($packages) > 0) {
		foreach ($packages as $package) {
			?>
			<tr class="item" id="box-<?php echo $box_id;?>-row-<?php echo $package["id"];?>" onClick="display_row_select('<?php echo $box_id;?>',document.forms[0],'box-<?php echo $box_id;?>-row-<?php echo $package["id"];?>', 'box-<?php echo $box_id;?>-chk-<?php echo $package["id"];?>')" onMouseOver="display_row_hover('box-<?php echo $box_id;?>-row-<?php echo $package["id"];?>')" onMouseOut="display_row_clear('box-<?php echo $box_id;?>-row-<?php echo $package["id"];?>')">
				<td class="title">
					<a onClick="display_row_block('box-<?php echo $box_id;?>-row-<?php echo $package["id"];?>')" href="packages.php?action=view&id=<?php echo $package["id"];?>"><span id="box-<?php echo $box_id;?>-text-<?php echo $package["id"];?>"><?php echo html_highlight_words(get_get_var("search_filter"), $package["name"]);?></span></a>
				</td>
				<td>
					Ian Berry
				</td>
				<td>
					<?php echo $package["category"];?>
				</td>
				<td class="checkbox" align="center">
					<input type='checkbox' name='box-<?php echo $box_id;?>-chk-<?php echo $package["id"];?>' id='box-<?php echo $box_id;?>-chk-<?php echo $package["id"];?>' title="<?php echo $package["name"];?>">
				</td>
			</tr>
			<?php
		}
	}else{
		?>
		<tr class="empty">
			<td colspan="6">
				No template packages found.
			</td>
		</tr>
		<?php
	}
	html_box_toolbar_draw($box_id, "0", "3", HTML_BOX_SEARCH_NONE);
	html_end_box(false);

	//html_box_actions_menu_draw($box_id, "0", $menu_items);
	html_box_actions_area_create($box_id);

	form_hidden_box("action_post", "package_list");
	form_end();

	echo "<br />\n";

	form_start("packages.php", "import_package", true);

	html_start_box("<strong>" . _("Import Package") . "</strong>");

	_package_import_field__file("import_package_file");
	_package_import_field__text("import_package_text");

	?>
	<tr>
		<td style="border-top: 1px solid #b5b5b5; padding: 1px;" colspan="2">
			<table width="100%" cellpadding="2" cellspacing="0">
				<tr>
					<td align="right">
						&nbsp;<input type="image" src="<?php echo html_get_theme_images_path('button_import.gif');?>" alt="<?php echo _('Import');?>" name="package_import" align="absmiddle">
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<?php

	html_end_box();

	form_hidden_box("action", "save");
	form_hidden_box("action_post", "package_import");
	form_end();

	//print_a(htmlspecialchars(package_export("1")));

	?>

	<script language="JavaScript">
	<!--
	function action_area_handle_type(box_id, type, parent_div, parent_form) {
		if (type == 'remove') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to remove these data templates?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Remove Data Template');
			action_area_update_submit_caption(box_id, 'Remove');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'duplicate') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to duplicate these data templates?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));
			parent_div.appendChild(action_area_generate_input('text', 'box-' + box_id + '-action-area-txt1', ''));

			action_area_update_header_caption(box_id, 'Duplicate Data Templates');
			action_area_update_submit_caption(box_id, 'Duplicate');
			action_area_update_selected_rows(box_id, parent_form);
		}
	}
	-->
	</script>

	<?php
}
Exemple #24
0
function user_group_graph_perms_edit($tab, $header_label)
{
    global $config, $assoc_actions;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request('id'));
    /* ==================================================== */
    $policy_array = array(1 => 'Allow', 2 => 'Deny');
    if (!empty($_REQUEST['id'])) {
        $policy = db_fetch_row_prepared('SELECT policy_graphs, policy_trees, policy_hosts, policy_graph_templates FROM user_auth_group WHERE id = ?', array(get_request_var_request('id')));
    }
    switch ($tab) {
        case 'permsg':
            process_graph_request_vars();
            graph_filter($header_label);
            /* print checkbox form for validation */
            print "<form name='policy' method='post' action='user_group_admin.php'>\n";
            /* box: device permissions */
            html_start_box('<strong>Default Graph Policy</strong>', '100%', '', '3', 'center', '');
            ?>
		<tr class='odd'>
			<td><table cellpadding="2" cellspacing="0"><tr>
			<td style="white-space:nowrap;" width="120">Default Graph policy for this User Group</td>
			<td width="10"> 
				<?php 
            form_dropdown('policy_graphs', $policy_array, '', '', $policy['policy_graphs'], '', '');
            ?>
			</td>
			<td>
				<input type="submit" name="update_policy" value="Update">
				<input type="hidden" name="tab" value="<?php 
            print $tab;
            ?>
">
				<input type="hidden" name="id" value="<?php 
            print get_request_var_request('id');
            ?>
">
			</td>
			</tr></table></td>
		</tr>
		<?php 
            html_end_box();
            print "</form>\n";
            /* if the number of rows is -1, set it to the default */
            if ($_REQUEST['rows'] == -1) {
                $rows = read_config_option('num_rows_table');
            } else {
                $rows = $_REQUEST['rows'];
            }
            /* form the 'where' clause for our main sql query */
            if (strlen(get_request_var_request('filter'))) {
                $sql_where = "WHERE (gtg.title_cache LIKE '%%" . get_request_var_request('filter') . "%%' AND gtg.local_graph_id>0)";
            } else {
                $sql_where = 'WHERE (gtg.local_graph_id>0)';
            }
            if (get_request_var_request('graph_template_id') == '-1') {
                /* Show all items */
            } elseif (get_request_var_request('graph_template_id') == '0') {
                $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' gtg.graph_template_id=0';
            } elseif (!empty($_REQUEST['graph_template_id'])) {
                $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' gtg.graph_template_id=' . get_request_var_request('graph_template_id');
            }
            if (get_request_var_request('associated') == 'false') {
                /* Show all items */
            } else {
                $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' (user_auth_group_perms.type=1 AND user_auth_group_perms.group_id=' . get_request_var_request('id', 0) . ')';
            }
            /* print checkbox form for validation */
            print "<form name='chk' method='post' action='" . htmlspecialchars('user_group_admin.php?action=edit&tab=permsg&id=' . get_request_var_request('id')) . "'>\n";
            html_start_box('', '100%', '', '3', 'center', '');
            $total_rows = db_fetch_cell("select\n\t\t\tCOUNT(gtg.id)\n\t\t\tFROM graph_templates_graph AS gtg\n\t\t\tLEFT JOIN user_auth_group_perms \n\t\t\tON (gtg.local_graph_id = user_auth_group_perms.item_id AND user_auth_group_perms.type = 1)\n\t\t\t{$sql_where}");
            $sql_query = "SELECT gtg.local_graph_id, gtg.title_cache, user_auth_group_perms.group_id\n\t\t\tFROM graph_templates_graph AS gtg\n\t\t\tLEFT JOIN user_auth_group_perms \n\t\t\tON (gtg.local_graph_id=user_auth_group_perms.item_id AND user_auth_group_perms.type=1)\n\t\t\t{$sql_where} \n\t\t\tORDER BY title_cache\n\t\t\tLIMIT " . $rows * (get_request_var_request('page') - 1) . ',' . $rows;
            $graphs = db_fetch_assoc($sql_query);
            $nav = html_nav_bar('user_group_admin.php?action=edit&tab=permsg&id=' . get_request_var_request('id'), MAX_DISPLAY_PAGES, get_request_var_request('page'), $rows, $total_rows, 7, 'Graphs', 'page', 'main');
            print $nav;
            $display_text = array('Graph Title', 'ID', 'Effective Policy');
            html_header_checkbox($display_text, false);
            if (sizeof($graphs)) {
                foreach ($graphs as $g) {
                    form_alternate_row('line' . $g['local_graph_id'], true);
                    form_selectable_cell(strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($g['title_cache'])) : htmlspecialchars($g['title_cache']), $g['local_graph_id'], 250);
                    form_selectable_cell($g['local_graph_id'], $g['local_graph_id']);
                    if (empty($g['group_id']) || $g['group_id'] == NULL) {
                        if ($policy['policy_graphs'] == 1) {
                            form_selectable_cell('<span style="color:green;font-weight:bold;">Access Granted</span>', $g['local_graph_id']);
                        } else {
                            form_selectable_cell('<span style="color:red;font-weight:bold;">Access Restricted</span>', $g['local_graph_id']);
                        }
                    } else {
                        if ($policy['policy_graphs'] == 1) {
                            form_selectable_cell('<span style="color:red;font-weight:bold;">Access Restricted</span>', $g['local_graph_id']);
                        } else {
                            form_selectable_cell('<span style="color:green;font-weight:bold;">Access Granted</span>', $g['local_graph_id']);
                        }
                    }
                    form_checkbox_cell($g['title_cache'], $g['local_graph_id']);
                    form_end_row();
                }
                /* put the nav bar on the bottom as well */
                print $nav;
            } else {
                print '<tr><td><em>No Matching Graphs Found</em></td></tr>';
            }
            html_end_box(false);
            form_hidden_box('action', 'edit', '');
            form_hidden_box('tab', $tab, '');
            form_hidden_box('id', get_request_var_request('id'), '');
            form_hidden_box('associate_graph', '1', '');
            if ($policy['policy_graphs'] == 1) {
                $assoc_actions = array(1 => 'Revoke Access', 2 => 'Grant Access');
            } else {
                $assoc_actions = array(1 => 'Grant Access', 2 => 'Revoke Access');
            }
            /* draw the dropdown containing a list of available actions for this form */
            draw_actions_dropdown($assoc_actions);
            print '</form>';
            break;
        case 'permsd':
            process_device_request_vars();
            device_filter($header_label);
            /* print checkbox form for validation */
            print "<form name='policy' method='post' action='user_group_admin.php'>\n";
            /* box: device permissions */
            html_start_box('<strong>Default Device Policy</strong>', '100%', '', '3', 'center', '');
            ?>
		<tr class='even'>
			<td><table cellspacing="0" cellpadding="2"><tr>
			<td style="white-space:nowrap;" width="120">Default Graph policy for this User Group</td>
			<td width="10"> 
				<?php 
            form_dropdown('policy_hosts', $policy_array, '', '', $policy['policy_hosts'], '', '');
            ?>
			</td>
			<td>
				<input type="submit" name="update_policy" value="Update">
				<input type="hidden" name="tab" value="<?php 
            print $tab;
            ?>
">
				<input type="hidden" name="id" value="<?php 
            print get_request_var_request('id');
            ?>
">
			</td>
			</tr></table></td>
		</tr>
		<?php 
            html_end_box();
            print "</form>\n";
            /* if the number of rows is -1, set it to the default */
            if ($_REQUEST['rows'] == -1) {
                $rows = read_config_option('num_rows_table');
            } else {
                $rows = $_REQUEST['rows'];
            }
            /* form the 'where' clause for our main sql query */
            /* 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_template_id') == '-1') {
                /* Show all items */
            } elseif (get_request_var_request('host_template_id') == '0') {
                $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' host.host_template_id=0';
            } elseif (!empty($_REQUEST['host_template_id'])) {
                $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' host.host_template_id=' . get_request_var_request('host_template_id');
            }
            if (get_request_var_request('associated') == 'false') {
                /* Show all items */
            } else {
                $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' user_auth_group_perms.group_id=' . get_request_var_request('id', 0);
            }
            /* print checkbox form for validation */
            print "<form name='chk' method='post' action='" . htmlspecialchars('user_group_admin.php?action=edit&tab=permsd&id=' . get_request_var_request('id')) . "'>\n";
            html_start_box('', '100%', '', '3', 'center', '');
            $total_rows = db_fetch_cell("SELECT\n\t\t\tCOUNT(host.id)\n\t\t\tFROM host\n\t\t\tLEFT JOIN user_auth_group_perms \n\t\t\tON (host.id = user_auth_group_perms.item_id AND user_auth_group_perms.type = 3)\n\t\t\t{$sql_where}");
            $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 host.*, user_auth_group_perms.group_id\n\t\t\tFROM host \n\t\t\tLEFT JOIN user_auth_group_perms \n\t\t\tON (host.id=user_auth_group_perms.item_id AND user_auth_group_perms.type=3)\n\t\t\t{$sql_where} \n\t\t\tORDER BY description\n\t\t\tLIMIT " . $rows * (get_request_var_request('page') - 1) . ',' . $rows;
            $hosts = db_fetch_assoc($sql_query);
            $nav = html_nav_bar('user_group_admin.php?action=edit&tab=permsd&id=' . get_request_var_request('id'), MAX_DISPLAY_PAGES, get_request_var_request('page'), $rows, $total_rows, 11, 'Devices', 'page', 'main');
            print $nav;
            $display_text = array('Description', 'ID', 'Effective Policy', 'Graphs', 'Data Sources', 'Status', 'Hostname');
            html_header_checkbox($display_text, false);
            if (sizeof($hosts)) {
                foreach ($hosts as $host) {
                    form_alternate_row('line' . $host['id'], true);
                    form_selectable_cell(strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($host['description'])) : htmlspecialchars($host['description']), $host['id'], 250);
                    form_selectable_cell(round($host['id'], 2), $host['id']);
                    if (empty($host['group_id']) || $host['group_id'] == NULL) {
                        if ($policy['policy_hosts'] == 1) {
                            form_selectable_cell('<span style="color:green;font-weight:bold;">Access Granted</span>', $host['id']);
                        } else {
                            form_selectable_cell('<span style="color:red;font-weight:bold;">Access Restricted</span>', $host['id']);
                        }
                    } else {
                        if ($policy['policy_hosts'] == 1) {
                            form_selectable_cell('<span style="color:red;font-weight:bold;">Access Restricted</span>', $host['id']);
                        } else {
                            form_selectable_cell('<span style="color:green;font-weight:bold;">Access Granted</span>', $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(strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($host['hostname'])) : htmlspecialchars($host['hostname']), $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 Matching Devices Found</em></td></tr>';
            }
            html_end_box(false);
            form_hidden_box('action', 'edit', '');
            form_hidden_box('tab', $tab, '');
            form_hidden_box('id', get_request_var_request('id'), '');
            form_hidden_box('associate_host', '1', '');
            if ($policy['policy_hosts'] == 1) {
                $assoc_actions = array(1 => 'Revoke Access', 2 => 'Grant Access');
            } else {
                $assoc_actions = array(1 => 'Grant Access', 2 => 'Revoke Access');
            }
            /* draw the dropdown containing a list of available actions for this form */
            draw_actions_dropdown($assoc_actions);
            print "</form>\n";
            break;
        case 'permste':
            process_template_request_vars();
            template_filter($header_label);
            /* print checkbox form for validation */
            print "<form name='policy' method='post' action='user_group_admin.php'>\n";
            /* box: device permissions */
            html_start_box('<strong>Default Graph Template Policy</strong>', '100%', '', '3', 'center', '');
            ?>
		<tr class='even'>
			<td><table cellspacing="0" cellpadding="2"><tr>
			<td style="white-space:nowrap;" width="120">Default Graph Template Template policy for this User Group</td>
			<td width="10"> 
				<?php 
            form_dropdown('policy_graph_templates', $policy_array, '', '', $policy['policy_graph_templates'], '', '');
            ?>
			</td>
			<td>
				<input type="submit" name="update_policy" value="Update">
				<input type="hidden" name="tab" value="<?php 
            print $tab;
            ?>
">
				<input type="hidden" name="id" value="<?php 
            print get_request_var_request('id');
            ?>
">
			</td>
			</tr></table></td>
		</tr>
		<?php 
            html_end_box();
            print "</form>\n";
            /* if the number of rows is -1, set it to the default */
            if ($_REQUEST['rows'] == -1) {
                $rows = read_config_option('num_rows_table');
            } else {
                $rows = $_REQUEST['rows'];
            }
            /* form the 'where' clause for our main sql query */
            /* form the 'where' clause for our main sql query */
            if (strlen(get_request_var_request('filter'))) {
                $sql_where = "WHERE (gt.name LIKE '%%" . get_request_var_request('filter') . "%%')";
            } else {
                $sql_where = '';
            }
            if (get_request_var_request('associated') == 'false') {
                /* Show all items */
            } else {
                $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' (user_auth_group_perms.type=4 AND user_auth_group_perms.group_id=' . get_request_var_request('id', 0) . ')';
            }
            /* print checkbox form for validation */
            print "<form name='chk' method='post' action='" . htmlspecialchars('user_group_admin.php?action=edit&tab=permste&id=' . get_request_var_request('id')) . "'>\n";
            html_start_box('', '100%', '', '3', 'center', '');
            $total_rows = db_fetch_cell("SELECT\n\t\t\tCOUNT(gt.id)\n\t\t\tFROM graph_templates AS gt\n\t\t\tINNER JOIN graph_local AS gl\n\t\t\tON gt.id = gl.graph_template_id\n\t\t\tLEFT JOIN user_auth_group_perms \n\t\t\tON (gt.id = user_auth_group_perms.item_id AND user_auth_group_perms.type = 4)\n\t\t\t{$sql_where}\n\t\t\tGROUP BY gl.graph_template_id");
            $sql_query = "SELECT gt.id, gt.name, count(*) AS totals, user_auth_group_perms.group_id\n\t\t\tFROM graph_templates AS gt\n\t\t\tINNER JOIN graph_local AS gl\n\t\t\tON gt.id = gl.graph_template_id\n\t\t\tLEFT JOIN user_auth_group_perms \n\t\t\tON (gt.id = user_auth_group_perms.item_id AND user_auth_group_perms.type = 4)\n\t\t\t{$sql_where} \n\t\t\tGROUP BY gl.graph_template_id\n\t\t\tORDER BY name\n\t\t\tLIMIT " . $rows * (get_request_var_request('page') - 1) . ',' . $rows;
            $graphs = db_fetch_assoc($sql_query);
            $nav = html_nav_bar('user_group_admin.php?action=edit&tab=permste&id=' . get_request_var_request('id'), MAX_DISPLAY_PAGES, get_request_var_request('page'), $rows, $total_rows, 11, 'Graph Templates', 'page', 'main');
            print $nav;
            $display_text = array('Template Name', 'ID', 'Effective Policy', 'Total Graphs');
            html_header_checkbox($display_text, false);
            if (sizeof($graphs)) {
                foreach ($graphs as $g) {
                    form_alternate_row('line' . $g['id'], true);
                    form_selectable_cell(strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($g['name'])) : htmlspecialchars($g['name']), $g['id'], 250);
                    form_selectable_cell($g['id'], $g['id']);
                    if (empty($g['group_id']) || $g['group_id'] == NULL) {
                        if ($policy['policy_graph_templates'] == 1) {
                            form_selectable_cell('<span style="color:green;font-weight:bold;">Access Granted</span>', $g['id']);
                        } else {
                            form_selectable_cell('<span style="color:red;font-weight:bold;">Access Restricted</span>', $g['id']);
                        }
                    } else {
                        if ($policy['policy_graph_templates'] == 1) {
                            form_selectable_cell('<span style="color:red;font-weight:bold;">Access Restricted</span>', $g['id']);
                        } else {
                            form_selectable_cell('<span style="color:green;font-weight:bold;">Access Granted</span>', $g['id']);
                        }
                    }
                    form_selectable_cell($g['totals'], $g['id']);
                    form_checkbox_cell($g['name'], $g['id']);
                    form_end_row();
                }
                /* put the nav bar on the bottom as well */
                print $nav;
            } else {
                print '<tr><td><em>No Matching Graph Templates Found</em></td></tr>';
            }
            html_end_box(false);
            form_hidden_box('action', 'edit', '');
            form_hidden_box('tab', $tab, '');
            form_hidden_box('id', get_request_var_request('id'), '');
            form_hidden_box('associate_template', '1', '');
            if ($policy['policy_graph_templates'] == 1) {
                $assoc_actions = array(1 => 'Revoke Access', 2 => 'Grant Access');
            } else {
                $assoc_actions = array(1 => 'Grant Access', 2 => 'Revoke Access');
            }
            /* draw the dropdown containing a list of available actions for this form */
            draw_actions_dropdown($assoc_actions);
            print '</form>';
            break;
        case 'permstr':
            process_tree_request_vars();
            tree_filter($header_label);
            /* print checkbox form for validation */
            print "<form name='policy' method='post' action='user_group_admin.php'>\n";
            /* box: device permissions */
            html_start_box('<strong>Default Tree Policy</strong>', '100%', '', '3', 'center', '');
            ?>
		<tr class='even'>
			<td><table cellspacing="0" cellpadding="2"><tr>
			<td style="white-space:nowrap;" width="120">Default Tree policy for this User Group</td>
			<td width="10"> 
				<?php 
            form_dropdown('policy_trees', $policy_array, '', '', $policy['policy_trees'], '', '');
            ?>
			</td>
			<td>
				<input type="submit" name="update_policy" value="Update">
				<input type="hidden" name="tab" value="<?php 
            print $tab;
            ?>
">
				<input type="hidden" name="id" value="<?php 
            print get_request_var_request('id');
            ?>
">
			</td>
			</tr></table></td>
		</tr>
		<?php 
            html_end_box();
            print "</form>\n";
            /* if the number of rows is -1, set it to the default */
            if ($_REQUEST['rows'] == -1) {
                $rows = read_config_option('num_rows_table');
            } else {
                $rows = $_REQUEST['rows'];
            }
            /* form the 'where' clause for our main sql query */
            if (strlen(get_request_var_request('filter'))) {
                $sql_where = "WHERE (gt.name LIKE '%%" . get_request_var_request('filter') . "%%')";
            } else {
                $sql_where = '';
            }
            if (get_request_var_request('associated') == 'false') {
                /* Show all items */
            } else {
                $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' (user_auth_group_perms.type=2 AND user_auth_group_perms.group_id=' . get_request_var_request('id', 0) . ')';
            }
            /* print checkbox form for validation */
            print "<form name='chk' method='post' action='" . htmlspecialchars('user_group_admin.php?action=edit&tab=permstr&id=' . get_request_var_request('id')) . "'>\n";
            html_start_box('', '100%', '', '3', 'center', '');
            $total_rows = db_fetch_cell("SELECT\n\t\t\tCOUNT(gt.id)\n\t\t\tFROM graph_tree AS gt\n\t\t\tLEFT JOIN user_auth_group_perms \n\t\t\tON (gt.id = user_auth_group_perms.item_id AND user_auth_group_perms.type = 2)\n\t\t\t{$sql_where}");
            $sql_query = "SELECT gt.id, gt.name, user_auth_group_perms.group_id\n\t\t\tFROM graph_tree AS gt\n\t\t\tLEFT JOIN user_auth_group_perms \n\t\t\tON (gt.id = user_auth_group_perms.item_id AND user_auth_group_perms.type = 2)\n\t\t\t{$sql_where} \n\t\t\tORDER BY name\n\t\t\tLIMIT " . $rows * (get_request_var_request('page') - 1) . ',' . $rows;
            $trees = db_fetch_assoc($sql_query);
            $nav = html_nav_bar('user_group_admin.php?action=edit&tab=permstr&id=' . get_request_var_request('id'), MAX_DISPLAY_PAGES, get_request_var_request('page'), $rows, $total_rows, 11, 'Trees', 'page', 'main');
            print $nav;
            $display_text = array('Tree Name', 'ID', 'Effective Policy');
            html_header_checkbox($display_text, false);
            if (sizeof($trees)) {
                foreach ($trees as $t) {
                    form_alternate_row('line' . $t['id'], true);
                    form_selectable_cell(strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($t['name'])) : htmlspecialchars($t['name']), $t['id'], 250);
                    form_selectable_cell($t['id'], $t['id']);
                    if (empty($t['group_id']) || $t['group_id'] == NULL) {
                        if ($policy['policy_trees'] == 1) {
                            form_selectable_cell('<span style="color:green;font-weight:bold;">Access Granted</span>', $t['id']);
                        } else {
                            form_selectable_cell('<span style="color:red;font-weight:bold;">Access Restricted</span>', $t['id']);
                        }
                    } else {
                        if ($policy['policy_trees'] == 1) {
                            form_selectable_cell('<span style="color:red;font-weight:bold;">Access Restricted</span>', $t['id']);
                        } else {
                            form_selectable_cell('<span style="color:green;font-weight:bold;">Access Granted</span>', $t['id']);
                        }
                    }
                    form_checkbox_cell($t['name'], $t['id']);
                    form_end_row();
                }
                /* put the nav bar on the bottom as well */
                print $nav;
            } else {
                print '<tr><td><em>No Matching Trees Found</em></td></tr>';
            }
            html_end_box(false);
            form_hidden_box('action', 'edit', '');
            form_hidden_box('tab', $tab, '');
            form_hidden_box('id', get_request_var_request('id'), '');
            form_hidden_box('associate_tree', '1', '');
            if ($policy['policy_graph_templates'] == 1) {
                $assoc_actions = array(1 => 'Revoke Access', 2 => 'Grant Access');
            } else {
                $assoc_actions = array(1 => 'Grant Access', 2 => 'Revoke Access');
            }
            /* draw the dropdown containing a list of available actions for this form */
            draw_actions_dropdown($assoc_actions);
            print '</form>';
            break;
    }
}