function get_filter_values($source, &$values) { $filters = array(); // :-] if (!preg_match_all("/%([a-z0-9_:-]*)%/", $source, $filters)) { return $values; } $filters = array_unique($filters[1]); foreach ($filters as $filter_key) { if (isset($values[$filter_key]) && !in_array($filter_key, $values['defaults'])) { continue; } $default = null; if (isset($values[$filter_key])) { $default = $values[$filter_key]; } $filter_func = "filter_{$filter_key}"; if (function_exists($filter_func)) { $filter_func($values, $default); } else { filter_value($filter_key, $values, $default); } } return $values; }
/** * Filters the parameters * * @param array $params * @param array $posted_params * @return array */ function filter_params($params, $posted_params) { $values = array(); foreach ($params as $param) { if (isset($posted_params[$param]) and $posted_params[$param] !== '') { $values[$param] = filter_value($posted_params[$param]); } } return $values; }
/** * This Function updates the container with selected items or take off removed items */ function multiple_select_update_field($data) { $form_field_value = explode('::', $data['form_field_value']); $form = $form_field_value[0]; $field = $form_field_value[1]; if ($form_field_value[3]) { $remove_value = $form_field_value[2] . '::' . $form_field_value[3]; } elseif ($form_field_value[2]) { $remove_value = $form_field_value[2]; } else { $remove_value = ''; } $selected = $field . '_selected'; // Remove Item if ($remove_value) { $remove_value = build_custom_remove_value($remove_value, $data); foreach ($data[$selected] as $key => $value) { if ($value == $remove_value) { unset($data[$selected][$key]); } } } else { // Add items if (!$data[$field]) { return 'ERROR||You must insert a value.'; } $data[$field] = filter_value($data[$field], $data); if ($data[$selected]) { if (!in_array($data[$field], $data[$selected])) { $data[$selected][] = $data[$field]; } } else { $data[$selected][] = $data[$field]; } } $field_selected = $data[$selected]; //treating the String based on the feature $data[$selected] = build_custom_string($data['Feature'], $field_selected, $selected, $data); $resp = multiple_select_items($form, $field, $data[$selected]); return $resp; }
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 hosts() { global $config, $device_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')), 'host_template_id' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'host_status' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-4')); validate_store_request_vars($filters, 'sess_thold_hstatus'); /* ================= 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(__('Device Status'), '100%', '', '3', 'center', ''); form_host_filter(); html_end_box(); /* form the 'where' clause for our main sql query */ $sql_where = ''; if (get_request_var('filter') != '') { $sql_where = "((h.hostname LIKE '%" . get_request_var('filter') . "%' OR h.description LIKE '%" . get_request_var('filter') . "%')"; } if (get_request_var('host_status') == '-1') { /* Show all items */ } elseif (get_request_var('host_status') == '-2') { $sql_where .= (strlen($sql_where) ? ' AND ' : '(') . "h.disabled='on'"; } elseif (get_request_var('host_status') == '-3') { $sql_where .= (strlen($sql_where) ? ' AND ' : '(') . "h.disabled=''"; } elseif (get_request_var('host_status') == '-4') { $sql_where .= (strlen($sql_where) ? ' AND ' : '(') . "(h.status!='3' OR h.disabled='on')"; } elseif (get_request_var('host_status') == '-5') { $sql_where .= (strlen($sql_where) ? ' AND ' : '(') . "(h.availability_method=0)"; } elseif (get_request_var('host_status') == '3') { $sql_where .= (strlen($sql_where) ? ' AND ' : '(') . "(h.availability_method!=0 AND h.status=3 AND h.disabled='')"; } else { $sql_where .= (strlen($sql_where) ? ' AND ' : '(') . "(h.status=" . get_request_var('host_status') . " AND h.disabled = '')"; } if (get_request_var('host_template_id') == '-1') { /* Show all items */ } elseif (get_request_var('host_template_id') == '0') { $sql_where .= (strlen($sql_where) ? ' AND ' : '(') . "h.host_template_id=0'"; } elseif (!isempty_request_var('host_template_id')) { $sql_where .= (strlen($sql_where) ? ' AND ' : '(') . "h.host_template_id=" . get_request_var('host_template_id'); } $sql_where .= strlen($sql_where) ? ')' : ''; $sortby = get_request_var('sort_column'); if ($sortby == 'hostname') { $sortby = 'INET_ATON(hostname)'; } $host_graphs = array_rekey(db_fetch_assoc('SELECT host_id, count(*) as graphs FROM graph_local GROUP BY host_id'), 'host_id', 'graphs'); $host_data_sources = array_rekey(db_fetch_assoc('SELECT host_id, count(*) as data_sources FROM data_local GROUP BY host_id'), 'host_id', 'data_sources'); $hosts = get_allowed_devices($sql_where, $sortby . ' ' . get_request_var('sort_direction'), $rows * (get_request_var('page') - 1) . ',' . $rows, $total_rows); $nav = html_nav_bar('thold_graph.php?action=hoststat', MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 12, __('Devices'), 'page', 'main'); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array('nosort' => array('display' => __('Actions'), 'align' => 'left', 'sort' => '', 'tip' => __('Hover over icons for help')), 'description' => array('display' => __('Description'), 'align' => 'left', 'sort' => 'ASC', 'tip' => __('A description for the Device')), 'id' => array('display' => __('ID'), 'align' => 'right', 'sort' => 'ASC', 'tip' => __('A Cacti unique identifier for the Device')), 'nosort1' => array('display' => __('Graphs'), 'align' => 'right', 'sort' => 'ASC', 'tip' => __('The number of Graphs for this Device')), 'nosort2' => array('display' => __('Data Sources'), 'align' => 'right', 'sort' => 'ASC', 'tip' => __('The number of Data Sources for this Device')), 'status' => array('display' => __('Status'), 'align' => 'center', 'sort' => 'ASC', 'tip' => __('The status for this Device as of the last time it was polled')), 'nosort3' => array('display' => __('In State'), 'align' => 'right', 'sort' => 'ASC', 'tip' => __('The last time Cacti found an issues with this Device. It can be higher than the Uptime for the the Device, if it was rebooted between Cacti polling cycles')), 'snmp_sysUpTimeInstance' => array('display' => __('Uptime'), 'align' => 'right', 'sort' => 'ASC', 'tip' => __('The official uptime of the Device as reported by SNMP')), 'hostname' => array('display' => __('Hostname'), 'align' => 'right', 'sort' => 'ASC', 'tip' => __('The official hostname for this Device')), 'cur_time' => array('display' => __('Current (ms)'), 'align' => 'right', 'sort' => 'DESC', 'tip' => __('The current response time for the Cacti Availability check')), 'avg_time' => array('display' => __('Average (ms)'), 'align' => 'right', 'sort' => 'DESC', 'tip' => __('The average response time for the Cacti Availability check')), 'availability' => array('display' => __('Availability'), 'align' => 'right', 'sort' => 'ASC', 'tip' => __('The overall Availability of this Device since the last counter reset in Cacti'))); html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false, 'thold_graph.php?action=hoststat'); if (sizeof($hosts)) { foreach ($hosts as $host) { if ($host['disabled'] == '' && ($host['status'] == HOST_RECOVERING || $host['status'] == HOST_UP) && ($host['availability_method'] != AVAIL_NONE && $host['availability_method'] != AVAIL_PING)) { $snmp_uptime = $host['snmp_sysUpTimeInstance']; $days = intval($snmp_uptime / (60 * 60 * 24 * 100)); $remainder = $snmp_uptime % (60 * 60 * 24 * 100); $hours = intval($remainder / (60 * 60 * 100)); $remainder = $remainder % (60 * 60 * 100); $minutes = intval($remainder / (60 * 100)); $uptime = $days . 'd:' . substr('00' . $hours, -2) . 'h:' . substr('00' . $minutes, -2) . 'm'; } else { $uptime = __('N/A'); } if (isset($host_graphs[$host['id']])) { $graphs = $host_graphs[$host['id']]; } else { $graphs = 0; } if (isset($host_data_sources[$host['id']])) { $ds = $host_data_sources[$host['id']]; } else { $ds = 0; } if ($host['availability_method'] != 0) { form_host_status_row_color($host['status'], $host['disabled']); print "<td width='1%' class='nowrap'>"; if (api_user_realm_auth('host.php')) { print '<a href="' . htmlspecialchars($config['url_path'] . 'host.php?action=edit&id=' . $host['id']) . '"><img src="' . $config['url_path'] . 'plugins/thold/images/edit_object.png" border="0" alt="" title="' . __('Edit Device') . '"></a>'; } print "<a href='" . htmlspecialchars($config['url_path'] . 'graph_view.php?action=preview&graph_template_id=0&filter=&host_id=' . $host['id']) . "'><img src='" . $config['url_path'] . "plugins/thold/images/view_graphs.gif' border='0' alt='' title='" . __('View Graphs') . "'></a>"; print '</td>'; ?> <td style='text-align:left'> <?php print filter_value($host['description'], get_request_var('filter')); ?> </td> <td style='text-align:right'><?php print round($host['id'], 2); ?> </td> <td style='text-align:right'><i><?php print number_format_i18n($graphs); ?> </i></td> <td style='text-align:right'><i><?php print number_format_i18n($ds); ?> </i></td> <td style='text-align:center'><?php print get_uncolored_device_status($host['disabled'] == 'on' ? true : false, $host['status']); ?> </td> <td style='text-align:right'><?php print get_timeinstate($host); ?> </td> <td style='text-align:right'><?php print $uptime; ?> </td> <td style='text-align:right'><?php print filter_value($host['hostname'], get_request_var('filter')); ?> </td> <td style='text-align:right'><?php print round($host['cur_time'], 2); ?> </td> <td style='text-align:right'><?php print round($host['avg_time'], 2); ?> </td> <td style='text-align:right'><?php print round($host['availability'], 2); ?> %</td> <?php } else { print "<tr class='deviceNotMonFull'>\n"; print "<td width='1%' class='nowrap'>\n"; if (api_user_realm_auth('host.php')) { print '<a href="' . htmlspecialchars($config['url_path'] . 'host.php?action=edit&id=' . $host["id"]) . '"><img src="' . $config['url_path'] . 'plugins/thold/images/edit_object.png" border="0" alt="" title="' . __('Edit Device') . '"></a>'; } print "<a href='" . htmlspecialchars($config['url_path'] . "graph_view.php?action=preview&graph_template_id=0&filter=&host_id=" . $host["id"]) . "'><img src='" . $config['url_path'] . "plugins/thold/images/view_graphs.gif' border='0' alt='' title='" . __('View Graphs') . "'></a>"; print "</td>"; ?> <td style='text-align:left'> <?php print filter_value($host['description'], get_request_var('filter')); ?> </td> <td style='text-align:right'><?php print $host['id']; ?> </td> <td style='text-align:right'><i><?php print number_format_i18n($graphs); ?> </i></td> <td style='text-align:right'><i><?php print number_format_i18n($ds); ?> </i></td> <td style='text-align:center'><?php print 'Not Monitored'; ?> </td> <td style='text-align:right'><?php print 'N/A'; ?> </td> <td style='text-align:right'><?php print $uptime; ?> </td> <td style='text-align:right'><?php print filter_value($host['hostname'], get_request_var('filter')); ?> </td> <td style='text-align:right'><?php print 'N/A'; ?> </td> <td style='text-align:right'><?php print 'N/A'; ?> </td> <td style='text-align:right'><?php print 'N/A'; ?> </td> <?php } form_end_row(); } } else { print '<tr><td class="center" colspan="12">' . __('No Devices') . '</td></tr>'; } html_end_box(false); if (sizeof($hosts)) { print $nav; } host_legend(); //thold_display_rusage(); }
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 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(); }
function list_tholds() { global $thold_states, $config, $host_id, $timearray, $thold_types; $thold_actions = array(1 => __('Delete'), 2 => __('Disable'), 3 => __('Enable'), 4 => __('Reapply Suggested Names'), 5 => __('Propagate Template')); thold_request_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'); } $statefilter = ''; if (isset_request_var('state')) { if (get_request_var('state') == '-1') { $statefilter = ''; } else { if (get_request_var('state') == '0') { $statefilter = "thold_data.thold_enabled='off'"; } if (get_request_var('state') == '2') { $statefilter = "thold_data.thold_enabled='on'"; } if (get_request_var('state') == '1') { $statefilter = '(thold_data.thold_alert!=0 OR thold_data.bl_alert>0)'; } if (get_request_var('state') == '3') { $statefilter = '((thold_data.thold_alert!=0 AND thold_data.thold_fail_count >= thold_data.thold_fail_trigger) OR (thold_data.bl_alert>0 AND thold_data.bl_fail_count >= thold_data.bl_fail_trigger))'; } } } top_header(); $sql_where = ''; $sort = get_request_var('sort_column'); $limit = ' LIMIT ' . $rows * (get_request_var('page') - 1) . ", {$rows}"; if (!isempty_request_var('host_id') && get_request_var('host_id') != '-1') { $sql_where .= (!strlen($sql_where) ? '(' : ' AND ') . "td.host_id = " . get_request_var('host_id'); } if (!isempty_request_var('data_template_id') && get_request_var('data_template_id') != '-1') { $sql_where .= (!strlen($sql_where) ? '(' : ' AND ') . "td.data_template_id = " . get_request_var('data_template_id'); } if ($statefilter != '') { $sql_where .= (!strlen($sql_where) ? '(' : ' AND ') . "{$statefilter}"; } if ($sql_where != '') { $sql_where .= ')'; } $tholds = get_allowed_thresholds($sql_where, $sort . ' ' . get_request_var('sort_direction'), $rows * (get_request_var('page') - 1) . ", {$rows}", $total_rows); $data_templates = db_fetch_assoc("SELECT DISTINCT data_template.id, data_template.name\n\t\tFROM data_template\n\t\tINNER JOIN thold_data \n\t\tON thold_data.data_template_id = data_template.id\n\t\tORDER BY data_template.name"); html_start_box(__('Threshold Management'), '100%', '', '3', 'center', 'thold.php?action=add'); ?> <tr class='even'> <td> <form id='listthold' action='thold.php' method='post'> <table class='filterTable'> <tr> <td> <?php print __('Search'); ?> </td> <td> <input type='text' id='filter' size='25' value='<?php print get_request_var('filter'); ?> '> </td> <?php print html_host_filter(get_request_var('host_id')); ?> <td> <?php print __('Template'); ?> </td> <td> <select id='data_template_id' onChange='applyFilter()'> <option value='-1'><?php print __('Any'); ?> </option> <?php foreach ($data_templates as $row) { echo "<option value='" . $row['id'] . "'" . (isset_request_var('data_template_id') && $row['id'] == get_request_var('data_template_id') ? ' selected' : '') . '>' . $row['name'] . '</option>'; } ?> </select> </td> <td> <?php print __('State'); ?> </td> <td> <select id='state' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var('state') == '-1') { ?> selected<?php } ?> ><?php print __('All'); ?> </option> <option value='1'<?php if (get_request_var('state') == '1') { ?> selected<?php } ?> ><?php print __('Breached'); ?> </option> <option value='3'<?php if (get_request_var('state') == '3') { ?> selected<?php } ?> ><?php print __('Triggered'); ?> </option> <option value='2'<?php if (get_request_var('state') == '2') { ?> selected<?php } ?> ><?php print __('Enabled'); ?> </option> <option value='0'<?php if (get_request_var('state') == '0') { ?> selected<?php } ?> ><?php print __('Disabled'); ?> </option> </select> </td> <td> <input type='button' id='refresh' value='<?php print __('Go'); ?> ' title='<?php print __('Apply Filters'); ?> ' onClick='applyFilter()'> </td> <td> <input type='button' id='clear' value='<?php print __('Clear'); ?> ' title='<?php print __('Return to Defaults'); ?> ' onClick='clearFilter()'> </td> </tr> </table> <input type='hidden' name='search' value='search'> <input type='hidden' id='page' value='<?php print get_filter_request_var('page'); ?> '> </form> <script type='text/javascript'> function applyFilter() { strURL = 'thold.php?header=false&host_id=' + $('#host_id').val(); strURL += '&state=' + $('#state').val(); strURL += '&data_template_id=' + $('#data_template_id').val(); strURL += '&filter=' + $('#filter').val(); loadPageNoHeader(strURL); } function clearFilter() { strURL = 'thold.php?header=false&clear=1'; loadPageNoHeader(strURL); } $(function() { $('#listthold').submit(function(event) { event.preventDefault(); applyFilter(); }); }); </script> </td> </tr> <?php html_end_box(); $nav = html_nav_bar('thold.php?filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 14, __('Thresholds'), 'page', 'main'); form_start('thold.php', 'chk'); print $nav; html_start_box('', '100%', '', '4', 'center', ''); $display_text = array('name' => array('display' => __('Name'), 'sort' => 'ASC', 'align' => 'left'), 'id' => array('display' => __('ID'), 'sort' => 'ASC', 'align' => 'right'), 'thold_type' => array('display' => __('Type'), 'sort' => 'ASC', 'align' => 'right'), 'data_source' => array('display' => __('DSName'), 'sort' => 'ASC', 'align' => 'right'), 'lastread' => array('display' => __('Current'), 'sort' => 'ASC', 'align' => 'right', 'tip' => __('The last measured value for the Data Source')), 'thold_hi' => array('display' => __('High'), 'sort' => 'ASC', 'align' => 'right', 'tip' => __('High Threshold values for Warning/Alert')), 'thold_low' => array('display' => __('Low'), 'sort' => 'ASC', 'align' => 'right', 'tip' => __('Low Threshold values for Warning/Alert')), 'nosort3' => array('display' => __('Trigger'), 'sort' => '', 'align' => 'right'), 'nosort4' => array('display' => __('Duration'), 'sort' => '', 'align' => 'right'), 'repeat_alert' => array('display' => __('Repeat'), 'sort' => 'ASC', 'align' => 'right'), 'thold_alert' => array('display' => __('Triggered'), 'sort' => 'ASC', 'align' => 'right'), 'template_enabled' => array('display' => __('Templated'), 'sort' => 'ASC', 'align' => 'right')); html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false); $c = 0; $i = 0; if (sizeof($tholds)) { foreach ($tholds as $thold_data) { $c++; $grapharr = db_fetch_row('SELECT DISTINCT graph_templates_item.local_graph_id FROM graph_templates_item, data_template_rrd WHERE (data_template_rrd.local_data_id=' . $thold_data['local_data_id'] . ' AND data_template_rrd.id=graph_templates_item.task_item_id)'); $local_graph_id = $grapharr['local_graph_id']; $alertstat = __('No'); $bgcolor = 'green'; if ($thold_data['thold_type'] == 0) { if ($thold_data['thold_alert'] != 0) { $alertstat = __('Yes'); if ($thold_data['thold_fail_count'] >= $thold_data['thold_fail_trigger']) { $bgcolor = 'red'; } elseif ($thold_data['thold_warning_fail_count'] >= $thold_data['thold_warning_fail_trigger']) { $bgcolor = 'warning'; } else { $bgcolor = 'yellow'; } } } elseif ($thold_data['thold_type'] == 2) { if ($thold_data['thold_alert'] != 0) { $alertstat = __('Yes'); if ($thold_data['thold_fail_count'] >= $thold_data['time_fail_trigger']) { $bgcolor = 'red'; } elseif ($thold_data['thold_warning_fail_count'] >= $thold_data['time_warning_fail_trigger']) { $bgcolor = 'warning'; } else { $bgcolor = 'yellow'; } } } else { if ($thold_data['bl_alert'] == 1) { $alertstat = __('baseline-LOW'); $bgcolor = $thold_data['bl_fail_count'] >= $thold_data['bl_fail_trigger'] ? 'orange' : 'yellow'; } elseif ($thold_data['bl_alert'] == 2) { $alertstat = __('baseline-HIGH'); $bgcolor = $thold_data['bl_fail_count'] >= $thold_data['bl_fail_trigger'] ? 'orange' : 'yellow'; } } $data_source = db_fetch_cell_prepared('SELECT data_source_name FROM data_template_rrd WHERE id = ?', array($thold_data['data_template_rrd_id'])); if ($thold_data['thold_enabled'] == 'off') { print "<tr class='selectable " . $thold_states['grey']['class'] . "' id='line" . $thold_data['id'] . "'>\n"; } else { print "<tr class='selectable " . $thold_states[$bgcolor]['class'] . "' id='line" . $thold_data['id'] . "'>\n"; } form_selectable_cell(filter_value($thold_data['name'] != '' ? $thold_data['name'] : $thold_data['name_cache'] . ' [' . $thold_data['data_source_name'] . ']', get_request_var('filter'), 'thold.php?action=edit&id=' . $thold_data['id']) . '</a>', $thold_data['id'], '', 'text-align:left'); form_selectable_cell($thold_data['id'], $thold_data['id'], '', 'text-align:right'); form_selectable_cell($thold_types[$thold_data['thold_type']], $thold_data['id'], '', 'text-align:right'); form_selectable_cell($data_source, $thold_data['id'], '', 'text-align:right'); switch ($thold_data['thold_type']) { case 0: form_selectable_cell(thold_format_number($thold_data['lastread']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(thold_format_number($thold_data['thold_warning_hi']) . ' / ' . thold_format_number($thold_data['thold_hi']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(thold_format_number($thold_data['thold_warning_low']) . ' / ' . thold_format_number($thold_data['thold_low']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell('<i>' . plugin_thold_duration_convert($thold_data['local_data_id'], $thold_data['thold_fail_trigger'], 'alert') . '</i>', $thold_data['id'], '', 'text-align:right'); form_selectable_cell(__('N/A'), $thold_data['id'], '', 'text-align:right'); break; case 1: form_selectable_cell(thold_format_number($thold_data['lastread']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(thold_format_number($thold_data['thold_warning_hi']) . ' / ' . thold_format_number($thold_data['thold_hi']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(thold_format_number($thold_data['thold_warning_low']) . ' / ' . thold_format_number($thold_data['thold_low']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell('<i>' . plugin_thold_duration_convert($thold_data['local_data_id'], $thold_data['bl_fail_trigger'], 'alert') . '</i>', $thold_data['id'], '', 'text-align:right'); form_selectable_cell($timearray[$thold_data['bl_ref_time_range'] / 300], $thold_data['id'], '', 'text-align:right'); break; case 2: form_selectable_cell(thold_format_number($thold_data['lastread']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(thold_format_number($thold_data['time_warning_hi']) . ' / ' . thold_format_number($thold_data['time_hi']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(thold_format_number($thold_data['time_warning_low']) . ' / ' . thold_format_number($thold_data['time_low']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell('<i>' . __('%d Triggers', $thold_data['time_fail_trigger']) . '</i>', $thold_data['id'], '', 'text-align:right'); form_selectable_cell('<i>' . plugin_thold_duration_convert($thold_data['local_data_id'], $thold_data['time_fail_length'], 'time') . '</i>', $thold_data['id'], '', 'text-align:right'); break; default: form_selectable_cell(thold_format_number($thold_data['lastread']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell('- / -', $thold_data['id'], '', 'text-align:right'); form_selectable_cell('- / -', $thold_data['id'], '', 'text-align:right'); form_selectable_cell(__('N/A'), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(__('N/A'), $thold_data['id'], '', 'text-align:right'); } form_selectable_cell($thold_data['repeat_alert'] == '' ? '' : plugin_thold_duration_convert($thold_data['local_data_id'], $thold_data['repeat_alert'], 'repeat'), $thold_data['id'], '', 'text-align:right'); form_selectable_cell($alertstat, $thold_data['id'], '', 'text-align:right'); if ($thold_data['thold_template_id'] != 0) { form_selectable_cell($thold_data['template_enabled'] == '' ? __('No') : __('Yes'), $thold_data['id'], '', 'text-align:right'); } else { form_selectable_cell(__('No'), $thold_data['id'], '', 'text-align:right'); } form_checkbox_cell($thold_data['name'], $thold_data['id'], '', 'text-align:left'); form_end_row(); } } else { print "<tr class='even'><td colspan='14'><center>" . __('No Thresholds') . "</center></td></tr>\n"; } html_end_box(false); if (sizeof($tholds)) { print $nav; } thold_legend(); draw_actions_dropdown($thold_actions); if (isset($host_id) && $host_id != '') { print "<input type='hidden' name='host_id' value='{$host_id}'>"; } form_end(); bottom_footer(); }
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); }
function mactrack_format_device_row($device, $actions = false) { global $config, $mactrack_device_types; /* viewer level */ if ($actions) { $row = "<a href='" . htmlspecialchars($config['url_path'] . 'plugins/mactrack/mactrack_interfaces.php?device_id=' . $device['device_id'] . '&issues=0&page=1') . "'><img src='" . $config['url_path'] . "plugins/mactrack/images/view_interfaces.gif' alt='' title='" . __('View Interfaces') . "' align='middle' border='0'></a>"; /* admin level */ if (api_user_realm_auth('mactrack_sites.php')) { if ($device['disabled'] == '') { $row .= "<img id='r_" . $device['device_id'] . "' src='" . $config['url_path'] . "plugins/mactrack/images/rescan_device.gif' alt='' onClick='scan_device(" . $device['device_id'] . ")' title='" . __('Rescan Device') . "' align='middle' border='0'>"; } else { $row .= "<img src='" . $config['url_path'] . "plugins/mactrack/images/view_none.gif' alt='' align='middle' border='0'>"; } } print "<td style='width:40px;'>" . $row . "</td>"; } form_selectable_cell(filter_value($device['device_name'], get_request_var('filter'), "mactrack_devices.php?action=edit&device_id=" . $device['device_id']), $device['device_id']); form_selectable_cell($device['site_name'], $device['device_id']); form_selectable_cell(get_colored_device_status($device['disabled'] == 'on' ? true : false, $device['snmp_status']), $device['device_id']); form_selectable_cell(filter_value($device['hostname'], get_request_var('filter')), $device['device_id']); form_selectable_cell($device['device_type'] == '' ? __('Not Detected') : $device['device_type'], $device['device_id']); form_selectable_cell($device['scan_type'] == '1' ? __('N/A') : $device['ips_total'], $device['device_id']); form_selectable_cell($device['scan_type'] == '3' ? __('N/A') : $device['ports_total'], $device['device_id']); form_selectable_cell($device['scan_type'] == '3' ? __('N/A') : $device['ports_active'], $device['device_id']); form_selectable_cell($device['scan_type'] == '3' ? __('N/A') : $device['ports_trunk'], $device['device_id']); form_selectable_cell($device['scan_type'] == '3' ? __('N/A') : $device['macs_active'], $device['device_id']); form_selectable_cell(number_format($device['last_runduration'], 1), $device['device_id']); form_checkbox_cell($device['device_name'], $device['device_id']); form_end_row(); }
/** 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(); } }
function mactrack_view_devices() { global $title, $report, $mactrack_search_types, $mactrack_device_types, $rows_selector, $config, $item_rows; mactrack_device_request_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'); } $webroot = $config['url_path'] . '/plugins/mactrack/'; mactrack_tabs(); html_start_box($title, '100%', '', '3', 'center', ''); mactrack_device_filter2(); html_end_box(); $sql_where = ''; $devices = mactrack_view_get_device_records($sql_where, $row_limit); $total_rows = db_fetch_cell("SELECT\n\t\tCOUNT(mac_track_devices.device_id)\n\t\tFROM mac_track_sites\n\t\tRIGHT JOIN mac_track_devices ON mac_track_devices.site_id = mac_track_sites.site_id\n\t\tLEFT JOIN mac_track_device_types ON (mac_track_device_types.device_type_id=mac_track_devices.device_type_id)\n\t\t{$sql_where}"); $nav = html_nav_bar('mactrack_view_devices.php?report=devices', MAX_DISPLAY_PAGES, get_request_var('page'), $row_limit, $total_rows, 13, __('Devices')); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array('nosort' => array(__('Actions'), ''), 'device_name' => array(__('Device Name'), 'ASC'), 'site_name' => array(__('Site Name'), 'ASC'), 'snmp_status' => array(__('Status'), 'ASC'), 'hostname' => array(__('Hostname'), 'ASC'), 'device_type' => array(__('Device Type'), 'ASC'), 'ips_total' => array(__('Total IP\'s'), 'DESC'), 'ports_total' => array(__('User Ports'), 'DESC'), 'ports_active' => array(__('User Ports Up'), 'DESC'), 'ports_trunk' => array(__('Trunk Ports'), 'DESC'), 'macs_active' => array(__('Active Macs'), 'DESC'), 'vlans_total' => array(__('Total VLAN\'s'), 'DESC'), 'last_runduration' => array(__('Last Duration'), 'DESC')); html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction')); $i = 0; if (sizeof($devices) > 0) { foreach ($devices as $device) { $hostinfo['hostname'] = $device['hostname']; $hostinfo['user'] = $device['user_name']; switch ($device['term_type']) { case 0: $hostinfo['transport'] = 'none'; break; case 1: $hostinfo['transport'] = 'telnet'; break; case 2: $hostinfo['transport'] = 'ssh'; break; case 3: $hostinfo['transport'] = 'http'; break; case 4: $hostinfo['transport'] = 'https'; break; } form_alternate_row(); ?> <td width=100> <?php if (api_user_realm_auth('mactrack_sites.php')) { ?> <a href='<?php print htmlspecialchars($webroot . 'mactrack_devices.php?action=edit&device_id=' . $device['device_id']); ?> ' title='<?php print __('Edit Device'); ?> '><img border='0' src='<?php print $webroot; ?> images/edit_object.png'></a> <?php api_plugin_hook_function('remote_link', $hostinfo); } ?> <?php if ($device['host_id'] > 0) { ?> <a href='<?php print htmlspecialchars($webroot . 'mactrack_view_graphs.php?action=preview&report=graphs&style=selective&graph_list=&host=' . $device['host_id'] . '&graph_template_id=0&filter='); ?> ' title='<?php print __('View Graphs'); ?> '><img border='0' src='<?php print $webroot; ?> images/view_graphs.gif'></a> <?php } else { ?> <img title='<?php print __('Device Not Mapped to Cacti Device'); ?> ' border='0' src='<?php print $webroot; ?> images/view_graphs_disabled.gif'> <?php } ?> <a href='<?php print htmlspecialchars($webroot . 'mactrack_view_macs.php?report=macs&reset&device_id=-1&scan_date=3&site_id=' . get_request_var('site_id') . '&device_id=' . $device['device_id']); ?> ' title='<?php print __('View MAC Addresses'); ?> '><img border='0' src='<?php print $webroot; ?> images/view_macs.gif'></a> <a href='<?php print htmlspecialchars($webroot . 'mactrack_view_interfaces.php?report=interfaces&reset&site=' . get_request_var('site_id') . '&device=' . $device['device_id']); ?> ' title='<?php print __('View Interfaces'); ?> '><img border='0' src='<?php print $webroot; ?> images/view_interfaces.gif'></a> </td> <td class='hyperLink'> <?php print filter_value($device['device_name'], get_request_var('filter')); ?> </td> <td><?php print filter_value($device['site_name'], get_request_var('filter')); ?> <td><?php print get_colored_device_status($device['disabled'] == 'on' ? true : false, $device['snmp_status']); ?> </td> <td><?php print filter_value($device['hostname'], get_request_var('filter')); ?> <td><?php print $device['device_type']; ?> </td)> <td><?php print $device['scan_type'] == '1' ? __('N/A') : number_format_i18n($device['ips_total']); ?> </td> <td><?php print $device['scan_type'] == '3' ? __('N/A') : number_format_i18n($device['ports_total']); ?> </td> <td><?php print $device['scan_type'] == '3' ? __('N/A') : number_format_i18n($device['ports_active']); ?> </td> <td><?php print $device['scan_type'] == '3' ? __('N/A') : number_format_i18n($device['ports_trunk']); ?> </td> <td><?php print $device['scan_type'] == '3' ? __('N/A') : number_format_i18n($device['macs_active']); ?> </td> <td><?php print $device['scan_type'] == '3' ? __('N/A') : number_format_i18n($device['vlans_total']); ?> </td> <td><?php print number_format($device['last_runduration'], 1); ?> </td> </tr> <?php } } else { print '<tr><td colspan="10"><em>' . __('No MacTrack Devices') . '</em></td></tr>'; } html_end_box(false); if (sizeof($devices)) { print $nav; mactrack_display_stats(); } }
function templates() { global $config, $thold_actions, $item_rows; include $config['base_path'] . '/plugins/thold/includes/arrays.php'; template_request_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(__('Threshold Templates'), '100%', '', '3', 'center', 'thold_templates.php?action=add'); ?> <tr class='even'> <td> <form id='listthold' action='thold_templates.php'> <table class='filterTable'> <tr> <td> <?php print __('Search'); ?> </td> <td> <input type='text' id='filter' size='25' value='<?php print get_request_var('filter'); ?> '> </td> <td> <?php print __('Templates'); ?> </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 => $value) { print "<option value='" . $key . "'"; if (get_request_var('rows') == $key) { print ' selected'; } print '>' . $value . "</option>\n"; } } ?> </select> </td> <td> <input id='refresh' type='button' value='<?php print __('Go'); ?> ' onClick='applyFilter()'> </td> <td> <input id='clear' type='button' value='<?php print __('Clear'); ?> ' onClick='clearFilter()'> </td> <td> <input id='import' type='button' value='<?php print __('Import'); ?> ' onClick='importTemplate()'> </td> </tr> </table> </form> <script type='text/javascript'> function applyFilter() { strURL = 'thold_templates.php?header=false&rows=' + $('#rows').val(); strURL += '&filter=' + $('#filter').val(); loadPageNoHeader(strURL); } function clearFilter() { strURL = 'thold_templates.php?header=false&clear=1'; loadPageNoHeader(strURL); } function importTemplate() { strURL = 'thold_templates.php?header=false&action=import'; loadPageNoHeader(strURL); } $(function() { $('#listthold').submit(function(event) { event.preventDefault(); applyFilter(); }); }); </script> </td> </tr> <?php html_end_box(); $sql_where = ''; $limit = ' LIMIT ' . $rows * (get_request_var('page') - 1) . ',' . $rows; $order = 'ORDER BY ' . get_request_var('sort_column') . ' ' . get_request_var('sort_direction'); if (strlen(get_request_var('filter'))) { $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . " thold_template.name LIKE '%" . get_request_var('filter') . "%'"; } $total_rows = db_fetch_cell('SELECT count(*) FROM thold_template'); $template_list = db_fetch_assoc("SELECT * FROM thold_template {$sql_where} {$order} {$limit}"); $nav = html_nav_bar('thold_templates.php?filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 10, __('Templates'), 'page', 'main'); form_start('thold_templates.php', 'chk'); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array('name' => array(__('Name'), 'ASC'), 'data_template_name' => array(__('Data Template'), 'ASC'), 'data_source_name' => array(__('DS Name'), 'ASC'), 'thold_type' => array(__('Type'), 'ASC'), 'nosort1' => array(__('High/Up'), ''), 'nosort2' => array(__('Low/Down'), ''), 'nosort3' => array(__('Trigger'), ''), 'nosort4' => array(__('Duration'), ''), 'nosort5' => array(__('Repeat'), '')); html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false); $i = 0; if (sizeof($template_list)) { foreach ($template_list as $template) { switch ($template['thold_type']) { case 0: # hi/lo $value_hi = thold_format_number($template['thold_hi']); $value_lo = thold_format_number($template['thold_low']); $value_trig = $template['thold_fail_trigger']; $value_duration = ''; $value_warning_hi = thold_format_number($template['thold_warning_hi']); $value_warning_lo = thold_format_number($template['thold_warning_low']); $value_warning_trig = $template['thold_warning_fail_trigger']; $value_warning_duration = ''; break; case 1: # baseline $value_hi = $template['bl_pct_up'] . (strlen($template['bl_pct_up']) ? '%' : '-'); $value_lo = $template['bl_pct_down'] . (strlen($template['bl_pct_down']) ? '%' : '-'); $value_trig = $template['bl_fail_trigger']; $step = db_fetch_cell_prepared('SELECT rrd_step FROM data_template_data WHERE data_template_id = ? LIMIT 1', array($template['data_template_id'])); $value_duration = $template['bl_ref_time_range'] / $step; break; case 2: #time $value_hi = thold_format_number($template['time_hi']); $value_lo = thold_format_number($template['time_low']); $value_trig = $template['time_fail_trigger']; $value_duration = $template['time_fail_length']; break; } $name = $template['name'] == '' ? $template['data_template_name'] . ' [' . $template['data_source_name'] . ']' : $template['name']; $name = filter_value($name, get_request_var('filter')); form_alternate_row('line' . $template['id']); form_selectable_cell('<a class="linkEditMain" href="' . htmlspecialchars('thold_templates.php?action=edit&id=' . $template['id']) . '">' . $name . '</a>', $template['id']); form_selectable_cell(filter_value($template['data_template_name'], get_request_var('filter')), $template['id']); form_selectable_cell($template['data_source_name'], $template['id']); form_selectable_cell($thold_types[$template['thold_type']], $template['id']); form_selectable_cell($value_hi, $template['id']); form_selectable_cell($value_lo, $template['id']); $trigger = plugin_thold_duration_convert($template['data_template_id'], $value_trig, 'alert', 'data_template_id'); form_selectable_cell(strlen($trigger) ? '<i>' . $trigger . '</i>' : '-', $template['id']); $duration = plugin_thold_duration_convert($template['data_template_id'], $value_duration, 'time', 'data_template_id'); form_selectable_cell(strlen($duration) ? $duration : '-', $template['id']); form_selectable_cell(plugin_thold_duration_convert($template['data_template_id'], $template['repeat_alert'], 'repeat', 'data_template_id'), $template['id']); form_checkbox_cell($template['data_template_name'], $template['id']); form_end_row(); } } else { print "<tr><td><em>" . __('No Threshold Templates') . "</em></td></tr>\n"; } html_end_box(false); if (sizeof($template_list)) { print $nav; } /* draw the dropdown containing a list of available actions for this form */ draw_actions_dropdown($thold_actions); form_end(); }
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 mactrack_view_aggregated_macs() { global $title, $report, $mactrack_search_types, $rows_selector, $config; global $mactrack_view_agg_macs_actions, $item_rows; mactrack_tabs(); html_start_box($title, '100%', '', '3', 'center', ''); mactrack_mac_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'); } $port_results = mactrack_view_get_mac_records($sql_where, TRUE, $row_limit); /* prevent table scans, either a device or site must be selected */ if (get_request_var('site_id') == -1 && get_request_var('device_id') == -1) { $total_rows = 0; } else { $rows_query_string = 'SELECT COUNT(*) FROM mac_track_aggregated_ports LEFT JOIN mac_track_sites ON (mac_track_aggregated_ports.site_id=mac_track_sites.site_id) LEFT JOIN mac_track_oui_database ON (mac_track_oui_database.vendor_mac=mac_track_aggregated_ports.vendor_mac) ' . str_replace('mac_track_ports', 'mac_track_aggregated_ports', $sql_where); $total_rows = db_fetch_cell($rows_query_string); } $nav = html_nav_bar('mactrack_view_macs.php?report=macs&scan_date=3', MAX_DISPLAY_PAGES, get_request_var('page'), $row_limit, $total_rows, 12, 'MAC Addresses'); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array('device_name' => array(__('Switch Name'), 'ASC'), 'hostname' => array(__('Switch Hostname'), 'ASC'), 'ip_address' => array(__('ED IP Address'), 'ASC')); if (strlen(read_config_option('mt_reverse_dns')) > 0) { $display_text['dns_hostname'] = array('ED DNS Hostname', 'ASC'); } $display_text = array_merge($display_text, array('mac_address' => array(__('ED MAC Address'), 'ASC'), 'vendor_name' => array(__('Vendor Name'), 'ASC'), 'port_number' => array(__('Port Number'), 'DESC'), 'port_name' => array(__('Port Name'), 'ASC'), 'vlan_id' => array(__('VLAN ID'), 'DESC'), 'vlan_name' => array(__('VLAN Name'), 'ASC'))); if (get_request_var('rows') == 1) { $display_text['max_scan_date'] = array(__('Last Scan Date'), 'DESC'); } else { $display_text['scan_date'] = array(__('Last Scan Date'), 'DESC'); } if (get_request_var('scan_date') == 3) { $display_text['count_rec'] = array(__('Count'), 'ASC'); } if (mactrack_check_user_realm(2122)) { html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction')); } else { html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction')); } $i = 0; $delim = read_config_option('mt_mac_delim'); if (sizeof($port_results)) { foreach ($port_results as $port_result) { if ($port_result['active_last'] == 1) { $color_line_date = "<span style='font-weight: bold;'>"; } else { $color_line_date = ''; } $key = str_replace($delim, '_', $port_result['mac_address']) . '-' . $port_result['device_id'] . $port_result['port_number'] . '-' . $port_result['date_last']; $key = $port_result['row_id']; form_alternate_row('line' . $key, true); form_selectable_cell(filter_value($port_result['device_name'], get_request_var('filter')), $key); form_selectable_cell(filter_value($port_result['hostname'], get_request_var('filter')), $key); form_selectable_cell(filter_value($port_result['ip_address'], get_request_var('filter')), $key); if (strlen(read_config_option('mt_reverse_dns')) > 0) { form_selectable_cell(filter_value($port_result['dns_hostname'], get_request_var('filter')), $key); } form_selectable_cell(filter_value($port_result['mac_address'], get_request_var('filter')), $key); form_selectable_cell(filter_value($port_result['vendor_name'], get_request_var('filter')), $key); form_selectable_cell($port_result['port_number'], $key); form_selectable_cell(filter_value($port_result['port_name'], get_request_var('filter')), $key); form_selectable_cell($port_result['vlan_id'], $key); form_selectable_cell(filter_value($port_result['vlan_name'], get_request_var('filter')), $key); form_selectable_cell($color_line_date . $port_result['date_last'], $key); form_selectable_cell($port_result['count_rec'], $key); if (mactrack_check_user_realm(2122)) { form_checkbox_cell($port_result['mac_address'], $key); } form_end_row(); } } else { if (get_request_var('site_id') == -1 && get_request_var('device_id') == -1) { print "<tr><td colspan='10'><em>" . __('You must first choose a Site, Device or other search criteria.') . "</em></td></tr>"; } else { print "<tr><td colspan='10'><em>" . __('No MacTrack Port Results') . "</em></td></tr>"; } } html_end_box(false); if (sizeof($port_results)) { print $nav; mactrack_display_stats(); } if (mactrack_check_user_realm(2122)) { /* draw the dropdown containing a list of available actions for this form */ draw_actions_dropdown($mactrack_view_agg_macs_actions); } }
function mactrack_view_sites() { global $title, $config, $item_rows; mactrack_sites_request_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'); } $webroot = $config['url_path'] . '/plugins/mactrack/'; mactrack_tabs(); html_start_box($title, '100%', '', '3', 'center', ''); mactrack_site_filter('mactrack_view_sites.php'); html_end_box(); $sql_where = ''; $sites = mactrack_view_get_site_records($sql_where, $row_limit); if (get_request_var('detail') == 'false') { $total_rows = db_fetch_cell("SELECT\n\t\t\tCOUNT(mac_track_sites.site_id)\n\t\t\tFROM mac_track_sites\n\t\t\t{$sql_where}"); } else { $total_rows = sizeof(db_fetch_assoc("SELECT\n\t\t\tmac_track_device_types.device_type_id, mac_track_sites.site_name\n\t\t\tFROM (mac_track_device_types\n\t\t\tRIGHT JOIN mac_track_devices ON (mac_track_device_types.device_type_id = mac_track_devices.device_type_id))\n\t\t\tRIGHT JOIN mac_track_sites ON (mac_track_devices.site_id = mac_track_sites.site_id)\n\t\t\t{$sql_where}\n\t\t\tGROUP BY mac_track_sites.site_name, mac_track_device_types.device_type_id")); } $nav = html_nav_bar('mactrack_view_sites.php', MAX_DISPLAY_PAGES, get_request_var('page'), $row_limit, $total_rows, 11, __('Sites')); print $nav; html_start_box('', '100%', '', '3', 'center', ''); if (get_request_var('detail') == 'false') { $display_text = array('nosort' => array(__('Actions'), ''), 'site_name' => array(__('Site Name'), 'ASC'), 'total_devices' => array(__('Devices'), 'DESC'), 'total_ips' => array(__('Total IP\'s'), 'DESC'), 'total_user_ports' => array(__('User Ports'), 'DESC'), 'total_oper_ports' => array(__('User Ports Up'), 'DESC'), 'total_macs' => array(__('MACS Found'), 'DESC'), 'total_device_errors' => array(__('Device Errors'), 'DESC')); html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction')); if (sizeof($sites) > 0) { foreach ($sites as $site) { form_alternate_row('row_' . $site['site_id'], true); ?> <td width=140> <?php if (api_user_realm_auth('mactrack_sites.php')) { echo "<a href='" . htmlspecialchars($webroot . 'mactrack_sites.php?action=edit&site_id=' . $site['site_id']) . "' title='" . __('Edit Site') . "'><img border='0' src='" . $webroot . "images/edit_object.png'></a>"; echo "<a href='#'><img id='r_" . $site['site_id'] . "' src='" . $webroot . "images/rescan_site.gif' alt='' onClick='site_scan(" . $site['site_id'] . ")' title='" . __('Rescan Site') . "' border='0'></a>"; } ?> <a href='<?php print htmlspecialchars($webroot . 'mactrack_view_devices.php?report=devices&reset&site_id=' . $site['site_id']); ?> ' title='<?php print __('View Devices'); ?> '><img border='0' src='<?php print $webroot; ?> images/view_devices.gif'></a> <a href='<?php print htmlspecialchars($webroot . 'mactrack_view_ips.php?report=ips&reset&site_id=' . $site['site_id']); ?> ' title='<?php print __('View IP Ranges'); ?> '><img border='0' src='<?php print $webroot; ?> images/view_networks.gif'></a> <a href='<?php print htmlspecialchars($webroot . 'plugins/mactrack/mactrack_view_arp.php?report=arp&reset&site_id=' . $site['site_id']); ?> ' title='<?php print __('View IP Addresses'); ?> '><img border='0' src='<?php print $webroot; ?> images/view_ipaddresses.gif'></a> <a href='<?php print htmlspecialchars($webroot . 'plugins/mactrack/mactrack_view_macs.php?report=macs&reset&device_id=-1&scan_date=3&site_id=' . $site['site_id']); ?> ' title='<?php print __('View MAC Addresses'); ?> '><img border='0' src='<?php print $webroot; ?> images/view_macs.gif'></a> <a href='<?php print htmlspecialchars($webroot . 'mactrack_view_interfaces.php?report=interfaces&reset&site=' . $site['site_id']); ?> ' title='<?php print __('View Interfaces'); ?> '><img border='0' src='<?php print $webroot; ?> images/view_interfaces.gif'></a> </td> <td class='hyperLink'> <?php print filter_value($site['site_name'], get_request_var('filter')); ?> </td> <td><?php print number_format_i18n($site['total_devices']); ?> </td> <td><?php print number_format_i18n($site['total_ips']); ?> </td> <td><?php print number_format_i18n($site['total_user_ports']); ?> </td> <td><?php print number_format_i18n($site['total_oper_ports']); ?> </td> <td><?php print number_format_i18n($site['total_macs']); ?> </td> <td><?php print $site['total_device_errors']; ?> </td> </tr> <?php } } else { print '<tr><td colspan="10"><em>' . __('No MacTrack Sites') . '</em></td></tr>'; } html_end_box(false); if (sizeof($sites)) { print $nav; mactrack_display_stats(); } } else { $display_text = array('nosort' => array(__('Actions'), ''), 'site_name' => array(__('Site Name'), 'ASC'), 'vendor' => array(__('Vendor'), 'ASC'), 'description' => array(__('Device Type'), 'DESC'), 'total_devices' => array(__('Total Devices'), 'DESC'), 'sum_ips_total' => array(__('Total IP\'s'), 'DESC'), 'sum_ports_total' => array(__('Total User Ports'), 'DESC'), 'sum_ports_active' => array(__('Total Oper Ports'), 'DESC'), 'sum_ports_trunk' => array(__('Total Trunks'), 'DESC'), 'sum_macs_active' => array(__('MACS Found'), 'DESC')); html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction')); if (sizeof($sites)) { foreach ($sites as $site) { form_alternate_row(); ?> <td width=100> <?php if (api_user_realm_auth('mactrack_sites.php')) { echo "<a href='" . htmlspecialchars($webroot . 'mactrack_sites.php?action=edit&site_id=' . $site['site_id']) . "' title='" . __('Edit Site') . "'><img border='0' src='" . $webroot . "images/edit_object.png'></a>"; } ?> <a href='<?php print htmlspecialchars($webroot . 'mactrack_view_devices.php?report=devices&site_id=' . $site['site_id'] . '&device_type_id=' . $site['device_type_id'] . '&type_id=-1&status=-1&filter='); ?> ' title='<?php print __('View Devices'); ?> '><img border='0' src='<?php print $webroot; ?> images/view_devices.gif'></a> <a href='<?php print htmlspecialchars($webroot . 'mactrack_view_ips.php?report=ips&reset&site_id=' . $site['site_id']); ?> ' title='<?php print __('View IP Ranges'); ?> '><img border='0' src='<?php print $webroot; ?> images/view_networks.gif'></a> <a href='<?php print htmlspecialchars($webroot . 'mactrack_view_macs.php?report=macs&reset&device_id=-1&scan_date=3&site_id=' . $site['site_id']); ?> ' title='<?php print __('View MAC Addresses'); ?> '><img border='0' src='<?php print $webroot; ?> images/view_macs.gif'></a> <a href='<?php print htmlspecialchars($webroot . 'mactrack_view_interfaces.php?report=interfaces&reset&site=' . $site['site_id']); ?> ' title='<?php print __('View Interfaces'); ?> '><img border='0' src='<?php print $webroot; ?> images/view_interfaces.gif'></a> </td> <td class='hyperLink'> <?php print filter_value($site['site_name'], get_request_var('filter')); ?> </td> <td><?php print filter_value($site['vendor'], get_request_var('filter')); ?> <td><?php print filter_value($site['description'], get_request_var('filter')); ?> <td><?php print number_format_i18n($site['total_devices']); ?> </td> <td><?php print $site['device_type'] == '1' ? __('N/A') : number_format_i18n($site['sum_ips_total']); ?> </td> <td><?php print $site['device_type'] == '3' ? __('N/A') : number_format_i18n($site['sum_ports_total']); ?> </td> <td><?php print $site['device_type'] == '3' ? __('N/A') : number_format_i18n($site['sum_ports_active']); ?> </td> <td><?php print $site['device_type'] == '3' ? __('N/A') : number_format_i18n($site['sum_ports_trunk']); ?> </td> <td><?php print $site['device_type'] == '3' ? __('N/A') : number_format_i18n($site['sum_macs_active']); ?> </td> </tr> <?php } } else { print '<tr><td colspan="10"><em>' . __('No MacTrack Sites') . '</em></td></tr>'; } html_end_box(false); if (sizeof($sites)) { print $nav; mactrack_display_stats(); } } print '<div id="response"></div>'; }
function mactrack_view_ips() { global $title, $report, $mactrack_search_types, $rows_selector, $config; global $item_rows; mactrack_view_ips_validate_request_vars(); mactrack_tabs(); html_start_box($title, '100%', '', '3', 'center', ''); mactrack_ip_address_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'); } $port_results = mactrack_view_get_ip_records($sql_where, TRUE, $row_limit); /* prevent table scans, either a device or site must be selected */ if (!strlen($sql_where)) { $total_rows = 0; } elseif (get_request_var('rows') == 1) { $rows_query_string = "SELECT\n\t\t\tCOUNT(mac_track_ips.device_id)\n\t\t\tFROM mac_track_ips\n\t\t\tLEFT JOIN mac_track_sites ON (mac_track_ips.site_id=mac_track_sites.site_id)\n\t\t\tLEFT JOIN mac_track_oui_database ON (mac_track_oui_database.vendor_mac=SUBSTRING(mac_track_ips.mac_address,1,8))\n\t\t\t{$sql_where}"; $total_rows = db_fetch_cell($rows_query_string); } else { $rows_query_string = "SELECT\n\t\t\tCOUNT(DISTINCT device_id, mac_address, port_number, ip_address)\n\t\t\tFROM mac_track_ips\n\t\t\tLEFT JOIN mac_track_sites ON (mac_track_ips.site_id=mac_track_sites.site_id)\n\t\t\tLEFT JOIN mac_track_oui_database ON (mac_track_oui_database.vendor_mac=SUBSTRING(mac_track_ips.mac_address,1,8))\n\t\t\t{$sql_where}"; $total_rows = db_fetch_cell($rows_query_string); } $nav = html_nav_bar('mactrack_view_arp.php', MAX_DISPLAY_PAGES, get_request_var('page'), $row_limit, $total_rows, 13, __('ARP Cache')); print $nav; html_start_box('', '100%', '', '3', 'center', ''); if (strlen(read_config_option('mt_reverse_dns')) > 0) { if (get_request_var('rows') == 1) { $display_text = array('device_name' => array(__('Switch Name'), 'ASC'), 'hostname' => array(__('Switch Hostname'), 'ASC'), 'ip_address' => array(__('ED IP Address'), 'ASC'), 'dns_hostname' => array(__('ED DNS Hostname'), 'ASC'), 'mac_address' => array(__('ED MAC Address'), 'ASC'), 'vendor_name' => array(__('Vendor Name'), 'ASC'), 'port_number' => array(__('Port Number'), 'DESC')); } else { $display_text = array('device_name' => array(__('Switch Name'), 'ASC'), 'hostname' => array(__('Switch Hostname'), 'ASC'), 'ip_address' => array(__('ED IP Address'), 'ASC'), 'dns_hostname' => array(__('ED DNS Hostname'), 'ASC'), 'mac_address' => array(__('ED MAC Address'), 'ASC'), 'vendor_name' => array(__('Vendor Name'), 'ASC'), 'port_number' => array(__('Port Number'), 'DESC')); } html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction')); } else { if (get_request_var('rows') == 1) { $display_text = array('device_name' => array(__('Switch Name'), 'ASC'), 'hostname' => array(__('Switch Hostname'), 'ASC'), 'ip_address' => array(__('ED IP Address'), 'ASC'), 'mac_address' => array(__('ED MAC Address'), 'ASC'), 'vendor_name' => array(__('Vendor Name'), 'ASC'), 'port_number' => array(__('Port Number'), 'DESC')); } else { $display_text = array('device_name' => array(__('Switch Device'), 'ASC'), 'hostname' => array(__('Switch Hostname'), 'ASC'), 'ip_address' => array(__('ED IP Address'), 'ASC'), 'mac_address' => array(__('ED MAC Address'), 'ASC'), 'vendor_name' => array(__('Vendor Name'), 'ASC'), 'port_number' => array(__('Port Number'), 'DESC')); } html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction')); } $i = 0; $delim = read_config_option('mt_mac_delim'); if (sizeof($port_results) > 0) { foreach ($port_results as $port_result) { form_alternate_row(); echo '<td>' . $port_result['device_name'] . '</td>'; echo '<td>' . $port_result['hostname'] . '</td>'; echo '<td>' . filter_value($port_result['ip_address'], get_request_var('filter')) . '</td>'; if (strlen(read_config_option('mt_reverse_dns')) > 0) { echo '<td>' . filter_value($port_result['dns_hostname'], get_request_var('filter')) . '</td>'; } echo '<td>' . filter_value($port_result['mac_address'], get_request_var('filter')) . '</td>'; echo '<td>' . filter_value($port_result['vendor_name'], get_request_var('filter')) . '</td>'; echo '<td>' . $port_result['port_number'] . '</td>'; form_end_row(); } } else { if (get_request_var('site_id') == -1 && get_request_var('device_id') == -1) { print '<tr><td colspan="10"><em>' . __('You must first choose a Site, Device or other search criteria.') . '</em></td></tr>'; } else { print '<tr><td colspan="10"><em>' . __('No MacTrack IP Results Found') . '</em></td></tr>'; } } html_end_box(false); if (sizeof($port_results)) { print $nav; mactrack_display_stats(); } }