$id]); if (empty($advanced_filter)) { $type = 0; } else { $type = 1; } echo $type; } // Get values of the current netflow filter. if ($get_filter_values) { $id = get_parameter('id'); $filter_values = db_get_row_filter('tnetflow_filter', ['id_sg' => $id]); // Decode HTML entities. $filter_values['advanced_filter'] = io_safe_output($filter_values['advanced_filter']); echo json_encode($filter_values); } return; } // Read filter configuration. $filter_id = (int) get_parameter('filter_id', 0); $filter['id_name'] = get_parameter('name', ''); $filter['id_group'] = (int) get_parameter('assign_group', 0); $filter['aggregate'] = get_parameter('aggregate', ''); $filter['ip_dst'] = get_parameter('ip_dst', ''); $filter['ip_src'] = get_parameter('ip_src', ''); $filter['dst_port'] = get_parameter('dst_port', ''); $filter['src_port'] = get_parameter('src_port', ''); $filter['advanced_filter'] = get_parameter('advanced_filter', ''); $filter['router_ip'] = get_parameter('router_ip'); // Read chart configuration. $chart_type = get_parameter('chart_type', 'netflow_area'); $max_aggregates = (int) get_parameter('max_aggregates', 10); $update_date = (int) get_parameter('update_date', 0); $connection_name = get_parameter('connection_name', ''); $interval_length = get_parameter('interval_length', NETFLOW_RES_MEDD); $address_resolution = (int) get_parameter('address_resolution', $config['netflow_get_ip_hostname']); $filter_selected = (int) get_parameter('filter_selected', 0); // Read time values. $date = get_parameter_post('date', date(DATE_FORMAT, get_system_time())); $time = get_parameter_post('time', date(TIME_FORMAT, get_system_time())); $end_date = strtotime($date.' '.$time); $is_period = (bool) get_parameter('is_period', false); $period = (int) get_parameter('period', SECONDS_1DAY); $time_lower = get_parameter('time_lower', date(TIME_FORMAT, ($end_date - $period))); $date_lower = get_parameter('date_lower', date(DATE_FORMAT, ($end_date - $period))); $start_date = ($is_period) ? ($end_date - $period) : strtotime($date_lower.' '.$time_lower); if (!$is_period) { $period = ($end_date - $start_date); } else { $time_lower = date(TIME_FORMAT, $start_date); $date_lower = date(DATE_FORMAT, $start_date); } // Read buttons. $draw = get_parameter('draw_button', ''); $save = get_parameter('save_button', ''); $update = get_parameter('update_button', ''); if (!is_metaconsole()) { // Header. ui_print_page_header( __('Netflow live view'), 'images/op_netflow.png', false, '', false, [] ); $is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'; if ($is_windows) { ui_print_error_message(__('Not supported in Windows systems')); } else { netflow_print_check_version_error(); } } else { $nav_bar = [ [ 'link' => 'index.php?sec=main', 'text' => __('Main'), ], [ 'link' => 'index.php?sec=netf&sec2=operation/netflow/nf_live_view', 'text' => __('Netflow live view'), ], ]; ui_meta_print_page_header($nav_bar); ui_meta_print_header(__('Netflow live view')); } // Save user defined filter. if ($save != '' && check_acl($config['id_user'], 0, 'AW')) { // Save filter args. $filter['filter_args'] = netflow_get_filter_arguments($filter, true); $filter_id = db_process_sql_insert('tnetflow_filter', $filter); if ($filter_id === false) { $filter_id = 0; ui_print_error_message(__('Error creating filter')); } else { ui_print_success_message(__('Filter created successfully')); } } else if ($update != '' && check_acl($config['id_user'], 0, 'AW')) { // Update current filter. // Do not update the filter name and group. $filter_copy = $filter; unset($filter_copy['id_name']); unset($filter_copy['id_group']); // Save filter args. $filter_copy['filter_args'] = netflow_get_filter_arguments($filter_copy, true); $result = db_process_sql_update( 'tnetflow_filter', $filter_copy, ['id_sg' => $filter_id] ); ui_print_result_message( $result, __('Filter updated successfully'), __('Error updating filter') ); } // The filter name will not be needed anymore. $filter['id_name'] = ''; $netflow_disable_custom_lvfilters = false; if (isset($config['netflow_disable_custom_lvfilters'])) { $netflow_disable_custom_lvfilters = $config['netflow_disable_custom_lvfilters']; } enterprise_hook('open_meta_frame'); $class = 'databox filters'; echo '
'; if ($draw != '') { // Draw. echo '