From 3b6f5bd02f435c545bcb7637a17f50251cb58de8 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 11 Jan 2022 14:30:59 +0100 Subject: [PATCH] services php8 --- pandora_console/include/class/HTML.class.php | 13 +++--- pandora_console/include/functions_agents.php | 2 +- pandora_console/include/functions_groups.php | 48 ++++++++++++-------- pandora_console/include/functions_html.php | 22 ++++----- pandora_console/include/lib/Agent.php | 4 +- pandora_console/include/lib/Module.php | 4 +- 6 files changed, 52 insertions(+), 41 deletions(-) diff --git a/pandora_console/include/class/HTML.class.php b/pandora_console/include/class/HTML.class.php index 293a28ecbb..46fc12829d 100644 --- a/pandora_console/include/class/HTML.class.php +++ b/pandora_console/include/class/HTML.class.php @@ -498,10 +498,10 @@ class HTML } // Print independent block of inputs. - $output .= '
  • '; + $output .= '
  • '; if (isset($input['wrapper']) === true) { - $output .= '<'.$input['wrapper'].' id="'.$input['block_id'].'" class="'.$class.'">'; + $output .= '<'.$input['wrapper'].' id="'.($input['block_id'] ?? '').'" class="'.$class.'">'; } if (!$direct) { @@ -551,9 +551,10 @@ class HTML $output .= '
  • '; } else { - if ($input['arguments']['type'] != 'hidden' - && $input['arguments']['type'] != 'hidden_extended' - && $input['arguments']['type'] != 'datalist' + if (is_array(($input['arguments'] ?? false)) === true + && ($input['arguments']['type'] ?? false) != 'hidden' + && ($input['arguments']['type'] ?? false) != 'hidden_extended' + && ($input['arguments']['type'] ?? false) != 'datalist' ) { // Raw content for attach at the start of the input. if (isset($input['surround_start']) === true) { @@ -580,7 +581,7 @@ class HTML $output .= $input['surround_end']; } } else { - $output .= self::printInput($input['arguments']); + $output .= self::printInput(($input['arguments'] ?? [])); // Allow dynamic content. $output .= ($input['extra'] ?? ''); } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index c87f1f62b4..811f0f9287 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1528,7 +1528,7 @@ function agents_get_modules( // ---------------------------------------------------------- foreach ($list_filter as $item) { $field = $item['field']; - $value = $item['value']; + $value = (string) $item['value']; // Check <> operator $operatorDistin = false; diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index b15c6216a0..52af88041a 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -572,15 +572,14 @@ function groups_get_groups_tree_recursive($groups, $trash=0, $trash2=0) } // If the user has ACLs on a gruop but not in his father, - // we consider it as a son of group "all" - if (!isset($groups[$group['parent']])) { + // we consider it as a son of group "all". + if (isset($groups[$group['parent']]) === false) { $group['parent'] = 0; } - if (is_array($tree[$group['parent']]) === false) { - $str = $tree[$group['parent']]; + if (is_array(($tree[$group['parent']] ?? null)) === false) { $tree[$group['parent']] = [ - 'nombre' => $tree[$group['parent']], + 'nombre' => ($tree[$group['parent']] ?? ''), 'id_grupo' => $group['parent'], ]; } @@ -590,7 +589,7 @@ function groups_get_groups_tree_recursive($groups, $trash=0, $trash2=0) } // Depends on the All group we give different format. - if (isset($groups[0])) { + if (isset($groups[0]) === true) { $tree = [$tree[0]]; } else { $tree = $tree[0]['branch']; @@ -991,31 +990,31 @@ function groups_get_agents_counter($group, $agent_filter=[], $module_filter=[], switch ($agent_status) { case AGENT_STATUS_CRITICAL: if ($critical > 0) { - $count ++; + $count++; } break; case AGENT_STATUS_WARNING: if (($total > 0) && ($critical == 0) && ($warning > 0)) { - $count ++; + $count++; } break; case AGENT_STATUS_UNKNOWN: if ($critical == 0 && $warning == 0 && $unknown > 0) { - $count ++; + $count++; } break; case AGENT_STATUS_NOT_INIT: if ($total == 0 || $total == $not_init) { - $count ++; + $count++; } break; case AGENT_STATUS_NORMAL: if ($critical == 0 && $warning == 0 && $unknown == 0 && $normal > 0) { - $count ++; + $count++; } break; @@ -1026,23 +1025,23 @@ function groups_get_agents_counter($group, $agent_filter=[], $module_filter=[], } else { if (array_search(AGENT_STATUS_CRITICAL, $agent_status) !== false) { if ($critical > 0) { - $count ++; + $count++; } } else if (array_search(AGENT_STATUS_WARNING, $agent_status) !== false) { if ($total > 0 && $critical = 0 && $warning > 0) { - $count ++; + $count++; } } else if (array_search(AGENT_STATUS_UNKNOWN, $agent_status) !== false) { if ($critical == 0 && $warning == 0 && $unknown > 0) { - $count ++; + $count++; } } else if (array_search(AGENT_STATUS_NOT_INIT, $agent_status) !== false) { if ($total == 0 || $total == $not_init) { - $count ++; + $count++; } } else if (array_search(AGENT_STATUS_NORMAL, $agent_status) !== false) { if ($critical == 0 && $warning == 0 && $unknown == 0 && $normal > 0) { - $count ++; + $count++; } } // Invalid status @@ -1846,8 +1845,12 @@ function groups_get_tree(&$groups, $parent=false) } -function groups_get_tree_good(&$groups, $parent=false, &$childs) +function groups_get_tree_good(&$groups, $parent, &$childs) { + if (isset($parent) === false) { + $parent = false; + } + $return = []; foreach ($groups as $id => $group) { @@ -1895,8 +1898,15 @@ function groups_get_tree_keys($groups, &$group_keys) } -function group_get_data($id_user=false, $user_strict=false, $acltags, $returnAllGroup=false, $mode='group', $agent_filter=[], $module_filter=[]) -{ +function group_get_data( + $id_user=false, + $user_strict=false, + $acltags=[], + $returnAllGroup=false, + $mode='group', + $agent_filter=[], + $module_filter=[] +) { global $config; if ($id_user == false) { $id_user = $config['id_user']; diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index be68bfa1aa..aabdd92a36 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -4598,7 +4598,7 @@ function html_print_input($data, $wrapper='div', $input_only=false) $output .= ' class="'.$data['input_class'].'">'; } - switch ($data['type']) { + switch (($data['type'] ?? null)) { case 'text': $output .= html_print_input_text( $data['name'], @@ -4650,15 +4650,15 @@ function html_print_input($data, $wrapper='div', $input_only=false) case 'text_extended': $output .= html_print_input_text_extended( - $data['name'], - $data['value'], - $data['id'], - $data['alt'], - $data['size'], - $data['maxlength'], - $data['disabled'], - $data['script'], - $data['attributes'], + ($data['name'] ?? null), + ($data['value'] ?? null), + ($data['id'] ?? null), + ($data['alt'] ?? null), + ($data['size'] ?? null), + ($data['maxlength'] ?? null), + ($data['disabled'] ?? null), + ($data['script'] ?? null), + ($data['attributes'] ?? null), ((isset($data['return']) === true) ? $data['return'] : false), ((isset($data['password']) === true) ? $data['password'] : false), ((isset($data['function']) === true) ? $data['function'] : '') @@ -4868,7 +4868,7 @@ function html_print_input($data, $wrapper='div', $input_only=false) case 'checkbox': $output .= html_print_checkbox( $data['name'], - $data['value'], + ($data['value'] ?? null), ((isset($data['checked']) === true) ? $data['checked'] : false), ((isset($data['return']) === true) ? $data['return'] : false), ((isset($data['disabled']) === true) ? $data['disabled'] : false), diff --git a/pandora_console/include/lib/Agent.php b/pandora_console/include/lib/Agent.php index c71d8415ce..acc01a9756 100644 --- a/pandora_console/include/lib/Agent.php +++ b/pandora_console/include/lib/Agent.php @@ -352,11 +352,11 @@ class Agent extends Entity $cps = 0; - if (is_array($direct_parents) === false) { + if (is_array(($direct_parents ?? null)) === false) { $direct_parents = []; } - if (is_array($mc_parents) === false) { + if (is_array(($mc_parents ?? null)) === false) { $mc_parents = []; } diff --git a/pandora_console/include/lib/Module.php b/pandora_console/include/lib/Module.php index d2a5956e8c..382960b84b 100644 --- a/pandora_console/include/lib/Module.php +++ b/pandora_console/include/lib/Module.php @@ -1200,11 +1200,11 @@ class Module extends Entity $cps = 0; - if (is_array($direct_parents) === false) { + if (is_array(($direct_parents ?? null)) === false) { $direct_parents = []; } - if (is_array($mc_parents) === false) { + if (is_array(($mc_parents ?? null)) === false) { $mc_parents = []; }