'noaccess'];
}
include 'general/noaccess.php';
return;
}
$access = ($event_a == true) ? 'ER' : (($event_w == true) ? 'EW' : (($event_m == true) ? 'EM' : 'ER'));
$readonly = false;
if (!is_metaconsole()
&& isset($config['event_replication'])
&& $config['event_replication'] == 1
&& $config['show_events_in_local'] == 1
) {
$readonly = true;
}
// Load specific stylesheet.
ui_require_css_file('events');
ui_require_css_file('tables');
if (is_metaconsole()) {
ui_require_css_file('tables_meta', ENTERPRISE_DIR.'/include/styles/');
}
// Load extra javascript.
ui_require_javascript_file('pandora_events');
// Get requests.
$default_filter = [
'status' => EVENT_NO_VALIDATED,
'event_view_hr' => $config['event_view_hr'],
'group_rep' => 1,
'tag_with' => [],
'tag_without' => [],
'history' => false,
];
$fb64 = get_parameter('fb64', null);
if (isset($fb64)) {
$filter = json_decode(base64_decode($fb64), true);
} else {
$filter = get_parameter(
'filter',
$default_filter
);
}
$id_group = get_parameter(
'filter[id_group]',
$filter['id_group']
);
$event_type = get_parameter(
'filter[event_type]',
$filter['event_type']
);
$severity = get_parameter(
'filter[severity]',
$filter['severity']
);
$status = get_parameter(
'filter[status]',
$filter['status']
);
$search = get_parameter(
'filter[search]',
$filter['search']
);
$text_agent = get_parameter(
'filter[text_agent]',
$filter['text_agent']
);
$id_agent = get_parameter(
'filter[id_agent]',
$filter['id_agent']
);
$id_agent_module = get_parameter(
'filter[id_agent_module]',
$filter['id_agent_module']
);
$pagination = get_parameter(
'filter[pagination]',
$filter['pagination']
);
$event_view_hr = get_parameter(
'filter[event_view_hr]',
$filter['event_view_hr']
);
$id_user_ack = get_parameter(
'filter[id_user_ack]',
$filter['id_user_ack']
);
$group_rep = get_parameter(
'filter[group_rep]',
$filter['group_rep']
);
$tag_with = get_parameter(
'filter[tag_with]',
$filter['tag_with']
);
$tag_without = get_parameter(
'filter[tag_without]',
$filter['tag_without']
);
$filter_only_alert = get_parameter(
'filter[filter_only_alert]',
$filter['filter_only_alert']
);
$id_group_filter = get_parameter(
'filter[id_group_filter]',
$filter['id_group_filter']
);
$date_from = get_parameter(
'filter[date_from]',
$filter['date_from']
);
$date_to = get_parameter(
'filter[date_to]',
$filter['date_to']
);
$source = get_parameter(
'filter[source]',
$filter['source']
);
$id_extra = get_parameter(
'filter[id_extra]',
$filter['id_extra']
);
$user_comment = get_parameter(
'filter[user_comment]',
$filter['user_comment']
);
$history = get_parameter(
'history',
$filter['history']
);
$section = get_parameter('section', false);
// Ajax responses.
if (is_ajax()) {
$get_events = get_parameter('get_events', 0);
// Datatables offset, limit.
$start = get_parameter('start', 0);
$length = get_parameter('length', $config['block_size']);
if ($get_events) {
try {
ob_start();
$order = get_datatable_order(true);
if (is_array($order) && $order['field'] == 'mini_severity') {
$order['field'] = 'te.criticity';
}
$fields = [
'te.id_evento',
'te.id_agente',
'te.id_usuario',
'te.id_grupo',
'te.estado',
'te.timestamp',
'te.evento',
'te.utimestamp',
'te.event_type',
'te.id_alert_am',
'te.criticity',
'te.user_comment',
'te.tags',
'te.source',
'te.id_extra',
'te.critical_instructions',
'te.warning_instructions',
'te.unknown_instructions',
'te.owner_user',
'if(te.ack_utimestamp > 0, from_unixtime(te.ack_utimestamp),"") as ack_utimestamp',
'te.custom_data',
'te.data',
'te.module_status',
'ta.alias as agent_name',
'tg.nombre as group_name',
];
if (!is_metaconsole()) {
$fields[] = 'am.nombre as module_name';
$fields[] = 'am.id_agente_modulo as id_agentmodule';
$fields[] = 'ta.server_name as server_name';
} else {
$fields[] = 'ts.server_name as server_name';
}
$events = events_get_all(
// Fields.
$fields,
// Filter.
$filter,
// Offset.
$start,
// Limit.
$length,
// Order.
$order['direction'],
// Sort field.
$order['field'],
// History.
$history
);
$count = events_get_all(
'count',
$filter
);
if ($count !== false) {
$count = $count['0']['nitems'];
}
if ($events) {
$data = array_reduce(
$events,
function ($carry, $item) {
$tmp = (object) $item;
if (strlen($tmp->evento) >= 255) {
$tmp->evento = io_safe_output(substr($tmp->evento, 0, 253).'...)');
} else {
$tmp->evento = io_safe_output($tmp->evento);
}
if ($tmp->module_name) {
$tmp->module_name = io_safe_output($tmp->module_name);
}
$tmp->agent_name = io_safe_output($tmp->agent_name);
$tmp->ack_utimestamp = ui_print_timestamp(
$tmp->ack_utimestamp,
true
);
$tmp->timestamp = ui_print_timestamp(
$tmp->timestamp,
true
);
$tmp->data = format_numeric($tmp->data, 1);
$tmp->b64 = base64_encode(json_encode($tmp));
$carry[] = $tmp;
return $carry;
}
);
}
// RecordsTotal && recordsfiltered resultados totales.
echo json_encode(
[
'data' => $data,
'recordsTotal' => $count,
'recordsFiltered' => $count,
]
);
$response = ob_get_clean();
} catch (Exception $e) {
echo json_encode(
['error' => $e->getMessage()]
);
}
// If not valid it will throw an exception.
json_decode($response);
if (json_last_error() == JSON_ERROR_NONE) {
// If valid dump.
echo $response;
} else {
echo json_encode(
['error' => $response]
);
}
}
// AJAX section ends.
exit;
}
/*
* Load user default form.
*/
$user_filter = db_get_row_sql(
sprintf(
'SELECT f.id_filter, f.id_name
FROM tevent_filter f
INNER JOIN tusuario u
ON u.default_event_filter=f.id_filter
WHERE u.id_user = "%s" ',
$config['id_user']
)
);
if ($user_filter !== false) {
$filter = events_get_event_filter($user_filter['id_filter']);
if ($filter !== false) {
$id_group = $filter['id_group'];
$event_type = $filter['event_type'];
$severity = $filter['severity'];
$status = $filter['status'];
$search = $filter['search'];
$text_agent = $filter['text_agent'];
$id_agent = $filter['id_agent'];
$id_agent_module = $filter['id_agent_module'];
$pagination = $filter['pagination'];
$event_view_hr = $filter['event_view_hr'];
$id_user_ack = $filter['id_user_ack'];
$group_rep = $filter['group_rep'];
$tag_with = json_decode(io_safe_output($filter['tag_with']));
$tag_without = json_decode(io_safe_output($filter['tag_without']));
$tag_with_base64 = base64_encode(json_encode($tag_with));
$tag_without_base64 = base64_encode(json_encode($tag_without));
$filter_only_alert = $filter['filter_only_alert'];
$id_group_filter = $filter['id_group_filter'];
$date_from = $filter['date_from'];
$date_to = $filter['date_to'];
$source = $filter['source'];
$id_extra = $filter['id_extra'];
$user_comment = $filter['user_comment'];
}
}
// TAGS.
// Get the tags where the user have permissions in Events reading tasks.
$tags = tags_get_user_tags($config['id_user'], $access);
$tags_select_with = [];
$tags_select_without = [];
$tag_with_temp = [];
$tag_without_temp = [];
foreach ($tags as $id_tag => $tag) {
if ((array_search($id_tag, $tag_with) === false)
|| (array_search($id_tag, $tag_with) === null)
) {
$tags_select_with[$id_tag] = ui_print_truncate_text($tag, 50, true);
} else {
$tag_with_temp[$id_tag] = ui_print_truncate_text($tag, 50, true);
}
if ((array_search($id_tag, $tag_without) === false)
|| (array_search($id_tag, $tag_without) === null)
) {
$tags_select_without[$id_tag] = ui_print_truncate_text($tag, 50, true);
} else {
$tag_without_temp[$id_tag] = ui_print_truncate_text($tag, 50, true);
}
}
$add_with_tag_disabled = empty($tags_select_with);
$remove_with_tag_disabled = empty($tag_with_temp);
$add_without_tag_disabled = empty($tags_select_without);
$remove_without_tag_disabled = empty($tag_without_temp);
$tabletags_with = html_get_predefined_table('transparent', 2);
$tabletags_with->id = 'filter_events_tags_with';
$tabletags_with->width = '100%';
$tabletags_with->cellspacing = 4;
$tabletags_with->cellpadding = 4;
$tabletags_with->class = 'noshadow';
$tabletags_with->styleTable = 'border: 0px;';
if (is_metaconsole()) {
$tabletags_with->class = 'nobady';
$tabletags_with->cellspacing = 0;
$tabletags_with->cellpadding = 0;
}
$data = [];
$data[0] = html_print_select(
$tags_select_with,
'select_with',
'',
'',
'',
0,
true,
true,
true,
'',
false,
'width: 200px;'
);
$data[1] = html_print_image(
'images/darrowright.png',
true,
[
'id' => 'button-add_with',
'style' => 'cursor: pointer;',
'title' => __('Add'),
]
);
$data[1] .= html_print_input_hidden(
'tag_with',
$tag_with_base64,
true
);
$data[1] .= '
'.html_print_image(
'images/darrowleft.png',
true,
[
'id' => 'button-remove_with',
'style' => 'cursor: pointer;',
'title' => __('Remove'),
]
);
$data[2] = html_print_select(
$tag_with_temp,
'tag_with_temp',
[],
'',
'',
0,
true,
true,
true,
'',
false,
'width: 200px;'
);
$tabletags_with->data[] = $data;
$tabletags_with->rowclass[] = '';
$tabletags_without = html_get_predefined_table('transparent', 2);
$tabletags_without->id = 'filter_events_tags_without';
$tabletags_without->width = '100%';
$tabletags_without->cellspacing = 4;
$tabletags_without->cellpadding = 4;
$tabletags_without->class = 'noshadow';
if (is_metaconsole()) {
$tabletags_without->class = 'nobady';
$tabletags_without->cellspacing = 0;
$tabletags_without->cellpadding = 0;
}
$tabletags_without->styleTable = 'border: 0px;';
$data = [];
$data[0] = html_print_select(
$tags_select_without,
'select_without',
'',
'',
'',
0,
true,
true,
true,
'',
false,
'width: 200px;'
);
$data[1] = html_print_image(
'images/darrowright.png',
true,
[
'id' => 'button-add_without',
'style' => 'cursor: pointer;',
'title' => __('Add'),
]
);
$data[1] .= html_print_input_hidden(
'tag_without',
$tag_without_base64,
true
);
$data[1] .= '
'.html_print_image(
'images/darrowleft.png',
true,
[
'id' => 'button-remove_without',
'style' => 'cursor: pointer;',
'title' => __('Remove'),
]
);
$data[2] = html_print_select(
$tag_without_temp,
'tag_without_temp',
[],
'',
'',
0,
true,
true,
true,
'',
false,
'width: 200px;'
);
$tabletags_without->data[] = $data;
$tabletags_without->rowclass[] = '';
if (io_safe_output($tag_with) == '["0"]') {
$tag_with = '[]';
}
if (io_safe_output($tag_without) == '["0"]') {
$tag_without = '[]';
}
/*
* END OF TAGS.
*/
// View.
$pure = get_parameter('pure', 0);
$url = ui_get_full_url('index.php?sec=eventos&sec2=operation/events/events');
// Concatenate parameters.
$url .= '';
if ($pure) {
// Fullscreen.
// Floating menu - Start.
echo '