function form_save() { global $export_types, $export_errors; /* ================= input validation ================= */ input_validate_input_number(get_request_var_post('export_item_id')); /* ==================================================== */ if (isset($_POST['save_component_export'])) { $export_errors = 0; $xml_data = get_item_xml($_POST['export_type'], $_POST['export_item_id'], (isset($_POST['include_deps']) ? $_POST['include_deps'] : '') == '' ? false : true); if ($_POST['output_format'] == '1') { top_header(); print "<table width='100%' align='center'><tr><td><pre>" . htmlspecialchars($xml_data) . '</pre></td></tr></table>'; bottom_footer(); } elseif ($_POST['output_format'] == '2') { header('Content-type: application/xml'); if ($export_errors) { echo "WARNING: Export Errors Encountered. Refresh Browser Window for Details!\n"; } print $xml_data; } elseif ($_POST['output_format'] == '3') { if ($export_errors) { header('Location: templates_export.php'); } else { header('Content-type: application/xml'); header('Content-Disposition: attachment; filename=cacti_' . $_POST['export_type'] . '_' . strtolower(clean_up_file_name(db_fetch_cell(str_replace('|id|', $_POST['export_item_id'], $export_types[$_POST['export_type']]['title_sql'])))) . '.xml'); print $xml_data; } } } }
function ds_edit() { global $struct_data_source, $struct_data_source_item, $data_source_types; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('id')); input_validate_input_number(get_request_var_request('host_id')); /* ==================================================== */ api_plugin_hook('data_source_edit_top'); $use_data_template = true; $host_id = 0; if (!empty($_REQUEST['id'])) { $data_local = db_fetch_row_prepared('SELECT host_id, data_template_id FROM data_local WHERE id = ?', array($_REQUEST['id'])); $data = db_fetch_row_prepared('SELECT * FROM data_template_data WHERE local_data_id = ?', array($_REQUEST['id'])); if (isset($data_local['data_template_id']) && $data_local['data_template_id'] >= 0) { $data_template = db_fetch_row_prepared('SELECT id, name FROM data_template WHERE id = ?', array($data_local['data_template_id'])); $data_template_data = db_fetch_row_prepared('SELECT * FROM data_template_data WHERE data_template_id = ? AND local_data_id = 0', array($data_local['data_template_id'])); } else { $_SESSION['sess_messages'] = 'Data Source "' . $_REQUEST['id'] . '" does not exist.'; header('Location: data_sources.php'); exit; } $header_label = '[edit: ' . htmlspecialchars(get_data_source_title($_REQUEST['id'])) . ']'; if (empty($data_local['data_template_id'])) { $use_data_template = false; } } else { $header_label = '[new]'; $use_data_template = false; } /* handle debug mode */ if (isset($_REQUEST['debug'])) { if ($_REQUEST['debug'] == '0') { kill_session_var('ds_debug_mode'); } elseif ($_REQUEST['debug'] == '1') { $_SESSION['ds_debug_mode'] = true; } } top_header(); if (!empty($_REQUEST['id'])) { ?> <table width='100%' align='center'> <tr> <td class='textInfo' colspan='2' valign='top'> <?php print htmlspecialchars(get_data_source_title($_REQUEST['id'])); ?> </td> <td class='textInfo' align='right' valign='top'> <span class='linkMarker'>*<a href='<?php print htmlspecialchars('data_sources.php?action=ds_edit&id=' . (isset($_REQUEST['id']) ? $_REQUEST['id'] : '0')); ?> &debug=<?php print isset($_SESSION['ds_debug_mode']) ? '0' : '1'; ?> '>Turn <strong><?php print isset($_SESSION['ds_debug_mode']) ? 'Off' : 'On'; ?> </strong> Data Source Debug Mode.</a><br> <?php if (!empty($data_template['id'])) { ?> <span class='linkMarker'>*<a href='<?php print htmlspecialchars('data_templates.php?action=template_edit&id=' . (isset($data_template['id']) ? $data_template['id'] : '0')); ?> '>Edit Data Template.</a><br><?php } if (!empty($_REQUEST['host_id']) || !empty($data_local['host_id'])) { ?> <span class='linkMarker'>*<a href='<?php print htmlspecialchars('host.php?action=edit&id=' . (isset($_REQUEST['host_id']) ? $_REQUEST['host_id'] : $data_local['host_id'])); ?> '>Edit Device.</a><br><?php } ?> </td> </tr> </table> <br> <?php } html_start_box("<strong>Data Template Selection</strong> {$header_label}", '100%', '', '3', 'center', ''); $form_array = array('data_template_id' => array('method' => 'drop_sql', 'friendly_name' => 'Selected Data Template', 'description' => 'The name given to this data template.', 'value' => isset($data_template) ? $data_template['id'] : '0', 'none_value' => 'None', 'sql' => 'SELECT id,name FROM data_template order by name'), 'host_id' => array('method' => 'drop_sql', 'friendly_name' => 'Device', 'description' => 'Choose the host that this graph belongs to.', 'value' => isset($_REQUEST['host_id']) ? $_REQUEST['host_id'] : $data_local['host_id'], 'none_value' => 'None', 'sql' => "SELECT id,CONCAT_WS('',description,' (',hostname,')') as name FROM host order by description,hostname"), '_data_template_id' => array('method' => 'hidden', 'value' => isset($data_template) ? $data_template['id'] : '0'), '_host_id' => array('method' => 'hidden', 'value' => empty($data_local['host_id']) ? isset($_REQUEST['host_id']) ? $_REQUEST['host_id'] : '0' : $data_local['host_id']), '_data_input_id' => array('method' => 'hidden', 'value' => isset($data['data_input_id']) ? $data['data_input_id'] : '0'), 'data_template_data_id' => array('method' => 'hidden', 'value' => isset($data) ? $data['id'] : '0'), 'local_data_template_data_id' => array('method' => 'hidden', 'value' => isset($data) ? $data['local_data_template_data_id'] : '0'), 'local_data_id' => array('method' => 'hidden', 'value' => isset($data) ? $data['local_data_id'] : '0')); draw_edit_form(array('config' => array(), 'fields' => $form_array)); html_end_box(); /* only display the "inputs" area if we are using a data template for this data source */ if (!empty($data['data_template_id'])) { $template_data_rrds = db_fetch_assoc_prepared('SELECT * FROM data_template_rrd WHERE local_data_id = ? ORDER BY data_source_name', array($_REQUEST['id'])); html_start_box('<strong>Supplemental Data Template Data</strong>', '100%', '', '3', 'center', ''); draw_nontemplated_fields_data_source($data['data_template_id'], $data['local_data_id'], $data, '|field|', '<strong>Data Source Fields</strong>', true, true, 0); draw_nontemplated_fields_data_source_item($data['data_template_id'], $template_data_rrds, '|field|_|id|', '<strong>Data Source Item Fields</strong>', true, true, true, 0); draw_nontemplated_fields_custom_data($data['id'], 'value_|id|', '<strong>Custom Data</strong>', true, true, 0); form_hidden_box('save_component_data', '1', ''); html_end_box(); } if ((isset($_REQUEST['id']) || isset($_REQUEST['new'])) && empty($data['data_template_id'])) { html_start_box('<strong>Data Source</strong>', '100%', '', '3', 'center', ''); $form_array = array(); while (list($field_name, $field_array) = each($struct_data_source)) { $form_array += array($field_name => $struct_data_source[$field_name]); if (!($use_data_template == false || !empty($data_template_data['t_' . $field_name]) || $field_array['flags'] == 'NOTEMPLATE')) { $form_array[$field_name]['description'] = ''; } $form_array[$field_name]['value'] = isset($data[$field_name]) ? $data[$field_name] : ''; $form_array[$field_name]['form_id'] = empty($data['id']) ? '0' : $data['id']; if (!($use_data_template == false || !empty($data_template_data['t_' . $field_name]) || $field_array['flags'] == 'NOTEMPLATE')) { $form_array[$field_name]['method'] = 'template_' . $form_array[$field_name]['method']; } } draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => inject_form_variables($form_array, isset($data) ? $data : array()))); html_end_box(); /* fetch ALL rrd's for this data source */ if (!empty($_REQUEST['id'])) { $template_data_rrds = db_fetch_assoc_prepared('SELECT id, data_source_name FROM data_template_rrd WHERE local_data_id = ? ORDER BY data_source_name', array($_REQUEST['id'])); } /* select the first "rrd" of this data source by default */ if (empty($_REQUEST['view_rrd'])) { $_REQUEST['view_rrd'] = isset($template_data_rrds[0]['id']) ? $template_data_rrds[0]['id'] : '0'; } /* get more information about the rrd we chose */ if (!empty($_REQUEST['view_rrd'])) { $local_data_template_rrd_id = db_fetch_cell_prepared('SELECT local_data_template_rrd_id FROM data_template_rrd WHERE id = ?', array($_REQUEST['view_rrd'])); $rrd = db_fetch_row_prepared('SELECT * FROM data_template_rrd WHERE id = ?', array($_REQUEST['view_rrd'])); $rrd_template = db_fetch_row_prepared('SELECT * FROM data_template_rrd WHERE id = ?', array($local_data_template_rrd_id)); $header_label = '[edit: ' . $rrd['data_source_name'] . ']'; } else { $header_label = ''; } $i = 0; if (isset($template_data_rrds)) { if (sizeof($template_data_rrds) > 1) { /* draw the data source tabs on the top of the page */ print "\t<table class='tabs' width='100%' cellspacing='0' cellpadding='3' align='center'>\n\t\t\t\t\t<tr>\n"; foreach ($template_data_rrds as $template_data_rrd) { $i++; print "\t<td " . ($template_data_rrd['id'] == $_REQUEST['view_rrd'] ? "class='even'" : "class='odd'") . " width='" . (strlen($template_data_rrd['data_source_name']) * 9 + 50) . "' align='center' class='tab'>\n\t\t\t\t\t\t\t\t<span class='textHeader'><a href='" . htmlspecialchars('data_sources.php?action=ds_edit&id=' . $_REQUEST['id'] . '&view_rrd=' . $template_data_rrd['id']) . "'>{$i}: " . htmlspecialchars($template_data_rrd['data_source_name']) . '</a>' . ($use_data_template == false ? " <a href='" . htmlspecialchars('data_sources.php?action=rrd_remove&id=' . $template_data_rrd['id'] . '&local_data_id=' . $_REQUEST['id']) . "'><img src='images/delete_icon.gif' border='0' alt='Delete'></a>" : '') . "</span>\n\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t<td width='1'></td>\n"; } print "\n\t\t\t\t\t<td></td>\n\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n"; } elseif (sizeof($template_data_rrds) == 1) { $_REQUEST['view_rrd'] = $template_data_rrds[0]['id']; } } html_start_box('', '100%', '', '3', 'center', ''); print "\t<tr>\n\t\t\t\t<td class='textHeaderDark'>\n\t\t\t\t\t<strong>Data Source Item</strong> {$header_label}\n\t\t\t\t</td>\n\t\t\t\t<td class='textHeaderDark' align='right'>\n\t\t\t\t\t" . (!empty($_REQUEST['id']) && empty($data_template['id']) ? "<strong><a class='linkOverDark' href='" . htmlspecialchars('data_sources.php?action=rrd_add&id=' . $_REQUEST['id']) . "'>New</a> </strong>" : '') . "\n\t\t\t\t</td>\n\t\t\t</tr>\n"; /* data input fields list */ if (empty($data['data_input_id']) || db_fetch_cell_prepared('SELECT type_id FROM data_input WHERE id = ?', array($data['data_input_id'])) > '1') { unset($struct_data_source_item['data_input_field_id']); } else { $struct_data_source_item['data_input_field_id']['sql'] = "SELECT id,CONCAT(data_name,' - ',name) as name FROM data_input_fields WHERE data_input_id=" . $data['data_input_id'] . " and input_output='out' and update_rra='on' order by data_name,name"; } $form_array = array(); while (list($field_name, $field_array) = each($struct_data_source_item)) { $form_array += array($field_name => $struct_data_source_item[$field_name]); if (!($use_data_template == false || $rrd_template['t_' . $field_name] == 'on')) { $form_array[$field_name]['description'] = ''; } $form_array[$field_name]['value'] = isset($rrd) ? $rrd[$field_name] : ''; if (!($use_data_template == false || $rrd_template['t_' . $field_name] == 'on')) { $form_array[$field_name]['method'] = 'template_' . $form_array[$field_name]['method']; } } draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => array('data_template_rrd_id' => array('method' => 'hidden', 'value' => isset($rrd) ? $rrd['id'] : '0'), 'local_data_template_rrd_id' => array('method' => 'hidden', 'value' => isset($rrd) ? $rrd['local_data_template_rrd_id'] : '0')) + $form_array)); html_end_box(); /* data source data goes here */ data_edit(); form_hidden_box('current_rrd', $_REQUEST['view_rrd'], '0'); } /* display the debug mode box if the user wants it */ if (isset($_SESSION['ds_debug_mode']) && isset($_REQUEST['id'])) { ?> <table width='100%' align='center'> <tr> <td> <span class='textInfo'>Data Source Debug</span><br> <pre><?php print @rrdtool_function_create($_REQUEST['id'], true); ?> </pre> </td> </tr> </table> <?php } if (isset($_REQUEST['id']) || isset($_REQUEST['new'])) { form_hidden_box('save_component_data_source', '1', ''); } else { form_hidden_box('save_component_data_source_new', '1', ''); } form_save_button('data_sources.php'); api_plugin_hook('data_source_edit_bottom'); bottom_footer(); }
function host_remove() { global $config; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('id')); /* ==================================================== */ if (read_config_option('deletion_verification') == 'on' && !isset($_REQUEST['confirm'])) { top_header(); form_confirm('Are You Sure?', "Are you sure you want to delete the host <strong>'" . htmlspecialchars(db_fetch_cell_prepared('SELECT description FROM host WHERE id = ?', array($_REQUEST['id']))) . "'</strong>?", htmlspecialchars('host.php'), htmlspecialchars('host.php?action=remove&id=' . $_REQUEST['id'])); bottom_footer(); exit; } if (read_config_option('deletion_verification') == '' || isset($_REQUEST['confirm'])) { api_device_remove($_REQUEST['id']); } }
function mactrack_site_remove() { global $config; /* ================= input validation ================= */ get_filter_request_var('site_id'); /* ==================================================== */ if (read_config_option('remove_verification') == 'on' && !isset_request_var('confirm')) { top_header(); form_confirm(__('Are You Sure?'), __("Are you sure you want to delete the site <strong>'%s'</strong>?", db_fetch_cell('SELECT description FROM host WHERE id=' . get_request_var('device_id'))), 'mactrack_sites.php', 'mactrack_sites.php?action=remove&site_id=' . get_request_var('site_id')); bottom_footer(); exit; } if (read_config_option('remove_verification') == '' || isset_request_var('confirm')) { api_mactrack_site_remove(get_request_var('site_id')); } }
function utilities_view_logfile() { global $log_tail_lines, $page_refresh_interval, $refresh; $logfile = read_config_option('path_cactilog'); if ($logfile == '') { $logfile = './log/rrd.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')); /* if the user pushed the 'clear' button */ if (isset($_REQUEST['clear_x'])) { kill_session_var('sess_logfile_tail_lines'); kill_session_var('sess_logfile_message_type'); kill_session_var('sess_logfile_filter'); kill_session_var('sess_logfile_refresh'); kill_session_var('sess_logfile_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_logfile_tail_lines', read_config_option('num_rows_log')); load_current_session_value('message_type', 'sess_logfile_message_type', '-1'); load_current_session_value('filter', 'sess_logfile_filter', ''); load_current_session_value('refresh', 'sess_logfile_refresh', read_config_option('log_refresh_interval')); load_current_session_value('reverse', 'sess_logfile_reverse', 1); load_current_session_value('rows', 'sess_default_rows', read_config_option('num_rows_table')); $_REQUEST['page_referrer'] = 'view_logfile'; load_current_session_value('page_referrer', 'page_referrer', 'view_logfile'); $refresh['seconds'] = get_request_var_request('refresh'); $refresh['page'] = 'utilities.php?action=view_logfile'; top_header(); ?> <script type="text/javascript"> <!-- function purgeLog() { strURL = '?action=view_logfile&purge_x=1&header=false'; $.get(strURL, function(data) { $('#main').html(data); applySkin(); }); } $(function() { $('#refreshme').click(function() { applyFilter(); }); $('#clear').click(function() { clearFilter(); }); $('#purge').click(function() { purgeLog(); }); $('#form_logfile').submit(function(event) { event.preventDefault(); applyFilter(); }); }); function applyFilter() { strURL = '?tail_lines=' + $('#tail_lines').val(); strURL = strURL + '&message_type=' + $('#message_type').val(); strURL = strURL + '&refresh=' + $('#refresh').val(); strURL = strURL + '&reverse=' + $('#reverse').val(); strURL = strURL + '&filter=' + $('#filter').val(); strURL = strURL + '&action=view_logfile'; strURL = strURL + '&header=false'; refreshMSeconds=$('#refresh').val()*1000; $.get(strURL, function(data) { $('#main').html(data); applySkin(); }); } function clearFilter() { strURL = '?clear_x=1'; strURL = strURL + '&action=view_logfile'; strURL = strURL + '&header=false'; $.get(strURL, function(data) { $('#main').html(data); applySkin(); }); } --> </script> <?php html_start_box('<strong>Log File Filters</strong>', '100%', '', '3', 'center', ''); ?> <tr class='even noprint'> <td> <form id="form_logfile" action="utilities.php"> <table cellpadding="2" cellspacing="0" border="0"> <tr> <td style='white-space: nowrap;' width="80"> Tail Lines </td> <td> <select id='tail_lines' name="tail_lines" onChange="applyFilter()"> <?php foreach ($log_tail_lines as $tail_lines => $display_text) { print "<option value='" . $tail_lines . "'"; if (get_request_var_request('tail_lines') == $tail_lines) { print ' selected'; } print '>' . $display_text . "</option>\n"; } ?> </select> </td> <td style='white-space: nowrap;'> Message Type </td> <td> <select id='message_type' name="message_type" onChange="applyFilter()"> <option value="-1"<?php if (get_request_var_request('message_type') == '-1') { ?> selected<?php } ?> >All</option> <option value="1"<?php if (get_request_var_request('message_type') == '1') { ?> selected<?php } ?> >Stats</option> <option value="2"<?php if (get_request_var_request('message_type') == '2') { ?> selected<?php } ?> >Warnings</option> <option value="3"<?php if (get_request_var_request('message_type') == '3') { ?> selected<?php } ?> >Errors</option> <option value="4"<?php if (get_request_var_request('message_type') == '4') { ?> selected<?php } ?> >Debug</option> <option value="5"<?php if (get_request_var_request('message_type') == '5') { ?> selected<?php } ?> >SQL Calls</option> </select> </td> <td> <input type="button" id='refreshme' name="go" value="Go" title="Set/Refresh Filters"> </td> <td> <input type="button" id='clear' name="clear_x" value="Clear" title="Clear Filters"> </td> <td> <input type="button" id='purge' name="purge_x" value="Purge" title="Purge Log File"> </td> </tr> <tr> <td> Refresh </td> <td> <select id='refresh' name="refresh" onChange="applyFilter()"> <?php foreach ($page_refresh_interval as $seconds => $display_text) { print "<option value='" . $seconds . "'"; if (get_request_var_request('refresh') == $seconds) { print ' selected'; } print '>' . $display_text . "</option>\n"; } ?> </select> </td> <td style='white-space: nowrap;'> Display Order </td> <td> <select id='reverse' name="reverse" onChange="applyFilter()"> <option value="1"<?php if (get_request_var_request('reverse') == '1') { ?> selected<?php } ?> >Newest First</option> <option value="2"<?php if (get_request_var_request('reverse') == '2') { ?> selected<?php } ?> >Oldest First</option> </select> </td> </tr> </table> <table cellpadding="2" cellspacing="0" border="0"> <tr> <td width="80"> Search </td> <td> <input id='filter' type="text" name="filter" size="75" value="<?php print htmlspecialchars(get_request_var_request('filter')); ?> "> </td> </tr> </table> <input type='hidden' name='action' value='view_logfile'> </form> </td> </tr> <?php html_end_box(); /* read logfile into an array and display */ $logcontents = tail_file($logfile, get_request_var_request('tail_lines'), get_request_var_request('message_type'), get_request_var_request('filter')); if (get_request_var_request('reverse') == 1) { $logcontents = array_reverse($logcontents); } if (get_request_var_request('message_type') > 0) { $start_string = '<strong>Log File</strong> [Total Lines: ' . sizeof($logcontents) . ' - Non-Matching Items Hidden]'; } else { $start_string = '<strong>Log File</strong> [Total Lines: ' . sizeof($logcontents) . ' - All Items Shown]'; } html_start_box($start_string, '100%', '', '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 + 5, $host_end - ($host_start + 5)); $new_item = $new_item . substr($item, 0, $host_start + 5) . "<a href='" . htmlspecialchars('host.php?action=edit&id=' . $host_id) . "'>" . substr($item, $host_start + 5, $host_end - ($host_start + 5)) . '</a>'; $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)); $new_item = $new_item . substr($item, 0, $ds_start + 3) . "<a href='" . htmlspecialchars('data_sources.php?action=ds_edit&id=' . $ds_id) . "'>" . substr($item, $ds_start + 3, $ds_end - ($ds_start + 3)) . '</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; } ?> <tr bgcolor='#<?php print $bgcolor; ?> '> <td> <?php print $new_item; ?> </td> </tr> <?php $j++; $i++; if ($j > 1000) { ?> <tr bgcolor='#EACC00'> <td> <?php print '>>>> LINE LIMIT OF 1000 LINES REACHED!! <<<<'; ?> </td> </tr> <?php break; } } html_end_box(); bottom_footer(); }
function thold_add_graphs_action_prepare() { global $config; $local_graph_id = get_filter_request_var('local_graph_id'); top_header(); html_start_box(__('Create Threshold from Template'), '60%', '', '3', 'center', ''); form_start('thold.php?action=add'); /* get the valid thold templates * remove those hosts that do not have any valid templates */ $templates = ''; $found_list = ''; $not_found = ''; $data_template_id = db_fetch_cell("SELECT dtr.data_template_id\n\t\t FROM data_template_rrd AS dtr\n\t\t LEFT JOIN graph_templates_item AS gti\n\t\t ON gti.task_item_id=dtr.id\n\t\t LEFT JOIN graph_local AS gl\n\t\t ON gl.id=gti.local_graph_id\n\t\t WHERE gl.id={$local_graph_id}"); if ($data_template_id != '') { if (sizeof(db_fetch_assoc("SELECT id FROM thold_template WHERE data_template_id={$data_template_id}"))) { $found_list .= '<li>' . get_graph_title($local_graph_id) . '</li>'; if (strlen($templates)) { $templates .= ", {$data_template_id}"; } else { $templates = "{$data_template_id}"; } } else { $not_found .= '<li>' . get_graph_title($local_graph_id) . '</li>'; } } else { $not_found .= '<li>' . get_graph_title($local_graph_id) . '</li>'; } if (strlen($templates)) { $sql = 'SELECT id, name FROM thold_template WHERE data_template_id IN (' . $templates . ') ORDER BY name'; } else { $sql = 'SELECT id, name FROM thold_template ORDER BY name'; } print "<tr><td colspan='2' class='textArea'>\n"; if (strlen($found_list)) { if (strlen($not_found)) { print '<p>' . __('The following Graph has no Threshold Templates associated with them.') . '</p>'; print '<ul>' . $not_found . '</ul>'; } print '<p>' . __('Are you sure you wish to create Thresholds for this Graph?') . ' <ul>' . $found_list . "</ul>\n\t\t\t</td>\n\t\t</tr>\n"; if (isset_request_var('tree_id')) { get_filter_request_var('tree_id'); } else { set_request_var('tree_id', ''); } if (isset_request_var('leaf_id')) { get_filter_request_var('leaf_id'); } else { set_request_var('leaf_id', ''); } $form_array = array('general_header' => array('friendly_name' => __('Available Threshold Templates'), 'method' => 'spacer'), 'thold_template_id' => array('method' => 'drop_sql', 'friendly_name' => __('Select a Threshold Template'), 'description' => '', 'none_value' => __('None'), 'value' => __('None'), 'sql' => $sql), 'usetemplate' => array('method' => 'hidden', 'value' => 1), 'local_graph_id' => array('method' => 'hidden', 'value' => $local_graph_id)); draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => $form_array)); } else { if (strlen($not_found)) { print '<p>' . __('There are no Threshold Templates associated with the following Graph.') . '</p>'; print '<ul>' . $not_found . '</ul>'; } $form_array = array('general_header' => array('friendly_name' => __('Please select an action'), 'method' => 'spacer'), 'doaction' => array('method' => 'drop_array', 'friendly_name' => __('Threshold Action'), 'description' => __('You may either create a new Threshold Template, or an non-templated Threshold from this screen.'), 'value' => 'None', 'array' => array(1 => __('Create a new Threshold'), 2 => __('Create a Threshold Template'))), 'usetemplate' => array('method' => 'hidden', 'value' => 1), 'local_graph_id' => array('method' => 'hidden', 'value' => $local_graph_id)); draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => $form_array)); } if (!strlen($not_found)) { $save_html = "<input type='submit' value='" . __('Continue') . "'>"; print "<tr>\n\t\t\t<td colspan='2' class='saveRow'>\n\t\t\t\t<input type='hidden' id='action' value='actions'>\n\t\t\t\t<input type='button' onClick='cactiReturnTo()' value='" . __('Cancel') . "' title='" . __('Cancel') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n"; } else { $save_html = "<input type='submit' value='" . __('Continue') . "'>"; print "<tr>\n\t\t\t<td colspan='2' class='saveRow'>\n\t\t\t\t<input type='button' onClick='cactiReturnTo()' value='" . __('Cancel') . "' title='" . __('Cancel') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n"; } html_end_box(); print "<script type='text/javascript'>\$(function() { applySkin() ;});</script>"; bottom_footer(); }
function field_remove() { global $registered_cacti_names; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('id')); input_validate_input_number(get_request_var_request('data_input_id')); /* ==================================================== */ if (read_config_option('deletion_verification') == 'on' && !isset($_REQUEST['confirm'])) { top_header(); form_confirm('Are You Sure?', "Are you sure you want to delete the field <strong>'" . htmlspecialchars(db_fetch_cell_prepared('SELECT name FROM data_input_fields WHERE id = ?', array(get_request_var_request('id'))), ENT_QUOTES) . "'</strong>?", htmlspecialchars('data_input.php?action=edit&id=' . $_REQUEST['data_input_id']), htmlspecialchars('data_input.php?action=field_remove&id=' . $_REQUEST['id'] . '&data_input_id=' . $_REQUEST['data_input_id'])); bottom_footer(); exit; } if (read_config_option('deletion_verification') == '' || isset($_REQUEST['confirm'])) { /* get information about the field we're going to delete so we can re-order the seqs */ $field = db_fetch_row_prepared('SELECT input_output,data_input_id FROM data_input_fields WHERE id = ?', array(get_request_var_request('id'))); db_execute_prepared('DELETE FROM data_input_fields WHERE id = ?', array(get_request_var_request('id'))); db_execute_prepared('DELETE FROM data_input_data WHERE data_input_field_id = ?', array(get_request_var_request('id'))); /* when a field is deleted; we need to re-order the field sequences */ if ($field['input_output'] == 'in' && preg_match_all('/<([_a-zA-Z0-9]+)>/', db_fetch_cell_prepared('SELECT input_string FROM data_input WHERE id = ?', array($field['data_input_id'])), $matches)) { $j = 0; for ($i = 0; $i < count($matches[1]); $i++) { if (in_array($matches[1][$i], $registered_cacti_names) == false) { $j++; db_execute_prepared("UPDATE data_input_fields SET sequence = ? WHERE data_input_id = ? AND input_output = 'in' AND data_name = ?", array($j, $field['data_input_id'], $matches[1][$i])); } } } } }
function form_actions() { global $colors, $user_actions, $fields_user_edit; /* ================= 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'] == '1') { /* delete */ if (!isset($_POST['delete_type'])) { $_POST['delete_type'] = 2; } $data_sources_to_act_on = array(); $graphs_to_act_on = array(); $devices_to_act_on = array(); for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ $selected_items[$i] = sanitize_search_string($selected_items[$i]); /* ==================================================== */ $data_sources = db_fetch_assoc('SELECT data_local.id AS local_data_id FROM data_local WHERE ' . array_to_sql_or($selected_items, 'data_local.snmp_index') . "\n\t\t\t\t\tAND snmp_query_id='" . mikrotik_data_query_by_hash('ce63249e6cc3d52bc69659a3f32194fe') . "'"); if (sizeof($data_sources) > 0) { foreach ($data_sources as $data_source) { $data_sources_to_act_on[] = $data_source['local_data_id']; } } $graphs = db_fetch_assoc('SELECT graph_local.id AS local_graph_id FROM graph_local WHERE ' . array_to_sql_or($selected_items, 'graph_local.snmp_index') . "\n\t\t\t\t\tAND snmp_query_id='" . mikrotik_data_query_by_hash('ce63249e6cc3d52bc69659a3f32194fe') . "'"); if (sizeof($graphs) > 0) { foreach ($graphs as $graph) { $graphs_to_act_on[] = $graph['local_graph_id']; } } $devices_to_act_on[] = $selected_items[$i]; } api_data_source_remove_multi($data_sources_to_act_on); api_graph_remove_multi($graphs_to_act_on); db_execute("DELETE FROM plugin_mikrotik_users WHERE name IN ('" . implode("','", $devices_to_act_on) . "')"); } header('Location: mikrotik_users.php&header=false'); exit; } /* setup some variables */ $user_list = ''; /* loop through each of the user templates selected on the previous page and get more info about them */ while (list($var, $val) = each($_POST)) { if (preg_match('/^chk_([A-Z0-9]+)$/', $var, $matches)) { /* ================= input validation ================= */ $matches[1] = sanitize_search_string($matches[1]); /* ==================================================== */ $user_list .= '<li>' . $matches[1] . '</li>'; $user_array[] = $matches[1]; } } top_header(); html_start_box('<strong>' . $user_actions[$_POST['drp_action']] . '</strong>', '60%', '', '3', 'center', ''); print "<form action='mikrotik_users.php' autocomplete='off' method='post'>\n"; if (isset($user_array) && sizeof($user_array)) { if ($_POST['drp_action'] == '1') { /* delete */ print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\" the following Users(s) and their Graph(s) will be deleted.</p>\n\t\t\t\t\t\t<ul>" . $user_list . "</ul>"; print "</td></tr>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t"; $save_html = "<input type='button' value='Cancel' onClick='cactiReturnTo()'> <input type='submit' value='Continue' title='Delete Device(s)'>"; } } else { print "<tr><td><span class='textError'>You must select at least one User.</span></td></tr>\n"; $save_html = "<input type='button' value='Return' onClick='cactiReturnTo()'>"; } print "<tr class='saveRow'>\n\t\t<td colspan='2' align='right' bgcolor='#eaeaea'>\n\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t<input type='hidden' name='selected_items' value='" . (isset($user_array) ? serialize($user_array) : '') . "'>\n\t\t\t<input type='hidden' name='drp_action' value='" . $_POST["drp_action"] . "'>\n\t\t\t{$save_html}\n\t\t</td>\n\t</tr>\n"; html_end_box(); bottom_footer(); }
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_device_remove() { global $config; /* ================= input validation ================= */ get_filter_request_var('device_id'); get_filter_request_var('type_id'); /* ==================================================== */ if (read_config_option('remove_verification') == 'on' && !isset_request_var('confirm')) { top_header(); form_confirm(__('Are You Sure?'), __('Are you sure you want to delete the host %s', db_fetch_cell_prepared('SELECT device_name FROM host WHERE id = ?', array(get_request_var('device_id')))), 'mactrack_devices.php', 'mactrack_devices.php?action=remove&id=' . get_request_var('device_id')); bottom_footer(); exit; } if (read_config_option('remove_verification') == '' || isset_request_var('confirm')) { api_mactrack_device_remove(get_request_var('device_id')); } }
function hmib_view_graphs() { global $current_user, $colors, $config, $host_template_hashes, $graph_template_hashes; include './lib/timespan_settings.php'; include './lib/html_graph.php'; html_graph_validate_preview_request_vars(); if (!isset($_SESSION['sess_hmib_gt'])) { $_SESSION['sess_hmib_gt'] = implode(',', array_rekey(db_fetch_assoc('SELECT DISTINCT gl.graph_template_id FROM graph_local AS gl WHERE gl.host_id IN( SELECT host_id FROM plugin_hmib_hrSystem )'), 'graph_template_id', 'graph_template_id')); } $gt = $_SESSION['sess_hmib_gt']; if (!isset($_SESSION['sess_hmib_hosts'])) { $_SESSION['sess_hmib_hosts'] = implode(',', array_rekey(db_fetch_assoc('SELECT h.id FROM host AS h WHERE h.id IN ( SELECT host_id FROM plugin_hmib_hrSystem ) UNION SELECT h.id FROM host AS h INNER JOIN host_template AS ht ON h.host_template_id=ht.id WHERE hash="7c13344910097cc599f0d0485305361d" ORDER BY id DESC'), 'id', 'id')); } $hosts = $_SESSION['sess_hmib_hosts']; /* include graph view filter selector */ html_start_box(__('Graph Preview Filters') . (isset_request_var('style') && strlen(get_request_var('style')) ? ' [ ' . __('Custom Graph List Applied - Filtering from List') . ' ]' : ''), '100%', '', '3', 'center', ''); html_graph_preview_filter('hmib.php', 'graphs', "h.id IN ({$hosts})", "gt.id IN ({$gt})"); html_end_box(); /* the user select a bunch of graphs of the 'list' view and wants them displayed here */ $sql_or = ''; if (isset_request_var('style')) { if (get_request_var('style') == 'selective') { /* process selected graphs */ if (!isempty_request_var('graph_list')) { foreach (explode(',', get_request_var('graph_list')) as $item) { $graph_list[$item] = 1; } } else { $graph_list = array(); } if (!isempty_request_var('graph_add')) { foreach (explode(',', get_request_var('graph_add')) as $item) { $graph_list[$item] = 1; } } /* remove items */ if (!isempty_request_var('graph_remove')) { foreach (explode(',', get_request_var('graph_remove')) as $item) { unset($graph_list[$item]); } } $graph_array = array_keys($graph_list); if (sizeof($graph_array)) { $sql_or = array_to_sql_or($graph_array, 'gl.id'); } } } $total_graphs = 0; // Filter sql_where $sql_where = strlen(get_request_var('filter')) ? "gtg.title_cache LIKE '%" . get_request_var('filter') . "%'" : ''; $sql_where .= (strlen($sql_or) && strlen($sql_where) ? ' AND ' : '') . $sql_or; // Host Id sql_where if (get_request_var('host_id') > 0) { $sql_where .= (strlen($sql_where) ? ' AND' : '') . ' gl.host_id=' . get_request_var('host_id'); } // Graph Template Id sql_where if (get_request_var('graph_template_id') > 0) { $sql_where .= (strlen($sql_where) ? ' AND' : '') . ' gl.graph_template_id=' . get_request_var('graph_template_id'); } $limit = get_request_var('graphs') * (get_request_var('page') - 1) . ',' . get_request_var('graphs'); $order = 'gtg.title_cache'; $graphs = get_allowed_graphs($sql_where, $order, $limit, $total_graphs); /* do some fancy navigation url construction so we don't have to try and rebuild the url string */ if (preg_match('/page=[0-9]+/', basename($_SERVER['QUERY_STRING']))) { $nav_url = str_replace('&page=' . get_request_var('page'), '', get_browser_query_string()); } else { $nav_url = get_browser_query_string() . '&host_id=' . get_request_var('host_id'); } $nav_url = preg_replace('/((\\?|&)host_id=[0-9]+|(\\?|&)filter=[a-zA-Z0-9]*)/', '', $nav_url); $nav = html_nav_bar($nav_url, MAX_DISPLAY_PAGES, get_request_var('page'), get_request_var('graphs'), $total_graphs, get_request_var('columns'), 'Graphs', 'page', 'main'); print $nav; html_start_box('', '100%', '', '3', 'center', ''); if (get_request_var('thumbnails') == 'true') { html_graph_thumbnail_area($graphs, '', 'graph_start=' . get_current_graph_start() . '&graph_end=' . get_current_graph_end(), '', get_request_var('columns')); } else { html_graph_area($graphs, '', 'graph_start=' . get_current_graph_start() . '&graph_end=' . get_current_graph_end(), '', get_request_var('columns')); } html_end_box(); if ($total_graphs > 0) { print $nav; } bottom_footer(); }
function tree_remove() { /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('id')); /* ==================================================== */ if (read_config_option('deletion_verification') == 'on' && !isset($_REQUEST['confirm'])) { top_header(); form_confirm('Are You Sure?', "Are you sure you want to delete the tree <strong>'" . htmlspecialchars(db_fetch_cell_prepared('SELECT name FROM graph_tree WHERE id = ?', array($_REQUEST['id'])), ENT_QUOTES) . "'</strong>?", htmlspecialchars('tree.php'), htmlspecialchars('tree.php?action=remove&id=' . $_REQUEST['id'])); bottom_footer(); exit; } if (read_config_option('deletion_verification') == '' || isset($_REQUEST['confirm'])) { db_execute_prepared('DELETE FROM graph_tree WHERE id = ?', array($_REQUEST['id'])); db_execute_prepared('DELETE FROM graph_tree_items WHERE graph_tree_id = ?', array($_REQUEST['id'])); } /* clear graph tree cache on save - affects current user only, other users should see changes in <5 minutes */ if (isset($_SESSION['dhtml_tree'])) { unset($_SESSION['dhtml_tree']); } }
function form_actions() { global $rra_actions; /* ================= input validation ================= */ input_validate_input_regex(get_request_var_post('drp_action'), '^([a-zA-Z0-9_]+)$'); /* ==================================================== */ /* 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'] == '1') { /* delete */ db_execute('DELETE FROM rra WHERE ' . array_to_sql_or($selected_items, 'id')); db_execute('DELETE FROM rra_cf WHERE ' . array_to_sql_or($selected_items, 'rra_id')); } header('Location: rra.php'); exit; } /* setup some variables */ $rra_list = ''; $i = 0; /* loop through each of the rra 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]); /* ==================================================== */ $rra_list .= '<li>' . htmlspecialchars(db_fetch_cell_prepared('SELECT name FROM rra WHERE id = ?', array($matches[1]))) . '</li>'; $rra_array[$i] = $matches[1]; $i++; } } top_header(); print "<form action='rra.php' method='post'>\n"; html_start_box('<strong>' . $rra_actions[$_POST['drp_action']] . '</strong>', '60%', '', '3', 'center', ''); if (isset($rra_array) && sizeof($rra_array)) { if ($_POST['drp_action'] == '1') { /* delete */ print "\t<tr>\n\t\t\t\t\t<td class='textArea' class='odd'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the folling Round Robin Archive definition(s) will be deleted.</p>\n\t\t\t\t\t\t<ul>{$rra_list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Delete Round Robin Archive definition(s)'>"; } } else { print "<tr><td class='odd'><span class='textError'>You must select at least one Round Robin Archive definition.</span></td></tr>\n"; $save_html = "<input type='button' value='Return' onClick='window.history.back()'>"; } print "\t<tr>\n\t\t\t<td align='right' class='saveRow'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($rra_array) ? serialize($rra_array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . $_POST['drp_action'] . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n"; html_end_box(); bottom_footer(); }
function settings() { global $tabs_graphs, $settings_graphs, $current_user, $graph_views, $current_user; $current_user = db_fetch_row_prepared('SELECT * FROM user_auth WHERE id = ?', array($_SESSION['sess_user_id'])); /* you cannot have per-user graph settings if cacti's user management is not turned on */ if (read_config_option('auth_method') == 0) { raise_message(6); display_output_messages(); return; } /* Find out whether this user has right here */ if (!is_view_allowed('graph_settings')) { print "<strong><font class='txtErrorTextBox'>YOU DO NOT HAVE RIGHTS TO CHANGE GRAPH SETTINGS</font></strong>"; bottom_footer(); exit; } if (read_config_option('auth_method') != 0) { $settings_graphs['tree']['default_tree_id']['sql'] = get_graph_tree_array(true); } print "<form method='post' action='graph_settings.php'>\n"; html_start_box('<strong>Graph Settings</strong>', '100%', '', '3', 'center', ''); while (list($tab_short_name, $tab_fields) = each($settings_graphs)) { $collapsible = true; print "<tr class='spacer tableHeader" . ($collapsible ? ' collapsible' : '') . "' id='row_{$tab_short_name}'><td colspan='2' style='cursor:pointer;' class='tableSubHeaderColumn'>" . $tabs_graphs[$tab_short_name] . ($collapsible ? "<div style='float:right;padding-right:4px;'><i class='fa fa-angle-double-up'></i></div>" : "") . "</td></tr>\n"; $form_array = array(); while (list($field_name, $field_array) = each($tab_fields)) { $form_array += array($field_name => $tab_fields[$field_name]); if (isset($field_array['items']) && is_array($field_array['items'])) { while (list($sub_field_name, $sub_field_array) = each($field_array['items'])) { if (graph_config_value_exists($sub_field_name, $_SESSION['sess_user_id'])) { $form_array[$field_name]['items'][$sub_field_name]['form_id'] = 1; } $form_array[$field_name]['items'][$sub_field_name]['value'] = db_fetch_cell_prepared('SELECT value FROM settings_graphs WHERE name = ? AND user_id = ?', array($sub_field_name, $_SESSION['sess_user_id'])); } } else { if (graph_config_value_exists($field_name, $_SESSION['sess_user_id'])) { $form_array[$field_name]['form_id'] = 1; } $form_array[$field_name]['value'] = db_fetch_cell_prepared('SELECT value FROM settings_graphs WHERE name = ? AND user_id = ?', array($field_name, $_SESSION['sess_user_id'])); } } draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => $form_array)); } html_end_box(); ?> <script type="text/javascript"> <!-- var themeFonts=<?php print read_config_option('font_method'); ?> ; function graphSettings() { if (themeFonts == 1) { $('#row_fonts').hide(); $('#row_custom_fonts').hide(); $('#row_title_size').hide(); $('#row_title_font').hide(); $('#row_legend_size').hide(); $('#row_legend_font').hide(); $('#row_axis_size').hide(); $('#row_axis_font').hide(); $('#row_unit_size').hide(); $('#row_unit_font').hide(); }else{ var custom_fonts = $('#custom_fonts').is(':checked'); switch(custom_fonts) { case true: $('#row_fonts').show(); $('#row_title_size').show(); $('#row_title_font').show(); $('#row_legend_size').show(); $('#row_legend_font').show(); $('#row_axis_size').show(); $('#row_axis_font').show(); $('#row_unit_size').show(); $('#row_unit_font').show(); break; case false: $('#row_fonts').show(); $('#row_title_size').hide(); $('#row_title_font').hide(); $('#row_legend_size').hide(); $('#row_legend_font').hide(); $('#row_axis_size').hide(); $('#row_axis_font').hide(); $('#row_unit_size').hide(); $('#row_unit_font').hide(); break; } } if ($('#timespan_sel').is(':checked')) { $('#row_default_rra_id').hide(); $('#row_default_timespan').show(); $('#row_default_timeshift').show(); $('#row_allow_graph_dates_in_future').show(); $('#row_first_weekdayid').show(); $('#row_day_shift_start').show(); $('#row_day_shift_end').show(); } else { $('#row_default_rra_id').show(); $('#row_default_timespan').hide(); $('#row_default_timeshift').hide(); $('#row_allow_graph_dates_in_future').hide(); $('#row_first_weekdayid').hide(); $('#row_day_shift_start').hide(); $('#row_day_shift_end').hide(); } } $(function() { graphSettings(); $('#navigation').show(); $('#navigation_right').show(); $('input[value="Save"]').click(function(event) { event.preventDefault(); href='<?php print $_SERVER['HTTP_REFERER']; ?> '; href=href+(href.indexOf('?') > 0 ? '&':'?')+'header=false'; $.post('graph_settings.php?header=false', $('input, select, textarea').serialize()).done(function(data) { document.location='<?php print $_SERVER['HTTP_REFERER']; ?> '; }); }); $('#timespan_sel').change(function() { graphSettings(); }); }); --> </script> <?php if (isset($_SERVER['HTTP_REFERER'])) { $timespan_sel_pos = strpos($_SERVER['HTTP_REFERER'], '&predefined_timespan'); if ($timespan_sel_pos) { $_SERVER['HTTP_REFERER'] = substr($_SERVER['HTTP_REFERER'], 0, $timespan_sel_pos); } } $_SESSION['graph_settings_referer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'graph_view.php'; form_hidden_box('save_component_graph_config', '1', ''); form_save_button('graph_settings.php', 'save'); }
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 form_actions() { global $config, $syslog_actions, $fields_syslog_action_edit; include dirname(__FILE__) . '/config.php'; get_filter_request_var('drp_action', FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^([a-zA-Z0-9_]+)$/'))); /* if we are to save this form, instead of display it */ if (isset_request_var('selected_items')) { $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); if ($selected_items != false) { if (get_request_var('drp_action') == '1') { /* delete */ for ($i = 0; $i < count($selected_items); $i++) { api_syslog_removal_remove($selected_items[$i]); } } else { if (get_request_var('drp_action') == '2') { /* disable */ for ($i = 0; $i < count($selected_items); $i++) { api_syslog_removal_disable($selected_items[$i]); } } else { if (get_request_var('drp_action') == '3') { /* enable */ for ($i = 0; $i < count($selected_items); $i++) { api_syslog_removal_enable($selected_items[$i]); } } else { if (get_request_var('drp_action') == '4') { /* reprocess */ for ($i = 0; $i < count($selected_items); $i++) { api_syslog_removal_reprocess($selected_items[$i]); } } } } } } header('Location: syslog_removal.php?header=false'); exit; } top_header(); form_start('syslog_removal.php'); html_start_box($syslog_actions[get_request_var('drp_action')], '60%', '', '3', 'center', ''); /* setup some variables */ $removal_array = array(); $removal_list = ''; /* loop through each of the clusters 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]); /* ==================================================== */ $removal_info = syslog_db_fetch_cell("SELECT name FROM `" . $syslogdb_default . "`.`syslog_remove` WHERE id=" . $matches[1]); $removal_list .= '<li>' . $removal_info . '</li>'; $removal_array[] = $matches[1]; } } if (sizeof($removal_array)) { if (get_request_var('drp_action') == '1') { /* delete */ print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Click \'Continue\' to Delete the following Syslog Removal Rule(s).') . "</p>\n\t\t\t\t\t<ul>{$removal_list}</ul>"; print "</td></tr>\n\t\t\t\t</td>\n\t\t\t</tr>\n"; $title = __('Delete Syslog Removal Rule(s)'); } else { if (get_request_var('drp_action') == '2') { /* disable */ print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Click \'Continue\' to Disable the following Syslog Removal Rule(s).') . "</p>\n\t\t\t\t\t<ul>{$removal_list}</ul>"; print "</td></tr>\n\t\t\t\t</td>\n\t\t\t</tr>\n"; $title = __('Disable Syslog Removal Rule(s)'); } else { if (get_request_var('drp_action') == '3') { /* enable */ print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Click \'Continue\' to Enable the following Syslog Removal Rule(s).') . "</p>\n\t\t\t\t\t<ul>{$removal_list}</ul>"; print "</td></tr>\n\t\t\t\t</td>\n\t\t\t</tr>\n"; $title = __('Enable Syslog Removal Rule(s)'); } else { if (get_request_var('drp_action') == '4') { /* reprocess */ print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Click \'Continue\' to Re-process the following Syslog Removal Rule(s).') . "</p>\n\t\t\t\t\t<ul>{$removal_list}</ul>"; print "</td></tr>\n\t\t\t\t</td>\n\t\t\t</tr>\n"; $title = __('Retroactively Process Syslog Removal Rule(s)'); } } } } $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='{$title}'"; } else { print "<tr><td class='even'><span class='textError'>" . __('You must select at least one Syslog Removal Rule.') . "</span></td></tr>\n"; $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>"; } 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($removal_array) ? serialize($removal_array) : '') . "'>\n\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t{$save_html}\n\t\t</td>\n\t</tr>\n"; html_end_box(); form_end(); bottom_footer(); }
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 form_aggregated_actions() { global $config, $mactrack_view_agg_macs_actions; /* ================= input validation ================= */ get_filter_request_var('drp_action'); /* ==================================================== */ /* if we are to save this form, instead of display it */ if (isset_request_var('selected_items')) { $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); if ($selected_items != false) { if (get_request_var('drp_action') == '01') { /* Delete */ if (sizeof($selected_items)) { db_execute('DELETE FROM mac_track_aggregated_ports WHERE row_id IN (' . implode(',', $selected_items) . ')'); } } header('Location: mactrack_view_macs.php'); exit; } } /* setup some variables */ $row_array = array(); $mac_address_list = ''; $row_list = ''; $i = 0; $row_ids = ''; /* loop through each of the ports 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]); /* ==================================================== */ $row_array[] = $matches[1]; } } if (sizeof($row_array)) { $row_ids = implode(',', $row_array); $rows_info = db_fetch_assoc('SELECT device_name, mac_address, ip_address, port_number, count_rec FROM mac_track_aggregated_ports WHERE row_id IN (' . implode(',', $row_array) . ')'); if (isset($rows_info)) { foreach ($rows_info as $row_info) { $row_list .= '<li>' . __(' Dev.:%s IP.:%s MAC.:%s PORT.:%s Count.: [%s]', $row_info['device_name'], $row_info['ip_address'], $row_info['mac_address'], $row_info['port_number'], $row_info['count_rec']) . '</li>'; } } } top_header(); html_start_box($mactrack_view_agg_macs_actions[get_request_var('drp_action')], '60%', '', '3', 'center', ''); form_start('mactrack_view_macs.php'); if (!sizeof($row_array)) { print "<tr><td class='even'><span class='textError'>" . __('You must select at least one Row.') . "</span></td></tr>\n"; $save_html = ""; } else { if (!mactrack_check_user_realm(2122)) { print "<tr><td class='even'><span class='textError'>" . __('You are not permitted to delete rows.') . "</span></td></tr>\n"; $save_html = ""; } else { $save_html = "<input type='submit' name='save' value='" . __('Yes') . "'>"; if (get_request_var('drp_action') == '1') { /* Delete Macs */ print "<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 rows from Aggregated table?') . "</p>\n\t\t\t\t\t<p><ul>{$row_list}</ul></p>\n\t\t\t\t</td>\n\t\t\t</tr>"; } } } 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($row_array) ? serialize($row_array) : '') . "'>\n\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>" . (strlen($save_html) ? "\n\t\t\t<input type='submit' name='cancel_x' value='No'>\n\t\t\t{$save_html}" : "<input type='submit' name='cancel' value='Return'>") . "\n\t\t</td>\n\t</tr>"; html_end_box(); 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 mikrotik_view_graphs() { global $current_user, $colors, $config, $host_template_hashes, $graph_template_hashes; include './lib/timespan_settings.php'; include './lib/html_graph.php'; html_graph_validate_preview_request_vars(); /* include graph view filter selector */ html_start_box('<strong>Graph Preview Filters</strong>' . (isset($_REQUEST['style']) && strlen($_REQUEST['style']) ? ' [ Custom Graph List Applied - Filtering from List ]' : ''), '100%', '', '3', 'center', ''); html_graph_preview_filter('mikrotik.php', 'graphs', 'ht.hash IN ("' . implode('","', $host_template_hashes) . '")', 'gt.hash IN ("' . implode('","', $graph_template_hashes) . '")'); html_end_box(); /* the user select a bunch of graphs of the 'list' view and wants them displayed here */ $sql_or = ''; if (isset($_REQUEST['style'])) { if (get_request_var_request('style') == 'selective') { /* process selected graphs */ if (!empty($_REQUEST['graph_list'])) { foreach (explode(',', $_REQUEST['graph_list']) as $item) { $graph_list[$item] = 1; } } else { $graph_list = array(); } if (!empty($_REQUEST['graph_add'])) { foreach (explode(',', $_REQUEST['graph_add']) as $item) { $graph_list[$item] = 1; } } /* remove items */ if (!empty($_REQUEST['graph_remove'])) { foreach (explode(',', $_REQUEST['graph_remove']) as $item) { unset($graph_list[$item]); } } $i = 0; foreach ($graph_list as $item => $value) { $graph_array[$i] = $item; $i++; } if (isset($graph_array) && sizeof($graph_array) > 0) { /* build sql string including each graph the user checked */ $sql_or = array_to_sql_or($graph_array, 'gtg.local_graph_id'); $set_rra_id = empty($rra_id) ? read_graph_config_option('default_rra_id') : get_request_var_request('rra_id'); } } } $total_graphs = 0; // Filter sql_where $sql_where = strlen($_REQUEST['filter']) ? "gtg.title_cache LIKE '%" . get_request_var_request('filter') . "%'" : ''; $sql_where .= (strlen($sql_or) && strlen($sql_where) ? ' AND ' : '') . $sql_or; // Host Id sql_where if ($_REQUEST['host_id'] > 0) { $sql_where .= (strlen($sql_where) ? ' AND' : '') . ' gl.host_id=' . $_REQUEST['host_id']; } else { $host_ids = mikrotik_host_ids_from_hashes($host_template_hashes); if (sizeof($host_ids)) { $sql_where .= (strlen($sql_where) ? ' AND' : '') . ' gl.host_id IN (' . implode(',', $host_ids) . ')'; } else { $sql_where .= (strlen($sql_where) ? ' AND' : '') . ' 1=0'; } } // Graph Template Id sql_where if ($_REQUEST['graph_template_id'] > 0) { $sql_where .= (strlen($sql_where) ? ' AND' : '') . ' gl.graph_template_id=' . $_REQUEST['graph_template_id']; } else { $graph_template_ids = mikrotik_graph_templates_from_hashes($graph_template_hashes); if (sizeof($graph_template_ids)) { $sql_where .= (strlen($sql_where) ? ' AND' : '') . ' gl.graph_template_id IN (' . implode(',', $graph_template_ids) . ')'; } else { $sql_where .= (strlen($sql_where) ? ' AND' : '') . ' 1=0'; } } $limit = $_REQUEST['graphs'] * ($_REQUEST['page'] - 1) . ',' . $_REQUEST['graphs']; $order = 'gtg.title_cache'; $graphs = get_allowed_graphs($sql_where, $order, $limit, $total_graphs); /* do some fancy navigation url construction so we don't have to try and rebuild the url string */ if (preg_match('/page=[0-9]+/', basename($_SERVER['QUERY_STRING']))) { $nav_url = str_replace('&page=' . get_request_var_request('page'), '', get_browser_query_string()); } else { $nav_url = get_browser_query_string() . '&host_id=' . get_request_var_request('host_id'); } $nav_url = preg_replace('/((\\?|&)host_id=[0-9]+|(\\?|&)filter=[a-zA-Z0-9]*)/', '', $nav_url); html_start_box('', '100%', '', '3', 'center', ''); $nav = html_nav_bar($nav_url, MAX_DISPLAY_PAGES, get_request_var_request('page'), get_request_var_request('graphs'), $total_graphs, get_request_var_request('columns'), 'Graphs', 'page', 'main'); print $nav; if (get_request_var_request('thumbnails') == 'true') { html_graph_thumbnail_area($graphs, '', 'graph_start=' . get_current_graph_start() . '&graph_end=' . get_current_graph_end(), '', get_request_var_request('columns')); } else { html_graph_area($graphs, '', 'graph_start=' . get_current_graph_start() . '&graph_end=' . get_current_graph_end(), '', get_request_var_request('columns')); } if ($total_graphs > 0) { print $nav; } html_end_box(); bottom_footer(); }
function syslog_uninstall_advisor() { global $config, $colors; include dirname(__FILE__) . '/config.php'; syslog_connect(); $syslog_exists = sizeof(syslog_db_fetch_row('SHOW TABLES FROM `' . $syslogdb_default . "` LIKE 'syslog'")); top_header(); $fields_syslog_update = array('uninstall_method' => array('method' => 'drop_array', 'friendly_name' => __('What uninstall method do you want to use?'), 'description' => __('When uninstalling syslog, you can remove everything, or only components, just in case you plan on re-installing in the future.'), 'value' => 'all', 'array' => array('all' => __('Remove Everything (Logs, Tables, Settings)'), 'syslog' => __('Syslog Data Only'))), 'mode' => array('method' => 'hidden', 'value' => 'uninstall'), 'id' => array('method' => 'hidden', 'value' => 'syslog')); print "<form action='plugins.php' method='get'>\n"; print "<table align='center' width='80%'><tr><td>\n"; html_start_box(__('Syslog Uninstall Preferences'), '100%', $colors['header'], '3', 'center', ''); draw_edit_form(array('config' => array(), 'fields' => inject_form_variables($fields_syslog_update, array()))); html_end_box(); syslog_confirm_button('uninstall', 'plugins.php', $syslog_exists); print "</td></tr></table>\n"; bottom_footer(); exit; }
function list_tholds() { global $thold_states, $config, $host_id, $timearray, $thold_types; $thold_actions = array(1 => __('Delete'), 2 => __('Disable'), 3 => __('Enable'), 4 => __('Reapply Suggested Names'), 5 => __('Propagate Template')); thold_request_validation(); /* if the number of rows is -1, set it to the default */ if (get_request_var('rows') == -1) { $rows = read_config_option('num_rows_table'); } else { $rows = get_request_var('rows'); } $statefilter = ''; if (isset_request_var('state')) { if (get_request_var('state') == '-1') { $statefilter = ''; } else { if (get_request_var('state') == '0') { $statefilter = "thold_data.thold_enabled='off'"; } if (get_request_var('state') == '2') { $statefilter = "thold_data.thold_enabled='on'"; } if (get_request_var('state') == '1') { $statefilter = '(thold_data.thold_alert!=0 OR thold_data.bl_alert>0)'; } if (get_request_var('state') == '3') { $statefilter = '((thold_data.thold_alert!=0 AND thold_data.thold_fail_count >= thold_data.thold_fail_trigger) OR (thold_data.bl_alert>0 AND thold_data.bl_fail_count >= thold_data.bl_fail_trigger))'; } } } top_header(); $sql_where = ''; $sort = get_request_var('sort_column'); $limit = ' LIMIT ' . $rows * (get_request_var('page') - 1) . ", {$rows}"; if (!isempty_request_var('host_id') && get_request_var('host_id') != '-1') { $sql_where .= (!strlen($sql_where) ? '(' : ' AND ') . "td.host_id = " . get_request_var('host_id'); } if (!isempty_request_var('data_template_id') && get_request_var('data_template_id') != '-1') { $sql_where .= (!strlen($sql_where) ? '(' : ' AND ') . "td.data_template_id = " . get_request_var('data_template_id'); } if ($statefilter != '') { $sql_where .= (!strlen($sql_where) ? '(' : ' AND ') . "{$statefilter}"; } if ($sql_where != '') { $sql_where .= ')'; } $tholds = get_allowed_thresholds($sql_where, $sort . ' ' . get_request_var('sort_direction'), $rows * (get_request_var('page') - 1) . ", {$rows}", $total_rows); $data_templates = db_fetch_assoc("SELECT DISTINCT data_template.id, data_template.name\n\t\tFROM data_template\n\t\tINNER JOIN thold_data \n\t\tON thold_data.data_template_id = data_template.id\n\t\tORDER BY data_template.name"); html_start_box(__('Threshold Management'), '100%', '', '3', 'center', 'thold.php?action=add'); ?> <tr class='even'> <td> <form id='listthold' action='thold.php' method='post'> <table class='filterTable'> <tr> <td> <?php print __('Search'); ?> </td> <td> <input type='text' id='filter' size='25' value='<?php print get_request_var('filter'); ?> '> </td> <?php print html_host_filter(get_request_var('host_id')); ?> <td> <?php print __('Template'); ?> </td> <td> <select id='data_template_id' onChange='applyFilter()'> <option value='-1'><?php print __('Any'); ?> </option> <?php foreach ($data_templates as $row) { echo "<option value='" . $row['id'] . "'" . (isset_request_var('data_template_id') && $row['id'] == get_request_var('data_template_id') ? ' selected' : '') . '>' . $row['name'] . '</option>'; } ?> </select> </td> <td> <?php print __('State'); ?> </td> <td> <select id='state' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var('state') == '-1') { ?> selected<?php } ?> ><?php print __('All'); ?> </option> <option value='1'<?php if (get_request_var('state') == '1') { ?> selected<?php } ?> ><?php print __('Breached'); ?> </option> <option value='3'<?php if (get_request_var('state') == '3') { ?> selected<?php } ?> ><?php print __('Triggered'); ?> </option> <option value='2'<?php if (get_request_var('state') == '2') { ?> selected<?php } ?> ><?php print __('Enabled'); ?> </option> <option value='0'<?php if (get_request_var('state') == '0') { ?> selected<?php } ?> ><?php print __('Disabled'); ?> </option> </select> </td> <td> <input type='button' id='refresh' value='<?php print __('Go'); ?> ' title='<?php print __('Apply Filters'); ?> ' onClick='applyFilter()'> </td> <td> <input type='button' id='clear' value='<?php print __('Clear'); ?> ' title='<?php print __('Return to Defaults'); ?> ' onClick='clearFilter()'> </td> </tr> </table> <input type='hidden' name='search' value='search'> <input type='hidden' id='page' value='<?php print get_filter_request_var('page'); ?> '> </form> <script type='text/javascript'> function applyFilter() { strURL = 'thold.php?header=false&host_id=' + $('#host_id').val(); strURL += '&state=' + $('#state').val(); strURL += '&data_template_id=' + $('#data_template_id').val(); strURL += '&filter=' + $('#filter').val(); loadPageNoHeader(strURL); } function clearFilter() { strURL = 'thold.php?header=false&clear=1'; loadPageNoHeader(strURL); } $(function() { $('#listthold').submit(function(event) { event.preventDefault(); applyFilter(); }); }); </script> </td> </tr> <?php html_end_box(); $nav = html_nav_bar('thold.php?filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 14, __('Thresholds'), 'page', 'main'); form_start('thold.php', 'chk'); print $nav; html_start_box('', '100%', '', '4', 'center', ''); $display_text = array('name' => array('display' => __('Name'), 'sort' => 'ASC', 'align' => 'left'), 'id' => array('display' => __('ID'), 'sort' => 'ASC', 'align' => 'right'), 'thold_type' => array('display' => __('Type'), 'sort' => 'ASC', 'align' => 'right'), 'data_source' => array('display' => __('DSName'), 'sort' => 'ASC', 'align' => 'right'), 'lastread' => array('display' => __('Current'), 'sort' => 'ASC', 'align' => 'right', 'tip' => __('The last measured value for the Data Source')), 'thold_hi' => array('display' => __('High'), 'sort' => 'ASC', 'align' => 'right', 'tip' => __('High Threshold values for Warning/Alert')), 'thold_low' => array('display' => __('Low'), 'sort' => 'ASC', 'align' => 'right', 'tip' => __('Low Threshold values for Warning/Alert')), 'nosort3' => array('display' => __('Trigger'), 'sort' => '', 'align' => 'right'), 'nosort4' => array('display' => __('Duration'), 'sort' => '', 'align' => 'right'), 'repeat_alert' => array('display' => __('Repeat'), 'sort' => 'ASC', 'align' => 'right'), 'thold_alert' => array('display' => __('Triggered'), 'sort' => 'ASC', 'align' => 'right'), 'template_enabled' => array('display' => __('Templated'), 'sort' => 'ASC', 'align' => 'right')); html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false); $c = 0; $i = 0; if (sizeof($tholds)) { foreach ($tholds as $thold_data) { $c++; $grapharr = db_fetch_row('SELECT DISTINCT graph_templates_item.local_graph_id FROM graph_templates_item, data_template_rrd WHERE (data_template_rrd.local_data_id=' . $thold_data['local_data_id'] . ' AND data_template_rrd.id=graph_templates_item.task_item_id)'); $local_graph_id = $grapharr['local_graph_id']; $alertstat = __('No'); $bgcolor = 'green'; if ($thold_data['thold_type'] == 0) { if ($thold_data['thold_alert'] != 0) { $alertstat = __('Yes'); if ($thold_data['thold_fail_count'] >= $thold_data['thold_fail_trigger']) { $bgcolor = 'red'; } elseif ($thold_data['thold_warning_fail_count'] >= $thold_data['thold_warning_fail_trigger']) { $bgcolor = 'warning'; } else { $bgcolor = 'yellow'; } } } elseif ($thold_data['thold_type'] == 2) { if ($thold_data['thold_alert'] != 0) { $alertstat = __('Yes'); if ($thold_data['thold_fail_count'] >= $thold_data['time_fail_trigger']) { $bgcolor = 'red'; } elseif ($thold_data['thold_warning_fail_count'] >= $thold_data['time_warning_fail_trigger']) { $bgcolor = 'warning'; } else { $bgcolor = 'yellow'; } } } else { if ($thold_data['bl_alert'] == 1) { $alertstat = __('baseline-LOW'); $bgcolor = $thold_data['bl_fail_count'] >= $thold_data['bl_fail_trigger'] ? 'orange' : 'yellow'; } elseif ($thold_data['bl_alert'] == 2) { $alertstat = __('baseline-HIGH'); $bgcolor = $thold_data['bl_fail_count'] >= $thold_data['bl_fail_trigger'] ? 'orange' : 'yellow'; } } $data_source = db_fetch_cell_prepared('SELECT data_source_name FROM data_template_rrd WHERE id = ?', array($thold_data['data_template_rrd_id'])); if ($thold_data['thold_enabled'] == 'off') { print "<tr class='selectable " . $thold_states['grey']['class'] . "' id='line" . $thold_data['id'] . "'>\n"; } else { print "<tr class='selectable " . $thold_states[$bgcolor]['class'] . "' id='line" . $thold_data['id'] . "'>\n"; } form_selectable_cell(filter_value($thold_data['name'] != '' ? $thold_data['name'] : $thold_data['name_cache'] . ' [' . $thold_data['data_source_name'] . ']', get_request_var('filter'), 'thold.php?action=edit&id=' . $thold_data['id']) . '</a>', $thold_data['id'], '', 'text-align:left'); form_selectable_cell($thold_data['id'], $thold_data['id'], '', 'text-align:right'); form_selectable_cell($thold_types[$thold_data['thold_type']], $thold_data['id'], '', 'text-align:right'); form_selectable_cell($data_source, $thold_data['id'], '', 'text-align:right'); switch ($thold_data['thold_type']) { case 0: form_selectable_cell(thold_format_number($thold_data['lastread']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(thold_format_number($thold_data['thold_warning_hi']) . ' / ' . thold_format_number($thold_data['thold_hi']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(thold_format_number($thold_data['thold_warning_low']) . ' / ' . thold_format_number($thold_data['thold_low']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell('<i>' . plugin_thold_duration_convert($thold_data['local_data_id'], $thold_data['thold_fail_trigger'], 'alert') . '</i>', $thold_data['id'], '', 'text-align:right'); form_selectable_cell(__('N/A'), $thold_data['id'], '', 'text-align:right'); break; case 1: form_selectable_cell(thold_format_number($thold_data['lastread']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(thold_format_number($thold_data['thold_warning_hi']) . ' / ' . thold_format_number($thold_data['thold_hi']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(thold_format_number($thold_data['thold_warning_low']) . ' / ' . thold_format_number($thold_data['thold_low']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell('<i>' . plugin_thold_duration_convert($thold_data['local_data_id'], $thold_data['bl_fail_trigger'], 'alert') . '</i>', $thold_data['id'], '', 'text-align:right'); form_selectable_cell($timearray[$thold_data['bl_ref_time_range'] / 300], $thold_data['id'], '', 'text-align:right'); break; case 2: form_selectable_cell(thold_format_number($thold_data['lastread']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(thold_format_number($thold_data['time_warning_hi']) . ' / ' . thold_format_number($thold_data['time_hi']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(thold_format_number($thold_data['time_warning_low']) . ' / ' . thold_format_number($thold_data['time_low']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell('<i>' . __('%d Triggers', $thold_data['time_fail_trigger']) . '</i>', $thold_data['id'], '', 'text-align:right'); form_selectable_cell('<i>' . plugin_thold_duration_convert($thold_data['local_data_id'], $thold_data['time_fail_length'], 'time') . '</i>', $thold_data['id'], '', 'text-align:right'); break; default: form_selectable_cell(thold_format_number($thold_data['lastread']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell('- / -', $thold_data['id'], '', 'text-align:right'); form_selectable_cell('- / -', $thold_data['id'], '', 'text-align:right'); form_selectable_cell(__('N/A'), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(__('N/A'), $thold_data['id'], '', 'text-align:right'); } form_selectable_cell($thold_data['repeat_alert'] == '' ? '' : plugin_thold_duration_convert($thold_data['local_data_id'], $thold_data['repeat_alert'], 'repeat'), $thold_data['id'], '', 'text-align:right'); form_selectable_cell($alertstat, $thold_data['id'], '', 'text-align:right'); if ($thold_data['thold_template_id'] != 0) { form_selectable_cell($thold_data['template_enabled'] == '' ? __('No') : __('Yes'), $thold_data['id'], '', 'text-align:right'); } else { form_selectable_cell(__('No'), $thold_data['id'], '', 'text-align:right'); } form_checkbox_cell($thold_data['name'], $thold_data['id'], '', 'text-align:left'); form_end_row(); } } else { print "<tr class='even'><td colspan='14'><center>" . __('No Thresholds') . "</center></td></tr>\n"; } html_end_box(false); if (sizeof($tholds)) { print $nav; } thold_legend(); draw_actions_dropdown($thold_actions); if (isset($host_id) && $host_id != '') { print "<input type='hidden' name='host_id' value='{$host_id}'>"; } form_end(); bottom_footer(); }
function form_actions() { global $actions, $assoc_actions; /* ================= input validation ================= */ get_filter_request_var('id'); get_filter_request_var('drp_action', FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^([a-zA-Z0-9_]+)$/'))); /* ================= input validation ================= */ /* if we are to save this form, instead of display it */ if (isset_request_var('selected_items')) { if (isset_request_var('save_list')) { if (get_request_var('drp_action') == '2') { /* delete */ schedule_delete(); } elseif (get_request_var('drp_action') == '1') { /* update */ schedule_update(); } header('Location: maint.php?header=false'); exit; } elseif (isset_request_var('save_hosts')) { $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); if ($selected_items != false) { if (get_request_var('drp_action') == '1') { /* associate */ for ($i = 0; $i < count($selected_items); $i++) { db_execute('REPLACE INTO plugin_maint_hosts (type, host, schedule) VALUES (1, ' . $selected_items[$i] . ', ' . get_request_var('id') . ')'); } } elseif (get_request_var('drp_action') == '2') { /* disassociate */ for ($i = 0; $i < count($selected_items); $i++) { db_execute('DELETE FROM plugin_maint_hosts WHERE type=1 AND host=' . $selected_items[$i] . ' AND schedule=' . get_request_var('id')); } } } header('Location: maint.php?action=edit&tab=hosts&header=false&id=' . get_request_var('id')); exit; } elseif (isset_request_var('save_webseer')) { $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); if ($selected_items != false) { if (get_request_var('drp_action') == '1') { /* associate */ for ($i = 0; $i < count($selected_items); $i++) { db_execute('REPLACE INTO plugin_maint_hosts (type, host, schedule) VALUES (2, ' . $selected_items[$i] . ', ' . get_request_var('id') . ')'); } } elseif (get_request_var('drp_action') == '2') { /* disassociate */ for ($i = 0; $i < count($selected_items); $i++) { db_execute('DELETE FROM plugin_maint_hosts WHERE type=2 AND host=' . $selected_items[$i] . ' AND schedule=' . get_request_var('id')); } } } header('Location: maint.php?action=edit&tab=webseer&header=false&id=' . get_request_var('id')); exit; } else { api_plugin_hook_function('maint_actions_execute'); } } /* setup some variables */ $list = ''; $array = array(); $list_name = ''; if (isset_request_var('id')) { $list_name = db_fetch_cell('SELECT name FROM plugin_maint_schedules WHERE id=' . get_request_var('id')); } if (isset_request_var('save_list')) { /* loop through each of the notification lists 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]); /* ==================================================== */ $list .= '<li><b>' . db_fetch_cell('SELECT name FROM plugin_maint_schedules WHERE id=' . $matches[1]) . '</b></li>'; $array[] = $matches[1]; } } top_header(); form_start('maint.php'); html_start_box($actions[get_request_var('drp_action')] . " {$list_name}", '60%', '', '3', 'center', ''); if (sizeof($array)) { if (get_request_var('drp_action') == '1') { /* update */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Update the following Maintenance Schedule(s).') . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Update Maintenance Schedule(s)') . "'>"; } elseif (get_request_var('drp_action') == '2') { /* delete */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Delete the following Maintenance Schedule(s). Any Devices(s) Associated with this Schedule will be Disassociated.') . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Delete Maintenance Schedule(s)') . "'>"; } } else { print "<tr><td><span class='textError'>" . __('You must select at least one Maintenance Schedule.') . "</span></td></tr>\n"; $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>"; } print "<tr class='saveRow'>\n\t\t\t<td>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='save_list' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n"; html_end_box(); form_end(); bottom_footer(); } elseif (isset_request_var('save_hosts')) { /* loop through each of the notification lists 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]); /* ==================================================== */ $list .= '<li><b>' . db_fetch_cell('SELECT description FROM host WHERE id=' . $matches[1]) . '</b></li>'; $array[] = $matches[1]; } } top_header(); form_start('maint.php'); html_start_box($assoc_actions[get_request_var('drp_action')] . ' ' . __('Device(s)'), '60%', '', '3', 'center', ''); if (sizeof($array)) { if (get_request_var('drp_action') == '1') { /* associate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to associate the following Device(s) with the Maintenance Schedule \'<b>%s</b>\'.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Associate Maintenance Schedule(s)') . "'>"; } elseif (get_request_var('drp_action') == '2') { /* disassociate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to disassociate the following Device(s) with the Maintenance Schedule \'<b>%s</b>\'.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Disassociate Maintenance Schedule(s)') . "'>"; } } else { print "<tr><td><span class='textError'>" . __('You must select at least one Device.') . "</span></td></tr>\n"; $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>"; } print "<tr class='saveRow'>\n\t\t\t<td>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='id' value='" . get_request_var('id') . "'>\n\t\t\t\t<input type='hidden' name='save_hosts' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n"; html_end_box(); form_end(); bottom_footer(); } elseif (isset_request_var('save_webseer')) { /* loop through each of the notification lists 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]); /* ==================================================== */ $list .= '<li><b>' . db_fetch_cell('SELECT description FROM host WHERE id=' . $matches[1]) . '</b></li>'; $array[] = $matches[1]; } } top_header(); html_start_box($assoc_actions[get_request_var('drp_action')] . ' ' . __('Device(s)'), '60%', '', '3', 'center', ''); form_start('maint.php'); if (sizeof($array)) { if (get_request_var('drp_action') == '1') { /* associate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to associate the Device(s) below with the Maintenance Schedule \'<b>%s</b>\'.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Associate Maintenance Schedule(s)') . "'>"; } elseif (get_request_var('drp_action') == '2') { /* disassociate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to disassociate the Devices(s) below with the Maintenance Schedule \'<b>%s</b>\'.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Disassociate Maintenance Schedule(s)') . "'>"; } } else { print "<tr><td><span class='textError'>" . __('You must select at least one Device.') . "</span></td></tr>\n"; $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>"; } print "<tr class='saveRow'>\n\t\t\t<td>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='id' value='" . get_request_var('id') . "'>\n\t\t\t\t<input type='hidden' name='save_webseer' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n"; form_end(); html_end_box(); bottom_footer(); } else { api_plugin_hook_function('maint_actions_prepare'); } }
function form_actions() { global $actions, $assoc_actions; /* ================= input validation ================= */ get_filter_request_var('drp_action'); /* ==================================================== */ /* if we are to save this form, instead of display it */ if (isset_request_var('selected_items')) { if (isset_request_var('save_list')) { $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); if ($selected_items != false) { if (get_request_var('drp_action') == '1') { /* delete */ db_execute('DELETE FROM plugin_notification_lists WHERE ' . array_to_sql_or($selected_items, 'id')); db_execute('UPDATE host SET thold_send_email=0 WHERE thold_send_email=2 AND ' . array_to_sql_or($selected_items, 'thold_host_email')); db_execute('UPDATE host SET thold_send_email=1 WHERE thold_send_email=3 AND ' . array_to_sql_or($selected_items, 'thold_host_email')); db_execute('UPDATE host SET thold_host_email=0 WHERE ' . array_to_sql_or($selected_items, 'thold_host_email')); } elseif (get_request_var('drp_action') == '2') { /* duplicate */ // To Do } } header('Location: notify_lists.php?header=false'); exit; } elseif (isset_request_var('save_associate')) { $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); if ($selected_items != false) { get_filter_request_var('notification_action'); if (get_request_var('drp_action') == '1') { /* associate */ for ($i = 0; $i < count($selected_items); $i++) { /* set the notification list */ db_execute('UPDATE host SET thold_host_email=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]); /* set the global/list election */ db_execute('UPDATE host SET thold_send_email=' . get_request_var('notification_action') . ' WHERE id=' . $selected_items[$i]); } } elseif (get_request_var('drp_action') == '2') { /* disassociate */ for ($i = 0; $i < count($selected_items); $i++) { /* set the notification list */ db_execute('UPDATE host SET thold_host_email=0 WHERE id=' . $selected_items[$i]); /* set the global/list election */ db_execute('UPDATE host SET thold_send_email=' . get_request_var('notification_action') . ' WHERE id=' . $selected_items[$i]); } } } header('Location: notify_lists.php?header=false&action=edit&tab=hosts&id=' . get_request_var('id')); exit; } elseif (isset_request_var('save_templates')) { $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); if ($selected_items != false) { get_filter_request_var('notification_action'); if (get_request_var('drp_action') == '1') { /* associate */ for ($i = 0; $i < count($selected_items); $i++) { if (get_request_var('notification_warning_action') > 0) { /* clear other settings */ if (get_request_var('notification_warning_action') == 1) { /* set the notification list */ db_execute('UPDATE thold_template SET notify_warning=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]); /* clear other items */ db_execute("UPDATE thold_template SET notify_warning_extra='' WHERE id=" . $selected_items[$i]); } else { /* set the notification list */ db_execute('UPDATE thold_template SET notify_warning=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]); } } if (get_request_var('notification_alert_action') > 0) { /* clear other settings */ if (get_request_var('notification_alert_action') == 1) { /* set the notification list */ db_execute('UPDATE thold_template SET notify_alert=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]); /* clear other items */ db_execute("UPDATE thold_template SET notify_extra='' WHERE id=" . $selected_items[$i]); db_execute('DELETE FROM plugin_thold_template_contact WHERE template_id=' . $selected_items[$i]); } else { /* set the notification list */ db_execute('UPDATE thold_template SET notify_alert=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]); } } } } elseif (get_request_var('drp_action') == '2') { /* disassociate */ for ($i = 0; $i < count($selected_items); $i++) { if (get_request_var('notification_warning_action') > 0) { /* set the notification list */ db_execute('UPDATE thold_template SET notify_warning=0 WHERE id=' . $selected_items[$i] . ' AND notify_warning=' . get_request_var('id')); } if (get_request_var('notification_alert_action') > 0) { /* set the notification list */ db_execute('UPDATE thold_template SET notify_alert=0 WHERE id=' . $selected_items[$i] . ' AND notify_alert=' . get_request_var('id')); } } } } header('Location: notify_lists.php?header=false&action=edit&tab=templates&id=' . get_request_var('id')); exit; } elseif (isset_request_var('save_tholds')) { $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); if ($selected_items != false) { get_filter_request_var('notification_action'); if (get_request_var('drp_action') == '1') { /* associate */ for ($i = 0; $i < count($selected_items); $i++) { if (get_request_var('notification_warning_action') > 0) { /* clear other settings */ if (get_request_var('notification_warning_action') == 1) { /* set the notification list */ db_execute('UPDATE thold_data SET notify_warning=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]); /* clear other items */ db_execute("UPDATE thold_data SET notify_warning_extra='' WHERE id=" . $selected_items[$i]); } else { /* set the notification list */ db_execute('UPDATE thold_data SET notify_warning=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]); } } if (get_request_var('notification_alert_action') > 0) { /* clear other settings */ if (get_request_var('notification_alert_action') == 1) { /* set the notification list */ db_execute('UPDATE thold_data SET notify_alert=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]); /* clear other items */ db_execute("UPDATE thold_data SET notify_extra='' WHERE id=" . $selected_items[$i]); db_execute('DELETE FROM plugin_thold_threshold_contact WHERE thold_id=' . $selected_items[$i]); } else { /* set the notification list */ db_execute('UPDATE thold_data SET notify_alert=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]); } } } } elseif (get_request_var('drp_action') == '2') { /* disassociate */ for ($i = 0; $i < count($selected_items); $i++) { if (get_request_var('notification_warning_action') > 0) { /* set the notification list */ db_execute('UPDATE thold_data SET notify_warning=0 WHERE id=' . $selected_items[$i] . ' AND notify_warning=' . get_request_var('id')); } if (get_request_var('notification_alert_action') > 0) { /* set the notification list */ db_execute('UPDATE thold_data SET notify_alert=0 WHERE id=' . $selected_items[$i] . ' AND notify_alert=' . get_request_var('id')); } } } } header('Location: notify_lists.php?header=false&action=edit&tab=tholds&id=' . get_request_var('id')); exit; } } /* setup some variables */ $list = ''; $array = array(); $list_name = ''; if (isset_request_var('id')) { $list_name = db_fetch_cell('SELECT name FROM plugin_notification_lists WHERE id=' . get_filter_request_var('id')); } if (isset_request_var('save_list')) { /* loop through each of the notification lists 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]); /* ==================================================== */ $list .= '<li><b>' . db_fetch_cell('SELECT name FROM plugin_notification_lists WHERE id=' . $matches[1]) . '</b></li>'; $array[] = $matches[1]; } } top_header(); form_start('notify_lists.php'); html_start_box($actions[get_request_var('drp_action')] . " {$list_name}", '60%', '', '3', 'center', ''); print "<form action='notify_lists.php' method='post'>\n"; if (sizeof($array)) { if (get_request_var('drp_action') == '1') { /* delete */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Delete Notification Lists(s). Any Device(s) or Threshold(s) associated with the List(s) will be reverted to the default.') . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Delete Notification List(s)') . "'>"; } elseif (get_request_var('drp_action') == '2') { /* duplicate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Duplicate the following Notification List(s).') . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Duplicate Notification List(s)') . "'>"; } } else { print "<tr><td class='even'><span class='textError'>" . __('You must select at least one Notification List.') . "</span></td></tr>\n"; $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>"; } print "<tr>\n\t\t\t\t<td class='saveRow'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='save_list' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n"; html_end_box(); form_end(); bottom_footer(); } elseif (isset_request_var('save_templates')) { /* loop through each of the notification lists 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]); /* ==================================================== */ $list .= '<li><b>' . db_fetch_cell('SELECT name FROM thold_template WHERE id=' . $matches[1]) . '</b></li>'; $array[] = $matches[1]; } } top_header(); form_start('notify_lists.php'); html_start_box(__('%s Threshold Template(s)', $assoc_actions[get_request_var('drp_action')]), '60%', '', '3', 'center', ''); if (sizeof($array)) { if (get_request_var('drp_action') == '1') { /* associate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Association the Notification List \'<b>%s</b>\' with the Threshold Template(s) below.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t\t<p><b>" . __('Warning Membership:') . "</b><br>"; form_dropdown('notification_warning_action', array(0 => __('No Change'), 1 => __('Notification List Only'), 2 => __('Notification List, Retain Other Settings')), '', '', 1, '', ''); print "</p>\n\t\t\t\t\t\t<p><b>" . __('Alert Membership:') . "</b><br>"; form_dropdown('notification_alert_action', array(0 => __('No Change'), 1 => __('Notification List Only'), 2 => __('Notification List, Retain Other Settings')), '', '', 1, '', ''); print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Associate Notification List(s)') . "'>"; } elseif (get_request_var('drp_action') == '2') { /* disassociate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Disassociate the Notification List \'<b>%s</b>\' from the Thresholds Template(s) below.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t\t<p><b>" . __('Warning Membership:') . "</b><br>"; form_dropdown('notification_warning_action', array(0 => __('No Change'), 1 => __('Remove List')), '', '', 1, '', ''); print "</p>\n\t\t\t\t\t\t<p><b>" . __('Alert Membership:') . "</b><br>"; form_dropdown('notification_alert_action', array(0 => __('No Change'), 1 => __('Remove List')), '', '', 1, '', ''); print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Disassociate Notification List(s)') . "'>"; } } else { print "<tr><td class='even'><span class='textError'>" . __('You must select at least one Threshold Template.') . "</span></td></tr>\n"; $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>"; } print "\t<tr>\n\t\t\t\t<td class='saveRow'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='id' value='" . get_request_var('id') . "'>\n\t\t\t\t<input type='hidden' name='save_templates' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n"; html_end_box(); form_end(); bottom_footer(); } elseif (isset_request_var('save_tholds')) { /* loop through each of the notification lists 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]); /* ==================================================== */ $list .= '<li><b>' . db_fetch_cell('SELECT name FROM thold_data WHERE id=' . $matches[1]) . '</b></li>'; $array[] = $matches[1]; } } top_header(); form_start('notify_lists.php'); html_start_box(__('%s Threshold(s)', $assoc_actions[get_request_var('drp_action')]), '60%', '', '3', 'center', ''); if (sizeof($array)) { if (get_request_var('drp_action') == '1') { /* associate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Associate the Notification List \'<b>%s</b>\' with the Threshold(s) below.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t\t<p><b>" . __('Warning Membership:') . "</b><br>"; form_dropdown('notification_warning_action', array(0 => __('No Change'), 1 => __('Notification List Only'), 2 => __('Notification List, Retain Other Settings')), '', '', 1, '', ''); print "</p>\n\t\t\t\t\t\t<p><b>" . __('Alert Membership:') . "</b><br>"; form_dropdown('notification_alert_action', array(0 => __('No Change'), 1 => __('Notification List Only'), 2 => __('Notification List, Retain Other Settings')), '', '', 1, '', ''); print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Associate Notification List(s)') . "'>"; } elseif (get_request_var('drp_action') == '2') { /* disassociate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Disassociate the Notification List \'<b>%s</b>\' from the Thresholds(s) below.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t\t<p><b>" . __('Warning Membership:') . "</b><br>"; form_dropdown('notification_warning_action', array(0 => __('No Change'), 1 => __('Remove List')), '', '', 1, '', ''); print "</p>\n\t\t\t\t\t\t<p><b>" . __('Alert Membership:') . "</b><br>"; form_dropdown('notification_alert_action', array(0 => __('No Change'), 1 => __('Remove List')), '', '', 1, '', ''); print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Disassociate Notification List(s)') . "'>"; } } else { print "<tr><td class='even'><span class='textError'>" . __('You must select at least one Threshold.') . "</span></td></tr>\n"; $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>"; } print "\t<tr>\n\t\t\t\t<td class='saveRow'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='id' value='" . get_request_var('id') . "'>\n\t\t\t\t<input type='hidden' name='save_tholds' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n"; html_end_box(); form_end(); bottom_footer(); } else { /* loop through each of the notification lists 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]); /* ==================================================== */ $list .= '<li>' . db_fetch_cell('SELECT description FROM host WHERE id=' . $matches[1]) . '</li>'; $array[] = $matches[1]; } } top_header(); form_start('notify_lists.php'); html_start_box($assoc_actions[get_request_var('drp_action')] . ' Device(s)', '60%', '', '3', 'center', ''); if (sizeof($array)) { if (get_request_var('drp_action') == '1') { /* associate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Associate the Notification List \'<b>%s</b>\' with the Device(s) below.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t\t<p><b>" . __('Resulting Membership:') . "<br>"; form_dropdown('notification_action', array(2 => __('Notification List Only'), 3 => __('Notification and Global Lists')), '', '', 2, '', ''); print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Associate Notification List(s)') . "'>"; } elseif (get_request_var('drp_action') == '2') { /* disassociate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Disassociate the Notification List \'<b>%s</b>\' from the Device(s) below.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t\t<p><b>" . __('Resulting Membership:') . "</b><br>"; form_dropdown('notification_action', array(1 => __('Global List'), 0 => __('Disabled')), '', '', 1, '', ''); print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Disassociate Notification List(s)') . "'>"; } } else { print "<tr><td class='even'><span class='textError'>" . __('You must select at least one Device.') . "</span></td></tr>\n"; $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>"; } print "<tr>\n\t\t\t\t<td class='saveRow'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='id' value='" . get_request_var('id') . "'>\n\t\t\t\t<input type='hidden' name='save_associate' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n"; html_end_box(); form_end(); bottom_footer(); } }
| 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 { array_push($xport_array, '"site_name","vendor","device_name","total_devices",' . '"total_ips","total_user_ports","total_oper_ports","total_trunks",' . '"total_macs_found"'); foreach ($sites as $site) {
function mactrack_utilities_recreate_aggregated_data() { global $config; if (read_config_option('remove_verification') == 'on' && !isset_request_var('confirm')) { top_header(); form_confirm(__('Are You Sure?'), __('Are you sure you want to delete and recreate all the Aggregated Port to MAC to IP results from the system?'), 'mactrack_utilities.php', 'mactrack_utilities.php?action=mactrack_utilities_recreate_aggregated_data'); bottom_footer(); exit; } if (read_config_option('remove_verification') == '' || isset_request_var('confirm')) { $old_rows = db_fetch_cell('SELECT COUNT(*) FROM mac_track_aggregated_ports'); db_execute('TRUNCATE TABLE mac_track_aggregated_ports'); db_execute('INSERT INTO mac_track_aggregated_ports (site_id, device_id, hostname, device_name, vlan_id, vlan_name, mac_address, vendor_mac, ip_address, dns_hostname, port_number, port_name, date_last, first_scan_date, count_rec, authorized) SELECT site_id, device_id, hostname, device_name, vlan_id, vlan_name, mac_address, vendor_mac, ip_address, dns_hostname, port_number, port_name, max(scan_date), min(scan_date), count(*), authorized FROM mac_track_ports GROUP BY site_id,device_id, mac_address, port_number, ip_address, vlan_id, authorized'); $new_rows = db_fetch_cell('SELECT COUNT(*) FROM mac_track_aggregated_ports'); top_header(); mactrack_utilities(); html_start_box('Device Tracking Database Results', '100%', '', '3', 'center', ''); ?> <td> The following number of records have been removed from the aggergated table: <?php print $old_rows; ?> . And <?php print $new_rows; ?> number of record will be added. </td> <?php html_end_box(); } }
function form_actions() { global $host_actions; /* ================= input validation ================= */ input_validate_input_regex(get_request_var_post('drp_action'), '^([a-zA-Z0-9_]+)$'); /* ==================================================== */ /* 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'] == '1') { /* delete */ db_execute('DELETE FROM host_template WHERE ' . array_to_sql_or($selected_items, 'id')); db_execute('DELETE FROM host_template_snmp_query WHERE ' . array_to_sql_or($selected_items, 'host_template_id')); db_execute('DELETE FROM host_template_graph WHERE ' . array_to_sql_or($selected_items, 'host_template_id')); /* "undo" any device that is currently using this template */ db_execute('UPDATE host SET host_template_id=0 WHERE ' . array_to_sql_or($selected_items, 'host_template_id')); } elseif ($_POST['drp_action'] == '2') { /* duplicate */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ duplicate_host_template($selected_items[$i], $_POST['title_format']); } } header('Location: host_templates.php'); exit; } /* setup some variables */ $host_list = ''; $i = 0; /* loop through each of the host templates 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]); /* ==================================================== */ $host_list .= '<li>' . htmlspecialchars(db_fetch_cell_prepared('SELECT name FROM host_template WHERE id = ?'), array($matches[1])) . '<br>'; $host_array[$i] = $matches[1]; $i++; } } top_header(); html_start_box('<strong>' . $host_actions[$_POST['drp_action']] . '</strong>', '60%', '', '3', 'center', ''); print "<form action='host_templates.php' autocomplete='off' method='post'>\n"; if (isset($host_array) && sizeof($host_array)) { if ($_POST['drp_action'] == '1') { /* delete */ print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>Are you sure you want to delete the following Device Template(s)? All Devices currently associated\n\t\t\t\t\t\twith these Device Template(s) will lose that assocation.</p>\n\t\t\t\t\t\t<p><ul>{$host_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Delete Device Template(s)'>"; } elseif ($_POST['drp_action'] == '2') { /* duplicate */ print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following Device Template(s) will be duplicated. You can\n\t\t\t\t\t\toptionally change the title format for the new Device Template(s).</p>\n\t\t\t\t\t\t<p><ul>{$host_list}</ul></p>\n\t\t\t\t\t\t<p><strong>Title Format:</strong><br>"; form_text_box('title_format', '<template_title> (1)', '', '255', '30', 'text'); print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Duplicate Device Template(s)'>"; } } else { print "<tr><td class='even'><span class='textError'>You must select at least one host template.</span></td></tr>\n"; $save_html = "<input type='button' value='Return' onClick='window.history.back()'>"; } print "\t<tr>\n\t\t\t<td align='right' class='saveRow'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($host_array) ? serialize($host_array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . $_POST['drp_action'] . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n\t\t"; html_end_box(); bottom_footer(); }
function data_query_item_remove() { /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('id')); input_validate_input_number(get_request_var_request('snmp_query_id')); /* ==================================================== */ if (read_config_option('deletion_verification') == 'on' && !isset($_REQUEST['confirm'])) { top_header(); form_confirm('Are You Sure?', "Are you sure you want to delete the Data Query Graph <strong>'" . htmlspecialchars(db_fetch_cell_prepared('SELECT name FROM snmp_query_graph WHERE id = ?', array($_REQUEST['id'])), ENT_QUOTES) . "'</strong>?", htmlspecialchars('data_queries.php?action=edit&id=' . $_REQUEST['snmp_query_id']), htmlspecialchars('data_queries.php?action=item_remove&id=' . $_REQUEST['id'] . '&snmp_query_id=' . $_REQUEST['snmp_query_id'])); bottom_footer(); exit; } if (read_config_option('deletion_verification') == '' || isset($_REQUEST['confirm'])) { db_execute_prepared('DELETE FROM snmp_query_graph WHERE id = ?', array($_REQUEST['id'])); db_execute_prepared('DELETE FROM snmp_query_graph_rrd WHERE snmp_query_graph_id = ?', array($_REQUEST['id'])); db_execute_prepared('DELETE FROM snmp_query_graph_rrd_sv WHERE snmp_query_graph_id = ?', array($_REQUEST['id'])); db_execute_prepared('DELETE FROM snmp_query_graph_sv WHERE snmp_query_graph_id = ?', array($_REQUEST['id'])); } }
function host_new_graphs($host_id, $host_template_id, $selected_graphs_array) { /* we use object buffering on this page to allow redirection to another page if no fields are actually drawn */ ob_start(); top_header(); print "<form method='post' action='graphs_new.php'>\n"; $snmp_query_id = 0; $num_output_fields = array(); while (list($form_type, $form_array) = each($selected_graphs_array)) { while (list($form_id1, $form_array2) = each($form_array)) { if ($form_type == 'cg') { $graph_template_id = $form_id1; html_start_box("<strong>Create Graph from '" . db_fetch_cell_prepared('SELECT name FROM graph_templates WHERE id = ?', array($graph_template_id)) . "'", '100%', '', '3', 'center', ''); } elseif ($form_type == 'sg') { while (list($form_id2, $form_array3) = each($form_array2)) { /* ================= input validation ================= */ input_validate_input_number($snmp_query_id); /* ==================================================== */ $snmp_query_id = $form_id1; $snmp_query_graph_id = $form_id2; $num_graphs = sizeof($form_array3); $snmp_query = db_fetch_row_prepared('SELECT snmp_query.name, snmp_query.xml_path FROM snmp_query WHERE snmp_query.id = ?', array($snmp_query_id)); $graph_template_id = db_fetch_cell_prepared('SELECT graph_template_id FROM snmp_query_graph WHERE id = ?', array($snmp_query_graph_id)); } /* DRAW: Data Query */ html_start_box("<strong>Create {$num_graphs} Graph" . ($num_graphs > 1 ? 's' : '') . " from '" . db_fetch_cell_prepared('SELECT name FROM snmp_query WHERE id = ?', array($snmp_query_id)) . "'", '100%', '', '3', 'center', ''); } /* ================= input validation ================= */ input_validate_input_number($graph_template_id); /* ==================================================== */ $data_templates = db_fetch_assoc_prepared('SELECT data_template.name AS data_template_name, data_template_rrd.data_source_name, data_template_data.* FROM (data_template, data_template_rrd, data_template_data, graph_templates_item) WHERE graph_templates_item.task_item_id = data_template_rrd.id AND data_template_rrd.data_template_id = data_template.id AND data_template_data.data_template_id = data_template.id AND data_template_rrd.local_data_id = 0 AND data_template_data.local_data_id = 0 AND graph_templates_item.local_graph_id = 0 AND graph_templates_item.graph_template_id = ? GROUP BY data_template.id ORDER BY data_template.name', array($graph_template_id)); $graph_template = db_fetch_row_prepared('SELECT graph_templates.name AS graph_template_name, graph_templates_graph.* FROM (graph_templates, graph_templates_graph) WHERE graph_templates.id = graph_templates_graph.graph_template_id AND graph_templates.id = ? AND graph_templates_graph.local_graph_id = 0', array($graph_template_id)); $graph_template_name = db_fetch_cell_prepared('SELECT name FROM graph_templates WHERE id = ?', array($graph_template_id)); array_push($num_output_fields, draw_nontemplated_fields_graph($graph_template_id, $graph_template, "g_{$snmp_query_id}" . '_' . $graph_template_id . '_|field|', '<strong>Graph</strong> [Template: ' . $graph_template['graph_template_name'] . ']', false, false, isset($snmp_query_graph_id) ? $snmp_query_graph_id : 0)); array_push($num_output_fields, draw_nontemplated_fields_graph_item($graph_template_id, 0, 'gi_' . $snmp_query_id . '_' . $graph_template_id . '_|id|_|field|', '<strong>Graph Items</strong> [Template: ' . $graph_template_name . ']', false)); /* DRAW: Data Sources */ if (sizeof($data_templates) > 0) { foreach ($data_templates as $data_template) { array_push($num_output_fields, draw_nontemplated_fields_data_source($data_template['data_template_id'], 0, $data_template, 'd_' . $snmp_query_id . '_' . $graph_template_id . '_' . $data_template['data_template_id'] . '_|field|', '<strong>Data Source</strong> [Template: ' . $data_template['data_template_name'] . ']', false, false, isset($snmp_query_graph_id) ? $snmp_query_graph_id : 0)); $data_template_items = db_fetch_assoc_prepared('SELECT data_template_rrd.* FROM data_template_rrd WHERE data_template_rrd.data_template_id = ? AND local_data_id = 0', array($data_template['data_template_id'])); array_push($num_output_fields, draw_nontemplated_fields_data_source_item($data_template['data_template_id'], $data_template_items, 'di_' . $snmp_query_id . '_' . $graph_template_id . '_' . $data_template['data_template_id'] . '_|id|_|field|', '', false, false, false, isset($snmp_query_graph_id) ? $snmp_query_graph_id : 0)); array_push($num_output_fields, draw_nontemplated_fields_custom_data($data_template['id'], 'c_' . $snmp_query_id . '_' . $graph_template_id . '_' . $data_template['data_template_id'] . '_|id|', '<strong>Custom Data</strong> [Template: ' . $data_template['data_template_name'] . ']', false, false, $snmp_query_id)); } } html_end_box(); } } /* no fields were actually drawn on the form; just save without prompting the user */ if (array_sum($num_output_fields) == 0) { ob_end_clean(); /* since the user didn't actually click "Create" to POST the data; we have to pretend like they did here */ $_POST['host_template_id'] = $host_template_id; $_POST['host_id'] = $host_id; $_POST['save_component_new_graphs'] = '1'; $_POST['selected_graphs_array'] = serialize($selected_graphs_array); host_new_graphs_save(); header('Location: graphs_new.php?host_id=' . $_POST['host_id']); exit; } /* flush the current output buffer to the browser */ ob_end_flush(); form_hidden_box('host_template_id', $host_template_id, '0'); form_hidden_box('host_id', $host_id, '0'); form_hidden_box('save_component_new_graphs', '1', ''); print "<input type='hidden' name='selected_graphs_array' value='" . serialize($selected_graphs_array) . "'>\n"; if (!substr_count($_SERVER['HTTP_REFERER'], 'graphs_new')) { $_REQUEST['returnto'] = basename($_SERVER['HTTP_REFERER']); } load_current_session_value('returnto', 'sess_graphs_new_returnto', ''); form_save_button($_REQUEST['returnto']); bottom_footer(); }
function form_actions() { global $actions; /* 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'] == '1') { /* delete */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ domain_remove($selected_items[$i]); } } elseif ($_POST['drp_action'] == '2') { /* disable */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ domain_disable($selected_items[$i]); } } elseif ($_POST['drp_action'] == '3') { /* enable */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ domain_enable($selected_items[$i]); } } elseif ($_POST['drp_action'] == '4') { /* default */ if (sizeof($selected_items) > 1) { /* error message */ } else { for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ domain_default($selected_items[$i]); } } } header('Location: user_domains.php'); exit; } /* setup some variables */ $d_list = ''; $d_array = array(); /* loop through each of the data queries and process them */ while (list($var, $val) = each($_POST)) { if (ereg('^chk_([0-9]+)$', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ $d_list .= '<li>' . db_fetch_cell_prepared('SELECT domain_name FROM user_domains WHERE domain_id = ?', array($matches[1])) . '</li>'; $d_array[] = $matches[1]; } } top_header(); html_start_box('<strong>' . $actions[$_POST['drp_action']] . '</strong>', '60%', '', '3', 'center', ''); print "<form action='user_domains.php' method='post'>\n"; if (isset($d_array) && sizeof($d_array)) { if ($_POST['drp_action'] == '1') { /* delete */ print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following User Domain(s) will be deleted.</p>\n\t\t\t\t\t\t<p><ul>{$d_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Delete User Domain(s)'>"; } else { if ($_POST['drp_action'] == '2') { /* disable */ print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following User Domain(s) will be disabled.</p>\n\t\t\t\t\t\t<p><ul>{$d_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Disable User Domain(s)'>"; } else { if ($_POST['drp_action'] == '3') { /* enable */ print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following User Domain(s) will be enabled.</p>\n\t\t\t\t\t\t<p><ul>{$d_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Enabled User Domain(s)'>"; } else { if ($_POST['drp_action'] == '4') { /* default */ print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following User Domain will become the default.</p>\n\t\t\t\t\t\t<p><ul>{$d_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Make Selected Domain Default'>"; } } } } } else { print "<tr><td class='even'><span class='textError'>You must select at least one data input method.</span></td></tr>\n"; $save_html = "<input type='button' value='Return' onClick='window.history.back()'>"; } print "\t<tr>\n\t\t\t<td align='right' class='saveRow'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($d_array) ? serialize($d_array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . $_POST['drp_action'] . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>"; html_end_box(); bottom_footer(); }