0 ) { $node = new Node($server_id); $node->connect(); } if ($event_rep === 0) { // Disable group by when there're result is unique. $filter['group_rep'] = 0; } // 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 ) { $node->disconnect(); } $r = false; } finally { if (is_metaconsole() === true && $server_id > 0 ) { $node->disconnect(); } } if ($r === false) { echo 'Failed'; } else { echo $r; } return; } // Validates an event (filtered or not). if ($validate_event === true) { $filter = get_parameter('filter', []); $id_evento = (int) get_parameter('id_evento', 0); $server_id = (int) get_parameter('server_id', 0); $event_rep = (int) get_parameter('event_rep', 0); try { if (is_metaconsole() === true && $server_id > 0 ) { $node = new Node($server_id); $node->connect(); } if ($event_rep === 0) { // Disable group by when there're result is unique. $filter['group_rep'] = EVENT_GROUP_REP_ALL; } // 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(); } } if ($r === false) { echo 'Failed'; } else { echo $r; } return; } // Sets status to in progress. if ($in_process_event === true) { $filter = get_parameter('filter', []); $id_evento = (int) get_parameter('id_evento', 0); $server_id = (int) get_parameter('server_id', 0); $event_rep = (int) get_parameter('event_rep', 0); try { if (is_metaconsole() === true && $server_id > 0 ) { $node = new Node($server_id); $node->connect(); } if ($event_rep === 0) { // Disable group by when there're result is unique. $filter['group_rep'] = EVENT_GROUP_REP_ALL; } // 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(); } } if ($r === false) { echo 'Failed'; } else { echo $r; } return; } // 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'); $values['severity'] = implode(',', get_parameter('severity', -1)); $values['status'] = get_parameter('status'); $values['search'] = get_parameter('search'); $values['not_search'] = get_parameter('not_search'); $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'); $values['owner_user'] = get_parameter('owner_user'); $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'); $values['search_secondary_groups'] = get_parameter('search_secondary_groups'); $values['search_recursive_groups'] = get_parameter('search_recursive_groups'); $values['id_group_filter'] = get_parameter('id_group_filter'); $values['date_from'] = get_parameter('date_from', null); $values['time_from'] = get_parameter('time_from'); $values['date_to'] = get_parameter('date_to', null); $values['time_to'] = get_parameter('time_to'); $values['source'] = get_parameter('source'); $values['id_extra'] = get_parameter('id_extra'); $values['user_comment'] = get_parameter('user_comment'); $values['id_source_event'] = get_parameter('id_source_event'); $values['custom_data'] = get_parameter('custom_data'); $values['custom_data_filter_type'] = get_parameter('custom_data_filter_type'); // Get private filter from user. $private_filter = get_parameter_switch('private_filter_user', 0); if ((int) $private_filter === 1) { $values['private_filter_user'] = $config['id_user']; } else { $values['private_filter_user'] = null; } if (is_metaconsole() === true) { $values['server_id'] = implode(',', get_parameter('server_id')); } $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'); $values['severity'] = implode(',', get_parameter('severity', -1)); $values['status'] = get_parameter('status'); $values['search'] = get_parameter('search'); $values['not_search'] = get_parameter('not_search'); $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'); $values['owner_user'] = get_parameter('owner_user'); $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'); $values['search_secondary_groups'] = get_parameter('search_secondary_groups'); $values['search_recursive_groups'] = get_parameter('search_recursive_groups'); $values['id_group_filter'] = get_parameter('id_group_filter'); $values['date_from'] = get_parameter('date_from'); $values['time_from'] = get_parameter('time_from'); $values['date_to'] = get_parameter('date_to'); $values['time_to'] = get_parameter('time_to'); $values['source'] = get_parameter('source'); $values['id_extra'] = get_parameter('id_extra'); $values['user_comment'] = get_parameter('user_comment'); $values['id_source_event'] = get_parameter('id_source_event'); $values['custom_data'] = get_parameter('custom_data'); $values['custom_data_filter_type'] = get_parameter('custom_data_filter_type'); // Get private filter from user. $private_filter = get_parameter('private_filter_user', 0); $user_private_filter = events_get_event_filter($id); if ((int) $private_filter === 1 && $user_private_filter['private_filter_user'] === null) { $values['private_filter_user'] = $config['id_user']; } else if ($private_filter === $user_private_filter['private_filter_user'] && $user_private_filter['private_filter_user'] !== $config['id_user']) { $values['private_filter_user'] = $user_private_filter['private_filter_user']; } else { $values['private_filter_user'] = null; } if (is_metaconsole() === true) { $values['server_id'] = implode(',', get_parameter('server_id')); } 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); if ($event_filter === false) { $event_filter = [ '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, 'search_recursive_groups' => 0, 'user_comment' => '', 'id_extra' => '', 'id_user_ack' => '', 'owner_user' => '', 'date_from' => '', 'time_from' => '', 'date_to' => '', 'time_to' => '', 'severity' => '', 'event_type' => '', 'group_rep' => EVENT_GROUP_REP_ALL, 'id_group' => 0, 'id_group_filter' => 0, 'group_name' => 'All', 'text_agent' => '', 'id_agent' => 0, 'id_name' => 'None', 'filter_id' => 0, ]; } else { $event_filter['module_search'] = io_safe_output( db_get_value_filter( 'nombre', 'tagente_modulo', ['id_agente_modulo' => $event_filter['id_agent_module']] ) ); $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']); if ($event_filter['group_name'] === false) { $event_filter['group_name'] = __('All'); } } } if (is_metaconsole() === true) { $server_name = db_get_value('server_name', 'tmetaconsole_setup', 'id', $event_filter['server_id']); if ($server_name !== false) { $event_filter['server_name'] = $server_name; } } $event_filter['module_search'] = io_safe_output(db_get_value_filter('nombre', 'tagente_modulo', ['id_agente_modulo' => $event_filter['id_agent_module']])); } $event_filter['search'] = io_safe_output($event_filter['search']); $event_filter['id_name'] = io_safe_output($event_filter['id_name']); $event_filter['text_agent'] = io_safe_output($event_filter['text_agent']); $event_filter['source'] = io_safe_output($event_filter['source']); $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) { $current = db_get_value_filter('default_event_filter', 'tusuario', ['id_user' => $config['id_user']]); $filters = events_get_event_filter_select(); $user_groups_array = users_get_groups_for_select( $config['id_user'], $access, true, true, false ); $action = 'index.php?sec=eventos&sec2=operation/events/events&pure='; if ($settings_modal !== 0 && $parameters_modal !== 0) { $action .= '&settings='.$settings_modal.'¶meters='.$parameters_modal; } echo '