mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 16:55:05 +02:00
#11165 new popup for command whois in netflow
This commit is contained in:
parent
4786a9260c
commit
3287ab2ee4
@ -2293,3 +2293,50 @@ function netflow_build_map_data($start_date, $end_date, $top, $aggregate, $advan
|
|||||||
array_merge($relations, $orphan_hosts)
|
array_merge($relations, $orphan_hosts)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run whois command and return all results as array.
|
||||||
|
*
|
||||||
|
* @param integer $ip Ip for search info with command whois.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function command_whois($ip)
|
||||||
|
{
|
||||||
|
$command = 'whois '.$ip;
|
||||||
|
$result = '';
|
||||||
|
exec($command, $result);
|
||||||
|
if (empty($result) === false && is_array($result) === true) {
|
||||||
|
$resultArray = parse_whois_output($result);
|
||||||
|
} else {
|
||||||
|
$resultArray = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $resultArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the result of command whois to array.
|
||||||
|
*
|
||||||
|
* @param array $lines Lines result of command whois.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function parse_whois_output($lines)
|
||||||
|
{
|
||||||
|
$resultArray = [];
|
||||||
|
if (is_array($lines) === true) {
|
||||||
|
foreach ($lines as $line) {
|
||||||
|
$parts = explode(':', $line, 2);
|
||||||
|
if (count($parts) === 2 && strpos($line, '#') !== 0) {
|
||||||
|
$key = trim($parts[0]);
|
||||||
|
$value = trim($parts[1]);
|
||||||
|
$resultArray[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $resultArray;
|
||||||
|
}
|
||||||
|
@ -41,7 +41,10 @@ if (! check_acl($config['id_user'], 0, 'AR')) {
|
|||||||
|
|
||||||
// Ajax callbacks.
|
// Ajax callbacks.
|
||||||
if (is_ajax() === true) {
|
if (is_ajax() === true) {
|
||||||
|
include_once $config['homedir'].'/include/functions_netflow.php';
|
||||||
$get_filter_values = get_parameter('get_filter_values', 0);
|
$get_filter_values = get_parameter('get_filter_values', 0);
|
||||||
|
$whois = (bool) get_parameter('whois', 0);
|
||||||
|
|
||||||
// Get values of the current network filter.
|
// Get values of the current network filter.
|
||||||
if ($get_filter_values) {
|
if ($get_filter_values) {
|
||||||
$id = get_parameter('id');
|
$id = get_parameter('id');
|
||||||
@ -51,6 +54,34 @@ if (is_ajax() === true) {
|
|||||||
echo json_encode($filter_values);
|
echo json_encode($filter_values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($whois) {
|
||||||
|
$ip = get_parameter('ip');
|
||||||
|
$info = command_whois($ip);
|
||||||
|
$output = '';
|
||||||
|
if (is_array($info) === true && count($info) > 0) {
|
||||||
|
$table = new \stdClass();
|
||||||
|
$table->class = 'details_table dataTable info_table';
|
||||||
|
$table->data = [];
|
||||||
|
$row = 0;
|
||||||
|
foreach ($info as $key => $value) {
|
||||||
|
$table->data[$row][0] = $key;
|
||||||
|
$table->data[$row][1] = $value;
|
||||||
|
$row++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output = html_print_table($table, true);
|
||||||
|
} else {
|
||||||
|
$output = ui_print_info_message(__('No data found'));
|
||||||
|
}
|
||||||
|
|
||||||
|
html_print_div(
|
||||||
|
[
|
||||||
|
'content' => $output,
|
||||||
|
'style' => 'max-height: 600px;',
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,6 +493,7 @@ foreach ($data as $item) {
|
|||||||
array_merge($hidden_main_link, ['main_value' => $item['host']]),
|
array_merge($hidden_main_link, ['main_value' => $item['host']]),
|
||||||
'image'
|
'image'
|
||||||
);
|
);
|
||||||
|
$row['main'] .= html_print_input_image('whois', 'images/eye.png', 'whois', '', true, ['onclick' => 'whois(\''.$item['host'].'\')']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$row['main'] .= '</div>';
|
$row['main'] .= '</div>';
|
||||||
@ -572,6 +604,13 @@ html_print_div(
|
|||||||
'style' => 'position: initial;',
|
'style' => 'position: initial;',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
html_print_div(
|
||||||
|
[
|
||||||
|
'id' => 'modal_whois',
|
||||||
|
'class' => 'invisible',
|
||||||
|
]
|
||||||
|
);
|
||||||
?>
|
?>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
@ -654,4 +693,29 @@ function nf_view_click_period() {
|
|||||||
document.getElementById('period_container').style.display = !is_period ? 'none' : 'flex';
|
document.getElementById('period_container').style.display = !is_period ? 'none' : 'flex';
|
||||||
document.getElementById('end_date_container').style.display = is_period ? 'none' : 'flex';
|
document.getElementById('end_date_container').style.display = is_period ? 'none' : 'flex';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function whois(ip) {
|
||||||
|
load_modal({
|
||||||
|
target: $('#modal_whois'),
|
||||||
|
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||||
|
modal: {
|
||||||
|
title: '<?php echo __('Details'); ?>',
|
||||||
|
ok: '<?php echo __('Ok'); ?>',
|
||||||
|
},
|
||||||
|
extradata: [
|
||||||
|
{
|
||||||
|
name: "ip",
|
||||||
|
value: ip,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "whois",
|
||||||
|
value: 1,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
onshow: {
|
||||||
|
page: '<?php echo $config['homedir'].'/operation/network/network_report'; ?>',
|
||||||
|
width: 800,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user