Example #1
0
function hmib_host_type()
{
    global $colors, $host_types_actions, $hmib_host_types, $config, $item_rows;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request("page"));
    input_validate_input_number(get_request_var_request("rows"));
    /* ==================================================== */
    /* clean up the vendor string */
    if (isset($_REQUEST["version"])) {
        $_REQUEST["version"] = sanitize_search_string(get_request_var("version"));
    }
    if (isset($_REQUEST["filter"])) {
        $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter"));
    }
    /* clean up sort_column */
    if (isset($_REQUEST["sort_column"])) {
        $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
    }
    /* clean up search string */
    if (isset($_REQUEST["sort_direction"])) {
        $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
    }
    /* if the user pushed the 'clear' button */
    if (isset($_REQUEST["clear"])) {
        kill_session_var("sess_hmib_host_type_current_page");
        kill_session_var("sess_hmib_host_type_filter");
        kill_session_var("sess_hmib_host_type_rows");
        kill_session_var("sess_hmib_host_type_version");
        kill_session_var("sess_hmib_host_type_sort_column");
        kill_session_var("sess_hmib_host_type_sort_direction");
        unset($_REQUEST["page"]);
        unset($_REQUEST["version"]);
        unset($_REQUEST["filter"]);
        unset($_REQUEST["rows"]);
        unset($_REQUEST["sort_column"]);
        unset($_REQUEST["sort_direction"]);
    }
    /* remember these search fields in session vars so we don't have to keep passing them around */
    load_current_session_value("page", "sess_hmib_host_type_current_page", "1");
    load_current_session_value("version", "sess_hmib_host_type_version", "All");
    load_current_session_value("filter", "sess_hmib_host_type_filter", "");
    load_current_session_value("rows", "sess_hmib_host_type_rows", "-1");
    load_current_session_value("sort_column", "sess_hmib_host_type_sort_column", "name");
    load_current_session_value("sort_direction", "sess_hmib_host_type_sort_direction", "ASC");
    if ($_REQUEST["rows"] == -1) {
        $row_limit = read_config_option("hmib_os_type_rows");
    } elseif ($_REQUEST["rows"] == -2) {
        $row_limit = 999999;
    } else {
        $row_limit = $_REQUEST["rows"];
    }
    html_start_box("<strong>Host MIB OS Type Filters</strong>", "100%", $colors["header"], "3", "center", "hmib_types.php?action=edit");
    hmib_host_type_filter();
    html_end_box();
    $sql_where = "";
    $host_types = hmib_get_host_types($sql_where, $row_limit);
    html_start_box("", "100%", $colors["header"], "3", "center", "");
    $total_rows = db_fetch_cell("SELECT\n\t\tCOUNT(*)\n\t\tFROM plugin_hmib_hrSystemTypes" . $sql_where);
    /* generate page list */
    $url_page_select = get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, "hmib_types.php?");
    if (defined("CACTI_VERSION")) {
        /* generate page list navigation */
        $nav = html_create_nav($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, 9, "hmib_types.php?filter=" . $_REQUEST["filter"]);
    } else {
        if ($total_rows > 0) {
            $nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t\t\t<td colspan='9'>\n\t\t\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td align='left' class='textHeaderDark'>\n\t\t\t\t\t\t\t\t\t<strong>&lt;&lt; ";
            if ($_REQUEST["page"] > 1) {
                $nav .= "<a class='linkOverDark' href='hmib_types.php?page=" . ($_REQUEST["page"] - 1) . "'>";
            }
            $nav .= "Previous";
            if ($_REQUEST["page"] > 1) {
                $nav .= "</a>";
            }
            $nav .= "</strong>\n\t\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\t\t\tShowing Rows " . ($row_limit * ($_REQUEST["page"] - 1) + 1) . " to " . ($total_rows < $row_limit || $total_rows < $row_limit * $_REQUEST["page"] ? $total_rows : $row_limit * $_REQUEST["page"]) . " of {$total_rows} [{$url_page_select}]\n\t\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t\t<td align='right' class='textHeaderDark'>\n\t\t\t\t\t\t\t\t\t<strong>";
            if ($_REQUEST["page"] * $row_limit < $total_rows) {
                $nav .= "<a class='linkOverDark' href='hmib_types.php?page=" . ($_REQUEST["page"] + 1) . "'>";
            }
            $nav .= "Next";
            if ($_REQUEST["page"] * $row_limit < $total_rows) {
                $nav .= "</a>";
            }
            $nav .= " &gt;&gt;</strong>\n\t\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
        } else {
            $nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t\t\t<td colspan='9'>\n\t\t\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\t\t\tNo Rows Found\n\t\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
        }
    }
    print $nav;
    $display_text = array("name" => array("Host Type Name", "ASC"), "version" => array("OS Version", "DESC"), "totals" => array("Hosts", "DESC"), "sysObjectID" => array("SNMP ObjectID", "DESC"), "sysDescrMatch" => array("SNMP Sys Description Match", "ASC"));
    html_header_sort_checkbox($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]);
    $i = 0;
    if (sizeof($host_types) > 0) {
        foreach ($host_types as $host_type) {
            form_alternate_row_color($colors["alternate"], $colors["light"], $i, 'line' . $host_type["id"]);
            $i++;
            form_selectable_cell('<a class="linkEditMain" href="hmib_types.php?action=edit&id=' . $host_type["id"] . '">' . $host_type["name"] . '</a>', $host_type["id"]);
            form_selectable_cell($host_type["version"], $host_type["id"]);
            form_selectable_cell($host_type["totals"], $host_type["id"]);
            form_selectable_cell($host_type["sysObjectID"], $host_type["id"]);
            form_selectable_cell($host_type["sysDescrMatch"], $host_type["id"]);
            form_checkbox_cell($host_type["name"], $host_type["id"]);
            form_end_row();
        }
        /* put the nav bar on the bottom as well */
        print $nav;
    } else {
        print "<tr><td colspan='10'><em>No Host Types Found</em></td></tr>";
    }
    html_end_box(false);
    /* draw the dropdown containing a list of available actions for this form */
    hmib_draw_actions_dropdown($host_types_actions);
}
Example #2
0
function hmib_host_type()
{
    global $host_types_actions, $hmib_host_types, $config, $item_rows;
    hmib_validate_request_vars();
    if (get_request_var('rows') == -1) {
        $row_limit = read_config_option('num_rows_table');
    } elseif (get_request_var('rows') == -2) {
        $row_limit = 999999;
    } else {
        $row_limit = get_request_var('rows');
    }
    html_start_box(__('Host MIB OS Type Filters'), '100%', '', '3', 'center', 'hmib_types.php?action=edit');
    hmib_host_type_filter();
    html_end_box();
    $sql_where = '';
    $host_types = hmib_get_host_types($sql_where, $row_limit);
    $total_rows = db_fetch_cell('SELECT
		COUNT(*)
		FROM plugin_hmib_hrSystemTypes' . $sql_where);
    $nav = html_nav_bar('hmib_types.php', MAX_DISPLAY_PAGES, get_request_var('page'), $row_limit, $total_rows, 9, __('OS Types'), 'page', 'main');
    form_start('hmib_types.php');
    print $nav;
    html_start_box('', '100%', '', '3', 'center', '');
    $display_text = array('name' => array(__('Host Type Name'), 'ASC'), 'version' => array(__('OS Version'), 'DESC'), 'totals' => array(__('Hosts'), 'DESC'), 'sysObjectID' => array(__('SNMP ObjectID'), 'DESC'), 'sysDescrMatch' => array(__('SNMP Sys Description Match'), 'ASC'));
    html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction'));
    if (sizeof($host_types)) {
        foreach ($host_types as $host_type) {
            form_alternate_row('line' . $host_type['id'], true);
            form_selectable_cell('<a class="linkEditMain" href="' . htmlspecialchars('hmib_types.php?action=edit&id=' . $host_type['id']) . '">' . $host_type['name'] . '</a>', $host_type['id']);
            form_selectable_cell($host_type['version'], $host_type['id']);
            form_selectable_cell($host_type['totals'], $host_type['id']);
            form_selectable_cell($host_type['sysObjectID'], $host_type['id']);
            form_selectable_cell($host_type['sysDescrMatch'], $host_type['id']);
            form_checkbox_cell($host_type['name'], $host_type['id']);
            form_end_row();
        }
    } else {
        print "<tr><td colspan='10'><em>" . __('No Host Types Found') . "</em></td></tr>";
    }
    html_end_box(false);
    if (sizeof($host_types)) {
        print $nav;
    }
    /* draw the dropdown containing a list of available actions for this form */
    draw_actions_dropdown($host_types_actions);
    form_end();
}