Exemplo n.º 1
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
}
Exemplo n.º 2
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 
}
Exemplo n.º 3
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 
}
Exemplo n.º 4
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 
}
Exemplo n.º 5
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";
}
Exemplo n.º 6
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 
}
Exemplo n.º 7
0
function cdef_edit() {
	$_cdef_preset_id = get_get_var_number("id");

	if (empty($_cdef_preset_id)) {
		$header_label = "[new]";
	}else{
		$cdef = api_data_preset_cdef_get($_cdef_preset_id);

		$header_label = "[edit: " . $cdef["name"] . "]";
	}

	form_start("presets_cdef.php", "form_cdef");

	/* ==================== Box: RRAs ==================== */

	html_start_box("<strong>" . _("CDEF Presets") . "</strong> $header_label");
	_data_preset_cdef__name("name", (isset($cdef["name"]) ? $cdef["name"] : ""), (isset($cdef["id"]) ? $cdef["id"] : "0"));
	_data_preset_cdef__cdef_string("cdef_string", (isset($cdef["cdef_string"]) ? $cdef["cdef_string"] : ""), (isset($cdef["id"]) ? $cdef["id"] : "0"));
	html_end_box();

	html_box_actions_area_create("1");

	form_hidden_box("preset_cdef_id", $_cdef_preset_id);
	form_hidden_box("action_post", "cdef_preset_edit");

	form_save_button("presets.php?action=view_cdef", "save_cdef");

	?>

	<script language="JavaScript">
	<!--
	function action_area_handle_type(box_id, type, parent_div, parent_form) {
		if (type == 'editor') {
			parent_div.appendChild(document.createTextNode('The dropdown boxes below provide quick access to the variables, mathematical operators, and functions that can be used in CDEF strings.'));

			action_area_update_header_caption(box_id, 'CDEF String Editor');

			_elm_function_input = action_area_generate_select('box-' + box_id + '-cdef_function');
			<?php echo get_js_dropdown_code('_elm_function_input', api_data_preset_cdef_function_list(), "");?>

			_elm_operator_input = action_area_generate_select('box-' + box_id + '-cdef_operator');
			<?php echo get_js_dropdown_code('_elm_operator_input', api_data_preset_cdef_operator_list(), "");?>

			_elm_variable_input = action_area_generate_select('box-' + box_id + '-cdef_variable');
			<?php echo get_js_dropdown_code('_elm_variable_input', api_data_preset_cdef_variable_list(), "");?>

			_elm_dt_container = document.createElement('div');
			_elm_dt_container.style.paddingTop = '8px';
			_elm_dt_container.style.paddingBottom = '3px';
			_elm_dt_container.style.marginLeft = '1px';
			_elm_dt_container.style.width = '550px';

			_elm_dt_table_fld = document.createElement('table');

			_elm_dt_table_fld.appendChild(action_area_generate_insert_row('Functions', _elm_function_input, 'javascript:insert_cdef_variable_name(\'box-' + box_id + '-cdef_function\')'));
			_elm_dt_table_fld.appendChild(action_area_generate_insert_row('Operators', _elm_operator_input, 'javascript:insert_cdef_variable_name(\'box-' + box_id + '-cdef_operator\')'));
			_elm_dt_table_fld.appendChild(action_area_generate_insert_row('Variables', _elm_variable_input, 'javascript:insert_cdef_variable_value(\'box-' + box_id + '-cdef_variable\')'));

			_elm_dt_container.appendChild(_elm_dt_table_fld);

			parent_div.appendChild(_elm_dt_container);
		}
	}

	function action_area_generate_insert_row(field_caption, input, href) {
		_elm_dt_tablerow_fld = document.createElement('tr');

		_elm_dt_tablecell_txt = document.createElement('td');
		_elm_dt_tablecell_txt.style.width = '90px';
		_elm_dt_tablecell_txt.appendChild(document.createTextNode(field_caption));

		_elm_dt_tablecell_inp = document.createElement('td');
		_elm_dt_tablecell_inp.style.width = '400px';
		_elm_dt_tablecell_inp.appendChild(input);

		_elm_dt_tablecell_ins = document.createElement('td');
		_elm_dt_tablecell_ins.style.textAlign = 'right';
		_elm_dt_href_insert = document.createElement('a');
		_elm_dt_href_insert.style.fontWeight = 'bold';
		_elm_dt_href_insert.href = href;
		_elm_dt_href_insert.textContent = 'insert';
		_elm_dt_tablecell_ins.appendChild(_elm_dt_href_insert);

		_elm_dt_tablerow_fld.appendChild(_elm_dt_tablecell_txt);
		_elm_dt_tablerow_fld.appendChild(_elm_dt_tablecell_inp);
		_elm_dt_tablerow_fld.appendChild(_elm_dt_tablecell_ins);

		return _elm_dt_tablerow_fld;
	}

	function insert_cdef_variable_name(dropdown_name) {
		cdef_string = document.getElementById('cdef_string');
		dropdown = document.getElementById(dropdown_name);

		if ((cdef_string.value.length > 0) && (cdef_string.value.substr(cdef_string.value.length - 1, cdef_string.value.length) != ",")) {
			cdef_string.value += ",";
		}

		cdef_string.value += dropdown.options[dropdown.selectedIndex].text;
	}

	function insert_cdef_variable_value(dropdown_name) {
		cdef_string = document.getElementById('cdef_string');
		dropdown = document.getElementById(dropdown_name);

		if ((cdef_string.value.length > 0) && (cdef_string.value.substr(cdef_string.value.length - 1, cdef_string.value.length) != ",")) {
			cdef_string.value += ",";
		}

		cdef_string.value += dropdown.options[dropdown.selectedIndex].value;
	}
	-->
	</script>

	<?php
}
Exemplo n.º 8
0
function view_logs() {

	$current_page = get_get_var_number("page", "1");

	/* setup action menu */
	$menu_items = array(
		"purge" => "Purge",
		"export" => "Export",
		"print" => "Print"
	);


	/* search field: filter (searchs device description and hostname) */
	$filter_array = array();
	$filter_url = "";
	if (isset_get_var("search_filter")) {
		$filter_array["message"] = get_get_var("search_filter");
		$filter_url .= ($filter_url == "" ? "" : "&") . "search_filter=" . urlencode(get_get_var("search_filter"));
	}
	if (isset_get_var("search_facility")) {
		$filter_array["facility"] = get_get_var("search_facility");
		$filter_url .= ($filter_url == "" ? "" : "&") . "search_facility=" . urlencode(get_get_var("search_facility"));
	}
	if (isset_get_var("search_severity")) {
		$filter_array["severity"] = get_get_var("search_severity");
		$filter_url .= ($filter_url == "" ? "" : "&") . "search_severity=" . urlencode(get_get_var("search_severity"));
	}
	if (isset_get_var("search_poller")) {
		$filter_array["poller_id"] = get_get_var("search_poller");
		$filter_url .= ($filter_url == "" ? "" : "&") . "search_poller=" . urlencode(get_get_var("search_poller"));
	}
	if (isset_get_var("search_host")) {
		$filter_array["host_id"] = get_get_var("search_host");
		$filter_url .= ($filter_url == "" ? "" : "&") . "search_host=" . urlencode(get_get_var("search_host"));
	}
	if (isset_get_var("search_plugin")) {
		$filter_array["plugin"] = get_get_var("search_plugin");
		$filter_url .= ($filter_url == "" ? "" : "&") . "search_plugin=" . urlencode(get_get_var("search_plugin"));
	}
	if (isset_get_var("search_username")) {
		$filter_array["username"] = get_get_var("search_username");
		$filter_url .= ($filter_url == "" ? "" : "&") . "search_username="******"search_username"));
	}
	if (isset_get_var("search_source")) {
		$filter_array["source"] = get_get_var("search_source");
		$filter_url .= ($filter_url == "" ? "" : "&") . "search_source=" . urlencode(get_get_var("search_source"));
	}
	if (isset_get_var("search_start_date")) {
		$filter_array["start_date"] = get_get_var("search_start_date");
		$filter_url .= ($filter_url == "" ? "" : "&") . "search_start_date=" . urlencode(get_get_var("search_start_date"));
	}
	if (isset_get_var("search_end_date")) {
		$filter_array["end_date"] = get_get_var("search_end_date");
		$filter_url .= ($filter_url == "" ? "" : "&") . "search_end_date=" . urlencode(get_get_var("search_end_date"));
	}

	/* get log entires */
	$logs = log_list($filter_array,read_config_option("num_rows_log"),read_config_option("num_rows_log")*($current_page-1));
	$total_rows = log_get_total($filter_array);

	/* generate page list */
	$url_string = build_get_url_string(array("search_filter","search_facility","search_severity","search_poller","search_host","search_plugin","search_username","search_source","search_start_date","search_end_date"));
	$url_page_select = get_page_list($current_page, MAX_DISPLAY_PAGES, read_config_option("num_rows_log"), $total_rows, "logs.php" . $url_string . ($url_string == "" ? "?" : "&") . "page=|PAGE_NUM|");

	/* Output html */
	$action_box_id = 1;
	form_start("logs.php");

	html_start_box("<strong>" . _("Log Management") . "</strong>", "", $url_page_select);

	print "<tr>\n";
	print "<td class='log-content-header-sub-div'>" . _("Date") . "</td>\n";
	print "<td class='log-content-header-sub-div'>" . _("Facility") . "</td>\n";
	print "<td class='log-content-header-sub-div'>" . _("Severity") . "</td>\n";
	print "<td class='log-content-header-sub-div'>" . _("Poller") . "</td>\n";
	print "<td class='log-content-header-sub-div'>" . _("Host") . "</td>\n";
	print "<td class='log-content-header-sub-div'>" . _("Plugin") . "</td>\n";
	print "<td class='log-content-header-sub-div'>" . _("User") . "</td>\n";
	print "<td colspan='2' class='log-content-header-sub-div'>" . _("Source") . "</td>\n";
	print "</tr>";

	$i = 0;
	if ((is_array($logs)) && (sizeof($logs) > 0)) {
		foreach ($logs as $log) {
			?>
			<tr class="<?php echo log_get_html_css_class(log_get_severity($log["severity"])); ?>">
				<td class="log-content-row">
					<?php echo $log["logdate"]; ?>
				</td>
				<td class="log-content-row">
					<?php echo log_get_facility($log["facility"]); ?>
				</td>
				<td class="log-content-row">
					<?php echo log_get_severity($log["severity"]); ?>
				</td>
				<td class="log-content-row">
					<?php if ($log["poller_name"] == "") { echo "SYSTEM"; }else{ echo $log["poller_name"]; } ?>
				</td>
				<td class="log-content-row">
					<?php if ($log["host"] == "") { echo "SYSTEM"; }else{ echo $log["host"]; } ?>
				</td>
				<td class="log-content-row">
					<?php if ($log["plugin"] == "") { echo "N/A"; }else{ echo $log["plugin"]; } ?>
				</td>
				<td class="log-content-row">
					<?php if ($log["username"] == "") { echo "SYSTEM"; }else{ echo $log["username"]; } ?>
				</td>
				<td class="log-content-row">
					<?php if ($log["source"] == "") { echo "SYSTEM"; }else{ echo $log["source"]; } ?>
				</td>
				<td width="1%" class="log-content-row">
					&nbsp;
				</td>
			</tr><tr class="<?php echo log_get_html_css_class(log_get_severity($log["severity"])); ?>">
				<td colspan="9" class="log-content-row-div">
					<?php echo $log["message"]; ?>
				</td>
			</tr>
			<?php
		}

	}else{
		?>
		<tr>
			<td class="content-list-empty" colspan="9">
				No Log Entries Found.
			</td>
		</tr>
		<?php
	}

	html_box_toolbar_draw($action_box_id, "0", "8", (sizeof($filter_array) == 0 ? HTML_BOX_SEARCH_INACTIVE : HTML_BOX_SEARCH_ACTIVE), $url_page_select, 0);
	html_end_box(false);

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

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

	/* fill in the list of available search dropdown */
	$search_facility = array();
	$search_facility["-1"] = "Any";
	$search_facility += log_list_facility();

	$search_severity = array();
	$search_severity["-2"] = "Any";
	$search_severity += log_list_severity();

	$search_poller = array();
	$search_poller["-1"] = "Any";
	$search_poller += log_list_poller();

	$search_host = array();
	$search_host["-1"] = "Any";
	$search_host += log_list_host();

	$search_plugin = array();
	$search_plugin["-1"] = "Any";
	$search_plugin["N/A"] = "N/A";
	$search_plugin += log_list_plugin();

	$search_username = array();
	$search_username["-1"] = "Any";
	$search_username += log_list_username();

	?>

	<script language="JavaScript">
	<!--
	function action_area_handle_type(box_id, type, parent_div, parent_form) {
		if (type == 'purge') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to purge the log?  All logs will be cleared!'));

			action_area_update_header_caption(box_id, 'Purge Logs');
			action_area_update_submit_caption(box_id, 'Purge');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'export') {
			<?php if (sizeof($filter_array) == 0) { ?>
			parent_div.appendChild(document.createTextNode('Are you sure you want to export all the logs?'));
			<?php }else{ ?>

			parent_div.appendChild(document.createTextNode('Are you sure you want to export the filtered logs?'));

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

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

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

			_elm_sev_input = action_area_generate_select('box-' + box_id + '-search_severity');
			<?php echo get_js_dropdown_code('_elm_sev_input', $search_severity, (isset_get_var("search_severity") ? get_get_var("search_severity") : "-2"));?>

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

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

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

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

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

			_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_start_date_input, 'Start Date Range (YYYY-MM-DD HH:MM:SS)', true, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_end_date_input, 'End Date Range (YYYY-MM-DD HH:MM:SS)', false, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_fac_input, 'Facility', false, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_sev_input, 'Severity', false, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_pol_input, 'Poller', false, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_host_input, 'Host', false, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_plug_input, 'Plugin', false, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_user_input, 'User', false, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_source_input, 'Source', false, false));

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


			<?php } ?>

			action_area_update_header_caption(box_id, 'Export');
			action_area_update_submit_caption(box_id, 'Export');
			action_area_update_selected_rows(box_id, parent_form);

		}else if (type == 'search') {

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

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

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

			_elm_sev_input = action_area_generate_select('box-' + box_id + '-search_severity');
			<?php echo get_js_dropdown_code('_elm_sev_input', $search_severity, (isset_get_var("search_severity") ? get_get_var("search_severity") : "-2"));?>

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

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

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

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

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

			_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_start_date_input, 'Start Date Range (YYYY-MM-DD HH:MM:SS)', true, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_end_date_input, 'End Date Range (YYYY-MM-DD HH:MM:SS)', false, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_fac_input, 'Facility', false, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_sev_input, 'Severity', false, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_pol_input, 'Poller', false, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_host_input, 'Host', false, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_plug_input, 'Plugin', false, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_user_input, 'User', false, false));
			parent_div.appendChild(action_area_generate_search_field(_elm_source_input, 'Source', 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');
		}else if (type == 'print') {
			window.open('?action=print<?php if ($filter_url != "") { echo "&" . $filter_url; } ?>');
			action_area_hide(<?php echo $action_box_id; ?>);
		}
	}
	-->
	</script>

	<?php

}
Exemplo n.º 9
0
function pollers() {
	$current_page = get_get_var_number("page", "1");

	global $colors, $poller_actions, $input_types;

	$menu_items = array(
		"enable" => _("Enable"),
		"disable" => _("Disable"),
		"delete" => _("Delete")
		);

	$filter_array = array();

	/* search field: filter (searches device description and hostname) */
	if (isset_get_var("search_filter")) {
		$filter_array["filter"] = array("name" => get_get_var("search_filter"), "hostname" => get_get_var("search_filter"));
	}

	/* clean up sort_column string */
	if (isset_get_var("sort_column")) {
		$filter_array["sort_column"] = get_get_var("sort_column");
	}else{
		$filter_array["sort_column"] = "name";
	}

	/* clean up sort_direction string */
	if (isset_get_var("sort_direction")) {
		$filter_array["sort_direction"] = get_get_var("sort_direction");
	}else{
		$filter_array["sort_direction"] = "ASC";
	}

	/* get a list of all devices on this page */
	$pollers = api_poller_list($filter_array, $current_page, read_config_option("num_rows_device"));

	/* get the total number of devices on all pages */
	$total_rows = api_poller_total_get($filter_array);

	/* generate page list */
	$url_string = build_get_url_string(array("search_filter"));
	$url_page_select = get_page_list($current_page, MAX_DISPLAY_PAGES, read_config_option("num_rows_device"), $total_rows, "pollers.php" . $url_string . ($url_string == "" ? "?" : "&") . "page=|PAGE_NUM|");

	form_start("pollers.php");

	$box_id = "1";
	html_start_box("<strong>" . _("Pollers") . "</strong>", "pollers.php?action=edit", $url_page_select);

	$display_text = array(
		"name"        => array(_("Name"),          "ASC"),
		"hostname"    => array(_("Hostname"),      "ASC"),
		"run_state"   => array(_("Status"),        "ASC"),
		"cur_time"    => array(_("Last Time"),     "DESC"),
		"min_time"    => array(_("Min Time"),      "DESC"),
		"max_time"    => array(_("Max Time"),      "DESC"),
		"avg_time"    => array(_("Avg Time"),      "DESC"),
		"active"      => array(_("Enabled"),       "ASC"),
		"last_update" => array(_("Last Run Date"), "ASC"));

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

	$i = 0;

	if (sizeof($pollers) > 0) {
	foreach ($pollers as $poller) {
		?>
		<tr class="item" id="box-<?php echo $box_id;?>-row-<?php echo $poller["poller_id"];?>" onClick="display_row_select('<?php echo $box_id;?>',document.forms[0],'box-<?php echo $box_id;?>-row-<?php echo $poller["poller_id"];?>', 'box-<?php echo $box_id;?>-chk-<?php echo $poller["poller_id"];?>')" onMouseOver="display_row_hover('box-<?php echo $box_id;?>-row-<?php echo $poller["poller_id"];?>')" onMouseOut="display_row_clear('box-<?php echo $box_id;?>-row-<?php echo $poller["poller_id"];?>')">
			<td class="title">
				<a href="pollers.php?action=edit&poller_id=<?php print $poller["id"];?>"><?php print $poller["name"];?></a>
			</td>
			<td>
				<?php echo $poller["hostname"];?>
			</td>
			<td>
				<?php echo $poller["run_state"];?>
			</td>
			<td>
				<?php echo $poller["cur_time"];?>
			</td>
			<td>
				<?php echo $poller["min_time"];?>
			</td>
			<td>
				<?php echo $poller["max_time"];?>
			</td>
			<td>
				<?php echo $poller["avg_time"];?>
			</td>
			<td>
				<?php echo ($poller["active"] == "on" ? _("Yes") : _("No"));?>
			</td>
			<td>
				<?php echo $poller["last_update"];?>
			</td>
			<td class="checkbox" align="center">
				<input type='checkbox' name='box-<?php echo $box_id;?>-chk-<?php echo $poller["poller_id"];?>' id='box-<?php echo $box_id;?>-chk-<?php echo $poller["poller_id"];?>' title="<?php echo $poller["name"];?>">
			</td>
		</tr>
		<?php
	}
	}else{
		?>
		<tr class="empty">
			<td colspan="6">
				<?php echo _("No Pollers Found.");?>
			</td>
		</tr>
		<?php
	}

	html_box_toolbar_draw($box_id, "0", "9", (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", "poller_list");
	form_end();
}
Exemplo n.º 10
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
}