From 324690ddad03810768c58d5ebcc5cfd844332fc9 Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 6 Aug 2019 14:52:43 +0200 Subject: [PATCH 1/2] Fixed pagination bug --- .../operation/snmpconsole/snmp_view.php | 155 +++++++++++------- 1 file changed, 95 insertions(+), 60 deletions(-) diff --git a/pandora_console/operation/snmpconsole/snmp_view.php b/pandora_console/operation/snmpconsole/snmp_view.php index c7f69b4109..66b0893c6a 100755 --- a/pandora_console/operation/snmpconsole/snmp_view.php +++ b/pandora_console/operation/snmpconsole/snmp_view.php @@ -1,17 +1,31 @@ $name) { $i++; } -$url = 'index.php?sec=estado&'.'sec2=operation/snmpconsole/snmp_view&'.'filter_severity='.$filter_severity.'&'.'filter_fired='.$filter_fired.'&'.'free_search_string='.$free_search_string.'&'.'pagination='.$pagination.'&'.'offset='.$offset.'&'.'trap_type='.$trap_type.'&'.'group_by='.$group_by.'&'.'date_from_trap='.$date_from_trap.'&'.'date_to_trap='.$date_to_trap.'&'.'time_from_trap='.$time_from_trap.'&'.'time_to_trap='.$time_to_trap; +$url = 'index.php?sec=estado&sec2=operation/snmpconsole/snmp_view&filter_severity='.$filter_severity.'&filter_fired='.$filter_fired.'&free_search_string='.$free_search_string.'&pagination='.$pagination.'&offset='.$offset.'&trap_type='.$trap_type.'&group_by='.$group_by.'&date_from_trap='.$date_from_trap.'&date_to_trap='.$date_to_trap.'&time_from_trap='.$time_from_trap.'&time_to_trap='.$time_to_trap; $statistics['text'] = ''.html_print_image('images/op_reporting.png', true, ['title' => __('Statistics')]).''; $list['text'] = ''.html_print_image('images/op_snmp.png', true, ['title' => __('List')]).''; @@ -70,7 +84,7 @@ $list['active'] = true; if ($config['pure']) { $fullscreen['text'] = ''.html_print_image('images/normal_screen.png', true, ['title' => __('Normal screen')]).''; } else { - // Fullscreen + // Fullscreen. $fullscreen['text'] = ''.html_print_image('images/full_screen.png', true, ['title' => __('Full screen')]).''; } @@ -131,7 +145,7 @@ if (isset($_GET['check'])) { } } -// Mass-process DELETE +// Mass-process DELETE. if (isset($_POST['deletebt'])) { $trap_ids = get_parameter_post('snmptrapid', []); if (is_array($trap_ids) && check_acl($config['id_user'], 0, 'IW')) { @@ -161,7 +175,7 @@ if (isset($_POST['deletebt'])) { } } -// Mass-process UPDATE +// Mass-process UPDATE. if (isset($_POST['updatebt'])) { $trap_ids = get_parameter_post('snmptrapid', []); if (is_array($trap_ids) && check_acl($config['id_user'], 0, 'IW')) { @@ -178,14 +192,14 @@ if (isset($_POST['updatebt'])) { } } -// All traps +// All traps. $all_traps = db_get_all_rows_sql('SELECT DISTINCT source FROM ttrap'); if (empty($all_traps)) { $all_traps = []; } -// Set filters +// Set filters. $agents = []; $oids = []; $severities = get_priorities(); @@ -206,7 +220,7 @@ foreach ($all_traps as $trap) { $prea = array_keys($user_groups); $ids = join(',', $prea); -// Cuantos usuarios hay operadores con un grupo que exista y no lo tenga ningun usuario +// Cuantos usuarios hay operadores con un grupo que exista y no lo tenga ningun usuario. $user_in_group_wo_agents = db_get_value_sql('select count(DISTINCT(id_usuario)) from tusuario_perfil where id_usuario ="'.$config['id_user'].'" and id_perfil = 1 and id_grupo in (select id_grupo from tgrupo where id_grupo in ('.$ids.') and id_grupo not in (select id_grupo from tagente))'); switch ($config['dbtype']) { @@ -244,6 +258,10 @@ switch ($config['dbtype']) { } } break; + + default: + // Default. + break; } if (empty($address_by_user_groups)) { @@ -293,6 +311,10 @@ switch ($config['dbtype']) { ) OR source='' OR source NOT IN (SELECT direccion FROM tagente WHERE direccion IS NOT NULL)) %s ORDER BY timestamp DESC"; break; + + default: + // Default. + break; } switch ($config['dbtype']) { @@ -335,6 +357,10 @@ switch ($config['dbtype']) { ) OR source='' OR source NOT IN (SELECT direccion FROM tagente WHERE direccion IS NOT NULL)) %s"; break; + + default: + // Default. + break; } // $whereSubquery = 'WHERE 1=1'; @@ -372,6 +398,10 @@ if ($free_search_string != '') { text LIKE \'%'.$free_search_string.'%\' OR description LIKE \'%'.$free_search_string.'%\')'; break; + + default: + // Default. + break; } } @@ -422,7 +452,7 @@ if ($trap_type == 5) { $whereSubquery .= ' AND type = '.$trap_type; } -// Disable this feature (time will decide if temporarily) in Oracle cause the group by is very confictive +// Disable this feature (time will decide if temporarily) in Oracle cause the group by is very confictive. if ($group_by && $config['dbtype'] != 'oracle') { $where_without_group = $whereSubquery; $whereSubquery .= ' GROUP BY source,oid'; @@ -444,6 +474,10 @@ switch ($config['dbtype']) { $sql = sprintf($sql, $whereSubquery); $sql = oracle_recode_query($sql, $set); break; + + default: + // Default. + break; } $sql_all = sprintf($sql_all, $whereSubquery); @@ -458,7 +492,7 @@ $table->size = []; $table->size[0] = '120px'; $table->data = []; -// Alert status select +// Alert status select. $table->data[1][0] = ''.__('Alert').''; $table->data[1][1] = html_print_select( $alerted, @@ -470,7 +504,7 @@ $table->data[1][1] = html_print_select( true ); -// Block size for pagination select +// Block size for pagination select. $table->data[2][0] = ''.__('Block size for pagination').''; $paginations[25] = 25; $paginations[50] = 50; @@ -487,7 +521,7 @@ $table->data[2][1] = html_print_select( true ); -// Severity select +// Severity select. $table->data[1][2] = ''.__('Severity').''; $table->data[1][3] = html_print_select( $severities, @@ -499,7 +533,7 @@ $table->data[1][3] = html_print_select( true ); -// Status +// Status. $table->data[3][0] = ''.__('Status').''; $status_array[-1] = __('All'); @@ -515,7 +549,7 @@ $table->data[3][1] = html_print_select( true ); -// Free search (search by all alphanumeric fields) +// Free search (search by all alphanumeric fields). $table->data[2][3] = ''.__('Free search').''.ui_print_help_tip( __( 'Search by any alphanumeric field in the trap. @@ -542,7 +576,7 @@ $table->data[5][1] = html_print_input_text('time_from_trap', $time_from_trap, fa $table->data[5][2] = ''.__('To (Time)').''; $table->data[5][3] = html_print_input_text('time_to_trap', $time_to_trap, false, 15, 10, true); -// Type filter (ColdStart, WarmStart, LinkDown, LinkUp, authenticationFailure, Other) +// Type filter (ColdStart, WarmStart, LinkDown, LinkUp, authenticationFailure, Other). $table->data[6][1] = ''.__('Trap type').''.ui_print_help_tip(__('Search by trap type'), true); $trap_types = [ -1 => __('None'), @@ -565,14 +599,14 @@ $table->data[6][2] = html_print_select( false ); -// Disable this feature (time will decide if temporarily) in Oracle cause the group by is very confictive +// Disable this feature (time will decide if temporarily) in Oracle cause the group by is very confictive. if ($config['dbtype'] != 'oracle') { $table->data[3][3] = ''.__('Group by Enterprise String/IP').''; $table->data[3][4] = __('Yes').' '.html_print_radio_button('group_by', 1, '', $group_by, true).'  '; $table->data[3][4] .= __('No').' '.html_print_radio_button('group_by', 0, '', $group_by, true); } -$filter = '
'; +$filter = ''; $filter .= html_print_table($table, true); $filter .= '
'; $filter .= html_print_submit_button(__('Update'), 'search', false, 'class="sub upd"', true); @@ -595,9 +629,9 @@ $filter_resume['trap_type'] = $trap_types[$trap_type]; $traps = db_get_all_rows_sql($sql); $trapcount = (int) db_get_value_sql($sql_count); -// No traps +// No traps. if (empty($traps)) { - // Header + // Header. ui_print_page_header( __('SNMP Console'), 'images/op_snmp.png', @@ -638,24 +672,24 @@ if (empty($traps)) { echo '