function validate_request_vars($force = false) { /* ================= input validation and session storage ================= */ $filters = array('id' => array('filter' => FILTER_VALIDATE_INT, 'default' => '-1'), 'tree_id' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_config_option('cycle_custom_graphs_tree', $force)), 'leaf_id' => array('filter' => FILTER_VALIDATE_INT, 'default' => '-2'), 'graphs' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('cycle_graphs', read_config_option('cycle_graphs'), $force)), 'cols' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('cycle_columns', read_config_option('cycle_columns'), $force)), 'width' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('cycle_width', read_config_option('cycle_width'), $force)), 'height' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('cycle_height', read_config_option('cycle_height'), $force)), 'timespan' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('cycle_timespan', read_config_option('cycle_timespan'), $force)), 'delay' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('cycle_delay', read_config_option('cycle_delay'), $force)), 'legend' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => read_user_setting('cycle_legend', read_config_option('cycle_legend'), $force), 'options' => array('options' => 'sanitize_search_string')), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => read_user_setting('cycle_filter', '', $force), 'options' => array('options' => 'sanitize_search_string'))); validate_store_request_vars($filters, 'sess_cycle'); /* ================= input validation ================= */ }
function flowview_gettimespan() { global $config; include_once $config['base_path'] . '/lib/time.php'; $timespan = get_filter_request_var('timespan'); $date1 = get_nfilter_request_var('date1'); $date2 = get_nfilter_request_var('date2'); $span = array(); if ($timespan > 0) { get_timespan($span, time(), $timespan, read_user_setting('first_weekdayid')); } else { $span['current_value_date1'] = $date1; $span['current_value_date2'] = $date2; $span['begin_now'] = strtotime($date1); $span['end_now'] = strtotime($date2); } print json_encode($span); }
/** function syslog_request_validation() * This is a generic funtion for this page that makes sure that * we have a good request. We want to protect against people who * like to create issues with Cacti. */ function syslog_request_validation($current_tab, $force = false) { global $title, $rows, $config, $reset_multi; include_once './lib/timespan_settings.php'; if ($current_tab != 'alerts' && isset_request_var('host') && get_nfilter_request_var('host') == -1) { kill_session_var('sess_syslog_' . $current_tab . '_hosts'); unset_request_var('host'); } /* ================= input validation and session storage ================= */ $filters = array('rows' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => read_user_setting('syslog_rows', '-1', $force)), 'page' => array('filter' => FILTER_VALIDATE_INT, 'default' => '1'), 'id' => array('filter' => FILTER_VALIDATE_INT, 'default' => ''), 'removal' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('syslog_removal', '1', $force)), 'refresh' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('syslog_refresh', read_config_option('syslog_refresh'), $force)), 'trimval' => array('filter' => FILTER_VALIDATE_INT, 'default' => read_user_setting('syslog_trimval', '75', $force)), 'enabled' => array('filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'), 'host' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '0', 'options' => array('options' => 'sanitize_search_string')), 'efacility' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => read_user_setting('syslog_efacility', '-1', $force), 'options' => array('options' => 'sanitize_search_string')), 'epriority' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => read_user_setting('syslog_epriority', '-1', $force), 'options' => array('options' => 'sanitize_search_string')), 'eprogram' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => read_user_setting('syslog_eprogram', '-1', $force), 'options' => array('options' => 'sanitize_search_string')), 'filter' => array('filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string')), 'sort_column' => array('filter' => FILTER_CALLBACK, 'default' => 'logtime', 'options' => array('options' => 'sanitize_search_string')), 'sort_direction' => array('filter' => FILTER_CALLBACK, 'default' => 'DESC', 'options' => array('options' => 'sanitize_search_string'))); validate_store_request_vars($filters, 'sess_syslogs_' . $current_tab); /* ================= input validation ================= */ api_plugin_hook_function('syslog_request_val'); if (isset_request_var('host')) { $_SESSION['sess_syslog_' . $current_tab . '_hosts'] = get_nfilter_request_var('host'); } else { if (isset($_SESSION['sess_syslog_' . $current_tab . '_hosts'])) { set_request_var('host', $_SESSION['sess_syslog_' . $current_tab . '_hosts']); } else { set_request_var('host', '-1'); } } }
$leaf_id = get_request_var('leaf_id'); $graphpp = get_request_var('graphs'); $cols = get_request_var('cols'); $filter = get_request_var('filter'); $id = get_request_var('id'); $width = get_request_var('width'); $height = get_request_var('height'); if (empty($tree_id)) { $tree_id = db_fetch_cell('SELECT id FROM graph_tree ORDER BY name LIMIT 1'); } if (empty($id)) { $id = -1; } /* get the start and end times for the graph */ $timespan = array(); $first_weekdayid = read_user_setting('first_weekdayid'); get_timespan($timespan, time(), get_request_var('timespan'), $first_weekdayid); $graph_tree = $tree_id; $html = ''; $out = ''; /* detect the next graph regardless of type */ get_next_graphid($graphpp, $filter, $graph_tree, $leaf_id); switch (read_config_option('cycle_custom_graphs_type')) { case '0': case '1': /* will only use the filter for full rotation */ break; case '2': $tree_list = get_graph_tree_array(); if (sizeof($tree_list)) { $html = "<td><select id='tree_id' name='tree_id' onChange='newTree()' title='" . __('Select Tree to View') . "'>\n";
function mikrotik_view_graphs() { global $current_user, $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(__('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('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_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]); } } $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_user_setting('default_rra_id') : get_request_var('rra_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'); } 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 (get_request_var('graph_template_id') > 0) { $sql_where .= (strlen($sql_where) ? ' AND' : '') . ' gl.graph_template_id IN(' . get_request_var('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 = 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(); }
$_POST['print_report'] = $print_report = $q['printed']; $_POST['resolve_addresses'] = $resolve_addresses = $q['resolve']; } else { $device = ''; if (isset_request_var('device_name')) { $device = get_nfilter_request_var('device_name'); } else { $device = db_fetch_cell("SELECT folder FROM plugin_flowview_devices ORDER BY id LIMIT 1"); $_POST['device_name'] = $device; } $timespan = 0; if (isset_request_var('predefined_timespan') && get_filter_request_var('predefined_timespan') > 0) { $timespan = get_request_var('predefined_timespan'); set_request_var('predefined_timespan', $timespan); $span = array(); get_timespan($span, time(), $timespan, read_user_setting('first_weekdayid')); $_POST['date1'] = $date1 = $span['current_value_date1']; $_POST['date2'] = $date2 = $span['current_value_date2']; } else { set_request_var('predefined_timespan', '0'); $timespan = 0; $date1 = date('Y-m-d H:i:s', time() - 8 * 3600); if (isset_request_var('date1')) { $date1 = get_nfilter_request_var('date1'); } $date2 = date('Y-m-d H:i:s'); if (isset_request_var('date2')) { $date2 = get_nfilter_request_var('date2'); } } $tos_fields = '';