mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 09:15:15 +02:00
Fixed issues with views in Netflow live view
This commit is contained in:
parent
e99183e1f0
commit
fb129750d5
@ -600,7 +600,7 @@ function netflow_get_stats(
|
|||||||
global $config, $nfdump_date_format;
|
global $config, $nfdump_date_format;
|
||||||
|
|
||||||
// Requesting remote data.
|
// Requesting remote data.
|
||||||
if (defined('METACONSOLE') && $connection_name != '') {
|
if (is_metaconsole() === true && empty($connection_name) === false) {
|
||||||
$data = metaconsole_call_remote_api($connection_name, 'netflow_get_stats', "$start_date|$end_date|".base64_encode(json_encode($filter))."|$aggregate|$max|$absolute|".(int) $address_resolution);
|
$data = metaconsole_call_remote_api($connection_name, 'netflow_get_stats', "$start_date|$end_date|".base64_encode(json_encode($filter))."|$aggregate|$max|$absolute|".(int) $address_resolution);
|
||||||
return json_decode($data, true);
|
return json_decode($data, true);
|
||||||
}
|
}
|
||||||
@ -612,7 +612,7 @@ function netflow_get_stats(
|
|||||||
// Execute nfdump.
|
// Execute nfdump.
|
||||||
exec($command, $string);
|
exec($command, $string);
|
||||||
|
|
||||||
if (! is_array($string)) {
|
if (is_array($string) === false) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1062,7 +1062,7 @@ function netflow_draw_item(
|
|||||||
) {
|
) {
|
||||||
$aggregate = $filter['aggregate'];
|
$aggregate = $filter['aggregate'];
|
||||||
$interval = ($end_date - $start_date);
|
$interval = ($end_date - $start_date);
|
||||||
if (defined('METACONSOLE')) {
|
if (is_metaconsole() === true) {
|
||||||
$width = 950;
|
$width = 950;
|
||||||
} else {
|
} else {
|
||||||
$width = 850;
|
$width = 850;
|
||||||
@ -1084,12 +1084,13 @@ function netflow_draw_item(
|
|||||||
$connection_name,
|
$connection_name,
|
||||||
$address_resolution
|
$address_resolution
|
||||||
);
|
);
|
||||||
if (empty($data)) {
|
|
||||||
|
if (empty($data) === true) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($output == 'HTML' || $output == 'PDF') {
|
if ($output === 'HTML' || $output === 'PDF') {
|
||||||
$html .= graph_netflow_aggregate_area(
|
return graph_netflow_aggregate_area(
|
||||||
$data,
|
$data,
|
||||||
$interval,
|
$interval,
|
||||||
$width,
|
$width,
|
||||||
@ -1098,9 +1099,8 @@ function netflow_draw_item(
|
|||||||
($output === 'HTML'),
|
($output === 'HTML'),
|
||||||
$end_date
|
$end_date
|
||||||
);
|
);
|
||||||
return $html;
|
} else if ($output === 'XML') {
|
||||||
} else if ($output == 'XML') {
|
$xml = '<aggregate>'.$aggregate."</aggregate>\n";
|
||||||
$xml .= '<aggregate>'.$aggregate."</aggregate>\n";
|
|
||||||
$xml .= '<resolution>'.$interval_length."</resolution>\n";
|
$xml .= '<resolution>'.$interval_length."</resolution>\n";
|
||||||
$xml .= netflow_aggregate_area_xml($data);
|
$xml .= netflow_aggregate_area_xml($data);
|
||||||
return $xml;
|
return $xml;
|
||||||
@ -1119,18 +1119,19 @@ function netflow_draw_item(
|
|||||||
$connection_name,
|
$connection_name,
|
||||||
$address_resolution
|
$address_resolution
|
||||||
);
|
);
|
||||||
if (empty($data)) {
|
|
||||||
|
if (empty($data) === true) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($output == 'HTML' || $output == 'PDF') {
|
if ($output === 'HTML' || $output === 'PDF') {
|
||||||
$html .= "<div class='w100p overflow'>";
|
$html = "<div class='w100p overflow'>";
|
||||||
$html .= netflow_data_table($data, $start_date, $end_date, $aggregate);
|
$html .= netflow_data_table($data, $start_date, $end_date, $aggregate);
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
} else if ($output == 'XML') {
|
} else if ($output === 'XML') {
|
||||||
$xml .= '<aggregate>'.$aggregate."</aggregate>\n";
|
$xml = '<aggregate>'.$aggregate."</aggregate>\n";
|
||||||
$xml .= '<resolution>'.$interval_length."</resolution>\n";
|
$xml .= '<resolution>'.$interval_length."</resolution>\n";
|
||||||
// Same as netflow_aggregate_area_xml.
|
// Same as netflow_aggregate_area_xml.
|
||||||
$xml .= netflow_aggregate_area_xml($data);
|
$xml .= netflow_aggregate_area_xml($data);
|
||||||
@ -1159,7 +1160,8 @@ function netflow_draw_item(
|
|||||||
$connection_name,
|
$connection_name,
|
||||||
$address_resolution
|
$address_resolution
|
||||||
);
|
);
|
||||||
if (empty($data_pie)) {
|
|
||||||
|
if (empty($data_pie) === true) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1222,51 +1224,56 @@ function netflow_draw_item(
|
|||||||
$connection_name,
|
$connection_name,
|
||||||
$address_resolution
|
$address_resolution
|
||||||
);
|
);
|
||||||
switch ($aggregate) {
|
|
||||||
case 'srcip':
|
|
||||||
case 'srcport':
|
|
||||||
$address_type = 'source_address';
|
|
||||||
$port_type = 'source_port';
|
|
||||||
$type = __('Sent');
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
if (empty($data_stats) === false) {
|
||||||
case 'dstip':
|
switch ($aggregate) {
|
||||||
case 'dstport':
|
case 'srcip':
|
||||||
$address_type = 'destination_address';
|
case 'srcport':
|
||||||
$port_type = 'destination_port';
|
$address_type = 'source_address';
|
||||||
$type = __('Received');
|
$port_type = 'source_port';
|
||||||
break;
|
$type = __('Sent');
|
||||||
}
|
break;
|
||||||
|
|
||||||
$data_graph = [
|
default:
|
||||||
'name' => __('Host detailed traffic').': '.$type,
|
case 'dstip':
|
||||||
'children' => [],
|
case 'dstport':
|
||||||
];
|
$address_type = 'destination_address';
|
||||||
$id = -1;
|
$port_type = 'destination_port';
|
||||||
|
$type = __('Received');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($data_stats as $sdata) {
|
$data_graph = [
|
||||||
$data_graph['children'][] = [
|
'name' => __('Host detailed traffic').': '.$type,
|
||||||
'id' => $i++,
|
'children' => [],
|
||||||
'name' => $sdata['agg'],
|
|
||||||
'children' => [
|
|
||||||
[
|
|
||||||
'id' => $i++,
|
|
||||||
'name' => $sdata['agg'],
|
|
||||||
'value' => $sdata['data'],
|
|
||||||
'tooltip_content' => network_format_bytes($sdata['data']),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
|
$id = -1;
|
||||||
|
|
||||||
|
foreach ($data_stats as $sdata) {
|
||||||
|
$data_graph['children'][] = [
|
||||||
|
'id' => $id++,
|
||||||
|
'name' => $sdata['agg'],
|
||||||
|
'children' => [
|
||||||
|
[
|
||||||
|
'id' => $id++,
|
||||||
|
'name' => $sdata['agg'],
|
||||||
|
'value' => $sdata['data'],
|
||||||
|
'tooltip_content' => network_format_bytes($sdata['data']),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return graph_netflow_host_traffic($data_graph, 'auto', 400);
|
||||||
}
|
}
|
||||||
return graph_netflow_host_traffic($data_graph, 'auto', 400);
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($output == 'HTML' || $output == 'PDF') {
|
if ($output === 'HTML' || $output === 'PDF') {
|
||||||
return graph_nodata_image(300, 110, 'data');
|
return graph_nodata_image(300, 110, 'data');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -763,7 +763,8 @@ function flot_slicesbar_graph(
|
|||||||
$height = ((int) $height + 15);
|
$height = ((int) $height + 15);
|
||||||
|
|
||||||
$style = 'width:'.$width.'%;';
|
$style = 'width:'.$width.'%;';
|
||||||
$style .= 'height:'.$height.'px;';
|
// Fixed height size.
|
||||||
|
$style .= 'height: 100%;';
|
||||||
$return = "<div id='".$graph_id."' class='noresizevc graph ".$adapt_key."' style='".$style."'></div>";
|
$return = "<div id='".$graph_id."' class='noresizevc graph ".$adapt_key."' style='".$style."'></div>";
|
||||||
|
|
||||||
$return .= "<div id='value_".$graph_id."' class='flot_container'></div>";
|
$return .= "<div id='value_".$graph_id."' class='flot_container'></div>";
|
||||||
|
@ -352,12 +352,12 @@ if (is_metaconsole()) {
|
|||||||
$filter_type = 0;
|
$filter_type = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<tr class='filter_save invisible'>";
|
echo "<tr class='filter_save' style='display: none;'>";
|
||||||
|
|
||||||
echo "<td colspan='6'>".ui_print_error_message('Define a name for the filter and click on Save as new filter again', '', true).'</td>';
|
echo "<td colspan='6'>".ui_print_error_message('Define a name for the filter and click on Save as new filter again', '', true).'</td>';
|
||||||
|
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
echo "<tr class='filter_save invisible'>";
|
echo "<tr class='filter_save' style='display: none;'>";
|
||||||
|
|
||||||
echo '<td><span id="filter_name_color"><b>'.__('Name').'</b></span></td>';
|
echo '<td><span id="filter_name_color"><b>'.__('Name').'</b></span></td>';
|
||||||
echo "<td colspan='2'>".html_print_input_text(
|
echo "<td colspan='2'>".html_print_input_text(
|
||||||
@ -373,7 +373,7 @@ if (is_metaconsole()) {
|
|||||||
echo "<td colspan='2'>".html_print_select_groups($config['id_user'], 'AR', $own_info['is_admin'], 'assign_group', $filter['id_group'], '', '', -1, true, false, false).'</td>';
|
echo "<td colspan='2'>".html_print_select_groups($config['id_user'], 'AR', $own_info['is_admin'], 'assign_group', $filter['id_group'], '', '', -1, true, false, false).'</td>';
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
|
|
||||||
$advanced_toggle = '<table class="w100p">';
|
$advanced_toggle = '<table style="width:100%">';
|
||||||
|
|
||||||
$advanced_toggle .= '<tr>';
|
$advanced_toggle .= '<tr>';
|
||||||
if ($netflow_disable_custom_lvfilters) {
|
if ($netflow_disable_custom_lvfilters) {
|
||||||
@ -381,7 +381,7 @@ if (is_metaconsole()) {
|
|||||||
$advanced_toggle .= '<td></td>';
|
$advanced_toggle .= '<td></td>';
|
||||||
} else {
|
} else {
|
||||||
$advanced_toggle .= '<td><b>'.__('Filter').'</b></td>';
|
$advanced_toggle .= '<td><b>'.__('Filter').'</b></td>';
|
||||||
$advanced_toggle .= '<td colspan="2">'.__('Normal').' '.html_print_radio_button_extended('filter_type', 0, '', $filter_type, false, 'displayNormalFilter();', 'class="mrgn_right_40px"', true).__('Custom').' '.html_print_radio_button_extended('filter_type', 1, '', $filter_type, false, 'displayAdvancedFilter();', 'class="mrgn_right_40px"', true).'</td>';
|
$advanced_toggle .= '<td colspan="2">'.__('Normal').' '.html_print_radio_button_extended('filter_type', 0, '', $filter_type, false, 'displayNormalFilter();', 'style="margin-right: 40px;"', true).__('Custom').' '.html_print_radio_button_extended('filter_type', 1, '', $filter_type, false, 'displayAdvancedFilter();', 'style="margin-right: 40px;"', true).'</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -403,7 +403,7 @@ if (is_metaconsole()) {
|
|||||||
$advanced_toggle .= '<td></td>';
|
$advanced_toggle .= '<td></td>';
|
||||||
$advanced_toggle .= '<td></td>';
|
$advanced_toggle .= '<td></td>';
|
||||||
} else {
|
} else {
|
||||||
$advanced_toggle .= "<td class='bolder'>".__('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:<br>25.46.157.214,160.253.135.249'), true).'</td>';
|
$advanced_toggle .= "<td style='font-weight:bold;'>".__('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:<br>25.46.157.214,160.253.135.249'), true).'</td>';
|
||||||
$advanced_toggle .= '<td colspan="2">'.html_print_input_text('ip_dst', $filter['ip_dst'], false, 40, 80, true).'</td>';
|
$advanced_toggle .= '<td colspan="2">'.html_print_input_text('ip_dst', $filter['ip_dst'], false, 40, 80, true).'</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,7 +411,7 @@ if (is_metaconsole()) {
|
|||||||
$advanced_toggle .= '<td></td>';
|
$advanced_toggle .= '<td></td>';
|
||||||
$advanced_toggle .= '<td></td>';
|
$advanced_toggle .= '<td></td>';
|
||||||
} else {
|
} else {
|
||||||
$advanced_toggle .= "<td class='bolder'>".__('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:<br>25.46.157.214,160.253.135.249'), true).'</td>';
|
$advanced_toggle .= "<td style='font-weight:bold;'>".__('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:<br>25.46.157.214,160.253.135.249'), true).'</td>';
|
||||||
$advanced_toggle .= '<td colspan="2">'.html_print_input_text('ip_src', $filter['ip_src'], false, 40, 80, true).'</td>';
|
$advanced_toggle .= '<td colspan="2">'.html_print_input_text('ip_src', $filter['ip_src'], false, 40, 80, true).'</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,7 +422,7 @@ if (is_metaconsole()) {
|
|||||||
$advanced_toggle .= '<td></td>';
|
$advanced_toggle .= '<td></td>';
|
||||||
$advanced_toggle .= '<td></td>';
|
$advanced_toggle .= '<td></td>';
|
||||||
} else {
|
} else {
|
||||||
$advanced_toggle .= "<td class='bolder'>".__('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:<br>80,22'), true).'</td>';
|
$advanced_toggle .= "<td style='font-weight:bold;'>".__('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:<br>80,22'), true).'</td>';
|
||||||
$advanced_toggle .= '<td colspan="2">'.html_print_input_text('dst_port', $filter['dst_port'], false, 40, 80, true).'</td>';
|
$advanced_toggle .= '<td colspan="2">'.html_print_input_text('dst_port', $filter['dst_port'], false, 40, 80, true).'</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,19 +430,19 @@ if (is_metaconsole()) {
|
|||||||
$advanced_toggle .= '<td></td>';
|
$advanced_toggle .= '<td></td>';
|
||||||
$advanced_toggle .= '<td></td>';
|
$advanced_toggle .= '<td></td>';
|
||||||
} else {
|
} else {
|
||||||
$advanced_toggle .= "<td class='bolder'>".__('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:<br>80,22'), true).'</td>';
|
$advanced_toggle .= "<td style='font-weight:bold;'>".__('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:<br>80,22'), true).'</td>';
|
||||||
$advanced_toggle .= '<td colspan="2">'.html_print_input_text('src_port', $filter['src_port'], false, 40, 80, true).'</td>';
|
$advanced_toggle .= '<td colspan="2">'.html_print_input_text('src_port', $filter['src_port'], false, 40, 80, true).'</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$advanced_toggle .= '</tr>';
|
$advanced_toggle .= '</tr>';
|
||||||
|
|
||||||
$advanced_toggle .= "<tr class='filter_advance invisible'>";
|
$advanced_toggle .= "<tr class='filter_advance' style='display: none;'>";
|
||||||
if ($netflow_disable_custom_lvfilters) {
|
if ($netflow_disable_custom_lvfilters) {
|
||||||
$advanced_toggle .= '<td></td>';
|
$advanced_toggle .= '<td></td>';
|
||||||
$advanced_toggle .= '<td></td>';
|
$advanced_toggle .= '<td></td>';
|
||||||
} else {
|
} else {
|
||||||
$advanced_toggle .= '<td>'.ui_print_help_icon('pcap_filter', true).'</td>';
|
$advanced_toggle .= '<td>'.ui_print_help_icon('pcap_filter', true).'</td>';
|
||||||
$advanced_toggle .= "<td colspan='5'>".html_print_textarea('advanced_filter', 4, 40, $filter['advanced_filter'], "class='min-height-0px w90p'", true).'</td>';
|
$advanced_toggle .= "<td colspan='5'>".html_print_textarea('advanced_filter', 4, 40, $filter['advanced_filter'], "style='min-height: 0px; width: 90%;'", true).'</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$advanced_toggle .= '</tr>';
|
$advanced_toggle .= '</tr>';
|
||||||
@ -490,14 +490,14 @@ if (is_metaconsole()) {
|
|||||||
echo '</td></tr>';
|
echo '</td></tr>';
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
|
|
||||||
echo "<table width='100%' class='min-height-0px right'><tr><td>";
|
echo "<table class='' width='100%' style='border: 0px; text-align:right;'><tr><td>";
|
||||||
|
|
||||||
echo html_print_submit_button(__('Draw'), 'draw_button', false, 'class="sub upd"', true);
|
echo html_print_submit_button(__('Draw'), 'draw_button', false, 'class="sub upd"', true);
|
||||||
|
|
||||||
if (!$netflow_disable_custom_lvfilters) {
|
if (!$netflow_disable_custom_lvfilters) {
|
||||||
if (check_acl($config['id_user'], 0, 'AW')) {
|
if (check_acl($config['id_user'], 0, 'AW')) {
|
||||||
html_print_submit_button(__('Save as new filter'), 'save_button', false, ' class="sub upd mrgn_lft_5px" onClick="return defineFilterName();"');
|
html_print_submit_button(__('Save as new filter'), 'save_button', false, 'style="margin-left: 5px;" class="sub upd" onClick="return defineFilterName();"');
|
||||||
html_print_submit_button(__('Update current filter'), 'update_button', false, 'class="sub upd mrgn_lft_5px"');
|
html_print_submit_button(__('Update current filter'), 'update_button', false, 'style="margin-left: 5px;" class="sub upd"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -670,11 +670,12 @@ if (is_metaconsole()) {
|
|||||||
// Check right filter type
|
// Check right filter type
|
||||||
$("#radiobtn0002").attr("checked", "checked");
|
$("#radiobtn0002").attr("checked", "checked");
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
// Get filter values from DB
|
// Get filter values from DB
|
||||||
<?php
|
<?php
|
||||||
if (! defined('METACONSOLE')) {
|
echo ');';
|
||||||
|
|
||||||
|
if (is_metaconsole() === false) {
|
||||||
echo 'jQuery.post ("ajax.php",';
|
echo 'jQuery.post ("ajax.php",';
|
||||||
} else {
|
} else {
|
||||||
echo 'jQuery.post ("'.$config['homeurl'].'../../ajax.php",';
|
echo 'jQuery.post ("'.$config['homeurl'].'../../ajax.php",';
|
||||||
@ -701,8 +702,8 @@ if (is_metaconsole()) {
|
|||||||
if (i == 'aggregate')
|
if (i == 'aggregate')
|
||||||
$("#aggregate").val(val);
|
$("#aggregate").val(val);
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
"json");
|
<?php echo ', "json");'; ?>
|
||||||
|
|
||||||
// Shows update filter button
|
// Shows update filter button
|
||||||
$("#submit-update_button").show();
|
$("#submit-update_button").show();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user