Merge branch 'ent-12829-Cambiar-filtro-Regex-search-para-que-busque-en-la-query' into 'develop'
change regex search in events See merge request artica/pandorafms!6949
This commit is contained in:
commit
a40e1fa019
|
@ -1,5 +1,14 @@
|
|||
START TRANSACTION;
|
||||
|
||||
-- Watch out! The following field migration must be done before altering the corresponding table.
|
||||
UPDATE `tevent_filter`
|
||||
SET `search` = `regex`,
|
||||
`regex` = '1'
|
||||
WHERE `regex` IS NOT NULL AND `regex` != '';
|
||||
|
||||
-- Watch out! The following alter command must be done after the previous update of this table.
|
||||
ALTER TABLE `tevent_filter` MODIFY COLUMN `regex` TINYINT unsigned NOT NULL DEFAULT 0;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tmerge_error` (
|
||||
`id` int(10) NOT NULL auto_increment,
|
||||
`id_node` int(10) default 0,
|
||||
|
|
|
@ -646,7 +646,7 @@ function load_form_filter() {
|
|||
if (i == 'search')
|
||||
$('#text-search').val(val);
|
||||
if (i == 'regex')
|
||||
$('#text-regex').val(val);
|
||||
$('#checkbox-regex').val(val);
|
||||
if (i == 'not_search')
|
||||
$('#checkbox-not_search').val(val);
|
||||
if (i == 'text_agent')
|
||||
|
@ -977,7 +977,7 @@ function save_new_filter() {
|
|||
"severity" : $("#severity").val(),
|
||||
"status" : $("#status").val(),
|
||||
"search" : $("#text-search").val(),
|
||||
"regex" : $('#text-regex').val(),
|
||||
"regex" : $('#checkbox-regex').val(),
|
||||
"not_search" : $("#checkbox-not_search").val(),
|
||||
"text_agent" : $("#text_id_agent").val(),
|
||||
"id_agent" : $('input:hidden[name=id_agent]').val(),
|
||||
|
@ -1058,7 +1058,7 @@ function save_update_filter() {
|
|||
"severity" : $("#severity").val(),
|
||||
"status" : $("#status").val(),
|
||||
"search" : $("#text-search").val(),
|
||||
"regex" : $('#text-regex').val(),
|
||||
"regex" : $('#checkbox-regex').val(),
|
||||
"not_search" : $("#checkbox-not_search").val(),
|
||||
"text_agent" : $("#text_id_agent").val(),
|
||||
"id_agent" : $('input:hidden[name=id_agent]').val(),
|
||||
|
@ -2596,6 +2596,7 @@ if ($get_events_fired) {
|
|||
'severity' => -1,
|
||||
'status' => -1,
|
||||
'search' => '',
|
||||
'regex' => 0,
|
||||
'not_search' => 0,
|
||||
'text_agent' => '',
|
||||
'id_agent' => 0,
|
||||
|
|
|
@ -1147,7 +1147,7 @@ function events_get_all(
|
|||
}
|
||||
|
||||
// Free search.
|
||||
if (empty($filter['search']) === false) {
|
||||
if (empty($filter['search']) === false && (bool) $filter['regex'] === false) {
|
||||
if (isset($config['dbconnection']->server_version) === true
|
||||
&& $config['dbconnection']->server_version > 50600
|
||||
) {
|
||||
|
@ -1177,14 +1177,13 @@ function events_get_all(
|
|||
$array_search[] = 'lower(ta.alias)';
|
||||
}
|
||||
|
||||
// Disregard repeated whitespaces in search string.
|
||||
// Disregard repeated whitespaces when searching.
|
||||
$collapsed_spaces_search = preg_replace('/( )+/', ' ', $filter['search']);
|
||||
|
||||
$sql_search = ' AND (';
|
||||
foreach ($array_search as $key => $field) {
|
||||
// Disregard repeated whitespaces in query searched string.
|
||||
$sql_search .= sprintf(
|
||||
'%s REGEXP_REPLACE(%s, "( \\s*)+", " ") %s like lower("%%%s%%")',
|
||||
'%s LOWER(REGEXP_REPLACE(%s, "( )+", " ")) %s like LOWER("%%%s%%")',
|
||||
($key === 0) ? '' : $nexo,
|
||||
$field,
|
||||
$not_search,
|
||||
|
|
|
@ -130,24 +130,28 @@ $severity = get_parameter(
|
|||
'filter[severity]',
|
||||
($filter['severity'] ?? '')
|
||||
);
|
||||
if (isset($filter['regex']) === true) {
|
||||
$regex = get_parameter(
|
||||
'filter[regex]',
|
||||
(io_safe_output($filter['regex']) ?? '')
|
||||
);
|
||||
} else {
|
||||
$regex = '';
|
||||
}
|
||||
|
||||
unset($filter['regex']);
|
||||
$status = get_parameter(
|
||||
'filter[status]',
|
||||
($filter['status'] ?? '')
|
||||
);
|
||||
|
||||
$regex_switch = (bool) get_parameter(
|
||||
'filter[regex]',
|
||||
($filter['regex'] ?? false)
|
||||
);
|
||||
|
||||
$search = get_parameter(
|
||||
'filter[search]',
|
||||
($filter['search'] ?? '')
|
||||
);
|
||||
|
||||
$regex = '';
|
||||
|
||||
if ($regex_switch === true) {
|
||||
$regex = $search;
|
||||
$search = '';
|
||||
}
|
||||
|
||||
$not_search = get_parameter(
|
||||
'filter[not_search]',
|
||||
0
|
||||
|
@ -1238,6 +1242,7 @@ if (is_ajax() === true) {
|
|||
|
||||
$regex_validation = false;
|
||||
if (empty($tmp) === false && $regex !== '') {
|
||||
|
||||
foreach (json_decode(json_encode($tmp), true) as $key => $field) {
|
||||
if ($key === 'b64') {
|
||||
continue;
|
||||
|
@ -1245,7 +1250,7 @@ if (is_ajax() === true) {
|
|||
|
||||
$field = strip_tags($field);
|
||||
|
||||
if (preg_match('/'.$regex.'/', $field)) {
|
||||
if (preg_match('/'.io_safe_output($regex).'/', $field)) {
|
||||
$regex_validation = true;
|
||||
}
|
||||
}
|
||||
|
@ -2090,6 +2095,23 @@ $data .= ui_print_help_tip(
|
|||
__('Search for elements NOT containing given text.'),
|
||||
true
|
||||
);
|
||||
|
||||
$data .= '   ';
|
||||
|
||||
$data .= html_print_checkbox_switch(
|
||||
'regex',
|
||||
$regex,
|
||||
$regex,
|
||||
true,
|
||||
false,
|
||||
'checked_slide_events(this);',
|
||||
true
|
||||
);
|
||||
$data .= ui_print_help_tip(
|
||||
__('Search by regular expression.'),
|
||||
true
|
||||
);
|
||||
|
||||
$data .= '</div>';
|
||||
|
||||
$in = '<div class="filter_input filter_input_not_search"><label>'.__('Free search').'</label>';
|
||||
|
@ -2126,12 +2148,6 @@ $in = '<div class="filter_input"><label>'.__('Severity').'</label>';
|
|||
$in .= $data.'</div>';
|
||||
$inputs[] = $in;
|
||||
|
||||
// REGEX search datatable.
|
||||
$in = '<div class="filter_input"><label>'.__('Regex search').ui_print_help_tip(__('Filter the results of the current page with regular expressions. It works on Agent name, Event name, Extra ID, Source, Custom data and Comment fields.'), true).'</label>';
|
||||
$in .= html_print_input_text('regex', $regex, '', '', 255, true);
|
||||
$in .= '</div>';
|
||||
$inputs[] = $in;
|
||||
|
||||
// User private filter.
|
||||
if (isset($private_filter_event) === false) {
|
||||
$private_filter_event = '';
|
||||
|
@ -2817,8 +2833,6 @@ try {
|
|||
true
|
||||
);
|
||||
|
||||
|
||||
|
||||
// Print datatable.
|
||||
html_print_div(
|
||||
[
|
||||
|
|
|
@ -1265,7 +1265,7 @@ CREATE TABLE IF NOT EXISTS `tevent_filter` (
|
|||
`custom_data_filter_type` TINYINT UNSIGNED DEFAULT 0,
|
||||
`owner_user` TEXT,
|
||||
`private_filter_user` TEXT,
|
||||
`regex` TEXT,
|
||||
`regex` TINYINT unsigned NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id_filter`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
|
||||
|
||||
|
|
Loading…
Reference in New Issue