| about.php and/or the AUTHORS file for specific developer information. | +-------------------------------------------------------------------------+ | http://www.cacti.net/ | +-------------------------------------------------------------------------+ */ $guest_account = true; chdir('../../'); include './include/auth.php'; include_once './include/global_arrays.php'; include_once './plugins/mactrack/lib/mactrack_functions.php'; $title = __('Device Tracking - Site Report View'); if (isset_request_var('export')) { mactrack_view_export_sites(); } else { mactrack_redirect(); general_header(); mactrack_view_sites(); bottom_footer(); } function mactrack_view_export_sites() { mactrack_sites_request_validation(); $sql_where = ''; $sites = mactrack_view_get_site_records($sql_where, 0, FALSE); $xport_array = array(); if (get_request_var('detail') == 'false') { array_push($xport_array, '"site_id","site_name","total_devices",' . '"total_device_errors","total_macs","total_ips","total_oper_ports",' . '"total_user_ports"'); foreach ($sites as $site) { array_push($xport_array, '"' . $site['site_id'] . '","' . $site['site_name'] . '","' . $site['total_devices'] . '","' . $site['total_device_errors'] . '","' . $site['total_macs'] . '","' . $site['total_ips'] . '","' . $site['total_oper_ports'] . '","' . $site['total_user_ports'] . '"'); } } else {
function actions_devices() { global $flow_actions, $config; if (isset_request_var('selected_items')) { $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); if ($selected_items != false) { if (get_nfilter_request_var('drp_action') == '1') { for ($i = 0; $i < count($selected_items); $i++) { db_execute('DELETE FROM plugin_flowview_devices WHERE id = ' . $selected_items[$i]); } } } header('Location: flowview_devices.php?tab=listeners&header=false'); exit; } /* setup some variables */ $device_list = ''; $i = 0; /* loop through each of the devices selected on the previous page and get more info about them */ while (list($var, $val) = each($_POST)) { if (preg_match('/^chk_([0-9]+)$/', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ $device_list .= '<li>' . db_fetch_cell('SELECT name FROM plugin_flowview_devices WHERE id=' . $matches[1]) . '</li>'; $device_array[$i] = $matches[1]; } $i++; } general_header(); form_start('flowview_devices.php'); html_start_box($flow_actions[get_nfilter_request_var('drp_action')], '60%', '', '3', 'center', ''); if (get_nfilter_request_var('drp_action') == '1') { /* Delete */ print "<tr>\n\t\t\t<td colspan='2' class='textArea'>\n\t\t\t\t<p>Click 'Continue' to delete the following Net-Flow Listeners. After which, you will need to restart your Flow-Capture Service.</p>\n\t\t\t\t<p>Also, remember to remove any left over files from your Net-Flow Capture location.</p>\n\t\t\t\t<p><ul>{$device_list}</ul></p>\n\t\t\t</td>\n\t\t</tr>\n"; } if (!isset($device_array)) { print "<tr><td class='even'><span class='textError'>You must select at least one device.</span></td></tr>\n"; $save_html = ''; } else { $save_html = "<input type='submit' value='Continue'>"; } print "<tr>\n\t\t<td class='saveRow'>\n\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t<input type='hidden' name='selected_items' value='" . (isset($device_array) ? serialize($device_array) : '') . "'>\n\t\t\t<input type='hidden' name='drp_action' value='" . get_filter_request_var('drp_action') . "'>\n\t\t\t<input type='button' onClick='javascript:document.location=\"flowview_devices.php\"' value='Cancel'>\n\t\t\t{$save_html}\n\t\t</td>\n\t</tr>\n"; html_end_box(); form_end(); bottom_footer(); }
function mactrack_snmp_remove() { /* ================= input validation ================= */ get_filter_request_var('id'); /* ==================================================== */ if (read_config_option('deletion_verification') == 'on' && !isset_request_var('confirm')) { general_header(); form_confirm(__('Are You Sure?'), __('Are you sure you want to delete the SNMP Option Set(s) %s?', db_fetch_cell_prepared('SELECT name FROM mactrack WHERE id = ?', array(get_request_var('id')))), 'mactrack_snmp.php', 'mactrack_snmp.php?action=remove&id=' . get_request_var('id')); bottom_footer(); exit; } if (read_config_option('deletion_verification') == '' || isset_request_var('confirm')) { db_execute_prepared('DELETE FROM mac_track_snmp_items WHERE snmp_id = ?', array(get_request_var('id'))); db_execute_prepared('DELETE FROM mac_track_snmp WHERE id = ?', array(get_request_var('id'))); } }
function flowview_display_report() { global $config, $colors; general_header(); if (isset_request_var('tab') && strlen(get_nfilter_request_var('tab')) > 10) { $flowdata = unserialize(base64_decode(get_nfilter_request_var('tab'))); $sessionid = get_nfilter_request_var('tab'); foreach ($flowdata['post'] as $item => $value) { switch ($item) { case 'bytes': case 'flows': case 'packets': break; case 'exclude': if (isset_request_var('exclude')) { get_filter_request_var('exclude'); break; } else { set_request_var($item, $value); break; } default: set_request_var($item, $value); break; } } set_request_var('action', 'view'); } else { $sessionid = ''; } include $config['base_path'] . '/plugins/flowview/variables.php'; include $config['base_path'] . '/plugins/flowview/arrays.php'; $rname = ''; if ($stat_report > 0) { $rname = $stat_report_array[$stat_report]; } if ($print_report > 0) { $rname = $print_report_array[$print_report]; } $current = ''; $error = flowview_check_fields(); if ($error != '') { display_tabs(); print "<font class='textError'>{$error}</font>"; html_end_box(); return; } /* if the user pushed the 'clear' button */ if (isset_request_var('clear')) { kill_session_var('sess_flows_exclude'); kill_session_var('sess_flows_table'); kill_session_var('sess_flows_bytes'); kill_session_var('sess_flows_packets'); kill_session_var('sess_flows_flows'); unset_request_var('exclude'); unset_request_var('table'); unset_request_var('bytes'); unset_request_var('packets'); unset_request_var('flows'); } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value('exclude', 'sess_flows_exclude', '0'); load_current_session_value('table', 'sess_flows_table', 'on'); load_current_session_value('bytes', 'sess_flows_bytes', ''); load_current_session_value('packets', 'sess_flows_packets', ''); load_current_session_value('flows', 'sess_flows_flows', ''); $filter = createfilter($sessionid); display_tabs(); if (isset_request_var('stat_report') && get_nfilter_request_var('stat_report') != 99) { html_start_box("Report: {$rname}", '100%', '', '3', 'center', ''); ?> <tr class='even'> <td> <form id='view' name='view' action='flowview.php' method='post'> <table class='filterTable'> <tr> <td> Exclude </td> <td> <select name='exclude' id='exclude'> <option value='0'<?php echo get_request_var('exclude') == 0 ? ' selected' : ''; ?> >None</option> <option value='1'<?php echo get_request_var('exclude') == 1 ? ' selected' : ''; ?> >Top Sample</option> <option value='2'<?php echo get_request_var('exclude') == 2 ? ' selected' : ''; ?> >Top 2 Samples</option> <option value='3'<?php echo get_request_var('exclude') == 3 ? ' selected' : ''; ?> >Top 3 Samples</option> <option value='4'<?php echo get_request_var('exclude') == 4 ? ' selected' : ''; ?> >Top 4 Samples</option> <option value='5'<?php echo get_request_var('exclude') == 5 ? ' selected' : ''; ?> >Top 5 Samples</option> </select> </td> <td> Show/Hide </td> <td> <input type='checkbox' name='table' id='table' <?php print get_request_var('table') == 'true' || get_request_var('table') == 'on' ? 'checked' : ''; ?> > </td> <td> <label for='table'>Table</label> </td> <td> <input type='checkbox' name='bytes' id='bytes' <?php print get_request_var('bytes') == 'true' || get_request_var('bytes') == 'on' ? 'checked' : ''; ?> > </td> <td> <label for='bytes'>Bytes Bar</label> </td> <td> <input type='checkbox' name='packets' id='packets' <?php print get_request_var('packets') == 'true' || get_request_var('packets') == 'on' ? 'checked' : ''; ?> > </td> <td> <label for='packets'>Packets Bar</label> </td> <td> <input type='checkbox' name='flows' id='flows' <?php print get_request_var('flows') == 'true' || get_request_var('flows') == 'on' ? 'checked' : ''; ?> > </td> <td> <label for='flows'>Flows Bar</label> </td> <td> <input type='button' id='clear' value='Clear' title='Clear Filters'> </td> </tr> </table> <input type='hidden' name='page' value='1'> <input type='hidden' name='tab' id='tab' value='<?php print $sessionid; ?> '> </form> </td> </tr> <?php html_end_box(); flowview_draw_chart('bytes', $rname); flowview_draw_chart('packets', $rname); flowview_draw_chart('flows', $rname); } elseif (isset_request_var('print_report') && get_nfilter_request_var('print_report') > 0) { html_start_box("Report: {$rname}", '100%', '', '3', 'center', ''); } echo "<div id='flowcontent'>"; echo $filter; html_end_box(); echo "</div>"; ?> <script type='text/javascript'> swfobject.embedSWF('open-flash-chart.swf', 'chartbytes', '98%', '275', '9.0.0', 'expressInstall.swf', {'data-file':'<?php print urlencode($config["url_path"] . "plugins/flowview/flowview.php?session=" . $sessionid . "&action=chartdata&exclude=" . get_request_var('exclude') . "&type=bytes&title={$rname}"); ?> ', 'id':'chartbytes'}); swfobject.embedSWF('open-flash-chart.swf', 'chartpackets', '98%', '275', '9.0.0', 'expressInstall.swf', {'data-file':'<?php print urlencode($config["url_path"] . "plugins/flowview/flowview.php?session=" . $sessionid . "&action=chartdata&exclude=" . get_request_var('exclude') . "&type=packets&title={$rname}"); ?> ', 'id':'chartpackets'}); swfobject.embedSWF('open-flash-chart.swf', 'chartflows', '98%', '275', '9.0.0', 'expressInstall.swf', {'data-file':'<?php print urlencode($config["url_path"] . "plugins/flowview/flowview.php?session=" . $sessionid . "&action=chartdata&exclude=" . get_request_var('exclude') . "&type=flows&title={$rname}"); ?> ', 'id':'chartflows'}); $('#bytes').click(function() { if (!$('#bytes').is(':checked')) { $('#wrapperbytes').hide(); $.get('flowview.php?action=updatesess&type=bytes&value='); }else{ $('#wrapperbytes').show(); } }); $('#packets').click(function() { if (!$('#packets').is(':checked')) { $('#wrapperpackets').hide(); $.get('flowview.php?action=updatesess&type=packets&value='); }else{ $('#wrapperpackets').show(); } }); $('#flows').click(function() { if (!$('#flows').is(':checked')) { $('#wrapperflows').hide(); $.get('flowview.php?action=updatesess&type=flows&value='); }else{ $('#wrapperflows').show(); } }); $('#table').click(function() { if (!$('#table').is(':checked')) { $('#flowcontent').hide(); $.get('flowview.php?action=updatesess&type=table&value='); }else{ $.get('flowview.php?action=updatesess&type=table&value=on'); $('#flowcontent').show(); } }); $('#clear').click(function() { loadPageNoHeader('flowview.php?header=false&action=view&clear=true&tab='+$('#tab').val()); }); $('#exclude').change(function() { loadPageNoHeader('flowview.php?header=false&action=view&exclude='+$('#exclude').val()+'&tab='+$('#tab').val()); }); if ($('#table').is(':checked') || <?php print isset_request_var('stat_report') ? get_nfilter_request_var('stat_report') == 99 ? 'true' : 'false' : 'true'; ?> ) { $('#flowcontent').show(); }else{ $('#flowcontent').hide(); } if ($('#bytes').is(':checked')) { $('#wrapperbytes').show(); } if ($('#packets').is(':checked')) { $('#wrapperpackets').show(); } if ($('#flows').is(':checked')) { $('#wrapperflows').show(); } $.tablesorter.addParser({ id: 'bytes', is: function(s) { return false; }, format: function(s) { if (s.indexOf('MB') > 0) { loc=s.indexOf('MB'); return s.substring(0,loc) * 1024 * 1024; }else if (s.indexOf('KB') > 0) { loc=s.indexOf('KB'); return s.substring(0,loc) * 1024; }else if (s.indexOf('Bytes') > 0) { loc=s.indexOf('Bytes'); return s.substring(0,loc); }else if (s.indexOf('GB') > 0) { loc=s.indexOf('GB'); return s.substring(0,loc) * 1024 * 1024 * 1024; }else if (s.indexOf('TB') > 0) { loc=s.indexOf('TB'); return s.substring(0,loc) * 1024 * 1024 * 1024 * 1024; }else{ return s; } }, type: 'numeric' }); $(function() { $('#sorttable').tablesorter({ widgets: ['zebra'], widgetZebra: { css: ['even', 'odd'] }, headerTemplate: '<div class="textSubHeaderDark">{content} {icon}</div>', cssIconAsc: 'fa-sort-asc', cssIconDesc: 'fa-sort-desc', cssIconNone: 'fa-sort', cssIcon: 'fa' }); $('#sorttable').resizable(); }); </script> <?php bottom_footer(); }
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 clog_view_logfile() { global $config, $colors, $log_tail_lines, $page_refresh_interval, $refresh; $logfile = read_config_option('path_cactilog'); if ($logfile == '') { $logfile = './log/cacti.log'; } /* helps determine output color */ $linecolor = true; input_validate_input_number(get_request_var_request('tail_files')); input_validate_input_number(get_request_var_request('message_type')); input_validate_input_number(get_request_var_request('refresh')); input_validate_input_number(get_request_var_request('reverse')); /* enable page refreshes */ kill_session_var('custom'); /* if the user pushed the 'clear' button */ if (isset($_REQUEST['clear'])) { kill_session_var('sess_clog_tail_lines'); kill_session_var('sess_clog_message_type'); kill_session_var('sess_clog_filter'); kill_session_var('sess_clog_refresh'); kill_session_var('sess_clog_reverse'); unset($_REQUEST['tail_lines']); unset($_REQUEST['message_type']); unset($_REQUEST['filter']); unset($_REQUEST['refresh']); unset($_REQUEST['reverse']); } load_current_session_value('tail_lines', 'sess_clog_tail_lines', read_config_option('num_rows_log')); load_current_session_value('message_type', 'sess_clog_message_type', '-1'); load_current_session_value('filter', 'sess_clog_filter', ''); load_current_session_value('refresh', 'sess_clog_refresh', read_config_option('log_refresh_interval')); load_current_session_value('reverse', 'sess_clog_reverse', 1); $_REQUEST['page_referrer'] = 'view_logfile'; load_current_session_value('page_referrer', 'page_referrer', 'view_logfile'); $refresh['seconds'] = $_REQUEST['refresh']; $refresh['page'] = $config['url_path'] . 'clog.php'; if (isset($_REQUEST['purge_continue']) && clog_admin()) { clog_purge_logfile(); } general_header(); if (isset($_REQUEST['purge']) && clog_admin()) { html_start_box('<strong>Purge</strong>', '50%', '', '3', 'center', ''); print "\t\n\t\t\t<form action='clog.php' autocomplete='off' method='post'>\n\t\t\t<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>Click \"Continue\" to purge the cacti log file.<br><br><br>Note: If logging is set to Cacti and Syslog, the log information will remain in Syslog.</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2' align='right' bgcolor='#eaeaea'>\n\t\t\t\t\t<input id='cancel' type='button' value='Cancel'> \n\t\t\t\t\t<input id='pc' type='button' name='purge_continue' value='Continue' title='Purge cacti.log'>\n\t\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\t\$('#pc').click(function() {\n\t\t\t\t\t\turl='?purge_continue=1&header=false';\n\t\t\t\t\t\t\$.get(location.pathname+url, function(data) {\n\t\t\t\t\t\t\t\$('#main').html(data);\n\t\t\t\t\t\t\tapplySkin();\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\n\t\t\t\t\t\$('#cancel').click(function() {\n\t\t\t\t\t\turl='?header=false';\n\t\t\t\t\t\t\$.get(location.pathname+url, function(data) {\n\t\t\t\t\t\t\t\$('#main').html(data);\n\t\t\t\t\t\t\tapplySkin();\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\n\t\t\t\t\t\$(function() {\n\t\t\t\t\t\tapplySkin();\n\t\t\t\t\t});\n\t\t\t\t\t</script>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t"; html_end_box(); return; } html_start_box('<strong>Log File Filters</strong>', '100%', $colors['header'], '3', 'center', ''); filter(); html_end_box(); /* read logfile into an array and display */ $logcontents = tail_file($logfile, $_REQUEST['tail_lines'], $_REQUEST['message_type'], $_REQUEST['filter']); $exclude_regex = read_config_option('clog_exclude', true); if ($_REQUEST['reverse'] == 1) { $logcontents = array_reverse($logcontents); } if (!clog_admin()) { if (strlen($exclude_regex)) { $ad_filter = ' - Admin Filter in Affect'; } else { $ad_filter = ' - No Admin Filter in Affect'; } } else { $ad_filter = ' - Admin View'; } if ($_REQUEST['message_type'] > 0) { $start_string = '<strong>Log File</strong> [Total Lines: ' . sizeof($logcontents) . $ad_filter . ' - Additional Filter in Affect]'; } else { $start_string = '<strong>Log File</strong> [Total Lines: ' . sizeof($logcontents) . $ad_filter . ' - No Other Filter in Affect]'; } html_start_box($start_string, '100%', $colors['header'], '3', 'center', ''); $i = 0; $j = 0; $linecolor = false; foreach ($logcontents as $item) { $host_start = strpos($item, 'Device['); $ds_start = strpos($item, 'DS['); $new_item = ''; if (!$host_start && !$ds_start) { $new_item = $item; } else { while ($host_start) { $host_end = strpos($item, ']', $host_start); $host_id = substr($item, $host_start + 7, $host_end - ($host_start + 7)); $new_item .= substr($item, 0, $host_start + 7) . "<a href='" . $config['url_path'] . 'host.php?action=edit&id=' . $host_id . "'>" . substr($item, $host_start + 5, $host_end - ($host_start + 7)) . '</a>'; $host_description = db_fetch_cell("SELECT description FROM host WHERE id={$host_id}"); $new_item .= '] Description[' . $host_description . ''; $item = substr($item, $host_end); $host_start = strpos($item, 'Device['); } $ds_start = strpos($item, 'DS['); while ($ds_start) { $ds_end = strpos($item, ']', $ds_start); $ds_id = substr($item, $ds_start + 3, $ds_end - ($ds_start + 3)); $graph_ids = clog_get_graphs_from_datasource($ds_id); $graph_add = '&graph_add='; if (sizeof($graph_ids)) { $new_item .= substr($item, 0, $ds_start + 3) . "<a href='" . $config['url_path'] . 'data_sources.php?action=ds_edit&id=' . $ds_id . "'>" . substr($item, $ds_start + 3, $ds_end - ($ds_start + 3)) . '</a>' . "] Graphs[<a href='" . $config['url_path'] . 'graph_view.php?page=1&style=selective&action=preview'; $i = 0; $titles = ''; foreach ($graph_ids as $key => $title) { $new_item .= '&graph_' . $key . '=' . $key; $graph_add .= ($i > 0 ? htmlspecialchars('%2C') : '') . $key; $i++; if (strlen($titles)) { $titles .= ",'" . $title . "'"; } else { $titles .= "'" . $title . "'"; } } $new_item .= $graph_add . "' title='View Graphs'>" . $titles . '</a>'; } $item = substr($item, $ds_end); $ds_start = strpos($item, 'DS['); } $new_item = $new_item . $item; } /* get the background color */ if (substr_count($new_item, 'ERROR') || substr_count($new_item, 'FATAL')) { $bgcolor = 'FF3932'; } elseif (substr_count($new_item, 'WARN')) { $bgcolor = 'EACC00'; } elseif (substr_count($new_item, ' SQL ')) { $bgcolor = '6DC8FE'; } elseif (substr_count($new_item, 'DEBUG')) { $bgcolor = 'C4FD3D'; } elseif (substr_count($new_item, 'STATS')) { $bgcolor = '96E78A'; } else { if ($linecolor) { $bgcolor = 'CCCCCC'; } else { $bgcolor = 'FFFFFF'; } $linecolor = !$linecolor; } /* respect the exclusion filter */ $show = true; if (!clog_admin() && @preg_match($exclude_regex, $new_item)) { $show = false; } if ($show) { ?> <tr bgcolor='#<?php print $bgcolor; ?> '> <td> <?php print $new_item; ?> </td> </tr> <?php $j++; $i++; } if ($j > 1000) { ?> <tr class='even'> <td> <?php print '>>>> LINE LIMIT OF 1000 LINES REACHED!! <<<<'; ?> </td> </tr> <?php break; } } html_end_box(); bottom_footer(); }
function actions_schedules() { global $colors, $sched_actions, $config; /* ================= input validation ================= */ input_validate_input_number(get_request_var_post('drp_action')); /* ==================================================== */ if (isset_request_var('selected_items')) { $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); if ($selected_items != false) { if (get_nfilter_request_var('drp_action') == '1') { for ($i = 0; $i < count($selected_items); $i++) { db_execute('DELETE FROM plugin_flowview_schedules WHERE id = ' . $selected_items[$i]); } } elseif (get_nfilter_request_var('drp_action') == '3') { for ($i = 0; $i < count($selected_items); $i++) { db_execute("UPDATE plugin_flowview_schedules SET enabled='' WHERE id = " . $selected_items[$i]); } } elseif (get_nfilter_request_var('drp_action') == '4') { for ($i = 0; $i < count($selected_items); $i++) { db_execute("UPDATE plugin_flowview_schedules SET enabled='on' WHERE id = " . $selected_items[$i]); } } elseif (get_nfilter_request_var('drp_action') == '2') { for ($i = 0; $i < count($selected_items); $i++) { plugin_flowview_run_schedule($selected_items[$i]); } } } header('Location: flowview_schedules.php?tab=sched&header=false'); exit; } /* setup some variables */ $schedule_list = ''; /* loop through each of the devices selected on the previous page and get more info about them */ while (list($var, $val) = each($_POST)) { if (preg_match('/^chk_([0-9]+)$/', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ $schedule_list .= '<li>' . db_fetch_cell_prepared('SELECT name FROM plugin_flowview_queries AS pfq INNER JOIN plugin_flowview_schedules AS pfs ON pfq.id=pfs.savedquery WHERE pfs.id = ?', array($matches[1])) . '</li>'; $schedule_array[] = $matches[1]; } } general_header(); form_start('flowview_schedules.php'); html_start_box($sched_actions[get_nfilter_request_var('drp_action')], '60%', '', '3', 'center', ''); if (get_nfilter_request_var('drp_action') == '1') { /* Delete */ print "<tr>\n\t\t\t<td colspan='2' class='textArea'>\n\t\t\t\t<p>Click 'Continue' to delete the following Schedule(s).</p>\n\t\t\t\t<p><ul>{$schedule_list}</ul></p>\n\t\t\t</td>\n\t\t</tr>"; } elseif (get_nfilter_request_var('drp_action') == '2') { /* Send Now */ print "<tr>\n\t\t\t<td colspan='2' class='textArea'>\n\t\t\t\t<p>Click 'Continue' to send the following Schedule(s) now.</p>\n\t\t\t\t<p><ul>{$schedule_list}</ul></p>\n\t\t\t</td>\n\t\t</tr>"; } elseif (get_nfilter_request_var('drp_action') == '3') { /* Disable */ print "<tr>\n\t\t\t<td colspan='2' class='textArea'>\n\t\t\t\t<p>Click 'Continue' to Disable the following Schedule(s).</p>\n\t\t\t\t<p><ul>{$schedule_list}</ul></p>\n\t\t\t</td>\n\t\t</tr>"; } elseif (get_nfilter_request_var('drp_action') == '4') { /* Enable */ print "<tr>\n\t\t\t<td colspan='2' class='textArea'>\n\t\t\t\t<p>Click 'Continue' to Enable the following Schedule(s).</p>\n\t\t\t\t<p><ul>{$schedule_list}</ul></p>\n\t\t\t</td>\n\t\t</tr>"; } if (!isset($schedule_array)) { print "<tr><td><span class='textError'>You must select at least one schedule.</span></td></tr>\n"; $save_html = ''; } else { $save_html = "<input type='submit' value='Continue'>"; } print "<tr>\n\t\t<td colspan='2' align='right' class='saveRow'>\n\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t<input type='hidden' name='selected_items' value='" . (isset($schedule_array) ? serialize($schedule_array) : '') . "'>\n\t\t\t<input type='hidden' name='drp_action' value='" . get_nfilter_request_var('drp_action') . "'>\n\t\t\t<input type='button' onClick='cactiReturnTo()' value='Cancel'>\n\t\t\t{$save_html}\n\t\t</td>\n\t</tr>"; html_end_box(); form_end(); bottom_footer(); }
function reports_form_actions() { global $config, $reports_actions; include_once $config['base_path'] . '/lib/reports.php'; /* ================= input validation ================= */ input_validate_input_number(get_request_var_post('drp_action')); /* ==================================================== */ /* if we are to save this form, instead of display it */ if (isset($_POST['selected_items'])) { $selected_items = unserialize(stripslashes($_POST['selected_items'])); if ($_POST['drp_action'] == REPORTS_DELETE) { /* delete */ db_execute('DELETE FROM reports WHERE ' . array_to_sql_or($selected_items, 'id')); db_execute('DELETE FROM reports_items WHERE ' . str_replace('id', 'report_id', array_to_sql_or($selected_items, 'id'))); } elseif ($_POST['drp_action'] == REPORTS_OWN) { /* take ownership */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ reports_log(__FUNCTION__ . ', takeown: ' . $selected_items[$i] . ' user: '******'sess_user_id'], false, 'REPORTS TRACE', POLLER_VERBOSITY_MEDIUM); db_execute('UPDATE reports SET user_id=' . $_SESSION['sess_user_id'] . ' WHERE id=' . $selected_items[$i]); } } elseif ($_POST['drp_action'] == REPORTS_DUPLICATE) { /* duplicate */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ reports_log(__FUNCTION__ . ', duplicate: ' . $selected_items[$i] . ' name: ' . $_POST['name_format'], false, 'REPORTS TRACE', POLLER_VERBOSITY_MEDIUM); duplicate_report($selected_items[$i], $_POST['name_format']); } } elseif ($_POST['drp_action'] == REPORTS_ENABLE) { /* enable */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ reports_log(__FUNCTION__ . ', enable: ' . $selected_items[$i], false, 'REPORTS TRACE', POLLER_VERBOSITY_MEDIUM); db_execute("UPDATE reports SET enabled='on' WHERE id=" . $selected_items[$i]); } } elseif ($_POST['drp_action'] == REPORTS_DISABLE) { /* disable */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ reports_log(__FUNCTION__ . ', disable: ' . $selected_items[$i], false, 'REPORTS TRACE', POLLER_VERBOSITY_MEDIUM); db_execute("UPDATE reports SET enabled='' WHERE id=" . $selected_items[$i]); } } elseif ($_POST['drp_action'] == REPORTS_SEND_NOW) { /* send now */ include_once $config['base_path'] . '/lib/reports.php'; $message = ''; for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ $_SESSION['reports_message'] = ''; $_SESSION['reports_error'] = ''; reports_send($selected_items[$i]); if (isset($_SESSION['reports_message']) && strlen($_SESSION['reports_message'])) { $message .= (strlen($message) ? '<br>' : '') . $_SESSION['reports_message']; } if (isset($_SESSION['reports_error']) && strlen($_SESSION['reports_error'])) { $message .= (strlen($message) ? '<br>' : '') . "<span style='color:red;'>" . $_SESSION['reports_error'] . '</span>'; } } if (strlen($message)) { $_SESSION['reports_message'] = $message; raise_message('reports_message'); } } header('Location: ' . get_reports_page()); exit; } /* setup some variables */ $reports_list = ''; $i = 0; /* loop through each of the graphs selected on the previous page and get more info about them */ while (list($var, $val) = each($_POST)) { if (preg_match('/^chk_([0-9]+)$/', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ $reports_list .= '<li>' . db_fetch_cell('SELECT name FROM reports WHERE id=' . $matches[1]) . '</li>'; $reports_array[$i] = $matches[1]; $i++; } } general_header(); ?> <script type='text/javascript'> <!-- function goTo(location) { document.location = location; } --> </script><?php print "<form name='report' action='" . get_reports_page() . "' method='post'>"; html_start_box('<strong>' . $reports_actions[$_POST['drp_action']] . '</strong>', '60%', '', '3', 'center', ''); if (!isset($reports_array)) { print "<tr><td class='even'><span class='textError'>You must select at least one Report.</span></td></tr>\n"; $save_html = ''; } else { $save_html = "<input type='submit' value='Yes' name='save'>"; if ($_POST['drp_action'] == REPORTS_DELETE) { /* delete */ print "\t<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>Are you sure you want to delete the following Reports?</p>\n\t\t\t\t\t<ul>{$reports_list}</ul>\n\t\t\t\t</td>\n\t\t\t</tr>\n\n\t\t\t"; } elseif (is_reports_admin() && $_POST['drp_action'] == REPORTS_OWN) { /* take ownership */ print "\t<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>Are you sure you wish to take ownership of the following reports?</p>\n\t\t\t\t\t<ul>{$reports_list}</ul>\n\t\t\t\t</td>\n\t\t\t</tr>\n\n\t\t\t"; } elseif ($_POST['drp_action'] == REPORTS_DUPLICATE) { /* duplicate */ print "\t<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>When you click save, the following Reports will be duplicated. You can\n\t\t\t\t\toptionally change the title format for the new Reports.</p>\n\t\t\t\t\t<ul>{$reports_list}</ul>\n\t\t\t\t\t<p><strong>Name Format:</strong><br>"; form_text_box('name_format', '<name> (1)', '', '255', '30', 'text'); print "</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n\n\t\t\t"; } elseif ($_POST['drp_action'] == REPORTS_ENABLE) { /* enable */ print "\t<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>Are you sure you wish to enable the following reports?</p>\n\t\t\t\t\t<ul>{$reports_list}</ul>\n\t\t\t\t\t<p><strong>Make sure, that those Reports have successfully been tested!</strong></p>\n\t\t\t\t</td>\n\t\t\t</tr>\n\n\t\t\t"; } elseif ($_POST['drp_action'] == REPORTS_DISABLE) { /* disable */ print "\t<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>Are you sure you wish to disable the following reports?</p>\n\t\t\t\t\t<ul>{$reports_list}</ul>\n\t\t\t\t</td>\n\t\t\t</tr>\n\n\t\t\t"; } elseif ($_POST['drp_action'] == REPORTS_SEND_NOW) { /* send now */ print "\t<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>Are you sure you want to send the following reports now?</p>\n\t\t\t\t\t<ul>{$reports_list}</ul>\n\t\t\t\t</td>\n\t\t\t</tr>\n\n\t\t\t"; } } print "\t<tr>\n\t\t<td align='right' class='saveRow'>\n\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t<input type='hidden' name='selected_items' value='" . (isset($reports_array) ? serialize($reports_array) : '') . "'>\n\t\t\t<input type='hidden' name='drp_action' value='" . $_POST['drp_action'] . "'>\n\t\t\t<input type='button' onClick='goTo(\"" . get_reports_page() . "\")' value='" . ($save_html == '' ? 'Return' : 'No') . "' name='cancel'>\n\t\t\t{$save_html}\n\t\t</td>\n\t</tr>"; html_end_box(); bottom_footer(); }