Пример #1
0
function _option_process($field_val, $row, $template)
{
    if ($template == 'hilight') {
        global $_hilight_words;
        return html_highlight_words($_hilight_words, $field_val);
    }
    $ret = str_replace("%id", $row['id'], $template);
    $ret = str_replace("%s", $field_val, $ret);
    return $ret;
}
Пример #2
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
}
Пример #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 
}
Пример #4
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 
}
Пример #5
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 
}
Пример #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 
}