'noaccess'];
}
include 'general/noaccess.php';
return;
}
$event_a = check_acl($config['id_user'], 0, 'ER');
$event_w = check_acl($config['id_user'], 0, 'EW');
$event_m = check_acl($config['id_user'], 0, 'EM');
$access = ($event_a == true) ? 'ER' : (($event_w == true) ? 'EW' : (($event_m == true) ? 'EM' : 'ER'));
// Load specific stylesheet.
ui_require_css_file('events');
// Load extra javascript.
ui_require_javascript_file('pandora_events');
// Get requests.
$id_group = get_parameter('filter[id_group]');
$event_type = get_parameter('filter[event_type]');
$severity = get_parameter('filter[severity]');
$status = get_parameter('filter[status]', EVENT_NO_VALIDATED);
$search = get_parameter('filter[search]');
$text_agent = get_parameter('filter[text_agent]');
$id_agent = get_parameter('filter[id_agent]');
$id_agent_module = get_parameter('filter[id_agent_module]');
$pagination = get_parameter('filter[pagination]');
$event_view_hr = get_parameter('filter[event_view_hr]', 8);
$id_user_ack = get_parameter('filter[id_user_ack]');
$group_rep = get_parameter('filter[group_rep]', 1);
$tag_with = get_parameter('filter[tag_with]', []);
$tag_without = get_parameter('filter[tag_without]', []);
$filter_only_alert = get_parameter('filter[filter_only_alert]');
$id_group_filter = get_parameter('filter[id_group_filter]');
$date_from = get_parameter('filter[date_from]');
$date_to = get_parameter('filter[date_to]');
$source = get_parameter('filter[source]');
$id_extra = get_parameter('filter[id_extra]');
$user_comment = get_parameter('filter[user_comment]');
// Ajax responses.
if (is_ajax()) {
$get_events = get_parameter('get_events', 0);
$filter = get_parameter('filter', []);
// Datatables offset, limit.
$start = get_parameter('start', 0);
$length = get_parameter('length', $config['block_size']);
if ($get_events) {
$order = get_datatable_order(true);
$events = events_get_all(
[
'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_agentmodule',
'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',
'te.ack_utimestamp',
'te.custom_data',
'te.data',
'te.module_status',
'ta.alias as agent_name',
'tg.nombre as group_name',
],
$filter,
// Offset.
$start,
// Limit.
$length,
// Order.
$order['direction'],
// Sort field.
$order['field']
);
$count = events_get_all(
'count',
$filter
);
if ($count !== false) {
$count = $count['0']['nitems'];
}
if ($events) {
$data = array_reduce(
$events,
function ($carry, $item) {
$carry[] = (object) $item;
return $carry;
}
);
}
// RecordsTotal && recordsfiltered resultados totales.
echo json_encode(
[
'data' => $data,
'recordsTotal' => $count,
'recordsFiltered' => $count,
]
);
}
// AJAX section ends.
exit;
}
// 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 (is_metaconsole()) {
// Load metaconsole frame.
enterprise_hook('open_meta_frame');
} else if ($pure) {
// Fullscreen.
// Floating menu - Start.
echo '
';
echo '';
echo '
';
// Floating menu - End.
ui_require_jquery_file('countdown');
} else {
// Header.
$pss = get_user_info($config['id_user']);
$hashup = md5($config['id_user'].$pss['password']);
// Fullscreen.
$fullscreen['active'] = false;
$fullscreen['text'] = ''.html_print_image('images/full_screen.png', true, ['title' => __('Full screen')]).'';
// Event list.
$list['active'] = false;
$list['text'] = ''.html_print_image('images/events_list.png', true, ['title' => __('Event list')]).'';
// History event list.
$history_list['active'] = false;
$history_list['text'] = ''.html_print_image('images/books.png', true, ['title' => __('History event list')]).'';
// RSS.
$rss['active'] = false;
$rss['text'] = ''.html_print_image('images/rss.png', true, ['title' => __('RSS Events')]).'';
// Marquee.
$marquee['active'] = false;
$marquee['text'] = ''.html_print_image('images/heart.png', true, ['title' => __('Marquee display')]).'';
// CSV.
$csv['active'] = false;
$csv['text'] = ''.html_print_image('images/csv_mc.png', true, ['title' => __('Export to CSV file')]).'';
// Sound events.
$sound_event['active'] = false;
$sound_event['text'] = ''.html_print_image('images/sound.png', true, ['title' => __('Sound events')]).'';
// If the user has administrator permission display manage tab.
if (check_acl($config['id_user'], 0, 'EW') || check_acl($config['id_user'], 0, 'EM')) {
// Manage events.
$manage_events['active'] = false;
$manage_events['text'] = ''.html_print_image('images/setup.png', true, ['title' => __('Manage events')]).'';
$manage_events['godmode'] = true;
$onheader = [
'manage_events' => $manage_events,
'fullscreen' => $fullscreen,
'list' => $list,
'history' => $history_list,
'rss' => $rss,
'marquee' => $marquee,
'csv' => $csv,
'sound_event' => $sound_event,
];
} else {
$onheader = [
'fullscreen' => $fullscreen,
'list' => $list,
'history' => $history_list,
'rss' => $rss,
'marquee' => $marquee,
'csv' => $csv,
'sound_event' => $sound_event,
];
}
// If the history event is not enabled, dont show the history tab.
if (!isset($config['metaconsole_events_history']) || $config['metaconsole_events_history'] != 1) {
unset($onheader['history']);
}
switch ($section) {
case 'sound_event':
$onheader['sound_event']['active'] = true;
$section_string = __('Sound events');
break;
case 'history':
$onheader['history']['active'] = true;
$section_string = __('History');
break;
default:
$onheader['list']['active'] = true;
$section_string = __('List');
break;
}
if (! defined('METACONSOLE')) {
unset($onheader['history']);
ui_print_page_header(
__('Events'),
'images/op_events.png',
false,
'eventview',
false,
$onheader,
true,
'eventsmodal'
);
} else {
unset($onheader['rss']);
unset($onheader['marquee']);
unset($onheader['csv']);
unset($onheader['sound_event']);
unset($onheader['fullscreen']);
ui_meta_print_header(__('Events'), $section_string, $onheader);
}
?>
";
echo '';
// Controls.
if (is_metaconsole() !== true) {
if (isset($config['event_replication'])
&& $config['event_replication'] == 1
) {
if ($config['show_events_in_local'] == 0) {
db_pandora_audit(
'ACL Violation',
'Trying to access event viewer. View disabled due event replication.'
);
ui_print_info_message(
[
'message' => __(
'Event viewer is disabled due event replication. For more information, please contact with the administrator'
),
'no_close' => true,
]
);
return;
} else {
$readonly = true;
}
}
}
/*
* Load filter form.
*/
// Group.
$user_groups_array = users_get_groups_for_select(
$config['id_user'],
$access,
true,
true,
false
);
$data = html_print_select(
$user_groups_array,
'id_group_filter',
$id_group_filter,
'',
'',
0,
true,
false,
false,
'w130'
);
$in = '';
$in .= $data.'
';
$inputs[] = $in;
// Event type.
$types = get_event_types();
$types['not_normal'] = __('Not normal');
$data = html_print_select(
$types,
'event_type',
$event_type,
'',
__('All'),
'',
true
);
$in = '';
$in .= $data.'
';
$inputs[] = $in;
// Criticity - severity.
$severity_select .= html_print_select(
get_priorities(),
'severity',
$severity,
'',
__('All'),
'-1',
true,
false,
false
);
$in = '';
$in .= $severity_select.'
';
$inputs[] = $in;
// Event status.
$data = html_print_select(
events_get_all_status(),
'status',
$status,
'',
'',
'',
true
);
$in = '';
$in .= $data.'
';
$inputs[] = $in;
// Max hours old.
$data = html_print_input_text(
'event_view_hr',
$event_view_hr,
'',
5,
255,
true
);
$in = '';
$in .= $data.'
';
$inputs[] = $in;
// Duplicates group { events | agents }.
$data = html_print_select(
[
0 => __('All events'),
1 => __('Group events'),
2 => __('Group agents'),
],
'group_rep',
$group_rep,
'',
'',
0,
true
);
$in = '';
$in .= $data.'
';
$inputs[] = $in;
// Source.
$data = html_print_input_text('source', $source, '', '', 255, true);
$in = '';
$in .= $data.'
';
$inputs[] = $in;
// Extra ID.
$data = html_print_input_text('id_extra', $id_extra, '', 11, 255, true);
$in = '';
$in .= $data.'
';
$inputs[] = $in;
// Comment.
$data = html_print_input_text(
'user_comment',
$user_comment,
'',
'',
255,
true
);
$in = '';
$in .= $data.'
';
$inputs[] = $in;
$buttons = [];
$buttons[] = [
'id' => 'load-filter',
'class' => 'float-left margin-right-2 sub config',
'text' => __('Load filter'),
'onclick' => '',
];
$buttons[] = [
'id' => 'save-filter',
'class' => 'float-left margin-right-2 sub wand',
'text' => __('Save filter'),
'onclick' => '',
];
/*
* Advanced filter.
*/
$adv_inputs = [];
// Free search.
$data = html_print_input_text('search', $search, '', '', 255, true);
$in = '';
$in .= $data.'
';
$adv_inputs[] = $in;
// Agent search.
$params = [];
$params['show_helptip'] = true;
$params['input_name'] = 'text_agent';
$params['value'] = $text_agent;
$params['return'] = true;
if ($meta) {
$params['javascript_page'] = 'enterprise/meta/include/ajax/events.ajax';
}
$params['print_hidden_input_idagent'] = true;
$params['hidden_input_idagent_name'] = 'id_agent';
$params['hidden_input_idagent_value'] = $id_agent;
$params['size'] = '';
$data = ui_print_agent_autocomplete_input($params);
$in = '';
$in .= $data.'
';
$adv_inputs[] = $in;
// Mixed. Metaconsole => server, Console => module.
if (is_metaconsole()) {
$title = __('Server');
$data = html_print_select_from_sql(
'SELECT id, server_name FROM tmetaconsole_setup',
'server_id',
$server_id,
'script',
__('All'),
'0',
true
);
} else {
$title = __('Module search');
$data = html_print_autocomplete_modules(
'module_search',
$text_module,
false,
true,
'',
[],
true,
$id_agent_module,
''
);
}
$in = '';
$in .= $data.'
';
$adv_inputs[] = $in;
// User ack.
$user_users = users_get_user_users(
$config['id_user'],
$access,
users_can_manage_group_all()
);
$data = html_print_select(
$user_users,
'id_user_ack',
$id_user_ack,
'',
__('Any'),
0,
true
);
$in = '';
$in .= $data.'
';
$adv_inputs[] = $in;
// Only alert events.
$data = html_print_select(
[
'-1' => __('All'),
'0' => __('Filter alert events'),
'1' => __('Only alert events'),
],
'filter_only_alert',
$filter_only_alert,
'',
'',
'',
true
);
$in = '';
$in .= $data.'
';
$adv_inputs[] = $in;
// Gap.
$adv_inputs[] = '';
// Date from.
$data = html_print_input_text(
'date_from',
$date_from,
'',
false,
10,
true,
// Disabled.
false,
// Required.
false,
// Function.
'',
// Class.
'',
// OnChange.
'',
// Autocomplete.
'off'
);
$in = '';
$adv_inputs[] = $in;
// Date to.
$data = html_print_input_text(
'date_to',
$date_to,
'',
false,
10,
true,
// Disabled.
false,
// Required.
false,
// Function.
'',
// Class.
'',
// OnChange.
'',
// Autocomplete.
'off'
);
$in = '';
$adv_inputs[] = $in;
// Tags.
if (is_metaconsole()) {
$data = '';
$data .= '';
} else {
$data = '';
$data .= '';
}
$in = '';
$in .= $data.'
';
$adv_inputs[] = $in;
// Load view.
$adv_filter = join('', $adv_inputs);
$filter = join('', $inputs);
$filter .= ui_toggle(
$adv_filter,
__('Advanced options'),
'',
'',
true,
true,
'white_box white_box_opened',
'no-border flex-row'
);
try {
$default_fields = [
'evento',
'id_evento',
// 'id_agente',
// 'id_usuario',
// 'id_grupo',
// 'estado',
'agent_name',
'timestamp',
// 'utimestamp',
// 'event_type',
// 'id_agentmodule',
// 'id_alert_am',
'event_type',
// 'user_comment',
// 'tags',
// 'source',
// 'id_extra',
// 'critical_instructions',
// 'warning_instructions',
// 'unknown_instructions',
// 'owner_user',
// 'ack_utimestamp',
// 'custom_data',
// 'data',
// 'module_status',
// 'similar_ids',
// 'event_rep',
// 'timestamp_rep',
// 'timestamp_rep_min',
// 'module_name',
[
'text' => 'options',
'class' => 'action_buttons',
],
];
$fields = explode(',', $config['event_fields']);
// Always check something is shown.
if (empty($fields)) {
$fields = $default_fields;
}
// Always add options column.
$fields = array_merge(
$fields,
[[
'text' => 'options',
'class' => 'action_buttons',
],
]
);
// Get column names.
$column_names = events_get_column_names($fields);
// Open current filter quick reference.
$active_filters_div = '';
// Event status.
$active_filters_div .= '
';
$active_filters_div .= '
'.__('Event status').'
';
$active_filters_div .= '
';
switch ($status) {
case EVENT_ALL:
default:
$active_filters_div .= __('Any status.');
break;
case EVENT_NEW:
$active_filters_div .= __('New events.');
break;
case EVENT_VALIDATE:
$active_filters_div .= __('Validated.');
break;
case EVENT_PROCESS:
$active_filters_div .= __('In proccess.');
break;
case EVENT_NO_VALIDATED:
$active_filters_div .= __('Not validated.');
break;
}
$active_filters_div .= '
';
$active_filters_div .= '
';
// Max. hours old.
$active_filters_div .= '
';
$active_filters_div .= '
'.__('Max. hours old').'
';
$active_filters_div .= '
';
if ($event_view_hr == 0) {
$active_filters_div .= __('Any time.');
} else if ($event_view_hr == 1) {
$active_filters_div .= __('Last hour.');
} else if ($event_view_hr > 1) {
$active_filters_div .= __('Last %d hours.', $event_view_hr);
}
$active_filters_div .= '
';
$active_filters_div .= '
';
// Duplicates.
$active_filters_div .= '
';
$active_filters_div .= '
'.__('Duplicated').'
';
$active_filters_div .= '
';
if ($group_rep == 0) {
$active_filters_div .= __('All events.');
} else if ($group_rep == 1) {
$active_filters_div .= __('Group events');
} else if ($group_rep == 2) {
$active_filters_div .= __('Group agents.');
}
$active_filters_div .= '
';
$active_filters_div .= '
';
// Close.
$active_filters_div .= '
';
$table_id = 'events';
// Print datatable.
ui_print_datatable(
[
'id' => $table_id,
'class' => 'info_table events',
'style' => 'width: 100%;',
'ajax_url' => 'operation/events/events',
'ajax_data' => ['get_events' => 1],
'form' => [
'id' => 'events_form',
'class' => 'flex-row',
'html' => $filter,
'inputs' => [],
'extra_buttons' => $buttons,
],
'extra_html' => $active_filters_div,
'pagination_options' => [
[
$config['block_size'],
10,
25,
100,
200,
500,
1000,
-1,
],
[
$config['block_size'],
10,
25,
100,
200,
500,
1000,
'All',
],
],
'order' => [
'field' => 'timestamp',
'direction' => 'desc',
],
'column_names' => $column_names,
'columns' => $fields,
'no_sortable_columns' => [-1],
'ajax_postprocess' => 'process_datatables_item(item)',
'drawCallback' => 'process_datatables_callback(this, settings)',
]
);
} catch (Exception $e) {
ui_print_error_message($e->getMessage());
}
// Close viewer.
enterprise_hook('close_meta_frame');
// Datepicker requirements.
ui_require_css_file('datepicker');
ui_include_time_picker();
ui_require_jquery_file(
'ui.datepicker-'.get_user_language(),
'include/javascript/i18n/'
);
// End. Load required JS.
html_print_input_hidden('meta', (int) is_metaconsole());
html_print_input_hidden('history', (int) $history);
html_print_input_hidden('filterid', $is_filter);
html_print_input_hidden(
'ajax_file',
ui_get_full_url('ajax.php', false, false, false)
);
// AJAX call options responses.
echo "";
echo "";
echo "";
// Load filter div for dialog.
echo '';
echo '';
?>