$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', array('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['output'] = get_parameter('output','bytes'); $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['advanced_filter'] = get_parameter('advanced_filter',''); // Read chart configuration $chart_type = get_parameter('chart_type', 'netflow_area'); $max_aggregates = (int) get_parameter('max_aggregates', 0); $period = (int) get_parameter('period', '86400'); $update_date = (int) get_parameter('update_date', 0); $date = get_parameter_post ('date', date (DATE_FORMAT, get_system_time ())); $time = get_parameter_post ('time', date (TIME_FORMAT, get_system_time ())); $connection_name = get_parameter('connection_name', ''); $interval_length = (int) get_parameter('interval_length', 300); // Read buttons $draw = get_parameter('draw_button', ''); $save = get_parameter('save_button', ''); $update = get_parameter('update_button', ''); // Calculate start and end dates $end_date = strtotime ($date . " " . $time); $start_date = $end_date - $period; if (! defined ('METACONSOLE')) { //Header ui_print_page_header (__('Netflow live view'), "images/op_netflow.png", false, "", false, array ()); if (! is_executable ($config['netflow_nfdump'])) { ui_print_error_message( sprintf(__('nfdump binary (%s) not found!'), $config['netflow_nfdump'])); } } else { $nav_bar = array(array('link' => 'index.php?sec=main', 'text' => __('Main')), array('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); $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')); } } // Update current filter else if ($update != '' && check_acl ($config["id_user"], 0, "AW")) { // 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); $result = db_process_sql_update ('tnetflow_filter', $filter_copy, array('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']; } open_meta_frame(); echo '
'; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; $max_values = array ('2' => '2', '5' => '5', '10' => '10', '15' => '15', '20' => '20', '25' => '25', '50' => '50'); echo ""; if (defined ('METACONSOLE')) { $list_servers = array(); $servers = db_get_all_rows_sql ("SELECT * FROM tmetaconsole_setup"); if ($servers === false) $servers = array(); foreach ($servers as $server) { // If connection was good then retrieve all data server if (metaconsole_load_external_db ($server)) { $connection = true; } else { $connection = false; } $row = db_get_row('tconfig', 'token', 'activate_netflow'); if ($row['value']) { $list_servers[$server['server_name']] = $server['server_name']; } metaconsole_restore_db(); } echo ""; echo ""; } echo ""; // Read filter type if ($filter['advanced_filter'] != '') { $filter_type = 1; } else { $filter_type = 0; } echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; $own_info = get_user_info ($config['id_user']); echo ""; echo ""; echo ""; echo ""; if ($netflow_disable_custom_lvfilters) { echo ""; echo ""; } else { echo ""; echo ""; } echo ""; $user_groups = users_get_groups ($config['id_user'], "AR", $own_info['is_admin'], true); $user_groups[0] = 0; //Add all groups. $sql = "SELECT * FROM tnetflow_filter WHERE id_group IN (".implode(',', array_keys ($user_groups)).")"; echo ""; echo ""; echo ""; if ($netflow_disable_custom_lvfilters) { echo ""; echo ""; } else { echo ""; echo ""; } if ($netflow_disable_custom_lvfilters) { echo ""; echo ""; } else { echo ""; echo ""; } echo ""; echo ""; if ($netflow_disable_custom_lvfilters) { echo ""; echo ""; } else { echo ""; echo ""; } if ($netflow_disable_custom_lvfilters) { echo ""; echo ""; } else { echo ""; echo ""; } echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; $aggregate_list = array(); $aggregate_list = array ('none' => __('None'), 'proto' => __('Protocol'), 'srcip' =>__('Src Ip Address'), 'dstip' =>__('Dst Ip Address'), 'srcport' =>__('Src Port'), 'dstport' =>__('Dst Port') ); echo ""; echo ""; $show_output = array ('bytes' => __('Bytes'), 'bytespersecond' => __('Bytes per second'), 'kilobytes' => __('Kilobytes'), 'megabytes' => __('Megabytes'), 'kilobytespersecond' => __('Kilobytes per second'), 'megabytespersecond' => __('Megabytes per second')); echo ""; echo ""; echo "
" . '' . __('Date') . '' . "" . html_print_input_text ('date', $date, false, 13, 10, true) . html_print_image ("images/calendar_view_day.png", true, array("alt" => "calendar")) . ui_print_help_tip(__('Date format in Pandora is year/month/day'), true) . html_print_input_text ('time', $time, false, 10, 5, true) . ui_print_help_tip(__('Time format in Pandora is hours(24h):minutes:seconds'), true) . "" . ''.__('Interval').'' . "" . html_print_select (netflow_get_valid_intervals (), 'period', $period, '', '', 0, true, false, false) . "" . ''.__('Resolution') . ui_print_help_tip (__("The interval will be divided in chunks the length of the resolution."), true) . '' . "" . html_print_select (netflow_get_valid_subintervals (), 'interval_length', $interval_length, '', '', 0, true, false, false) ."
" . '' . __('Type') . '' . "" . html_print_select (netflow_get_chart_types (), 'chart_type', $chart_type,'','',0,true) . "" . '' . __('Max. values') . '' . "" . html_print_select ($max_values, 'max_aggregates', $max_aggregates, '', '', 0, true) . "" . ''.__('Connection').'' . "" . html_print_select($list_servers, 'connection_name', $connection_name, '', '', 0, true, false, false) . "
" . ''.__('Filter').'' . "" . __('Normal') . ' ' . html_print_radio_button_extended ('filter_type', 0, '', $filter_type, false, 'displayNormalFilter();', 'style="margin-right: 40px;"', true) . __('Advanced') . ' ' . html_print_radio_button_extended ('filter_type', 1, '', $filter_type, false, 'displayAdvancedFilter();', 'style="margin-right: 40px;"', true) . "" . ''.__('Load filter').'' . "" . html_print_select_from_sql ($sql, 'filter_id', $filter_id, '', __('none'), 0, true) . "
" . __('Dst Ip'). ui_print_help_tip (__("Destination IP. A comma separated list of destination ip. If we leave the field blank, will show all ip. Example filter by ip:
25.46.157.214,160.253.135.249"), true) . "
" . html_print_input_text ('ip_dst', $filter['ip_dst'], false, 30, 80, true) . "" . __('Src Ip'). ui_print_help_tip (__("Source IP. A comma separated list of source ip. If we leave the field blank, will show all ip. Example filter by ip:
25.46.157.214,160.253.135.249"), true) . "
" . html_print_input_text ('ip_src', $filter['ip_src'], false, 30, 80, true) . "
" . __('Dst Port'). ui_print_help_tip (__("Destination port. A comma separated list of destination ports. If we leave the field blank, will show all ports. Example filter by ports 80 and 22:
80,22"), true) . "
" . html_print_input_text ('dst_port', $filter['dst_port'], false, 30, 80, true) . "" . __('Src Port'). ui_print_help_tip (__("Source port. A comma separated list of source ports. If we leave the field blank, will show all ports. Example filter by ports 80 and 22:
80,22"), true) . "
" . html_print_input_text ('src_port', $filter['src_port'], false, 30, 80, true) . "
" . ''.__('Aggregate by').''. ui_print_help_icon ('aggregate_by', true) . "" . html_print_select ($aggregate_list, "aggregate", $filter['aggregate'], '', '', 0, true, false, true, '', false) . "" . ''.__('Output format').'' . "" . html_print_select ($show_output, 'output', $filter['output'], '', '', 0, true, false, true, '', false) . "
"; echo "
"; if (defined ('METACONSOLE')) { echo "
"; } html_print_submit_button (__('Draw'), 'draw_button', false, 'class="sub upd"'); if (!$netflow_disable_custom_lvfilters) { if (check_acl ($config["id_user"], 0, "AW")) { html_print_submit_button (__('Save as new filter'), 'save_button', false, 'class="sub upd" onClick="return defineFilterName();"'); html_print_submit_button (__('Update current filter'), 'update_button', false, 'class="sub upd"'); } } if (defined ('METACONSOLE')) { echo "
"; } echo'
'; if ($draw != '') { // Get the command to call nfdump $command = netflow_get_command ($filter); // Draw echo "
"; echo netflow_draw_item ($start_date, $end_date, $interval_length, $chart_type, $filter, $max_aggregates, $connection_name); } close_meta_frame(); ui_require_jquery_file ("ui-timepicker-addon"); ?>