diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php
index 430ca9d6a1..8c4f5db14b 100644
--- a/pandora_console/include/functions_agents.php
+++ b/pandora_console/include/functions_agents.php
@@ -949,11 +949,11 @@ function agents_get_group_agents(
$filter = [];
- // check available groups for target user only if asking for 'All' group
+ // Check available groups for target user only if asking for 'All' group.
if (!$noACL && $id_group == 0) {
- $id_group = $id_group == 0 ? array_keys(users_get_groups(false, 'AR', false)) : groups_safe_acl($config['id_user'], $id_group, 'AR');
+ $id_group = ($id_group == 0) ? array_keys(users_get_groups(false, 'AR', false)) : groups_safe_acl($config['id_user'], $id_group, 'AR');
if (empty($id_group)) {
- // An empty array means the user doesn't have access
+ // An empty array means the user doesn't have access.
return [];
}
}
@@ -970,7 +970,7 @@ function agents_get_group_agents(
$id_group = groups_get_id_recursive($id_group, true);
}
- // check available groups for target user only if asking for 'All' group
+ // Check available groups for target user only if asking for 'All' group.
if (!$noACL && $id_group == 0) {
$id_group = array_keys(
users_get_groups(false, 'AR', true, false, (array) $id_group)
@@ -978,7 +978,7 @@ function agents_get_group_agents(
}
}
- // Search for primary and secondary groups
+ // Search for primary and secondary groups.
if (!empty($id_group)) {
$filter[] = '('.db_format_array_where_clause_sql(
[
@@ -990,7 +990,7 @@ function agents_get_group_agents(
}
if ($search === true) {
- // No added search. Show both disabled and non-disabled
+ // No added search. Show both disabled and non-disabled.
} else if (is_array($search)) {
if (!$search['all_agents']) {
$filter['disabled'] = 0;
diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php
index 84d18e2743..701042448f 100644
--- a/pandora_console/include/functions_html.php
+++ b/pandora_console/include/functions_html.php
@@ -2257,7 +2257,7 @@ function html_print_checkbox_extended($name, $value, $checked, $disabled, $scrip
if ($id == '') {
$output .= ' id="checkbox-'.$id_aux.'"';
} else {
- $output .= ' '.$id.'"';
+ $output .= ' id='.$id;
}
if ($script != '') {
diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php
index a9a9a076bd..5578b9182f 100644
--- a/pandora_console/operation/agentes/ver_agente.php
+++ b/pandora_console/operation/agentes/ver_agente.php
@@ -1,17 +1,32 @@
$v) {
@@ -139,7 +164,7 @@ if (is_ajax()) {
$id_agents = get_parameter('id_agents');
$selection = get_parameter('selection');
- // No filter by module group
+ // No filter by module group.
$modules = select_modules_for_agent_group(0, $id_agents, $selection, false, true);
echo json_encode($modules);
return;
@@ -314,28 +339,28 @@ if (is_ajax()) {
}
if (!empty($module_name)) {
- $filter .= " AND t1.nombre COLLATE utf8_general_ci LIKE '%$module_name%'";
+ $filter .= " AND t1.nombre COLLATE utf8_general_ci LIKE '%".$module_name."%'";
}
- // Status selector
+ // Status selector.
if ($status_modulo == AGENT_MODULE_STATUS_NORMAL) {
- // Normal
+ // Normal.
$sql_conditions .= ' estado = 0 AND utimestamp > 0 )
OR (t1.id_tipo_modulo IN(21,22,23,100)) ';
} else if ($status_modulo == AGENT_MODULE_STATUS_CRITICAL_BAD) {
- // Critical
+ // Critical.
$sql_conditions .= ' estado = 1 AND utimestamp > 0 )';
} else if ($status_modulo == AGENT_MODULE_STATUS_WARNING) {
- // Warning
+ // Warning.
$sql_conditions .= ' estado = 2 AND utimestamp > 0 )';
} else if ($status_modulo == AGENT_MODULE_STATUS_NOT_NORMAL) {
- // Not normal
+ // Not normal.
$sql_conditions .= ' estado <> 0)';
} else if ($status_modulo == AGENT_MODULE_STATUS_UNKNOWN) {
- // Unknown
+ // Unknown.
$sql_conditions .= ' estado = 3 AND utimestamp <> 0 )';
} else if ($status_modulo == AGENT_MODULE_STATUS_NOT_INIT) {
- // Not init
+ // Not init.
$sql_conditions .= ' utimestamp = 0 )
AND t1.id_tipo_modulo NOT IN (21,22,23,100)';
}
@@ -415,7 +440,7 @@ if (is_ajax()) {
foreach ($array_reduced as $server_name => $id_agents) {
// Metaconsole db connection
- // $server_name can be the server id (ugly hack, I know)
+ // $server_name can be the server id (ugly hack, I know).
if (is_numeric($server_name)) {
$connection = metaconsole_get_connection_by_id($server_name);
} else {
@@ -426,7 +451,7 @@ if (is_ajax()) {
continue;
}
- // Get agent's modules
+ // Get agent's modules.
$sql = sprintf(
'SELECT t1.id_agente, t1.id_agente_modulo, t1.nombre
FROM tagente_modulo t1 %s
@@ -454,7 +479,7 @@ if (is_ajax()) {
$modules_aux = [];
foreach ($modules as $key => $module) {
- // Don't change this order, is used in the serialization
+ // Don't change this order, is used in the serialization.
$module_data = [
'id_module' => $module['id_agente_modulo'],
'id_agent' => $module['id_agente'],
@@ -469,7 +494,7 @@ if (is_ajax()) {
$modules = $modules_aux;
- // Build the next array using the common values
+ // Build the next array using the common values.
if (!empty($last_modules_set)) {
$modules = array_intersect_key($modules, $last_modules_set);
@@ -483,7 +508,7 @@ if (is_ajax()) {
$last_modules_set = $modules;
- // Restore db connection
+ // Restore db connection.
metaconsole_restore_db();
}
@@ -493,7 +518,6 @@ if (is_ajax()) {
$module_data_processed = array_map(
function ($item) {
- // data: -> id_module | id_agent | server_name;
return implode('|', $item);
},
$module_data
@@ -603,16 +627,16 @@ if (is_ajax()) {
if ($get_agent_modules_json) {
$id_agent = (int) get_parameter('id_agent');
- // Use -1 as not received
+ // Use -1 as not received.
$disabled = (int) get_parameter('disabled', -1);
$delete_pending = (int) get_parameter('delete_pending', -1);
- // Use 0 as not received
+ // Use 0 as not received.
$id_tipo_modulo = (int) get_parameter('id_tipo_modulo', 0);
$status_modulo = (int) get_parameter('status_module', -1);
$tags = (array) get_parameter('tags', []);
- // Filter
+ // Filter.
$filter = [];
if ($disabled !== -1) {
$filter['disabled'] = $disabled;
@@ -630,30 +654,34 @@ if (is_ajax()) {
$filter = false;
}
- $get_only_string_modules = get_parameter('get_only_string_modules', false);
+ $get_only_string_modules = get_parameter(
+ 'get_only_string_modules',
+ false
+ );
+
if ($get_only_string_modules) {
$filter['tagente_modulo.id_tipo_modulo IN'] = '(17,23,3,10,33)';
}
- // Status selector
+ // Status selector.
if ($status_modulo == AGENT_MODULE_STATUS_NORMAL) {
- // Normal
- $sql_conditions .= ' estado = 0 AND utimestamp > 0 )
+ // Normal.
+ $sql_conditions .= ' estado = 0 AND utimestamp > 0 )
OR (tagente_modulo.id_tipo_modulo IN(21,22,23,100)) ';
} else if ($status_modulo == AGENT_MODULE_STATUS_CRITICAL_BAD) {
- // Critical
+ // Critical.
$sql_conditions .= ' estado = 1 AND utimestamp > 0 )';
} else if ($status_modulo == AGENT_MODULE_STATUS_WARNING) {
- // Warning
+ // Warning.
$sql_conditions .= ' estado = 2 AND utimestamp > 0 )';
} else if ($status_modulo == AGENT_MODULE_STATUS_NOT_NORMAL) {
- // Not normal
+ // Not normal.
$sql_conditions .= ' estado <> 0 )';
} else if ($status_modulo == AGENT_MODULE_STATUS_UNKNOWN) {
- // Unknown
+ // Unknown.
$sql_conditions .= ' estado = 3 AND utimestamp <> 0 )';
} else if ($status_modulo == AGENT_MODULE_STATUS_NOT_INIT) {
- // Not init
+ // Not init.
$sql_conditions .= ' utimestamp = 0 )
AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)';
}
@@ -666,7 +694,7 @@ if (is_ajax()) {
$get_id_and_name = (bool) get_parameter('get_id_and_name');
$get_distinct_name = (bool) get_parameter('get_distinct_name');
- // Fields
+ // Fields.
$fields = '*';
if ($get_id_and_name) {
$fields = [
@@ -683,7 +711,8 @@ if (is_ajax()) {
$agentName = (string) get_parameter('agent_name', null);
$server_name = (string) get_parameter('server_name', null);
$server_id = (int) get_parameter('server_id', 0);
- // This will force to get local modules although metaconsole is active, by default get all modules from all nodes
+ // This will force to get local modules although metaconsole is active,
+ // by default get all modules from all nodes.
$force_local_modules = (int) get_parameter('force_local_modules', 0);
if ($agentName != null) {
@@ -706,7 +735,7 @@ if (is_ajax()) {
}
if (metaconsole_load_external_db($connection) == NOERR) {
- // Get all agents if no agent was given
+ // Get all agents if no agent was given.
if ($id_agent == 0) {
$id_agent = array_keys(
agents_get_group_agents(
@@ -720,11 +749,11 @@ if (is_ajax()) {
$agent_modules = agents_get_modules($id_agent, $fields, $filter, $indexed, true, $force_tags);
}
- // Restore db connection
+ // Restore db connection.
metaconsole_restore_db();
}
} else {
- // Get all agents if no agent was given
+ // Get all agents if no agent was given.
if ($id_agent == 0) {
$id_agent = array_keys(
agents_get_group_agents(
@@ -768,7 +797,7 @@ if (is_ajax()) {
$id_agent = (int) get_parameter('id_agent');
$metaconsole = (bool) get_parameter('metaconsole', false);
$id_server = (int) get_parameter('id_server', 0);
- // Metaconsole
+ // Metaconsole.
$server = null;
if ($metaconsole) {
$filter = [];
@@ -805,7 +834,7 @@ if (is_ajax()) {
echo ''.__('Last remote contact').': '.human_time_comparation($agent['ultimo_contacto_remoto']).'
';
if (!$metaconsole) {
- // Fix : Only show agents with module with tags of user profile
+ // Fix : Only show agents with module with tags of user profile.
$_user_tags = tags_get_user_tags($config['id_user'], 'RR');
$_sql_post = '';
@@ -842,10 +871,10 @@ if (is_ajax()) {
if ($bad_modules === false) {
$size_bad_modules = 0;
} else {
- $size_bad_modules = sizeof($bad_modules);
+ $size_bad_modules = count($bad_modules);
}
- // Modules down
+ // Modules down.
if ($size_bad_modules > 0) {
echo ''.__('Monitors down').': '.$size_bad_modules.' / '.$total_modules;
echo '