function package_view() { $_package_id = get_get_var_number("id"); if (!empty($_package_id)) { /* get information about this package */ $package = api_package_get($_package_id); /* get a list of scripts associated with this package */ $package_scripts = api_package_metadata_list($_package_id, PACKAGE_METADATA_TYPE_SCRIPT); /* get a list of screenshots associated with this package */ $package_screenshots = api_package_metadata_list($_package_id, PACKAGE_METADATA_TYPE_SCREENSHOT); /* get a list of all graph templates associated with this package */ $package_templates = api_package_graph_template_list($_package_id); ?> <table width="98%" align="center" cellspacing="0" cellpadding="3"> <tr> <td valign="top"> <span class="textInfo"><?php echo htmlspecialchars($package["name"]);?></span> [<a href="packages.php?action=edit&id=<?php echo $package["id"];?>">edit</a>]<br> <span class="textArea"><?php echo nl2br(htmlspecialchars($package["description"]));?></a> </td> </tr> </table> <br> <table width="98%" align="center" cellspacing="1" cellpadding="3"> <tr> <td style="background-color: #9C9C9C; color: white;" colspan="2"> <strong>Basic Information</strong> </td> </tr> <tr> <td width="200" style="background-color: #f5f5f5; border-right: 1px dashed #d1d1d1;"> <strong>Category</strong> </td> <td style="border-bottom: 1px solid #f7f7f7;"> <?php echo $package["category"];?> </td> </tr> <tr> <td style="background-color: #f5f5f5; border-right: 1px dashed #d1d1d1;"> <strong>Sub Category</strong> </td> <td style="border-bottom: 1px solid #f7f7f7;"> <?php echo $package["subcategory"];?> </td> </tr> <tr> <td style="background-color: #f5f5f5; border-right: 1px dashed #d1d1d1;"> <strong>Vendor</strong> </td> <td style="border-bottom: 1px solid #f7f7f7;"> <?php echo $package["vendor"];?> </td> </tr> <tr> <td style="background-color: #f5f5f5; border-right: 1px dashed #d1d1d1;"> <strong>Model/Version</strong> </td> <td> <?php echo $package["model"];?> </td> </tr> <tr> <td style="background-color: #9C9C9C; color: white;" colspan="2"> <strong>Author Information</strong> </td> </tr> <tr> <td width="200" style="background-color: #f5f5f5; border-right: 1px dashed #d1d1d1;"> <strong>Author Name</strong> </td> <td style="border-bottom: 1px solid #f7f7f7;"> <?php echo $package["author_name"];?> </td> </tr> <tr> <td style="background-color: #f5f5f5; border-right: 1px dashed #d1d1d1;"> <strong>Author Email</strong> </td> <td style="border-bottom: 1px solid #f7f7f7;"> <?php echo $package["author_email"];?> </td> </tr> <tr> <td style="background-color: #f5f5f5; border-right: 1px dashed #d1d1d1;"> <strong>Forum User</strong> </td> <td style="border-bottom: 1px solid #f7f7f7;"> <?php echo $package["author_user_forum"];?> </td> </tr> <tr> <td style="background-color: #f5f5f5; border-right: 1px dashed #d1d1d1;"> <strong>Template Repository User</strong> </td> <td style="border-bottom: 1px solid #f7f7f7;"> <?php echo $package["author_user_repository"];?> </td> </tr> </table> <?php if (sizeof($package_templates) > 0) { ?> <br> <table width="98%" align="center" cellspacing="0" cellpadding="3"> <tr> <td> <p class="textInfo">Associated Graph Templates</p> </td> </tr> <tr> <td> <ul style="list-style-type: disc; font-size: 12px;"> <?php foreach ($package_templates as $template) { echo "<li><a href=\"graph_templates.php?action=edit&id=" . $template["id"] . "\">" . $template["template_name"] . "</a></li>\n"; } ?> </ul> </td> </tr> </table> <?php } ?> <br> <table width="98%" align="center" cellspacing="0" cellpadding="3"> <tr> <td valign="top"> <p class="textInfo">Installation Instructions</p> <p style="font-family: monospace;"><?php echo nl2br(htmlspecialchars($package["description_install"]));?> </td> </tr> </table> <?php if (sizeof($package_scripts) > 0) { ?> <br> <table width="98%" align="center" cellspacing="0" cellpadding="3"> <tr> <td> <p class="textInfo">Scripts</p> </td> </tr> </table> <br> <table width="98%" align="center" cellspacing="1" cellpadding="3"> <?php foreach ($package_scripts as $script) { ?> <tr> <td style="background-color: #9C9C9C; color: white;" colspan="2"> <strong><?php echo $script["name"];?></strong> </td> </tr> <tr> <td width="200" style="background-color: #f5f5f5; border-right: 1px dashed #d1d1d1;"> <strong>Description</strong> </td> <td style="border-bottom: 1px solid #f7f7f7;"> <?php echo nl2br(htmlspecialchars($script["description"]));?> </td> </tr> <tr> <td width="200" style="background-color: #f5f5f5; border-right: 1px dashed #d1d1d1;"> <strong>Required</strong> </td> <td style="border-bottom: 1px solid #f7f7f7;"> <?php echo (empty($script["required"]) ? "No" : "Yes");?> </td> </tr> <tr> <td width="200" style="background-color: #f5f5f5; border-right: 1px dashed #d1d1d1;"> <strong>Installation Instructions</strong> </td> <td style="border-bottom: 1px solid #f7f7f7;"> <?php echo nl2br(htmlspecialchars($script["description_install"]));?> </td> </tr> <tr> <td width="200" style="background-color: #f5f5f5; border-right: 1px dashed #d1d1d1;"> <strong>Payload</strong> </td> <td style="border-bottom: 1px solid #f7f7f7;"> <a href="packages.php?action=view_metadata_script&id=<?php echo $script["id"];?>" target="_new">Download Script</a> </td> </tr> <?php } ?> </table> <?php } if (sizeof($package_screenshots) > 0) { ?> <br> <table width="98%" align="center" cellspacing="0" cellpadding="3"> <tr> <td> <p class="textInfo">Screenshots</p> </td> </tr> <tr> <td> <ul style="list-style-type: disc; font-size: 12px;"> <?php $js_id_list = ""; $js_title_list = ""; $js_description_list = ""; $i = 0; foreach ($package_screenshots as $screenshot) { echo "<li><a href=\"javascript:view_screenshot($i)\">" . $screenshot["name"] . "</a></li>\n"; $js_id_list .= "\"" . $screenshot["id"] . "\"" . ($i < sizeof($package_screenshots) - 1 ? "," : ""); $js_title_list .= "\"" . addslashes(htmlspecialchars($screenshot["name"])) . "\"" . ($i < sizeof($package_screenshots) - 1 ? "," : ""); $js_description_list .= "\"" . addslashes(htmlspecialchars($screenshot["description"])) . "\"" . ($i < sizeof($package_screenshots) - 1 ? "," : ""); $i++; } ?> </ul> </td> </tr> <tr> <td> </td> </tr> <tr> <td style="background-color: #9C9C9C; color: white;" colspan="2"> <strong><span id="screenshot_title"></span></strong> </td> </tr> <tr> <td> <span id="screenshot_description"></span> </td> </tr> <tr> <td> <img id="screenshot_image" src="" alt=""> </td> </tr> </table> <script language="JavaScript"> <!-- var screenshot_ids = new Array(<?php echo $js_id_list;?>); var screenshot_titles = new Array(<?php echo $js_title_list;?>); var screenshot_descriptions = new Array(<?php echo $js_description_list;?>); function view_screenshot(id) { document.getElementById('screenshot_title').innerHTML = screenshot_titles[id]; document.getElementById('screenshot_description').innerHTML = screenshot_descriptions[id]; document.getElementById('screenshot_image').src = 'packages.php?action=view_metadata_screenshot&id=' + screenshot_ids[id]; } view_screenshot(0); --> </script> <?php } } }
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 }
function gprint_edit() { $_gprint_preset_id = get_get_var_number("id"); if (empty($_gprint_preset_id)) { $header_label = "[new]"; }else{ $gprint = api_data_preset_gprint_get($_gprint_preset_id); $header_label = "[edit: " . $gprint["name"] . "]"; } form_start("presets_gprint.php", "form_gprint"); /* ==================== Box: Colors ==================== */ html_start_box("<strong>" . _("GPRINT Presets") . "</strong> $header_label"); _data_preset_gprint__name("name", (isset($gprint["name"]) ? $gprint["name"] : ""), (isset($gprint["id"]) ? $gprint["id"] : "0")); _data_preset_gprint__gprint_text("gprint_text", (isset($gprint["gprint_text"]) ? $gprint["gprint_text"] : ""), (isset($gprint["id"]) ? $gprint["id"] : "0")); html_end_box(); form_hidden_box("preset_gprint_id", $_gprint_preset_id); form_hidden_box("action_post", "gprint_preset_edit"); form_save_button("presets.php?action=view_gprint", "save_gprint"); }
function script_field_edit() { $_script_id = get_get_var_number("script_id"); $_script_field_id = get_get_var_number("id"); $_field_type = get_get_var_number("field_type"); if (empty($_script_field_id)) { $header_label = "[new]"; }else{ $script_field = api_script_field_get($_script_field_id); $header_label = "[edit: " . $script_field["data_name"] . "]"; } $script = api_script_get($_script_id); if (($_field_type == SCRIPT_FIELD_TYPE_INPUT) || ($_field_type == SCRIPT_FIELD_TYPE_OUTPUT)) { $current_field_type = $_field_type; }else{ $current_field_type = ($script_field["input_output"] == "in" ? SCRIPT_FIELD_TYPE_INPUT : "out"); } if ($current_field_type == SCRIPT_FIELD_TYPE_INPUT) { $current_field_type_friendly = _("Input"); }elseif ($current_field_type == SCRIPT_FIELD_TYPE_OUTPUT) { $current_field_type_friendly = _("Output"); } form_start("scripts_fields.php", "form_script_field"); html_start_box("<strong>$current_field_type_friendly Field</strong> $header_label"); if ($current_field_type == SCRIPT_FIELD_TYPE_INPUT) { field_row_header("Input Options"); _script_field_field__field_input_type("field_input_type", (isset($script_field["field_input_type"]) ? $script_field["field_input_type"] : ""), (isset($script_field["id"]) ? $script_field["id"] : "0")); _script_field_field__field_input_value_custom("field_input_value_custom", (isset($script_field["field_input_value"]) ? $script_field["field_input_value"] : ""), (isset($script_field["id"]) ? $script_field["id"] : "0")); _script_field_field__field_input_value_device("field_input_value_device", (isset($script_field["field_input_value"]) ? $script_field["field_input_value"] : ""), (isset($script_field["id"]) ? $script_field["id"] : "0")); } field_row_header("Field Options"); if ($current_field_type == SCRIPT_FIELD_TYPE_INPUT) { _script_field_field__data_name_input("data_name", $_script_id, (isset($script_field["data_name"]) ? $script_field["data_name"] : ""), (isset($script_field["id"]) ? $script_field["id"] : "0")); }else if ($current_field_type == SCRIPT_FIELD_TYPE_OUTPUT) { _script_field_field__data_name_output("data_name", (isset($script_field["data_name"]) ? $script_field["data_name"] : ""), (isset($script_field["id"]) ? $script_field["id"] : "0")); } _script_field_field__name("name", (isset($script_field["name"]) ? $script_field["name"] : ""), (isset($script_field["id"]) ? $script_field["id"] : "0")); if ($current_field_type == SCRIPT_FIELD_TYPE_INPUT) { _script_field_field__regexp_match("regexp_match", (isset($script_field["regexp_match"]) ? $script_field["regexp_match"] : ""), (isset($script_field["id"]) ? $script_field["id"] : "0")); _script_field_field__allow_empty("allow_empty", (isset($script_field["allow_empty"]) ? $script_field["allow_empty"] : ""), (isset($script_field["id"]) ? $script_field["id"] : "0")); }else if ($current_field_type == SCRIPT_FIELD_TYPE_OUTPUT) { _script_field_field__update_rrd("update_rrd", (isset($script_field["update_rrd"]) ? $script_field["update_rrd"] : ""), (isset($script_field["id"]) ? $script_field["id"] : "0")); } _script_field_field__field_input_type_js_update((isset($script_field["field_input_type"]) ? $script_field["field_input_type"] : SCRIPT_FIELD_INPUT_CUSTOM), (empty($_script_field_id) ? 0 : $_script_field_id)); html_end_box(); form_hidden_box("id", $_script_field_id, "0"); form_hidden_box("script_id", $_script_id, "0"); form_hidden_box("field_type", $current_field_type, "0"); form_hidden_box("action_post", "script_field_edit"); form_save_button("scripts.php?action=edit&id=" . $_script_id); }
function tree_item_movedown() { $_graph_tree_item_id = get_get_var_number("id"); api_graph_tree_item_move($_graph_tree_item_id, "down"); }
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 }
function data_query_edit() { $_data_query_id = get_get_var_number("id"); if (empty($_data_query_id)) { $header_label = "[new]"; } else { $data_query = api_data_query_get($_data_query_id); $header_label = "[edit: " . $data_query["name"] . "]"; } form_start("data_queries.php", "form_data_query"); html_start_box("<strong>" . _("Data Queries") . "</strong> {$header_label}"); _data_query_field__name("name", isset($data_query["name"]) ? $data_query["name"] : "", isset($data_query["id"]) ? $data_query["id"] : "0"); _data_query_field__input_type("input_type", isset($data_query["input_type"]) ? $data_query["input_type"] : "", isset($data_query["id"]) ? $data_query["id"] : "0"); _data_query_field__index_order_type("index_order_type", isset($data_query["index_order_type"]) ? $data_query["index_order_type"] : "", isset($data_query["id"]) ? $data_query["id"] : "0"); _data_query_field__index_title_format("index_title_format", isset($data_query["index_title_format"]) ? $data_query["index_title_format"] : "|chosen_order_field|", isset($data_query["id"]) ? $data_query["id"] : "0"); if (!empty($_data_query_id)) { _data_query_field__field_specific_hdr(); _data_query_field__index_order("index_order", isset($data_query["index_order"]) ? $data_query["index_order"] : "", isset($data_query["id"]) ? $data_query["id"] : "0"); _data_query_field__index_field_id("index_field_id", $_data_query_id, isset($data_query["index_field_id"]) ? $data_query["index_field_id"] : "", isset($data_query["id"]) ? $data_query["id"] : "0"); } /* input type specific fields */ _data_query_field__snmp_specific_hdr(); _data_query_field__snmp_oid_num_rows("snmp_oid_num_rows", isset($data_query["snmp_oid_num_rows"]) ? $data_query["snmp_oid_num_rows"] : "", isset($data_query["id"]) ? $data_query["id"] : "0"); _data_query_field__script_specific_hdr(); _data_query_field__script_path("script_path", isset($data_query["script_path"]) ? $data_query["script_path"] : "", isset($data_query["id"]) ? $data_query["id"] : "0"); _data_query_field__script_server_specific_hdr(); _data_query_field__script_server_function("script_server_function", isset($data_query["script_server_function"]) ? $data_query["script_server_function"] : "", isset($data_query["id"]) ? $data_query["id"] : "0"); /* be sure that we have the correct input type value show we display the correct form rows */ if (isset_post_cache_field("input_type")) { $_input_type = get_post_cache_field("input_type"); } else { $_input_type = isset($data_query["input_type"]) ? $data_query["input_type"] : ""; } echo "<script language=\"JavaScript\">\n<!--\nupdate_data_query_type_fields('{$_input_type}');\n-->\n</script>\n"; html_end_box(); if (!empty($_data_query_id)) { html_start_box("<strong>" . _("Data Query Fields") . "</strong>"); ?> <tr class="heading"> <td colspan="2"> Input Fields </td> <td align="right"> <a href="data_queries.php?action=field_edit&field_type=<?php echo DATA_QUERY_FIELD_TYPE_INPUT; ?> &data_query_id=<?php echo $_data_query_id; ?> ">Add</a> </td> </tr> <?php $input_fields = api_data_query_field_list($_data_query_id, DATA_QUERY_FIELD_TYPE_INPUT); if (sizeof($input_fields) > 0) { foreach ($input_fields as $field) { ?> <tr class="item" id="row_<?php echo $field["id"]; ?> " onClick="display_row_select('row_<?php echo $field["id"]; ?> ', 'chk_<?php echo $field["id"]; ?> ')" onMouseOver="display_row_hover('row_<?php echo $field["id"]; ?> ')" onMouseOut="display_row_clear('row_<?php echo $field["id"]; ?> ')"> <td class="title"> <a class="linkEditMain" onClick="display_row_block('row_<?php echo $field["id"]; ?> ')" href="data_queries.php?action=field_edit&id=<?php echo $field["id"]; ?> &data_query_id=<?php echo $field["data_query_id"]; ?> "><?php echo $field["name"]; ?> </a> </td> <td> <?php echo $field["name_desc"]; ?> </td> <td align="right"> <input type='checkbox' id='chk_<?php echo $field["id"]; ?> ' name='chk_<?php echo $field["id"]; ?> ' title="<?php echo $field["name"]; ?> "> </td> </tr> <?php } } else { ?> <tr> <td class="empty" colspan="2"> No input fields found. Remember that <strong>at least one index field</strong> must be defined! </td> </tr> <?php } ?> <tr class="heading"> <td colspan="2"> Output Fields </td> <td align="right"> <a href="data_queries.php?action=field_edit&field_type=<?php echo DATA_QUERY_FIELD_TYPE_OUTPUT; ?> &data_query_id=<?php echo $_data_query_id; ?> ">Add</a> </td> </tr> <?php $output_fields = api_data_query_field_list($_data_query_id, DATA_QUERY_FIELD_TYPE_OUTPUT); if (sizeof($output_fields) > 0) { foreach ($output_fields as $field) { ?> <tr class="item" id="row_<?php echo $field["id"]; ?> " onClick="display_row_select('row_<?php echo $field["id"]; ?> ', 'chk_<?php echo $field["id"]; ?> ')" onMouseOver="display_row_hover('row_<?php echo $field["id"]; ?> ')" onMouseOut="display_row_clear('row_<?php echo $field["id"]; ?> ')"> <td class="item"> <a class="linkEditMain" onClick="display_row_block('row_<?php echo $field["id"]; ?> ')" href="data_queries.php?action=field_edit&id=<?php echo $field["id"]; ?> &data_query_id=<?php echo $field["data_query_id"]; ?> "><?php echo $field["name"]; ?> </a> </td> <td> <?php echo $field["name_desc"]; ?> </td> <td align="right"> <input type='checkbox' id='chk_<?php echo $field["id"]; ?> ' name='chk_<?php echo $field["id"]; ?> ' title="<?php echo $field["name"]; ?> "> </td> </tr> <?php } } else { ?> <tr class="empty"> <td colspan="2"> No output fields found. </td> </tr> <?php } html_end_box(); } form_hidden_box("data_query_id", $_data_query_id); form_save_button("data_queries.php", "save_data_query"); }
function tree_edit() { $menu_items = array("remove" => "Remove"); $_graph_tree_id = get_get_var_number("id"); if (empty($_graph_tree_id)) { $header_label = "[new]"; } else { $graph_tree = api_graph_tree_get($_graph_tree_id); $header_label = "[edit: " . $graph_tree["name"] . "]"; } form_start("graph_trees.php", "form_graph_tree"); html_start_box("<strong>" . _("Graph Trees") . "</strong> {$header_label}", ""); _graph_tree_field__name("name", isset($graph_tree["name"]) ? $graph_tree["name"] : "", empty($_graph_tree_id) ? 0 : $_graph_tree_id); _graph_tree_field__sort_type("sort_type", isset($graph_tree["sort_type"]) ? $graph_tree["sort_type"] : "", empty($_graph_tree_id) ? 0 : $_graph_tree_id); html_end_box(); form_hidden_box("id", $_graph_tree_id); form_hidden_box("action_post", "graph_tree_edit"); form_save_button("graph_trees.php"); if (!empty($_graph_tree_id)) { echo "<br />\n"; form_start("graph_trees_items.php", "form_graph_tree_item"); $box_id = "1"; html_start_box("<strong>" . _("Tree Items") . "</strong>", "graph_trees_items.php?action=edit&tree_id=" . $_graph_tree_id . "&parent_id=0"); html_header_checkbox(array(_("Item"), _("Type"), ""), $box_id, "1"); /* get a sorted list of all graph items inside of this tree */ $tree_items = api_graph_tree_item_list($_graph_tree_id); /* get a list of available types (header, host, graph, etc) */ $tree_item_types = api_graph_tree_item_type_list(); if (is_array($tree_items) > 0 && sizeof($tree_items) > 0) { foreach ($tree_items as $tree_item) { $current_depth = api_graph_tree_item_depth_get($tree_item["order_key"]); /* keep track of the current item's sort type so we know whether to display sort * arrays for items children or not */ $sort_cache[$current_depth] = $tree_item["sort_children_type"]; $transparent_indent = ""; if ($tree_item["item_type"] == TREE_ITEM_TYPE_GRAPH) { $item_text = $tree_item["graph_title"]; } else { if ($tree_item["item_type"] == TREE_ITEM_TYPE_HEADER) { $item_text = "<strong>" . $tree_item["item_value"] . "</strong></a> (<a href='graph_trees_items.php?action=edit&tree_id=" . $_graph_tree_id . "&parent_id=" . $tree_item["id"] . "'>Add</a>)"; } else { if ($tree_item["item_type"] == TREE_ITEM_TYPE_HOST) { $item_text = "<strong>Device:</strong> " . $tree_item["host_hostname"]; } } } ?> <tr class="item" id="box-<?php echo $box_id; ?> -row-<?php echo $tree_item["id"]; ?> " onClick="display_row_select('<?php echo $box_id; ?> ',document.forms[1],'box-<?php echo $box_id; ?> -row-<?php echo $tree_item["id"]; ?> ', 'box-<?php echo $box_id; ?> -chk-<?php echo $tree_item["id"]; ?> ')" onMouseOver="display_row_hover('box-<?php echo $box_id; ?> -row-<?php echo $tree_item["id"]; ?> ')" onMouseOut="display_row_clear('box-<?php echo $box_id; ?> -row-<?php echo $tree_item["id"]; ?> ')"> <td class="title"> <img width="<?php echo ($current_depth - 1) * 20; ?> " height="1" align="middle" alt=""> <a onClick="display_row_block('box-<?php echo $box_id; ?> -row-<?php echo $tree_item["id"]; ?> ')" href="graph_trees_items.php?action=edit&tree_id=<?php echo $_graph_tree_id; ?> &id=<?php echo $tree_item["id"]; ?> "><span id="box-<?php echo $box_id; ?> -text-<?php echo $tree_item["id"]; ?> "><?php echo html_highlight_words(get_get_var("search_filter"), $item_text); ?> </span></a> </td> <td> <?php echo $tree_item_types[$tree_item["item_type"]]; ?> </td> <?php if (isset($sort_cache[$current_depth - 1]) && $sort_cache[$current_depth - 1] != TREE_ORDERING_NONE || $graph_tree["sort_type"] != TREE_ORDERING_NONE) { ?> <td width="80"> </td> <?php } else { ?> <td width="80" align="center"> <a href="graph_trees_items.php?action=movedown&id=<?php echo $tree_item["id"]; ?> &graph_tree_id=<?php echo $_graph_tree_id; ?> "><img src="<?php echo html_get_theme_images_path("move_down.gif"); ?> " border="0" alt="Move Down"></a> <a href="graph_trees_items.php?action=moveup&id=<?php echo $tree_item["id"]; ?> &graph_tree_id=<?php echo $_graph_tree_id; ?> "><img src="<?php echo html_get_theme_images_path("move_up.gif"); ?> " border="0" alt="Move Up"></a> </td> <?php } ?> <td class="checkbox" align="center"> <input type='checkbox' name='box-<?php echo $box_id; ?> -chk-<?php echo $tree_item["id"]; ?> ' id='box-<?php echo $box_id; ?> -chk-<?php echo $tree_item["id"]; ?> ' title="<?php echo strip_tags($item_text); ?> "> </td> </tr> <?php } } else { ?> <tr class="empty"> <td colspan="6"> No graph tree items found. </td> </tr> <?php } html_box_toolbar_draw($box_id, "1", "3", HTML_BOX_SEARCH_NONE); html_end_box(false); html_box_actions_menu_draw($box_id, "1", $menu_items); form_hidden_box("graph_tree_id", $_graph_tree_id); form_hidden_box("action", "save"); form_hidden_box("action_post", "graph_tree_item_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 graph tree items?')); parent_div.appendChild(action_area_generate_selected_rows(box_id)); action_area_update_header_caption(box_id, 'Remove Graph Tree Item'); action_area_update_submit_caption(box_id, 'Remove'); action_area_update_selected_rows(box_id, parent_form); } } --> </script> <?php } }
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 }
function rra_presets_edit() { global $xajax, $colors; $_rra_preset_id = get_get_var_number("id"); if (empty($_rra_preset_id)) { $header_label = "[new]"; }else{ $rra = api_data_preset_rra_get($_rra_preset_id); $header_label = "[edit: " . $rra["name"] . "]"; } form_start("presets_rra.php", "form_rra"); /* ==================== Box: RRAs ==================== */ html_start_box("<strong>" . _("RRA Presets") . "</strong> $header_label"); _data_preset_rra__name("name", (isset($rra["name"]) ? $rra["name"] : ""), (isset($rra["id"]) ? $rra["id"] : "0")); html_end_box(); /* ==================== Box: RRA Items ==================== */ if (!empty($_rra_preset_id)) { $rra_items = api_data_preset_rra_item_list($_rra_preset_id); _data_preset_rra_item_js("form_rra"); $box_id = "1"; html_start_box("<strong>" . _("RRA Items") . "</strong>", "javascript:new_rra_item('$box_id')", "", $box_id, true, 0); $empty_rra_item_list = false; if (is_array($rra_items)) { /* if there are no rra items to display, we need to create a "fake" item which we will then turn * into a "new" row using JS */ if (sizeof($rra_items) == 0) { $empty_rra_item_list = true; $rra_items = array( array( "id" => "0", "consolidation_function" => "1", "steps" => "", "rows" => "", "x_files_factor" => "", "hw_alpha" => "", "hw_beta" => "", "hw_gamma" => "", "hw_seasonal_period" => "", "hw_rra_num" => "", "hw_threshold" => "", "hw_window_length" => "" ) ); } foreach ($rra_items as $rra_item) { ?> <tr id="row<?php echo $rra_item["id"];?>"> <td> <table width="100%" cellpadding="3" cellspacing="0"> <tr bgcolor="<?php echo $colors["header_panel_background"];?>"> <td colspan="2" class="textSubHeaderDark" id="row_rra_item_header_<?php echo $rra_item["id"];?>"> <?php echo (empty($rra_item["id"]) ? "(new)" : api_data_preset_rra_item_friendly_name_get($rra_item["consolidation_function"], $rra_item["steps"], $rra_item["rows"]));?> </td> <td align="right" class="textSubHeaderDark"> <a class="linkOverDark" href="#" onClick="javascript:xajax_xajax_remove_rra_item('<?php echo $rra_item["id"];?>')">Remove</a> </td> </tr> <?php _data_preset_rra_item__consolidation_function("rrai|consolidation_function|" . $rra_item["id"], $rra_item["consolidation_function"], $rra_item["id"]); _data_preset_rra_item__steps("rrai|steps|" . $rra_item["id"], $rra_item["steps"], $rra_item["id"]); _data_preset_rra_item__rows("rrai|rows|" . $rra_item["id"], $rra_item["rows"], $rra_item["id"]); _data_preset_rra_item__x_files_factor("rrai|x_files_factor|" . $rra_item["id"], $rra_item["x_files_factor"], $rra_item["id"]); _data_preset_rra_item__hw_alpha("rrai|hw_alpha|" . $rra_item["id"], $rra_item["hw_alpha"], $rra_item["id"]); _data_preset_rra_item__hw_beta("rrai|hw_beta|" . $rra_item["id"], $rra_item["hw_beta"], $rra_item["id"]); _data_preset_rra_item__hw_gamma("rrai|hw_gamma|" . $rra_item["id"], $rra_item["hw_gamma"], $rra_item["id"]); _data_preset_rra_item__hw_seasonal_period("rrai|hw_seasonal_period|" . $rra_item["id"], $rra_item["hw_seasonal_period"], $rra_item["id"]); _data_preset_rra_item__hw_rra_num("rrai|hw_rra_num|" . $rra_item["id"], $rra_item["hw_rra_num"], $rra_item["id"]); _data_preset_rra_item__hw_threshold("rrai|hw_threshold|" . $rra_item["id"], $rra_item["hw_threshold"], $rra_item["id"]); _data_preset_rra_item__hw_window_length("rrai|hw_window_length|" . $rra_item["id"], $rra_item["hw_window_length"], $rra_item["id"]); _data_preset_rra_item__consolidation_function_js_update($rra_item["consolidation_function"], $rra_item["id"]); ?> </table> </td> </tr> <?php } } html_end_box(); echo "<a name='rra_preset_bottom' />\n"; if ($empty_rra_item_list == true) { ?> <script language="JavaScript"> <!-- make_row_new(document.getElementById("row0"), true); --> </script> <?php } ?> <?php } form_hidden_box("preset_rra_id", $_rra_preset_id); form_hidden_box("action_post", "rra_preset_edit"); form_save_button("presets.php?action=view_rra", "save_rra"); }
function script_edit() { $menu_items = array( "remove" => "Remove" ); $_script_id = get_get_var_number("id"); if (empty($_script_id)) { $header_label = "[new]"; }else{ $script = api_script_get($_script_id); $header_label = "[edit: " . $script["name"] . "]"; } form_start("scripts.php", "form_script"); html_start_box("<strong>" . _("Scripts") . "</strong> $header_label"); _script_field__name("name", (isset($script["name"]) ? $script["name"] : ""), (isset($script["id"]) ? $script["id"] : "0")); _script_field__type_id("type_id", (isset($script["type_id"]) ? $script["type_id"] : ""), (isset($script["id"]) ? $script["id"] : "0")); _script_field__input_string("input_string", (isset($script["input_string"]) ? $script["input_string"] : ""), (isset($script["id"]) ? $script["id"] : "0")); html_end_box(); form_hidden_box("id", $_script_id); form_hidden_box("action_post", "script_edit"); form_save_button("scripts.php"); if (!empty($_script_id)) { echo "<br />\n"; form_start("scripts_fields.php", "form_script_item"); $box_id = "1"; html_start_box("<strong>" . _("Script Fields") . "</strong>"); ?> <tr class="heading"> <td colspan="2"> Input Fields </td> <td align="right"> <a href="scripts_fields.php?action=edit&field_type=<?php echo SCRIPT_FIELD_TYPE_INPUT;?>&script_id=<?php echo $_script_id;?>">Add</a> </td> </tr> <?php $input_fields = api_script_field_list($_script_id, SCRIPT_FIELD_TYPE_INPUT); if ((is_array($input_fields) > 0) && (sizeof($input_fields) > 0)) { foreach ($input_fields as $field) { ?> <tr class="item" id="box-<?php echo $box_id;?>-row-<?php echo $field["id"];?>" onClick="display_row_select('<?php echo $box_id;?>',document.forms[1],'box-<?php echo $box_id;?>-row-<?php echo $field["id"];?>', 'box-<?php echo $box_id;?>-chk-<?php echo $field["id"];?>')" onMouseOver="display_row_hover('box-<?php echo $box_id;?>-row-<?php echo $field["id"];?>')" onMouseOut="display_row_clear('box-<?php echo $box_id;?>-row-<?php echo $field["id"];?>')"> <td class="item"> <a onClick="display_row_block('box-<?php echo $box_id;?>-row-<?php echo $field["id"];?>')" href="scripts_fields.php?action=edit&script_id=<?php echo $_script_id;?>&id=<?php echo $field["id"];?>"><span id="box-<?php echo $box_id;?>-text-<?php echo $field["id"];?>"><?php echo $field["data_name"];?></span></a> </td> <td> <?php echo $field["name"];?> </td> <td class="checkbox"align="center"> <input type='checkbox' name='box-<?php echo $box_id;?>-chk-<?php echo $field["id"];?>' id='box-<?php echo $box_id;?>-chk-<?php echo $field["id"];?>' title="<?php echo $field["data_name"];?>"> </td> </tr> <?php } }else{ ?> <tr class="empty"> <td colspan="2"> No input fields found. This means that no input parameters will be passed to the script. </td> </tr> <?php } ?> <tr class="heading"> <td colspan="2"> Output Fields </td> <td align="right"> <a href="scripts_fields.php?action=edit&field_type=<?php echo SCRIPT_FIELD_TYPE_OUTPUT;?>&script_id=<?php echo $_script_id;?>">Add</a> </td> </tr> <?php $output_fields = api_script_field_list($_script_id, SCRIPT_FIELD_TYPE_OUTPUT); if ((is_array($output_fields) > 0) && (sizeof($output_fields) > 0)) { foreach ($output_fields as $field) { ?> <tr class="item" id="box-<?php echo $box_id;?>-row-<?php echo $field["id"];?>" onClick="display_row_select('<?php echo $box_id;?>',document.forms[1],'box-<?php echo $box_id;?>-row-<?php echo $field["id"];?>', 'box-<?php echo $box_id;?>-chk-<?php echo $field["id"];?>')" onMouseOver="display_row_hover('box-<?php echo $box_id;?>-row-<?php echo $field["id"];?>')" onMouseOut="display_row_clear('box-<?php echo $box_id;?>-row-<?php echo $field["id"];?>')"> <td class="title"> <a onClick="display_row_block('box-<?php echo $box_id;?>-row-<?php echo $field["id"];?>')" href="scripts_fields.php?action=edit&script_id=<?php echo $_script_id;?>&id=<?php echo $field["id"];?>"><span id="box-<?php echo $box_id;?>-text-<?php echo $field["id"];?>"><?php echo $field["data_name"];?></span></a> </td> <td> <?php echo $field["name"];?> </td> <td class="checkbox" align="center"> <input type='checkbox' name='box-<?php echo $box_id;?>-chk-<?php echo $field["id"];?>' id='box-<?php echo $box_id;?>-chk-<?php echo $field["id"];?>' title="<?php echo $field["data_name"];?>"> </td> </tr> <?php } }else{ ?> <tr class="empty"> <td colspan="2"> No output fields found. Remember that <strong>at least one output field</strong> must be defined! </td> </tr> <?php } html_box_toolbar_draw($box_id, "1", "2", HTML_BOX_SEARCH_NONE); html_end_box(false); html_box_actions_menu_draw($box_id, "1", $menu_items); form_hidden_box("script_id", $_script_id); form_hidden_box("action", "save"); form_hidden_box("action_post", "script_field_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 script fields?')); parent_div.appendChild(action_area_generate_selected_rows(box_id)); action_area_update_header_caption(box_id, 'Remove Script Field'); action_area_update_submit_caption(box_id, 'Remove'); action_area_update_selected_rows(box_id, parent_form); } } --> </script> <?php } }
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 }
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"> </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 }
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(); }