2012-03-01 17:41:02 +01:00
|
|
|
|
<?php
|
2019-02-08 17:30:47 +01:00
|
|
|
|
/**
|
|
|
|
|
* Manage AJAX response for event pages.
|
|
|
|
|
*
|
|
|
|
|
* @category Ajax
|
|
|
|
|
* @package Pandora FMS
|
|
|
|
|
* @subpackage Events
|
|
|
|
|
* @version 1.0.0
|
|
|
|
|
* @license See below
|
|
|
|
|
*
|
|
|
|
|
* ______ ___ _______ _______ ________
|
|
|
|
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
|
|
|
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
|
|
|
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
|
|
|
|
*
|
|
|
|
|
* ============================================================================
|
2020-11-27 13:52:35 +01:00
|
|
|
|
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
2019-02-08 17:30:47 +01:00
|
|
|
|
* Please see http://pandorafms.org for full contribution list
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation for version 2.
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
* ============================================================================
|
|
|
|
|
*/
|
2012-03-01 17:41:02 +01:00
|
|
|
|
|
2022-03-24 18:52:06 +01:00
|
|
|
|
use PandoraFMS\Enterprise\Metaconsole\Node;
|
|
|
|
|
|
2019-06-11 12:58:18 +02:00
|
|
|
|
// Begin.
|
|
|
|
|
global $config;
|
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
|
require_once 'include/functions_events.php';
|
|
|
|
|
require_once 'include/functions_agents.php';
|
|
|
|
|
require_once 'include/functions_ui.php';
|
|
|
|
|
require_once 'include/functions_db.php';
|
|
|
|
|
require_once 'include/functions_io.php';
|
|
|
|
|
require_once 'include/functions.php';
|
|
|
|
|
enterprise_include_once('meta/include/functions_events_meta.php');
|
|
|
|
|
enterprise_include_once('include/functions_metaconsole.php');
|
|
|
|
|
|
2019-06-11 12:58:18 +02:00
|
|
|
|
// Check access.
|
|
|
|
|
check_login();
|
|
|
|
|
|
|
|
|
|
if (! check_acl($config['id_user'], 0, 'ER')
|
|
|
|
|
&& ! check_acl($config['id_user'], 0, 'EW')
|
|
|
|
|
&& ! check_acl($config['id_user'], 0, 'EM')
|
|
|
|
|
) {
|
|
|
|
|
db_pandora_audit(
|
2022-01-20 10:55:23 +01:00
|
|
|
|
AUDIT_LOG_ACL_VIOLATION,
|
2019-06-11 12:58:18 +02:00
|
|
|
|
'Trying to access event viewer'
|
|
|
|
|
);
|
|
|
|
|
include 'general/noaccess.php';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-30 17:17:05 +02:00
|
|
|
|
$drawConsoleSound = (bool) get_parameter('drawConsoleSound', false);
|
2022-06-23 18:06:25 +02:00
|
|
|
|
$process_buffers = (bool) get_parameter('process_buffers', false);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
$get_extended_event = (bool) get_parameter('get_extended_event');
|
|
|
|
|
$change_status = (bool) get_parameter('change_status');
|
2023-01-05 10:36:14 +01:00
|
|
|
|
$get_Acknowledged = (bool) get_parameter('get_Acknowledged');
|
2019-01-30 16:18:44 +01:00
|
|
|
|
$change_owner = (bool) get_parameter('change_owner');
|
|
|
|
|
$add_comment = (bool) get_parameter('add_comment');
|
|
|
|
|
$dialogue_event_response = (bool) get_parameter('dialogue_event_response');
|
|
|
|
|
$perform_event_response = (bool) get_parameter('perform_event_response');
|
|
|
|
|
$get_response = (bool) get_parameter('get_response');
|
2022-09-23 13:55:01 +02:00
|
|
|
|
$get_response_massive = (bool) get_parameter('get_response_massive');
|
|
|
|
|
$get_row_response_action = (bool) get_parameter('get_row_response_action');
|
2022-09-27 09:51:37 +02:00
|
|
|
|
$draw_row_response_info = (bool) get_parameter('draw_row_response_info', false);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
$meta = get_parameter('meta', 0);
|
|
|
|
|
$history = get_parameter('history', 0);
|
2014-12-03 11:52:09 +01:00
|
|
|
|
$table_events = get_parameter('table_events', 0);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
$total_events = (bool) get_parameter('total_events');
|
|
|
|
|
$total_event_graph = (bool) get_parameter('total_event_graph');
|
|
|
|
|
$graphic_event_group = (bool) get_parameter('graphic_event_group');
|
2019-02-27 10:59:44 +01:00
|
|
|
|
$get_table_response_command = (bool) get_parameter('get_table_response_command');
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$save_filter_modal = get_parameter('save_filter_modal', 0);
|
|
|
|
|
$load_filter_modal = get_parameter('load_filter_modal', 0);
|
|
|
|
|
$get_filter_values = get_parameter('get_filter_values', 0);
|
|
|
|
|
$update_event_filter = get_parameter('update_event_filter', 0);
|
|
|
|
|
$save_event_filter = get_parameter('save_event_filter', 0);
|
2022-06-15 13:06:10 +02:00
|
|
|
|
$in_process_event = (bool) get_parameter('in_process_event', 0);
|
|
|
|
|
$validate_event = (bool) get_parameter('validate_event', 0);
|
|
|
|
|
$delete_event = (bool) get_parameter('delete_event', 0);
|
2019-06-20 19:23:13 +02:00
|
|
|
|
$get_event_filters = get_parameter('get_event_filters', 0);
|
2021-10-13 14:58:31 +02:00
|
|
|
|
$get_comments = (bool) get_parameter('get_comments', false);
|
2019-07-15 15:31:01 +02:00
|
|
|
|
$get_events_fired = (bool) get_parameter('get_events_fired');
|
2019-11-22 13:38:08 +01:00
|
|
|
|
$get_id_source_event = get_parameter('get_id_source_event');
|
2022-03-24 18:52:06 +01:00
|
|
|
|
$node_id = (int) get_parameter('node_id', 0);
|
2022-06-14 18:47:09 +02:00
|
|
|
|
|
2021-10-13 14:58:31 +02:00
|
|
|
|
if ($get_comments === true) {
|
2019-06-20 21:11:56 +02:00
|
|
|
|
$event = get_parameter('event', false);
|
2022-09-27 15:08:09 +02:00
|
|
|
|
$event_rep = (int) get_parameter('event_rep', 0);
|
2023-02-15 19:38:57 +01:00
|
|
|
|
$event_rep = get_parameter_post('event')['event_rep'];
|
|
|
|
|
$group_rep = get_parameter_post('event')['group_rep'];
|
|
|
|
|
|
2019-06-20 21:11:56 +02:00
|
|
|
|
if ($event === false) {
|
|
|
|
|
return __('Failed to retrieve comments');
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-13 14:58:31 +02:00
|
|
|
|
$eventsGrouped = [];
|
2022-06-14 18:47:09 +02:00
|
|
|
|
// Consider if the event is grouped.
|
2022-06-21 11:17:18 +02:00
|
|
|
|
$whereGrouped = '1=1';
|
2023-02-15 19:38:57 +01:00
|
|
|
|
if ($group_rep === EVENT_GROUP_REP_EVENTS && $event_rep > 1) {
|
2022-06-14 18:47:09 +02:00
|
|
|
|
// Default grouped message filtering (evento and estado).
|
|
|
|
|
$whereGrouped = sprintf(
|
2022-08-01 07:08:00 +02:00
|
|
|
|
'`evento` = "%s"',
|
|
|
|
|
$event['evento']
|
2019-06-20 21:11:56 +02:00
|
|
|
|
);
|
2021-10-13 14:58:31 +02:00
|
|
|
|
|
2022-06-14 18:47:09 +02:00
|
|
|
|
// If id_agente is reported, filter the messages by them as well.
|
|
|
|
|
if ((int) $event['id_agente'] > 0) {
|
|
|
|
|
$whereGrouped .= sprintf(
|
|
|
|
|
' AND `id_agente` = %d',
|
|
|
|
|
(int) $event['id_agente']
|
2021-12-01 13:15:34 +01:00
|
|
|
|
);
|
2019-06-20 21:11:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-14 18:47:09 +02:00
|
|
|
|
if ((int) $event['id_agentmodule'] > 0) {
|
|
|
|
|
$whereGrouped .= sprintf(
|
|
|
|
|
' AND `id_agentmodule` = %d',
|
|
|
|
|
(int) $event['id_agentmodule']
|
2021-10-13 14:58:31 +02:00
|
|
|
|
);
|
2022-06-14 18:47:09 +02:00
|
|
|
|
}
|
2023-02-15 19:38:57 +01:00
|
|
|
|
} else if ($group_rep === EVENT_GROUP_REP_EXTRAIDS) {
|
2022-09-27 15:08:09 +02:00
|
|
|
|
$whereGrouped = sprintf(
|
|
|
|
|
'`id_extra` = "%s"',
|
|
|
|
|
$event['id_extra']
|
|
|
|
|
);
|
2022-07-22 10:13:57 +02:00
|
|
|
|
} else {
|
|
|
|
|
$whereGrouped = sprintf('`id_evento` = %d', $event['id_evento']);
|
2022-06-21 11:17:18 +02:00
|
|
|
|
}
|
2019-06-20 21:11:56 +02:00
|
|
|
|
|
2022-06-21 11:17:18 +02:00
|
|
|
|
try {
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $event['server_id'] > 0
|
|
|
|
|
) {
|
|
|
|
|
$node = new Node($event['server_id']);
|
|
|
|
|
$node->connect();
|
|
|
|
|
}
|
2019-06-20 21:11:56 +02:00
|
|
|
|
|
2022-06-21 11:17:18 +02:00
|
|
|
|
$sql = sprintf(
|
|
|
|
|
'SELECT `user_comment`
|
|
|
|
|
FROM tevento
|
|
|
|
|
WHERE %s',
|
|
|
|
|
$whereGrouped
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Get grouped comments.
|
|
|
|
|
$eventsGrouped = db_get_all_rows_sql($sql);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
// Unexistent agent.
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $event['server_id'] > 0
|
|
|
|
|
) {
|
|
|
|
|
$node->disconnect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$eventsGrouped = [];
|
|
|
|
|
} finally {
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $event['server_id'] > 0
|
|
|
|
|
) {
|
|
|
|
|
$node->disconnect();
|
2019-06-20 21:11:56 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-13 14:58:31 +02:00
|
|
|
|
// End of get_comments.
|
|
|
|
|
echo events_page_comments($event, true, $eventsGrouped);
|
2019-06-20 21:11:56 +02:00
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-06-20 19:23:13 +02:00
|
|
|
|
|
|
|
|
|
if ($get_event_filters) {
|
|
|
|
|
$event_filter = events_get_event_filter_select();
|
|
|
|
|
|
|
|
|
|
echo io_json_mb_encode($event_filter);
|
2019-06-20 21:11:56 +02:00
|
|
|
|
return;
|
2019-06-20 19:23:13 +02:00
|
|
|
|
}
|
2019-06-13 12:30:09 +02:00
|
|
|
|
|
|
|
|
|
// Delete event (filtered or not).
|
2022-06-15 13:06:10 +02:00
|
|
|
|
if ($delete_event === true) {
|
2019-06-13 12:30:09 +02:00
|
|
|
|
$filter = get_parameter('filter', []);
|
2022-06-15 13:06:10 +02:00
|
|
|
|
$id_evento = (int) get_parameter('id_evento', 0);
|
|
|
|
|
$server_id = (int) get_parameter('server_id', 0);
|
2022-09-27 15:08:09 +02:00
|
|
|
|
$event_rep = (int) get_parameter('event_rep', 0);
|
2019-06-18 18:35:34 +02:00
|
|
|
|
|
2022-06-15 13:06:10 +02:00
|
|
|
|
try {
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $server_id > 0
|
|
|
|
|
) {
|
|
|
|
|
$node = new Node($server_id);
|
|
|
|
|
$node->connect();
|
|
|
|
|
}
|
2019-06-13 12:30:09 +02:00
|
|
|
|
|
2022-06-15 13:06:10 +02:00
|
|
|
|
if ($event_rep === 0) {
|
|
|
|
|
// Disable group by when there're result is unique.
|
|
|
|
|
$filter['group_rep'] = 0;
|
|
|
|
|
}
|
2019-06-18 18:35:34 +02:00
|
|
|
|
|
2022-06-15 13:06:10 +02:00
|
|
|
|
// Check acl.
|
|
|
|
|
if (! check_acl($config['id_user'], 0, 'EM')) {
|
|
|
|
|
echo 'unauthorized';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$r = events_delete($id_evento, $filter, false, true);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
// Unexistent agent.
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $server_id > 0
|
|
|
|
|
) {
|
2022-03-24 18:52:06 +01:00
|
|
|
|
$node->disconnect();
|
2022-06-15 13:06:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$r = false;
|
|
|
|
|
} finally {
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $server_id > 0
|
|
|
|
|
) {
|
2022-03-24 18:52:06 +01:00
|
|
|
|
$node->disconnect();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-18 18:35:34 +02:00
|
|
|
|
if ($r === false) {
|
|
|
|
|
echo 'Failed';
|
|
|
|
|
} else {
|
|
|
|
|
echo $r;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-13 12:30:09 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Validates an event (filtered or not).
|
2022-06-15 13:06:10 +02:00
|
|
|
|
if ($validate_event === true) {
|
2019-06-13 12:30:09 +02:00
|
|
|
|
$filter = get_parameter('filter', []);
|
2022-06-15 13:06:10 +02:00
|
|
|
|
$id_evento = (int) get_parameter('id_evento', 0);
|
|
|
|
|
$server_id = (int) get_parameter('server_id', 0);
|
2022-09-27 15:08:09 +02:00
|
|
|
|
$event_rep = (int) get_parameter('event_rep', 0);
|
2019-06-18 18:35:34 +02:00
|
|
|
|
|
2022-06-15 13:06:10 +02:00
|
|
|
|
try {
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $server_id > 0
|
|
|
|
|
) {
|
|
|
|
|
$node = new Node($server_id);
|
|
|
|
|
$node->connect();
|
|
|
|
|
}
|
2019-06-13 12:30:09 +02:00
|
|
|
|
|
2022-06-15 13:06:10 +02:00
|
|
|
|
if ($event_rep === 0) {
|
|
|
|
|
// Disable group by when there're result is unique.
|
2022-09-27 15:08:09 +02:00
|
|
|
|
$filter['group_rep'] = EVENT_GROUP_REP_ALL;
|
2022-06-15 13:06:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check acl.
|
|
|
|
|
if (!check_acl($config['id_user'], 0, 'EW')) {
|
|
|
|
|
echo 'unauthorized';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$r = events_update_status(
|
|
|
|
|
$id_evento,
|
|
|
|
|
EVENT_VALIDATE,
|
|
|
|
|
$filter
|
|
|
|
|
);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
// Unexistent agent.
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $server_id > 0
|
|
|
|
|
) {
|
|
|
|
|
$node->disconnect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$r = false;
|
|
|
|
|
} finally {
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $server_id > 0
|
|
|
|
|
) {
|
|
|
|
|
$node->disconnect();
|
|
|
|
|
}
|
2019-06-18 18:35:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($r === false) {
|
|
|
|
|
echo 'Failed';
|
|
|
|
|
} else {
|
|
|
|
|
echo $r;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-13 12:30:09 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Sets status to in progress.
|
2022-06-15 13:06:10 +02:00
|
|
|
|
if ($in_process_event === true) {
|
2019-06-13 12:30:09 +02:00
|
|
|
|
$filter = get_parameter('filter', []);
|
2022-06-15 13:06:10 +02:00
|
|
|
|
$id_evento = (int) get_parameter('id_evento', 0);
|
|
|
|
|
$server_id = (int) get_parameter('server_id', 0);
|
2022-09-27 15:08:09 +02:00
|
|
|
|
$event_rep = (int) get_parameter('event_rep', 0);
|
2019-06-18 18:35:34 +02:00
|
|
|
|
|
2022-06-15 13:06:10 +02:00
|
|
|
|
try {
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $server_id > 0
|
|
|
|
|
) {
|
|
|
|
|
$node = new Node($server_id);
|
|
|
|
|
$node->connect();
|
|
|
|
|
}
|
2019-06-13 12:30:09 +02:00
|
|
|
|
|
2022-06-15 13:06:10 +02:00
|
|
|
|
if ($event_rep === 0) {
|
|
|
|
|
// Disable group by when there're result is unique.
|
2022-09-27 15:08:09 +02:00
|
|
|
|
$filter['group_rep'] = EVENT_GROUP_REP_ALL;
|
2022-06-15 13:06:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check acl.
|
|
|
|
|
if (! check_acl($config['id_user'], 0, 'EW')) {
|
|
|
|
|
echo 'unauthorized';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$r = events_update_status(
|
|
|
|
|
$id_evento,
|
|
|
|
|
EVENT_PROCESS,
|
|
|
|
|
$filter
|
|
|
|
|
);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
// Unexistent agent.
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $server_id > 0
|
|
|
|
|
) {
|
|
|
|
|
$node->disconnect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$r = false;
|
|
|
|
|
} finally {
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $server_id > 0
|
|
|
|
|
) {
|
|
|
|
|
$node->disconnect();
|
|
|
|
|
}
|
2019-06-18 18:35:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($r === false) {
|
|
|
|
|
echo 'Failed';
|
|
|
|
|
} else {
|
|
|
|
|
echo $r;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-13 12:30:09 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
2019-06-11 12:58:18 +02:00
|
|
|
|
|
|
|
|
|
// Saves an event filter.
|
|
|
|
|
if ($save_event_filter) {
|
|
|
|
|
$values = [];
|
|
|
|
|
$values['id_name'] = get_parameter('id_name');
|
|
|
|
|
$values['id_group'] = get_parameter('id_group');
|
|
|
|
|
$values['event_type'] = get_parameter('event_type');
|
2020-01-13 18:24:29 +01:00
|
|
|
|
$values['severity'] = implode(',', get_parameter('severity', -1));
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$values['status'] = get_parameter('status');
|
|
|
|
|
$values['search'] = get_parameter('search');
|
2022-11-18 14:04:54 +01:00
|
|
|
|
$values['not_search'] = get_parameter('not_search');
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$values['text_agent'] = get_parameter('text_agent');
|
|
|
|
|
$values['id_agent'] = get_parameter('id_agent');
|
|
|
|
|
$values['id_agent_module'] = get_parameter('id_agent_module');
|
|
|
|
|
$values['pagination'] = get_parameter('pagination');
|
|
|
|
|
$values['event_view_hr'] = get_parameter('event_view_hr');
|
|
|
|
|
$values['id_user_ack'] = get_parameter('id_user_ack');
|
2022-11-03 12:00:58 +01:00
|
|
|
|
$values['owner_user'] = get_parameter('owner_user');
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$values['group_rep'] = get_parameter('group_rep');
|
|
|
|
|
$values['tag_with'] = get_parameter('tag_with', io_json_mb_encode([]));
|
|
|
|
|
$values['tag_without'] = get_parameter(
|
|
|
|
|
'tag_without',
|
|
|
|
|
io_json_mb_encode([])
|
|
|
|
|
);
|
|
|
|
|
$values['filter_only_alert'] = get_parameter('filter_only_alert');
|
2022-07-05 17:02:40 +02:00
|
|
|
|
$values['search_secondary_groups'] = get_parameter('search_secondary_groups');
|
2022-09-29 12:54:46 +02:00
|
|
|
|
$values['search_recursive_groups'] = get_parameter('search_recursive_groups');
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$values['id_group_filter'] = get_parameter('id_group_filter');
|
2022-09-29 12:54:46 +02:00
|
|
|
|
$values['date_from'] = get_parameter('date_from', null);
|
2021-07-05 17:42:45 +02:00
|
|
|
|
$values['time_from'] = get_parameter('time_from');
|
2022-09-29 12:54:46 +02:00
|
|
|
|
$values['date_to'] = get_parameter('date_to', null);
|
2021-07-05 17:42:45 +02:00
|
|
|
|
$values['time_to'] = get_parameter('time_to');
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$values['source'] = get_parameter('source');
|
|
|
|
|
$values['id_extra'] = get_parameter('id_extra');
|
|
|
|
|
$values['user_comment'] = get_parameter('user_comment');
|
2019-11-22 13:38:08 +01:00
|
|
|
|
$values['id_source_event'] = get_parameter('id_source_event');
|
2022-03-29 18:09:19 +02:00
|
|
|
|
$values['custom_data'] = get_parameter('custom_data');
|
|
|
|
|
$values['custom_data_filter_type'] = get_parameter('custom_data_filter_type');
|
2021-04-28 12:50:04 +02:00
|
|
|
|
|
2022-09-29 09:17:37 +02:00
|
|
|
|
if (is_metaconsole() === true) {
|
|
|
|
|
$values['server_id'] = implode(',', get_parameter('server_id'));
|
2021-04-28 12:50:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$exists = (bool) db_get_value_filter(
|
|
|
|
|
'id_filter',
|
|
|
|
|
'tevent_filter',
|
|
|
|
|
$values
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if ($exists) {
|
|
|
|
|
echo 'duplicate';
|
|
|
|
|
} else {
|
|
|
|
|
$result = db_process_sql_insert('tevent_filter', $values);
|
|
|
|
|
|
|
|
|
|
if ($result === false) {
|
|
|
|
|
echo 'error';
|
|
|
|
|
} else {
|
|
|
|
|
echo $result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($update_event_filter) {
|
|
|
|
|
$values = [];
|
|
|
|
|
$id = get_parameter('id');
|
|
|
|
|
$values['id_group'] = get_parameter('id_group');
|
|
|
|
|
$values['event_type'] = get_parameter('event_type');
|
2020-01-13 18:24:29 +01:00
|
|
|
|
$values['severity'] = implode(',', get_parameter('severity', -1));
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$values['status'] = get_parameter('status');
|
|
|
|
|
$values['search'] = get_parameter('search');
|
2022-11-18 14:04:54 +01:00
|
|
|
|
$values['not_search'] = get_parameter('not_search');
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$values['text_agent'] = get_parameter('text_agent');
|
|
|
|
|
$values['id_agent'] = get_parameter('id_agent');
|
|
|
|
|
$values['id_agent_module'] = get_parameter('id_agent_module');
|
|
|
|
|
$values['pagination'] = get_parameter('pagination');
|
|
|
|
|
$values['event_view_hr'] = get_parameter('event_view_hr');
|
|
|
|
|
$values['id_user_ack'] = get_parameter('id_user_ack');
|
2022-11-03 12:00:58 +01:00
|
|
|
|
$values['owner_user'] = get_parameter('owner_user');
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$values['group_rep'] = get_parameter('group_rep');
|
|
|
|
|
$values['tag_with'] = get_parameter('tag_with', io_json_mb_encode([]));
|
|
|
|
|
$values['tag_without'] = get_parameter(
|
|
|
|
|
'tag_without',
|
|
|
|
|
io_json_mb_encode([])
|
|
|
|
|
);
|
|
|
|
|
$values['filter_only_alert'] = get_parameter('filter_only_alert');
|
2022-07-05 17:02:40 +02:00
|
|
|
|
$values['search_secondary_groups'] = get_parameter('search_secondary_groups');
|
2022-09-29 12:54:46 +02:00
|
|
|
|
$values['search_recursive_groups'] = get_parameter('search_recursive_groups');
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$values['id_group_filter'] = get_parameter('id_group_filter');
|
|
|
|
|
$values['date_from'] = get_parameter('date_from');
|
2021-07-05 17:42:45 +02:00
|
|
|
|
$values['time_from'] = get_parameter('time_from');
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$values['date_to'] = get_parameter('date_to');
|
2021-07-05 17:42:45 +02:00
|
|
|
|
$values['time_to'] = get_parameter('time_to');
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$values['source'] = get_parameter('source');
|
|
|
|
|
$values['id_extra'] = get_parameter('id_extra');
|
|
|
|
|
$values['user_comment'] = get_parameter('user_comment');
|
2019-11-22 13:38:08 +01:00
|
|
|
|
$values['id_source_event'] = get_parameter('id_source_event');
|
2022-03-29 18:09:19 +02:00
|
|
|
|
$values['custom_data'] = get_parameter('custom_data');
|
|
|
|
|
$values['custom_data_filter_type'] = get_parameter('custom_data_filter_type');
|
2019-06-11 12:58:18 +02:00
|
|
|
|
|
2021-07-05 17:42:45 +02:00
|
|
|
|
if (is_metaconsole() === true) {
|
2022-09-29 09:17:37 +02:00
|
|
|
|
$values['server_id'] = implode(',', get_parameter('server_id'));
|
2021-04-28 12:50:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-11 12:58:18 +02:00
|
|
|
|
if (io_safe_output($values['tag_with']) == '["0"]') {
|
|
|
|
|
$values['tag_with'] = '[]';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (io_safe_output($values['tag_without']) == '["0"]') {
|
|
|
|
|
$values['tag_without'] = '[]';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$result = db_process_sql_update(
|
|
|
|
|
'tevent_filter',
|
|
|
|
|
$values,
|
|
|
|
|
['id_filter' => $id]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if ($result === false) {
|
|
|
|
|
echo 'error';
|
|
|
|
|
} else {
|
|
|
|
|
echo 'ok';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get db values of a single filter.
|
|
|
|
|
if ($get_filter_values) {
|
|
|
|
|
$id_filter = get_parameter('id');
|
|
|
|
|
|
|
|
|
|
$event_filter = events_get_event_filter($id_filter);
|
|
|
|
|
|
2019-06-20 14:18:49 +02:00
|
|
|
|
if ($event_filter === false) {
|
|
|
|
|
$event_filter = [
|
2022-07-05 17:02:40 +02:00
|
|
|
|
'status' => EVENT_NO_VALIDATED,
|
|
|
|
|
'event_view_hr' => $config['event_view_hr'],
|
|
|
|
|
'tag_with' => [],
|
|
|
|
|
'tag_without' => [],
|
|
|
|
|
'history' => false,
|
|
|
|
|
'module_search' => '',
|
|
|
|
|
'filter_only_alert' => '-1',
|
|
|
|
|
'search_secondary_groups' => 0,
|
2022-09-29 12:54:46 +02:00
|
|
|
|
'search_recursive_groups' => 0,
|
2022-07-05 17:02:40 +02:00
|
|
|
|
'user_comment' => '',
|
|
|
|
|
'id_extra' => '',
|
|
|
|
|
'id_user_ack' => '',
|
2022-11-03 12:00:58 +01:00
|
|
|
|
'owner_user' => '',
|
2022-07-05 17:02:40 +02:00
|
|
|
|
'date_from' => '',
|
|
|
|
|
'time_from' => '',
|
|
|
|
|
'date_to' => '',
|
|
|
|
|
'time_to' => '',
|
|
|
|
|
'severity' => '',
|
|
|
|
|
'event_type' => '',
|
2022-09-27 15:08:09 +02:00
|
|
|
|
'group_rep' => EVENT_GROUP_REP_ALL,
|
2022-07-05 17:02:40 +02:00
|
|
|
|
'id_group' => 0,
|
|
|
|
|
'id_group_filter' => 0,
|
|
|
|
|
'group_name' => 'All',
|
|
|
|
|
'text_agent' => '',
|
|
|
|
|
'id_agent' => 0,
|
|
|
|
|
'id_name' => 'None',
|
|
|
|
|
'filter_id' => 0,
|
2019-06-20 14:18:49 +02:00
|
|
|
|
];
|
2020-10-29 10:24:37 +01:00
|
|
|
|
} else {
|
2022-06-15 13:06:10 +02:00
|
|
|
|
$event_filter['module_search'] = io_safe_output(
|
|
|
|
|
db_get_value_filter(
|
|
|
|
|
'nombre',
|
|
|
|
|
'tagente_modulo',
|
|
|
|
|
['id_agente_modulo' => $event_filter['id_agent_module']]
|
|
|
|
|
)
|
|
|
|
|
);
|
2020-10-29 10:24:37 +01:00
|
|
|
|
$a = array_keys(users_get_groups(false));
|
|
|
|
|
$event_filter['group_name'] = '';
|
|
|
|
|
foreach ($a as $key => $value) {
|
|
|
|
|
if ($value == $event_filter['id_group']) {
|
|
|
|
|
$event_filter['group_name'] = db_get_value('nombre', 'tgrupo', 'id_grupo', $event_filter['id_group_filter']);
|
2020-10-29 14:57:54 +01:00
|
|
|
|
if ($event_filter['group_name'] === false) {
|
|
|
|
|
$event_filter['group_name'] = __('All');
|
|
|
|
|
}
|
2020-10-29 10:24:37 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-05 17:42:45 +02:00
|
|
|
|
if (is_metaconsole() === true) {
|
2021-04-28 12:50:04 +02:00
|
|
|
|
$server_name = db_get_value('server_name', 'tmetaconsole_setup', 'id', $event_filter['server_id']);
|
|
|
|
|
if ($server_name !== false) {
|
|
|
|
|
$event_filter['server_name'] = $server_name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-29 12:30:54 +01:00
|
|
|
|
$event_filter['module_search'] = io_safe_output(db_get_value_filter('nombre', 'tagente_modulo', ['id_agente_modulo' => $event_filter['id_agent_module']]));
|
2019-06-20 14:18:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$event_filter['search'] = io_safe_output($event_filter['search']);
|
|
|
|
|
$event_filter['id_name'] = io_safe_output($event_filter['id_name']);
|
2020-10-29 10:24:37 +01:00
|
|
|
|
$event_filter['text_agent'] = io_safe_output($event_filter['text_agent']);
|
|
|
|
|
$event_filter['source'] = io_safe_output($event_filter['source']);
|
|
|
|
|
|
|
|
|
|
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$event_filter['tag_with'] = base64_encode(
|
|
|
|
|
io_safe_output($event_filter['tag_with'])
|
|
|
|
|
);
|
|
|
|
|
$event_filter['tag_without'] = base64_encode(
|
|
|
|
|
io_safe_output($event_filter['tag_without'])
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
echo io_json_mb_encode($event_filter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($load_filter_modal) {
|
2020-10-29 12:30:54 +01:00
|
|
|
|
$current = db_get_value_filter('default_event_filter', 'tusuario', ['id_user' => $config['id_user']]);
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$filters = events_get_event_filter_select();
|
|
|
|
|
$user_groups_array = users_get_groups_for_select(
|
|
|
|
|
$config['id_user'],
|
|
|
|
|
$access,
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
false
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
echo '<div id="load-filter-select" class="load-filter-modal">';
|
2022-11-22 11:35:38 +01:00
|
|
|
|
echo '<form method="post" id="form_load_filter" action="index.php?sec=eventos&sec2=operation/events/events&pure=">';
|
2021-04-21 13:05:18 +02:00
|
|
|
|
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$table = new StdClass;
|
|
|
|
|
$table->id = 'load_filter_form';
|
|
|
|
|
$table->width = '100%';
|
|
|
|
|
$table->cellspacing = 4;
|
|
|
|
|
$table->cellpadding = 4;
|
2023-02-24 10:04:23 +01:00
|
|
|
|
$table->styleTable = 'font-weight: bold; color: #555; text-align:left; border: 0px !important;';
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$table->class = 'databox';
|
2023-02-27 09:57:17 +01:00
|
|
|
|
$filter_id_width = '300px';
|
2022-10-24 19:55:22 +02:00
|
|
|
|
if (is_metaconsole() === true) {
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$table->cellspacing = 0;
|
|
|
|
|
$table->cellpadding = 0;
|
|
|
|
|
$table->class = 'databox filters';
|
2019-11-12 17:12:44 +01:00
|
|
|
|
$filter_id_width = '150px';
|
2019-06-11 12:58:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$data = [];
|
|
|
|
|
$table->rowid[3] = 'update_filter_row1';
|
2023-02-24 10:04:23 +01:00
|
|
|
|
$data[0] = '<b>'.__('Load filter').'</b>'.$jump;
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$data[0] .= html_print_select(
|
|
|
|
|
$filters,
|
|
|
|
|
'filter_id',
|
|
|
|
|
$current,
|
|
|
|
|
'',
|
|
|
|
|
__('None'),
|
|
|
|
|
0,
|
2019-11-12 17:12:44 +01:00
|
|
|
|
true,
|
|
|
|
|
false,
|
|
|
|
|
true,
|
|
|
|
|
'',
|
|
|
|
|
false,
|
|
|
|
|
'margin-left:5px; width:'.$filter_id_width.';'
|
2019-06-11 12:58:18 +02:00
|
|
|
|
);
|
2023-02-27 09:57:17 +01:00
|
|
|
|
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$table->data[] = $data;
|
|
|
|
|
$table->rowclass[] = '';
|
|
|
|
|
|
|
|
|
|
html_print_table($table);
|
2023-02-27 09:57:17 +01:00
|
|
|
|
|
|
|
|
|
html_print_div(
|
|
|
|
|
[
|
|
|
|
|
'class' => 'action-buttons',
|
|
|
|
|
'content' => html_print_submit_button(
|
|
|
|
|
__('Load filter'),
|
|
|
|
|
'load_filter',
|
|
|
|
|
false,
|
|
|
|
|
[
|
|
|
|
|
'icon' => 'update',
|
|
|
|
|
'mode' => 'secondary mini',
|
|
|
|
|
],
|
|
|
|
|
true
|
|
|
|
|
).html_print_input_hidden('load_filter', 1, true),
|
|
|
|
|
]
|
|
|
|
|
);
|
2021-04-21 13:05:18 +02:00
|
|
|
|
echo '</form>';
|
2019-06-11 12:58:18 +02:00
|
|
|
|
echo '</div>';
|
|
|
|
|
?>
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
function show_filter() {
|
|
|
|
|
$("#load-filter-select").dialog({
|
2023-02-27 09:57:17 +01:00
|
|
|
|
title: 'Load filter',
|
2019-06-11 12:58:18 +02:00
|
|
|
|
resizable: true,
|
|
|
|
|
draggable: true,
|
2019-06-17 18:33:39 +02:00
|
|
|
|
modal: false,
|
2019-11-12 17:12:44 +01:00
|
|
|
|
closeOnEscape: true,
|
2023-02-27 09:57:17 +01:00
|
|
|
|
width: 340
|
2019-06-11 12:58:18 +02:00
|
|
|
|
});
|
|
|
|
|
}
|
2021-04-21 13:05:18 +02:00
|
|
|
|
|
|
|
|
|
|
2019-06-11 12:58:18 +02:00
|
|
|
|
function load_form_filter() {
|
|
|
|
|
jQuery.post (
|
|
|
|
|
"<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
|
|
|
|
{
|
|
|
|
|
"page" : "include/ajax/events",
|
|
|
|
|
"get_filter_values" : 1,
|
|
|
|
|
"id" : $('#filter_id').val()
|
|
|
|
|
},
|
|
|
|
|
function (data) {
|
|
|
|
|
jQuery.each (data, function (i, val) {
|
|
|
|
|
if (i == 'id_name')
|
|
|
|
|
$("#hidden-id_name").val(val);
|
2020-10-29 10:24:37 +01:00
|
|
|
|
if (i == 'id_group'){
|
|
|
|
|
$('#id_group').val(val);
|
|
|
|
|
}
|
2019-06-11 12:58:18 +02:00
|
|
|
|
if (i == 'event_type')
|
|
|
|
|
$("#event_type").val(val);
|
2020-01-13 18:24:29 +01:00
|
|
|
|
if (i == 'severity') {
|
|
|
|
|
const multiple = val.split(",");
|
|
|
|
|
$("#severity").val(multiple);
|
|
|
|
|
}
|
2019-06-11 12:58:18 +02:00
|
|
|
|
if (i == 'status')
|
|
|
|
|
$("#status").val(val);
|
|
|
|
|
if (i == 'search')
|
2020-10-29 10:24:37 +01:00
|
|
|
|
$('#text-search').val(val);
|
2022-11-18 14:04:54 +01:00
|
|
|
|
if (i == 'not_search')
|
|
|
|
|
$('#checkbox-not_search').val(val);
|
2019-06-11 12:58:18 +02:00
|
|
|
|
if (i == 'text_agent')
|
2020-10-29 10:24:37 +01:00
|
|
|
|
$('input[name=text_agent]').val(val);
|
2019-06-11 12:58:18 +02:00
|
|
|
|
if (i == 'id_agent')
|
|
|
|
|
$('input:hidden[name=id_agent]').val(val);
|
|
|
|
|
if (i == 'id_agent_module')
|
|
|
|
|
$('input:hidden[name=module_search_hidden]').val(val);
|
|
|
|
|
if (i == 'pagination')
|
|
|
|
|
$("#pagination").val(val);
|
|
|
|
|
if (i == 'event_view_hr')
|
|
|
|
|
$("#text-event_view_hr").val(val);
|
|
|
|
|
if (i == 'id_user_ack')
|
|
|
|
|
$("#id_user_ack").val(val);
|
2022-11-03 12:00:58 +01:00
|
|
|
|
if (i == 'owner_user')
|
|
|
|
|
$("#owner_user").val(val);
|
2019-06-11 12:58:18 +02:00
|
|
|
|
if (i == 'group_rep')
|
|
|
|
|
$("#group_rep").val(val);
|
|
|
|
|
if (i == 'tag_with')
|
|
|
|
|
$("#hidden-tag_with").val(val);
|
|
|
|
|
if (i == 'tag_without')
|
|
|
|
|
$("#hidden-tag_without").val(val);
|
|
|
|
|
if (i == 'filter_only_alert')
|
|
|
|
|
$("#filter_only_alert").val(val);
|
2022-07-05 17:02:40 +02:00
|
|
|
|
if (i == 'search_secondary_groups')
|
|
|
|
|
$("#checkbox-search_secondary_groups").val(val);
|
2022-09-29 12:54:46 +02:00
|
|
|
|
if (i == 'search_recursive_groups')
|
|
|
|
|
$("#checkbox-search_recursive_groups").val(val);
|
2019-06-11 12:58:18 +02:00
|
|
|
|
if (i == 'id_group_filter')
|
|
|
|
|
$("#id_group_filter").val(val);
|
|
|
|
|
if (i == 'source')
|
|
|
|
|
$("#text-source").val(val);
|
|
|
|
|
if (i == 'id_extra')
|
|
|
|
|
$("#text-id_extra").val(val);
|
|
|
|
|
if (i == 'user_comment')
|
|
|
|
|
$("#text-user_comment").val(val);
|
2019-11-22 13:38:08 +01:00
|
|
|
|
if (i == 'id_source_event')
|
|
|
|
|
$("#text-id_source_event").val(val);
|
2021-04-28 12:50:04 +02:00
|
|
|
|
if (i == 'server_id')
|
|
|
|
|
$("#server_id").val(val);
|
|
|
|
|
if (i == 'server_name')
|
|
|
|
|
$("#select2-server_id-container").text(val);
|
2020-10-29 10:24:37 +01:00
|
|
|
|
if(i == 'date_from')
|
|
|
|
|
$("#text-date_from").val(val);
|
2021-07-05 17:42:45 +02:00
|
|
|
|
if(i == 'time_from')
|
|
|
|
|
$("#text-time_from").val(val);
|
2020-10-29 10:24:37 +01:00
|
|
|
|
if(i == 'date_to')
|
|
|
|
|
$("#text-date_to").val(val);
|
2021-07-05 17:42:45 +02:00
|
|
|
|
if(i == 'time_to')
|
|
|
|
|
$("#text-time_to").val(val);
|
2020-10-29 10:24:37 +01:00
|
|
|
|
if(i == 'module_search')
|
|
|
|
|
$('input[name=module_search]').val(val);
|
|
|
|
|
if(i == 'group_name')
|
|
|
|
|
$("#select2-id_group_filter-container").text(val);
|
|
|
|
|
|
2019-06-11 12:58:18 +02:00
|
|
|
|
});
|
|
|
|
|
reorder_tags_inputs();
|
|
|
|
|
// Update the info with the loaded filter
|
|
|
|
|
$('#filterid').val($('#filter_id').val());
|
|
|
|
|
$('#filter_loaded_span').html($('#filter_loaded_text').html() + ': ' + $("#hidden-id_name").val());
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
"json"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Close dialog.
|
|
|
|
|
$("#load-filter-select").dialog('close');
|
2019-06-18 17:40:31 +02:00
|
|
|
|
|
|
|
|
|
// Update indicator.
|
|
|
|
|
$("#current_filter").text($('#filter_id option:selected').text());
|
|
|
|
|
|
|
|
|
|
// Search.
|
|
|
|
|
dt_events.draw(false);
|
2019-06-11 12:58:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).ready (function() {
|
|
|
|
|
show_filter();
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
<?php
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($save_filter_modal) {
|
|
|
|
|
echo '<div id="save-filter-select">';
|
|
|
|
|
if (check_acl($config['id_user'], 0, 'EW')
|
|
|
|
|
|| check_acl($config['id_user'], 0, 'EM')
|
|
|
|
|
) {
|
|
|
|
|
echo '<div id="#info_box"></div>';
|
|
|
|
|
$table = new StdClass;
|
|
|
|
|
$table->id = 'save_filter_form';
|
|
|
|
|
$table->width = '100%';
|
|
|
|
|
$table->cellspacing = 4;
|
|
|
|
|
$table->cellpadding = 4;
|
|
|
|
|
$table->class = 'databox';
|
2022-10-24 19:55:22 +02:00
|
|
|
|
if (is_metaconsole() === true) {
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$table->class = 'databox filters';
|
|
|
|
|
$table->cellspacing = 0;
|
|
|
|
|
$table->cellpadding = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-24 10:04:23 +01:00
|
|
|
|
$table->styleTable = 'font-weight: bold; text-align:left; border: 0px !important;';
|
2022-10-24 19:55:22 +02:00
|
|
|
|
if (is_metaconsole() === false) {
|
2023-02-24 10:04:23 +01:00
|
|
|
|
$table->style[0] = '';
|
2019-06-11 12:58:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$data = [];
|
|
|
|
|
$table->rowid[0] = 'update_save_selector';
|
|
|
|
|
$data[0] = html_print_radio_button(
|
|
|
|
|
'filter_mode',
|
|
|
|
|
'new',
|
2023-02-27 09:57:17 +01:00
|
|
|
|
__('New filter'),
|
2019-06-11 12:58:18 +02:00
|
|
|
|
true,
|
|
|
|
|
true
|
2023-02-27 09:57:17 +01:00
|
|
|
|
);
|
2019-06-11 12:58:18 +02:00
|
|
|
|
|
|
|
|
|
$data[1] = html_print_radio_button(
|
|
|
|
|
'filter_mode',
|
|
|
|
|
'update',
|
2023-02-27 09:57:17 +01:00
|
|
|
|
__('Update filter'),
|
2019-06-11 12:58:18 +02:00
|
|
|
|
false,
|
|
|
|
|
true
|
2023-02-27 09:57:17 +01:00
|
|
|
|
);
|
2019-06-11 12:58:18 +02:00
|
|
|
|
|
|
|
|
|
$table->data[] = $data;
|
|
|
|
|
$table->rowclass[] = '';
|
|
|
|
|
|
|
|
|
|
$data = [];
|
|
|
|
|
$table->rowid[1] = 'save_filter_row1';
|
2023-02-27 09:57:17 +01:00
|
|
|
|
$table->size[0] = '50%';
|
|
|
|
|
$table->size[1] = '50%';
|
2023-02-24 10:04:23 +01:00
|
|
|
|
$data[0] = '<b>'.__('Filter name').'</b>'.$jump;
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$data[0] .= html_print_input_text('id_name', '', '', 15, 255, true);
|
|
|
|
|
if (is_metaconsole()) {
|
|
|
|
|
$data[1] = __('Save in Group').$jump;
|
|
|
|
|
} else {
|
2023-02-24 10:04:23 +01:00
|
|
|
|
$data[1] = '<b>'.__('Filter group').'</b>'.$jump;
|
2019-06-11 12:58:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-18 11:00:48 +02:00
|
|
|
|
$user_groups_array = users_get_groups_for_select(
|
|
|
|
|
$config['id_user'],
|
|
|
|
|
'EW',
|
|
|
|
|
users_can_manage_group_all(),
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$data[1] .= html_print_select(
|
|
|
|
|
$user_groups_array,
|
2022-07-15 11:38:46 +02:00
|
|
|
|
'id_group_filter_dialog',
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$id_group_filter,
|
|
|
|
|
'',
|
|
|
|
|
'',
|
|
|
|
|
0,
|
|
|
|
|
true,
|
|
|
|
|
false,
|
|
|
|
|
false,
|
|
|
|
|
'w130'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$table->data[] = $data;
|
|
|
|
|
$table->rowclass[] = '';
|
|
|
|
|
|
|
|
|
|
$data = [];
|
|
|
|
|
$table->rowid[2] = 'save_filter_row2';
|
|
|
|
|
|
|
|
|
|
$table->data[] = $data;
|
|
|
|
|
$table->rowclass[] = '';
|
|
|
|
|
|
|
|
|
|
$data = [];
|
|
|
|
|
$table->rowid[3] = 'update_filter_row1';
|
|
|
|
|
$data[0] = __('Overwrite filter').$jump;
|
|
|
|
|
// Fix : Only admin user can see filters of group ALL for update.
|
|
|
|
|
$_filters_update = events_get_event_filter_select(false);
|
|
|
|
|
|
|
|
|
|
$data[0] .= html_print_select(
|
|
|
|
|
$_filters_update,
|
|
|
|
|
'overwrite_filter',
|
|
|
|
|
'',
|
|
|
|
|
'',
|
|
|
|
|
'',
|
|
|
|
|
0,
|
2023-02-27 09:57:17 +01:00
|
|
|
|
true,
|
2019-06-11 12:58:18 +02:00
|
|
|
|
false,
|
2023-02-27 09:57:17 +01:00
|
|
|
|
true,
|
|
|
|
|
'w130'
|
2019-06-11 12:58:18 +02:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$table->data[] = $data;
|
|
|
|
|
$table->rowclass[] = '';
|
|
|
|
|
|
|
|
|
|
html_print_table($table);
|
2022-10-24 19:55:22 +02:00
|
|
|
|
|
|
|
|
|
html_print_div(
|
|
|
|
|
[
|
|
|
|
|
'class' => 'action-buttons',
|
|
|
|
|
'content' => html_print_submit_button(
|
|
|
|
|
__('Save filter'),
|
|
|
|
|
'save_filter',
|
|
|
|
|
false,
|
|
|
|
|
[
|
|
|
|
|
'icon' => 'update',
|
2022-11-07 14:04:07 +01:00
|
|
|
|
'mode' => 'secondary mini',
|
2022-10-24 19:55:22 +02:00
|
|
|
|
'onClick' => 'save_new_filter();',
|
|
|
|
|
],
|
|
|
|
|
true
|
|
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
);
|
2023-02-27 09:57:17 +01:00
|
|
|
|
|
|
|
|
|
html_print_div(
|
|
|
|
|
[
|
|
|
|
|
'class' => 'action-buttons',
|
|
|
|
|
'content' => html_print_submit_button(
|
|
|
|
|
__('Update filter'),
|
|
|
|
|
'update_filter',
|
|
|
|
|
false,
|
|
|
|
|
[
|
|
|
|
|
'icon' => 'update',
|
|
|
|
|
'mode' => 'secondary mini',
|
|
|
|
|
'onClick' => 'save_update_filter();',
|
|
|
|
|
],
|
|
|
|
|
true
|
|
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
);
|
2019-06-11 12:58:18 +02:00
|
|
|
|
} else {
|
|
|
|
|
include 'general/noaccess.php';
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-27 09:57:17 +01:00
|
|
|
|
$modal_title = __('Save/Update filters');
|
2019-06-11 12:58:18 +02:00
|
|
|
|
echo '</div>';
|
|
|
|
|
?>
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
function show_save_filter() {
|
2019-06-17 18:33:39 +02:00
|
|
|
|
$('#save_filter_row1').show();
|
|
|
|
|
$('#save_filter_row2').show();
|
|
|
|
|
$('#update_filter_row1').hide();
|
2023-02-27 09:57:17 +01:00
|
|
|
|
$('#button-update_filter').hide();
|
2019-06-17 18:33:39 +02:00
|
|
|
|
// Filter save mode selector
|
|
|
|
|
$("[name='filter_mode']").click(function() {
|
|
|
|
|
if ($(this).val() == 'new') {
|
|
|
|
|
$('#save_filter_row1').show();
|
|
|
|
|
$('#save_filter_row2').show();
|
2023-02-27 09:57:17 +01:00
|
|
|
|
$('#button-save_filter').show();
|
2019-06-17 18:33:39 +02:00
|
|
|
|
$('#update_filter_row1').hide();
|
2023-02-27 09:57:17 +01:00
|
|
|
|
$('#button-update_filter').hide();
|
2019-06-17 18:33:39 +02:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$('#save_filter_row1').hide();
|
|
|
|
|
$('#save_filter_row2').hide();
|
|
|
|
|
$('#update_filter_row1').show();
|
2023-02-27 09:57:17 +01:00
|
|
|
|
$('#button-update_filter').show();
|
|
|
|
|
$('#button-save_filter').hide();
|
2019-06-17 18:33:39 +02:00
|
|
|
|
}
|
|
|
|
|
});
|
2019-06-11 12:58:18 +02:00
|
|
|
|
$("#save-filter-select").dialog({
|
2023-02-27 09:57:17 +01:00
|
|
|
|
title: '<?php echo $modal_title; ?>',
|
2019-06-11 12:58:18 +02:00
|
|
|
|
resizable: true,
|
|
|
|
|
draggable: true,
|
2019-06-17 18:33:39 +02:00
|
|
|
|
modal: false,
|
2023-02-24 10:04:23 +01:00
|
|
|
|
closeOnEscape: true,
|
|
|
|
|
width: 700
|
2019-06-11 12:58:18 +02:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function save_new_filter() {
|
|
|
|
|
// If the filter name is blank show error
|
|
|
|
|
if ($('#text-id_name').val() == '') {
|
|
|
|
|
$('#show_filter_error').html("<h3 class='error'><?php echo __('Filter name cannot be left blank'); ?></h3>");
|
|
|
|
|
|
|
|
|
|
// Close dialog
|
|
|
|
|
$('.ui-dialog-titlebar-close').trigger('click');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var id_filter_save;
|
|
|
|
|
|
|
|
|
|
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
|
|
|
|
{
|
2019-06-20 19:23:13 +02:00
|
|
|
|
"page" : "include/ajax/events",
|
2019-06-11 12:58:18 +02:00
|
|
|
|
"save_event_filter" : 1,
|
|
|
|
|
"id_name" : $("#text-id_name").val(),
|
2022-07-15 11:38:46 +02:00
|
|
|
|
"id_group" : $("#id_group_filter").val(),
|
2019-06-11 12:58:18 +02:00
|
|
|
|
"event_type" : $("#event_type").val(),
|
|
|
|
|
"severity" : $("#severity").val(),
|
|
|
|
|
"status" : $("#status").val(),
|
|
|
|
|
"search" : $("#text-search").val(),
|
2022-11-18 14:04:54 +01:00
|
|
|
|
"not_search" : $("#checkbox-not_search").val(),
|
2019-06-11 12:58:18 +02:00
|
|
|
|
"text_agent" : $("#text_id_agent").val(),
|
|
|
|
|
"id_agent" : $('input:hidden[name=id_agent]').val(),
|
|
|
|
|
"id_agent_module" : $('input:hidden[name=module_search_hidden]').val(),
|
|
|
|
|
"pagination" : $("#pagination").val(),
|
|
|
|
|
"event_view_hr" : $("#text-event_view_hr").val(),
|
|
|
|
|
"id_user_ack" : $("#id_user_ack").val(),
|
2022-11-03 12:00:58 +01:00
|
|
|
|
"owner_user" : $("#owner_user").val(),
|
2019-06-11 12:58:18 +02:00
|
|
|
|
"group_rep" : $("#group_rep").val(),
|
|
|
|
|
"tag_with": Base64.decode($("#hidden-tag_with").val()),
|
|
|
|
|
"tag_without": Base64.decode($("#hidden-tag_without").val()),
|
|
|
|
|
"filter_only_alert" : $("#filter_only_alert").val(),
|
2022-07-05 17:02:40 +02:00
|
|
|
|
"search_secondary_groups" : $("#checkbox-search_secondary_groups").val(),
|
2022-09-29 12:54:46 +02:00
|
|
|
|
"search_recursive_groups" : $("#checkbox-search_recursive_groups").val(),
|
2022-07-15 11:38:46 +02:00
|
|
|
|
"id_group_filter": $("#id_group_filter_dialog").val(),
|
2019-06-11 12:58:18 +02:00
|
|
|
|
"date_from": $("#text-date_from").val(),
|
2021-07-05 17:42:45 +02:00
|
|
|
|
"time_from": $("#text-time_from").val(),
|
2019-06-11 12:58:18 +02:00
|
|
|
|
"date_to": $("#text-date_to").val(),
|
2021-07-05 17:42:45 +02:00
|
|
|
|
"time_to": $("#text-time_to").val(),
|
2019-06-11 12:58:18 +02:00
|
|
|
|
"source": $("#text-source").val(),
|
|
|
|
|
"id_extra": $("#text-id_extra").val(),
|
2019-11-22 13:38:08 +01:00
|
|
|
|
"user_comment": $("#text-user_comment").val(),
|
2021-04-28 12:50:04 +02:00
|
|
|
|
"id_source_event": $("#text-id_source_event").val(),
|
2022-03-29 18:09:19 +02:00
|
|
|
|
"server_id": $("#server_id").val(),
|
|
|
|
|
"custom_data": $("#text-custom_data").val(),
|
|
|
|
|
"custom_data_filter_type": $("#custom_data_filter_type").val()
|
2019-06-11 12:58:18 +02:00
|
|
|
|
},
|
|
|
|
|
function (data) {
|
|
|
|
|
$("#info_box").hide();
|
|
|
|
|
if (data == 'error') {
|
|
|
|
|
$("#info_box").filter(function(i, item) {
|
|
|
|
|
if ($(item).data('type_info_box') == "error_create_filter") {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}).show();
|
|
|
|
|
}
|
|
|
|
|
else if (data == 'duplicate') {
|
|
|
|
|
$("#info_box").filter(function(i, item) {
|
|
|
|
|
if ($(item).data('type_info_box') == "duplicate_create_filter") {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}).show();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
id_filter_save = data;
|
|
|
|
|
|
|
|
|
|
$("#info_box").filter(function(i, item) {
|
|
|
|
|
if ($(item).data('type_info_box') == "success_create_filter") {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}).show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Close dialog.
|
|
|
|
|
$("#save-filter-select").dialog('close');
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This updates an event filter
|
|
|
|
|
function save_update_filter() {
|
|
|
|
|
var id_filter_update = $("#overwrite_filter").val();
|
|
|
|
|
var name_filter_update = $("#overwrite_filter option[value='"+id_filter_update+"']").text();
|
|
|
|
|
|
|
|
|
|
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
2019-06-20 19:23:13 +02:00
|
|
|
|
{"page" : "include/ajax/events",
|
2019-06-11 12:58:18 +02:00
|
|
|
|
"update_event_filter" : 1,
|
|
|
|
|
"id" : $("#overwrite_filter").val(),
|
2022-07-15 11:38:46 +02:00
|
|
|
|
"id_group" : $("#id_group_filter").val(),
|
2019-06-11 12:58:18 +02:00
|
|
|
|
"event_type" : $("#event_type").val(),
|
|
|
|
|
"severity" : $("#severity").val(),
|
|
|
|
|
"status" : $("#status").val(),
|
|
|
|
|
"search" : $("#text-search").val(),
|
2022-11-18 14:04:54 +01:00
|
|
|
|
"not_search" : $("#checkbox-not_search").val(),
|
2019-06-11 12:58:18 +02:00
|
|
|
|
"text_agent" : $("#text_id_agent").val(),
|
|
|
|
|
"id_agent" : $('input:hidden[name=id_agent]').val(),
|
|
|
|
|
"id_agent_module" : $('input:hidden[name=module_search_hidden]').val(),
|
|
|
|
|
"pagination" : $("#pagination").val(),
|
|
|
|
|
"event_view_hr" : $("#text-event_view_hr").val(),
|
|
|
|
|
"id_user_ack" : $("#id_user_ack").val(),
|
2022-11-03 12:00:58 +01:00
|
|
|
|
"owner_user" : $("#owner_user").val(),
|
2019-06-11 12:58:18 +02:00
|
|
|
|
"group_rep" : $("#group_rep").val(),
|
|
|
|
|
"tag_with" : Base64.decode($("#hidden-tag_with").val()),
|
|
|
|
|
"tag_without" : Base64.decode($("#hidden-tag_without").val()),
|
|
|
|
|
"filter_only_alert" : $("#filter_only_alert").val(),
|
2022-07-05 17:02:40 +02:00
|
|
|
|
"search_secondary_groups" : $("#checkbox-search_secondary_groups").val(),
|
2022-09-29 12:54:46 +02:00
|
|
|
|
"search_recursive_groups" : $("#checkbox-search_recursive_groups").val(),
|
2022-07-15 11:38:46 +02:00
|
|
|
|
"id_group_filter": $("#id_group_filter_dialog").val(),
|
2019-06-11 12:58:18 +02:00
|
|
|
|
"date_from": $("#text-date_from").val(),
|
2021-07-05 17:42:45 +02:00
|
|
|
|
"time_from": $("#text-time_from").val(),
|
2019-06-11 12:58:18 +02:00
|
|
|
|
"date_to": $("#text-date_to").val(),
|
2021-07-05 17:42:45 +02:00
|
|
|
|
"time_to": $("#text-time_to").val(),
|
2019-06-11 12:58:18 +02:00
|
|
|
|
"source": $("#text-source").val(),
|
|
|
|
|
"id_extra": $("#text-id_extra").val(),
|
2019-11-22 13:38:08 +01:00
|
|
|
|
"user_comment": $("#text-user_comment").val(),
|
2021-04-28 12:50:04 +02:00
|
|
|
|
"id_source_event": $("#text-id_source_event").val(),
|
2022-04-01 14:06:51 +02:00
|
|
|
|
"server_id": $("#server_id").val(),
|
|
|
|
|
"custom_data": $("#text-custom_data").val(),
|
|
|
|
|
"custom_data_filter_type": $("#custom_data_filter_type").val()
|
2019-11-22 13:38:08 +01:00
|
|
|
|
|
2019-06-11 12:58:18 +02:00
|
|
|
|
},
|
|
|
|
|
function (data) {
|
|
|
|
|
$(".info_box").hide();
|
|
|
|
|
if (data == 'ok') {
|
|
|
|
|
$(".info_box").filter(function(i, item) {
|
|
|
|
|
if ($(item).data('type_info_box') == "success_update_filter") {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}).show();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$(".info_box").filter(function(i, item) {
|
|
|
|
|
if ($(item).data('type_info_box') == "error_create_filter") {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}).show();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// First remove all options of filters select
|
|
|
|
|
$('#filter_id').find('option').remove().end();
|
|
|
|
|
// Add 'none' option the first
|
|
|
|
|
$('#filter_id').append ($('<option></option>').html ( <?php echo "'".__('none')."'"; ?> ).attr ("value", 0));
|
|
|
|
|
// Reload filters select
|
|
|
|
|
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
2019-06-20 19:23:13 +02:00
|
|
|
|
{"page" : "include/ajax/events",
|
2019-06-11 12:58:18 +02:00
|
|
|
|
"get_event_filters" : 1
|
|
|
|
|
},
|
|
|
|
|
function (data) {
|
|
|
|
|
jQuery.each (data, function (i, val) {
|
|
|
|
|
s = js_html_entity_decode(val);
|
|
|
|
|
if (i == id_filter_update) {
|
|
|
|
|
$('#filter_id').append ($('<option selected="selected"></option>').html (s).attr ("value", i));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$('#filter_id').append ($('<option></option>').html (s).attr ("value", i));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
"json"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Close dialog
|
|
|
|
|
$('.ui-dialog-titlebar-close').trigger('click');
|
|
|
|
|
|
|
|
|
|
// Update the info with the loaded filter
|
|
|
|
|
$("#hidden-id_name").val($('#text-id_name').val());
|
|
|
|
|
$('#filter_loaded_span').html($('#filter_loaded_text').html() + ': ' + name_filter_update);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(function (){
|
|
|
|
|
show_save_filter();
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
<?php
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-11 19:49:17 +02:00
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
|
if ($get_response === true) {
|
2020-06-26 15:36:51 +02:00
|
|
|
|
if (! check_acl($config['id_user'], 0, 'EW')) {
|
|
|
|
|
echo 'unauthorized';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
|
$response_id = get_parameter('response_id');
|
|
|
|
|
$server_id = (int) get_parameter('server_id', 0);
|
|
|
|
|
$event_id = (int) get_parameter('event_id', 0);
|
2022-09-27 09:51:37 +02:00
|
|
|
|
$response_parameters = json_decode(
|
|
|
|
|
io_safe_output(
|
|
|
|
|
get_parameter('response_parameters', '')
|
|
|
|
|
),
|
|
|
|
|
true
|
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
|
$event_response = db_get_row(
|
|
|
|
|
'tevent_response',
|
|
|
|
|
'id',
|
|
|
|
|
$response_id
|
|
|
|
|
);
|
2012-10-09 18:05:32 +02:00
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
|
if (empty($event_response) === true) {
|
|
|
|
|
return [];
|
2020-06-26 15:36:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
|
if (empty($event_id) === false) {
|
|
|
|
|
try {
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $server_id > 0
|
|
|
|
|
) {
|
|
|
|
|
$node = new Node($server_id);
|
|
|
|
|
$node->connect();
|
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
|
$event_response['target'] = events_get_response_target(
|
|
|
|
|
$event_id,
|
2022-09-27 09:51:37 +02:00
|
|
|
|
$event_response,
|
2022-09-28 09:30:30 +02:00
|
|
|
|
$response_parameters,
|
|
|
|
|
$server_id,
|
|
|
|
|
($server_id !== 0) ? $node->server_name() : 'Metaconsole'
|
2022-09-23 13:55:01 +02:00
|
|
|
|
);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
// Unexistent agent.
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $server_id > 0
|
|
|
|
|
) {
|
|
|
|
|
$node->disconnect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
} finally {
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $server_id > 0
|
|
|
|
|
) {
|
|
|
|
|
$node->disconnect();
|
|
|
|
|
}
|
2022-06-15 13:06:10 +02:00
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
|
echo json_encode($event_response);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
|
|
return;
|
2012-10-09 18:05:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
|
|
|
|
|
|
if ($get_response_massive === true) {
|
2020-06-26 15:36:51 +02:00
|
|
|
|
if (! check_acl($config['id_user'], 0, 'EW')) {
|
|
|
|
|
echo 'unauthorized';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
|
$response_id = get_parameter('response_id');
|
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
|
$event_response = db_get_row(
|
|
|
|
|
'tevent_response',
|
|
|
|
|
'id',
|
|
|
|
|
$response_id
|
|
|
|
|
);
|
2022-06-15 13:06:10 +02:00
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
|
if (empty($event_response) === true) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
2022-06-15 13:06:10 +02:00
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
|
$events = json_decode(
|
|
|
|
|
io_safe_output(
|
|
|
|
|
get_parameter('events', '')
|
|
|
|
|
),
|
|
|
|
|
true
|
|
|
|
|
);
|
2022-06-15 13:06:10 +02:00
|
|
|
|
|
2022-09-27 09:51:37 +02:00
|
|
|
|
$response_parameters = json_decode(
|
|
|
|
|
io_safe_output(
|
|
|
|
|
get_parameter('response_parameters', '')
|
|
|
|
|
),
|
|
|
|
|
true
|
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
|
$event_response_targets = [];
|
|
|
|
|
if (is_metaconsole() === true) {
|
|
|
|
|
foreach ($events as $server_id => $idEvents) {
|
|
|
|
|
foreach ($idEvents as $idEvent) {
|
|
|
|
|
$event_response_targets[$idEvent.'|'.$server_id]['target'] = get_events_get_response_target(
|
|
|
|
|
$idEvent,
|
|
|
|
|
$event_response,
|
2022-09-27 09:51:37 +02:00
|
|
|
|
$server_id,
|
|
|
|
|
$response_parameters
|
2022-09-23 13:55:01 +02:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2022-09-27 09:51:37 +02:00
|
|
|
|
foreach ($events as $idEvent) {
|
2022-09-23 13:55:01 +02:00
|
|
|
|
$event_response_targets[$idEvent]['target'] = get_events_get_response_target(
|
|
|
|
|
$idEvent,
|
2022-09-27 09:51:37 +02:00
|
|
|
|
$event_response,
|
|
|
|
|
0,
|
|
|
|
|
$response_parameters
|
2022-09-23 13:55:01 +02:00
|
|
|
|
);
|
2022-06-15 13:06:10 +02:00
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
|
$result = [
|
|
|
|
|
'event_response' => $event_response,
|
|
|
|
|
'event_response_targets' => $event_response_targets,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
echo json_encode($result);
|
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
|
return;
|
2012-10-09 18:05:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
|
if ($get_row_response_action === true) {
|
2019-01-30 16:18:44 +01:00
|
|
|
|
$response_id = get_parameter('response_id');
|
2022-09-23 13:55:01 +02:00
|
|
|
|
$response = json_decode(
|
|
|
|
|
io_safe_output(
|
|
|
|
|
get_parameter('response', '')
|
|
|
|
|
),
|
|
|
|
|
true
|
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
|
$end = (bool) get_parameter('end', false);
|
|
|
|
|
$index = $response['event_id'];
|
|
|
|
|
if (is_metaconsole() === true) {
|
|
|
|
|
$index .= '-'.$response['server_id'];
|
2019-01-30 16:18:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
|
echo get_row_response_action(
|
|
|
|
|
$response,
|
|
|
|
|
$response_id,
|
|
|
|
|
$end,
|
|
|
|
|
$index
|
|
|
|
|
);
|
2019-02-27 10:59:44 +01:00
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
|
return;
|
2012-10-09 18:05:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-15 13:06:10 +02:00
|
|
|
|
if ($perform_event_response === true) {
|
2019-01-30 16:18:44 +01:00
|
|
|
|
global $config;
|
|
|
|
|
|
2020-06-26 15:36:51 +02:00
|
|
|
|
if (! check_acl($config['id_user'], 0, 'EW')) {
|
2022-09-23 13:55:01 +02:00
|
|
|
|
echo __('unauthorized');
|
2020-06-26 15:36:51 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-13 14:10:57 +02:00
|
|
|
|
$target = get_parameter('target', '');
|
2019-01-30 16:18:44 +01:00
|
|
|
|
$response_id = get_parameter('response_id');
|
2020-04-15 15:50:08 +02:00
|
|
|
|
$event_id = (int) get_parameter('event_id');
|
|
|
|
|
$server_id = (int) get_parameter('server_id', 0);
|
2022-09-23 13:55:01 +02:00
|
|
|
|
$response = json_decode(
|
|
|
|
|
io_safe_output(
|
|
|
|
|
get_parameter('response', '')
|
|
|
|
|
),
|
|
|
|
|
true
|
|
|
|
|
);
|
2020-04-15 15:50:08 +02:00
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
|
$event_response = $response;
|
|
|
|
|
if (empty($event_response) === true) {
|
|
|
|
|
echo __('No data');
|
|
|
|
|
return;
|
2020-08-13 14:10:57 +02:00
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
|
$command = $event_response['target'];
|
2022-06-16 11:31:07 +02:00
|
|
|
|
$command_timeout = ($event_response !== false) ? $event_response['command_timeout'] : 90;
|
2022-06-15 13:06:10 +02:00
|
|
|
|
if (enterprise_installed() === true) {
|
2022-06-16 11:31:07 +02:00
|
|
|
|
if ($event_response !== false
|
|
|
|
|
&& (int) $event_response['server_to_exec'] !== 0
|
|
|
|
|
&& $event_response['type'] === 'command'
|
|
|
|
|
) {
|
2019-01-30 16:18:44 +01:00
|
|
|
|
$commandExclusions = [
|
|
|
|
|
'vi',
|
|
|
|
|
'vim',
|
|
|
|
|
'nano',
|
|
|
|
|
];
|
|
|
|
|
|
2019-02-27 10:59:44 +01:00
|
|
|
|
$server_data = db_get_row(
|
|
|
|
|
'tserver',
|
|
|
|
|
'id_server',
|
|
|
|
|
$event_response['server_to_exec']
|
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
2022-06-16 11:31:07 +02:00
|
|
|
|
if (in_array(strtolower($command), $commandExclusions) === true) {
|
2019-01-30 16:18:44 +01:00
|
|
|
|
echo 'Only stdin/stdout commands are supported';
|
|
|
|
|
} else {
|
|
|
|
|
switch (PHP_OS) {
|
|
|
|
|
case 'FreeBSD':
|
|
|
|
|
$timeout_bin = '/usr/local/bin/gtimeout';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'NetBSD':
|
|
|
|
|
$timeout_bin = '/usr/pkg/bin/gtimeout';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
$timeout_bin = '/usr/bin/timeout';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-16 11:31:07 +02:00
|
|
|
|
if (empty($server_data['port']) === true) {
|
|
|
|
|
system(
|
|
|
|
|
'ssh pandora_exec_proxy@'.$server_data['ip_address'].' "'.$timeout_bin.' '.$command_timeout.' '.io_safe_output($command).' 2>&1"',
|
|
|
|
|
$ret_val
|
|
|
|
|
);
|
2020-01-14 15:43:17 +01:00
|
|
|
|
} else {
|
2022-06-16 11:31:07 +02:00
|
|
|
|
system(
|
|
|
|
|
'ssh -p '.$server_data['port'].' pandora_exec_proxy@'.$server_data['ip_address'].' "'.$timeout_bin.' '.$command_timeout.' '.io_safe_output($command).' 2>&1"',
|
|
|
|
|
$ret_val
|
|
|
|
|
);
|
2020-01-14 15:43:17 +01:00
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
switch (PHP_OS) {
|
|
|
|
|
case 'FreeBSD':
|
|
|
|
|
$timeout_bin = '/usr/local/bin/gtimeout';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'NetBSD':
|
|
|
|
|
$timeout_bin = '/usr/pkg/bin/gtimeout';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
$timeout_bin = '/usr/bin/timeout';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-10 11:54:30 +01:00
|
|
|
|
system($timeout_bin.' '.$command_timeout.' '.io_safe_output($command).' 2>&1', $ret_val);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
switch (PHP_OS) {
|
|
|
|
|
case 'FreeBSD':
|
|
|
|
|
$timeout_bin = '/usr/local/bin/gtimeout';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'NetBSD':
|
|
|
|
|
$timeout_bin = '/usr/pkg/bin/gtimeout';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
$timeout_bin = '/usr/bin/timeout';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-23 13:55:01 +02:00
|
|
|
|
system($timeout_bin.' '.$command_timeout.' '.io_safe_output($command).' 2>&1', $ret_val);
|
2019-12-10 11:54:30 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($ret_val != 0) {
|
2021-03-11 15:40:23 +01:00
|
|
|
|
echo "<div class='left'>";
|
2019-12-10 11:54:30 +01:00
|
|
|
|
echo __('Error executing response');
|
|
|
|
|
echo '</div><br>';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
2012-10-09 18:05:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-31 Miguel de Dios <miguel.dedios@artica.es>
* include/styles/jquery-ui-1.10.0.custom.css,
include/styles/images/ui-*,
include/javascript/jquery.jquery-ui-1.10.0.custom.js,
include/javascript/jquery-1.9.0.js: added the last version of
jquery and jqueryUI.
* godmode/reporting/visual_console_builder.editor.js,
include/ajax/events.php, include/functions_events.php,
include/functions_reporting.php,
include/javascript/pandora_events.js,
include/javascript/jquery.scrollTo.js,
include/javascript/jquery.tablesorter.pager.js,
include/javascript/jquery.tablesorter.js, include/functions_ui.php,
extensions/update_manager/lib/functions.php,
extensions/update_manager/main.php, extensions/agents_alerts.php,
operation/events/events.php, general/login_page.php,
general/logoff.php, general/header.php,
general/login_help_dialog.php: fixes about the new jquery and
jqueryUI version.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7554 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-01-31 17:49:08 +01:00
|
|
|
|
if ($dialogue_event_response) {
|
2019-01-30 16:18:44 +01:00
|
|
|
|
global $config;
|
|
|
|
|
|
2020-06-26 15:36:51 +02:00
|
|
|
|
if (! check_acl($config['id_user'], 0, 'EW')) {
|
|
|
|
|
echo 'unauthorized';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
|
$event_id = get_parameter('event_id');
|
|
|
|
|
$response_id = get_parameter('response_id');
|
|
|
|
|
$command = get_parameter('target');
|
2022-09-23 13:55:01 +02:00
|
|
|
|
$event_response = json_decode(
|
|
|
|
|
io_safe_output(
|
|
|
|
|
get_parameter('response', '')
|
|
|
|
|
),
|
|
|
|
|
true
|
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
|
|
switch ($event_response['type']) {
|
|
|
|
|
case 'command':
|
2022-09-23 13:55:01 +02:00
|
|
|
|
echo get_row_response_action(
|
|
|
|
|
$event_response,
|
|
|
|
|
$response_id
|
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'url':
|
|
|
|
|
$command = str_replace('localhost', $_SERVER['SERVER_NAME'], $command);
|
2021-03-11 15:40:23 +01:00
|
|
|
|
echo "<iframe src='".$command."' id='divframe' class='w100p height_90p'></iframe>";
|
2019-02-08 17:30:47 +01:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
// Ignore.
|
2019-01-30 16:18:44 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
2012-10-09 18:05:32 +02:00
|
|
|
|
}
|
2012-10-01 13:15:31 +02:00
|
|
|
|
|
2021-11-29 16:12:15 +01:00
|
|
|
|
if ($add_comment === true) {
|
|
|
|
|
$comment = (string) get_parameter('comment');
|
|
|
|
|
$eventId = (int) get_parameter('event_id');
|
2022-06-14 18:47:09 +02:00
|
|
|
|
$server_id = 0;
|
|
|
|
|
if (is_metaconsole() === true) {
|
|
|
|
|
$server_id = (int) get_parameter('server_id');
|
|
|
|
|
}
|
2021-11-29 16:12:15 +01:00
|
|
|
|
|
|
|
|
|
// Safe comments for hacks.
|
2020-06-19 10:59:43 +02:00
|
|
|
|
if (preg_match('/script/i', io_safe_output($comment))) {
|
2020-06-09 11:40:39 +02:00
|
|
|
|
$return = false;
|
2019-01-30 16:18:44 +01:00
|
|
|
|
} else {
|
2022-06-14 18:47:09 +02:00
|
|
|
|
try {
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $server_id > 0
|
|
|
|
|
) {
|
|
|
|
|
$node = new Node($server_id);
|
|
|
|
|
$node->connect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$return = events_comment(
|
|
|
|
|
$eventId,
|
|
|
|
|
$comment,
|
|
|
|
|
'Added comment'
|
|
|
|
|
);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
// Unexistent agent.
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $server_id > 0
|
|
|
|
|
) {
|
|
|
|
|
$node->disconnect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$return = false;
|
|
|
|
|
} finally {
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $server_id > 0
|
|
|
|
|
) {
|
|
|
|
|
$node->disconnect();
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-29 16:12:15 +01:00
|
|
|
|
echo ($return === true) ? 'comment_ok' : 'comment_error';
|
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
|
return;
|
2012-10-01 13:15:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-14 18:47:09 +02:00
|
|
|
|
if ($change_status === true) {
|
2019-01-30 16:18:44 +01:00
|
|
|
|
$event_ids = get_parameter('event_ids');
|
|
|
|
|
$new_status = get_parameter('new_status');
|
2022-06-15 13:06:10 +02:00
|
|
|
|
$server_id = 0;
|
|
|
|
|
if (is_metaconsole() === true) {
|
|
|
|
|
$server_id = (int) get_parameter('server_id');
|
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
2022-06-14 18:47:09 +02:00
|
|
|
|
try {
|
|
|
|
|
if (is_metaconsole() === true
|
2022-06-15 13:06:10 +02:00
|
|
|
|
&& $server_id > 0
|
2022-06-14 18:47:09 +02:00
|
|
|
|
) {
|
2022-06-15 13:06:10 +02:00
|
|
|
|
$node = new Node($server_id);
|
2022-03-24 18:52:06 +01:00
|
|
|
|
$node->connect();
|
|
|
|
|
}
|
2022-06-14 18:47:09 +02:00
|
|
|
|
|
2022-03-24 18:52:06 +01:00
|
|
|
|
$return = events_change_status(
|
|
|
|
|
explode(',', $event_ids),
|
2022-06-14 18:47:09 +02:00
|
|
|
|
$new_status
|
2022-03-24 18:52:06 +01:00
|
|
|
|
);
|
2022-06-14 18:47:09 +02:00
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
// Unexistent agent.
|
|
|
|
|
if (is_metaconsole() === true
|
2022-06-15 13:06:10 +02:00
|
|
|
|
&& $server_id > 0
|
2022-06-14 18:47:09 +02:00
|
|
|
|
) {
|
|
|
|
|
$node->disconnect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$success = false;
|
|
|
|
|
echo 'owner_error';
|
|
|
|
|
} finally {
|
|
|
|
|
if (is_metaconsole() === true
|
2022-06-15 13:06:10 +02:00
|
|
|
|
&& $server_id > 0
|
2022-06-14 18:47:09 +02:00
|
|
|
|
) {
|
|
|
|
|
$node->disconnect();
|
|
|
|
|
}
|
2022-03-24 18:52:06 +01:00
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
2020-10-30 14:42:10 +01:00
|
|
|
|
if ($return !== false) {
|
2022-03-21 18:15:58 +01:00
|
|
|
|
$event_st = events_display_status($new_status);
|
|
|
|
|
|
2020-10-30 14:42:10 +01:00
|
|
|
|
echo json_encode(
|
|
|
|
|
[
|
2022-03-21 18:15:58 +01:00
|
|
|
|
'status_title' => $event_st['title'],
|
2022-06-14 18:47:09 +02:00
|
|
|
|
'status_img' => html_print_image(
|
|
|
|
|
$event_st['img'],
|
|
|
|
|
true,
|
|
|
|
|
false,
|
|
|
|
|
true
|
|
|
|
|
),
|
2022-03-21 18:15:58 +01:00
|
|
|
|
'status' => 'status_ok',
|
|
|
|
|
'user' => db_get_value(
|
2020-10-30 14:42:10 +01:00
|
|
|
|
'fullname',
|
|
|
|
|
'tusuario',
|
|
|
|
|
'id_user',
|
|
|
|
|
$config['id_user']
|
|
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
} else {
|
2020-10-30 14:42:10 +01:00
|
|
|
|
echo json_encode(
|
|
|
|
|
[
|
|
|
|
|
'status' => 'status_error',
|
|
|
|
|
'user' => db_get_value(
|
|
|
|
|
'fullname',
|
|
|
|
|
'tusuario',
|
|
|
|
|
'id_user',
|
|
|
|
|
$config['id_user']
|
|
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
2012-10-01 13:15:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-05 10:36:14 +01:00
|
|
|
|
if ($get_Acknowledged === true) {
|
2023-01-25 11:25:20 +01:00
|
|
|
|
$event_id = (int) get_parameter('event_id', 0);
|
|
|
|
|
$server_id = (int) get_parameter('server_id', 0);
|
|
|
|
|
|
|
|
|
|
$return = '';
|
|
|
|
|
try {
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $server_id > 0
|
|
|
|
|
) {
|
|
|
|
|
$node = new Node($server_id);
|
|
|
|
|
$node->connect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo events_page_general_acknowledged($event_id);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
// Unexistent agent.
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $server_id > 0
|
|
|
|
|
) {
|
|
|
|
|
$node->disconnect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$return = false;
|
|
|
|
|
} finally {
|
|
|
|
|
if (is_metaconsole() === true
|
|
|
|
|
&& $server_id > 0
|
|
|
|
|
) {
|
|
|
|
|
$node->disconnect();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $return;
|
2023-01-05 10:36:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-15 13:06:10 +02:00
|
|
|
|
if ($change_owner === true) {
|
|
|
|
|
$new_owner = get_parameter('new_owner', '');
|
|
|
|
|
$event_id = (int) get_parameter('event_id', 0);
|
|
|
|
|
$server_id = (int) get_parameter('server_id', 0);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
2022-06-15 13:06:10 +02:00
|
|
|
|
if ($new_owner === -1) {
|
2019-01-30 16:18:44 +01:00
|
|
|
|
$new_owner = '';
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-14 18:47:09 +02:00
|
|
|
|
try {
|
|
|
|
|
if (is_metaconsole() === true
|
2022-06-15 13:06:10 +02:00
|
|
|
|
&& $server_id > 0
|
2022-06-14 18:47:09 +02:00
|
|
|
|
) {
|
2022-06-15 13:06:10 +02:00
|
|
|
|
$node = new Node($server_id);
|
2022-03-24 18:52:06 +01:00
|
|
|
|
$node->connect();
|
2022-06-14 18:47:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$return = events_change_owner(
|
|
|
|
|
$event_id,
|
|
|
|
|
$new_owner,
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
// Unexistent agent.
|
|
|
|
|
if (is_metaconsole() === true
|
2022-06-15 13:06:10 +02:00
|
|
|
|
&& $server_id > 0
|
2022-06-14 18:47:09 +02:00
|
|
|
|
) {
|
2022-03-24 18:52:06 +01:00
|
|
|
|
$node->disconnect();
|
2022-06-14 18:47:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$return = false;
|
|
|
|
|
} finally {
|
|
|
|
|
if (is_metaconsole() === true
|
2022-06-15 13:06:10 +02:00
|
|
|
|
&& $server_id > 0
|
2022-06-14 18:47:09 +02:00
|
|
|
|
) {
|
2022-03-24 18:52:06 +01:00
|
|
|
|
$node->disconnect();
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
2022-06-14 18:47:09 +02:00
|
|
|
|
if ($return === true) {
|
2019-01-30 16:18:44 +01:00
|
|
|
|
echo 'owner_ok';
|
|
|
|
|
} else {
|
|
|
|
|
echo 'owner_error';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
2012-10-01 13:15:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-17 17:02:33 +02:00
|
|
|
|
|
|
|
|
|
// Generate a modal window with extended information of given event.
|
2013-02-20 Miguel de Dios <miguel.dedios@artica.es>
* godmode/servers/recon_script.php, godmode/servers/plugin.php,
godmode/snmpconsole/snmp_filters.php,
godmode/massive/massive_delete_alerts.php,
godmode/massive/massive_enable_disable_alerts.php,
godmode/massive/massive_edit_agents.php,
godmode/massive/massive_delete_modules.php,
godmode/massive/massive_add_action_alerts.php,
godmode/massive/massive_delete_action_alerts.php: improved the code
style.
* include/ajax/events.php, include/functions_events.php,
operation/agentes/custom_fields.php: fixed the show admin custom
fields for user without permisitions.
Fixes: #3605278
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7683 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-02-20 13:07:00 +01:00
|
|
|
|
if ($get_extended_event) {
|
2019-01-30 16:18:44 +01:00
|
|
|
|
global $config;
|
|
|
|
|
|
2022-03-25 14:05:38 +01:00
|
|
|
|
$event = io_safe_output(get_parameter('event', false));
|
2019-06-20 21:11:56 +02:00
|
|
|
|
$filter = get_parameter('filter', false);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
2019-06-17 17:02:33 +02:00
|
|
|
|
if ($event === false) {
|
|
|
|
|
return;
|
2019-01-30 16:18:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-17 17:02:33 +02:00
|
|
|
|
$event_id = $event['id_evento'];
|
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
|
$readonly = false;
|
2022-06-15 13:06:10 +02:00
|
|
|
|
if (enterprise_hook('enterprise_acl', [$config['id_user'], 'eventos', 'execute_event_responses']) === false) {
|
2019-06-17 17:02:33 +02:00
|
|
|
|
$readonly = true;
|
2019-01-30 16:18:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-08 17:30:47 +01:00
|
|
|
|
// Clean url from events and store in array.
|
2019-01-30 16:18:44 +01:00
|
|
|
|
$event['clean_tags'] = events_clean_tags($event['tags']);
|
|
|
|
|
|
2019-02-08 17:30:47 +01:00
|
|
|
|
// If the event is not found, we abort.
|
2022-06-15 13:06:10 +02:00
|
|
|
|
if (empty($event) === true) {
|
2019-01-30 16:18:44 +01:00
|
|
|
|
ui_print_error_message('Event not found');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dialog_page = get_parameter('dialog_page', 'general');
|
2019-06-14 19:23:04 +02:00
|
|
|
|
$filter = get_parameter('filter', []);
|
2019-07-10 13:04:06 +02:00
|
|
|
|
$similar_ids = get_parameter('similar_ids', $event_id);
|
2019-06-17 17:02:33 +02:00
|
|
|
|
$group_rep = $filter['group_rep'];
|
2022-10-27 09:07:04 +02:00
|
|
|
|
$event_rep = (empty($group_rep) === true) ? EVENT_GROUP_REP_EVENTS : $group_rep;
|
2022-06-14 18:47:09 +02:00
|
|
|
|
$timestamp_first = $event['timestamp_first'];
|
|
|
|
|
$timestamp_last = $event['timestamp_last'];
|
2019-06-17 17:02:33 +02:00
|
|
|
|
$server_id = $event['server_id'];
|
2022-06-15 13:06:10 +02:00
|
|
|
|
if (empty($server_id) === true && empty($event['server_name']) === false && is_metaconsole() === true) {
|
2021-12-07 12:17:26 +01:00
|
|
|
|
$server_id = metaconsole_get_id_server($event['server_name']);
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-17 17:02:33 +02:00
|
|
|
|
$comments = $event['comments'];
|
|
|
|
|
|
2019-07-10 13:04:06 +02:00
|
|
|
|
$event['similar_ids'] = $similar_ids;
|
2023-02-15 19:38:57 +01:00
|
|
|
|
$event['group_rep'] = $group_rep;
|
2019-07-10 13:04:06 +02:00
|
|
|
|
|
2022-06-15 13:06:10 +02:00
|
|
|
|
if (isset($comments) === false) {
|
2019-06-17 17:02:33 +02:00
|
|
|
|
$comments = $event['user_comment'];
|
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
2019-02-08 17:30:47 +01:00
|
|
|
|
// Check ACLs.
|
2019-06-19 16:52:14 +02:00
|
|
|
|
$access = false;
|
2019-01-30 16:18:44 +01:00
|
|
|
|
if (is_user_admin($config['id_user'])) {
|
2019-02-08 17:30:47 +01:00
|
|
|
|
// Do nothing if you're admin, you get full access.
|
2019-06-19 16:52:14 +02:00
|
|
|
|
$access = true;
|
2019-01-30 16:18:44 +01:00
|
|
|
|
} else if ($config['id_user'] == $event['owner_user']) {
|
2019-02-08 17:30:47 +01:00
|
|
|
|
// Do nothing if you're the owner user, you get access.
|
2019-06-19 16:52:14 +02:00
|
|
|
|
$access = true;
|
2019-01-30 16:18:44 +01:00
|
|
|
|
} else if ($event['id_grupo'] == 0) {
|
2019-02-08 17:30:47 +01:00
|
|
|
|
// If the event has access to all groups, you get access.
|
2019-06-19 16:52:14 +02:00
|
|
|
|
$access = true;
|
2019-01-30 16:18:44 +01:00
|
|
|
|
} else {
|
2019-02-08 17:30:47 +01:00
|
|
|
|
// Get your groups.
|
2019-01-30 16:18:44 +01:00
|
|
|
|
$groups = users_get_groups($config['id_user'], 'ER');
|
|
|
|
|
|
|
|
|
|
if (in_array($event['id_grupo'], array_keys($groups))) {
|
2019-02-08 17:30:47 +01:00
|
|
|
|
// If event group is among the groups of the user, you get access.
|
2019-06-19 16:52:14 +02:00
|
|
|
|
$access = true;
|
|
|
|
|
} else if ($event['id_agente']
|
|
|
|
|
&& agents_check_access_agent($event['id_agente'], 'ER')
|
|
|
|
|
) {
|
|
|
|
|
// Secondary group, indirect access.
|
|
|
|
|
$access = true;
|
2019-01-30 16:18:44 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-19 16:52:14 +02:00
|
|
|
|
if (!$access) {
|
|
|
|
|
// If all the access types fail, abort.
|
|
|
|
|
echo 'Access denied';
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-08 17:30:47 +01:00
|
|
|
|
// Print group_rep in a hidden field to recover it from javascript.
|
2019-01-30 16:18:44 +01:00
|
|
|
|
html_print_input_hidden('group_rep', (int) $group_rep);
|
2022-03-24 18:52:06 +01:00
|
|
|
|
if ($node_id > 0) {
|
|
|
|
|
html_print_input_hidden('node_id', (int) $node_id);
|
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
|
|
if ($event === false) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-08 17:30:47 +01:00
|
|
|
|
// Tabs.
|
2021-10-15 09:36:22 +02:00
|
|
|
|
$tabs = "<ul class='event_detail_tab_menu'>";
|
2021-03-11 15:40:23 +01:00
|
|
|
|
$tabs .= "<li><a href='#extended_event_general_page' id='link_general'>".html_print_image(
|
2023-02-09 16:13:30 +01:00
|
|
|
|
'images/event.svg',
|
2021-03-11 15:40:23 +01:00
|
|
|
|
true,
|
2023-02-09 16:13:30 +01:00
|
|
|
|
['class' => 'invert_filter main_menu_icon']
|
2021-03-11 15:40:23 +01:00
|
|
|
|
).'<span>'.__('General').'</span></a></li>';
|
2019-02-11 19:46:46 +01:00
|
|
|
|
if (events_has_extended_info($event['id_evento']) === true) {
|
2021-03-11 15:40:23 +01:00
|
|
|
|
$tabs .= "<li><a href='#extended_event_related_page' id='link_related'>".html_print_image(
|
2023-02-09 16:13:30 +01:00
|
|
|
|
'images/details.svg',
|
2021-03-11 15:40:23 +01:00
|
|
|
|
true,
|
2023-02-09 16:13:30 +01:00
|
|
|
|
['class' => 'invert_filter main_menu_icon']
|
2021-03-11 15:40:23 +01:00
|
|
|
|
).'<span>'.__('Related').'</span></a></li>';
|
2019-02-08 19:07:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-11 15:40:23 +01:00
|
|
|
|
$tabs .= "<li><a href='#extended_event_details_page' id='link_details'>".html_print_image(
|
2023-02-09 16:13:30 +01:00
|
|
|
|
'images/details.svg',
|
2021-03-11 15:40:23 +01:00
|
|
|
|
true,
|
2023-02-09 16:13:30 +01:00
|
|
|
|
['class' => 'invert_filter main_menu_icon']
|
2021-03-11 15:40:23 +01:00
|
|
|
|
).'<span>'.__('Details').'</span></a></li>';
|
|
|
|
|
$tabs .= "<li><a href='#extended_event_custom_fields_page' id='link_custom_fields'>".html_print_image(
|
2023-02-09 16:13:30 +01:00
|
|
|
|
'images/agent-fields.svg',
|
2021-03-11 15:40:23 +01:00
|
|
|
|
true,
|
2023-02-09 16:13:30 +01:00
|
|
|
|
['class' => 'invert_filter main_menu_icon']
|
2021-03-11 15:40:23 +01:00
|
|
|
|
).'<span>'.__('Agent fields').'</span></a></li>';
|
|
|
|
|
$tabs .= "<li><a href='#extended_event_comments_page' id='link_comments'>".html_print_image(
|
2023-02-09 16:13:30 +01:00
|
|
|
|
'images/edit.svg',
|
2021-03-11 15:40:23 +01:00
|
|
|
|
true,
|
2023-02-09 16:13:30 +01:00
|
|
|
|
['class' => 'invert_filter main_menu_icon']
|
2021-03-11 15:40:23 +01:00
|
|
|
|
).'<span>'.__('Comments').'</span></a></li>';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
|
|
if (!$readonly
|
2019-02-08 17:30:47 +01:00
|
|
|
|
&& ((tags_checks_event_acl(
|
|
|
|
|
$config['id_user'],
|
|
|
|
|
$event['id_grupo'],
|
|
|
|
|
'EM',
|
|
|
|
|
$event['clean_tags'],
|
2022-06-14 18:47:09 +02:00
|
|
|
|
[]
|
2019-02-08 17:30:47 +01:00
|
|
|
|
)) || (tags_checks_event_acl(
|
|
|
|
|
$config['id_user'],
|
|
|
|
|
$event['id_grupo'],
|
|
|
|
|
'EW',
|
|
|
|
|
$event['clean_tags'],
|
2022-06-14 18:47:09 +02:00
|
|
|
|
[]
|
2021-03-11 16:11:06 +01:00
|
|
|
|
)) || (tags_checks_event_acl(
|
|
|
|
|
$config['id_user'],
|
|
|
|
|
$event['id_grupo'],
|
|
|
|
|
'ER',
|
|
|
|
|
$event['clean_tags'],
|
2022-06-14 18:47:09 +02:00
|
|
|
|
[]
|
2019-02-08 17:30:47 +01:00
|
|
|
|
)))
|
2019-01-30 16:18:44 +01:00
|
|
|
|
) {
|
2021-03-11 15:40:23 +01:00
|
|
|
|
$tabs .= "<li><a href='#extended_event_responses_page' id='link_responses'>".html_print_image(
|
2023-02-09 16:13:30 +01:00
|
|
|
|
'images/responses.svg',
|
2021-03-11 15:40:23 +01:00
|
|
|
|
true,
|
2023-02-09 16:13:30 +01:00
|
|
|
|
['class' => 'invert_filter main_menu_icon']
|
2021-03-11 15:40:23 +01:00
|
|
|
|
).'<span>'.__('Responses').'</span></a></li>';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-15 09:36:22 +02:00
|
|
|
|
if (empty($event['custom_data']) === false) {
|
2021-03-11 15:40:23 +01:00
|
|
|
|
$tabs .= "<li><a href='#extended_event_custom_data_page' id='link_custom_data'>".html_print_image(
|
2023-02-09 16:13:30 +01:00
|
|
|
|
'images/custom-input@svg.svg',
|
2021-03-11 15:40:23 +01:00
|
|
|
|
true,
|
2023-02-09 16:13:30 +01:00
|
|
|
|
['class' => 'invert_filter main_menu_icon']
|
2021-03-11 15:40:23 +01:00
|
|
|
|
).'<span>'.__('Custom data').'</span></a></li>';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$tabs .= '</ul>';
|
|
|
|
|
|
2019-02-08 17:30:47 +01:00
|
|
|
|
// Get criticity image.
|
2019-01-30 16:18:44 +01:00
|
|
|
|
switch ($event['criticity']) {
|
|
|
|
|
default:
|
|
|
|
|
case 0:
|
2019-05-27 15:49:10 +02:00
|
|
|
|
$img_sev = 'images/status_sets/default/severity_maintenance_rounded.png';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
break;
|
|
|
|
|
case 1:
|
2019-05-27 15:49:10 +02:00
|
|
|
|
$img_sev = 'images/status_sets/default/severity_informational_rounded.png';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 2:
|
2019-05-27 15:49:10 +02:00
|
|
|
|
$img_sev = 'images/status_sets/default/severity_normal_rounded.png';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 3:
|
2019-05-27 15:49:10 +02:00
|
|
|
|
$img_sev = 'images/status_sets/default/severity_warning_rounded.png';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 4:
|
2019-05-27 15:49:10 +02:00
|
|
|
|
$img_sev = 'images/status_sets/default/severity_critical_rounded.png';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 5:
|
2019-05-27 15:49:10 +02:00
|
|
|
|
$img_sev = 'images/status_sets/default/severity_minor_rounded.png';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 6:
|
2019-05-27 15:49:10 +02:00
|
|
|
|
$img_sev = 'images/status_sets/default/severity_major_rounded.png';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$readonly
|
2019-02-08 17:30:47 +01:00
|
|
|
|
&& ((tags_checks_event_acl(
|
|
|
|
|
$config['id_user'],
|
|
|
|
|
$event['id_grupo'],
|
|
|
|
|
'EM',
|
|
|
|
|
$event['clean_tags'],
|
2022-06-14 18:47:09 +02:00
|
|
|
|
[]
|
2019-02-08 17:30:47 +01:00
|
|
|
|
)) || (tags_checks_event_acl(
|
|
|
|
|
$config['id_user'],
|
|
|
|
|
$event['id_grupo'],
|
|
|
|
|
'EW',
|
|
|
|
|
$event['clean_tags'],
|
2022-06-14 18:47:09 +02:00
|
|
|
|
[]
|
2021-03-11 16:11:06 +01:00
|
|
|
|
)) || (tags_checks_event_acl(
|
|
|
|
|
$config['id_user'],
|
|
|
|
|
$event['id_grupo'],
|
|
|
|
|
'ER',
|
|
|
|
|
$event['clean_tags'],
|
2022-06-14 18:47:09 +02:00
|
|
|
|
[]
|
2019-02-08 17:30:47 +01:00
|
|
|
|
)))
|
2019-01-30 16:18:44 +01:00
|
|
|
|
) {
|
2022-06-15 13:06:10 +02:00
|
|
|
|
$responses = events_page_responses($event, $server_id);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
} else {
|
|
|
|
|
$responses = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$console_url = '';
|
2022-06-15 13:06:10 +02:00
|
|
|
|
$details = events_page_details($event, $server_id);
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
2022-06-14 18:47:09 +02:00
|
|
|
|
$related = '';
|
2019-02-11 19:46:46 +01:00
|
|
|
|
if (events_has_extended_info($event['id_evento']) === true) {
|
2022-06-15 13:06:10 +02:00
|
|
|
|
$related = events_page_related(
|
|
|
|
|
$event,
|
|
|
|
|
$server
|
|
|
|
|
);
|
2019-02-08 19:07:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-02 11:25:26 +01:00
|
|
|
|
$connected = true;
|
2022-06-15 13:06:10 +02:00
|
|
|
|
if (is_metaconsole() === true && empty($server_id) === false) {
|
|
|
|
|
$server = metaconsole_get_connection_by_id($server_id);
|
2021-02-02 11:25:26 +01:00
|
|
|
|
if (metaconsole_connect($server) === NOERR) {
|
|
|
|
|
$connected = true;
|
|
|
|
|
} else {
|
|
|
|
|
$connected = false;
|
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-02 11:25:26 +01:00
|
|
|
|
if ($connected === true) {
|
|
|
|
|
$custom_fields = events_page_custom_fields($event);
|
|
|
|
|
$custom_data = events_page_custom_data($event);
|
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
2022-06-15 13:06:10 +02:00
|
|
|
|
if (is_metaconsole() === true && empty($server_id) === false) {
|
2019-01-30 16:18:44 +01:00
|
|
|
|
metaconsole_restore_db();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$general = events_page_general($event);
|
|
|
|
|
|
2019-06-20 21:11:56 +02:00
|
|
|
|
$comments = '<div id="extended_event_comments_page" class="extended_event_pages"></div>';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
2022-06-15 13:06:10 +02:00
|
|
|
|
$notifications = '<div id="notification_comment_error" class="invisible_events">';
|
|
|
|
|
$notifications .= ui_print_error_message(
|
|
|
|
|
__('Error adding comment'),
|
|
|
|
|
'',
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
$notifications .= '</div>';
|
|
|
|
|
$notifications .= '<div id="notification_comment_success" class="invisible_events">';
|
|
|
|
|
$notifications .= ui_print_success_message(
|
|
|
|
|
__('Comment added successfully'),
|
|
|
|
|
'',
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
$notifications .= '</div>';
|
|
|
|
|
$notifications .= '<div id="notification_status_error" class="invisible_events">';
|
|
|
|
|
$notifications .= ui_print_error_message(
|
|
|
|
|
__('Error changing event status'),
|
|
|
|
|
'',
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
$notifications .= '</div>';
|
|
|
|
|
$notifications .= '<div id="notification_status_success" class="invisible_events">';
|
|
|
|
|
$notifications .= ui_print_success_message(
|
|
|
|
|
__('Event status changed successfully'),
|
|
|
|
|
'',
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
$notifications .= '</div>';
|
|
|
|
|
$notifications .= '<div id="notification_owner_error" class="invisible_events">';
|
|
|
|
|
$notifications .= ui_print_error_message(
|
|
|
|
|
__('Error changing event owner'),
|
|
|
|
|
'',
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
$notifications .= '</div>';
|
|
|
|
|
$notifications .= '<div id="notification_owner_success" class="invisible_events">';
|
|
|
|
|
$notifications .= ui_print_success_message(
|
|
|
|
|
__('Event owner changed successfully'),
|
|
|
|
|
'',
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
$notifications .= '</div>';
|
|
|
|
|
$notifications .= '<div id="notification_delete_error" class="invisible_events">';
|
|
|
|
|
$notifications .= ui_print_error_message(
|
|
|
|
|
__('Error deleting event'),
|
|
|
|
|
'',
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
$notifications .= '</div>';
|
2022-03-22 18:02:53 +01:00
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
2022-03-14 15:29:40 +01:00
|
|
|
|
$loading = '<div id="response_loading" class="invisible_events">'.html_print_image('images/spinner.gif', true).'</div>';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
2019-06-20 21:11:56 +02:00
|
|
|
|
$i = 0;
|
|
|
|
|
$tab['general'] = $i++;
|
|
|
|
|
$tab['details'] = $i++;
|
|
|
|
|
if (!empty($related)) {
|
|
|
|
|
$tab['related'] = $i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$tab['custom_fields'] = $i++;
|
|
|
|
|
$tab['comments'] = $i++;
|
|
|
|
|
$tab['responses'] = $i++;
|
|
|
|
|
$tab['custom_data'] = $i++;
|
|
|
|
|
|
2019-04-15 13:11:58 +02:00
|
|
|
|
$out = '<div id="tabs">'.$tabs.$notifications.$loading.$general.$details.$related.$custom_fields.$comments.$responses.$custom_data.html_print_input_hidden('id_event', $event['id_evento']).'</div>';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
|
|
$js = '<script>
|
2012-10-01 13:15:31 +02:00
|
|
|
|
$(function() {
|
|
|
|
|
$tabs = $( "#tabs" ).tabs({
|
|
|
|
|
});
|
|
|
|
|
';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
2019-02-08 17:30:47 +01:00
|
|
|
|
// Load the required tab.
|
2019-01-30 16:18:44 +01:00
|
|
|
|
switch ($dialog_page) {
|
|
|
|
|
case 'general':
|
2019-06-20 21:11:56 +02:00
|
|
|
|
$js .= '$tabs.tabs( "option", "active", '.$tab['general'].');';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'details':
|
2019-06-20 21:11:56 +02:00
|
|
|
|
$js .= '$tabs.tabs( "option", "active", '.$tab['details'].');';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
break;
|
|
|
|
|
|
2019-02-08 19:07:49 +01:00
|
|
|
|
case 'related':
|
2019-06-20 21:11:56 +02:00
|
|
|
|
$js .= '$tabs.tabs( "option", "active", '.$tab['related'].');';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
break;
|
|
|
|
|
|
2019-02-08 19:07:49 +01:00
|
|
|
|
case 'custom_fields':
|
2019-06-20 21:11:56 +02:00
|
|
|
|
$js .= '$tabs.tabs( "option", "active", '.$tab['custom_fields'].');';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
break;
|
|
|
|
|
|
2019-02-08 19:07:49 +01:00
|
|
|
|
case 'comments':
|
2019-06-20 21:11:56 +02:00
|
|
|
|
$js .= '$tabs.tabs( "option", "active", '.$tab['comments'].');';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
break;
|
|
|
|
|
|
2019-02-08 19:07:49 +01:00
|
|
|
|
case 'responses':
|
2019-06-20 21:11:56 +02:00
|
|
|
|
$js .= '$tabs.tabs( "option", "active", '.$tab['responses'].');';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
break;
|
2019-02-08 17:30:47 +01:00
|
|
|
|
|
2019-02-08 19:07:49 +01:00
|
|
|
|
case 'custom_data':
|
2019-06-20 21:11:56 +02:00
|
|
|
|
$js .= '$tabs.tabs( "option", "active", '.$tab['custom_data'].');';
|
2019-02-08 19:07:49 +01:00
|
|
|
|
break;
|
|
|
|
|
|
2019-02-08 17:30:47 +01:00
|
|
|
|
default:
|
|
|
|
|
// Ignore.
|
|
|
|
|
break;
|
2019-01-30 16:18:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-08 19:07:49 +01:00
|
|
|
|
$js .= '});';
|
|
|
|
|
|
2019-06-20 21:11:56 +02:00
|
|
|
|
$js .= '
|
|
|
|
|
$("#link_comments").click(function (){
|
|
|
|
|
$.post ({
|
|
|
|
|
url : "ajax.php",
|
|
|
|
|
data : {
|
|
|
|
|
page: "include/ajax/events",
|
|
|
|
|
get_comments: 1,
|
2022-07-22 10:13:57 +02:00
|
|
|
|
event: '.json_encode($event).',
|
|
|
|
|
event_rep: '.$event_rep.'
|
2019-06-20 21:11:56 +02:00
|
|
|
|
},
|
|
|
|
|
dataType : "html",
|
|
|
|
|
success: function (data) {
|
|
|
|
|
$("#extended_event_comments_page").empty();
|
|
|
|
|
$("#extended_event_comments_page").html(data);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});';
|
|
|
|
|
|
2019-02-11 19:46:46 +01:00
|
|
|
|
if (events_has_extended_info($event['id_evento']) === true) {
|
2019-02-08 19:07:49 +01:00
|
|
|
|
$js .= '
|
|
|
|
|
$("#link_related").click(function (){
|
|
|
|
|
$.post ({
|
|
|
|
|
url : "ajax.php",
|
|
|
|
|
data : {
|
|
|
|
|
page: "include/ajax/events_extended",
|
|
|
|
|
get_extended_info: 1,
|
|
|
|
|
id_event: '.$event['id_evento'].'
|
|
|
|
|
},
|
|
|
|
|
dataType : "html",
|
|
|
|
|
success: function (data) {
|
|
|
|
|
$("#related_data").html(data);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$js .= '</script>';
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
|
|
echo $out.$js;
|
2012-10-01 13:15:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 11:52:09 +01:00
|
|
|
|
if ($table_events) {
|
2019-01-30 16:18:44 +01:00
|
|
|
|
include_once 'include/functions_events.php';
|
|
|
|
|
include_once 'include/functions_graph.php';
|
|
|
|
|
|
2023-01-10 14:57:40 +01:00
|
|
|
|
$id_agente = (int) get_parameter('id_agente');
|
|
|
|
|
$all_events_24h = (int) get_parameter('all_events_24h');
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
2019-02-08 17:30:47 +01:00
|
|
|
|
// Fix: for tag functionality groups have to be all user_groups
|
|
|
|
|
// (propagate ACL funct!).
|
2019-01-30 16:18:44 +01:00
|
|
|
|
$groups = users_get_groups($config['id_user']);
|
|
|
|
|
|
|
|
|
|
$tags_condition = tags_get_acl_tags(
|
|
|
|
|
$config['id_user'],
|
|
|
|
|
array_keys($groups),
|
|
|
|
|
'ER',
|
|
|
|
|
'event_condition',
|
|
|
|
|
'AND'
|
|
|
|
|
);
|
2023-01-10 14:57:40 +01:00
|
|
|
|
|
|
|
|
|
$tableEvents24h = new stdClass();
|
|
|
|
|
$tableEvents24h->class = 'filter_table';
|
2023-02-24 13:37:47 +01:00
|
|
|
|
$tableEvents24h->styleTable = 'border: 0;padding: 0;margin: 0 0 10px;';
|
2023-01-10 14:57:40 +01:00
|
|
|
|
$tableEvents24h->width = '100%';
|
|
|
|
|
$tableEvents24h->data = [];
|
|
|
|
|
|
2023-02-24 13:37:47 +01:00
|
|
|
|
$tableEvents24h->data[0] = html_print_div(
|
2023-01-10 14:57:40 +01:00
|
|
|
|
[
|
2023-02-24 13:37:47 +01:00
|
|
|
|
'class' => 'flex-row-center',
|
|
|
|
|
'content' => '<span class="font_14px mrgn_right_10px">'.__('Show all Events 24h').'</span>'.html_print_switch(
|
|
|
|
|
[
|
|
|
|
|
'name' => 'all_events_24h',
|
|
|
|
|
'value' => $all_events_24h,
|
|
|
|
|
'id' => 'checkbox-all_events_24h',
|
|
|
|
|
]
|
|
|
|
|
),
|
2023-01-10 14:57:40 +01:00
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
html_print_table($tableEvents24h);
|
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
|
$date_subtract_day = (time() - (24 * 60 * 60));
|
|
|
|
|
|
2023-01-10 14:57:40 +01:00
|
|
|
|
if ($all_events_24h !== 0) {
|
2019-01-30 16:18:44 +01:00
|
|
|
|
events_print_event_table(
|
2019-02-08 17:30:47 +01:00
|
|
|
|
'utimestamp > '.$date_subtract_day,
|
2019-01-30 16:18:44 +01:00
|
|
|
|
200,
|
|
|
|
|
'100%',
|
|
|
|
|
false,
|
|
|
|
|
$id_agente,
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
events_print_event_table(
|
2019-02-08 17:30:47 +01:00
|
|
|
|
'estado <> 1 '.$tags_condition,
|
2019-01-30 16:18:44 +01:00
|
|
|
|
200,
|
|
|
|
|
'100%',
|
|
|
|
|
false,
|
|
|
|
|
$id_agente,
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
}
|
2014-12-03 11:52:09 +01:00
|
|
|
|
}
|
2016-07-22 16:08:45 +02:00
|
|
|
|
|
2018-10-24 16:36:44 +02:00
|
|
|
|
if ($total_events) {
|
2019-01-30 16:18:44 +01:00
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
|
|
$sql_count_event = 'SELECT SQL_NO_CACHE COUNT(id_evento) FROM tevento ';
|
|
|
|
|
if ($config['event_view_hr']) {
|
|
|
|
|
$sql_count_event .= 'WHERE utimestamp > (UNIX_TIMESTAMP(NOW()) - '.($config['event_view_hr'] * SECONDS_1HOUR).')';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$system_events = db_get_value_sql($sql_count_event);
|
|
|
|
|
echo $system_events;
|
|
|
|
|
return;
|
2018-10-24 16:36:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($total_event_graph) {
|
2019-01-30 16:18:44 +01:00
|
|
|
|
global $config;
|
2018-10-24 16:36:44 +02:00
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
|
include_once $config['homedir'].'/include/functions_graph.php';
|
2018-10-24 16:36:44 +02:00
|
|
|
|
|
2022-12-13 09:10:13 +01:00
|
|
|
|
$out = '<div style="flex: 0 0 300px; width:99%; height:100%;">';
|
|
|
|
|
$out .= grafico_eventos_total('', 0, 0, false, true);
|
|
|
|
|
$out .= '<div>';
|
|
|
|
|
echo $out;
|
2019-01-30 16:18:44 +01:00
|
|
|
|
return;
|
2018-10-24 16:36:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($graphic_event_group) {
|
2019-01-30 16:18:44 +01:00
|
|
|
|
global $config;
|
2018-10-24 16:36:44 +02:00
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
|
include_once $config['homedir'].'/include/functions_graph.php';
|
2018-10-24 16:36:44 +02:00
|
|
|
|
|
2022-12-13 09:10:13 +01:00
|
|
|
|
$out = '<div style="flex: 0 0 300px; width:99%; height:100%;">';
|
|
|
|
|
$out .= grafico_eventos_grupo(0, 0, '', false, true);
|
|
|
|
|
$out .= '<div>';
|
|
|
|
|
echo $out;
|
2019-01-30 16:18:44 +01:00
|
|
|
|
return;
|
2018-10-24 16:36:44 +02:00
|
|
|
|
}
|
2019-02-27 10:59:44 +01:00
|
|
|
|
|
|
|
|
|
if ($get_table_response_command) {
|
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
|
|
$response_id = get_parameter('event_response_id');
|
|
|
|
|
$params_string = db_get_value(
|
|
|
|
|
'params',
|
|
|
|
|
'tevent_response',
|
|
|
|
|
'id',
|
|
|
|
|
$response_id
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$params = explode(',', $params_string);
|
|
|
|
|
|
|
|
|
|
$table = new stdClass;
|
|
|
|
|
$table->id = 'events_responses_table_command';
|
|
|
|
|
$table->width = '90%';
|
|
|
|
|
$table->styleTable = 'text-align:center; margin: 0 auto;';
|
|
|
|
|
|
|
|
|
|
$table->style = [];
|
|
|
|
|
$table->style[0] = 'text-align:center;';
|
|
|
|
|
$table->style[1] = 'text-align:center;';
|
|
|
|
|
|
|
|
|
|
$table->head = [];
|
2019-03-07 09:05:38 +01:00
|
|
|
|
$table->head[0] = __('Parameters');
|
2019-02-27 10:59:44 +01:00
|
|
|
|
$table->head[0] .= ui_print_help_tip(
|
|
|
|
|
__('These commands will apply to all selected events'),
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
$table->head[1] = __('Value');
|
|
|
|
|
|
|
|
|
|
if (isset($params) === true
|
|
|
|
|
&& is_array($params) === true
|
|
|
|
|
) {
|
|
|
|
|
foreach ($params as $key => $value) {
|
|
|
|
|
$table->data[$key][0] = $value;
|
|
|
|
|
$table->data[$key][1] = html_print_input_text(
|
|
|
|
|
$value.'-'.$key,
|
|
|
|
|
'',
|
|
|
|
|
'',
|
|
|
|
|
50,
|
|
|
|
|
255,
|
|
|
|
|
true,
|
|
|
|
|
false,
|
|
|
|
|
false,
|
|
|
|
|
'',
|
|
|
|
|
'response_command_input'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo '<form id="form_response_command">';
|
|
|
|
|
echo html_print_table($table, true);
|
|
|
|
|
echo '</form>';
|
|
|
|
|
echo html_print_submit_button(
|
|
|
|
|
__('Execute'),
|
|
|
|
|
'enter_command',
|
|
|
|
|
false,
|
2021-03-11 15:40:23 +01:00
|
|
|
|
'class="sub next float-right mrgn_top_15px mrgn_right_25px"',
|
2019-02-27 10:59:44 +01:00
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-07-15 15:31:01 +02:00
|
|
|
|
|
2022-06-23 18:06:25 +02:00
|
|
|
|
if ($process_buffers === true) {
|
|
|
|
|
$buffers = get_parameter('buffers', '');
|
|
|
|
|
|
|
|
|
|
$buffers = json_decode(io_safe_output($buffers), true);
|
|
|
|
|
|
|
|
|
|
$alert = false;
|
|
|
|
|
$content = '<ul>';
|
|
|
|
|
foreach ($buffers['data'] as $node => $data) {
|
|
|
|
|
$content .= '<li>';
|
|
|
|
|
$content .= '<span><b>';
|
|
|
|
|
$content .= __('Events').': ';
|
|
|
|
|
$content .= $node;
|
|
|
|
|
$content .= '</b></span>';
|
|
|
|
|
|
|
|
|
|
$class_total = 'info';
|
|
|
|
|
$str_total = '';
|
|
|
|
|
if ($buffers['settings']['total'] == $data) {
|
|
|
|
|
$alert = true;
|
|
|
|
|
$class_total .= ' danger';
|
|
|
|
|
$str_total = html_print_image(
|
|
|
|
|
'images/error_red.png',
|
|
|
|
|
true,
|
|
|
|
|
[
|
|
|
|
|
'title' => __('Total number of events in this node reached'),
|
|
|
|
|
'class' => 'forced-title',
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isset($buffers['error'][$node]) === true) {
|
|
|
|
|
$alert = true;
|
|
|
|
|
$class_total .= ' danger';
|
|
|
|
|
$str_total = html_print_image(
|
|
|
|
|
'images/error_red.png',
|
|
|
|
|
true,
|
|
|
|
|
[
|
|
|
|
|
'title' => $buffers['error'][$node],
|
|
|
|
|
'class' => 'forced-title',
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$content .= '<span class="'.$class_total.'">';
|
|
|
|
|
$content .= $data;
|
|
|
|
|
if (empty($str_total) === false) {
|
|
|
|
|
$content .= '<span class="text">';
|
|
|
|
|
$content .= ' '.$str_total;
|
|
|
|
|
$content .= '</span>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$content .= '</span>';
|
|
|
|
|
|
|
|
|
|
$content .= '</li>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$content .= '</ul>';
|
|
|
|
|
|
|
|
|
|
$title = __('Total Events per node').': (';
|
|
|
|
|
$title .= $buffers['settings']['total'].')';
|
|
|
|
|
if ($alert === true) {
|
|
|
|
|
$title .= html_print_image(
|
|
|
|
|
'images/error_red.png',
|
|
|
|
|
true,
|
|
|
|
|
[
|
|
|
|
|
'title' => __('Error'),
|
|
|
|
|
'class' => 'forced-title',
|
|
|
|
|
'style' => 'margin-top: -2px;',
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$output = ui_toggle(
|
|
|
|
|
$content,
|
|
|
|
|
$title,
|
|
|
|
|
'',
|
|
|
|
|
'',
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
'white_box white_box_opened',
|
|
|
|
|
'no-border flex-row'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
echo $output;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-30 17:17:05 +02:00
|
|
|
|
if ($drawConsoleSound === true) {
|
2022-07-01 13:08:39 +02:00
|
|
|
|
echo ui_require_css_file('wizard', 'include/styles/', true);
|
|
|
|
|
echo ui_require_css_file('discovery', 'include/styles/', true);
|
|
|
|
|
echo ui_require_css_file('sound_events', 'include/styles/', true);
|
|
|
|
|
$output = '<div id="tabs-sound-modal">';
|
|
|
|
|
// Header tabs.
|
|
|
|
|
$output .= '<ul class="tabs-sound-modal-options">';
|
|
|
|
|
$output .= '<li>';
|
|
|
|
|
$output .= '<a href="#tabs-sound-modal-1">';
|
|
|
|
|
$output .= html_print_image(
|
|
|
|
|
'images/gear.png',
|
|
|
|
|
true,
|
|
|
|
|
[
|
|
|
|
|
'title' => __('Options'),
|
|
|
|
|
'class' => 'invert_filter',
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
$output .= '</a>';
|
|
|
|
|
$output .= '</li>';
|
|
|
|
|
$output .= '<li>';
|
|
|
|
|
$output .= '<a href="#tabs-sound-modal-2">';
|
|
|
|
|
$output .= html_print_image(
|
|
|
|
|
'images/list.png',
|
|
|
|
|
true,
|
|
|
|
|
[
|
|
|
|
|
'title' => __('Events list'),
|
|
|
|
|
'class' => 'invert_filter',
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
$output .= '</a>';
|
|
|
|
|
$output .= '</li>';
|
|
|
|
|
$output .= '</ul>';
|
|
|
|
|
|
|
|
|
|
// Content tabs.
|
|
|
|
|
$output .= '<div id="tabs-sound-modal-1">';
|
|
|
|
|
$output .= '<h3 class="console-configuration">';
|
|
|
|
|
$output .= __('Console configuration');
|
|
|
|
|
$output .= '</h3>';
|
|
|
|
|
$inputs = [];
|
|
|
|
|
|
|
|
|
|
// Load filter.
|
|
|
|
|
$fields = \events_get_event_filter_select();
|
|
|
|
|
$inputs[] = [
|
|
|
|
|
'label' => \__('Set condition'),
|
|
|
|
|
'arguments' => [
|
|
|
|
|
'type' => 'select',
|
|
|
|
|
'fields' => $fields,
|
|
|
|
|
'name' => 'filter_id',
|
|
|
|
|
'selected' => 0,
|
|
|
|
|
'return' => true,
|
|
|
|
|
'nothing' => \__('All new events'),
|
|
|
|
|
'nothing_value' => 0,
|
|
|
|
|
'class' => 'fullwidth',
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$times_interval = [
|
|
|
|
|
10 => '10 '.__('seconds'),
|
|
|
|
|
15 => '15 '.__('seconds'),
|
|
|
|
|
30 => '30 '.__('seconds'),
|
|
|
|
|
60 => '60 '.__('seconds'),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$times_sound = [
|
|
|
|
|
2 => '2 '.__('seconds'),
|
|
|
|
|
5 => '5 '.__('seconds'),
|
|
|
|
|
10 => '10 '.__('seconds'),
|
|
|
|
|
15 => '15 '.__('seconds'),
|
|
|
|
|
30 => '30 '.__('seconds'),
|
|
|
|
|
60 => '60 '.__('seconds'),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$inputs[] = [
|
|
|
|
|
'class' => 'interval-sounds',
|
|
|
|
|
'direct' => 1,
|
|
|
|
|
'block_content' => [
|
|
|
|
|
[
|
|
|
|
|
'label' => __('Interval'),
|
|
|
|
|
'arguments' => [
|
|
|
|
|
'type' => 'select',
|
|
|
|
|
'fields' => $times_interval,
|
|
|
|
|
'name' => 'interval',
|
|
|
|
|
'selected' => 10,
|
|
|
|
|
'return' => true,
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2022-11-03 15:12:50 +01:00
|
|
|
|
'label' => __('Sound duration'),
|
2022-07-01 13:08:39 +02:00
|
|
|
|
'arguments' => [
|
|
|
|
|
'type' => 'select',
|
|
|
|
|
'fields' => $times_sound,
|
|
|
|
|
'name' => 'time_sound',
|
|
|
|
|
'selected' => 10,
|
|
|
|
|
'return' => true,
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$sounds = [
|
|
|
|
|
'aircraftalarm.wav' => 'Air craft alarm',
|
|
|
|
|
'air_shock_alarm.wav' => 'Air shock alarm',
|
|
|
|
|
'alien_alarm.wav' => 'Alien alarm',
|
|
|
|
|
'alien_beacon.wav' => 'Alien beacon',
|
|
|
|
|
'bell_school_ringing.wav' => 'Bell school ringing',
|
|
|
|
|
'Door_Alarm.wav' => 'Door alarm',
|
|
|
|
|
'EAS_beep.wav' => 'EAS beep',
|
|
|
|
|
'Firewarner.wav' => 'Fire warner',
|
|
|
|
|
'HardPCMAlarm.wav' => 'Hard PCM Alarm',
|
|
|
|
|
'negativebeep.wav' => 'Negative beep',
|
|
|
|
|
'Star_Trek_emergency_simulation.wav' => 'StarTrek emergency simulation',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$inputs[] = [
|
|
|
|
|
'class' => 'test-sounds',
|
|
|
|
|
'direct' => 1,
|
|
|
|
|
'block_content' => [
|
|
|
|
|
[
|
|
|
|
|
'label' => \__('Sound melody'),
|
|
|
|
|
'arguments' => [
|
|
|
|
|
'type' => 'select',
|
|
|
|
|
'fields' => $sounds,
|
|
|
|
|
'name' => 'sound_id',
|
|
|
|
|
'selected' => 'Star_Trek_emergency_simulation.wav',
|
|
|
|
|
'return' => true,
|
|
|
|
|
'class' => 'fullwidth',
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'arguments' => [
|
|
|
|
|
'type' => 'button',
|
|
|
|
|
'name' => 'melody_sound',
|
|
|
|
|
'label' => __('Test sound'),
|
2023-02-09 16:13:30 +01:00
|
|
|
|
'attributes' => ['icon' => 'sound'],
|
2022-07-01 13:08:39 +02:00
|
|
|
|
'return' => true,
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// Print form.
|
|
|
|
|
$output .= HTML::printForm(
|
|
|
|
|
[
|
|
|
|
|
'form' => [
|
|
|
|
|
'action' => '',
|
|
|
|
|
'method' => 'POST',
|
|
|
|
|
],
|
|
|
|
|
'inputs' => $inputs,
|
|
|
|
|
],
|
|
|
|
|
true,
|
|
|
|
|
false
|
|
|
|
|
);
|
|
|
|
|
$output .= '</div>';
|
|
|
|
|
|
|
|
|
|
$output .= '<div id="tabs-sound-modal-2">';
|
2022-07-04 17:09:30 +02:00
|
|
|
|
$output .= '<h3 class="title-discovered-alerts">';
|
|
|
|
|
$output .= __('Discovered alerts');
|
|
|
|
|
$output .= '</h3>';
|
|
|
|
|
$output .= '<div class="empty-discovered-alerts">';
|
|
|
|
|
$output .= html_print_image(
|
|
|
|
|
'images/no-alerts-discovered.png',
|
|
|
|
|
true,
|
|
|
|
|
[
|
|
|
|
|
'title' => __('No alerts discovered'),
|
|
|
|
|
'class' => 'invert_filter',
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
$output .= '<span class="text-discovered-alerts">';
|
|
|
|
|
$output .= __('Congrats! there’s nothing to show');
|
|
|
|
|
$output .= '</span>';
|
|
|
|
|
$output .= '</div>';
|
|
|
|
|
$output .= '<div class="elements-discovered-alerts"><ul></ul></div>';
|
2023-02-07 16:48:23 +01:00
|
|
|
|
$output .= html_print_input_hidden(
|
|
|
|
|
'ajax_file_sound_console',
|
|
|
|
|
ui_get_full_url('ajax.php', false, false, false),
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
$output .= html_print_input_hidden(
|
|
|
|
|
'meta',
|
|
|
|
|
is_metaconsole(),
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
$output .= '<div id="sound_event_details_window"></div>';
|
2023-02-07 17:41:27 +01:00
|
|
|
|
$output .= '<div id="sound_event_response_window"></div>';
|
2022-07-01 13:08:39 +02:00
|
|
|
|
$output .= '</div>';
|
|
|
|
|
$output .= '</div>';
|
|
|
|
|
|
|
|
|
|
$output .= '<div class="actions-sound-modal">';
|
|
|
|
|
$output .= '<div id="progressbar_time"></div>';
|
|
|
|
|
$output .= '<div class="buttons-sound-modal">';
|
2022-07-04 17:09:30 +02:00
|
|
|
|
$output .= '<div class="container-button-play">';
|
2022-07-01 13:08:39 +02:00
|
|
|
|
$output .= html_print_input(
|
|
|
|
|
[
|
2022-07-04 17:09:30 +02:00
|
|
|
|
'label' => __('Start'),
|
2022-07-01 13:08:39 +02:00
|
|
|
|
'type' => 'button',
|
|
|
|
|
'name' => 'start-search',
|
2023-02-09 16:13:30 +01:00
|
|
|
|
'attributes' => [ 'icon' => 'wand' ],
|
2022-07-01 13:08:39 +02:00
|
|
|
|
'return' => true,
|
2022-07-04 17:09:30 +02:00
|
|
|
|
],
|
|
|
|
|
'div',
|
|
|
|
|
true
|
2022-07-01 13:08:39 +02:00
|
|
|
|
);
|
2022-07-04 17:09:30 +02:00
|
|
|
|
$output .= '</div>';
|
|
|
|
|
$output .= '<div class="container-button-alert">';
|
2022-07-01 13:08:39 +02:00
|
|
|
|
$output .= html_print_input(
|
|
|
|
|
[
|
|
|
|
|
'type' => 'button',
|
|
|
|
|
'name' => 'no-alerts',
|
2022-07-04 17:09:30 +02:00
|
|
|
|
'label' => __('No alerts'),
|
2023-02-09 16:13:30 +01:00
|
|
|
|
'attributes' => [ 'icon' => 'fail' ],
|
2022-07-01 13:08:39 +02:00
|
|
|
|
'return' => true,
|
2022-07-04 17:09:30 +02:00
|
|
|
|
],
|
|
|
|
|
'div',
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
$output .= '</div>';
|
|
|
|
|
|
|
|
|
|
$output .= html_print_input(
|
|
|
|
|
[
|
|
|
|
|
'type' => 'hidden',
|
|
|
|
|
'name' => 'mode_alert',
|
|
|
|
|
'value' => 0,
|
|
|
|
|
'return' => true,
|
|
|
|
|
],
|
|
|
|
|
'div',
|
|
|
|
|
true
|
2022-07-01 13:08:39 +02:00
|
|
|
|
);
|
|
|
|
|
$output .= '</div>';
|
|
|
|
|
$output .= '</div>';
|
|
|
|
|
|
2022-06-30 17:17:05 +02:00
|
|
|
|
echo $output;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-15 15:31:01 +02:00
|
|
|
|
if ($get_events_fired) {
|
2021-04-06 19:11:37 +02:00
|
|
|
|
global $config;
|
2022-05-30 17:47:28 +02:00
|
|
|
|
$filter_id = (int) get_parameter('filter_id', 0);
|
|
|
|
|
$interval = (int) get_parameter('interval', 10);
|
|
|
|
|
|
|
|
|
|
if (empty($filter_id) === true) {
|
|
|
|
|
$filter = [
|
|
|
|
|
'id_group' => 0,
|
|
|
|
|
'event_type' => '',
|
|
|
|
|
'severity' => -1,
|
|
|
|
|
'status' => -1,
|
|
|
|
|
'search' => '',
|
2022-11-18 14:04:54 +01:00
|
|
|
|
'not_search' => 0,
|
2022-05-30 17:47:28 +02:00
|
|
|
|
'text_agent' => '',
|
|
|
|
|
'id_agent' => 0,
|
|
|
|
|
'id_agent_module' => 0,
|
|
|
|
|
'pagination' => 0,
|
|
|
|
|
'id_user_ack' => 0,
|
2022-09-27 15:08:09 +02:00
|
|
|
|
'group_rep' => EVENT_GROUP_REP_ALL,
|
2022-05-30 17:47:28 +02:00
|
|
|
|
'tag_with' => [],
|
|
|
|
|
'tag_without' => [],
|
|
|
|
|
'filter_only_alert' => -1,
|
2022-07-05 17:02:40 +02:00
|
|
|
|
'search_secondary_groups' => 0,
|
2022-09-29 12:54:46 +02:00
|
|
|
|
'search_recursive_groups' => 0,
|
2022-05-30 17:47:28 +02:00
|
|
|
|
'source' => '',
|
|
|
|
|
'id_extra' => '',
|
|
|
|
|
'user_comment' => '',
|
|
|
|
|
'id_source_event' => 0,
|
|
|
|
|
'server_id' => 0,
|
|
|
|
|
'custom_data' => '',
|
|
|
|
|
'custom_data_filter_type' => 0,
|
|
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
$filter = events_get_event_filter($filter_id);
|
2019-07-15 15:31:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-27 12:41:06 +01:00
|
|
|
|
if (is_metaconsole() === true) {
|
|
|
|
|
$servers = metaconsole_get_servers();
|
|
|
|
|
if (is_array($servers) === true) {
|
|
|
|
|
$servers = array_reduce(
|
|
|
|
|
$servers,
|
|
|
|
|
function ($carry, $item) {
|
|
|
|
|
$carry[$item['id']] = $item['server_name'];
|
|
|
|
|
return $carry;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
$servers = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($filter['server_id'] === '') {
|
|
|
|
|
$filter['server_id'] = array_keys($servers);
|
|
|
|
|
} else {
|
|
|
|
|
if (is_array($filter['server_id']) === false) {
|
|
|
|
|
if (is_numeric($filter['server_id']) === true) {
|
|
|
|
|
if ($filter['server_id'] !== 0) {
|
|
|
|
|
$filter['server_id'] = [$filter['server_id']];
|
|
|
|
|
} else {
|
|
|
|
|
$filter['server_id'] = array_keys($servers);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$filter['server_id'] = explode(',', $filter['server_id']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-30 17:47:28 +02:00
|
|
|
|
// Set time.
|
|
|
|
|
$filter['event_view_hr'] = 0;
|
2019-07-15 15:31:01 +02:00
|
|
|
|
|
2022-05-30 17:47:28 +02:00
|
|
|
|
$start = (time() - $interval);
|
|
|
|
|
$end = time();
|
2019-07-15 15:31:01 +02:00
|
|
|
|
|
2022-05-30 17:47:28 +02:00
|
|
|
|
$filter['date_from'] = date('Y-m-d', $start);
|
|
|
|
|
$filter['date_to'] = date('Y-m-d', $end);
|
|
|
|
|
$filter['time_from'] = date('H:i:s', $start);
|
|
|
|
|
$filter['time_to'] = date('H:i:s', $end);
|
|
|
|
|
$data = events_get_all(
|
|
|
|
|
['te.*'],
|
|
|
|
|
$filter
|
|
|
|
|
);
|
2019-07-15 15:31:01 +02:00
|
|
|
|
|
2022-05-30 17:47:28 +02:00
|
|
|
|
$return = [];
|
|
|
|
|
if (empty($data) === false) {
|
|
|
|
|
foreach ($data as $event) {
|
2023-02-07 16:48:23 +01:00
|
|
|
|
$return[] = array_merge(
|
|
|
|
|
$event,
|
|
|
|
|
[
|
|
|
|
|
'fired' => $event['id_evento'],
|
|
|
|
|
'message' => ui_print_string_substr(
|
|
|
|
|
strip_tags(io_safe_output($event['evento'])),
|
|
|
|
|
75,
|
|
|
|
|
true,
|
|
|
|
|
'9'
|
|
|
|
|
),
|
|
|
|
|
'priority' => ui_print_event_priority($event['criticity'], true, true),
|
|
|
|
|
'type' => events_print_type_img(
|
|
|
|
|
$event['event_type'],
|
|
|
|
|
true
|
|
|
|
|
),
|
|
|
|
|
'timestamp' => ui_print_timestamp(
|
|
|
|
|
$event['timestamp'],
|
|
|
|
|
true,
|
|
|
|
|
['style' => 'font-size: 9pt; letter-spacing: 0.3pt;']
|
|
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
);
|
2022-05-30 17:47:28 +02:00
|
|
|
|
}
|
2019-07-15 15:31:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-07 16:48:23 +01:00
|
|
|
|
echo io_safe_output(io_json_mb_encode($return));
|
2022-05-30 17:47:28 +02:00
|
|
|
|
return;
|
2019-07-15 15:31:01 +02:00
|
|
|
|
}
|
2022-09-27 09:51:37 +02:00
|
|
|
|
|
|
|
|
|
if ($draw_row_response_info === true) {
|
|
|
|
|
$event_response = json_decode(
|
|
|
|
|
io_safe_output(
|
|
|
|
|
get_parameter('response', '')
|
|
|
|
|
),
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$massive = (bool) get_parameter('massive', false);
|
|
|
|
|
|
|
|
|
|
$output .= '';
|
|
|
|
|
if ($massive === true) {
|
|
|
|
|
$output .= '<div>';
|
|
|
|
|
$output .= '<h5>';
|
|
|
|
|
$output .= $event_response['description'];
|
|
|
|
|
$output .= '</h5>';
|
|
|
|
|
$output .= '</div>';
|
|
|
|
|
} else {
|
|
|
|
|
$output .= '<tr class="params_rows">';
|
|
|
|
|
$output .= '<td>';
|
|
|
|
|
$output .= __('Description');
|
|
|
|
|
$output .= '</td>';
|
|
|
|
|
$output .= '<td class="height_30px" colspan="2">';
|
|
|
|
|
$output .= $event_response['description'];
|
|
|
|
|
$output .= '</td>';
|
|
|
|
|
$output .= '</tr>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (empty($event_response['params']) === false) {
|
|
|
|
|
$response_params = explode(',', $event_response['params']);
|
|
|
|
|
if (is_array($response_params) === true) {
|
|
|
|
|
if ($massive === true) {
|
|
|
|
|
$output .= '<div>';
|
|
|
|
|
} else {
|
|
|
|
|
$output .= '<tr class="params_rows">';
|
|
|
|
|
$output .= '<td class="left pdd_l_20px height_30px" colspan="3">';
|
|
|
|
|
$output .= __('Parameters');
|
|
|
|
|
$output .= '</td>';
|
|
|
|
|
$output .= '</tr>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($response_params as $param) {
|
|
|
|
|
$param = trim(io_safe_output($param));
|
|
|
|
|
if ($massive === true) {
|
|
|
|
|
$output .= '<div>';
|
|
|
|
|
$output .= '<label>';
|
|
|
|
|
$output .= $param;
|
|
|
|
|
$output .= '</label>';
|
|
|
|
|
$output .= '<input type="text" name="values_params_'.$param.'" />';
|
|
|
|
|
$output .= '</div>';
|
|
|
|
|
} else {
|
|
|
|
|
$output .= '<tr class="params_rows">';
|
|
|
|
|
$output .= '<td style="text-align:left; padding-left:40px; font-weight: normal; font-style: italic;">';
|
|
|
|
|
$output .= $param;
|
|
|
|
|
$output .= '</td>';
|
|
|
|
|
$output .= '<td style="text-align:left" colspan="2">';
|
|
|
|
|
$output .= '<input type="text" name="values_params_'.$param.'" />';
|
|
|
|
|
$output .= '</td>';
|
|
|
|
|
$output .= '</tr>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($massive === true) {
|
|
|
|
|
$output .= '</div>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo $output;
|
|
|
|
|
return;
|
|
|
|
|
}
|