/** function syslog_messages() * This is the main page display function in Syslog. Displays all the * syslog messages that are relevant to Syslog. */ function syslog_messages($tab = "syslog") { global $colors, $sql_where, $hostfilter, $severities; global $config, $syslog_incoming_config, $reset_multi, $syslog_levels; include "./include/global_arrays.php"; /* force the initial timespan to be 30 minutes for performance reasons */ if (!isset($_SESSION["sess_syslog_init"])) { $_SESSION["sess_current_timespan"] = 1; $_SESSION["sess_syslog_init"] = 1; } if (file_exists("./lib/timespan_settings.php")) { include "./lib/timespan_settings.php"; } else { include "./include/html/inc_timespan_settings.php"; } include dirname(__FILE__) . "/config.php"; /* create the custom css and javascript for the page */ generate_syslog_cssjs(); $url_curr_page = get_browser_query_string(); $sql_where = ""; if ($_REQUEST["rows"] == -1) { $row_limit = read_config_option("num_rows_syslog"); } elseif ($_REQUEST["rows"] == -2) { $row_limit = 999999; } else { $row_limit = $_REQUEST["rows"]; } $syslog_messages = get_syslog_messages($sql_where, $row_limit, $tab); $total_rows = syslog_filter($sql_where, $tab); /* generate page list */ $url_page_select = get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, "syslog.php?tab={$tab}"); if ($total_rows > 0) { $nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t\t\t<td colspan='13'>\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><< "; if ($_REQUEST["page"] > 1) { $nav .= "<a class='linkOverDark' href='syslog.php?tab={$tab}&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 " . ($total_rows == 0 ? "None" : $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='syslog.php?tab={$tab}&page=" . ($_REQUEST["page"] + 1) . "'>"; } $nav .= "Next"; if ($_REQUEST["page"] * $row_limit < $total_rows) { $nav .= "</a>"; } $nav .= " >></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"] . "' class='noprint'>\n\t\t\t\t\t<td colspan='22'>\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; if ($tab == "syslog") { if (api_plugin_user_realm_auth('syslog_alerts.php')) { $display_text = array("nosortt" => array("Actions", "ASC"), "host_id" => array("Host", "ASC"), "logtime" => array("Date", "ASC"), "message" => array("Message", "ASC"), "facility_id" => array("Facility", "ASC"), "priority_id" => array("Priority", "ASC")); } else { $display_text = array("host_id" => array("Host", "ASC"), "logtime" => array("Date", "ASC"), "message" => array("Message", "ASC"), "facility_id" => array("Facility", "ASC"), "priority_id" => array("Priority", "ASC")); } html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]); $hosts = array_rekey(syslog_db_fetch_assoc("SELECT host_id, host FROM `" . $syslogdb_default . "`.`syslog_hosts`"), "host_id", "host"); $facilities = array_rekey(syslog_db_fetch_assoc("SELECT facility_id, facility FROM `" . $syslogdb_default . "`.`syslog_facilities`"), "facility_id", "facility"); $priorities = array_rekey(syslog_db_fetch_assoc("SELECT priority_id, priority FROM `" . $syslogdb_default . "`.`syslog_priorities`"), "priority_id", "priority"); $i = 0; if (sizeof($syslog_messages) > 0) { foreach ($syslog_messages as $syslog_message) { $title = "'" . str_replace("\"", "", str_replace("'", "", $syslog_message["message"])) . "'"; $tip_options = "CLICKCLOSE, 'true', WIDTH, '40', DELAY, '500', FOLLOWMOUSE, 'true', FADEIN, 450, FADEOUT, 450, BGCOLOR, '#F9FDAF', STICKY, 'true', SHADOWCOLOR, '#797C6E', TITLE, 'Message'"; syslog_row_color($colors["alternate"], $colors["light"], $i, $priorities[$syslog_message["priority_id"]], $title); $i++; if (api_plugin_user_realm_auth('syslog_alerts.php')) { print "<td style='whitspace-nowrap;width:1%;'>"; if ($syslog_message['mtype'] == 'main') { print "<a href='syslog_alerts.php?id=" . $syslog_message[$syslog_incoming_config["id"]] . "&date=" . $syslog_message["logtime"] . "&action=newedit&type=0'><img src='images/green.gif' align='absmiddle' border=0></a>\n\t\t\t\t\t\t<a href='syslog_removal.php?id=" . $syslog_message[$syslog_incoming_config["id"]] . "&date=" . $syslog_message["logtime"] . "&action=newedit&type=new&type=0'><img src='images/red.gif' align='absmiddle' border=0></a>\n"; } print "</td>\n"; } print "<td>" . $hosts[$syslog_message["host_id"]] . "</td>\n"; print "<td>" . $syslog_message["logtime"] . "</td>\n"; print "<td>" . (strlen($_REQUEST["filter"]) ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", title_trim($syslog_message[$syslog_incoming_config["textField"]], get_request_var_request("trimval"))) : title_trim($syslog_message[$syslog_incoming_config["textField"]], get_request_var_request("trimval"))) . "</td>\n"; print "<td>" . ucfirst($facilities[$syslog_message["facility_id"]]) . "</td>\n"; print "<td>" . ucfirst($priorities[$syslog_message["priority_id"]]) . "</td>\n"; } } else { print "<tr><td><em>No Messages</em></td></tr>"; } print $nav; html_end_box(false); syslog_syslog_legend(); } else { $display_text = array("name" => array("Alert Name", "ASC"), "severity" => array("Severity", "ASC"), "count" => array("Count", "ASC"), "logtime" => array("Date", "ASC"), "logmsg" => array("Message", "ASC"), "slhost" => array("Host", "ASC"), "facility" => array("Facility", "ASC"), "priority" => array("Priority", "ASC")); html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]); $i = 0; if (sizeof($syslog_messages) > 0) { foreach ($syslog_messages as $log) { $title = "'" . str_replace("\"", "", str_replace("'", "", $log["logmsg"])) . "'"; $tip_options = "CLICKCLOSE, 'true', WIDTH, '40', DELAY, '500', FOLLOWMOUSE, 'true', FADEIN, 450, FADEOUT, 450, BGCOLOR, '#F9FDAF', STICKY, 'true', SHADOWCOLOR, '#797C6E', TITLE, 'Message'"; switch ($log['severity']) { case "0": $color = "notice"; break; case "1": $color = "warn"; break; case "2": $color = "crit"; break; default: $color = "info"; break; } syslog_row_color($colors["alternate"], $colors["light"], $i, $color, $title); $i++; print "<td><a class='linkEditMain' href='" . $config["url_path"] . "plugins/syslog/syslog.php?id=" . $log["seq"] . "&tab=current'>" . (strlen($log["name"]) ? $log["name"] : "Alert Removed") . "</a></td>\n"; print "<td>" . (isset($severities[$log["severity"]]) ? $severities[$log["severity"]] : "Unknown") . "</td>\n"; print "<td>" . $log["count"] . "</td>\n"; print "<td>" . $log["logtime"] . "</td>\n"; print "<td>" . (strlen($_REQUEST["filter"]) ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", title_trim($log["logmsg"], get_request_var_request("trimval"))) : title_trim($log["logmsg"], get_request_var_request("trimval"))) . "</td>\n"; print "<td>" . $log["host"] . "</td>\n"; print "<td>" . ucfirst($log["facility"]) . "</td>\n"; print "<td>" . ucfirst($log["priority"]) . "</td>\n"; } } else { print "<tr><td><em>No Messages</em></td></tr>"; } print $nav; html_end_box(false); syslog_log_legend(); } /* put the nav bar on the bottom as well */ ?> </td> </tr> </table> </td> </tr> </table> </form> <script type='text/javascript'> function syslogFindPos(obj) { var curleft = curtop = 0; if (obj.offsetParent) { curleft = obj.offsetLeft; curtop = obj.offsetTop; while (obj = obj.offsetParent) { curleft += obj.offsetLeft; curtop += obj.offsetTop; } } return [curleft,curtop]; } function setHostMultiSelect() { selectPos = syslogFindPos(document.getElementById("host_select")); textSize = document.getElementById("host_all").scrollHeight; if (textSize == 0) textSize = 16; if (window.innerHeight) { height = window.innerHeight; }else{ height = document.body.clientHeight; } //alert("Height:"+height+", YPos:"+selectPos[1]+", TextSize:"+textSize); /* the full window size of the multi-select */ size = parseInt((height-selectPos[1]-5)/textSize); window.onresize = null; document.getElementById("host_select").size=size; window.onresize = this; } window.onresize = setHostMultiSelect; window.onload = setHostMultiSelect; </script> <?php }
function api_user_realm_auth($filename = '') { return api_plugin_user_realm_auth($filename); }
function mikrotik_devices() { global $config, $colors, $item_rows; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('status')); input_validate_input_number(get_request_var_request('page')); input_validate_input_number(get_request_var_request('rows')); /* ==================================================== */ /* clean up sort_column */ if (isset($_REQUEST['sort_column'])) { $_REQUEST['sort_column'] = sanitize_search_string(get_request_var_request('sort_column')); } /* clean up sort_direction */ if (isset($_REQUEST['sort_direction'])) { $_REQUEST['sort_direction'] = sanitize_search_string(get_request_var_request('sort_direction')); } /* clean up filter string */ if (isset($_REQUEST['filter'])) { $_REQUEST['filter'] = sanitize_search_string(get_request_var_request('filter')); } if (isset($_REQUEST['reset'])) { kill_session_var('sess_mikrotik_device_sort_column'); kill_session_var('sess_mikrotik_device_sort_direction'); kill_session_var('sess_mikrotik_device_status'); kill_session_var('sess_mikrotik_device_filter'); kill_session_var('sess_default_rows'); kill_session_var('sess_mikrotik_device_current_page'); } elseif (isset($_REQUEST['clear'])) { kill_session_var('sess_mikrotik_device_sort_column'); kill_session_var('sess_mikrotik_device_sort_direction'); kill_session_var('sess_mikrotik_device_status'); kill_session_var('sess_mikrotik_device_filter'); kill_session_var('sess_default_rows'); kill_session_var('sess_mikrotik_device_current_page'); unset($_REQUEST['sort_column']); unset($_REQUEST['sort_direction']); unset($_REQUEST['status']); unset($_REQUEST['filter']); unset($_REQUEST['rows']); unset($_REQUEST['page']); } else { /* if any of the settings changed, reset the page number */ $changed = false; $changed += mikrotik_check_changed('status', 'sess_mikrotik_device_status'); $changed += mikrotik_check_changed('filter', 'sess_mikrotik_device_filter'); $changed += mikrotik_check_changed('rows', 'sess_default_rows'); if ($changed) { $_REQUEST['page'] = '1'; } } load_current_session_value('page', 'sess_mikrotik_device_current_page', '1'); load_current_session_value('rows', 'sess_default_rows', read_config_option('num_rows_table')); load_current_session_value('sort_column', 'sess_mikrotik_device_sort_column', 'description'); load_current_session_value('sort_direction', 'sess_mikrotik_device_sort_direction', 'ASC'); load_current_session_value('status', 'sess_mikrotik_device_status', '-1'); load_current_session_value('filter', 'sess_mikrotik_device_filter', ''); ?> <script type='text/javascript'> function applyFilter() { strURL = '?action=devices'; strURL += '&status=' + $('#status').val(); strURL += '&filter=' + $('#filter').val(); strURL += '&rows=' + $('#rows').val(); strURL += '&header=false'; loadPageNoHeader(strURL); } function clearFilter() { strURL = '?action=devices&clear=&header=false'; loadPageNoHeader(strURL); } $(function() { $('#form_devices').submit(function(event) { event.preventDefault(); applyFilter(); }); }); </script> <?php html_start_box('<strong>Device Filter</strong>', '100%', $colors['header'], '3', 'center', ''); ?> <tr class='even noprint'> <td> <form id='form_devices' action='mikrotik.php?action=devices'> <table class='filterTable'> <tr> <td> Search </td> <td> <input id='filter' type='text' size='25' value='<?php print get_request_var_request('filter'); ?> '> </td> <td> Status </td> <td> <select id='status' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var_request('type') == '-1') { ?> selected<?php } ?> >All</option> <?php $statuses = db_fetch_assoc('SELECT DISTINCT status FROM host INNER JOIN plugin_mikrotik_system ON host.id=plugin_mikrotik_system.host_id'); $statuses = array_merge($statuses, array('-2' => array('status' => '-2'))); if (sizeof($statuses)) { foreach ($statuses as $s) { switch ($s['status']) { case '0': $status = 'Unknown'; break; case '1': $status = 'Down'; break; case '2': $status = 'Recovering'; break; case '3': $status = 'Up'; break; case '-2': $status = 'Disabled'; break; } echo "<option value='" . $s['status'] . "' " . (get_request_var_request('status') == $s['status'] ? 'selected' : '') . '>' . $status . '</option>'; } } ?> </select> </td> <td> Devices </td> <td> <select id='rows' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var_request('rows') == '-1') { ?> selected<?php } ?> >Default</option> <?php if (sizeof($item_rows)) { foreach ($item_rows as $key => $name) { echo "<option value='" . $key . "' " . (get_request_var_request('rows') == $key ? 'selected' : '') . '>' . $name . '</option>'; } } ?> </select> </td> <td> <input id='refresh' type='button' onClick='applyFilter()' value='Go'> </td> <td> <input id='clear' type='button' onClick='clearFilter()' value='Clear'> </td> </tr> </table> <input type='hidden' id='page' name='page' value='<?php print $_REQUEST['page']; ?> '> </form> </td> </tr> <?php html_end_box(); html_start_box('', '100%', $colors['header'], '3', 'center', ''); if ($_REQUEST['rows'] == '-1') { $num_rows = read_config_option('num_rows_table'); } else { $num_rows = get_request_var_request('rows'); } $limit = ' LIMIT ' . $num_rows * (get_request_var_request('page') - 1) . ',' . $num_rows; $sql_where = ''; if ($_REQUEST['status'] != '-1') { $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' hrs.host_status=' . $_REQUEST['status']; } $sql_join = ''; if ($_REQUEST['filter'] != '') { $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . " h.description LIKE '%" . $_REQUEST['filter'] . "%' OR\n\t\t\th.hostname LIKE '%" . $_REQUEST['filter'] . "%'"; } $sql = "SELECT hrs.*, h.hostname, h.description, h.disabled, trees.trees, queues.queues\n\t\tFROM plugin_mikrotik_system AS hrs\n\t\tINNER JOIN host AS h \n\t\tON h.id=hrs.host_id\n\t\tLEFT JOIN (SELECT host_id AS hid, count(*) AS trees FROM plugin_mikrotik_trees GROUP BY host_id) AS trees\n\t\tON trees.hid=hrs.host_id\n\t\tLEFT JOIN (SELECT host_id AS hid, count(*) AS queues FROM plugin_mikrotik_queues GROUP BY host_id) AS queues\n\t\tON queues.hid=hrs.host_id\n\t\t{$sql_join}\n\t\t{$sql_where}\n\t\tORDER BY " . get_request_var_request("sort_column") . " " . get_request_var_request("sort_direction") . " " . $limit; //echo $sql; $rows = db_fetch_assoc($sql); $total_rows = db_fetch_cell("SELECT COUNT(*)\n\t\tFROM plugin_mikrotik_system AS hrs\n\t\tINNER JOIN host AS h\n\t\tON h.id=hrs.host_id\n\t\t{$sql_join}\n\t\t{$sql_where}"); $nav = html_nav_bar('mikrotik.php?action=devices', MAX_DISPLAY_PAGES, get_request_var_request('page'), $num_rows, $total_rows, 15, 'Devices', 'page', 'main'); print $nav; $display_text = array('nosort' => array('display' => 'Actions', 'sort' => 'ASC', 'align' => 'left'), 'description' => array('display' => 'Name', 'sort' => 'ASC', 'align' => 'left'), 'host_status' => array('display' => 'Status', 'sort' => 'DESC', 'align' => 'center'), 'firmwareVersion' => array('display' => 'FW Ver', 'sort' => 'DESC', 'align' => 'right'), 'licVersion' => array('display' => 'Lic Ver', 'sort' => 'DESC', 'align' => 'right'), 'uptime' => array('display' => 'Uptime(d:h:m)', 'sort' => 'DESC', 'align' => 'right'), 'trees' => array('display' => 'Trees', 'sort' => 'DESC', 'align' => 'right'), 'users' => array('display' => 'Users', 'sort' => 'DESC', 'align' => 'right'), 'cpuPercent' => array('display' => 'CPU %', 'sort' => 'DESC', 'align' => 'right'), 'numCpus' => array('display' => 'CPUs', 'sort' => 'DESC', 'align' => 'right'), 'processes' => array('display' => 'Processes', 'sort' => 'DESC', 'align' => 'right'), 'memSize' => array('display' => 'Total Mem', 'sort' => 'DESC', 'align' => 'right'), 'memUsed' => array('display' => 'Used Mem', 'sort' => 'DESC', 'align' => 'right'), 'diskSize' => array('display' => 'Total Disk', 'sort' => 'DESC', 'align' => 'right'), 'diskUsed' => array('display' => 'Used Disk', 'sort' => 'DESC', 'align' => 'right')); html_header_sort($display_text, get_request_var_request('sort_column'), get_request_var_request('sort_direction'), 'false'); /* set some defaults */ $url = $config['url_path'] . 'plugins/mikrotik/mikrotik.php'; $users = $config['url_path'] . 'plugins/mikrotik/images/view_users.gif'; $usersn = $config['url_path'] . 'plugins/mikrotik/images/view_users_none.gif'; $host = $config['url_path'] . 'plugins/mikrotik/images/view_hosts.gif'; $trees = $config['url_path'] . 'plugins/mikrotik/images/view_trees.gif'; $treesn = $config['url_path'] . 'plugins/mikrotik/images/view_trees_none.gif'; $queues = $config['url_path'] . 'plugins/mikrotik/images/view_queues.gif'; $queuesn = $config['url_path'] . 'plugins/mikrotik/images/view_queues_none.gif'; $interfaces = $config['url_path'] . 'plugins/mikrotik/images/view_interfaces.gif'; $dashboard = $config['url_path'] . 'plugins/mikrotik/images/view_dashboard.gif'; $graphs = $config['url_path'] . 'plugins/mikrotik/images/view_graphs.gif'; $nographs = $config['url_path'] . 'plugins/mikrotik/images/view_graphs_disabled.gif'; $hcpudq = read_config_option('mikrotik_dq_host_cpu'); if (sizeof($rows)) { foreach ($rows as $row) { $days = intval($row['uptime'] / (60 * 60 * 24 * 100)); $remainder = $row['uptime'] % (60 * 60 * 24 * 100); $hours = intval($remainder / (60 * 60 * 100)); $remainder = $remainder % (60 * 60 * 100); $minutes = intval($remainder / (60 * 100)); $found = db_fetch_cell('SELECT COUNT(*) FROM graph_local WHERE host_id=' . $row['host_id']); form_alternate_row(); echo "<td style='white-space:nowrap;min-width:115px;text-align:left;'>"; //echo "<a style='padding:1px;' href='" . htmlspecialchars("$url?action=dashboard&reset=1&device=" . $row["host_id"]) . "'><img src='$dashboard' title='View Dashboard' align='absmiddle' border='0'></a>"; if ($row['users'] > 0) { echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=users&reset=1&device=" . $row['host_id']) . "'><img src='{$users}' title='View Users' align='absmiddle' border='0' alt=''></a>"; } else { echo "<img style='border:0px;padding:3px;' src='{$usersn}' title='No Users Found' align='absmiddle' alt=''>"; } if ($row['queues'] > 0) { echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=queues&reset=1&device=" . $row['host_id']) . "'><img src='{$queues}' title='View Simple Queue' align='absmiddle' border='0' alt=''></a>"; } else { echo "<img style='border:0px;padding:3px;' src='{$queuesn}' title='No Simple Queues Found' align='absmiddle' alt=''>"; } if ($row['trees'] > 0) { echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=trees&reset=1&device=" . $row['host_id']) . "'><img src='{$trees}' title='View Queue Trees' align='absmiddle' border='0' alt=''></a>"; } else { echo "<img style='border:0px;padding:3px;' src='{$treesn}' title='No Queue Trees Found' align='absmiddle' alt=''>"; } echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=interfaces&reset=1&device=" . $row['host_id']) . "'><img src='{$interfaces}' title='View Interfaces' align='absmiddle' border='0' alt=''></a>"; if ($found) { echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=graphs&reset=1&host_id=" . $row['host_id'] . "&style=selective&graph_add=&graph_list=&graph_template_id=0&filter=") . "'><img src='{$graphs}' title='View Graphs' align='absmiddle' border='0' alt=''></a>"; } else { echo "<img src='{$nographs}' title='No Graphs Defined' align='absmiddle' border='0'>"; } $graph_cpu = mikrotik_get_graph_url($hcpudq, $row['host_id'], '', $row['numCpus'], false); $graph_cpup = mikrotik_get_graph_template_url(mikrotik_template_by_hash('7df474393f58bae8e8d6b85f10efad71'), $row['host_id'], round($row['cpuPercent'], 2), false); $graph_users = mikrotik_get_graph_template_url(mikrotik_template_by_hash('99e37ff13139f586d257ba9a637d7340'), $row['host_id'], empty($rows['users']) ? '-' : $row['users'], false); $graph_aproc = mikrotik_get_graph_template_url(mikrotik_template_by_hash('e797d967db24fd86341a8aa8c60fa9e0'), $row['host_id'], $row['host_status'] < 2 ? 'N/A' : $row['processes'], false); $graph_disk = mikrotik_get_graph_template_url(mikrotik_template_by_hash('0ece13b90785aa04d1f554a093685948'), $row['host_id'], $row['host_status'] < 2 ? 'N/A' : round($row['diskUsed'], 2), false); $graph_mem = mikrotik_get_graph_template_url(mikrotik_template_by_hash('4396ae857c4f9bc5ed1f26b5361e42d9'), $row['host_id'], $row['host_status'] < 2 ? 'N/A' : round($row['memUsed'], 2), false); $graph_upt = mikrotik_get_graph_template_url(mikrotik_template_by_hash('7d8dc3050621a2cb937cac3895bc5d5b'), $row['host_id'], $row['host_status'] < 2 ? 'N/A' : mikrotik_format_uptime($days, $hours, $minutes), false); if (api_plugin_user_realm_auth('host.php')) { $host_url = "<a class='hyperLink' href='" . htmlspecialchars($config['url_path'] . 'host.php?action=edit&id=' . $row['host_id']) . "' title='Edit Hosts'>" . $row['hostname'] . '</a>'; } else { $host_url = $row['hostname']; } echo '</td>'; echo "<td style='text-align:left;white-space:nowrap;'><strong>" . (strlen($_REQUEST['filter']) ? preg_replace('/(' . preg_quote(get_request_var_request('filter'), '/') . ')/i', "<span class='filteredValue'>\\1</span>", $row['description'] . '</strong> [' . $host_url . ']') : $row['description'] . '</strong> [' . $host_url . ']') . '</td>'; echo "<td style='text-align:center;'>" . get_colored_device_status($row['disabled'] == 'on' ? true : false, $row['host_status']) . '</td>'; echo "<td style='text-align:right;'>" . $row['firmwareVersion'] . '</td>'; echo "<td style='text-align:right;'>" . $row['licVersion'] . '</td>'; echo "<td style='text-align:right;'>" . $graph_upt . '</td>'; echo "<td style='text-align:right;'>" . (!empty($row['trees']) ? $row['trees'] : '-') . '</td>'; echo "<td style='text-align:right;'>" . $graph_users . '</td>'; echo "<td style='text-align:right;'>" . ($row['host_status'] < 2 ? 'N/A' : $graph_cpup) . '</td>'; echo "<td style='text-align:right;'>" . ($row['host_status'] < 2 ? 'N/A' : $graph_cpu) . '</td>'; echo "<td style='text-align:right;'>" . $graph_aproc . '</td>'; echo "<td style='text-align:right;'>" . mikrotik_memory($row['memSize']) . '</td>'; echo "<td style='text-align:right;'>" . $graph_mem . ' %</td>'; echo "<td style='text-align:right;'>" . mikrotik_memory($row['diskSize']) . '</td>'; echo "<td style='text-align:right;'>" . $graph_disk . ' %</td>'; form_end_row(); } print $nav; } else { print '<tr><td colspan="5"><em>No Devices Found</em></td></tr>'; } html_end_box(); }
function mikrotik_devices() { global $config, $colors, $item_rows; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request("status")); input_validate_input_number(get_request_var_request("page")); input_validate_input_number(get_request_var_request("rows")); /* ==================================================== */ /* clean up sort_column */ if (isset($_REQUEST["sort_column"])) { $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); } /* clean up sort_direction */ if (isset($_REQUEST["sort_direction"])) { $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); } /* clean up filter string */ if (isset($_REQUEST["filter"])) { $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter")); } if (isset($_REQUEST["reset"])) { kill_session_var("sess_mikrotik_device_sort_column"); kill_session_var("sess_mikrotik_device_sort_direction"); kill_session_var("sess_mikrotik_device_status"); kill_session_var("sess_mikrotik_device_filter"); kill_session_var("sess_mikrotik_device_rows"); kill_session_var("sess_mikrotik_device_current_page"); } elseif (isset($_REQUEST["clear"])) { kill_session_var("sess_mikrotik_device_sort_column"); kill_session_var("sess_mikrotik_device_sort_direction"); kill_session_var("sess_mikrotik_device_status"); kill_session_var("sess_mikrotik_device_filter"); kill_session_var("sess_mikrotik_device_rows"); kill_session_var("sess_mikrotik_device_current_page"); unset($_REQUEST["sort_column"]); unset($_REQUEST["sort_direction"]); unset($_REQUEST["status"]); unset($_REQUEST["filter"]); unset($_REQUEST["rows"]); unset($_REQUEST["page"]); } else { /* if any of the settings changed, reset the page number */ $changed = false; $changed += mikrotik_check_changed("status", "sess_mikrotik_device_status"); $changed += mikrotik_check_changed("fitler", "sess_mikrotik_device_filter"); $changed += mikrotik_check_changed("rows", "sess_mikrotik_device_rows"); if ($changed) { $_REQUEST["page"] = "1"; } } load_current_session_value("page", "sess_mikrotik_device_current_page", "1"); load_current_session_value("rows", "sess_mikrotik_device_rows", "-1"); load_current_session_value("sort_column", "sess_mikrotik_device_sort_column", "description"); load_current_session_value("sort_direction", "sess_mikrotik_device_sort_direction", "ASC"); load_current_session_value("status", "sess_mikrotik_device_status", "-1"); load_current_session_value("filter", "sess_mikrotik_device_filter", ""); ?> <script type="text/javascript"> <!-- function applyHostFilter(objForm) { strURL = '?action=devices'; strURL = strURL + '&status=' + objForm.status.value; strURL = strURL + '&filter=' + objForm.filter.value; strURL = strURL + '&rows=' + objForm.rows.value; document.location = strURL; } function clearHosts() { strURL = '?action=devices&clear='; document.location = strURL; } --> </script> <?php html_start_box("<strong>Device Filter</strong>", "100%", $colors["header"], "3", "center", ""); ?> <tr bgcolor="#<?php print $colors["panel"]; ?> "> <td> <form name="devices" action="mikrotik.php?action=devices"> <table cellpadding="0" cellspacing="0"> <tr> <td nowrap style='white-space: nowrap;' width="60"> Status: </td> <td width="1"> <select name="status" onChange="applyHostFilter(document.devices)"> <option value="-1"<?php if (get_request_var_request("type") == "-1") { ?> selected<?php } ?> >All</option> <?php $statuses = db_fetch_assoc("SELECT DISTINCT status\n\t\t\t\t\t\t\t\tFROM host\n\t\t\t\t\t\t\t\tINNER JOIN plugin_mikrotik_system\n\t\t\t\t\t\t\t\tON host.id=plugin_mikrotik_system.host_id"); $statuses = array_merge($statuses, array("-2" => array("status" => "-2"))); if (sizeof($statuses)) { foreach ($statuses as $s) { switch ($s["status"]) { case "0": $status = "Unknown"; break; case "1": $status = "Down"; break; case "2": $status = "Recovering"; break; case "3": $status = "Up"; break; case "-2": $status = "Disabled"; break; } echo "<option value='" . $s["status"] . "' " . (get_request_var_request("status") == $s["status"] ? "selected" : "") . ">" . $status . "</option>"; } } ?> </select> </td> <td nowrap style='white-space: nowrap;' width="60"> Rows: </td> <td width="1"> <select name="rows" onChange="applyHostFilter(document.devices)"> <option value="-1"<?php if (get_request_var_request("rows") == "-1") { ?> selected<?php } ?> >Default</option> <?php if (sizeof($item_rows)) { foreach ($item_rows as $key => $name) { echo "<option value='" . $key . "' " . (get_request_var_request("rows") == $key ? "selected" : "") . ">" . $name . "</option>"; } } ?> </select> </td> <td nowrap style='white-space: nowrap;' width="60"> Search: </td> <td> <input type='text' size='40' name='filter' value='<?php print get_request_var_request("filter"); ?> '> </td> <td nowrap> <input type="button" onClick="applyHostFilter(document.devices)" value="Go" border="0"> </td> <td nowrap> <input type="button" onClick="clearHosts()" value="Clear" name="clear" border="0"> </td> </tr> </table> <input type='hidden' name='action' value='devices'> </form> </td> </tr> <?php html_end_box(); html_start_box("", "100%", $colors["header"], "3", "center", ""); if ($_REQUEST["rows"] == "-1") { $num_rows = read_config_option("num_rows_device"); } else { $num_rows = get_request_var_request("rows"); } $limit = " LIMIT " . $num_rows * (get_request_var_request("page") - 1) . "," . $num_rows; $sql_where = ""; if ($_REQUEST["status"] != "-1") { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " hrs.host_status=" . $_REQUEST["status"]; } $sql_join = ""; if ($_REQUEST["filter"] != "") { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " host.description LIKE '%" . $_REQUEST["filter"] . "%' OR\n\t\t\thost.hostname LIKE '%" . $_REQUEST["filter"] . "%'"; } $sql = "SELECT hrs.*, host.hostname, host.description, host.disabled\n\t\tFROM plugin_mikrotik_system AS hrs\n\t\tINNER JOIN host ON host.id=hrs.host_id\n\t\t{$sql_join}\n\t\t{$sql_where}\n\t\tORDER BY " . get_request_var_request("sort_column") . " " . get_request_var_request("sort_direction") . " " . $limit; //echo $sql; $rows = db_fetch_assoc($sql); $total_rows = db_fetch_cell("SELECT COUNT(*)\n\t\tFROM plugin_mikrotik_system AS hrs\n\t\tINNER JOIN host ON host.id=hrs.host_id\n\t\t{$sql_join}\n\t\t{$sql_where}"); if ($total_rows > 0) { /* generate page list */ $url_page_select = get_page_list(get_request_var_request("page"), MAX_DISPLAY_PAGES, $num_rows, $total_rows, "mikrotik.php" . "?action=devices"); $nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t<td colspan='16'>\n\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td align='left' class='textHeaderDark'>\n\t\t\t\t\t\t\t<strong><< "; if (get_request_var_request("page") > 1) { $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("mikrotik.php" . "?action=devices&page=" . (get_request_var_request("page") - 1)) . "'>"; } $nav .= "Previous"; if (get_request_var_request("page") > 1) { $nav .= "</a>"; } $nav .= "</strong>\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\tShowing Rows " . ($num_rows * (get_request_var_request("page") - 1) + 1) . " to " . ($total_rows < $num_rows || $total_rows < $num_rows * get_request_var_request("page") ? $total_rows : $num_rows * get_request_var_request("page")) . " of {$total_rows} [{$url_page_select}]\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td align='right' class='textHeaderDark'>\n\t\t\t\t\t\t\t<strong>"; if (get_request_var_request("page") * $num_rows < $total_rows) { $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("mikrotik.php" . "?action=devices&page=" . (get_request_var_request("page") + 1)) . "'>"; } $nav .= "Next"; if (get_request_var_request("page") * $num_rows < $total_rows) { $nav .= "</a>"; } $nav .= " >></strong>\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t</td>\n\t\t</tr>\n"; } else { $nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t<td colspan='16'>\n\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\tNo Rows Found\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t</td>\n\t\t</tr>\n"; } print $nav; $display_text = array("nosort" => array("Actions", array("ASC", "left")), "description" => array("Name", array("ASC", "left")), "host_status" => array("Status", array("DESC", "right")), "uptime" => array("Uptime(d:h:m)", array("DESC", "right")), "users" => array("Users", array("DESC", "right")), "cpuPercent" => array("CPU %", array("DESC", "right")), "numCpus" => array("CPUs", array("DESC", "right")), "processes" => array("Processes", array("DESC", "right")), "memSize" => array("Total Mem", array("DESC", "right")), "memUsed" => array("Used Mem", array("DESC", "right")), "diskSize" => array("Total Disk", array("DESC", "right")), "diskUsed" => array("Used Disk", array("DESC", "right"))); mikrotik_header_sort($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"), "action=devices"); /* set some defaults */ $url = $config["url_path"] . "plugins/mikrotik/mikrotik.php"; $users = $config["url_path"] . "plugins/mikrotik/images/view_users.gif"; $host = $config["url_path"] . "plugins/mikrotik/images/view_hosts.gif"; $trees = $config["url_path"] . "plugins/mikrotik/images/view_trees.gif"; $dashboard = $config["url_path"] . "plugins/mikrotik/images/view_dashboard.gif"; $graphs = $config["url_path"] . "plugins/mikrotik/images/view_graphs.gif"; $nographs = $config["url_path"] . "plugins/mikrotik/images/view_graphs_disabled.gif"; $hcpudq = read_config_option("mikrotik_dq_host_cpu"); $i = 0; if (sizeof($rows)) { foreach ($rows as $row) { $days = intval($row["uptime"] / (60 * 60 * 24 * 100)); $remainder = $row["uptime"] % (60 * 60 * 24 * 100); $hours = intval($remainder / (60 * 60 * 100)); $remainder = $remainder % (60 * 60 * 100); $minutes = intval($remainder / (60 * 100)); $found = db_fetch_cell("SELECT COUNT(*) FROM graph_local WHERE host_id=" . $row["host_id"]); form_alternate_row_color($colors["alternate"], $colors["light"], $i); $i++; echo "<td width='100' align='left'>"; //echo "<a style='padding:1px;' href='" . htmlspecialchars("$url?action=dashboard&reset=1&device=" . $row["host_id"]) . "'><img src='$dashboard' title='View Dashboard' align='absmiddle' border='0'></a>"; echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?action=users&reset=1&device=" . $row["host_id"]) . "'><img src='{$users}' title='View Users' align='absmiddle' border='0'></a>"; echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?action=trees&reset=1&device=" . $row["host_id"]) . "'><img src='{$trees}' title='View Queue Trees' align='absmiddle' border='0'></a>"; if ($found) { echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?action=graphs&reset=1&host=" . $row["host_id"] . "&style=selective&graph_add=&graph_list=&graph_template_id=0&filter=") . "'><img src='{$graphs}' title='View Graphs' align='absmiddle' border='0'></a>"; } else { echo "<img src='{$nographs}' title='No Graphs Defined' align='absmiddle' border='0'>"; } $graph_cpu = mikrotik_get_graph_url($hcpudq, $row["host_id"], "", $row["numCpus"], false); $graph_cpup = mikrotik_get_graph_template_url(read_config_option("mikrotik_gt_cpu"), $row["host_id"], round($row["cpuPercent"], 2), false); $graph_users = mikrotik_get_graph_template_url(read_config_option("mikrotik_gt_users"), $row["host_id"], $row["users"], false); $graph_aproc = mikrotik_get_graph_template_url(read_config_option("mikrotik_gt_processes"), $row["host_id"], $row["host_status"] < 2 ? "N/A" : $row["processes"], false); $graph_disk = mikrotik_get_graph_template_url(read_config_option("mikrotik_gt_disk"), $row["host_id"], $row["host_status"] < 2 ? "N/A" : round($row["diskUsed"], 2), false); $graph_mem = mikrotik_get_graph_template_url(read_config_option("mikrotik_gt_memory"), $row["host_id"], $row["host_status"] < 2 ? "N/A" : round($row["memUsed"], 2), false); $graph_upt = mikrotik_get_graph_template_url(read_config_option("mikrotik_gt_uptime"), $row["host_id"], $row["host_status"] < 2 ? "N/A" : mikrotik_format_uptime($days, $hours, $minutes), false); if (api_plugin_user_realm_auth('host.php')) { $host_url = "<a href='" . htmlspecialchars($config["url_path"] . "host.php?action=edit&id=" . $row["host_id"]) . "' title='Edit Hosts'>" . $row["hostname"] . "</a>"; } else { $host_url = $row["hostname"]; } echo "</td>"; echo "<td style='white-space:nowrap;' align='left' width='200'><strong>" . $row["description"] . "</strong> [" . $host_url . "]" . "</td>"; echo "<td style='white-space:nowrap;' align='right'>" . get_colored_device_status($row["disabled"] == "on" ? true : false, $row["host_status"]) . "</td>"; echo "<td style='white-space:nowrap;' align='right'>" . $graph_upt . "</td>"; echo "<td style='white-space:nowrap;' align='right'>" . $graph_users . "</td>"; echo "<td style='white-space:nowrap;' align='right'>" . ($row["host_status"] < 2 ? "N/A" : $graph_cpup) . "</td>"; echo "<td style='white-space:nowrap;' align='right'>" . ($row["host_status"] < 2 ? "N/A" : $graph_cpu) . "</td>"; echo "<td style='white-space:nowrap;' align='right'>" . $graph_aproc . "</td>"; echo "<td style='white-space:nowrap;' align='right'>" . mikrotik_memory($row["memSize"]) . "</td>"; echo "<td style='white-space:nowrap;' align='right'>" . $graph_mem . " %</td>"; echo "<td style='white-space:nowrap;' align='right'>" . mikrotik_memory($row["diskSize"]) . "</td>"; echo "<td style='white-space:nowrap;' align='right'>" . $graph_disk . " %</td>"; } echo "</tr>"; print $nav; } else { print "<tr><td><em>No Devices Found</em></td></tr>"; } html_end_box(); }
function hmib_software() { global $config, $colors, $item_rows, $hmib_hrSWTypes; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request("template")); input_validate_input_number(get_request_var_request("page")); input_validate_input_number(get_request_var_request("rows")); input_validate_input_number(get_request_var_request("device")); input_validate_input_number(get_request_var_request("ostype")); input_validate_input_number(get_request_var_request("type")); /* ==================================================== */ /* clean up sort_column */ if (isset($_REQUEST["sort_column"])) { $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); } /* clean up sort_direction */ if (isset($_REQUEST["sort_direction"])) { $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); } /* clean up filter string */ if (isset($_REQUEST["filter"])) { $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter")); } if (isset($_REQUEST["reset"])) { kill_session_var("sess_hmib_sw_sort_column"); kill_session_var("sess_hmib_sw_sort_direction"); kill_session_var("sess_hmib_sw_template"); kill_session_var("sess_hmib_sw_filter"); kill_session_var("sess_hmib_sw_rows"); kill_session_var("sess_hmib_sw_device"); kill_session_var("sess_hmib_sw_ostype"); kill_session_var("sess_hmib_sw_type"); kill_session_var("sess_hmib_sw_current_page"); } elseif (isset($_REQUEST["clear"])) { kill_session_var("sess_hmib_sw_sort_column"); kill_session_var("sess_hmib_sw_sort_direction"); kill_session_var("sess_hmib_sw_template"); kill_session_var("sess_hmib_sw_filter"); kill_session_var("sess_hmib_sw_rows"); kill_session_var("sess_hmib_sw_device"); kill_session_var("sess_hmib_sw_ostype"); kill_session_var("sess_hmib_sw_type"); kill_session_var("sess_hmib_sw_current_page"); unset($_REQUEST["sort_column"]); unset($_REQUEST["sort_direction"]); unset($_REQUEST["template"]); unset($_REQUEST["filter"]); unset($_REQUEST["rows"]); unset($_REQUEST["device"]); unset($_REQUEST["ostype"]); unset($_REQUEST["type"]); unset($_REQUEST["page"]); } else { /* if any of the settings changed, reset the page number */ $changed = false; $changed += hmib_check_changed("ostype", "sess_hmib_sw_ostype"); $changed += hmib_check_changed("type", "sess_hmib_sw_type"); $changed += hmib_check_changed("status", "sess_hmib_sw_status"); $changed += hmib_check_changed("template", "sess_hmib_sw_template"); $changed += hmib_check_changed("filter", "sess_hmib_sw_filter"); $changed += hmib_check_changed("device", "sess_hmib_sw_device"); $changed += hmib_check_changed("rows", "sess_hmib_sw_rows"); if (hmib_check_changed("ostype", "sess_hmib_sw_ostype")) { $_REQUEST["device"] = -1; $changed = true; } if ($changed) { $_REQUEST["page"] = "1"; } } load_current_session_value("page", "sess_hmib_sw_current_page", "1"); load_current_session_value("rows", "sess_hmib_sw_rows", "-1"); load_current_session_value("ostype", "sess_hmib_sw_ostype", "-1"); load_current_session_value("type", "sess_hmib_sw_type", "-1"); load_current_session_value("device", "sess_hmib_sw_device", "-1"); load_current_session_value("sort_column", "sess_hmib_sw_sort_column", "name"); load_current_session_value("sort_direction", "sess_hmib_sw_sort_direction", "ASC"); load_current_session_value("template", "sess_hmib_sw_template", "-1"); load_current_session_value("filter", "sess_hmib_sw_filter", ""); ?> <script type="text/javascript"> <!-- function applySWFilter(objForm) { strURL = '?action=software'; strURL = strURL + '&template=' + objForm.template.value; strURL = strURL + '&filter=' + objForm.filter.value; strURL = strURL + '&rows=' + objForm.rows.value; strURL = strURL + '&device=' + objForm.device.value; strURL = strURL + '&ostype=' + objForm.ostype.value; strURL = strURL + '&type=' + objForm.type.value; document.location = strURL; } function clearSW() { strURL = '?action=software&clear='; document.location = strURL; } --> </script> <?php html_start_box("<strong>Software Inventory</strong>", "100%", $colors["header"], "3", "center", ""); ?> <tr bgcolor="#<?php print $colors["panel"]; ?> "> <td> <form name="software" method="get" action="hmib.php?action=software"> <table cellpadding="0" cellspacing="0"> <tr> <td nowrap style='white-space: nowrap;' width="60"> OS Type: </td> <td width="1"> <select name="ostype" onChange="applySWFilter(document.software)"> <option value="-1"<?php if (get_request_var_request("ostype") == "-1") { ?> selected<?php } ?> >All</option> <?php $ostypes = db_fetch_assoc("SELECT DISTINCT id, CONCAT_WS('', name, ' [', version, ']') AS name\n\t\t\t\t\t\t\t\tFROM plugin_hmib_hrSystemTypes AS hrst\n\t\t\t\t\t\t\t\tINNER JOIN plugin_hmib_hrSystem AS hrs\n\t\t\t\t\t\t\t\tON hrst.id=hrs.host_type\n\t\t\t\t\t\t\t\tWHERE name!='' ORDER BY name"); if (sizeof($ostypes)) { foreach ($ostypes as $t) { echo "<option value='" . $t["id"] . "' " . (get_request_var_request("ostype") == $t["id"] ? "selected" : "") . ">" . $t["name"] . "</option>"; } } ?> </select> </td> <td nowrap style='white-space: nowrap;' width="60"> Device: </td> <td width="1"> <select name="device" onChange="applySWFilter(document.software)"> <option value="-1"<?php if (get_request_var_request("device") == "-1") { ?> selected<?php } ?> >All</option> <?php $hosts = db_fetch_assoc("SELECT DISTINCT host.id, host.description\n\t\t\t\t\t\t\t\tFROM plugin_hmib_hrSystem AS hrs\n\t\t\t\t\t\t\t\tINNER JOIN host\n\t\t\t\t\t\t\t\tON hrs.host_id=host.id " . (get_request_var_request("ostype") > 0 ? "WHERE hrs.host_type=" . get_request_var_request("ostype") : "") . " ORDER BY description"); if (sizeof($hosts)) { foreach ($hosts as $h) { echo "<option value='" . $h["id"] . "' " . (get_request_var_request("device") == $h["id"] ? "selected" : "") . ">" . $h["description"] . "</option>"; } } ?> </select> </td> <td nowrap style='white-space: nowrap;' width="60"> Device Template: </td> <td width="1"> <select name="template" onChange="applySWFilter(document.software)"> <option value="-1"<?php if (get_request_var_request("template") == "-1") { ?> selected<?php } ?> >All</option> <?php $templates = db_fetch_assoc("SELECT DISTINCT ht.id, ht.name\n\t\t\t\t\t\t\t\tFROM host_template AS ht\n\t\t\t\t\t\t\t\tINNER JOIN host\n\t\t\t\t\t\t\t\tON ht.id=host.host_template_id\n\t\t\t\t\t\t\t\tINNER JOIN plugin_hmib_hrSystem AS hrs\n\t\t\t\t\t\t\t\tON host.id=hrs.host_id\n\t\t\t\t\t\t\t\tORDER BY name"); if (sizeof($templates)) { foreach ($templates as $t) { echo "<option value='" . $t["id"] . "' " . (get_request_var_request("template") == $t["id"] ? "selected" : "") . ">" . $t["name"] . "</option>"; } } ?> </select> </td> <td nowrap style='white-space: nowrap;' width="60"> Rows: </td> <td width="1"> <select name="rows" onChange="applySWFilter(document.software)"> <option value="-1"<?php if (get_request_var_request("rows") == "-1") { ?> selected<?php } ?> >Default</option> <?php if (sizeof($item_rows)) { foreach ($item_rows as $key => $name) { echo "<option value='" . $key . "' " . (get_request_var_request("rows") == $key ? "selected" : "") . ">" . $name . "</option>"; } } ?> </select> </td> </tr> </table> <table cellpadding="0" cellspacing="0"> <tr> <td nowrap style='white-space: nowrap;' width="60"> Type: </td> <td width="1"> <select name="type" onChange="applySWFilter(document.software)"> <option value="-1"<?php if (get_request_var_request("type") == "-1") { ?> selected<?php } ?> >All</option> <?php $types = db_fetch_assoc("SELECT DISTINCT type\n\t\t\t\t\t\t\t\tFROM plugin_hmib_hrSWInstalled\n\t\t\t\t\t\t\t\tORDER BY type"); if (sizeof($types)) { foreach ($types as $t) { echo "<option value='" . $t["type"] . "' " . (get_request_var_request("type") == $t["type"] ? "selected" : "") . ">" . $hmib_hrSWTypes[$t["type"]] . "</option>"; } } ?> </select> </td> <td nowrap style='white-space: nowrap;' width="60"> Search: </td> <td> <input type='text' size='40' name='filter' value='<?php print get_request_var_request("filter"); ?> '> </td> <td nowrap> <input type="button" onClick="applySWFilter(document.software)" value="Go" border="0"> <input type="button" onClick="clearSW()" value="Clear" name="clear" border="0"> </td> </tr> </table> <input type='hidden' name='action' value='software'> </form> </td> </tr> <?php html_end_box(); html_start_box("", "100%", $colors["header"], "3", "center", ""); if ($_REQUEST["rows"] == "-1") { $num_rows = read_config_option("num_rows_device"); } else { $num_rows = get_request_var_request("rows"); } $limit = " LIMIT " . $num_rows * (get_request_var_request("page") - 1) . "," . $num_rows; $sql_where = ""; if ($_REQUEST["template"] != "-1") { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " host.host_template_id=" . $_REQUEST["template"]; } if ($_REQUEST["device"] != "-1") { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " host.id=" . $_REQUEST["device"]; } if ($_REQUEST["ostype"] != "-1") { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " hrs.host_type=" . $_REQUEST["ostype"]; } if ($_REQUEST["type"] != "-1") { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " hrswi.type=" . $_REQUEST["type"]; } if ($_REQUEST["filter"] != "") { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " (host.description LIKE '%" . $_REQUEST["filter"] . "%' OR\n\t\t\thrswi.name LIKE '%" . $_REQUEST["filter"] . "%' OR\n\t\t\thrswi.date LIKE '%" . $_REQUEST["filter"] . "%' OR\n\t\t\thost.hostname LIKE '%" . $_REQUEST["filter"] . "%')"; } $sql = "SELECT hrswi.*, host.hostname, host.description, host.disabled\n\t\tFROM plugin_hmib_hrSWInstalled AS hrswi\n\t\tINNER JOIN host ON host.id=hrswi.host_id\n\t\tINNER JOIN plugin_hmib_hrSystem AS hrs ON host.id=hrs.host_id\n\t\t{$sql_where}\n\t\tORDER BY " . get_request_var_request("sort_column") . " " . get_request_var_request("sort_direction") . " " . $limit; //echo $sql; $rows = db_fetch_assoc($sql); $total_rows = db_fetch_cell("SELECT COUNT(*)\n\t\tFROM plugin_hmib_hrSWInstalled AS hrswi\n\t\tINNER JOIN host ON host.id=hrswi.host_id\n\t\tINNER JOIN plugin_hmib_hrSystem AS hrs ON host.id=hrs.host_id\n\t\t{$sql_where}"); if ($total_rows > 0) { /* generate page list */ $url_page_select = get_page_list(get_request_var_request("page"), MAX_DISPLAY_PAGES, $num_rows, $total_rows, "hmib.php" . "?action=software"); $nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t<td colspan='16'>\n\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td align='left' class='textHeaderDark'>\n\t\t\t\t\t\t\t<strong><< "; if (get_request_var_request("page") > 1) { $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("hmib.php" . "?action=software&page=" . (get_request_var_request("page") - 1)) . "'>"; } $nav .= "Previous"; if (get_request_var_request("page") > 1) { $nav .= "</a>"; } $nav .= "</strong>\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\tShowing Rows " . ($num_rows * (get_request_var_request("page") - 1) + 1) . " to " . ($total_rows < $num_rows || $total_rows < $num_rows * get_request_var_request("page") ? $total_rows : $num_rows * get_request_var_request("page")) . " of {$total_rows} [{$url_page_select}]\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td align='right' class='textHeaderDark'>\n\t\t\t\t\t\t\t<strong>"; if (get_request_var_request("page") * $num_rows < $total_rows) { $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("hmib.php" . "?action=software&page=" . (get_request_var_request("page") + 1)) . "'>"; } $nav .= "Next"; if (get_request_var_request("page") * $num_rows < $total_rows) { $nav .= "</a>"; } $nav .= " >></strong>\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t</td>\n\t\t</tr>\n"; } else { $nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t<td colspan='16'>\n\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\tNo Rows Found\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t</td>\n\t\t</tr>\n"; } print $nav; $display_text = array("description" => array("Name", array("ASC", "left")), "name" => array("Package", array("DESC", "left")), "type" => array("Type", array("ASC", "left")), "date" => array("Installed", array("DESC", "right"))); hmib_header_sort($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"), "action=software"); $i = 0; if (sizeof($rows)) { foreach ($rows as $row) { form_alternate_row_color($colors["alternate"], $colors["light"], $i); $i++; if (api_plugin_user_realm_auth('host.php')) { $host_url = "<a href='" . htmlspecialchars($config["url_path"] . "host.php?action=edit&id=" . $row["host_id"]) . "' title='Edit Hosts'>" . $row["hostname"] . "</a>"; } else { $host_url = $row["hostname"]; } echo "<td style='white-space:nowrap;' align='left' width='200'><strong>" . (strlen($_REQUEST["filter"]) ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $row["description"] . "</strong> [" . $host_url) : $row["description"] . "</strong> [" . $host_url) . "]</td>"; echo "<td style='white-space:nowrap;' align='left'>" . (strlen($_REQUEST["filter"]) ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $row["name"]) : $row["name"]) . "</td>"; echo "<td style='white-space:nowrap;' align='left'>" . (isset($hmib_hrSWTypes[$row["type"]]) ? $hmib_hrSWTypes[$row["type"]] : "Unknown") . "</td>"; echo "<td style='white-space:nowrap;' align='right'>" . (strlen($_REQUEST["filter"]) ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $row["date"]) : $row["date"]) . "</td>"; } echo "</tr>"; print $nav; } else { print "<tr><td><em>No Software Packages Found</em></td></tr>"; } html_end_box(); }
function hmib_software() { global $config, $item_rows, $hmib_hrSWTypes; /* ================= input validation and session storage ================= */ $filters = array('rows' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'page' => array('filter' => FILTER_VALIDATE_INT, 'default' => '1'), 'template' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'device' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'type' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'ostype' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'sort_column' => array('filter' => FILTER_CALLBACK, 'default' => 'name', 'options' => array('options' => 'sanitize_search_string')), 'sort_direction' => array('filter' => FILTER_CALLBACK, 'default' => 'ASC', 'options' => array('options' => 'sanitize_search_string'))); validate_store_request_vars($filters, 'sess_hmib_sw'); /* ================= input validation ================= */ ?> <script type='text/javascript'> function applyFilter(objForm) { strURL = '?action=software'; strURL += '&template=' + $('#template').val(); strURL += '&filter=' + $('#filter').val(); strURL += '&rows=' + $('#rows').val(); strURL += '&device=' + $('#device').val(); strURL += '&ostype=' + $('#ostype').val(); strURL += '&type=' + $('#type').val(); strURL += '&page=' + $('#page').val(); strURL += '&header=false'; $.get(strURL, function(data) { $('#main').html(data); applyFilter(); }); } function clearFilter() { strURL = '?action=software&clear=true&header=false'; $.get(strURL, function(data) { $('#main').html(data); applyFilter(); }); } $(function() { $('#software').submit(function(event) { event.preventDefault(); applyFilter(); }); }); </script> <?php html_start_box(__('Software Inventory'), '100%', '', '3', 'center', ''); ?> <tr class='even'> <td> <form id='software' method='get'> <table class='filterTable'> <tr> <td style='width:55px;white-space:nowrap;'> <?php print __('OS Type'); ?> </td> <td> <select id='ostype' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var('ostype') == '-1') { ?> selected<?php } ?> ><?php print __('All'); ?> </option> <?php $ostypes = db_fetch_assoc("SELECT DISTINCT id, CONCAT_WS('', name, ' [', version, ']') AS name\n\t\t\t\t\t\t\t\tFROM plugin_hmib_hrSystemTypes AS hrst\n\t\t\t\t\t\t\t\tINNER JOIN plugin_hmib_hrSystem AS hrs\n\t\t\t\t\t\t\t\tON hrst.id=hrs.host_type\n\t\t\t\t\t\t\t\tWHERE name!='' ORDER BY name"); if (sizeof($ostypes)) { foreach ($ostypes as $t) { echo "<option value='" . $t['id'] . "' " . (get_request_var('ostype') == $t['id'] ? 'selected' : '') . '>' . $t['name'] . '</option>'; } } ?> </select> </td> <td> <?php print __('Device'); ?> </td> <td> <select id='device' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var('device') == '-1') { ?> selected<?php } ?> ><?php print __('All'); ?> </option> <?php $hosts = db_fetch_assoc('SELECT DISTINCT host.id, host.description FROM plugin_hmib_hrSystem AS hrs INNER JOIN host ON hrs.host_id=host.id ' . (get_request_var('ostype') > 0 ? 'WHERE hrs.host_type=' . get_request_var('ostype') : '') . ' ORDER BY description'); if (sizeof($hosts)) { foreach ($hosts as $h) { echo "<option value='" . $h['id'] . "' " . (get_request_var('device') == $h['id'] ? 'selected' : '') . '>' . $h['description'] . '</option>'; } } ?> </select> </td> <td> <?php print __('Template'); ?> </td> <td> <select id='template' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var('template') == '-1') { ?> selected<?php } ?> ><?php print __('All'); ?> </option> <?php $templates = db_fetch_assoc('SELECT DISTINCT ht.id, ht.name FROM host_template AS ht INNER JOIN host ON ht.id=host.host_template_id INNER JOIN plugin_hmib_hrSystem AS hrs ON host.id=hrs.host_id ORDER BY name'); if (sizeof($templates)) { foreach ($templates as $t) { echo "<option value='" . $t['id'] . "' " . (get_request_var('template') == $t['id'] ? 'selected' : '') . '>' . $t['name'] . '</option>'; } } ?> </select> </td> <td> <input type='button' onClick='applyFilter()' value='<?php print __('Go'); ?> '> </td> <td> <input type='button' onClick='clearFilter()' value='<?php print __('Clear'); ?> '> </td> </tr> </table> <table class='filterTable'> <tr> <td style='width:55px;'> <?php print __('Search'); ?> </td> <td> <input type='textbox' size='25' id='filter' value='<?php print get_request_var('filter'); ?> '> </td> <td> <?php print __('Type'); ?> </td> <td> <select id='type' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var('type') == '-1') { ?> selected<?php } ?> ><?php print __('All'); ?> </option> <?php $types = db_fetch_assoc('SELECT DISTINCT type FROM plugin_hmib_hrSWInstalled ORDER BY type'); if (sizeof($types)) { foreach ($types as $t) { echo "<option value='" . $t['type'] . "' " . (get_request_var('type') == $t['type'] ? 'selected' : '') . '>' . $hmib_hrSWTypes[$t['type']] . '</option>'; } } ?> </select> </td> <td> <?php print __('Applications'); ?> </td> <td> <select id='rows' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var('rows') == '-1') { ?> selected<?php } ?> ><?php print __('Default'); ?> </option> <?php if (sizeof($item_rows)) { foreach ($item_rows as $key => $name) { echo "<option value='" . $key . "' " . (get_request_var('rows') == $key ? 'selected' : '') . '>' . $name . '</option>'; } } ?> </select> </td> </tr> </table> <input type='hidden' id='page' value='<?php print get_request_var('page'); ?> '> </form> </td> </tr> <?php html_end_box(); if (get_request_var('rows') == '-1') { $num_rows = read_config_option('num_rows_table'); } else { $num_rows = get_request_var('rows'); } $limit = ' LIMIT ' . $num_rows * (get_request_var('page') - 1) . ',' . $num_rows; $sql_where = ''; if (get_request_var('template') != '-1') { $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' host.host_template_id=' . get_request_var('template'); } if (get_request_var('device') != '-1') { $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' host.id=' . get_request_var('device'); } if (get_request_var('ostype') != '-1') { $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' hrs.host_type=' . get_request_var('ostype'); } if (get_request_var('type') != '-1') { $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' hrswi.type=' . get_request_var('type'); } if (get_request_var('filter') != '') { $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . " (host.description LIKE '%" . get_request_var('filter') . "%' OR\n\t\t\thrswi.name LIKE '%" . get_request_var('filter') . "%' OR\n\t\t\thrswi.date LIKE '%" . get_request_var('filter') . "%' OR\n\t\t\thost.hostname LIKE '%" . get_request_var('filter') . "%')"; } $sql = "SELECT hrswi.*, host.hostname, host.description, host.disabled\n\t\tFROM plugin_hmib_hrSWInstalled AS hrswi\n\t\tINNER JOIN host ON host.id=hrswi.host_id\n\t\tINNER JOIN plugin_hmib_hrSystem AS hrs ON host.id=hrs.host_id\n\t\t{$sql_where}\n\t\tORDER BY " . get_request_var('sort_column') . ' ' . get_request_var('sort_direction') . ' ' . $limit; $rows = db_fetch_assoc($sql); $total_rows = db_fetch_cell("SELECT COUNT(*)\n\t\tFROM plugin_hmib_hrSWInstalled AS hrswi\n\t\tINNER JOIN host ON host.id=hrswi.host_id\n\t\tINNER JOIN plugin_hmib_hrSystem AS hrs ON host.id=hrs.host_id\n\t\t{$sql_where}"); $nav = html_nav_bar('hmib.php?action=software', MAX_DISPLAY_PAGES, get_request_var('page'), $num_rows, $total_rows, 16, __('Applications'), 'page', 'main'); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array('description' => array('display' => __('Hostname'), 'sort' => 'ASC', 'align' => 'left'), 'name' => array('display' => __('Package'), 'sort' => 'DESC', 'align' => 'left'), 'type' => array('display' => __('Type'), 'sort' => 'ASC', 'align' => 'left'), 'date' => array('display' => __('Installed'), 'sort' => 'DESC', 'align' => 'right')); html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false, 'hmib.php?action=software'); if (sizeof($rows)) { foreach ($rows as $row) { form_alternate_row(); if (api_plugin_user_realm_auth('host.php')) { $host_url = "<a href='" . htmlspecialchars($config['url_path'] . 'host.php?action=edit&id=' . $row['host_id']) . "' title='" . __('Edit Device') . "'>" . $row['hostname'] . '</a>'; } else { $host_url = $row['hostname']; } echo "<td>" . (strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span style='background-color: #F8D93D;'>\\1</span>", $row['description'] . ' [' . $host_url) : $row['description'] . ' [' . $host_url) . ']</td>'; echo "<td>" . (strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span style='background-color: #F8D93D;'>\\1</span>", $row['name']) : $row['name']) . '</td>'; echo "<td>" . (isset($hmib_hrSWTypes[$row['type']]) ? $hmib_hrSWTypes[$row['type']] : 'Unknown') . '</td>'; echo "<td class='right'>" . (strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", $row['date']) : $row['date']) . '</td>'; } echo '</tr>'; } else { print '<tr><td><em>' . __('No Software Packages Found') . '</em></td></tr>'; } html_end_box(false); if (sizeof($rows)) { print $nav; } }
/** function syslog_messages() * This is the main page display function in Syslog. Displays all the * syslog messages that are relevant to Syslog. */ function syslog_messages($tab = 'syslog') { global $sql_where, $hostfilter, $severities; global $config, $syslog_incoming_config, $reset_multi, $syslog_levels; include dirname(__FILE__) . '/config.php'; include './include/global_arrays.php'; /* force the initial timespan to be 30 minutes for performance reasons */ if (!isset($_SESSION['sess_syslog_init'])) { $_SESSION['sess_current_timespan'] = 1; $_SESSION['sess_syslog_init'] = 1; } $url_curr_page = get_browser_query_string(); $sql_where = ''; 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'); } $syslog_messages = get_syslog_messages($sql_where, $row_limit, $tab); syslog_filter($sql_where, $tab); if ($tab == 'syslog') { if (get_request_var('removal') == 1) { $total_rows = syslog_db_fetch_cell("SELECT SUM(totals)\n\t\t\t\tFROM (\n\t\t\t\t\tSELECT count(*) AS totals\n\t\t\t\t\tFROM `" . $syslogdb_default . "`.`syslog` AS syslog\n\t\t\t\t\t{$sql_where}\n\t\t\t\t\tUNION\n\t\t\t\t\tSELECT count(*) AS totals\n\t\t\t\t\tFROM `" . $syslogdb_default . "`.`syslog_removed` AS syslog\n\t\t\t\t\t{$sql_where}\n\t\t\t\t) AS rowcount"); } elseif (get_request_var("removal") == -1) { $total_rows = syslog_db_fetch_cell("SELECT count(*) \n\t\t\t\tFROM `" . $syslogdb_default . "`.`syslog` AS syslog\n\t\t\t\t{$sql_where}"); } else { $total_rows = syslog_db_fetch_cell("SELECT count(*) \n\t\t\t\tFROM `" . $syslogdb_default . "`.`syslog_removed` AS syslog\n\t\t\t\t{$sql_where}"); } } else { $total_rows = syslog_db_fetch_cell("SELECT count(*)\n\t\t\tFROM `" . $syslogdb_default . "`.`syslog_logs` AS syslog\n\t\t\tLEFT JOIN `" . $syslogdb_default . "`.`syslog_facilities` AS sf\n\t\t\tON syslog.facility_id=sf.facility_id \n\t\t\tLEFT JOIN `" . $syslogdb_default . "`.`syslog_priorities` AS sp\n\t\t\tON syslog.priority_id=sp.priority_id \n\t\t\tLEFT JOIN `" . $syslogdb_default . "`.`syslog_alert` AS sa\n\t\t\tON syslog.alert_id=sa.id \n\t\t\tLEFT JOIN `" . $syslogdb_default . "`.`syslog_programs` AS spr\n\t\t\tON syslog.program_id=spr.program_id " . $sql_where); } if ($tab == 'syslog') { $nav = html_nav_bar("syslog.php?tab={$tab}", MAX_DISPLAY_PAGES, get_request_var_request('page'), $row_limit, $total_rows, 7, 'Messages', 'page', 'main'); if (api_plugin_user_realm_auth('syslog_alerts.php')) { $display_text = array('nosortt' => array(__('Actions'), 'ASC'), 'logtime' => array(__('Date'), 'ASC'), 'host_id' => array(__('Host'), 'ASC'), 'program' => array(__('Program'), 'ASC'), 'message' => array(__('Message'), 'ASC'), 'facility_id' => array(__('Facility'), 'ASC'), 'priority_id' => array(__('Priority'), 'ASC')); } else { $display_text = array('logtime' => array(__('Date'), 'ASC'), 'host_id' => array(__('Host'), 'ASC'), 'program' => array(__('Program'), 'ASC'), 'message' => array(__('Message'), 'ASC'), 'facility_id' => array(__('Facility'), 'ASC'), 'priority_id' => array(__('Priority'), 'ASC')); } print $nav; html_start_box('', '100%', '', '3', 'center', ''); html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction')); $hosts = array_rekey(syslog_db_fetch_assoc('SELECT host_id, host FROM `' . $syslogdb_default . '`.`syslog_hosts`'), 'host_id', 'host'); $facilities = array_rekey(syslog_db_fetch_assoc('SELECT facility_id, facility FROM `' . $syslogdb_default . '`.`syslog_facilities`'), 'facility_id', 'facility'); $priorities = array_rekey(syslog_db_fetch_assoc('SELECT priority_id, priority FROM `' . $syslogdb_default . '`.`syslog_priorities`'), 'priority_id', 'priority'); if (sizeof($syslog_messages)) { foreach ($syslog_messages as $syslog_message) { $title = htmlspecialchars($syslog_message['message'], ENT_QUOTES); syslog_row_color($syslog_message['priority_id'], $title); if (api_plugin_user_realm_auth('syslog_alerts.php')) { print "<td class='nowrap left' style='width:1%:padding:1px !important;'>"; if ($syslog_message['mtype'] == 'main') { print "<a style='padding:1px' href='" . htmlspecialchars('syslog_alerts.php?id=' . $syslog_message[$syslog_incoming_config['id']] . '&action=newedit&type=0') . "'><img src='images/add.png' border='0'></a>\n\t\t\t\t\t\t<a style='padding:1px' href='" . htmlspecialchars('syslog_removal.php?id=' . $syslog_message[$syslog_incoming_config['id']] . '&action=newedit&type=new&type=0') . "'><img src='images/delete.png' border='0'></a>\n"; } print "</td>\n"; } print '<td class="left nowrap">' . $syslog_message['logtime'] . "</td>\n"; print '<td class="left nowrap">' . $hosts[$syslog_message['host_id']] . "</td>\n"; print '<td class="left nowrap">' . $syslog_message['program'] . "</td>\n"; print '<td class="left syslogMessage">' . filter_value(title_trim($syslog_message[$syslog_incoming_config['textField']], get_request_var_request('trimval')), get_request_var('filter')) . "</td>\n"; print '<td class="left nowrap">' . ucfirst($facilities[$syslog_message['facility_id']]) . "</td>\n"; print '<td class="left nowrap">' . ucfirst($priorities[$syslog_message['priority_id']]) . "</td>\n"; } } else { print "<tr><td class='center' colspan='7'><em>" . __('No Syslog Messages') . "</em></td></tr>"; } html_end_box(false); if (sizeof($syslog_messages)) { print $nav; } syslog_syslog_legend(); print "<script type='text/javascript'>\$(function() { \$('button').tooltip({ closed: true }).on('focus', function() { \$('#filter').tooltip('close') }).on('click', function() { \$(this).tooltip('close'); }); })</script>\n"; } else { $nav = html_nav_bar("syslog.php?tab={$tab}", MAX_DISPLAY_PAGES, get_request_var_request('page'), $row_limit, $total_rows, 8, 'Alert Log Rows', 'page', 'main'); print $nav; $display_text = array('name' => array('display' => __('Alert Name'), 'sort' => 'ASC', 'align' => 'left'), 'severity' => array('display' => __('Severity'), 'sort' => 'ASC', 'align' => 'left'), 'logtime' => array('display' => __('Date'), 'sort' => 'ASC', 'align' => 'left'), 'logmsg' => array('display' => __('Message'), 'sort' => 'ASC', 'align' => 'left'), 'count' => array('display' => __('Count'), 'sort' => 'ASC', 'align' => 'right'), 'host' => array('display' => __('Host'), 'sort' => 'ASC', 'align' => 'right'), 'facility_id' => array('display' => __('Facility'), 'sort' => 'ASC', 'align' => 'right'), 'priority_id' => array('display' => __('Priority'), 'sort' => 'ASC', 'align' => 'right')); html_start_box('', '100%', '', '3', 'center', ''); html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction')); if (sizeof($syslog_messages)) { foreach ($syslog_messages as $log) { $title = htmlspecialchars($log['logmsg'], ENT_QUOTES); syslog_row_color($log['severity'], $title); print "<td class='left'><a class='linkEditMain' href='" . htmlspecialchars($config['url_path'] . 'plugins/syslog/syslog.php?id=' . $log['seq'] . '&tab=current') . "'>" . (strlen($log['name']) ? $log['name'] : 'Alert Removed') . "</a></td>\n"; print '<td class="left nowrap">' . (isset($severities[$log['severity']]) ? $severities[$log['severity']] : 'Unknown') . "</td>\n"; print '<td class="left nowrap">' . $log['logtime'] . "</td>\n"; print '<td class="left syslogMessage">' . filter_value(title_trim($log['logmsg'], get_request_var_request('trimval')), get_request_var('filter')) . "</td>\n"; print '<td class="right nowrap">' . $log['count'] . "</td>\n"; print '<td class="right nowrap">' . $log['host'] . "</td>\n"; print '<td class="right nowrap">' . ucfirst($log['facility']) . "</td>\n"; print '<td class="right nowrap">' . ucfirst($log['priority']) . "</td>\n"; print "</tr>\n"; } } else { print "<tr><td colspan='11'><em>" . __('No Alert Log Messages') . "</em></td></tr>"; } html_end_box(false); if (sizeof($syslog_messages)) { print $nav; } syslog_log_legend(); } }