function mactrack_device_request_validation() { /* ================= 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'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'sort_column' => array('filter' => FILTER_CALLBACK, 'default' => 'site_name', 'options' => array('options' => 'sanitize_search_string')), 'sort_direction' => array('filter' => FILTER_CALLBACK, 'default' => 'ASC', 'options' => array('options' => 'sanitize_search_string')), 'site_id' => array('filter' => FILTER_VALIDATE_INT, 'default' => '-1', 'pageset' => true), 'type_id' => array('filter' => FILTER_VALIDATE_INT, 'default' => '-1', 'pageset' => true), 'status' => array('filter' => FILTER_VALIDATE_INT, 'default' => '-1', 'pageset' => true), 'device_type_id' => array('filter' => FILTER_VALIDATE_INT, 'default' => '-1', 'pageset' => true), 'detail' => array('filter' => FILTER_CALLBACK, 'default' => 'false', 'options' => array('options' => 'sanitize_search_string'))); validate_store_request_vars($filters, 'sess_mactrack_device'); /* ================= input validation ================= */ }
function validate_request_vars($force = false) { /* ================= input validation and session storage ================= */ $filters = array('id' => array('filter' => FILTER_VALIDATE_INT, 'default' => '-1'), 'tree_id' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_config_option('cycle_custom_graphs_tree', $force)), 'leaf_id' => array('filter' => FILTER_VALIDATE_INT, 'default' => '-2'), 'graphs' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('cycle_graphs', read_config_option('cycle_graphs'), $force)), 'cols' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('cycle_columns', read_config_option('cycle_columns'), $force)), 'width' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('cycle_width', read_config_option('cycle_width'), $force)), 'height' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('cycle_height', read_config_option('cycle_height'), $force)), 'timespan' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('cycle_timespan', read_config_option('cycle_timespan'), $force)), 'delay' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('cycle_delay', read_config_option('cycle_delay'), $force)), 'legend' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => read_user_setting('cycle_legend', read_config_option('cycle_legend'), $force), 'options' => array('options' => 'sanitize_search_string')), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => read_user_setting('cycle_filter', '', $force), 'options' => array('options' => 'sanitize_search_string'))); validate_store_request_vars($filters, 'sess_cycle'); /* ================= input validation ================= */ }
function mactrack_vmacs_validate_request_vars() { /* ================= 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'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'sort_column' => array('filter' => FILTER_CALLBACK, 'default' => 'vendor_mac', '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_mactrack_vmacs'); /* ================= input validation ================= */ }
function mikrotik_user() { global $user_actions, $item_rows; /* ================= input validation and session storage ================= */ $filters = array('rows' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'type' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'page' => array('filter' => FILTER_VALIDATE_INT, 'default' => '1'), 'status' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), '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_mtue'); /* ================= input validation and session storage ================= */ /* if the number of rows is -1, set it to the default */ if (get_request_var('rows') != '-1') { $rows = get_request_var('rows'); } else { $rows = read_config_option('num_rows_table'); } ?> <script type='text/javascript'> function applyFilter(objForm) { strURL = 'mikrotik_users.php?filter=' + $('#filter').val(); strURL += '&status=' + $('#status').val(); strURL += '&type=' + $('#type').val(); strURL += '&rows=' + $('#rows').val(); strURL += '&header=false'; loadPageNoHeader(strURL); } function clearFilter() { strURL = 'mikrotik_users.php?clear=1'; strURL += '&header=false'; loadPageNoHeader(strURL); } $(function() { $('#users').submit(function(event) { event.preventDefault(); applyFilter(); }); }); </script> <?php html_start_box(__('MikroTik Users'), '100%', '', '3', 'center', ''); ?> <tr class='even'> <td> <form id='users' action='mikrotik_users.php'> <table class='filterTable'> <tr> <td> <?php print __('Search'); ?> </td> <td> <input type='text' id='filter' size='25' value='<?php print htmlspecialchars(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> <option value='0'<?php if (get_request_var('type') == '0') { ?> selected<?php } ?> ><?php print __('Hotspot'); ?> </option> <option value='1'<?php if (get_request_var('type') == '1') { ?> selected<?php } ?> ><?php print __('PPPoe'); ?> </option> </select> </td> <td> <?php print __('Users'); ?> </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) > 0) { foreach ($item_rows as $key => $value) { print "<option value='" . $key . "'"; if (get_request_var('rows') == $key) { print ' selected'; } print '>' . htmlspecialchars($value) . "</option>\n"; } } ?> </select> </td> <td> <?php print __('Status'); ?> </td> <td> <select id='status' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var('status') == '-1') { ?> selected<?php } ?> ><?php print __('All'); ?> </option> <option value='1'<?php if (get_request_var('status') == '1') { ?> selected<?php } ?> ><?php print __('Active'); ?> </option> <option value='2'<?php if (get_request_var('status') == '2') { ?> selected<?php } ?> ><?php print __('Inactive'); ?> </option> </select> <td> <input type='button' value='<?php print __('Go'); ?> ' title='<?php print __('Set/Refresh Filters'); ?> ' onClick='applyFilter()'> </td> <td> <input type='button' name='clear_x' value='<?php print __('Clear'); ?> ' title='<?php print __('Clear Filters'); ?> ' onClick='clearFilter()'> </td> </tr> </table> <input type='hidden' name='page' value='1'> </form> </td> </tr> <?php html_end_box(); /* form the 'where' clause for our main sql query */ if (strlen(get_request_var('filter'))) { $sql_where = "WHERE (name LIKE '%%" . get_request_var('filter') . "%%') AND name!=''"; } else { $sql_where = "WHERE name!=''"; } if (get_request_var('status') == 1) { $sql_where .= ' AND present=1'; } elseif (get_request_var('status') == 2) { $sql_where .= ' AND present=0'; } if (get_request_var('type') == '0') { $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' userType=0'; } elseif (get_request_var('type') == '1') { $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' userType=1'; } $total_rows = db_fetch_cell("SELECT \n\t\tCOUNT(DISTINCT name)\n\t\tFROM plugin_mikrotik_users\n\t\t{$sql_where}"); $sortby = get_request_var('sort_column'); $sql_query = "SELECT name, domain, userType, MAX(last_seen) AS last_seen, MAX(present) AS present\n\t\tFROM plugin_mikrotik_users\n\t\t{$sql_where}\n\t\tGROUP BY name, domain\n\t\tORDER BY " . $sortby . ' ' . get_request_var('sort_direction') . ' LIMIT ' . $rows * (get_request_var('page') - 1) . ',' . $rows; $users = db_fetch_assoc($sql_query); $nav = html_nav_bar('mikrotik_users.php?filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 6, __('Users'), 'page', 'main'); form_start('mikrotik_users.php', 'chk'); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array('name' => array(__('User Name'), 'ASC'), 'domain' => array(__('Domain'), 'ASC'), 'type' => array(__('Type'), 'ASC'), 'last_seen' => array(__('Last Seen'), 'DESC'), 'present' => array(__('Active'), 'ASC')); html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false); if (sizeof($users)) { foreach ($users as $user) { form_alternate_row('line' . $user['name'], true); form_selectable_cell("<span class='noLinkEditMain'>" . filter_value($user['name'], get_request_var('filter')) . '</span>', $user['name'], 250); form_selectable_cell($user['domain'] != '' ? $user['domain'] : 'Not Set', $user['name']); form_selectable_cell($user['userType'] == '0' ? 'Hotspot' : 'PPPoe', $user['name']); form_selectable_cell($user['last_seen'], $user['name']); form_selectable_cell($user['present'] == 0 ? '<b><i>' . __('Inactive') . '</i></b>' : '<b><i>' . __('Active') . '</i></b>', $user['name']); form_checkbox_cell($user['name'], $user['name']); form_end_row(); } } else { print '<tr><td><em>' . __('No Users Found') . '</em></td></tr>'; } html_end_box(false); if (sizeof($users)) { print $nav; } /* draw the dropdown containing a list of available actions for this form */ draw_actions_dropdown($user_actions); form_end(); }
/** * This is a generic funtion for this page that makes sure that * we have a good request. We want to protect against people who * like to create issues with Cacti. */ function thold_request_validation() { global $title, $rows_selector, $config, $reset_multi; /* ================= 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'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'sort_column' => array('filter' => FILTER_CALLBACK, 'default' => 'thold_alert', 'options' => array('options' => 'sanitize_search_string')), 'sort_direction' => array('filter' => FILTER_CALLBACK, 'default' => 'DESC', 'options' => array('options' => 'sanitize_search_string')), 'state' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => read_config_option('thold_filter_default')), 'data_template_id' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'host_id' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1')); validate_store_request_vars($filters, 'sess_lth'); /* ================= input validation ================= */ }
function mactrack_view_macs_validate_request_vars() { /* ================= 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'), 'site_id' => array('filter' => FILTER_VALIDATE_INT, 'default' => '-1'), 'device_id' => array('filter' => FILTER_VALIDATE_INT, 'default' => '-1'), 'vlan' => array('filter' => FILTER_VALIDATE_INT, 'default' => '-1'), 'mac_filter_type_id' => array('filter' => FILTER_VALIDATE_INT, 'default' => '1'), 'port_name_filter_type_id' => array('filter' => FILTER_VALIDATE_INT, 'default' => '1'), 'ip_filter_type_id' => array('filter' => FILTER_VALIDATE_INT, 'default' => '1'), 'authorized' => array('filter' => FILTER_VALIDATE_INT, 'default' => '-1', 'pageset' => true), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'ip_filter' => array('filter' => FILTER_CALLBACK, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'mac_filter' => array('filter' => FILTER_CALLBACK, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'port_name_filter' => array('filter' => FILTER_CALLBACK, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'scan_date' => array('filter' => FILTER_CALLBACK, 'default' => '2', 'options' => array('options' => 'sanitize_search_string')), 'sort_column' => array('filter' => FILTER_CALLBACK, 'default' => 'device_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_mactrack_view_macs'); /* ================= input validation ================= */ }
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 mactrack_snmp() { global $config, $item_rows; global $mactrack_snmp_actions; /* ================= 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'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), '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_mactrack_snmp'); /* ================= input validation ================= */ if (get_request_var('rows') == '-1') { $rows = read_config_option('num_rows_table'); } else { $rows = get_request_var('rows'); } html_start_box(__('Mactrack SNMP Options'), '100%', '', '3', 'center', 'mactrack_snmp.php?action=edit'); snmp_options_filter(); html_end_box(); /* form the 'where' clause for our main sql query */ $sql_where = ''; if (get_request_var('filter') != '') { $sql_where .= "WHERE (mac_track_snmp.name LIKE '%" . get_request_var('filter') . "%')"; } $total_rows = db_fetch_cell("SELECT\n\t\tCOUNT(mac_track_snmp.id)\n\t\tFROM mac_track_snmp\n\t\t{$sql_where}"); $snmp_groups = db_fetch_assoc("SELECT *\n\t\tFROM mac_track_snmp\n\t\t{$sql_where}\n\t\tORDER BY " . get_request_var('sort_column') . ' ' . get_request_var('sort_direction') . ' LIMIT ' . $rows * (get_request_var('page') - 1) . ',' . $rows); $nav = html_nav_bar('mactrack_snmp.php?filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 12, __('SNMP Settings')); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array('name' => array(__('Title of SNMP Option Set'), 'ASC')); html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction')); if (sizeof($snmp_groups)) { foreach ($snmp_groups as $snmp_group) { form_alternate_row('line' . $snmp_group['id'], true); form_selectable_cell(filter_value($snmp_group['name'], get_request_var('filter'), 'mactrack_snmp.php?action=edit&id=' . $snmp_group['id'] . '&page=1'), $snmp_group['id']); form_checkbox_cell($snmp_group['name'], $snmp_group['id']); form_end_row(); } } else { print '<tr><td colspan="3"><em>' . __('No SNMP Option Sets') . '</em></td></tr>'; } html_end_box(false); if (sizeof($snmp_groups)) { print $nav; } draw_actions_dropdown($mactrack_snmp_actions); form_end(); }
function syslog_removal() { global $syslog_actions, $message_types, $config; include dirname(__FILE__) . '/config.php'; /* ================= 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'), 'id' => array('filter' => FILTER_VALIDATE_INT, 'default' => '1'), 'enabled' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), '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_syslogr'); /* ================= input validation ================= */ html_start_box(__('Syslog Removal Rule Filters'), '100%', '', '3', 'center', 'syslog_removal.php?action=edit&type=1'); syslog_filter(); html_end_box(); $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'); } $removals = syslog_get_removal_records($sql_where, $row_limit); $rows_query_string = "SELECT COUNT(*)\n\t\tFROM `" . $syslogdb_default . "`.`syslog_remove`\n\t\t{$sql_where}"; $total_rows = syslog_db_fetch_cell($rows_query_string); $nav = html_nav_bar('syslog_removal.php?filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_request_var('page'), $row_limit, $total_rows, 13, 'Rules', 'page', 'main'); form_start('syslog_removal.php', 'chk'); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array('name' => array(__('Removal Name'), 'ASC'), 'enabled' => array(__('Enabled'), 'ASC'), 'type' => array(__('Match Type'), 'ASC'), 'message' => array(__('Search String'), 'ASC'), 'method' => array(__('Method'), 'DESC'), 'date' => array(__('Last Modified'), 'ASC'), 'user' => array(__('By User'), 'DESC')); html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction')); if (sizeof($removals)) { foreach ($removals as $removal) { form_alternate_row('line' . $removal['id'], true); form_selectable_cell(filter_value(title_trim($removal['name'], read_config_option('max_title_length')), get_request_var('filter'), $config['url_path'] . 'plugins/syslog/syslog_removal.php?action=edit&id=' . $removal['id']), $removal['id']); form_selectable_cell($removal['enabled'] == 'on' ? __('Yes') : __('No'), $removal['id']); form_selectable_cell($message_types[$removal['type']], $removal['id']); form_selectable_cell($removal['message'], $removal['id']); form_selectable_cell($removal['method'] == 'del' ? __('Deletion') : __('Transfer'), $removal['id']); form_selectable_cell(date('Y-m-d H:i:s', $removal['date']), $removal['id']); form_selectable_cell($removal['user'], $removal['id']); form_checkbox_cell($removal['name'], $removal['id']); form_end_row(); } } else { print "<tr><td colspan='4'><em>" . __('No Syslog Removal Rules Defined') . "</em></td></tr>"; } html_end_box(false); if (sizeof($removals)) { print $nav; } draw_actions_dropdown($syslog_actions); form_end(); }
function template_request_validation() { /* ================= 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'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), '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')), 'associated' => array('filter' => FILTER_CALLBACK, 'default' => 'true', 'options' => array('options' => 'sanitize_search_string'))); validate_store_request_vars($filters, 'sess_tt'); /* ================= input validation ================= */ }
function syslog_alerts() { global $syslog_actions, $config, $message_types, $severities; include dirname(__FILE__) . '/config.php'; /* ================= 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'), 'id' => array('filter' => FILTER_VALIDATE_INT, 'default' => '1'), 'enabled' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), '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_sysloga'); /* ================= input validation ================= */ html_start_box(__('Syslog Alert Filters'), '100%', '', '3', 'center', 'syslog_alerts.php?action=edit'); syslog_filter(); html_end_box(); $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'); } $alerts = syslog_get_alert_records($sql_where, $row_limit); $rows_query_string = "SELECT COUNT(*)\n\t\tFROM `" . $syslogdb_default . "`.`syslog_alert`\n\t\t{$sql_where}"; $total_rows = syslog_db_fetch_cell($rows_query_string); $nav = html_nav_bar('syslog_alerts.php?filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_request_var('page'), $row_limit, $total_rows, 13, __('Alerts'), 'page', 'main'); form_start('syslog_alerts.php', 'chk'); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array('name' => array(__('Alert Name'), 'ASC'), 'severity' => array(__('Severity'), 'ASC'), 'method' => array(__('Method'), 'ASC'), 'num' => array(__('Threshold Count'), 'ASC'), 'enabled' => array(__('Enabled'), 'ASC'), 'type' => array(__('Match Type'), 'ASC'), 'message' => array(__('Search String'), 'ASC'), 'email' => array(__('E-Mail Addresses'), 'DESC'), 'date' => array(__('Last Modified'), 'ASC'), 'user' => array(__('By User'), 'DESC')); html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction')); if (sizeof($alerts)) { foreach ($alerts as $alert) { form_alternate_row('line' . $alert['id'], true); form_selectable_cell("<a class='linkEditMain' href='" . $config['url_path'] . 'plugins/syslog/syslog_alerts.php?action=edit&id=' . $alert['id'] . "'>" . (get_request_var('filter') != '' ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", $alert['name']) : $alert['name']) . '</a>', $alert['id']); form_selectable_cell($severities[$alert['severity']], $alert['id']); form_selectable_cell($alert['method'] == 1 ? __('Threshold') : __('Individual'), $alert['id']); form_selectable_cell($alert['method'] == 1 ? $alert['num'] : __('N/A'), $alert['id']); form_selectable_cell($alert['enabled'] == 'on' ? __('Yes') : __('No'), $alert['id']); form_selectable_cell($message_types[$alert['type']], $alert['id']); form_selectable_cell(title_trim($alert['message'], 60), $alert['id']); form_selectable_cell(substr_count($alert['email'], ',') ? __('Multiple') : $alert['email'], $alert['id']); form_selectable_cell(date('Y-m-d H:i:s', $alert['date']), $alert['id']); form_selectable_cell($alert['user'], $alert['id']); form_checkbox_cell($alert['name'], $alert['id']); form_end_row(); } } else { print "<tr><td colspan='4'><em>" . __('No Syslog Alerts Defined') . "</em></td></tr>"; } html_end_box(false); if (sizeof($alerts)) { print $nav; } draw_actions_dropdown($syslog_actions); form_end(); }
function mikrotik_devices() { global $config, $item_rows; /* ================= input validation and session storage ================= */ $filters = array('rows' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => read_config_option('num_rows_table')), 'page' => array('filter' => FILTER_VALIDATE_INT, 'default' => '1'), 'status' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'sort_column' => array('filter' => FILTER_CALLBACK, 'default' => 'description', '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_mtd'); /* ================= input validation ================= */ ?> <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(__('Device Filter'), '100%', '', '3', 'center', ''); ?> <tr class='even noprint'> <td> <form id='form_devices' action='mikrotik.php?action=devices'> <table class='filterTable'> <tr> <td> <?php print __('Search'); ?> </td> <td> <input id='filter' type='text' size='25' value='<?php print get_request_var('filter'); ?> '> </td> <td> <?php print __('Status'); ?> </td> <td> <select id='status' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var('type') == '-1') { ?> selected<?php } ?> ><?php print __('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('status') == $s['status'] ? 'selected' : '') . '>' . $status . '</option>'; } } ?> </select> </td> <td> <?php print __('Devices'); ?> </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> <td> <input id='refresh' type='button' onClick='applyFilter()' value='<?php print __('Go'); ?> '> </td> <td> <input id='clear' type='button' onClick='clearFilter()' value='<?php print __('Clear'); ?> '> </td> </tr> </table> <input type='hidden' id='page' name='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('status') != '-1') { $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' hrs.host_status=' . get_request_var('status'); } $sql_join = ''; if (get_request_var('filter') != '') { $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . " h.description LIKE '%" . get_request_var('filter') . "%' OR\n\t\t\th.hostname LIKE '%" . get_request_var('filter') . "%'"; } $sql = "SELECT hrs.*, h.hostname, h.description, h.disabled, trees.trees, queues.queues, aps.aps\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\tLEFT JOIN (SELECT host_id AS hid, count(*) AS aps FROM plugin_mikrotik_wireless_aps GROUP BY host_id) AS aps\n\t\tON aps.hid=hrs.host_id\n\t\t{$sql_join}\n\t\t{$sql_where}\n\t\tORDER BY " . get_request_var("sort_column") . " " . get_request_var("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('page'), $num_rows, $total_rows, 16, __('Devices'), 'page', 'main'); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array('nosort' => array('display' => __('Actions'), 'sort' => 'ASC', 'align' => 'left'), 'description' => array('display' => __('Name'), 'sort' => 'ASC', 'align' => 'left'), 'sysDescr' => array('display' => __('Description'), '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('sort_column'), get_request_var('sort_direction'), 'false', 'mikrotik.php?action=devices'); /* 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'; $aps = $config['url_path'] . 'plugins/mikrotik/images/view_aps.gif'; $apsn = $config['url_path'] . 'plugins/mikrotik/images/view_aps_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>"; } elseif (read_config_option('mikrotik_users_freq') != '-1') { 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>"; } elseif (read_config_option('mikrotik_queues_freq') != '-1') { 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>"; } elseif (read_config_option('mikrotik_trees_freq') != '-1') { echo "<img style='border:0px;padding:3px;' src='{$treesn}' title='" . __('No Queue Trees Found') . "' align='absmiddle' alt=''>"; } if ($row['aps'] > 0) { echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=wireless_aps&reset=1&device=" . $row['host_id']) . "'><img src='{$aps}' title='" . __('View Wireless Aps') . "' align='absmiddle' border='0' alt=''></a>"; } elseif (read_config_option('mikrotik_wireless_aps_freq') != '-1') { echo "<img style='border:0px;padding:3px;' src='{$apsn}' title='" . __('No Wireless Aps 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($row['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 Device'>" . (strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter'), '/') . ')/i', "<span class='filteredValue'>\\1</span>", $row['description']) : $row['description']) . '</a>'; } else { $host_url = $row['description']; } echo '</td>'; echo "<td style='text-align:left;white-space:nowrap;'>" . $host_url . '</td>'; echo "<td style='text-align:left;'>" . $row['sysDescr'] . '</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['firmwareVersionLatest'] != $row['firmwareVersion'] && $row['firmwareVersionLatest'] != '' ? '* ' : '') . $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 == '-' ? '-' : $graph_mem . ' %') . '</td>'; echo "<td style='text-align:right;'>" . mikrotik_memory($row['diskSize']) . '</td>'; echo "<td style='text-align:right;'>" . ($graph_disk == '-' ? '-' : $graph_disk . ' %') . '</td>'; form_end_row(); } } else { print '<tr><td colspan="5"><em>' . __('No Devices Found') . '</em></td></tr>'; } html_end_box(); if (sizeof($rows)) { print $nav; } echo '<script type="text/javascript">$(function() { $("a.hyperLink, img").tooltip(); });</script>'; }
function mactrack_macw() { global $macw_actions, $config, $item_rows; /* ================= 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'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), '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_mactrack_macw'); /* ================= input validation ================= */ 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(__('MacTrack MacWatch Filters'), '100%', '', '3', 'center', 'mactrack_macwatch.php?action=edit'); mactrack_macw_filter(); html_end_box(); $sql_where = ''; $macw = mactrack_macw_get_macw_records($sql_where, $row_limit); $total_rows = db_fetch_cell("SELECT count(*) FROM mac_track_macwatch {$sql_where}"); $nav = html_nav_bar('mactrack_macwatch.php?filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_request_var('page'), $row_limit, $total_rows, 9, __('Watches')); form_start('mactrack_macwatch.php', 'chk'); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array('name' => array(__('Watch Name'), 'ASC'), 'mac_address' => array(__('Mac Address'), 'ASC'), 'ticket_number' => array(__('Ticket Number'), 'ASC'), 'nosort' => array(__('Watch Description'), 'ASC'), 'date_first_seen' => array(__('First Seen'), 'ASC'), 'date_last_seen' => array(__('Last Seen'), 'ASC')); html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction')); $i = 0; if (sizeof($macw)) { foreach ($macw as $mac) { form_alternate_row('line' . $mac['mac_id'], true); form_selectable_cell(filter_value($mac['name'], get_request_var('filter'), 'mactrack_macwatch.php?action=edit&mac_id=' . $mac['mac_id']), $mac['mac_id']); form_selectable_cell(filter_value($mac['mac_address'], get_request_var('filter')), $mac['mac_id']); form_selectable_cell(filter_value($mac['ticket_number'], get_request_var('filter')), $mac['mac_id']); form_selectable_cell(filter_value($mac['description'], get_request_var('filter')), $mac['mac_id']); form_selectable_cell($mac['date_first_seen'] == '0000-00-00 00:00:00' ? __('N/A') : $mac['date_first_seen'], $mac['mac_id']); form_selectable_cell($mac['date_last_seen'] == '0000-00-00 00:00:00' ? __('N/A') : $mac['date_last_seen'], $mac['mac_id']); form_selectable_cell($mac['name'], $mac['mac_id']); form_end_row(); } } else { print '<tr><td colspan="10"><em>' . __('No MacTrack Watched Macs') . '</em></td></tr>'; } html_end_box(false); if (sizeof($macw)) { print $nav; } /* draw the dropdown containing a list of available actions for this form */ draw_actions_dropdown($macw_actions); form_end(); }
function show_schedules() { global $sendinterval_arr, $colors, $config, $sched_actions, $item_rows; /* ================= 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'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'sort_column' => array('filter' => FILTER_CALLBACK, 'default' => 'title', '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_fvs'); /* ================= input validation ================= */ if (get_request_var('rows') == '-1') { $rows = read_config_option('num_rows_table'); } else { $rows = get_request_var('rows'); } html_start_box('FlowView Schedules', '100%', '', '3', 'center', 'flowview_schedules.php?action=edit'); ?> <tr class='even'> <td> <form name='form_schedule' action='flowview_schedules.php'> <table class='filterTable'> <tr> <td> Search </td> <td> <input type='text' id='filter' size='25' value='<?php print htmlspecialchars(get_request_var('filter')); ?> '> </td> <td> <?php print __('Schedules'); ?> </td> <td> <select id='rows' onChange='applyFilter()'> <option value='-1'<?php print (get_request_var('rows') == '-1' ? ' selected>' : '>') . __('Default'); ?> </option> <?php if (sizeof($item_rows)) { foreach ($item_rows as $key => $value) { print "<option value='" . $key . "'"; if (get_request_var('rows') == $key) { print ' selected'; } print '>' . $value . "</option>\n"; } } ?> </select> </td> <td> <input type='submit' value='Go' title='Set/Refresh Filters'> </td> <td> <input type='submit' name='clear' value='Clear' title='Clear Filters'> </td> </tr> </table> <input type='hidden' name='page' value='1'> </form> </td> </tr> <?php html_end_box(); if (get_request_var('filter') != '') { $sql_where = "WHERE (name LIKE '%" . get_request_var_request('filter') . "%')"; } else { $sql_where = ''; } $sql = "SELECT pfs.*, pfq.name \n\t\tFROM plugin_flowview_schedules AS pfs\n\t\tLEFT JOIN plugin_flowview_queries AS pfq \n\t\tON (pfs.savedquery=pfq.id) \n\t\t{$sql_where}\n\t\tORDER BY " . get_request_var_request('sort_column') . ' ' . get_request_var_request('sort_direction') . ' LIMIT ' . $rows * (get_request_var('page') - 1) . ", {$rows}"; $result = db_fetch_assoc($sql); $total_rows = db_fetch_cell("SELECT COUNT(*) \n\t\tFROM plugin_flowview_schedules AS pfs\n\t\tLEFT JOIN plugin_flowview_queries AS pfq \n\t\tON (pfs.savedquery=pfq.id) \n\t\t{$sql_where}"); $nav = html_nav_bar('flowview_schedules.php?filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 5, 'Schedules', 'page', 'main'); form_start('flowview_schedules.php', 'chk'); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_array = array('title' => array('Schedule Title', 'ASC'), 'name' => array('Filter Name', 'ASC'), 'sendinterval' => array('Interval', 'ASC'), 'start' => array('Start Date', 'ASC'), 'lastsent+sendinterval' => array('Next Send', 'ASC'), 'email' => array('Email', 'ASC'), 'enabled' => array('Enabled', 'ASC')); html_header_sort_checkbox($display_array, get_request_var_request('sort_column'), get_request_var_request('sort_direction'), false); $i = 0; if (count($result)) { foreach ($result as $row) { form_alternate_row('line' . $row['id'], true); form_selectable_cell('<a class="linkEditMain" href="' . htmlspecialchars('flowview_schedules.php?tab=sched&action=edit&id=' . $row['id']) . '">' . $row['title'] . '</a>', $row['id']); form_selectable_cell($row['name'], $row['id']); form_selectable_cell($sendinterval_arr[$row['sendinterval']], $row['id']); form_selectable_cell($row['start'], $row['id']); form_selectable_cell(date('Y-m-d G:i:s', $row['lastsent'] + $row['sendinterval']), $row['id']); form_selectable_cell($row['email'], $row['id']); form_selectable_cell($row['enabled'] == 'on' ? "<span class='deviceUp'><b>Yes</b></span>" : "<span class='deviceDown'><b>No</b></span>", $row['id']); form_checkbox_cell($row['name'], $row['id']); form_end_row(); } } html_end_box(false); if (count($result)) { print $nav; } draw_actions_dropdown($sched_actions); form_end(); }
function lists() { global $actions, $item_rows; /* ================= 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'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'sort_column' => array('filter' => FILTER_CALLBACK, 'default' => 'description', '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_lists'); /* ================= input validation ================= */ /* if the number of rows is -1, set it to the default */ if (get_request_var('rows') == -1) { $rows = read_config_option('num_rows_table'); } else { $rows = get_request_var('rows'); } html_start_box(__('Notification Lists'), '100%', '', '3', 'center', 'notify_lists.php?action=edit'); ?> <tr class='even'> <td> <form id='lists' action='notify_lists.php'> <table class='filterTable'> <tr> <td> <?php print __('Search'); ?> </td> <td> <input type='text' id='filter' size='25' value='<?php print htmlspecialchars(get_request_var('filter')); ?> '> </td> <td> <?php print __('Lists'); ?> </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) > 0) { foreach ($item_rows as $key => $value) { print "<option value='" . $key . "'"; if (get_request_var('rows') == $key) { print ' selected'; } print '>' . htmlspecialchars($value) . "</option>\n"; } } ?> </select> </td> <td> <input type='button' value='<?php print __('Go'); ?> ' title='<?php print __('Set/Refresh Filters'); ?> ' onClick='applyFilter()'> </td> <td> <input type='button' name='clear' value='<?php print __('Clear'); ?> ' title='<?php print __('Clear Filters'); ?> ' onClick='clearFilter()'> </td> </tr> </table> <input type='hidden' id='page' value='<?php print get_filter_request_var('page'); ?> '> </form> <script type='text/javascript'> function applyFilter() { strURL = 'notify_lists.php?header=false'; strURL += '&rows=' + $('#rows').val(); strURL += '&filter=' + $('#filter').val(); loadPageNoHeader(strURL); } function clearFilter() { strURL = 'notify_lists.php?header=false&clear=1'; loadPageNoHeader(strURL); } $(function() { $('#lists').submit(function(event) { event.preventDefault(); applyFilter(); }); }); </script> </td> </tr> <?php html_end_box(); /* form the 'where' clause for our main sql query */ if (strlen(get_request_var('filter'))) { $sql_where = "WHERE (name LIKE '%" . get_request_var('filter') . "%' OR\n\t\tdescription LIKE '%" . get_request_var('filter') . "%' OR\n\t\temails LIKE '%" . get_request_var('filter') . "%')"; } else { $sql_where = ''; } $total_rows = db_fetch_cell("SELECT\n\t\tCOUNT(*)\n\t\tFROM plugin_notification_lists\n\t\t{$sql_where}"); $lists = db_fetch_assoc("SELECT id, name, description, emails\n\t\tFROM plugin_notification_lists\n\t\t{$sql_where}\n\t\tORDER BY " . get_request_var('sort_column') . ' ' . get_request_var('sort_direction') . ' LIMIT ' . $rows * (get_request_var('page') - 1) . ',' . $rows); $nav = html_nav_bar('notify_lists.php?filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 10, __('Lists'), 'page', 'main'); form_start('notify_lists.php', 'chk'); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array('name' => array(__('List Name'), 'ASC'), 'description' => array(__('Description'), 'ASC'), 'emails' => array(__('Emails'), 'ASC')); html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false); if (sizeof($lists)) { foreach ($lists as $item) { form_alternate_row('line' . $item['id'], true); form_selectable_cell(filter_value($item['name'], get_request_var('filter'), 'notify_lists.php?action=edit&id=' . $item['id']), $item['id'], '25%'); form_selectable_cell(filter_value($item['description'], get_request_var('filter')), $item['id'], '35%'); form_selectable_cell(filter_value($item['emails'], get_request_var('filter')), $item['id']); form_checkbox_cell($item['name'], $item['id']); form_end_row(); } } else { print '<tr><td><em>' . __('No Notification Lists') . '</em></td></tr>'; } html_end_box(false); if (sizeof($lists)) { print $nav; } form_hidden_box('save_list', '1', ''); /* draw the dropdown containing a list of available actions for this form */ draw_actions_dropdown($actions); form_end(); }
function thold_show_log() { global $config, $item_rows, $thold_log_states, $thold_status, $thold_types, $thold_log_retention; $step = read_config_option('poller_interval'); /* ================= 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'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'sort_column' => array('filter' => FILTER_CALLBACK, 'default' => 'time', 'options' => array('options' => 'sanitize_search_string')), 'sort_direction' => array('filter' => FILTER_CALLBACK, 'default' => 'DESC', 'options' => array('options' => 'sanitize_search_string')), 'threshold_id' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'host_id' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'status' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1')); validate_store_request_vars($filters, 'sess_thold_log'); /* ================= input validation ================= */ /* if the number of rows is -1, set it to the default */ if (get_request_var('rows') == -1) { $rows = read_config_option('num_rows_table'); } else { $rows = get_request_var('rows'); } $days = read_config_option('thold_log_storage'); if (isset($thold_log_retention[$days])) { $days = $thold_log_retention[$days]; } else { $days = __('%d Days', $days); } html_start_box(__('Threshold Log for [ %s ]', $days), '100%', '', '3', 'center', ''); form_thold_log_filter(); html_end_box(); $sql_where = ''; if (get_request_var('host_id') == '-1') { /* Show all items */ } elseif (get_request_var('host_id') == '0') { $sql_where .= (strlen($sql_where) ? ' AND' : '') . ' h.id IS NULL'; } elseif (!isempty_request_var('host_id')) { $sql_where .= (strlen($sql_where) ? ' AND' : '') . ' tl.host_id=' . get_request_var('host_id'); } if (get_request_var('threshold_id') == '-1') { /* Show all items */ } elseif (get_request_var('threshold_id') == '0') { $sql_where .= (strlen($sql_where) ? ' AND' : '') . ' td.id IS NULL'; } elseif (!isempty_request_var('threshold_id')) { $sql_where .= (strlen($sql_where) ? ' AND' : '') . ' tl.threshold_id=' . get_request_var('threshold_id'); } if (get_request_var('status') == '-1') { /* Show all items */ } else { $sql_where .= (strlen($sql_where) ? ' AND' : '') . ' tl.status=' . get_request_var('status'); } if (strlen(get_request_var('filter'))) { $sql_where .= (strlen($sql_where) ? ' AND' : '') . " tl.description LIKE '%" . get_request_var('filter') . "%'"; } $sortby = get_request_var('sort_column') . ' ' . get_request_var('sort_direction'); $limit = $rows * (get_request_var('page') - 1) . ',' . $rows; $logs = get_allowed_threshold_logs($sql_where, $sortby, $limit, $total_rows); $nav = html_nav_bar('thold_graph.php?action=log', MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 8, __('Log Entries'), 'page', 'main'); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array('hdescription' => array('display' => __('Device'), 'sort' => 'ASC', 'align' => 'left'), 'time' => array('display' => __('Time'), 'sort' => 'ASC', 'align' => 'left'), 'type' => array('display' => __('Type'), 'sort' => 'DESC', 'align' => 'left'), 'description' => array('display' => __('Event Description'), 'sort' => 'ASC', 'align' => 'left'), 'threshold_value' => array('display' => __('Alert Value'), 'sort' => 'ASC', 'align' => 'right'), 'current' => array('display' => __('Measured Value'), 'sort' => 'ASC', 'align' => 'right')); html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false, 'thold_graph.php?action=log'); $i = 0; if (sizeof($logs)) { foreach ($logs as $l) { ?> <tr class='<?php print $thold_log_states[$l['status']]['class']; ?> '> <td class='left nowrap'><?php print $l['hdescription']; ?> </td> <td class='left nowrap'><?php print date('Y-m-d H:i:s', $l['time']); ?> </td> <td class='left nowrap'><?php print $thold_types[$l['type']]; ?> </td> <td class='left nowrap'><?php print strlen($l['description']) ? $l['description'] : __('Restoral Event'); ?> </td> <td class='right'><?php print $l['threshold_value'] != '' ? thold_format_number($l['threshold_value']) : __('N/A'); ?> </td> <td class='right'><?php print $l['current'] != '' ? thold_format_number($l['current']) : __('N/A'); ?> </td> <?php form_end_row(); } } else { print '<tr><td class="center" colspan="8">' . __('No Threshold Logs Found') . '</td></tr>'; } html_end_box(false); if (sizeof($logs)) { print $nav; } log_legend(); }
function mactrack_interfaces_request_validation() { /* ================= 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'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'sort_column' => array('filter' => FILTER_CALLBACK, 'default' => 'device_name', 'options' => array('options' => 'sanitize_search_string')), 'sort_direction' => array('filter' => FILTER_CALLBACK, 'default' => 'ASC', 'options' => array('options' => 'sanitize_search_string')), 'site_id' => array('filter' => FILTER_VALIDATE_INT, 'default' => '-1', 'pageset' => true), 'device_id' => array('filter' => FILTER_VALIDATE_INT, 'default' => '-1', 'pageset' => true), 'device_type_id' => array('filter' => FILTER_VALIDATE_INT, 'default' => '-1', 'pageset' => true), 'issues' => array('filter' => FILTER_VALIDATE_INT, 'default' => '-2', 'pageset' => true), 'period' => array('filter' => FILTER_VALIDATE_INT, 'default' => '-2', 'pageset' => true), 'bwusage' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_config_option('mt_interface_high'), 'pageset' => true), 'totals' => array('filter' => FILTER_CALLBACK, 'default' => 'true', 'options' => array('options' => 'sanitize_search_string'))); validate_store_request_vars($filters, 'sess_mactrack_int'); /* ================= input validation ================= */ }
function show_devices() { global $action, $expire_arr, $rotation_arr, $version_arr, $nesting_arr; global $config, $flow_actions; /* ================= input validation and session storage ================= */ $filters = array('page' => array('filter' => FILTER_VALIDATE_INT, 'default' => '1'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), '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_fvd'); /* ================= input validation ================= */ $sql_where = get_request_var('filter') != '' ? "name LIKE '%" . get_request_var('filter') . "%'" : ''; $num_rows = read_config_option('num_rows_table'); $sql = "SELECT * \n\t\tFROM plugin_flowview_devices \n\t\t{$sql_where}\n\t\tORDER BY " . get_request_var('sort_column') . ' ' . get_request_var('sort_direction') . ' LIMIT ' . ($num_rows * (get_request_var('page') - 1) . ',' . $num_rows); $result = db_fetch_assoc($sql); $total_rows = db_fetch_cell("SELECT COUNT(*) FROM plugin_flowview_devices {$sql_where}"); html_start_box('FlowView Listeners', '100%', '', '4', 'center', 'flowview_devices.php?action=edit'); ?> <tr class='even'> <td> <form name='listeners' action='flowview_devices.php'> <table class='fitlerTable'> <tr> <td> Search </td> <td> <input type='text' id='filter' size='40' value='<?php print htmlspecialchars(get_request_var('filter')); ?> '> </td> <td> <input id='refresh' type='button' value='Go' title='Set/Refresh Filters'> </td> <td> <input id='clear' type='button' name='clear' value='Clear' title='Clear Filters'> </td> </tr> </table> <input type='hidden' name='page' value='<?php print get_request_var('page'); ?> '> </form> </td> </tr> <?php html_end_box(); $nav = html_nav_bar('flowview_devices.php', MAX_DISPLAY_PAGES, get_request_var('page'), $num_rows, $total_rows, 10, 'Listeners', 'page', 'main'); form_start('flowview_devices.php', 'chk'); print $nav; html_start_box('', '100%', '', '4', 'center', ''); $display_array = array('name' => array('Name', 'ASC'), 'folder' => array('Directory', 'ASC'), 'nexting' => array('Nesting', 'ASC'), 'allowfrom' => array('Allowed From', 'ASC'), 'port' => array('Port', 'ASC'), 'version' => array('Version', 'ASC'), 'compression' => array('Compression', 'ASC'), 'rotation' => array('Rotation', 'ASC'), 'expire' => array('Expire', 'ASC')); html_header_sort_checkbox($display_array, get_request_var('sort_column'), get_request_var('sort_direction'), false); if (count($result)) { foreach ($result as $row) { form_alternate_row('line' . $row['id'], true); form_selectable_cell('<a class="linkEditMain" href="flowview_devices.php?&tab=listeners&action=edit&id=' . $row['id'] . '">' . $row['name'] . '</a>', $row['id']); form_selectable_cell($row['folder'], $row['id']); form_selectable_cell($nesting_arr[$row['nesting']], $row['id']); form_selectable_cell($row['allowfrom'], $row['id']); form_selectable_cell($row['port'], $row['id']); form_selectable_cell($version_arr[$row['version']], $row['id']); form_selectable_cell($row['compression'], $row['id']); form_selectable_cell($rotation_arr[$row['rotation']], $row['id']); form_selectable_cell($expire_arr[$row['expire']], $row['id']); form_checkbox_cell($row['name'], $row['id']); form_end_row(); } } else { print "<tr class='even'><td colspan=10><center>No Devices</center></td></tr>\n"; } html_end_box(false); if (count($result)) { print $nav; } draw_actions_dropdown($flow_actions); form_end(); }
/** function syslog_request_validation() * This is a generic funtion for this page that makes sure that * we have a good request. We want to protect against people who * like to create issues with Cacti. */ function syslog_request_validation($current_tab, $force = false) { global $title, $rows, $config, $reset_multi; include_once './lib/timespan_settings.php'; if ($current_tab != 'alerts' && isset_request_var('host') && get_nfilter_request_var('host') == -1) { kill_session_var('sess_syslog_' . $current_tab . '_hosts'); unset_request_var('host'); } /* ================= input validation and session storage ================= */ $filters = array('rows' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => read_user_setting('syslog_rows', '-1', $force)), 'page' => array('filter' => FILTER_VALIDATE_INT, 'default' => '1'), 'id' => array('filter' => FILTER_VALIDATE_INT, 'default' => ''), 'removal' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('syslog_removal', '1', $force)), 'refresh' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('syslog_refresh', read_config_option('syslog_refresh'), $force)), 'trimval' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('syslog_trimval', '75', $force)), 'enabled' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'host' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '0', 'options' => array('options' => 'sanitize_search_string')), 'efacility' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => read_user_setting('syslog_efacility', '-1', $force), 'options' => array('options' => 'sanitize_search_string')), 'epriority' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => read_user_setting('syslog_epriority', '-1', $force), 'options' => array('options' => 'sanitize_search_string')), 'eprogram' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => read_user_setting('syslog_eprogram', '-1', $force), 'options' => array('options' => 'sanitize_search_string')), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'sort_column' => array('filter' => FILTER_CALLBACK, 'default' => 'logtime', 'options' => array('options' => 'sanitize_search_string')), 'sort_direction' => array('filter' => FILTER_CALLBACK, 'default' => 'DESC', 'options' => array('options' => 'sanitize_search_string'))); validate_store_request_vars($filters, 'sess_syslogs_' . $current_tab); /* ================= input validation ================= */ api_plugin_hook_function('syslog_request_val'); if (isset_request_var('host')) { $_SESSION['sess_syslog_' . $current_tab . '_hosts'] = get_nfilter_request_var('host'); } else { if (isset($_SESSION['sess_syslog_' . $current_tab . '_hosts'])) { set_request_var('host', $_SESSION['sess_syslog_' . $current_tab . '_hosts']); } else { set_request_var('host', '-1'); } } }
function webseer_urls($header_label) { global $assoc_actions, $item_rows; /* ================= 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'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'associated' => array('filter' => FILTER_CALLBACK, 'default' => 'true', 'options' => array('options' => 'sanitize_search_string'))); validate_store_request_vars($filters, 'sess_maint_ws'); /* ================= input validation ================= */ /* if the number of rows is -1, set it to the default */ if (get_request_var('rows') == '-1') { $rows = read_config_option('num_rows_table'); } else { $rows = get_request_var('rows'); } ?> <script type='text/javascript'> function applyFilter() { strURL = 'maint.php?tab=webseer&action=edit&id=<?php print get_request_var('id'); ?> '; strURL += '&rows=' + $('#rows').val(); strURL += '&associated=' + $('#associated').is(':checked'); strURL += '&filter=' + $('#filter').val(); strURL += '&header=false'; loadPageNoHeader(strURL); } function clearFilter() { strURL = 'maint.php?tab=webseer&action=edit&id=<?php print get_request_var('id'); ?> &clear=true&header=false'; loadPageNoHeader(strURL); } </script> <?php html_start_box(__('Associated Web URL\'s ') . htmlspecialchars($header_label), '100%', '', '3', 'center', ''); ?> <tr class='even'> <td> <form name='form_devices' method='post' action='maint.php?action=edit&tab=webseer'> <table class='filterTable'> <tr> <td> <?php print __('Search'); ?> </td> <td> <input type='text' id='filter' size='25' value='<?php print htmlspecialchars(get_request_var('filter')); ?> ' onChange='applyFilter()'> </td> <td> <?php print __('Rules'); ?> </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) > 0) { foreach ($item_rows as $key => $value) { print "<option value='" . $key . "'"; if (get_request_var('rows') == $key) { print ' selected'; } print '>' . htmlspecialchars($value) . "</option>\n"; } } ?> </select> </td> <td> <input type='checkbox' id='associated' onChange='applyFilter()' <?php print get_request_var('associated') == 'true' || get_request_var('associated') == 'on' ? 'checked' : ''; ?> > </td> <td> <label for='associated'><?php print __('Associated'); ?> </label> </td> <td> <input type='button' value='<?php print __('Go'); ?> ' onClick='applyFilter()' title='<?php print __('Set/Refresh Filters'); ?> '> </td> <td> <input type='button' name='clear' value='<?php print __('Clear'); ?> ' onClick='clearFilter()' title='<?php print __('Clear Filters'); ?> '> </td> </tr> </table> <input type='hidden' name='page' value='<?php print get_request_var('page'); ?> '> <input type='hidden' name='id' value='<?php print get_request_var('id'); ?> '> </form> </td> </tr> <?php html_end_box(); /* form the 'where' clause for our main sql query */ if (strlen(get_request_var('filter'))) { $sql_where = "WHERE ((u.url LIKE '%" . get_request_var('filter') . "%') \n\t\t\tOR (u.display_name LIKE '%" . get_request_var('filter') . "%') \n\t\t\tOR (u.ip LIKE '%" . get_request_var('filter') . "%'))"; } else { $sql_where = ''; } if (get_request_var('associated') == 'false') { $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' (pmh.type=2 OR pmh.type IS NULL)'; } else { $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' pmh.type=2 AND pmh.schedule=' . get_request_var('id'); } $total_rows = db_fetch_cell("SELECT\n\t\tCOUNT(*)\n\t\tFROM plugin_webseer_urls AS u\n\t\tLEFT JOIN plugin_maint_hosts AS pmh\n\t\tON u.id=pmh.host\n\t\t{$sql_where}"); $sql_query = "SELECT u.*, pmh.host AS associated, pmh.type AS maint_type\n\t\tFROM plugin_webseer_urls AS u\n\t\tLEFT JOIN plugin_maint_hosts AS pmh\n\t\tON u.id=pmh.host\n\t\t{$sql_where} \n\t\tLIMIT " . $rows * (get_request_var('page') - 1) . ',' . $rows; $urls = db_fetch_assoc($sql_query); $nav = html_nav_bar('notify_lists.php?action=edit&id=' . get_request_var('id'), MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 13, __('Lists'), 'page', 'main'); form_start('maint.php', 'chk'); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array(__('Description'), __('ID'), __('Associated Schedules'), __('Enabled'), __('Hostname'), __('URL')); html_header_checkbox($display_text); if (sizeof($urls)) { foreach ($urls as $url) { form_alternate_row('line' . $url['id']); form_selectable_cell(strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($url['display_name'])) : htmlspecialchars($url['display_name']), $url['id'], 250); form_selectable_cell(round($url['id'], 2), $url['id']); if ($url['associated'] != '' && $url['maint_type'] == '2') { form_selectable_cell('<span class="deviceUp">' . __('Current Schedule') . '</span>', $url['id']); } else { if (sizeof($lists = db_fetch_assoc('SELECT name FROM plugin_maint_schedules INNER JOIN plugin_maint_hosts ON plugin_maint_schedules.id=plugin_maint_hosts.schedule WHERE type=2 AND host=' . $url['id']))) { $names = ''; foreach ($lists['name'] as $name) { $names .= (strlen($names) ? ', ' : '') . "<span class='deviceRecovering'>{$name}</span>"; } form_selectable_cell($names, $url['id']); } else { form_selectable_cell('<span class="deviceUnknown">' . __('No Schedules') . '</span>', $url['id']); } } form_selectable_cell($url['enabled'] == 'on' ? __('Enabled') : __('Disabled'), $url['id']); if (empty($url['ip'])) { $url['ip'] = __('USING DNS'); } form_selectable_cell(strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", '<i>' . htmlspecialchars($url['ip'])) . '</i>' : '<i>' . htmlspecialchars($url['ip']) . '</i>', $url['id']); form_selectable_cell(strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($url['url'])) : htmlspecialchars($url['url']), $url['id']); form_checkbox_cell($url['display_name'], $url['id']); form_end_row(); } } else { print "<tr><td><em>" . __('No Associated WebSeer URL\'s Found') . "</em></td></tr>"; } html_end_box(false); if (sizeof($urls)) { print $nav; } form_hidden_box('id', get_request_var('id'), ''); form_hidden_box('save_webseer', '1', ''); /* draw the dropdown containing a list of available actions for this form */ draw_actions_dropdown($assoc_actions); form_end(); }
function mactrack_maca() { global $maca_actions, $config, $item_rows; /* ================= 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'), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'sort_column' => array('filter' => FILTER_CALLBACK, 'default' => 'mac_address', '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_mactrack_maca'); /* ================= input validation ================= */ 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(__('MacTrack MacAuth Filters'), '100%', '', '3', 'center', 'mactrack_macauth.php?action=edit'); mactrack_maca_filter(); html_end_box(); $sql_where = ''; $maca = mactrack_maca_get_maca_records($sql_where, $row_limit); $total_rows = db_fetch_cell("SELECT count(*)\n\t\tFROM mac_track_macauth\n\t\t{$sql_where}"); $nav = html_nav_bar('mactrack_macauth.php?filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_request_var('page'), $row_limit, $total_rows, 9, __('Authorized Mac Addresses')); form_start('mactrack_macauth.php', 'chk'); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array('mac_address' => array(__('Mac Address'), 'ASC'), 'nosort' => array(__('Reason'), 'ASC'), 'added_date' => array(__('Added/Modified'), 'ASC'), 'date_last_seen' => array(__('By'), 'ASC')); html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction')); if (sizeof($maca)) { foreach ($maca as $mac) { form_alternate_row('line' . $mac['mac_id'], true); form_selectable_cell(filter_value($mac['mac_address'], get_request_var('filter'), 'mactrack_macauth.php?action=edit&mac_id=' . $mac['mac_id']), $mac['mac_id']); form_selectable_cell(filter_value($mac['description'], get_request_var('filter')), $mac['mac_id']); form_selectable_cell($mac['added_date'], $mac['mac_id']); form_selectable_cell(db_fetch_cell_prepared('SELECT full_name FROM user_auth WHERE id = ?', array($mac['added_by'])), $mac['mac_id']); form_checkbox_cell($mac['mac_address'], $mac['mac_id']); form_end_row(); } } else { print "<tr><td colspan=10><em>" . __('No Authorized Mac Addresses') . "</em></td></tr>"; } html_end_box(false); if (sizeof($maca)) { print $nav; } draw_actions_dropdown($maca_actions); }