2013-02-04 Miguel de Dios <miguel.dedios@artica.es>

* install.php: cleaned source code style.
	
	* godmode/netflow/nf_edit.php, include/functions_netflow.php: fixed
	the empty data.
	
	Fixes: #3603092




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7567 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-02-04 12:19:17 +00:00
parent 0d9606c92f
commit c2a39c1ee8
4 changed files with 50 additions and 25 deletions

View File

@ -1,3 +1,12 @@
2013-02-04 Miguel de Dios <miguel.dedios@artica.es>
* install.php: cleaned source code style.
* godmode/netflow/nf_edit.php, include/functions_netflow.php: fixed
the empty data.
Fixes: #3603092
2013-02-04 Miguel de Dios <miguel.dedios@artica.es> 2013-02-04 Miguel de Dios <miguel.dedios@artica.es>
* include/javascript/pandora_alerts.js: cleaned source code style. * include/javascript/pandora_alerts.js: cleaned source code style.

View File

@ -35,7 +35,8 @@ $pure = get_parameter('pure', 0);
//Header //Header
if (! defined ('METACONSOLE')) { if (! defined ('METACONSOLE')) {
ui_print_page_header (__('Manage Netflow Filter'), "images/networkmap/so_cisco_new.png", false, "", true); ui_print_page_header (__('Manage Netflow Filter'), "images/networkmap/so_cisco_new.png", false, "", true);
} else { }
else {
$nav_bar = array(array('link' => 'index.php?sec=main', 'text' => __('Main')), $nav_bar = array(array('link' => 'index.php?sec=main', 'text' => __('Main')),
array('link' => 'index.php?sec=netf&sec2=godmode/netflow/nf_edit', 'text' => __('Netflow filters'))); array('link' => 'index.php?sec=netf&sec2=godmode/netflow/nf_edit', 'text' => __('Netflow filters')));
@ -113,7 +114,8 @@ $table->head = array ();
$table->head[0] = __('Name'); $table->head[0] = __('Name');
$table->head[1] = __('Group'); $table->head[1] = __('Group');
$table->head[2] = __('Action') . $table->head[2] = __('Action') .
html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();'); html_print_checkbox('all_delete', 0, false, true, false,
'check_all_checkboxes();');
$table->style = array (); $table->style = array ();
$table->style[0] = 'font-weight: bold'; $table->style[0] = 'font-weight: bold';
$table->align = array (); $table->align = array ();

View File

@ -297,7 +297,8 @@ function netflow_data_table ($data, $start_date, $end_date, $aggregate, $unit) {
$source_count++; $source_count++;
$j++; $j++;
} }
} else { }
else {
$table->style[1] = 'padding: 4px;'; $table->style[1] = 'padding: 4px;';
} }
@ -306,6 +307,8 @@ function netflow_data_table ($data, $start_date, $end_date, $aggregate, $unit) {
$table->head[1] = __('Data'); $table->head[1] = __('Data');
$table->align[1] = "right"; $table->align[1] = "right";
$i = 0; $i = 0;
foreach ($data as $timestamp => $value) { foreach ($data as $timestamp => $value) {
$table->data[$i][0] = date ($time_format, $timestamp); $table->data[$i][0] = date ($time_format, $timestamp);
$table->data[$i][1] = format_numeric ($value['data']) . '&nbsp;' . netflow_format_unit ($unit); $table->data[$i][1] = format_numeric ($value['data']) . '&nbsp;' . netflow_format_unit ($unit);
@ -410,7 +413,8 @@ function netflow_get_data ($start_date, $end_date, $interval_length, $filter, $a
$num_intervals = $config['graph_res'] * 50; $num_intervals = $config['graph_res'] * 50;
$period = $end_date - $start_date; $period = $end_date - $start_date;
$interval_length = (int) ($period / $num_intervals); $interval_length = (int) ($period / $num_intervals);
} else { }
else {
$period = $end_date - $start_date; $period = $end_date - $start_date;
$num_intervals = (int) ($period / $interval_length); $num_intervals = (int) ($period / $interval_length);
} }
@ -447,7 +451,8 @@ function netflow_get_data ($start_date, $end_date, $interval_length, $filter, $a
$val = explode(',',$line); $val = explode(',',$line);
if ($aggregate == 'proto') { if ($aggregate == 'proto') {
$values['sources'][$val[3]] = 1; $values['sources'][$val[3]] = 1;
} else { }
else {
$values['sources'][$val[4]] = 1; $values['sources'][$val[4]] = 1;
} }
} }
@ -511,7 +516,8 @@ function netflow_get_data ($start_date, $end_date, $interval_length, $filter, $a
$values[$interval_start]['data'] = $data['totalbytes']; $values[$interval_start]['data'] = $data['totalbytes'];
break; break;
} }
} else { }
else {
// Set default values // Set default values
foreach ($values['sources'] as $source => $discard) { foreach ($values['sources'] as $source => $discard) {
@ -528,6 +534,10 @@ function netflow_get_data ($start_date, $end_date, $interval_length, $filter, $a
} }
} }
if (($aggregate != 'none') && (empty($values['data']))) {
return array();
}
return $values; return $values;
} }
@ -963,12 +973,14 @@ function netflow_draw_item ($start_date, $end_date, $interval_length, $type, $fi
$html .= "&nbsp;<b>" . __('Aggregate') . ":</b> " . netflow_format_aggregate ($aggregate); $html .= "&nbsp;<b>" . __('Aggregate') . ":</b> " . netflow_format_aggregate ($aggregate);
$html .= graph_netflow_aggregate_pie ($data, netflow_format_aggregate ($aggregate)); $html .= graph_netflow_aggregate_pie ($data, netflow_format_aggregate ($aggregate));
return $html; return $html;
} else if ($output == 'PDF') { }
else if ($output == 'PDF') {
$html = "<b>" . __('Unit') . ":</b> " . netflow_format_unit ($unit); $html = "<b>" . __('Unit') . ":</b> " . netflow_format_unit ($unit);
$html .= "&nbsp;<b>" . __('Aggregate') . ":</b> $aggregate"; $html .= "&nbsp;<b>" . __('Aggregate') . ":</b> $aggregate";
$html .= graph_netflow_aggregate_pie ($data, netflow_format_aggregate ($aggregate), 2, true); $html .= graph_netflow_aggregate_pie ($data, netflow_format_aggregate ($aggregate), 2, true);
return $html; return $html;
} else if ($output == 'XML') { }
else if ($output == 'XML') {
$xml = "<unit>$unit</unit>\n"; $xml = "<unit>$unit</unit>\n";
$xml .= "<aggregate>$aggregate</aggregate>\n"; $xml .= "<aggregate>$aggregate</aggregate>\n";
$xml .= netflow_aggregate_pie_xml ($data); $xml .= netflow_aggregate_pie_xml ($data);
@ -989,8 +1001,10 @@ function netflow_draw_item ($start_date, $end_date, $interval_length, $type, $fi
$html .= "&nbsp;<b>" . _('Resolution') . ":</b> $interval_length " . __('seconds'); $html .= "&nbsp;<b>" . _('Resolution') . ":</b> $interval_length " . __('seconds');
} }
$html .= netflow_data_table ($data, $start_date, $end_date, $aggregate, $unit); $html .= netflow_data_table ($data, $start_date, $end_date, $aggregate, $unit);
return $html; return $html;
} else if ($output == 'XML') { }
else if ($output == 'XML') {
$xml = "<unit>$unit</unit>\n"; $xml = "<unit>$unit</unit>\n";
$xml .= "<aggregate>$aggregate</aggregate>\n"; $xml .= "<aggregate>$aggregate</aggregate>\n";
$xml .= "<resolution>$interval_length</resolution>\n"; $xml .= "<resolution>$interval_length</resolution>\n";