From 49df65e69a4a3d9214cd0b0a3266efdf86ca07ba Mon Sep 17 00:00:00 2001
From: Calvo <luis.calvo@artica.es>
Date: Fri, 17 Jun 2022 15:02:57 +0200
Subject: [PATCH 01/83] Fix ACL for ncm

---
 pandora_console/include/functions_users.php | 46 +++++++++++----------
 1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/pandora_console/include/functions_users.php b/pandora_console/include/functions_users.php
index f4e6e25be8..da732c658e 100755
--- a/pandora_console/include/functions_users.php
+++ b/pandora_console/include/functions_users.php
@@ -235,27 +235,31 @@ function groups_combine_acl($acl_group_a, $acl_group_b)
     }
 
     $acl_list = [
-        'agent_view'          => 1,
-        'agent_edit'          => 1,
-        'agent_disable'       => 1,
-        'alert_edit'          => 1,
-        'alert_management'    => 1,
-        'pandora_management'  => 1,
-        'db_management'       => 1,
-        'user_management'     => 1,
-        'report_view'         => 1,
-        'report_edit'         => 1,
-        'report_management'   => 1,
-        'event_view'          => 1,
-        'event_edit'          => 1,
-        'event_management'    => 1,
-        'map_view'            => 1,
-        'map_edit'            => 1,
-        'map_management'      => 1,
-        'vconsole_view'       => 1,
-        'vconsole_edit'       => 1,
-        'vconsole_management' => 1,
-        'tags'                => 1,
+        'agent_view'                => 1,
+        'agent_edit'                => 1,
+        'agent_disable'             => 1,
+        'alert_edit'                => 1,
+        'alert_management'          => 1,
+        'pandora_management'        => 1,
+        'db_management'             => 1,
+        'user_management'           => 1,
+        'report_view'               => 1,
+        'report_edit'               => 1,
+        'report_management'         => 1,
+        'event_view'                => 1,
+        'event_edit'                => 1,
+        'event_management'          => 1,
+        'map_view'                  => 1,
+        'map_edit'                  => 1,
+        'map_management'            => 1,
+        'vconsole_view'             => 1,
+        'vconsole_edit'             => 1,
+        'vconsole_management'       => 1,
+        'tags'                      => 1,
+        'network_config_view'       => 1,
+        'network_config_edit'       => 1,
+        'network_config_management' => 1,
+
     ];
 
     foreach ($acl_group_a['tags'] as $key => $value) {

From b67f73539ff6cece292992fdcd40e933d138b4b3 Mon Sep 17 00:00:00 2001
From: Daniel Barbero <daniel.barbero@artica.es>
Date: Thu, 15 Sep 2022 12:07:05 +0200
Subject: [PATCH 02/83] fixed tree view services pandora_enterprise#9493

---
 pandora_console/include/functions_modules.php | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php
index 6c265e8e0f..3f1644693d 100755
--- a/pandora_console/include/functions_modules.php
+++ b/pandora_console/include/functions_modules.php
@@ -4191,6 +4191,11 @@ function modules_get_counter_by_states($state)
 
 function modules_get_state_condition($state, $prefix='tae')
 {
+    // Not  use empty state 0 -> AGENT_MODULE_STATUS_NORMAL.
+    if ($state === '') {
+        return '1=1';
+    }
+
     switch ($state) {
         case AGENT_MODULE_STATUS_CRITICAL_ALERT:
         case AGENT_MODULE_STATUS_CRITICAL_BAD:

From 181a480b9d7b3a696622b312596d91081cc0ca00 Mon Sep 17 00:00:00 2001
From: "alejandro.campos@artica.es" <alejandro.campos@artica.es>
Date: Mon, 19 Sep 2022 10:44:25 +0200
Subject: [PATCH 03/83] fixed api methods for creating and deleting scheduled
 downtimes agents

---
 pandora_console/include/functions_api.php | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php
index d711432ef9..2eb053e83a 100644
--- a/pandora_console/include/functions_api.php
+++ b/pandora_console/include/functions_api.php
@@ -7685,8 +7685,7 @@ function api_set_planned_downtimes_delete_agents($id, $thrash1, $other, $thrash3
     }
 
     if (!empty($other['data'][0])) {
-        $agents = io_safe_input($other['data']);
-        $agents = explode(';', $agents);
+        $agents = $other['data'];
         $results = false;
         foreach ($agents as $agent) {
             if (db_get_value_sql(sprintf('SELECT id from tplanned_downtime_agents WHERE id_agent = %d AND id_downtime = %d', $agent, $id)) !== false) {
@@ -7762,8 +7761,7 @@ function api_set_planned_downtimes_add_agents($id, $thrash1, $other, $thrash3)
     }
 
     if (!empty($other['data'][0])) {
-        $agents = io_safe_input($other['data']);
-        $agents = explode(';', $agents);
+        $agents = $other['data'];
         $results = false;
         foreach ($agents as $agent) {
             if (db_get_value_sql(sprintf('SELECT id from tplanned_downtime_agents tpd WHERE tpd.id_agent = %d AND id_downtime = %d', $agent, $id)) === false) {

From 5a237971f881a78861e5e5c223cbe90584832b1b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20Gonz=C3=A1lez?= <jose.gonzalez@pandorafms.com>
Date: Tue, 20 Sep 2022 13:02:32 +0200
Subject: [PATCH 04/83] Fix style issue

---
 pandora_console/include/styles/omnishell.css | 1 -
 1 file changed, 1 deletion(-)

diff --git a/pandora_console/include/styles/omnishell.css b/pandora_console/include/styles/omnishell.css
index a958eb630a..16b5fdd50a 100644
--- a/pandora_console/include/styles/omnishell.css
+++ b/pandora_console/include/styles/omnishell.css
@@ -398,7 +398,6 @@ li > input[type="email"],
   border: none;
   border-radius: 0;
   border-bottom: 1px solid #ccc;
-  font-weight: lighter;
   padding: 0px 0px 2px 0px;
   box-sizing: border-box;
   margin-bottom: 4px;

From 9e90c8da07a2f361fc8c0649c8fc8e91d008d63d Mon Sep 17 00:00:00 2001
From: Daniel Maya <daniel.maya@pandorafms.com>
Date: Tue, 20 Sep 2022 13:56:36 +0200
Subject: [PATCH 05/83] #9506 Changes in user profiles

---
 pandora_console/godmode/users/user_list.php | 113 +++++++++++++++-----
 1 file changed, 85 insertions(+), 28 deletions(-)

diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php
index efc3321c2c..b0dda31890 100644
--- a/pandora_console/godmode/users/user_list.php
+++ b/pandora_console/godmode/users/user_list.php
@@ -52,6 +52,8 @@ if (is_ajax()) {
     $method = get_parameter('method');
     $group_id = get_parameter('group_id');
     $group_recursion = (bool) get_parameter('group_recursion', 0);
+    $get_user_profile_group = (bool) get_parameter('get_user_profile_group', false);
+
     $return_all = false;
 
     if ($group_id == -1) {
@@ -93,6 +95,37 @@ if (is_ajax()) {
         echo json_encode($ret_id);
         return;
     }
+
+    if ($get_user_profile_group === true) {
+        $id_user = get_parameter('id_user');
+
+        $user_profiles = [];
+
+        // User profiles.
+        if (users_is_admin()) {
+            $user_profiles = db_get_all_rows_field_filter(
+                'tusuario_perfil',
+                'id_usuario',
+                $id_user
+            );
+        } else {
+            $user_profiles_aux = users_get_user_profile($id_user);
+            foreach ($group_um as $key => $value) {
+                if (isset($user_profiles_aux[$key]) === true) {
+                    $user_profiles[$key] = $user_profiles_aux[$key];
+                    unset($user_profiles_aux[$key]);
+                }
+            }
+        }
+
+        foreach ($user_profiles as $key => $value) {
+            $user_profiles[$key]['id_perfil'] = profile_get_name($value['id_perfil']);
+            $user_profiles[$key]['id_grupo'] = groups_get_name($value['id_grupo'], true);
+        }
+
+        echo json_encode($user_profiles);
+        return;
+    }
 }
 
 $sortField = get_parameter('sort_field');
@@ -588,10 +621,8 @@ $cont = 0;
 foreach ($info as $user_id => $user_info) {
     // User profiles.
     if ($user_is_admin || $user_id == $config['id_user'] || isset($group_um[0])) {
-        $user_profiles = db_get_all_rows_field_filter(
-            'tusuario_perfil',
-            'id_usuario',
-            $user_id
+        $user_profiles = db_get_all_rows_sql(
+            'SELECT * FROM tusuario_perfil where id_usuario LIKE "'.$user_id.'" LIMIT 5'
         );
     } else {
         $user_profiles_aux = users_get_user_profile($user_id);
@@ -674,9 +705,9 @@ foreach ($info as $user_id => $user_info) {
     if ($user_profiles !== false) {
         $total_profile = 0;
 
-            $data[4] .= '<div class="text_end">';
+        $data[4] .= '<div class="text_end" id="profiles_'.$user_profiles[0]['id_usuario'].'">';
         foreach ($user_profiles as $row) {
-            if ($total_profile <= 5) {
+            if ($total_profile < 5) {
                 $data[4] .= "<div class='float-left'>";
                 $data[4] .= profile_get_name($row['id_perfil']);
                 $data[4] .= ' / </div>';
@@ -685,8 +716,7 @@ foreach ($info as $user_id => $user_info) {
                 $data[4] .= '</div>';
 
                 if ($total_profile == 0 && count($user_profiles) >= 5) {
-                    $data[4] .= '<span onclick="showGroups()" class="pdd_l_15px">
-            '.html_print_image(
+                    $data[4] .= '<span onclick="showGroups(`'.$row['id_usuario'].'`)" class="pdd_l_15px">'.html_print_image(
                         'images/zoom.png',
                         true,
                         [
@@ -694,16 +724,15 @@ foreach ($info as $user_id => $user_info) {
                             'class' => 'invert_filter',
                         ]
                     ).'</span>';
+
+                    $data[4] .= html_print_input_hidden(
+                        'show_groups_'.$row['id_usuario'],
+                        -1,
+                        true
+                    );
                 }
 
-                $data[4] .= '<br />';
-                $data[4] .= '<br />';
-                $data[4] .= '</div>';
-            } else {
-                $data[4] .= "<div id='groups_list' class='invisible'>";
-                $data[4] .= '<div >';
-                $data[4] .= profile_get_name($row['id_perfil']);
-                $data[4] .= ' / '.groups_get_name($row['id_grupo'], true).'</div>';
+                $data[4] .= '<br/>';
                 $data[4] .= '<br/>';
             }
 
@@ -882,16 +911,44 @@ echo '</div>';
 
 enterprise_hook('close_meta_frame');
 
-echo '<script type="text/javascript">
-function showGroups(){
-var groups_list = document.getElementById("groups_list");
+?>;
+<script type="text/javascript">
+    function showGroups(id_user) {
+        if ($(`#hidden-show_groups_${id_user}`).val() === '-1') {
+            var request = $.ajax({
+                url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
+                type: 'GET',
+                dataType: 'JSON',
+                data: {
+                    page: 'godmode/users/user_list',
+                    get_user_profile_group: 1,
+                    id_user: id_user
+                },
+                success: function (data, textStatus, xhr) {
+                    let count = 1;
+                    data.forEach( function(valor, indice, array) {
+                        if (count >= 6) {
+                            let main_div = $(`#profiles_${id_user}`);
+                            main_div.append(
+                                `<div id="left_${id_user}_${count}" class='float-left'>${valor.id_perfil} / </div>`,
+                                `<div id="right_${id_user}_${count}" class='float-left pdd_l_5px'>${valor.id_grupo}</div>`,
+                                `<br/><br/>`
+                            );
+                        }
+                        count ++;
+                    });
+                }
+            });
+            $(`#hidden-show_groups_${id_user}`).val('1');
+        } else if ($(`#hidden-show_groups_${id_user}`).val() === '1') {
+            $(`#hidden-show_groups_${id_user}`).val('0');
+            $(`div[id^=left_${id_user}_]`).hide();
+            $(`div[id^=right_${id_user}_]`).hide();
+        } else {
+            $(`#hidden-show_groups_${id_user}`).val('1');
+            $(`div[id^=left_${id_user}_]`).show();
+            $(`div[id^=right_${id_user}_]`).show();
+        }
+    }
 
-if(groups_list.style.display == "none"){
-    document.querySelectorAll("[id=groups_list]").forEach(element=> 
-    element.style.display = "block");
-}else{
-    document.querySelectorAll("[id=groups_list]").forEach(element=> 
-    element.style.display = "none");
-};
-}
-</script>';
+</script>;

From 9b79ea79128db9cd8b19f9c49e0f9d5177d7f404 Mon Sep 17 00:00:00 2001
From: Daniel Maya <daniel.maya@pandorafms.com>
Date: Tue, 20 Sep 2022 16:05:27 +0200
Subject: [PATCH 06/83] #9506 Fixed um

---
 pandora_console/godmode/users/user_list.php | 14 ++++++++++----
 pandora_console/include/functions_users.php |  7 ++++---
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php
index b0dda31890..d282ff05af 100644
--- a/pandora_console/godmode/users/user_list.php
+++ b/pandora_console/godmode/users/user_list.php
@@ -99,10 +99,16 @@ if (is_ajax()) {
     if ($get_user_profile_group === true) {
         $id_user = get_parameter('id_user');
 
+        $user_is_admin = users_is_admin();
+
         $user_profiles = [];
 
+        if ($user_is_admin === false) {
+            $group_um = users_get_groups_UM($config['id_user']);
+        }
+
         // User profiles.
-        if (users_is_admin()) {
+        if ($user_is_admin || $id_user == $config['id_user'] || isset($group_um[0])) {
             $user_profiles = db_get_all_rows_field_filter(
                 'tusuario_perfil',
                 'id_usuario',
@@ -625,7 +631,7 @@ foreach ($info as $user_id => $user_info) {
             'SELECT * FROM tusuario_perfil where id_usuario LIKE "'.$user_id.'" LIMIT 5'
         );
     } else {
-        $user_profiles_aux = users_get_user_profile($user_id);
+        $user_profiles_aux = users_get_user_profile($user_id, 'LIMIT 5');
         $user_profiles = [];
         foreach ($group_um as $key => $value) {
             if (isset($user_profiles_aux[$key]) === true) {
@@ -911,7 +917,7 @@ echo '</div>';
 
 enterprise_hook('close_meta_frame');
 
-?>;
+?>
 <script type="text/javascript">
     function showGroups(id_user) {
         if ($(`#hidden-show_groups_${id_user}`).val() === '-1') {
@@ -951,4 +957,4 @@ enterprise_hook('close_meta_frame');
         }
     }
 
-</script>;
+</script>
diff --git a/pandora_console/include/functions_users.php b/pandora_console/include/functions_users.php
index f4e6e25be8..5db489377a 100755
--- a/pandora_console/include/functions_users.php
+++ b/pandora_console/include/functions_users.php
@@ -838,13 +838,14 @@ function users_has_profile_without_UM($id_user, $id_groups)
 }
 
 
-function users_get_user_profile($id_user)
+function users_get_user_profile($id_user, $limit='')
 {
     $sql = sprintf(
         "SELECT * FROM tusuario_perfil
         INNER JOIN tperfil ON tperfil.id_perfil = tusuario_perfil.id_perfil
-        WHERE tusuario_perfil.id_usuario like '%s'",
-        $id_user
+        WHERE tusuario_perfil.id_usuario like '%s' %s",
+        $id_user,
+        $limit
     );
 
     $aux = db_get_all_rows_sql($sql);

From 927658448e8327330294265aecf8f34fd49964d7 Mon Sep 17 00:00:00 2001
From: "alejandro.campos@artica.es" <alejandro.campos@artica.es>
Date: Tue, 20 Sep 2022 18:03:29 +0200
Subject: [PATCH 07/83] change permissions

---
 pandora_console/include/functions_api.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php
index d711432ef9..0b11d77926 100644
--- a/pandora_console/include/functions_api.php
+++ b/pandora_console/include/functions_api.php
@@ -10174,7 +10174,7 @@ function api_set_module_data($id, $thrash2, $other, $trash1)
     }
 
     if ($other['type'] == 'array') {
-        if (!util_api_check_agent_and_print_error(modules_get_agentmodule_agent($id), 'string', 'AW')) {
+        if (!util_api_check_agent_and_print_error(modules_get_agentmodule_agent($id), 'string')) {
             return;
         }
 

From 29c06a17f7c7b94d7de377d427feb0b228996cd0 Mon Sep 17 00:00:00 2001
From: Daniel Maya <daniel.maya@pandorafms.com>
Date: Wed, 21 Sep 2022 11:19:00 +0200
Subject: [PATCH 08/83] #9506 Fixed show profiles

---
 pandora_console/godmode/users/user_list.php | 59 ++++++++++-----------
 1 file changed, 29 insertions(+), 30 deletions(-)

diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php
index d282ff05af..85a95a8f22 100644
--- a/pandora_console/godmode/users/user_list.php
+++ b/pandora_console/godmode/users/user_list.php
@@ -711,37 +711,35 @@ foreach ($info as $user_id => $user_info) {
     if ($user_profiles !== false) {
         $total_profile = 0;
 
-        $data[4] .= '<div class="text_end" id="profiles_'.$user_profiles[0]['id_usuario'].'">';
+        $data[4] .= '<div class="text_end">';
         foreach ($user_profiles as $row) {
-            if ($total_profile < 5) {
-                $data[4] .= "<div class='float-left'>";
-                $data[4] .= profile_get_name($row['id_perfil']);
-                $data[4] .= ' / </div>';
-                $data[4] .= "<div class='float-left pdd_l_5px'>";
-                $data[4] .= groups_get_name($row['id_grupo'], true);
-                $data[4] .= '</div>';
+            $data[4] .= "<div class='float-left'>";
+            $data[4] .= profile_get_name($row['id_perfil']);
+            $data[4] .= ' / </div>';
+            $data[4] .= "<div class='float-left pdd_l_5px'>";
+            $data[4] .= groups_get_name($row['id_grupo'], true);
+            $data[4] .= '</div>';
 
-                if ($total_profile == 0 && count($user_profiles) >= 5) {
-                    $data[4] .= '<span onclick="showGroups(`'.$row['id_usuario'].'`)" class="pdd_l_15px">'.html_print_image(
-                        'images/zoom.png',
-                        true,
-                        [
-                            'title' => __('Show'),
-                            'class' => 'invert_filter',
-                        ]
-                    ).'</span>';
+            if ($total_profile == 0 && count($user_profiles) >= 5) {
+                $data[4] .= '<span onclick="showGroups(`'.$row['id_usuario'].'`)">'.html_print_image(
+                    'images/zoom.png',
+                    true,
+                    [
+                        'title' => __('Show profiles'),
+                        'class' => 'invert_filter',
+                    ]
+                ).'</span>';
 
-                    $data[4] .= html_print_input_hidden(
-                        'show_groups_'.$row['id_usuario'],
-                        -1,
-                        true
-                    );
-                }
-
-                $data[4] .= '<br/>';
-                $data[4] .= '<br/>';
+                $data[4] .= html_print_input_hidden(
+                    'show_groups_'.$row['id_usuario'],
+                    -1,
+                    true
+                );
             }
 
+            $data[4] .= '<br/>';
+            $data[4] .= '<br/>';
+
             $total_profile++;
         }
 
@@ -754,6 +752,8 @@ foreach ($info as $user_id => $user_info) {
         }
 
         $data[4] .= '</div>';
+        $data[4] .= '<div class="invisible" id="profiles_'.$user_profiles[0]['id_usuario'].'">';
+        $data[4] .= '</div>';
     } else {
         $data[4] .= __('The user doesn\'t have any assigned profile/group');
     }
@@ -946,14 +946,13 @@ enterprise_hook('close_meta_frame');
                 }
             });
             $(`#hidden-show_groups_${id_user}`).val('1');
+            $(`#profiles_${id_user}`).show();
         } else if ($(`#hidden-show_groups_${id_user}`).val() === '1') {
             $(`#hidden-show_groups_${id_user}`).val('0');
-            $(`div[id^=left_${id_user}_]`).hide();
-            $(`div[id^=right_${id_user}_]`).hide();
+            $(`#profiles_${id_user}`).hide();
         } else {
             $(`#hidden-show_groups_${id_user}`).val('1');
-            $(`div[id^=left_${id_user}_]`).show();
-            $(`div[id^=right_${id_user}_]`).show();
+            $(`#profiles_${id_user}`).show();
         }
     }
 

From 1e590728aa53c1338744a0e55c11a51dcdb1a222 Mon Sep 17 00:00:00 2001
From: "edu.corral" <eduardo.corral@artica.es>
Date: Wed, 21 Sep 2022 17:41:09 +0200
Subject: [PATCH 09/83] ent 9098 gis cli

---
 pandora_server/util/pandora_manage.pl | 45 ++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index 8df2893194..1539d1f5ee 100755
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -251,6 +251,11 @@ sub help_screen{
 	print "\nEVENTS\n\n" unless $param ne '';
 	help_screen_line('--event_in_progress', '<id_event> ', 'Set event in progress');
 
+	print "\nGIS\n\n" unless $param ne '';
+	help_screen_line('--get_gis_agent', '<agent_id> ', 'Gets agent GIS information');
+	help_screen_line('--insert_gis_data', '<agent_id> [<latitude>] [<longitude>] [<altitude>]', 'Sets new GIS data for specified agent');
+
+
 	print "\n";
 	exit;
 }
@@ -275,10 +280,11 @@ sub api_call($$$;$$$$) {
 		$params->{"other"} = $other;
 		$params->{"return_type"} = $return_type;
 		$params->{"other_mode"} = "url_encode_separator_|";
-		
+
 		# Call the API.
 		my $ua = new LWP::UserAgent;
 		my $url = $pa_config->{"console_api_url"};
+
 		my $response = $ua->post($url, $params);
 
 		if ($response->is_success) {
@@ -8043,6 +8049,14 @@ sub pandora_manage_main ($$$) {
 			param_check($ltotal, 4, 5);
 			cli_agent_update_custom_fields();
 		}
+		elsif ($param eq '--get_gis_agent') {
+			param_check($ltotal, 1, 0);
+			cli_get_gis_agent();
+		}
+		elsif ($param eq '--insert_gis_data'){
+			# param_check($ltotal, 4, 0);
+			cli_insert_gis_data();
+		}
 		else {
 			print_log "[ERROR] Invalid option '$param'.\n\n";
 			$param = '';
@@ -8763,3 +8777,32 @@ sub pandora_validate_alert_id($$$$) {
 
     return 1;
 }
+
+##############################################################################
+# Get GIS data from agent
+##############################################################################
+
+sub cli_get_gis_agent(){
+
+	my $agent_id = @ARGV[2];
+
+	my $result = api_call(\%conf,'get', 'gis_agent', $agent_id);
+	print "$result \n\n ";
+
+}
+
+##############################################################################
+# Set GIS data for specified agent
+##############################################################################
+
+sub cli_insert_gis_data(){
+
+	my ($agent_id, $latitude, $longitude, $altitude) = @ARGV[2..5];
+	my $agent_id = @ARGV[2];
+	my @position = @ARGV[3..5];
+	my $other = join('|', @position);
+
+	my $result = api_call(\%conf,'set', 'gis_agent_only_position', $agent_id, undef, "$other");
+	print "$result \n\n ";
+
+}
\ No newline at end of file

From 8a1740ddfb5dc5337abab76b819fa425e23c8240 Mon Sep 17 00:00:00 2001
From: Calvo <luis.calvo@artica.es>
Date: Thu, 22 Sep 2022 09:27:08 +0200
Subject: [PATCH 10/83] Added ldap timeout

---
 pandora_console/godmode/setup/setup_auth.php | 15 +++++++++++++++
 pandora_console/include/auth/mysql.php       | 20 +++++++++++++++-----
 pandora_console/include/functions_config.php |  8 ++++++++
 3 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/pandora_console/godmode/setup/setup_auth.php b/pandora_console/godmode/setup/setup_auth.php
index e1318f96c2..0a93a36da2 100644
--- a/pandora_console/godmode/setup/setup_auth.php
+++ b/pandora_console/godmode/setup/setup_auth.php
@@ -199,6 +199,21 @@ if (is_ajax()) {
                 );
                 $table->data['ldap_admin_pass'] = $row;
 
+                // Ldapsearch timeout.
+                // Default Ldapsearch timeout.
+                set_when_empty($config['ldap_searh_timeout'], 5);
+                $row = [];
+                $row['name'] = __('Ldap search timeout (secs)');
+                $row['control'] = html_print_input_text(
+                    'ldap_search_timeout',
+                    $config['ldap_search_timeout'],
+                    '',
+                    10,
+                    10,
+                    true
+                );
+                $table->data['ldap_search_timeout'] = $row;
+
                 // Enable/disable secondary ldap.
                 // Set default value.
                 set_unless_defined($config['secondary_ldap_enabled'], false);
diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php
index 67053ab0be..16ea1456f2 100644
--- a/pandora_console/include/auth/mysql.php
+++ b/pandora_console/include/auth/mysql.php
@@ -799,8 +799,16 @@ function ldap_process_user_login($login, $password, $secondary_server=false)
         return false;
     }
 
-    // Set the LDAP version
+    // Set the LDAP version.
     ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $ldap['ldap_version']);
+    ldap_set_option($ds, LDAP_OPT_NETWORK_TIMEOUT, 1);
+
+    // Set ldap search timeout.
+    ldap_set_option(
+        $ds,
+        LDAP_OPT_TIMELIMIT,
+        (empty($config['ldap_search_timmeout']) === true) ? 5 : ((int) $config['ldap_search_timeout'])
+    );
 
     if ($ldap['ldap_start_tls']) {
         if (!@ldap_start_tls($ds)) {
@@ -821,7 +829,8 @@ function ldap_process_user_login($login, $password, $secondary_server=false)
             io_safe_output($ldap['ldap_admin_login']),
             io_output_password($ldap['ldap_admin_pass']),
             io_safe_output($login),
-            $ldap['ldap_start_tls']
+            $ldap['ldap_start_tls'],
+            $config['ldap_search_timeout']
         );
 
         if ($sr) {
@@ -1430,7 +1439,8 @@ function local_ldap_search(
     $ldap_admin_user=null,
     $ldap_admin_pass=null,
     $user=null,
-    $ldap_start_tls=null
+    $ldap_start_tls=null,
+    $ldap_search_time=5
 ) {
     global $config;
 
@@ -1463,8 +1473,8 @@ function local_ldap_search(
     }
 
     $dn = " -b '".$dn."'";
-
-    $shell_ldap_search = explode("\n", shell_exec('ldapsearch -LLL -o ldif-wrap=no -x'.$ldap_host.$ldap_version.' -E pr=10000/noprompt '.$ldap_admin_user.$ldap_admin_pass.$dn.$filter.$tls.' | grep -v "^#\|^$" | sed "s/:\+ /=>/g"'));
+    $ldapsearch_command = 'ldapsearch -LLL -o ldif-wrap=no -o nettimeout='.$ldap_search_time.' -x'.$ldap_host.$ldap_version.' -E pr=10000/noprompt '.$ldap_admin_user.$ldap_admin_pass.$dn.$filter.$tls.' | grep -v "^#\|^$" | sed "s/:\+ /=>/g"';
+    $shell_ldap_search = explode("\n", shell_exec($ldapsearch_command));
     foreach ($shell_ldap_search as $line) {
         $values = explode('=>', $line);
         if (!empty($values[0]) && !empty($values[1])) {
diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php
index e0a3547ec5..f0b6691751 100644
--- a/pandora_console/include/functions_config.php
+++ b/pandora_console/include/functions_config.php
@@ -612,6 +612,10 @@ function config_update_config()
                         $error_update[] = __('Admin LDAP password');
                     }
 
+                    if (config_update_value('ldap_search_timeout', (int) get_parameter('ldap_search_timeout', 5), true) === false) {
+                        $error_update[] = __('Ldap search timeout');
+                    }
+
                     if (config_update_value('ldap_server_secondary', get_parameter('ldap_server_secondary'), true) === false) {
                         $error_update[] = __('Secondary LDAP server');
                     }
@@ -2651,6 +2655,10 @@ function config_process_config()
         config_update_value('ldap_admin_pass', '');
     }
 
+    if (!isset($config['ldap_search_timeout'])) {
+        config_update_value('ldap_search_timeout', 5);
+    }
+
     if (!isset($config['ldap_server_secondary'])) {
         config_update_value('ldap_server_secondary', 'localhost');
     }

From 9499da3176cf42be275ec210fabfbbe872a88525 Mon Sep 17 00:00:00 2001
From: Calvo <luis.calvo@artica.es>
Date: Thu, 22 Sep 2022 12:34:40 +0200
Subject: [PATCH 11/83] API and LDAP remote user fix with login error fix

---
 pandora_console/include/auth/mysql.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php
index 67053ab0be..cf11f7fc5f 100644
--- a/pandora_console/include/auth/mysql.php
+++ b/pandora_console/include/auth/mysql.php
@@ -289,7 +289,7 @@ function process_user_login_remote($login, $pass, $api=false)
 
     // Authentication ok, check if the user exists in the local database
     if (is_user($login)) {
-        if (!user_can_login($login)) {
+        if (!user_can_login($login) && $api === false) {
             return false;
         }
 

From eed28bc668504e382d6800ec9d76954dc6770ff7 Mon Sep 17 00:00:00 2001
From: Calvo <luis.calvo@artica.es>
Date: Thu, 22 Sep 2022 17:07:43 +0200
Subject: [PATCH 12/83] Fix user form reset if profile fails

---
 pandora_console/godmode/users/configure_user.php | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php
index 3ed36f8737..d98fc1d944 100644
--- a/pandora_console/godmode/users/configure_user.php
+++ b/pandora_console/godmode/users/configure_user.php
@@ -512,6 +512,14 @@ if ($create_user) {
 
                         $result_profile = profile_create_user_profile($id, $profile2, $group2, false, $tags, $no_hierarchy);
 
+                        if ($result_profile === false) {
+                            $is_err = true;
+                            $user_info = $values;
+                            $password_new = '';
+                            $password_confirm = '';
+                            $new_user = true;
+                        }
+
                         ui_print_result_message(
                             $result_profile,
                             __('Profile added successfully'),

From 795308367fb80bc5557dd6760f6e812e77cec526 Mon Sep 17 00:00:00 2001
From: Daniel Maya <daniel.maya@pandorafms.com>
Date: Fri, 23 Sep 2022 13:24:46 +0200
Subject: [PATCH 13/83] #9254 load password with ajax

---
 pandora_console/include/ajax/config.ajax.php  |  7 ++++++-
 pandora_console/include/javascript/pandora.js | 16 ++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/pandora_console/include/ajax/config.ajax.php b/pandora_console/include/ajax/config.ajax.php
index 1f0ea777f9..abe4d6f1ff 100644
--- a/pandora_console/include/ajax/config.ajax.php
+++ b/pandora_console/include/ajax/config.ajax.php
@@ -1,6 +1,7 @@
 <?php
 
 $token_name = get_parameter('token_name', 0);
+$no_boolean = (bool) get_parameter('no_boolean', 0);
 
 $value_token = db_get_value(
     'value',
@@ -9,4 +10,8 @@ $value_token = db_get_value(
     $token_name
 );
 
-echo (bool) $value_token;
+if ($no_boolean === true) {
+    echo json_encode(io_safe_output($value_token));
+} else {
+    echo (bool) $value_token;
+}
diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js
index d55be120e6..0e6ab73d01 100644
--- a/pandora_console/include/javascript/pandora.js
+++ b/pandora_console/include/javascript/pandora.js
@@ -2176,3 +2176,19 @@ $.fn.filterByText = function(textbox) {
       });
   });
 };
+
+function loadPasswordConfig(id, value) {
+  $.ajax({
+    url: "ajax.php",
+    data: {
+      page: "include/ajax/config.ajax",
+      token_name: `${value}`,
+      no_boolean: 1
+    },
+    type: "GET",
+    dataType: "json",
+    success: function(data) {
+      $(`#${id}`).val(data);
+    }
+  });
+}

From 225646cd9dca32b59c56a092e254b95b2d81f79b Mon Sep 17 00:00:00 2001
From: Daniel Barbero <daniel.barbero@artica.es>
Date: Fri, 23 Sep 2022 13:55:01 +0200
Subject: [PATCH 14/83] fixed response events pandora_enterprise#9423

---
 pandora_console/include/ajax/events.php       | 317 +++++-----
 pandora_console/include/functions_events.php  | 105 +++-
 pandora_console/include/functions_ui.php      |   7 +-
 .../include/javascript/pandora_events.js      | 551 +++++++-----------
 pandora_console/include/styles/events.css     |  33 ++
 5 files changed, 479 insertions(+), 534 deletions(-)

diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php
index c902a6479a..0d9dbda151 100644
--- a/pandora_console/include/ajax/events.php
+++ b/pandora_console/include/ajax/events.php
@@ -64,7 +64,8 @@ $add_comment = (bool) get_parameter('add_comment');
 $dialogue_event_response = (bool) get_parameter('dialogue_event_response');
 $perform_event_response = (bool) get_parameter('perform_event_response');
 $get_response = (bool) get_parameter('get_response');
-$get_response_target = (bool) get_parameter('get_response_target');
+$get_response_massive = (bool) get_parameter('get_response_massive');
+$get_row_response_action = (bool) get_parameter('get_row_response_action');
 $get_response_params = (bool) get_parameter('get_response_params');
 $get_response_description = (bool) get_parameter('get_response_description');
 $meta = get_parameter('meta', 0);
@@ -1090,50 +1091,6 @@ if ($get_response_params) {
     return;
 }
 
-if ($get_response_target === true) {
-    if (! check_acl($config['id_user'], 0, 'EW')) {
-        echo 'unauthorized';
-        return;
-    }
-
-    $response_id = (int) get_parameter('response_id');
-    $event_id = (int) get_parameter('event_id');
-    $server_id = (int) get_parameter('server_id');
-
-    try {
-        if (is_metaconsole() === true
-            && $server_id > 0
-        ) {
-            $node = new Node($server_id);
-            $node->connect();
-        }
-
-        $event_response = db_get_row('tevent_response', 'id', $response_id);
-
-        if (empty($event_response) === true) {
-            return;
-        }
-
-        echo events_get_response_target($event_id, $response_id);
-    } catch (\Exception $e) {
-        // Unexistent agent.
-        if (is_metaconsole() === true
-            && $server_id > 0
-        ) {
-            $node->disconnect();
-        }
-
-        return;
-    } finally {
-        if (is_metaconsole() === true
-            && $server_id > 0
-        ) {
-            $node->disconnect();
-        }
-    }
-
-    return;
-}
 
 if ($get_response === true) {
     if (! check_acl($config['id_user'], 0, 'EW')) {
@@ -1142,62 +1099,21 @@ if ($get_response === true) {
     }
 
     $response_id = get_parameter('response_id');
-    $server_id = (int) get_parameter('server_id');
+    $server_id = (int) get_parameter('server_id', 0);
+    $event_id = (int) get_parameter('event_id', 0);
 
-    try {
-        if (is_metaconsole() === true
-            && $server_id > 0
-        ) {
-            $node = new Node($server_id);
-            $node->connect();
-        }
-
-        $event_response = db_get_row(
-            'tevent_response',
-            'id',
-            $response_id
-        );
-    } catch (\Exception $e) {
-        // Unexistent agent.
-        if (is_metaconsole() === true
-            && $server_id > 0
-        ) {
-            $node->disconnect();
-        }
-
-        return;
-    } finally {
-        if (is_metaconsole() === true
-            && $server_id > 0
-        ) {
-            $node->disconnect();
-        }
-    }
+    $event_response = db_get_row(
+        'tevent_response',
+        'id',
+        $response_id
+    );
 
     if (empty($event_response) === true) {
-        return;
+        return [];
     }
 
-    echo json_encode($event_response);
 
-    return;
-}
-
-if ($perform_event_response === true) {
-    global $config;
-
-    if (! check_acl($config['id_user'], 0, 'EW')) {
-        echo 'unauthorized';
-        return;
-    }
-
-    $target = get_parameter('target', '');
-    $response_id = get_parameter('response_id');
-    $event_id = (int) get_parameter('event_id');
-    $server_id = (int) get_parameter('server_id', 0);
-
-    $event_response = false;
-    if (empty($target) === true) {
+    if (empty($event_id) === false) {
         try {
             if (is_metaconsole() === true
                 && $server_id > 0
@@ -1206,20 +1122,9 @@ if ($perform_event_response === true) {
                 $node->connect();
             }
 
-            $event_response = db_get_row(
-                'tevent_response',
-                'id',
-                $response_id
-            );
-
-            if (empty($event_response) === true) {
-                return;
-            }
-
-            $command = events_get_response_target(
+            $event_response['target'] = events_get_response_target(
                 $event_id,
-                $response_id,
-                $server_id
+                $event_response
             );
         } catch (\Exception $e) {
             // Unexistent agent.
@@ -1237,10 +1142,121 @@ if ($perform_event_response === true) {
                 $node->disconnect();
             }
         }
-    } else {
-        $command = $target;
     }
 
+    echo json_encode($event_response);
+
+    return;
+}
+
+
+if ($get_response_massive === true) {
+    if (! check_acl($config['id_user'], 0, 'EW')) {
+        echo 'unauthorized';
+        return;
+    }
+
+    $response_id = get_parameter('response_id');
+
+    $event_response = db_get_row(
+        'tevent_response',
+        'id',
+        $response_id
+    );
+
+    if (empty($event_response) === true) {
+        return [];
+    }
+
+
+    $events = json_decode(
+        io_safe_output(
+            get_parameter('events', '')
+        ),
+        true
+    );
+
+    $event_response_targets = [];
+    if (is_metaconsole() === true) {
+        foreach ($events as $server_id => $idEvents) {
+            foreach ($idEvents as $idEvent) {
+                $event_response_targets[$idEvent.'|'.$server_id]['target'] = get_events_get_response_target(
+                    $idEvent,
+                    $event_response,
+                    $server_id
+                );
+            }
+        }
+    } else {
+        foreach ($idEvents as $idEvent) {
+            $event_response_targets[$idEvent]['target'] = get_events_get_response_target(
+                $idEvent,
+                $event_response
+            );
+        }
+    }
+
+    $result = [
+        'event_response'         => $event_response,
+        'event_response_targets' => $event_response_targets,
+    ];
+
+    echo json_encode($result);
+
+    return;
+}
+
+if ($get_row_response_action === true) {
+    $response_id = get_parameter('response_id');
+    $response = json_decode(
+        io_safe_output(
+            get_parameter('response', '')
+        ),
+        true
+    );
+
+    $end = (bool) get_parameter('end', false);
+    $index = $response['event_id'];
+    if (is_metaconsole() === true) {
+        $index .= '-'.$response['server_id'];
+    }
+
+    echo get_row_response_action(
+        $response,
+        $response_id,
+        $end,
+        $index
+    );
+
+    return;
+}
+
+if ($perform_event_response === true) {
+    global $config;
+
+    if (! check_acl($config['id_user'], 0, 'EW')) {
+        echo __('unauthorized');
+        return;
+    }
+
+    $target = get_parameter('target', '');
+    $response_id = get_parameter('response_id');
+    $event_id = (int) get_parameter('event_id');
+    $server_id = (int) get_parameter('server_id', 0);
+    $response = json_decode(
+        io_safe_output(
+            get_parameter('response', '')
+        ),
+        true
+    );
+
+    $event_response = $response;
+    if (empty($event_response) === true) {
+        echo __('No data');
+        return;
+    }
+
+    $command = $event_response['target'];
     $command_timeout = ($event_response !== false) ? $event_response['command_timeout'] : 90;
     if (enterprise_installed() === true) {
         if ($event_response !== false
@@ -1320,7 +1336,7 @@ if ($perform_event_response === true) {
             break;
         }
 
-            system($timeout_bin.' '.$command_timeout.' '.io_safe_output($command).' 2>&1', $ret_val);
+        system($timeout_bin.' '.$command_timeout.' '.io_safe_output($command).' 2>&1', $ret_val);
     }
 
     if ($ret_val != 0) {
@@ -1343,78 +1359,19 @@ if ($dialogue_event_response) {
     $event_id = get_parameter('event_id');
     $response_id = get_parameter('response_id');
     $command = get_parameter('target');
-    $massive = get_parameter('massive');
-    $end = get_parameter('end');
-    $show_execute_again_btn = get_parameter('show_execute_again_btn');
-    $out_iterator = get_parameter('out_iterator');
-    $event_response = db_get_row('tevent_response', 'id', $response_id);
-    $server_id = get_parameter('server_id');
+    $event_response = json_decode(
+        io_safe_output(
+            get_parameter('response', '')
+        ),
+        true
+    );
 
-    $event = db_get_row('tevento', 'id_evento', $event_id);
-
-    $prompt = '<br>> ';
     switch ($event_response['type']) {
         case 'command':
-            $display_command = (bool) $event_response['display_command'];
-            $command_str = ($display_command === true) ? $command : '';
-
-            if ($massive) {
-                echo "<div class='left'>";
-                echo $prompt.sprintf(
-                    '(Event #'.$event_id.') '.__(
-                        'Executing command: %s',
-                        $command_str
-                    )
-                );
-                echo '</div><br>';
-
-                echo "<div id='response_loading_command_".$out_iterator."' style='display: none'>";
-                echo html_print_image(
-                    'images/spinner.gif',
-                    true
-                );
-                echo '</div><br>';
-                echo "<br><div id='response_out_".$out_iterator."'><br><br></div><br>";
-
-                if ($end) {
-                    echo "<br><div id='re_exec_command_".$out_iterator."' style='display: none'><br>";
-                    html_print_button(
-                        __('Execute again'),
-                        'btn_str',
-                        false,
-                        'execute_event_response(false);',
-                        "class='sub next'"
-                    );
-                    echo "<span id='execute_again_loading' style='display: none'>";
-                    echo html_print_image(
-                        'images/spinner.gif',
-                        true
-                    );
-                    echo '</span>';
-                    echo '</div>';
-                }
-            } else {
-                echo "<div class='left'>";
-
-                echo $prompt.'Executing command: '.$command_str;
-                echo '</div><br>';
-
-                echo "<div id='response_loading_command' style='display:none'>";
-                echo html_print_image('images/spinner.gif', true);
-                echo '</div>';
-                echo "<br><br><br><div id='response_out' class='left'></div>";
-
-                echo "<br><div id='re_exec_command' style='display:none'><br><br>";
-                html_print_button(
-                    __('Execute again'),
-                    'btn_str',
-                    false,
-                    "perform_response({'target':'".$command."','event_id':".$event_id.",'server_id':".$server_id.'}, '.$response_id.');',
-                    "class='sub next'"
-                );
-
-                echo '</div>';
-            }
+            echo get_row_response_action(
+                $event_response,
+                $response_id
+            );
         break;
 
         case 'url':
diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index c36536348f..5537a7b521 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -3430,7 +3430,7 @@ function events_page_responses($event)
             __('Execute'),
             'custom_response_button',
             false,
-            'execute_response('.$event['id_evento'].','.$server_id.')',
+            'execute_response('.$event['id_evento'].','.$server_id.',0)',
             "class='sub next w70p'",
             true
         );
@@ -3438,6 +3438,7 @@ function events_page_responses($event)
 
     $table_responses->data[] = $data;
 
+    // TODO quitar el async: false. get_response_params and get_response_description.
     $responses_js = "<script>
 			$('#select_custom_response').change(function() {
 				var id_response = $('#select_custom_response').val();
@@ -3477,7 +3478,7 @@ function events_page_responses($event)
  */
 function events_get_response_target(
     int $event_id,
-    int $response_id
+    array $event_response
 ) {
     global $config;
 
@@ -3490,9 +3491,7 @@ function events_get_response_target(
     }
 
     $event = db_get_row('tevento', 'id_evento', $event_id);
-    $event_response = db_get_row('tevent_response', 'id', $response_id);
     $target = io_safe_output($event_response['target']);
-
     if (strpos($target, '_agent_alias_') !== false) {
         $agente_table_name = 'tagente';
         $filter = ['id_agente' => $event['id_agente']];
@@ -5464,3 +5463,101 @@ function events_get_criticity_class($criticity)
         return 'datos_blue';
     }
 }
+
+
+// TODO
+function get_row_response_action(
+    array $event_response,
+    ?int $response_id,
+    $end=false,
+    $index=null
+) {
+    $output = '<div class="container-massive-events-response-cell">';
+    $display_command = (bool) $event_response['display_command'];
+    $command_str = ($display_command === true) ? $event_response['target'] : '';
+
+    // String command.
+    $output .= '<div class="container-massive-events-response-command">';
+    $output .= '<b>';
+    $output .= __('Event # %d', $event_response['event_id']);
+    if (empty($command_str) === false) {
+        $output .= ' ';
+        $output .= __('Executing command: ');
+    }
+
+    $output .= '</b>';
+    $output .= '<span>'.$command_str.'</span>';
+    $output .= '</div>';
+
+    // Spinner.
+    $output .= '<div id="response_loading_command'.$index.'" style="display:none">';
+    $output .= html_print_image(
+        'images/spinner.gif',
+        true
+    );
+    $output .= '</div>';
+
+    // Output.
+    $output .= '<div id="response_out'.$index.'" class="container-massive-events-response-output"></div>';
+
+    // Butom.
+    $output .= '<div id="re_exec_command'.$index.'" style="display:none" class="container-massive-events-response-execute">';
+    $output .= html_print_button(
+        __('Execute again'),
+        'btn_str',
+        false,
+        'perform_response(\''.base64_encode(json_encode($event_response)).'\','.$response_id.',\''.trim($index).'\')',
+        "class='sub next'",
+        true
+    );
+    $output .= '</div>';
+
+    $output .= '</div>';
+
+    return $output;
+}
+
+
+/**
+ * Get evet get response target.
+ *
+ * @param integer $event_id       Id event.
+ * @param array   $event_response Response.
+ * @param integer $server_id      Server id.
+ *
+ * @return string
+ */
+function get_events_get_response_target(
+    $event_id,
+    $event_response,
+    $server_id=0
+) {
+    try {
+        if (is_metaconsole() === true
+            && $server_id > 0
+        ) {
+            $node = new Node($server_id);
+            $node->connect();
+        }
+
+        return events_get_response_target(
+            $event_id,
+            $event_response
+        );
+    } catch (\Exception $e) {
+        // Unexistent agent.
+        if (is_metaconsole() === true
+            && $server_id > 0
+        ) {
+            $node->disconnect();
+        }
+
+        return '';
+    } finally {
+        if (is_metaconsole() === true
+            && $server_id > 0
+        ) {
+            $node->disconnect();
+        }
+    }
+}
diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php
index 9db7f80fb7..8bd84d0e02 100755
--- a/pandora_console/include/functions_ui.php
+++ b/pandora_console/include/functions_ui.php
@@ -3402,7 +3402,7 @@ function ui_print_datatable(array $parameters)
         $filter .= '</li>';
 
         $filter .= '</ul><div id="both"></div></form>';
-        if (isset($parameters['form']['no_toggle']) === false && ($parameters['form']['no_toggle'] !== true)) {
+        if (isset($parameters['form']['no_toggle']) === false) {
             $filter = ui_toggle(
                 $filter,
                 __('Filter'),
@@ -3466,7 +3466,10 @@ function ui_print_datatable(array $parameters)
     foreach ($names as $column) {
         if (is_array($column)) {
             $table .= '<th id="'.$column['id'].'" class="'.$column['class'].'" ';
-            $table .= 'title="'.__($column['title']).'" ';
+            if (isset($column['title']) === true) {
+                $table .= 'title="'.__($column['title']).'" ';
+            }
+
             $table .= ' style="'.$column['style'].'">'.__($column['text']);
             $table .= $column['extra'];
             $table .= '</th>';
diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js
index b7f4170afa..5e0ec83920 100644
--- a/pandora_console/include/javascript/pandora_events.js
+++ b/pandora_console/include/javascript/pandora_events.js
@@ -85,29 +85,6 @@ function show_event_dialog(event, dialog_page) {
       $("#refrcounter").countdown("pause");
       $("div.vc-countdown").countdown("pause");
 
-      /*
-      switch (result) {
-        case "comment_ok":
-          $("#notification_comment_success").show();
-          break;
-        case "comment_error":
-          $("#notification_comment_error").show();
-          break;
-        case "status_ok":
-          $("#notification_status_success").show();
-          break;
-        case "status_error":
-          $("#notification_status_error").show();
-          break;
-        case "owner_ok":
-          $("#notification_owner_success").show();
-          break;
-        case "owner_error":
-          $("#notification_owner_error").show();
-          break;
-      }
-      */
-
       forced_title_callback();
     },
     "html"
@@ -119,37 +96,129 @@ function show_event_dialog(event, dialog_page) {
 function execute_response(event_id, server_id) {
   var response_id = $("#select_custom_response option:selected").val();
 
-  var response = get_response(response_id, server_id);
+  var params = [];
+  params.push({ name: "page", value: "include/ajax/events" });
+  params.push({ name: "get_response", value: 1 });
+  params.push({ name: "response_id", value: response_id });
+  params.push({ name: "server_id", value: server_id });
+  params.push({ name: "event_id", value: event_id });
 
-  // If cannot get response abort it
-  if (response == null) {
-    return;
-  }
+  jQuery.ajax({
+    data: params,
+    type: "POST",
+    url: $("#hidden-ajax_file").val(),
+    dataType: "json",
+    success: function(response) {
+      // If cannot get response abort it
+      if (response == null) {
+        return [];
+      }
 
-  response["target"] = get_response_target(event_id, response_id, server_id);
-  response["event_id"] = event_id;
-  response["server_id"] = server_id;
+      response["event_id"] = event_id;
+      response["server_id"] = server_id;
+      if (response["type"] == "url" && response["new_window"] == 1) {
+        window.open(response["target"], "_blank");
+      } else {
+        show_response_dialog(response_id, response);
+      }
+    }
+  });
+}
 
-  if (response["type"] == "url" && response["new_window"] == 1) {
-    window.open(response["target"], "_blank");
-  } else {
-    show_response_dialog(response_id, response);
-  }
+// Check the response type and open it in a modal dialog or new window
+function execute_response_massive(events, response_id) {
+  var params = [];
+  params.push({ name: "page", value: "include/ajax/events" });
+  params.push({ name: "get_response_massive", value: 1 });
+  params.push({ name: "response_id", value: response_id });
+  params.push({ name: "events", value: JSON.stringify(events) });
+
+  jQuery.ajax({
+    data: params,
+    type: "POST",
+    url: $("#hidden-ajax_file").val(),
+    dataType: "json",
+    success: function(data) {
+      // If cannot get response abort it
+      if (data == null) {
+        return [];
+      }
+
+      $(".container-massive-events-response").empty();
+
+      // Convert to array.
+      var array_data = Object.entries(data.event_response_targets);
+      var total_count = array_data.length;
+
+      // Each input checkeds.
+      array_data.forEach(function(element, index) {
+        var id = element[0];
+        var target = element[1].target;
+        var meta = $("#hidden-meta").val();
+        var event_id = id;
+        var server_id = 0;
+        if (meta != 0) {
+          var split_id = id.split("|");
+          event_id = split_id[0];
+          server_id = split_id[1];
+        }
+
+        var end = 0;
+        if (total_count - 1 === index) {
+          end = 1;
+        }
+
+        var response = data.event_response;
+        response["event_id"] = event_id;
+        response["server_id"] = server_id;
+        response["target"] = target;
+        if (response["type"] == "url" && response["new_window"] == 1) {
+          window.open(response["target"], "_blank");
+        } else {
+          var params = [];
+          params.push({ name: "page", value: "include/ajax/events" });
+          params.push({ name: "get_row_response_action", value: 1 });
+          params.push({ name: "response_id", value: response_id });
+          params.push({ name: "server_id", value: response.server_id });
+          params.push({ name: "end", value: end });
+          params.push({ name: "response", value: JSON.stringify(response) });
+
+          jQuery.ajax({
+            data: params,
+            type: "POST",
+            url: $("#hidden-ajax_file").val(),
+            dataType: "html",
+            success: function(data) {
+              $(".container-massive-events-response").append(data);
+              response["event_id"] = event_id;
+              response["server_id"] = server_id;
+              response["target"] = target;
+              perform_response(
+                btoa(JSON.stringify(response)),
+                response_id,
+                event_id + "-" + server_id
+              );
+            }
+          });
+        }
+      });
+    }
+  });
 }
 
 //Show the modal window of an event response
 function show_response_dialog(response_id, response) {
   var params = [];
-  params.push("page=include/ajax/events");
-  params.push("dialogue_event_response=1");
-  params.push("massive=0");
-  params.push("event_id=" + response["event_id"]);
-  params.push("target=" + encodeURIComponent(response["target"]));
-  params.push("response_id=" + response_id);
-  params.push("server_id=" + response["server_id"]);
+  params.push({ name: "page", value: "include/ajax/events" });
+  params.push({ name: "dialogue_event_response", value: 1 });
+  params.push({ name: "event_id", value: response.event_id });
+  params.push({ name: "target", value: response.target });
+  params.push({ name: "response_id", value: response_id });
+  params.push({ name: "server_id", value: response.server_id });
+  params.push({ name: "response", value: JSON.stringify(response) });
 
   jQuery.ajax({
-    data: params.join("&"),
+    data: params,
     type: "POST",
     url: $("#hidden-ajax_file").val(),
     dataType: "html",
@@ -164,7 +233,7 @@ function show_response_dialog(response_id, response) {
           draggable: true,
           modal: false,
           open: function() {
-            perform_response(response, response_id);
+            perform_response(btoa(JSON.stringify(response)), response_id, "");
           },
           width: response["modal_width"],
           height: response["modal_height"]
@@ -174,89 +243,6 @@ function show_response_dialog(response_id, response) {
   });
 }
 
-//Show the modal window of event responses when multiple events are selected
-function show_massive_response_dialog(
-  response_id,
-  response,
-  out_iterator,
-  end
-) {
-  var params = [];
-  params.push("page=include/ajax/events");
-  params.push("dialogue_event_response=1");
-  params.push("massive=1");
-  params.push("end=" + end);
-  params.push("out_iterator=" + out_iterator);
-  params.push("event_id=" + response["event_id"]);
-  params.push("target=" + response["target"]);
-  params.push("response_id=" + response_id);
-  params.push("server_id=" + response["server_id"]);
-
-  jQuery.ajax({
-    data: params.join("&"),
-    response_tg: response,
-    response_id: response_id,
-    out_iterator: out_iterator,
-    type: "POST",
-    url: $("#hidden-ajax_file").val(),
-    dataType: "html",
-    success: function(data) {
-      if (out_iterator === 0) $("#event_response_window").empty();
-
-      $("#event_response_window")
-        .hide()
-        .append(data)
-        .dialog({
-          title: $("#select_custom_response option:selected").html(),
-          resizable: true,
-          draggable: true,
-          modal: false,
-          open: function() {
-            $("#response_loading_dialog").hide();
-            $("#button-submit_event_response").show();
-          },
-          close: function() {
-            $("#checkbox-all_validate_box").prop("checked", false);
-            $(".chk_val").prop("checked", false);
-          },
-          width: response["modal_width"],
-          height: response["modal_height"]
-        })
-        .show();
-
-      perform_response_massive(
-        this.response_tg,
-        this.response_id,
-        this.out_iterator
-      );
-    }
-  });
-}
-
-// Get an event response from db
-function get_response(response_id, server_id) {
-  var response = "";
-
-  var params = [];
-  params.push("page=include/ajax/events");
-  params.push("get_response=1");
-  params.push("response_id=" + response_id);
-  params.push("server_id=" + server_id);
-
-  jQuery.ajax({
-    data: params.join("&"),
-    type: "POST",
-    url: $("#hidden-ajax_file").val(),
-    async: false,
-    dataType: "json",
-    success: function(data) {
-      response = data;
-    }
-  });
-
-  return response;
-}
-
 // Get an event response params from db
 function get_response_params(response_id) {
   var response_params;
@@ -315,120 +301,38 @@ function add_row_param(id_table, param) {
   );
 }
 
-// Get an event response from db
-function get_response_target(
-  event_id,
-  response_id,
-  server_id,
-  response_command
-) {
-  var target = "";
+// Perform a response and put the output into a div
+function perform_response(response, response_id, index) {
+  $("#re_exec_command" + index).hide();
+  $("#response_loading_command" + index).show();
+  $("#response_out" + index).html("");
 
-  // Replace the main macros
-  var params = [];
-  params.push("page=include/ajax/events");
-  params.push("get_response_target=1");
-  params.push("event_id=" + event_id);
-  params.push("response_id=" + response_id);
-  params.push("server_id=" + server_id);
-
-  jQuery.ajax({
-    data: params.join("&"),
-    type: "POST",
-    url: $("#hidden-ajax_file").val(),
-    async: false,
-    dataType: "html",
-    success: function(data) {
-      target = data;
-    }
-  });
-
-  // Replace the custom params macros.
-  var response_params = get_response_params(response_id);
-  if (response_params.length > 1 || response_params[0] != "") {
-    for (var i = 0; i < response_params.length; i++) {
-      if (!response_command) {
-        var response_param = "_" + response_params[i] + "_";
-
-        if (
-          response_params[i].startsWith("_") &&
-          response_params[i].endsWith("_")
-        ) {
-          response_param = response_params[i];
-        }
-
-        target = target.replace(
-          response_param,
-          $("#" + response_params[i]).val()
-        );
-      } else {
-        target = target.replace(
-          "_" + response_params[i] + "_",
-          response_command[response_params[i] + "-" + i]
-        );
-      }
-    }
+  try {
+    response = JSON.parse(atob(response));
+  } catch (e) {
+    console.error(e);
+    return;
   }
 
-  return target;
-}
-
-// Perform a response and put the output into a div
-function perform_response(response, response_id) {
-  $("#re_exec_command").hide();
-  $("#response_loading_command").show();
-  $("#response_out").html("");
-
   var params = [];
-  params.push("page=include/ajax/events");
-  params.push("perform_event_response=1");
-  params.push("target=" + encodeURIComponent(response["target"]));
-  params.push("response_id=" + response_id);
-  params.push("event_id=" + response["event_id"]);
-  params.push("server_id=" + response["server_id"]);
+  params.push({ name: "page", value: "include/ajax/events" });
+  params.push({ name: "perform_event_response", value: 1 });
+  params.push({ name: "target", value: response["target"] });
+  params.push({ name: "response_id", value: response_id });
+  params.push({ name: "event_id", value: response["event_id"] });
+  params.push({ name: "server_id", value: response["server_id"] });
+  params.push({ name: "response", value: JSON.stringify(response) });
 
   jQuery.ajax({
-    data: params.join("&"),
+    data: params,
     type: "POST",
     url: $("#hidden-ajax_file").val(),
-    async: true,
     dataType: "html",
     success: function(data) {
       var out = data.replace(/[\n|\r]/g, "<br>");
-      $("#response_out").html(out);
-      $("#response_loading_command").hide();
-      $("#re_exec_command").show();
-    }
-  });
-
-  return false;
-}
-
-// Perform a response and put the output into a div
-function perform_response_massive(response, response_id, out_iterator) {
-  $("#re_exec_command").hide();
-  $("#response_loading_command_" + out_iterator).show();
-  $("#response_out_" + out_iterator).html("");
-
-  var params = [];
-  params.push("page=include/ajax/events");
-  params.push("perform_event_response=1");
-  params.push("target=" + response["target"]);
-  params.push("response_id=" + response_id);
-  params.push("event_id=" + response["event_id"]);
-  params.push("server_id=" + response["server_id"]);
-
-  jQuery.ajax({
-    data: params.join("&"),
-    type: "POST",
-    url: $("#hidden-ajax_file").val(),
-    async: true,
-    dataType: "html",
-    success: function(data) {
-      var out = data.replace(/[\n|\r]/g, "<br>");
-      $("#response_out_" + out_iterator).html(out);
-      $("#response_loading_command_" + out_iterator).hide();
-      $("#re_exec_command_" + out_iterator).show();
+      $("#response_out" + index).html(out);
+      $("#response_loading_command" + index).hide();
+      $("#re_exec_command" + index).show();
     }
   });
 
@@ -594,54 +498,6 @@ function event_comment(current_event) {
   return false;
 }
 
-function show_event_response_command_dialog(id, response, total_checked) {
-  var params = [];
-  params.push("page=include/ajax/events");
-  params.push("get_table_response_command=1");
-  params.push("event_response_id=" + id);
-
-  jQuery.ajax({
-    data: params.join("&"),
-    type: "POST",
-    url: $("#hidden-ajax_file").val(),
-    dataType: "html",
-    success: function(data) {
-      $("#event_response_command_window")
-        .hide()
-        .empty()
-        .append(data)
-        .dialog({
-          resizable: true,
-          draggable: true,
-          modal: false,
-          open: function() {
-            $("#response_loading_dialog").hide();
-            $("#button-submit_event_response").show();
-          },
-          width: 600,
-          height: 300
-        })
-        .show();
-
-      $("#submit-enter_command").on("click", function(e) {
-        e.preventDefault();
-        var response_command = [];
-
-        $(".response_command_input").each(function() {
-          response_command[$(this).attr("name")] = $(this).val();
-        });
-
-        check_massive_response_event(
-          id,
-          response,
-          total_checked,
-          response_command
-        );
-      });
-    }
-  });
-}
-
 var processed = 0;
 function update_event(table, id_evento, type, event_rep, row, server_id) {
   var inputs = $("#events_form :input");
@@ -838,58 +694,14 @@ function execute_event_response(event_list_btn) {
       }
 
       if (!isNaN(response_id)) {
-        // It is a custom response
-        var response = get_response(response_id);
-
-        // If cannot get response abort it
-        if (response == null) {
-          return;
-        }
-
-        // Limit number of events to apply custom responses
-        // due performance reasons.
-        if (total_checked > $("#max_execution_event_response").val()) {
-          $("#max_custom_event_resp_msg").show();
-          return;
-        }
-
-        var response_command = [];
-        $(".response_command_input").each(function() {
-          response_command[$(this).attr("name")] = $(this).val();
-        });
-
         if (event_list_btn) {
           $("#button-submit_event_response").hide(function() {
             $("#response_loading_dialog").show(function() {
-              var check_params = get_response_params(response_id);
-
-              if (check_params[0] !== "") {
-                show_event_response_command_dialog(
-                  response_id,
-                  response,
-                  total_checked
-                );
-              } else {
-                check_massive_response_event(
-                  response_id,
-                  response,
-                  total_checked,
-                  response_command
-                );
-              }
+              show_response_dialog_massive(response_id);
             });
           });
         } else {
-          $("#button-btn_str").hide(function() {
-            $("#execute_again_loading").show(function() {
-              check_massive_response_event(
-                response_id,
-                response,
-                total_checked,
-                response_command
-              );
-            });
-          });
+          check_execute_response_massive(response_id);
         }
       } else {
         // It is not a custom response
@@ -964,15 +776,63 @@ function execute_event_response(event_list_btn) {
   });
 }
 
-function check_massive_response_event(
-  response_id,
-  response,
-  total_checked,
-  response_command
-) {
-  var counter = 0;
-  var end = 0;
+function show_response_dialog_massive(response_id) {
+  var params = [];
+  params.push({ name: "page", value: "include/ajax/events" });
+  params.push({ name: "get_response", value: 1 });
+  params.push({ name: "response_id", value: response_id });
 
+  jQuery.ajax({
+    data: params,
+    type: "POST",
+    url: $("#hidden-ajax_file").val(),
+    dataType: "json",
+    success: function(response) {
+      // If cannot get response abort it
+      if (response == null) {
+        return [];
+      }
+
+      $("#event_response_window")
+        .hide()
+        .empty()
+        .append('<div class="container-massive-events-response"></div>')
+        .dialog({
+          title: $("#response_id option:selected").html(),
+          resizable: true,
+          draggable: true,
+          modal: false,
+          open: function() {
+            check_execute_response_massive(response_id);
+          },
+          close: function() {
+            $("#checkbox-all_validate_box").prop("checked", false);
+            $(".chk_val").prop("checked", false);
+            $("#response_loading_dialog").hide();
+            $("#button-submit_event_response").show();
+          },
+          buttons: [
+            {
+              text: "Execute All",
+              id: "execute-again-all",
+              class:
+                "ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next",
+              click: function() {
+                execute_event_response(false);
+              }
+            }
+          ],
+          width: response["modal_width"],
+          height: response["modal_height"]
+        })
+        .show();
+    }
+  });
+}
+
+function check_execute_response_massive(response_id) {
+  var events = [];
+  $(".container-massive-events-response").empty();
   $(".chk_val:checked").each(function() {
     var event_id = $(this).val();
     var meta = $("#hidden-meta").val();
@@ -981,23 +841,18 @@ function check_massive_response_event(
       var split_id = event_id.split("|");
       event_id = split_id[0];
       server_id = split_id[1];
+
+      if (events[server_id] === undefined) {
+        events[server_id] = [];
+      }
+
+      events[server_id].push(event_id);
+    } else {
+      events.push(event_id);
     }
-
-    response["target"] = get_response_target(
-      event_id,
-      response_id,
-      server_id,
-      response_command
-    );
-    response["server_id"] = server_id;
-    response["event_id"] = event_id;
-
-    if (total_checked - 1 === counter) end = 1;
-
-    show_massive_response_dialog(response_id, response, counter, end);
-
-    counter++;
   });
+
+  execute_response_massive(events, response_id);
 }
 
 function event_widget_options() {
diff --git a/pandora_console/include/styles/events.css b/pandora_console/include/styles/events.css
index 2e92c0d302..5ad4579f61 100644
--- a/pandora_console/include/styles/events.css
+++ b/pandora_console/include/styles/events.css
@@ -396,3 +396,36 @@ div.multi-response-buttons {
 .white_table_graph_header {
   align-items: center;
 }
+
+.container-massive-events-response {
+  display: flex;
+  flex-direction: column;
+  justify-content: flex-start;
+  align-items: flex-start;
+}
+
+.container-massive-events-response-cell {
+  margin-bottom: 10px;
+  width: 100%;
+  display: flex;
+  flex-direction: column;
+  justify-content: flex-start;
+  align-content: flex-start;
+}
+
+.container-massive-events-response-command > span {
+  font-style: italic;
+}
+
+.container-massive-events-response-output {
+  /*border: 2px dashed #ddd;*/
+  /*padding: 10px;*/
+  margin: 10px;
+}
+
+.container-massive-events-response-execute {
+  display: flex;
+  flex-direction: row;
+  justify-content: flex-end;
+  align-items: center;
+}

From bf5a5e16dc4e36d460cc144cdb7ce169d1282b34 Mon Sep 17 00:00:00 2001
From: Calvo <luis.calvo@artica.es>
Date: Mon, 26 Sep 2022 12:49:00 +0200
Subject: [PATCH 15/83] Fix agent edtion unique ip issues

---
 pandora_console/godmode/agentes/configurar_agente.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php
index af29579055..ace8b9c106 100644
--- a/pandora_console/godmode/agentes/configurar_agente.php
+++ b/pandora_console/godmode/agentes/configurar_agente.php
@@ -1047,7 +1047,7 @@ if ($update_agent) {
         // If there is an agent with the same name, but a different ID.
     }
 
-    if ($unique_ip && $direccion_agente != '') {
+    if ($direccion_agente !== $address_list && (bool) $unique_ip === true && $direccion_agente != '') {
         $sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"';
         $exists_ip  = db_get_row_sql($sql);
     }

From fbce8b7533ae507407eb91eea4389151114caa8d Mon Sep 17 00:00:00 2001
From: Daniel Barbero <daniel.barbero@artica.es>
Date: Tue, 27 Sep 2022 09:51:37 +0200
Subject: [PATCH 16/83] fixed response events pandora_enterprise#9423

---
 pandora_console/include/ajax/events.php       | 138 ++++++++++-----
 pandora_console/include/functions_events.php  |  77 ++++++---
 .../include/javascript/pandora_events.js      | 163 ++++++++++--------
 pandora_console/include/styles/events.css     |  23 +++
 .../agentes/estado_generalagente.php          |   5 +-
 5 files changed, 267 insertions(+), 139 deletions(-)

diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php
index 0d9dbda151..dbb7924517 100644
--- a/pandora_console/include/ajax/events.php
+++ b/pandora_console/include/ajax/events.php
@@ -66,8 +66,7 @@ $perform_event_response = (bool) get_parameter('perform_event_response');
 $get_response = (bool) get_parameter('get_response');
 $get_response_massive = (bool) get_parameter('get_response_massive');
 $get_row_response_action = (bool) get_parameter('get_row_response_action');
-$get_response_params = (bool) get_parameter('get_response_params');
-$get_response_description = (bool) get_parameter('get_response_description');
+$draw_row_response_info = (bool) get_parameter('draw_row_response_info', false);
 $meta = get_parameter('meta', 0);
 $history = get_parameter('history', 0);
 $table_events = get_parameter('table_events', 0);
@@ -1055,43 +1054,6 @@ $(document).ready(function (){
 }
 
 
-if ($get_response_description) {
-    $response_id = get_parameter('response_id');
-
-    $description = db_get_value('description', 'tevent_response', 'id', $response_id);
-
-    if ($description === false) {
-        return;
-    }
-
-    $description = io_safe_output($description);
-    $description = str_replace("\r\n", '<br>', $description);
-
-    echo $description;
-
-    return;
-}
-
-if ($get_response_params) {
-    if (! check_acl($config['id_user'], 0, 'EW')) {
-        echo 'unauthorized';
-        return;
-    }
-
-    $response_id = get_parameter('response_id');
-
-    $params = db_get_value('params', 'tevent_response', 'id', $response_id);
-
-    if ($params === false) {
-        return;
-    }
-
-    echo json_encode(explode(',', $params));
-
-    return;
-}
-
-
 if ($get_response === true) {
     if (! check_acl($config['id_user'], 0, 'EW')) {
         echo 'unauthorized';
@@ -1101,6 +1063,12 @@ if ($get_response === true) {
     $response_id = get_parameter('response_id');
     $server_id = (int) get_parameter('server_id', 0);
     $event_id = (int) get_parameter('event_id', 0);
+    $response_parameters = json_decode(
+        io_safe_output(
+            get_parameter('response_parameters', '')
+        ),
+        true
+    );
 
     $event_response = db_get_row(
         'tevent_response',
@@ -1124,7 +1092,8 @@ if ($get_response === true) {
 
             $event_response['target'] = events_get_response_target(
                 $event_id,
-                $event_response
+                $event_response,
+                $response_parameters
             );
         } catch (\Exception $e) {
             // Unexistent agent.
@@ -1168,7 +1137,6 @@ if ($get_response_massive === true) {
         return [];
     }
 
-
     $events = json_decode(
         io_safe_output(
             get_parameter('events', '')
@@ -1176,6 +1144,13 @@ if ($get_response_massive === true) {
         true
     );
 
+    $response_parameters = json_decode(
+        io_safe_output(
+            get_parameter('response_parameters', '')
+        ),
+        true
+    );
+
     $event_response_targets = [];
     if (is_metaconsole() === true) {
         foreach ($events as $server_id => $idEvents) {
@@ -1183,15 +1158,18 @@ if ($get_response_massive === true) {
                 $event_response_targets[$idEvent.'|'.$server_id]['target'] = get_events_get_response_target(
                     $idEvent,
                     $event_response,
-                    $server_id
+                    $server_id,
+                    $response_parameters
                 );
             }
         }
     } else {
-        foreach ($idEvents as $idEvent) {
+        foreach ($events as $idEvent) {
             $event_response_targets[$idEvent]['target'] = get_events_get_response_target(
                 $idEvent,
-                $event_response
+                $event_response,
+                0,
+                $response_parameters
             );
         }
     }
@@ -2491,3 +2469,75 @@ if ($get_events_fired) {
     echo io_json_mb_encode($return);
     return;
 }
+
+if ($draw_row_response_info === true) {
+    $event_response = json_decode(
+        io_safe_output(
+            get_parameter('response', '')
+        ),
+        true
+    );
+
+    $massive = (bool) get_parameter('massive', false);
+
+    $output .= '';
+    if ($massive === true) {
+        $output .= '<div>';
+        $output .= '<h5>';
+        $output .= $event_response['description'];
+        $output .= '</h5>';
+        $output .= '</div>';
+    } else {
+        $output .= '<tr class="params_rows">';
+        $output .= '<td>';
+        $output .= __('Description');
+        $output .= '</td>';
+        $output .= '<td class="height_30px" colspan="2">';
+        $output .= $event_response['description'];
+        $output .= '</td>';
+        $output .= '</tr>';
+    }
+
+    if (empty($event_response['params']) === false) {
+        $response_params = explode(',', $event_response['params']);
+        if (is_array($response_params) === true) {
+            if ($massive === true) {
+                $output .= '<div>';
+            } else {
+                $output .= '<tr class="params_rows">';
+                $output .= '<td class="left pdd_l_20px height_30px" colspan="3">';
+                $output .= __('Parameters');
+                $output .= '</td>';
+                $output .= '</tr>';
+            }
+
+            foreach ($response_params as $param) {
+                $param = trim(io_safe_output($param));
+                if ($massive === true) {
+                    $output .= '<div>';
+                    $output .= '<label>';
+                    $output .= $param;
+                    $output .= '</label>';
+                    $output .= '<input type="text" name="values_params_'.$param.'" />';
+                    $output .= '</div>';
+                } else {
+                    $output .= '<tr class="params_rows">';
+                    $output .= '<td style="text-align:left; padding-left:40px; font-weight: normal; font-style: italic;">';
+                    $output .= $param;
+                    $output .= '</td>';
+                    $output .= '<td style="text-align:left" colspan="2">';
+                    $output .= '<input type="text" name="values_params_'.$param.'" />';
+                    $output .= '</td>';
+                    $output .= '</tr>';
+                }
+            }
+
+            if ($massive === true) {
+                $output .= '</div>';
+            }
+        }
+    }
+
+    echo $output;
+    return;
+}
diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index 5537a7b521..c3345cf9db 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -3438,31 +3438,18 @@ function events_page_responses($event)
 
     $table_responses->data[] = $data;
 
-    // TODO quitar el async: false. get_response_params and get_response_description.
     $responses_js = "<script>
 			$('#select_custom_response').change(function() {
 				var id_response = $('#select_custom_response').val();
-				var params = get_response_params(id_response);
-				var description = get_response_description(id_response);
-				$('.params_rows').remove();
-				$('#responses_table')
-					.append('<tr class=\"params_rows\"><td>".__('Description')."</td><td class=\"height_30px\" colspan=\"2\">'+description+'</td></tr>');
-
-				if (params.length == 1 && params[0] == '') {
-					return;
-				}
-
-				$('#responses_table')
-					.append('<tr class=\"params_rows\"><td class=\"left pdd_l_20px height_30px\" colspan=\"3\">".__('Parameters')."</td></tr>');
-
-				for (i = 0; i < params.length; i++) {
-					add_row_param('responses_table',params[i]);
-				}
+                table_info_response_event(id_response,".$event['id_evento'].','.$event['server_id'].");
 			});
 			$('#select_custom_response').trigger('change');
 			</script>";
 
-    $responses = '<div id="extended_event_responses_page" class="extended_event_pages">'.html_print_table($table_responses, true).$responses_js.'</div>';
+    $responses = '<div id="extended_event_responses_page" class="extended_event_pages">';
+    $responses .= html_print_table($table_responses, true);
+    $responses .= $responses_js;
+    $responses .= '</div>';
 
     return $responses;
 }
@@ -3471,14 +3458,16 @@ function events_page_responses($event)
 /**
  * Replace macros in the target of a response and return it.
  *
- * @param integer $event_id    Event identifier.
- * @param integer $response_id Event response identifier.
+ * @param integer    $event_id            Event identifier.
+ * @param array      $event_response      Event Response.
+ * @param array|null $response_parameters If parameters response values.
  *
  * @return string The response text with the macros applied.
  */
 function events_get_response_target(
     int $event_id,
-    array $event_response
+    array $event_response,
+    ?array $response_parameters=null
 ) {
     global $config;
 
@@ -3492,6 +3481,35 @@ function events_get_response_target(
 
     $event = db_get_row('tevento', 'id_evento', $event_id);
     $target = io_safe_output($event_response['target']);
+
+    // Replace parameters response.
+    if (isset($response_parameters) === true
+        && empty($response_parameters) === false
+    ) {
+        $response_parameters = array_reduce(
+            $response_parameters,
+            function ($carry, $item) {
+                $carry[$item['name']] = $item['value'];
+                return $carry;
+            }
+        );
+    }
+
+    if (empty($event_response['params']) === false) {
+        $response_params = explode(',', $event_response['params']);
+        if (is_array($response_params) === true) {
+            foreach ($response_params as $param) {
+                $param = trim(io_safe_output($param));
+                $target = str_replace(
+                    '_'.$param.'_',
+                    $response_parameters['values_params_'.$param],
+                    $target
+                );
+            }
+        }
+    }
+
+    // Replace macros.
     if (strpos($target, '_agent_alias_') !== false) {
         $agente_table_name = 'tagente';
         $filter = ['id_agente' => $event['id_agente']];
@@ -5465,7 +5483,16 @@ function events_get_criticity_class($criticity)
 }
 
 
-// TODO
+/**
+ * Draw row response events.
+ *
+ * @param array        $event_response Response.
+ * @param integer|null $response_id    Id .
+ * @param boolean      $end            End block.
+ * @param integer|null $index          Index block.
+ *
+ * @return string Html output.
+ */
 function get_row_response_action(
     array $event_response,
     ?int $response_id,
@@ -5530,7 +5557,8 @@ function get_row_response_action(
 function get_events_get_response_target(
     $event_id,
     $event_response,
-    $server_id=0
+    $server_id=0,
+    $response_parameters=[]
 ) {
     try {
         if (is_metaconsole() === true
@@ -5542,7 +5570,8 @@ function get_events_get_response_target(
 
         return events_get_response_target(
             $event_id,
-            $event_response
+            $event_response,
+            $response_parameters
         );
     } catch (\Exception $e) {
         // Unexistent agent.
diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js
index 5e0ec83920..17fac351f3 100644
--- a/pandora_console/include/javascript/pandora_events.js
+++ b/pandora_console/include/javascript/pandora_events.js
@@ -96,12 +96,28 @@ function show_event_dialog(event, dialog_page) {
 function execute_response(event_id, server_id) {
   var response_id = $("#select_custom_response option:selected").val();
 
+  var response_parameters_list = $('input[name^="values_params_"]');
+  var response_parameters = [];
+  if (response_parameters_list.length > 0) {
+    response_parameters_list.each(function() {
+      var acum = {
+        name: $(this).attr("name"),
+        value: $(this).val()
+      };
+      response_parameters.push(acum);
+    });
+  }
+
   var params = [];
   params.push({ name: "page", value: "include/ajax/events" });
   params.push({ name: "get_response", value: 1 });
   params.push({ name: "response_id", value: response_id });
   params.push({ name: "server_id", value: server_id });
   params.push({ name: "event_id", value: event_id });
+  params.push({
+    name: "response_parameters",
+    value: JSON.stringify(response_parameters)
+  });
 
   jQuery.ajax({
     data: params,
@@ -126,12 +142,13 @@ function execute_response(event_id, server_id) {
 }
 
 // Check the response type and open it in a modal dialog or new window
-function execute_response_massive(events, response_id) {
+function execute_response_massive(events, response_id, response_parameters) {
   var params = [];
   params.push({ name: "page", value: "include/ajax/events" });
   params.push({ name: "get_response_massive", value: 1 });
   params.push({ name: "response_id", value: response_id });
   params.push({ name: "events", value: JSON.stringify(events) });
+  params.push({ name: "response_parameters", value: response_parameters });
 
   jQuery.ajax({
     data: params,
@@ -193,10 +210,16 @@ function execute_response_massive(events, response_id) {
               response["event_id"] = event_id;
               response["server_id"] = server_id;
               response["target"] = target;
+
+              var indexstr = event_id;
+              if (meta != 0) {
+                indexstr += "-" + server_id;
+              }
+
               perform_response(
                 btoa(JSON.stringify(response)),
                 response_id,
-                event_id + "-" + server_id
+                indexstr
               );
             }
           });
@@ -236,71 +259,14 @@ function show_response_dialog(response_id, response) {
             perform_response(btoa(JSON.stringify(response)), response_id, "");
           },
           width: response["modal_width"],
-          height: response["modal_height"]
+          height: response["modal_height"],
+          buttons: []
         })
         .show();
     }
   });
 }
 
-// Get an event response params from db
-function get_response_params(response_id) {
-  var response_params;
-
-  var params = [];
-  params.push("page=include/ajax/events");
-  params.push("get_response_params=1");
-  params.push("response_id=" + response_id);
-
-  jQuery.ajax({
-    data: params.join("&"),
-    type: "POST",
-    url: $("#hidden-ajax_file").val(),
-    async: false,
-    dataType: "json",
-    success: function(data) {
-      response_params = data;
-    }
-  });
-
-  return response_params;
-}
-
-// Get an event response description from db
-function get_response_description(response_id) {
-  var response_description = "";
-
-  var params = [];
-  params.push("page=include/ajax/events");
-  params.push("get_response_description=1");
-  params.push("response_id=" + response_id);
-
-  jQuery.ajax({
-    data: params.join("&"),
-    type: "POST",
-    url: $("#hidden-ajax_file").val(),
-    async: false,
-    dataType: "html",
-    success: function(data) {
-      response_description = data;
-    }
-  });
-
-  return response_description;
-}
-
-function add_row_param(id_table, param) {
-  $("#" + id_table).append(
-    '<tr class="params_rows"><td style="text-align:left; padding-left:40px; font-weight: normal; font-style: italic;">' +
-      param +
-      '</td><td style="text-align:left" colspan="2"><input type="text" name="' +
-      param +
-      '" id="' +
-      param +
-      '"></td></tr>'
-  );
-}
-
 // Perform a response and put the output into a div
 function perform_response(response, response_id, index) {
   $("#re_exec_command" + index).hide();
@@ -670,8 +636,13 @@ function execute_delete_event_reponse(
 
 // Imported from old files.
 function execute_event_response(event_list_btn) {
+  var response_id = $("select[name=response_id]").val();
+  if (!isNaN(response_id)) {
+    table_info_response_event(response_id, 0, 0, true);
+  }
+
   var message =
-    "<h4 style = 'text-align: center; color:black' > Are you sure?</h4> ";
+    "<h4 style = 'text-align: center; color:black' > Are you sure?</h4> <div id='massive-parameters-response'></div> ";
   confirmDialog({
     title: "ATTENTION",
     message: message,
@@ -683,8 +654,6 @@ function execute_event_response(event_list_btn) {
       $("#max_custom_event_resp_msg").hide();
       $("#max_custom_selected").hide();
 
-      var response_id = $("select[name=response_id]").val();
-
       var total_checked = $(".chk_val:checked").length;
 
       // Check select an event.
@@ -694,14 +663,28 @@ function execute_event_response(event_list_btn) {
       }
 
       if (!isNaN(response_id)) {
+        var response_parameters_list = $('input[name^="values_params_"]');
+        var response_parameters = [];
+        if (response_parameters_list.length > 0) {
+          response_parameters_list.each(function() {
+            var acum = {
+              name: $(this).attr("name"),
+              value: $(this).val()
+            };
+            response_parameters.push(acum);
+          });
+        }
+
+        response_parameters = JSON.stringify(response_parameters);
+
         if (event_list_btn) {
           $("#button-submit_event_response").hide(function() {
             $("#response_loading_dialog").show(function() {
-              show_response_dialog_massive(response_id);
+              show_response_dialog_massive(response_id, response_parameters);
             });
           });
         } else {
-          check_execute_response_massive(response_id);
+          check_execute_response_massive(response_id, response_parameters);
         }
       } else {
         // It is not a custom response
@@ -776,7 +759,7 @@ function execute_event_response(event_list_btn) {
   });
 }
 
-function show_response_dialog_massive(response_id) {
+function show_response_dialog_massive(response_id, response_parameters) {
   var params = [];
   params.push({ name: "page", value: "include/ajax/events" });
   params.push({ name: "get_response", value: 1 });
@@ -803,7 +786,7 @@ function show_response_dialog_massive(response_id) {
           draggable: true,
           modal: false,
           open: function() {
-            check_execute_response_massive(response_id);
+            check_execute_response_massive(response_id, response_parameters);
           },
           close: function() {
             $("#checkbox-all_validate_box").prop("checked", false);
@@ -830,7 +813,7 @@ function show_response_dialog_massive(response_id) {
   });
 }
 
-function check_execute_response_massive(response_id) {
+function check_execute_response_massive(response_id, response_parameters) {
   var events = [];
   $(".container-massive-events-response").empty();
   $(".chk_val:checked").each(function() {
@@ -852,7 +835,7 @@ function check_execute_response_massive(response_id) {
     }
   });
 
-  execute_response_massive(events, response_id);
+  execute_response_massive(events, response_id, response_parameters);
 }
 
 function event_widget_options() {
@@ -1136,3 +1119,43 @@ function check_event_sound(settings) {
     "json"
   );
 }
+
+function table_info_response_event(response_id, event_id, server_id, massive) {
+  var params = [];
+  params.push({ name: "page", value: "include/ajax/events" });
+  params.push({ name: "get_response", value: 1 });
+  params.push({ name: "response_id", value: response_id });
+  params.push({ name: "server_id", value: server_id });
+  params.push({ name: "event_id", value: event_id });
+
+  jQuery.ajax({
+    data: params,
+    type: "POST",
+    url: $("#hidden-ajax_file").val(),
+    dataType: "json",
+    success: function(response) {
+      if (response) {
+        var params = [];
+        params.push({ name: "page", value: "include/ajax/events" });
+        params.push({ name: "draw_row_response_info", value: 1 });
+        params.push({ name: "massive", value: massive === true ? 1 : 0 });
+        params.push({ name: "response", value: JSON.stringify(response) });
+
+        jQuery.ajax({
+          data: params,
+          type: "POST",
+          url: $("#hidden-ajax_file").val(),
+          dataType: "html",
+          success: function(output) {
+            if (massive === true) {
+              $("#massive-parameters-response").append(output);
+            } else {
+              $(".params_rows").remove();
+              $("#responses_table").append(output);
+            }
+          }
+        });
+      }
+    }
+  });
+}
diff --git a/pandora_console/include/styles/events.css b/pandora_console/include/styles/events.css
index 5ad4579f61..a235861c27 100644
--- a/pandora_console/include/styles/events.css
+++ b/pandora_console/include/styles/events.css
@@ -429,3 +429,26 @@ div.multi-response-buttons {
   justify-content: flex-end;
   align-items: center;
 }
+
+#massive-parameters-response {
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+  align-items: center;
+}
+
+#massive-parameters-response > div {
+  width: 80%;
+}
+
+#massive-parameters-response > div h5 {
+  text-align: center;
+}
+
+#massive-parameters-response > div div {
+  display: flex;
+  flex-direction: row;
+  justify-content: space-between;
+  align-items: center;
+  margin-bottom: 5px;
+}
diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php
index 42d325e7f0..91714803f9 100755
--- a/pandora_console/operation/agentes/estado_generalagente.php
+++ b/pandora_console/operation/agentes/estado_generalagente.php
@@ -564,7 +564,10 @@ for ($i = 0; $i < $custom_fields_count; $i++) {
         $columns = array_merge($first_column, $second_column);
     } else {
         $columns = $first_column;
-        $filas = count($table_data->data);
+        if ($table_data->data !== null) {
+            $filas = count($table_data->data);
+        }
+
         $table_data->colspan[$filas][1] = 3;
     }
 

From 9e2c6edfebd756d8cfa075cd0863e27cc1d01a00 Mon Sep 17 00:00:00 2001
From: Daniel Barbero <daniel.barbero@artica.es>
Date: Tue, 27 Sep 2022 15:08:09 +0200
Subject: [PATCH 17/83] new group by events for extraid pandora_enterprise#9425

---
 pandora_console/include/ajax/events.php       | 24 ++---
 pandora_console/include/constants.php         |  5 ++
 pandora_console/include/functions_api.php     | 32 +++----
 pandora_console/include/functions_events.php  | 88 +++++++++++++------
 .../include/functions_reporting.php           |  2 +-
 pandora_console/mobile/operation/events.php   |  6 +-
 pandora_console/operation/events/events.php   | 17 ++--
 pandora_console/operation/menu.php            |  2 +-
 8 files changed, 111 insertions(+), 65 deletions(-)

diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php
index c902a6479a..4dd887d37b 100644
--- a/pandora_console/include/ajax/events.php
+++ b/pandora_console/include/ajax/events.php
@@ -90,7 +90,7 @@ $node_id = (int) get_parameter('node_id', 0);
 
 if ($get_comments === true) {
     $event = get_parameter('event', false);
-    $event_rep = get_parameter('event_rep', false);
+    $event_rep = (int) get_parameter('event_rep', 0);
     if ($event === false) {
         return __('Failed to retrieve comments');
     }
@@ -98,7 +98,7 @@ if ($get_comments === true) {
     $eventsGrouped = [];
     // Consider if the event is grouped.
     $whereGrouped = '1=1';
-    if (isset($event_rep) === true && $event_rep > 0) {
+    if ($event_rep === EVENT_GROUP_REP_EVENTS) {
         // Default grouped message filtering (evento and estado).
         $whereGrouped = sprintf(
             '`evento` = "%s"',
@@ -119,6 +119,11 @@ if ($get_comments === true) {
                 (int) $event['id_agentmodule']
             );
         }
+    } else if ($event_rep === EVENT_GROUP_REP_EXTRAIDS) {
+        $whereGrouped = sprintf(
+            '`id_extra` = "%s"',
+            $event['id_extra']
+        );
     } else {
         $whereGrouped = sprintf('`id_evento` = %d', $event['id_evento']);
     }
@@ -175,7 +180,7 @@ if ($delete_event === true) {
     $filter = get_parameter('filter', []);
     $id_evento = (int) get_parameter('id_evento', 0);
     $server_id = (int) get_parameter('server_id', 0);
-    $event_rep = get_parameter('event_rep', 0);
+    $event_rep = (int) get_parameter('event_rep', 0);
 
     try {
         if (is_metaconsole() === true
@@ -228,7 +233,7 @@ 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 = get_parameter('event_rep', 0);
+    $event_rep = (int) get_parameter('event_rep', 0);
 
     try {
         if (is_metaconsole() === true
@@ -240,7 +245,7 @@ if ($validate_event === true) {
 
         if ($event_rep === 0) {
             // Disable group by when there're result is unique.
-            $filter['group_rep'] = 0;
+            $filter['group_rep'] = EVENT_GROUP_REP_ALL;
         }
 
         // Check acl.
@@ -285,7 +290,7 @@ 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 = get_parameter('event_rep', 0);
+    $event_rep = (int) get_parameter('event_rep', 0);
 
     try {
         if (is_metaconsole() === true
@@ -297,7 +302,7 @@ if ($in_process_event === true) {
 
         if ($event_rep === 0) {
             // Disable group by when there're result is unique.
-            $filter['group_rep'] = 0;
+            $filter['group_rep'] = EVENT_GROUP_REP_ALL;
         }
 
         // Check acl.
@@ -464,7 +469,6 @@ if ($get_filter_values) {
         $event_filter = [
             'status'                  => EVENT_NO_VALIDATED,
             'event_view_hr'           => $config['event_view_hr'],
-            'group_rep'               => 1,
             'tag_with'                => [],
             'tag_without'             => [],
             'history'                 => false,
@@ -480,7 +484,7 @@ if ($get_filter_values) {
             'time_to'                 => '',
             'severity'                => '',
             'event_type'              => '',
-            'group_rep'               => 0,
+            'group_rep'               => EVENT_GROUP_REP_ALL,
             'id_group'                => 0,
             'id_group_filter'         => 0,
             'group_name'              => 'All',
@@ -2474,7 +2478,7 @@ if ($get_events_fired) {
             'id_agent_module'         => 0,
             'pagination'              => 0,
             'id_user_ack'             => 0,
-            'group_rep'               => 0,
+            'group_rep'               => EVENT_GROUP_REP_ALL,
             'tag_with'                => [],
             'tag_without'             => [],
             'filter_only_alert'       => -1,
diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php
index 64be59b7aa..6688a91d78 100644
--- a/pandora_console/include/constants.php
+++ b/pandora_console/include/constants.php
@@ -45,6 +45,11 @@ define('EVENT_VALIDATE', 1);
 define('EVENT_PROCESS', 2);
 define('EVENT_NO_VALIDATED', 3);
 
+// Events group by constants.
+define('EVENT_GROUP_REP_ALL', 0);
+define('EVENT_GROUP_REP_EVENTS', 1);
+define('EVENT_GROUP_REP_AGENTS', 2);
+define('EVENT_GROUP_REP_EXTRAIDS', 3);
 
 // Agents disabled status.
 define('AGENT_ENABLED', 0);
diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php
index 3bf6845eae..c8219f86e3 100644
--- a/pandora_console/include/functions_api.php
+++ b/pandora_console/include/functions_api.php
@@ -11297,7 +11297,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
     $id_user_ack = 0;
     $event_view_hr = 0;
     $tag = '';
-    $group_rep = 0;
+    $group_rep = EVENT_GROUP_REP_ALL;
     $utimestamp_upper = 0;
     $utimestamp_bottom = 0;
     $id_alert_template = -1;
@@ -11500,7 +11500,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
         $alert_join = ' INNER JOIN talert_template_modules ON '.$table_events.'.id_alert_am=talert_template_modules.id';
     }
 
-    if ($group_rep == 0) {
+    if ($group_rep == EVENT_GROUP_REP_ALL) {
         if ($filter['total']) {
             $sql = 'SELECT COUNT(*)
                         FROM '.$table_events.'
@@ -15953,7 +15953,7 @@ function api_set_create_event_filter($name, $thrash1, $other, $thrash3)
 
     $id_user_ack = (in_array($other['data'][9], $users)) ? $other['data'][9] : 0;
 
-    $group_rep = ($other['data'][10] == 0 || $other['data'][10] == 1) ? $other['data'][10] : 0;
+    $group_rep = ($other['data'][10] == EVENT_GROUP_REP_ALL || $other['data'][10] == EVENT_GROUP_REP_EVENTS) ? $other['data'][10] : EVENT_GROUP_REP_ALL;
 
     $date_from = (preg_match('/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/', $other['data'][11])) ? $other['data'][11] : '0000-00-00';
 
@@ -16180,7 +16180,7 @@ function api_set_update_event_filter($id_event_filter, $thrash1, $other, $thrash
                 break;
 
                 case 11:
-                    $values['group_rep'] = ($other['data'][11] == 0 || $other['data'][11] == 1) ? $other['data'][11] : 0;
+                    $values['group_rep'] = ($other['data'][11] == EVENT_GROUP_REP_ALL || $other['data'][11] == EVENT_GROUP_REP_EVENTS) ? $other['data'][11] : EVENT_GROUP_REP_ALL;
                 break;
 
                 case 12:
@@ -17549,9 +17549,11 @@ function api_set_enable_disable_discovery_task($id_task, $thrash2, $other)
     }
 }
 
+
 /**
  * Make report (PDF, CSV or XML) and send it via e-mail (this method is intended to be used by server's execution
  * of alert actions that involve sending reports by e-mail).
+ *
  * @param [string] $server_id        id server (Node)
  * @param [string] $console_event_id console Id node event in tevent
  * @param [string] $trash2           don't use
@@ -17598,15 +17600,12 @@ function api_set_send_report($thrash1, $thrash2, $other, $returnType)
     $date_today = preg_split('/[\s,]+/', io_safe_output($date_today));
     $date_today = __($date_today[0]).' '.$date_today[1].' '.$date_today[2].' '.$date_today[3].' '.$date_today[4];
 
-
     if ($make_report_from_template === true) {
         $filter['id_report'] = $id_item;
 
         $template = reports_get_report_templates(
             $filter,
-            [
-                'description'
-            ],
+            ['description'],
             $return_all_group,
             'RR'
         )[0];
@@ -17614,15 +17613,16 @@ function api_set_send_report($thrash1, $thrash2, $other, $returnType)
         $description = $template['description'];
 
         // Report macros post-process.
-        $body_email = str_replace([
+        $body_email = str_replace(
+            [
                 '_report_description_',
                 '_report_generated_date_',
-                '_report_date_'
+                '_report_date_',
             ],
             [
                 $description,
                 $date_today,
-                $date_today
+                $date_today,
             ],
             $body_email
         );
@@ -17636,7 +17636,7 @@ function api_set_send_report($thrash1, $thrash2, $other, $returnType)
             $template_regex_agents,
             false,
             '',
-            $email, 
+            $email,
             $subject_email,
             $body_email,
             $report_type,
@@ -17651,15 +17651,16 @@ function api_set_send_report($thrash1, $thrash2, $other, $returnType)
         }
 
         // Report macros post-process.
-        $body_email = str_replace([
+        $body_email = str_replace(
+            [
                 '_report_description_',
                 '_report_generated_date_',
-                '_report_date_'
+                '_report_date_',
             ],
             [
                 $report['description'],
                 $date_today,
-                $date_today
+                $date_today,
             ],
             $body_email
         );
@@ -17846,4 +17847,3 @@ function api_set_send_report($thrash1, $thrash2, $other, $returnType)
         returnData($returnType, $data, ';');
     }
 }
-
diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index b3aece13a3..65adff285a 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -382,14 +382,16 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal
     }
 
     if (isset($filter) === false
-        || is_array($filter) === true
+        || is_array($filter) === false
     ) {
-        $filter = ['group_rep' => 0];
+        $filter = ['group_rep' => EVENT_GROUP_REP_ALL];
     }
 
+    hd($filter['group_rep'], true);
+
     switch ($filter['group_rep']) {
-        case '0':
-        case '2':
+        case EVENT_GROUP_REP_ALL:
+        case EVENT_GROUP_REP_AGENTS:
         default:
             // No groups option direct update.
             $delete_sql = sprintf(
@@ -399,7 +401,8 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal
             );
         break;
 
-        case '1':
+        case EVENT_GROUP_REP_EVENTS:
+        case EVENT_GROUP_REP_EXTRAIDS:
             // Group by events.
             $sql = events_get_all(
                 ['te.*'],
@@ -418,8 +421,16 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal
                 true
             );
 
-            $target_ids = db_get_all_rows_sql(
-                sprintf(
+            if ((int) $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS) {
+                $sql = sprintf(
+                    'SELECT tu.id_evento FROM tevento tu INNER JOIN ( %s ) tf
+                    ON tu.id_extra = tf.id_extra
+                    AND tf.max_id_evento = %d',
+                    $sql,
+                    $id_evento
+                );
+            } else {
+                $sql = sprintf(
                     'SELECT tu.id_evento FROM tevento tu INNER JOIN ( %s ) tf
                     ON tu.estado = tf.estado
                     AND tu.evento = tf.evento
@@ -428,8 +439,10 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal
                     AND tf.max_id_evento = %d',
                     $sql,
                     $id_evento
-                )
-            );
+                );
+            }
+
+            $target_ids = db_get_all_rows_sql($sql);
 
             // Try to avoid deadlock while updating full set.
             if ($target_ids !== false && count($target_ids) > 0) {
@@ -475,12 +488,12 @@ function events_update_status($id_evento, $status, $filter=null)
     }
 
     if (isset($filter) === false || is_array($filter) === false) {
-        $filter = ['group_rep' => 0];
+        $filter = ['group_rep' => EVENT_GROUP_REP_ALL];
     }
 
     switch ($filter['group_rep']) {
-        case '0':
-        case '2':
+        case EVENT_GROUP_REP_ALL:
+        case EVENT_GROUP_REP_AGENTS:
         default:
             // No groups option direct update.
             $update_sql = sprintf(
@@ -492,7 +505,8 @@ function events_update_status($id_evento, $status, $filter=null)
             );
         break;
 
-        case '1':
+        case EVENT_GROUP_REP_EVENTS:
+        case EVENT_GROUP_REP_EXTRAIDS:
             // Group by events.
             $sql = events_get_all(
                 ['te.*'],
@@ -511,8 +525,16 @@ function events_update_status($id_evento, $status, $filter=null)
                 true
             );
 
-            $target_ids = db_get_all_rows_sql(
-                sprintf(
+            if ((int) $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS) {
+                $sql = sprintf(
+                    'SELECT tu.id_evento FROM tevento tu INNER JOIN ( %s ) tf
+                    ON tu.id_extra = tf.id_extra
+                    AND tf.max_id_evento = %d',
+                    $sql,
+                    $id_evento
+                );
+            } else {
+                $sql = sprintf(
                     'SELECT tu.id_evento FROM tevento tu INNER JOIN ( %s ) tf
                     ON tu.estado = tf.estado
                     AND tu.evento = tf.evento
@@ -521,8 +543,10 @@ function events_update_status($id_evento, $status, $filter=null)
                     AND tf.max_id_evento = %d',
                     $sql,
                     $id_evento
-                )
-            );
+                );
+            }
+
+            $target_ids = db_get_all_rows_sql($sql);
 
             // Try to avoid deadlock while updating full set.
             if ($target_ids !== false && count($target_ids) > 0) {
@@ -1363,7 +1387,10 @@ function events_get_all(
     // Order.
     $order_by = '';
     if (isset($order, $sort_field) === true) {
-        if (isset($filter['group_rep']) === true && $filter['group_rep'] == 1) {
+        if (isset($filter['group_rep']) === true
+            && $filter['group_rep'] === EVENT_GROUP_REP_EVENTS
+            && $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS
+        ) {
             $order_by = events_get_sql_order('MAX('.$sort_field.')', $order);
         } else {
             $order_by = events_get_sql_order($sort_field, $order);
@@ -1397,22 +1424,22 @@ function events_get_all(
     $group_by = 'GROUP BY ';
     $tagente_join = 'LEFT';
     if (isset($filter['group_rep']) === false) {
-        $filter['group_rep'] = 0;
+        $filter['group_rep'] = EVENT_GROUP_REP_ALL;
     }
 
     switch ($filter['group_rep']) {
-        case '0':
+        case EVENT_GROUP_REP_ALL:
         default:
             // All events.
             $group_by = '';
         break;
 
-        case '1':
+        case EVENT_GROUP_REP_EVENTS:
             // Group by events.
             $group_by .= 'te.evento, te.id_agente, te.id_agentmodule';
         break;
 
-        case '2':
+        case EVENT_GROUP_REP_AGENTS:
             // Group by agents.
             $tagente_join = 'INNER';
             $group_by = '';
@@ -1426,6 +1453,11 @@ function events_get_all(
                 );
             }
         break;
+
+        case EVENT_GROUP_REP_EXTRAIDS:
+            // Group by events.
+            $group_by .= 'te.id_extra';
+        break;
     }
 
     $tgrupo_join = 'LEFT';
@@ -1511,7 +1543,9 @@ function events_get_all(
         }
     }
 
-    if ((int) $filter['group_rep'] === 1 && $count === false) {
+    if (($filter['group_rep'] === EVENT_GROUP_REP_EVENTS
+        || $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS) && $count === false
+    ) {
         $sql = sprintf(
             'SELECT %s
                 %s
@@ -2880,9 +2914,9 @@ function events_get_agent(
 
     // Group by agent.
     if ((bool) $show_summary_group === true) {
-        $filters['group_rep'] = 1;
+        $filters['group_rep'] = EVENT_GROUP_REP_EVENTS;
     } else {
-        $filters['group_rep'] = 2;
+        $filters['group_rep'] = EVENT_GROUP_REP_AGENTS;
     }
 
     $events = Event::search(
@@ -5092,7 +5126,7 @@ function events_get_count_events_validated_by_user($data)
  *
  * @return string SQL.
  */
-function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=0, $only_fields=false)
+function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=EVENT_GROUP_REP_ALL, $only_fields=false)
 {
     $sort_field_translated = $sort_field;
     switch ($sort_field) {
@@ -5113,7 +5147,7 @@ function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=
         break;
 
         case 'timestamp':
-            $sort_field_translated = ($group_rep == 0) ? 'timestamp' : 'timestamp_last';
+            $sort_field_translated = ($group_rep == EVENT_GROUP_REP_ALL) ? 'timestamp' : 'timestamp_last';
         break;
 
         case 'user_id':
diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php
index 5217ba2b15..bd9f4a076d 100755
--- a/pandora_console/include/functions_reporting.php
+++ b/pandora_console/include/functions_reporting.php
@@ -4011,7 +4011,7 @@ function reporting_groups_nodes($content)
         }
 
         // Grouped.
-        $filters['group_rep'] = 1;
+        $filters['group_rep'] = EVENT_GROUP_REP_EVENTS;
 
         $events = Event::search(
             [
diff --git a/pandora_console/mobile/operation/events.php b/pandora_console/mobile/operation/events.php
index 360f2710d6..50e9aab8ba 100644
--- a/pandora_console/mobile/operation/events.php
+++ b/pandora_console/mobile/operation/events.php
@@ -357,10 +357,10 @@ class Events
                             );
 
                             if (isset($group_rep) === false) {
-                                $group_rep = 0;
+                                $group_rep = EVENT_GROUP_REP_ALL;
                             }
 
-                            if ((int) $group_rep !== 0) {
+                            if ((int) $group_rep !== EVENT_GROUP_REP_ALL) {
                                 if ($event['event_rep'] <= 1) {
                                     $event['event_repeated'] = '<i>'.__('No').'</i>';
                                 } else {
@@ -1068,7 +1068,7 @@ class Events
             $filters['id_agent'] = $this->id_agent;
         }
 
-        $filters['group_rep'] = 1;
+        $filters['group_rep'] = EVENT_GROUP_REP_EVENTS;
 
         if (isset($this->limit) === true
             && $this->limit !== -1
diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php
index b3d4b52377..e17dd58854 100644
--- a/pandora_console/operation/events/events.php
+++ b/pandora_console/operation/events/events.php
@@ -84,7 +84,7 @@ ui_require_javascript_file('pandora_events');
 $default_filter = [
     'status'        => EVENT_NO_VALIDATED,
     'event_view_hr' => $config['event_view_hr'],
-    'group_rep'     => 1,
+    'group_rep'     => EVENT_GROUP_REP_EVENTS,
     'tag_with'      => [],
     'tag_without'   => [],
     'history'       => false,
@@ -1626,9 +1626,10 @@ $inputs[] = $in;
 // Duplicates group { events | agents }.
 $data = html_print_select(
     [
-        0 => __('All events'),
-        1 => __('Group events'),
-        2 => __('Group agents'),
+        EVENT_GROUP_REP_ALL      => __('All events'),
+        EVENT_GROUP_REP_EVENTS   => __('Group events'),
+        EVENT_GROUP_REP_AGENTS   => __('Group agents'),
+        EVENT_GROUP_REP_EXTRAIDS => __('Group extra id'),
     ],
     'group_rep',
     $group_rep,
@@ -2227,12 +2228,14 @@ try {
     $active_filters_div .= '<div>';
     $active_filters_div .= '<div class="label box-shadow">'.__('Duplicated').'</div>';
     $active_filters_div .= '<div id="summary_duplicates" class="content">';
-    if ($group_rep == 0) {
+    if ($group_rep == EVENT_GROUP_REP_ALL) {
         $active_filters_div .= __('All events.');
-    } else if ($group_rep == 1) {
+    } else if ($group_rep == EVENT_GROUP_REP_EVENTS) {
         $active_filters_div .= __('Group events');
-    } else if ($group_rep == 2) {
+    } else if ($group_rep == EVENT_GROUP_REP_AGENTS) {
         $active_filters_div .= __('Group agents.');
+    } else if ($group_rep == EVENT_GROUP_REP_EXTRAIDS) {
+        $active_filters_div .= __('Group extra id.');
     }
 
     $active_filters_div .= '</div>';
diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php
index 1e3eae4c8a..de5c92ac29 100644
--- a/pandora_console/operation/menu.php
+++ b/pandora_console/operation/menu.php
@@ -404,7 +404,7 @@ if ($access_console_node === true) {
                 $user_event_filter = [
                     'status'        => EVENT_NO_VALIDATED,
                     'event_view_hr' => $config['event_view_hr'],
-                    'group_rep'     => 1,
+                    'group_rep'     => EVENT_GROUP_REP_EVENTS,
                     'tag_with'      => [],
                     'tag_without'   => [],
                     'history'       => false,

From 8d8140faa46149f932de170ea6309ccbe27a3d38 Mon Sep 17 00:00:00 2001
From: Daniel Barbero <daniel.barbero@artica.es>
Date: Wed, 28 Sep 2022 09:30:30 +0200
Subject: [PATCH 18/83] add new macros response events pandora_enterprise#9423

---
 pandora_console/include/ajax/events.php      |  4 ++-
 pandora_console/include/functions_events.php | 36 +++++++++++++++++---
 2 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php
index dbb7924517..7075016c64 100644
--- a/pandora_console/include/ajax/events.php
+++ b/pandora_console/include/ajax/events.php
@@ -1093,7 +1093,9 @@ if ($get_response === true) {
             $event_response['target'] = events_get_response_target(
                 $event_id,
                 $event_response,
-                $response_parameters
+                $response_parameters,
+                $server_id,
+                ($server_id !== 0) ? $node->server_name() : 'Metaconsole'
             );
         } catch (\Exception $e) {
             // Unexistent agent.
diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index a91868a2c2..cdbd930972 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -3522,16 +3522,20 @@ function events_page_responses($event)
 /**
  * Replace macros in the target of a response and return it.
  *
- * @param integer    $event_id            Event identifier.
- * @param array      $event_response      Event Response.
- * @param array|null $response_parameters If parameters response values.
+ * @param integer      $event_id            Event identifier.
+ * @param array        $event_response      Event Response.
+ * @param array|null   $response_parameters If parameters response values.
+ * @param integer|null $server_id           Server Id.
+ * @param string|null  $server_name         Name server.
  *
  * @return string The response text with the macros applied.
  */
 function events_get_response_target(
     int $event_id,
     array $event_response,
-    ?array $response_parameters=null
+    ?array $response_parameters=null,
+    ?int $server_id=0,
+    ?string $server_name=''
 ) {
     global $config;
 
@@ -3899,6 +3903,26 @@ function events_get_response_target(
         );
     }
 
+    if (is_metaconsole() === true
+        && strpos($target, '_node_id_') !== false
+    ) {
+        $target = str_replace(
+            '_node_id_',
+            $server_id,
+            $target
+        );
+    }
+
+    if (is_metaconsole() === true
+        && strpos($target, '_node_name_') !== false
+    ) {
+        $target = str_replace(
+            '_node_name_',
+            $server_name,
+            $target
+        );
+    }
+
     return $target;
 }
 
@@ -5635,7 +5659,9 @@ function get_events_get_response_target(
         return events_get_response_target(
             $event_id,
             $event_response,
-            $response_parameters
+            $response_parameters,
+            $server_id,
+            ($server_id !== 0) ? $node->server_name() : 'Metaconsole'
         );
     } catch (\Exception $e) {
         // Unexistent agent.

From 8438045cf6edecdb0b5050cb02414ec609454792 Mon Sep 17 00:00:00 2001
From: Daniel Barbero <daniel.barbero@artica.es>
Date: Thu, 29 Sep 2022 12:54:46 +0200
Subject: [PATCH 19/83] filter recursive groups in events
 pandora_enterprise#2133

---
 pandora_console/extras/mr/58.sql              |  5 +++
 .../godmode/events/event_edit_filter.php      |  4 ++
 pandora_console/include/ajax/events.php       | 12 +++++-
 pandora_console/include/functions_events.php  |  6 ++-
 pandora_console/operation/events/events.php   | 38 ++++++++++++++++++-
 pandora_console/pandoradb.sql                 |  1 +
 6 files changed, 61 insertions(+), 5 deletions(-)
 create mode 100644 pandora_console/extras/mr/58.sql

diff --git a/pandora_console/extras/mr/58.sql b/pandora_console/extras/mr/58.sql
new file mode 100644
index 0000000000..ea5c7e0135
--- /dev/null
+++ b/pandora_console/extras/mr/58.sql
@@ -0,0 +1,5 @@
+START TRANSACTION;
+
+ALTER TABLE `tevent_filter` ADD COLUMN `search_recursive_groups` INT NOT NULL DEFAULT 0;
+
+COMMIT;
\ No newline at end of file
diff --git a/pandora_console/godmode/events/event_edit_filter.php b/pandora_console/godmode/events/event_edit_filter.php
index 91045ce0ea..2e7e009686 100644
--- a/pandora_console/godmode/events/event_edit_filter.php
+++ b/pandora_console/godmode/events/event_edit_filter.php
@@ -90,6 +90,7 @@ if ($id) {
 
     $filter_only_alert = $filter['filter_only_alert'];
     $search_secondary_groups = $filter['search_secondary_groups'];
+    $search_recursive_groups = $filter['search_recursive_groups'];
     $custom_data = $filter['custom_data'];
     $custom_data_filter_type = $filter['custom_data_filter_type'];
 
@@ -128,6 +129,7 @@ if ($id) {
     $tag_without_base64 = base64_encode($tag_without_json);
     $filter_only_alert = '';
     $search_secondary_groups = 0;
+    $search_recursive_groups = 0;
 }
 
 if ($update || $create) {
@@ -170,6 +172,7 @@ if ($update || $create) {
 
     $filter_only_alert = get_parameter('filter_only_alert', '');
     $search_secondary_groups = get_parameter('search_secondary_groups', 0);
+    $search_recursive_groups = get_parameter('search_recursive_groups', 0);
 
     $custom_data = get_parameter('custom_data', '');
     $custom_data_filter_type = get_parameter('custom_data_filter_type', '');
@@ -198,6 +201,7 @@ if ($update || $create) {
         'user_comment'            => $user_comment,
         'filter_only_alert'       => $filter_only_alert,
         'search_secondary_groups' => $search_secondary_groups,
+        'search_recursive_groups' => $search_recursive_groups,
         'custom_data'             => $custom_data,
         'custom_data_filter_type' => $custom_data_filter_type,
     ];
diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php
index c902a6479a..674bd8131b 100644
--- a/pandora_console/include/ajax/events.php
+++ b/pandora_console/include/ajax/events.php
@@ -360,10 +360,11 @@ if ($save_event_filter) {
     );
     $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['date_from'] = get_parameter('date_from', null);
     $values['time_from'] = get_parameter('time_from');
-    $values['date_to'] = get_parameter('date_to');
+    $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');
@@ -417,6 +418,7 @@ if ($update_event_filter) {
     );
     $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');
@@ -471,6 +473,7 @@ if ($get_filter_values) {
             'module_search'           => '',
             'filter_only_alert'       => '-1',
             'search_secondary_groups' => 0,
+            'search_recursive_groups' => 0,
             'user_comment'            => '',
             'id_extra'                => '',
             'id_user_ack'             => '',
@@ -657,6 +660,8 @@ function load_form_filter() {
                     $("#filter_only_alert").val(val);
                 if (i == 'search_secondary_groups')
                     $("#checkbox-search_secondary_groups").val(val);
+                if (i == 'search_recursive_groups')
+                    $("#checkbox-search_recursive_groups").val(val);
                 if (i == 'id_group_filter')
                     $("#id_group_filter").val(val);
                 if (i == 'source')
@@ -900,6 +905,7 @@ function save_new_filter() {
             "tag_without": Base64.decode($("#hidden-tag_without").val()),
             "filter_only_alert" : $("#filter_only_alert").val(),
             "search_secondary_groups" : $("#checkbox-search_secondary_groups").val(),
+            "search_recursive_groups" : $("#checkbox-search_recursive_groups").val(),
             "id_group_filter": $("#id_group_filter_dialog").val(),
             "date_from": $("#text-date_from").val(),
             "time_from": $("#text-time_from").val(),
@@ -976,6 +982,7 @@ function save_update_filter() {
         "tag_without" : Base64.decode($("#hidden-tag_without").val()),
         "filter_only_alert" : $("#filter_only_alert").val(),
         "search_secondary_groups" : $("#checkbox-search_secondary_groups").val(),
+        "search_recursive_groups" : $("#checkbox-search_recursive_groups").val(),
         "id_group_filter": $("#id_group_filter_dialog").val(),
         "date_from": $("#text-date_from").val(),
         "time_from": $("#text-time_from").val(),
@@ -2479,6 +2486,7 @@ if ($get_events_fired) {
             'tag_without'             => [],
             'filter_only_alert'       => -1,
             'search_secondary_groups' => 0,
+            'search_recursive_groups' => 0,
             'source'                  => '',
             'id_extra'                => '',
             'user_comment'            => '',
diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index b3aece13a3..b5bdb156ff 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -627,6 +627,7 @@ function events_update_status($id_evento, $status, $filter=null)
  *     'tag_without'
  *     'filter_only_alert'
  *     'search_secondary_groups'
+ *     'search_recursive_groups'
  *     'module_search'
  *     'group_rep'
  *     'server_id'
@@ -864,7 +865,10 @@ function events_get_all(
     if (isset($groups) === true
         && (is_array($groups) === true || ($groups > 0))
     ) {
-        if ($recursiveGroups === true) {
+        if ($recursiveGroups === true
+            || (isset($filter['search_recursive_groups']) === true
+            && (bool) $filter['search_recursive_groups'] === true)
+        ) {
             // Add children groups.
             $children = [];
             if (is_array($groups) === true) {
diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php
index b3d4b52377..f37f000e9c 100644
--- a/pandora_console/operation/events/events.php
+++ b/pandora_console/operation/events/events.php
@@ -173,6 +173,10 @@ $search_secondary_groups = get_parameter(
     'filter[search_secondary_groups]',
     0
 );
+$search_recursive_groups = get_parameter(
+    'filter[search_recursive_groups]',
+    0
+);
 $id_group_filter = get_parameter(
     'filter[id_group_filter]',
     ($filter['id_group'] ?? '')
@@ -1058,6 +1062,7 @@ if ($loaded_filter !== false && $from_event_graph != 1 && isset($fb64) === false
 
         $filter_only_alert = $filter['filter_only_alert'];
         $search_secondary_groups = ($filter['search_secondary_groups'] ?? 0);
+        $search_recursive_groups = ($filter['search_recursive_groups'] ?? 0);
         $id_group_filter = $filter['id_group_filter'];
         $date_from = $filter['date_from'];
         $time_from = $filter['time_from'];
@@ -1676,6 +1681,28 @@ $in = '<div class="filter_input"><label>'.__('Severity').'</label>';
 $in .= $data.'</div>';
 $inputs[] = $in;
 
+// Search recursive groups.
+$data = html_print_checkbox_switch(
+    'search_recursive_groups',
+    $search_recursive_groups,
+    $search_recursive_groups,
+    true,
+    false,
+    'search_in_secondary_groups(this);',
+    true
+);
+
+$in = '<div class="filter_input filter_input_switch"><label>';
+$in .= __('Group recursion');
+$in .= ui_print_help_tip(
+    __('WARNING: This could cause a performace impact.'),
+    true
+);
+$in .= '</label>';
+$in .= $data;
+$in .= '</div>';
+$inputs[] = $in;
+
 // Search secondary groups.
 $data = html_print_checkbox_switch(
     'search_secondary_groups',
@@ -1687,8 +1714,15 @@ $data = html_print_checkbox_switch(
     true
 );
 
-$in = '<div class="filter_input filter_input_switch"><label>'.__('Search in secondary groups').'</label>';
-$in .= $data.'</div>';
+$in = '<div class="filter_input filter_input_switch"><label>';
+$in .= __('Search in secondary groups');
+$in .= ui_print_help_tip(
+    __('WARNING: This could cause a performace impact.'),
+    true
+);
+$in .= '</label>';
+$in .= $data;
+$in .= '</div>';
 $inputs[] = $in;
 
 // Trick view in table.
diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql
index 8e794fb15d..5e8ebb5460 100644
--- a/pandora_console/pandoradb.sql
+++ b/pandora_console/pandoradb.sql
@@ -1245,6 +1245,7 @@ CREATE TABLE IF NOT EXISTS `tevent_filter` (
   `tag_without` TEXT,
   `filter_only_alert` INT NOT NULL DEFAULT -1,
   `search_secondary_groups` INT NOT NULL DEFAULT 0,
+  `search_recursive_groups` INT NOT NULL DEFAULT 0,
   `date_from` date DEFAULT NULL,
   `date_to` date DEFAULT NULL,
   `source` TINYTEXT,

From 429cefcf2be2e5dcaf9bb83d51e7eb5a9b993149 Mon Sep 17 00:00:00 2001
From: sergio <sergio.bravo@pandorafms.com>
Date: Fri, 30 Sep 2022 09:59:53 +0200
Subject: [PATCH 20/83] #9300 label change

---
 pandora_console/include/lib/Dashboard/Widgets/service_map.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/include/lib/Dashboard/Widgets/service_map.php b/pandora_console/include/lib/Dashboard/Widgets/service_map.php
index 0fa8d13f10..9dfe181fd8 100644
--- a/pandora_console/include/lib/Dashboard/Widgets/service_map.php
+++ b/pandora_console/include/lib/Dashboard/Widgets/service_map.php
@@ -328,7 +328,7 @@ class ServiceMapWidget extends Widget
         ];
 
         $inputs[] = [
-            'label'     => __('Enable sunburst'),
+            'label'     => __('Show sunburst by default'),
             'arguments' => [
                 'type'   => 'switch',
                 'name'   => 'sunburst',

From f367e852d19d47296e97e410cce44885cbc30e50 Mon Sep 17 00:00:00 2001
From: "edu.corral" <eduardo.corral@artica.es>
Date: Fri, 30 Sep 2022 11:06:28 +0200
Subject: [PATCH 21/83] ent 8956 cli create user comment entities

---
 pandora_server/util/pandora_manage.pl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index 1f04ef717c..e1f5730316 100755
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -567,8 +567,8 @@ sub pandora_create_user ($$$$$) {
 		exit;
 	}
 
-	return db_insert ($dbh, 'id_user', 'INSERT INTO tusuario (id_user, fullname, password, comments, is_admin)
-                         VALUES (?, ?, ?, ?, ?)', safe_input($name), safe_input($name), $password, safe_input($comments), $is_admin);
+	return db_insert ($dbh, 'id_user', 'INSERT INTO tusuario (id_user, fullname, password, is_admin, comments)
+                         VALUES (?, ?, ?, ?, ?)', safe_input($name), safe_input($name), $password, $is_admin, decode_entities($comments));
 }
 
 ##########################################################################

From b29f7eb1606ba4ec51081384570413d2d1460bcc Mon Sep 17 00:00:00 2001
From: Calvo <luis.calvo@artica.es>
Date: Fri, 30 Sep 2022 14:54:16 +0200
Subject: [PATCH 22/83] Fix planned downtime issues

---
 .../agentes/planned_downtime.editor.php       | 100 ++++++++++++------
 .../godmode/agentes/planned_downtime.list.php |  41 ++++++-
 pandora_console/include/javascript/pandora.js |  13 ++-
 .../operation/agentes/ver_agente.php          |   9 +-
 4 files changed, 125 insertions(+), 38 deletions(-)

diff --git a/pandora_console/godmode/agentes/planned_downtime.editor.php b/pandora_console/godmode/agentes/planned_downtime.editor.php
index cec18a21ca..cdd5152bd0 100644
--- a/pandora_console/godmode/agentes/planned_downtime.editor.php
+++ b/pandora_console/godmode/agentes/planned_downtime.editor.php
@@ -1104,11 +1104,7 @@ $table->data[1][0] = __('Available agents');
 $table->data[1][1] = html_print_select($agents, 'id_agents[]', -1, '', _('Any'), -2, true, true, true, '', false, 'min-width: 250px;width: 70%;');
 
 
-if ($type_downtime != 'quiet') {
-    echo '<div id="available_modules_selection_mode" style="padding-top:20px;display: none;">';
-} else {
-    echo '<div id="available_modules_selection_mode" style="padding-top:20px">';
-}
+$table->rowid[2] = 'available_modules_selection_mode';
 
 $table->data[2][1] = html_print_select(
     [
@@ -1128,19 +1124,13 @@ $table->data[2][1] = html_print_select(
     'min-width:180px;'
 );
 
-echo '</div>';
 
+$table->rowid[3] = 'available_modules';
 $table->data[3][0] = __('Available modules:').ui_print_help_tip(
     __('Only for type Quiet for downtimes.'),
     true
 );
 
-if ($type_downtime != 'quiet') {
-    echo '<div id="available_modules" style="display: none;">';
-} else {
-    echo '<div id="available_modules" style="">';
-}
-
 $table->data[3][1] = html_print_select(
     [],
     'module[]',
@@ -1155,7 +1145,6 @@ $table->data[3][1] = html_print_select(
     false,
     'min-width: 250px;width: 70%;'
 );
-echo '</div>';
 
 // Print agent table.
 html_print_table($table);
@@ -1184,7 +1173,6 @@ if ($id_downtime > 0) {
 }
 
 echo '</div>';
-html_print_input_hidden('all_agents', implode(',', array_keys($agents)));
 html_print_input_hidden('all_common_modules', '');
 echo '</form>';
 
@@ -1405,12 +1393,18 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
     }
 
     $agents = (array) get_parameter('id_agents');
+    $filter_group = (int) get_parameter('filter_group', 0);
     $module_names = (array) get_parameter('module');
     $modules_selection_mode = (string) get_parameter('modules_selection_mode');
+    $type_downtime = (string) get_parameter('type_downtime', 'quiet');
 
     $all_modules = ($modules_selection_mode === 'all' && (empty($module_names) || (string) $module_names[0] === '0'));
     $all_common_modules = ($modules_selection_mode === 'common' && (empty($module_names) || (string) $module_names[0] === '0'));
 
+    if ($type_downtime === 'disable_agents') {
+        $all_modules = true;
+    }
+
     if ($all_common_modules === true) {
         $module_names = explode(',', get_parameter('all_common_modules'));
     }
@@ -1429,11 +1423,14 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
     } else {
         // If is selected 'Any', get all the agents.
         if (count($agents) === 1 && (int) $agents[0] === -2) {
-            $all_agents = get_parameter('all_agents');
-            $agents = explode(',', $all_agents);
+            $agents = agents_get_agents(
+                ['id_grupo' => $filter_group],
+                'id_agent'
+            );
         }
 
         foreach ($agents as $agent_id) {
+            $agent_id = (int) $agent_id;
             // Check module belongs to the agent.
             if ($modules_selection_mode == 'all' && $all_modules === false) {
                 $check = false;
@@ -1466,17 +1463,40 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
                 continue;
             }
 
-            $values = [
-                'id_downtime' => $id_downtime,
-                'id_agent'    => $agent_id,
-                'all_modules' => $all_modules,
-            ];
-            $result = db_process_sql_insert(
+            // Check if agent is already in downtime.
+            $agent_in_downtime = db_get_value_filter(
+                'id_downtime',
                 'tplanned_downtime_agents',
-                $values
+                [
+                    'id_agent'    => $agent_id,
+                    'id_downtime' => $id_downtime,
+                ]
             );
 
-            if ($result && !$all_modules) {
+            if ($agent_in_downtime !== false) {
+                $values = ['all_modules' => $all_modules];
+
+                $result = db_process_sql_update(
+                    'tplanned_downtime_agents',
+                    $values,
+                    [
+                        'id_downtime' => $id_downtime,
+                        'id_agent'    => $agent_id,
+                    ]
+                );
+            } else {
+                $values = [
+                    'id_downtime' => $id_downtime,
+                    'id_agent'    => $agent_id,
+                    'all_modules' => $all_modules,
+                ];
+                $result = db_process_sql_insert(
+                    'tplanned_downtime_agents',
+                    $values
+                );
+            }
+
+            if ($result !== false && (bool) $all_modules === false) {
                 foreach ($module_names as $module_name) {
                     $module = modules_get_agentmodule_id(
                         $module_name,
@@ -1487,17 +1507,32 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
                         continue;
                     }
 
-                    $values = [
-                        'id_downtime'     => $id_downtime,
-                        'id_agent'        => $agent_id,
-                        'id_agent_module' => $module['id_agente_modulo'],
-                    ];
-                    $result = db_process_sql_insert(
+                     // Check if modules are already in downtime.
+                    $module_in_downtime = db_get_value_filter(
+                        'id_downtime',
                         'tplanned_downtime_modules',
-                        $values
+                        [
+                            'id_downtime'     => $id_downtime,
+                            'id_agent'        => $agent_id,
+                            'id_agent_module' => $module['id_agente_modulo'],
+                        ]
                     );
 
-                    if ($result) {
+                    if ($module_in_downtime !== false) {
+                        continue;
+                    } else {
+                        $values = [
+                            'id_downtime'     => $id_downtime,
+                            'id_agent'        => $agent_id,
+                            'id_agent_module' => $module['id_agente_modulo'],
+                        ];
+                        $result = db_process_sql_insert(
+                            'tplanned_downtime_modules',
+                            $values
+                        );
+                    }
+
+                    if ($result !== false) {
                         $values = ['id_user' => $config['id_user']];
                         $result = db_process_sql_update(
                             'tplanned_downtime',
@@ -1526,6 +1561,7 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
                 $("#available_modules_selection_mode").hide();
                 break;
             case 'quiet':
+            case 'disable_agent_modules':
                 $("#available_modules_selection_mode").show();
                 $("#available_modules").show();
                 break;
diff --git a/pandora_console/godmode/agentes/planned_downtime.list.php b/pandora_console/godmode/agentes/planned_downtime.list.php
index 78f717d7d1..0900ee2aba 100755
--- a/pandora_console/godmode/agentes/planned_downtime.list.php
+++ b/pandora_console/godmode/agentes/planned_downtime.list.php
@@ -137,12 +137,49 @@ if (is_ajax() === true) {
             'filters' => get_parameter('filter', []),
         ];
 
-        $modules = get_agents_modules_planned_dowtime($id, $options);
+        $type_downtime = db_get_value_filter(
+            'type_downtime',
+            'tplanned_downtime',
+            ['id' => $id]
+        );
+
+        if ($type_downtime === 'disable_agents') {
+            $sql = sprintf(
+                'SELECT ta.alias as agent_name
+                    FROM tplanned_downtime_agents tpa JOIN tagente ta
+                    ON tpa.id_agent = ta.id_agente
+                    WHERE tpa.id_downtime = %d',
+                $id
+            );
+            $data = db_get_all_rows_sql($sql);
+
+            if (empty($data) === false) {
+                $data = array_reduce(
+                    $data,
+                    function ($carry, $item) {
+                        global $config;
+                        // Transforms array of arrays $data into an array
+                        // of objects, making a post-process of certain fields.
+                        $tmp = (object) $item;
+
+                        $tmp->agent_name  = io_safe_output($item['agent_name']);
+                        $tmp->module_name   = __('All modules');
+
+                        $carry[] = $tmp;
+                        return $carry;
+                    }
+                );
+            }
+        } else {
+            $data = get_agents_modules_planned_dowtime($id, $options);
+        }
+
+
         $count = get_agents_modules_planned_dowtime($id, $options, $count);
 
         echo json_encode(
             [
-                'data'            => $modules,
+                'data'            => $data,
                 'recordsTotal'    => $count[0]['total'],
                 'recordsFiltered' => $count[0]['total'],
             ]
diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js
index d55be120e6..c8679b4fe0 100644
--- a/pandora_console/include/javascript/pandora.js
+++ b/pandora_console/include/javascript/pandora.js
@@ -196,6 +196,13 @@ function agent_changed_by_multiple_agents(event, id_agent, selected) {
     serialized = "";
   }
 
+  var id_group = null;
+  if (typeof $("#filter_group") !== "undefined") {
+    try {
+      id_group = $("#filter_group").val();
+    } catch (error) {}
+  }
+
   $("#module")
     .prop("disabled", true)
     .empty()
@@ -238,7 +245,8 @@ function agent_changed_by_multiple_agents(event, id_agent, selected) {
       selection_mode: selection_mode,
       serialized: serialized,
       id_server: id_server,
-      status_module: module_status
+      status_module: module_status,
+      id_group: id_group
     },
     function(data) {
       $("#module").empty();
@@ -575,7 +583,8 @@ function module_changed_by_multiple_modules(event, id_module, selected) {
       status_module: status_module,
       "module_name[]": idModules,
       selection_mode: selection_mode,
-      tags: tags_selected
+      tags: tags_selected,
+      id_group: id_group
     },
     function(data) {
       $("#agents").append(
diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php
index 3c4eebb991..9b0e8da11f 100644
--- a/pandora_console/operation/agentes/ver_agente.php
+++ b/pandora_console/operation/agentes/ver_agente.php
@@ -473,6 +473,7 @@ if (is_ajax()) {
         $serialized = get_parameter('serialized', '');
         $id_server = (int) get_parameter('id_server', 0);
         $status_modulo = (int) get_parameter('status_module', -1);
+        $id_group_selected = (int) get_parameter('id_group', 0);
         $metaconsole_server_name = null;
         if (!empty($id_server)) {
             $metaconsole_server_name = db_get_value(
@@ -700,14 +701,18 @@ if (is_ajax()) {
                 // Get all user's groups.
                 $id_group = array_keys(users_get_groups($config['id_user']));
 
-                if (is_array($id_group)) {
+                if (is_array($id_group) && empty($id_group_selected) === true) {
                     $id_group = implode(',', $id_group);
+                } else {
+                    if (in_array($id_group_selected, $id_group) === true) {
+                        $id_group = $id_group_selected;
+                    }
                 }
 
                 $where_tags .= ' AND tagente.id_grupo IN ('.$id_group.')';
 
                 if ($selection_mode == 'common') {
-                    $sql_agent_total = 'SELECT count(*) FROM tagente WHERE disabled=0';
+                    $sql_agent_total = 'SELECT count(*) FROM tagente WHERE disabled=0'.$where_tags;
                     $agent_total = db_get_value_sql($sql_agent_total);
                     $sql = sprintf(
                         "SELECT t1.nombre, t1.id_agente_modulo FROM tagente_modulo t1

From 63349973e8c0b47fe668bf7673f3e5ad3bf40841 Mon Sep 17 00:00:00 2001
From: "edu.corral" <eduardo.corral@artica.es>
Date: Mon, 3 Oct 2022 09:34:35 +0200
Subject: [PATCH 23/83] ent 8956 cli create user

---
 pandora_server/util/pandora_manage.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index e1f5730316..1c7590aa13 100755
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -568,7 +568,7 @@ sub pandora_create_user ($$$$$) {
 	}
 
 	return db_insert ($dbh, 'id_user', 'INSERT INTO tusuario (id_user, fullname, password, is_admin, comments)
-                         VALUES (?, ?, ?, ?, ?)', safe_input($name), safe_input($name), $password, $is_admin, decode_entities($comments));
+                         VALUES (?, ?, ?, ?, ?)', safe_input($name), safe_input($name), $password, $is_admin ? '1' : '0', decode_entities($comments));
 }
 
 ##########################################################################

From 9f800df03465522e1fea8c1199743bc0f047ae6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20Gonz=C3=A1lez?= <jose.gonzalez@pandorafms.com>
Date: Mon, 3 Oct 2022 12:41:55 +0200
Subject: [PATCH 24/83] Added default definition for SNMP Interface Wizard

---
 pandora_console/godmode/setup/performance.php | 27 ++++++++
 .../include/class/AgentWizard.class.php       | 62 +++++++++++--------
 pandora_console/include/functions_config.php  | 36 +++++++++++
 3 files changed, 98 insertions(+), 27 deletions(-)

diff --git a/pandora_console/godmode/setup/performance.php b/pandora_console/godmode/setup/performance.php
index 89b745cfca..ba965f026f 100644
--- a/pandora_console/godmode/setup/performance.php
+++ b/pandora_console/godmode/setup/performance.php
@@ -701,6 +701,28 @@ if (enterprise_installed() === true) {
     );
 }
 
+// Agent Wizard defaults.
+$defaultAgentWizardOptions = json_decode(io_safe_output($config['agent_wizard_defaults']));
+$tableSnmpWizard = new stdClass();
+$tableSnmpWizard->width = '100%';
+$tableSnmpWizard->class = 'databox filters';
+$tableSnmpWizard->data = [];
+$tableSnmpWizard->style[0] = 'font-weight: bold';
+$tableSnmpWizard->style[2] = 'font-weight: bold';
+$tableSnmpWizard->size[0] = '30%';
+$tableSnmpWizard->size[2] = '30%';
+
+$i = 0;
+$j = 0;
+foreach ($defaultAgentWizardOptions as $key => $value) {
+    $tableSnmpWizard->data[$i][$j++] = $key;
+    $tableSnmpWizard->data[$i][$j++] = html_print_checkbox_switch('agent_wizard_defaults_'.$key, 1, $value, true);
+    if ($j >= 3) {
+        $j = 0;
+        $i++;
+    }
+}
+
 echo '<form id="form_setup" method="post">';
 
 echo '<fieldset class="full-column">';
@@ -725,6 +747,11 @@ echo '<fieldset>';
     html_print_table($table_other);
 echo '</fieldset>';
 
+echo '<fieldset>';
+    echo '<legend>'.__('Agent SNMP Interface Wizard defaults').' '.ui_print_help_icon('agent_snmp_wizard_options_tab', true).'</legend>';
+    html_print_table($tableSnmpWizard);
+echo '</fieldset>';
+
 echo '<div class="action-buttons" style="width: '.$table->width.'">';
 html_print_input_hidden('update_config', 1);
 html_print_submit_button(
diff --git a/pandora_console/include/class/AgentWizard.class.php b/pandora_console/include/class/AgentWizard.class.php
index f97324dfc4..46a974a0d5 100644
--- a/pandora_console/include/class/AgentWizard.class.php
+++ b/pandora_console/include/class/AgentWizard.class.php
@@ -14,7 +14,7 @@
  * |___|   |___._|__|__|_____||_____|__| |___._| |___|   |__|_|__|_______|
  *
  * ============================================================================
- * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
+ * Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
  * Please see http://pandorafms.org for full contribution list
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -285,6 +285,13 @@ class AgentWizard extends HTML
      */
     private $wmiBinary = '';
 
+    /**
+     * Default values for SNMP Interfaces.
+     *
+     * @var string
+     */
+    private $defaultSNMPValues = [];
+
 
     /**
      * Constructor
@@ -319,6 +326,7 @@ class AgentWizard extends HTML
         $this->idPolicy = get_parameter('id', '');
         $this->targetIp = get_parameter('targetIp', '');
         $this->wmiBinary = $config['wmiBinary'];
+        $this->defaultSNMPValues = (array) json_decode(io_safe_output($config['agent_wizard_defaults']));
 
         if (empty($this->idAgent) === false) {
             $array_aux = db_get_all_rows_sql(
@@ -330,7 +338,7 @@ class AgentWizard extends HTML
                 )
             );
 
-            if (!empty($array_aux)) {
+            if (empty($array_aux) === false) {
                 $this->datalist = [];
                 foreach ($array_aux as $key => $value) {
                     $this->datalist[] = $value['ip'];
@@ -547,7 +555,7 @@ class AgentWizard extends HTML
         // Fill with servers to perform the discover.
         $fieldsServers = [];
         $fieldsServers[0] = __('Local console');
-        if (enterprise_installed()) {
+        if (enterprise_installed() === true) {
             enterprise_include_once('include/functions_satellite.php');
             // Get the servers.
             $rows = get_proxy_servers();
@@ -607,7 +615,7 @@ class AgentWizard extends HTML
             ],
         ];
 
-        if (!empty($this->datalist)) {
+        if (empty($this->datalist) === false) {
             $inputs[] = [
                 'id'        => 'li_address_list',
                 'arguments' => [
@@ -4701,7 +4709,7 @@ class AgentWizard extends HTML
             'execution_type'     => 'network',
             'value'              => '1.3.6.1.2.1.2.2.1.8.'.$value,
             'module_unit'        => '',
-            'default_enabled'    => true,
+            'default_enabled'    => (bool) $this->defaultSNMPValues['ifOperStatus'],
             'module_enabled'     => false,
             'module_thresholds'  => [
                 'min_warning'   => $min_warning,
@@ -4758,7 +4766,7 @@ class AgentWizard extends HTML
             'execution_type'     => 'network',
             'value'              => '1.3.6.1.4.1.9.2.2.1.1.12.'.$value,
             'module_unit'        => 'packets/s',
-            'default_enabled'    => true,
+            'default_enabled'    => (bool) $this->defaultSNMPValues['locIfInCRC'],
             'module_enabled'     => false,
             'module_thresholds'  => [
                 'min_warning'   => '0',
@@ -4812,7 +4820,7 @@ class AgentWizard extends HTML
                 'module_info'        => 'Indicates whether the port is operating in half-duplex, full-duplex, disagree or auto negotiation mode. If the port could not agree with the far end on port duplex, the port will be in disagree(3) mode.',
                 'execution_type'     => 'network',
                 'value'              => $duplexMismatchOID,
-                'default_enabled'    => true,
+                'default_enabled'    => (bool) $this->defaultSNMPValues['DuplexMismatch'],
                 'module_enabled'     => false,
                 'module_thresholds'  => [
                     'min_warning'   => '0',
@@ -4901,7 +4909,7 @@ class AgentWizard extends HTML
                     'id_plugin'          => $plugin_id,
                     'id_modulo'          => MODULE_PLUGIN,
                     'macros'             => json_encode($macros),
-                    'default_enabled'    => true,
+                    'default_enabled'    => (bool) $this->defaultSNMPValues['Bandwidth'],
                     'module_enabled'     => false,
                     'module_unit'        => '%',
                     'module_thresholds'  => [
@@ -4940,7 +4948,7 @@ class AgentWizard extends HTML
                     'id_plugin'          => $plugin_id,
                     'id_modulo'          => MODULE_PLUGIN,
                     'macros'             => json_encode($macros),
-                    'default_enabled'    => true,
+                    'default_enabled'    => (bool) $this->defaultSNMPValues['inUsage'],
                     'module_enabled'     => false,
                     'module_unit'        => '%',
                     'module_thresholds'  => [
@@ -4979,7 +4987,7 @@ class AgentWizard extends HTML
                     'id_plugin'          => $plugin_id,
                     'id_modulo'          => MODULE_PLUGIN,
                     'macros'             => json_encode($macros),
-                    'default_enabled'    => true,
+                    'default_enabled'    => (bool) $this->defaultSNMPValues['outUsage'],
                     'module_enabled'     => false,
                     'module_unit'        => '%',
                     'module_thresholds'  => [
@@ -5011,7 +5019,7 @@ class AgentWizard extends HTML
             'execution_type'     => 'network',
             'value'              => '1.3.6.1.2.1.2.2.1.7.'.$value,
             'module_unit'        => '',
-            'default_enabled'    => false,
+            'default_enabled'    => (bool) $this->defaultSNMPValues['ifAdminStatus'],
             'module_enabled'     => false,
             'module_thresholds'  => [
                 'min_warning'   => '0',
@@ -5038,7 +5046,7 @@ class AgentWizard extends HTML
             'execution_type'     => 'network',
             'value'              => '1.3.6.1.2.1.2.2.1.13.'.$value,
             'module_unit'        => 'packets/s',
-            'default_enabled'    => false,
+            'default_enabled'    => (bool) $this->defaultSNMPValues['ifInDiscards'],
             'module_enabled'     => false,
             'module_thresholds'  => [
                 'min_warning'   => '0',
@@ -5065,7 +5073,7 @@ class AgentWizard extends HTML
             'execution_type'     => 'network',
             'value'              => '1.3.6.1.2.1.2.2.1.19.'.$value,
             'module_unit'        => 'packets/s',
-            'default_enabled'    => false,
+            'default_enabled'    => (bool) $this->defaultSNMPValues['ifOutDiscards'],
             'module_enabled'     => false,
             'module_thresholds'  => [
                 'min_warning'   => '0',
@@ -5092,7 +5100,7 @@ class AgentWizard extends HTML
             'execution_type'     => 'network',
             'value'              => '1.3.6.1.2.1.2.2.1.14.'.$value,
             'module_unit'        => 'packets/s',
-            'default_enabled'    => false,
+            'default_enabled'    => (bool) $this->defaultSNMPValues['ifInErrors'],
             'module_enabled'     => false,
             'module_thresholds'  => [
                 'min_warning'   => '0',
@@ -5119,7 +5127,7 @@ class AgentWizard extends HTML
             'execution_type'     => 'network',
             'value'              => '1.3.6.1.2.1.2.2.1.20.'.$value,
             'module_unit'        => 'packets/s',
-            'default_enabled'    => false,
+            'default_enabled'    => (bool) $this->defaultSNMPValues['ifOutErrors'],
             'module_enabled'     => false,
             'module_thresholds'  => [
                 'min_warning'   => '0',
@@ -5189,7 +5197,7 @@ class AgentWizard extends HTML
             'execution_type'     => 'network',
             'value'              => '1.3.6.1.2.1.2.2.1.10.'.$value,
             'module_unit'        => 'bytes/s',
-            'default_enabled'    => true,
+            'default_enabled'    => (bool) $this->defaultSNMPValues['ifInOctets'],
             'module_enabled'     => false,
             'module_thresholds'  => [
                 'min_warning'   => '0',
@@ -5217,7 +5225,7 @@ class AgentWizard extends HTML
             'execution_type'     => 'network',
             'value'              => '1.3.6.1.2.1.2.2.1.16.'.$value,
             'module_unit'        => 'bytes/s',
-            'default_enabled'    => true,
+            'default_enabled'    => (bool) $this->defaultSNMPValues['ifOutOctets'],
             'module_enabled'     => false,
             'module_thresholds'  => [
                 'min_warning'   => '0',
@@ -5245,7 +5253,7 @@ class AgentWizard extends HTML
             'execution_type'     => 'network',
             'value'              => '1.3.6.1.2.1.2.2.1.11.'.$value,
             'module_unit'        => 'packets/s',
-            'default_enabled'    => false,
+            'default_enabled'    => (bool) $this->defaultSNMPValues['ifInUcastPkts'],
             'module_enabled'     => false,
             'module_thresholds'  => [
                 'min_warning'   => '0',
@@ -5272,7 +5280,7 @@ class AgentWizard extends HTML
             'execution_type'     => 'network',
             'value'              => '1.3.6.1.2.1.2.2.1.17.'.$value,
             'module_unit'        => 'packets/s',
-            'default_enabled'    => false,
+            'default_enabled'    => (bool) $this->defaultSNMPValues['ifOutUcastPkts'],
             'module_enabled'     => false,
             'module_thresholds'  => [
                 'min_warning'   => '0',
@@ -5299,7 +5307,7 @@ class AgentWizard extends HTML
             'execution_type'     => 'network',
             'value'              => '1.3.6.1.2.1.2.2.1.12.'.$value,
             'module_unit'        => 'packets/s',
-            'default_enabled'    => false,
+            'default_enabled'    => (bool) $this->defaultSNMPValues['ifInNUcastPkts'],
             'module_enabled'     => false,
             'module_thresholds'  => [
                 'min_warning'   => '0',
@@ -5326,7 +5334,7 @@ class AgentWizard extends HTML
             'execution_type'     => 'network',
             'value'              => '1.3.6.1.2.1.2.2.1.18.'.$value,
             'module_unit'        => 'packets/s',
-            'default_enabled'    => false,
+            'default_enabled'    => (bool) $this->defaultSNMPValues['ifOutNUcastPkts'],
             'module_enabled'     => false,
             'module_thresholds'  => [
                 'min_warning'   => '0',
@@ -5396,7 +5404,7 @@ class AgentWizard extends HTML
             'execution_type'     => 'network',
             'value'              => '1.3.6.1.2.1.31.1.1.1.6.'.$value,
             'module_unit'        => 'bytes/s',
-            'default_enabled'    => true,
+            'default_enabled'    => (bool) $this->defaultSNMPValues['ifHCInOctets'],
             'module_enabled'     => false,
             'module_thresholds'  => [
                 'min_warning'   => '0',
@@ -5424,7 +5432,7 @@ class AgentWizard extends HTML
             'execution_type'     => 'network',
             'value'              => '1.3.6.1.2.1.31.1.1.1.10.'.$value,
             'module_unit'        => 'bytes/s',
-            'default_enabled'    => true,
+            'default_enabled'    => (bool) $this->defaultSNMPValues['ifHCOutOctets'],
             'module_enabled'     => false,
             'module_thresholds'  => [
                 'min_warning'   => '0',
@@ -5452,7 +5460,7 @@ class AgentWizard extends HTML
             'execution_type'     => 'network',
             'value'              => '1.3.6.1.2.1.31.1.1.1.7.'.$value,
             'module_unit'        => 'packets/s',
-            'default_enabled'    => false,
+            'default_enabled'    => (bool) $this->defaultSNMPValues['ifHCInUcastPkts'],
             'module_enabled'     => false,
             'module_thresholds'  => [
                 'min_warning'   => '0',
@@ -5480,7 +5488,7 @@ class AgentWizard extends HTML
             'execution_type'     => 'network',
             'value'              => '1.3.6.1.2.1.31.1.1.1.11.'.$value,
             'module_unit'        => 'packets/s',
-            'default_enabled'    => false,
+            'default_enabled'    => (bool) $this->defaultSNMPValues['ifHCOutUcastPkts'],
             'module_enabled'     => false,
             'module_thresholds'  => [
                 'min_warning'   => '0',
@@ -5507,7 +5515,7 @@ class AgentWizard extends HTML
             'execution_type'     => 'network',
             'value'              => '1.3.6.1.2.1.31.1.1.1.7.'.$value,
             'module_unit'        => 'packets/s',
-            'default_enabled'    => false,
+            'default_enabled'    => (bool) $this->defaultSNMPValues['ifHCInNUcastPkts'],
             'module_enabled'     => false,
             'module_thresholds'  => [
                 'min_warning'   => '0',
@@ -5534,7 +5542,7 @@ class AgentWizard extends HTML
             'execution_type'     => 'network',
             'value'              => '1.3.6.1.2.1.31.1.1.1.11.'.$value,
             'module_unit'        => 'packets/s',
-            'default_enabled'    => false,
+            'default_enabled'    => (bool) $this->defaultSNMPValues['ifHCOutNUcastPkts'],
             'module_enabled'     => false,
             'module_thresholds'  => [
                 'min_warning'   => '0',
diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php
index 647b719ae3..8793784147 100644
--- a/pandora_console/include/functions_config.php
+++ b/pandora_console/include/functions_config.php
@@ -916,6 +916,16 @@ function config_update_config()
                         $error_update[] = __('Default WMI Binary');
                     }
 
+                    // Walk the array with defaults.
+                    $defaultAgentWizardOptions = json_decode(io_safe_output($config['agent_wizard_defaults']));
+                    foreach ($defaultAgentWizardOptions as $key => $value) {
+                        $selectedAgentWizardOptions[$key] = get_parameter_switch('agent_wizard_defaults_'.$key);
+                    }
+
+                    if (config_update_value('agent_wizard_defaults', json_encode($selectedAgentWizardOptions), true) === false) {
+                        $error_update[] = __('SNMP Interface Agent Wizard');
+                    }
+
                     $pjs = get_parameter('phantomjs_cache_interval');
                     switch ($pjs) {
                         case $config['phantomjs_cache_interval']:
@@ -2255,6 +2265,32 @@ function config_process_config()
         config_update_value('2Fa_auth', '');
     }
 
+    if (isset($config['agent_wizard_defaults']) === false) {
+        config_update_value(
+            'agent_wizard_defaults',
+            json_encode(
+                [
+                    'ifOperStatus'    => 1,
+                    'ifInOctets'      => 1,
+                    'ifOutOctets'     => 1,
+                    'ifInUcastPkts'   => 0,
+                    'ifOutUcastPkts'  => 0,
+                    'ifInNUcastPkts'  => 0,
+                    'ifOutNUcastPkts' => 0,
+                    'locIfInCRC'      => 1,
+                    'Bandwidth'       => 1,
+                    'inUsage'         => 1,
+                    'outUsage'        => 1,
+                    'ifAdminStatus'   => 0,
+                    'ifInDiscards'    => 0,
+                    'ifOutDiscards'   => 0,
+                    'ifInErrors'      => 0,
+                    'ifOutErrors'     => 0,
+                ],
+            )
+        );
+    }
+
     /*
      * Parse the ACL IP list for access API
      */

From dc38e2e50acba0f0c6f587ce50b66cf037f3f31f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20Gonz=C3=A1lez?= <jose.gonzalez@pandorafms.com>
Date: Tue, 4 Oct 2022 15:12:12 +0200
Subject: [PATCH 25/83] Added exclude words for passwords control

---
 pandora_console/include/functions_config.php | 10 +++++-
 pandora_console/include/styles/pandora.css   | 34 ++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php
index 647b719ae3..4afd0cf5a4 100644
--- a/pandora_console/include/functions_config.php
+++ b/pandora_console/include/functions_config.php
@@ -467,7 +467,7 @@ function config_update_config()
                 break;
 
                 case 'pass':
-                    if (isset($config['enterprise_installed']) === true && (bool) $config['enterprise_installed'] === 1) {
+                    if (isset($config['enterprise_installed']) === true && (bool) $config['enterprise_installed'] === true) {
                         if (config_update_value('enable_pass_policy', get_parameter('enable_pass_policy'), true) === false) {
                             $error_update[] = __('Enable password policy');
                         }
@@ -515,6 +515,10 @@ function config_update_config()
                         if (config_update_value('reset_pass_option', (bool) get_parameter('reset_pass_option'), true) === false) {
                             $error_update[] = __('Activate reset password');
                         }
+
+                        if (config_update_value('exclusion_word_list', (string) get_parameter('exclusion_word_list'), true) === false) {
+                            $error_update[] = __('Exclusion word list for passwords');
+                        }
                     }
                 break;
 
@@ -2195,6 +2199,10 @@ function config_process_config()
         config_update_value('reset_pass_option', 0);
     }
 
+    if (isset($config['exclusion_word_list']) === false) {
+        config_update_value('exclusion_word_list', '');
+    }
+
     if (!isset($config['include_agents'])) {
         config_update_value('include_agents', 0);
     }
diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css
index eeff4d2fce..13e617f877 100644
--- a/pandora_console/include/styles/pandora.css
+++ b/pandora_console/include/styles/pandora.css
@@ -9119,3 +9119,37 @@ div#err_msg_centralised {
   margin-right: -110px;
   margin-top: 13px;
 }
+
+.tag-editor {
+  padding: 0.5em !important;
+}
+
+.tag-editor div {
+  float: right !important;
+}
+
+.tag-editor .tag-editor-tag {
+  padding: 5px !important;
+  color: #fff !important;
+  background: #82b92e !important;
+  border-radius: 0 2px 2px 0 !important;
+}
+
+.tag-editor .tag-editor-delete {
+  padding: 5px !important;
+  line-height: 16px !important;
+  background: #82b92e !important;
+  border-radius: 2px 0 0 2px !important;
+}
+
+.tag-editor .tag-editor-delete i {
+  line-height: 16pt !important;
+}
+
+.tag-editor .tag-editor-delete i:before {
+  color: #fff !important;
+}
+
+.tag-editor .tag-editor-delete:hover i:before {
+  color: #ccc !important;
+}

From 381dea9b54fb78782cf9b02563d687fa4e76df0d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20Gonz=C3=A1lez?= <jose.gonzalez@pandorafms.com>
Date: Tue, 4 Oct 2022 16:54:34 +0200
Subject: [PATCH 26/83] Added excluded password utility

---
 pandora_console/include/auth/mysql.php        | 10 ++++++++--
 pandora_console/operation/users/user_edit.php |  2 +-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php
index 67053ab0be..43b90aaeb2 100644
--- a/pandora_console/include/auth/mysql.php
+++ b/pandora_console/include/auth/mysql.php
@@ -701,7 +701,13 @@ function delete_user($id_user)
 function update_user_password($user, $password_new)
 {
     global $config;
-    if (isset($config['auth']) && $config['auth'] == 'pandora') {
+
+    if (excludedPassword($password_new) === true) {
+        $config['auth_error'] = __('The password provided is not valid. Please, set another one.');
+        return false;
+    }
+
+    if (isset($config['auth']) === true && $config['auth'] === 'pandora') {
         $sql = sprintf(
             "UPDATE tusuario SET password = '".md5($password_new)."', last_pass_change = '".date('Y-m-d H:i:s', get_system_time())."' WHERE id_user = '".$user."'"
         );
@@ -714,7 +720,7 @@ function update_user_password($user, $password_new)
         );
         $remote_pass_update = db_process_sql($sql, 'affected_rows', $connection);
 
-        if (!$remote_pass_update) {
+        if ((bool) $remote_pass_update === false) {
             $config['auth_error'] = __('Could not changes password on remote pandora');
             return false;
         }
diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php
index a42fe2e8bc..5e8308eabc 100644
--- a/pandora_console/operation/users/user_edit.php
+++ b/pandora_console/operation/users/user_edit.php
@@ -211,7 +211,7 @@ if (isset($_GET['modified']) && !$view_mode) {
         $user_info = $upd_info;
     } else {
         if (!$error_msg) {
-            $error_msg = __('Error updating passwords: ');
+            $error_msg = __('Error updating passwords: ').($config['auth_error'] ?? '');
         }
 
         $user_auth_error = $config['auth_error'];

From b5dcc5936e214bcb729f9d09d013a10fb43dc057 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20Gonz=C3=A1lez?= <jose.gonzalez@pandorafms.com>
Date: Tue, 4 Oct 2022 16:59:25 +0200
Subject: [PATCH 27/83] Fix issue

---
 pandora_console/include/functions_config.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php
index 647b719ae3..f333b77680 100644
--- a/pandora_console/include/functions_config.php
+++ b/pandora_console/include/functions_config.php
@@ -467,7 +467,7 @@ function config_update_config()
                 break;
 
                 case 'pass':
-                    if (isset($config['enterprise_installed']) === true && (bool) $config['enterprise_installed'] === 1) {
+                    if (isset($config['enterprise_installed']) === true && (bool) $config['enterprise_installed'] === true) {
                         if (config_update_value('enable_pass_policy', get_parameter('enable_pass_policy'), true) === false) {
                             $error_update[] = __('Enable password policy');
                         }

From 05cbc2fb0e5e8f04d6cf633c1ba5503df74b966e Mon Sep 17 00:00:00 2001
From: "alejandro.campos@artica.es" <alejandro.campos@artica.es>
Date: Tue, 4 Oct 2022 18:00:47 +0200
Subject: [PATCH 28/83] fixed vulnerability

---
 pandora_console/extras/mr/58.sql           |  5 +++++
 pandora_console/include/lib/User.php       |  8 ++++++++
 pandora_console/include/rest-api/index.php | 14 +++++++++++++-
 pandora_console/pandoradb.sql              |  1 +
 4 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 pandora_console/extras/mr/58.sql

diff --git a/pandora_console/extras/mr/58.sql b/pandora_console/extras/mr/58.sql
new file mode 100644
index 0000000000..9ddcadb607
--- /dev/null
+++ b/pandora_console/extras/mr/58.sql
@@ -0,0 +1,5 @@
+START TRANSACTION;
+
+ALTER TABLE `tusuario` ADD COLUMN `auth_token_secret` VARCHAR(45) DEFAULT NULL;
+
+COMMIT;
\ No newline at end of file
diff --git a/pandora_console/include/lib/User.php b/pandora_console/include/lib/User.php
index ce03e31a03..45605e9abe 100644
--- a/pandora_console/include/lib/User.php
+++ b/pandora_console/include/lib/User.php
@@ -188,6 +188,14 @@ class User implements PublicLogin
             $config['public_access'] = false;
         }
 
+        if (empty($other_secret) === true) {
+            $auth_token_secret = db_get_value('auth_token_secret', 'tusuario', 'id_user', $config['id_user']);
+
+            if (empty($auth_token_secret) === false) {
+                $other_secret = $auth_token_secret;
+            }
+        }
+
         // Build a hash to check.
         $hashCheck = self::generatePublicHash($other_secret);
         if ($hashCheck === $hash) {
diff --git a/pandora_console/include/rest-api/index.php b/pandora_console/include/rest-api/index.php
index 8db1b40c2f..dee51a9bc7 100644
--- a/pandora_console/include/rest-api/index.php
+++ b/pandora_console/include/rest-api/index.php
@@ -66,7 +66,19 @@ if ($doLogin === true) {
         ]
     ) === true
     ) {
-        echo json_encode(['auth_hash' => User::generatePublicHash()]);
+        $newGeneratedSecret = bin2hex(openssl_random_pseudo_bytes(15));
+
+        $res_update = update_user(
+            $id_user,
+            ['auth_token_secret' => $newGeneratedSecret]
+        );
+
+        if ($res_update === false) {
+            http_response_code(404);
+            return;
+        }
+
+        echo json_encode(['auth_hash' => User::generatePublicHash($newGeneratedSecret)]);
     } else {
         db_pandora_audit(
             AUDIT_LOG_ACL_VIOLATION,
diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql
index f3c3e61472..1ae2807317 100644
--- a/pandora_console/pandoradb.sql
+++ b/pandora_console/pandoradb.sql
@@ -1308,6 +1308,7 @@ CREATE TABLE IF NOT EXISTS `tusuario` (
   `integria_user_level_pass` VARCHAR(45),
   `allowed_ip_active` TINYINT UNSIGNED DEFAULT 0,
   `allowed_ip_list` TEXT,
+  `auth_token_secret` VARCHAR(45) DEFAULT NULL,
   CONSTRAINT `fk_filter_id` FOREIGN KEY (`id_filter`) REFERENCES tevent_filter (`id_filter`) ON DELETE SET NULL,
   UNIQUE KEY `id_user` (`id_user`)
 ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;

From 2ea3c3038cf7b66c35ed45499693aeca6d59922f Mon Sep 17 00:00:00 2001
From: "alejandro.campos@artica.es" <alejandro.campos@artica.es>
Date: Tue, 4 Oct 2022 18:13:50 +0200
Subject: [PATCH 29/83] fixed vulnerabilities

---
 pandora_console/ajax.php                             | 1 +
 pandora_console/extras/delete_files/delete_files.txt | 1 +
 2 files changed, 2 insertions(+)

diff --git a/pandora_console/ajax.php b/pandora_console/ajax.php
index 8b98d1c34a..4139117364 100644
--- a/pandora_console/ajax.php
+++ b/pandora_console/ajax.php
@@ -110,6 +110,7 @@ $auth_class = io_safe_output(
 $page = (string) get_parameter('page');
 $page = safe_url_extraclean($page);
 $page .= '.php';
+$page = realpath($page);
 $public_hash = get_parameter('auth_hash', false);
 $public_login = false;
 
diff --git a/pandora_console/extras/delete_files/delete_files.txt b/pandora_console/extras/delete_files/delete_files.txt
index f9acc8ade4..96223ccd69 100644
--- a/pandora_console/extras/delete_files/delete_files.txt
+++ b/pandora_console/extras/delete_files/delete_files.txt
@@ -1666,3 +1666,4 @@ godmode/um_client/vendor/sebastian/object-enumerator
 godmode/um_client/vendor/sebastian
 godmode/um_client/vendor
 update_manager_client/resources/styles/pandora.css
+enterprise/meta/general/upload_head_image.php

From 461f4f13cb070cfed12010a4b7c43c9547068f57 Mon Sep 17 00:00:00 2001
From: Daniel Barbero <daniel.barbero@artica.es>
Date: Wed, 5 Oct 2022 17:06:55 +0200
Subject: [PATCH 30/83] new widget grouped meter graphs pandora_enterprise#8620

---
 .../include/lib/Dashboard/Widget.php          |   1 +
 .../Dashboard/Widgets/GroupedMeterGraphs.php  | 883 ++++++++++++++++++
 pandora_console/include/styles/dashboards.css | 122 +++
 3 files changed, 1006 insertions(+)
 create mode 100644 pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php

diff --git a/pandora_console/include/lib/Dashboard/Widget.php b/pandora_console/include/lib/Dashboard/Widget.php
index cbb4a7ccfe..de5727a56f 100644
--- a/pandora_console/include/lib/Dashboard/Widget.php
+++ b/pandora_console/include/lib/Dashboard/Widget.php
@@ -416,6 +416,7 @@ class Widget
                     $className .= '\OsQuickReportWidget';
                 break;
 
+                case 'GroupedMeterGraphs':
                 case 'ColorModuleTabs':
                 case 'BlockHistogram':
                     $className .= '\\'.$name;
diff --git a/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php b/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php
new file mode 100644
index 0000000000..a6ca136d32
--- /dev/null
+++ b/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php
@@ -0,0 +1,883 @@
+<?php
+/**
+ * Widget Color tabs modules Pandora FMS Console
+ *
+ * @category   Console Class
+ * @package    Pandora FMS
+ * @subpackage Widget
+ * @version    1.0.0
+ * @license    See below
+ *
+ *    ______                 ___                    _______ _______ ________
+ *   |   __ \.-----.--.--.--|  |.-----.----.-----. |    ___|   |   |     __|
+ *  |    __/|  _  |     |  _  ||  _  |   _|  _  | |    ___|       |__     |
+ * |___|   |___._|__|__|_____||_____|__| |___._| |___|   |__|_|__|_______|
+ *
+ * ============================================================================
+ * Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
+ * Please see http://pandorafms.org for full contribution list
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation for version 2.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * ============================================================================
+ */
+
+namespace PandoraFMS\Dashboard;
+
+use PandoraFMS\Enterprise\Metaconsole\Node;
+
+global $config;
+
+/**
+ * URL Widgets
+ */
+class GroupedMeterGraphs extends Widget
+{
+    private const STATUS_NORMAL = 'normal';
+    private const STATUS_CRITICAL = 'critical';
+    private const STATUS_WARNING = 'warning';
+    private const RATIO_WITH_BOX = 20.1518;
+
+    /**
+     * Name widget.
+     *
+     * @var string
+     */
+    protected $name;
+
+    /**
+     * Title widget.
+     *
+     * @var string
+     */
+    protected $title;
+
+    /**
+     * Page widget;
+     *
+     * @var string
+     */
+    protected $page;
+
+    /**
+     * Class name widget.
+     *
+     * @var [type]
+     */
+    protected $className;
+
+    /**
+     * Values options for each widget.
+     *
+     * @var [type]
+     */
+    protected $values;
+
+    /**
+     * Configuration required.
+     *
+     * @var boolean
+     */
+    protected $configurationRequired;
+
+    /**
+     * Error load widget.
+     *
+     * @var boolean
+     */
+    protected $loadError;
+
+    /**
+     * Width.
+     *
+     * @var integer
+     */
+    protected $width;
+
+    /**
+     * Heigth.
+     *
+     * @var integer
+     */
+    protected $height;
+
+    /**
+     * Grid Width.
+     *
+     * @var integer
+     */
+    protected $gridWidth;
+
+    /**
+     * Cell ID.
+     *
+     * @var integer
+     */
+    protected $cellId;
+
+    /**
+     * Size.
+     *
+     * @var array
+     */
+    private array $size;
+
+    /**
+     * Number of boxes.
+     *
+     * @var float
+     */
+    private float $boxNumber;
+
+    /**
+     * Thresholds.
+     *
+     * @var array
+     */
+    private array $thresholds;
+
+
+    /**
+     * Construct.
+     *
+     * @param integer      $cellId      Cell ID.
+     * @param integer      $dashboardId Dashboard ID.
+     * @param integer      $widgetId    Widget ID.
+     * @param integer|null $width       New width.
+     * @param integer|null $height      New height.
+     * @param integer|null $gridWidth   Grid width.
+     */
+    public function __construct(
+        int $cellId,
+        int $dashboardId=0,
+        int $widgetId=0,
+        ?int $width=0,
+        ?int $height=0,
+        ?int $gridWidth=0
+    ) {
+        global $config;
+
+        // WARNING: Do not edit. This chunk must be in the constructor.
+        parent::__construct(
+            $cellId,
+            $dashboardId,
+            $widgetId
+        );
+
+        // Width.
+        $this->width = $width;
+
+        // Height.
+        $this->height = $height;
+
+        // Grid Width.
+        $this->gridWidth = $gridWidth;
+
+        // Cell Id.
+        $this->cellId = $cellId;
+
+        // Options.
+        $this->values = $this->decoders($this->getOptionsWidget());
+
+        // Positions.
+        $this->position = $this->getPositionWidget();
+
+        // Page.
+        $this->page = basename(__FILE__);
+
+        // ClassName.
+        $class = new \ReflectionClass($this);
+        $this->className = $class->getShortName();
+
+        // Title.
+        $this->title = __('Color tabs modules');
+
+        // Name.
+        if (empty($this->name) === true) {
+            $this->name = 'single_graph';
+        }
+
+        // This forces at least a first configuration.
+        $this->configurationRequired = false;
+        if (empty($this->values['moduleGroupedMeterGraphs']) === true) {
+            $this->configurationRequired = true;
+        }
+
+        $this->overflow_scrollbars = false;
+    }
+
+
+    /**
+     * Decoders hack for retrocompability.
+     *
+     * @param array $decoder Values.
+     *
+     * @return array Returns the values ​​with the correct key.
+     */
+    public function decoders(array $decoder): array
+    {
+        $values = [];
+        // Retrieve global - common inputs.
+        $values = parent::decoders($decoder);
+
+        $values['agentsGroupedMeterGraphs'] = [];
+        if (isset($decoder['agentsGroupedMeterGraphs']) === true) {
+            if (isset($decoder['agentsGroupedMeterGraphs'][0]) === true
+                && empty($decoder['agentsGroupedMeterGraphs']) === false
+            ) {
+                $values['agentsGroupedMeterGraphs'] = explode(
+                    ',',
+                    $decoder['agentsGroupedMeterGraphs'][0]
+                );
+            }
+        }
+
+        if (isset($decoder['selectionGroupedMeterGraphs']) === true) {
+            $values['selectionGroupedMeterGraphs'] = $decoder['selectionGroupedMeterGraphs'];
+        }
+
+        $values['moduleGroupedMeterGraphs'] = [];
+        if (isset($decoder['moduleGroupedMeterGraphs']) === true) {
+            if (empty($decoder['moduleGroupedMeterGraphs']) === false) {
+                $values['moduleGroupedMeterGraphs'] = $decoder['moduleGroupedMeterGraphs'];
+            }
+        }
+
+        if (isset($decoder['formatData']) === true) {
+            $values['formatData'] = $decoder['formatData'];
+        }
+
+        $values['label'] = 'module';
+        if (isset($decoder['label']) === true) {
+            $values['label'] = $decoder['label'];
+        }
+
+        $values['min_critical'] = null;
+        if (isset($decoder['min_critical']) === true) {
+            $values['min_critical'] = $decoder['min_critical'];
+        }
+
+        $values['max_critical'] = null;
+        if (isset($decoder['max_critical']) === true) {
+            $values['max_critical'] = $decoder['max_critical'];
+        }
+
+        $values['min_warning'] = null;
+        if (isset($decoder['min_warning']) === true) {
+            $values['min_warning'] = $decoder['min_warning'];
+        }
+
+        $values['max_warning'] = null;
+        if (isset($decoder['max_warning']) === true) {
+            $values['max_warning'] = $decoder['max_warning'];
+        }
+
+        if (isset($decoder['fontColor']) === true) {
+            $values['fontColor'] = $decoder['fontColor'];
+        }
+
+        return $values;
+    }
+
+
+    /**
+     * Generates inputs for form (specific).
+     *
+     * @return array Of inputs.
+     *
+     * @throws Exception On error.
+     */
+    public function getFormInputs(): array
+    {
+        $values = $this->values;
+
+        // Retrieve global - common inputs.
+        $inputs = parent::getFormInputs();
+
+        $blocks = [
+            'row1',
+            'row2',
+        ];
+
+        $inputs['blocks'] = $blocks;
+
+        foreach ($inputs as $kInput => $vInput) {
+            $inputs['inputs']['row1'][] = $vInput;
+        }
+
+        if (empty($values['fontColor']) === true) {
+            $values['fontColor'] = '#2c3e50';
+        }
+
+        $inputs['inputs']['row1'][] = [
+            'label'     => __('Font color'),
+            'arguments' => [
+                'wrapper' => 'div',
+                'name'    => 'fontColor',
+                'type'    => 'color',
+                'value'   => $values['fontColor'],
+                'return'  => true,
+            ],
+        ];
+
+        // Format Data.
+        $inputs['inputs']['row1'][] = [
+            'label'     => __('Format Data'),
+            'arguments' => [
+                'name'  => 'formatData',
+                'id'    => 'formatData',
+                'type'  => 'switch',
+                'value' => $values['formatData'],
+            ],
+        ];
+
+        $inputs['inputs']['row1'][] = [
+            'class'         => 'dashboard-input-threshold',
+            'direct'        => 1,
+            'block_content' => [
+                [
+                    'label'     => __('Warning threshold'),
+                    'arguments' => [],
+                ],
+                [
+                    'label'     => __('Min'),
+                    'arguments' => [
+                        'name'  => 'min_warning',
+                        'id'    => 'min_warning',
+                        'type'  => 'number',
+                        'value' => $values['min_warning'],
+                    ],
+                ],
+                [
+                    'label'     => __('Max'),
+                    'arguments' => [
+                        'name'  => 'max_warning',
+                        'id'    => 'max_warning',
+                        'type'  => 'number',
+                        'value' => $values['max_warning'],
+                    ],
+                ],
+            ],
+        ];
+
+        $inputs['inputs']['row1'][] = [
+            'class'         => 'dashboard-input-threshold',
+            'direct'        => 1,
+            'block_content' => [
+                [
+                    'label'     => __('Critical threshold'),
+                    'arguments' => [],
+                ],
+                [
+                    'label'     => __('Min'),
+                    'arguments' => [
+                        'name'  => 'min_critical',
+                        'id'    => 'min_critical',
+                        'type'  => 'number',
+                        'value' => $values['min_critical'],
+                    ],
+                ],
+                [
+                    'label'     => __('Max'),
+                    'arguments' => [
+                        'name'  => 'max_critical',
+                        'id'    => 'max_critical',
+                        'type'  => 'number',
+                        'value' => $values['max_critical'],
+                    ],
+                ],
+            ],
+
+        ];
+
+        // Type Label.
+        $fields = [
+            'module'       => __('Module'),
+            'agent'        => __('Agent'),
+            'agent_module' => __('Agent / module'),
+        ];
+
+        $inputs['inputs']['row2'][] = [
+            'label'     => __('Label'),
+            'arguments' => [
+                'type'     => 'select',
+                'fields'   => $fields,
+                'name'     => 'label',
+                'selected' => $values['label'],
+                'return'   => true,
+            ],
+        ];
+
+        $inputs['inputs']['row2'][] = [
+            'arguments' => [
+                'type'                   => 'select_multiple_modules_filtered_select2',
+                'agent_values'           => agents_get_agents_selected(0),
+                'agent_name'             => 'agentsGroupedMeterGraphs[]',
+                'agent_ids'              => $values['agentsGroupedMeterGraphs'],
+                'selectionModules'       => $values['selectionGroupedMeterGraphs'],
+                'selectionModulesNameId' => 'selectionGroupedMeterGraphs',
+                'modules_ids'            => $values['moduleGroupedMeterGraphs'],
+                'modules_name'           => 'moduleGroupedMeterGraphs[]',
+            ],
+        ];
+
+        return $inputs;
+    }
+
+
+    /**
+     * Get Post for widget.
+     *
+     * @return array
+     */
+    public function getPost():array
+    {
+        // Retrieve global - common inputs.
+        $values = parent::getPost();
+
+        $values['agentsGroupedMeterGraphs'] = \get_parameter(
+            'agentsGroupedMeterGraphs',
+            []
+        );
+        $values['selectionGroupedMeterGraphs'] = \get_parameter(
+            'selectionGroupedMeterGraphs',
+            0
+        );
+
+        $values['moduleGroupedMeterGraphs'] = \get_parameter(
+            'moduleGroupedMeterGraphs'
+        );
+
+        $agColor = [];
+        if (isset($values['agentsGroupedMeterGraphs'][0]) === true
+            && empty($values['agentsGroupedMeterGraphs'][0]) === false
+        ) {
+            $agColor = explode(',', $values['agentsGroupedMeterGraphs'][0]);
+        }
+
+        $agModule = [];
+        if (isset($values['moduleGroupedMeterGraphs'][0]) === true
+            && empty($values['moduleGroupedMeterGraphs'][0]) === false
+        ) {
+            $agModule = explode(',', $values['moduleGroupedMeterGraphs'][0]);
+        }
+
+        $values['moduleGroupedMeterGraphs'] = get_same_modules_all(
+            $agColor,
+            $agModule
+        );
+
+        $values['formatData'] = \get_parameter_switch('formatData', 0);
+
+        $values['fontColor'] = \get_parameter('fontColor', '#2c3e50');
+
+        $values['label'] = \get_parameter('label', 'module');
+
+        $values['min_critical'] = \get_parameter('min_critical', null);
+        $values['max_critical'] = \get_parameter('max_critical', null);
+        $values['min_warning'] = \get_parameter('min_warning', null);
+        $values['max_warning'] = \get_parameter('max_warning', null);
+
+        return $values;
+    }
+
+
+    /**
+     * Draw widget.
+     *
+     * @return string;
+     */
+    public function load()
+    {
+        $this->size = parent::getSize();
+        $this->boxNumber = ceil(($this->size['width'] * 0.65) / self::RATIO_WITH_BOX);
+
+        $output = '';
+        if (is_metaconsole() === true) {
+            $modules_nodes = array_reduce(
+                $this->values['moduleGroupedMeterGraphs'],
+                function ($carry, $item) {
+                    $explode = explode('|', $item);
+                    $carry[$explode[0]][] = $explode[1];
+                    return $carry;
+                },
+                []
+            );
+
+            $modules = [];
+            foreach ($modules_nodes as $n => $mod) {
+                try {
+                    $node = new Node((int) $n);
+                    $node->connect();
+                    $node_mods = $this->getInfoModules($mod);
+                    if (empty($node_mods) === false) {
+                        foreach ($node_mods as $value) {
+                            $value['id_node'] = $n;
+                            $value['server_name'] = $node->toArray()['server_name'];
+                            $modules[] = $value;
+                        }
+                    }
+
+                    $node->disconnect();
+                } catch (\Exception $e) {
+                    // Unexistent agent.
+                    $node->disconnect();
+                }
+            }
+        } else {
+            $modules = $this->getInfoModules(
+                $this->values['moduleGroupedMeterGraphs']
+            );
+        }
+
+        if ($modules !== false && empty($modules) === false) {
+            $moduleData = array_map(
+                function ($module) {
+                    return ($module['data'] ?? 0);
+                },
+                $modules
+            );
+
+            $tresholdData = [
+                ($this->values['min_critical'] ?? 0),
+                ($this->values['max_critical'] ?? 0),
+                ($this->values['min_warning'] ?? 0),
+                ($this->values['max_warning'] ?? 0),
+            ];
+
+            $max = max(
+                array_merge(
+                    $moduleData,
+                    $tresholdData
+                )
+            );
+
+            $min = min(
+                array_merge(
+                    $moduleData,
+                    $tresholdData
+                )
+            );
+
+            $this->thresholds = $this->calculateThreshold($max, $min);
+
+            $output .= '<div class="container-grouped-meter" style="color:'.$this->values['fontColor'].'">';
+            foreach ($modules as $module) {
+                $output .= $this->drawRowModule(
+                    $module,
+                    $max
+                );
+            }
+
+            $output .= '</div>';
+        } else {
+            $output .= '<div class="container-center">';
+            $output .= \ui_print_info_message(
+                __('Not found modules'),
+                '',
+                true
+            );
+            $output .= '</div>';
+        }
+
+        return $output;
+    }
+
+
+    /**
+     * Get info modules.
+     *
+     * @param array $modules Modules.
+     *
+     * @return array Data.
+     */
+    private function getInfoModules(array $modules): array
+    {
+        $where = sprintf(
+            'tagente_modulo.id_agente_modulo IN (%s)
+            AND tagente_modulo.delete_pending = 0',
+            implode(',', $modules)
+        );
+
+        $sql = sprintf(
+            'SELECT tagente_modulo.id_agente_modulo AS `id`,
+                tagente_modulo.nombre AS `name`,
+                tagente_modulo.unit AS `unit`,
+                tagente_modulo.min_warning AS w_min,
+                tagente_modulo.max_warning AS w_max,
+                tagente_modulo.str_warning AS w_str,
+                tagente_modulo.min_critical AS c_min,
+                tagente_modulo.max_critical AS c_max,
+                tagente_modulo.str_critical AS c_str,
+                tagente_modulo.id_tipo_modulo AS type_module,
+                tagente_estado.datos AS `data`,
+                tagente_estado.timestamp AS `timestamp`,
+                tagente_estado.estado AS `status`,
+                tagente.alias
+            FROM tagente_modulo
+            LEFT JOIN tagente_estado
+                ON tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
+            LEFT JOIN tagente
+                ON tagente_modulo.id_agente = tagente.id_agente
+            WHERE %s',
+            $where
+        );
+
+        $modules = db_get_all_rows_sql($sql);
+
+        if ($modules === false) {
+            $modules = [];
+        }
+
+        return $modules;
+    }
+
+
+    /**
+     * Draw info module.
+     *
+     * @param array $data Data module.
+     * @param float $max  Value max.
+     *
+     * @return string
+     */
+    private function drawRowModule(
+        array $data,
+        float $max
+    ):string {
+        global $config;
+
+        $module_data = $this->getBoxPercentageMaths($max, $data['data']);
+
+        $output = '';
+        $output .= '<div class="container-info-module-meter">';
+
+        // Module name.
+        $output .= '<div class="container-info-module-meter-title">';
+        $name = '';
+        switch ($this->values['label']) {
+            case 'agent':
+                $name = $data['alias'];
+            break;
+
+            case 'agent_module':
+                $name = $data['alias'].' / '.$data['name'];
+            break;
+
+            default:
+            case 'module':
+                $name = $data['name'];
+            break;
+        }
+
+        $output .= $name;
+        $output .= '</div>';
+
+        // Graphs.
+        $output .= '<div class="container-info-module-meter-graphs">';
+        for ($i = 0; $i < $this->boxNumber; $i++) {
+            $class = 'meter-graph-';
+            $class .= $this->getThresholdStatus($i);
+
+            if ($module_data > $i) {
+                $class .= ' meter-graph-opacity';
+            }
+
+            $output .= '<div class="'.$class.'">';
+            $output .= '</div>';
+        }
+
+        $output .= '</div>';
+
+        // Data.
+        $class = 'container-info-module-meter-data';
+        $class .= ' meter-data-';
+        $class .= $this->getThresholdStatus($module_data);
+
+        $output .= '<div class="'.$class.'">';
+        if ($data['data'] !== null && $data['data'] !== '') {
+            if (isset($this->values['formatData']) === true
+                && (bool) $this->values['formatData'] === true
+            ) {
+                $output .= format_for_graph(
+                    $data['data'],
+                    $config['graph_precision']
+                );
+            } else {
+                $output .= sla_truncate(
+                    $data['data'],
+                    $config['graph_precision']
+                );
+            }
+
+            $output .= ' '.$data['unit'];
+        } else {
+            $output .= '--';
+        }
+
+        $output .= '</div>';
+
+        $output .= '</div>';
+
+        return $output;
+    }
+
+
+    /**
+     * Get status.
+     *
+     * @return array
+     */
+    private static function getStatuses()
+    {
+        return [
+            self::STATUS_CRITICAL,
+            self::STATUS_WARNING,
+            self::STATUS_NORMAL,
+        ];
+    }
+
+
+    /**
+     * Get tresholds.
+     *
+     * @param float $max Value max.
+     * @param float $min Value min.
+     *
+     * @return array Array threshold.
+     */
+    private function calculateThreshold(float $max, float $min)
+    {
+        $nMax = null;
+        if ($this->values['min_warning'] !== null) {
+            $nMax = $this->getBoxPercentageMaths($max, $this->values['min_warning']);
+        }
+
+        $wMin = null;
+        if ($this->values['min_warning'] !== null) {
+            $wMin = $this->getBoxPercentageMaths($max, $this->values['min_warning']);
+        }
+
+        $wMax = null;
+        if ($this->values['max_warning'] !== null) {
+            $wMax = $this->getBoxPercentageMaths($max, $this->values['max_warning']);
+        }
+
+        $cMin = null;
+        if ($this->values['min_critical'] !== null) {
+            $cMin = $this->getBoxPercentageMaths($max, $this->values['min_critical']);
+        }
+
+        $cMax = null;
+        if ($this->values['max_critical'] !== null) {
+            $cMax = $this->getBoxPercentageMaths($max, $this->values['max_critical']);
+        }
+
+        $thresholds = [
+            'normal'   => [
+                'min' => $min,
+                'max' => $nMax,
+            ],
+            'warning'  => [
+                'min' => $wMin,
+                'max' => $wMax,
+            ],
+            'critical' => [
+                'min' => $cMin,
+                'max' => $cMax,
+            ],
+        ];
+
+        return $thresholds;
+    }
+
+
+    /**
+     * Get porcentage.
+     *
+     * @param float $max   Maximum.
+     * @param float $value Value.
+     *
+     * @return float
+     */
+    private function getBoxPercentageMaths(float $max, float $value):float
+    {
+        return (($value / $max) * $this->boxNumber);
+    }
+
+
+    /**
+     * Get status compare tresholds.
+     *
+     * @param float $value Value to compare.
+     *
+     * @return string
+     */
+    private function getThresholdStatus(
+        float $value
+    ) {
+        foreach (self::getStatuses() as $status) {
+            if ($this->thresholds[$status]['min'] === null
+                && $this->thresholds[$status]['max'] === null
+            ) {
+                continue;
+            }
+
+            if (($this->thresholds[$status]['min'] === null
+                && $this->thresholds[$status]['max'] >= $value)
+                || ($this->thresholds[$status]['max'] === null
+                && $this->thresholds[$status]['min'] <= $value)
+                || ($this->thresholds[$status]['min'] <= $value
+                && $this->thresholds[$status]['max'] >= $value)
+            ) {
+                return $status;
+            }
+        }
+
+        return self::STATUS_NORMAL;
+    }
+
+
+    /**
+     * Get description.
+     *
+     * @return string.
+     */
+    public static function getDescription()
+    {
+        return __('Grouped meter graphs');
+    }
+
+
+    /**
+     * Get Name.
+     *
+     * @return string.
+     */
+    public static function getName()
+    {
+        return 'GroupedMeterGraphs';
+    }
+
+
+    /**
+     * Get size Modal Configuration.
+     *
+     * @return array
+     */
+    public function getSizeModalConfiguration(): array
+    {
+        $size = [
+            'width'  => (is_metaconsole() === true) ? 1000 : 900,
+            'height' => 480,
+        ];
+
+        return $size;
+    }
+
+
+}
diff --git a/pandora_console/include/styles/dashboards.css b/pandora_console/include/styles/dashboards.css
index e8ab6204d9..973881ffc8 100644
--- a/pandora_console/include/styles/dashboards.css
+++ b/pandora_console/include/styles/dashboards.css
@@ -677,6 +677,128 @@ form.modal-dashboard
   text-align: initial;
 }
 
+.container-grouped-meter {
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+  align-items: center;
+  width: 98%;
+  padding: 5px;
+}
+.container-grouped-meter .container-info-module-meter {
+  display: flex;
+  flex-direction: row;
+  justify-content: center;
+  align-items: center;
+  width: 100%;
+  height: 30px;
+}
+
+.container-grouped-meter
+  .container-info-module-meter
+  .container-info-module-meter-title {
+  flex: 1 1 20%;
+  font-size: 100%;
+  font-weight: bolder;
+  text-align: right;
+  padding-right: 10px;
+  text-overflow: ellipsis;
+  overflow: hidden;
+  white-space: nowrap;
+}
+
+.container-grouped-meter
+  .container-info-module-meter
+  .container-info-module-meter-graphs {
+  flex: 1 1 65%;
+  display: flex;
+  flex-direction: row;
+  justify-content: space-around;
+  align-items: center;
+  height: 100%;
+}
+
+.container-grouped-meter
+  .container-info-module-meter
+  .container-info-module-meter-graphs
+  div {
+  border-radius: 2px;
+  width: 17px;
+  height: 90%;
+  opacity: 0.4;
+}
+
+.container-grouped-meter
+  .container-info-module-meter
+  .container-info-module-meter-graphs
+  div.meter-graph-critical {
+  background-color: #e63c52;
+}
+
+.container-grouped-meter
+  .container-info-module-meter
+  .container-info-module-meter-graphs
+  div.meter-graph-warning {
+  background-color: #f3b200;
+}
+
+.container-grouped-meter
+  .container-info-module-meter
+  .container-info-module-meter-graphs
+  div.meter-graph-normal {
+  background-color: #82b92e;
+}
+
+.container-grouped-meter
+  .container-info-module-meter
+  .container-info-module-meter-graphs
+  div.meter-graph-opacity {
+  opacity: 1;
+}
+
+.container-grouped-meter
+  .container-info-module-meter
+  .container-info-module-meter-data {
+  flex: 1 1 15%;
+  font-size: 150%;
+  font-weight: bolder;
+  text-align: right;
+  text-overflow: ellipsis;
+  overflow: hidden;
+  white-space: nowrap;
+}
+
+.container-grouped-meter
+  .container-info-module-meter
+  .container-info-module-meter-data.meter-data-critical {
+  color: #e63c52;
+}
+
+.container-grouped-meter
+  .container-info-module-meter
+  .container-info-module-meter-data.meter-data-warning {
+  color: #f3b200;
+}
+
+.container-grouped-meter
+  .container-info-module-meter
+  .container-info-module-meter-data.meter-data-normal {
+  color: #82b92e;
+}
+
+.dashboard-input-threshold {
+  align-items: center;
+  justify-content: space-between;
+}
+
+.dashboard-input-threshold input {
+  max-width: 20% !important;
+}
+
+.dashboard-input-threshold label:not(:first-child) {
+  flex: 0 !important;
+}
+
 .content-widget .dataTables_wrapper {
   width: 98%;
   margin-top: 5px;

From 54b44cc7fc6f4d04cb26bdb83d42960da8a99106 Mon Sep 17 00:00:00 2001
From: Daniel Barbero <daniel.barbero@artica.es>
Date: Thu, 6 Oct 2022 09:41:31 +0200
Subject: [PATCH 31/83] new widget grouped meter graphs pandora_enterprise#8620

---
 .../Dashboard/Widgets/GroupedMeterGraphs.php  | 38 ++++++++++++++-----
 pandora_console/include/styles/dashboards.css |  1 -
 2 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php b/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php
index a6ca136d32..9ba51eeefb 100644
--- a/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php
+++ b/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php
@@ -41,6 +41,7 @@ class GroupedMeterGraphs extends Widget
     private const STATUS_CRITICAL = 'critical';
     private const STATUS_WARNING = 'warning';
     private const RATIO_WITH_BOX = 20.1518;
+    private const MAX_MODULES = 20;
 
     /**
      * Name widget.
@@ -66,14 +67,14 @@ class GroupedMeterGraphs extends Widget
     /**
      * Class name widget.
      *
-     * @var [type]
+     * @var string
      */
     protected $className;
 
     /**
      * Values options for each widget.
      *
-     * @var [type]
+     * @var array
      */
     protected $values;
 
@@ -534,7 +535,24 @@ class GroupedMeterGraphs extends Widget
             );
         }
 
-        if ($modules !== false && empty($modules) === false) {
+        if ($modules !== false
+            && empty($modules) === false
+            && is_array($modules) === true
+        ) {
+            if (count($modules) > self::MAX_MODULES) {
+                $output .= '<div class="container-center">';
+                $output .= \ui_print_info_message(
+                    __(
+                        'The maximum number of modules to display is %d, please reconfigure the widget.',
+                        self::MAX_MODULES
+                    ),
+                    '',
+                    true
+                );
+                $output .= '</div>';
+                return $output;
+            }
+
             $moduleData = array_map(
                 function ($module) {
                     return ($module['data'] ?? 0);
@@ -657,7 +675,6 @@ class GroupedMeterGraphs extends Widget
         $output .= '<div class="container-info-module-meter">';
 
         // Module name.
-        $output .= '<div class="container-info-module-meter-title">';
         $name = '';
         switch ($this->values['label']) {
             case 'agent':
@@ -674,6 +691,7 @@ class GroupedMeterGraphs extends Widget
             break;
         }
 
+        $output .= '<div class="container-info-module-meter-title" title="'.$name.'">';
         $output .= $name;
         $output .= '</div>';
 
@@ -698,27 +716,29 @@ class GroupedMeterGraphs extends Widget
         $class .= ' meter-data-';
         $class .= $this->getThresholdStatus($module_data);
 
-        $output .= '<div class="'.$class.'">';
+        $result_data = '';
         if ($data['data'] !== null && $data['data'] !== '') {
             if (isset($this->values['formatData']) === true
                 && (bool) $this->values['formatData'] === true
             ) {
-                $output .= format_for_graph(
+                $result_data .= format_for_graph(
                     $data['data'],
                     $config['graph_precision']
                 );
             } else {
-                $output .= sla_truncate(
+                $result_data .= sla_truncate(
                     $data['data'],
                     $config['graph_precision']
                 );
             }
 
-            $output .= ' '.$data['unit'];
+            $result_data .= ' '.$data['unit'];
         } else {
-            $output .= '--';
+            $result_data .= '--';
         }
 
+        $output .= '<div class="'.$class.'" title="'.$result_data.'">';
+        $output .= $result_data;
         $output .= '</div>';
 
         $output .= '</div>';
diff --git a/pandora_console/include/styles/dashboards.css b/pandora_console/include/styles/dashboards.css
index 973881ffc8..1f01152379 100644
--- a/pandora_console/include/styles/dashboards.css
+++ b/pandora_console/include/styles/dashboards.css
@@ -683,7 +683,6 @@ form.modal-dashboard
   justify-content: center;
   align-items: center;
   width: 98%;
-  padding: 5px;
 }
 .container-grouped-meter .container-info-module-meter {
   display: flex;

From 014441a2daa8a7f39deedfbaac9cc3a0723c07ec Mon Sep 17 00:00:00 2001
From: Daniel Barbero <daniel.barbero@artica.es>
Date: Thu, 6 Oct 2022 17:13:45 +0200
Subject: [PATCH 32/83] new widget grouped meter graphs pandora_enterprise#8620

---
 .../Dashboard/Widgets/GroupedMeterGraphs.php  | 224 ++++++++++++++----
 1 file changed, 176 insertions(+), 48 deletions(-)

diff --git a/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php b/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php
index 9ba51eeefb..b88414d623 100644
--- a/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php
+++ b/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php
@@ -42,6 +42,7 @@ class GroupedMeterGraphs extends Widget
     private const STATUS_WARNING = 'warning';
     private const RATIO_WITH_BOX = 20.1518;
     private const MAX_MODULES = 20;
+    private const MAX_INCREASE = 0.10;
 
     /**
      * Name widget.
@@ -257,6 +258,16 @@ class GroupedMeterGraphs extends Widget
             $values['label'] = $decoder['label'];
         }
 
+        $values['min_value'] = null;
+        if (isset($decoder['min_value']) === true) {
+            $values['min_value'] = $decoder['min_value'];
+        }
+
+        $values['max_value'] = null;
+        if (isset($decoder['max_value']) === true) {
+            $values['max_value'] = $decoder['max_value'];
+        }
+
         $values['min_critical'] = null;
         if (isset($decoder['min_critical']) === true) {
             $values['min_critical'] = $decoder['min_critical'];
@@ -336,6 +347,36 @@ class GroupedMeterGraphs extends Widget
             ],
         ];
 
+        $inputs['inputs']['row1'][] = [
+            'class'         => 'dashboard-input-threshold',
+            'direct'        => 1,
+            'block_content' => [
+                [
+                    'label'     => __('Values'),
+                    'arguments' => [],
+                ],
+                [
+                    'label'     => __('Min'),
+                    'arguments' => [
+                        'name'  => 'min_value',
+                        'id'    => 'min_value',
+                        'type'  => 'number',
+                        'value' => $values['min_value'],
+                    ],
+                ],
+                [
+                    'label'     => __('Max'),
+                    'arguments' => [
+                        'name'  => 'max_value',
+                        'id'    => 'max_value',
+                        'type'  => 'number',
+                        'value' => $values['max_value'],
+                    ],
+                ],
+            ],
+
+        ];
+
         $inputs['inputs']['row1'][] = [
             'class'         => 'dashboard-input-threshold',
             'direct'        => 1,
@@ -478,6 +519,9 @@ class GroupedMeterGraphs extends Widget
 
         $values['label'] = \get_parameter('label', 'module');
 
+        $values['min_value'] = \get_parameter('min_value', null);
+        $values['max_value'] = \get_parameter('max_value', null);
+
         $values['min_critical'] = \get_parameter('min_critical', null);
         $values['max_critical'] = \get_parameter('max_critical', null);
         $values['min_warning'] = \get_parameter('min_warning', null);
@@ -553,41 +597,75 @@ class GroupedMeterGraphs extends Widget
                 return $output;
             }
 
-            $moduleData = array_map(
-                function ($module) {
-                    return ($module['data'] ?? 0);
-                },
-                $modules
-            );
+            $max = null;
+            $min = null;
+            // Dinamic treshold.
+            if ($this->values['min_critical'] !== null
+                || $this->values['max_critical'] !== null
+                || $this->values['min_warning'] !== null
+                || $this->values['max_warning'] !== null
+            ) {
+                if ($this->values['max_value'] === null || $this->values['min_value'] === null) {
+                    $tresholdData = [
+                        ($this->values['min_critical'] ?? 0),
+                        ($this->values['max_critical'] ?? 0),
+                        ($this->values['min_warning'] ?? 0),
+                        ($this->values['max_warning'] ?? 0),
+                    ];
 
-            $tresholdData = [
-                ($this->values['min_critical'] ?? 0),
-                ($this->values['max_critical'] ?? 0),
-                ($this->values['min_warning'] ?? 0),
-                ($this->values['max_warning'] ?? 0),
-            ];
+                    $moduleData = array_map(
+                        function ($module) {
+                            return ($module['data'] ?? 0);
+                        },
+                        $modules
+                    );
+                }
 
-            $max = max(
-                array_merge(
-                    $moduleData,
-                    $tresholdData
-                )
-            );
+                if ($this->values['max_value'] === null) {
+                    $max = max(
+                        array_merge(
+                            $moduleData,
+                            $tresholdData
+                        )
+                    );
+                } else {
+                    $max = $this->values['max_value'];
+                }
 
-            $min = min(
-                array_merge(
-                    $moduleData,
-                    $tresholdData
-                )
-            );
+                // Increases max.
+                if ($this->values['max_critical'] === null && $this->values['max_value'] === null) {
+                    $max_increase = ($max * self::MAX_INCREASE);
+                    $max = ($max + $max_increase);
+                }
 
-            $this->thresholds = $this->calculateThreshold($max, $min);
+                if ($this->values['min_value'] === null) {
+                    $min = min(
+                        array_merge(
+                            $moduleData,
+                            $tresholdData
+                        )
+                    );
+                } else {
+                    $min = $this->values['min_value'];
+                }
 
-            $output .= '<div class="container-grouped-meter" style="color:'.$this->values['fontColor'].'">';
+                $tresholds_array = [
+                    'min_critical' => $this->values['min_critical'],
+                    'max_critical' => $this->values['max_critical'],
+                    'min_warning'  => $this->values['min_warning'],
+                    'max_warning'  => $this->values['max_warning'],
+                ];
+
+                $this->thresholds = $this->calculateThreshold($max, $min, $tresholds_array);
+            }
+
+            $style = 'color:'.$this->values['fontColor'].';';
+            $output .= '<div class="container-grouped-meter" style="'.$style.'">';
             foreach ($modules as $module) {
                 $output .= $this->drawRowModule(
                     $module,
-                    $max
+                    $max,
+                    $min
                 );
             }
 
@@ -658,18 +736,63 @@ class GroupedMeterGraphs extends Widget
     /**
      * Draw info module.
      *
-     * @param array $data Data module.
-     * @param float $max  Value max.
+     * @param array      $data Data module.
+     * @param null|float $max  Value max.
+     * @param null|float $min  Value min.
      *
      * @return string
      */
     private function drawRowModule(
         array $data,
-        float $max
+        ?float $max,
+        ?float $min
     ):string {
         global $config;
 
-        $module_data = $this->getBoxPercentageMaths($max, $data['data']);
+        // Dinamic.
+        if ($max === null && $min === null) {
+            $all_values_module = [
+                ($data['w_min'] ?? 0),
+                ($data['w_max'] ?? 0),
+                ($data['c_min'] ?? 0),
+                ($data['c_max'] ?? 0),
+                ($data['data'] ?? 0),
+            ];
+
+            if ($this->values['max_value'] === null) {
+                $max = max($all_values_module);
+            } else {
+                $max = $this->values['max_value'];
+            }
+
+            // Increases max.
+            if (empty($data['c_max']) === true
+                && $this->values['max_value'] === null
+            ) {
+                $max_increase = ($max * self::MAX_INCREASE);
+                $max = ($max + $max_increase);
+            }
+
+            $min = 0;
+            if ($this->values['min_value'] !== null) {
+                $min = $this->values['min_value'];
+            }
+
+            $thresholds_array = [
+                'min_critical' => (empty($data['c_min']) === true) ? null : $data['c_min'],
+                'max_critical' => (empty($data['c_max']) === true) ? null : $data['c_max'],
+                'min_warning'  => (empty($data['w_min']) === true) ? null : $data['w_min'],
+                'max_warning'  => (empty($data['w_max']) === true) ? null : $data['w_max'],
+            ];
+
+            $this->thresholds = $this->calculateThreshold(
+                $max,
+                $min,
+                $thresholds_array
+            );
+        }
+
+        $module_data = $this->getBoxPercentageMaths($max, $min, $data['data']);
 
         $output = '';
         $output .= '<div class="container-info-module-meter">';
@@ -765,41 +888,42 @@ class GroupedMeterGraphs extends Widget
     /**
      * Get tresholds.
      *
-     * @param float $max Value max.
-     * @param float $min Value min.
+     * @param float $max              Value max.
+     * @param float $min              Value min.
+     * @param array $thresholds_array Array thresholds.
      *
      * @return array Array threshold.
      */
-    private function calculateThreshold(float $max, float $min)
+    private function calculateThreshold(float $max, float $min, array $thresholds_array)
     {
         $nMax = null;
-        if ($this->values['min_warning'] !== null) {
-            $nMax = $this->getBoxPercentageMaths($max, $this->values['min_warning']);
+        if ($thresholds_array['min_warning'] !== null) {
+            $nMax = $this->getBoxPercentageMaths($max, $min, $thresholds_array['min_warning']);
         }
 
         $wMin = null;
-        if ($this->values['min_warning'] !== null) {
-            $wMin = $this->getBoxPercentageMaths($max, $this->values['min_warning']);
+        if ($thresholds_array['min_warning'] !== null) {
+            $wMin = $this->getBoxPercentageMaths($max, $min, $thresholds_array['min_warning']);
         }
 
         $wMax = null;
-        if ($this->values['max_warning'] !== null) {
-            $wMax = $this->getBoxPercentageMaths($max, $this->values['max_warning']);
+        if ($thresholds_array['max_warning'] !== null) {
+            $wMax = $this->getBoxPercentageMaths($max, $min, $thresholds_array['max_warning']);
         }
 
         $cMin = null;
-        if ($this->values['min_critical'] !== null) {
-            $cMin = $this->getBoxPercentageMaths($max, $this->values['min_critical']);
+        if ($thresholds_array['min_critical'] !== null) {
+            $cMin = $this->getBoxPercentageMaths($max, $min, $thresholds_array['min_critical']);
         }
 
         $cMax = null;
-        if ($this->values['max_critical'] !== null) {
-            $cMax = $this->getBoxPercentageMaths($max, $this->values['max_critical']);
+        if ($thresholds_array['max_critical'] !== null) {
+            $cMax = $this->getBoxPercentageMaths($max, $min, $thresholds_array['max_critical']);
         }
 
         $thresholds = [
             'normal'   => [
-                'min' => $min,
+                'min' => $this->getBoxPercentageMaths($max, $min, $min),
                 'max' => $nMax,
             ],
             'warning'  => [
@@ -820,13 +944,17 @@ class GroupedMeterGraphs extends Widget
      * Get porcentage.
      *
      * @param float $max   Maximum.
+     * @param float $min   Minimum.
      * @param float $value Value.
      *
      * @return float
      */
-    private function getBoxPercentageMaths(float $max, float $value):float
-    {
-        return (($value / $max) * $this->boxNumber);
+    private function getBoxPercentageMaths(
+        float $max,
+        float $min,
+        float $value
+    ):float {
+        return (((($value - $min) / ($max - $min))) * $this->boxNumber);
     }
 
 

From 7eb1aa554935a2603f51aa14d0d4d0e65d131251 Mon Sep 17 00:00:00 2001
From: Calvo <luis.calvo@artica.es>
Date: Thu, 6 Oct 2022 19:58:28 +0200
Subject: [PATCH 33/83] Added id to form on html print form grid

---
 pandora_console/include/class/HTML.class.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/include/class/HTML.class.php b/pandora_console/include/class/HTML.class.php
index 6b4d153a7a..da6e63285a 100644
--- a/pandora_console/include/class/HTML.class.php
+++ b/pandora_console/include/class/HTML.class.php
@@ -933,7 +933,7 @@ class HTML
         $cb_args = $data['cb_args'];
 
         $output_head = '<form class="discovery" onsubmit="'.$form['onsubmit'].'"  enctype="'.$form['enctype'].'" action="'.$form['action'].'" method="'.$form['method'];
-        $output_head .= '" '.$form['extra'].'>';
+        $output_head .= '" id="'.$form['id'].'" '.$form['extra'].'>';
 
         if ($return === false) {
             echo $output_head;

From 83ac81ab2336a7182c1f905e341eeb6b9d5b4ccb Mon Sep 17 00:00:00 2001
From: Daniel Maya <daniel.maya@pandorafms.com>
Date: Fri, 7 Oct 2022 10:56:12 +0200
Subject: [PATCH 34/83] #9506 Fixed meta

---
 pandora_console/godmode/users/user_list.php | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php
index 85a95a8f22..e99a5648b1 100644
--- a/pandora_console/godmode/users/user_list.php
+++ b/pandora_console/godmode/users/user_list.php
@@ -31,8 +31,6 @@ global $config;
 
 check_login();
 
-enterprise_hook('open_meta_frame');
-
 require_once $config['homedir'].'/include/functions_profile.php';
 require_once $config['homedir'].'/include/functions_users.php';
 require_once $config['homedir'].'/include/functions_groups.php';
@@ -134,6 +132,8 @@ if (is_ajax()) {
     }
 }
 
+enterprise_hook('open_meta_frame');
+
 $sortField = get_parameter('sort_field');
 $sort = get_parameter('sort', 'none');
 $tab = get_parameter('tab', 'user');
@@ -924,7 +924,7 @@ enterprise_hook('close_meta_frame');
             var request = $.ajax({
                 url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
                 type: 'GET',
-                dataType: 'JSON',
+                dataType: 'json',
                 data: {
                     page: 'godmode/users/user_list',
                     get_user_profile_group: 1,
@@ -943,6 +943,9 @@ enterprise_hook('close_meta_frame');
                         }
                         count ++;
                     });
+                },
+                error: function (e, textStatus) {
+                    console.error(textStatus);
                 }
             });
             $(`#hidden-show_groups_${id_user}`).val('1');

From 1c157ba2e4349b5448da9ee3f21146f9e151a85f Mon Sep 17 00:00:00 2001
From: Calvo <luis.calvo@artica.es>
Date: Fri, 7 Oct 2022 13:15:44 +0200
Subject: [PATCH 35/83] Fix reset user creation form on error

---
 .../godmode/users/configure_user.php          |  6 ++---
 pandora_console/include/functions_profile.php | 23 ++++++++++++++++---
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php
index d98fc1d944..800f738394 100644
--- a/pandora_console/godmode/users/configure_user.php
+++ b/pandora_console/godmode/users/configure_user.php
@@ -1444,7 +1444,7 @@ html_print_input_hidden('json_profile', '');
 echo '</form>';
 
 
-profile_print_profile_table($id);
+profile_print_profile_table($id, io_safe_output($json_profile));
 
 echo '<br />';
 
@@ -1560,11 +1560,11 @@ $(document).ready (function () {
         switch_ehorus_conf();
     });
     $('#checkbox-ehorus_user_level_enabled').trigger('change');
-
     var img_delete = '<?php echo $delete_image; ?>';
     var id_user = '<?php echo io_safe_output($id); ?>';
     var is_metaconsole = '<?php echo $meta; ?>';
     var user_is_global_admin = '<?php echo users_is_admin($id); ?>';
+    var is_err = '<?php echo $is_err; ?>';
     var data = [];
 
     $('input:image[name="add"]').click(function (e) {
@@ -1588,7 +1588,7 @@ $(document).ready (function () {
             return;
         }
 
-        if (id_user === '') {
+        if (id_user === '' || is_err === 1) {
             let new_json = `{"profile":${profile},"group":${group},"tags":[${tags}],"hierarchy":${hierarchy}}`;
             data.push(new_json);
             json_profile.val('['+data+']');
diff --git a/pandora_console/include/functions_profile.php b/pandora_console/include/functions_profile.php
index a16772c49e..c6a62c4c9d 100644
--- a/pandora_console/include/functions_profile.php
+++ b/pandora_console/include/functions_profile.php
@@ -181,7 +181,7 @@ function profile_delete_profile_and_clean_users($id_profile)
  * @param int User id
  * @param bool Show the tags select or not
  */
-function profile_print_profile_table($id)
+function profile_print_profile_table($id, $json_profile=false)
 {
     global $config;
 
@@ -243,7 +243,19 @@ function profile_print_profile_table($id)
     }
 
     if ($result === false) {
-        $result = [];
+        if ($json_profile !== false && empty($json_profile) !== true) {
+            $profile_decoded = json_decode($json_profile);
+            foreach ($profile_decoded as $profile) {
+                        $result[] = [
+                            'id_grupo'  => $profile->group,
+                            'id_perfil' => $profile->profile,
+                            'tags'      => $profile->tags,
+                            'hierarchy' => $profile->hierarchy,
+                        ];
+            }
+        } else {
+            $result = [];
+        }
     }
 
     foreach ($result as $profile) {
@@ -268,7 +280,12 @@ function profile_print_profile_table($id)
         if (empty($profile['tags'])) {
             $data['tags'] = '';
         } else {
-            $tags_ids = explode(',', $profile['tags']);
+            if (is_array($profile['tags'] === false)) {
+                $tags_ids = explode(',', $profile['tags']);
+            } else {
+                $tags_ids = $profile['tags'];
+            }
+
             $tags = tags_get_tags($tags_ids);
             $data['tags'] = tags_get_tags_formatted($tags);
         }

From a3eaaf1f5e1ffa39609bdece496bbcda554f6b64 Mon Sep 17 00:00:00 2001
From: "alejandro.campos@artica.es" <alejandro.campos@artica.es>
Date: Mon, 10 Oct 2022 09:49:11 +0200
Subject: [PATCH 36/83] workaround to avoid visual issue in PDFs

---
 pandora_console/include/functions_reporting_html.php | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php
index 029b0d70b6..cd764dbf32 100644
--- a/pandora_console/include/functions_reporting_html.php
+++ b/pandora_console/include/functions_reporting_html.php
@@ -1944,7 +1944,16 @@ function reporting_html_inventory($table, $item, $pdf=0)
                                         $table1->head[$k] = $k;
                                         $table1->headstyle[$k] = 'text-align: left';
                                         $table1->cellstyle[$str_key][$k] = 'text-align: left;';
-                                        $table1->data[$str_key][$k] = $v;
+                                        if ($pdf === 0) {
+                                            $table1->data[$str_key][$k] = $v;
+                                        } else {
+                                            // Workaround to prevent table columns from growing indefinitely in PDFs.
+                                            $table1->data[$str_key][$k] = preg_replace(
+                                                '/([^\s]{30})(?=[^\s])/',
+                                                '$1'.'<br>',
+                                                $v
+                                            );
+                                        }
                                     }
                                 }
                             }

From ce823dca38eb265c87ed05105ad7f3f220595427 Mon Sep 17 00:00:00 2001
From: Daniel Barbero <daniel.barbero@artica.es>
Date: Mon, 10 Oct 2022 11:20:03 +0200
Subject: [PATCH 37/83] new widget grouped meter graphs pandora_enterprise#8620

---
 pandora_console/include/functions_agents.php  | 35 +++++++++++++++----
 pandora_console/include/functions_html.php    |  4 ++-
 pandora_console/include/functions_modules.php | 30 +++++++++++++---
 .../include/javascript/pandora_dashboards.js  | 15 ++++++++
 .../Dashboard/Widgets/GroupedMeterGraphs.php  | 35 ++++++++++++++++---
 pandora_console/include/styles/dashboards.css |  1 +
 6 files changed, 104 insertions(+), 16 deletions(-)

diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php
index 178088195c..c0d91e35f1 100644
--- a/pandora_console/include/functions_agents.php
+++ b/pandora_console/include/functions_agents.php
@@ -3487,12 +3487,13 @@ function agents_get_agent_custom_field($agent_id, $custom_field_name)
 /**
  * Unverified documentation.
  *
- * @param integer $id_group      Module group.
- * @param array   $id_agents     Array of agent ids.
- * @param boolean $selection     Show common (false) or all modules (true).
- * @param boolean $return        Return (false) or dump to output (true).
- * @param boolean $index_by_name Use module name as key.
- * @param boolean $pure_return   Return as retrieved from DB.
+ * @param integer $id_group         Module group.
+ * @param array   $id_agents        Array of agent ids.
+ * @param boolean $selection        Show common (false) or all modules (true).
+ * @param boolean $return           Return (false) or dump to output (true).
+ * @param boolean $index_by_name    Use module name as key.
+ * @param boolean $pure_return      Return as retrieved from DB.
+ * @param boolean $notStringModules Not string modules.
  *
  * @return array With modules or null if error.
  */
@@ -3502,7 +3503,8 @@ function select_modules_for_agent_group(
     $selection,
     $return=true,
     $index_by_name=false,
-    $pure_return=false
+    $pure_return=false,
+    $notStringModules=false
 ) {
     global $config;
     $agents = (empty($id_agents)) ? [] : implode(',', $id_agents);
@@ -3510,6 +3512,7 @@ function select_modules_for_agent_group(
     $filter_agent_group = '';
     $filter_group = '';
     $filter_agent = '';
+    $filter_not_string_modules = '';
     $selection_filter = '';
     $sql_conditions_tags = '';
     $sql_tags_inner = '';
@@ -3524,6 +3527,23 @@ function select_modules_for_agent_group(
         $filter_agent = ' AND tagente.id_agente IN ('.$agents.')';
     }
 
+    if ($notStringModules === true) {
+        $filter_not_string_modules = sprintf(
+            ' AND (tagente_modulo.id_tipo_modulo <> %d AND
+                tagente_modulo.id_tipo_modulo <> %d AND
+                tagente_modulo.id_tipo_modulo <> %d AND
+                tagente_modulo.id_tipo_modulo <> %d AND
+                tagente_modulo.id_tipo_modulo <> %d AND
+                tagente_modulo.id_tipo_modulo <> %d)',
+            MODULE_TYPE_GENERIC_DATA_STRING,
+            MODULE_TYPE_REMOTE_TCP_STRING,
+            MODULE_TYPE_REMOTE_SNMP_STRING,
+            MODULE_TYPE_ASYNC_STRING,
+            MODULE_TYPE_WEB_CONTENT_STRING,
+            MODULE_TYPE_REMOTE_CMD_STRING
+        );
+    }
+
     if (!users_can_manage_group_all('AR')) {
         $group_string = implode(',', $groups);
         $filter_agent_group = " AND (
@@ -3567,6 +3587,7 @@ function select_modules_for_agent_group(
 				$filter_agent_group
 				$filter_group
 				$filter_agent
+                $filter_not_string_modules
 				$sql_conditions_tags
 		) x
 		GROUP BY nombre
diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php
index c519645560..e0b35678c0 100644
--- a/pandora_console/include/functions_html.php
+++ b/pandora_console/include/functions_html.php
@@ -5608,7 +5608,9 @@ function html_print_input($data, $wrapper='div', $input_only=false)
                     0,
                     $data['agent_ids'],
                     $data['selectionModules'],
-                    true
+                    true,
+                    false,
+                    (isset($data['notStringModules']) === true && $data['notStringModules'] === true) ? true : false
                 );
             }
 
diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php
index 6c265e8e0f..49521d8b1d 100755
--- a/pandora_console/include/functions_modules.php
+++ b/pandora_console/include/functions_modules.php
@@ -3607,8 +3607,26 @@ function modules_get_agentmodule_mininterval_no_async($id_agent)
 }
 
 
-function get_modules_agents($id_module_group, $id_agents, $selection, $select_mode=true, $useName=false)
-{
+/**
+ * Get modules agents.
+ *
+ * @param integer $id_module_group  ID module group.
+ * @param array   $id_agents        Array agents.
+ * @param boolean $selection        Selection.
+ * @param boolean $select_mode      Mode.
+ * @param boolean $useName          Use name.
+ * @param boolean $notStringModules Not string modules.
+ *
+ * @return array Modules for this agents.
+ */
+function get_modules_agents(
+    $id_module_group,
+    $id_agents,
+    $selection,
+    $select_mode=true,
+    $useName=false,
+    $notStringModules=false
+) {
     if ((bool) is_metaconsole() === true) {
         if ($select_mode === true) {
             $agents = array_reduce(
@@ -3657,7 +3675,8 @@ function get_modules_agents($id_module_group, $id_agents, $selection, $select_mo
                     $selection,
                     false,
                     false,
-                    true
+                    true,
+                    $notStringModules
                 );
 
                 metaconsole_restore_db();
@@ -3744,7 +3763,10 @@ function get_modules_agents($id_module_group, $id_agents, $selection, $select_mo
             $id_module_group,
             $id_agents,
             $selection,
-            false
+            false,
+            false,
+            false,
+            $notStringModules
         );
     }
 
diff --git a/pandora_console/include/javascript/pandora_dashboards.js b/pandora_console/include/javascript/pandora_dashboards.js
index f6e4445744..c08e6bdbf7 100644
--- a/pandora_console/include/javascript/pandora_dashboards.js
+++ b/pandora_console/include/javascript/pandora_dashboards.js
@@ -1536,3 +1536,18 @@ function loadSliceWidget(settings) {
     }
   });
 }
+
+// eslint-disable-next-line no-unused-vars
+function showManualThresholds(element) {
+  $("#min_warning").val(null);
+  $("#max_warning").val(null);
+  $("#min_critical").val(null);
+  $("#max_critical").val(null);
+  if ($(element).is(":checked") === true) {
+    $(".dashboard-input-threshold-warning").removeClass("invisible_important");
+    $(".dashboard-input-threshold-critical").removeClass("invisible_important");
+  } else {
+    $(".dashboard-input-threshold-warning").addClass("invisible_important");
+    $(".dashboard-input-threshold-critical").addClass("invisible_important");
+  }
+}
diff --git a/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php b/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php
index b88414d623..fcca4b5968 100644
--- a/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php
+++ b/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php
@@ -253,6 +253,10 @@ class GroupedMeterGraphs extends Widget
             $values['formatData'] = $decoder['formatData'];
         }
 
+        if (isset($decoder['manualThresholds']) === true) {
+            $values['manualThresholds'] = $decoder['manualThresholds'];
+        }
+
         $values['label'] = 'module';
         if (isset($decoder['label']) === true) {
             $values['label'] = $decoder['label'];
@@ -377,8 +381,25 @@ class GroupedMeterGraphs extends Widget
 
         ];
 
+        // Format Data.
         $inputs['inputs']['row1'][] = [
-            'class'         => 'dashboard-input-threshold',
+            'label'     => __('Manual thresholds'),
+            'arguments' => [
+                'name'     => 'manualThresholds',
+                'id'       => 'manualThresholds',
+                'type'     => 'switch',
+                'value'    => $values['manualThresholds'],
+                'onchange' => 'showManualThresholds(this)',
+            ],
+        ];
+
+        $class_invisible = '';
+        if ((bool) $values['manualThresholds'] !== true) {
+            $class_invisible = 'invisible_important';
+        }
+
+        $inputs['inputs']['row1'][] = [
+            'class'         => 'dashboard-input-threshold dashboard-input-threshold-warning '.$class_invisible,
             'direct'        => 1,
             'block_content' => [
                 [
@@ -407,7 +428,7 @@ class GroupedMeterGraphs extends Widget
         ];
 
         $inputs['inputs']['row1'][] = [
-            'class'         => 'dashboard-input-threshold',
+            'class'         => 'dashboard-input-threshold dashboard-input-threshold-critical '.$class_invisible,
             'direct'        => 1,
             'block_content' => [
                 [
@@ -464,6 +485,7 @@ class GroupedMeterGraphs extends Widget
                 'selectionModulesNameId' => 'selectionGroupedMeterGraphs',
                 'modules_ids'            => $values['moduleGroupedMeterGraphs'],
                 'modules_name'           => 'moduleGroupedMeterGraphs[]',
+                'notStringModules'       => true,
             ],
         ];
 
@@ -522,6 +544,7 @@ class GroupedMeterGraphs extends Widget
         $values['min_value'] = \get_parameter('min_value', null);
         $values['max_value'] = \get_parameter('max_value', null);
 
+        $values['manualThresholds'] = \get_parameter_switch('manualThresholds', 0);
         $values['min_critical'] = \get_parameter('min_critical', null);
         $values['max_critical'] = \get_parameter('max_critical', null);
         $values['min_warning'] = \get_parameter('min_warning', null);
@@ -792,7 +815,7 @@ class GroupedMeterGraphs extends Widget
             );
         }
 
-        $module_data = $this->getBoxPercentageMaths($max, $min, $data['data']);
+        $module_data = $this->getBoxPercentageMaths($max, $min, (float) $data['data']);
 
         $output = '';
         $output .= '<div class="container-info-module-meter">';
@@ -954,6 +977,10 @@ class GroupedMeterGraphs extends Widget
         float $min,
         float $value
     ):float {
+        if ($min === 0.00 && $max === 0.00) {
+            return 0;
+        }
+
         return (((($value - $min) / ($max - $min))) * $this->boxNumber);
     }
 
@@ -1021,7 +1048,7 @@ class GroupedMeterGraphs extends Widget
     {
         $size = [
             'width'  => (is_metaconsole() === true) ? 1000 : 900,
-            'height' => 480,
+            'height' => 550,
         ];
 
         return $size;
diff --git a/pandora_console/include/styles/dashboards.css b/pandora_console/include/styles/dashboards.css
index 1f01152379..64c6fbe4b4 100644
--- a/pandora_console/include/styles/dashboards.css
+++ b/pandora_console/include/styles/dashboards.css
@@ -683,6 +683,7 @@ form.modal-dashboard
   justify-content: center;
   align-items: center;
   width: 98%;
+  margin-top: 10px;
 }
 .container-grouped-meter .container-info-module-meter {
   display: flex;

From d068a9e9cc731af0b12e7d67b1d43291c88e3099 Mon Sep 17 00:00:00 2001
From: Daniel Barbero <daniel.barbero@artica.es>
Date: Mon, 10 Oct 2022 13:18:57 +0200
Subject: [PATCH 38/83] fixed group by extra_id pandora_enterprise#9425

---
 pandora_console/include/functions_events.php | 13 ++++----
 pandora_console/include/functions_ui.php     | 34 ++++++++++++++------
 2 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index 65adff285a..a5d2e48f5f 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -387,8 +387,6 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal
         $filter = ['group_rep' => EVENT_GROUP_REP_ALL];
     }
 
-    hd($filter['group_rep'], true);
-
     switch ($filter['group_rep']) {
         case EVENT_GROUP_REP_ALL:
         case EVENT_GROUP_REP_AGENTS:
@@ -1543,8 +1541,8 @@ function events_get_all(
         }
     }
 
-    if (($filter['group_rep'] === EVENT_GROUP_REP_EVENTS
-        || $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS) && $count === false
+    if (((int) $filter['group_rep'] === EVENT_GROUP_REP_EVENTS
+        || (int) $filter['group_rep'] === EVENT_GROUP_REP_EXTRAIDS) && $count === false
     ) {
         $sql = sprintf(
             'SELECT %s
@@ -1576,7 +1574,9 @@ function events_get_all(
             %s
             %s
             %s JOIN tgrupo tg
-                ON %s',
+                ON %s 
+            %s
+            %s',
             join(',', $fields),
             $group_selects_trans,
             $tevento,
@@ -1605,7 +1605,8 @@ function events_get_all(
             join(' ', $agent_join_filters),
             $tgrupo_join,
             join(' ', $tgrupo_join_filters),
-            join(' ', $sql_filters)
+            join(' ', $sql_filters),
+            $order_by
         );
     } else {
         $sql = sprintf(
diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php
index 632069a397..a55d338407 100755
--- a/pandora_console/include/functions_ui.php
+++ b/pandora_console/include/functions_ui.php
@@ -6510,7 +6510,7 @@ function ui_print_breadcrums($tab_name)
 /**
  * Show last comment
  *
- * @param array $comments array with comments
+ * @param string $comments String with comments.
  *
  * @return string  HTML string with the last comment of the events.
  */
@@ -6534,31 +6534,45 @@ function ui_print_comments($comments)
     foreach ($comments_array as $comm) {
         // Show the comments more recent first.
         if (is_array($comm)) {
-            $last_comment[] = array_reverse($comm);
+            $order_utimestamp = array_reduce(
+                $comm,
+                function ($carry, $item) {
+                    $carry[$item['utimestamp']] = $item;
+                    return $carry;
+                }
+            );
+
+            $key_max_utimestamp = max(array_keys($order_utimestamp));
+
+            $last_comment = $order_utimestamp[$key_max_utimestamp];
         }
     }
 
+    if (empty($last_comment) === true) {
+        return '';
+    }
+
     // Only show the last comment. If commment its too long,the comment will short with ...
     // If $config['prominent_time'] is timestamp the date show Month, day, hour and minutes.
     // Else show comments hours ago
-    if ($last_comment[0][0]['action'] != 'Added comment') {
-        $last_comment[0][0]['comment'] = $last_comment[0][0]['action'];
+    if ($last_comment['action'] != 'Added comment') {
+        $last_comment['comment'] = $last_comment['action'];
     }
 
-    $short_comment = substr($last_comment[0][0]['comment'], 0, 20);
+    $short_comment = substr($last_comment['comment'], 0, 20);
     if ($config['prominent_time'] == 'timestamp') {
-        $comentario = '<i>'.date($config['date_format'], $last_comment[0][0]['utimestamp']).'&nbsp;('.$last_comment[0][0]['id_user'].'):&nbsp;'.$last_comment[0][0]['comment'].'';
+        $comentario = '<i>'.date($config['date_format'], $last_comment['utimestamp']).'&nbsp;('.$last_comment['id_user'].'):&nbsp;'.$last_comment['comment'].'';
 
         if (strlen($comentario) > '200px') {
-            $comentario = '<i>'.date($config['date_format'], $last_comment[0][0]['utimestamp']).'&nbsp;('.$last_comment[0][0]['id_user'].'):&nbsp;'.$short_comment.'...';
+            $comentario = '<i>'.date($config['date_format'], $last_comment['utimestamp']).'&nbsp;('.$last_comment['id_user'].'):&nbsp;'.$short_comment.'...';
         }
     } else {
-        $rest_time = (time() - $last_comment[0][0]['utimestamp']);
+        $rest_time = (time() - $last_comment['utimestamp']);
         $time_last = (($rest_time / 60) / 60);
-        $comentario = '<i>'.number_format($time_last, 0).'&nbsp; Hours &nbsp;('.$last_comment[0][0]['id_user'].'):&nbsp;'.$last_comment[0][0]['comment'].'';
+        $comentario = '<i>'.number_format($time_last, 0).'&nbsp; Hours &nbsp;('.$last_comment['id_user'].'):&nbsp;'.$last_comment['comment'].'';
 
         if (strlen($comentario) > '200px') {
-            $comentario = '<i>'.number_format($time_last, 0).'&nbsp; Hours &nbsp;('.$last_comment[0][0]['id_user'].'):&nbsp;'.$short_comment.'...';
+            $comentario = '<i>'.number_format($time_last, 0).'&nbsp; Hours &nbsp;('.$last_comment['id_user'].'):&nbsp;'.$short_comment.'...';
         }
     }
 

From ab59537d42a2f2e1479fe996cd2c5be38598a157 Mon Sep 17 00:00:00 2001
From: Daniel Barbero <daniel.barbero@artica.es>
Date: Mon, 10 Oct 2022 13:29:40 +0200
Subject: [PATCH 39/83] new widget grouped meter graphs pandora_enterprise#8620

---
 .../images/widgets/GroupedMeterGraphs.png        | Bin 0 -> 5458 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 pandora_console/images/widgets/GroupedMeterGraphs.png

diff --git a/pandora_console/images/widgets/GroupedMeterGraphs.png b/pandora_console/images/widgets/GroupedMeterGraphs.png
new file mode 100644
index 0000000000000000000000000000000000000000..b9e7ece040f6b9ffef97a0169a180490997abf0a
GIT binary patch
literal 5458
zcmV-Y6|L%tP)<h;3K|Lk000e1NJLTq003tI003tQ1^@s7YDR2t00004XF*Lt006O%
z3;baP0000uWmrjOO-%qQ0000800D<-00aO40096102%-Q00002paK8{000010001I
zpaTE|000010001I000007)jkP000!lNkl<ZcmeG_3y@XCm3=?&J%;)4A3g@L1_uLZ
zlq{r30V>%tDsEg!U_>$IXELiOySl6;R%O*>%OtL~?kb`~%vuoeGbY(xlO-lbK!K2w
zF^p9Pl|c$*`OU~M-}mOd`|iEl=e{|YzWw_C-g|du!0D=)?(^wBefsq6fA^D!z%~5x
zt;s|;$7c<aC9-jJRo&tqmQ6xn{g!Qig<&uMu9aVU$BKjz);;<UPk2SR`@w&|7wGD<
zTYg__&;Uf(wR6WJ(==V<z5Lp{7ELvXT7_IomMp<wp5M{YK~{f%eJ&D9UGhkh{OLav
z<igYl3!OckliJfm%OR1&0YPOWL3sYR)8v7c&sga0U#D~Aid<%1&Oy#dTOS%}p|_F~
zmJeBC-Rge8A&JdiZ*MQr`m@PKgs{vbAbU@Kc|7qdMKw_oKalRp%#dYC-}+D)NvG4~
zh1C0eS{8g|Kh|MfA*TRoSEFYe-<oA;*)jo-jk@#J#ebG0$+RQc6dHK0ar?!(p;Q^B
z-hSsTix0Cj2wRaFUfBLw-89R2A`e4lwIX3<-Szq}Yn%7(yo+Z<7%Qt)%Q4c;*InL(
z4CvGRTSbpPt*~=}W*hg08*V_}JioiUo9Mc3SJ*t`@-dRhq!oe1dq&D+G6ep3=Nic{
z3<6R_&NWh3SC@$2!U-esp9CK}FOpvbNI-gi`}Ps3<K}EWH8<F9!hivd?8XduyBdj@
zp4s%fYEy|#714s=FmaaG{xX8(j*S>Jti-Ag*4NGLv;?t2-~-w6{JIx|CgjHV%nRGC
z?*Zv5D+G{Dd)|0x=FFK$5AA2OS?dG*#~=LE5jU?2scO7!^yty#*8hkT@M|uwwEU}Q
zOmO%M$BnmO^yijWSP6q4i^Uv50I<Jwo`U^A`w_(=HMeRG|2;ix!S5t{Nh*~h*tRsM
z`}m|RI8P(wg1!SB`fuGf*@Dsk-%(=;d_aGw&f#}YtFh?lTLAOVRU_nqeiYp5-+yBJ
zAYfH0m-AI8k6U=&w~)*~S3#npgT``4hi*m3B69N?8CFnMVoH7^NJ&^^;DZgI$e=}@
zJ0;h1UC}=>aPxUVdEXH*Y<zNU6Z8+z5WBUld_pWttGIdJBOB%+PLZTuyJdKCYfC~s
zbM#UqmdeNG$QC3@xZ$NYrt7*iT0|4!%$W2cKk`IAPeI7^bmR64StsKSNiI`~RHhr5
zY+O~6x}x;ff9=ZLfD4&je4!w|S#pUhL`%AM^v>I_ZRLp$LB$B*6NU;<f9v885N`=;
zXlxp#Yh4#3vXs7~GVq!_``DU)p;gp(5GKk{d1ciH-@4}q4J-|W<#iKP=JBR?o2@|{
z%Nr)VX!`W&cdYs0bM|)xk@K3M>#x6_w70ht9ME}5;CT>UxNxDv_Aukg6SQE#0<W|^
zX)sEIW(o%V^RNA;%?q=nJVDUe72-5aBQO<_Wtl*jcX@(<0UK28B5=Bek#X9Eur=Py
z(pJ5{q1`JG<l6CJB0>Bh4X;om?2AxHJIOB!qy-tK0<TaI79A$`K+ALtTE0E`1c-L&
zy!*nz4|!DnbTN;kL<pfqe9_^I7-fP@M6(m5i+rIVEILuGvwGbWtwYQtpHH~xS_h-h
zu$o{dgc|Wh2el4ANQ@ZP7Yf3n!^E)Gefw93EfoL3A|Lui7ab-P)`uaTP$RbJIy*bb
z3#NFX!$Y8BK}t<1hh^w;*$Azztu_;kOud$0*m!LC(m4yh$HL$F+lAd$zrpvgEK{-J
zvMJJEzO{I9pWQ)4AuKy)>U*n~)TSY`wjcm#F-dev_<0By<K&o{`n$R-_p@m@1hE7d
zG)kIz35)XzD~j1szv8bya^rCo<Q4(&kO|c=CWaX<d!@(IAk$e{KIJyN=J{FJQz0-}
z!z(*y`mN@%2}T(P)7LLw^gbPI*<T<pFHfPUW=Xu@Qo!uTgX!4{g<a#q1cri-O%LS7
zQpj)lcHN`*{Nlm2YcE>4a^;}pA3EGQbLQwb-?8?p@zqm=%Q83@lYaI;yDDLg-7Tju
zP5SdYZ(n!t;6bu$*Df+|-aN8z-##*X_H5G9(n9L$>KsvFG69b7S;FESiS`3G-E@<&
z<d*xsAff>d_6yW(TEEDR0q}jP-kH$9PM9!(EM2<PnlVkCI@QW>O-&5}n#dKafGGah
zv12`F380IrYkFLiA;hV%#K&~Gej369<-@?Sudk25TnHUhJ$7b?c=SOR;phh$cpt}k
zZ7mAfyE#F|PRlK&X(@?xx60&->fF+1SH>iVI<k52rAkg*H=S}GF?1q=VM=<MZY>>1
zB?+#Wby1}bX~M-fK8xaMQ63kEm{6Nj1ktfFXSYxlw;NB3g@-HqzcY*vFj%5b>mx9%
z&u!)*m5?er9S-V(a|TVZ06wT*utNjN6zf7&ITQv}4jgP%f&&;9#bMhL+@Fr8N%OY$
zJoqR5yR1!Fjl9>}O%UEgtJmAzUF7LWQ>^#^H@BY5gDs-Zzk)2pS2-S@KP9(5j<R`p
zt{NjSX+ZbIGG`_8gE5}SFGwL#LSb?6@kil`s&cp>0IeK2+_8XGj)!6We^n~Ca{;Xu
zINZSq3R{tU{uN{)zKVIZa?p3knO<v`AM?VuT47;KN8}e|AyGm+&RV)jYL1SP=ZOL?
zNFl#gZuik7*>Rwa7^8DrOP%Sny*(&_RSXph3u8QyUy>>ZRgfKwE|}_UwMHeJV!~E2
zo?oO0;%Fb7bw6`}TmgKyL27`gC1Z)lr2GwdKJ{O0{I~17&z$<9qU1VLmM$7Vvh-4i
zK_1;macu0fGGGVC9(4JwFRlOaeUB%5yRK#v7^tu$$=a8{^7W;c&0BQRO{Qb-3z?$a
zY(p8P_VKI-rfXXW5$O9(%aLy|e4K8JWV<TFGZ%YQhfgmI?6z4fN+YmBqR2eXT7XoP
zN+Y8uVhT~yh8&X&EvCr1i6m^Ln{rG`$cCorBrC_2bXM293t3R)Wg}cNg&G=~V#=6I
zWm?zDK?y>YQK?dzDaGi4JjEoE9+OOs?kv*dt}$%{RVta$lCi$gUG?>I-FNUXrvd!X
z%D_tM`d4;Ll(Kp?p+y})MmQE)5~ixO-nIPdQ*@EUISuwnDUdQy>iU?z8lq)#XQF%(
zEh#w`?@`W-I26Qsp32bHZ9F|QI^e53ZiPWxv?KH|NA4t*fJvy#rcJ*q?@?l(74Q!U
zRE4g6aQp4oI=0LpV|mIv{nDE=C0%!pB!`3w&P<q!l3caoD#uQuLz!n@d~=Rz=*}Uq
zGmRkyNwQ+xdCOJ%FjKZN8@6n}f*z^NA7vuv5cTPCF#UTg7dJ!pEM*!RU%yb-lnGw>
zeg3I`uJ7&c8u0H(Rn^{0=X`PF!fU?P;+8)prnlACUGuRu8}(A;lh)%SUViRJZ_?ca
zMRY>dO+YE}TefVu?$Jl@IehnnPc0Lr+n@iBrDtB;evxUI<3vn=d;I%%?EUDYkL>E`
z#uqi7Dnz#aVb3jY7LsJ?wCtq_WN_B3SthKDZP>8EIvxT(!r+VkVC@<Hcv@II8-K-$
z7395rd%odTXrPDhq6h4;z;t=pvSkEr&43T<%FCB8ciro86UgI5dpax+Pxm`-=&KBy
zc-SzX8I13SN4lGz)zTNb(E#tO%<kR0NioL>y@Y$wU^NJ<CGsh1EQMi_@2d>7V1*u8
z6bTH110`Sw4i+}p1r}L}w|T`MlD$1#?gB-^I$z6Rg7a=m6I_pm!&a5m2Ep}c*w?8U
ztrFa2gG&!QJWW;z?z+Jx2sap%c$+Fy6N}rsZg}D!^Wx?QwhStQ385kgqatoFDuQ$o
z3=8sTkua;Am}X#QFhW#*F~=M+Pl2l$Mu@@(Yrqx|yPjQ$oI$q?^zxt#v|z=$z?NZ8
zSb|Wz;e;8$n@(;p-h4tjz)-cI<pRH%+o=xv(PMhx2Udn}&3O2+FO4O*fqUiV6NHB!
zDX%23p$qPY&UW(f$O<x#wpid6963ZDubxD3LstY_j6VMYS2Mmf<6%?;<?%2o0(AH`
zP!Z%uMciP-d-;Kt@k%5t4SM$|+@L4}-$@j1P?U*65lAy|1HiXtJPaQ_>v;H@wv&$I
zTkw&y&JSjJ-NJ#D;ajgTW3#=-lH>xzB<20B7c{&4*vk)gQ-H+>u4a7e6?AL{og#cA
z<+KH39Y6N+gW0%l;lRqcCE$gJUL6LH&?ydti%c2lOJJBXP>MidMWW1LC<4j^ZUFe!
z%WG@~o#LJ&&c1{nYlVd&vwkkHGJI>s!|Yh>bL-wGwc`>5kD)XjPlay1_}0x&5ugXI
zW_)YL!~9qb6~RpSwN`#~OvlR)tc+J8LxolnWuW;T3a%u|L^W^>TR=e?0O-0UzBL0F
zdUt5Kpf7=so^|livo37w#q&d2@Msd7CLfkzD}YC`Fzxt++ZoWigGC0iid9dZ`Uaaf
zHf(Kah~8RanJ)YM!tc^mf5*TIIz><fdia5IRF=8y8~6RzO&;iBRWsN|bK5<;cIh|w
zP5I39ue|=7pZ_<tMv!XhCa+-p$nvTk^u@9@ZV5pCfo4~s^Jaq<H9l{)&QYQB=1>DF
zblw~{L509SFAf5+3Rz0gBU+@gdwP&p@%Xq!!=*Z+CCUixW6tfvb0Vd992~IIMs!q-
zjK@ay(Ibt79&J>WI6c;=36C|J^jM=g*vA@qB?^TbnrPKML`E8FI$@-<36eDu^dx6O
zk(BsgoUDQqQo5;UBwb1qRZhzZH7#cobU%_L>*to{3~AW1vIhZSBl__-HvT1klAIou
zFtjR3mn+Z36JTyS!pSgGF}h=NtgC{I>#VDr9mzPgB*uAi^VTZGEUT7ebCjDxpBB7n
zNS(TrYF&NXlA<sB6l9$BTXv3-l<WnjZaQytep)OLLQhGN(x$E+yKCj5Ga;f`tbvRJ
zBY<@;y*^nn)X8B54D&lnK$o*8?p|@t33_DBF_U+4<seVvz|0^Sk6lb(1Q?Xrvna#o
z3yvO>%8txv2So?zQAeS1;3<-9%Ba=#tdNe8hyCJ9Kv7gvEt6Z|@h(0!N8vX%HY#T_
z6KCm?_bViPBExX;C7_r}W=#Cle)`6ay_9PkXVa#4>0O%B1>XUH<M;oy<*B<n+uLrY
z=labVGiH!UlO~m9!M=FaqfO!D$&<!`0|#I&UK%xa!plon-m}i_r6j+cROsXAouSLE
zJ42Rn{+0GE<waa_`sovE*JM&X%U^x<RRta-`ZT*khYpb&Z@f{DmsPy--FtuZcp+uc
zOD}c(6TQ?WKWv(Em81rKP>&a8-MZ;IQwJATz%cOM?&i&#$!o8@X0g)870ISeo5;3p
z+bsClv14T8#*NmqS$taO0}N#VWzkE^1j?omoxmPo7j^Qlc23k~?op!<DZ+KA`Sa(?
z_&^QpQeAS%C8VmV$}$ur1u(r1V!^b@v*7CLYMUNH+&RMvWzzIcb3xq%*aPgMnyJhf
zB9*RdfVY|Hv(|PYf-!1qYi$@VQ$T-&4z8%cZXJ771#!s3`bZ1P&&EBM!eAGb{(47(
z(1}c;E|X5p+P{B4x%Xb{hmHzO=DdpsWddbWsA6Cjwb&Klc%p1Sy|uOoMk}8N2hBE|
zkig@E@YRbP&=Vud9WUvM_}p+{m*JVeTj_9kFajC`i~~lB+6@~gKnb%(f%8QJ<svZ-
zKK02ffrqK^=}(@HM@8`|P@az0di?14G$<b*ul)q2gCVRx+H&di{7ZAcVen~DK7G;Q
zEuJR~9EowlWMC-rLX(Ak3mC_(Ux_;J!^UAs82c5CE*XPS2BKeK#ODQvjniKwU<^E~
zs`XzI%qy({MwD*$$z&W~zhqFP^}yLjWbgr2md@hvK~|Q|;@B|qusC>@ns+RY4TDkO
zs46^F4aZgi=3m={v{)P)MmZuJ(hBt>`EuaBZ!ZV$e|tH258TW7(c!&tF9&om0t|_9
z&cgEhy&vvJXVWSs9EoxKMr(d_{FO&uF}$YeM~7dB6gjxd4E@M&$K+n==6Ud1quZ}Y
z2Bq`q779mVoI*1bbv$Uk;7d7I+^}(mu%)~k{~?_5Lb7%)eKnw8B*yU@t@+X67aMrD
z=h#`CAAPUj2SNTwf5ibE{GtQzN=fI_E)<TWS@RpM`O)vEKc(U2+~_!oyg%7$^(}6b
z$Tjq*HoRQ1bg#6-&>}I8-)Jm~wKW(Tzx{u`mQgN)No4=~3~XWG+LzzjSg~|gW-;MN
zj8ja8!o~%o;Gcc1c8JXI!|KBGpR>k+CJT)M{$MRm@&#H-_?$Bi7y(9IXc)JCrIdv<
zSZNK)XpLP*L&aGfyH195z`>>$EKYvXle>e?8ixIK8qqozi(|uf`pnK|v2;wcSU-|4
z$8R(ic5My56!!0fR&TZa*1n>qd*?1VH4@|ajn@3=Zfj@w?8MwDx!-c))x>8giXCkg
z8=uctp>QP4TA`U4j^``^`u>O#{V@`!Ojigx`+<B0#5E&BfB<%(Z^vk7*F^?7Qv>}*
z%OI=kDIV-1OJ(uUcNINTr9{8AGZFm+eZ>g3iFY39$rJI`;j=h)WQL3^uGrC5vGFla
z#rR+s^~6^fotnIP+vGwIvnLXX*6yw(Y(3ih(0-#epu;d2Mqqd*jGaWT`t?yyy;@Ft
zf9z3@#{ANU%u{`IC>u{jT!@NcnqU|CVM#K&%<P9Qe7@+VU;q0jWLatJ=;-j?8}3gD
z`xW>~;17($8pc=PIlw?Govx~}HYl4yvJ3VAyOiu^+e<%t>~D@8IrxCA$m)nhLWSD|
zcoP6K2w%$iIJ1Y!)&G~Je)fWCwLf0*o%?@-dWZ4zZnk0MQr!t{|KwES(1CX+_I7p*
z`CrmP-HY+dM~zO_%((p2*zps++glGIo_9joc*D1;+0uwM9QZahpN-*n2>22y9bE7`
z1bh}~J39P=2VW=!!X<mb!%hD1+c$0{laG)5?VEg&PK@<xRGhvVr47FtHR!KKIZY#m
z;JvjT`rev0{N9?lfC6Ccc}@V{lCtEzRH)FG3bVs66|#l=|3lDL+<OA(-T(jq07*qo
IM6N<$f}x9gfdBvi

literal 0
HcmV?d00001


From 40c9ed762c550ba7383a5cb29ea6bb29b0632aae Mon Sep 17 00:00:00 2001
From: "edu.corral" <eduardo.corral@artica.es>
Date: Mon, 10 Oct 2022 16:16:00 +0200
Subject: [PATCH 40/83] ent 9117 mouseover service tree

---
 .../include/javascript/tree/TreeController.js          | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js
index 073a862c4c..f3dc4ad16a 100644
--- a/pandora_console/include/javascript/tree/TreeController.js
+++ b/pandora_console/include/javascript/tree/TreeController.js
@@ -858,11 +858,12 @@ var TreeController = {
                 $content.append($statusImage);
               }
               var image_tooltip =
-                '<span><img class="invert_filter" src="' +
-                (controller.baseURL.length > 0 ? controller.baseURL : "") +
-                'images/help.png" class="img_help" title="' +
+                '<span><img class="invert_filter forced_title" data-title="' +
                 (element.title ? element.title : element.name) +
-                '" alt="' +
+                '" data-use_title_for_force_title="1" src="' +
+                (controller.baseURL.length > 0 ? controller.baseURL : "") +
+                'images/help.png" class="img_help" ' +
+                ' alt="' +
                 element.name +
                 '"/></span> ';
 
@@ -883,7 +884,6 @@ var TreeController = {
                     window.location.href = element.serviceDetail;
                   })
                   .css("cursor", "pointer");
-
                 $content.append($serviceDetailImage);
                 $content.append(" " + image_tooltip);
 

From a078fb790adbf80c707398f60e597ebf2573a18f Mon Sep 17 00:00:00 2001
From: "edu.corral" <eduardo.corral@artica.es>
Date: Tue, 11 Oct 2022 09:46:53 +0200
Subject: [PATCH 41/83] ent 9117 service tree mouseover

---
 pandora_console/include/class/TreeService.class.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/include/class/TreeService.class.php b/pandora_console/include/class/TreeService.class.php
index 4b3a9061cc..e68158c117 100644
--- a/pandora_console/include/class/TreeService.class.php
+++ b/pandora_console/include/class/TreeService.class.php
@@ -537,7 +537,7 @@ class TreeService extends Tree
                     if (empty($title) === true) {
                         $tmp['title'] = '';
                     } else {
-                        $tmp['title'] = $title.'/';
+                        $tmp['title'] = io_safe_output($title).'/';
                     }
 
                     $tmp['title'] .= $service->name();

From 2262754eafb09ffb30f2b61aadd9f7bb3730dc88 Mon Sep 17 00:00:00 2001
From: "edu.corral" <eduardo.corral@artica.es>
Date: Tue, 11 Oct 2022 11:46:02 +0200
Subject: [PATCH 42/83] ent 9098 insert_gis_data

---
 pandora_server/util/pandora_manage.pl | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index 1539d1f5ee..0778658e2f 100755
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -266,7 +266,7 @@ sub help_screen{
 sub api_call($$$;$$$$) {
 	my ($pa_config, $op, $op2, $id, $id2, $other, $return_type) = @_;
 	my $content = undef;
- 
+
 	eval {
 		# Set the parameters for the POST request.
 		my $params = {};
@@ -294,7 +294,7 @@ sub api_call($$$;$$$$) {
 			$content = $response->decoded_content();
 		}
 	};
-	
+
 	return $content;
 }
 
@@ -8054,7 +8054,7 @@ sub pandora_manage_main ($$$) {
 			cli_get_gis_agent();
 		}
 		elsif ($param eq '--insert_gis_data'){
-			# param_check($ltotal, 4, 0);
+			param_check($ltotal, 4, 0);
 			cli_insert_gis_data();
 		}
 		else {
@@ -8805,4 +8805,4 @@ sub cli_insert_gis_data(){
 	my $result = api_call(\%conf,'set', 'gis_agent_only_position', $agent_id, undef, "$other");
 	print "$result \n\n ";
 
-}
\ No newline at end of file
+}

From 83a669b1bcc481a3558bf8dac2b1f8b3b7ffff03 Mon Sep 17 00:00:00 2001
From: Ramon Novoa <ramon.novoa@pandorafms.com>
Date: Tue, 11 Oct 2022 11:48:02 +0200
Subject: [PATCH 43/83] Update copies of the Tentacle Server. Small fixes.

---
 pandora_agents/pc/tentacle_server     |   23 +-
 pandora_agents/unix/tentacle_server   |   23 +-
 pandora_server/NetBSD/tentacle_server |   23 +-
 pandora_server/bin/tentacle_server    |    8 +-
 pandora_server/util/tentacle_serverd  |    1 -
 tentacle/NetBSD/tentacle_server       | 1869 -------------------------
 tentacle/tentacle_server              |    9 +-
 tentacle/util/tentacle_serverd        |    1 -
 8 files changed, 80 insertions(+), 1877 deletions(-)
 delete mode 100755 tentacle/NetBSD/tentacle_server

diff --git a/pandora_agents/pc/tentacle_server b/pandora_agents/pc/tentacle_server
index d945a134e8..4458237003 100755
--- a/pandora_agents/pc/tentacle_server
+++ b/pandora_agents/pc/tentacle_server
@@ -5,7 +5,7 @@
 # Tentacle have IANA assigned port tpc/41121 as official port.
 ##########################################################################
 # Copyright (c) 2007-2008  Ramon Novoa  <rnovoa@artica.es>
-# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L
+# Copyright (c) 2005-2022 Artica Soluciones Tecnologicas S.L
 #
 # tentacle_server.pl	Tentacle Server. See https://pandorafms.com/docs/ for
 #                       protocol description.
@@ -1740,6 +1740,19 @@ sub callback_stop {
 	Win32::Daemon::StopService();
 }
 
+
+################################################################################
+## SUB check_ssleay_version
+## Print a message if the installed version of Net::SSLeay may leak memory.
+################################################################################
+sub check_ssleay_version {
+	eval {
+		require Net::SSLeay;
+		return unless defined($Net::SSLeay::VERSION) && $Net::SSLeay::VERSION =~ m/^(\d+)\.(\d+)/ && $1 <= 1 && $2 < 88;
+		print_log ("Net::SSLeay version $Net::SSLeay::VERSION detected. Versions prior to 1.88 may leak memory. To upgrade it see: https://metacpan.org/pod/Net::SSLeay");
+	};
+}
+
 ################################################################################
 # Main
 ################################################################################
@@ -1753,12 +1766,20 @@ if ($> == 0 && $^O ne 'MSWin32') {
 # Parse command line options
 parse_options ();
 
+# Try to open the log file.
+if (defined($log_file)) {
+    open(my $fh, ">>", $log_file) || die("Error opening the log file '$log_file': $!.\n");
+    close($fh);
+}
+
 # Check command line arguments
 if ($#ARGV != -1) {
 	print_help ();
 	exit 1;
 }
 
+check_ssleay_version() if $t_ssl == 1;
+
 # Show IPv6 status
 if ($SOCKET_MODULE eq 'IO::Socket::INET') {
 	print_log ("IO::Socket::INET6 is not found. IPv6 is disabled.");
diff --git a/pandora_agents/unix/tentacle_server b/pandora_agents/unix/tentacle_server
index d945a134e8..4458237003 100755
--- a/pandora_agents/unix/tentacle_server
+++ b/pandora_agents/unix/tentacle_server
@@ -5,7 +5,7 @@
 # Tentacle have IANA assigned port tpc/41121 as official port.
 ##########################################################################
 # Copyright (c) 2007-2008  Ramon Novoa  <rnovoa@artica.es>
-# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L
+# Copyright (c) 2005-2022 Artica Soluciones Tecnologicas S.L
 #
 # tentacle_server.pl	Tentacle Server. See https://pandorafms.com/docs/ for
 #                       protocol description.
@@ -1740,6 +1740,19 @@ sub callback_stop {
 	Win32::Daemon::StopService();
 }
 
+
+################################################################################
+## SUB check_ssleay_version
+## Print a message if the installed version of Net::SSLeay may leak memory.
+################################################################################
+sub check_ssleay_version {
+	eval {
+		require Net::SSLeay;
+		return unless defined($Net::SSLeay::VERSION) && $Net::SSLeay::VERSION =~ m/^(\d+)\.(\d+)/ && $1 <= 1 && $2 < 88;
+		print_log ("Net::SSLeay version $Net::SSLeay::VERSION detected. Versions prior to 1.88 may leak memory. To upgrade it see: https://metacpan.org/pod/Net::SSLeay");
+	};
+}
+
 ################################################################################
 # Main
 ################################################################################
@@ -1753,12 +1766,20 @@ if ($> == 0 && $^O ne 'MSWin32') {
 # Parse command line options
 parse_options ();
 
+# Try to open the log file.
+if (defined($log_file)) {
+    open(my $fh, ">>", $log_file) || die("Error opening the log file '$log_file': $!.\n");
+    close($fh);
+}
+
 # Check command line arguments
 if ($#ARGV != -1) {
 	print_help ();
 	exit 1;
 }
 
+check_ssleay_version() if $t_ssl == 1;
+
 # Show IPv6 status
 if ($SOCKET_MODULE eq 'IO::Socket::INET') {
 	print_log ("IO::Socket::INET6 is not found. IPv6 is disabled.");
diff --git a/pandora_server/NetBSD/tentacle_server b/pandora_server/NetBSD/tentacle_server
index d945a134e8..4458237003 100755
--- a/pandora_server/NetBSD/tentacle_server
+++ b/pandora_server/NetBSD/tentacle_server
@@ -5,7 +5,7 @@
 # Tentacle have IANA assigned port tpc/41121 as official port.
 ##########################################################################
 # Copyright (c) 2007-2008  Ramon Novoa  <rnovoa@artica.es>
-# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L
+# Copyright (c) 2005-2022 Artica Soluciones Tecnologicas S.L
 #
 # tentacle_server.pl	Tentacle Server. See https://pandorafms.com/docs/ for
 #                       protocol description.
@@ -1740,6 +1740,19 @@ sub callback_stop {
 	Win32::Daemon::StopService();
 }
 
+
+################################################################################
+## SUB check_ssleay_version
+## Print a message if the installed version of Net::SSLeay may leak memory.
+################################################################################
+sub check_ssleay_version {
+	eval {
+		require Net::SSLeay;
+		return unless defined($Net::SSLeay::VERSION) && $Net::SSLeay::VERSION =~ m/^(\d+)\.(\d+)/ && $1 <= 1 && $2 < 88;
+		print_log ("Net::SSLeay version $Net::SSLeay::VERSION detected. Versions prior to 1.88 may leak memory. To upgrade it see: https://metacpan.org/pod/Net::SSLeay");
+	};
+}
+
 ################################################################################
 # Main
 ################################################################################
@@ -1753,12 +1766,20 @@ if ($> == 0 && $^O ne 'MSWin32') {
 # Parse command line options
 parse_options ();
 
+# Try to open the log file.
+if (defined($log_file)) {
+    open(my $fh, ">>", $log_file) || die("Error opening the log file '$log_file': $!.\n");
+    close($fh);
+}
+
 # Check command line arguments
 if ($#ARGV != -1) {
 	print_help ();
 	exit 1;
 }
 
+check_ssleay_version() if $t_ssl == 1;
+
 # Show IPv6 status
 if ($SOCKET_MODULE eq 'IO::Socket::INET') {
 	print_log ("IO::Socket::INET6 is not found. IPv6 is disabled.");
diff --git a/pandora_server/bin/tentacle_server b/pandora_server/bin/tentacle_server
index feb8ecf9af..4458237003 100755
--- a/pandora_server/bin/tentacle_server
+++ b/pandora_server/bin/tentacle_server
@@ -5,7 +5,7 @@
 # Tentacle have IANA assigned port tpc/41121 as official port.
 ##########################################################################
 # Copyright (c) 2007-2008  Ramon Novoa  <rnovoa@artica.es>
-# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L
+# Copyright (c) 2005-2022 Artica Soluciones Tecnologicas S.L
 #
 # tentacle_server.pl	Tentacle Server. See https://pandorafms.com/docs/ for
 #                       protocol description.
@@ -1766,6 +1766,12 @@ if ($> == 0 && $^O ne 'MSWin32') {
 # Parse command line options
 parse_options ();
 
+# Try to open the log file.
+if (defined($log_file)) {
+    open(my $fh, ">>", $log_file) || die("Error opening the log file '$log_file': $!.\n");
+    close($fh);
+}
+
 # Check command line arguments
 if ($#ARGV != -1) {
 	print_help ();
diff --git a/pandora_server/util/tentacle_serverd b/pandora_server/util/tentacle_serverd
index 0c0f35ff97..80e8364946 100755
--- a/pandora_server/util/tentacle_serverd
+++ b/pandora_server/util/tentacle_serverd
@@ -119,7 +119,6 @@ case "$1" in
 			rc_status -v
 		else
 			echo "Tentacle Server could not be started."
-			echo "Verify that Tentacle port is not used."
 			rc_failed 7 # program not running
 		fi
 
diff --git a/tentacle/NetBSD/tentacle_server b/tentacle/NetBSD/tentacle_server
deleted file mode 100755
index d945a134e8..0000000000
--- a/tentacle/NetBSD/tentacle_server
+++ /dev/null
@@ -1,1869 +0,0 @@
-#!/usr/bin/perl
-##########################################################################
-# Tentacle Server
-# See https://pandorafms.com/docs/ for protocol description.
-# Tentacle have IANA assigned port tpc/41121 as official port.
-##########################################################################
-# Copyright (c) 2007-2008  Ramon Novoa  <rnovoa@artica.es>
-# Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L
-#
-# tentacle_server.pl	Tentacle Server. See https://pandorafms.com/docs/ for
-#                       protocol description.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-##########################################################################
-
-package tentacle::server;
-=head1 NAME
-
-tentacle_server - Tentacle Server
-
-=head1 VERSION
-
-Version 0.6.1
-
-=head1 USAGE
-
-tentacle_server B<< -s F<storage_directory> >> [I<options>]
-
-=head1 DESCRIPTION
-
-B<tentacle_server(1)> is a server for B<tentacle>, a B<client/server> file transfer protocol that aims to be:
-
-=over
-
-=item    * Secure by design.
-
-=item    * Easy to use.
-
-=item    * Versatile and cross-platform. 
-
-=back 
-
-Tentacle was created to replace more complex tools like SCP and FTP for simple file transfer/retrieval, and switch from authentication mechanisms like .netrc, interactive logins and SSH keys to X.509 certificates. Simple password authentication over a SSL secured connection is supported too.
-
-The client and server (B<TCP port 41121>) are designed to be run from the command line or called from a shell script, and B<no configuration files are needed>. 
-
-=cut
-
-use strict;
-use warnings;
-use Getopt::Std;
-use IO::Select;
-use IO::Compress::Zip qw(zip $ZipError);
-use IO::Uncompress::Unzip qw(unzip $UnzipError);
-use threads;
-use Thread::Semaphore;
-use POSIX ":sys_wait_h";
-use Time::HiRes qw(usleep);
-use Scalar::Util qw(refaddr);
-use POSIX qw(strftime);
-
-# Constants for Win32 services.
-use constant WIN32_SERVICE_STOPPED => 0x01;
-use constant WIN32_SERVICE_RUNNING => 0x04;
-
-my $t_libwrap_installed = eval { require Authen::Libwrap } ? 1 : 0;
-
-if ($t_libwrap_installed) {
-	Authen::Libwrap->import( qw( hosts_ctl STRING_UNKNOWN ) );
-}
-
-# Log errors, 1 enabled, 0 disabled
-my $t_log = 0;
-
-# Log information, 1 enabled, 0 enabled
-my $t_log_hard = 0;
-
-my $SOCKET_MODULE;
-if ($^O eq 'MSWin32') {
-	# Only support INET on windows
-	require IO::Socket::INET;
-	$SOCKET_MODULE = 'IO::Socket::INET';
-} else {
-	$SOCKET_MODULE =
-		eval { require IO::Socket::INET6 } ? 'IO::Socket::INET6'
-		  : eval { require IO::Socket::INET }  ? 'IO::Socket::INET'
-		  : die $@;
-}
-
-# Service name for Win32.
-my $SERVICE_NAME="Tentacle Server";
-
-# Service parameters.
-my $SERVICE_PARAMS=join(' ', @ARGV);
-
-# Program version
-our $VERSION = '0.6.2';
-
-# IPv4 address to listen on
-my @t_addresses = ('0', '0.0.0.0');
-
-# Block size for socket read/write operations in bytes
-my $t_block_size = 1024;
-
-# Client socket
-my $t_client_socket;
-
-# Run as daemon, 1 true, 0 false
-my $t_daemon = 0;
-
-# Storage directory
-my $t_directory = '';
-
-# Filters
-my @t_filters;
-
-# Enable (1) or disable (0) insecure mode
-my $t_insecure = 0;
-
-# String containing quoted invalid file name characters
-my $t_invalid_chars = '\?\[\]\/\\\=\+\<\>\:\;\'\,\*\~';
-
-# Maximum number of simultaneous connections
-my $t_max_conn = 10;
-
-# Maximum file size allowed by the server in bytes
-my $t_max_size = 2000000;
-
-# File overwrite, 1 enabled, 0 disabled
-my $t_overwrite = 0;
-
-# Port to listen on
-my $t_port = 41121;
-
-# Server password
-my $t_pwd = '';
-
-# Do not output error messages, 1 enabled, 0 disabled
-my $t_quiet = 0;
-
-# Number of retries for socket read/write operations
-my $t_retries = 3;
-
-# Select handler
-my $t_select;
-
-# Semaphore
-my $t_sem :shared;
-
-# Server socket
-my @t_server_sockets;
-
-# Server select handler
-my $t_server_select;
-
-# Use SSL, 1 true, 0 false
-my $t_ssl = 0;
-
-# SSL ca certificate file
-my $t_ssl_ca = '';
-
-# SSL certificate file
-my $t_ssl_cert = '';
-
-# SSL private key file
-my $t_ssl_key = '';
-
-# SSL private key password
-my $t_ssl_pwd = '';
-
-# Timeout for socket read/write operations in seconds
-my $t_timeout = 1;
-
-# Address to proxy client requests to
-my $t_proxy_ip = undef;
-
-# Port to proxy client requests to
-my $t_proxy_port = 41121;
-
-# Proxy socket
-my $t_proxy_socket;
-
-# Proxy selected handler
-my $t_proxy_select;
-
-# Use libwrap, 1 true, 0 false
-my $t_use_libwrap = 0;
-
-# Program name for libwrap
-my $t_program_name = $0;
-$t_program_name =~ s/.*\///g;
-
-# Log file
-my $log_file = undef;
-
-################################################################################
-## SUB print_help
-## Print help screen.
-################################################################################
-sub print_help {
-	$" = ',';
-
-	print ("Usage: $0 -s <storage directory> [options]\n\n");
-	print ("Tentacle server v$VERSION. See https://pandorafms.com/docs/ for protocol description.\n\n");
-	print ("Options:\n");
-	print ("\t-a ip_addresses\tIP addresses to listen on (default @t_addresses).\n");
-	print ("\t               \t(Multiple addresses separated by comma can be defined.)\n");
-	print ("\t-c number\tMaximum number of simultaneous connections (default $t_max_conn).\n");
-	print ("\t-d\t\tRun as daemon.\n");
-	print ("\t-e cert\t\tOpenSSL certificate file. Enables SSL.\n");
-	print ("\t-f ca_cert\tVerify that the peer certificate is signed by a ca.\n");
-	print ("\t-F config_file\tConfiguration file full path.\n");
-	print ("\t-h\t\tShow help.\n");
-	print ("\t-I\t\tEnable insecure operations (file listing and moving).\n");
-	print ("\t-i\t\tFilters.\n");
-	print ("\t-k key\t\tOpenSSL private key file.\n");
-	print ("\t-l log_file\t\tFile to write logs.\n");
-	print ("\t-m size\t\tMaximum file size in bytes (default ${t_max_size}b).\n");
-	print ("\t-o\t\tEnable file overwrite.\n");
-	print ("\t-p port\t\tPort to listen on (default $t_port).\n");
-	print ("\t-q\t\tQuiet. Do now print error messages.\n");
-	print ("\t-r number\tNumber of retries for network opertions (default $t_retries).\n");
-	print ("\t-S (install|uninstall|run) Manage the win32 service.\n");
-	print ("\t-t time\t\tTime-out for network operations in seconds (default ${t_timeout}s).\n");
-	print ("\t-v\t\tBe verbose (display errors).\n");
-	print ("\t-V\t\tBe verbose on hard way (display errors and other info).\n");
-	print ("\t-w\t\tPrompt for OpenSSL private key password.\n");
-	print ("\t-x pwd\t\tServer password.\n");
-	print ("\t-b ip_address\tProxy requests to the given address.\n");
-	print ("\t-g port\t\tProxy requests to the given port.\n");
-	print ("\t-T\t\tEnable tcpwrappers support.\n");
-	print ("\t  \t\t(To use this option, 'Authen::Libwrap' should be installed.)\n\n");
-}
-
-################################################################################
-## SUB daemonize
-## Turn the current process into a daemon.
-################################################################################
-sub daemonize {
-	my $pid;
-
-	require POSIX;
-
-	chdir ('/') || error ("Cannot chdir to /: $!.");
-	umask 0;
-
-	open (STDIN, '/dev/null') || error ("Cannot read /dev/null: $!.");
-
-	# Do not be verbose when running as a daemon
-	open (STDOUT, '>/dev/null') || error ("Cannot write to /dev/null: $!.");
-	open (STDERR, '>/dev/null') || error ("Cannot write to /dev/null: $!.");
-
-	# Fork
-	$pid = fork ();
-	if (! defined ($pid)) {
-		error ("Cannot fork: $!.");
-	}
-
-	# Parent
-	if ($pid != 0) {
-		exit;
-	}
-
-	# Child
-	POSIX::setsid () || error ("Cannot start a new session: $!.");
-}
-
-################################################################################
-## SUB parse_options
-## Parse command line options and initialize global variables.
-################################################################################
-sub parse_options {
-	my %opts;
-	my $CONF = {};
-	my $token_value;
-	my $tmp;
-	my @t_addresses_tmp;
-
-	# Get options
-	if (getopts ('a:b:c:de:f:F:g:hIi:k:l:m:op:qr:s:S:t:TvVwx:', \%opts) == 0 || defined ($opts{'h'})) {
-		print_help ();
-		exit 1;
-	}
-
-	# The Win32 service must be installed/uninstalled without checking other parameters.
-	if (defined ($opts{'S'})) {
-		my $service_action = $opts{'S'};
-		if ($^O ne 'MSWin32') {
-			error ("Windows services are only available on Win32.");
-		} else {
-			eval "use Win32::Daemon";
-			die($@) if ($@);
-
-			if ($service_action eq 'install') {
-				install_service();
-			} elsif ($service_action eq 'uninstall') {
-				uninstall_service();
-			}
-		}
-	}
-
-	# Configuration file
-	if (defined($opts{'F'})) {
-		parse_config_file($opts{'F'}, $CONF);
-	}
-
-	# Address
-	$token_value = get_config_value($opts{'a'}, $CONF->{'addresses'});
-	if (defined ($token_value)) {
-		@t_addresses = ();
-		@t_addresses_tmp = split(/,/, $token_value);
-		
-		foreach my $t_address (@t_addresses_tmp) {
-			$t_address =~ s/^ *(.*?) *$/$1/;
-			if (($t_address ne '0') && 
-				($t_address !~ /^[a-zA-Z\.]+$/ && ($t_address  !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/
-					|| $1 < 0 || $1 > 255 || $2 < 0 || $2 > 255
-					|| $3 < 0 || $3 > 255 || $4 < 0 || $4 > 255)) &&
-				($t_address !~ /^[0-9a-f:]+$/o)) {
-					error ("Address $t_address is not valid.");
-			}
-			push @t_addresses, $t_address;
-		}
-	}
-	
-	# Maximum simultaneous connections
-	$token_value = get_config_value($opts{'c'}, $CONF->{'max_connections'});
-	if (defined ($token_value)) {
-		$t_max_conn = $token_value;
-		if ($t_max_conn !~ /^\d+$/ || $t_max_conn < 1) {
-			error ("Invalid number of maximum simultaneous connections.");
-		}
-	}
-
-	# Run as daemon
-	$token_value = get_config_value($opts{'d'}, $CONF->{'daemon'}, 1);
-	if (defined ($token_value)) {
-		if ($^ eq 'MSWin32') {
-			error ("-d flag not available for this OS.");
-		}
-
-		$t_daemon = 1;
-	}
-
-	# Enable SSL
-	$token_value = get_config_value($opts{'e'}, $CONF->{'ssl_cert'});
-	if (defined ($token_value)) {
-
-		require IO::Socket::SSL;
-
-		$t_ssl_cert = $token_value;
-		if (! -f $t_ssl_cert) {
-			error ("File $t_ssl_cert does not exist.");
-		}
-
-		$t_ssl = 1;
-	}
-
-	# Verify peer certificate
-	$token_value = get_config_value($opts{'f'}, $CONF->{'ssl_ca'});
-	if (defined ($token_value)) {
-		$t_ssl_ca = $token_value;
-		if (! -f $t_ssl_ca) {
-			error ("File $t_ssl_ca does not exist.");
-		}
-	}
-
-	# Insecure mode
-	$token_value = get_config_value($opts{'I'}, $CONF->{'insecure'}, 1);
-	if (defined ($token_value)) {
-		$t_insecure = 1;
-	}
-
-	# Filters (regexp:dir;regexp:dir...)
-	$token_value = get_config_value($opts{'i'}, $CONF->{'filters'});
-	if (defined ($token_value)) {
-		my @filters = split (';', $token_value);
-		foreach my $filter (@filters) {
-			my ($regexp, $dir) = split (':', $filter);
-			next unless defined ($regexp) && defined ($dir);
-
-			# Remove any trailing /
-			my $char = chop ($dir);
-			$dir .= $char if ($char) ne '/';
-
-			push(@t_filters, [$regexp, $dir]);
-		}
-	}
-
-	# SSL private key file
-	$token_value = get_config_value($opts{'k'}, $CONF->{'ssl_key'});
-	if (defined ($token_value)) {
-		$t_ssl_key = $token_value;
-		if (! -f $t_ssl_key) {
-			error ("File $t_ssl_key does not exist.");
-		}
-	}
-
-	# Maximum file size
-	$token_value = get_config_value($opts{'m'}, $CONF->{'max_size'});
-	if (defined ($token_value)) {
-		$t_max_size = $token_value;
-		if ($t_max_size !~ /^\d+$/ || $t_max_size < 1) {
-			error ("Invalid maximum file size.");
-		}
-	}
-
-	# File overwrite
-	$token_value = get_config_value($opts{'o'}, $CONF->{'overwrite'}, 1);
-	if (defined ($token_value)) {
-		$t_overwrite = 1;
-	}
-
-	# Port
-	$token_value = get_config_value($opts{'p'}, $CONF->{'port'});
-	if (defined ($token_value)) {
-		$t_port = $token_value;
-		if ($t_port !~ /^\d+$/ || $t_port < 1 || $t_port > 65535) {
-			error ("Port $t_port is not valid.");
-		}
-	}
-
-	# Quiet mode
-	$token_value = get_config_value($opts{'q'}, $CONF->{'quiet'}, 1);
-	if (defined ($token_value)) {
-		$t_quiet = 1;
-	}
-
-	# Retries
-	$token_value = get_config_value($opts{'r'}, $CONF->{'retries'});
-	if (defined ($token_value)) {
-		$t_retries = $token_value;
-		if ($t_retries !~ /^\d+$/ || $t_retries < 1) {
-			error ("Invalid number of retries for network operations.");
-		}
-	}
-
-	# Storage directory
-	$token_value = get_config_value($opts{'s'}, $CONF->{'directory'});
-	if (defined ($token_value)) {
-
-		$t_directory = $token_value;
-		
-		# Check that directory exists
-		if (! -d $t_directory) {
-			error ("Directory $t_directory does not exist.");
-		}
-
-		# Check directory permissions
-		if (! -w $t_directory) {
-			error ("Cannot write to directory $t_directory.");
-		}
-
-		# Remove the trailing / if present
-		$tmp = chop ($t_directory);
-		if ($tmp ne '/') {
-			$t_directory .= $tmp;
-		}
-	}
-	else {
-		$token_value = get_config_value($opts{'b'}, $CONF->{'proxy_ip'});
-		if (! defined($token_value)) {
-			print_help ();
-			exit 1;
-		}
-	}
-
-	# Timeout
-	$token_value = get_config_value($opts{'t'}, $CONF->{'timeout'});
-	if (defined ($token_value)) {
-		$t_timeout = $token_value;
-		if ($t_timeout !~ /^\d+$/ || $t_timeout < 1) {
-			error ("Invalid timeout for network operations.");
-		}
-	}
-
-	# Read verbose from config file
-	if (defined($CONF->{'verbose'})) {
-		if ($CONF->{'verbose'} eq "1") {
-			$t_log = 1;
-		} elsif ($CONF->{'verbose'} eq "2") {
-			$t_log = 1;
-			$t_log_hard = 1;
-		}
-	}
-	# Be verbose
-	if (defined ($opts{'v'})) {
-		$t_log = 1;
-		$t_log_hard = 0;
-	}
-	# Be verbose hard
-	if (defined ($opts{'V'})) {
-		$t_log = 1;
-		$t_log_hard = 1;
-	}
-
-	# SSL private key password
-	$token_value = get_config_value($opts{'w'}, $CONF->{'ssl_password'}, 1);
-	if (defined ($token_value)) {
-		$t_ssl_pwd = ask_passwd ("Enter private key file password: ", "Enter private key file password again for confirmation: ");
-	}
-
-	# Server password
-	$token_value = get_config_value($opts{'x'}, $CONF->{'password'});
-	if (defined ($token_value)) {
-		$t_pwd = $token_value;
-	}
-	
-	#Proxy IP address
-	$token_value = get_config_value($opts{'b'}, $CONF->{'proxy_ip'});
-	if (defined ($token_value)) {
-		$t_proxy_ip = $token_value;
-		if ($t_proxy_ip !~ /^[a-zA-Z\.]+$/ && ($t_proxy_ip  !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/
-			|| $1 < 0 || $1 > 255 || $2 < 0 || $2 > 255
-			|| $3 < 0 || $3 > 255 || $4 < 0 || $4 > 255) &&
-			$t_proxy_ip !~ /^[0-9a-f:]+$/o) {
-			error ("Proxy address $t_proxy_ip is not valid.");
-		}		
-	}
-	
-	# Proxy Port
-	$token_value = get_config_value($opts{'g'}, $CONF->{'proxy_port'});
-	if (defined ($token_value)) {
-		$t_proxy_port = $token_value;
-		if ($t_proxy_port !~ /^\d+$/ || $t_proxy_port < 1 || $t_proxy_port > 65535) {
-			error ("Proxy port $t_port is not valid.");
-		}
-	}	
-
-	# TCP wrappers support
-	$token_value = get_config_value($opts{'T'}, $CONF->{'use_libwrap'}, 1);
-	if (defined ($token_value)) {
-		if ($t_libwrap_installed) {
-			$t_use_libwrap = 1;
-		} else {
-			error ("Authen::Libwrap is not installed.");
-		}
-	}
-
-	# Win32 service management
-	if (defined ($opts{'S'})) {
-		my $service_action = $opts{'S'};
-		if ($^O ne 'MSWin32') {
-			error ("Windows services are only available on Win32.");
-		} else {
-			eval "use Win32::Daemon";
-			die($@) if ($@);
-
-			if ($service_action eq 'run') {
-				Win32::Daemon::RegisterCallbacks({
-			        start       =>  \&callback_start,
-			        running     =>  \&callback_running,
-			        stop        =>  \&callback_stop,
-				});
-				Win32::Daemon::StartService();
-				exit 0;
-			} else {
-				error("Unknown action: $service_action");
-			}
-		}
-	}
-	
-	# Get the config file
-	$token_value = get_config_value($opts{'l'}, $CONF->{'log_file'});
-	if (defined ($token_value)) {
-		$log_file = $token_value;
-	}
-
-	# No command lines config values
-
-	# Get the block size
-	if (defined ($CONF->{'block_size'})) {
-		if ($t_port !~ /^\d+$/ || $t_port < 1) {
-			error ("Invalid block size: " . $CONF->{'block_size'} . ".");
-		}
-		$t_block_size = $CONF->{'block_size'};
-	}
-
-	# Configuration file invalid chars
-	if (defined ($CONF->{'invalid_chars'})) {
-		$t_invalid_chars = $CONF->{'invalid_chars'};
-	}
-}
-
-################################################################################
-## SUB parse_config_file
-## Get all options from a config file.
-################################################################################
-sub parse_config_file {
-	my ($config_file, $CONF) = @_;
-
-	# File should be writable
-	if (! -r $config_file) {
-		print "Configuration file $config_file is not readable.\n";
-		return;
-	}
-
-	# Open the file
-	my $FH;
-	if (! open ($FH, "< $config_file")) {
-		print "Cannot open configuration file $config_file.\n";
-		return;
-	}
-
-	# Read the file and only get the well formed lines
-	while (<$FH>) {
-		my $buffer_line = $_;
-		if ($buffer_line =~ /^[a-zA-Z]/){ # begins with letters
-			if ($buffer_line =~ m/([\w\-\_\.]+)\s+(.*)/){
-				$CONF->{$1} = $2 unless $2 eq "";
-			}
-		}
-	}
-
- 	close ($FH);
-	return;
-}
-
-################################################################################
-## SUB parse_config_file
-## Search in command line options and config hash from configuration file
-## to get a value (command line is a priority)
-################################################################################
-sub get_config_value {
-	my ($cmd_value, $conf_value, $bool) = @_;
-	$bool = 0 unless defined($bool);
-
-	return $cmd_value if defined($cmd_value);
-	# The boolean type value is 1 or undef (0 should be translated like undefP)
-	if ($bool && defined($conf_value)) {
-		return undef if ($conf_value ne "1");
-	}
-	return $conf_value;
-}
-
-################################################################################
-## SUB start_proxy
-## Open the proxy server socket.
-################################################################################
-sub start_proxy {
-
-	# Connect to server
-	$t_proxy_socket = $SOCKET_MODULE->new (
-	    PeerAddr => $t_proxy_ip,
-		PeerPort => $t_proxy_port,
-	);
-
-	if (! defined ($t_proxy_socket)) {
-		error ("Cannot connect to $t_proxy_ip on port $t_proxy_port: $!.");
-	}
-	
-	# Create proxy selector
-	$t_proxy_select = IO::Select->new ();
-	$t_proxy_select->add ($t_proxy_socket);
-	
-}
-
-################################################################################
-## SUB start_server
-## Open the server socket.
-################################################################################
-sub start_server {
-
-	my $t_server_socket;
-
-	foreach my $t_address (@t_addresses) {
-
-		$t_server_socket = $SOCKET_MODULE->new (
-			Listen    => $t_max_conn,
-			LocalAddr => $t_address,
-			LocalPort => $t_port,
-			Proto     => 'tcp',
-			ReuseAddr     => 1,
-		);
-
-		if (! defined ($t_server_socket)) {
-			print_log ("Cannot open socket for address $t_address on port $t_port: $!.");
-			next;
-		}
-
-		print_log ("Server listening on $t_address port $t_port (press <ctr-c> to stop)");
-	
-		# Say message if tentacle proxy is enable
-		if (defined ($t_proxy_ip)) {
-			print_log ("Proxy Mode enable, data will be sent to $t_proxy_ip port $t_proxy_port");	
-		}
-	
-		push @t_server_sockets, $t_server_socket;
-	}
-
-	if (!@t_server_sockets) {
-		error ("Cannot open socket for all addresses on port $t_port: $!.");
-	}
-	
-	$t_server_select = IO::Select->new();
-	foreach my $t_server_socket (@t_server_sockets){
-		$t_server_select->add($t_server_socket);
- 	}
-}
-
-################################################################################
-## SUB send_data_proxy
-## Send data to proxy socket.
-################################################################################
-sub send_data_proxy {
-	my $data = $_[0];
-	my $block_size;
-	my $retries = 0;
-	my $size;
-	my $total = 0;
-	my $written;
-
-	$size = length ($data);
-
-	while (1) {
-
-		# Try to write data to the socket
-		if ($t_proxy_select->can_write ($t_timeout)) {
-
-			$block_size = ($size - $total) > $t_block_size ? $t_block_size : ($size - $total);
-			$written = syswrite ($t_proxy_socket, $data, $size - $total, $total);
-
-			# Write error
-			if (! defined ($written)) {
-				error ("Connection error from " . $t_proxy_socket->sockhost () . ": $!.");
-			}
-			
-			# EOF
-			if ($written == 0) {
-				error ("Connection from " . $t_proxy_socket->sockhost () . " unexpectedly closed.");
-			}
-	
-			$total += $written;
-
-			# Check if all data was written
-			if ($total == $size) {
-				return;
-			}
-		}
-		# Retry
-		else {
-			$retries++;
-			if ($retries > $t_retries) {
-				error ("Connection from " . $t_proxy_socket->sockhost () . " timed out.");
-			}
-		}
-	}
-}
-
-################################################################################
-## SUB close_proxy
-## Close the proxy socket.
-################################################################################
-sub close_proxy {
-	$t_proxy_socket->shutdown (2);
-	$t_proxy_socket->close ();
-}
-
-################################################################################
-## SUB stop_server
-## Close the server socket.
-################################################################################
-sub stop_server {
-
-	foreach my $t_server_socket (@t_server_sockets) {
-		$t_server_socket->shutdown (2);
-		$t_server_socket->close ();
-	}
-	print_log ("Server going down");
-	
-	exit 0;
-}
-
-################################################################################
-## SUB start_ssl
-## Convert the client socket to an IO::Socket::SSL socket.
-################################################################################
-sub start_ssl {
-	my $err;
-
-	if ($t_ssl_ca eq '') {
-		IO::Socket::SSL->start_SSL (
-			$t_client_socket,
-			SSL_cert_file => $t_ssl_cert,
-			SSL_key_file => $t_ssl_key,
-			SSL_passwd_cb => sub {return $t_ssl_pwd},
-			SSL_server => 1,
-			# Verify peer
-			SSL_verify_mode => 0x01,
-		);
-	}
-	else {
-		IO::Socket::SSL->start_SSL (
-			$t_client_socket,
-			SSL_ca_file => $t_ssl_ca,
-			SSL_cert_file => $t_ssl_cert,
-			SSL_key_file => $t_ssl_key,
-			SSL_passwd_cb => sub {return $t_ssl_pwd},
-			SSL_server => 1,
-			# Fail verification if no peer certificate exists
-			SSL_verify_mode => 0x03,
-		);
-	}
-
-	$err = IO::Socket::SSL::errstr ();
-	if ($err ne '') {
-		error ($err);
-	}
-
-	print_log ("SSL started for " . $t_client_socket->sockhost ());
-}
-
-################################################################################
-## SUB accept_connections
-## Manage incoming connections.
-################################################################################
-sub accept_connections {
-	my $pid;
-	my $t_server_socket;
-
-	# Ignore SIGPIPE
-	$SIG{PIPE} = 'IGNORE';
-
-	# Start server
-	start_server ();
-
-	# Initialize semaphore
-	$t_sem = Thread::Semaphore->new ($t_max_conn);
-
-	while (1) {
-		my @ready = $t_server_select->can_read;
-		foreach $t_server_socket (@ready) {
-
-			# Accept connection
-			$t_client_socket = $t_server_socket->accept ();
-
-			if (! defined ($t_client_socket)) {
-				next if ($! ne ''); # EINTR
-				error ("accept: $!.");
-			}
-
-			print_info ("Client connected from " . $t_client_socket->peerhost ());
-
-			if ($t_use_libwrap && (! hosts_ctl($t_program_name, $t_client_socket))) {
-				print_log ("Connection from " . $t_client_socket->peerhost() . " is closed by tcpwrappers.");
-				$t_client_socket->shutdown (2);
-				$t_client_socket->close();
-			}
-			else {
-
-				# Create a new thread and serve the client
-				$t_sem->down();
-				my $thr = threads->create(\&serve_client);
-				if (! defined ($thr)) {
-					error ("Error creating thread: $!.");
-				}
-				$thr->detach();
-				$t_client_socket->close ();
-			}
-		}
-
-		usleep (1000);
-	}
-}
-
-################################################################################
-## SUB serve_client
-## Serve a connected client.
-################################################################################
-sub serve_client() {
-
-	eval {		
-		# Add client socket to select queue
-		$t_select = IO::Select->new ();
-		$t_select->add ($t_client_socket);
-			
-		# Start SSL
-		if ($t_ssl == 1) {
-			start_ssl ();
-		}
-	
-		# Authenticate client
-		if ($t_pwd ne '') {
-			auth_pwd ();
-		}
-	
-		# Check if proxy mode is enable
-		if (defined ($t_proxy_ip)) {
-			serve_proxy_connection ();	
-		} else {
-			serve_connection ();
-		}
-	};
-
-	$t_client_socket->shutdown (2);
-	$t_client_socket->close ();
-	$t_sem->up();
-}
-
-################################################################################
-## SUB serve_proxy_connection
-## Actuate as a proxy between its client and other tentacle server.
-################################################################################
-sub serve_proxy_connection {
-	
-	# We are a proxy! Start a connection to the Tentacle Server.
-	start_proxy();
-
-	# Forward data between the client and the server.
-	eval {
-		my $select = IO::Select->new ();
-		$select->add($t_proxy_socket);
-		$select->add($t_client_socket);
-		while (my @ready = $select->can_read()) {
-			foreach my $socket (@ready) {
-				if (refaddr($socket) == refaddr($t_client_socket)) {
-					my ($read, $data) = recv_data($t_block_size);
-					return unless defined($data);
-					send_data_proxy($data);
-				}
-				else {
-					my ($read, $data) = recv_data_proxy($t_block_size);
-					return unless defined($data);
-					send_data($data);
-				}
-			}
-		}
-	};
-
-	# Close the connection to the Tentacle Server.
-	close_proxy();
-}
-
-################################################################################
-## SUB serve_connection
-## Read and process commands from the client.
-################################################################################
-sub serve_connection {
-	my $command;
-
-	# Read commands
-	while ($command = recv_command ($t_block_size)) {
-		
-		# Client wants to send a file
-		if ($command =~ /^SEND <(.*)> SIZE (\d+)$/) {
-			print_info ("Request to send file '$1' size ${2}b from " . $t_client_socket->sockhost ());
-			recv_file ($1, $2);
-		}
-		# Client wants to receive a file
-		elsif ($command =~ /^RECV <(.*)>$/) {
-			print_info ("Request to receive file '$1' from " . $t_client_socket->sockhost ());
-			send_file ($1);
-		}
-		elsif ($command =~ /^ZSEND <(.*)> SIZE (\d+)$/) {
-			print_info ("Request to send compressed file '$1' size ${2}b from " . $t_client_socket->sockhost ());
-			zrecv_file ($1, $2);
-		}
-		# Client wants to receive a file
-		elsif ($command =~ /^ZRECV <(.*)>$/) {
-			print_info ("Request to receive compressed file '$1' from " . $t_client_socket->sockhost ());
-			zsend_file ($1);
-		}
-		# Quit
-		elsif ($command =~ /^QUIT$/) {
-			print_info ("Connection closed from " . $t_client_socket->sockhost ());
-			last;
-		}
-		# File listing.
-		elsif ($command =~ /^LS <(.*)>$/) {
-			if ($t_insecure == 0) {
-				print_info ("Insecure mode disabled. Rejected request to list files matched by filter $1 from " . $t_client_socket->sockhost ());
-				last;
-			}
-
-			print_info ("Request to list files matched by filter $1 from " . $t_client_socket->sockhost ());
-			send_file_list ($1);
-		}
-		# Client wants to move a file
-		elsif ($command =~ /^MV <(.*)>$/) {
-			if ($t_insecure == 0) {
-				print_info ("Insecure mode disabled. Rejected request to move file $1 from " . $t_client_socket->sockhost ());
-				last;
-			}
-
-			print_info ("Request to move file '$1' from " . $t_client_socket->sockhost ());
-			move_file ($1);
-		}
-		# Unknown command
-		else {
-			print_log ("Unknown command '$command' from " . $t_client_socket->sockhost ());
-			last;
-		}
-	}
-}
-
-################################################################################
-## SUB auth_pwd
-## Authenticate client with server password.
-################################################################################
-sub auth_pwd {
-	my $client_digest;
-	my $command;
-	my $pwd_digest;
-
-	require Digest::MD5;
-	
-	# Wait for password
-	$command = recv_command ($t_block_size);
-	if ($command !~ /^PASS (.*)$/) {
-		error ("Client " . $t_client_socket->sockhost () . " did not authenticate.");
-	}
-	
-	$client_digest = $1;
-	$pwd_digest = Digest::MD5::md5 ($t_pwd);
-	$pwd_digest = Digest::MD5::md5_hex ($pwd_digest);
-
-	if ($client_digest ne $pwd_digest) {
-		error ("Invalid password from " . $t_client_socket->sockhost () . ".");
-	}
-
-	print_log ("Client " . $t_client_socket->sockhost () . " authenticated");
-	send_data ("PASS OK\n");
-}
-
-################################################################################
-## SUB recv_file
-## Receive a file of size $_[1] and save it in $t_directory as $_[0].
-################################################################################
-sub recv_file {
-	my $base_name = $_[0];
-	my $data = '';
-	my $file;
-	my $size = $_[1];
-
-	# Check file name
-	if ($base_name =~ /[$t_invalid_chars]/) {
-		print_log ("File '$base_name' size ${size}b from " . $t_client_socket->sockhost () . " has an invalid file name");
-		send_data ("SEND ERR (invalid file name)\n");
-		return;
-	}
-
-	# Check file size, empty files are not allowed
-	if ($size < 1 || $size > $t_max_size) {
-		print_log ("File '$base_name' size ${size}b from " . $t_client_socket->sockhost () . " is too big");
-		send_data ("SEND ERR (file is too big)\n");
-		return;
-	}
-	
-	# Apply filters
-	$file = "$t_directory/" . apply_filters ($base_name) . $base_name;
-
-	# Check if file exists
-	if (-f $file && $t_overwrite == 0) {
-		print_log ("File '$base_name' size ${size}b from " . $t_client_socket->sockhost () . " already exists");
-		send_data ("SEND ERR (file already exists)\n");
-		return;
-	}
-
-	send_data ("SEND OK\n");
-
-	# Receive file
-	$data = recv_data_block ($size);
-
-	# Write it to disk
-	open (FILE, "> $file") || error ("Cannot open file '$file' for writing.");
-	binmode (FILE);
-	print (FILE $data);
-	close (FILE);
-
-	send_data ("SEND OK\n");
-	print_info ("Received file '$base_name' size ${size}b from " . $t_client_socket->sockhost ());
-}
-
-################################################################################
-## SUB zrecv_file
-## Receive a compressed file of size $_[1] and save it in $t_directory as $_[0].
-################################################################################
-sub zrecv_file {
-	my $base_name = $_[0];
-	my $data = '';
-	my $file;
-	my $size = $_[1];
-	my $zdata = '';
-
-	# Check file name
-	if ($base_name =~ /[$t_invalid_chars]/) {
-		print_log ("File '$base_name' size ${size}b from " . $t_client_socket->sockhost () . " has an invalid file name");
-		send_data ("ZSEND ERR (invalid file name)\n");
-		return;
-	}
-
-	# Check file size, empty files are not allowed
-	if ($size < 1 || $size > $t_max_size) {
-		print_log ("File '$base_name' size ${size}b from " . $t_client_socket->sockhost () . " is too big");
-		send_data ("ZSEND ERR (file is too big)\n");
-		return;
-	}
-	
-	# Apply filters
-	$file = "$t_directory/" . apply_filters ($base_name) . $base_name;
-
-	# Check if file exists
-	if (-f $file && $t_overwrite == 0) {
-		print_log ("File '$base_name' size ${size}b from " . $t_client_socket->sockhost () . " already exists");
-		send_data ("ZSEND ERR (file already exists)\n");
-		return;
-	}
-
-	send_data ("ZSEND OK\n");
-
-	# Receive file
-	$zdata = recv_data_block ($size);
-	if (!unzip(\$zdata => \$data)) {
-		print_log ("Uncompress error: $UnzipError");
-		send_data ("ZSEND ERR\n");
-		return;
-	}
-
-	# Write it to disk
-	open (FILE, "> $file") || error ("Cannot open file '$file' for writing.");
-	binmode (FILE);
-	print (FILE $data);
-	close (FILE);
-
-	send_data ("ZSEND OK\n");
-	print_info ("Received compressed file '$base_name' size ${size}b from " . $t_client_socket->sockhost ());
-}
-
-################################################################################
-## SUB send_file
-## Send a file to the client
-################################################################################
-sub send_file {
-	my $base_name = $_[0];
-	my $data = '';
-	my $file;
-	my $response;
-	my $size;
-
-	# Check file name
-	if ($base_name =~ /[$t_invalid_chars]/) {
-		print_log ("Requested file '$base_name' from " . $t_client_socket->sockhost () . " has an invalid file name");
-		send_data ("RECV ERR (file has an invalid file name)\n");
-		return;
-	}
-	
-	# Apply filters
-	$file = "$t_directory/" . apply_filters ($base_name) . $base_name;
-
-	# Check if file exists
-	if (! -f $file) {
-		print_log ("Requested file '$file' from " . $t_client_socket->sockhost () . " does not exist");
-		send_data ("RECV ERR (file does not exist)\n");
-		return;
-	}
-
-	$size = -s $file;
-	send_data ("RECV SIZE $size\n");
-	
-	# Wait for client response
-	$response = recv_command ($t_block_size);
-	if ($response ne "RECV OK") {
-		print_log ("Requested file '$file' from " . $t_client_socket->sockhost () . " not sent");
-		return;
-	}
-
-	# Send the file
-	open (FILE, $file) || error ("Cannot open file '$file' for reading.");
-	binmode (FILE);
-	{
-		local $/ = undef;
-		$data = <FILE>;
-	}
-
-	send_data ($data);
-	close (FILE);
-
-	print_log ("Requested file '$file' from " . $t_client_socket->sockhost () . " sent");
-}
-
-################################################################################
-## SUB zsend_file
-## Send a file to the client
-################################################################################
-sub zsend_file {
-	my $base_name = $_[0];
-	my $data = '';
-	my $file;
-	my $response;
-	my $size;
-
-	# Check file name
-	if ($base_name =~ /[$t_invalid_chars]/) {
-		print_log ("Requested compressed file '$base_name' from " . $t_client_socket->sockhost () . " has an invalid file name");
-		send_data ("ZRECV ERR (file has an invalid file name)\n");
-		return;
-	}
-	
-	# Apply filters
-	$file = "$t_directory/" . apply_filters ($base_name) . $base_name;
-
-	# Check if file exists
-	if (! -f $file) {
-		print_log ("Requested compressed '$file' from " . $t_client_socket->sockhost () . " does not exist");
-		send_data ("ZRECV ERR (file does not exist)\n");
-		return;
-	}
-
-	# Read the file and compress its contents
-	if (! zip($file => \$data)) {
-		send_data ("QUIT\n");
-		error ("Compression error: $ZipError");
-		return;
-	}
-
-	$size = length($data);
-	send_data ("ZRECV SIZE $size\n");
-	
-	# Wait for client response
-	$response = recv_command ($t_block_size);
-	if ($response ne "ZRECV OK") {
-		print_log ("Requested compressed '$file' from " . $t_client_socket->sockhost () . " not sent");
-		return;
-	}
-
-	# Send the file
-	send_data ($data);
-
-	print_log ("Requested compressed '$file' from " . $t_client_socket->sockhost () . " sent");
-}
-
-################################################################################
-# Common functions
-################################################################################
-
-################################################################################
-## SUB print_log
-## Print log messages.
-################################################################################
-sub print_log($) {
-
-	my ($msg) = @_;
-	
-	return unless ($t_log == 1);
-	
-	my $fh = *STDOUT;
-	if (defined($log_file)) {
-		open($fh, ">>", $log_file) || die("Starting log failed: $!.\n");
-	}
-
-	print ($fh strftime ("%Y-%m-%d %H:%M:%S", localtime()) . "[log]$msg.\n");
-
-	close ($fh) if (defined($log_file));
-
-}
-
-################################################################################
-## SUB print_log
-## Print log messages.
-################################################################################
-sub print_info($) {
-
-	my ($msg) = @_;
-	
-	return unless ($t_log_hard == 1);
-	
-	my $fh = *STDOUT;
-	if (defined($log_file)) {
-		open($fh, ">>", $log_file) || die("Starting log failed: $!.\n");
-	}
-
-	print ($fh strftime ("%Y-%m-%d %H:%M:%S", localtime()) . "[info]$msg.\n");
-
-	close ($fh) if (defined($log_file));
-
-}
-
-################################################################################
-## SUB error
-## Print an error and exit the program.
-################################################################################
-sub error {
-
-	my ($msg) = @_;
-	
-	return unless ($t_quiet == 0);
-
-	my $fh = *STDERR;
-	if (defined($log_file)) {
-		open($fh, ">>", $log_file) || die("$!\n");
-	}
-
-	print ($fh strftime ("%Y-%m-%d %H:%M:%S", localtime()) . "[err]$msg\n");
-
-	close ($fh) if (defined($log_file));
-
-	die("\n");
-}
-
-################################################################################
-## SUB move_file
-## Send a file to the client and delete it
-################################################################################
-sub move_file {
-	my $base_name = $_[0];
-	my $data = '';
-	my $file;
-	my $response;
-	my $size;
-
-	# Check file name
-	if ($base_name =~ /[$t_invalid_chars]/) {
-		print_log ("Requested file '$base_name' from " . $t_client_socket->sockhost () . " has an invalid file name");
-		send_data ("MV ERR\n");
-		return;
-	}
-	
-	# Apply filters
-	$file = "$t_directory/" . apply_filters ($base_name) . $base_name;
-
-	# Check if file exists
-	if (! -f $file) {
-		print_log ("Requested file '$file' from " . $t_client_socket->sockhost () . " does not exist");
-		send_data ("MV ERR\n");
-		return;
-	}
-
-	$size = -s $file;
-	send_data ("MV SIZE $size\n");
-	
-	# Wait for client response
-	$response = recv_command ($t_block_size);
-	if ($response ne "MV OK") {
-		print_log ("Requested file '$file' from " . $t_client_socket->sockhost () . " not sent");
-		return;
-	}
-
-	# Send the file
-	open (FILE, $file) || error ("Cannot open file '$file' for reading.");
-	binmode (FILE);
-
-	while ($data = <FILE>) {
-		send_data ($data);
-	}
-
-	close (FILE);
-	unlink($file);
-
-	print_log ("Requested file '$file' from " . $t_client_socket->sockhost () . " sent and deleted");
-}
-
-################################################################################
-## SUB send_file_list
-## Send a list of files to the client after applying the given filter.
-################################################################################
-sub send_file_list {
-	my $filter = $_[0];
-	my $data = '';
-	my $dir;
-	my $dh;
-	my $response;
-	my $size;
-
-	# Check file name
-	if ($filter =~ /[$t_invalid_chars]/) {
-		print_log ("Invalid file listing filter '$filter' from " . $t_client_socket->sockhost ());
-		send_data ("LS ERR\n");
-		return;
-	}
-	
-	# Apply filters
-	$dir = "$t_directory/" . apply_filters ($filter);
-
-	# Open the directory.
-	if (! opendir ($dh, $dir)) {
-		print_log ("Error opening directory $dir as requested from " . $t_client_socket->sockhost () . ": $!");
-		send_data ("LS ERR\n");
-		return;
-	}
-
-	# List files.
-	while (my $file = readdir ($dh)) {
-		next if ($file =~ /[$t_invalid_chars]/); # Only list files valid for Tentacle.
-		$data .= "$file\n";
-	}
-	closedir $dh;
-
-	$size = length ($data);
-	send_data ("LS SIZE $size\n");
-	
-	# Wait for client response
-	$response = recv_command ($t_block_size);
-	if ($response ne "LS OK") {
-		print_log ("Requested directory listing from " . $t_client_socket->sockhost () . " not sent");
-		return;
-	}
-
-	send_data ($data);
-
-	print_log ("Requested directory listing from " . $t_client_socket->sockhost () . " sent");
-}
-
-################################################################################
-## SUB recv_data_proxy
-## Recv data from proxy socket.
-################################################################################
-sub recv_data_proxy {
-	my $data;
-	my $read;
-	my $retries = 0;
-	my $size = $_[0];
-
-	while (1) {
-
-		# Try to read data from the socket
-		if ($t_proxy_select->can_read ($t_timeout)) {
-			
-			# Read at most $size bytes
-			$read = sysread ($t_proxy_socket, $data, $size);
-
-			# Read error
-			if (! defined ($read)) {
-				error ("Read error from " . $t_proxy_socket->sockhost () . ": $!.");
-			}
-	
-			# EOF
-			if ($read == 0) {
-				error ("Connection from " . $t_proxy_socket->sockhost () . " unexpectedly closed.");
-			}
-	
-			return ($read, $data);
-		}
-
-		# Retry
-		$retries++;
-
-		# But check for error conditions first
-		if ($retries > $t_retries) {
-			error ("Connection from " . $t_proxy_socket->sockhost () . " timed out.");
-		}
-	}
-}
-################################################################################
-## SUB recv_data
-## Read data from the client socket. Returns the number of bytes read and the
-## string of bytes as a two element array.
-################################################################################
-sub recv_data {
-	my $data;
-	my $read;
-	my $retries = 0;
-	my $size = $_[0];
-
-	while (1) {
-
-		# Try to read data from the socket
-		if ($t_select->can_read ($t_timeout)) {
-			
-			# Read at most $size bytes
-			$read = sysread ($t_client_socket, $data, $size);
-
-			# Read error
-			if (! defined ($read)) {
-				error ("Read error from " . $t_client_socket->sockhost () . ": $!.");
-			}
-	
-			# EOF
-			if ($read == 0) {
-				error ("Connection from " . $t_client_socket->sockhost () . " unexpectedly closed.");
-			}
-	
-			return ($read, $data);
-		}
-
-		# Retry
-		$retries++;
-
-		# But check for error conditions first
-		if ($retries > $t_retries) {
-			error ("Connection from " . $t_client_socket->sockhost () . " timed out.");
-		}
-	}
-}
-
-################################################################################
-## SUB send_data
-## Write data to the client socket.
-################################################################################
-sub send_data {
-	my $data = $_[0];
-	my $block_size;
-	my $retries = 0;
-	my $size;
-	my $total = 0;
-	my $written;
-
-	$size = length ($data);
-
-	while (1) {
-
-		# Try to write data to the socket
-		if ($t_select->can_write ($t_timeout)) {
-
-			$block_size = ($size - $total) > $t_block_size ? $t_block_size : ($size - $total);
-			$written = syswrite ($t_client_socket, $data, $block_size, $total);
-
-			# Write error
-			if (! defined ($written)) {
-				error ("Connection error from " . $t_client_socket->sockhost () . ": $!.");
-			}
-			
-			# EOF
-			if ($written == 0) {
-				error ("Connection from " . $t_client_socket->sockhost () . " unexpectedly closed.");
-			}
-	
-			$total += $written;
-
-			# Check if all data was written
-			if ($total == $size) {
-				return;
-			}
-		}
-		# Retry
-		else {
-			$retries++;
-			if ($retries > $t_retries) {
-				error ("Connection from " . $t_client_socket->sockhost () . " timed out.");
-			}
-		}
-	}
-}
-
-################################################################################
-## SUB recv_command
-## Read a command from the client, ended by a new line character.
-################################################################################
-sub recv_command {
-	my $buffer;
-	my $char;
-	my $command = '';
-	my $read;
-	my $total = 0;
-
-	while (1) {
-		
-		($read, $buffer) = recv_data ($t_block_size);
-		$command .= $buffer;
-		$total += $read;
-
-		# Check if the command is complete
-		$char = chop ($command);
-		if ($char eq "\n") {
-			return $command;
-		}
-	
-		$command .= $char;
-
-		# Avoid overflow
-		if ($total > $t_block_size) {
-			error ("Received too much data from " . $t_client_socket->sockhost () . ".");
-		}
-	}
-}
-
-################################################################################
-## SUB recv_data_block
-## Read $_[0] bytes of data from the client.
-################################################################################
-sub recv_data_block {
-	my $buffer = '';
-	my $data = '';
-	my $read;
-	my $size = $_[0];
-	my $total = 0;
-
-	while (1) {
-
-		($read, $buffer) = recv_data ($size - $total);
-		$data .= $buffer;
-		$total += $read;
-
-		# Check if all data has been read
-		if ($total == $size) {
-			return $data;
-		}
-	}
-}
-
-################################################################################
-## SUB ask_passwd
-## Asks the user for a password.
-################################################################################
-sub ask_passwd {
-	my $msg1 = $_[0];
-	my $msg2 = $_[1];
-	my $pwd1;
-	my $pwd2;
-
-	require Term::ReadKey;
-
-	# Disable keyboard echo
-	Term::ReadKey::ReadMode('noecho');
-	
-	# Promt for password
-	print ($msg1);
-	$pwd1 = Term::ReadKey::ReadLine(0);
-	print ("\n$msg2");
-	$pwd2 = Term::ReadKey::ReadLine(0);
-	print ("\n");
-
-	# Restore original settings
-	Term::ReadKey::ReadMode('restore');
-
-	if ($pwd1 ne $pwd2) {
-		print ("Error: passwords do not match.\n");
-		exit 1;
-	}
-
-	# Remove the trailing new line character
-	chop $pwd1;
-
-	return $pwd1;
-}
-
-################################################################################
-## SUB apply_filters
-## Applies filters to the given file.
-################################################################################
-sub apply_filters ($) {
-	my ($file_name) = @_;
-
-	foreach my $filter (@t_filters) {
-		my ($regexp, $dir) = @{$filter};
-		if ($file_name =~ /$regexp/) {
-			print_log ("File '$file_name' matches filter '$regexp' (changing to directory '$dir')");
-			return $dir . '/';
-		}
-	}
-
-	return '';
-}
-
-################################################################################
-## SUB install_service
-## Install the Windows service.
-################################################################################
-sub install_service() {
-
-	my $service_path = $0;
-	my $service_params = $SERVICE_PARAMS;
-
-	# Change the service parameter from 'install' to 'run'.
-	$service_params =~ s/\-S\s+\S+/\-S run/;
-
-	my %service_hash = (
-		machine =>  '',
-		name	=>  'TENTACLESRV',
-		display =>  $SERVICE_NAME,
-		path	=>  $service_path,
-		user	=>  '',
-		pwd	 =>  '',
-		description => 'Tentacle Server http://sourceforge.net/projects/tentacled/',
-		parameters => $service_params
-	);
-	
-	if (Win32::Daemon::CreateService(\%service_hash)) {
-		print "Successfully added.\n";
-		exit 0;
-	} else {
-		print "Failed to add service: " . Win32::FormatMessage(Win32::Daemon::GetLastError()) . "\n";
-		exit 1;
-	}
-}
-
-################################################################################
-## SUB uninstall_service
-## Install the Windows service.
-################################################################################
-sub uninstall_service() {
-	if (Win32::Daemon::DeleteService('', 'TENTACLESRV')) {
-		print "Successfully deleted.\n";
-		exit 0;
-	} else {
-		print "Failed to delete service: " . Win32::FormatMessage(Win32::Daemon::GetLastError()) . "\n";
-		exit 1;
-	}
-}
-
-################################################################################
-## SUB callback_running
-## Windows service callback function for the running event.
-################################################################################
-sub callback_running {
-
-	if (Win32::Daemon::State() == WIN32_SERVICE_RUNNING) {
-	}
-}
-
-################################################################################
-## SUB callback_start
-## Windows service callback function for the start event.
-################################################################################
-sub callback_start {
-
-	# Accept_connections ();
-	my $thr = threads->create(\&accept_connections);
-	if (!defined($thr)) {
-		Win32::Daemon::State(WIN32_SERVICE_STOPPED);
-		Win32::Daemon::StopService();
-		return;
-	}
-	$thr->detach();
-
-	Win32::Daemon::State(WIN32_SERVICE_RUNNING);
-}
-
-################################################################################
-## SUB callback_stop
-## Windows service callback function for the stop event.
-################################################################################
-sub callback_stop {
-
-	foreach my $t_server_socket (@t_server_sockets) {
-		$t_server_socket->shutdown (2);
-		$t_server_socket->close ();
-	}
-
-	Win32::Daemon::State(WIN32_SERVICE_STOPPED);
-	Win32::Daemon::StopService();
-}
-
-################################################################################
-# Main
-################################################################################
-
-# Never run as root
-if ($> == 0 && $^O ne 'MSWin32') {
-	print ("Error: for safety reasons $0 cannot be run with root privileges.\n");
-	exit 1;
-}
-
-# Parse command line options
-parse_options ();
-
-# Check command line arguments
-if ($#ARGV != -1) {
-	print_help ();
-	exit 1;
-}
-
-# Show IPv6 status
-if ($SOCKET_MODULE eq 'IO::Socket::INET') {
-	print_log ("IO::Socket::INET6 is not found. IPv6 is disabled.");
-}
-
-# Run as daemon?
-if ($t_daemon == 1 && $^O ne 'MSWin32') {
-	daemonize ();
-}
-
-# Handle ctr-c
-if ($^O eq 'MSWin32') {
-	no warnings;
-	$SIG{INT2} = \&stop_server;
-	use warnings;
-}
-else {
-	$SIG{INT} = \&stop_server;
-}
-
-# Accept connections
-accept_connections();
-
-__END__
-
-=head1 REQUIRED ARGUMENTES
-
-=over 
-
-=item B<< -s F<storage_directory> >>	Root directory to store the files received by the server
-
-=back 
-
-=head1 OPTIONS
-
-=over
-
-=item 	I<-a ip_address>	Address to B<listen> on (default I<0.0.0.0>).
-
-=item	I<-c number>		B<Maximum> number of simultaneous B<connections> (default I<10>).
-
-=item	I<-d>			Run as B<daemon>.
-
-=item	I<-e cert>		B<OpenSSL certificate> file. Enables SSL.
-
-=item	I<-f ca_cert>	Verify that the peer certificate is signed by a B<CA>.
-
-=item	I<-h>			Show B<help>.
-
-=item	I<-i>			B<Filters>.
-
-=item	I<-k key>		B<OpenSSL private key> file.
-
-=item	I<-m size>		B<Maximum file size> in bytes (default I<2000000b>).
-
-=item	I<-o>			Enable file B<overwrite>.
-
-=item	I<-p port>		B<Port to listen> on (default I<41121>).
-
-=item	I<-q>			B<Quiet>. Do now print error messages.
-
-=item	I<-r number>		B<Number of retries> for network opertions (default I<3>).
-
-=item	I<-t time>		B<Time-out> for network operations in B<seconds> (default I<1s>).
-
-=item	I<-v>			Be B<verbose>.
-
-=item	I<-w>			Prompt for B<OpenSSL private key password>.
-
-=item	I<-x> pwd		B<Server password>.
-
-=back
-
-=head1 EXIT STATUS
-
-=over 
-
-=item 0 on Success
-
-=item 1 on Error
-
-=back 
-
-=head1 CONFIGURATION
-
-Tentacle doesn't use any configurationf files, all the configuration is done by the options passed when it's started.
-
-=head1 DEPENDENCIES
-
-L<Getopt::Std>, L<IO::Select>, L<IO::Socket::INET>, L<Thread::Semaphore>, L<POSIX> 
-
-
-=head1 LICENSE
-
-This is released under the GNU Lesser General Public License.
-
-=head1 SEE ALSO
-
-L<Getopt::Std>, L<IO::Select>, L<IO::Socket::INET>, L<Thread::Semaphore>, L<POSIX> 
-
-Protocol description and more info at: L<< https://pandorafms.com/docs/index.php?title=Pandora:Documentation_en:Tentacle >>
-
-=head1 COPYRIGHT
-
-Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L
-
-=cut
- 
diff --git a/tentacle/tentacle_server b/tentacle/tentacle_server
index 8eb5aa3203..4458237003 100755
--- a/tentacle/tentacle_server
+++ b/tentacle/tentacle_server
@@ -5,7 +5,7 @@
 # Tentacle have IANA assigned port tpc/41121 as official port.
 ##########################################################################
 # Copyright (c) 2007-2008  Ramon Novoa  <rnovoa@artica.es>
-# Copyright (c) 2005-2021 Artica Soluciones Tecnologicas S.L
+# Copyright (c) 2005-2022 Artica Soluciones Tecnologicas S.L
 #
 # tentacle_server.pl	Tentacle Server. See https://pandorafms.com/docs/ for
 #                       protocol description.
@@ -230,7 +230,6 @@ sub print_help {
 	print ("\t-p port\t\tPort to listen on (default $t_port).\n");
 	print ("\t-q\t\tQuiet. Do now print error messages.\n");
 	print ("\t-r number\tNumber of retries for network opertions (default $t_retries).\n");
-	print ("\t-s Storage directory\n");
 	print ("\t-S (install|uninstall|run) Manage the win32 service.\n");
 	print ("\t-t time\t\tTime-out for network operations in seconds (default ${t_timeout}s).\n");
 	print ("\t-v\t\tBe verbose (display errors).\n");
@@ -1767,6 +1766,12 @@ if ($> == 0 && $^O ne 'MSWin32') {
 # Parse command line options
 parse_options ();
 
+# Try to open the log file.
+if (defined($log_file)) {
+    open(my $fh, ">>", $log_file) || die("Error opening the log file '$log_file': $!.\n");
+    close($fh);
+}
+
 # Check command line arguments
 if ($#ARGV != -1) {
 	print_help ();
diff --git a/tentacle/util/tentacle_serverd b/tentacle/util/tentacle_serverd
index 0c0f35ff97..80e8364946 100755
--- a/tentacle/util/tentacle_serverd
+++ b/tentacle/util/tentacle_serverd
@@ -119,7 +119,6 @@ case "$1" in
 			rc_status -v
 		else
 			echo "Tentacle Server could not be started."
-			echo "Verify that Tentacle port is not used."
 			rc_failed 7 # program not running
 		fi
 

From 07232d82d18b456cd1bcc51a8266292549344b4f Mon Sep 17 00:00:00 2001
From: "alejandro.campos@artica.es" <alejandro.campos@artica.es>
Date: Tue, 11 Oct 2022 13:26:25 +0200
Subject: [PATCH 44/83] fix several problems in history db settings

---
 pandora_console/include/functions_config.php | 7 ++++---
 pandora_console/include/lib/Core/Config.php  | 2 ++
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php
index 647b719ae3..a4aa1f45de 100644
--- a/pandora_console/include/functions_config.php
+++ b/pandora_console/include/functions_config.php
@@ -1577,9 +1577,10 @@ function config_update_config()
                     }
 
                     $history_db_string_days = get_parameter('history_db_string_days');
-                    if (is_numeric($history_db_string_days) === false
+                    if ((is_numeric($history_db_string_days) === false
                         || $history_db_string_days <= 0
-                        || config_update_value('history_db_string_days', $history_db_string_days) === false
+                        || config_update_value('history_db_string_days', $history_db_string_days) === false)
+                        && get_parameter_switch('history_db_adv', 0) === 1
                     ) {
                         $error_update[] = __('String Days');
                     }
@@ -1843,7 +1844,7 @@ function config_update_config()
         $config['error_config_update_config']['correct'] = false;
         $values = implode('<br> -', $error_update);
         $config['error_config_update_config']['message'] = sprintf(
-            __('Failed updated: the next values cannot update: <br> -%s'),
+            __('Update failed. The next values could not be updated: <br> -%s'),
             $values
         );
 
diff --git a/pandora_console/include/lib/Core/Config.php b/pandora_console/include/lib/Core/Config.php
index dbed566598..00875fd077 100644
--- a/pandora_console/include/lib/Core/Config.php
+++ b/pandora_console/include/lib/Core/Config.php
@@ -90,7 +90,9 @@ final class Config
             }
 
             ob_get_clean();
+        }
 
+        if (empty($settings) === true) {
             if ($config['history_db_connection'] !== false) {
                 $data = \db_get_all_rows_sql(
                     'SELECT * FROM `tconfig`',

From b218cd0d15b739569684cdf48dab00c687f86628 Mon Sep 17 00:00:00 2001
From: "alejandro.campos@artica.es" <alejandro.campos@artica.es>
Date: Tue, 11 Oct 2022 13:32:29 +0200
Subject: [PATCH 45/83] fix several problems in history db settings

---
 pandora_console/include/lib/Core/Config.php | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/pandora_console/include/lib/Core/Config.php b/pandora_console/include/lib/Core/Config.php
index 00875fd077..6c12b85e0c 100644
--- a/pandora_console/include/lib/Core/Config.php
+++ b/pandora_console/include/lib/Core/Config.php
@@ -93,7 +93,9 @@ final class Config
         }
 
         if (empty($settings) === true) {
-            if ($config['history_db_connection'] !== false) {
+            if (isset($config['history_db_connection']) === true
+                && $config['history_db_connection'] !== false
+            ) {
                 $data = \db_get_all_rows_sql(
                     'SELECT * FROM `tconfig`',
                     false,

From ac7f8419a61ee0092fa81033d336dcae84a7bb1a Mon Sep 17 00:00:00 2001
From: "alejandro.campos@artica.es" <alejandro.campos@artica.es>
Date: Tue, 11 Oct 2022 13:39:47 +0200
Subject: [PATCH 46/83] fix several problems in history db settings

---
 pandora_console/include/lib/Core/Config.php | 44 ++++++++++-----------
 1 file changed, 21 insertions(+), 23 deletions(-)

diff --git a/pandora_console/include/lib/Core/Config.php b/pandora_console/include/lib/Core/Config.php
index 6c12b85e0c..43d1ff7cc1 100644
--- a/pandora_console/include/lib/Core/Config.php
+++ b/pandora_console/include/lib/Core/Config.php
@@ -92,31 +92,29 @@ final class Config
             ob_get_clean();
         }
 
-        if (empty($settings) === true) {
-            if (isset($config['history_db_connection']) === true
-                && $config['history_db_connection'] !== false
-            ) {
-                $data = \db_get_all_rows_sql(
-                    'SELECT * FROM `tconfig`',
-                    false,
-                    false,
-                    $config['history_db_connection']
-                );
-            }
-
-            if (is_array($data) !== true) {
-                return [];
-            }
-
-            self::$settings = array_reduce(
-                $data,
-                function ($carry, $item) {
-                    $carry[$item['token']] = $item['value'];
-                    return $carry;
-                },
-                []
+        if (isset($config['history_db_connection']) === true
+            && $config['history_db_connection'] !== false
+        ) {
+            $data = \db_get_all_rows_sql(
+                'SELECT * FROM `tconfig`',
+                false,
+                false,
+                $config['history_db_connection']
             );
         }
+
+        if (is_array($data) !== true) {
+            return [];
+        }
+
+        self::$settings = array_reduce(
+            $data,
+            function ($carry, $item) {
+                $carry[$item['token']] = $item['value'];
+                return $carry;
+            },
+            []
+        );
     }
 
 

From 5e062b2a517f134ecc80517f82d06563a16cefcc Mon Sep 17 00:00:00 2001
From: Daniel Maya <daniel.maya@pandorafms.com>
Date: Tue, 11 Oct 2022 17:22:53 +0200
Subject: [PATCH 47/83] #9591 added dialog

---
 .../include/class/SatelliteAgent.class.php    | 200 ++++++++++++------
 1 file changed, 141 insertions(+), 59 deletions(-)

diff --git a/pandora_console/include/class/SatelliteAgent.class.php b/pandora_console/include/class/SatelliteAgent.class.php
index a6026da751..72c15795a4 100644
--- a/pandora_console/include/class/SatelliteAgent.class.php
+++ b/pandora_console/include/class/SatelliteAgent.class.php
@@ -223,8 +223,9 @@ class SatelliteAgent extends HTML
 
         echo $modal.$msg.$aux;
 
-        echo '<div id="satellite_actions" class="action-buttons" style="width: 100%">';
+        echo '<div style="display: flex;justify-content: space-between;">';
 
+        echo '<div class="flex-content-left">';
         html_print_select(
             [
                 '0' => 'Disable / Enable selected agents',
@@ -248,18 +249,18 @@ class SatelliteAgent extends HTML
         );
         echo '</div>';
 
-        echo '</br></br>';
-
-        // Create button.
-        echo '<div class="w100p flex-content-right">';
+        // Create button add host.
+        echo '<div class="flex-content-right">';
         html_print_submit_button(
             __('Add host'),
             'create',
             false,
             'class="sub next"'
         );
+        echo '</div>';
 
         echo '</div>';
+
         // Load own javascript file.
         echo $this->loadJS();
     }
@@ -1255,6 +1256,8 @@ class SatelliteAgent extends HTML
 
         $(document).ready(function() {
 
+            $('body').append('<div id="dialog"></div>');
+
             $("#submit-create").on('click', function() {
                 show_form();
             });
@@ -1267,61 +1270,140 @@ class SatelliteAgent extends HTML
             $('#submit-submit_satellite_action').click(function() {
                 const checks = $('input[name*=check_]:checked');
                 const action = $('#satellite_action').val();
-                $.each(checks, function(i, val) {
-                    const params = val.value.split(",");
-                    if (action === '0') {
-                        if (params[2] === '0') {
-                            $.ajax({
-                                method: 'post',
-                                async: false,
-                                url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
-                                data: {
-                                    page: 'enterprise/godmode/servers/agents_satellite',
-                                    method: 'disableAgent',
-                                    address: params[0],
-                                    disable: params[3],
-                                    id: params[4],
-                                    name: params[1],
-                                    no_msg: 1,
-                                    server_remote:  <?php echo $this->satellite_server; ?>,
-                                },
-                                datatype: "json",
-                                success: function (data) {
-                                },
-                                error: function(e) {
-                                    console.error(e);
-                                }
-                            });
-                        }
-                    } else {
-                        if (params[3] === '0') {
-                            $.ajax({
-                                method: 'post',
-                                async: false,
-                                url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
-                                data: {
-                                    page: 'enterprise/godmode/servers/agents_satellite',
-                                    method: 'deleteAgent',
-                                    address: params[0],
-                                    name: params[1],
-                                    id: params[4],
-                                    delete: params[2],
-                                    no_msg: 1,
-                                    server_remote:  <?php echo $this->satellite_server; ?>,
-                                },
-                                datatype: "json",
-                                success: function (data) {
-                                },
-                                error: function(e) {
-                                    console.error(e);
-                                }
-                            });
-                        }
-                    }
-                });
+                let agent_delete_error = [];
+                let agent_disable_error = [];
+                $('#aux').empty();
+                $('#aux').text('<?php echo __('Are you sure?'); ?>');
+                $('#aux').dialog({
+                    title: (action === '0') ? '<?php echo __('Disable / Enable Agents'); ?>' : '<?php echo __('Delete / create Agents'); ?>',
+                    buttons: [
+                        {
+                            class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
+                            text: '<?php echo __('Cancel'); ?>',
+                            click: function(e) {
+                                $(this).dialog('close');
+                                cleanupDOM();
 
-                var dt_satellite_agents = $("#satellite_agents").DataTable();
-                dt_satellite_agents.draw();
+                            }
+                        },
+                        {
+                            text: '<?php echo __('Ok'); ?>',
+                            class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
+                            click: function(e) {
+                                $(this).dialog('close');
+                                $.each(checks, function(i, val) {
+                                    const params = val.value.split(",");
+                                    if (action === '0') {
+                                        if (params[2] === '0') {
+                                            $.ajax({
+                                                method: 'post',
+                                                async: false,
+                                                url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
+                                                data: {
+                                                    page: 'enterprise/godmode/servers/agents_satellite',
+                                                    method: 'disableAgent',
+                                                    address: params[0],
+                                                    disable: params[3],
+                                                    id: params[4],
+                                                    name: params[1],
+                                                    no_msg: 1,
+                                                    server_remote:  <?php echo $this->satellite_server; ?>,
+                                                },
+                                                datatype: "json",
+                                                success: function (data) {
+                                                },
+                                                error: function(e) {
+                                                    console.error(e);
+                                                }
+                                            });
+                                        } else {
+                                            agent_disable_error.push(params[0]);
+                                        }
+                                    } else {
+                                        if (params[3] === '0') {
+                                            $.ajax({
+                                                method: 'post',
+                                                async: false,
+                                                url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
+                                                data: {
+                                                    page: 'enterprise/godmode/servers/agents_satellite',
+                                                    method: 'deleteAgent',
+                                                    address: params[0],
+                                                    name: params[1],
+                                                    id: params[4],
+                                                    delete: params[2],
+                                                    no_msg: 1,
+                                                    server_remote:  <?php echo $this->satellite_server; ?>,
+                                                },
+                                                datatype: "json",
+                                                success: function (data) {
+                                                },
+                                                error: function(e) {
+                                                    console.error(e);
+                                                }
+                                            });
+                                        } else {
+                                            agent_delete_error.push(params[0]);
+                                        }
+                                    }
+                                });
+
+                                if (agent_delete_error.length > 0) {
+                                     $("#dialog").dialog({
+                                        resizable: true,
+                                        draggable: true,
+                                        modal: true,
+                                        height: 240,
+                                        width: 600,
+                                        title: '<?php echo __('Warning'); ?>',
+                                        open: function(){
+                                            let text = '<?php echo __('These agents could not be deleted. They must first be enabled'); ?>';
+                                            text += ` (${agent_delete_error.join()})`;
+                                            $('#dialog').html(`<br><table><tr><td><img src="images/icono-warning-triangulo.png" class="float-left mrgn_lft_25px"></td><td><p id="p_configurar_agente" >${text}</p></td></tr></table>`);
+                                        },
+                                        buttons: [
+                                            {
+                                                text: "Ok",
+                                                click: function() {
+                                                    $( this ).dialog( "close" );
+                                                    return false;
+                                                }
+                                            }
+                                        ]
+                                    });
+                                }
+
+                                if (agent_disable_error.length > 0) {
+                                     $("#dialog").dialog({
+                                        resizable: true,
+                                        draggable: true,
+                                        modal: true,
+                                        height: 240,
+                                        width: 600,
+                                        title: '<?php echo __('Warning'); ?>',
+                                        open: function(){
+                                            let text = '<?php echo __('These agents could not be disabled. They must first be created'); ?>';
+                                            text += ` (${agent_disable_error.join()})`;
+                                            $('#dialog').html(`<br><table><tr><td><img src="images/icono-warning-triangulo.png" class="float-left mrgn_lft_25px"></td><td><p id="p_configurar_agente" >${text}</p></td></tr></table>`);
+                                        },
+                                        buttons: [
+                                            {
+                                                text: "Ok",
+                                                click: function() {
+                                                    $( this ).dialog( "close" );
+                                                    return false;
+                                                }
+                                            }
+                                        ]
+                                    });
+                                }
+
+                                var dt_satellite_agents = $("#satellite_agents").DataTable();
+                                dt_satellite_agents.draw();
+                            }
+                        }
+                    ]
+                });
             });
         });
 

From fc37d9919c7dadf34ad4cb2811467d988271b894 Mon Sep 17 00:00:00 2001
From: "jose.gonzalez@pandorafms.com" <jose.gonzalez@pandorafms.com>
Date: Thu, 13 Oct 2022 12:06:04 +0200
Subject: [PATCH 48/83] Fix javascript injection in agent names

---
 pandora_console/godmode/agentes/configurar_agente.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php
index af29579055..f71ead533b 100644
--- a/pandora_console/godmode/agentes/configurar_agente.php
+++ b/pandora_console/godmode/agentes/configurar_agente.php
@@ -181,7 +181,7 @@ $module_macros = [];
 // Create agent.
 if ($create_agent) {
     $mssg_warning = 0;
-    $alias_safe_output = io_safe_output(get_parameter('alias', ''));
+    $alias_safe_output = strip_tags(io_safe_output(get_parameter('alias', '')));
     $alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $alias_safe_output)));
     $alias_as_name = (int) get_parameter_post('alias_as_name', 0);
     $direccion_agente = (string) get_parameter_post('direccion', '');
@@ -935,7 +935,7 @@ if ($update_agent) {
     $mssg_warning = 0;
     $id_agente = (int) get_parameter_post('id_agente');
     $nombre_agente = str_replace('`', '&lsquo;', (string) get_parameter_post('agente', ''));
-    $alias_safe_output = io_safe_output(get_parameter('alias', ''));
+    $alias_safe_output = strip_tags(io_safe_output(get_parameter('alias', '')));
     $alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $alias_safe_output)));
     $alias_as_name = (int) get_parameter_post('alias_as_name', 0);
     $direccion_agente = (string) get_parameter_post('direccion', '');

From f3bc5427baee7575a38a42db35a75e56ee9b8ec0 Mon Sep 17 00:00:00 2001
From: Daniel Maya <daniel.maya@pandorafms.com>
Date: Thu, 13 Oct 2022 13:22:36 +0200
Subject: [PATCH 49/83] #9506 Fixed meta ajax

---
 pandora_console/godmode/users/user_list.php | 74 ++++++++++-----------
 1 file changed, 37 insertions(+), 37 deletions(-)

diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php
index e99a5648b1..a5ec875334 100644
--- a/pandora_console/godmode/users/user_list.php
+++ b/pandora_console/godmode/users/user_list.php
@@ -54,6 +54,43 @@ if (is_ajax()) {
 
     $return_all = false;
 
+    if ($get_user_profile_group === true) {
+        $id_user = get_parameter('id_user');
+
+        $user_is_admin = users_is_admin();
+
+        $user_profiles = [];
+
+        if ($user_is_admin === false) {
+            $group_um = users_get_groups_UM($config['id_user']);
+        }
+
+        // User profiles.
+        if ($user_is_admin || $id_user == $config['id_user'] || isset($group_um[0])) {
+            $user_profiles = db_get_all_rows_field_filter(
+                'tusuario_perfil',
+                'id_usuario',
+                $id_user
+            );
+        } else {
+            $user_profiles_aux = users_get_user_profile($id_user);
+            foreach ($group_um as $key => $value) {
+                if (isset($user_profiles_aux[$key]) === true) {
+                    $user_profiles[$key] = $user_profiles_aux[$key];
+                    unset($user_profiles_aux[$key]);
+                }
+            }
+        }
+
+        foreach ($user_profiles as $key => $value) {
+            $user_profiles[$key]['id_perfil'] = profile_get_name($value['id_perfil']);
+            $user_profiles[$key]['id_grupo'] = groups_get_name($value['id_grupo'], true);
+        }
+
+        echo json_encode($user_profiles);
+        return;
+    }
+
     if ($group_id == -1) {
         $sql = 'SELECT tusuario.id_user FROM tusuario 
                         LEFT OUTER JOIN tusuario_perfil
@@ -93,43 +130,6 @@ if (is_ajax()) {
         echo json_encode($ret_id);
         return;
     }
-
-    if ($get_user_profile_group === true) {
-        $id_user = get_parameter('id_user');
-
-        $user_is_admin = users_is_admin();
-
-        $user_profiles = [];
-
-        if ($user_is_admin === false) {
-            $group_um = users_get_groups_UM($config['id_user']);
-        }
-
-        // User profiles.
-        if ($user_is_admin || $id_user == $config['id_user'] || isset($group_um[0])) {
-            $user_profiles = db_get_all_rows_field_filter(
-                'tusuario_perfil',
-                'id_usuario',
-                $id_user
-            );
-        } else {
-            $user_profiles_aux = users_get_user_profile($id_user);
-            foreach ($group_um as $key => $value) {
-                if (isset($user_profiles_aux[$key]) === true) {
-                    $user_profiles[$key] = $user_profiles_aux[$key];
-                    unset($user_profiles_aux[$key]);
-                }
-            }
-        }
-
-        foreach ($user_profiles as $key => $value) {
-            $user_profiles[$key]['id_perfil'] = profile_get_name($value['id_perfil']);
-            $user_profiles[$key]['id_grupo'] = groups_get_name($value['id_grupo'], true);
-        }
-
-        echo json_encode($user_profiles);
-        return;
-    }
 }
 
 enterprise_hook('open_meta_frame');

From 4dd311063e75e135967992cab78a60149714d57a Mon Sep 17 00:00:00 2001
From: Daniel Barbero <daniel.barbero@artica.es>
Date: Fri, 14 Oct 2022 09:31:45 +0200
Subject: [PATCH 50/83] fixed errors view events sort and save filters
 pandora_enterprise#9425

---
 pandora_console/godmode/events/event_edit_filter.php | 8 ++++++--
 pandora_console/include/functions_events.php         | 8 ++++++++
 pandora_console/operation/events/events.php          | 4 ++++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/pandora_console/godmode/events/event_edit_filter.php b/pandora_console/godmode/events/event_edit_filter.php
index 91045ce0ea..25d9d297c5 100644
--- a/pandora_console/godmode/events/event_edit_filter.php
+++ b/pandora_console/godmode/events/event_edit_filter.php
@@ -438,8 +438,12 @@ $table->data[10][1] = html_print_select(
     true
 );
 
-$repeated_sel[0] = __('All events');
-$repeated_sel[1] = __('Group events');
+$repeated_sel = [
+    EVENT_GROUP_REP_ALL      => __('All events'),
+    EVENT_GROUP_REP_EVENTS   => __('Group events'),
+    EVENT_GROUP_REP_AGENTS   => __('Group agents'),
+    EVENT_GROUP_REP_EXTRAIDS => __('Group extra id'),
+];
 $table->data[11][0] = '<b>'.__('Repeated').'</b>';
 $table->data[11][1] = html_print_select(
     $repeated_sel,
diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index 8935f78995..52d6c49f98 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -5190,6 +5190,14 @@ function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=
             $sort_field_translated = 'id_extra';
         break;
 
+        case 'agent_name':
+            $sort_field_translated = 'ta.nombre';
+        break;
+
+        case 'module_custom_id':
+            $sort_field_translated = 'am.custom_id';
+        break;
+
         default:
             $sort_field_translated = $sort_field;
         break;
diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php
index 281cb6d57b..50d565756d 100644
--- a/pandora_console/operation/events/events.php
+++ b/pandora_console/operation/events/events.php
@@ -356,6 +356,10 @@ if (is_ajax() === true) {
                             $order['field'] = 'agent_name';
                         break;
 
+                        case 'if(te.ack_utimestamp > 0, from_unixtime(te.ack_utimestamp),"") as ack_utimestamp':
+                            $order['field'] = 'ack_utimestamp';
+                        break;
+
                         default:
                             $order['field'] = $field;
                         break;

From a10aa7a258d8f25c2fd7ae489988eccf1d088e69 Mon Sep 17 00:00:00 2001
From: "jose.gonzalez@pandorafms.com" <jose.gonzalez@pandorafms.com>
Date: Fri, 14 Oct 2022 13:29:26 +0200
Subject: [PATCH 51/83] Added control for add the notifications by default to
 users

---
 pandora_console/include/auth/mysql.php | 141 +++++++++++++++++--------
 1 file changed, 99 insertions(+), 42 deletions(-)

diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php
index 67053ab0be..f13dfbf62e 100644
--- a/pandora_console/include/auth/mysql.php
+++ b/pandora_console/include/auth/mysql.php
@@ -1,22 +1,38 @@
 <?php
 
-// Pandora FMS - http://pandorafms.com
-// ==================================================
-// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
-// Please see http://pandorafms.org for full contribution list
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the  GNU Lesser General Public License
-// as published by the Free Software Foundation; version 2
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+/**
+ * MySQL Authentication functions.
+ *
+ * @category   Functions.
+ * @package    Pandora FMS
+ * @subpackage Login.
+ * @version    1.0.0
+ * @license    See below
+ *
+ *    ______                 ___                    _______ _______ ________
+ *   |   __ \.-----.--.--.--|  |.-----.----.-----. |    ___|   |   |     __|
+ *  |    __/|  _  |     |  _  ||  _  |   _|  _  | |    ___|       |__     |
+ * |___|   |___._|__|__|_____||_____|__| |___._| |___|   |__|_|__|_______|
+ *
+ * ============================================================================
+ * Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
+ * Please see http://pandorafms.org for full contribution list
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation for version 2.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * ============================================================================
+ */
 
+// Begin.
 /**
  * @package Include/auth
  */
 
-if (!isset($config)) {
+if (isset($config) === false) {
     die(
         '
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
@@ -63,7 +79,7 @@ $config['user_can_update_password'] = true;
 $config['admin_can_add_user'] = true;
 $config['admin_can_delete_user'] = true;
 $config['admin_can_disable_user'] = false;
-// currently not implemented
+// Currently not implemented.
 $config['admin_can_make_admin'] = true;
 
 
@@ -544,7 +560,7 @@ function get_user_fullname($user)
 /**
  * Gets the users email
  *
- * @param mixed User id.
+ * @param mixed $user User id.
  *
  * @return string The users email address
  */
@@ -557,14 +573,14 @@ function get_user_email($user)
 /**
  * Gets a Users info
  *
- * @param mixed User id
+ * @param mixed $user User id.
  *
  * @return mixed An array of users
  */
 function get_user_info($user)
 {
     static $cache_user_info = [];
-    if (array_key_exists($user, $cache_user_info)) {
+    if (array_key_exists($user, $cache_user_info) === true) {
         return $cache_user_info[$user];
     } else {
         $return = db_get_row('tusuario', 'id_user', get_user_id($user));
@@ -579,24 +595,19 @@ function get_user_info($user)
  * We can't simplify this because some auth schemes (like LDAP) automatically (or it's at least cheaper to) return all the information
  * Functions like get_user_info allow selection of specifics (in functions_db)
  *
- * @param string Field to order by (id_user, fullname or registered)
+ * @param mixed  $order  Field to order by (id_user, fullname or registered).
+ * @param string $filter Filter.
+ * @param string $fields Fields.
  *
  * @return array An array of user information
  */
 function get_users($order='fullname', $filter=false, $fields=false)
 {
-    if (is_array($order)) {
+    if (is_array($order) === true) {
         $filter['order'] = $order['field'].' '.$order['order'];
     } else {
-        switch ($order) {
-            case 'registered':
-            case 'last_connect':
-            case 'fullname':
-            break;
-
-            default:
-                $order = 'fullname';
-            break;
+        if ($order !== 'registered' || $order !== 'last_connect' || $order !== 'fullname') {
+            $order = 'fullname';
         }
 
         $filter['order'] = $order.' ASC';
@@ -618,9 +629,11 @@ function get_users($order='fullname', $filter=false, $fields=false)
 /**
  * Sets the last login for a user
  *
- * @param string User id
+ * @param string $id_user User id.
+ *
+ * @return mixed.
  */
-function process_user_contact($id_user)
+function process_user_contact(string $id_user)
 {
     return db_process_sql_update(
         'tusuario',
@@ -633,6 +646,10 @@ function process_user_contact($id_user)
 /**
  * Create a new user
  *
+ * @param string $id_user   Id User.
+ * @param string $password  Password for this user.
+ * @param array  $user_info Array with information of the user.
+ *
  * @return boolean false
  */
 function create_user($id_user, $password, $user_info)
@@ -643,16 +660,48 @@ function create_user($id_user, $password, $user_info)
     $values['last_connect'] = 0;
     $values['registered'] = get_system_time();
 
-    return (@db_process_sql_insert('tusuario', $values)) !== false;
+    $output = (@db_process_sql_insert('tusuario', $values)) !== false;
+
+    // Add user to notification system.
+    if ($output !== false) {
+        if (isset($values['is_admin']) === true && (bool) $values['is_admin'] === true) {
+            // Administrator user must be activated in all notifications sections.
+            $notificationSources = db_get_all_rows_filter('tnotification_source', [], 'id');
+            foreach ($notificationSources as $notification) {
+                @db_process_sql_insert(
+                    'tnotification_source_user',
+                    [
+                        'id_source' => $notification['id'],
+                        'id_user'   => $id_user,
+                    ]
+                );
+            }
+        } else {
+            // Other users only will be activated in `Message` notifications.
+            $notificationSource = db_get_value('id', 'tnotification_source', 'description', 'Message');
+            @db_process_sql_insert(
+                'tnotification_source_user',
+                [
+                    'id_source' => $notificationSource,
+                    'id_user'   => $id_user,
+                ]
+            );
+        }
+    }
+
+    return $output;
 }
 
 
 /**
  * Save password history
  *
+ * @param string $id_user  Id User.
+ * @param string $password Password of user.
+ *
  * @return boolean false
  */
-function save_pass_history($id_user, $password)
+function save_pass_history(string $id_user, string $password)
 {
     $values['id_user'] = $id_user;
     $values['password'] = md5($password);
@@ -665,9 +714,11 @@ function save_pass_history($id_user, $password)
 /**
  * Deletes the user
  *
- * @param string User id
+ * @param string $id_user User id.
+ *
+ * @return boolean.
  */
-function delete_user($id_user)
+function delete_user(string $id_user)
 {
     $result = db_process_sql_delete(
         'tusuario_perfil',
@@ -685,6 +736,12 @@ function delete_user($id_user)
         return false;
     }
 
+    // Remove from notification list as well.
+    $result = db_process_sql_delete(
+        'tnotification_source_user',
+        ['id_user' => $id_user]
+    );
+
     return true;
 }
 
@@ -693,15 +750,15 @@ function delete_user($id_user)
  * Update the password in MD5 for user pass as id_user with
  * password in plain text.
  *
- * @param string user User ID
- * @param string password Password in plain text.
+ * @param string $user         User ID.
+ * @param string $password_new Password in plain text.
  *
  * @return mixed False in case of error or invalid values passed. Affected rows otherwise
  */
-function update_user_password($user, $password_new)
+function update_user_password(string $user, string $password_new)
 {
     global $config;
-    if (isset($config['auth']) && $config['auth'] == 'pandora') {
+    if (isset($config['auth']) === true && $config['auth'] === 'pandora') {
         $sql = sprintf(
             "UPDATE tusuario SET password = '".md5($password_new)."', last_pass_change = '".date('Y-m-d H:i:s', get_system_time())."' WHERE id_user = '".$user."'"
         );
@@ -714,7 +771,7 @@ function update_user_password($user, $password_new)
         );
         $remote_pass_update = db_process_sql($sql, 'affected_rows', $connection);
 
-        if (!$remote_pass_update) {
+        if ((bool) $remote_pass_update === false) {
             $config['auth_error'] = __('Could not changes password on remote pandora');
             return false;
         }
@@ -735,14 +792,14 @@ function update_user_password($user, $password_new)
  * Update the data of a user that user is choose with
  * id_user.
  *
- * @param string user User ID
- * @param array values Associative array with index as name of field and content.
+ * @param string $id_user User ID.
+ * @param array  $values  Associative array with index as name of field and content.
  *
  * @return mixed False in case of error or invalid values passed. Affected rows otherwise
  */
-function update_user($id_user, $values)
+function update_user(string $id_user, array $values)
 {
-    if (! is_array($values)) {
+    if (is_array($values) === false) {
         return false;
     }
 

From f3bae30f55b98884ff45e8f1655984e16c61612c Mon Sep 17 00:00:00 2001
From: Daniel Maya <daniel.maya@pandorafms.com>
Date: Fri, 14 Oct 2022 13:53:05 +0200
Subject: [PATCH 52/83] #9641 heatmap changes

---
 pandora_console/include/ajax/heatmap.ajax.php |   6 +
 .../include/class/Heatmap.class.php           | 177 ++++++++++++++++--
 2 files changed, 163 insertions(+), 20 deletions(-)

diff --git a/pandora_console/include/ajax/heatmap.ajax.php b/pandora_console/include/ajax/heatmap.ajax.php
index 6d06c0e2ce..c33b0015aa 100644
--- a/pandora_console/include/ajax/heatmap.ajax.php
+++ b/pandora_console/include/ajax/heatmap.ajax.php
@@ -78,6 +78,7 @@ if (is_ajax() === true) {
                         0 => __('Group agents'),
                         1 => __('Group modules by tag'),
                         2 => __('Group modules by module group'),
+                        3 => __('Group modules by agents'),
                     ],
                     'type',
                     $type,
@@ -203,6 +204,10 @@ if (is_ajax() === true) {
                     '5'
                 );
             break;
+
+            case 3:
+                // Empty.
+            break;
         }
 
         echo '</div>';
@@ -212,6 +217,7 @@ if (is_ajax() === true) {
         enterprise_include_once('include/functions_agents.php');
         $id = get_parameter('id', 0);
         switch ($type) {
+            case 3:
             case 2:
                 $data = db_get_row('tagente_modulo', 'id_agente_modulo', $id);
 
diff --git a/pandora_console/include/class/Heatmap.class.php b/pandora_console/include/class/Heatmap.class.php
index 916b4b9873..ece2ced842 100644
--- a/pandora_console/include/class/Heatmap.class.php
+++ b/pandora_console/include/class/Heatmap.class.php
@@ -139,7 +139,7 @@ class Heatmap
         ui_require_css_file('heatmap');
 
         $settings = [
-            'type'     => 'POST',
+            'type'     => 'GET',
             'dataType' => 'html',
             'url'      => ui_get_full_url(
                 'ajax.php',
@@ -169,11 +169,41 @@ class Heatmap
                     setting['data']['height'] = $(`#div_${randomId}`).height() + 10;
                     setting['data']['width'] = $(`#div_${randomId}`).width();
 
+                    var totalModules = 0;
+
                     // Initial charge.
-                    ajaxRequest(
-                        `div_${randomId}`,
-                        setting
-                    );
+                    $.ajax({
+                        type: setting.type,
+                        dataType: setting.dataType,
+                        url: setting.url,
+                        data: setting.data,
+                        success: function(data) {
+                            $(`#div_${randomId}`).append(data);
+                            totalModules = $('rect').length;
+                            let cont = 0;
+                            while (cont < Math.ceil(totalModules / 10)) {
+                                oneSquare(getRandomInteger(1, 10), getRandomInteger(100, 900));
+                                cont ++;
+                            }
+                        }
+                    });
+
+                    function getRandomInteger(min, max) {
+                        return Math.floor(Math.random() * max) + min;
+                    }
+
+                    function oneSquare(solid, time) {
+                        var randomPoint = getRandomInteger(1, totalModules);
+                        let target = $(`#${randomId}_${randomPoint}`);
+                        setTimeout(function() {
+                            let class_name = target.attr('class');
+                            class_name = class_name.split(' ')[0];
+                            const newClassName = class_name.split('_')[0];
+                            target.removeClass(`${class_name} hover`);
+                            target.addClass(`${newClassName}_${solid} hover`);
+                            oneSquare(getRandomInteger(1, 10), getRandomInteger(100, 900));
+                        }, time);
+                    }
 
                     // Refresh.
                     setInterval(
@@ -206,23 +236,29 @@ class Heatmap
                                     // randomly sort.
                                     lista = lista.sort(function() {return Math.random() - 0.5});
 
-                                    const countPerSecond = total / refresh;
+                                    let countPerSecond = total / refresh;
+                                    if (countPerSecond < 1) {
+                                        countPerSecond = 1;
+                                    }
 
                                     let cont = 0;
                                     let limit = countPerSecond - 1;
 
                                     const timer = setInterval(
-                                        function() {
-                                            while (cont <= limit) {
-                                                $(`#${randomId}_${lista[cont]['id']}`).removeClass();
-                                                $(`#${randomId}_${lista[cont]['id']}`).addClass(`${lista[cont]['status']} hover`);
-
-                                                cont++;
+                                    function() {
+                                        while (cont <= limit) {
+                                            if (typeof lista[cont] !== 'undefined') {
+                                                const rect = document.getElementsByName(`${lista[cont]['id']}`);
+                                                $(`#${rect[0].id}`).removeClass();
+                                                $(`#${rect[0].id}`).addClass(`${lista[cont]['status']} hover`);
                                             }
-                                            limit = limit + countPerSecond;
-                                        },
-                                        1000
-                                    );
+
+                                            cont++;
+                                        }
+                                        limit = limit + countPerSecond;
+                                    },
+                                    1000
+                                );
 
                                     setTimeout(
                                         function(){
@@ -567,6 +603,97 @@ class Heatmap
     }
 
 
+    /**
+     * Get all modules group by agents
+     *
+     * @return array
+     */
+    protected function getAllModulesByAgents()
+    {
+        $filter_name = '';
+        if (empty($this->search) === false) {
+            $filter_name = 'AND nombre LIKE "%'.$this->search.'%"';
+        }
+
+        // All modules.
+        $sql = sprintf(
+            'SELECT am.id_agente_modulo AS id, ae.known_status AS `status`, am.id_agente AS id_grupo, ae.last_status_change FROM tagente_modulo am
+            INNER JOIN tagente_estado ae ON am.id_agente_modulo = ae.id_agente_modulo
+            WHERE am.disabled = 0 %s GROUP BY ae.id_agente_modulo ORDER BY id_grupo',
+            $filter_name
+        );
+
+        $result = db_get_all_rows_sql($sql);
+
+        // Module status.
+        foreach ($result as $key => $module) {
+            $status = '';
+            switch ($module['status']) {
+                case AGENT_MODULE_STATUS_CRITICAL_BAD:
+                case AGENT_MODULE_STATUS_CRITICAL_ALERT:
+                case 1:
+                case 100:
+                    $status = 'critical';
+                break;
+
+                case AGENT_MODULE_STATUS_NORMAL:
+                case AGENT_MODULE_STATUS_NORMAL_ALERT:
+                case 0:
+                case 300:
+                    $status = 'normal';
+                break;
+
+                case AGENT_MODULE_STATUS_WARNING:
+                case AGENT_MODULE_STATUS_WARNING_ALERT:
+                case 2:
+                case 200:
+                    $status = 'warning';
+                break;
+
+                default:
+                case AGENT_MODULE_STATUS_UNKNOWN:
+                case 3:
+                    $status = 'unknown';
+                break;
+                case AGENT_MODULE_STATUS_NOT_INIT:
+                case 5:
+                    $status = 'notinit';
+                break;
+            }
+
+            if ($module['last_status_change'] != 0) {
+                $seconds = (time() - $module['last_status_change']);
+
+                if ($seconds >= SECONDS_1DAY) {
+                    $status .= '_10';
+                } else if ($seconds >= 77760) {
+                    $status .= '_9';
+                } else if ($seconds >= 69120) {
+                    $status .= '_8';
+                } else if ($seconds >= 60480) {
+                    $status .= '_7';
+                } else if ($seconds >= 51840) {
+                    $status .= '_6';
+                } else if ($seconds >= 43200) {
+                    $status .= '_5';
+                } else if ($seconds >= 34560) {
+                    $status .= '_4';
+                } else if ($seconds >= 25920) {
+                    $status .= '_3';
+                } else if ($seconds >= 17280) {
+                    $status .= '_2';
+                } else if ($seconds >= 8640) {
+                    $status .= '_1';
+                }
+            }
+
+            $result[$key]['status'] = $status;
+        }
+
+        return $result;
+    }
+
+
     /**
      * GetData
      *
@@ -575,6 +702,10 @@ class Heatmap
     public function getData()
     {
         switch ($this->type) {
+            case 3:
+                $data = $this->getAllModulesByAgents();
+            break;
+
             case 2:
                 $data = $this->getAllModulesByGroup();
             break;
@@ -709,9 +840,10 @@ class Heatmap
         $groups = [];
         $contX = 0;
         $contY = 0;
+        $cont = 1;
         foreach ($result as $value) {
-            echo '<rect id="'.$this->randomId.'_'.$value['id'].'" class="'.$value['status'].' hover"
-                width="1" height="1" x ="'.$contX.' "y="'.$contY.'" />';
+            echo '<rect id="'.$this->randomId.'_'.$cont.'" class="'.$value['status'].' hover"
+                width="1" height="1" x ="'.$contX.' "y="'.$contY.'" name="'.$value['id'].'" />';
 
             $contX++;
             if ($contX >= $Xaxis) {
@@ -724,14 +856,15 @@ class Heatmap
             } else {
                 $groups[$value['id_grupo']] += 1;
             }
+
+            $cont++;
         }
 
         ?>
             <script type="text/javascript">
                 $('rect').click(function() {
                     const type = <?php echo $this->type; ?>;
-                    const hash = '<?php echo $this->randomId; ?>';
-                    const id = this.id.replace(`${hash}_`, '');
+                    const id = $(`#${this.id}`).attr("name");
 
                     $("#info_dialog").dialog({
                         resizable: true,
@@ -778,6 +911,10 @@ class Heatmap
             foreach ($groups as $key => $group) {
                 $name = '';
                 switch ($this->type) {
+                    case 3:
+                        $name = agents_get_alias($key);
+                    break;
+
                     case 2:
                         $name = modules_get_modulegroup_name($key);
                     break;

From b31240a3cc06553eee5f88bfe2e6dfa03103e13e Mon Sep 17 00:00:00 2001
From: artica <artica.devel@gmail.com>
Date: Sat, 15 Oct 2022 01:00:23 +0200
Subject: [PATCH 53/83] Auto-updated build strings.

---
 pandora_agents/unix/DEBIAN/control             | 2 +-
 pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +-
 pandora_agents/unix/pandora_agent              | 2 +-
 pandora_agents/unix/pandora_agent.redhat.spec  | 2 +-
 pandora_agents/unix/pandora_agent.spec         | 2 +-
 pandora_agents/unix/pandora_agent_installer    | 2 +-
 pandora_agents/win32/installer/pandora.mpi     | 2 +-
 pandora_agents/win32/pandora.cc                | 2 +-
 pandora_agents/win32/versioninfo.rc            | 2 +-
 pandora_console/DEBIAN/control                 | 2 +-
 pandora_console/DEBIAN/make_deb_package.sh     | 2 +-
 pandora_console/include/config_process.php     | 2 +-
 pandora_console/install.php                    | 2 +-
 pandora_console/pandora_console.redhat.spec    | 2 +-
 pandora_console/pandora_console.rhel7.spec     | 2 +-
 pandora_console/pandora_console.spec           | 2 +-
 pandora_server/DEBIAN/control                  | 2 +-
 pandora_server/DEBIAN/make_deb_package.sh      | 2 +-
 pandora_server/lib/PandoraFMS/Config.pm        | 2 +-
 pandora_server/lib/PandoraFMS/PluginTools.pm   | 2 +-
 pandora_server/pandora_server.redhat.spec      | 2 +-
 pandora_server/pandora_server.spec             | 2 +-
 pandora_server/pandora_server_installer        | 2 +-
 pandora_server/util/pandora_db.pl              | 2 +-
 pandora_server/util/pandora_manage.pl          | 2 +-
 25 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control
index 4018039f20..963f9e92d1 100644
--- a/pandora_agents/unix/DEBIAN/control
+++ b/pandora_agents/unix/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-agent-unix
-Version: 7.0NG.765-221014
+Version: 7.0NG.765-221015
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh
index 44889d501d..e3fea972e1 100644
--- a/pandora_agents/unix/DEBIAN/make_deb_package.sh
+++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221014"
+pandora_version="7.0NG.765-221015"
 
 echo "Test if you has the tools for to make the packages."
 whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent
index 2f5e6417a9..c152c996de 100755
--- a/pandora_agents/unix/pandora_agent
+++ b/pandora_agents/unix/pandora_agent
@@ -1015,7 +1015,7 @@ my $Sem = undef;
 my $ThreadSem = undef;
 
 use constant AGENT_VERSION => '7.0NG.765';
-use constant AGENT_BUILD => '221014';
+use constant AGENT_BUILD => '221015';
 
 # Agent log default file size maximum and instances
 use constant DEFAULT_MAX_LOG_SIZE => 600000;
diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec
index 2fffcc1d23..b4b02b5113 100644
--- a/pandora_agents/unix/pandora_agent.redhat.spec
+++ b/pandora_agents/unix/pandora_agent.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221014
+%define release     221015
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec
index 51c0844ab9..db992fdae3 100644
--- a/pandora_agents/unix/pandora_agent.spec
+++ b/pandora_agents/unix/pandora_agent.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221014
+%define release     221015
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer
index 4221c2f2b2..c8a6306ffe 100755
--- a/pandora_agents/unix/pandora_agent_installer
+++ b/pandora_agents/unix/pandora_agent_installer
@@ -10,7 +10,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221014"
+PI_BUILD="221015"
 OS_NAME=`uname -s`
 
 FORCE=0
diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi
index 2f669dbbf9..9f17f24e64 100644
--- a/pandora_agents/win32/installer/pandora.mpi
+++ b/pandora_agents/win32/installer/pandora.mpi
@@ -186,7 +186,7 @@ UpgradeApplicationID
 {}
 
 Version
-{221014}
+{221015}
 
 ViewReadme
 {Yes}
diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc
index 30860fc1d2..e9af8777f2 100644
--- a/pandora_agents/win32/pandora.cc
+++ b/pandora_agents/win32/pandora.cc
@@ -30,7 +30,7 @@ using namespace Pandora;
 using namespace Pandora_Strutils;
 
 #define PATH_SIZE    _MAX_PATH+1
-#define PANDORA_VERSION ("7.0NG.765 Build 221014")
+#define PANDORA_VERSION ("7.0NG.765 Build 221015")
 
 string pandora_path;
 string pandora_dir;
diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc
index b6193a0aed..d946eeb14d 100644
--- a/pandora_agents/win32/versioninfo.rc
+++ b/pandora_agents/win32/versioninfo.rc
@@ -11,7 +11,7 @@ BEGIN
       VALUE "LegalCopyright", "Artica ST"
       VALUE "OriginalFilename", "PandoraAgent.exe"
       VALUE "ProductName", "Pandora FMS Windows Agent"
-      VALUE "ProductVersion", "(7.0NG.765(Build 221014))"
+      VALUE "ProductVersion", "(7.0NG.765(Build 221015))"
       VALUE "FileVersion", "1.0.0.0"
     END
   END
diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control
index 3019355c3f..adaf607dc9 100644
--- a/pandora_console/DEBIAN/control
+++ b/pandora_console/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-console
-Version: 7.0NG.765-221014
+Version: 7.0NG.765-221015
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh
index f532ec4147..340a8ef6f6 100644
--- a/pandora_console/DEBIAN/make_deb_package.sh
+++ b/pandora_console/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221014"
+pandora_version="7.0NG.765-221015"
 
 package_pear=0
 package_pandora=1
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index ad8c93d54a..4c8bdbc88d 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -20,7 +20,7 @@
 /**
  * Pandora build version and version
  */
-$build_version = 'PC221014';
+$build_version = 'PC221015';
 $pandora_version = 'v7.0NG.765';
 
 // Do not overwrite default timezone set if defined.
diff --git a/pandora_console/install.php b/pandora_console/install.php
index d7d1442226..83d0e95ae1 100644
--- a/pandora_console/install.php
+++ b/pandora_console/install.php
@@ -129,7 +129,7 @@
         <div style='height: 10px'>
             <?php
             $version = '7.0NG.765';
-            $build = '221014';
+            $build = '221015';
             $banner = "v$version Build $build";
 
             error_reporting(0);
diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec
index 6217be599f..ec137cecfb 100644
--- a/pandora_console/pandora_console.redhat.spec
+++ b/pandora_console/pandora_console.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221014
+%define release     221015
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec
index 511a26cd56..b9de628094 100644
--- a/pandora_console/pandora_console.rhel7.spec
+++ b/pandora_console/pandora_console.rhel7.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221014
+%define release     221015
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec
index cb62e2f4a6..63f32d7d61 100644
--- a/pandora_console/pandora_console.spec
+++ b/pandora_console/pandora_console.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221014
+%define release     221015
 %define httpd_name      httpd
 # User and Group under which Apache is running
 %define httpd_name  apache2
diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control
index 7dd36b5048..f8bfb01363 100644
--- a/pandora_server/DEBIAN/control
+++ b/pandora_server/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-server
-Version: 7.0NG.765-221014
+Version: 7.0NG.765-221015
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh
index add783e6e3..473865ed44 100644
--- a/pandora_server/DEBIAN/make_deb_package.sh
+++ b/pandora_server/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221014"
+pandora_version="7.0NG.765-221015"
 
 package_cpan=0
 package_pandora=1
diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm
index 85b7db6ac4..6cf33fef75 100644
--- a/pandora_server/lib/PandoraFMS/Config.pm
+++ b/pandora_server/lib/PandoraFMS/Config.pm
@@ -46,7 +46,7 @@ our @EXPORT = qw(
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221014";
+my $pandora_build = "221015";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 # Setup hash
diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm
index 980dc84d9d..7fcc2ebd97 100644
--- a/pandora_server/lib/PandoraFMS/PluginTools.pm
+++ b/pandora_server/lib/PandoraFMS/PluginTools.pm
@@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221014";
+my $pandora_build = "221015";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 our %EXPORT_TAGS = ( 'all' => [ qw() ] );
diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec
index b26554742d..60090c75de 100644
--- a/pandora_server/pandora_server.redhat.spec
+++ b/pandora_server/pandora_server.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221014
+%define release     221015
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec
index 1c705de963..90b3c86c99 100644
--- a/pandora_server/pandora_server.spec
+++ b/pandora_server/pandora_server.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221014
+%define release     221015
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer
index 7aa8c6f4de..967e304f3f 100755
--- a/pandora_server/pandora_server_installer
+++ b/pandora_server/pandora_server_installer
@@ -9,7 +9,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221014"
+PI_BUILD="221015"
 
 MODE=$1
 if [ $# -gt 1 ]; then
diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl
index 21efbbd6a4..ed707ec9d8 100755
--- a/pandora_server/util/pandora_db.pl
+++ b/pandora_server/util/pandora_db.pl
@@ -35,7 +35,7 @@ use PandoraFMS::Config;
 use PandoraFMS::DB;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221014";
+my $version = "7.0NG.765 Build 221015";
 
 # Pandora server configuration
 my %conf;
diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index f7c72111b2..bc6562221f 100755
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -36,7 +36,7 @@ use Encode::Locale;
 Encode::Locale::decode_argv;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221014";
+my $version = "7.0NG.765 Build 221015";
 
 # save program name for logging
 my $progname = basename($0);

From 92f0e4b709e9f5cd8907cece0e282fd4f60f1f31 Mon Sep 17 00:00:00 2001
From: artica <artica.devel@gmail.com>
Date: Sun, 16 Oct 2022 01:00:17 +0200
Subject: [PATCH 54/83] Auto-updated build strings.

---
 pandora_agents/unix/DEBIAN/control             | 2 +-
 pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +-
 pandora_agents/unix/pandora_agent              | 2 +-
 pandora_agents/unix/pandora_agent.redhat.spec  | 2 +-
 pandora_agents/unix/pandora_agent.spec         | 2 +-
 pandora_agents/unix/pandora_agent_installer    | 2 +-
 pandora_agents/win32/installer/pandora.mpi     | 2 +-
 pandora_agents/win32/pandora.cc                | 2 +-
 pandora_agents/win32/versioninfo.rc            | 2 +-
 pandora_console/DEBIAN/control                 | 2 +-
 pandora_console/DEBIAN/make_deb_package.sh     | 2 +-
 pandora_console/include/config_process.php     | 2 +-
 pandora_console/install.php                    | 2 +-
 pandora_console/pandora_console.redhat.spec    | 2 +-
 pandora_console/pandora_console.rhel7.spec     | 2 +-
 pandora_console/pandora_console.spec           | 2 +-
 pandora_server/DEBIAN/control                  | 2 +-
 pandora_server/DEBIAN/make_deb_package.sh      | 2 +-
 pandora_server/lib/PandoraFMS/Config.pm        | 2 +-
 pandora_server/lib/PandoraFMS/PluginTools.pm   | 2 +-
 pandora_server/pandora_server.redhat.spec      | 2 +-
 pandora_server/pandora_server.spec             | 2 +-
 pandora_server/pandora_server_installer        | 2 +-
 pandora_server/util/pandora_db.pl              | 2 +-
 pandora_server/util/pandora_manage.pl          | 2 +-
 25 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control
index 963f9e92d1..76d7898ad8 100644
--- a/pandora_agents/unix/DEBIAN/control
+++ b/pandora_agents/unix/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-agent-unix
-Version: 7.0NG.765-221015
+Version: 7.0NG.765-221016
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh
index e3fea972e1..de627a9852 100644
--- a/pandora_agents/unix/DEBIAN/make_deb_package.sh
+++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221015"
+pandora_version="7.0NG.765-221016"
 
 echo "Test if you has the tools for to make the packages."
 whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent
index c152c996de..42496307c4 100755
--- a/pandora_agents/unix/pandora_agent
+++ b/pandora_agents/unix/pandora_agent
@@ -1015,7 +1015,7 @@ my $Sem = undef;
 my $ThreadSem = undef;
 
 use constant AGENT_VERSION => '7.0NG.765';
-use constant AGENT_BUILD => '221015';
+use constant AGENT_BUILD => '221016';
 
 # Agent log default file size maximum and instances
 use constant DEFAULT_MAX_LOG_SIZE => 600000;
diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec
index b4b02b5113..9ad80766f8 100644
--- a/pandora_agents/unix/pandora_agent.redhat.spec
+++ b/pandora_agents/unix/pandora_agent.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221015
+%define release     221016
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec
index db992fdae3..4e502da95c 100644
--- a/pandora_agents/unix/pandora_agent.spec
+++ b/pandora_agents/unix/pandora_agent.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221015
+%define release     221016
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer
index c8a6306ffe..c9e2bf612b 100755
--- a/pandora_agents/unix/pandora_agent_installer
+++ b/pandora_agents/unix/pandora_agent_installer
@@ -10,7 +10,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221015"
+PI_BUILD="221016"
 OS_NAME=`uname -s`
 
 FORCE=0
diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi
index 9f17f24e64..d163f8892c 100644
--- a/pandora_agents/win32/installer/pandora.mpi
+++ b/pandora_agents/win32/installer/pandora.mpi
@@ -186,7 +186,7 @@ UpgradeApplicationID
 {}
 
 Version
-{221015}
+{221016}
 
 ViewReadme
 {Yes}
diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc
index e9af8777f2..caed117ba1 100644
--- a/pandora_agents/win32/pandora.cc
+++ b/pandora_agents/win32/pandora.cc
@@ -30,7 +30,7 @@ using namespace Pandora;
 using namespace Pandora_Strutils;
 
 #define PATH_SIZE    _MAX_PATH+1
-#define PANDORA_VERSION ("7.0NG.765 Build 221015")
+#define PANDORA_VERSION ("7.0NG.765 Build 221016")
 
 string pandora_path;
 string pandora_dir;
diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc
index d946eeb14d..e86d6bc5f4 100644
--- a/pandora_agents/win32/versioninfo.rc
+++ b/pandora_agents/win32/versioninfo.rc
@@ -11,7 +11,7 @@ BEGIN
       VALUE "LegalCopyright", "Artica ST"
       VALUE "OriginalFilename", "PandoraAgent.exe"
       VALUE "ProductName", "Pandora FMS Windows Agent"
-      VALUE "ProductVersion", "(7.0NG.765(Build 221015))"
+      VALUE "ProductVersion", "(7.0NG.765(Build 221016))"
       VALUE "FileVersion", "1.0.0.0"
     END
   END
diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control
index adaf607dc9..b49afec11f 100644
--- a/pandora_console/DEBIAN/control
+++ b/pandora_console/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-console
-Version: 7.0NG.765-221015
+Version: 7.0NG.765-221016
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh
index 340a8ef6f6..7a175debaa 100644
--- a/pandora_console/DEBIAN/make_deb_package.sh
+++ b/pandora_console/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221015"
+pandora_version="7.0NG.765-221016"
 
 package_pear=0
 package_pandora=1
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index 4c8bdbc88d..784d3b7750 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -20,7 +20,7 @@
 /**
  * Pandora build version and version
  */
-$build_version = 'PC221015';
+$build_version = 'PC221016';
 $pandora_version = 'v7.0NG.765';
 
 // Do not overwrite default timezone set if defined.
diff --git a/pandora_console/install.php b/pandora_console/install.php
index 83d0e95ae1..c061d760bb 100644
--- a/pandora_console/install.php
+++ b/pandora_console/install.php
@@ -129,7 +129,7 @@
         <div style='height: 10px'>
             <?php
             $version = '7.0NG.765';
-            $build = '221015';
+            $build = '221016';
             $banner = "v$version Build $build";
 
             error_reporting(0);
diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec
index ec137cecfb..b41d5c200a 100644
--- a/pandora_console/pandora_console.redhat.spec
+++ b/pandora_console/pandora_console.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221015
+%define release     221016
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec
index b9de628094..a227099479 100644
--- a/pandora_console/pandora_console.rhel7.spec
+++ b/pandora_console/pandora_console.rhel7.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221015
+%define release     221016
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec
index 63f32d7d61..6df46f8da6 100644
--- a/pandora_console/pandora_console.spec
+++ b/pandora_console/pandora_console.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221015
+%define release     221016
 %define httpd_name      httpd
 # User and Group under which Apache is running
 %define httpd_name  apache2
diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control
index f8bfb01363..fde05dbc52 100644
--- a/pandora_server/DEBIAN/control
+++ b/pandora_server/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-server
-Version: 7.0NG.765-221015
+Version: 7.0NG.765-221016
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh
index 473865ed44..c3d5305197 100644
--- a/pandora_server/DEBIAN/make_deb_package.sh
+++ b/pandora_server/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221015"
+pandora_version="7.0NG.765-221016"
 
 package_cpan=0
 package_pandora=1
diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm
index 6cf33fef75..f973996b9e 100644
--- a/pandora_server/lib/PandoraFMS/Config.pm
+++ b/pandora_server/lib/PandoraFMS/Config.pm
@@ -46,7 +46,7 @@ our @EXPORT = qw(
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221015";
+my $pandora_build = "221016";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 # Setup hash
diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm
index 7fcc2ebd97..3f269cb1b0 100644
--- a/pandora_server/lib/PandoraFMS/PluginTools.pm
+++ b/pandora_server/lib/PandoraFMS/PluginTools.pm
@@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221015";
+my $pandora_build = "221016";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 our %EXPORT_TAGS = ( 'all' => [ qw() ] );
diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec
index 60090c75de..30241fc5a4 100644
--- a/pandora_server/pandora_server.redhat.spec
+++ b/pandora_server/pandora_server.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221015
+%define release     221016
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec
index 90b3c86c99..b87320bd03 100644
--- a/pandora_server/pandora_server.spec
+++ b/pandora_server/pandora_server.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221015
+%define release     221016
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer
index 967e304f3f..f0d822337b 100755
--- a/pandora_server/pandora_server_installer
+++ b/pandora_server/pandora_server_installer
@@ -9,7 +9,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221015"
+PI_BUILD="221016"
 
 MODE=$1
 if [ $# -gt 1 ]; then
diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl
index ed707ec9d8..d1d9f82626 100755
--- a/pandora_server/util/pandora_db.pl
+++ b/pandora_server/util/pandora_db.pl
@@ -35,7 +35,7 @@ use PandoraFMS::Config;
 use PandoraFMS::DB;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221015";
+my $version = "7.0NG.765 Build 221016";
 
 # Pandora server configuration
 my %conf;
diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index bc6562221f..e1506f7cf2 100755
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -36,7 +36,7 @@ use Encode::Locale;
 Encode::Locale::decode_argv;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221015";
+my $version = "7.0NG.765 Build 221016";
 
 # save program name for logging
 my $progname = basename($0);

From b79b7e5d57a02f5e7ea91e3450100ab6ad500deb Mon Sep 17 00:00:00 2001
From: artica <artica.devel@gmail.com>
Date: Mon, 17 Oct 2022 01:00:17 +0200
Subject: [PATCH 55/83] Auto-updated build strings.

---
 pandora_agents/unix/DEBIAN/control             | 2 +-
 pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +-
 pandora_agents/unix/pandora_agent              | 2 +-
 pandora_agents/unix/pandora_agent.redhat.spec  | 2 +-
 pandora_agents/unix/pandora_agent.spec         | 2 +-
 pandora_agents/unix/pandora_agent_installer    | 2 +-
 pandora_agents/win32/installer/pandora.mpi     | 2 +-
 pandora_agents/win32/pandora.cc                | 2 +-
 pandora_agents/win32/versioninfo.rc            | 2 +-
 pandora_console/DEBIAN/control                 | 2 +-
 pandora_console/DEBIAN/make_deb_package.sh     | 2 +-
 pandora_console/include/config_process.php     | 2 +-
 pandora_console/install.php                    | 2 +-
 pandora_console/pandora_console.redhat.spec    | 2 +-
 pandora_console/pandora_console.rhel7.spec     | 2 +-
 pandora_console/pandora_console.spec           | 2 +-
 pandora_server/DEBIAN/control                  | 2 +-
 pandora_server/DEBIAN/make_deb_package.sh      | 2 +-
 pandora_server/lib/PandoraFMS/Config.pm        | 2 +-
 pandora_server/lib/PandoraFMS/PluginTools.pm   | 2 +-
 pandora_server/pandora_server.redhat.spec      | 2 +-
 pandora_server/pandora_server.spec             | 2 +-
 pandora_server/pandora_server_installer        | 2 +-
 pandora_server/util/pandora_db.pl              | 2 +-
 pandora_server/util/pandora_manage.pl          | 2 +-
 25 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control
index 76d7898ad8..c0a043b65f 100644
--- a/pandora_agents/unix/DEBIAN/control
+++ b/pandora_agents/unix/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-agent-unix
-Version: 7.0NG.765-221016
+Version: 7.0NG.765-221017
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh
index de627a9852..376ee10fb8 100644
--- a/pandora_agents/unix/DEBIAN/make_deb_package.sh
+++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221016"
+pandora_version="7.0NG.765-221017"
 
 echo "Test if you has the tools for to make the packages."
 whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent
index 42496307c4..45dbf33561 100755
--- a/pandora_agents/unix/pandora_agent
+++ b/pandora_agents/unix/pandora_agent
@@ -1015,7 +1015,7 @@ my $Sem = undef;
 my $ThreadSem = undef;
 
 use constant AGENT_VERSION => '7.0NG.765';
-use constant AGENT_BUILD => '221016';
+use constant AGENT_BUILD => '221017';
 
 # Agent log default file size maximum and instances
 use constant DEFAULT_MAX_LOG_SIZE => 600000;
diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec
index 9ad80766f8..611d497c2e 100644
--- a/pandora_agents/unix/pandora_agent.redhat.spec
+++ b/pandora_agents/unix/pandora_agent.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221016
+%define release     221017
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec
index 4e502da95c..7c0f1de9c9 100644
--- a/pandora_agents/unix/pandora_agent.spec
+++ b/pandora_agents/unix/pandora_agent.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221016
+%define release     221017
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer
index c9e2bf612b..a9a7fb7350 100755
--- a/pandora_agents/unix/pandora_agent_installer
+++ b/pandora_agents/unix/pandora_agent_installer
@@ -10,7 +10,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221016"
+PI_BUILD="221017"
 OS_NAME=`uname -s`
 
 FORCE=0
diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi
index d163f8892c..164fdc29e5 100644
--- a/pandora_agents/win32/installer/pandora.mpi
+++ b/pandora_agents/win32/installer/pandora.mpi
@@ -186,7 +186,7 @@ UpgradeApplicationID
 {}
 
 Version
-{221016}
+{221017}
 
 ViewReadme
 {Yes}
diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc
index caed117ba1..42a66fda57 100644
--- a/pandora_agents/win32/pandora.cc
+++ b/pandora_agents/win32/pandora.cc
@@ -30,7 +30,7 @@ using namespace Pandora;
 using namespace Pandora_Strutils;
 
 #define PATH_SIZE    _MAX_PATH+1
-#define PANDORA_VERSION ("7.0NG.765 Build 221016")
+#define PANDORA_VERSION ("7.0NG.765 Build 221017")
 
 string pandora_path;
 string pandora_dir;
diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc
index e86d6bc5f4..55b05dbc59 100644
--- a/pandora_agents/win32/versioninfo.rc
+++ b/pandora_agents/win32/versioninfo.rc
@@ -11,7 +11,7 @@ BEGIN
       VALUE "LegalCopyright", "Artica ST"
       VALUE "OriginalFilename", "PandoraAgent.exe"
       VALUE "ProductName", "Pandora FMS Windows Agent"
-      VALUE "ProductVersion", "(7.0NG.765(Build 221016))"
+      VALUE "ProductVersion", "(7.0NG.765(Build 221017))"
       VALUE "FileVersion", "1.0.0.0"
     END
   END
diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control
index b49afec11f..64689dd755 100644
--- a/pandora_console/DEBIAN/control
+++ b/pandora_console/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-console
-Version: 7.0NG.765-221016
+Version: 7.0NG.765-221017
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh
index 7a175debaa..94ff4318f3 100644
--- a/pandora_console/DEBIAN/make_deb_package.sh
+++ b/pandora_console/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221016"
+pandora_version="7.0NG.765-221017"
 
 package_pear=0
 package_pandora=1
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index 784d3b7750..0823f278b7 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -20,7 +20,7 @@
 /**
  * Pandora build version and version
  */
-$build_version = 'PC221016';
+$build_version = 'PC221017';
 $pandora_version = 'v7.0NG.765';
 
 // Do not overwrite default timezone set if defined.
diff --git a/pandora_console/install.php b/pandora_console/install.php
index c061d760bb..11cd881e99 100644
--- a/pandora_console/install.php
+++ b/pandora_console/install.php
@@ -129,7 +129,7 @@
         <div style='height: 10px'>
             <?php
             $version = '7.0NG.765';
-            $build = '221016';
+            $build = '221017';
             $banner = "v$version Build $build";
 
             error_reporting(0);
diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec
index b41d5c200a..db5324e114 100644
--- a/pandora_console/pandora_console.redhat.spec
+++ b/pandora_console/pandora_console.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221016
+%define release     221017
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec
index a227099479..e887679dbd 100644
--- a/pandora_console/pandora_console.rhel7.spec
+++ b/pandora_console/pandora_console.rhel7.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221016
+%define release     221017
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec
index 6df46f8da6..de18fc1c64 100644
--- a/pandora_console/pandora_console.spec
+++ b/pandora_console/pandora_console.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221016
+%define release     221017
 %define httpd_name      httpd
 # User and Group under which Apache is running
 %define httpd_name  apache2
diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control
index fde05dbc52..ed66eb51f8 100644
--- a/pandora_server/DEBIAN/control
+++ b/pandora_server/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-server
-Version: 7.0NG.765-221016
+Version: 7.0NG.765-221017
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh
index c3d5305197..a74c12ae4a 100644
--- a/pandora_server/DEBIAN/make_deb_package.sh
+++ b/pandora_server/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221016"
+pandora_version="7.0NG.765-221017"
 
 package_cpan=0
 package_pandora=1
diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm
index f973996b9e..022b6c8ab5 100644
--- a/pandora_server/lib/PandoraFMS/Config.pm
+++ b/pandora_server/lib/PandoraFMS/Config.pm
@@ -46,7 +46,7 @@ our @EXPORT = qw(
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221016";
+my $pandora_build = "221017";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 # Setup hash
diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm
index 3f269cb1b0..9bf3ac8dab 100644
--- a/pandora_server/lib/PandoraFMS/PluginTools.pm
+++ b/pandora_server/lib/PandoraFMS/PluginTools.pm
@@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221016";
+my $pandora_build = "221017";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 our %EXPORT_TAGS = ( 'all' => [ qw() ] );
diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec
index 30241fc5a4..c2d2d779f8 100644
--- a/pandora_server/pandora_server.redhat.spec
+++ b/pandora_server/pandora_server.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221016
+%define release     221017
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec
index b87320bd03..84cc39b429 100644
--- a/pandora_server/pandora_server.spec
+++ b/pandora_server/pandora_server.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221016
+%define release     221017
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer
index f0d822337b..ddd4b97d4e 100755
--- a/pandora_server/pandora_server_installer
+++ b/pandora_server/pandora_server_installer
@@ -9,7 +9,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221016"
+PI_BUILD="221017"
 
 MODE=$1
 if [ $# -gt 1 ]; then
diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl
index d1d9f82626..e6e49316ab 100755
--- a/pandora_server/util/pandora_db.pl
+++ b/pandora_server/util/pandora_db.pl
@@ -35,7 +35,7 @@ use PandoraFMS::Config;
 use PandoraFMS::DB;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221016";
+my $version = "7.0NG.765 Build 221017";
 
 # Pandora server configuration
 my %conf;
diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index e1506f7cf2..ba59b8b2c1 100755
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -36,7 +36,7 @@ use Encode::Locale;
 Encode::Locale::decode_argv;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221016";
+my $version = "7.0NG.765 Build 221017";
 
 # save program name for logging
 my $progname = basename($0);

From 0db0b50ebdb2c291473a5517978fa3e26d6ee524 Mon Sep 17 00:00:00 2001
From: Daniel Maya <daniel.maya@pandorafms.com>
Date: Mon, 17 Oct 2022 10:32:28 +0200
Subject: [PATCH 56/83] #9641 heatmap changes 2

---
 pandora_console/include/class/Heatmap.class.php | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/pandora_console/include/class/Heatmap.class.php b/pandora_console/include/class/Heatmap.class.php
index ece2ced842..8572d6cad1 100644
--- a/pandora_console/include/class/Heatmap.class.php
+++ b/pandora_console/include/class/Heatmap.class.php
@@ -350,8 +350,10 @@ class Heatmap
 
         // All agents.
         $sql = sprintf(
-            'SELECT DISTINCT id_agente as id,alias,id_grupo,normal_count,warning_count,critical_count, unknown_count,notinit_count,total_count,fired_count,
-            (SELECT last_status_change FROM tagente_estado WHERE id_agente = tagente.id_agente ORDER BY last_status_change DESC LIMIT 1) AS last_status_change
+            'SELECT DISTINCT id_agente as id,alias,id_grupo,normal_count,warning_count,critical_count,
+            unknown_count,notinit_count,total_count,fired_count,
+            (SELECT last_status_change FROM tagente_estado WHERE id_agente = tagente.id_agente
+            ORDER BY last_status_change DESC LIMIT 1) AS last_status_change
             FROM tagente WHERE `disabled` = 0 %s %s ORDER BY id_grupo,id_agente ASC',
             $alias,
             $id_grupo
@@ -427,7 +429,8 @@ class Heatmap
 
         // All modules.
         $sql = sprintf(
-            'SELECT am.id_agente_modulo AS id, ae.known_status AS `status`, am.id_module_group AS id_grupo, ae.last_status_change FROM tagente_modulo am
+            'SELECT am.id_agente_modulo AS id, ae.estado AS `status`, am.id_module_group AS id_grupo,
+            ae.last_status_change FROM tagente_modulo am
             INNER JOIN tagente_estado ae ON am.id_agente_modulo = ae.id_agente_modulo
             WHERE am.disabled = 0 %s %s GROUP BY am.id_module_group, am.id_agente_modulo',
             $filter_group,
@@ -525,7 +528,8 @@ class Heatmap
 
         // All modules.
         $sql = sprintf(
-            'SELECT ae.id_agente_modulo AS id, ae.known_status AS `status`, tm.id_tag AS id_grupo, ae.last_status_change FROM tagente_estado ae 
+            'SELECT ae.id_agente_modulo AS id, ae.estado AS `status`, tm.id_tag AS id_grupo,
+            ae.last_status_change FROM tagente_estado ae
             INNER JOIN ttag_module tm ON tm.id_agente_modulo = ae.id_agente_modulo
             WHERE 1=1 %s %s GROUP BY tm.id_tag, ae.id_agente_modulo',
             $filter_tag,
@@ -617,7 +621,8 @@ class Heatmap
 
         // All modules.
         $sql = sprintf(
-            'SELECT am.id_agente_modulo AS id, ae.known_status AS `status`, am.id_agente AS id_grupo, ae.last_status_change FROM tagente_modulo am
+            'SELECT am.id_agente_modulo AS id, ae.estado AS `status`, am.id_agente AS id_grupo,
+            ae.last_status_change FROM tagente_modulo am
             INNER JOIN tagente_estado ae ON am.id_agente_modulo = ae.id_agente_modulo
             WHERE am.disabled = 0 %s GROUP BY ae.id_agente_modulo ORDER BY id_grupo',
             $filter_name

From 357f9cc8176870caf4c3f2b05624896b1b428694 Mon Sep 17 00:00:00 2001
From: Daniel Maya <daniel.maya@pandorafms.com>
Date: Mon, 17 Oct 2022 10:44:35 +0200
Subject: [PATCH 57/83] #9641 heatmap changes 3

---
 pandora_console/operation/heatmap.php | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/pandora_console/operation/heatmap.php b/pandora_console/operation/heatmap.php
index 3ed2b8e7ce..a9ab10ed47 100644
--- a/pandora_console/operation/heatmap.php
+++ b/pandora_console/operation/heatmap.php
@@ -91,6 +91,10 @@ if ($is_ajax === false && $pure === false) {
 
     $header_name = __('Heatmap view');
     switch ($type) {
+        case 3:
+            $header_name .= ' - '.__('Agents');
+        break;
+
         case 2:
             if (current($filter) == 0) {
                 $header_name .= ' - '.__('Module group').': '.__('Not assigned');

From 2251062d3060a239c4e9cc1bfd366f262fba51f4 Mon Sep 17 00:00:00 2001
From: Calvo <luis.calvo@pandorafms.com>
Date: Mon, 17 Oct 2022 12:26:38 +0200
Subject: [PATCH 58/83] Fix user profile add bugs

---
 .../godmode/users/configure_user.php          | 27 ++++++++++++++++---
 pandora_console/include/functions_profile.php | 11 +++++---
 .../include/javascript/pandora_ui.js          | 23 ++++++++++++++++
 3 files changed, 54 insertions(+), 7 deletions(-)

diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php
index 800f738394..945bea5edd 100644
--- a/pandora_console/godmode/users/configure_user.php
+++ b/pandora_console/godmode/users/configure_user.php
@@ -489,6 +489,10 @@ if ($create_user) {
             if (!empty($json_profile)) {
                 $json_profile = json_decode(io_safe_output($json_profile), true);
                 foreach ($json_profile as $key => $profile) {
+                    if (is_array($profile) === false) {
+                        $profile = json_decode($profile, true);
+                    }
+
                     if (!empty($profile)) {
                         $group2 = $profile['group'];
                         $profile2 = $profile['profile'];
@@ -806,6 +810,10 @@ if ($add_profile && empty($json_profile)) {
         'Profile: '.$profile2.' Group: '.$group2.' Tags: '.$tags
     );
     $return = profile_create_user_profile($id2, $profile2, $group2, false, $tags, $no_hierarchy);
+    if ($return === false) {
+        $is_err = true;
+    }
+
     ui_print_result_message(
         $return,
         __('Profile added successfully'),
@@ -1439,7 +1447,7 @@ if ($config['admin_can_add_user']) {
 
 echo '</div>';
 
-html_print_input_hidden('json_profile', '');
+html_print_input_hidden('json_profile', $json_profile);
 
 echo '</form>';
 
@@ -1566,7 +1574,12 @@ $(document).ready (function () {
     var user_is_global_admin = '<?php echo users_is_admin($id); ?>';
     var is_err = '<?php echo $is_err; ?>';
     var data = [];
+    var aux = 0;
 
+    if(json_profile.val() != '') {
+        var data = JSON.parse(json_profile.val());
+    }
+    
     $('input:image[name="add"]').click(function (e) {
         e.preventDefault();
         var profile = $('#assign_profile').val();
@@ -1588,10 +1601,14 @@ $(document).ready (function () {
             return;
         }
 
-        if (id_user === '' || is_err === 1) {
+        if (id_user == '' || is_err == 1) {
             let new_json = `{"profile":${profile},"group":${group},"tags":[${tags}],"hierarchy":${hierarchy}}`;
             data.push(new_json);
-            json_profile.val('['+data+']');
+            json_profile.val(JSON.stringify(data));
+            profile_text = `<a href="index.php?sec2=godmode/users/configure_profile&id=${profile}">${profile_text}</a>`;
+            group_img = `<img id="img_group_${aux}" src="" data-title="${group_text}" data-use_title_for_force_title="1" class="bot forced_title" alt="${group_text}"/>`;
+            group_text = `<a href="index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id=${group}">${group_img}${group_text}</a>`;
+
             $('#table_profiles tr:last').before(
                 `<tr>
                     <td>${profile_text}</td>
@@ -1601,6 +1618,10 @@ $(document).ready (function () {
                     <td>${img_delete}</td>
                 </tr>`
             );
+
+            getGroupIcon(group, $(`#img_group_${aux}`));
+            aux++;
+
         } else {
             this.form.submit();
         }
diff --git a/pandora_console/include/functions_profile.php b/pandora_console/include/functions_profile.php
index c6a62c4c9d..ad052dadbd 100644
--- a/pandora_console/include/functions_profile.php
+++ b/pandora_console/include/functions_profile.php
@@ -181,7 +181,7 @@ function profile_delete_profile_and_clean_users($id_profile)
  * @param int User id
  * @param bool Show the tags select or not
  */
-function profile_print_profile_table($id, $json_profile=false)
+function profile_print_profile_table($id, $json_profile=false, $return=false)
 {
     global $config;
 
@@ -246,6 +246,10 @@ function profile_print_profile_table($id, $json_profile=false)
         if ($json_profile !== false && empty($json_profile) !== true) {
             $profile_decoded = json_decode($json_profile);
             foreach ($profile_decoded as $profile) {
+                if (is_object($profile) === false) {
+                    $profile = json_decode($profile);
+                }
+
                         $result[] = [
                             'id_grupo'  => $profile->group,
                             'id_perfil' => $profile->profile,
@@ -293,10 +297,10 @@ function profile_print_profile_table($id, $json_profile=false)
         $data['hierarchy'] = $profile['no_hierarchy'] ? __('Yes') : __('No');
 
         $data['actions'] = '<form method="post" onsubmit="if (!confirm (\''.__('Are you sure?').'\')) return false">';
+        $data['actions'] .= html_print_input_image('del', 'images/cross.png', 1, ['class' => 'invert_filter'], true);
         $data['actions'] .= html_print_input_hidden('delete_profile', 1, true);
         $data['actions'] .= html_print_input_hidden('id_user_profile', $profile['id_up'], true);
         $data['actions'] .= html_print_input_hidden('id_user', $id, true);
-        $data['actions'] .= html_print_input_image('del', 'images/cross.png', 1, ['class' => 'invert_filter'], true);
         $data['actions'] .= '</form>';
 
         array_push($table->data, $data);
@@ -362,8 +366,7 @@ function profile_print_profile_table($id, $json_profile=false)
     $data['actions'] .= '</form>';
 
     array_push($table->data, $data);
-
-    html_print_table($table);
+    html_print_table($table, $return);
     if (!is_metaconsole()) {
         echo '</div>';
     }
diff --git a/pandora_console/include/javascript/pandora_ui.js b/pandora_console/include/javascript/pandora_ui.js
index eeeb5fcfd5..ecb23827d9 100644
--- a/pandora_console/include/javascript/pandora_ui.js
+++ b/pandora_console/include/javascript/pandora_ui.js
@@ -740,3 +740,26 @@ function reveal_password(name) {
     revealElement.attr("src", imagesPath + "eye_show.png");
   }
 }
+
+/**
+ * Returns html img group icon.
+ * @param {int} $id_group
+ */
+function getGroupIcon(id_group, img_container) {
+  $.ajax({
+    type: "POST",
+    url: "ajax.php",
+    dataType: "json",
+    data: {
+      page: "godmode/groups/group_list",
+      get_group_json: 1,
+      id_group: id_group
+    },
+    success: function(data) {
+      img_container.attr("src", "images/groups_small/" + data["icon"] + ".png");
+    },
+    error: function() {
+      img_container.attr("src", "");
+    }
+  });
+}

From 391ff40c93e2776f54315eacf333f959e7ec5ab1 Mon Sep 17 00:00:00 2001
From: Calvo <luis.calvo@pandorafms.com>
Date: Mon, 17 Oct 2022 12:47:54 +0200
Subject: [PATCH 59/83] Fix var name misspell

---
 pandora_console/include/auth/mysql.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php
index 16ea1456f2..d6d557d099 100644
--- a/pandora_console/include/auth/mysql.php
+++ b/pandora_console/include/auth/mysql.php
@@ -807,7 +807,7 @@ function ldap_process_user_login($login, $password, $secondary_server=false)
     ldap_set_option(
         $ds,
         LDAP_OPT_TIMELIMIT,
-        (empty($config['ldap_search_timmeout']) === true) ? 5 : ((int) $config['ldap_search_timeout'])
+        (empty($config['ldap_search_timeout']) === true) ? 5 : ((int) $config['ldap_search_timeout'])
     );
 
     if ($ldap['ldap_start_tls']) {

From ed8b6678cd2a9439d5bdf45d6cf0ea7c5e7cfb9f Mon Sep 17 00:00:00 2001
From: artica <artica.devel@gmail.com>
Date: Tue, 18 Oct 2022 01:00:21 +0200
Subject: [PATCH 60/83] Auto-updated build strings.

---
 pandora_agents/unix/DEBIAN/control             | 2 +-
 pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +-
 pandora_agents/unix/pandora_agent              | 2 +-
 pandora_agents/unix/pandora_agent.redhat.spec  | 2 +-
 pandora_agents/unix/pandora_agent.spec         | 2 +-
 pandora_agents/unix/pandora_agent_installer    | 2 +-
 pandora_agents/win32/installer/pandora.mpi     | 2 +-
 pandora_agents/win32/pandora.cc                | 2 +-
 pandora_agents/win32/versioninfo.rc            | 2 +-
 pandora_console/DEBIAN/control                 | 2 +-
 pandora_console/DEBIAN/make_deb_package.sh     | 2 +-
 pandora_console/include/config_process.php     | 2 +-
 pandora_console/install.php                    | 2 +-
 pandora_console/pandora_console.redhat.spec    | 2 +-
 pandora_console/pandora_console.rhel7.spec     | 2 +-
 pandora_console/pandora_console.spec           | 2 +-
 pandora_server/DEBIAN/control                  | 2 +-
 pandora_server/DEBIAN/make_deb_package.sh      | 2 +-
 pandora_server/lib/PandoraFMS/Config.pm        | 2 +-
 pandora_server/lib/PandoraFMS/PluginTools.pm   | 2 +-
 pandora_server/pandora_server.redhat.spec      | 2 +-
 pandora_server/pandora_server.spec             | 2 +-
 pandora_server/pandora_server_installer        | 2 +-
 pandora_server/util/pandora_db.pl              | 2 +-
 pandora_server/util/pandora_manage.pl          | 2 +-
 25 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control
index c0a043b65f..1e38797198 100644
--- a/pandora_agents/unix/DEBIAN/control
+++ b/pandora_agents/unix/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-agent-unix
-Version: 7.0NG.765-221017
+Version: 7.0NG.765-221018
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh
index 376ee10fb8..e7662144c6 100644
--- a/pandora_agents/unix/DEBIAN/make_deb_package.sh
+++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221017"
+pandora_version="7.0NG.765-221018"
 
 echo "Test if you has the tools for to make the packages."
 whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent
index 45dbf33561..bf7572f67c 100755
--- a/pandora_agents/unix/pandora_agent
+++ b/pandora_agents/unix/pandora_agent
@@ -1015,7 +1015,7 @@ my $Sem = undef;
 my $ThreadSem = undef;
 
 use constant AGENT_VERSION => '7.0NG.765';
-use constant AGENT_BUILD => '221017';
+use constant AGENT_BUILD => '221018';
 
 # Agent log default file size maximum and instances
 use constant DEFAULT_MAX_LOG_SIZE => 600000;
diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec
index 611d497c2e..6074ba5280 100644
--- a/pandora_agents/unix/pandora_agent.redhat.spec
+++ b/pandora_agents/unix/pandora_agent.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221017
+%define release     221018
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec
index 7c0f1de9c9..b4081b677d 100644
--- a/pandora_agents/unix/pandora_agent.spec
+++ b/pandora_agents/unix/pandora_agent.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221017
+%define release     221018
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer
index a9a7fb7350..c7c2027a81 100755
--- a/pandora_agents/unix/pandora_agent_installer
+++ b/pandora_agents/unix/pandora_agent_installer
@@ -10,7 +10,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221017"
+PI_BUILD="221018"
 OS_NAME=`uname -s`
 
 FORCE=0
diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi
index 164fdc29e5..9af1e6a8c9 100644
--- a/pandora_agents/win32/installer/pandora.mpi
+++ b/pandora_agents/win32/installer/pandora.mpi
@@ -186,7 +186,7 @@ UpgradeApplicationID
 {}
 
 Version
-{221017}
+{221018}
 
 ViewReadme
 {Yes}
diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc
index 42a66fda57..04eea8f5e8 100644
--- a/pandora_agents/win32/pandora.cc
+++ b/pandora_agents/win32/pandora.cc
@@ -30,7 +30,7 @@ using namespace Pandora;
 using namespace Pandora_Strutils;
 
 #define PATH_SIZE    _MAX_PATH+1
-#define PANDORA_VERSION ("7.0NG.765 Build 221017")
+#define PANDORA_VERSION ("7.0NG.765 Build 221018")
 
 string pandora_path;
 string pandora_dir;
diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc
index 55b05dbc59..3192279b81 100644
--- a/pandora_agents/win32/versioninfo.rc
+++ b/pandora_agents/win32/versioninfo.rc
@@ -11,7 +11,7 @@ BEGIN
       VALUE "LegalCopyright", "Artica ST"
       VALUE "OriginalFilename", "PandoraAgent.exe"
       VALUE "ProductName", "Pandora FMS Windows Agent"
-      VALUE "ProductVersion", "(7.0NG.765(Build 221017))"
+      VALUE "ProductVersion", "(7.0NG.765(Build 221018))"
       VALUE "FileVersion", "1.0.0.0"
     END
   END
diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control
index 64689dd755..fce3f648cf 100644
--- a/pandora_console/DEBIAN/control
+++ b/pandora_console/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-console
-Version: 7.0NG.765-221017
+Version: 7.0NG.765-221018
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh
index 94ff4318f3..bb0fe38433 100644
--- a/pandora_console/DEBIAN/make_deb_package.sh
+++ b/pandora_console/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221017"
+pandora_version="7.0NG.765-221018"
 
 package_pear=0
 package_pandora=1
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index 0823f278b7..28a11a0f1c 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -20,7 +20,7 @@
 /**
  * Pandora build version and version
  */
-$build_version = 'PC221017';
+$build_version = 'PC221018';
 $pandora_version = 'v7.0NG.765';
 
 // Do not overwrite default timezone set if defined.
diff --git a/pandora_console/install.php b/pandora_console/install.php
index 11cd881e99..0d925f107e 100644
--- a/pandora_console/install.php
+++ b/pandora_console/install.php
@@ -129,7 +129,7 @@
         <div style='height: 10px'>
             <?php
             $version = '7.0NG.765';
-            $build = '221017';
+            $build = '221018';
             $banner = "v$version Build $build";
 
             error_reporting(0);
diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec
index db5324e114..5afb98159f 100644
--- a/pandora_console/pandora_console.redhat.spec
+++ b/pandora_console/pandora_console.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221017
+%define release     221018
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec
index e887679dbd..21ddaf5adc 100644
--- a/pandora_console/pandora_console.rhel7.spec
+++ b/pandora_console/pandora_console.rhel7.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221017
+%define release     221018
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec
index de18fc1c64..503fc0383b 100644
--- a/pandora_console/pandora_console.spec
+++ b/pandora_console/pandora_console.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221017
+%define release     221018
 %define httpd_name      httpd
 # User and Group under which Apache is running
 %define httpd_name  apache2
diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control
index ed66eb51f8..bbcc24efdf 100644
--- a/pandora_server/DEBIAN/control
+++ b/pandora_server/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-server
-Version: 7.0NG.765-221017
+Version: 7.0NG.765-221018
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh
index a74c12ae4a..4dab9e00b9 100644
--- a/pandora_server/DEBIAN/make_deb_package.sh
+++ b/pandora_server/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221017"
+pandora_version="7.0NG.765-221018"
 
 package_cpan=0
 package_pandora=1
diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm
index 022b6c8ab5..acf6f53651 100644
--- a/pandora_server/lib/PandoraFMS/Config.pm
+++ b/pandora_server/lib/PandoraFMS/Config.pm
@@ -46,7 +46,7 @@ our @EXPORT = qw(
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221017";
+my $pandora_build = "221018";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 # Setup hash
diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm
index 9bf3ac8dab..a0d72e02cf 100644
--- a/pandora_server/lib/PandoraFMS/PluginTools.pm
+++ b/pandora_server/lib/PandoraFMS/PluginTools.pm
@@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221017";
+my $pandora_build = "221018";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 our %EXPORT_TAGS = ( 'all' => [ qw() ] );
diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec
index c2d2d779f8..cfcfd49b42 100644
--- a/pandora_server/pandora_server.redhat.spec
+++ b/pandora_server/pandora_server.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221017
+%define release     221018
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec
index 84cc39b429..d90c6cf9fc 100644
--- a/pandora_server/pandora_server.spec
+++ b/pandora_server/pandora_server.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221017
+%define release     221018
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer
index ddd4b97d4e..52487caa93 100755
--- a/pandora_server/pandora_server_installer
+++ b/pandora_server/pandora_server_installer
@@ -9,7 +9,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221017"
+PI_BUILD="221018"
 
 MODE=$1
 if [ $# -gt 1 ]; then
diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl
index e6e49316ab..e4a5c8b726 100755
--- a/pandora_server/util/pandora_db.pl
+++ b/pandora_server/util/pandora_db.pl
@@ -35,7 +35,7 @@ use PandoraFMS::Config;
 use PandoraFMS::DB;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221017";
+my $version = "7.0NG.765 Build 221018";
 
 # Pandora server configuration
 my %conf;
diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index ba59b8b2c1..3ec677ac1f 100755
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -36,7 +36,7 @@ use Encode::Locale;
 Encode::Locale::decode_argv;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221017";
+my $version = "7.0NG.765 Build 221018";
 
 # save program name for logging
 my $progname = basename($0);

From 3f8e0f765a7254a0f632570615fb6e7bf1d8b274 Mon Sep 17 00:00:00 2001
From: Calvo <luis.calvo@pandorafms.com>
Date: Tue, 18 Oct 2022 09:52:08 +0200
Subject: [PATCH 61/83] Fix adding agnents planned downtime

---
 .../godmode/agentes/planned_downtime.editor.php    | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/pandora_console/godmode/agentes/planned_downtime.editor.php b/pandora_console/godmode/agentes/planned_downtime.editor.php
index cdd5152bd0..fdb8de3b06 100644
--- a/pandora_console/godmode/agentes/planned_downtime.editor.php
+++ b/pandora_console/godmode/agentes/planned_downtime.editor.php
@@ -1423,9 +1423,19 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
     } else {
         // If is selected 'Any', get all the agents.
         if (count($agents) === 1 && (int) $agents[0] === -2) {
-            $agents = agents_get_agents(
+            $agents = db_get_all_rows_filter(
+                'tagente',
                 ['id_grupo' => $filter_group],
-                'id_agent'
+                'id_agente'
+            );
+
+            $agents = array_reduce(
+                $agents,
+                function ($carry, $item) {
+                    $carry[] = $item['id_agente'];
+
+                    return $carry;
+                }
             );
         }
 

From fcb1cd24b5c0bb8e1981dbf70132cedf66b0b512 Mon Sep 17 00:00:00 2001
From: Daniel Maya <daniel.maya@pandorafms.com>
Date: Tue, 18 Oct 2022 11:02:06 +0200
Subject: [PATCH 62/83] #9665 Fixed button

---
 pandora_console/godmode/alerts/alert_commands.php | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php
index bbdd17841e..7b07f583f9 100644
--- a/pandora_console/godmode/alerts/alert_commands.php
+++ b/pandora_console/godmode/alerts/alert_commands.php
@@ -828,7 +828,8 @@ if (isset($data) === true && count($table->data) > 0) {
     );
 }
 
-if ($is_management_allowed === true && check_acl_restricted_all($config['id_user'], $command['id_group'], 'PM')) {
+// Commands can only be created by the super administrator.
+if (users_is_admin() === true) {
     echo '<div class="action-buttons" style="width: '.$table->width.'">';
     echo '<form method="post" action="index.php?sec='.$sec.'&sec2=godmode/alerts/configure_alert_command&pure='.$pure.'">';
     html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');

From 1acb67ecad9dd1ed81f92266fb08c1590514f937 Mon Sep 17 00:00:00 2001
From: Daniel Barbero <daniel.barbero@artica.es>
Date: Tue, 18 Oct 2022 13:40:09 +0200
Subject: [PATCH 63/83] fixed multi selector pandora_enterprise#8620

---
 .../include/lib/Dashboard/Widgets/agent_module.php     | 10 +++++++---
 pandora_console/operation/agentes/ver_agente.php       |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/pandora_console/include/lib/Dashboard/Widgets/agent_module.php b/pandora_console/include/lib/Dashboard/Widgets/agent_module.php
index d4eb582cfc..fbc4165b4d 100644
--- a/pandora_console/include/lib/Dashboard/Widgets/agent_module.php
+++ b/pandora_console/include/lib/Dashboard/Widgets/agent_module.php
@@ -710,9 +710,13 @@ class AgentModuleWidget extends Widget
 
                 if (empty($allModules) === false) {
                     if (is_metaconsole() === true && $this->values['mShowCommonModules'] !== 'on') {
-                        $modules = $agent->searchModules(
-                            ['nombre' => array_keys($reduceAllModules['modules_selected'][$tserver])]
-                        );
+                        if (isset($reduceAllModules['modules_selected'][$tserver]) === true) {
+                            $modules = $agent->searchModules(
+                                ['nombre' => array_keys($reduceAllModules['modules_selected'][$tserver])]
+                            );
+                        } else {
+                            $modules = null;
+                        }
                     } else {
                         $modules = $agent->searchModules(
                             ['nombre' => array_keys($allModules)]
diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php
index d3797d127b..3e296bdeb2 100644
--- a/pandora_console/operation/agentes/ver_agente.php
+++ b/pandora_console/operation/agentes/ver_agente.php
@@ -223,7 +223,7 @@ if (is_ajax()) {
             $id_agents,
             $selection,
             $select_mode,
-            true
+            (bool) !$select_mode
         );
 
         // Clean double safe input.

From f219a9678fb9cfae749be01ed5c6ab36af172540 Mon Sep 17 00:00:00 2001
From: Daniel Barbero <daniel.barbero@artica.es>
Date: Tue, 18 Oct 2022 16:55:05 +0200
Subject: [PATCH 64/83] minor fix 500 pandora_enterprise#9667

---
 pandora_console/include/functions_config.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php
index 2c09175f95..958261274a 100644
--- a/pandora_console/include/functions_config.php
+++ b/pandora_console/include/functions_config.php
@@ -2275,7 +2275,7 @@ function config_process_config()
                     'ifOutDiscards'   => 0,
                     'ifInErrors'      => 0,
                     'ifOutErrors'     => 0,
-                ],
+                ]
             )
         );
     }

From 11df57cd14d0b324b0147f652f6bf8b348d52cbf Mon Sep 17 00:00:00 2001
From: Calvo <luis.calvo@pandorafms.com>
Date: Tue, 18 Oct 2022 19:55:45 +0200
Subject: [PATCH 65/83] Fix planned downtime agent recursion bugs

---
 .../godmode/agentes/planned_downtime.editor.php      | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/pandora_console/godmode/agentes/planned_downtime.editor.php b/pandora_console/godmode/agentes/planned_downtime.editor.php
index fdb8de3b06..ed41aee0ef 100644
--- a/pandora_console/godmode/agentes/planned_downtime.editor.php
+++ b/pandora_console/godmode/agentes/planned_downtime.editor.php
@@ -1397,6 +1397,7 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
     $module_names = (array) get_parameter('module');
     $modules_selection_mode = (string) get_parameter('modules_selection_mode');
     $type_downtime = (string) get_parameter('type_downtime', 'quiet');
+    $recursion = (bool) get_parameter_checkbox('recursion', false);
 
     $all_modules = ($modules_selection_mode === 'all' && (empty($module_names) || (string) $module_names[0] === '0'));
     $all_common_modules = ($modules_selection_mode === 'common' && (empty($module_names) || (string) $module_names[0] === '0'));
@@ -1423,6 +1424,15 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
     } else {
         // If is selected 'Any', get all the agents.
         if (count($agents) === 1 && (int) $agents[0] === -2) {
+            if ($recursion === true) {
+                $filter_group = groups_get_children_ids(
+                    $filter_group,
+                    false,
+                    true,
+                    'AW'
+                );
+            };
+
             $agents = db_get_all_rows_filter(
                 'tagente',
                 ['id_grupo' => $filter_group],
@@ -1886,7 +1896,6 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
         $('input.hasDatepicker[readonly]').disable();
 
         $("#checkbox-recursion").click(function() {
-            recursion = this.checked;
             $("#filter_group").trigger("change");
         });
 
@@ -1896,6 +1905,7 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
         });
 
         function populate_agents_selector() {
+            recursion = $("#checkbox-recursion").prop('checked');
             jQuery.post ("ajax.php",
                 {"page": "operation/agentes/ver_agente",
                     "get_agents_group_json": 1,

From 95c485db38c33b2bcc013511c784c596fc196f60 Mon Sep 17 00:00:00 2001
From: artica <artica.devel@gmail.com>
Date: Wed, 19 Oct 2022 01:00:22 +0200
Subject: [PATCH 66/83] Auto-updated build strings.

---
 pandora_agents/unix/DEBIAN/control             | 2 +-
 pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +-
 pandora_agents/unix/pandora_agent              | 2 +-
 pandora_agents/unix/pandora_agent.redhat.spec  | 2 +-
 pandora_agents/unix/pandora_agent.spec         | 2 +-
 pandora_agents/unix/pandora_agent_installer    | 2 +-
 pandora_agents/win32/installer/pandora.mpi     | 2 +-
 pandora_agents/win32/pandora.cc                | 2 +-
 pandora_agents/win32/versioninfo.rc            | 2 +-
 pandora_console/DEBIAN/control                 | 2 +-
 pandora_console/DEBIAN/make_deb_package.sh     | 2 +-
 pandora_console/include/config_process.php     | 2 +-
 pandora_console/install.php                    | 2 +-
 pandora_console/pandora_console.redhat.spec    | 2 +-
 pandora_console/pandora_console.rhel7.spec     | 2 +-
 pandora_console/pandora_console.spec           | 2 +-
 pandora_server/DEBIAN/control                  | 2 +-
 pandora_server/DEBIAN/make_deb_package.sh      | 2 +-
 pandora_server/lib/PandoraFMS/Config.pm        | 2 +-
 pandora_server/lib/PandoraFMS/PluginTools.pm   | 2 +-
 pandora_server/pandora_server.redhat.spec      | 2 +-
 pandora_server/pandora_server.spec             | 2 +-
 pandora_server/pandora_server_installer        | 2 +-
 pandora_server/util/pandora_db.pl              | 2 +-
 pandora_server/util/pandora_manage.pl          | 2 +-
 25 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control
index 1e38797198..6c10912b2a 100644
--- a/pandora_agents/unix/DEBIAN/control
+++ b/pandora_agents/unix/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-agent-unix
-Version: 7.0NG.765-221018
+Version: 7.0NG.765-221019
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh
index e7662144c6..87f758b280 100644
--- a/pandora_agents/unix/DEBIAN/make_deb_package.sh
+++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221018"
+pandora_version="7.0NG.765-221019"
 
 echo "Test if you has the tools for to make the packages."
 whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent
index bf7572f67c..251f2927d9 100755
--- a/pandora_agents/unix/pandora_agent
+++ b/pandora_agents/unix/pandora_agent
@@ -1015,7 +1015,7 @@ my $Sem = undef;
 my $ThreadSem = undef;
 
 use constant AGENT_VERSION => '7.0NG.765';
-use constant AGENT_BUILD => '221018';
+use constant AGENT_BUILD => '221019';
 
 # Agent log default file size maximum and instances
 use constant DEFAULT_MAX_LOG_SIZE => 600000;
diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec
index 6074ba5280..96deffa71b 100644
--- a/pandora_agents/unix/pandora_agent.redhat.spec
+++ b/pandora_agents/unix/pandora_agent.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221018
+%define release     221019
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec
index b4081b677d..852a055fa3 100644
--- a/pandora_agents/unix/pandora_agent.spec
+++ b/pandora_agents/unix/pandora_agent.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221018
+%define release     221019
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer
index c7c2027a81..72f4314a52 100755
--- a/pandora_agents/unix/pandora_agent_installer
+++ b/pandora_agents/unix/pandora_agent_installer
@@ -10,7 +10,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221018"
+PI_BUILD="221019"
 OS_NAME=`uname -s`
 
 FORCE=0
diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi
index 9af1e6a8c9..604bb2667c 100644
--- a/pandora_agents/win32/installer/pandora.mpi
+++ b/pandora_agents/win32/installer/pandora.mpi
@@ -186,7 +186,7 @@ UpgradeApplicationID
 {}
 
 Version
-{221018}
+{221019}
 
 ViewReadme
 {Yes}
diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc
index 04eea8f5e8..390e62ef5a 100644
--- a/pandora_agents/win32/pandora.cc
+++ b/pandora_agents/win32/pandora.cc
@@ -30,7 +30,7 @@ using namespace Pandora;
 using namespace Pandora_Strutils;
 
 #define PATH_SIZE    _MAX_PATH+1
-#define PANDORA_VERSION ("7.0NG.765 Build 221018")
+#define PANDORA_VERSION ("7.0NG.765 Build 221019")
 
 string pandora_path;
 string pandora_dir;
diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc
index 3192279b81..bf75355b5e 100644
--- a/pandora_agents/win32/versioninfo.rc
+++ b/pandora_agents/win32/versioninfo.rc
@@ -11,7 +11,7 @@ BEGIN
       VALUE "LegalCopyright", "Artica ST"
       VALUE "OriginalFilename", "PandoraAgent.exe"
       VALUE "ProductName", "Pandora FMS Windows Agent"
-      VALUE "ProductVersion", "(7.0NG.765(Build 221018))"
+      VALUE "ProductVersion", "(7.0NG.765(Build 221019))"
       VALUE "FileVersion", "1.0.0.0"
     END
   END
diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control
index fce3f648cf..fda0595bec 100644
--- a/pandora_console/DEBIAN/control
+++ b/pandora_console/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-console
-Version: 7.0NG.765-221018
+Version: 7.0NG.765-221019
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh
index bb0fe38433..33353a7eba 100644
--- a/pandora_console/DEBIAN/make_deb_package.sh
+++ b/pandora_console/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221018"
+pandora_version="7.0NG.765-221019"
 
 package_pear=0
 package_pandora=1
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index 28a11a0f1c..f5e5c0b3f4 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -20,7 +20,7 @@
 /**
  * Pandora build version and version
  */
-$build_version = 'PC221018';
+$build_version = 'PC221019';
 $pandora_version = 'v7.0NG.765';
 
 // Do not overwrite default timezone set if defined.
diff --git a/pandora_console/install.php b/pandora_console/install.php
index 0d925f107e..1ac6341e29 100644
--- a/pandora_console/install.php
+++ b/pandora_console/install.php
@@ -129,7 +129,7 @@
         <div style='height: 10px'>
             <?php
             $version = '7.0NG.765';
-            $build = '221018';
+            $build = '221019';
             $banner = "v$version Build $build";
 
             error_reporting(0);
diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec
index 5afb98159f..f2b471dd1c 100644
--- a/pandora_console/pandora_console.redhat.spec
+++ b/pandora_console/pandora_console.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221018
+%define release     221019
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec
index 21ddaf5adc..9aebbb348c 100644
--- a/pandora_console/pandora_console.rhel7.spec
+++ b/pandora_console/pandora_console.rhel7.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221018
+%define release     221019
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec
index 503fc0383b..6de7cfcfe9 100644
--- a/pandora_console/pandora_console.spec
+++ b/pandora_console/pandora_console.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221018
+%define release     221019
 %define httpd_name      httpd
 # User and Group under which Apache is running
 %define httpd_name  apache2
diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control
index bbcc24efdf..05c44b5d78 100644
--- a/pandora_server/DEBIAN/control
+++ b/pandora_server/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-server
-Version: 7.0NG.765-221018
+Version: 7.0NG.765-221019
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh
index 4dab9e00b9..65d47aabd2 100644
--- a/pandora_server/DEBIAN/make_deb_package.sh
+++ b/pandora_server/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221018"
+pandora_version="7.0NG.765-221019"
 
 package_cpan=0
 package_pandora=1
diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm
index acf6f53651..5e6bd174ea 100644
--- a/pandora_server/lib/PandoraFMS/Config.pm
+++ b/pandora_server/lib/PandoraFMS/Config.pm
@@ -46,7 +46,7 @@ our @EXPORT = qw(
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221018";
+my $pandora_build = "221019";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 # Setup hash
diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm
index a0d72e02cf..45afe175cf 100644
--- a/pandora_server/lib/PandoraFMS/PluginTools.pm
+++ b/pandora_server/lib/PandoraFMS/PluginTools.pm
@@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221018";
+my $pandora_build = "221019";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 our %EXPORT_TAGS = ( 'all' => [ qw() ] );
diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec
index cfcfd49b42..4d353aa645 100644
--- a/pandora_server/pandora_server.redhat.spec
+++ b/pandora_server/pandora_server.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221018
+%define release     221019
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec
index d90c6cf9fc..5fe2628d7b 100644
--- a/pandora_server/pandora_server.spec
+++ b/pandora_server/pandora_server.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221018
+%define release     221019
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer
index 52487caa93..f7207abc6d 100755
--- a/pandora_server/pandora_server_installer
+++ b/pandora_server/pandora_server_installer
@@ -9,7 +9,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221018"
+PI_BUILD="221019"
 
 MODE=$1
 if [ $# -gt 1 ]; then
diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl
index e4a5c8b726..6e5894d446 100755
--- a/pandora_server/util/pandora_db.pl
+++ b/pandora_server/util/pandora_db.pl
@@ -35,7 +35,7 @@ use PandoraFMS::Config;
 use PandoraFMS::DB;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221018";
+my $version = "7.0NG.765 Build 221019";
 
 # Pandora server configuration
 my %conf;
diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index eaa333102e..4a5d03f7da 100755
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -36,7 +36,7 @@ use Encode::Locale;
 Encode::Locale::decode_argv;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221018";
+my $version = "7.0NG.765 Build 221019";
 
 # save program name for logging
 my $progname = basename($0);

From 6ef3505eab8bb253a2f5356e9ec91b861f409290 Mon Sep 17 00:00:00 2001
From: Daniel Barbero <daniel.barbero@artica.es>
Date: Wed, 19 Oct 2022 16:20:49 +0200
Subject: [PATCH 67/83] event multiple operations pandora_enterprise#9671

---
 .../include/javascript/pandora_events.js           |  6 +++---
 pandora_console/operation/events/events.php        | 14 ++++++++++++--
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js
index f4cd5f6e2b..df84985a37 100644
--- a/pandora_console/include/javascript/pandora_events.js
+++ b/pandora_console/include/javascript/pandora_events.js
@@ -707,7 +707,7 @@ function execute_event_response(event_list_btn) {
               }
 
               in_process_event(
-                "events",
+                "table_events",
                 event_id,
                 $(this).attr("event_rep"),
                 this.parentElement.parentElement,
@@ -727,7 +727,7 @@ function execute_event_response(event_list_btn) {
               }
 
               validate_event(
-                "events",
+                "table_events",
                 event_id,
                 $(this).attr("event_rep"),
                 this.parentElement.parentElement,
@@ -747,7 +747,7 @@ function execute_event_response(event_list_btn) {
               }
 
               execute_delete_event_reponse(
-                "events",
+                "table_events",
                 event_id,
                 $(this).attr("event_rep"),
                 this.parentElement.parentElement,
diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php
index cf7c6b9a54..e0a826cef8 100644
--- a/pandora_console/operation/events/events.php
+++ b/pandora_console/operation/events/events.php
@@ -1445,7 +1445,7 @@ if ($pure) {
     ).'</a>';
 
     // If the user has administrator permission display manage tab.
-    if ($event_w || $event_m) {
+    if ($event_w === true || $event_m === true) {
         // Manage events.
         $manage_events['active'] = false;
         $manage_events['text'] = '<a href="index.php?sec=eventos&sec2=godmode/events/events&amp;section=filter&amp;pure='.$config['pure'].'">'.html_print_image(
@@ -1771,7 +1771,7 @@ $buttons[] = [
     'onclick' => '',
 ];
 
-if ($event_w || $event_m) {
+if ($event_w === true || $event_m === true) {
     $buttons[] = [
         'id'      => 'save-filter',
         'class'   => 'float-left margin-right-2 sub wand',
@@ -2395,6 +2395,16 @@ if (is_user_admin($config['id_user'])) {
     );
 }
 
+$array_events_actions = [];
+if ($event_w === true && $readonly === false) {
+    $array_events_actions['in_progress_selected'] = __('In progress selected');
+    $array_events_actions['validate_selected'] = __('Validate selected');
+}
+
+if ($event_m === true && $readonly === false) {
+    $array_events_actions['delete_selected'] = __('Delete selected');
+}
+
 foreach ($event_responses as $val) {
     $array_events_actions[$val['id']] = $val['name'];
 }

From d707c29110ca13fec7aa1f8c2119a0dd90a6de17 Mon Sep 17 00:00:00 2001
From: "alejandro.campos@artica.es" <alejandro.campos@artica.es>
Date: Wed, 19 Oct 2022 16:46:07 +0200
Subject: [PATCH 68/83] minor fix

---
 pandora_console/ajax.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/ajax.php b/pandora_console/ajax.php
index 4139117364..bea9dfc771 100644
--- a/pandora_console/ajax.php
+++ b/pandora_console/ajax.php
@@ -116,7 +116,7 @@ $public_login = false;
 
 
 if (false === ((bool) get_parameter('doLogin', false) === true
-    && $page === 'include/rest-api/index.php')
+    && $page === realpath('include/rest-api/index.php'))
 ) {
     // Check user.
     if (class_exists($auth_class) === false || $public_hash === false) {

From f87737a0933feb0b16f12a93d004cbdfb0df75bb Mon Sep 17 00:00:00 2001
From: "alejandro.campos@artica.es" <alejandro.campos@artica.es>
Date: Wed, 19 Oct 2022 17:07:22 +0200
Subject: [PATCH 69/83] minor fix

---
 pandora_console/include/lib/User.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/include/lib/User.php b/pandora_console/include/lib/User.php
index 45605e9abe..227bb77c91 100644
--- a/pandora_console/include/lib/User.php
+++ b/pandora_console/include/lib/User.php
@@ -128,7 +128,7 @@ class User implements PublicLogin
     {
         $user = new self($data);
 
-        if ($user === null) {
+        if ($user->idUser === null) {
             return false;
         }
 

From 17a87392e3588878e1e5202926d7de2e1a576cb4 Mon Sep 17 00:00:00 2001
From: "alejandro.campos@artica.es" <alejandro.campos@artica.es>
Date: Wed, 19 Oct 2022 18:38:27 +0200
Subject: [PATCH 70/83] minor fix

---
 pandora_console/include/lib/Core/Config.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/include/lib/Core/Config.php b/pandora_console/include/lib/Core/Config.php
index 43d1ff7cc1..656d68f9f2 100644
--- a/pandora_console/include/lib/Core/Config.php
+++ b/pandora_console/include/lib/Core/Config.php
@@ -69,7 +69,7 @@ final class Config
             $link->options(MYSQLI_OPT_CONNECT_TIMEOUT, 2);
             $rc = mysqli_real_connect(
                 $link,
-                $$config['history_db_host'],
+                $config['history_db_host'],
                 $config['history_db_user'],
                 io_output_password($config['history_db_pass']),
                 $config['history_db_name'],

From 61b3bc724a2e9b30f9caedbdd1c1d5e893bfe8ff Mon Sep 17 00:00:00 2001
From: artica <artica.devel@gmail.com>
Date: Thu, 20 Oct 2022 01:00:21 +0200
Subject: [PATCH 71/83] Auto-updated build strings.

---
 pandora_agents/unix/DEBIAN/control             | 2 +-
 pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +-
 pandora_agents/unix/pandora_agent              | 2 +-
 pandora_agents/unix/pandora_agent.redhat.spec  | 2 +-
 pandora_agents/unix/pandora_agent.spec         | 2 +-
 pandora_agents/unix/pandora_agent_installer    | 2 +-
 pandora_agents/win32/installer/pandora.mpi     | 2 +-
 pandora_agents/win32/pandora.cc                | 2 +-
 pandora_agents/win32/versioninfo.rc            | 2 +-
 pandora_console/DEBIAN/control                 | 2 +-
 pandora_console/DEBIAN/make_deb_package.sh     | 2 +-
 pandora_console/include/config_process.php     | 2 +-
 pandora_console/install.php                    | 2 +-
 pandora_console/pandora_console.redhat.spec    | 2 +-
 pandora_console/pandora_console.rhel7.spec     | 2 +-
 pandora_console/pandora_console.spec           | 2 +-
 pandora_server/DEBIAN/control                  | 2 +-
 pandora_server/DEBIAN/make_deb_package.sh      | 2 +-
 pandora_server/lib/PandoraFMS/Config.pm        | 2 +-
 pandora_server/lib/PandoraFMS/PluginTools.pm   | 2 +-
 pandora_server/pandora_server.redhat.spec      | 2 +-
 pandora_server/pandora_server.spec             | 2 +-
 pandora_server/pandora_server_installer        | 2 +-
 pandora_server/util/pandora_db.pl              | 2 +-
 pandora_server/util/pandora_manage.pl          | 2 +-
 25 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control
index 6c10912b2a..6f0ae93823 100644
--- a/pandora_agents/unix/DEBIAN/control
+++ b/pandora_agents/unix/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-agent-unix
-Version: 7.0NG.765-221019
+Version: 7.0NG.765-221020
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh
index 87f758b280..6cabe80795 100644
--- a/pandora_agents/unix/DEBIAN/make_deb_package.sh
+++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221019"
+pandora_version="7.0NG.765-221020"
 
 echo "Test if you has the tools for to make the packages."
 whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent
index 251f2927d9..f2231c3a22 100755
--- a/pandora_agents/unix/pandora_agent
+++ b/pandora_agents/unix/pandora_agent
@@ -1015,7 +1015,7 @@ my $Sem = undef;
 my $ThreadSem = undef;
 
 use constant AGENT_VERSION => '7.0NG.765';
-use constant AGENT_BUILD => '221019';
+use constant AGENT_BUILD => '221020';
 
 # Agent log default file size maximum and instances
 use constant DEFAULT_MAX_LOG_SIZE => 600000;
diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec
index 96deffa71b..0df77e7444 100644
--- a/pandora_agents/unix/pandora_agent.redhat.spec
+++ b/pandora_agents/unix/pandora_agent.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221019
+%define release     221020
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec
index 852a055fa3..d4e1993594 100644
--- a/pandora_agents/unix/pandora_agent.spec
+++ b/pandora_agents/unix/pandora_agent.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221019
+%define release     221020
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer
index 72f4314a52..745ce5ca0a 100755
--- a/pandora_agents/unix/pandora_agent_installer
+++ b/pandora_agents/unix/pandora_agent_installer
@@ -10,7 +10,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221019"
+PI_BUILD="221020"
 OS_NAME=`uname -s`
 
 FORCE=0
diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi
index 604bb2667c..8ae5743490 100644
--- a/pandora_agents/win32/installer/pandora.mpi
+++ b/pandora_agents/win32/installer/pandora.mpi
@@ -186,7 +186,7 @@ UpgradeApplicationID
 {}
 
 Version
-{221019}
+{221020}
 
 ViewReadme
 {Yes}
diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc
index 390e62ef5a..0072c2f178 100644
--- a/pandora_agents/win32/pandora.cc
+++ b/pandora_agents/win32/pandora.cc
@@ -30,7 +30,7 @@ using namespace Pandora;
 using namespace Pandora_Strutils;
 
 #define PATH_SIZE    _MAX_PATH+1
-#define PANDORA_VERSION ("7.0NG.765 Build 221019")
+#define PANDORA_VERSION ("7.0NG.765 Build 221020")
 
 string pandora_path;
 string pandora_dir;
diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc
index bf75355b5e..8b3317b378 100644
--- a/pandora_agents/win32/versioninfo.rc
+++ b/pandora_agents/win32/versioninfo.rc
@@ -11,7 +11,7 @@ BEGIN
       VALUE "LegalCopyright", "Artica ST"
       VALUE "OriginalFilename", "PandoraAgent.exe"
       VALUE "ProductName", "Pandora FMS Windows Agent"
-      VALUE "ProductVersion", "(7.0NG.765(Build 221019))"
+      VALUE "ProductVersion", "(7.0NG.765(Build 221020))"
       VALUE "FileVersion", "1.0.0.0"
     END
   END
diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control
index fda0595bec..1c311e17d2 100644
--- a/pandora_console/DEBIAN/control
+++ b/pandora_console/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-console
-Version: 7.0NG.765-221019
+Version: 7.0NG.765-221020
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh
index 33353a7eba..27051ef7a3 100644
--- a/pandora_console/DEBIAN/make_deb_package.sh
+++ b/pandora_console/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221019"
+pandora_version="7.0NG.765-221020"
 
 package_pear=0
 package_pandora=1
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index f5e5c0b3f4..028f9233b3 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -20,7 +20,7 @@
 /**
  * Pandora build version and version
  */
-$build_version = 'PC221019';
+$build_version = 'PC221020';
 $pandora_version = 'v7.0NG.765';
 
 // Do not overwrite default timezone set if defined.
diff --git a/pandora_console/install.php b/pandora_console/install.php
index 1ac6341e29..1780552970 100644
--- a/pandora_console/install.php
+++ b/pandora_console/install.php
@@ -129,7 +129,7 @@
         <div style='height: 10px'>
             <?php
             $version = '7.0NG.765';
-            $build = '221019';
+            $build = '221020';
             $banner = "v$version Build $build";
 
             error_reporting(0);
diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec
index f2b471dd1c..1635e52c46 100644
--- a/pandora_console/pandora_console.redhat.spec
+++ b/pandora_console/pandora_console.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221019
+%define release     221020
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec
index 9aebbb348c..80ea5992aa 100644
--- a/pandora_console/pandora_console.rhel7.spec
+++ b/pandora_console/pandora_console.rhel7.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221019
+%define release     221020
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec
index 6de7cfcfe9..69771af3fc 100644
--- a/pandora_console/pandora_console.spec
+++ b/pandora_console/pandora_console.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221019
+%define release     221020
 %define httpd_name      httpd
 # User and Group under which Apache is running
 %define httpd_name  apache2
diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control
index 05c44b5d78..3d5f4ca340 100644
--- a/pandora_server/DEBIAN/control
+++ b/pandora_server/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-server
-Version: 7.0NG.765-221019
+Version: 7.0NG.765-221020
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh
index 65d47aabd2..0afba6aa82 100644
--- a/pandora_server/DEBIAN/make_deb_package.sh
+++ b/pandora_server/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221019"
+pandora_version="7.0NG.765-221020"
 
 package_cpan=0
 package_pandora=1
diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm
index 5e6bd174ea..e6e081eb24 100644
--- a/pandora_server/lib/PandoraFMS/Config.pm
+++ b/pandora_server/lib/PandoraFMS/Config.pm
@@ -46,7 +46,7 @@ our @EXPORT = qw(
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221019";
+my $pandora_build = "221020";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 # Setup hash
diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm
index 45afe175cf..01c97863e0 100644
--- a/pandora_server/lib/PandoraFMS/PluginTools.pm
+++ b/pandora_server/lib/PandoraFMS/PluginTools.pm
@@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221019";
+my $pandora_build = "221020";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 our %EXPORT_TAGS = ( 'all' => [ qw() ] );
diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec
index 4d353aa645..8aaaab57bd 100644
--- a/pandora_server/pandora_server.redhat.spec
+++ b/pandora_server/pandora_server.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221019
+%define release     221020
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec
index 5fe2628d7b..96b1230370 100644
--- a/pandora_server/pandora_server.spec
+++ b/pandora_server/pandora_server.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221019
+%define release     221020
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer
index f7207abc6d..47b34f86f3 100755
--- a/pandora_server/pandora_server_installer
+++ b/pandora_server/pandora_server_installer
@@ -9,7 +9,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221019"
+PI_BUILD="221020"
 
 MODE=$1
 if [ $# -gt 1 ]; then
diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl
index 6e5894d446..3e55eb4e49 100755
--- a/pandora_server/util/pandora_db.pl
+++ b/pandora_server/util/pandora_db.pl
@@ -35,7 +35,7 @@ use PandoraFMS::Config;
 use PandoraFMS::DB;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221019";
+my $version = "7.0NG.765 Build 221020";
 
 # Pandora server configuration
 my %conf;
diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index 4a5d03f7da..3c922d8e59 100755
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -36,7 +36,7 @@ use Encode::Locale;
 Encode::Locale::decode_argv;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221019";
+my $version = "7.0NG.765 Build 221020";
 
 # save program name for logging
 my $progname = basename($0);

From 89bd5ec22ca0699c173c329e84d5d91685669566 Mon Sep 17 00:00:00 2001
From: Daniel Maya <daniel.maya@pandorafms.com>
Date: Thu, 20 Oct 2022 10:42:27 +0200
Subject: [PATCH 72/83] #9665 Fixed button 2

---
 pandora_console/godmode/alerts/alert_commands.php | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php
index 7b07f583f9..121828de32 100644
--- a/pandora_console/godmode/alerts/alert_commands.php
+++ b/pandora_console/godmode/alerts/alert_commands.php
@@ -797,11 +797,7 @@ foreach ($commands as $command) {
 
     // (IMPORTANT, DO NOT CHANGE!) only users with permissions over "All" group have access to edition of commands belonging to "All" group.
     if ($is_management_allowed === true && !$command['internal'] && check_acl_restricted_all($config['id_user'], $command['id_group'], 'LM')) {
-        if (check_acl($config['id_user'], 0, 'PM') || is_user_admin(
-            $config['id_user
-            ']
-        )
-        ) {
+        if (is_user_admin($config['id_user']) === true) {
                     $data['action'] = '<span class="inline_flex">';
             $data['action'] .= '<a href="index.php?sec='.$sec.'&sec2=godmode/alerts/alert_commands&amp;copy_command=1&id='.$command['id'].'&pure='.$pure.'"
             onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/copy.png', true, ['class' => 'invert_filter']).'</a>';

From 2d71c75405ab2e7af87371d7b9072c789c0aeb70 Mon Sep 17 00:00:00 2001
From: Calvo <luis.calvo@pandorafms.com>
Date: Thu, 20 Oct 2022 13:42:08 +0200
Subject: [PATCH 73/83] Added title to printFormAsGrid

---
 pandora_console/include/class/HTML.class.php | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/pandora_console/include/class/HTML.class.php b/pandora_console/include/class/HTML.class.php
index da6e63285a..e47aa40b7c 100644
--- a/pandora_console/include/class/HTML.class.php
+++ b/pandora_console/include/class/HTML.class.php
@@ -935,6 +935,12 @@ class HTML
         $output_head = '<form class="discovery" onsubmit="'.$form['onsubmit'].'"  enctype="'.$form['enctype'].'" action="'.$form['action'].'" method="'.$form['method'];
         $output_head .= '" id="'.$form['id'].'" '.$form['extra'].'>';
 
+        if (isset($form['title']) === true && empty($form['title']) === false) {
+            $output_head .= '<div class="form_title"">';
+            $output_head .= '<span>'.$form['title'].'</span>';
+            $output_head .= '</div>';
+        }
+
         if ($return === false) {
             echo $output_head;
         }

From e31699eed7a92923e20917208807ba34878e989f Mon Sep 17 00:00:00 2001
From: artica <artica.devel@gmail.com>
Date: Fri, 21 Oct 2022 01:00:25 +0200
Subject: [PATCH 74/83] Auto-updated build strings.

---
 pandora_agents/unix/DEBIAN/control             | 2 +-
 pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +-
 pandora_agents/unix/pandora_agent              | 2 +-
 pandora_agents/unix/pandora_agent.redhat.spec  | 2 +-
 pandora_agents/unix/pandora_agent.spec         | 2 +-
 pandora_agents/unix/pandora_agent_installer    | 2 +-
 pandora_agents/win32/installer/pandora.mpi     | 2 +-
 pandora_agents/win32/pandora.cc                | 2 +-
 pandora_agents/win32/versioninfo.rc            | 2 +-
 pandora_console/DEBIAN/control                 | 2 +-
 pandora_console/DEBIAN/make_deb_package.sh     | 2 +-
 pandora_console/include/config_process.php     | 2 +-
 pandora_console/install.php                    | 2 +-
 pandora_console/pandora_console.redhat.spec    | 2 +-
 pandora_console/pandora_console.rhel7.spec     | 2 +-
 pandora_console/pandora_console.spec           | 2 +-
 pandora_server/DEBIAN/control                  | 2 +-
 pandora_server/DEBIAN/make_deb_package.sh      | 2 +-
 pandora_server/lib/PandoraFMS/Config.pm        | 2 +-
 pandora_server/lib/PandoraFMS/PluginTools.pm   | 2 +-
 pandora_server/pandora_server.redhat.spec      | 2 +-
 pandora_server/pandora_server.spec             | 2 +-
 pandora_server/pandora_server_installer        | 2 +-
 pandora_server/util/pandora_db.pl              | 2 +-
 pandora_server/util/pandora_manage.pl          | 2 +-
 25 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control
index 6f0ae93823..eec5ecd976 100644
--- a/pandora_agents/unix/DEBIAN/control
+++ b/pandora_agents/unix/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-agent-unix
-Version: 7.0NG.765-221020
+Version: 7.0NG.765-221021
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh
index 6cabe80795..14364bf96c 100644
--- a/pandora_agents/unix/DEBIAN/make_deb_package.sh
+++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221020"
+pandora_version="7.0NG.765-221021"
 
 echo "Test if you has the tools for to make the packages."
 whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent
index f2231c3a22..45d3a02f54 100755
--- a/pandora_agents/unix/pandora_agent
+++ b/pandora_agents/unix/pandora_agent
@@ -1015,7 +1015,7 @@ my $Sem = undef;
 my $ThreadSem = undef;
 
 use constant AGENT_VERSION => '7.0NG.765';
-use constant AGENT_BUILD => '221020';
+use constant AGENT_BUILD => '221021';
 
 # Agent log default file size maximum and instances
 use constant DEFAULT_MAX_LOG_SIZE => 600000;
diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec
index 0df77e7444..a7b0a826e2 100644
--- a/pandora_agents/unix/pandora_agent.redhat.spec
+++ b/pandora_agents/unix/pandora_agent.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221020
+%define release     221021
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec
index d4e1993594..1322e44c56 100644
--- a/pandora_agents/unix/pandora_agent.spec
+++ b/pandora_agents/unix/pandora_agent.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221020
+%define release     221021
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer
index 745ce5ca0a..20a4e8d08a 100755
--- a/pandora_agents/unix/pandora_agent_installer
+++ b/pandora_agents/unix/pandora_agent_installer
@@ -10,7 +10,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221020"
+PI_BUILD="221021"
 OS_NAME=`uname -s`
 
 FORCE=0
diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi
index 8ae5743490..bcd15bf4ce 100644
--- a/pandora_agents/win32/installer/pandora.mpi
+++ b/pandora_agents/win32/installer/pandora.mpi
@@ -186,7 +186,7 @@ UpgradeApplicationID
 {}
 
 Version
-{221020}
+{221021}
 
 ViewReadme
 {Yes}
diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc
index 0072c2f178..6533e881df 100644
--- a/pandora_agents/win32/pandora.cc
+++ b/pandora_agents/win32/pandora.cc
@@ -30,7 +30,7 @@ using namespace Pandora;
 using namespace Pandora_Strutils;
 
 #define PATH_SIZE    _MAX_PATH+1
-#define PANDORA_VERSION ("7.0NG.765 Build 221020")
+#define PANDORA_VERSION ("7.0NG.765 Build 221021")
 
 string pandora_path;
 string pandora_dir;
diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc
index 8b3317b378..47970d4802 100644
--- a/pandora_agents/win32/versioninfo.rc
+++ b/pandora_agents/win32/versioninfo.rc
@@ -11,7 +11,7 @@ BEGIN
       VALUE "LegalCopyright", "Artica ST"
       VALUE "OriginalFilename", "PandoraAgent.exe"
       VALUE "ProductName", "Pandora FMS Windows Agent"
-      VALUE "ProductVersion", "(7.0NG.765(Build 221020))"
+      VALUE "ProductVersion", "(7.0NG.765(Build 221021))"
       VALUE "FileVersion", "1.0.0.0"
     END
   END
diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control
index 1c311e17d2..a380cabfce 100644
--- a/pandora_console/DEBIAN/control
+++ b/pandora_console/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-console
-Version: 7.0NG.765-221020
+Version: 7.0NG.765-221021
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh
index 27051ef7a3..525832db0f 100644
--- a/pandora_console/DEBIAN/make_deb_package.sh
+++ b/pandora_console/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221020"
+pandora_version="7.0NG.765-221021"
 
 package_pear=0
 package_pandora=1
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index 028f9233b3..3984581598 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -20,7 +20,7 @@
 /**
  * Pandora build version and version
  */
-$build_version = 'PC221020';
+$build_version = 'PC221021';
 $pandora_version = 'v7.0NG.765';
 
 // Do not overwrite default timezone set if defined.
diff --git a/pandora_console/install.php b/pandora_console/install.php
index 1780552970..dd63ef5f09 100644
--- a/pandora_console/install.php
+++ b/pandora_console/install.php
@@ -129,7 +129,7 @@
         <div style='height: 10px'>
             <?php
             $version = '7.0NG.765';
-            $build = '221020';
+            $build = '221021';
             $banner = "v$version Build $build";
 
             error_reporting(0);
diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec
index 1635e52c46..8791c52dff 100644
--- a/pandora_console/pandora_console.redhat.spec
+++ b/pandora_console/pandora_console.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221020
+%define release     221021
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec
index 80ea5992aa..5d13a36ffb 100644
--- a/pandora_console/pandora_console.rhel7.spec
+++ b/pandora_console/pandora_console.rhel7.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221020
+%define release     221021
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec
index 69771af3fc..407a16c9bc 100644
--- a/pandora_console/pandora_console.spec
+++ b/pandora_console/pandora_console.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221020
+%define release     221021
 %define httpd_name      httpd
 # User and Group under which Apache is running
 %define httpd_name  apache2
diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control
index 3d5f4ca340..c43a723d23 100644
--- a/pandora_server/DEBIAN/control
+++ b/pandora_server/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-server
-Version: 7.0NG.765-221020
+Version: 7.0NG.765-221021
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh
index 0afba6aa82..90a561094c 100644
--- a/pandora_server/DEBIAN/make_deb_package.sh
+++ b/pandora_server/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221020"
+pandora_version="7.0NG.765-221021"
 
 package_cpan=0
 package_pandora=1
diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm
index e6e081eb24..7d8a1ae579 100644
--- a/pandora_server/lib/PandoraFMS/Config.pm
+++ b/pandora_server/lib/PandoraFMS/Config.pm
@@ -46,7 +46,7 @@ our @EXPORT = qw(
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221020";
+my $pandora_build = "221021";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 # Setup hash
diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm
index 01c97863e0..49bad52416 100644
--- a/pandora_server/lib/PandoraFMS/PluginTools.pm
+++ b/pandora_server/lib/PandoraFMS/PluginTools.pm
@@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221020";
+my $pandora_build = "221021";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 our %EXPORT_TAGS = ( 'all' => [ qw() ] );
diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec
index 8aaaab57bd..4f7a118b77 100644
--- a/pandora_server/pandora_server.redhat.spec
+++ b/pandora_server/pandora_server.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221020
+%define release     221021
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec
index 96b1230370..f9b690f41c 100644
--- a/pandora_server/pandora_server.spec
+++ b/pandora_server/pandora_server.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221020
+%define release     221021
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer
index 47b34f86f3..dd87c2a4d4 100755
--- a/pandora_server/pandora_server_installer
+++ b/pandora_server/pandora_server_installer
@@ -9,7 +9,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221020"
+PI_BUILD="221021"
 
 MODE=$1
 if [ $# -gt 1 ]; then
diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl
index 3e55eb4e49..2ba7f416aa 100755
--- a/pandora_server/util/pandora_db.pl
+++ b/pandora_server/util/pandora_db.pl
@@ -35,7 +35,7 @@ use PandoraFMS::Config;
 use PandoraFMS::DB;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221020";
+my $version = "7.0NG.765 Build 221021";
 
 # Pandora server configuration
 my %conf;
diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index 3c922d8e59..31c8238c9a 100755
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -36,7 +36,7 @@ use Encode::Locale;
 Encode::Locale::decode_argv;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221020";
+my $version = "7.0NG.765 Build 221021";
 
 # save program name for logging
 my $progname = basename($0);

From 4118f7656b3fae51a457089ff74e623deed384fd Mon Sep 17 00:00:00 2001
From: artica <artica.devel@gmail.com>
Date: Sat, 22 Oct 2022 01:00:24 +0200
Subject: [PATCH 75/83] Auto-updated build strings.

---
 pandora_agents/unix/DEBIAN/control             | 2 +-
 pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +-
 pandora_agents/unix/pandora_agent              | 2 +-
 pandora_agents/unix/pandora_agent.redhat.spec  | 2 +-
 pandora_agents/unix/pandora_agent.spec         | 2 +-
 pandora_agents/unix/pandora_agent_installer    | 2 +-
 pandora_agents/win32/installer/pandora.mpi     | 2 +-
 pandora_agents/win32/pandora.cc                | 2 +-
 pandora_agents/win32/versioninfo.rc            | 2 +-
 pandora_console/DEBIAN/control                 | 2 +-
 pandora_console/DEBIAN/make_deb_package.sh     | 2 +-
 pandora_console/include/config_process.php     | 2 +-
 pandora_console/install.php                    | 2 +-
 pandora_console/pandora_console.redhat.spec    | 2 +-
 pandora_console/pandora_console.rhel7.spec     | 2 +-
 pandora_console/pandora_console.spec           | 2 +-
 pandora_server/DEBIAN/control                  | 2 +-
 pandora_server/DEBIAN/make_deb_package.sh      | 2 +-
 pandora_server/lib/PandoraFMS/Config.pm        | 2 +-
 pandora_server/lib/PandoraFMS/PluginTools.pm   | 2 +-
 pandora_server/pandora_server.redhat.spec      | 2 +-
 pandora_server/pandora_server.spec             | 2 +-
 pandora_server/pandora_server_installer        | 2 +-
 pandora_server/util/pandora_db.pl              | 2 +-
 pandora_server/util/pandora_manage.pl          | 2 +-
 25 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control
index eec5ecd976..bbca5727f2 100644
--- a/pandora_agents/unix/DEBIAN/control
+++ b/pandora_agents/unix/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-agent-unix
-Version: 7.0NG.765-221021
+Version: 7.0NG.765-221022
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh
index 14364bf96c..53f4a1d9e0 100644
--- a/pandora_agents/unix/DEBIAN/make_deb_package.sh
+++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221021"
+pandora_version="7.0NG.765-221022"
 
 echo "Test if you has the tools for to make the packages."
 whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent
index 45d3a02f54..226864239d 100755
--- a/pandora_agents/unix/pandora_agent
+++ b/pandora_agents/unix/pandora_agent
@@ -1015,7 +1015,7 @@ my $Sem = undef;
 my $ThreadSem = undef;
 
 use constant AGENT_VERSION => '7.0NG.765';
-use constant AGENT_BUILD => '221021';
+use constant AGENT_BUILD => '221022';
 
 # Agent log default file size maximum and instances
 use constant DEFAULT_MAX_LOG_SIZE => 600000;
diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec
index a7b0a826e2..64cebc8ffe 100644
--- a/pandora_agents/unix/pandora_agent.redhat.spec
+++ b/pandora_agents/unix/pandora_agent.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221021
+%define release     221022
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec
index 1322e44c56..ae6a67c85e 100644
--- a/pandora_agents/unix/pandora_agent.spec
+++ b/pandora_agents/unix/pandora_agent.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221021
+%define release     221022
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer
index 20a4e8d08a..8483573019 100755
--- a/pandora_agents/unix/pandora_agent_installer
+++ b/pandora_agents/unix/pandora_agent_installer
@@ -10,7 +10,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221021"
+PI_BUILD="221022"
 OS_NAME=`uname -s`
 
 FORCE=0
diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi
index bcd15bf4ce..fddfc174c5 100644
--- a/pandora_agents/win32/installer/pandora.mpi
+++ b/pandora_agents/win32/installer/pandora.mpi
@@ -186,7 +186,7 @@ UpgradeApplicationID
 {}
 
 Version
-{221021}
+{221022}
 
 ViewReadme
 {Yes}
diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc
index 6533e881df..e4fcda3aef 100644
--- a/pandora_agents/win32/pandora.cc
+++ b/pandora_agents/win32/pandora.cc
@@ -30,7 +30,7 @@ using namespace Pandora;
 using namespace Pandora_Strutils;
 
 #define PATH_SIZE    _MAX_PATH+1
-#define PANDORA_VERSION ("7.0NG.765 Build 221021")
+#define PANDORA_VERSION ("7.0NG.765 Build 221022")
 
 string pandora_path;
 string pandora_dir;
diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc
index 47970d4802..40c320f331 100644
--- a/pandora_agents/win32/versioninfo.rc
+++ b/pandora_agents/win32/versioninfo.rc
@@ -11,7 +11,7 @@ BEGIN
       VALUE "LegalCopyright", "Artica ST"
       VALUE "OriginalFilename", "PandoraAgent.exe"
       VALUE "ProductName", "Pandora FMS Windows Agent"
-      VALUE "ProductVersion", "(7.0NG.765(Build 221021))"
+      VALUE "ProductVersion", "(7.0NG.765(Build 221022))"
       VALUE "FileVersion", "1.0.0.0"
     END
   END
diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control
index a380cabfce..2b149dc615 100644
--- a/pandora_console/DEBIAN/control
+++ b/pandora_console/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-console
-Version: 7.0NG.765-221021
+Version: 7.0NG.765-221022
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh
index 525832db0f..7a694ce3dc 100644
--- a/pandora_console/DEBIAN/make_deb_package.sh
+++ b/pandora_console/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221021"
+pandora_version="7.0NG.765-221022"
 
 package_pear=0
 package_pandora=1
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index 3984581598..535ba720d9 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -20,7 +20,7 @@
 /**
  * Pandora build version and version
  */
-$build_version = 'PC221021';
+$build_version = 'PC221022';
 $pandora_version = 'v7.0NG.765';
 
 // Do not overwrite default timezone set if defined.
diff --git a/pandora_console/install.php b/pandora_console/install.php
index dd63ef5f09..7ec5663045 100644
--- a/pandora_console/install.php
+++ b/pandora_console/install.php
@@ -129,7 +129,7 @@
         <div style='height: 10px'>
             <?php
             $version = '7.0NG.765';
-            $build = '221021';
+            $build = '221022';
             $banner = "v$version Build $build";
 
             error_reporting(0);
diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec
index 8791c52dff..4a023f31ca 100644
--- a/pandora_console/pandora_console.redhat.spec
+++ b/pandora_console/pandora_console.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221021
+%define release     221022
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec
index 5d13a36ffb..546f3883ed 100644
--- a/pandora_console/pandora_console.rhel7.spec
+++ b/pandora_console/pandora_console.rhel7.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221021
+%define release     221022
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec
index 407a16c9bc..2167129c96 100644
--- a/pandora_console/pandora_console.spec
+++ b/pandora_console/pandora_console.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221021
+%define release     221022
 %define httpd_name      httpd
 # User and Group under which Apache is running
 %define httpd_name  apache2
diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control
index c43a723d23..2b7311a400 100644
--- a/pandora_server/DEBIAN/control
+++ b/pandora_server/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-server
-Version: 7.0NG.765-221021
+Version: 7.0NG.765-221022
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh
index 90a561094c..69063133e7 100644
--- a/pandora_server/DEBIAN/make_deb_package.sh
+++ b/pandora_server/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221021"
+pandora_version="7.0NG.765-221022"
 
 package_cpan=0
 package_pandora=1
diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm
index 7d8a1ae579..385a4e37ff 100644
--- a/pandora_server/lib/PandoraFMS/Config.pm
+++ b/pandora_server/lib/PandoraFMS/Config.pm
@@ -46,7 +46,7 @@ our @EXPORT = qw(
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221021";
+my $pandora_build = "221022";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 # Setup hash
diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm
index 49bad52416..8f57d0f598 100644
--- a/pandora_server/lib/PandoraFMS/PluginTools.pm
+++ b/pandora_server/lib/PandoraFMS/PluginTools.pm
@@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221021";
+my $pandora_build = "221022";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 our %EXPORT_TAGS = ( 'all' => [ qw() ] );
diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec
index 4f7a118b77..304a507af6 100644
--- a/pandora_server/pandora_server.redhat.spec
+++ b/pandora_server/pandora_server.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221021
+%define release     221022
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec
index f9b690f41c..c2c4aa00b9 100644
--- a/pandora_server/pandora_server.spec
+++ b/pandora_server/pandora_server.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221021
+%define release     221022
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer
index dd87c2a4d4..9c23097476 100755
--- a/pandora_server/pandora_server_installer
+++ b/pandora_server/pandora_server_installer
@@ -9,7 +9,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221021"
+PI_BUILD="221022"
 
 MODE=$1
 if [ $# -gt 1 ]; then
diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl
index 2ba7f416aa..bea666cce6 100755
--- a/pandora_server/util/pandora_db.pl
+++ b/pandora_server/util/pandora_db.pl
@@ -35,7 +35,7 @@ use PandoraFMS::Config;
 use PandoraFMS::DB;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221021";
+my $version = "7.0NG.765 Build 221022";
 
 # Pandora server configuration
 my %conf;
diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index 31c8238c9a..aa3e443586 100755
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -36,7 +36,7 @@ use Encode::Locale;
 Encode::Locale::decode_argv;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221021";
+my $version = "7.0NG.765 Build 221022";
 
 # save program name for logging
 my $progname = basename($0);

From bd0f136dc0217e7c6e06beaf5b7d9c7beb7ec016 Mon Sep 17 00:00:00 2001
From: artica <artica.devel@gmail.com>
Date: Sun, 23 Oct 2022 01:00:17 +0200
Subject: [PATCH 76/83] Auto-updated build strings.

---
 pandora_agents/unix/DEBIAN/control             | 2 +-
 pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +-
 pandora_agents/unix/pandora_agent              | 2 +-
 pandora_agents/unix/pandora_agent.redhat.spec  | 2 +-
 pandora_agents/unix/pandora_agent.spec         | 2 +-
 pandora_agents/unix/pandora_agent_installer    | 2 +-
 pandora_agents/win32/installer/pandora.mpi     | 2 +-
 pandora_agents/win32/pandora.cc                | 2 +-
 pandora_agents/win32/versioninfo.rc            | 2 +-
 pandora_console/DEBIAN/control                 | 2 +-
 pandora_console/DEBIAN/make_deb_package.sh     | 2 +-
 pandora_console/include/config_process.php     | 2 +-
 pandora_console/install.php                    | 2 +-
 pandora_console/pandora_console.redhat.spec    | 2 +-
 pandora_console/pandora_console.rhel7.spec     | 2 +-
 pandora_console/pandora_console.spec           | 2 +-
 pandora_server/DEBIAN/control                  | 2 +-
 pandora_server/DEBIAN/make_deb_package.sh      | 2 +-
 pandora_server/lib/PandoraFMS/Config.pm        | 2 +-
 pandora_server/lib/PandoraFMS/PluginTools.pm   | 2 +-
 pandora_server/pandora_server.redhat.spec      | 2 +-
 pandora_server/pandora_server.spec             | 2 +-
 pandora_server/pandora_server_installer        | 2 +-
 pandora_server/util/pandora_db.pl              | 2 +-
 pandora_server/util/pandora_manage.pl          | 2 +-
 25 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control
index bbca5727f2..d40fc5cb47 100644
--- a/pandora_agents/unix/DEBIAN/control
+++ b/pandora_agents/unix/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-agent-unix
-Version: 7.0NG.765-221022
+Version: 7.0NG.765-221023
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh
index 53f4a1d9e0..137bc8031e 100644
--- a/pandora_agents/unix/DEBIAN/make_deb_package.sh
+++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221022"
+pandora_version="7.0NG.765-221023"
 
 echo "Test if you has the tools for to make the packages."
 whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent
index 226864239d..2acf9e97d2 100755
--- a/pandora_agents/unix/pandora_agent
+++ b/pandora_agents/unix/pandora_agent
@@ -1015,7 +1015,7 @@ my $Sem = undef;
 my $ThreadSem = undef;
 
 use constant AGENT_VERSION => '7.0NG.765';
-use constant AGENT_BUILD => '221022';
+use constant AGENT_BUILD => '221023';
 
 # Agent log default file size maximum and instances
 use constant DEFAULT_MAX_LOG_SIZE => 600000;
diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec
index 64cebc8ffe..c66df4b8d1 100644
--- a/pandora_agents/unix/pandora_agent.redhat.spec
+++ b/pandora_agents/unix/pandora_agent.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221022
+%define release     221023
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec
index ae6a67c85e..8e5ff65174 100644
--- a/pandora_agents/unix/pandora_agent.spec
+++ b/pandora_agents/unix/pandora_agent.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221022
+%define release     221023
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer
index 8483573019..5f678a81ee 100755
--- a/pandora_agents/unix/pandora_agent_installer
+++ b/pandora_agents/unix/pandora_agent_installer
@@ -10,7 +10,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221022"
+PI_BUILD="221023"
 OS_NAME=`uname -s`
 
 FORCE=0
diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi
index fddfc174c5..dcdacfe1e7 100644
--- a/pandora_agents/win32/installer/pandora.mpi
+++ b/pandora_agents/win32/installer/pandora.mpi
@@ -186,7 +186,7 @@ UpgradeApplicationID
 {}
 
 Version
-{221022}
+{221023}
 
 ViewReadme
 {Yes}
diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc
index e4fcda3aef..ead4396148 100644
--- a/pandora_agents/win32/pandora.cc
+++ b/pandora_agents/win32/pandora.cc
@@ -30,7 +30,7 @@ using namespace Pandora;
 using namespace Pandora_Strutils;
 
 #define PATH_SIZE    _MAX_PATH+1
-#define PANDORA_VERSION ("7.0NG.765 Build 221022")
+#define PANDORA_VERSION ("7.0NG.765 Build 221023")
 
 string pandora_path;
 string pandora_dir;
diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc
index 40c320f331..b985adee71 100644
--- a/pandora_agents/win32/versioninfo.rc
+++ b/pandora_agents/win32/versioninfo.rc
@@ -11,7 +11,7 @@ BEGIN
       VALUE "LegalCopyright", "Artica ST"
       VALUE "OriginalFilename", "PandoraAgent.exe"
       VALUE "ProductName", "Pandora FMS Windows Agent"
-      VALUE "ProductVersion", "(7.0NG.765(Build 221022))"
+      VALUE "ProductVersion", "(7.0NG.765(Build 221023))"
       VALUE "FileVersion", "1.0.0.0"
     END
   END
diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control
index 2b149dc615..ed194c1200 100644
--- a/pandora_console/DEBIAN/control
+++ b/pandora_console/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-console
-Version: 7.0NG.765-221022
+Version: 7.0NG.765-221023
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh
index 7a694ce3dc..fe781cc4f5 100644
--- a/pandora_console/DEBIAN/make_deb_package.sh
+++ b/pandora_console/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221022"
+pandora_version="7.0NG.765-221023"
 
 package_pear=0
 package_pandora=1
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index 535ba720d9..bd656030e0 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -20,7 +20,7 @@
 /**
  * Pandora build version and version
  */
-$build_version = 'PC221022';
+$build_version = 'PC221023';
 $pandora_version = 'v7.0NG.765';
 
 // Do not overwrite default timezone set if defined.
diff --git a/pandora_console/install.php b/pandora_console/install.php
index 7ec5663045..e8f55b7639 100644
--- a/pandora_console/install.php
+++ b/pandora_console/install.php
@@ -129,7 +129,7 @@
         <div style='height: 10px'>
             <?php
             $version = '7.0NG.765';
-            $build = '221022';
+            $build = '221023';
             $banner = "v$version Build $build";
 
             error_reporting(0);
diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec
index 4a023f31ca..517d6bb9a6 100644
--- a/pandora_console/pandora_console.redhat.spec
+++ b/pandora_console/pandora_console.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221022
+%define release     221023
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec
index 546f3883ed..196c546c68 100644
--- a/pandora_console/pandora_console.rhel7.spec
+++ b/pandora_console/pandora_console.rhel7.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221022
+%define release     221023
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec
index 2167129c96..786f11f6a9 100644
--- a/pandora_console/pandora_console.spec
+++ b/pandora_console/pandora_console.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221022
+%define release     221023
 %define httpd_name      httpd
 # User and Group under which Apache is running
 %define httpd_name  apache2
diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control
index 2b7311a400..3b5174da8c 100644
--- a/pandora_server/DEBIAN/control
+++ b/pandora_server/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-server
-Version: 7.0NG.765-221022
+Version: 7.0NG.765-221023
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh
index 69063133e7..7eafcc30fa 100644
--- a/pandora_server/DEBIAN/make_deb_package.sh
+++ b/pandora_server/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221022"
+pandora_version="7.0NG.765-221023"
 
 package_cpan=0
 package_pandora=1
diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm
index 385a4e37ff..e41e1a7574 100644
--- a/pandora_server/lib/PandoraFMS/Config.pm
+++ b/pandora_server/lib/PandoraFMS/Config.pm
@@ -46,7 +46,7 @@ our @EXPORT = qw(
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221022";
+my $pandora_build = "221023";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 # Setup hash
diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm
index 8f57d0f598..b3f60692e3 100644
--- a/pandora_server/lib/PandoraFMS/PluginTools.pm
+++ b/pandora_server/lib/PandoraFMS/PluginTools.pm
@@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221022";
+my $pandora_build = "221023";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 our %EXPORT_TAGS = ( 'all' => [ qw() ] );
diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec
index 304a507af6..e47b37be8f 100644
--- a/pandora_server/pandora_server.redhat.spec
+++ b/pandora_server/pandora_server.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221022
+%define release     221023
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec
index c2c4aa00b9..45bd0aa52a 100644
--- a/pandora_server/pandora_server.spec
+++ b/pandora_server/pandora_server.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221022
+%define release     221023
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer
index 9c23097476..ec988421f6 100755
--- a/pandora_server/pandora_server_installer
+++ b/pandora_server/pandora_server_installer
@@ -9,7 +9,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221022"
+PI_BUILD="221023"
 
 MODE=$1
 if [ $# -gt 1 ]; then
diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl
index bea666cce6..9a23656d5d 100755
--- a/pandora_server/util/pandora_db.pl
+++ b/pandora_server/util/pandora_db.pl
@@ -35,7 +35,7 @@ use PandoraFMS::Config;
 use PandoraFMS::DB;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221022";
+my $version = "7.0NG.765 Build 221023";
 
 # Pandora server configuration
 my %conf;
diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index aa3e443586..53f7a5a009 100755
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -36,7 +36,7 @@ use Encode::Locale;
 Encode::Locale::decode_argv;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221022";
+my $version = "7.0NG.765 Build 221023";
 
 # save program name for logging
 my $progname = basename($0);

From 204d711b309534e601dde92c51be94171cf4fd59 Mon Sep 17 00:00:00 2001
From: artica <artica.devel@gmail.com>
Date: Mon, 24 Oct 2022 01:00:19 +0200
Subject: [PATCH 77/83] Auto-updated build strings.

---
 pandora_agents/unix/DEBIAN/control             | 2 +-
 pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +-
 pandora_agents/unix/pandora_agent              | 2 +-
 pandora_agents/unix/pandora_agent.redhat.spec  | 2 +-
 pandora_agents/unix/pandora_agent.spec         | 2 +-
 pandora_agents/unix/pandora_agent_installer    | 2 +-
 pandora_agents/win32/installer/pandora.mpi     | 2 +-
 pandora_agents/win32/pandora.cc                | 2 +-
 pandora_agents/win32/versioninfo.rc            | 2 +-
 pandora_console/DEBIAN/control                 | 2 +-
 pandora_console/DEBIAN/make_deb_package.sh     | 2 +-
 pandora_console/include/config_process.php     | 2 +-
 pandora_console/install.php                    | 2 +-
 pandora_console/pandora_console.redhat.spec    | 2 +-
 pandora_console/pandora_console.rhel7.spec     | 2 +-
 pandora_console/pandora_console.spec           | 2 +-
 pandora_server/DEBIAN/control                  | 2 +-
 pandora_server/DEBIAN/make_deb_package.sh      | 2 +-
 pandora_server/lib/PandoraFMS/Config.pm        | 2 +-
 pandora_server/lib/PandoraFMS/PluginTools.pm   | 2 +-
 pandora_server/pandora_server.redhat.spec      | 2 +-
 pandora_server/pandora_server.spec             | 2 +-
 pandora_server/pandora_server_installer        | 2 +-
 pandora_server/util/pandora_db.pl              | 2 +-
 pandora_server/util/pandora_manage.pl          | 2 +-
 25 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control
index d40fc5cb47..40c8314915 100644
--- a/pandora_agents/unix/DEBIAN/control
+++ b/pandora_agents/unix/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-agent-unix
-Version: 7.0NG.765-221023
+Version: 7.0NG.765-221024
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh
index 137bc8031e..d6c894f25c 100644
--- a/pandora_agents/unix/DEBIAN/make_deb_package.sh
+++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221023"
+pandora_version="7.0NG.765-221024"
 
 echo "Test if you has the tools for to make the packages."
 whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent
index 2acf9e97d2..f2d3dc0763 100755
--- a/pandora_agents/unix/pandora_agent
+++ b/pandora_agents/unix/pandora_agent
@@ -1015,7 +1015,7 @@ my $Sem = undef;
 my $ThreadSem = undef;
 
 use constant AGENT_VERSION => '7.0NG.765';
-use constant AGENT_BUILD => '221023';
+use constant AGENT_BUILD => '221024';
 
 # Agent log default file size maximum and instances
 use constant DEFAULT_MAX_LOG_SIZE => 600000;
diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec
index c66df4b8d1..ddff1e7eb0 100644
--- a/pandora_agents/unix/pandora_agent.redhat.spec
+++ b/pandora_agents/unix/pandora_agent.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221023
+%define release     221024
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec
index 8e5ff65174..27131fe816 100644
--- a/pandora_agents/unix/pandora_agent.spec
+++ b/pandora_agents/unix/pandora_agent.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221023
+%define release     221024
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer
index 5f678a81ee..67b326a2af 100755
--- a/pandora_agents/unix/pandora_agent_installer
+++ b/pandora_agents/unix/pandora_agent_installer
@@ -10,7 +10,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221023"
+PI_BUILD="221024"
 OS_NAME=`uname -s`
 
 FORCE=0
diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi
index dcdacfe1e7..a87682994a 100644
--- a/pandora_agents/win32/installer/pandora.mpi
+++ b/pandora_agents/win32/installer/pandora.mpi
@@ -186,7 +186,7 @@ UpgradeApplicationID
 {}
 
 Version
-{221023}
+{221024}
 
 ViewReadme
 {Yes}
diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc
index ead4396148..bd497b0747 100644
--- a/pandora_agents/win32/pandora.cc
+++ b/pandora_agents/win32/pandora.cc
@@ -30,7 +30,7 @@ using namespace Pandora;
 using namespace Pandora_Strutils;
 
 #define PATH_SIZE    _MAX_PATH+1
-#define PANDORA_VERSION ("7.0NG.765 Build 221023")
+#define PANDORA_VERSION ("7.0NG.765 Build 221024")
 
 string pandora_path;
 string pandora_dir;
diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc
index b985adee71..015503fbe4 100644
--- a/pandora_agents/win32/versioninfo.rc
+++ b/pandora_agents/win32/versioninfo.rc
@@ -11,7 +11,7 @@ BEGIN
       VALUE "LegalCopyright", "Artica ST"
       VALUE "OriginalFilename", "PandoraAgent.exe"
       VALUE "ProductName", "Pandora FMS Windows Agent"
-      VALUE "ProductVersion", "(7.0NG.765(Build 221023))"
+      VALUE "ProductVersion", "(7.0NG.765(Build 221024))"
       VALUE "FileVersion", "1.0.0.0"
     END
   END
diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control
index ed194c1200..76251ee1f5 100644
--- a/pandora_console/DEBIAN/control
+++ b/pandora_console/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-console
-Version: 7.0NG.765-221023
+Version: 7.0NG.765-221024
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh
index fe781cc4f5..c8cdd3f471 100644
--- a/pandora_console/DEBIAN/make_deb_package.sh
+++ b/pandora_console/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221023"
+pandora_version="7.0NG.765-221024"
 
 package_pear=0
 package_pandora=1
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index bd656030e0..e99f102d3a 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -20,7 +20,7 @@
 /**
  * Pandora build version and version
  */
-$build_version = 'PC221023';
+$build_version = 'PC221024';
 $pandora_version = 'v7.0NG.765';
 
 // Do not overwrite default timezone set if defined.
diff --git a/pandora_console/install.php b/pandora_console/install.php
index e8f55b7639..ef83f771a1 100644
--- a/pandora_console/install.php
+++ b/pandora_console/install.php
@@ -129,7 +129,7 @@
         <div style='height: 10px'>
             <?php
             $version = '7.0NG.765';
-            $build = '221023';
+            $build = '221024';
             $banner = "v$version Build $build";
 
             error_reporting(0);
diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec
index 517d6bb9a6..20a8d728db 100644
--- a/pandora_console/pandora_console.redhat.spec
+++ b/pandora_console/pandora_console.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221023
+%define release     221024
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec
index 196c546c68..3610166861 100644
--- a/pandora_console/pandora_console.rhel7.spec
+++ b/pandora_console/pandora_console.rhel7.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221023
+%define release     221024
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec
index 786f11f6a9..b275dceca5 100644
--- a/pandora_console/pandora_console.spec
+++ b/pandora_console/pandora_console.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221023
+%define release     221024
 %define httpd_name      httpd
 # User and Group under which Apache is running
 %define httpd_name  apache2
diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control
index 3b5174da8c..7161399fd5 100644
--- a/pandora_server/DEBIAN/control
+++ b/pandora_server/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-server
-Version: 7.0NG.765-221023
+Version: 7.0NG.765-221024
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh
index 7eafcc30fa..0080ae3d02 100644
--- a/pandora_server/DEBIAN/make_deb_package.sh
+++ b/pandora_server/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221023"
+pandora_version="7.0NG.765-221024"
 
 package_cpan=0
 package_pandora=1
diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm
index e41e1a7574..d3082637a2 100644
--- a/pandora_server/lib/PandoraFMS/Config.pm
+++ b/pandora_server/lib/PandoraFMS/Config.pm
@@ -46,7 +46,7 @@ our @EXPORT = qw(
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221023";
+my $pandora_build = "221024";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 # Setup hash
diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm
index b3f60692e3..7f2c4ce8fb 100644
--- a/pandora_server/lib/PandoraFMS/PluginTools.pm
+++ b/pandora_server/lib/PandoraFMS/PluginTools.pm
@@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221023";
+my $pandora_build = "221024";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 our %EXPORT_TAGS = ( 'all' => [ qw() ] );
diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec
index e47b37be8f..5b83a04379 100644
--- a/pandora_server/pandora_server.redhat.spec
+++ b/pandora_server/pandora_server.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221023
+%define release     221024
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec
index 45bd0aa52a..01925c9bd1 100644
--- a/pandora_server/pandora_server.spec
+++ b/pandora_server/pandora_server.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221023
+%define release     221024
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer
index ec988421f6..eadf04577f 100755
--- a/pandora_server/pandora_server_installer
+++ b/pandora_server/pandora_server_installer
@@ -9,7 +9,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221023"
+PI_BUILD="221024"
 
 MODE=$1
 if [ $# -gt 1 ]; then
diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl
index 9a23656d5d..506ea0cef1 100755
--- a/pandora_server/util/pandora_db.pl
+++ b/pandora_server/util/pandora_db.pl
@@ -35,7 +35,7 @@ use PandoraFMS::Config;
 use PandoraFMS::DB;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221023";
+my $version = "7.0NG.765 Build 221024";
 
 # Pandora server configuration
 my %conf;
diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index 53f7a5a009..0e6fee8089 100755
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -36,7 +36,7 @@ use Encode::Locale;
 Encode::Locale::decode_argv;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221023";
+my $version = "7.0NG.765 Build 221024";
 
 # save program name for logging
 my $progname = basename($0);

From 821bdf16da799e05dc9b76a449d3dbbbdee17945 Mon Sep 17 00:00:00 2001
From: Daniel Barbero <daniel.barbero@artica.es>
Date: Mon, 24 Oct 2022 09:26:22 +0200
Subject: [PATCH 78/83] fix error types php7.2 pandora_enterprise#9695

---
 .../include/lib/Dashboard/Widgets/GroupedMeterGraphs.php    | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php b/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php
index fcca4b5968..2eed27df11 100644
--- a/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php
+++ b/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php
@@ -126,21 +126,21 @@ class GroupedMeterGraphs extends Widget
      *
      * @var array
      */
-    private array $size;
+    private $size;
 
     /**
      * Number of boxes.
      *
      * @var float
      */
-    private float $boxNumber;
+    private $boxNumber;
 
     /**
      * Thresholds.
      *
      * @var array
      */
-    private array $thresholds;
+    private $thresholds;
 
 
     /**

From 183d1ae12067310898652d3d130575f60fc423cf Mon Sep 17 00:00:00 2001
From: Calvo <luis.calvo@pandorafms.com>
Date: Mon, 24 Oct 2022 16:44:10 +0200
Subject: [PATCH 79/83] Fix vulnerabilies

---
 pandora_console/godmode/agentes/module_manager.php | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php
index 6cfa2685b4..b63392ac4c 100644
--- a/pandora_console/godmode/agentes/module_manager.php
+++ b/pandora_console/godmode/agentes/module_manager.php
@@ -40,16 +40,7 @@ require_once $config['homedir'].'/include/functions_modules.php';
 require_once $config['homedir'].'/include/functions_agents.php';
 require_once $config['homedir'].'/include/functions_servers.php';
 
-$search_string = io_safe_output(
-    urldecode(
-        trim(
-            get_parameter(
-                'search_string',
-                ''
-            )
-        )
-    )
-);
+$search_string = get_parameter('search_string');
 
 global $policy_page;
 

From ce4fc252099a0dacabdaccf284897179f526c008 Mon Sep 17 00:00:00 2001
From: artica <artica.devel@gmail.com>
Date: Tue, 25 Oct 2022 01:00:22 +0200
Subject: [PATCH 80/83] Auto-updated build strings.

---
 pandora_agents/unix/DEBIAN/control             | 2 +-
 pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +-
 pandora_agents/unix/pandora_agent              | 2 +-
 pandora_agents/unix/pandora_agent.redhat.spec  | 2 +-
 pandora_agents/unix/pandora_agent.spec         | 2 +-
 pandora_agents/unix/pandora_agent_installer    | 2 +-
 pandora_agents/win32/installer/pandora.mpi     | 2 +-
 pandora_agents/win32/pandora.cc                | 2 +-
 pandora_agents/win32/versioninfo.rc            | 2 +-
 pandora_console/DEBIAN/control                 | 2 +-
 pandora_console/DEBIAN/make_deb_package.sh     | 2 +-
 pandora_console/include/config_process.php     | 2 +-
 pandora_console/install.php                    | 2 +-
 pandora_console/pandora_console.redhat.spec    | 2 +-
 pandora_console/pandora_console.rhel7.spec     | 2 +-
 pandora_console/pandora_console.spec           | 2 +-
 pandora_server/DEBIAN/control                  | 2 +-
 pandora_server/DEBIAN/make_deb_package.sh      | 2 +-
 pandora_server/lib/PandoraFMS/Config.pm        | 2 +-
 pandora_server/lib/PandoraFMS/PluginTools.pm   | 2 +-
 pandora_server/pandora_server.redhat.spec      | 2 +-
 pandora_server/pandora_server.spec             | 2 +-
 pandora_server/pandora_server_installer        | 2 +-
 pandora_server/util/pandora_db.pl              | 2 +-
 pandora_server/util/pandora_manage.pl          | 2 +-
 25 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control
index 40c8314915..418e5c533b 100644
--- a/pandora_agents/unix/DEBIAN/control
+++ b/pandora_agents/unix/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-agent-unix
-Version: 7.0NG.765-221024
+Version: 7.0NG.765-221025
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh
index d6c894f25c..f17a12ba4c 100644
--- a/pandora_agents/unix/DEBIAN/make_deb_package.sh
+++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221024"
+pandora_version="7.0NG.765-221025"
 
 echo "Test if you has the tools for to make the packages."
 whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent
index f2d3dc0763..bd218084aa 100755
--- a/pandora_agents/unix/pandora_agent
+++ b/pandora_agents/unix/pandora_agent
@@ -1015,7 +1015,7 @@ my $Sem = undef;
 my $ThreadSem = undef;
 
 use constant AGENT_VERSION => '7.0NG.765';
-use constant AGENT_BUILD => '221024';
+use constant AGENT_BUILD => '221025';
 
 # Agent log default file size maximum and instances
 use constant DEFAULT_MAX_LOG_SIZE => 600000;
diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec
index ddff1e7eb0..3ef82d0f6b 100644
--- a/pandora_agents/unix/pandora_agent.redhat.spec
+++ b/pandora_agents/unix/pandora_agent.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221024
+%define release     221025
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec
index 27131fe816..319baafe0c 100644
--- a/pandora_agents/unix/pandora_agent.spec
+++ b/pandora_agents/unix/pandora_agent.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221024
+%define release     221025
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer
index 67b326a2af..d340058fc1 100755
--- a/pandora_agents/unix/pandora_agent_installer
+++ b/pandora_agents/unix/pandora_agent_installer
@@ -10,7 +10,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221024"
+PI_BUILD="221025"
 OS_NAME=`uname -s`
 
 FORCE=0
diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi
index a87682994a..59e8afd49f 100644
--- a/pandora_agents/win32/installer/pandora.mpi
+++ b/pandora_agents/win32/installer/pandora.mpi
@@ -186,7 +186,7 @@ UpgradeApplicationID
 {}
 
 Version
-{221024}
+{221025}
 
 ViewReadme
 {Yes}
diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc
index bd497b0747..8273b52825 100644
--- a/pandora_agents/win32/pandora.cc
+++ b/pandora_agents/win32/pandora.cc
@@ -30,7 +30,7 @@ using namespace Pandora;
 using namespace Pandora_Strutils;
 
 #define PATH_SIZE    _MAX_PATH+1
-#define PANDORA_VERSION ("7.0NG.765 Build 221024")
+#define PANDORA_VERSION ("7.0NG.765 Build 221025")
 
 string pandora_path;
 string pandora_dir;
diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc
index 015503fbe4..596b47dd03 100644
--- a/pandora_agents/win32/versioninfo.rc
+++ b/pandora_agents/win32/versioninfo.rc
@@ -11,7 +11,7 @@ BEGIN
       VALUE "LegalCopyright", "Artica ST"
       VALUE "OriginalFilename", "PandoraAgent.exe"
       VALUE "ProductName", "Pandora FMS Windows Agent"
-      VALUE "ProductVersion", "(7.0NG.765(Build 221024))"
+      VALUE "ProductVersion", "(7.0NG.765(Build 221025))"
       VALUE "FileVersion", "1.0.0.0"
     END
   END
diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control
index 76251ee1f5..cb3bc5b155 100644
--- a/pandora_console/DEBIAN/control
+++ b/pandora_console/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-console
-Version: 7.0NG.765-221024
+Version: 7.0NG.765-221025
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh
index c8cdd3f471..3121f6e7f6 100644
--- a/pandora_console/DEBIAN/make_deb_package.sh
+++ b/pandora_console/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221024"
+pandora_version="7.0NG.765-221025"
 
 package_pear=0
 package_pandora=1
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index e99f102d3a..6a511b2487 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -20,7 +20,7 @@
 /**
  * Pandora build version and version
  */
-$build_version = 'PC221024';
+$build_version = 'PC221025';
 $pandora_version = 'v7.0NG.765';
 
 // Do not overwrite default timezone set if defined.
diff --git a/pandora_console/install.php b/pandora_console/install.php
index ef83f771a1..6cc5fccf1c 100644
--- a/pandora_console/install.php
+++ b/pandora_console/install.php
@@ -129,7 +129,7 @@
         <div style='height: 10px'>
             <?php
             $version = '7.0NG.765';
-            $build = '221024';
+            $build = '221025';
             $banner = "v$version Build $build";
 
             error_reporting(0);
diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec
index 20a8d728db..354e1e2cf2 100644
--- a/pandora_console/pandora_console.redhat.spec
+++ b/pandora_console/pandora_console.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221024
+%define release     221025
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec
index 3610166861..3768cc0e98 100644
--- a/pandora_console/pandora_console.rhel7.spec
+++ b/pandora_console/pandora_console.rhel7.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221024
+%define release     221025
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec
index b275dceca5..e1465defc3 100644
--- a/pandora_console/pandora_console.spec
+++ b/pandora_console/pandora_console.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221024
+%define release     221025
 %define httpd_name      httpd
 # User and Group under which Apache is running
 %define httpd_name  apache2
diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control
index 7161399fd5..39630d0e5c 100644
--- a/pandora_server/DEBIAN/control
+++ b/pandora_server/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-server
-Version: 7.0NG.765-221024
+Version: 7.0NG.765-221025
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh
index 0080ae3d02..bd0e456795 100644
--- a/pandora_server/DEBIAN/make_deb_package.sh
+++ b/pandora_server/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221024"
+pandora_version="7.0NG.765-221025"
 
 package_cpan=0
 package_pandora=1
diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm
index d3082637a2..5db218084b 100644
--- a/pandora_server/lib/PandoraFMS/Config.pm
+++ b/pandora_server/lib/PandoraFMS/Config.pm
@@ -46,7 +46,7 @@ our @EXPORT = qw(
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221024";
+my $pandora_build = "221025";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 # Setup hash
diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm
index 7f2c4ce8fb..36b3b6a06b 100644
--- a/pandora_server/lib/PandoraFMS/PluginTools.pm
+++ b/pandora_server/lib/PandoraFMS/PluginTools.pm
@@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221024";
+my $pandora_build = "221025";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 our %EXPORT_TAGS = ( 'all' => [ qw() ] );
diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec
index 5b83a04379..aa40d1532c 100644
--- a/pandora_server/pandora_server.redhat.spec
+++ b/pandora_server/pandora_server.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221024
+%define release     221025
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec
index 01925c9bd1..011acdf124 100644
--- a/pandora_server/pandora_server.spec
+++ b/pandora_server/pandora_server.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221024
+%define release     221025
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer
index eadf04577f..9b46fed24d 100755
--- a/pandora_server/pandora_server_installer
+++ b/pandora_server/pandora_server_installer
@@ -9,7 +9,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221024"
+PI_BUILD="221025"
 
 MODE=$1
 if [ $# -gt 1 ]; then
diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl
index 506ea0cef1..55c3e4d860 100755
--- a/pandora_server/util/pandora_db.pl
+++ b/pandora_server/util/pandora_db.pl
@@ -35,7 +35,7 @@ use PandoraFMS::Config;
 use PandoraFMS::DB;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221024";
+my $version = "7.0NG.765 Build 221025";
 
 # Pandora server configuration
 my %conf;
diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index 0e6fee8089..22a4028a30 100755
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -36,7 +36,7 @@ use Encode::Locale;
 Encode::Locale::decode_argv;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221024";
+my $version = "7.0NG.765 Build 221025";
 
 # save program name for logging
 my $progname = basename($0);

From 6b1906d17855857b6eb0dfa2786c5f4d4117e970 Mon Sep 17 00:00:00 2001
From: "jose.gonzalez@pandorafms.com" <jose.gonzalez@pandorafms.com>
Date: Tue, 25 Oct 2022 09:37:49 +0200
Subject: [PATCH 81/83] Added control for user creation

---
 pandora_console/godmode/users/configure_user.php | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php
index 355d93abff..bc3c440f87 100644
--- a/pandora_console/godmode/users/configure_user.php
+++ b/pandora_console/godmode/users/configure_user.php
@@ -442,6 +442,13 @@ if ($create_user) {
         $password_new = '';
         $password_confirm = '';
         $new_user = true;
+    } else if (excludedPassword($password_new) === true) {
+        $is_err = true;
+        ui_print_error_message(__('The password provided is not valid. Please set another one.'));
+        $user_info = $values;
+        $password_new = '';
+        $password_confirm = '';
+        $new_user = true;
     } else {
         if ((!is_user_admin($config['id_user']) || $config['enable_pass_policy_admin']) && $config['enable_pass_policy']) {
             $pass_ok = login_validate_pass($password_new, $id, true);

From c2c62bae066a70747d8d5b916c56e3f052869554 Mon Sep 17 00:00:00 2001
From: Calvo <luis.calvo@pandorafms.com>
Date: Tue, 25 Oct 2022 17:37:56 +0200
Subject: [PATCH 82/83] Fix missing parameter meta on event comments ajax

---
 pandora_console/include/functions_config.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php
index 004eab67fd..866a023f26 100644
--- a/pandora_console/include/functions_config.php
+++ b/pandora_console/include/functions_config.php
@@ -612,7 +612,7 @@ function config_update_config()
                         $error_update[] = __('Admin LDAP login');
                     }
 
-                    if (config_update_value('ldap_admin_pass', io_input_password(io_safe_output(get_parameter('ldap_admin_pass'))), true) === false) {
+                    if (config_update_value('ldap_admin_pass', io_input_password(get_parameter('ldap_admin_pass')), true) === false) {
                         $error_update[] = __('Admin LDAP password');
                     }
 
@@ -648,7 +648,7 @@ function config_update_config()
                         $error_update[] = __('Admin secondary LDAP login');
                     }
 
-                    if (config_update_value('ldap_admin_pass_secondary', io_input_password(io_safe_output(get_parameter('ldap_admin_pass_secondary'))), true) === false) {
+                    if (config_update_value('ldap_admin_pass_secondary', io_input_password(get_parameter('ldap_admin_pass_secondary')), true) === false) {
                         $error_update[] = __('Admin secondary LDAP password');
                     }
 

From b1c35e738560377bb0a1838aa164a96c0006545b Mon Sep 17 00:00:00 2001
From: artica <artica.devel@gmail.com>
Date: Wed, 26 Oct 2022 01:00:24 +0200
Subject: [PATCH 83/83] Auto-updated build strings.

---
 pandora_agents/unix/DEBIAN/control             | 2 +-
 pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +-
 pandora_agents/unix/pandora_agent              | 2 +-
 pandora_agents/unix/pandora_agent.redhat.spec  | 2 +-
 pandora_agents/unix/pandora_agent.spec         | 2 +-
 pandora_agents/unix/pandora_agent_installer    | 2 +-
 pandora_agents/win32/installer/pandora.mpi     | 2 +-
 pandora_agents/win32/pandora.cc                | 2 +-
 pandora_agents/win32/versioninfo.rc            | 2 +-
 pandora_console/DEBIAN/control                 | 2 +-
 pandora_console/DEBIAN/make_deb_package.sh     | 2 +-
 pandora_console/include/config_process.php     | 2 +-
 pandora_console/install.php                    | 2 +-
 pandora_console/pandora_console.redhat.spec    | 2 +-
 pandora_console/pandora_console.rhel7.spec     | 2 +-
 pandora_console/pandora_console.spec           | 2 +-
 pandora_server/DEBIAN/control                  | 2 +-
 pandora_server/DEBIAN/make_deb_package.sh      | 2 +-
 pandora_server/lib/PandoraFMS/Config.pm        | 2 +-
 pandora_server/lib/PandoraFMS/PluginTools.pm   | 2 +-
 pandora_server/pandora_server.redhat.spec      | 2 +-
 pandora_server/pandora_server.spec             | 2 +-
 pandora_server/pandora_server_installer        | 2 +-
 pandora_server/util/pandora_db.pl              | 2 +-
 pandora_server/util/pandora_manage.pl          | 2 +-
 25 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control
index 418e5c533b..afbea35741 100644
--- a/pandora_agents/unix/DEBIAN/control
+++ b/pandora_agents/unix/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-agent-unix
-Version: 7.0NG.765-221025
+Version: 7.0NG.765-221026
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh
index f17a12ba4c..3d6a014c29 100644
--- a/pandora_agents/unix/DEBIAN/make_deb_package.sh
+++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221025"
+pandora_version="7.0NG.765-221026"
 
 echo "Test if you has the tools for to make the packages."
 whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent
index bd218084aa..8f762f9a65 100755
--- a/pandora_agents/unix/pandora_agent
+++ b/pandora_agents/unix/pandora_agent
@@ -1015,7 +1015,7 @@ my $Sem = undef;
 my $ThreadSem = undef;
 
 use constant AGENT_VERSION => '7.0NG.765';
-use constant AGENT_BUILD => '221025';
+use constant AGENT_BUILD => '221026';
 
 # Agent log default file size maximum and instances
 use constant DEFAULT_MAX_LOG_SIZE => 600000;
diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec
index 3ef82d0f6b..686f414780 100644
--- a/pandora_agents/unix/pandora_agent.redhat.spec
+++ b/pandora_agents/unix/pandora_agent.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221025
+%define release     221026
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec
index 319baafe0c..b9eab464a0 100644
--- a/pandora_agents/unix/pandora_agent.spec
+++ b/pandora_agents/unix/pandora_agent.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.765
-%define release     221025
+%define release     221026
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer
index d340058fc1..a59808a885 100755
--- a/pandora_agents/unix/pandora_agent_installer
+++ b/pandora_agents/unix/pandora_agent_installer
@@ -10,7 +10,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221025"
+PI_BUILD="221026"
 OS_NAME=`uname -s`
 
 FORCE=0
diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi
index 59e8afd49f..a6bcc390be 100644
--- a/pandora_agents/win32/installer/pandora.mpi
+++ b/pandora_agents/win32/installer/pandora.mpi
@@ -186,7 +186,7 @@ UpgradeApplicationID
 {}
 
 Version
-{221025}
+{221026}
 
 ViewReadme
 {Yes}
diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc
index 8273b52825..2baf3ae615 100644
--- a/pandora_agents/win32/pandora.cc
+++ b/pandora_agents/win32/pandora.cc
@@ -30,7 +30,7 @@ using namespace Pandora;
 using namespace Pandora_Strutils;
 
 #define PATH_SIZE    _MAX_PATH+1
-#define PANDORA_VERSION ("7.0NG.765 Build 221025")
+#define PANDORA_VERSION ("7.0NG.765 Build 221026")
 
 string pandora_path;
 string pandora_dir;
diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc
index 596b47dd03..61bf9e4d76 100644
--- a/pandora_agents/win32/versioninfo.rc
+++ b/pandora_agents/win32/versioninfo.rc
@@ -11,7 +11,7 @@ BEGIN
       VALUE "LegalCopyright", "Artica ST"
       VALUE "OriginalFilename", "PandoraAgent.exe"
       VALUE "ProductName", "Pandora FMS Windows Agent"
-      VALUE "ProductVersion", "(7.0NG.765(Build 221025))"
+      VALUE "ProductVersion", "(7.0NG.765(Build 221026))"
       VALUE "FileVersion", "1.0.0.0"
     END
   END
diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control
index cb3bc5b155..1f7e782c96 100644
--- a/pandora_console/DEBIAN/control
+++ b/pandora_console/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-console
-Version: 7.0NG.765-221025
+Version: 7.0NG.765-221026
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh
index 3121f6e7f6..a517b126f8 100644
--- a/pandora_console/DEBIAN/make_deb_package.sh
+++ b/pandora_console/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221025"
+pandora_version="7.0NG.765-221026"
 
 package_pear=0
 package_pandora=1
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index 6a511b2487..4be9ac7945 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -20,7 +20,7 @@
 /**
  * Pandora build version and version
  */
-$build_version = 'PC221025';
+$build_version = 'PC221026';
 $pandora_version = 'v7.0NG.765';
 
 // Do not overwrite default timezone set if defined.
diff --git a/pandora_console/install.php b/pandora_console/install.php
index 6cc5fccf1c..74dad39609 100644
--- a/pandora_console/install.php
+++ b/pandora_console/install.php
@@ -129,7 +129,7 @@
         <div style='height: 10px'>
             <?php
             $version = '7.0NG.765';
-            $build = '221025';
+            $build = '221026';
             $banner = "v$version Build $build";
 
             error_reporting(0);
diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec
index 354e1e2cf2..d6ab2ce34a 100644
--- a/pandora_console/pandora_console.redhat.spec
+++ b/pandora_console/pandora_console.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221025
+%define release     221026
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec
index 3768cc0e98..cfba7a5d73 100644
--- a/pandora_console/pandora_console.rhel7.spec
+++ b/pandora_console/pandora_console.rhel7.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221025
+%define release     221026
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec
index e1465defc3..9033c89955 100644
--- a/pandora_console/pandora_console.spec
+++ b/pandora_console/pandora_console.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.765
-%define release     221025
+%define release     221026
 %define httpd_name      httpd
 # User and Group under which Apache is running
 %define httpd_name  apache2
diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control
index 39630d0e5c..d0abcaa44b 100644
--- a/pandora_server/DEBIAN/control
+++ b/pandora_server/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-server
-Version: 7.0NG.765-221025
+Version: 7.0NG.765-221026
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh
index bd0e456795..9cfd75351f 100644
--- a/pandora_server/DEBIAN/make_deb_package.sh
+++ b/pandora_server/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.765-221025"
+pandora_version="7.0NG.765-221026"
 
 package_cpan=0
 package_pandora=1
diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm
index 5db218084b..a87b8eaf83 100644
--- a/pandora_server/lib/PandoraFMS/Config.pm
+++ b/pandora_server/lib/PandoraFMS/Config.pm
@@ -46,7 +46,7 @@ our @EXPORT = qw(
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221025";
+my $pandora_build = "221026";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 # Setup hash
diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm
index 36b3b6a06b..252a0c14e2 100644
--- a/pandora_server/lib/PandoraFMS/PluginTools.pm
+++ b/pandora_server/lib/PandoraFMS/PluginTools.pm
@@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.765";
-my $pandora_build = "221025";
+my $pandora_build = "221026";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 our %EXPORT_TAGS = ( 'all' => [ qw() ] );
diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec
index aa40d1532c..85c9120e6b 100644
--- a/pandora_server/pandora_server.redhat.spec
+++ b/pandora_server/pandora_server.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221025
+%define release     221026
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec
index 011acdf124..787073d078 100644
--- a/pandora_server/pandora_server.spec
+++ b/pandora_server/pandora_server.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.765
-%define release     221025
+%define release     221026
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer
index 9b46fed24d..bc70c102c4 100755
--- a/pandora_server/pandora_server_installer
+++ b/pandora_server/pandora_server_installer
@@ -9,7 +9,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.765"
-PI_BUILD="221025"
+PI_BUILD="221026"
 
 MODE=$1
 if [ $# -gt 1 ]; then
diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl
index 55c3e4d860..9b8ddc6c86 100755
--- a/pandora_server/util/pandora_db.pl
+++ b/pandora_server/util/pandora_db.pl
@@ -35,7 +35,7 @@ use PandoraFMS::Config;
 use PandoraFMS::DB;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221025";
+my $version = "7.0NG.765 Build 221026";
 
 # Pandora server configuration
 my %conf;
diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index 22a4028a30..b0e964727d 100755
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -36,7 +36,7 @@ use Encode::Locale;
 Encode::Locale::decode_argv;
 
 # version: define current version
-my $version = "7.0NG.765 Build 221025";
+my $version = "7.0NG.765 Build 221026";
 
 # save program name for logging
 my $progname = basename($0);