From 9e77c38d5cd2252ee78c1766cb90a4747fc4c493 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Fri, 13 Jan 2012 14:52:52 +0000 Subject: [PATCH] 2012-01-13 Ramon Novoa * include/functions_graph.php, include/functions_netflow.php, operation/netflow/nf_view.php: Aesthetic fixes. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5369 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 ++++ pandora_console/include/functions_graph.php | 31 ++++++++++++------- pandora_console/include/functions_netflow.php | 27 ++++++++-------- pandora_console/operation/netflow/nf_view.php | 18 +++++++---- 4 files changed, 51 insertions(+), 31 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 0735ab376c..39bfea7806 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2012-01-13 Ramon Novoa + + * include/functions_graph.php, + include/functions_netflow.php, + operation/netflow/nf_view.php: Aesthetic fixes. + 2012-01-13 Ramon Novoa * include/functions_graph.php, diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index c2e23681cd..fe07e52c59 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -1936,12 +1936,11 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, * Print an area graph with netflow aggregated */ -function graph_netflow_aggregate_area ($data, $period, $width, $height, $title, $unit_name, $avg_only = 0, $pure=0, $date = 0, $only_image = false, $homeurl = '') { +function graph_netflow_aggregate_area ($data, $period, $width, $height, $only_image) { global $config; global $graphic_type; - echo"

".__('Area graph')."

"; - include_flash_chart_script($homeurl); + include_flash_chart_script($config['homeurl']); if (empty ($data)) { echo fs_error_image (); @@ -1991,8 +1990,14 @@ function graph_netflow_aggregate_area ($data, $period, $width, $height, $title, $flash_chart = false; } - return stacked_area_graph($flash_chart, $chart, $width, $height, null, $sources, - null, "images/image_problem.opaque.png", "", "", + if ($config['homeurl'] != '') { + $homeurl = $config['homeurl'] . '/'; + } else { + $homeurl = ''; + } + + return area_graph($flash_chart, $chart, $width, $height, array (), $sources, + null, "images/image_problem.opaque.png", "", "", $homeurl, $config['homedir'] . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size'], ""); } @@ -2002,12 +2007,11 @@ function graph_netflow_aggregate_area ($data, $period, $width, $height, $title, /** * Print an area graph with netflow total */ -function graph_netflow_total_area ($data, $period, $width, $height, $title, $unit_name, $avg_only = 0, $pure=0, $date = 0, $only_image = false, $homeurl = '') { +function graph_netflow_total_area ($data, $period, $width, $height, $only_image) { global $config; global $graphic_type; - echo"

Gráfica de área

"; - include_flash_chart_script($homeurl); + include_flash_chart_script($config['homeurl']); if (empty ($data)) { echo fs_error_image (); @@ -2041,6 +2045,12 @@ function graph_netflow_total_area ($data, $period, $width, $height, $title, $uni $flash_chart = false; } + if ($config['homeurl'] != '') { + $homeurl = $config['homeurl'] . '/'; + } else { + $homeurl = ''; + } + return area_graph($flash_chart, $chart, $width, $height, array (), array (), array (), "images/image_problem.opaque.png", "", "", $homeurl, $config['homedir'] . "/images/logo_vertical_water.png", @@ -2050,12 +2060,10 @@ function graph_netflow_total_area ($data, $period, $width, $height, $title, $uni /** * Print a pie graph with netflow aggregated */ -function graph_netflow_aggregate_pie ($data) { +function graph_netflow_aggregate_pie ($data, $aggregate) { global $config; global $graphic_type; - echo"

".__('Graphic totalized')."

"; - if (empty ($data)) { echo fs_error_image (); return; @@ -2073,6 +2081,7 @@ function graph_netflow_aggregate_pie ($data) { } $i++; } + return pie3d_graph($config['flash_charts'], $values, 320, 200, __('Other'), '', $config['homedir'] . "/images/logo_vertical_water.png", $config['fontpath'], $config['font_size']); diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 90a29b0b36..0cbfcbd46e 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -184,7 +184,7 @@ function sort_netflow_data (&$netflow_data) { usort($netflow_data, "compare_flows"); } -function netflow_stat_table ($data, $start_date, $end_date, $show){ +function netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit){ global $nfdump_date_format; $start_date = date ($nfdump_date_format, $start_date); @@ -193,29 +193,28 @@ function netflow_stat_table ($data, $start_date, $end_date, $show){ $table->width = '50%'; $table->class = 'databox'; $table->data = array(); - $title = __('From')." ".$start_date." ".__('to')." ".$end_date; $j = 0; $x = 1; - echo"

".__('Amount per period')." (".$show.")

"; - $table->data[0][0] = ''.__('Rank').''; - $table->data[0][1] = ''.$title.''; + $table->data[0][0] = '' . __($aggregate) . ''; + $table->data[0][1] = '' . __($unit) . ''; while (isset ($data[$j])) { $agg = $data[$j]['agg']; if (!isset($values[$agg])){ $values[$agg] = $data[$j]['data']; $table->data[$x][0] = $agg; - $table->data[$x][1] = format_numeric ($data[$j]['data']) .' '.$show; + $table->data[$x][1] = format_numeric ($data[$j]['data']); } else { $values[$agg] += $data[$j]['data']; $table->data[$x][0] = $agg; - $table->data[$x][1] = format_numeric ($data[$j]['data']) .' '.$show; + $table->data[$x][1] = format_numeric ($data[$j]['data']); } $j++; $x++; } -html_print_table($table); + + html_print_table($table); } /** @@ -224,11 +223,11 @@ html_print_table($table); * @param array data Statistic data. * @param string start_date Start date. * @param string end_date End date. - * @param string unit Unit to display. + * @param string aggregate Aggregate field. * * @return The statistics table. */ -function netflow_data_table ($data, $start_date, $end_date, $unit){ +function netflow_data_table ($data, $start_date, $end_date, $aggregate) { global $nfdump_date_format; $period = $end_date - $start_date; @@ -253,12 +252,11 @@ function netflow_data_table ($data, $start_date, $end_date, $unit){ } $values = array(); - //$table->size = array ('50%'); + $table->size = array ('50%'); $table->class = 'databox'; $table->data = array(); - echo"

".__('Table values'). " (".$unit.")

"; - $table->data[0][0] = ''.__('Rank').''; + $table->data[0][0] = ''.__($aggregate).''; $j = 0; $source_index = array (); @@ -326,6 +324,7 @@ function netflow_get_data ($start_date, $end_date, $command, $unique_id, $aggreg $values['sources'] = array (); $agg_command = $command . " -s $aggregate/$unit -n $max -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); exec($agg_command, $string); + foreach($string as $line){ if ($line=='') { continue; @@ -381,7 +380,7 @@ function netflow_get_data ($start_date, $end_date, $command, $unique_id, $aggreg function netflow_get_stats ($start_date, $end_date, $command, $aggregate, $max, $unit){ global $nfdump_date_format; - $command .= ' -s ' . $aggregate . ' -n ' . $max . ' -t '.date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); + $command .= " -s $aggregate/$unit -n $max -t " .date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date); exec($command, $string); if(! is_array($string)){ diff --git a/pandora_console/operation/netflow/nf_view.php b/pandora_console/operation/netflow/nf_view.php index 4889cc5b61..8e562d0d2a 100644 --- a/pandora_console/operation/netflow/nf_view.php +++ b/pandora_console/operation/netflow/nf_view.php @@ -136,6 +136,7 @@ for ($x = 0; isset($all_rcs[$x]['id_rc']); $x++) { // Get item filters $filter = db_get_row_sql("SELECT * FROM tnetflow_filter WHERE id_sg = '" . io_safe_input ($content_report['id_filter']) . "'", false, true); $command = netflow_get_command ($filter); + $title = $filter['id_name']; $aggregate = $filter['aggregate']; $unit = $filter['output']; @@ -145,23 +146,28 @@ for ($x = 0; isset($all_rcs[$x]['id_rc']); $x++) { $unique_id = $report_id . '_' . $content_id . '_' . ($end_date - $start_date); $data = netflow_get_data ($start_date, $end_date, $command, $unique_id, $aggregate, $max_aggregates, $unit); if ($aggregate != 'none') { - echo graph_netflow_aggregate_area($data, $interval, 660, 320, '', '', '', '', $end_date, $unit); + echo '

' . $title . ' (' . __($aggregate) . '/' . __($unit) . ')

'; + echo graph_netflow_aggregate_area($data, $interval, 660, 320, 0); } else { - echo graph_netflow_total_area($data, $interval, 660, 320, '', '','','',$date); + echo '

' . $title . ' (' . __($unit) . ')

'; + echo graph_netflow_total_area($data, $interval, 660, 320, 0); } break; case '1': - $result = netflow_get_stats ($start_date, $end_date, $command, $aggregate, $max_aggregates, $unit); - echo graph_netflow_aggregate_pie($result); + $data = netflow_get_stats ($start_date, $end_date, $command, $aggregate, $max_aggregates, $unit); + echo '

' . $title . ' (' . __($aggregate) . '/' . __($unit) . ')

'; + echo graph_netflow_aggregate_pie($data, $aggregate, $unit, $title); break; case '2': $unique_id = $report_id . '_' . $content_id . '_' . ($end_date - $start_date); $data = netflow_get_data ($start_date, $end_date, $command, $unique_id, $aggregate, $max_aggregates, $unit); - echo netflow_data_table ($data, $start_date, $end_date, $unit); + echo '

' . $title . ' (' . __($aggregate) . '/' . __($unit) . ')

'; + echo netflow_data_table ($data, $start_date, $end_date, $aggregate); break; case '3': $data = netflow_get_stats ($start_date, $end_date, $command, $aggregate, $max_aggregates, $unit); - echo netflow_stat_table ($data, $start_date, $end_date, $unit); + echo '

' . $title . '

'; + echo netflow_stat_table ($data, $start_date, $end_date, $aggregate, $unit); break; default: echo fs_error_image();