function mactrack_view_ip_ranges() { global $title, $config, $item_rows; mactrack_view_ips_validate_request_vars(); if (get_request_var('rows') == -1) { $row_limit = read_config_option('num_rows_table'); } elseif (get_request_var('rows') == -2) { $row_limit = 999999; } else { $row_limit = get_request_var('rows'); } $webroot = $config['url_path'] . 'plugins/mactrack/'; mactrack_tabs(); html_start_box($title, '100%', '', '3', 'center', ''); mactrack_ips_filter(); html_end_box(); $sql_where = ''; $ip_ranges = mactrack_view_get_ip_range_records($sql_where, $row_limit); $total_rows = db_fetch_cell("SELECT\n\t\tCOUNT(mac_track_ip_ranges.ip_range)\n\t\tFROM mac_track_ip_ranges\n\t\tINNER JOIN mac_track_sites ON (mac_track_ip_ranges.site_id=mac_track_sites.site_id)\n\t\t{$sql_where}"); $nav = html_nav_bar('mactrack_view_ips.php', MAX_DISPLAY_PAGES, get_request_var('page'), $row_limit, $total_rows, 7, __('IP Address Ranges')); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array('nosort' => array(__('Actions'), ''), 'site_name' => array(__('Site Name'), 'ASC'), 'ip_range' => array(__('IP Range'), 'ASC'), 'ips_current' => array(__('Current IP Addresses'), 'DESC'), 'ips_current_date' => array(__('Current Date'), 'DESC'), 'ips_max' => array(__('Maximum IP Addresses'), 'DESC'), 'ips_max_date' => array(__('Maximum Date'), 'DESC')); html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction')); if (sizeof($ip_ranges)) { foreach ($ip_ranges as $ip_range) { form_alternate_row(); ?> <td width=80> <a href='<?php print htmlspecialchars($webroot . 'mactrack_sites.php?action=edit&site_id=' . $ip_range['site_id']); ?> ' title='Edit Site'><img border='0' src='<?php print $webroot; ?> images/edit_object.png'></a> <a href='<?php print htmlspecialchars($webroot . 'mactrack_view_macs.php?report=macs&reset&ip_filter_type_id=3&ip_filter=' . $ip_range['ip_range'] . '&device_id=-1&scan_date=3&site_id=' . $ip_range['site_id']); ?> ' title='View MAC Addresses'><img border='0' src='<?php print $webroot; ?> images/view_macs.gif'></a> <a href='<?php print htmlspecialchars($webroot . 'mactrack_view_arp.php?report=arp&reset&ip_filter_type_id=3&ip_filter=' . $ip_range['ip_range'] . '.' . '&device_id=-1&scan_date=3&site_id=' . $ip_range['site_id']); ?> ' title='View IP Addresses'><img border='0' src='<?php print $webroot; ?> images/view_ipaddresses.gif'></a> </td> <td class='hyperLink'> <?php print $ip_range['site_name']; ?> </td> <td><?php print $ip_range['ip_range'] . '.*'; ?> </td> <td><?php print number_format_i18n($ip_range['ips_current']); ?> </td> <td><?php print $ip_range['ips_current_date']; ?> </td> <td><?php print number_format_i18n($ip_range['ips_max']); ?> </td> <td><?php print $ip_range['ips_max_date']; ?> </td> </tr> <?php } } else { print '<tr><td colspan="10"><em>' . __('No MacTrack Site IP Ranges Found') . '</em></td></tr>'; } html_end_box(false); if (sizeof($ip_ranges)) { print $nav; mactrack_display_stats(); } }
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 utilities_view_poller_cache() { global $poller_actions; define("MAX_DISPLAY_PAGES", 21); /* ================= input validation ================= */ input_validate_input_number(get_request_var_request("host_id")); input_validate_input_number(get_request_var_request("page")); input_validate_input_number(get_request_var_request("poller_action")); /* ==================================================== */ /* clean up search filter */ if (isset($_REQUEST["filter"])) { $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter")); } /* clean up sort_column */ if (isset($_REQUEST["sort_column"])) { $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); } /* clean up sort direction */ if (isset($_REQUEST["sort_direction"])) { $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); } /* if the user pushed the 'clear' button */ if (isset($_REQUEST["clear_x"])) { kill_session_var("sess_poller_current_page"); kill_session_var("sess_poller_host_id"); kill_session_var("sess_poller_poller_action"); kill_session_var("sess_poller_filter"); unset($_REQUEST["page"]); unset($_REQUEST["filter"]); unset($_REQUEST["host_id"]); unset($_REQUEST["poller_action"]); } if (!empty($_SESSION["sess_poller_action"]) && !empty($_REQUEST["poller_action"])) { if ($_SESSION["sess_poller_poller_action"] != $_REQUEST["poller_action"]) { $_REQUEST["page"] = 1; } } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value("page", "sess_poller_current_page", "1"); load_current_session_value("host_id", "sess_poller_host_id", "-1"); load_current_session_value("poller_action", "sess_poller_poller_action", "-1"); load_current_session_value("filter", "sess_poller_filter", ""); load_current_session_value("sort_column", "sess_poller_sort_column", "data_template_data.name_cache"); load_current_session_value("sort_direction", "sess_poller_sort_direction", "ASC"); $_REQUEST['page_referrer'] = 'view_poller_cache'; load_current_session_value('page_referrer', 'page_referrer', 'view_poller_cache'); ?> <script type="text/javascript"> <!-- function applyPItemFilterChange(objForm) { strURL = '?poller_action=' + objForm.poller_action.value; strURL = strURL + '&host_id=' + objForm.host_id.value; strURL = strURL + '&filter=' + objForm.filter.value; strURL = strURL + '&action=view_poller_cache'; document.location = strURL; } --> </script> <?php html_start_box("<strong>Poller Cache Items</strong>", "100%", "", "3", "center", ""); ?> <tr class='even noprint'> <td> <form name="form_pollercache" action="utilities.php"> <table cellpadding="0" cellspacing="0"> <tr> <td nowrap style='white-space: nowrap;' width="50"> Host: </td> <td width="1"> <select name="host_id" onChange="applyPItemFilterChange(document.form_pollercache)"> <option value="-1"<?php if (get_request_var_request("host_id") == "-1") { ?> selected<?php } ?> >Any</option> <option value="0"<?php if (get_request_var_request("host_id") == "0") { ?> selected<?php } ?> >None</option> <?php $hosts = db_fetch_assoc("select id,description,hostname from host order by description"); if (sizeof($hosts) > 0) { foreach ($hosts as $host) { print "<option value='" . $host["id"] . "'"; if (get_request_var_request("host_id") == $host["id"]) { print " selected"; } print ">" . $host["description"] . "</option>\n"; } } ?> </select> </td> <td nowrap style='white-space: nowrap;' width="50"> Action: </td> <td width="1"> <select name="poller_action" onChange="applyPItemFilterChange(document.form_pollercache)"> <option value="-1"<?php if (get_request_var_request("poller_action") == '-1') { ?> selected<?php } ?> >Any</option> <option value="0"<?php if (get_request_var_request("poller_action") == '0') { ?> selected<?php } ?> >SNMP</option> <option value="1"<?php if (get_request_var_request("poller_action") == '1') { ?> selected<?php } ?> >Script</option> <option value="2"<?php if (get_request_var_request("poller_action") == '2') { ?> selected<?php } ?> >Script Server</option> </select> </td> <td nowrap style='white-space: nowrap;' width="50"> Search: </td> <td width="1"> <input type="text" name="filter" size="40" value="<?php print htmlspecialchars(get_request_var_request("filter")); ?> "> </td> <td nowrap style='white-space: nowrap;'> <input type="submit" name="go" value="Go" title="Set/Refresh Filters"> <input type="submit" name="clear_x" value="Clear" title="Clear Filters"> </td> </tr> </table> <input type='hidden' name='page' value='1'> <input type='hidden' name='action' value='view_poller_cache'> </form> </td> </tr> <?php html_end_box(); /* form the 'where' clause for our main sql query */ $sql_where = "WHERE poller_item.local_data_id=data_template_data.local_data_id"; if (get_request_var_request("poller_action") != "-1") { $sql_where .= " AND poller_item.action='" . get_request_var_request("poller_action") . "'"; } if (get_request_var_request("host_id") == "-1") { /* Show all items */ } elseif (get_request_var_request("host_id") == "0") { $sql_where .= " AND poller_item.host_id=0"; } elseif (!empty($_REQUEST["host_id"])) { $sql_where .= " AND poller_item.host_id=" . get_request_var_request("host_id"); } if (strlen(get_request_var_request("filter"))) { $sql_where .= " AND (data_template_data.name_cache LIKE '%%" . get_request_var_request("filter") . "%%'\n\t\t\tOR host.description LIKE '%%" . get_request_var_request("filter") . "%%'\n\t\t\tOR poller_item.arg1 LIKE '%%" . get_request_var_request("filter") . "%%'\n\t\t\tOR poller_item.hostname LIKE '%%" . get_request_var_request("filter") . "%%'\n\t\t\tOR poller_item.rrd_path LIKE '%%" . get_request_var_request("filter") . "%%')"; } html_start_box("", "100%", "", "3", "center", ""); $total_rows = db_fetch_cell("SELECT\n\t\tCOUNT(*)\n\t\tFROM data_template_data\n\t\tRIGHT JOIN (poller_item\n\t\tLEFT JOIN host\n\t\tON poller_item.host_id=host.id)\n\t\tON data_template_data.local_data_id=poller_item.local_data_id\n\t\t{$sql_where}"); $poller_sql = "SELECT\n\t\tpoller_item.*,\n\t\tdata_template_data.name_cache,\n\t\thost.description\n\t\tFROM data_template_data\n\t\tRIGHT JOIN (poller_item\n\t\tLEFT JOIN host\n\t\tON poller_item.host_id=host.id)\n\t\tON data_template_data.local_data_id=poller_item.local_data_id\n\t\t{$sql_where}\n\t\tORDER BY " . get_request_var_request("sort_column") . " " . get_request_var_request("sort_direction") . ", action ASC\n\t\tLIMIT " . read_config_option("num_rows_data_source") * (get_request_var_request("page") - 1) . "," . read_config_option("num_rows_data_source"); $poller_cache = db_fetch_assoc($poller_sql); $nav = html_nav_bar("utilities.php?action=view_poller_cache&host_id=" . get_request_var_request("host_id") . "&poller_action=" . get_request_var_request("poller_action"), MAX_DISPLAY_PAGES, get_request_var_request("page"), read_config_option("num_rows_data_source"), $total_rows, 3); print $nav; $display_text = array("data_template_data.name_cache" => array("Data Source Name", "ASC"), "nosort" => array("Details", "ASC")); html_header_sort($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction")); $i = 0; if (sizeof($poller_cache) > 0) { foreach ($poller_cache as $item) { form_alternate_row(); ?> <td width="375"> <a class="linkEditMain" href="<?php print htmlspecialchars("data_sources.php?action=ds_edit&id=" . $item["local_data_id"]); ?> "><?php print strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter"), "/") . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $item["name_cache"]) : $item["name_cache"]; ?> </a> </td> <td> <?php if ($item["action"] == 0) { if ($item["snmp_version"] != 3) { $details = "SNMP Version: " . $item["snmp_version"] . ", " . "Community: " . $item["snmp_community"] . ", " . "OID: " . (strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter"), "/") . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $item["arg1"]) : $item["arg1"]); } else { $details = "SNMP Version: " . $item["snmp_version"] . ", " . "User: "******"snmp_username"] . ", OID: " . $item["arg1"]; } } elseif ($item["action"] == 1) { $details = "Script: " . (strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter"), "/") . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $item["arg1"]) : $item["arg1"]); } else { $details = "Script Server: " . (strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter"), "/") . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $item["arg1"]) : $item["arg1"]); } print $details; ?> </td> </tr> <?php form_alternate_row(); ?> <td> </td> <td> RRD: <?php print $item["rrd_path"]; ?> </td> </tr> <?php $i++; } } print $nav; html_end_box(); }
function mactrack_view_sites() { global $title, $colors, $config, $item_rows; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request("site_id")); input_validate_input_number(get_request_var_request("device_id")); input_validate_input_number(get_request_var_request("page")); input_validate_input_number(get_request_var_request("rows")); /* ==================================================== */ /* clean up search string */ if (isset($_REQUEST["detail"])) { $_REQUEST["detail"] = sanitize_search_string(get_request_var("detail")); } /* clean up search string */ if (isset($_REQUEST["filter"])) { $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter")); } /* clean up sort_column */ if (isset($_REQUEST["sort_column"])) { $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); } /* clean up search string */ if (isset($_REQUEST["sort_direction"])) { $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); } /* if the user pushed the 'clear' button */ if (isset($_REQUEST["clear_x"]) || isset($_REQUEST["reset"])) { kill_session_var("sess_mactrack_view_sites_current_page"); kill_session_var("sess_mactrack_view_sites_detail"); kill_session_var("sess_mactrack_view_sites_device_type_id"); kill_session_var("sess_mactrack_view_sites_site_id"); kill_session_var("sess_mactrack_view_sites_filter"); kill_session_var("sess_mactrack_view_sites_rows"); kill_session_var("sess_mactrack_view_sites_sort_column"); kill_session_var("sess_mactrack_view_sites_sort_direction"); $_REQUEST["page"] = 1; if (isset($_REQUEST["clear_x"])) { unset($_REQUEST["filter"]); unset($_REQUEST["rows"]); unset($_REQUEST["device_type_id"]); unset($_REQUEST["site_id"]); unset($_REQUEST["detail"]); unset($_REQUEST["sort_column"]); unset($_REQUEST["sort_direction"]); } }else{ /* if any of the settings changed, reset the page number */ $changed = 0; $changed += mactrack_check_changed("device_type_id", "sess_mactrack_view_sites_device_type_id"); $changed += mactrack_check_changed("site_id", "sess_mactrack_view_sites_site_id"); $changed += mactrack_check_changed("filter", "sess_mactrack_view_sites_filter"); $changed += mactrack_check_changed("rows", "sess_mactrack_view_sites_rows"); $changed += mactrack_check_changed("detail", "sess_mactrack_view_sites_detail"); if ($changed) { $_REQUEST["page"] = "1"; } } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value("page", "sess_mactrack_view_sites_current_page", "1"); load_current_session_value("detail", "sess_mactrack_view_sites_detail", "false"); load_current_session_value("device_type_id", "sess_mactrack_view_sites_device_type_id", "-1"); load_current_session_value("site_id", "sess_mactrack_view_sites_site_id", "-1"); load_current_session_value("filter", "sess_mactrack_view_sites_filter", ""); load_current_session_value("rows", "sess_mactrack_view_sites_rows", "-1"); load_current_session_value("sort_column", "sess_mactrack_view_sites_sort_column", "site_name"); load_current_session_value("sort_direction", "sess_mactrack_view_sites_sort_direction", "ASC"); if ($_REQUEST["rows"] == -1) { $row_limit = read_config_option("num_rows_mactrack"); }elseif ($_REQUEST["rows"] == -2) { $row_limit = 999999; }else{ $row_limit = $_REQUEST["rows"]; } if (defined("URL_PATH")) { $webroot = URL_PATH; }else{ $webroot = $config["url_path"]; } mactrack_tabs(); mactrack_view_header(); mactrack_site_filter(); mactrack_view_footer(); html_start_box("", "100%", $colors["header"], "3", "center", ""); $sql_where = ""; $sites = mactrack_view_get_site_records($sql_where, $row_limit); if ($_REQUEST["detail"] == "false") { $total_rows = db_fetch_cell("SELECT COUNT(mac_track_sites.site_id) FROM mac_track_sites $sql_where"); }else{ $total_rows = sizeof(db_fetch_assoc("SELECT mac_track_device_types.device_type_id, mac_track_sites.site_name FROM (mac_track_device_types RIGHT JOIN mac_track_devices ON (mac_track_device_types.device_type_id = mac_track_devices.device_type_id)) RIGHT JOIN mac_track_sites ON (mac_track_devices.site_id = mac_track_sites.site_id) $sql_where GROUP BY mac_track_sites.site_name, mac_track_device_types.device_type_id")); } /* generate page list */ $url_page_select = str_replace("&page", "?page", get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, "mactrack_view_sites.php")); if (isset($config["base_path"])) { if ($total_rows > 0) { $nav = "<tr bgcolor='#" . $colors["header"] . "'> <td colspan='11'> <table width='100%' cellspacing='0' cellpadding='0' border='0'> <tr> <td align='left' class='textHeaderDark'> <strong><< "; if ($_REQUEST["page"] > 1) { $nav .= "<a class='linkOverDark' href='mactrack_view_sites.php?page=" . ($_REQUEST["page"]-1) . "'>"; } $nav .= "Previous"; if ($_REQUEST["page"] > 1) { $nav .= "</a>"; } $nav .= "</strong> </td>\n <td align='center' class='textHeaderDark'> Showing Rows " . ($total_rows == 0 ? "None" : (($row_limit*($_REQUEST["page"]-1))+1) . " to " . ((($total_rows < $row_limit) || ($total_rows < ($row_limit*$_REQUEST["page"]))) ? $total_rows : ($row_limit*$_REQUEST["page"])) . " of $total_rows [$url_page_select]") . " </td>\n <td align='right' class='textHeaderDark'> <strong>"; if (($_REQUEST["page"] * $row_limit) < $total_rows) { $nav .= "<a class='linkOverDark' href='mactrack_view_sites.php?page=" . ($_REQUEST["page"]+1) . "'>"; } $nav .= "Next"; if (($_REQUEST["page"] * $row_limit) < $total_rows) { $nav .= "</a>"; } $nav .= " >></strong> </td>\n </tr> </table> </td> </tr>\n"; }else{ $nav = "<tr bgcolor='#" . $colors["header"] . "' class='noprint'> <td colspan='22'> <table width='100%' cellspacing='0' cellpadding='0' border='0'> <tr> <td align='center' class='textHeaderDark'> No Rows Found </td>\n </tr> </table> </td> </tr>\n"; } }else{ $nav = html_create_nav($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, 11, "mactrack_view_sites.php"); } print $nav; if ($_REQUEST["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, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]); $i = 0; if (sizeof($sites) > 0) { foreach ($sites as $site) { form_alternate_row_color($colors["alternate"],$colors["light"],$i,'row_' . $site["site_id"]); $i++; ?> <td width=140> <?php if (mactrack_authorized(2121)) { echo "<a href='" . $webroot . "plugins/mactrack/mactrack_sites.php?action=edit&site_id=" . $site['site_id'] . "' title='Edit Site'><img border='0' src='" . $webroot . "plugins/mactrack/images/edit_object.png'></a>"; echo "<a href='#'><img id='r_" . $site["site_id"] . "' src='" . $config['url_path'] . "plugins/mactrack/images/rescan_site.gif' alt='' onMouseOver='style.cursor=\"pointer\"' onClick='site_scan(" . $site["site_id"] . ")' title='Rescan Site' border='0'></a>"; } ?> <a href='<?php print $webroot . "plugins/mactrack/mactrack_view_devices.php?report=devices&reset&site_id=" . $site['site_id'];?>' title='View Devices'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_devices.gif'></a> <a href='<?php print $webroot . "plugins/mactrack/mactrack_view_ips.php?report=ips&reset&site_id=" . $site['site_id'];?>' title='View IP Ranges'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_networks.gif'></a> <a href='<?php print $webroot . "plugins/mactrack/mactrack_view_arp.php?report=arp&reset&site_id=" . $site['site_id'];?>' title='View IP Addresses'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_ipaddresses.gif'></a> <a href='<?php print $webroot . "plugins/mactrack/mactrack_view_macs.php?report=macs&reset&device_id=-1&scan_date=3&site_id=" . $site['site_id'];?>' title='View MAC Addresses'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_macs.gif'></a> <a href='<?php print $webroot . "plugins/mactrack/mactrack_view_interfaces.php?report=interfaces&reset&site=" . $site['site_id'];?>' title='View Interfaces'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_interfaces.gif'></a> </td> <td width=200> <?php print "<strong>" . (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $site["site_name"]) : $site["site_name"]) . "</strong>";?> </td> <td><?php print number_format($site["total_devices"]);?></td> <td><?php print number_format($site["total_ips"]);?></td> <td><?php print number_format($site["total_user_ports"]);?></td> <td><?php print number_format($site["total_oper_ports"]);?></td> <td><?php print number_format($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>"; } print $nav; html_end_box(false); 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, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]); $i = 0; if (sizeof($sites) > 0) { foreach ($sites as $site) { form_alternate_row_color($colors["alternate"],$colors["light"],$i); $i++; ?> <td width=100> <?php if (mactrack_authorized(2121)) { echo "<a href='" . $webroot . "plugins/mactrack/mactrack_sites.php?action=edit&site_id=" . $site['site_id'] . "' title='Edit Site'><img border='0' src='" . $webroot . "plugins/mactrack/images/edit_object.png'></a>"; } ?> <a href='<?php print $webroot . "plugins/mactrack/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='View Devices'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_devices.gif'></a> <a href='<?php print $webroot . "plugins/mactrack/mactrack_view_ips.php?report=ips&reset&site_id=" . $site['site_id'];?>' title='View IP Ranges'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_networks.gif'></a> <a href='<?php print $webroot . "plugins/mactrack/mactrack_view_macs.php?report=macs&reset&device_id=-1&scan_date=3&site_id=" . $site['site_id'];?>' title='View MAC Addresses'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_macs.gif'></a> <a href='<?php print $webroot . "plugins/mactrack/mactrack_view_interfaces.php?report=interfaces&reset&site=" . $site['site_id'];?>' title='View Interfaces'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_interfaces.gif'></a> </td> <td width=200> <?php print "<strong>" . (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $site["site_name"]) : $site["site_name"]) . "</strong>";?> </td> <td><?php print (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $site["vendor"]) : $site["vendor"]);?></td> <td><?php print (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $site["description"]) : $site["description"]);?></td> <td><?php print number_format($site["total_devices"]);?></td> <td><?php print ($site["device_type"] == "1" ? "N/A" : number_format($site["sum_ips_total"]));?></td> <td><?php print ($site["device_type"] == "3" ? "N/A" : number_format($site["sum_ports_total"]));?></td> <td><?php print ($site["device_type"] == "3" ? "N/A" : number_format($site["sum_ports_active"]));?></td> <td><?php print ($site["device_type"] == "3" ? "N/A" : number_format($site["sum_ports_trunk"]));?></td> <td><?php print ($site["device_type"] == "3" ? "N/A" : number_format($site["sum_macs_active"]));?></td> </tr> <?php } }else{ print "<tr><td colspan='10'><em>No MacTrack Sites</em></td></tr>"; } print $nav; html_end_box(false); mactrack_display_stats(); } print "<div id='response'></div>"; }
/** function syslog_messages() * This is the main page display function in Syslog. Displays all the * syslog messages that are relevant to Syslog. */ function syslog_messages($tab = "syslog") { global $colors, $sql_where, $hostfilter, $severities; global $config, $syslog_incoming_config, $reset_multi, $syslog_levels; include "./include/global_arrays.php"; /* force the initial timespan to be 30 minutes for performance reasons */ if (!isset($_SESSION["sess_syslog_init"])) { $_SESSION["sess_current_timespan"] = 1; $_SESSION["sess_syslog_init"] = 1; } if (file_exists("./lib/timespan_settings.php")) { include "./lib/timespan_settings.php"; } else { include "./include/html/inc_timespan_settings.php"; } include dirname(__FILE__) . "/config.php"; /* create the custom css and javascript for the page */ generate_syslog_cssjs(); $url_curr_page = get_browser_query_string(); $sql_where = ""; if ($_REQUEST["rows"] == -1) { $row_limit = read_config_option("num_rows_syslog"); } elseif ($_REQUEST["rows"] == -2) { $row_limit = 999999; } else { $row_limit = $_REQUEST["rows"]; } $syslog_messages = get_syslog_messages($sql_where, $row_limit, $tab); $total_rows = syslog_filter($sql_where, $tab); /* generate page list */ $url_page_select = get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, "syslog.php?tab={$tab}"); if ($total_rows > 0) { $nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t\t\t<td colspan='13'>\n\t\t\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td align='left' class='textHeaderDark'>\n\t\t\t\t\t\t\t\t\t<strong><< "; if ($_REQUEST["page"] > 1) { $nav .= "<a class='linkOverDark' href='syslog.php?tab={$tab}&page=" . ($_REQUEST["page"] - 1) . "'>"; } $nav .= "Previous"; if ($_REQUEST["page"] > 1) { $nav .= "</a>"; } $nav .= "</strong>\n\t\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\t\t\tShowing Rows " . ($total_rows == 0 ? "None" : $row_limit * ($_REQUEST["page"] - 1) + 1 . " to " . ($total_rows < $row_limit || $total_rows < $row_limit * $_REQUEST["page"] ? $total_rows : $row_limit * $_REQUEST["page"]) . " of {$total_rows} [{$url_page_select}]") . "\n\t\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t\t<td align='right' class='textHeaderDark'>\n\t\t\t\t\t\t\t\t\t<strong>"; if ($_REQUEST["page"] * $row_limit < $total_rows) { $nav .= "<a class='linkOverDark' href='syslog.php?tab={$tab}&page=" . ($_REQUEST["page"] + 1) . "'>"; } $nav .= "Next"; if ($_REQUEST["page"] * $row_limit < $total_rows) { $nav .= "</a>"; } $nav .= " >></strong>\n\t\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; } else { $nav = "<tr bgcolor='#" . $colors["header"] . "' class='noprint'>\n\t\t\t\t\t<td colspan='22'>\n\t\t\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\t\t\tNo Rows Found\n\t\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; } print $nav; if ($tab == "syslog") { if (api_plugin_user_realm_auth('syslog_alerts.php')) { $display_text = array("nosortt" => array("Actions", "ASC"), "host_id" => array("Host", "ASC"), "logtime" => array("Date", "ASC"), "message" => array("Message", "ASC"), "facility_id" => array("Facility", "ASC"), "priority_id" => array("Priority", "ASC")); } else { $display_text = array("host_id" => array("Host", "ASC"), "logtime" => array("Date", "ASC"), "message" => array("Message", "ASC"), "facility_id" => array("Facility", "ASC"), "priority_id" => array("Priority", "ASC")); } html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]); $hosts = array_rekey(syslog_db_fetch_assoc("SELECT host_id, host FROM `" . $syslogdb_default . "`.`syslog_hosts`"), "host_id", "host"); $facilities = array_rekey(syslog_db_fetch_assoc("SELECT facility_id, facility FROM `" . $syslogdb_default . "`.`syslog_facilities`"), "facility_id", "facility"); $priorities = array_rekey(syslog_db_fetch_assoc("SELECT priority_id, priority FROM `" . $syslogdb_default . "`.`syslog_priorities`"), "priority_id", "priority"); $i = 0; if (sizeof($syslog_messages) > 0) { foreach ($syslog_messages as $syslog_message) { $title = "'" . str_replace("\"", "", str_replace("'", "", $syslog_message["message"])) . "'"; $tip_options = "CLICKCLOSE, 'true', WIDTH, '40', DELAY, '500', FOLLOWMOUSE, 'true', FADEIN, 450, FADEOUT, 450, BGCOLOR, '#F9FDAF', STICKY, 'true', SHADOWCOLOR, '#797C6E', TITLE, 'Message'"; syslog_row_color($colors["alternate"], $colors["light"], $i, $priorities[$syslog_message["priority_id"]], $title); $i++; if (api_plugin_user_realm_auth('syslog_alerts.php')) { print "<td style='whitspace-nowrap;width:1%;'>"; if ($syslog_message['mtype'] == 'main') { print "<a href='syslog_alerts.php?id=" . $syslog_message[$syslog_incoming_config["id"]] . "&date=" . $syslog_message["logtime"] . "&action=newedit&type=0'><img src='images/green.gif' align='absmiddle' border=0></a>\n\t\t\t\t\t\t<a href='syslog_removal.php?id=" . $syslog_message[$syslog_incoming_config["id"]] . "&date=" . $syslog_message["logtime"] . "&action=newedit&type=new&type=0'><img src='images/red.gif' align='absmiddle' border=0></a>\n"; } print "</td>\n"; } print "<td>" . $hosts[$syslog_message["host_id"]] . "</td>\n"; print "<td>" . $syslog_message["logtime"] . "</td>\n"; print "<td>" . (strlen($_REQUEST["filter"]) ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", title_trim($syslog_message[$syslog_incoming_config["textField"]], get_request_var_request("trimval"))) : title_trim($syslog_message[$syslog_incoming_config["textField"]], get_request_var_request("trimval"))) . "</td>\n"; print "<td>" . ucfirst($facilities[$syslog_message["facility_id"]]) . "</td>\n"; print "<td>" . ucfirst($priorities[$syslog_message["priority_id"]]) . "</td>\n"; } } else { print "<tr><td><em>No Messages</em></td></tr>"; } print $nav; html_end_box(false); syslog_syslog_legend(); } else { $display_text = array("name" => array("Alert Name", "ASC"), "severity" => array("Severity", "ASC"), "count" => array("Count", "ASC"), "logtime" => array("Date", "ASC"), "logmsg" => array("Message", "ASC"), "slhost" => array("Host", "ASC"), "facility" => array("Facility", "ASC"), "priority" => array("Priority", "ASC")); html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]); $i = 0; if (sizeof($syslog_messages) > 0) { foreach ($syslog_messages as $log) { $title = "'" . str_replace("\"", "", str_replace("'", "", $log["logmsg"])) . "'"; $tip_options = "CLICKCLOSE, 'true', WIDTH, '40', DELAY, '500', FOLLOWMOUSE, 'true', FADEIN, 450, FADEOUT, 450, BGCOLOR, '#F9FDAF', STICKY, 'true', SHADOWCOLOR, '#797C6E', TITLE, 'Message'"; switch ($log['severity']) { case "0": $color = "notice"; break; case "1": $color = "warn"; break; case "2": $color = "crit"; break; default: $color = "info"; break; } syslog_row_color($colors["alternate"], $colors["light"], $i, $color, $title); $i++; print "<td><a class='linkEditMain' href='" . $config["url_path"] . "plugins/syslog/syslog.php?id=" . $log["seq"] . "&tab=current'>" . (strlen($log["name"]) ? $log["name"] : "Alert Removed") . "</a></td>\n"; print "<td>" . (isset($severities[$log["severity"]]) ? $severities[$log["severity"]] : "Unknown") . "</td>\n"; print "<td>" . $log["count"] . "</td>\n"; print "<td>" . $log["logtime"] . "</td>\n"; print "<td>" . (strlen($_REQUEST["filter"]) ? eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", title_trim($log["logmsg"], get_request_var_request("trimval"))) : title_trim($log["logmsg"], get_request_var_request("trimval"))) . "</td>\n"; print "<td>" . $log["host"] . "</td>\n"; print "<td>" . ucfirst($log["facility"]) . "</td>\n"; print "<td>" . ucfirst($log["priority"]) . "</td>\n"; } } else { print "<tr><td><em>No Messages</em></td></tr>"; } print $nav; html_end_box(false); syslog_log_legend(); } /* put the nav bar on the bottom as well */ ?> </td> </tr> </table> </td> </tr> </table> </form> <script type='text/javascript'> function syslogFindPos(obj) { var curleft = curtop = 0; if (obj.offsetParent) { curleft = obj.offsetLeft; curtop = obj.offsetTop; while (obj = obj.offsetParent) { curleft += obj.offsetLeft; curtop += obj.offsetTop; } } return [curleft,curtop]; } function setHostMultiSelect() { selectPos = syslogFindPos(document.getElementById("host_select")); textSize = document.getElementById("host_all").scrollHeight; if (textSize == 0) textSize = 16; if (window.innerHeight) { height = window.innerHeight; }else{ height = document.body.clientHeight; } //alert("Height:"+height+", YPos:"+selectPos[1]+", TextSize:"+textSize); /* the full window size of the multi-select */ size = parseInt((height-selectPos[1]-5)/textSize); window.onresize = null; document.getElementById("host_select").size=size; window.onresize = this; } window.onresize = setHostMultiSelect; window.onload = setHostMultiSelect; </script> <?php }
function rra() { /* clean up sort_column */ if (isset($_REQUEST["sort_column"])) { $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); } /* clean up search string */ if (isset($_REQUEST["sort_direction"])) { $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value("sort_column", "sess_rra_sort_column", "timespan"); load_current_session_value("sort_direction", "sess_rra_sort_direction", "ASC"); html_start_box("<strong>Round Robin Archives</strong>", "100%", "", "3", "center", "rra.php?action=edit"); $display_text = array("name" => array("Name", "ASC"), "steps" => array("Steps", "ASC"), "rows" => array("Rows", "ASC"), "timespan" => array("Timespan", "ASC")); html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"], 4); $rras = db_fetch_assoc("SELECT\n\t\tid,\n\t\tname,\n\t\trows,\n\t\tsteps,\n\t\ttimespan\n\t\tFROM rra\n\t\tORDER BY " . $_REQUEST['sort_column'] . " " . $_REQUEST['sort_direction']); $i = 0; if (sizeof($rras) > 0) { foreach ($rras as $rra) { form_alternate_row('', true); ?> <td> <a class="linkEditMain" href="<?php print htmlspecialchars("rra.php?action=edit&id=" . $rra["id"]); ?> "><?php print htmlspecialchars($rra["name"]); ?> </a> </td> <td> <?php print $rra["steps"]; ?> </td> <td> <?php print $rra["rows"]; ?> </td> <td> <?php print $rra["timespan"]; ?> </td> <td align="right"> <a href="<?php print htmlspecialchars("rra.php?action=remove&id=" . $rra["id"]); ?> "><img src="images/delete_icon.gif" style="height:10px;width:10px;" border="0" alt="Delete"></a> </td> </tr> <?php } } html_end_box(); }
function update_show_current() { global $plugins, $pluginslist, $plugin_architecture, $config, $status_names, $actions, $item_rows; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request("page")); input_validate_input_number(get_request_var_request("rows")); /* ==================================================== */ /* clean up search string */ if (isset($_REQUEST["filter"])) { $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter")); } /* clean up sort_column */ if (isset($_REQUEST["sort_column"])) { $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); } /* clean up search string */ if (isset($_REQUEST["sort_direction"])) { $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); } /* if the user pushed the 'clear' button */ if (isset($_REQUEST["clear_x"])) { kill_session_var("sess_plugins_filter"); kill_session_var("sess_plugins_rows"); kill_session_var("sess_plugins_sort_column"); kill_session_var("sess_plugins_sort_direction"); unset($_REQUEST["page"]); unset($_REQUEST["rows"]); unset($_REQUEST["filter"]); unset($_REQUEST["sort_column"]); unset($_REQUEST["sort_direction"]); $_REQUEST["page"] = 1; } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value("filter", "sess_plugins_filter", ""); load_current_session_value("rows", "sess_plugins_rows", "-1"); load_current_session_value("sort_column", "sess_plugins_sort_column", "name"); load_current_session_value("sort_direction", "sess_plugins_sort_direction", "ASC"); load_current_session_value("page", "sess_plugins_current_page", "1"); $table = plugins_load_temp_table(); ?> <script type="text/javascript"> <!-- function applyFilterChange(objForm) { strURL = '?rows=' + objForm.rows.value; strURL = strURL + '&filter=' + objForm.filter.value; document.location = strURL; } --> </script> <?php html_start_box("<strong>Plugin Management</strong> (Cacti Version: " . $config["cacti_version"] . (isset($plugin_architecture['version']) ? ", Plugin Architecture Version: " . $plugin_architecture['version'] : "") . ")", "100%", "", "3", "center", ""); ?> <tr class='even noprint'> <td class="noprint"> <form name="form_plugins" method="get" action="plugins.php"> <table cellpadding="0" cellspacing="0"> <tr class="noprint"> <td nowrap style='white-space: nowrap;' width="50"> Search: </td> <td width="1"> <input type="text" name="filter" size="40" value="<?php print get_request_var_request("filter"); ?> "> </td> <td nowrap style='white-space: nowrap;' width="50"> Rows: </td> <td width="1"> <select name="rows" onChange="applyFilterChange(document.form_plugins)"> <option value="-1"<?php if (get_request_var_request("rows") == "-1") { ?> selected<?php } ?> >Default</option> <?php if (sizeof($item_rows) > 0) { foreach ($item_rows as $key => $value) { print "<option value='" . $key . "'"; if (get_request_var_request("rows") == $key) { print " selected"; } print ">" . htmlspecialchars($value) . "</option>\n"; } } ?> </select> </td> <td nowrap style='white-space: nowrap;'> <input type="submit" value="Go" title="Set/Refresh Filters"> </td> <td nowrap style='white-space: nowrap;'> <input type="submit" name="clear_x" value="Clear" title="Clear Filters"> </td> </tr> </table> <input type='hidden' name='page' value='1'> </form> </td> </tr> <?php html_end_box(); /* print checkbox form for validation */ print "<form name='chk' method='post' action='plugins.php'>\n"; html_start_box("", "100%", "", "3", "center", ""); /* form the 'where' clause for our main sql query */ $sql_where = "WHERE ({$table}.name LIKE '%%" . get_request_var_request("filter") . "%%')"; if (get_request_var_request("sort_column") == "version") { $sortc = "version+0"; } else { $sortc = get_request_var_request("sort_column"); } if (get_request_var_request("sort_column") == "id") { $sortd = "ASC"; } else { $sortd = get_request_var_request("sort_direction"); } if ($_REQUEST['rows'] == '-1') { $rows = read_config_option('num_rows_device'); } else { $rows = get_request_var_request('rows'); } $total_rows = db_fetch_cell("SELECT\n\t\tcount(*)\n\t\tFROM {$table}\n\t\t{$sql_where}"); $plugins = db_fetch_assoc("SELECT *\n\t\tFROM {$table}\n\t\t{$sql_where}\n\t\tORDER BY " . $sortc . " " . $sortd . "\n\t\tLIMIT " . $rows * (get_request_var_request("page") - 1) . "," . $rows); db_execute("DROP TABLE {$table}"); $nav = html_nav_bar("plugins.php?filter=" . get_request_var_request("filter"), MAX_DISPLAY_PAGES, get_request_var_request("page"), $rows, $total_rows, 8); print $nav; $display_text = array("nosort" => array("Actions", ""), "directory" => array("Name", "ASC"), "version" => array("Version", "ASC"), "id" => array("Load Order", "ASC"), "name" => array("Description", "ASC"), "nosort1" => array("Type", "ASC"), "status" => array("Status", "ASC"), "author" => array("Author", "ASC")); html_header_sort($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"), 1); $i = 0; if (sizeof($plugins)) { if (get_request_var_request("sort_column") == "id") { $inst_system_plugins = get_system_plugins($plugins); if (sizeof($inst_system_plugins)) { foreach ($inst_system_plugins as $plugin) { form_alternate_row('', true); print format_plugin_row($plugin, false, false, true); } } } $j = 0; foreach ($plugins as $plugin) { if (isset($plugins[$j + 1]) && $plugins[$j + 1]['status'] < 0 || !isset($plugins[$j + 1])) { $last_plugin = true; } else { $last_plugin = false; } if ($plugin['status'] <= 0 || is_system_plugin($plugin) || get_request_var_request('sort_column') != 'id') { $load_ordering = false; } else { $load_ordering = true; } if (get_request_var_request("sort_column") == "id") { if (!is_system_plugin($plugin)) { form_alternate_row('', true); print format_plugin_row($plugin, $last_plugin, $load_ordering, false); $i++; } } else { form_alternate_row('', true); print format_plugin_row($plugin, $last_plugin, $load_ordering, is_system_plugin($plugin)); $i++; } $j++; } print $nav; } else { print "<tr><td><em>No Plugins Found</em></td></tr>"; } html_end_box(false); html_start_box("", "100%", "", "3", "center", ""); echo "<tr><td colspan=10><strong>NOTE:</strong> Please sort by 'Load Order' to change plugin load ordering.<br><strong>NOTE:</strong> SYSTEM plugins can not be ordered.</td></tr>"; html_end_box(); print "</form>\n"; }
function mactrack_vmacs() { global $site_actions, $config, $item_rows; mactrack_vmacs_validate_request_vars(); if (get_request_var('rows') == -1) { $row_limit = read_config_option('num_rows_table'); } elseif (get_request_var('rows') == -2) { $row_limit = 999999; } else { $row_limit = get_request_var('rows'); } html_start_box(__('MacTrack Vendor Mac Filter'), '100%', '', '3', 'center', ''); mactrack_vmac_filter(); html_end_box(); $sql_where = ''; $vmacs = mactrack_vmacs_get_vmac_records($sql_where, $row_limit); $total_rows = db_fetch_cell("SELECT\n\t\tCOUNT(*)\n\t\tFROM mac_track_oui_database\n\t\t{$sql_where}"); $nav = html_nav_bar('mactrack_vendormacs.php', MAX_DISPLAY_PAGES, get_request_var('page'), $row_limit, $total_rows, 9, __('Vendor Macs')); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array('vendor_mac' => array(__('Vendor MAC'), 'ASC'), 'vendor_name' => array(__('Corporation'), 'ASC'), 'vendor_address' => array(__('Address'), 'ASC')); html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction')); if (sizeof($vmacs)) { foreach ($vmacs as $vmac) { form_alternate_row(); ?> <td class='linkEditMain'><?php print $vmac['vendor_mac']; ?> </td> <td><?php print get_request_var('filter') != '' ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", $vmac['vendor_name']) : $vmac['vendor_name']; ?> </td> <td><?php print get_request_var('filter') != '' ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", $vmac['vendor_address']) : $vmac['vendor_address']; ?> </td> </tr> <?php } } else { print '<tr><td><em>' . __('No MacTrack Vendor MACS') . '</em></td></tr>'; } html_end_box(false); if (sizeof($vmacs)) { print $nav; } }
function hmib_summary() { global $device_actions, $item_rows, $config; /* ================= input validation ================= */ get_filter_request_var('htop'); get_filter_request_var('ptop'); /* ==================================================== */ /* clean up sort string */ if (isset_request_var('sort_column')) { set_request_var('sort_column', sanitize_search_string(get_nfilter_request_var('sort_column'))); } /* clean up sort string */ if (isset_request_var('sort_direction')) { set_request_var('sort_direction', sanitize_search_string(get_nfilter_request_var('sort_direction'))); } /* clean up search string */ if (isset_request_var('filter')) { set_request_var('filter', sanitize_search_string(get_nfilter_request_var('filter'))); } /* remember these search fields in session vars so we don't have * to keep passing them around */ if (isset_request_var('area') && get_nfilter_request_var('area') == 'processes') { if (isset_request_var('clear')) { kill_session_var('sess_hmib_proc_top'); kill_session_var('sess_hmib_proc_filter'); kill_session_var('sess_hmib_proc_sort_column'); kill_session_var('sess_hmib_proc_sort_direction'); unset_request_var('filter'); unset_request_var('ptop'); unset_request_var('sort_column'); unset_request_var('sort_direction'); } if (isset_request_var('sort_column')) { $_SESSION['sess_hmib_proc_sort_column'] = get_request_var('sort_column'); $_SESSION['sess_hmib_proc_sort_direction'] = get_request_var('sort_direction'); } elseif (!isset($_SESSION['sess_hmib_proc_sort_column'])) { $_SESSION['sess_hmib_proc_sort_column'] = 'maxCpu'; $_SESSION['sess_hmib_proc_sort_direction'] = 'DESC'; } if (!isset($_SESSION['sess_hmib_host_sort_column'])) { $_SESSION['sess_hmib_host_sort_column'] = 'downHosts'; $_SESSION['sess_hmib_host_sort_direction'] = 'DESC'; } } elseif (isset_request_var('area') && get_nfilter_request_var('area') == 'hosts') { if (isset_request_var('clear')) { kill_session_var('sess_hmib_host_top'); kill_session_var('sess_hmib_host_sort_column'); kill_session_var('sess_hmib_host_sort_direction'); unset_request_var('htop'); unset_request_var('sort_column'); unset_request_var('sort_direction'); } if (isset_request_var('sort_column')) { $_SESSION['sess_hmib_host_sort_column'] = get_request_var('sort_column'); $_SESSION['sess_hmib_host_sort_direction'] = get_request_var('sort_direction'); } elseif (!isset($_SESSION['sess_hmib_host_sort_column'])) { $_SESSION['sess_hmib_host_sort_column'] = 'downHosts'; $_SESSION['sess_hmib_host_sort_direction'] = 'DESC'; } if (!isset($_SESSION['sess_hmib_proc_sort_column'])) { $_SESSION['sess_hmib_proc_sort_column'] = 'maxCpu'; $_SESSION['sess_hmib_proc_sort_direction'] = 'DESC'; } } else { if (!isset($_SESSION['sess_hmib_host_sort_column'])) { $_SESSION['sess_hmib_host_sort_column'] = 'downHosts'; $_SESSION['sess_hmib_host_sort_direction'] = 'DESC'; } if (!isset($_SESSION['sess_hmib_proc_sort_column'])) { $_SESSION['sess_hmib_proc_sort_column'] = 'maxCpu'; $_SESSION['sess_hmib_proc_sort_direction'] = 'DESC'; } } load_current_session_value('ptop', 'sess_hmib_proc_top', read_config_option('hmib_top_processes')); load_current_session_value('htop', 'sess_hmib_host_top', read_config_option('hmib_top_types')); load_current_session_value('filter', 'sess_hmib_proc_filter', ''); /* set some defaults */ $url = $config['url_path'] . 'plugins/hmib/hmib.php'; $proc = $config['url_path'] . 'plugins/hmib/images/cog.png'; $host = $config['url_path'] . 'plugins/hmib/images/server.png'; $hardw = $config['url_path'] . 'plugins/hmib/images/view_hardware.gif'; $inven = $config['url_path'] . 'plugins/hmib/images/view_inventory.gif'; $storage = $config['url_path'] . 'plugins/hmib/images/drive.png'; $htdq = db_fetch_cell("SELECT id \n\t\tFROM snmp_query\n\t\tWHERE hash='137aeab842986a76cf5bdef41b96c9a3'"); $hcpudq = db_fetch_cell("SELECT id \n\t\tFROM snmp_query\n\t\tWHERE hash='0d1ab53fe37487a5d0b9e1d3ee8c1d0d'"); $hugt = db_fetch_cell("SELECT id \n\t\tFROM graph_templates \n\t\tWHERE hash='e8462bbe094e4e9e814d4e681671ea82'"); $hpgt = db_fetch_cell("SELECT id \n\t\tFROM graph_templates \n\t\tWHERE hash='62205afbd4066e5c4700338841e3901e'"); $htsd = db_fetch_cell("SELECT id\n\t\tFROM host_template\n\t\tWHERE hash='7c13344910097cc599f0d0485305361d'"); if ($htdq == 0 || $hcpudq == 0 || $hugt == 0 || $hpgt == 0 || $htsd == 0) { $templates_missing = true; } else { $templates_missing = false; } ?> <script type='text/javascript'> function applyFilter(objForm) { strURL = '?action=summary&area=hosts&header=false'; strURL += '&htop=' + $('#htop').val(); loadPageNoHeader(strURL); } function clearFilter() { strURL = '?area=hosts&clear=true&header=false'; loadPageNoHeader(strURL); } </script> <?php html_start_box(__('Summary Filter'), '100%', '', '3', 'center', ''); ?> <tr class='even'> <td> <form name='host_summary'> <table class='filterTable'> <tr> <td> <?php print __('Top'); ?> </td> <td> <select id='htop' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var('htop') == '-1') { ?> selected<?php } ?> ><?php print __('All Records'); ?> </option> <option value='5'<?php if (get_request_var('htop') == '5') { ?> selected<?php } ?> ><?php print __('%d Records', 5); ?> </option> <option value='10'<?php if (get_request_var('htop') == '10') { ?> selected<?php } ?> ><?php print __('%d Record', 10); ?> s</option> <option value='15'<?php if (get_request_var('htop') == '15') { ?> selected<?php } ?> ><?php print __('%d Record', 15); ?> s</option> <option value='20'<?php if (get_request_var('htop') == '20') { ?> selected<?php } ?> ><?php print __('%d Record', 20); ?> s</option> </select> </td> <td> <input type='button' onClick='applyFilter()' value='<?php print __('Go'); ?> '> </td> <td> <input type='button' onClick='clearFilter()' value='<?php print __('Clear'); ?> ' name='clear'> </td> <td> <?php print $templates_missing ? '<strong>' . __('WARNING: You need to import your Host MIB Host Template to view Graphs. See the README for more information.') . '</strong>' : ''; ?> </td> </tr> </table> </form> </td> </tr> <?php html_end_box(false); html_start_box(__('Device Type Summary Statistics'), '100%', '', '3', 'center', ''); if (!isset($_SESSION['sess_hmib_host_top'])) { $limit = 'LIMIT ' . read_config_option('hmib_top_types'); } elseif ($_SESSION['sess_hmib_host_top'] == '-1') { $limit = ''; } else { $limit = 'LIMIT ' . $_SESSION['sess_hmib_host_top']; } $sql = 'SELECT hrst.id AS id, hrst.name AS name, hrst.version AS version, hrs.host_type AS host_type, SUM(CASE WHEN host_status=3 THEN 1 ELSE 0 END) AS upHosts, SUM(CASE WHEN host_status=2 THEN 1 ELSE 0 END) AS recHosts, SUM(CASE WHEN host_status=1 THEN 1 ELSE 0 END) AS downHosts, SUM(CASE WHEN host_status=0 THEN 1 ELSE 0 END) AS disabledHosts, SUM(users) AS users, SUM(numCpus) AS cpus, AVG(memUsed) AS avgMem, MAX(memUsed) AS maxMem, AVG(swapUsed) AS avgSwap, MAX(swapUsed) AS maxSwap, AVG(cpuPercent) AS avgCpuPercent, MAX(cpuPercent) AS maxCpuPercent, AVG(processes) AS avgProcesses, MAX(processes) AS maxProcesses FROM plugin_hmib_hrSystem AS hrs LEFT JOIN plugin_hmib_hrSystemTypes AS hrst ON hrs.host_type=hrst.id GROUP BY name, version ORDER BY ' . $_SESSION['sess_hmib_host_sort_column'] . ' ' . $_SESSION['sess_hmib_host_sort_direction'] . ' ' . $limit; $rows = db_fetch_assoc($sql); $display_text = array('nosort' => array('display' => __('Actions'), 'sort' => 'ASC', 'align' => 'left'), 'name' => array('display' => __('Type'), 'sort' => 'ASC', 'align' => 'left'), '(version/1)' => array('display' => __('Version'), 'sort' => 'ASC', 'align' => 'right'), 'upHosts' => array('display' => __('Up'), 'sort' => 'DESC', 'align' => 'right'), 'recHosts' => array('display' => __('Recovering'), 'sort' => 'DESC', 'align' => 'right'), 'downHosts' => array('display' => __('Down'), 'sort' => 'DESC', 'align' => 'right'), 'disabledHosts' => array('display' => __('Disabled'), 'sort' => 'DESC', 'align' => 'right'), 'users' => array('display' => __('Logins'), 'sort' => 'DESC', 'align' => 'right'), 'cpus' => array('display' => __('CPUS'), 'sort' => 'DESC', 'align' => 'right'), 'avgCpuPercent' => array('display' => __('Avg CPU'), 'sort' => 'DESC', 'align' => 'right'), 'maxCpuPercent' => array('display' => __('Max CPU'), 'sort' => 'DESC', 'align' => 'right'), 'avgMem' => array('display' => __('Avg Mem'), 'sort' => 'DESC', 'align' => 'right'), 'maxMem' => array('display' => __('Max Mem'), 'sort' => 'DESC', 'align' => 'right'), 'avgSwap' => array('display' => __('Avg Swap'), 'sort' => 'DESC', 'align' => 'right'), 'maxSwap' => array('display' => __('Max Swap'), 'sort' => 'DESC', 'align' => 'right'), 'avgProcesses' => array('display' => __('Avg Proc'), 'sort' => 'DESC', 'align' => 'right'), 'maxProcesses' => array('display' => __('Max Proc'), 'sort' => 'DESC', 'align' => 'right')); html_header_sort($display_text, $_SESSION['sess_hmib_host_sort_column'], $_SESSION['sess_hmib_host_sort_direction'], false, 'hmib.php?action=summary&area=hosts'); if (sizeof($rows)) { foreach ($rows as $row) { if (!$templates_missing) { $host_id = db_fetch_cell("SELECT id FROM host WHERE host_template_id={$htsd}"); $graph_url = hmib_get_graph_url($htdq, 0, $host_id, $row['id']); $graph_ncpu = hmib_get_graph_url($hcpudq, $row['id'], 0, '', $row['cpus'], false); $graph_acpu = hmib_get_graph_url($hcpudq, $row['id'], 0, '', round($row['avgCpuPercent'], 2), false); $graph_mcpu = hmib_get_graph_url($hcpudq, $row['id'], 0, '', round($row['maxCpuPercent'], 2), false); $graph_users = hmib_get_graph_template_url($hugt, $row['id'], 0, $row['users'], false); $graph_aproc = hmib_get_graph_template_url($hpgt, $row['id'], 0, number_format_i18n($row['avgProcesses'], 0), false); $graph_mproc = hmib_get_graph_template_url($hpgt, $row['id'], 0, number_format_i18n($row['maxProcesses'], 0), false); } else { $graph_url = ''; $graph_ncpu = ''; $graph_acpu = ''; $graph_mcpu = ''; $graph_users = ''; $graph_aproc = ''; $graph_mproc = ''; } form_alternate_row(); echo "<td style='white-space:nowrap;' width='120'>"; echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=devices&type=" . $row['id']) . "'><img src='{$host}' title='" . __('View Devices') . "' align='absmiddle' alt=''></a>"; echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=storage&ostype=" . $row['id']) . "'><img src='{$storage}' title='" . __('View Storage') . "' align='absmiddle' alt=''></a>"; echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=hardware&ostype=" . $row['id']) . "'><img src='{$hardw}' title='" . __('View Hardware') . "' align='absmiddle' alt=''></a>"; echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=running&type=" . $row['id']) . "'><img src='{$proc}' title='" . __('View Processes') . "' align='absmiddle' alt=''></a>"; echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=software&ostype=" . $row['id']) . "'><img src='{$inven}' title='" . __('View Software Inventory') . "' align='absmiddle' alt=''></a>"; echo $graph_url; echo '</td>'; $upHosts = hmib_get_device_status_url($row['upHosts'], $row['host_type'], 3); $recHosts = hmib_get_device_status_url($row['recHosts'], $row['host_type'], 2); $downHosts = hmib_get_device_status_url($row['downHosts'], $row['host_type'], 1); $disaHosts = hmib_get_device_status_url($row['disabledHosts'], $row['host_type'], 0); echo "<td class='nowrap left'>" . ($row['name'] != '' ? $row['name'] : 'Unknown') . '</td>'; echo "<td class='nowrap right'>" . $row['version'] . '</td>'; echo "<td class='nowrap right'>" . $upHosts . '</td>'; echo "<td class='nowrap right'>" . $recHosts . '</td>'; echo "<td class='nowrap right'>" . $downHosts . '</td>'; echo "<td class='nowrap right'>" . $disaHosts . '</td>'; echo "<td class='nowrap right'>" . $graph_users . '</td>'; echo "<td class='nowrap right'>" . $graph_ncpu . '</td>'; echo "<td class='nowrap right'>" . $graph_acpu . ' %</td>'; echo "<td class='nowrap right'>" . $graph_mcpu . ' %</td>'; echo "<td class='nowrap right'>" . round($row['avgMem'], 2) . ' %</td>'; echo "<td class='nowrap right'>" . round($row['maxMem'], 2) . ' %</td>'; echo "<td class='nowrap right'>" . round($row['avgSwap'], 2) . ' %</td>'; echo "<td class='nowrap right'>" . round($row['maxSwap'], 2) . ' %</td>'; echo "<td class='nowrap right'>" . $graph_aproc . '</td>'; echo "<td class='nowrap right'>" . $graph_mproc . '</td>'; } echo '</tr>'; } else { print '<tr><td colspan="8"><em>' . __('No Device Types') . '</em></td></tr>'; } html_end_box(); html_start_box(__('Process Summary Filter'), '100%', '', '3', 'center', ''); ?> <script type='text/javascript'> function applyProcFilter(objForm) { strURL = '?action=summary&area=processes'; strURL += '&filter=' + $('#filter').val(); strURL += '&ptop=' + $('#ptop').val(); strURL += '&header=false'; loadPageNoHeader(strURL); } function clearProc() { strURL = '?action=summary&area=processes&clear=true&header=false'; loadPageNoHeader(strURL); } $(function() { $('#proc_summary').submit(function(event) { event.preventDefault(); applyProcFilter(); }); }); </script> <?php ?> <tr class='even'> <td> <form id='proc_summary'> <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 __('Top'); ?> </td> <td> <select id='ptop' onChange='applyProcFilter()'> <option value='-1'<?php if (get_request_var('ptop') == '-1') { ?> selected<?php } ?> ><?php print __('All Records'); ?> </option> <option value='5'<?php if (get_request_var('ptop') == '5') { ?> selected<?php } ?> ><?php print __('%d Records', 5); ?> </option> <option value='10'<?php if (get_request_var('ptop') == '10') { ?> selected<?php } ?> ><?php print __('%d Records', 10); ?> </option> <option value='15'<?php if (get_request_var('ptop') == '15') { ?> selected<?php } ?> ><?php print __('%d Records', 15); ?> </option> <option value='20'<?php if (get_request_var('ptop') == '20') { ?> selected<?php } ?> ><?php print __('%d Records', 20); ?> </option> </select> </td> <td> <input type='button' onClick='applyProcFilter(document.proc_summary)' value='<?php print __('Go'); ?> '> </td> <td> <input type='button' onClick='clearProc()' value='<?php print __('Clear'); ?> '> </td> <td> <?php print $templates_missing ? '<strong>' . __('WARNING: You need to import your Host MIB Host Template to view Graphs. See the README for more information.') . '</strong>' : ''; ?> </td> </tr> </table> </form> </td> </tr> <?php html_end_box(false); html_start_box(__('Process Summary Statistics'), '100%', '', '3', 'center', ''); if (!isset($_SESSION['sess_hmib_proc_top'])) { $limit = 'LIMIT ' . read_config_option('hmib_top_processes'); } elseif ($_SESSION['sess_hmib_proc_top'] == '-1') { $limit = ''; } else { $limit = 'LIMIT ' . $_SESSION['sess_hmib_proc_top']; } if (strlen(get_request_var('filter'))) { $sql_where = "AND (hrswr.name LIKE '%" . get_request_var('filter') . "%' OR\n\t\t\thrswr.path LIKE '%" . get_request_var('filter') . "%' OR\n\t\t\thrswr.parameters LIKE '%" . get_request_var('filter') . "%')"; } else { $sql_where = ''; } $sql = "SELECT\n\t\thrswr.name AS name,\n\t\tCOUNT(DISTINCT hrswr.path) AS paths,\n\t\tCOUNT(DISTINCT hrswr.host_id) AS numHosts,\n\t\tCOUNT(hrswr.host_id) AS numProcesses,\n\t\tAVG(hrswr.perfCPU) AS avgCpu,\n\t\tMAX(hrswr.perfCPU) AS maxCpu,\n\t\tAVG(hrswr.perfMemory) AS avgMemory,\n\t\tMAX(hrswr.perfMemory) AS maxMemory\n\t\tFROM plugin_hmib_hrSWRun AS hrswr\n\t\tWHERE hrswr.name!='System Idle Process' AND hrswr.name!=''\n\t\t{$sql_where}\n\t\tGROUP BY hrswr.name\n\t\tORDER BY " . $_SESSION['sess_hmib_proc_sort_column'] . ' ' . $_SESSION['sess_hmib_proc_sort_direction'] . ' ' . $limit; $rows = db_fetch_assoc($sql); //echo $sql; $display_text = array('nosort' => array('display' => __('Actions'), 'sort' => 'ASC', 'align' => 'left'), 'name' => array('display' => __('Process Name'), 'sort' => 'ASC', 'align' => 'left'), 'paths' => array('display' => __('Num Paths'), 'sort' => 'DESC', 'align' => 'right'), 'numHosts' => array('display' => __('Hosts'), 'sort' => 'DESC', 'align' => 'right'), 'numProcesses' => array('display' => __('Processes'), 'sort' => 'DESC', 'align' => 'right'), 'avgCpu' => array('display' => __('Avg CPU'), 'sort' => 'DESC', 'align' => 'right'), 'maxCpu' => array('display' => __('Max CPU'), 'sort' => 'DESC', 'align' => 'right'), 'avgMemory' => array('display' => __('Avg Memory'), 'sort' => 'DESC', 'align' => 'right'), 'maxMemory' => array('display' => __('Max Memory'), 'sort' => 'DESC', 'align' => 'right')); html_header_sort($display_text, $_SESSION['sess_hmib_proc_sort_column'], $_SESSION['sess_hmib_proc_sort_direction'], false, 'hmib.php?action=summary&area=processes'); /* set some defaults */ $url = $config['url_path'] . 'plugins/hmib/hmib.php'; $proc = $config['url_path'] . 'plugins/hmib/images/cog.png'; $host = $config['url_path'] . 'plugins/hmib/images/server.png'; /* get the data query for the application use */ $adq = db_fetch_cell("SELECT id\n\t\tFROM snmp_query\n\t\tWHERE hash='6b0ef0fe7f1d85bbb6812801ca15a7c5'"); if (sizeof($rows)) { foreach ($rows as $row) { $graph_url = hmib_get_graph_url($adq, 0, 0, $row['name']); form_alternate_row(); echo "<td width='70'>"; echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=devices&process=" . $row['name']) . "'><img src='{$host}' title='" . __('View Devices') . "' align='absmiddle' alt=''></a>"; echo "<a style='padding:1px;' href='" . htmlspecialchars("{$url}?reset=1&action=running&process=" . $row['name']) . "'><img src='{$proc}' title='" . __('View Processes') . "' align='absmiddle' alt=''></a>"; echo $graph_url; echo '</td>'; echo "<td class='left' width='140'>" . $row['name'] . '</td>'; echo "<td class='right'>" . $row['paths'] . '</td>'; echo "<td class='right'>" . $row['numHosts'] . '</td>'; echo "<td class='right'>" . $row['numProcesses'] . '</td>'; echo "<td class='right'>" . number_format_i18n($row['avgCpu'] / 3600, 0) . ' Hrs</td>'; echo "<td class='right'>" . number_format_i18n($row['maxCpu'] / 3600, 0) . ' Hrs</td>'; echo "<td class='right'>" . number_format_i18n($row['avgMemory'] / 1024, 2) . ' MB</td>'; echo "<td class='right'>" . number_format_i18n($row['maxMemory'] / 1024, 2) . ' MB</td>'; } echo '</tr>'; } else { print '<tr><td><em>' . __('No Processes') . '</em></td></tr>'; } html_end_box(); }
function update_show_current() { global $plugins, $pluginslist, $config, $status_names, $actions, $item_rows; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('page')); input_validate_input_number(get_request_var_request('rows')); input_validate_input_number(get_request_var_request('state')); /* ==================================================== */ /* clean up search string */ if (isset($_REQUEST['filter'])) { $_REQUEST['filter'] = sanitize_search_string(get_request_var_request('filter')); } /* clean up sort_column */ if (isset($_REQUEST['sort_column'])) { $_REQUEST['sort_column'] = sanitize_search_string(get_request_var_request('sort_column')); } /* clean up search string */ if (isset($_REQUEST['sort_direction'])) { $_REQUEST['sort_direction'] = sanitize_search_string(get_request_var_request('sort_direction')); } /* if the user pushed the 'clear' button */ if (isset($_REQUEST['clear_x'])) { kill_session_var('sess_plugins_filter'); kill_session_var('sess_default_rows'); kill_session_var('sess_plugins_state'); kill_session_var('sess_plugins_sort_column'); kill_session_var('sess_plugins_sort_direction'); unset($_REQUEST['page']); unset($_REQUEST['rows']); unset($_REQUEST['state']); unset($_REQUEST['filter']); unset($_REQUEST['sort_column']); unset($_REQUEST['sort_direction']); $_REQUEST['page'] = 1; } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value('filter', 'sess_plugins_filter', ''); load_current_session_value('rows', 'sess_default_rows', read_config_option('num_rows_table')); load_current_session_value('state', 'sess_plugins_state', '5'); load_current_session_value('sort_column', 'sess_plugins_sort_column', 'name'); load_current_session_value('sort_direction', 'sess_plugins_sort_direction', 'ASC'); load_current_session_value('page', 'sess_plugins_current_page', '1'); $table = plugins_load_temp_table(); ?> <script type="text/javascript"> function applyFilter() { strURL = 'plugins.php?filter='+$('#filter').val()+'&rows='+$('#rows').val()+'&page='+$('#page').val()+'&state='+$('#state').val()+'&header=false'; $.get(strURL, function(data) { $('#main').html(data); applySkin(); }); } function clearFilter() { strURL = 'plugins.php?clear_x=1&header=false'; $.get(strURL, function(data) { $('#main').html(data); applySkin(); }); } $(function() { $('#refresh').click(function() { applyFilter(); }); $('#clear').click(function() { clearFilter(); }); $('#form_plugins').submit(function(event) { event.preventDefault(); applyFilter(); }); }); </script> <?php html_start_box('<strong>Plugin Management</strong> (Cacti Version: ' . $config['cacti_version'] . ')', '100%', '', '3', 'center', ''); ?> <tr class='even noprint'> <td class="noprint"> <form id="form_plugins" method="get" action="plugins.php"> <table cellpadding="2" cellspacing="0"> <tr class="noprint"> <td width="50"> Search </td> <td> <input id='filter' type="text" name="filter" size="25" value="<?php print get_request_var_request('filter'); ?> "> </td> <td> Status </td> <td> <select id='state' name="state" onChange="applyFilter()"> <option value="-3"<?php if (get_request_var_request('state') == '-3') { ?> selected<?php } ?> >All</option> <option value="1"<?php if (get_request_var_request('state') == '1') { ?> selected<?php } ?> >Active</option> <option value="4"<?php if (get_request_var_request('state') == '4') { ?> selected<?php } ?> >Installed</option> <option value="5"<?php if (get_request_var_request('state') == '5') { ?> selected<?php } ?> >Active/Installed</option> <option value="0"<?php if (get_request_var_request('state') == '0') { ?> selected<?php } ?> >Not Installed</option> <option value="-1"<?php if (get_request_var_request('state') == '-1') { ?> selected<?php } ?> >Legacy Installed</option> <option value="-2"<?php if (get_request_var_request('state') == '-2') { ?> selected<?php } ?> >Legacy Not Intalled</option> </select> </td> <td> Plugins </td> <td> <select id='rows' name="rows" onChange="applyFilter()"> <?php if (sizeof($item_rows) > 0) { foreach ($item_rows as $key => $value) { print "<option value='" . $key . "'"; if (get_request_var_request('rows') == $key) { print ' selected'; } print '>' . htmlspecialchars($value) . "</option>\n"; } } ?> </select> </td> <td> <input type="button" id='refresh' value="Go" title="Set/Refresh Filters"> </td> <td> <input type="button" id='clear' name="clear_x" value="Clear" title="Clear Filters"> </td> </tr> </table> <input type='hidden' id='page' name='page' value='<?php print $_REQUEST['page']; ?> '> </form> </td> </tr> <?php html_end_box(); /* print checkbox form for validation */ print "<form name='chk' method='post' action='plugins.php'>\n"; html_start_box('', '100%', '', '3', 'center', ''); $sql_where = ''; /* form the 'where' clause for our main sql query */ if (strlen($_REQUEST['filter'])) { $sql_where = "WHERE ({$table}.name LIKE '%%" . get_request_var_request('filter') . "%%')"; } if ($_REQUEST['state'] > -3) { if ($_REQUEST['state'] == 5) { $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' status IN(1,4)'; } else { $sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . ' status=' . $_REQUEST['state']; } } if (get_request_var_request('sort_column') == 'version') { $sortc = 'version+0'; } else { $sortc = get_request_var_request('sort_column'); } if (get_request_var_request('sort_column') == 'id') { $sortd = 'ASC'; } else { $sortd = get_request_var_request('sort_direction'); } if ($_REQUEST['rows'] == '-1') { $rows = read_config_option('num_rows_table'); } else { $rows = get_request_var_request('rows'); } $total_rows = db_fetch_cell("SELECT\n\t\tcount(*)\n\t\tFROM {$table}\n\t\t{$sql_where}"); $plugins = db_fetch_assoc("SELECT *\n\t\tFROM {$table}\n\t\t{$sql_where}\n\t\tORDER BY " . $sortc . ' ' . $sortd . ' LIMIT ' . $rows * (get_request_var_request('page') - 1) . ',' . $rows); db_execute("DROP TABLE {$table}"); $nav = html_nav_bar('plugins.php?filter=' . get_request_var_request('filter'), MAX_DISPLAY_PAGES, get_request_var_request('page'), $rows, $total_rows, 8, 'Plugins', 'page', 'main'); print $nav; $display_text = array('nosort' => array('display' => 'Actions', 'align' => 'left', 'sort' => '', 'tip' => 'Actions available include "Install", "Activate", "Disable", "Enable", "Uninstall".'), 'directory' => array('display' => 'Plugin Name', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'The name for this Plugin. The name is controlled by the direcotry it resides in.'), 'id' => array('display' => 'Load Order', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'The load order of the Plugin. You can change the load order by first sorting by it, then moving a Plugin either up or down.'), 'name' => array('display' => 'Plugin Description', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'A description that the Plugins author has given to the Plugin.'), 'version' => array('display' => 'Version', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'The version of this Plugin.'), 'status' => array('display' => 'Status', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'The status of this Plugin.'), 'author' => array('display' => 'Author', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'The author of this Plugin.')); html_header_sort($display_text, get_request_var_request('sort_column'), get_request_var_request('sort_direction'), 1); $i = 0; if (sizeof($plugins)) { $j = 0; foreach ($plugins as $plugin) { if (isset($plugins[$j + 1]) && $plugins[$j + 1]['status'] < 0 || !isset($plugins[$j + 1])) { $last_plugin = true; } else { $last_plugin = false; } if ($plugin['status'] <= 0 || get_request_var_request('sort_column') != 'id') { $load_ordering = false; } else { $load_ordering = true; } form_alternate_row('', true); print format_plugin_row($plugin, $last_plugin, $load_ordering); $i++; $j++; } print $nav; } else { print '<tr><td><em>No Plugins Found</em></td></tr>'; } html_end_box(false); print "</form>\n"; }
function mactrack_view_ip_ranges() { global $title, $colors, $config, $item_rows; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request("site_id")); input_validate_input_number(get_request_var_request("page")); /* ==================================================== */ /* clean up sort_column */ if (isset($_REQUEST["sort_column"])) { $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); } /* clean up search string */ if (isset($_REQUEST["sort_direction"])) { $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); } if (isset($_REQUEST["reset"])) { kill_session_var("sess_mactrack_view_ips_rows_selector"); kill_session_var("sess_mactrack_view_ips_current_page"); kill_session_var("sess_mactrack_view_ips_sort_column"); kill_session_var("sess_mactrack_view_ips_sort_row"); $_REQUEST["page"] = 1; } /* if any of the settings changed, reset the page number */ /* if the user pushed the 'clear' button */ if (isset($_REQUEST["clear_x"]) || isset($_REQUEST["reset"])) { kill_session_var("sess_mactrack_view_ips_rows_selector"); kill_session_var("sess_mactrack_view_ips_current_page"); kill_session_var("sess_mactrack_view_ips_sort_column"); kill_session_var("sess_mactrack_view_ips_sort_row"); $_REQUEST["page"] = 1; if (isset($_REQUEST["clear_x"])) { unset($_REQUEST["rows"]); unset($_REQUEST["sort_column"]); unset($_REQUEST["sort_direction"]); } }else{ $changed = 0; $changed += mactrack_check_changed("site_id", "sess_mactrack_view_ips_site_id"); $changed += mactrack_check_changed("rows", "sess_mactrack_view_ips_rows"); if ($changed) { $_REQUEST["page"] = "1"; } } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value("page", "sess_mactrack_view_ips_current_page", "1"); load_current_session_value("site_id", "sess_mactrack_view_ips_site_id", "-1"); load_current_session_value("rows", "sess_mactrack_view_ips_rows", "-1"); load_current_session_value("sort_column", "sess_mactrack_view_ips_sort_column", "site_name"); load_current_session_value("sort_direction", "sess_mactrack_view_ips_sort_direction", "ASC"); if ($_REQUEST["rows"] == -1) { $row_limit = read_config_option("num_rows_mactrack"); }elseif ($_REQUEST["rows"] == -2) { $row_limit = 999999; }else{ $row_limit = $_REQUEST["rows"]; } if (defined("URL_PATH")) { $webroot = URL_PATH; }else{ $webroot = $config["url_path"]; } mactrack_tabs(); mactrack_view_header(); mactrack_ips_filter(); mactrack_view_footer(); html_start_box("", "100%", $colors["header"], "3", "center", ""); $sql_where = ""; $ip_ranges = mactrack_view_get_ip_range_records($sql_where, $row_limit); $total_rows = db_fetch_cell("SELECT COUNT(mac_track_ip_ranges.ip_range) FROM mac_track_ip_ranges INNER JOIN mac_track_sites ON (mac_track_ip_ranges.site_id=mac_track_sites.site_id) $sql_where"); /* generate page list */ $url_page_select = str_replace("&page", "?page", get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, "mactrack_view_ips.php")); if (isset($config["base_path"])) { if ($total_rows > 0) { $nav = "<tr bgcolor='#" . $colors["header"] . "'> <td colspan='13'> <table width='100%' cellspacing='0' cellpadding='0' border='0'> <tr> <td align='left' class='textHeaderDark'> <strong><< "; if ($_REQUEST["page"] > 1) { $nav .= "<a class='linkOverDark' href='mactrack_view_ips.php?page=" . ($_REQUEST["page"]-1) . "'>"; } $nav .= "Previous"; if ($_REQUEST["page"] > 1) { $nav .= "</a>"; } $nav .= "</strong> </td>\n <td align='center' class='textHeaderDark'> Showing Rows " . ($total_rows == 0 ? "None" : (($row_limit*($_REQUEST["page"]-1))+1) . " to " . ((($total_rows < $row_limit) || ($total_rows < ($row_limit*$_REQUEST["page"]))) ? $total_rows : ($row_limit*$_REQUEST["page"])) . " of $total_rows [$url_page_select]") . " </td>\n <td align='right' class='textHeaderDark'> <strong>"; if (($_REQUEST["page"] * $row_limit) < $total_rows) { $nav .= "<a class='linkOverDark' href='mactrack_view_ips.php?page=" . ($_REQUEST["page"]+1) . "'>"; } $nav .= "Next"; if (($_REQUEST["page"] * $row_limit) < $total_rows) { $nav .= "</a>"; } $nav .= " >></strong> </td>\n </tr> </table> </td> </tr>\n"; }else{ $nav = "<tr bgcolor='#" . $colors["header"] . "' class='noprint'> <td colspan='22'> <table width='100%' cellspacing='0' cellpadding='0' border='0'> <tr> <td align='center' class='textHeaderDark'> No Rows Found </td>\n </tr> </table> </td> </tr>\n"; } }else{ $nav = html_create_nav($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, 13, "mactrack_view_sites.php"); } print $nav; $display_text = array( "nosort" => array("Actions", ""), "site_name" => array("Site Name", "ASC"), "ip_range" => array("IP Range", "ASC"), "ips_current" => array("Current IP Addresses", "DESC"), "ips_current_date" => array("Current Date", "DESC"), "ips_max" => array("Maximum IP Addresses", "DESC"), "ips_max_date" => array("Maximum Date", "DESC")); html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]); $i = 0; if (sizeof($ip_ranges) > 0) { foreach ($ip_ranges as $ip_range) { form_alternate_row_color($colors["alternate"],$colors["light"],$i); $i++; ?> <td width=80> <a href='<?php print htmlspecialchars($webroot . "plugins/mactrack/mactrack_sites.php?action=edit&site_id=" . $ip_range['site_id']);?>' title='Edit Site'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/edit_object.png'></a> <a href='<?php print htmlspecialchars($webroot . "plugins/mactrack/mactrack_view_macs.php?report=macs&reset&ip_filter_type_id=3&ip_filter=" . $ip_range["ip_range"] . "." . "&device_id=-1&scan_date=3&site_id=" . $ip_range['site_id']);?>' title='View MAC Addresses'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_macs.gif'></a> <a href='<?php print htmlspecialchars($webroot . "plugins/mactrack/mactrack_view_arp.php?report=arp&reset&ip_filter_type_id=3&ip_filter=" . $ip_range["ip_range"] . "." . "&device_id=-1&scan_date=3&site_id=" . $ip_range['site_id']);?>' title='View IP Addresses'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_ipaddresses.gif'></a> </td> <td width=200> <?php print "<strong>" . $ip_range["site_name"] . "</strong>";?> </td> <td><?php print $ip_range["ip_range"] . ".*";?></td> <td><?php print number_format($ip_range["ips_current"]);?></td> <td><?php print $ip_range["ips_current_date"];?></td> <td><?php print number_format($ip_range["ips_max"]);?></td> <td><?php print $ip_range["ips_max_date"];?></td> </tr> <?php } }else{ print "<tr><td colspan='10'><em>No MacTrack Site IP Ranges Found</em></td></tr>"; } print $nav; html_end_box(false); mactrack_display_stats(); }
/** 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() { global $title, $mactrack_rows, $config; mactrack_interfaces_request_validation(); general_header(); $sql_where = ''; if (get_request_var('rows') == -1) { $row_limit = read_config_option('num_rows_table'); } elseif (get_request_var('rows') == -2) { $row_limit = 99999999; } else { $row_limit = get_request_var('rows'); } $stats = mactrack_get_records($sql_where, TRUE, $row_limit); mactrack_tabs(); html_start_box($title, '100%', '', '3', 'center', ''); mactrack_filter_table(); html_end_box(); $rows_query_string = "SELECT COUNT(*)\n\t\tFROM mac_track_interfaces\n\t\tINNER JOIN mac_track_devices\n\t\tON mac_track_interfaces.device_id=mac_track_devices.device_id\n\t\tINNER JOIN mac_track_device_types\n\t\tON mac_track_device_types.device_type_id=mac_track_devices.device_type_id\n\t\t{$sql_where}"; $total_rows = db_fetch_cell($rows_query_string); $nav = html_nav_bar('mactrack_view_interfaces.php?report=interfaces', MAX_DISPLAY_PAGES, get_request_var('page'), $row_limit, $total_rows, 22, __('Interfaces')); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = mactrack_display_array(); html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction')); $i = 0; if (sizeof($stats)) { foreach ($stats as $stat) { /* find the background color and enclose it */ $class = mactrack_int_row_class($stat); if ($bgc) { print "<tr id='row_" . $stat['device_id'] . '_' . $stat['ifName'] . "' class='{$class}'>\n"; $i++; } else { if ($i % 2 == 1) { $class = 'odd'; } else { $class = 'even'; } print "<tr id='row_" . $stat['device_id'] . "' class='{$class}'>\n"; $i++; } print mactrack_format_interface_row($stat); } } else { print '<tr><td colspan="7"><em>' . __('No MacTrack Interfaces Found') . '</em></td></tr>'; } html_end_box(false); if (sizeof($stats)) { print $nav; } print '<div class="center" style="position:fixed;left:0;bottom:0;display:table;margin-left:auto;margin-right:auto;width:100%;">'; html_start_box('', '100%', '', '3', 'center', ''); print '<tr>'; mactrack_legend_row('int_up', 'Interface Up'); mactrack_legend_row('int_up_wo_alias', 'No Alias'); mactrack_legend_row('int_errors', 'Errors Present'); mactrack_legend_row('int_discards', 'Discards Present'); mactrack_legend_row('int_no_graph', 'No Graphs'); mactrack_legend_row('int_down', 'Interface Down'); print '</tr>'; html_end_box(false); print '</div>'; if (sizeof($stats)) { mactrack_display_stats(); } print '<div id="response"></div>'; bottom_footer(); }
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 mactrack_vmacs() { global $colors, $site_actions, $config, $item_rows; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request("page")); input_validate_input_number(get_request_var_request("rows")); /* ==================================================== */ /* clean up search string */ if (isset($_REQUEST["filter"])) { $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter")); } /* clean up sort_column */ if (isset($_REQUEST["sort_column"])) { $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); } /* clean up search string */ if (isset($_REQUEST["sort_direction"])) { $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); } /* if the user pushed the 'clear' button */ if (isset($_REQUEST["clear_x"])) { kill_session_var("sess_mactrack_vmacs_current_page"); kill_session_var("sess_mactrack_vmacs_filter"); kill_session_var("sess_mactrack_vmacs_rows"); kill_session_var("sess_mactrack_vmacs_sort_column"); kill_session_var("sess_mactrack_vmacs_sort_direction"); $_REQUEST["page"] = 1; unset($_REQUEST["filter"]); unset($_REQUEST["rows"]); unset($_REQUEST["sort_column"]); unset($_REQUEST["sort_direction"]); }else{ /* if any of the settings changed, reset the page number */ $changed = 0; $changed += mactrack_check_changed("filter", "sess_mactrack_vmacs_filter"); $changed += mactrack_check_changed("rows", "sess_mactrack_vmacs_rows"); if ($changed) { $_REQUEST["page"] = "1"; } } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value("page", "sess_mactrack_vmacs_current_page", "1"); load_current_session_value("filter", "sess_mactrack_vmacs_filter", ""); load_current_session_value("rows", "sess_mactrack_vmacs_rows", "-1"); load_current_session_value("sort_column", "sess_mactrack_vmacs_sort_column", "vendor_mac"); load_current_session_value("sort_direction", "sess_mactrack_vmacs_sort_direction", "ASC"); if ($_REQUEST["rows"] == -1) { $row_limit = read_config_option("num_rows_mactrack"); }elseif ($_REQUEST["rows"] == -2) { $row_limit = 999999; }else{ $row_limit = $_REQUEST["rows"]; } html_start_box("<strong>MacTrack Vendor Mac Filter</strong>", "100%", $colors["header"], "3", "center", ""); mactrack_vmac_filter(); html_end_box(); html_start_box("", "100%", $colors["header"], "3", "center", ""); $sql_where = ""; $vmacs = mactrack_vmacs_get_vmac_records($sql_where, $row_limit); $total_rows = db_fetch_cell("SELECT COUNT(*) FROM mac_track_oui_database $sql_where"); /* generate page list */ $url_page_select = str_replace("&page", "?page", get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, "mactrack_vendormacs.php")); if (defined("CACTI_VERSION")) { /* generate page list navigation */ $nav = html_create_nav($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, 11, "mactrack_vendormacs.php?filter=" . $_REQUEST["filter"]); }else{ if ($total_rows > 0) { $nav = "<tr bgcolor='#" . $colors["header"] . "'> <td colspan='9'> <table width='100%' cellspacing='0' cellpadding='0' border='0'> <tr> <td align='left' class='textHeaderDark'> <strong><< "; if ($_REQUEST["page"] > 1) { $nav .= "<a class='linkOverDark' href='mactrack_vendormacs.php?page=" . ($_REQUEST["page"]-1) . "'>"; } $nav .= "Previous"; if ($_REQUEST["page"] > 1) { $nav .= "</a>"; } $nav .= "</strong> </td>\n <td align='center' class='textHeaderDark'> Showing Rows " . (($row_limit*($_REQUEST["page"]-1))+1) . " to " . ((($total_rows < $row_limit) || ($total_rows < ($row_limit*$_REQUEST["page"]))) ? $total_rows : ($row_limit*$_REQUEST["page"])) . " of $total_rows [$url_page_select] </td>\n <td align='right' class='textHeaderDark'> <strong>"; if (($_REQUEST["page"] * $row_limit) < $total_rows) { $nav .= "<a class='linkOverDark' href='mactrack_vendormacs.php?page=" . ($_REQUEST["page"]+1) . "'>"; } $nav .= "Next"; if (($_REQUEST["page"] * $row_limit) < $total_rows) { $nav .= "</a>"; } $nav .= " >></strong> </td>\n </tr> </table> </td> </tr>\n"; }else{ $nav = "<tr bgcolor='#" . $colors["header"] . "' class='noprint'> <td colspan='22'> <table width='100%' cellspacing='0' cellpadding='0' border='0'> <tr> <td align='center' class='textHeaderDark'> No Rows Found </td>\n </tr> </table> </td> </tr>\n"; } } if ($total_rows) { print $nav; } $display_text = array( "vendor_mac" => array("Vendor MAC", "ASC"), "vendor_name" => array("Name", "ASC"), "vendor_address" => array("Address", "ASC")); html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]); $i = 0; if (sizeof($vmacs) > 0) { foreach ($vmacs as $vmac) { form_alternate_row_color($colors["alternate"],$colors["light"],$i); $i++; ?> <td class="linkEditMain"><?php print $vmac["vendor_mac"];?></td> <td><?php print (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $vmac["vendor_name"]) : $vmac["vendor_name"]);?></td> <td><?php print (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $vmac["vendor_address"]) : $vmac["vendor_address"]);?></td> </tr> <?php } /* put the nav bar on the bottom as well */ print $nav; }else{ print "<tr><td><em>No MacTrack Vendor MACS</em></td></tr>"; } html_end_box(false); }
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 user() { global $colors, $auth_realms; /* clean up sort_column */ if (isset($_REQUEST["sort_column"])) { $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); } /* clean up search string */ if (isset($_REQUEST["sort_direction"])) { $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value("sort_column", "sess_user_admin_sort_column", "username"); load_current_session_value("sort_direction", "sess_user_admin_sort_direction", "ASC"); html_start_box("<strong>User Management</strong>", "98%", $colors["header"], "3", "center", "user_admin.php?action=user_edit"); $display_text = array("username" => array("User Name", "ASC"), "full_name" => array("Full Name", "ASC"), "realm" => array("Realm", "ASC"), "policy_graphs" => array("Default Graph Policy", "ASC"), "dtime" => array("Last Login", "DESC")); html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"], 6); $user_list = db_fetch_assoc("SELECT\n\t\tid,\n\t\tuser_auth.username,\n\t\tfull_name,\n\t\trealm,\n\t\tpolicy_graphs,\n\t\ttime,\n\t\tmax(time) as dtime\n\t\tFROM user_auth\n\t\tLEFT JOIN user_log ON (user_auth.id = user_log.user_id)\n\t\tGROUP BY id\n\t\tORDER BY " . $_REQUEST['sort_column'] . " " . $_REQUEST['sort_direction']); $i = 0; if (sizeof($user_list) > 0) { foreach ($user_list as $user) { if (empty($user["dtime"]) || $user["dtime"] == "12/31/1969") { $last_login = "******"; } else { $last_login = strftime("%A, %B %d, %Y %H:%M:%S ", strtotime($user["dtime"])); } form_alternate_row_color($colors["alternate"], $colors["light"], $i); ?> <td> <a class="linkEditMain" href="user_admin.php?action=user_edit&id=<?php print $user["id"]; ?> "><?php print $user["username"]; ?> </a> </td> <td> <?php print $user["full_name"]; ?> </td> <td> <?php print $auth_realms[$user["realm"]]; ?> </td> <td> <?php if ($user["policy_graphs"] == "1") { print "ALLOW"; } else { print "DENY"; } ?> </td> <td> <?php print $last_login; ?> </td> <td align="right"> <a href="user_admin.php?action=user_remove&id=<?php print $user["id"]; ?> "><img src="images/delete_icon.gif" width="10" height="10" border="0" alt="Delete"></a> </td> </tr> <?php $i++; } } html_end_box(); }
function mactrack_site() { global $colors, $site_actions, $config, $item_rows; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request("site_id")); input_validate_input_number(get_request_var_request("page")); input_validate_input_number(get_request_var_request("rows")); /* ==================================================== */ /* clean up search string */ if (isset($_REQUEST["detail"])) { $_REQUEST["detail"] = sanitize_search_string(get_request_var("detail")); } /* clean up search string */ if (isset($_REQUEST["filter"])) { $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter")); } /* clean up sort_column */ if (isset($_REQUEST["sort_column"])) { $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); } /* clean up search string */ if (isset($_REQUEST["sort_direction"])) { $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); } /* if the user pushed the 'clear' button */ if (isset($_REQUEST["clear_x"])) { kill_session_var("sess_mactrack_sites_current_page"); kill_session_var("sess_mactrack_sites_detail"); kill_session_var("sess_mactrack_sites_device_type_id"); kill_session_var("sess_mactrack_sites_site_id"); kill_session_var("sess_mactrack_sites_rows"); kill_session_var("sess_mactrack_sites_filter"); kill_session_var("sess_mactrack_sites_sort_column"); kill_session_var("sess_mactrack_sites_sort_direction"); $_REQUEST["page"] = 1; unset($_REQUEST["filter"]); unset($_REQUEST["device_type_id"]); unset($_REQUEST["site_id"]); unset($_REQUEST["rows"]); unset($_REQUEST["detail"]); unset($_REQUEST["sort_column"]); unset($_REQUEST["sort_direction"]); }else{ /* if any of the settings changed, reset the page number */ $changed = 0; $changed += mactrack_check_changed("device_type_id", "sess_mactrack_sites_device_type_id"); $changed += mactrack_check_changed("site_id", "sess_mactrack_sites_site_id"); $changed += mactrack_check_changed("rows", "sess_mactrack_sites_rows"); $changed += mactrack_check_changed("filter", "sess_mactrack_sites_filter"); $changed += mactrack_check_changed("detail", "sess_mactrack_sites_detail"); if ($changed) { $_REQUEST["page"] = "1"; } } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value("page", "sess_mactrack_sites_current_page", "1"); load_current_session_value("detail", "sess_mactrack_sites_detail", "false"); load_current_session_value("device_type_id", "sess_mactrack_sites_device_type_id", "-1"); load_current_session_value("site_id", "sess_mactrack_sites_site_id", "-1"); load_current_session_value("rows", "sess_mactrack_sites_rows", "-1"); load_current_session_value("filter", "sess_mactrack_sites_filter", ""); load_current_session_value("sort_column", "sess_mactrack_sites_sort_column", "site_name"); load_current_session_value("sort_direction", "sess_mactrack_sites_sort_direction", "ASC"); if ($_REQUEST["rows"] == -1) { $row_limit = read_config_option("num_rows_mactrack"); }elseif ($_REQUEST["rows"] == -2) { $row_limit = 999999; }else{ $row_limit = $_REQUEST["rows"]; } html_start_box("<strong>MacTrack Site Filters</strong>", "100%", $colors["header"], "3", "center", "mactrack_sites.php?action=edit"); mactrack_site_filter(); html_end_box(); html_start_box("", "100%", $colors["header"], "3", "center", ""); $sql_where = ""; $sites = mactrack_site_get_site_records($sql_where, $row_limit); if ($_REQUEST["detail"] == "false") { $total_rows = db_fetch_cell("SELECT COUNT(mac_track_sites.site_id) FROM mac_track_sites $sql_where"); }else{ $total_rows = db_fetch_cell("SELECT count(*) FROM (mac_track_device_types RIGHT JOIN mac_track_devices ON (mac_track_device_types.device_type_id = mac_track_devices.device_type_id)) RIGHT JOIN mac_track_sites ON (mac_track_devices.site_id = mac_track_sites.site_id) $sql_where GROUP BY mac_track_sites.site_name, mac_track_device_types.device_type_id"); } /* generate page list */ $url_page_select = str_replace("&page", "?page", get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, "mactrack_sites.php")); if ($_REQUEST["detail"] == "false") { if (defined("CACTI_VERSION")) { /* generate page list navigation */ $nav = html_create_nav($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, 9, "mactrack_sites.php?filter=" . $_REQUEST["filter"]); }else{ if ($total_rows > 0) { $nav = "<tr bgcolor='#" . $colors["header"] . "'> <td colspan='9'> <table width='100%' cellspacing='0' cellpadding='0' border='0'> <tr> <td align='left' class='textHeaderDark'> <strong><< "; if ($_REQUEST["page"] > 1) { $nav .= "<a class='linkOverDark' href='mactrack_sites.php?page=" . ($_REQUEST["page"]-1) . "'>"; } $nav .= "Previous"; if ($_REQUEST["page"] > 1) { $nav .= "</a>"; } $nav .= "</strong> </td>\n <td align='center' class='textHeaderDark'> Showing Rows " . (($row_limit*($_REQUEST["page"]-1))+1) . " to " . ((($total_rows < $row_limit) || ($total_rows < ($row_limit*$_REQUEST["page"]))) ? $total_rows : ($row_limit*$_REQUEST["page"])) . " of $total_rows [$url_page_select] </td>\n <td align='right' class='textHeaderDark'> <strong>"; if (($_REQUEST["page"] * $row_limit) < $total_rows) { $nav .= "<a class='linkOverDark' href='mactrack_sites.php?page=" . ($_REQUEST["page"]+1) . "'>"; } $nav .= "Next"; if (($_REQUEST["page"] * $row_limit) < $total_rows) { $nav .= "</a>"; } $nav .= " >></strong> </td>\n </tr> </table> </td> </tr>\n"; }else{ $nav = "<tr bgcolor='#" . $colors["header"] . "' class='noprint'> <td colspan='22'> <table width='100%' cellspacing='0' cellpadding='0' border='0'> <tr> <td align='center' class='textHeaderDark'> No Rows Found </td>\n </tr> </table> </td> </tr>\n"; } } print $nav; $display_text = array( "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_checkbox($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]); $i = 0; if (sizeof($sites) > 0) { foreach ($sites as $site) { form_alternate_row_color($colors["alternate"],$colors["light"],$i, 'line' . $site["site_id"]); $i++; form_selectable_cell("<a class='linkEditMain' href='mactrack_sites.php?action=edit&site_id=" . $site["site_id"] . "'>". (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $site["site_name"]) : $site["site_name"]) . "</a>", $site["site_id"]); form_selectable_cell(number_format($site["total_devices"]), $site["site_id"]); form_selectable_cell(number_format($site["total_ips"]), $site["site_id"]); form_selectable_cell(number_format($site["total_user_ports"]), $site["site_id"]); form_selectable_cell(number_format($site["total_oper_ports"]), $site["site_id"]); form_selectable_cell(number_format($site["total_macs"]), $site["site_id"]); form_selectable_cell($site["total_device_errors"], $site["site_id"]); form_checkbox_cell($site["site_name"], $site["site_id"]); form_end_row(); } /* put the nav bar on the bottom as well */ print $nav; }else{ print "<tr><td><em>No MacTrack Sites</em></td></tr>"; } html_end_box(false); }else{ if (defined("CACTI_VERSION")) { /* generate page list navigation */ $nav = html_create_nav($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, 10, "mactrack_sites.php?filter=" . $_REQUEST["filter"]); }else{ if ($total_rows > 0) { $nav = "<tr bgcolor='#" . $colors["header"] . "'> <td colspan='10'> <table width='100%' cellspacing='0' cellpadding='0' border='0'> <tr> <td align='left' class='textHeaderDark'> <strong><< "; if ($_REQUEST["page"] > 1) { $nav .= "<a class='linkOverDark' href='mactrack_sites.php?page=" . ($_REQUEST["page"]-1) . "'>"; } $nav .= "Previous"; if ($_REQUEST["page"] > 1) { $nav .= "</a>"; } $nav .= "</strong> </td>\n <td align='center' class='textHeaderDark'> Showing Rows " . (($row_limit*($_REQUEST["page"]-1))+1) . " to " . ((($total_rows < $row_limit) || ($total_rows < ($row_limit*$_REQUEST["page"]))) ? $total_rows : ($row_limit*$_REQUEST["page"])) . " of $total_rows [$url_page_select] </td>\n <td align='right' class='textHeaderDark'> <strong>"; if (($_REQUEST["page"] * $row_limit) < $total_rows) { $nav .= "<a class='linkOverDark' href='mactrack_sites.php?page=" . ($_REQUEST["page"]+1) . "'>"; } $nav .= "Next"; if (($_REQUEST["page"] * $row_limit) < $total_rows) { $nav .= "</a>"; } $nav .= " >></strong> </td>\n </tr> </table> </td> </tr>\n"; }else{ $nav = "<tr bgcolor='#" . $colors["header"] . "' class='noprint'> <td colspan='22'> <table width='100%' cellspacing='0' cellpadding='0' border='0'> <tr> <td align='center' class='textHeaderDark'> No Rows Found </td>\n </tr> </table> </td> </tr>\n"; } } print $nav; $display_text = array( "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, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]); $i = 0; if (sizeof($sites) > 0) { foreach ($sites as $site) { form_alternate_row_color($colors["alternate"],$colors["light"],$i); $i++; ?> <td width=200> <a class='linkEditMain' href='mactrack_sites.php?action=edit&site_id=<?php print $site["site_id"];?>'><?php print (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $site["site_name"]) : $site["site_name"]);?></a> </td> <td><?php print (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $site["vendor"]) : $site["vendor"]);?></td> <td><?php print (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $site["description"]) : $site["description"]);?></td> <td><?php print number_format($site["total_devices"]);?></td> <td><?php print number_format($site["sum_ips_total"]);?></td> <td><?php print number_format($site["sum_ports_total"]);?></td> <td><?php print number_format($site["sum_ports_active"]);?></td> <td><?php print number_format($site["sum_ports_trunk"]);?></td> <td><?php print number_format($site["sum_macs_active"]);?></td> </tr> <?php } /* put the nav bar on the bottom as well */ print $nav; }else{ print "<tr><td><em>No MacTrack Sites</em></td></tr>"; } html_end_box(false); } /* draw the dropdown containing a list of available actions for this form */ if ($_REQUEST["detail"] == "false") { mactrack_draw_actions_dropdown($site_actions); } }
function utilities_view_poller_cache() { global $colors, $poller_actions; define("MAX_DISPLAY_PAGES", 21); /* ================= input validation ================= */ input_validate_input_number(get_request_var_request("host_id")); input_validate_input_number(get_request_var_request("page")); input_validate_input_number(get_request_var_request("poller_action")); /* ==================================================== */ /* clean up search filter */ if (isset($_REQUEST["filter"])) { $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter")); } /* clean up sort_column */ if (isset($_REQUEST["sort_column"])) { $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); } /* clean up sort direction */ if (isset($_REQUEST["sort_direction"])) { $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); } /* if the user pushed the 'clear' button */ if (isset($_REQUEST["clear_x"])) { kill_session_var("sess_poller_current_page"); kill_session_var("sess_poller_host_id"); kill_session_var("sess_poller_poller_action"); kill_session_var("sess_poller_filter"); unset($_REQUEST["page"]); unset($_REQUEST["filter"]); unset($_REQUEST["host_id"]); unset($_REQUEST["poller_action"]); } if (!empty($_SESSION["sess_poller_action"]) && !empty($_REQUEST["poller_action"])) { if ($_SESSION["sess_poller_poller_action"] != $_REQUEST["poller_action"]) { $_REQUEST["page"] = 1; } } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value("page", "sess_poller_current_page", "1"); load_current_session_value("host_id", "sess_poller_host_id", "-1"); load_current_session_value("poller_action", "sess_poller_poller_action", "-1"); load_current_session_value("filter", "sess_poller_filter", ""); load_current_session_value("sort_column", "sess_poller_sort_column", "data_template_data.name_cache"); load_current_session_value("sort_direction", "sess_poller_sort_direction", "ASC"); $_REQUEST['page_referrer'] = 'view_poller_cache'; load_current_session_value('page_referrer', 'page_referrer', 'view_poller_cache'); ?> <script type="text/javascript"> <!-- function applyPItemFilterChange(objForm) { strURL = '?poller_action=' + objForm.poller_action.value; strURL = strURL + '&host_id=' + objForm.host_id.value; strURL = strURL + '&filter=' + objForm.filter.value; strURL = strURL + '&action=view_poller_cache'; document.location = strURL; } --> </script> <?php html_start_box("<strong>Poller Cache Items</strong>", "100%", $colors["header"], "3", "center", ""); include "./include/html/inc_poller_item_filter_table.php"; html_end_box(); /* form the 'where' clause for our main sql query */ $sql_where = "WHERE poller_item.local_data_id=data_template_data.local_data_id"; if ($_REQUEST["poller_action"] == "-1") { /* Show all items */ } else { $sql_where .= " AND poller_item.action='" . $_REQUEST["poller_action"] . "'"; } if ($_REQUEST["host_id"] == "-1") { /* Show all items */ } elseif ($_REQUEST["host_id"] == "0") { $sql_where .= " AND poller_item.host_id=0"; } elseif (!empty($_REQUEST["host_id"])) { $sql_where .= " AND poller_item.host_id=" . $_REQUEST["host_id"]; } if (strlen($_REQUEST["filter"])) { $sql_where .= " AND (data_template_data.name_cache LIKE '%%" . $_REQUEST["filter"] . "%%'\n\t\t\tOR host.description LIKE '%%" . $_REQUEST["filter"] . "%%'\n\t\t\tOR poller_item.arg1 LIKE '%%" . $_REQUEST["filter"] . "%%'\n\t\t\tOR poller_item.hostname LIKE '%%" . $_REQUEST["filter"] . "%%'\n\t\t\tOR poller_item.rrd_path LIKE '%%" . $_REQUEST["filter"] . "%%')"; } html_start_box("", "100%", $colors["header"], "3", "center", ""); $total_rows = db_fetch_cell("SELECT\n\t\tCOUNT(*)\n\t\tFROM data_template_data\n\t\tINNER JOIN (poller_item\n\t\tINNER JOIN host\n\t\tON poller_item.host_id = host.id)\n\t\tON data_template_data.local_data_id = poller_item.local_data_id\n\t\t{$sql_where}"); $poller_sql = "SELECT\n\t\tpoller_item.*,\n\t\tdata_template_data.name_cache,\n\t\thost.description\n\t\tFROM data_template_data\n\t\tINNER JOIN (poller_item\n\t\tINNER JOIN host\n\t\tON poller_item.host_id = host.id)\n\t\tON data_template_data.local_data_id = poller_item.local_data_id\n\t\t{$sql_where}\n\t\tORDER BY " . $_REQUEST["sort_column"] . " " . $_REQUEST["sort_direction"] . ", action ASC\n\t\tLIMIT " . read_config_option("num_rows_data_source") * ($_REQUEST["page"] - 1) . "," . read_config_option("num_rows_data_source"); // print $poller_sql; $poller_cache = db_fetch_assoc($poller_sql); /* generate page list */ $url_page_select = get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, read_config_option("num_rows_data_source"), $total_rows, "utilities.php?action=view_poller_cache&host_id=" . $_REQUEST["host_id"] . "&poller_action=" . $_REQUEST["poller_action"]); $nav = "<tr bgcolor='#" . $colors["header"] . "'>\n\t\t\t<td colspan='7'>\n\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td align='left' class='textHeaderDark'>\n\t\t\t\t\t\t\t<strong><< "; if ($_REQUEST["page"] > 1) { $nav .= "<a class='linkOverDark' href='utilities.php?action=view_poller_cache&host_id=" . $_REQUEST["host_id"] . "&poller_action=" . $_REQUEST["poller_action"] . "&page=" . ($_REQUEST["page"] - 1) . "'>"; } $nav .= "Previous"; if ($_REQUEST["page"] > 1) { $nav .= "</a>"; } $nav .= "</strong>\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\n\t\t\t\t\t\t\tShowing Rows " . (read_config_option("num_rows_data_source") * ($_REQUEST["page"] - 1) + 1) . " to " . ($total_rows < read_config_option("num_rows_data_source") || $total_rows < read_config_option("num_rows_data_source") * $_REQUEST["page"] ? $total_rows : read_config_option("num_rows_data_source") * $_REQUEST["page"]) . " of {$total_rows} [{$url_page_select}]\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td align='right' class='textHeaderDark'>\n\t\t\t\t\t\t\t<strong>"; if ($_REQUEST["page"] * read_config_option("num_rows_data_source") < $total_rows) { $nav .= "<a class='linkOverDark' href='utilities.php?action=view_poller_cache&host_id=" . $_REQUEST["host_id"] . "&poller_action=" . $_REQUEST["poller_action"] . "&page=" . ($_REQUEST["page"] + 1) . "'>"; } $nav .= "Next"; if ($_REQUEST["page"] * read_config_option("num_rows_data_source") < $total_rows) { $nav .= "</a>"; } $nav .= " >></strong>\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t</td>\n\t\t</tr>\n"; print $nav; $display_text = array("data_template_data.name_cache" => array("Data Source Name", "ASC"), "" => array("Details", "ASC")); html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]); $i = 0; if (sizeof($poller_cache) > 0) { foreach ($poller_cache as $item) { form_alternate_row_color($colors["form_alternate1"], $colors["form_alternate2"], $i); ?> <td width="375"> <a class="linkEditMain" href="data_sources.php?action=ds_edit&id=<?php print $item["local_data_id"]; ?> "><?php print eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $item["name_cache"]); ?> </a> </td> <td> <?php if ($item["action"] == 0) { if ($item["snmp_version"] != 3) { $details = "SNMP Version: " . $item["snmp_version"] . ", " . "Community: " . $item["snmp_community"] . ", " . "OID: " . eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $item["arg1"]); } else { $details = "SNMP Version: " . $item["snmp_version"] . ", " . "User: "******"snmp_username"] . ", OID: " . $item["arg1"]; } } elseif ($item["action"] == 1) { $details = "Script: " . eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $item["arg1"]); } else { $details = "Script Server: " . eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $item["arg1"]); } print $details; ?> </td> </tr> <?php form_alternate_row_color($colors["form_alternate1"], $colors["form_alternate2"], $i); ?> <td> </td> <td> RRD: <?php print $item["rrd_path"]; ?> </td> </tr> <?php $i++; } } html_end_box(); }
function mikrotik_devices() { global $config, $colors, $item_rows; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('status')); input_validate_input_number(get_request_var_request('page')); input_validate_input_number(get_request_var_request('rows')); /* ==================================================== */ /* clean up sort_column */ if (isset($_REQUEST['sort_column'])) { $_REQUEST['sort_column'] = sanitize_search_string(get_request_var_request('sort_column')); } /* clean up sort_direction */ if (isset($_REQUEST['sort_direction'])) { $_REQUEST['sort_direction'] = sanitize_search_string(get_request_var_request('sort_direction')); } /* clean up filter string */ if (isset($_REQUEST['filter'])) { $_REQUEST['filter'] = sanitize_search_string(get_request_var_request('filter')); } if (isset($_REQUEST['reset'])) { kill_session_var('sess_mikrotik_device_sort_column'); kill_session_var('sess_mikrotik_device_sort_direction'); kill_session_var('sess_mikrotik_device_status'); kill_session_var('sess_mikrotik_device_filter'); kill_session_var('sess_default_rows'); kill_session_var('sess_mikrotik_device_current_page'); } elseif (isset($_REQUEST['clear'])) { kill_session_var('sess_mikrotik_device_sort_column'); kill_session_var('sess_mikrotik_device_sort_direction'); kill_session_var('sess_mikrotik_device_status'); kill_session_var('sess_mikrotik_device_filter'); kill_session_var('sess_default_rows'); kill_session_var('sess_mikrotik_device_current_page'); unset($_REQUEST['sort_column']); unset($_REQUEST['sort_direction']); unset($_REQUEST['status']); unset($_REQUEST['filter']); unset($_REQUEST['rows']); unset($_REQUEST['page']); } else { /* if any of the settings changed, reset the page number */ $changed = false; $changed += mikrotik_check_changed('status', 'sess_mikrotik_device_status'); $changed += mikrotik_check_changed('filter', 'sess_mikrotik_device_filter'); $changed += mikrotik_check_changed('rows', 'sess_default_rows'); if ($changed) { $_REQUEST['page'] = '1'; } } load_current_session_value('page', 'sess_mikrotik_device_current_page', '1'); load_current_session_value('rows', 'sess_default_rows', read_config_option('num_rows_table')); load_current_session_value('sort_column', 'sess_mikrotik_device_sort_column', 'description'); load_current_session_value('sort_direction', 'sess_mikrotik_device_sort_direction', 'ASC'); load_current_session_value('status', 'sess_mikrotik_device_status', '-1'); load_current_session_value('filter', 'sess_mikrotik_device_filter', ''); ?> <script type='text/javascript'> function applyFilter() { strURL = '?action=devices'; strURL += '&status=' + $('#status').val(); strURL += '&filter=' + $('#filter').val(); strURL += '&rows=' + $('#rows').val(); strURL += '&header=false'; loadPageNoHeader(strURL); } function clearFilter() { strURL = '?action=devices&clear=&header=false'; loadPageNoHeader(strURL); } $(function() { $('#form_devices').submit(function(event) { event.preventDefault(); applyFilter(); }); }); </script> <?php html_start_box('<strong>Device Filter</strong>', '100%', $colors['header'], '3', 'center', ''); ?> <tr class='even noprint'> <td> <form id='form_devices' action='mikrotik.php?action=devices'> <table class='filterTable'> <tr> <td> Search </td> <td> <input id='filter' type='text' size='25' value='<?php print get_request_var_request('filter'); ?> '> </td> <td> Status </td> <td> <select id='status' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var_request('type') == '-1') { ?> selected<?php } ?> >All</option> <?php $statuses = db_fetch_assoc('SELECT DISTINCT status FROM host INNER JOIN plugin_mikrotik_system ON host.id=plugin_mikrotik_system.host_id'); $statuses = array_merge($statuses, array('-2' => array('status' => '-2'))); if (sizeof($statuses)) { foreach ($statuses as $s) { switch ($s['status']) { case '0': $status = 'Unknown'; break; case '1': $status = 'Down'; break; case '2': $status = 'Recovering'; break; case '3': $status = 'Up'; break; case '-2': $status = 'Disabled'; break; } echo "<option value='" . $s['status'] . "' " . (get_request_var_request('status') == $s['status'] ? 'selected' : '') . '>' . $status . '</option>'; } } ?> </select> </td> <td> Devices </td> <td> <select id='rows' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var_request('rows') == '-1') { ?> selected<?php } ?> >Default</option> <?php if (sizeof($item_rows)) { foreach ($item_rows as $key => $name) { echo "<option value='" . $key . "' " . (get_request_var_request('rows') == $key ? 'selected' : '') . '>' . $name . '</option>'; } } ?> </select> </td> <td> <input id='refresh' type='button' onClick='applyFilter()' value='Go'> </td> <td> <input id='clear' type='button' onClick='clearFilter()' value='Clear'> </td> </tr> </table> <input type='hidden' id='page' name='page' value='<?php print $_REQUEST['page']; ?> '> </form> </td> </tr> <?php html_end_box(); html_start_box('', '100%', $colors['header'], '3', 'center', ''); if ($_REQUEST['rows'] == '-1') { $num_rows = read_config_option('num_rows_table'); } else { $num_rows = get_request_var_request('rows'); } $limit = ' LIMIT ' . $num_rows * (get_request_var_request('page') - 1) . ',' . $num_rows; $sql_where = ''; if ($_REQUEST['status'] != '-1') { $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' hrs.host_status=' . $_REQUEST['status']; } $sql_join = ''; if ($_REQUEST['filter'] != '') { $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . " h.description LIKE '%" . $_REQUEST['filter'] . "%' OR\n\t\t\th.hostname LIKE '%" . $_REQUEST['filter'] . "%'"; } $sql = "SELECT hrs.*, h.hostname, h.description, h.disabled, trees.trees, queues.queues\n\t\tFROM plugin_mikrotik_system AS hrs\n\t\tINNER JOIN host AS h \n\t\tON h.id=hrs.host_id\n\t\tLEFT JOIN (SELECT host_id AS hid, count(*) AS trees FROM plugin_mikrotik_trees GROUP BY host_id) AS trees\n\t\tON trees.hid=hrs.host_id\n\t\tLEFT JOIN (SELECT host_id AS hid, count(*) AS queues FROM plugin_mikrotik_queues GROUP BY host_id) AS queues\n\t\tON queues.hid=hrs.host_id\n\t\t{$sql_join}\n\t\t{$sql_where}\n\t\tORDER BY " . get_request_var_request("sort_column") . " " . get_request_var_request("sort_direction") . " " . $limit; //echo $sql; $rows = db_fetch_assoc($sql); $total_rows = db_fetch_cell("SELECT COUNT(*)\n\t\tFROM plugin_mikrotik_system AS hrs\n\t\tINNER JOIN host AS h\n\t\tON h.id=hrs.host_id\n\t\t{$sql_join}\n\t\t{$sql_where}"); $nav = html_nav_bar('mikrotik.php?action=devices', MAX_DISPLAY_PAGES, get_request_var_request('page'), $num_rows, $total_rows, 15, 'Devices', 'page', 'main'); print $nav; $display_text = array('nosort' => array('display' => 'Actions', 'sort' => 'ASC', 'align' => 'left'), 'description' => array('display' => 'Name', 'sort' => 'ASC', 'align' => 'left'), 'host_status' => array('display' => 'Status', 'sort' => 'DESC', 'align' => 'center'), 'firmwareVersion' => array('display' => 'FW Ver', 'sort' => 'DESC', 'align' => 'right'), 'licVersion' => array('display' => 'Lic Ver', 'sort' => 'DESC', 'align' => 'right'), 'uptime' => array('display' => 'Uptime(d:h:m)', 'sort' => 'DESC', 'align' => 'right'), 'trees' => array('display' => 'Trees', 'sort' => 'DESC', 'align' => 'right'), 'users' => array('display' => 'Users', 'sort' => 'DESC', 'align' => 'right'), 'cpuPercent' => array('display' => 'CPU %', 'sort' => 'DESC', 'align' => 'right'), 'numCpus' => array('display' => 'CPUs', 'sort' => 'DESC', 'align' => 'right'), 'processes' => array('display' => 'Processes', 'sort' => 'DESC', 'align' => 'right'), 'memSize' => array('display' => 'Total Mem', 'sort' => 'DESC', 'align' => 'right'), 'memUsed' => array('display' => 'Used Mem', 'sort' => 'DESC', 'align' => 'right'), 'diskSize' => array('display' => 'Total Disk', 'sort' => 'DESC', 'align' => 'right'), 'diskUsed' => array('display' => 'Used Disk', 'sort' => 'DESC', 'align' => 'right')); html_header_sort($display_text, get_request_var_request('sort_column'), get_request_var_request('sort_direction'), 'false'); /* set some defaults */ $url = $config['url_path'] . 'plugins/mikrotik/mikrotik.php'; $users = $config['url_path'] . 'plugins/mikrotik/images/view_users.gif'; $usersn = $config['url_path'] . 'plugins/mikrotik/images/view_users_none.gif'; $host = $config['url_path'] . 'plugins/mikrotik/images/view_hosts.gif'; $trees = $config['url_path'] . 'plugins/mikrotik/images/view_trees.gif'; $treesn = $config['url_path'] . 'plugins/mikrotik/images/view_trees_none.gif'; $queues = $config['url_path'] . 'plugins/mikrotik/images/view_queues.gif'; $queuesn = $config['url_path'] . 'plugins/mikrotik/images/view_queues_none.gif'; $interfaces = $config['url_path'] . 'plugins/mikrotik/images/view_interfaces.gif'; $dashboard = $config['url_path'] . 'plugins/mikrotik/images/view_dashboard.gif'; $graphs = $config['url_path'] . 'plugins/mikrotik/images/view_graphs.gif'; $nographs = $config['url_path'] . 'plugins/mikrotik/images/view_graphs_disabled.gif'; $hcpudq = read_config_option('mikrotik_dq_host_cpu'); if (sizeof($rows)) { foreach ($rows as $row) { $days = intval($row['uptime'] / (60 * 60 * 24 * 100)); $remainder = $row['uptime'] % (60 * 60 * 24 * 100); $hours = intval($remainder / (60 * 60 * 100)); $remainder = $remainder % (60 * 60 * 100); $minutes = intval($remainder / (60 * 100)); $found = db_fetch_cell('SELECT COUNT(*) FROM graph_local WHERE host_id=' . $row['host_id']); form_alternate_row(); echo "<td style='white-space:nowrap;min-width:115px;text-align:left;'>"; //echo "<a style='padding:1px;' href='" . htmlspecialchars("$url?action=dashboard&reset=1&device=" . $row["host_id"]) . "'><img src='$dashboard' title='View Dashboard' align='absmiddle' border='0'></a>"; if ($row['users'] > 0) { echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=users&reset=1&device=" . $row['host_id']) . "'><img src='{$users}' title='View Users' align='absmiddle' border='0' alt=''></a>"; } else { echo "<img style='border:0px;padding:3px;' src='{$usersn}' title='No Users Found' align='absmiddle' alt=''>"; } if ($row['queues'] > 0) { echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=queues&reset=1&device=" . $row['host_id']) . "'><img src='{$queues}' title='View Simple Queue' align='absmiddle' border='0' alt=''></a>"; } else { echo "<img style='border:0px;padding:3px;' src='{$queuesn}' title='No Simple Queues Found' align='absmiddle' alt=''>"; } if ($row['trees'] > 0) { echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=trees&reset=1&device=" . $row['host_id']) . "'><img src='{$trees}' title='View Queue Trees' align='absmiddle' border='0' alt=''></a>"; } else { echo "<img style='border:0px;padding:3px;' src='{$treesn}' title='No Queue Trees Found' align='absmiddle' alt=''>"; } echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=interfaces&reset=1&device=" . $row['host_id']) . "'><img src='{$interfaces}' title='View Interfaces' align='absmiddle' border='0' alt=''></a>"; if ($found) { echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=graphs&reset=1&host_id=" . $row['host_id'] . "&style=selective&graph_add=&graph_list=&graph_template_id=0&filter=") . "'><img src='{$graphs}' title='View Graphs' align='absmiddle' border='0' alt=''></a>"; } else { echo "<img src='{$nographs}' title='No Graphs Defined' align='absmiddle' border='0'>"; } $graph_cpu = mikrotik_get_graph_url($hcpudq, $row['host_id'], '', $row['numCpus'], false); $graph_cpup = mikrotik_get_graph_template_url(mikrotik_template_by_hash('7df474393f58bae8e8d6b85f10efad71'), $row['host_id'], round($row['cpuPercent'], 2), false); $graph_users = mikrotik_get_graph_template_url(mikrotik_template_by_hash('99e37ff13139f586d257ba9a637d7340'), $row['host_id'], empty($rows['users']) ? '-' : $row['users'], false); $graph_aproc = mikrotik_get_graph_template_url(mikrotik_template_by_hash('e797d967db24fd86341a8aa8c60fa9e0'), $row['host_id'], $row['host_status'] < 2 ? 'N/A' : $row['processes'], false); $graph_disk = mikrotik_get_graph_template_url(mikrotik_template_by_hash('0ece13b90785aa04d1f554a093685948'), $row['host_id'], $row['host_status'] < 2 ? 'N/A' : round($row['diskUsed'], 2), false); $graph_mem = mikrotik_get_graph_template_url(mikrotik_template_by_hash('4396ae857c4f9bc5ed1f26b5361e42d9'), $row['host_id'], $row['host_status'] < 2 ? 'N/A' : round($row['memUsed'], 2), false); $graph_upt = mikrotik_get_graph_template_url(mikrotik_template_by_hash('7d8dc3050621a2cb937cac3895bc5d5b'), $row['host_id'], $row['host_status'] < 2 ? 'N/A' : mikrotik_format_uptime($days, $hours, $minutes), false); if (api_plugin_user_realm_auth('host.php')) { $host_url = "<a class='hyperLink' href='" . htmlspecialchars($config['url_path'] . 'host.php?action=edit&id=' . $row['host_id']) . "' title='Edit Hosts'>" . $row['hostname'] . '</a>'; } else { $host_url = $row['hostname']; } echo '</td>'; echo "<td style='text-align:left;white-space:nowrap;'><strong>" . (strlen($_REQUEST['filter']) ? preg_replace('/(' . preg_quote(get_request_var_request('filter'), '/') . ')/i', "<span class='filteredValue'>\\1</span>", $row['description'] . '</strong> [' . $host_url . ']') : $row['description'] . '</strong> [' . $host_url . ']') . '</td>'; echo "<td style='text-align:center;'>" . get_colored_device_status($row['disabled'] == 'on' ? true : false, $row['host_status']) . '</td>'; echo "<td style='text-align:right;'>" . $row['firmwareVersion'] . '</td>'; echo "<td style='text-align:right;'>" . $row['licVersion'] . '</td>'; echo "<td style='text-align:right;'>" . $graph_upt . '</td>'; echo "<td style='text-align:right;'>" . (!empty($row['trees']) ? $row['trees'] : '-') . '</td>'; echo "<td style='text-align:right;'>" . $graph_users . '</td>'; echo "<td style='text-align:right;'>" . ($row['host_status'] < 2 ? 'N/A' : $graph_cpup) . '</td>'; echo "<td style='text-align:right;'>" . ($row['host_status'] < 2 ? 'N/A' : $graph_cpu) . '</td>'; echo "<td style='text-align:right;'>" . $graph_aproc . '</td>'; echo "<td style='text-align:right;'>" . mikrotik_memory($row['memSize']) . '</td>'; echo "<td style='text-align:right;'>" . $graph_mem . ' %</td>'; echo "<td style='text-align:right;'>" . mikrotik_memory($row['diskSize']) . '</td>'; echo "<td style='text-align:right;'>" . $graph_disk . ' %</td>'; form_end_row(); } print $nav; } else { print '<tr><td colspan="5"><em>No Devices Found</em></td></tr>'; } html_end_box(); }
function data_query() { global $colors; /* clean up sort_column */ if (isset($_REQUEST["sort_column"])) { $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); } /* clean up search string */ if (isset($_REQUEST["sort_direction"])) { $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value("sort_column", "sess_data_queries_sort_column", "name"); load_current_session_value("sort_direction", "sess_data_queries_sort_direction", "ASC"); html_start_box("<strong>Data Queries</strong>", "98%", $colors["header"], "3", "center", "data_queries.php?action=edit"); $display_text = array( "name" => array("Name", "ASC"), "data_input_method" => array("Data Input Method", "ASC")); html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"], 3); $snmp_queries = db_fetch_assoc("SELECT snmp_query.id, snmp_query.name, data_input.name AS data_input_method FROM snmp_query INNER JOIN data_input ON (snmp_query.data_input_id = data_input.id) ORDER BY " . $_REQUEST['sort_column'] . " " . $_REQUEST['sort_direction']); $i = 0; if (sizeof($snmp_queries) > 0) { foreach ($snmp_queries as $snmp_query) { form_alternate_row_color($colors["alternate"],$colors["light"],$i); $i++; ?> <td> <a class="linkEditMain" href="data_queries.php?action=edit&id=<?php print $snmp_query["id"];?>"><?php print $snmp_query["name"];?></a> </td> <td> <?php print $snmp_query["data_input_method"]; ?> </td> <td align="right"> <a href="data_queries.php?action=remove&id=<?php print $snmp_query["id"];?>"><img src="images/delete_icon.gif" width="10" height="10" border="0" alt="Delete"></a> </td> </tr> <?php } } html_end_box(); }
function mactrack_view_devices() { global $title, $report, $colors, $mactrack_search_types, $mactrack_device_types, $rows_selector, $config, $item_rows; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request("site_id")); input_validate_input_number(get_request_var_request("device_id")); input_validate_input_number(get_request_var_request("type_id")); input_validate_input_number(get_request_var_request("device_type_id")); input_validate_input_number(get_request_var_request("status")); input_validate_input_number(get_request_var_request("page")); input_validate_input_number(get_request_var_request("rows")); /* ==================================================== */ /* clean up search string */ if (isset($_REQUEST["filter"])) { $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter")); } /* clean up sort_column */ if (isset($_REQUEST["sort_column"])) { $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); } /* clean up search string */ if (isset($_REQUEST["sort_direction"])) { $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); } /* if the user pushed the 'clear' button */ if (isset($_REQUEST["clear_x"]) || isset($_REQUEST["reset"])) { kill_session_var("sess_mactrack_view_device_current_page"); kill_session_var("sess_mactrack_view_device_filter"); kill_session_var("sess_mactrack_view_device_site_id"); kill_session_var("sess_mactrack_view_device_type_id"); kill_session_var("sess_mactrack_view_device_rows"); kill_session_var("sess_mactrack_view_device_device_type_id"); kill_session_var("sess_mactrack_view_device_status"); kill_session_var("sess_mactrack_view_device_sort_column"); kill_session_var("sess_mactrack_view_device_sort_direction"); $_REQUEST["page"] = 1; if (isset($_REQUEST["clear_x"])) { unset($_REQUEST["filter"]); unset($_REQUEST["site_id"]); unset($_REQUEST["type_id"]); unset($_REQUEST["rows"]); unset($_REQUEST["device_type_id"]); unset($_REQUEST["status"]); unset($_REQUEST["sort_column"]); unset($_REQUEST["sort_direction"]); } }else{ /* if any of the settings changed, reset the page number */ $changed = 0; $changed += mactrack_check_changed("filter", "sess_mactrack_view_device_filter"); $changed += mactrack_check_changed("site_id", "sess_mactrack_view_device_site_id"); $changed += mactrack_check_changed("rows", "sess_mactrack_view_device_rows"); $changed += mactrack_check_changed("type_id", "sess_mactrack_view_device_type_id"); $changed += mactrack_check_changed("device_type_id", "sess_mactrack_view_device_device_type_id"); $changed += mactrack_check_changed("status", "sess_mactrack_view_device_status"); if ($changed) { $_REQUEST["page"] = "1"; } } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value("page", "sess_mactrack_view_device_current_page", "1"); load_current_session_value("filter", "sess_mactrack_view_device_filter", ""); load_current_session_value("site_id", "sess_mactrack_view_device_site_id", "-1"); load_current_session_value("type_id", "sess_mactrack_view_device_type_id", "-1"); load_current_session_value("device_type_id", "sess_mactrack_view_device_device_type_id", "-1"); load_current_session_value("status", "sess_mactrack_view_device_status", "-1"); load_current_session_value("rows", "sess_mactrack_view_device_rows", "-1"); load_current_session_value("sort_column", "sess_mactrack_view_device_sort_column", "site_name"); load_current_session_value("sort_direction", "sess_mactrack_view_device_sort_direction", "ASC"); if ($_REQUEST["rows"] == -1) { $row_limit = read_config_option("num_rows_mactrack"); }elseif ($_REQUEST["rows"] == -2) { $row_limit = 999999; }else{ $row_limit = $_REQUEST["rows"]; } if (defined("URL_PATH")) { $webroot = URL_PATH; }else{ $webroot = $config["url_path"]; } mactrack_tabs(); mactrack_view_header(); mactrack_device_filter2(); mactrack_view_footer(); html_start_box("", "100%", $colors["header"], "3", "center", ""); $sql_where = ""; $devices = mactrack_view_get_device_records($sql_where, $row_limit); $total_rows = db_fetch_cell("SELECT COUNT(mac_track_devices.device_id) FROM mac_track_sites RIGHT JOIN mac_track_devices ON mac_track_devices.site_id = mac_track_sites.site_id LEFT JOIN mac_track_device_types ON (mac_track_device_types.device_type_id=mac_track_devices.device_type_id) $sql_where"); /* generate page list */ $url_page_select = get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, "mactrack_view_devices.php?report=devices"); if (isset($config["base_path"])) { if ($total_rows > 0) { $nav = "<tr bgcolor='#" . $colors["header"] . "'> <td colspan='13'> <table width='100%' cellspacing='0' cellpadding='0' border='0'> <tr> <td align='left' class='textHeaderDark'> <strong><< "; if ($_REQUEST["page"] > 1) { $nav .= "<a class='linkOverDark' href='mactrack_view_devices.php?report=devices&page=" . ($_REQUEST["page"]-1) . "'>"; } $nav .= "Previous"; if ($_REQUEST["page"] > 1) { $nav .= "</a>"; } $nav .= "</strong> </td>\n <td align='center' class='textHeaderDark'> Showing Rows " . ($total_rows == 0 ? "None" : (($row_limit*($_REQUEST["page"]-1))+1) . " to " . ((($total_rows < $row_limit) || ($total_rows < ($row_limit*$_REQUEST["page"]))) ? $total_rows : ($row_limit*$_REQUEST["page"])) . " of $total_rows [$url_page_select]") . " </td>\n <td align='right' class='textHeaderDark'> <strong>"; if (($_REQUEST["page"] * $row_limit) < $total_rows) { $nav .= "<a class='linkOverDark' href='mactrack_view_devices.php?report=devices&page=" . ($_REQUEST["page"]+1) . "'>"; } $nav .= "Next"; if (($_REQUEST["page"] * $row_limit) < $total_rows) { $nav .= "</a>"; } $nav .= " >></strong> </td>\n </tr> </table> </td> </tr>\n"; }else{ $nav = "<tr bgcolor='#" . $colors["header"] . "' class='noprint'> <td colspan='22'> <table width='100%' cellspacing='0' cellpadding='0' border='0'> <tr> <td align='center' class='textHeaderDark'> No Rows Found </td>\n </tr> </table> </td> </tr>\n"; } }else{ $nav = html_create_nav($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, 13, "mactrack_view_sites.php"); } print $nav; $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, $_REQUEST["sort_column"], $_REQUEST["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_color($colors["alternate"],$colors["light"],$i); $i++; ?> <td width=100> <?php if (mactrack_authorized(2121)) {?> <a href='<?php print $webroot . "plugins/mactrack/mactrack_devices.php?action=edit&device_id=" . $device['device_id'];?>' title='Edit Device'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/edit_object.png'></a> <?php api_plugin_hook_function('remote_link', $hostinfo); } ?> <?php if ($device["host_id"] > 0) {?> <a href='<?php print $webroot . "plugins/mactrack/mactrack_view_graphs.php?action=preview&report=graphs&style=selective&graph_list=&host_id=" . $device["host_id"] . "&graph_template_id=0&filter=";?>' title='View Graphs'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_graphs.gif'></a> <?php }else{?> <img title='Device Not Mapped to Cacti Device' border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_graphs_disabled.gif'> <?php }?> <a href='<?php print $webroot . "plugins/mactrack/mactrack_view_macs.php?report=macs&reset&device_id=-1&scan_date=3&site_id=" . $_REQUEST["site_id"] . "&device_id=" . $device['device_id'];?>' title='View MAC Addresses'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_macs.gif'></a> <a href='<?php print $webroot . "plugins/mactrack/mactrack_view_interfaces.php?report=interfaces&reset&site=" . $_REQUEST["site_id"] . "&device=" . $device['device_id'];?>' title='View Interfaces'><img border='0' src='<?php print $webroot;?>plugins/mactrack/images/view_interfaces.gif'></a> </td> <td width=150> <?php print "<strong>" . (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $device["device_name"]) : $device["device_name"]) . "</strong>";?> </td> <td><?php print (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $device["site_name"]) : $device["site_name"]);?></td> <td><?php print get_colored_device_status(($device["disabled"] == "on" ? true : false), $device["snmp_status"]);?></td> <td><?php print (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $device["hostname"]) : $device["hostname"]);?></td> <td><?php print $device["device_type"];?></td> <td><?php print ($device["scan_type"] == "1" ? "N/A" : $device["ips_total"]);?></td> <td><?php print ($device["scan_type"] == "3" ? "N/A" : $device["ports_total"]);?></td> <td><?php print ($device["scan_type"] == "3" ? "N/A" : $device["ports_active"]);?></td> <td><?php print ($device["scan_type"] == "3" ? "N/A" : $device["ports_trunk"]);?></td> <td><?php print ($device["scan_type"] == "3" ? "N/A" : $device["macs_active"]);?></td> <td><?php print ($device["scan_type"] == "3" ? "N/A" : $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>"; } print $nav; html_end_box(false); mactrack_display_stats(); }
function utilities_view_poller_cache() { global $colors, $poller_actions; define("MAX_DISPLAY_PAGES", 21); /* ================= input validation ================= */ input_validate_input_number(get_request_var_request("host_id")); input_validate_input_number(get_request_var_request("page")); input_validate_input_number(get_request_var_request("poller_action")); /* ==================================================== */ /* clean up search filter */ if (isset($_REQUEST["filter"])) { $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter")); } /* clean up sort_column */ if (isset($_REQUEST["sort_column"])) { $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); } /* clean up sort direction */ if (isset($_REQUEST["sort_direction"])) { $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); } /* if the user pushed the 'clear' button */ if (isset($_REQUEST["clear_x"])) { kill_session_var("sess_poller_current_page"); kill_session_var("sess_poller_host_id"); kill_session_var("sess_poller_poller_action"); kill_session_var("sess_poller_filter"); unset($_REQUEST["page"]); unset($_REQUEST["filter"]); unset($_REQUEST["host_id"]); unset($_REQUEST["poller_action"]); } if ((!empty($_SESSION["sess_poller_action"])) && (!empty($_REQUEST["poller_action"]))) { if ($_SESSION["sess_poller_poller_action"] != $_REQUEST["poller_action"]) { $_REQUEST["page"] = 1; } } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value("page", "sess_poller_current_page", "1"); load_current_session_value("host_id", "sess_poller_host_id", "-1"); load_current_session_value("poller_action", "sess_poller_poller_action", "-1"); load_current_session_value("filter", "sess_poller_filter", ""); load_current_session_value("sort_column", "sess_poller_sort_column", "data_template_data.name_cache"); load_current_session_value("sort_direction", "sess_poller_sort_direction", "ASC"); $_REQUEST['page_referrer'] = 'view_poller_cache'; load_current_session_value('page_referrer', 'page_referrer', 'view_poller_cache'); ?> <script type="text/javascript"> <!-- function applyPItemFilterChange(objForm) { strURL = '?poller_action=' + objForm.poller_action.value; strURL = strURL + '&host_id=' + objForm.host_id.value; strURL = strURL + '&filter=' + objForm.filter.value; strURL = strURL + '&action=view_poller_cache'; document.location = strURL; } --> </script> <?php html_start_box("<strong>Poller Cache Items</strong>", "100%", $colors["header"], "3", "center", ""); ?> <tr bgcolor="<?php print $colors["panel"];?>"> <form name="form_pollercache"> <td> <table cellpadding="0" cellspacing="0"> <tr> <td nowrap style='white-space: nowrap;' width="50"> Host: </td> <td width="1"> <select name="host_id" onChange="applyPItemFilterChange(document.form_pollercache)"> <option value="-1"<?php if (get_request_var_request("host_id") == "-1") {?> selected<?php }?>>Any</option> <option value="0"<?php if (get_request_var_request("host_id") == "0") {?> selected<?php }?>>None</option> <?php $hosts = db_fetch_assoc("select id,description,hostname from host order by description"); if (sizeof($hosts) > 0) { foreach ($hosts as $host) { print "<option value='" . $host["id"] . "'"; if (get_request_var_request("host_id") == $host["id"]) { print " selected"; } print ">" . $host["description"] . "</option>\n"; } } ?> </select> </td> <td nowrap style='white-space: nowrap;' width="50"> Action: </td> <td width="1"> <select name="poller_action" onChange="applyPItemFilterChange(document.form_pollercache)"> <option value="-1"<?php if (get_request_var_request("poller_action") == '-1') {?> selected<?php }?>>Any</option> <option value="0"<?php if (get_request_var_request("poller_action") == '0') {?> selected<?php }?>>SNMP</option> <option value="1"<?php if (get_request_var_request("poller_action") == '1') {?> selected<?php }?>>Script</option> <option value="2"<?php if (get_request_var_request("poller_action") == '2') {?> selected<?php }?>>Script Server</option> </select> </td> <td nowrap style='white-space: nowrap;' width="50"> Search: </td> <td width="1"> <input type="text" name="filter" size="40" value="<?php print get_request_var_request("filter");?>"> </td> <td nowrap style='white-space: nowrap;'> <input type="image" src="images/button_go.gif" name="go" alt="Go" border="0" align="absmiddle"> <input type="image" src="images/button_clear.gif" name="clear" alt="Clear" border="0" align="absmiddle"> </td> </tr> </table> </td> <input type='hidden' name='page' value='1'> <input type='hidden' name='action' value='view_poller_cache'> </form> </tr> <?php html_end_box(); /* form the 'where' clause for our main sql query */ $sql_where = "WHERE poller_item.local_data_id=data_template_data.local_data_id"; if (get_request_var_request("poller_action") != "-1") { $sql_where .= " AND poller_item.action='" . get_request_var_request("poller_action") . "'"; } if (get_request_var_request("host_id") == "-1") { /* Show all items */ }elseif (get_request_var_request("host_id") == "0") { $sql_where .= " AND poller_item.host_id=0"; }elseif (!empty($_REQUEST["host_id"])) { $sql_where .= " AND poller_item.host_id=" . get_request_var_request("host_id"); } if (strlen(get_request_var_request("filter"))) { $sql_where .= " AND (data_template_data.name_cache LIKE '%%" . get_request_var_request("filter") . "%%' OR host.description LIKE '%%" . get_request_var_request("filter") . "%%' OR poller_item.arg1 LIKE '%%" . get_request_var_request("filter") . "%%' OR poller_item.hostname LIKE '%%" . get_request_var_request("filter") . "%%' OR poller_item.rrd_path LIKE '%%" . get_request_var_request("filter") . "%%')"; } html_start_box("", "100%", $colors["header"], "3", "center", ""); $total_rows = db_fetch_cell("SELECT COUNT(*) FROM data_template_data RIGHT JOIN (poller_item LEFT JOIN host ON poller_item.host_id=host.id) ON data_template_data.local_data_id=poller_item.local_data_id $sql_where"); $poller_sql = "SELECT poller_item.*, data_template_data.name_cache, host.description FROM data_template_data RIGHT JOIN (poller_item LEFT JOIN host ON poller_item.host_id=host.id) ON data_template_data.local_data_id=poller_item.local_data_id $sql_where ORDER BY " . get_request_var_request("sort_column") . " " . get_request_var_request("sort_direction") . ", action ASC LIMIT " . (read_config_option("num_rows_data_source")*(get_request_var_request("page")-1)) . "," . read_config_option("num_rows_data_source"); // print $poller_sql; $poller_cache = db_fetch_assoc($poller_sql); /* generate page list */ $url_page_select = get_page_list(get_request_var_request("page"), MAX_DISPLAY_PAGES, read_config_option("num_rows_data_source"), $total_rows, "utilities.php?action=view_poller_cache&host_id=" . get_request_var_request("host_id") . "&poller_action=" . get_request_var_request("poller_action")); $nav = "<tr bgcolor='#" . $colors["header"] . "'> <td colspan='7'> <table width='100%' cellspacing='0' cellpadding='0' border='0'> <tr> <td align='left' class='textHeaderDark'> <strong><< "; if (get_request_var_request("page") > 1) { $nav .= "<a class='linkOverDark' href='utilities.php?action=view_poller_cache&host_id=" . get_request_var_request("host_id") . "&poller_action=" . get_request_var_request("poller_action") . "&page=" . (get_request_var_request("page")-1) . "'>"; } $nav .= "Previous"; if (get_request_var_request("page") > 1) { $nav .= "</a>"; } $nav .= "</strong> </td>\n <td align='center' class='textHeaderDark'> Showing Rows " . ((read_config_option("num_rows_data_source")*(get_request_var_request("page")-1))+1) . " to " . ((($total_rows < read_config_option("num_rows_data_source")) || ($total_rows < (read_config_option("num_rows_data_source")*get_request_var_request("page")))) ? $total_rows : (read_config_option("num_rows_data_source")*get_request_var_request("page"))) . " of $total_rows [$url_page_select] </td>\n <td align='right' class='textHeaderDark'> <strong>"; if ((get_request_var_request("page") * read_config_option("num_rows_data_source")) < $total_rows) { $nav .= "<a class='linkOverDark' href='utilities.php?action=view_poller_cache&host_id=" . get_request_var_request("host_id") . "&poller_action=" . get_request_var_request("poller_action") . "&page=" . (get_request_var_request("page")+1) . "'>"; } $nav .= "Next"; if ((get_request_var_request("page") * read_config_option("num_rows_data_source")) < $total_rows) { $nav .= "</a>"; } $nav .= " >></strong> </td>\n </tr> </table> </td> </tr>\n"; print $nav; $display_text = array( "data_template_data.name_cache" => array("Data Source Name", "ASC"), "" => array("Details", "ASC")); html_header_sort($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction")); $i = 0; if (sizeof($poller_cache) > 0) { foreach ($poller_cache as $item) { form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i); ?> <td width="375"> <a class="linkEditMain" href="data_sources.php?action=ds_edit&id=<?php print $item["local_data_id"];?>"><?php print eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $item["name_cache"]);?></a> </td> <td> <?php if ($item["action"] == 0) { if ($item["snmp_version"] != 3) { $details = "SNMP Version: " . $item["snmp_version"] . ", " . "Community: " . $item["snmp_community"] . ", " . "OID: " . (strlen(get_request_var_request("filter")) ? (eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $item["arg1"])) : $item["arg1"]); }else{ $details = "SNMP Version: " . $item["snmp_version"] . ", " . "User: "******"snmp_username"] . ", OID: " . $item["arg1"]; } }elseif ($item["action"] == 1) { $details = "Script: " . (strlen(get_request_var_request("filter")) ? (eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $item["arg1"])) : $item["arg1"]); }else{ $details = "Script Server: " . (strlen(get_request_var_request("filter")) ? (eregi_replace("(" . preg_quote(get_request_var_request("filter")) . ")", "<span style='background-color: #F8D93D;'>\\1</span>", $item["arg1"])) : $item["arg1"]); } print $details; ?> </td> </tr> <?php form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i); ?> <td> </td> <td> RRD: <?php print $item["rrd_path"];?> </td> </tr> <?php $i++; } } html_end_box(); }
function thold_show_log() { global $config, $colors, $item_rows; $thold_log = array('Alarm' => 'F21924', 'Warning' => 'FB4A14', 'Re-Trigger' => 'FF7A30', 'Alert Trigger' => 'FAFD9E', 'Warn Trigger' => 'FAFD9E', 'Restoral' => 'CCFFCC', 'Restore' => 'CDCFC4', 'Alarm2Warn' => 'FACD6E'); $thold_status = array('0' => 'Restore', '1' => 'Alert Trigger', '2' => 'Re-Trigger', '3' => 'Warning', '4' => 'Alarm', '5' => 'Restoral', '6' => 'Warn Trigger', '7' => 'Alarm-Warn'); $types = array('High/Low', 'Baseline Deviation', 'Time Based'); /* ================= input validation ================= */ input_validate_input_number(get_request_var_request("threshold_id")); input_validate_input_number(get_request_var_request("host_id")); input_validate_input_number(get_request_var_request("page")); input_validate_input_number(get_request_var_request("status")); input_validate_input_number(get_request_var_request("rows")); /* ==================================================== */ /* clean up search string */ if (isset($_REQUEST["filter"])) { $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter")); } /* clean up sort_column */ if (isset($_REQUEST["sort_column"])) { $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); } /* clean up search string */ if (isset($_REQUEST["sort_direction"])) { $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); } /* if the user pushed the 'clear' button */ if (isset($_REQUEST["clear"])) { kill_session_var("sess_thold_log_current_page"); kill_session_var("sess_thold_log_filter"); kill_session_var("sess_thold_log_threshold_id"); kill_session_var("sess_thold_log_host_id"); kill_session_var("sess_thold_log_status"); kill_session_var("sess_thold_log_rows"); kill_session_var("sess_thold_log_sort_column"); kill_session_var("sess_thold_log_sort_direction"); unset($_REQUEST["page"]); unset($_REQUEST["filter"]); unset($_REQUEST["host_id"]); unset($_REQUEST["threshold_id"]); unset($_REQUEST["status"]); unset($_REQUEST["rows"]); unset($_REQUEST["sort_column"]); unset($_REQUEST["sort_direction"]); } else { /* if any of the settings changed, reset the page number */ $changed = 0; $changed += thold_request_check_changed('filter', 'sess_thold_log_filter'); $changed += thold_request_check_changed('threshold_id', 'sess_thold_log_threshold_id'); $changed += thold_request_check_changed('host_id', 'sess_thold_log_host_id'); $changed += thold_request_check_changed('status', 'sess_thold_log_status'); $changed += thold_request_check_changed('rows', 'sess_thold_log_rows'); $changed += thold_request_check_changed('sort_column', 'sess_thold_log_sort_column'); $changed += thold_request_check_changed('sort_direction', 'sess_thold_log_sort_direction'); if ($changed) { $_REQUEST['page'] = '1'; } } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value("page", "sess_thold_log_current_page", "1"); load_current_session_value("filter", "sess_thold_log_filter", ""); load_current_session_value("threshold_id", "sess_thold_log_threshold_id", "-1"); load_current_session_value("host_id", "sess_thold_log_host_id", "-1"); load_current_session_value("status", "sess_thold_log_status", "-1"); load_current_session_value("rows", "sess_thold_log_rows", read_config_option("num_rows_device")); load_current_session_value("sort_column", "sess_thold_log_sort_column", "time"); load_current_session_value("sort_direction", "sess_thold_log_sort_direction", "DESC"); /* if the number of rows is -1, set it to the default */ if ($_REQUEST["rows"] == -1) { $_REQUEST["rows"] = read_config_option("num_rows_device"); } ?> <script type="text/javascript"> <!-- function filterChange(objForm) { strURL = '?tab=log&status=' + objForm.status.value; strURL = strURL + '&threshold_id=' + objForm.threshold_id.value; strURL = strURL + '&host_id=' + objForm.host_id.value; strURL = strURL + '&rows=' + objForm.rows.value; strURL = strURL + '&filter=' + objForm.filter.value; document.location = strURL; } --> </script> <?php html_start_box("<strong>Threshold Log</strong> [last 30 days]", "100%", $colors["header"], "3", "center", ""); form_thold_log_filter(); html_end_box(); $sql_where = ''; if ($_REQUEST["host_id"] == "-1") { /* Show all items */ } elseif ($_REQUEST["host_id"] == "0") { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " host.id IS NULL"; } elseif (!empty($_REQUEST["host_id"])) { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " plugin_thold_log.host_id=" . $_REQUEST["host_id"]; } if ($_REQUEST["threshold_id"] == "-1") { /* Show all items */ } elseif ($_REQUEST["threshold_id"] == "0") { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " thold_data.id IS NULL"; } elseif (!empty($_REQUEST["threshold_id"])) { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " plugin_thold_log.threshold_id=" . $_REQUEST["threshold_id"]; } if ($_REQUEST["status"] == "-1") { /* Show all items */ } else { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " plugin_thold_log.status=" . $_REQUEST["status"]; } if (strlen($_REQUEST["filter"])) { $sql_where .= (strlen($sql_where) ? " AND" : "WHERE") . " plugin_thold_log.description LIKE '%" . $_REQUEST["filter"] . "%'"; } html_start_box("", "100%", $colors["header"], "3", "center", ""); $sortby = $_REQUEST["sort_column"]; $current_user = db_fetch_row('SELECT * FROM user_auth WHERE id=' . $_SESSION['sess_user_id']); $sql_where .= ' AND ' . get_graph_permissions_sql($current_user['policy_graphs'], $current_user['policy_hosts'], $current_user['policy_graph_templates']); $total_rows = db_fetch_cell("SELECT\r\n\t\tCOUNT(*)\r\n\t\tFROM plugin_thold_log\r\n\t\tLEFT JOIN host ON plugin_thold_log.host_id=host.id\r\n\t\tLEFT JOIN thold_data ON plugin_thold_log.threshold_id=thold_data.id\r\n\t\tLEFT JOIN graph_templates_graph AS gtg ON plugin_thold_log.graph_id=gtg.local_graph_id\r\n\t\tLEFT JOIN user_auth_perms\r\n\t\tON (host.id=user_auth_perms.item_id\r\n\t\tAND user_auth_perms.type=3\r\n\t\tAND user_auth_perms.user_id=" . $_SESSION['sess_user_id'] . ")\r\n\t\t{$sql_where}"); $sql_query = "SELECT plugin_thold_log.*, host.description AS hdescription, thold_data.name AS name, gtg.title_cache\r\n\t\tFROM plugin_thold_log\r\n\t\tLEFT JOIN host ON plugin_thold_log.host_id=host.id\r\n\t\tLEFT JOIN thold_data ON plugin_thold_log.threshold_id=thold_data.id\r\n\t\tLEFT JOIN graph_templates_graph AS gtg ON plugin_thold_log.graph_id=gtg.local_graph_id\r\n\t\tLEFT JOIN user_auth_perms\r\n\t\tON (host.id=user_auth_perms.item_id\r\n\t\tAND user_auth_perms.type=3\r\n\t\tAND user_auth_perms.user_id=" . $_SESSION['sess_user_id'] . ")\r\n\t\t{$sql_where}\r\n\t\tORDER BY " . $sortby . " " . $_REQUEST["sort_direction"] . "\r\n\t\tLIMIT " . $_REQUEST["rows"] * ($_REQUEST["page"] - 1) . "," . $_REQUEST["rows"]; //print $sql_query; $logs = db_fetch_assoc($sql_query); /* generate page list */ $url_page_select = get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, $_REQUEST["rows"], $total_rows, "thold_graph.php?tab=log"); if ($total_rows) { $nav = "<tr bgcolor='#" . $colors["header"] . "'>\r\n\t\t\t\t<td colspan='11'>\r\n\t\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td align='left' class='textHeaderDark'>\r\n\t\t\t\t\t\t\t\t<strong><< "; if ($_REQUEST["page"] > 1) { $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("thold_graph.php?tab=log&page=" . ($_REQUEST["page"] - 1)) . "'>"; } $nav .= "Previous"; if ($_REQUEST["page"] > 1) { $nav .= "</a>"; } $nav .= "</strong>\r\n\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\r\n\t\t\t\t\t\t\t\tShowing Rows " . ($_REQUEST["rows"] * ($_REQUEST["page"] - 1) + 1) . " to " . ($total_rows < read_config_option("num_rows_device") || $total_rows < $_REQUEST["rows"] * $_REQUEST["page"] ? $total_rows : $_REQUEST["rows"] * $_REQUEST["page"]) . " of {$total_rows} [{$url_page_select}]\r\n\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t\t<td align='right' class='textHeaderDark'>\r\n\t\t\t\t\t\t\t\t<strong>"; if ($_REQUEST["page"] * $_REQUEST["rows"] < $total_rows) { $nav .= "<a class='linkOverDark' href='" . htmlspecialchars("thold_graph.php?tab=log&page=" . ($_REQUEST["page"] + 1)) . "'>"; } $nav .= "Next"; if ($_REQUEST["page"] * $_REQUEST["rows"] < $total_rows) { $nav .= "</a>"; } $nav .= " >></strong>\r\n\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</table>\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\n"; } else { $nav = "<tr bgcolor='#" . $colors["header"] . "'>\r\n\t\t\t\t<td colspan='11'>\r\n\t\t\t\t\t<table width='100%' cellspacing='0' cellpadding='0' border='0'>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td align='center' class='textHeaderDark'>\r\n\t\t\t\t\t\t\t\tNo Rows Found\r\n\t\t\t\t\t\t\t</td>\n\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</table>\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\n"; } print $nav; $display_text = array("hdescription" => array("<br>Host", "ASC"), "name" => array("<br>Threshold", "ASC"), "time" => array("<br>Time", "ASC"), "threshold_value" => array("Alarm<br>Value", "ASC"), "current" => array("Current<br>Value", "ASC"), "status" => array("<br>Status", "DESC"), "type" => array("<br>Type", "DESC"), "description" => array("<br>Event Description", "ASC")); html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]); $i = 0; if (sizeof($logs)) { foreach ($logs as $l) { ?> <tr style='background-color:#<?php print $thold_log[$thold_status[$l['status']]]; ?> '> <td style='white-space:nowrap;'><?php print $l["hdescription"]; ?> </td> <td style='white-space:nowrap;'><?php print $l["name"]; ?> </td> <td style='white-space:nowrap;'><?php print date("Y-m-d H:i:s", $l["time"]); ?> </td> <td><?php print $l["threshold_value"] != '' ? thold_format_number($l["threshold_value"]) : 'N/A'; ?> </td> <td><?php print $l["current"] != '' ? thold_format_number($l["current"]) : 'N/A'; ?> </td> <td nowrap style='white-space:nowrap;'><?php print $thold_status[$l["status"]]; ?> </td> <td nowrap style='white-space:nowrap;'><?php print $types[$l["type"]]; ?> </td> <td style='white-space:nowrap;'><?php print strlen($l["description"]) ? $l["description"] : "Restoral Event"; ?> </td> <?php form_end_row(); } } else { print "<tr><td><em>No Threshold Logs Found</em></td></tr>"; } /* put the nav bar on the bottom as well */ print $nav; html_end_box(false); log_legend(); //thold_display_rusage(); }
function utilities_view_poller_cache() { global $poller_actions, $item_rows; define('MAX_DISPLAY_PAGES', 21); /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('host_id')); input_validate_input_number(get_request_var_request('page')); input_validate_input_number(get_request_var_request('rows')); input_validate_input_number(get_request_var_request('poller_action')); /* ==================================================== */ /* clean up search filter */ if (isset($_REQUEST['filter'])) { $_REQUEST['filter'] = sanitize_search_string(get_request_var('filter')); } /* clean up sort_column */ if (isset($_REQUEST['sort_column'])) { $_REQUEST['sort_column'] = sanitize_search_string(get_request_var('sort_column')); } /* clean up sort direction */ if (isset($_REQUEST['sort_direction'])) { $_REQUEST['sort_direction'] = sanitize_search_string(get_request_var('sort_direction')); } /* if the user pushed the 'clear' button */ if (isset($_REQUEST['clear_x'])) { kill_session_var('sess_poller_current_page'); kill_session_var('sess_poller_host_id'); kill_session_var('sess_poller_poller_action'); kill_session_var('sess_poller_filter'); kill_session_var('sess_default_rows'); unset($_REQUEST['page']); unset($_REQUEST['filter']); unset($_REQUEST['rows']); unset($_REQUEST['host_id']); unset($_REQUEST['poller_action']); } if (!empty($_SESSION['sess_poller_action']) && !empty($_REQUEST['poller_action'])) { if ($_SESSION['sess_poller_poller_action'] != $_REQUEST['poller_action']) { $_REQUEST['page'] = 1; } } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value('page', 'sess_poller_current_page', '1'); load_current_session_value('host_id', 'sess_poller_host_id', '-1'); load_current_session_value('poller_action', 'sess_poller_poller_action', '-1'); load_current_session_value('filter', 'sess_poller_filter', ''); load_current_session_value('sort_column', 'sess_poller_sort_column', 'data_template_data.name_cache'); load_current_session_value('sort_direction', 'sess_poller_sort_direction', 'ASC'); load_current_session_value('rows', 'sess_default_rows', read_config_option('num_rows_table')); $_REQUEST['page_referrer'] = 'view_poller_cache'; load_current_session_value('page_referrer', 'page_referrer', 'view_poller_cache'); ?> <script type="text/javascript"> function applyFilter() { strURL = '?poller_action=' + $('#poller_action').val(); strURL = strURL + '&host_id=' + $('#host_id').val(); strURL = strURL + '&filter=' + $('#filter').val(); strURL = strURL + '&rows=' + $('#rows').val(); strURL = strURL + '&page=' + $('#page').val(); strURL = strURL + '&action=view_poller_cache'; strURL = strURL + '&header=false'; $.get(strURL, function(data) { $('#main').html(data); applySkin(); }); } function clearFilter() { strURL = '?clear_x=1&header=false'; $.get(strURL, function(data) { $('#main').html(data); applySkin(); }); } $(function() { $('#refresh').click(function() { applyFilter(); }); $('#clear').click(function() { clearFilter(); }); $('#form_pollercache').submit(function(event) { event.preventDefault(); applyFilter(); }); }); </script> <?php html_start_box('<strong>Poller Cache Items</strong>', '100%', '', '3', 'center', ''); ?> <tr class='even noprint'> <td> <form id="form_pollercache" action="utilities.php"> <table cellpadding="2" cellspacing="0"> <tr> <td width="50"> Device </td> <td> <select id='host_id' name="host_id" onChange="applyFilter()"> <option value="-1"<?php if (get_request_var_request('host_id') == '-1') { ?> selected<?php } ?> >Any</option> <option value="0"<?php if (get_request_var_request('host_id') == '0') { ?> selected<?php } ?> >None</option> <?php $hosts = db_fetch_assoc('SELECT id, description, hostname FROM host ORDER BY description'); if (sizeof($hosts) > 0) { foreach ($hosts as $host) { print "<option value='" . $host['id'] . "'"; if (get_request_var_request('host_id') == $host['id']) { print ' selected'; } print '>' . $host['description'] . "</option>\n"; } } ?> </select> </td> <td> Action </td> <td> <select id='poller_action' name="poller_action" onChange="applyFilter()"> <option value="-1"<?php if (get_request_var_request('poller_action') == '-1') { ?> selected<?php } ?> >Any</option> <option value="0"<?php if (get_request_var_request('poller_action') == '0') { ?> selected<?php } ?> >SNMP</option> <option value="1"<?php if (get_request_var_request('poller_action') == '1') { ?> selected<?php } ?> >Script</option> <option value="2"<?php if (get_request_var_request('poller_action') == '2') { ?> selected<?php } ?> >Script Server</option> </select> </td> <td> Rows </td> <td> <select id='rows' name="rows" onChange="applyFilter()"> <?php if (sizeof($item_rows) > 0) { foreach ($item_rows as $key => $value) { print "<option value='" . $key . "'"; if (get_request_var_request('rows') == $key) { print ' selected'; } print '>' . htmlspecialchars($value) . "</option>\n"; } } ?> </select> </td> <td> <input type="button" id='refresh' name="go" value="Go" title="Set/Refresh Filters"> </td> <td> <input type="button" id='clear' name="clear_x" value="Clear" title="Clear Filters"> </td> </tr> </table> <table cellpadding='2' cellspacing='2' border='0'> <tr> <td width='50'> Search </td> <td> <input id='filter' type="text" name="filter" size="25" value="<?php print htmlspecialchars(get_request_var_request('filter')); ?> "> </td> </tr> </table> <input type='hidden' id='page' name='page' value='<?php print $_REQUEST['page']; ?> '> <input type='hidden' name='action' value='view_poller_cache'> </form> </td> </tr> <?php html_end_box(); /* form the 'where' clause for our main sql query */ $sql_where = 'WHERE poller_item.local_data_id = data_template_data.local_data_id'; if (get_request_var_request('poller_action') != '-1') { $sql_where .= " AND poller_item.action='" . get_request_var_request('poller_action') . "'"; } if (get_request_var_request('host_id') == '-1') { /* Show all items */ } elseif (get_request_var_request('host_id') == '0') { $sql_where .= ' AND poller_item.host_id = 0'; } elseif (!empty($_REQUEST['host_id'])) { $sql_where .= ' AND poller_item.host_id = ' . get_request_var_request('host_id'); } if (strlen(get_request_var_request('filter'))) { $sql_where .= " AND (data_template_data.name_cache LIKE '%%" . get_request_var_request('filter') . "%%'\n\t\t\tOR host.description LIKE '%%" . get_request_var_request('filter') . "%%'\n\t\t\tOR poller_item.arg1 LIKE '%%" . get_request_var_request('filter') . "%%'\n\t\t\tOR poller_item.hostname LIKE '%%" . get_request_var_request('filter') . "%%'\n\t\t\tOR poller_item.rrd_path LIKE '%%" . get_request_var_request('filter') . "%%')"; } html_start_box('', '100%', '', '3', 'center', ''); $total_rows = db_fetch_cell("SELECT\n\t\tCOUNT(*)\n\t\tFROM data_template_data\n\t\tRIGHT JOIN (poller_item\n\t\tLEFT JOIN host\n\t\tON poller_item.host_id = host.id)\n\t\tON data_template_data.local_data_id = poller_item.local_data_id\n\t\t{$sql_where}"); $poller_sql = "SELECT\n\t\tpoller_item.*,\n\t\tdata_template_data.name_cache,\n\t\thost.description\n\t\tFROM data_template_data\n\t\tRIGHT JOIN (poller_item\n\t\tLEFT JOIN host\n\t\tON poller_item.host_id = host.id)\n\t\tON data_template_data.local_data_id = poller_item.local_data_id\n\t\t{$sql_where}\n\t\tORDER BY " . get_request_var_request('sort_column') . ' ' . get_request_var_request('sort_direction') . ', action ASC LIMIT ' . get_request_var_request('rows') * (get_request_var_request('page') - 1) . ',' . get_request_var_request('rows'); $poller_cache = db_fetch_assoc($poller_sql); $nav = html_nav_bar('utilities.php?action=view_poller_cache&host_id=' . get_request_var_request('host_id') . '&poller_action=' . get_request_var_request('poller_action'), MAX_DISPLAY_PAGES, get_request_var_request('page'), get_request_var_request('rows'), $total_rows, 3, 'Entries', 'page', 'main'); print $nav; $display_text = array('data_template_data.name_cache' => array('Data Source Name', 'ASC'), 'nosort' => array('Details', 'ASC')); html_header_sort($display_text, get_request_var_request('sort_column'), get_request_var_request('sort_direction')); $i = 0; if (sizeof($poller_cache) > 0) { foreach ($poller_cache as $item) { if ($i % 2 == 0) { $class = 'odd'; } else { $class = 'even'; } print "<tr class='{$class}'>\n"; ?> <td width="375"> <a class="linkEditMain" href="<?php print htmlspecialchars('data_sources.php?action=ds_edit&id=' . $item['local_data_id']); ?> "><?php print strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter'), '/') . ')/i', "<span class='filteredValue'>\\1</span>", $item['name_cache']) : $item['name_cache']; ?> </a> </td> <td> <?php if ($item['action'] == 0) { if ($item['snmp_version'] != 3) { $details = 'SNMP Version: ' . $item['snmp_version'] . ', ' . 'Community: ' . $item['snmp_community'] . ', ' . 'OID: ' . (strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter'), '/') . ')/i', "<span class='filteredValue'>\\1</span>", $item['arg1']) : $item['arg1']); } else { $details = 'SNMP Version: ' . $item['snmp_version'] . ', ' . 'User: '******'snmp_username'] . ', OID: ' . $item['arg1']; } } elseif ($item['action'] == 1) { $details = 'Script: ' . (strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter'), '/') . ')/i', "<span class='filteredValue'>\\1</span>", $item['arg1']) : $item['arg1']); } else { $details = 'Script Server: ' . (strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter'), '/') . ')/i', "<span class='filteredValue'>\\1</span>", $item['arg1']) : $item['arg1']); } print $details; ?> </td> </tr> <?php print "<tr class='{$class}'>\n"; ?> <td> </td> <td> RRD: <?php print $item['rrd_path']; ?> </td> </tr> <?php $i++; } } print $nav; html_end_box(); }
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_site() { global $site_actions, $config, $item_rows; mactrack_site_validate_req_vars(); if (get_request_var('rows') == -1) { $row_limit = read_config_option('num_rows_table'); } elseif (get_request_var('rows') == -2) { $row_limit = 999999; } else { $row_limit = get_request_var('rows'); } html_start_box(__('MacTrack Site Filters'), '100%', '', '3', 'center', 'mactrack_sites.php?action=edit'); mactrack_site_filter(); html_end_box(); $sql_where = ''; $sites = mactrack_site_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 = db_fetch_cell("SELECT count(*)\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"); } if (get_request_var('detail') == 'false') { $nav = html_nav_bar('mactrack_sites.php?filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_filter_request_var('page'), $row_limit, $total_rows, 9, __('Sites')); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array('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_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction')); $i = 0; if (sizeof($sites)) { foreach ($sites as $site) { form_alternate_row('line' . $site['site_id'], true); form_selectable_cell("<a class='linkEditMain' href='mactrack_sites.php?action=edit&site_id=" . $site['site_id'] . "'>" . (get_request_var('filter') != '' ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", $site['site_name']) : $site['site_name']) . '</a>', $site['site_id']); form_selectable_cell(number_format_i18n($site['total_devices']), $site['site_id']); form_selectable_cell(number_format_i18n($site['total_ips']), $site['site_id']); form_selectable_cell(number_format_i18n($site['total_user_ports']), $site['site_id']); form_selectable_cell(number_format_i18n($site['total_oper_ports']), $site['site_id']); form_selectable_cell(number_format_i18n($site['total_macs']), $site['site_id']); form_selectable_cell($site['total_device_errors'], $site['site_id']); form_checkbox_cell($site['site_name'], $site['site_id']); form_end_row(); } } else { print '<tr><td><em>' . __('No MacTrack Sites') . '</em></td></tr>'; } html_end_box(false); if (sizeof($sites)) { print $nav; } } else { $nav = html_nav_bar('mactrack_sites.php?filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_filter_request_var('page'), $row_limit, $total_rows, 10, __('Sites')); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array('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=200> <a class='linkEditMain' href='mactrack_sites.php?action=edit&site_id=<?php print $site['site_id']; ?> '><?php print get_request_var('filter') != '' ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", $site['site_name']) : $site['site_name']; ?> </a> </td> <td><?php print get_request_var('filter') != '' ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", $site['vendor']) : $site['vendor']; ?> </td> <td><?php print get_request_var('filter') != '' ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", $site['description']) : $site['description']; ?> </td> <td><?php print number_format_i18n($site['total_devices']); ?> </td> <td><?php print number_format_i18n($site['sum_ips_total']); ?> </td> <td><?php print number_format_i18n($site['sum_ports_total']); ?> </td> <td><?php print number_format_i18n($site['sum_ports_active']); ?> </td> <td><?php print number_format_i18n($site['sum_ports_trunk']); ?> </td> <td><?php print number_format_i18n($site['sum_macs_active']); ?> </td> </tr> <?php } } else { print '<tr><td><em>' . __('No MacTrack Sites') . '</em></td></tr>'; } html_end_box(false); if (sizeof($sites)) { print $nav; } } /* draw the dropdown containing a list of available actions for this form */ if (get_request_var('detail') == 'false') { draw_actions_dropdown($site_actions); } }
function utilities_view_poller_cache() { global $colors, $poller_actions, $item_rows; define("MAX_DISPLAY_PAGES", 21); /* ================= input validation ================= */ input_validate_input_number(get_request_var_request("device_id")); input_validate_input_number(get_request_var_request("page")); input_validate_input_number(get_request_var_request("rows")); input_validate_input_number(get_request_var_request("poller_action")); /* ==================================================== */ /* clean up search filter */ if (isset($_REQUEST["filter"])) { $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter")); } /* clean up sort_column */ if (isset($_REQUEST["sort_column"])) { $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); } /* clean up sort direction */ if (isset($_REQUEST["sort_direction"])) { $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); } /* if the user pushed the 'clear' button */ if (isset($_REQUEST["clear_x"])) { kill_session_var("sess_poller_cache_current_page"); kill_session_var("sess_poller_cache_rows"); kill_session_var("sess_poller_cache_device_id"); kill_session_var("sess_poller_cache_poller_action"); kill_session_var("sess_poller_cache_filter"); unset($_REQUEST["page"]); unset($_REQUEST["rows"]); unset($_REQUEST["filter"]); unset($_REQUEST["device_id"]); unset($_REQUEST["poller_action"]); } if ((!empty($_SESSION["sess_poller_cache_action"])) && (!empty($_REQUEST["poller_action"]))) { if ($_SESSION["sess_poller_cache_poller_action"] != $_REQUEST["poller_action"]) { $_REQUEST["page"] = 1; } } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value("page", "sess_poller_cache_current_page", "1"); load_current_session_value("rows", "sess_poller_cache_rows", "-1"); load_current_session_value("device_id", "sess_poller_cache_device_id", "-1"); load_current_session_value("poller_action", "sess_poller_cache_poller_action", "-1"); load_current_session_value("filter", "sess_poller_cache_filter", ""); load_current_session_value("sort_column", "sess_poller_cache_sort_column", "data_template_data.name_cache"); load_current_session_value("sort_direction", "sess_poller_cache_sort_direction", "ASC"); $_REQUEST['page_referrer'] = 'view_poller_cache'; load_current_session_value('page_referrer', 'page_referrer', 'view_poller_cache'); ?> <script type="text/javascript"> <!-- $().ready(function() { $("#device").autocomplete("./lib/ajax/get_devices_brief.php", { max: 8, highlight: false, scroll: true, scrollHeight: 300 }); $("#device").result(function(event, data, formatted) { if (data) { $(this).parent().find("#device_id").val(data[1]); applyPItemFilterChange(document.form_pollercache); }else{ $(this).parent().find("#device_id").val(0); } }); }); function applyPItemFilterChange(objForm) { if (objForm.device_id.value) { strURL = '?device_id=' + objForm.device_id.value; strURL = strURL + '&filter=' + objForm.filter.value; }else{ strURL = '?filter=' + objForm.filter.value; } strURL = strURL + '&poller_action=' + objForm.poller_action.value; strURL = strURL + '&rows=' + objForm.rows.value; strURL = strURL + '&action=view_poller_cache'; strURL = strURL + '&page=1'; document.location = strURL; } --> </script> <?php html_start_box("<strong>" . __("Poller Cache Items") . "</strong>", "100", $colors["header"], "3", "center", "", true); ?> <tr class='rowAlternate2'> <td> <form name="form_pollercache" action="utilities.php"> <table cellpadding="0" cellspacing="0"> <tr> <td class="nw50"> <?php print __("Host:");?> </td> <td class="w1"> <?php if (isset($_REQUEST["device_id"])) { $hostname = db_fetch_cell("SELECT description as name FROM device WHERE id=".$_REQUEST["device_id"]." ORDER BY description,hostname"); } else { $hostname = ""; } ?> <input class="ac_field" type="text" id="device" size="30" value="<?php print $hostname; ?>"> <input type="hidden" id="device_id"> </td> <td class="nw50"> <?php print __("Action:");?> </td> <td class="w1"> <select name="poller_action" onChange="applyPItemFilterChange(document.form_pollercache)"> <option value="-1"<?php if (get_request_var_request('poller_action') == '-1') {?> selected<?php }?>><?php print __("Any");?></option> <option value="0"<?php if (get_request_var_request('poller_action') == '0') {?> selected<?php }?>><?php print __("SNMP");?></option> <option value="1"<?php if (get_request_var_request('poller_action') == '1') {?> selected<?php }?>><?php print __("Script");?></option> <option value="2"<?php if (get_request_var_request('poller_action') == '2') {?> selected<?php }?>><?php print __("Script Server");?></option> </select> </td> <td class="nw120"> <input type="submit" Value="<?php print __("Go");?>" name="go" align="middle"> <input type="submit" Value="<?php print __("Clear");?>" name="clear_x" align="middle"> </td> </tr> </table> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="nw50"> <?php print __("Search:");?> </td> <td class="w1"> <input type="text" name="filter" size="40" value="<?php print $_REQUEST["filter"];?>"> </td> <td class="nw50"> <?php print __("Rows:");?> </td> <td class="w1"> <select name="rows" onChange="applyPItemFilterChange(document.form_pollercache)"> <option value="-1"<?php if (get_request_var_request("rows") == "-1") {?> selected<?php }?>>Default</option> <?php if (sizeof($item_rows) > 0) { foreach ($item_rows as $key => $value) { print "<option value='" . $key . "'"; if (get_request_var_request("rows") == $key) { print " selected"; } print ">" . $value . "</option>\n"; } } ?> </select> </td> </tr> </table> <div><input type='hidden' name='page' value='1'></div> <div><input type='hidden' name='action' value='view_poller_cache'></div> </form> </td> </tr> <?php html_end_box(false); /* form the 'where' clause for our main sql query */ $sql_where = "WHERE poller_item.local_data_id=data_template_data.local_data_id"; if (get_request_var_request("poller_action") == "-1") { /* Show all items */ }else { $sql_where .= " AND poller_item.action='" . $_REQUEST["poller_action"] . "'"; } if (get_request_var_request("device_id") == "-1") { /* Show all items */ }elseif (get_request_var_request("device_id") == "0") { $sql_where .= " AND poller_item.device_id=0"; }elseif (!empty($_REQUEST["device_id"])) { $sql_where .= " AND poller_item.device_id=" . $_REQUEST["device_id"]; } if (strlen(get_request_var_request("filter"))) { $sql_where .= " AND (data_template_data.name_cache LIKE '%%" . $_REQUEST["filter"] . "%%' OR device.description LIKE '%%" . get_request_var_request("filter") . "%%' OR poller_item.arg1 LIKE '%%" . get_request_var_request("filter") . "%%' OR poller_item.hostname LIKE '%%" . get_request_var_request("filter") . "%%' OR poller_item.rrd_path LIKE '%%" . get_request_var_request("filter") . "%%')"; } html_start_box("", "100", $colors["header"], "0", "center", ""); $total_rows = db_fetch_cell("SELECT COUNT(*) FROM data_template_data RIGHT JOIN (poller_item LEFT JOIN device ON poller_item.device_id=device.id) ON data_template_data.local_data_id=poller_item.local_data_id $sql_where"); if (get_request_var_request("rows") == "-1") { $rows = read_config_option("num_rows_data_source"); }else{ $rows = get_request_var_request("rows"); } $poller_sql = "SELECT poller_item.*, data_template_data.name_cache, device.description FROM data_template_data RIGHT JOIN (poller_item LEFT JOIN device ON poller_item.device_id=device.id) ON data_template_data.local_data_id=poller_item.local_data_id $sql_where ORDER BY " . get_request_var_request("sort_column") . " " . get_request_var_request("sort_direction") . ", action ASC LIMIT " . ($rows*(get_request_var_request("page")-1)) . "," . $rows; // print $poller_sql; $poller_cache = db_fetch_assoc($poller_sql); /* generate page list navigation */ $nav = html_create_nav($_REQUEST["page"], MAX_DISPLAY_PAGES, $rows, $total_rows, 7, "utilities.php?action=view_poller_cache"); print $nav; html_end_box(false); $display_text = array( "data_template_data.name_cache" => array(__("Data Source Name"), "ASC"), "" => array(__("Details"), "ASC")); html_header_sort($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction")); if (sizeof($poller_cache) > 0) { foreach ($poller_cache as $item) { form_alternate_row_color(); ?> <td width="375"> <a class="linkEditMain" href="<?php print htmlspecialchars("data_sources.php?action=ds_edit&id=" . $item["local_data_id"]);?>"><?php print (strlen($_REQUEST["filter"]) ? preg_replace("/(" . preg_quote($_REQUEST["filter"]) . ")/i", "<span class=\"filter\">\\1</span>", $item["name_cache"]) : $item["name_cache"]);?></a> </td> <td> <?php if ($item["action"] == 0) { if ($item["snmp_version"] != 3) { $details = __("SNMP Version:") . " " . $item["snmp_version"] . ", " . __("Community:") . " " . $item["snmp_community"] . ", " . __("OID:") . " " . (strlen(get_request_var_request("filter")) ? (preg_replace("/(" . preg_quote(get_request_var_request("filter")) . ")/i", "<span class=\"filter\">\\1</span>", $item["arg1"])) : $item["arg1"]); }else{ $details = __("SNMP Version:") . " " . $item["snmp_version"] . ", " . __("User:"******" " . $item["snmp_username"] . ", " . __("OID:") . " " . $item["arg1"]; } }elseif ($item["action"] == 1) { $details = __("Script:") . " " . (strlen(get_request_var_request("filter")) ? (preg_replace("/(" . preg_quote(get_request_var_request("filter")) . ")/i", "<span class=\"filter\">\\1</span>", $item["arg1"])) : $item["arg1"]); }else{ $details = __("Script Server:") . " " . (strlen(get_request_var_request("filter")) ? (preg_replace("/(" . preg_quote(get_request_var_request("filter")) . ")/i", "<span class=\"filter\">\\1</span>", $item["arg1"])) : $item["arg1"]); } print $details; ?> </td> <?php form_end_row(); form_alternate_row_color(); ?> <td> </td> <td> RRD: <?php print $item["rrd_path"];?> </td> <?php form_end_row(); } form_end_table(); print $nav; }else{ print "<tr><td><em>" . __("No Records Found") . "</em></td></tr>\n"; } print "</table>\n"; }
function mactrack_view() { global $title, $colors, $mactrack_rows, $config; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request("rows")); input_validate_input_number(get_request_var_request("page")); input_validate_input_number(get_request_var_request("issues")); input_validate_input_number(get_request_var_request("bwusage")); input_validate_input_number(get_request_var_request("device")); input_validate_input_number(get_request_var_request("site")); input_validate_input_number(get_request_var_request("type")); /* ==================================================== */ /* clean up filter */ if (isset($_REQUEST["filter"])) { $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter")); } /* clean up totals */ if (isset($_REQUEST["totals"])) { $_REQUEST["totals"] = sanitize_search_string(get_request_var("totals")); } /* clean up */ if (isset($_REQUEST["sort_column"])) { $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); } /* clean up */ if (isset($_REQUEST["sort_direction"])) { $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); } /* if the user pushed the 'clear' button */ if (isset($_REQUEST["clear_x"]) || isset($_REQUEST["reset"])) { kill_session_var("sess_mactrack_int_current_page"); kill_session_var("sess_mactrack_int_rows"); kill_session_var("sess_mactrack_int_totals"); kill_session_var("sess_mactrack_int_device_id"); kill_session_var("sess_mactrack_int_state"); kill_session_var("sess_mactrack_int_site"); kill_session_var("sess_mactrack_int_device"); kill_session_var("sess_mactrack_int_issues"); kill_session_var("sess_mactrack_int_bwusage"); kill_session_var("sess_mactrack_int_type"); kill_session_var("sess_mactrack_int_period"); kill_session_var("sess_mactrack_int_filter"); kill_session_var("sess_mactrack_int_sort_column"); kill_session_var("sess_mactrack_int_sort_direction"); $_REQUEST["page"] = 1; if (isset($_REQUEST["clear_x"])) { unset($_REQUEST["device_id"]); unset($_REQUEST["totals"]); unset($_REQUEST["state"]); unset($_REQUEST["site"]); unset($_REQUEST["totals"]); unset($_REQUEST["device"]); unset($_REQUEST["issues"]); unset($_REQUEST["bwusage"]); unset($_REQUEST["type"]); unset($_REQUEST["period"]); unset($_REQUEST["filter"]); unset($_REQUEST["rows"]); unset($_REQUEST["sort_column"]); unset($_REQUEST["sort_direction"]); } }else{ /* if any of the settings changed, reset the page number */ $changed = 0; $changed += mactrack_check_changed("device_id", "sess_mactrack_int_device_id"); $changed += mactrack_check_changed("site", "sess_mactrack_int_site"); $changed += mactrack_check_changed("totals", "sess_mactrack_int_totals"); $changed += mactrack_check_changed("device", "sess_mactrack_int_device"); $changed += mactrack_check_changed("issues", "sess_mactrack_int_issues"); $changed += mactrack_check_changed("bwusage", "sess_mactrack_int_bwusage"); $changed += mactrack_check_changed("type", "sess_mactrack_int_type"); $changed += mactrack_check_changed("period", "sess_mactrack_int_period"); $changed += mactrack_check_changed("filter", "sess_mactrack_int_filter"); $changed += mactrack_check_changed("rows", "sess_mactrack_int_rows"); $changed += mactrack_check_changed("sort_column", "sess_mactrack_int_sort_column"); $changed += mactrack_check_changed("sort_direction", "sess_mactrack_int_sort_direction"); if ($changed) { $_REQUEST["page"] = "1"; } } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value("page", "sess_mactrack_int_current_page", "1"); load_current_session_value("totals", "sess_mactrack_int_totals", "on"); load_current_session_value("rows", "sess_mactrack_int_rows", read_config_option("num_rows_device")); load_current_session_value("device_id", "sess_mactrack_int_device_id", "-1"); load_current_session_value("site", "sess_mactrack_int_site", "-1"); load_current_session_value("issues", "sess_mactrack_int_issues", "-3"); load_current_session_value("bwusage", "sess_mactrack_int_bwusage", read_config_option("mactrack_interface_high")); load_current_session_value("type", "sess_mactrack_int_type", "-1"); load_current_session_value("device", "sess_mactrack_int_device", "-1"); load_current_session_value("period", "sess_mactrack_int_period", "-2"); load_current_session_value("filter", "sess_mactrack_int_filter", ""); load_current_session_value("sort_column", "sess_mactrack_int_sort_column", "device_name"); load_current_session_value("sort_direction", "sess_mactrack_int_sort_direction", "DESC"); include_once("./plugins/mactrack/general_header.php"); print "<script type='text/javascript' src='" . $config["url_path"] . "plugins/mactrack/mactrack.js'></script>"; $sql_where = ""; if ($_REQUEST["rows"] == -1) { $row_limit = read_config_option("num_rows_device"); }elseif ($_REQUEST["rows"] == -2) { $row_limit = 99999999; }else{ $row_limit = $_REQUEST["rows"]; } $stats = mactrack_get_records($sql_where, TRUE, $row_limit); mactrack_tabs(); html_start_box("<strong>Scanned Device Interfaces</strong>", "100%", $colors["header"], "3", "center", ""); mactrack_filter_table(); html_end_box(); //Last device restart: if ($_REQUEST["device"]!=-1){ html_start_box("", "100%", $colors["header"], "3", "center", ""); print "<tr>"; if (sizeof($stats)>0) $last_run_time = max(strtotime($stats[0]["last_up_time"]),strtotime($stats[0]["last_down_time"])); else $last_run_time = read_config_option("mt_last_run_time", TRUE); $diff = strtotime("now") - $last_run_time; $upTime = ($stats[0]["sysUptime"]/100) + $diff; $days = intval($upTime / (60*60*24)); $remainder = $upTime % (60*60*24); $hours = intval($remainder / (60*60)); $remainder = $remainder % (60*60); $minutes = intval($remainder / (60)); $upTime = $days . "d:" . $hours . "h:" . $minutes . "m"; print "<td style='text-align:right'><strong>Last device restart:</strong> ".$upTime."</td>"; print "</tr>"; html_end_box(false); } html_start_box("", "100%", $colors["header"], "3", "center", ""); $rows_query_string = "SELECT COUNT(*) FROM mac_track_interfaces INNER JOIN mac_track_devices ON mac_track_interfaces.device_id=mac_track_devices.device_id INNER JOIN mac_track_device_types ON mac_track_device_types.device_type_id=mac_track_devices.device_type_id $sql_where"; //echo $rows_query_string; $total_rows = db_fetch_cell($rows_query_string); /* generate page list */ if ($total_rows > 0) { $url_page_select = get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, $row_limit, $total_rows, "mactrack_view_interfaces.php?report=interfaces"); $nav = "<tr bgcolor='#" . $colors["header"] . "' class='noprint'> <td colspan='22'> <table width='100%' cellspacing='0' cellpadding='0' border='0'> <tr> <td align='left' class='textHeaderDark'> <strong><< "; if ($_REQUEST["page"] > 1) { $nav .= "<a class='linkOverDark' href='mactrack_view_interfaces.php?page=" . ($_REQUEST["page"]-1) . "'>"; } $nav .= "Previous"; if ($_REQUEST["page"] > 1) { $nav .= "</a>"; } $nav .= "</strong> </td>\n <td align='center' class='textHeaderDark'> Showing Rows " . (($row_limit*($_REQUEST["page"]-1))+1) . " to " . ((($total_rows < $row_limit) || ($total_rows < ($row_limit*$_REQUEST["page"]))) ? $total_rows : ($row_limit*$_REQUEST["page"])) . " of $total_rows [$url_page_select] </td>\n <td align='right' class='textHeaderDark'> <strong>"; if (($_REQUEST["page"] * $row_limit) < $total_rows) { $nav .= "<a class='linkOverDark' href='mactrack_view_interfaces.php?page=" . ($_REQUEST["page"]+1) . "'>"; } $nav .= "Next"; if (($_REQUEST["page"] * $row_limit) < $total_rows) { $nav .= "</a>"; } $nav .= " >></strong> </td>\n </tr> </table> </td> </tr>\n"; }else{ $nav = "<tr bgcolor='#" . $colors["header"] . "' class='noprint'> <td colspan='22'> <table width='100%' cellspacing='0' cellpadding='0' border='0'> <tr> <td align='center' class='textHeaderDark'> No Rows Found </td>\n </tr> </table> </td> </tr>\n"; } print $nav; $display_text = mactrack_display_array(); html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]); $i = 0; if (sizeof($stats) > 0) { //$stats = order_by_name($stats); foreach ($stats as $stat) { /* find the background color and enclose it */ $bgc = mactrack_int_row_color($stat); if ($bgc) { print "<tr id='row_" . $stat["device_id"] . "_" . $stat["ifName"] . "' style='background-color:#$bgc;'>\n"; $i++; }else{ if (($i % 2) == 1) { $current_color = $colors["alternate"]; }else{ $current_color = $colors["light"]; } print "<tr id='row_" . $stat["device_id"] . "' style='background-color:#$bgc;'>\n"; $i++; } print mactrack_format_interface_row($stat); } }else{ print "<tr><td colspan='7'><em>No Scanner Devices Found</em></td></tr>"; } /* put the nav bar on the bottom as well */ print $nav; html_end_box(false); html_start_box("", "100%", $colors["header"], "3", "center", ""); print "<tr>"; mactrack_legend_row("mt_int_up_bgc", "Interface Up"); mactrack_legend_row("mt_int_up_wo_alias_bgc", "No Alias"); mactrack_legend_row("mt_int_errors_bgc", "Errors Present"); mactrack_legend_row("mt_int_discards_bgc", "Discards Present"); mactrack_legend_row("mt_int_unmapped_bgc", "Unmapped to Tree"); mactrack_legend_row("mt_int_no_graph_bgc", "No Graphs"); mactrack_legend_row("mt_int_no_device_bgc", "Not Integrated"); mactrack_legend_row("mt_int_down_bgc", "Interface Down"); print "</tr>"; html_end_box(false); mactrack_display_stats(); print "<div id='response'></div>"; print "<script> function printreport(id){ if (id==-1 ||typeof id == 'undefined') alert('To generate the report, you must select one device.'); else window.open('https://monitorizacion.urjc.es/cacti/plugins/mactrack/pdfreport.php?did='+id, '_blank'); } </script>"; include_once("./include/bottom_footer.php"); }
function template_edit() { global $colors; if (!empty($_GET["id"])) { $graph_template = db_fetch_row("select * from graph_template where id=" . $_GET["id"]); $header_label = _("[edit: ") . $graph_template["template_name"] . "]"; } else { $header_label = _("[new]"); } form_start("graph_templates.php", "form_graph_template"); /* ==================== Box: Graph Template ==================== */ html_start_box("<strong>" . _("Graph Template") . "</strong> {$header_label}", "98%", $colors["header_background"], "3", "center", ""); _graph_template_field__template_name("template_name", isset($graph_template) ? $graph_template["template_name"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]); html_end_box(); /* graph item list goes here */ if (!empty($_GET["id"])) { /* ==================== Box: Graph Items ==================== */ html_start_box("<strong>" . _("Graph Items") . "</strong>", "98%", $colors["header_background"], "3", "center", "graph_templates_items.php?action=edit&graph_template_id=" . $_GET["id"]); draw_graph_item_editor($_GET["id"], "graph_template", false); html_end_box(); /* ==================== Box: Graph Item Inputs ==================== */ html_start_box("<strong>" . _("Graph Item Inputs") . "</strong>", "98%", $colors["header_background"], "3", "center", "graph_templates_inputs.php?action=edit&graph_template_id=" . $_GET["id"]); $display_text = array("name" => array(_("Name"), "ASC")); html_header_sort($display_text, $sort_column, $sort_direction, 2); $template_item_list = db_fetch_assoc("select id,name from graph_template_item_input where graph_template_id=" . $_GET["id"] . " order by name"); $i = 0; if (sizeof($template_item_list) > 0) { foreach ($template_item_list as $item) { form_alternate_row_color($colors["form_alternate1"], $colors["form_alternate2"], $i); $i++; ?> <td> <a class="linkEditMain" href="graph_templates_inputs.php?action=edit&id=<?php print $item["id"]; ?> &graph_template_id=<?php print $_GET["id"]; ?> "><?php print $item["name"]; ?> </a> </td> <td align="right"> <a href="graph_templates_inputs.php?action=remove&id=<?php print $item["id"]; ?> &graph_template_id=<?php print $_GET["id"]; ?> "><img src="<?php print html_get_theme_images_path('delete_icon.gif'); ?> " width="10" height="10" border="0" alt="Delete"></a> </td> </tr> <?php } } else { print "<tr bgcolor='#" . $colors["form_alternate2"] . "'><td colspan='2'><em>" . _("No Inputs") . "</em></td></tr>"; } html_end_box(); } /* ==================== Box: Graph ==================== */ /* the user clicked the "add item" link. we need to make sure they get redirected back to * this page if an error occurs */ if ($_GET["action"] == "sv_add") { form_hidden_box("redirect_sv_add", "x", ""); } html_start_box("<strong>" . _("Graph") . "</strong>", "98%", $colors["header_background"], "3", "center", ""); field_row_header("General Options"); _graph_field__title("title", true, empty($_GET["id"]) ? 0 : $_GET["id"], "t_title", isset($graph_template["t_title"]) ? $graph_template["t_title"] : ""); _graph_field__vertical_label("vertical_label", true, isset($graph_template["vertical_label"]) ? $graph_template["vertical_label"] : "", empty($_GET["id"]) ? 0 : $_GET["id"], "t_vertical_label", isset($graph_template["t_vertical_label"]) ? $graph_template["t_vertical_label"] : ""); _graph_field__image_format("image_format", isset($graph_template["image_format"]) ? $graph_template["image_format"] : "", true, empty($_GET["id"]) ? 0 : $_GET["id"], "t_image_format", isset($graph_template["t_image_format"]) ? $graph_template["t_image_format"] : ""); _graph_field__export("export", true, isset($graph_template["export"]) ? $graph_template["export"] : "", empty($_GET["id"]) ? 0 : $_GET["id"], "t_export", isset($graph_template["t_export"]) ? $graph_template["t_export"] : ""); _graph_field__force_rules_legend("force_rules_legend", true, isset($graph_template["force_rules_legend"]) ? $graph_template["force_rules_legend"] : "", empty($_GET["id"]) ? 0 : $_GET["id"], "t_force_rules_legend", isset($graph_template["t_force_rules_legend"]) ? $graph_template["t_force_rules_legend"] : ""); field_row_header("Image Size Options"); _graph_field__height("height", true, isset($graph_template["height"]) ? $graph_template["height"] : "", empty($_GET["id"]) ? 0 : $_GET["id"], "t_height", isset($graph_template["t_height"]) ? $graph_template["t_height"] : ""); _graph_field__width("width", true, isset($graph_template["width"]) ? $graph_template["width"] : "", empty($_GET["id"]) ? 0 : $_GET["id"], "t_width", isset($graph_template["t_width"]) ? $graph_template["t_width"] : ""); field_row_header("Grid Options"); _graph_field__x_grid("x_grid", true, isset($graph_template["x_grid"]) ? $graph_template["x_grid"] : "", empty($_GET["id"]) ? 0 : $_GET["id"], "t_x_grid", isset($graph_template["t_x_grid"]) ? $graph_template["t_x_grid"] : ""); _graph_field__y_grid("y_grid", true, isset($graph_template["y_grid"]) ? $graph_template["y_grid"] : "", empty($_GET["id"]) ? 0 : $_GET["id"], "t_y_grid", isset($graph_template["t_y_grid"]) ? $graph_template["t_y_grid"] : ""); _graph_field__y_grid_alt("y_grid_alt", true, isset($graph_template["y_grid_alt"]) ? $graph_template["y_grid_alt"] : "", empty($_GET["id"]) ? 0 : $_GET["id"], "t_y_grid_alt", isset($graph_template["t_y_grid_alt"]) ? $graph_template["t_y_grid_alt"] : ""); _graph_field__no_minor("no_minor", true, isset($graph_template["no_minor"]) ? $graph_template["no_minor"] : "", empty($_GET["id"]) ? 0 : $_GET["id"], "t_no_minor", isset($graph_template["t_no_minor"]) ? $graph_template["t_no_minor"] : ""); field_row_header("Auto Scaling Options"); _graph_field__auto_scale("auto_scale", true, isset($graph_template["auto_scale"]) ? $graph_template["auto_scale"] : "", empty($_GET["id"]) ? 0 : $_GET["id"], "t_auto_scale", isset($graph_template["t_auto_scale"]) ? $graph_template["t_auto_scale"] : ""); _graph_field__auto_scale_opts("auto_scale_opts", true, isset($graph_template["auto_scale_opts"]) ? $graph_template["auto_scale_opts"] : "", empty($_GET["id"]) ? 0 : $_GET["id"], "t_auto_scale_opts", isset($graph_template["t_auto_scale_opts"]) ? $graph_template["t_auto_scale_opts"] : ""); _graph_field__auto_scale_log("auto_scale_log", true, isset($graph_template["auto_scale_log"]) ? $graph_template["auto_scale_log"] : "", empty($_GET["id"]) ? 0 : $_GET["id"], "t_auto_scale_log", isset($graph_template["t_auto_scale_log"]) ? $graph_template["t_auto_scale_log"] : ""); _graph_field__auto_scale_rigid("auto_scale_rigid", true, isset($graph_template["auto_scale_rigid"]) ? $graph_template["auto_scale_rigid"] : "", empty($_GET["id"]) ? 0 : $_GET["id"], "t_auto_scale_rigid", isset($graph_template["t_auto_scale_rigid"]) ? $graph_template["t_auto_scale_rigid"] : ""); _graph_field__auto_padding("auto_padding", true, isset($graph_template["auto_padding"]) ? $graph_template["auto_padding"] : "", empty($_GET["id"]) ? 0 : $_GET["id"], "t_auto_padding", isset($graph_template["t_auto_padding"]) ? $graph_template["t_auto_padding"] : ""); field_row_header("Fixed Scaling Options"); _graph_field__upper_limit("upper_limit", true, isset($graph_template["upper_limit"]) ? $graph_template["upper_limit"] : "", empty($_GET["id"]) ? 0 : $_GET["id"], "t_upper_limit", isset($graph_template["t_upper_limit"]) ? $graph_template["t_upper_limit"] : ""); _graph_field__lower_limit("lower_limit", true, isset($graph_template["lower_limit"]) ? $graph_template["lower_limit"] : "", empty($_GET["id"]) ? 0 : $_GET["id"], "t_lower_limit", isset($graph_template["t_lower_limit"]) ? $graph_template["t_lower_limit"] : ""); _graph_field__base_value("base_value", true, isset($graph_template["base_value"]) ? $graph_template["base_value"] : "", empty($_GET["id"]) ? 0 : $_GET["id"], "t_base_value", isset($graph_template["t_base_value"]) ? $graph_template["t_base_value"] : ""); field_row_header("Units Display Options"); _graph_field__unit_value("unit_value", true, isset($graph_template["unit_value"]) ? $graph_template["unit_value"] : "", empty($_GET["id"]) ? 0 : $_GET["id"], "t_unit_value", isset($graph_template["t_unit_value"]) ? $graph_template["t_unit_value"] : ""); _graph_field__unit_length("unit_length", true, isset($graph_template["unit_length"]) ? $graph_template["unit_length"] : "", empty($_GET["id"]) ? 0 : $_GET["id"], "t_unit_length", isset($graph_template["t_unit_length"]) ? $graph_template["t_unit_length"] : ""); _graph_field__unit_exponent_value("unit_exponent_value", true, isset($graph_template["unit_exponent_value"]) ? $graph_template["unit_exponent_value"] : "", empty($_GET["id"]) ? 0 : $_GET["id"], "t_unit_exponent_value", isset($graph_template["t_unit_exponent_value"]) ? $graph_template["t_unit_exponent_value"] : ""); html_end_box(); form_hidden_box("graph_template_id", empty($_GET["id"]) ? 0 : $_GET["id"], ""); form_hidden_box("action_post", "graph_template_edit"); form_save_button("graph_templates.php"); }