Merge remote-tracking branch 'origin/develop' into ent-8676-consolas-visuales-en-consola-movil

This commit is contained in:
Daniel Barbero Martin 2022-03-11 09:44:53 +01:00
commit e05d741109
50 changed files with 1273 additions and 335 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.760-220308 Version: 7.0NG.760-220311
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.760-220308" pandora_version="7.0NG.760-220311"
echo "Test if you has the tools for to make the packages." echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -1015,7 +1015,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.760'; use constant AGENT_VERSION => '7.0NG.760';
use constant AGENT_BUILD => '220308'; use constant AGENT_BUILD => '220311';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.760 %define version 7.0NG.760
%define release 220308 %define release 220311
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.760 %define version 7.0NG.760
%define release 220308 %define release 220311
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -10,7 +10,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.760" PI_VERSION="7.0NG.760"
PI_BUILD="220308" PI_BUILD="220311"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{220308} {220311}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.760 Build 220308") #define PANDORA_VERSION ("7.0NG.760 Build 220311")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST" VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent" VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.760(Build 220308))" VALUE "ProductVersion", "(7.0NG.760(Build 220311))"
VALUE "FileVersion", "1.0.0.0" VALUE "FileVersion", "1.0.0.0"
END END
END END

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.760-220308 Version: 7.0NG.760-220311
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.760-220308" pandora_version="7.0NG.760-220311"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -36,6 +36,7 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
).'</div>'; ).'</div>';
// ======= Servers List =============================================== // ======= Servers List ===============================================
if ((bool) check_acl($config['id_user'], 0, 'AW') !== false) {
$servers_list = '<div id="servers_list">'; $servers_list = '<div id="servers_list">';
$servers = []; $servers = [];
$servers['all'] = (int) db_get_value('COUNT(id_server)', 'tserver'); $servers['all'] = (int) db_get_value('COUNT(id_server)', 'tserver');
@ -60,6 +61,7 @@ echo sprintf('<div id="header_table" class="header_table_%s">', $menuTypeClass);
$servers_check_img_link .= '</a>'; $servers_check_img_link .= '</a>';
}; };
$servers_list .= $servers_check_img_link.'</div>'; $servers_list .= $servers_check_img_link.'</div>';
}

View File

@ -107,7 +107,12 @@ echo '</a></div>';
require 'operation/menu.php'; require 'operation/menu.php';
require 'godmode/menu.php'; require 'godmode/menu.php';
echo sprintf('<div id="button_collapse" class="button_%s button_collapse"></div>', $menuTypeClass); html_print_div(
[
'id' => 'button_collapse',
'class' => sprintf('button_collapse button_%s', $menuTypeClass),
]
);
echo '</div>'; echo '</div>';
// Menu_container. // Menu_container.

View File

@ -31,6 +31,7 @@ global $config;
enterprise_include('godmode/agentes/configurar_agente.php'); enterprise_include('godmode/agentes/configurar_agente.php');
enterprise_include_once('include/functions_modules.php'); enterprise_include_once('include/functions_modules.php');
enterprise_include('include/functions_policies.php');
require_once $config['homedir'].'/include/functions_agents.php'; require_once $config['homedir'].'/include/functions_agents.php';
require_once $config['homedir'].'/include/functions_cron.php'; require_once $config['homedir'].'/include/functions_cron.php';
ui_require_javascript_file('encode_decode_base64'); ui_require_javascript_file('encode_decode_base64');

View File

@ -1,27 +1,53 @@
<?php <?php
/**
* Planned downtimes list.
*
* @category Planned downtimes
* @package Pandora FMS
* @subpackage Community
* @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.
* ============================================================================
*/
// Pandora FMS - http://pandorafms.com // Load global vars.
// ==================================================
// 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 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.
// Load global vars
global $config; global $config;
check_login(); check_login();
$read_permisson = check_acl($config['id_user'], 0, 'AR'); $read_permisson = (bool) check_acl($config['id_user'], 0, 'AR');
$write_permisson = check_acl($config['id_user'], 0, 'AD'); $write_permisson = (bool) check_acl($config['id_user'], 0, 'AD');
$manage_permisson = check_acl($config['id_user'], 0, 'AW'); $manage_permisson = (bool) check_acl($config['id_user'], 0, 'AW');
$access = ($read_permisson == true) ? 'AR' : (($write_permisson == true) ? 'AD' : (($manage_permisson == true) ? 'AW' : 'AR')); $access = null;
if ($read_permisson === true) {
$access = 'AR';
}
if (! $read_permisson && !$manage_permisson) { if ($write_permisson === true) {
$access = 'AD';
}
if ($manage_permisson === true) {
$access = 'AW';
}
if ($read_permisson === false && $manage_permisson === false) {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION, AUDIT_LOG_ACL_VIOLATION,
'Trying to access downtime scheduler' 'Trying to access downtime scheduler'
@ -35,16 +61,109 @@ require_once 'include/functions_events.php';
require_once 'include/functions_planned_downtimes.php'; require_once 'include/functions_planned_downtimes.php';
require_once 'include/functions_reporting.php'; require_once 'include/functions_reporting.php';
$malformed_downtimes = planned_downtimes_get_malformed(); if (is_ajax() === true) {
$malformed_downtimes_exist = !empty($malformed_downtimes) ? true : false; $show_info_agents_modules_affected = (bool) get_parameter(
'show_info_agents_modules_affected',
false
);
$get_info_agents_modules_affected = (bool) get_parameter(
'get_info_agents_modules_affected',
false
);
if ($show_info_agents_modules_affected === true) {
$id = (int) get_parameter('id', 0);
$columns = [
'agent_name',
'module_name',
];
$column_names = [
__('Agents'),
__('Modules'),
];
ui_print_datatable(
[
'id' => 'agent_modules_affected_planned_downtime',
'class' => 'info_table',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => 'godmode/agentes/planned_downtime.list',
'ajax_data' => [
'get_info_agents_modules_affected' => 1,
'id' => $id,
],
'order' => [
'field' => 'agent_name',
'direction' => 'asc',
],
'search_button_class' => 'sub filter float-right',
'form' => [
'inputs' => [
[
'label' => __('Agents'),
'type' => 'text',
'class' => 'w200px',
'id' => 'filter_agents',
'name' => 'filter_agents',
],
[
'label' => __('Modules'),
'type' => 'text',
'class' => 'w200px',
'id' => 'filter_modules',
'name' => 'filter_modules',
],
],
],
]
);
return;
}
if ($get_info_agents_modules_affected === true) {
$id = (int) get_parameter('id', 0);
// Catch post parameters.
$options = [
'limit' => get_parameter('start', 0),
'offset' => get_parameter('length', $config['block_size']),
'order' => get_datatable_order(),
'filters' => get_parameter('filter', []),
];
$modules = get_agents_modules_planned_dowtime($id, $options);
$count = get_agents_modules_planned_dowtime($id, $options, $count);
echo json_encode(
[
'data' => $modules,
'recordsTotal' => $count[0]['total'],
'recordsFiltered' => $count[0]['total'],
]
);
return;
}
return;
}
$malformed_downtimes = planned_downtimes_get_malformed();
$malformed_downtimes_exist = (empty($malformed_downtimes) === false) ? true : false;
$migrate_malformed = (bool) get_parameter('migrate_malformed'); $migrate_malformed = (bool) get_parameter('migrate_malformed');
if ($migrate_malformed) { if ($migrate_malformed === true) {
$migration_result = planned_downtimes_migrate_malformed_downtimes(); $migration_result = planned_downtimes_migrate_malformed_downtimes();
if ($migration_result['status'] == false) { $str = 'An error occurred while migrating the malformed scheduled downtimes';
$str2 = 'Please run the migration again or contact with the administrator';
if ((bool) $migration_result['status'] === false) {
ui_print_error_message( ui_print_error_message(
__('An error occurred while migrating the malformed scheduled downtimes').'. '.__('Please run the migration again or contact with the administrator') __($str).'. '.__($str2)
); );
echo '<br>'; echo '<br>';
} }
@ -63,12 +182,15 @@ ui_print_page_header(
$id_downtime = (int) get_parameter('id_downtime', 0); $id_downtime = (int) get_parameter('id_downtime', 0);
$stop_downtime = (bool) get_parameter('stop_downtime'); $stop_downtime = (bool) get_parameter('stop_downtime');
// STOP DOWNTIME // STOP DOWNTIME.
if ($stop_downtime) { if ($stop_downtime === true) {
$downtime = db_get_row('tplanned_downtime', 'id', $id_downtime); $downtime = db_get_row('tplanned_downtime', 'id', $id_downtime);
// Check AD permission on the downtime // Check AD permission on the downtime.
if (empty($downtime) || (! check_acl($config['id_user'], $downtime['id_group'], 'AD') && ! check_acl($config['id_user'], $downtime['id_group'], 'AW'))) { if (empty($downtime) === true
|| ((bool) check_acl($config['id_user'], $downtime['id_group'], 'AD') === false
&& (bool) check_acl($config['id_user'], $downtime['id_group'], 'AW') === false)
) {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION, AUDIT_LOG_ACL_VIOLATION,
'Trying to access downtime scheduler' 'Trying to access downtime scheduler'
@ -80,7 +202,9 @@ if ($stop_downtime) {
$result = planned_downtimes_stop($downtime); $result = planned_downtimes_stop($downtime);
if ($result === false) { if ($result === false) {
ui_print_error_message(__('An error occurred stopping the scheduled downtime')); ui_print_error_message(
__('An error occurred stopping the scheduled downtime')
);
} else { } else {
echo $result['message']; echo $result['message'];
} }
@ -88,11 +212,14 @@ if ($stop_downtime) {
$delete_downtime = (int) get_parameter('delete_downtime'); $delete_downtime = (int) get_parameter('delete_downtime');
// DELETE WHOLE DOWNTIME! // DELETE WHOLE DOWNTIME!
if ($delete_downtime) { if (empty($delete_downtime) === false) {
$downtime = db_get_row('tplanned_downtime', 'id', $id_downtime); $downtime = db_get_row('tplanned_downtime', 'id', $id_downtime);
// Check AD permission on the downtime // Check AD permission on the downtime.
if (empty($downtime) || (! check_acl($config['id_user'], $downtime['id_group'], 'AD') && ! check_acl($config['id_user'], $downtime['id_group'], 'AW'))) { if (empty($downtime) === true
|| ((bool) check_acl($config['id_user'], $downtime['id_group'], 'AD') === false
&& (bool) check_acl($config['id_user'], $downtime['id_group'], 'AW') === false)
) {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION, AUDIT_LOG_ACL_VIOLATION,
'Trying to access downtime scheduler' 'Trying to access downtime scheduler'
@ -102,10 +229,13 @@ if ($delete_downtime) {
} }
// The downtime shouldn't be running!! // The downtime shouldn't be running!!
if ($downtime['executed']) { if ((bool) $downtime['executed'] === true) {
ui_print_error_message(__('This scheduled downtime is running')); ui_print_error_message(__('This scheduled downtime is running'));
} else { } else {
$result = db_process_sql_delete('tplanned_downtime', ['id' => $id_downtime]); $result = db_process_sql_delete(
'tplanned_downtime',
['id' => $id_downtime]
);
ui_print_result_message( ui_print_result_message(
$result, $result,
@ -119,15 +249,25 @@ if ($delete_downtime) {
$offset = (int) get_parameter('offset'); $offset = (int) get_parameter('offset');
$filter_params = []; $filter_params = [];
$search_text = $filter_params['search_text'] = (string) get_parameter('search_text'); $search_text = (string) get_parameter('search_text');
$date_from = $filter_params['date_from'] = (string) get_parameter('date_from'); $date_from = (string) get_parameter('date_from');
$date_to = $filter_params['date_to'] = (string) get_parameter('date_to'); $date_to = (string) get_parameter('date_to');
$execution_type = $filter_params['execution_type'] = (string) get_parameter('execution_type'); $execution_type = (string) get_parameter('execution_type');
$show_archived = $filter_params['archived'] = (bool) get_parameter('archived'); $show_archived = (bool) get_parameter('archived');
$agent_id = $filter_params['agent_id'] = (int) get_parameter('agent_id'); $agent_id = (int) get_parameter('agent_id');
$agent_name = $filter_params['agent_name'] = (string) (!empty($agent_id) ? get_parameter('agent_name') : ''); $agent_name = (string) ((empty($agent_id) === false) ? get_parameter('agent_name') : '');
$module_id = $filter_params['module_id'] = (int) get_parameter('module_name_hidden'); $module_id = (int) get_parameter('module_name_hidden');
$module_name = $filter_params['module_name'] = (string) (!empty($module_id) ? get_parameter('module_name') : ''); $module_name = (string) ((empty($module_id) === false) ? get_parameter('module_name') : '');
$filter_params['search_text'] = $search_text;
$filter_params['date_from'] = $date_from;
$filter_params['date_to'] = $date_to;
$filter_params['execution_type'] = $execution_type;
$filter_params['archived'] = $show_archived;
$filter_params['agent_id'] = $agent_id;
$filter_params['agent_name'] = $agent_name;
$filter_params['module_id'] = $module_id;
$filter_params['module_name'] = $module_name;
$filter_params_str = http_build_query($filter_params); $filter_params_str = http_build_query($filter_params);
@ -141,11 +281,32 @@ $table_form->data = [];
$row = []; $row = [];
// Search text. // Search text.
$row[] = __('Search').'&nbsp;'.html_print_input_text('search_text', $search_text, '', 50, 250, true); $row[] = __('Search').'&nbsp;'.html_print_input_text(
'search_text',
$search_text,
'',
50,
250,
true
);
// Dates. // Dates.
$date_inputs = __('From').'&nbsp;'.html_print_input_text('date_from', $date_from, '', 10, 10, true); $date_inputs = __('From').'&nbsp;'.html_print_input_text(
'date_from',
$date_from,
'',
10,
10,
true
);
$date_inputs .= '&nbsp;&nbsp;'; $date_inputs .= '&nbsp;&nbsp;';
$date_inputs .= __('To').'&nbsp;'.html_print_input_text('date_to', $date_to, '', 10, 10, true); $date_inputs .= __('To').'&nbsp;'.html_print_input_text(
'date_to',
$date_to,
'',
10,
10,
true
);
$row[] = $date_inputs; $row[] = $date_inputs;
$table_form->data[] = $row; $table_form->data[] = $row;
@ -157,9 +318,24 @@ $execution_type_fields = [
'once' => __('Once'), 'once' => __('Once'),
'periodically' => __('Periodically'), 'periodically' => __('Periodically'),
]; ];
$row[] = __('Execution type').'&nbsp;'.html_print_select($execution_type_fields, 'execution_type', $execution_type, '', __('Any'), '', true, false, false); $row[] = __('Execution type').'&nbsp;'.html_print_select(
$execution_type_fields,
'execution_type',
$execution_type,
'',
__('Any'),
'',
true,
false,
false
);
// Show past downtimes. // Show past downtimes.
$row[] = __('Show past downtimes').'&nbsp;'.html_print_checkbox('archived', 1, $show_archived, true); $row[] = __('Show past downtimes').'&nbsp;'.html_print_checkbox(
'archived',
1,
$show_archived,
true
);
$table_form->data[] = $row; $table_form->data[] = $row;
@ -178,48 +354,84 @@ $agent_input = __('Agent').'&nbsp;'.ui_print_agent_autocomplete_input($params);
$row[] = $agent_input; $row[] = $agent_input;
// Module. // Module.
$row[] = __('Module').'&nbsp;'.html_print_autocomplete_modules('module_name', $module_name, false, true, '', [], true); $row[] = __('Module').'&nbsp;'.html_print_autocomplete_modules(
'module_name',
$module_name,
false,
true,
'',
[],
true
);
$row[] = html_print_submit_button(__('Search'), 'search', false, 'class="sub search"', true); $row[] = html_print_submit_button(
__('Search'),
'search',
false,
'class="sub search"',
true
);
$table_form->data[] = $row; $table_form->data[] = $row;
// End of table filter. // End of table filter.
// Useful to know if the user has done a form filtering. // Useful to know if the user has done a form filtering.
$filter_performed = false; $filter_performed = false;
$downtimes = [];
$groups = users_get_groups(false, $access); $groups = users_get_groups(false, $access);
if (!empty($groups)) { if (empty($groups) === false) {
$where_values = '1=1'; $where_values = '1=1';
$groups_string = implode(',', array_keys($groups)); $groups_string = implode(',', array_keys($groups));
$where_values .= " AND id_group IN ($groups_string)"; $where_values .= sprintf(' AND id_group IN (%s)', $groups_string);
// WARNING: add $filter_performed = true; to any future filter. // WARNING: add $filter_performed = true; to any future filter.
if (!empty($search_text)) { if (empty($search_text) === false) {
$filter_performed = true; $filter_performed = true;
$where_values .= sprintf(
$where_values .= " AND (name LIKE '%$search_text%' OR description LIKE '%$search_text%')"; ' AND (name LIKE "%%%s%%" OR description LIKE "%%%s%%")',
$search_text,
$search_text
);
} }
if (!empty($execution_type)) { if (empty($execution_type) === false) {
$filter_performed = true; $filter_performed = true;
$where_values .= sprintf(' AND type_execution = "%s"', $execution_type);
$where_values .= " AND type_execution = '$execution_type'";
} }
if (!empty($date_from)) { if (empty($date_from) === false) {
$filter_performed = true; $filter_performed = true;
$where_values .= sprintf(
$where_values .= " AND (type_execution = 'periodically' OR (type_execution = 'once' AND date_from >= '".strtotime("$date_from 00:00:00")."'))"; ' AND (type_execution = "periodically"
OR (type_execution = "once"
AND date_from >= "%s")
)',
strtotime($date_from.' 00:00:00')
);
} }
if (!empty($date_to)) { if (empty($date_to) === false) {
$filter_performed = true; $filter_performed = true;
$periodically_monthly_w = sprintf(
$periodically_monthly_w = "type_periodicity = 'monthly' 'type_periodicity = "monthly" AND (
AND ((periodically_day_from <= '".date('d', strtotime($date_from))."' AND periodically_day_to >= '".date('d', strtotime($date_to))."') (
OR (periodically_day_from > periodically_day_to periodically_day_from <= "%s"
AND (periodically_day_from <= '".date('d', strtotime($date_from))."' OR periodically_day_to >= '".date('d', strtotime($date_to))."')))"; AND periodically_day_to >= "%s"
)
OR (
periodically_day_from > periodically_day_to
AND (
periodically_day_from <= "%s"
OR periodically_day_to >= "%s"
)
)
)',
date('d', strtotime($date_from)),
date('d', strtotime($date_to)),
date('d', strtotime($date_from)),
date('d', strtotime($date_to))
);
$periodically_weekly_days = []; $periodically_weekly_days = [];
$date_from_aux = strtotime($date_from); $date_from_aux = strtotime($date_from);
@ -229,7 +441,7 @@ if (!empty($groups)) {
while ($date_from_aux <= $date_end && $days_number < 7) { while ($date_from_aux <= $date_end && $days_number < 7) {
$weekday_actual = strtolower(date('l', $date_from_aux)); $weekday_actual = strtolower(date('l', $date_from_aux));
$periodically_weekly_days[] = "$weekday_actual = 1"; $periodically_weekly_days[] = $weekday_actual.' = 1';
$date_from_aux = ($date_from_aux + SECONDS_1DAY); $date_from_aux = ($date_from_aux + SECONDS_1DAY);
$days_number++; $days_number++;
@ -237,36 +449,60 @@ if (!empty($groups)) {
$periodically_weekly_w = "type_periodicity = 'weekly' AND (".implode(' OR ', $periodically_weekly_days).')'; $periodically_weekly_w = "type_periodicity = 'weekly' AND (".implode(' OR ', $periodically_weekly_days).')';
$periodically_w = "type_execution = 'periodically' AND (($periodically_monthly_w) OR ($periodically_weekly_w))"; $periodically_w = sprintf(
'type_execution = "periodically" AND ((%s) OR (%s))',
$periodically_monthly_w,
$periodically_weekly_w
);
$once_w = "type_execution = 'once' AND date_to <= '".strtotime("$date_to 23:59:59")."'"; $once_w = sprintf(
'type_execution = "once" AND date_to <= "%s"',
strtotime($date_to.' 23:59:59')
);
$where_values .= " AND (($periodically_w) OR ($once_w))"; $where_values .= sprintf(
' AND ((%s) OR (%s))',
$periodically_w,
$once_w
);
} }
if (!$show_archived) { if ($show_archived === false) {
$filter_performed = true; $filter_performed = true;
$where_values .= sprintf(
$where_values .= " AND (type_execution = 'periodically' OR (type_execution = 'once' AND date_to >= '".time()."'))"; ' AND (type_execution = "periodically"
OR (type_execution = "once"
AND date_to >= "%s"))',
time()
);
} }
if (!empty($agent_id)) { if (empty($agent_id) === false) {
$filter_performed = true; $filter_performed = true;
$where_values .= sprintf(
$where_values .= " AND id IN (SELECT id_downtime FROM tplanned_downtime_agents WHERE id_agent = $agent_id)"; ' AND id IN (SELECT id_downtime FROM tplanned_downtime_agents WHERE id_agent = %d)',
$agent_id
);
} }
if (!empty($module_id)) { if (empty($module_id) === false) {
$filter_performed = true; $filter_performed = true;
$where_values .= sprintf(
$where_values .= " AND (id IN (SELECT id_downtime ' AND (id IN (
SELECT id_downtime
FROM tplanned_downtime_modules FROM tplanned_downtime_modules
WHERE id_agent_module = $module_id) WHERE id_agent_module = %d)
OR id IN (SELECT id_downtime OR id IN (
SELECT id_downtime
FROM tplanned_downtime_agents tpda, tagente_modulo tam FROM tplanned_downtime_agents tpda, tagente_modulo tam
WHERE tpda.id_agent = tam.id_agente WHERE tpda.id_agent = tam.id_agente
AND tam.id_agente_modulo = $module_id AND tam.id_agente_modulo = %d
AND tpda.all_modules = 1))"; AND tpda.all_modules = 1
)
)',
$module_id,
$module_id
);
} }
// Columns of the table tplanned_downtime. // Columns of the table tplanned_downtime.
@ -296,68 +532,41 @@ if (!empty($groups)) {
'id_user', 'id_user',
]; ];
switch ($config['dbtype']) {
case 'mysql':
case 'postgresql':
$columns_str = implode(',', $columns); $columns_str = implode(',', $columns);
$sql = "SELECT $columns_str $sql = sprintf(
'SELECT %s
FROM tplanned_downtime FROM tplanned_downtime
WHERE $where_values WHERE %s
ORDER BY type_execution DESC, date_from DESC ORDER BY type_execution DESC, date_from DESC
LIMIT ".$config['block_size']." LIMIT %d
OFFSET $offset"; OFFSET %d',
break; $columns_str,
$where_values,
$config['block_size'],
$offset
);
case 'oracle': $sql_count = sprintf(
// Oracle doesn't have TIME type, so we should transform the DATE value 'SELECT COUNT(id) AS num
$new_time_from = "TO_CHAR(periodically_time_from, 'HH24:MI:SS') AS periodically_time_from";
$new_time_to = "TO_CHAR(periodically_time_to, 'HH24:MI:SS') AS periodically_time_to";
$time_from_key = array_search('periodically_time_from', $columns);
$time_to_key = array_search('periodically_time_to', $columns);
if ($time_from_key !== false) {
$columns[$time_from_key] = $new_time_from;
}
if ($time_to_key !== false) {
$columns[$time_to_key] = $new_time_to;
}
$columns_str = implode(',', $columns);
$set = [];
$set['limit'] = $config['block_size'];
$set['offset'] = $offset;
$sql = "SELECT $columns_str
FROM tplanned_downtime FROM tplanned_downtime
WHERE $where_values WHERE %s',
ORDER BY type_execution DESC, date_from DESC"; $where_values
);
$sql = oracle_recode_query($sql, $set);
break;
}
$sql_count = "SELECT COUNT(id) AS num
FROM tplanned_downtime
WHERE $where_values";
$downtimes = db_get_all_rows_sql($sql); $downtimes = db_get_all_rows_sql($sql);
$downtimes_number_res = db_get_all_rows_sql($sql_count); $downtimes_number_res = db_get_all_rows_sql($sql_count);
$downtimes_number = $downtimes_number_res != false ? $downtimes_number_res[0]['num'] : 0; $downtimes_number = ($downtimes_number_res !== false) ? $downtimes_number_res[0]['num'] : 0;
} else {
$downtimes = [];
} }
$url_list = 'index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list';
$url_editor = 'index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor';
// No downtimes cause the user has not anyone. // No downtimes cause the user has not anyone.
if (!$downtimes && !$filter_performed) { if ($downtimes === false && $filter_performed === false) {
include_once $config['homedir'].'/general/first_task/planned_downtime.php'; include_once $config['homedir'].'/general/first_task/planned_downtime.php';
} } else if ($downtimes === false) {
// No downtimes cause the user performed a search. // No downtimes cause the user performed a search.
else if (!$downtimes) {
// Filter form. // Filter form.
echo "<form method='post' action='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list'>"; echo '<form method="post" action="'.$url_list.'">';
html_print_table($table_form); html_print_table($table_form);
echo '</form>'; echo '</form>';
@ -367,22 +576,25 @@ else if (!$downtimes) {
echo '<div class="action-buttons w100p" >'; echo '<div class="action-buttons w100p" >';
// Create button. // Create button.
if ($write_permisson) { if ($write_permisson === true) {
echo '&nbsp;'; echo '&nbsp;';
echo '<form method="post" class="display_in" action="index.php?sec=extensions&amp;sec2=godmode/agentes/planned_downtime.editor">'; echo '<form method="post" class="display_in" action="'.$url_editor.'">';
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"'); html_print_submit_button(__('Create'), 'create', false, 'class="sub next"');
echo '</form>'; echo '</form>';
} }
echo '</div>'; echo '</div>';
} } else {
// Has downtimes. // Has downtimes.
else { echo '<form method="post" action="'.$url_list.'">';
echo "<form method='post' action='index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list'>";
html_print_table($table_form); html_print_table($table_form);
echo '</form>'; echo '</form>';
ui_pagination($downtimes_number, "index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list&$filter_params_str", $offset); ui_pagination(
$downtimes_number,
$url_list.'&'.$filter_params_str,
$offset
);
// User groups with AR, AD or AW permission. // User groups with AR, AD or AW permission.
$groupsAD = users_get_groups($config['id_user'], $access); $groupsAD = users_get_groups($config['id_user'], $access);
@ -402,8 +614,11 @@ else {
$table->head['execution'] = __('Execution'); $table->head['execution'] = __('Execution');
$table->head['configuration'] = __('Configuration'); $table->head['configuration'] = __('Configuration');
$table->head['running'] = __('Running'); $table->head['running'] = __('Running');
$table->head['agents_modules'] = __('Affected');
if ($write_permisson || $manage_permisson) { if ($write_permisson === true
|| $manage_permisson === true
) {
$table->head['stop'] = __('Stop downtime'); $table->head['stop'] = __('Stop downtime');
$table->head['copy'] = __('Copy'); $table->head['copy'] = __('Copy');
$table->head['edit'] = __('Edit'); $table->head['edit'] = __('Edit');
@ -414,7 +629,9 @@ else {
$table->align['group'] = 'center'; $table->align['group'] = 'center';
$table->align['running'] = 'center'; $table->align['running'] = 'center';
if ($write_permisson || $manage_permisson) { if ($write_permisson === true
|| $manage_permisson === true
) {
$table->align['stop'] = 'center'; $table->align['stop'] = 'center';
$table->align['edit'] = 'center'; $table->align['edit'] = 'center';
$table->align['delete'] = 'center'; $table->align['delete'] = 'center';
@ -430,7 +647,7 @@ else {
WHERE id_downtime = '.$downtime['id'] WHERE id_downtime = '.$downtime['id']
); );
$data['name'] = $downtime['name']." ($total)"; $data['name'] = $downtime['name'].' ('.$total.')';
$data['description'] = $downtime['description']; $data['description'] = $downtime['description'];
$data['group'] = ui_print_group_icon($downtime['id_group'], true); $data['group'] = ui_print_group_icon($downtime['id_group'], true);
@ -451,7 +668,7 @@ else {
$data['configuration'] = reporting_format_planned_downtime_dates($downtime); $data['configuration'] = reporting_format_planned_downtime_dates($downtime);
if ($downtime['executed'] == 0) { if ((int) $downtime['executed'] === 0) {
$data['running'] = html_print_image( $data['running'] = html_print_image(
'images/pixel_red.png', 'images/pixel_red.png',
true, true,
@ -473,44 +690,124 @@ else {
); );
} }
$settings = [
'url' => ui_get_full_url('ajax.php', false, false, false),
'loadingText' => __('Loading, this operation might take several minutes...'),
'title' => __('Agents / Modules affected'),
'id' => $downtime['id'],
];
$data['agents_modules'] = '<a href="#" onclick=\'dialogAgentModulesAffected('.json_encode($settings).')\'>';
$data['agents_modules'] .= html_print_image(
'images/search_big.png',
true,
[
'title' => __('Agents and modules affected'),
'style' => 'width:22px; height: 22px;',
]
);
$data['agents_modules'] .= '</a>';
// If user have writting permissions. // If user have writting permissions.
if (in_array($downtime['id_group'], $groupsAD)) { if (in_array($downtime['id_group'], $groupsAD) === true) {
// Stop button // Stop button.
if ($downtime['type_execution'] == 'once' && $downtime['executed'] == 1) { if ($downtime['type_execution'] === 'once'
if (check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW') && (int) $downtime['executed'] === 1
|| check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AD')
) { ) {
$data['stop'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list'.'&stop_downtime=1&id_downtime='.$downtime['id'].'&'.$filter_params_str.'">'.html_print_image('images/cancel.png', true, ['title' => __('Stop downtime')]); if ((bool) check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW') === true
|| (bool) check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AD') === true
) {
$url_list_params = $url_list.'&stop_downtime=1&id_downtime='.$downtime['id'].'&'.$filter_params_str;
$data['stop'] = '<a href="'.$url_list_params.'">';
$data['stop'] .= html_print_image(
'images/cancel.png',
true,
['title' => __('Stop downtime')]
);
} else { } else {
$data['stop'] = html_print_image('images/cancel.png', true, ['title' => __('Stop downtime')]); $data['stop'] = html_print_image(
'images/cancel.png',
true,
['title' => __('Stop downtime')]
);
} }
} else { } else {
$data['stop'] = ''; $data['stop'] = '';
} }
// Edit & delete buttons. // Edit & delete buttons.
if ($downtime['executed'] == 0) { if ((int) $downtime['executed'] === 0) {
if (check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW') if ((bool) check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW') === true
|| check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AD') || (bool) check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AD') === true
) { ) {
// Copy. // Copy.
$data['copy'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&downtime_copy=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/copy.png', true, ['title' => __('Copy'), 'class' => 'invert_filter']).'</a>'; $data['copy'] = '<a href="'.$url_editor.'&downtime_copy=1&id_downtime='.$downtime['id'].'">';
$data['copy'] .= html_print_image(
'images/copy.png',
true,
[
'title' => __('Copy'),
'class' => 'invert_filter',
]
);
$data['copy'] .= '</a>';
// Edit. // Edit.
$data['edit'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&edit_downtime=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/config.png', true, ['title' => __('Update'), 'class' => 'invert_filter']).'</a>'; $data['edit'] = '<a href="'.$url_editor.'&edit_downtime=1&id_downtime='.$downtime['id'].'">';
$data['edit'] .= html_print_image(
'images/config.png',
true,
[
'title' => __('Update'),
'class' => 'invert_filter',
]
);
$data['edit'] .= '</a>';
// Delete. // Delete.
$data['delete'] = '<a id="delete_downtime" href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list'.'&delete_downtime=1&id_downtime='.$downtime['id'].'&'.$filter_params_str.'">'.html_print_image('images/cross.png', true, ['title' => __('Delete'), 'class' => 'invert_filter']); $url_delete = $url_list.'&delete_downtime=1&id_downtime='.$downtime['id'].'&'.$filter_params_str;
$data['delete'] = '<a id="delete_downtime" href="'.$url_delete.'">';
$data['delete'] .= html_print_image(
'images/cross.png',
true,
[
'title' => __('Delete'),
'class' => 'invert_filter',
]
);
$data['delete'] .= '</a>';
} else { } else {
$data['edit'] = ''; $data['edit'] = '';
$data['delete'] = ''; $data['delete'] = '';
} }
} else if ($downtime['executed'] == 1 && $downtime['type_execution'] == 'once') { } else if ((int) $downtime['executed'] === 1
if (check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW') && $downtime['type_execution'] === 'once'
|| check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AD') ) {
if ((bool) check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AW') === true
|| (bool) check_acl_restricted_all($config['id_user'], $downtime['id_group'], 'AD') === true
) { ) {
// Copy. // Copy.
$data['copy'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&downtime_copy=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/copy.png', true, ['title' => __('Copy'), 'class' => 'invert_filter']).'</a>'; $data['copy'] = '<a href="'.$url_editor.'&downtime_copy=1&id_downtime='.$downtime['id'].'">';
$data['copy'] .= html_print_image(
'images/copy.png',
true,
[
'title' => __('Copy'),
'class' => 'invert_filter',
]
);
$data['copy'] .= '</a>';
// Edit. // Edit.
$data['edit'] = '<a href="index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.editor&edit_downtime=1&id_downtime='.$downtime['id'].'">'.html_print_image('images/config.png', true, ['title' => __('Update'), 'class' => 'invert_filter']).'</a>'; $data['edit'] = '<a href="'.$url_editor.'&edit_downtime=1&id_downtime='.$downtime['id'].'">';
$data['edit'] .= html_print_image(
'images/config.png',
true,
[
'title' => __('Update'),
'class' => 'invert_filter',
]
);
$data['edit'] .= '</a>';
// Delete. // Delete.
$data['delete'] = __('N/A'); $data['delete'] = __('N/A');
} else { } else {
@ -529,7 +826,9 @@ else {
$data['delete'] = ''; $data['delete'] = '';
} }
if (!empty($malformed_downtimes_exist) && isset($malformed_downtimes[$downtime['id']])) { if (empty($malformed_downtimes_exist) === false
&& isset($malformed_downtimes[$downtime['id']]) === true
) {
$next_row_num = count($table->data); $next_row_num = count($table->data);
$table->cellstyle[$next_row_num][0] = 'color: red'; $table->cellstyle[$next_row_num][0] = 'color: red';
$table->cellstyle[$next_row_num][1] = 'color: red'; $table->cellstyle[$next_row_num][1] = 'color: red';
@ -542,7 +841,17 @@ else {
} }
html_print_table($table); html_print_table($table);
ui_pagination($downtimes_number, "index.php?sec=extensions&sec2=godmode/agentes/planned_downtime.list&$filter_params_str", $offset, 0, false, 'offset', true, 'pagination-bottom'); ui_pagination(
$downtimes_number,
$url_list.'&'.$filter_params_str,
$offset,
0,
false,
'offset',
true,
'pagination-bottom'
);
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
// CSV export button. // CSV export button.
@ -551,32 +860,44 @@ else {
__('Export to CSV'), __('Export to CSV'),
'csv_export', 'csv_export',
false, false,
"location.href='godmode/agentes/planned_downtime.export_csv.php?$filter_params_str'", 'location.href="godmode/agentes/planned_downtime.export_csv.php?'.$filter_params_str.'"',
'class="sub next"' 'class="sub next"'
); );
echo '</div>'; echo '</div>';
// Create button. // Create button.
if ($write_permisson) { if ($write_permisson === true) {
echo '&nbsp;'; echo '&nbsp;';
echo '<form method="post" action="index.php?sec=extensions&amp;sec2=godmode/agentes/planned_downtime.editor" class="display_in" >'; echo '<form method="post" action="'.$url_editor.'" class="display_in" >';
html_print_submit_button(__('Create'), 'create', false, 'class="sub next"'); html_print_submit_button(
__('Create'),
'create',
false,
'class="sub next"'
);
echo '</form>'; echo '</form>';
} }
echo '</div>'; echo '</div>';
} }
ui_require_jquery_file('ui.datepicker-'.get_user_language(), 'include/javascript/i18n/'); ui_require_jquery_file(
'ui.datepicker-'.get_user_language(),
'include/javascript/i18n/'
);
ui_require_javascript_file('pandora_planned_downtimes');
?> ?>
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
$("input[name=module_name_hidden]").val(<?php echo (int) $module_id; ?>); $("input[name=module_name_hidden]").val(<?php echo (int) $module_id; ?>);
$(document).ready (function () { $(document).ready (function () {
$("#text-date_from, #text-date_to").datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"}); $("#text-date_from, #text-date_to")
$.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]); .datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
$.datepicker
.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]);
$("a#delete_downtime").click(function (e) { $("a#delete_downtime").click(function (e) {
if (!confirm("<?php echo __('WARNING: If you delete this scheduled downtime, it will not be taken into account in future SLA reports'); ?>")) { if (!confirm("<?php echo __('WARNING: If you delete this scheduled downtime, it will not be taken into account in future SLA reports'); ?>")) {

View File

@ -64,6 +64,40 @@ require_once $config['homedir'].'/include/functions_users.php';
$create_profiles = (int) get_parameter('create_profiles'); $create_profiles = (int) get_parameter('create_profiles');
// Get users and groups user can manage to check and for selectors.
$group_um = users_get_groups_UM($config['id_user']);
$users_profiles = '';
$users_order = [
'field' => 'id_user',
'order' => 'ASC',
];
$info_users = [];
// Is admin.
if (users_is_admin()) {
$info_users = users_get_info($users_order, 'id_user');
// has PM permission.
} else if (check_acl($config['id_user'], 0, 'PM')) {
$info_users = users_get_info($users_order, 'id_user');
foreach ($info_users as $id_user => $value) {
if (users_is_admin($id_user)) {
unset($info_users[$value]);
}
}
} else {
$info = [];
foreach ($group_um as $group => $value) {
$info = array_merge($info, users_get_users_by_group($group, $value));
}
foreach ($info as $key => $value) {
if (!$value['is_admin']) {
$info_users[$key] = $value['id_user'];
}
}
}
if ($create_profiles) { if ($create_profiles) {
$profiles_id = get_parameter('profiles_id', -1); $profiles_id = get_parameter('profiles_id', -1);
$groups_id = get_parameter('groups_id', -1); $groups_id = get_parameter('groups_id', -1);
@ -74,8 +108,42 @@ if ($create_profiles) {
$result = false; $result = false;
} else { } else {
foreach ($profiles_id as $profile) { foreach ($profiles_id as $profile) {
// Check profiles permissions for non admin user.
if (is_user_admin($config['user_id']) === false) {
$user_profiles = profile_get_profiles(
[
'pandora_management' => '<> 1',
'db_management' => '<> 1',
]
);
if (array_search((int) $profile, array_keys($user_profiles)) === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to add administrator profile whith standar user for user '.io_safe_input($user)
);
exit;
}
}
foreach ($groups_id as $group) { foreach ($groups_id as $group) {
if (check_acl($config['id_user'], $group, 'UM') === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to add profile group without permission for user '.io_safe_input($user)
);
exit;
}
foreach ($users_id as $user) { foreach ($users_id as $user) {
if (array_search($user, $info_users) === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to edit user without permission for user '.io_safe_input($user)
);
exit;
}
$profile_data = db_get_row_filter('tusuario_perfil', ['id_usuario' => $user, 'id_perfil' => $profile, 'id_grupo' => $group]); $profile_data = db_get_row_filter('tusuario_perfil', ['id_usuario' => $user, 'id_perfil' => $profile, 'id_grupo' => $group]);
// If the profile doesnt exist, we create it // If the profile doesnt exist, we create it
if ($profile_data === false) { if ($profile_data === false) {
@ -142,7 +210,6 @@ $table->size[2] = '33%';
$data = []; $data = [];
$data[0] = '<form method="post" id="form_profiles" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_users&option=add_profiles">'; $data[0] = '<form method="post" id="form_profiles" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_users&option=add_profiles">';
$group_um = users_get_groups_UM($config['id_user']);
$display_all_group = true; $display_all_group = true;
if (check_acl($config['id_user'], 0, 'PM')) { if (check_acl($config['id_user'], 0, 'PM')) {
@ -205,36 +272,6 @@ $data[1] = html_print_select_groups(
$data[2] = '<span id="alerts_loading" class="invisible">'; $data[2] = '<span id="alerts_loading" class="invisible">';
$data[2] .= html_print_image('images/spinner.png', true); $data[2] .= html_print_image('images/spinner.png', true);
$data[2] .= '</span>'; $data[2] .= '</span>';
$users_profiles = '';
$users_order = [
'field' => 'id_user',
'order' => 'ASC',
];
$info_users = [];
// Is admin.
if (users_is_admin()) {
$info_users = users_get_info($users_order, 'id_user');
// has PM permission.
} else if (check_acl($config['id_user'], 0, 'PM')) {
$info_users = users_get_info($users_order, 'id_user');
foreach ($info_users as $id_user => $value) {
if (users_is_admin($id_user)) {
unset($info_users[$value]);
}
}
} else {
$info = [];
foreach ($group_um as $group => $value) {
$info = array_merge($info, users_get_users_by_group($group, $value));
}
foreach ($info as $key => $value) {
if (!$value['is_admin']) {
$info_users[$key] = $value['id_user'];
}
}
}
$data[2] .= html_print_select( $data[2] .= html_print_select(
$info_users, $info_users,

View File

@ -743,6 +743,7 @@ switch ($action) {
break; break;
case 'agent_module': case 'agent_module':
case 'agent_module_status':
$description = $item['description']; $description = $item['description'];
$es = json_decode($item['external_source'], true); $es = json_decode($item['external_source'], true);
@ -4744,6 +4745,7 @@ $(document).ready (function () {
switch (type){ switch (type){
case 'agent_module': case 'agent_module':
case 'agent_module_status':
case 'alert_report_actions': case 'alert_report_actions':
var agents_multiple = $('#id_agents2').val(); var agents_multiple = $('#id_agents2').val();
var modules_multiple = $('#module').val(); var modules_multiple = $('#module').val();
@ -4878,6 +4880,7 @@ $(document).ready (function () {
} }
switch (type){ switch (type){
case 'agent_module': case 'agent_module':
case 'agent_module_status':
case 'alert_report_actions': case 'alert_report_actions':
var agents_multiple = $('#id_agents2').val(); var agents_multiple = $('#id_agents2').val();
var modules_multiple = $('#module').val(); var modules_multiple = $('#module').val();
@ -6345,9 +6348,10 @@ function chooseType() {
break; break;
case 'agent_module': case 'agent_module':
$("#row_module_group").show();
case 'agent_module_status':
$("#row_description").show(); $("#row_description").show();
$("#row_group").show(); $("#row_group").show();
$("#row_module_group").show();
$("#select_agent_modules").show(); $("#select_agent_modules").show();
$("#agents_modules_row").show(); $("#agents_modules_row").show();
$("#modules_row").show(); $("#modules_row").show();

View File

@ -1655,6 +1655,7 @@ switch ($action) {
break; break;
case 'agent_module': case 'agent_module':
case 'agent_module_status':
$agents_to_report_text = get_parameter('id_agents2-multiple-text', ''); $agents_to_report_text = get_parameter('id_agents2-multiple-text', '');
$modules_to_report_text = get_parameter('module-multiple-text', ''); $modules_to_report_text = get_parameter('module-multiple-text', '');
@ -2456,6 +2457,7 @@ switch ($action) {
break; break;
case 'agent_module': case 'agent_module':
case 'agent_module_status':
$agents_to_report_text = get_parameter('id_agents2-multiple-text'); $agents_to_report_text = get_parameter('id_agents2-multiple-text');
$modules_to_report_text = get_parameter('module-multiple-text', ''); $modules_to_report_text = get_parameter('module-multiple-text', '');

View File

@ -324,6 +324,16 @@ if ($create_user) {
$user_is_admin = (int) get_parameter('is_admin', 0); $user_is_admin = (int) get_parameter('is_admin', 0);
if (users_is_admin() === false && $user_is_admin !== 0) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to create with administrator privileges to user by non administrator user '.$config['id_user']
);
include 'general/noaccess.php';
exit;
}
$values = []; $values = [];
$values['id_user'] = (string) get_parameter('id_user'); $values['id_user'] = (string) get_parameter('id_user');
$values['fullname'] = (string) get_parameter('fullname'); $values['fullname'] = (string) get_parameter('fullname');
@ -538,6 +548,16 @@ if ($update_user) {
$values['default_event_filter'] = (int) get_parameter('default_event_filter'); $values['default_event_filter'] = (int) get_parameter('default_event_filter');
$values['default_custom_view'] = (int) get_parameter('default_custom_view'); $values['default_custom_view'] = (int) get_parameter('default_custom_view');
if (users_is_admin() === false && (bool) $values['is_admin'] !== false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to add administrator privileges to user by non administrator user '.$config['id_user']
);
include 'general/noaccess.php';
exit;
}
// eHorus user level conf. // eHorus user level conf.
$values['ehorus_user_level_enabled'] = (bool) get_parameter('ehorus_user_level_enabled', false); $values['ehorus_user_level_enabled'] = (bool) get_parameter('ehorus_user_level_enabled', false);
$values['ehorus_user_level_user'] = (string) get_parameter('ehorus_user_level_user'); $values['ehorus_user_level_user'] = (string) get_parameter('ehorus_user_level_user');

View File

@ -260,9 +260,21 @@ if (is_metaconsole() === true) {
$disable_user = get_parameter('disable_user', false); $disable_user = get_parameter('disable_user', false);
if ((bool) get_parameter('user_del', false) === true) { $delete_user = (bool) get_parameter('user_del', false);
if ($delete_user === true) {
// Delete user. // Delete user.
$id_user = get_parameter('delete_user', 0); $id_user = get_parameter('delete_user', 0);
if (users_is_admin($id_user) === true && users_is_admin() === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to delete admininstrator user by non administrator user '.$config['id_user']
);
include 'general/noaccess.php';
exit;
}
// Only allow delete user if is not the actual user. // Only allow delete user if is not the actual user.
if ($id_user != $config['id_user']) { if ($id_user != $config['id_user']) {
$user_row = users_get_user_by_id($id_user); $user_row = users_get_user_by_id($id_user);
@ -332,6 +344,16 @@ if ((bool) get_parameter('user_del', false) === true) {
// Disable_user. // Disable_user.
$id_user = get_parameter('id', 0); $id_user = get_parameter('id', 0);
if (users_is_admin($id_user) === true && users_is_admin() === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to disable admininstrator user by non administrator user '.$config['id_user']
);
include 'general/noaccess.php';
exit;
}
if ($id_user !== 0) { if ($id_user !== 0) {
$result = users_disable($id_user, $disable_user); $result = users_disable($id_user, $disable_user);
} else { } else {
@ -545,6 +567,13 @@ if ($search) {
} }
} }
foreach ($info1 as $user_id => $user_info) {
// If user is not admin then don't display admin users.
if ($user_is_admin === false && (bool) $user_info['is_admin'] === true) {
unset($info1[$user_id]);
}
}
$info = $info1; $info = $info1;
// Prepare pagination. // Prepare pagination.
@ -557,11 +586,6 @@ $rowPair = true;
$iterator = 0; $iterator = 0;
$cont = 0; $cont = 0;
foreach ($info as $user_id => $user_info) { foreach ($info as $user_id => $user_info) {
if (!$user_is_admin && $user_info['is_admin']) {
// If user is not admin then don't display admin users.
continue;
}
// User profiles. // User profiles.
if ($user_is_admin || $user_id == $config['id_user'] || isset($group_um[0])) { if ($user_is_admin || $user_id == $config['id_user'] || isset($group_um[0])) {
$user_profiles = db_get_all_rows_field_filter( $user_profiles = db_get_all_rows_field_filter(
@ -853,6 +877,7 @@ if ($is_management_allowed === true) {
} }
} }
echo '</div>'; echo '</div>';
enterprise_hook('close_meta_frame'); enterprise_hook('close_meta_frame');

View File

@ -544,11 +544,6 @@ class AgentWizard extends HTML
// Get the servers. // Get the servers.
$rows = get_proxy_servers(); $rows = get_proxy_servers();
// Check if satellite server has remote configuration enabled.
$satellite_remote = config_agents_has_remote_configuration(
$this->idAgent
);
// Generate a list with allowed servers. // Generate a list with allowed servers.
if (isset($rows) === true && is_array($rows) === true) { if (isset($rows) === true && is_array($rows) === true) {
foreach ($rows as $row) { foreach ($rows as $row) {

View File

@ -158,7 +158,9 @@ class CredentialStore extends Wizard
// Check access. // Check access.
check_login(); check_login();
if (! check_acl($config['id_user'], 0, 'AR')) { if ((bool) check_acl($config['id_user'], 0, 'PM') === false
|| (bool) check_acl($config['id_user'], 0, 'UM') === false
) {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION, AUDIT_LOG_ACL_VIOLATION,
'Trying to access credential store' 'Trying to access credential store'

View File

@ -20,7 +20,7 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC220308'; $build_version = 'PC220311';
$pandora_version = 'v7.0NG.760'; $pandora_version = 'v7.0NG.760';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.

View File

@ -750,6 +750,7 @@ function agents_get_agents_selected($group)
'id_tmetaconsole_setup', 'id_tmetaconsole_setup',
'id_agente', 'id_agente',
'alias', 'alias',
'server_name',
], ],
'AR', 'AR',
[ [
@ -764,7 +765,7 @@ function agents_get_agents_selected($group)
$all = array_reduce( $all = array_reduce(
$all, $all,
function ($carry, $item) { function ($carry, $item) {
$carry[$item['id_tmetaconsole_setup'].'|'.$item['id_tagente']] = $item['alias']; $carry[$item['id_tmetaconsole_setup'].'|'.$item['id_tagente']] = $item['server_name'].' &raquo; '.$item['alias'];
return $carry; return $carry;
}, },
[] []
@ -1243,6 +1244,11 @@ function agents_get_group_agents(
unset($search['string']); unset($search['string']);
} }
if (isset($search['matchIds']) === true && is_array($search['matchIds']) === true) {
$filter[] = sprintf('id_agente IN (%s)', implode(', ', $search['matchIds']));
unset($search['matchIds']);
}
if (isset($search['name']) === true) { if (isset($search['name']) === true) {
$name = io_safe_input($search['name']); $name = io_safe_input($search['name']);
$filter[] = "nombre LIKE '$name'"; $filter[] = "nombre LIKE '$name'";
@ -3223,8 +3229,8 @@ function agents_get_network_interfaces($agents=false, $agents_filter=false)
$ni_by_agents = []; $ni_by_agents = [];
foreach ($agents as $agent) { foreach ($agents as $agent) {
$agent_id = (isset($agent['id_agente'])) ? $agent['id_agente'] : $agent; $agent_id = (isset($agent['id_agente'])) ? $agent['id_agente'] : $agent;
$agent_group_id = $agent['id_grupo']; $agent_group_id = (isset($agent['id_grupo']) === true) ? $agent['id_grupo'] : '';
$agent_name = $agent['alias']; $agent_name = (isset($agent['alias']) === true) ? $agent['alias'] : '';
$agent_interfaces = []; $agent_interfaces = [];
$accepted_module_types = []; $accepted_module_types = [];
@ -4180,3 +4186,78 @@ function get_planned_downtime_agents_list($id_downtime, $filter_cond, $id_groups
return $agents; return $agents;
} }
/**
* Agent Module status and data
*
* @param integer $id_group Group
* @param array $agents Agents filter.
* @param array $modules Modules filter.
*
* @return array Result.
*/
function get_status_data_agent_modules($id_group, $agents=[], $modules=[])
{
$slq_filter_group = '';
if (empty($id_group) === false) {
$slq_filter_group = sprintf(
' AND tagente.id_grupo = %d',
$id_group
);
}
$slq_filter_agent = '';
if (empty($agents) === false) {
$slq_filter_agent = sprintf(
' AND tagente_modulo.id_agente IN (%s)',
implode(',', $agents)
);
}
$slq_filter_module = '';
if (empty($modules) === false) {
$slq_filter_module = sprintf(
' AND tagente_modulo.id_agente_modulo IN (%s)',
implode(',', $modules)
);
}
$sql = sprintf(
'SELECT tagente_modulo.id_agente_modulo as id_agent_module,
tagente_modulo.nombre as name_module,
tagente_modulo.unit as unit_module,
tagente_modulo.id_agente as id_agent,
tagente_estado.datos as data_module,
tagente_estado.timestamp as data_time_module,
tagente_estado.estado as status_module,
tagente.alias as name_agent,
tagente.id_grupo as id_group,
tgrupo.nombre as name_group
FROM tagente_modulo
INNER JOIN tagente_estado
ON tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
INNER JOIN tagente
ON tagente_modulo.id_agente = tagente.id_agente
LEFT JOIN tagent_secondary_group
ON tagente.id_agente = tagent_secondary_group.id_agent
INNER JOIN tgrupo
ON tagente.id_grupo = tgrupo.id_grupo
WHERE 1=1
%s
%s
%s
',
$slq_filter_group,
$slq_filter_agent,
$slq_filter_module
);
$res = db_get_all_rows_sql($sql);
if ($res === false) {
$res = [];
}
return $res;
}

View File

@ -4936,7 +4936,13 @@ function html_print_input($data, $wrapper='div', $input_only=false)
((isset($data['size']) === true) ? $data['size'] : false), ((isset($data['size']) === true) ? $data['size'] : false),
((isset($data['modal']) === true) ? $data['modal'] : false), ((isset($data['modal']) === true) ? $data['modal'] : false),
((isset($data['message']) === true) ? $data['message'] : ''), ((isset($data['message']) === true) ? $data['message'] : ''),
((isset($data['select_all']) === true) ? $data['select_all'] : false) ((isset($data['select_all']) === true) ? $data['select_all'] : false),
((isset($data['simple_multiple_options']) === true) ? $data['simple_multiple_options'] : false),
((isset($data['required']) === true) ? $data['required'] : false),
((isset($data['truncate_size']) === true) ? $data['truncate_size'] : false),
((isset($data['select2_enable']) === true) ? $data['select2_enable'] : true),
((isset($data['select2_multiple_enable']) === true) ? $data['select2_multiple_enable'] : false),
((isset($data['select2_multiple_enable_all']) === true) ? $data['select2_multiple_enable_all'] : false)
); );
break; break;

View File

@ -989,7 +989,7 @@ function planned_downtimes_copy($id_downtime)
foreach ($planned_modules as $planned_module) { foreach ($planned_modules as $planned_module) {
// Unset id. // Unset id.
unset($planned_module['id']); unset($planned_module['id']);
// Set id_planned downtime // Set id_planned downtime.
$planned_module['id_downtime'] = $result['id_downtime']; $planned_module['id_downtime'] = $result['id_downtime'];
$result['id_modules'][] = db_process_sql_insert( $result['id_modules'][] = db_process_sql_insert(
'tplanned_downtime_moduless', 'tplanned_downtime_moduless',
@ -1004,3 +1004,82 @@ function planned_downtimes_copy($id_downtime)
return $result; return $result;
} }
/**
* Get agentts and modules for planned_downtime.
*
* @param [type] $id Id planned.
*
* @return array Result array data.
*/
function get_agents_modules_planned_dowtime($id, $options, $count=false)
{
$result = [];
$filters_agent = '';
if (isset($options['filters']['filter_agents']) === true
&& empty($options['filters']['filter_agents']) === false
) {
$filters_agent = sprintf(
' AND (tagente.alias LIKE "%%%s%%")',
$options['filters']['filter_agents']
);
}
$filters_module = '';
if (isset($options['filters']['filter_modules']) === true
&& empty($options['filters']['filter_modules']) === false
) {
$filters_module = sprintf(
' AND (tagente_modulo.nombre LIKE "%%%s%%")',
$options['filters']['filter_modules']
);
}
if ($count === false) {
$query = sprintf(
'SELECT tplanned_downtime_modules.*,
tagente.alias as agent_name,
tagente_modulo.nombre as module_name
FROM tplanned_downtime_modules
INNER JOIN tagente
ON tplanned_downtime_modules.id_agent = tagente.id_agente
INNER JOIN tagente_modulo
ON tplanned_downtime_modules.id_agent_module = tagente_modulo.id_agente_modulo
WHERE id_downtime = %d
%s
%s
ORDER BY %s
LIMIT %d, %d',
$id,
$filters_agent,
$filters_module,
$options['order'],
$options['limit'],
$options['offset']
);
} else {
$query = sprintf(
'SELECT count(tplanned_downtime_modules.id) as total
FROM tplanned_downtime_modules
INNER JOIN tagente
ON tplanned_downtime_modules.id_agent = tagente.id_agente
INNER JOIN tagente_modulo
ON tplanned_downtime_modules.id_agent_module = tagente_modulo.id_agente_modulo
WHERE id_downtime = %d
%s
%s',
$id,
$filters_agent,
$filters_module
);
}
$result = db_get_all_rows_sql($query);
if ($result === false) {
$result = [];
}
return $result;
}

View File

@ -730,6 +730,13 @@ function reporting_make_reporting_data(
); );
break; break;
case 'agent_module_status':
$report['contents'][] = reporting_agent_module_status(
$report,
$content
);
break;
case 'alert_report_actions': case 'alert_report_actions':
$report['contents'][] = reporting_alert_report_actions( $report['contents'][] = reporting_alert_report_actions(
$report, $report,
@ -2854,6 +2861,136 @@ function reporting_agent_module($report, $content)
} }
/**
* Agents module status
*
* @param array $report Info Report.
* @param array $content Info content.
*
* @return array
*/
function reporting_agent_module_status($report, $content)
{
global $config;
$return['type'] = 'agent_module_status';
if (empty($content['name'])) {
$content['name'] = __('Agent/Modules Status');
}
$return['title'] = io_safe_output($content['name']);
$return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak'];
$group_name = groups_get_name($content['id_group'], true);
if ($content['id_module_group'] == 0) {
$module_group_name = __('All');
} else {
$module_group_name = db_get_value(
'name',
'tmodule_group',
'id_mg',
$content['id_module_group']
);
}
$return['subtitle'] = $group_name.' - '.$module_group_name;
$return['description'] = io_safe_output($content['description']);
$return['date'] = reporting_get_date_text($report, $content);
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
$return['data'] = [];
$external_source = json_decode(
$content['external_source'],
true
);
$agents = json_decode(
io_safe_output(
base64_decode($external_source['id_agents'])
),
true
);
$modules = json_decode(
io_safe_output(
base64_decode($external_source['module'])
),
true
);
if (is_metaconsole() === true) {
$agents_per_node = [];
$modules_per_node = [];
if (empty($agents) === false) {
foreach ($agents as $value) {
$agent_array = explode('|', $value);
$agents_per_node[$agent_array[0]][] = $agent_array[1];
}
}
if (empty($modules) === false) {
foreach ($modules as $value) {
$module_array = explode('|', $value);
$modules_per_node[$module_array[0]][] = $module_array[1];
}
}
if (empty($agents_per_node) === false) {
foreach ($agents_per_node as $server => $agents) {
$connection = metaconsole_get_connection_by_id($server);
if (metaconsole_connect($connection) != NOERR) {
continue;
}
$res[$connection['server_name']] = get_status_data_agent_modules(
$content['id_group'],
$agents,
$modules_per_node[$server]
);
metaconsole_restore_db();
}
} else {
$metaconsole_connections = metaconsole_get_connection_names();
// For all nodes.
if (isset($metaconsole_connections) === true
&& is_array($metaconsole_connections) === true
) {
foreach ($metaconsole_connections as $metaconsole) {
// Get server connection data.
$server_data = metaconsole_get_connection($metaconsole);
// Establishes connection.
if (metaconsole_load_external_db($server_data) !== NOERR) {
continue;
}
$res[$server_data['server_name']] = get_status_data_agent_modules(
$content['id_group'],
$agents,
$modules
);
metaconsole_restore_db();
}
}
}
} else {
$res['node'] = get_status_data_agent_modules(
$content['id_group'],
$agents,
$modules
);
}
$return['data'] = $res;
return reporting_check_structure_content($return);
}
function reporting_exception( function reporting_exception(
$report, $report,
$content, $content,
@ -11049,11 +11186,29 @@ function reporting_get_stats_users($data)
$tdata = []; $tdata = [];
$tdata[0] = html_print_image('images/user.png', true, ['title' => __('Defined users'), 'class' => 'invert_filter']); $tdata[0] = html_print_image('images/user.png', true, ['title' => __('Defined users'), 'class' => 'invert_filter']);
$user_groups = users_get_strict_mode_groups($config['id_user'], false); $user_is_admin = users_is_admin();
if (array_key_exists(0, $user_groups)) {
$users = users_get_user_users($config['id_user'], 'AR', true); $users = [];
if ($user_is_admin) {
$users = get_users('', ['disabled' => 0], ['id_user', 'is_admin']);
} else { } else {
$users = users_get_user_users($config['id_user'], 'AR', false); $group_um = users_get_groups_UM($config['id_user']);
// 0 is the group 'all'.
if (isset($group_um[0])) {
$users = get_users('', ['disabled' => 0], ['id_user', 'is_admin']);
} else {
foreach ($group_um as $group => $value) {
$users = array_merge($users, users_get_users_by_group($group, $value, false));
}
}
}
foreach ($users as $user_id => $user_info) {
// If user is not admin then don't display admin users.
if ($user_is_admin === false && (bool) $user_info['is_admin'] === true) {
unset($users[$user_id]);
}
} }
$tdata[1] = count($users); $tdata[1] = count($users);

View File

@ -377,6 +377,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1)
reporting_html_agent_module($table, $item); reporting_html_agent_module($table, $item);
break; break;
case 'agent_module_status':
reporting_html_agent_module_status($table, $item);
break;
case 'alert_report_actions': case 'alert_report_actions':
reporting_html_alert_report_actions($table, $item); reporting_html_alert_report_actions($table, $item);
break; break;
@ -1999,6 +2003,125 @@ function reporting_html_agent_module($table, $item)
} }
/**
* Html report agent modules status.
*
* @param object $table Head table or false if it comes from pdf.
* @param array $item Items data.
* @param integer $pdf Pdf output.
*
* @return mixed
*/
function reporting_html_agent_module_status($table, $item, $pdf=0)
{
global $config;
$return_pdf = '';
if (empty($item['data']) === true) {
if ($pdf !== 0) {
$return_pdf .= __('No items');
} else {
$table->colspan['group_report']['cell'] = 3;
$table->cellstyle['group_report']['cell'] = 'text-align: center;';
$table->data['group_report']['cell'] = __('No items');
}
} else {
$table_info = new stdClass();
$table_info->width = '99%';
$table_info->align = [];
if (is_metaconsole() === true) {
$table_info->align['server'] = 'left';
}
$table_info->align['name_group'] = 'left';
$table_info->align['name_agent'] = 'left';
$table_info->align['name_module'] = 'left';
$table_info->align['status_module'] = 'left';
$table_info->align['data_module'] = 'left';
$table_info->align['data_time_module'] = 'left';
$table_info->headstyle = [];
if (is_metaconsole() === true) {
$table_info->headstyle['server'] = 'text-align: left';
}
$table_info->headstyle['name_group'] = 'text-align: left';
$table_info->headstyle['name_agent'] = 'text-align: left';
$table_info->headstyle['name_module'] = 'text-align: left';
$table_info->headstyle['status_module'] = 'text-align: left';
$table_info->headstyle['data_module'] = 'text-align: left';
$table_info->headstyle['data_time_module'] = 'text-align: left';
$table_info->head = [];
if (is_metaconsole() === true) {
$table_info->head['server'] = __('Server');
}
$table_info->head['name_agent'] = __('Agent');
$table_info->head['name_module'] = __('Module');
$table_info->head['name_group'] = __('Group');
$table_info->head['status_module'] = __('Status');
$table_info->head['data_module'] = __('Data');
$table_info->head['data_time_module'] = __('Last time');
$table_info->data = [];
foreach ($item['data'] as $server => $info) {
foreach ($info as $data) {
$row = [];
if (is_metaconsole() === true) {
$row['server'] = $server;
}
$row['name_agent'] = $data['name_agent'];
$row['name_module'] = $data['name_module'];
$row['name_group'] = $data['name_group'];
$row['status_module'] = ui_print_module_status(
$data['status_module'],
true,
'status_rounded_rectangles',
null,
($pdf === 1) ? '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' : ''
);
if (is_numeric($data['data_module']) === true) {
$row['data_module'] = remove_right_zeros(
number_format(
$data['data_module'],
$config['graph_precision']
)
);
} else {
$row['data_module'] = (empty($data['data_module']) === true) ? '--' : $data['data_module'];
}
$row['data_module'] .= $data['unit_module'];
$row['data_time_module'] = $data['data_time_module'];
$table_info->data[] = $row;
}
}
if ($pdf !== 0) {
$table_info->title = $item['title'];
$table_info->titleclass = 'title_table_pdf';
$table_info->titlestyle = 'text-align:left;';
$return_pdf .= html_print_table($table_info, true);
} else {
$table->colspan['data']['cell'] = 3;
$table->cellstyle['data']['cell'] = 'text-align: center;';
$table->data['data']['cell'] = html_print_table($table_info, true);
}
}
if ($pdf !== 0) {
return $return_pdf;
}
}
/** /**
* Function to print to HTML Exception report. * Function to print to HTML Exception report.
* *

View File

@ -796,6 +796,11 @@ function reports_get_report_types($template=false, $not_editor=false)
} }
} }
$types['agent_module_status'] = [
'optgroup' => __('Grouped'),
'name' => __('Agents/Modules status'),
];
// Only pandora managers have access to the whole database. // Only pandora managers have access to the whole database.
if (check_acl($config['id_user'], 0, 'PM')) { if (check_acl($config['id_user'], 0, 'PM')) {
$types['sql'] = [ $types['sql'] = [

View File

@ -2741,6 +2741,7 @@ function ui_print_status_image(
* @param boolean $return True or false. * @param boolean $return True or false.
* @param string $class Custom class or use defined. * @param string $class Custom class or use defined.
* @param string $title Custom title or inherit from module status. * @param string $title Custom title or inherit from module status.
* @param string $div_content Content.
* *
* @return string HTML code for shape. * @return string HTML code for shape.
*/ */
@ -2748,7 +2749,8 @@ function ui_print_module_status(
$status, $status,
$return=false, $return=false,
$class='status_rounded_rectangles', $class='status_rounded_rectangles',
$title=null $title=null,
$div_content=''
) { ) {
$color = modules_get_color_status($status, true); $color = modules_get_color_status($status, true);
if ($title === null) { if ($title === null) {
@ -2758,7 +2760,7 @@ function ui_print_module_status(
$output = '<div style="background: '.$color; $output = '<div style="background: '.$color;
$output .= '" class="'.$class; $output .= '" class="'.$class;
$output .= ' forced_title" data-title="'.$title.'" title="'; $output .= ' forced_title" data-title="'.$title.'" title="';
$output .= $title.'" data-use_title_for_force_title="1"></div>'; $output .= $title.'" data-use_title_for_force_title="1">'.$div_content.'</div>';
if ($return === false) { if ($return === false) {
echo $output; echo $output;
@ -3618,6 +3620,15 @@ function ui_print_datatable(array $parameters)
ui_require_javascript_file('buttons.html5.min'); ui_require_javascript_file('buttons.html5.min');
ui_require_javascript_file('buttons.print.min'); ui_require_javascript_file('buttons.print.min');
} else { } else {
// Load datatable.min.css.
$output .= '<link rel="stylesheet" href="';
$output .= ui_get_full_url(
'include/styles/js/datatables.min.css',
false,
false,
false
);
$output .= '"/>';
// Load tables.css. // Load tables.css.
$output .= '<link rel="stylesheet" href="'; $output .= '<link rel="stylesheet" href="';
$output .= ui_get_full_url( $output .= ui_get_full_url(

View File

@ -777,10 +777,13 @@ function users_get_groups_UM($id_user)
/** /**
* Obtiene una matriz con los grupos como clave y si tiene o no permiso UM sobre ese grupo(valor) * Obtiene una matriz con los grupos como clave y si tiene o no permiso UM sobre ese grupo(valor)
* *
* @param string User id * @param string $id_group User id.
* @param boolean $um Um.
* @param boolean $disabled Reurn also disabled users.
*
* @return array Return . * @return array Return .
*/ */
function users_get_users_by_group($id_group, $um=false) function users_get_users_by_group($id_group, $um=false, $disabled=true)
{ {
$sql = sprintf( $sql = sprintf(
"SELECT tusuario.* FROM tusuario "SELECT tusuario.* FROM tusuario
@ -789,6 +792,10 @@ function users_get_users_by_group($id_group, $um=false)
$id_group $id_group
); );
if ($disabled === false) {
$sql .= 'WHERE tusuario.disabled = 0';
}
$users = db_get_all_rows_sql($sql); $users = db_get_all_rows_sql($sql);
$return = []; $return = [];
foreach ($users as $key => $user) { foreach ($users as $key => $user) {

View File

@ -0,0 +1,32 @@
/* globals $, uniqId, confirmDialog*/
// eslint-disable-next-line no-unused-vars
function dialogAgentModulesAffected(settings) {
confirmDialog({
title: settings.title,
size: 500,
message: function() {
var id = "div-" + uniqId();
var loading = settings.loadingText;
$.ajax({
method: "post",
url: settings.url,
data: {
page: "godmode/agentes/planned_downtime.list",
show_info_agents_modules_affected: 1,
id: settings.id
},
dataType: "html",
success: function(data) {
$("#" + id)
.empty()
.append(data);
},
error: function(error) {
console.error(error);
}
});
return "<div id ='" + id + "'>" + loading + "</div>";
}
});
}

View File

@ -577,14 +577,19 @@ function confirmDialog(settings) {
*/ */
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
function generalShowMsg(data, idMsg) { function generalShowMsg(data, idMsg) {
var title = "Response"; var title = data.title[data.error];
var text = data; var text = data.text[data.error];
var failed = false; var failed = !data.error;
if (typeof data.error != "number") {
title = "Response";
text = data;
failed = false;
if (typeof data == "object") { if (typeof data == "object") {
title = data.title || "Response"; title = data.title || "Response";
text = data.text || data.error || data.result; text = data.text || data.error || data.result;
failed = failed || data.error; failed = data.failed || data.error;
} }
if (failed) { if (failed) {
@ -600,6 +605,7 @@ function generalShowMsg(data, idMsg) {
$("body").append('<div title="' + title + '" id="' + idMsg + '"></div>'); $("body").append('<div title="' + title + '" id="' + idMsg + '"></div>');
$("#" + idMsg).empty(); $("#" + idMsg).empty();
} }
}
$("#" + idMsg).empty(); $("#" + idMsg).empty();
$("#" + idMsg).html(text); $("#" + idMsg).html(text);

View File

@ -389,7 +389,7 @@ ul li {
.button_collapse { .button_collapse {
margin-top: auto; margin-top: auto;
height: 38px; min-height: 38px;
background-color: #505050; background-color: #505050;
text-align: center; text-align: center;
color: #fff; color: #fff;
@ -427,7 +427,6 @@ ul li {
} }
.button_classic { .button_classic {
width: 215px;
background-image: url(../../images/button_collapse_menu.png); background-image: url(../../images/button_collapse_menu.png);
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center; background-position: center;
@ -440,7 +439,7 @@ ul li {
} }
/* Menu height: 601px, 720px, 735px */ /* Menu height: 601px, 720px, 735px */
@media screen and (max-height: 720px) { @media screen and (max-height: 750px) {
.menu li, .menu li,
.menu li a, .menu li a,
.menu li div { .menu li div {
@ -448,7 +447,7 @@ ul li {
} }
} }
@media screen and (max-height: 735px) { @media screen and (max-height: 750px) {
.operation { .operation {
padding-top: 10px; padding-top: 10px;
} }

View File

@ -6038,7 +6038,6 @@ form#modal_form_feedback input[type="email"] {
border: none; border: none;
border-radius: 0; border-radius: 0;
border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
font-weight: lighter;
padding: 0px 0px 2px 0px; padding: 0px 0px 2px 0px;
box-sizing: border-box; box-sizing: border-box;
margin-bottom: 4px; margin-bottom: 4px;

View File

@ -129,7 +129,7 @@
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '7.0NG.760'; $version = '7.0NG.760';
$build = '220308'; $build = '220311';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

View File

@ -176,6 +176,7 @@ function load_agents_selector(group) {
{ {
"page" : "operation/agentes/ver_agente", "page" : "operation/agentes/ver_agente",
"get_agents_group_json" : 1, "get_agents_group_json" : 1,
"get_agents_also_interfaces" : 1,
"id_group" : group, "id_group" : group,
"privilege" : "AW", "privilege" : "AW",
"keys_prefix" : "_", "keys_prefix" : "_",
@ -216,6 +217,7 @@ $("#checkbox-recursion").change (function () {
jQuery.post ("ajax.php", jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente", {"page" : "operation/agentes/ver_agente",
"get_agents_group_json" : 1, "get_agents_group_json" : 1,
"get_agents_also_interfaces" : 1,
"id_group" : $("#group_id").val(), "id_group" : $("#group_id").val(),
"privilege" : "AW", "privilege" : "AW",
"keys_prefix" : "_", "keys_prefix" : "_",
@ -226,7 +228,6 @@ $("#checkbox-recursion").change (function () {
$("#module").html(''); $("#module").html('');
jQuery.each (data, function (id, value) { jQuery.each (data, function (id, value) {
id = id.substring(1); id = id.substring(1);
option = $("<option></option>") option = $("<option></option>")
.attr ("value", value["id_agente"]) .attr ("value", value["id_agente"])
.html (value["alias"]); .html (value["alias"]);

View File

@ -49,6 +49,7 @@ if (is_ajax()) {
$get_agent_modules_json = (bool) get_parameter('get_agent_modules_json'); $get_agent_modules_json = (bool) get_parameter('get_agent_modules_json');
$get_agent_status_tooltip = (bool) get_parameter('get_agent_status_tooltip'); $get_agent_status_tooltip = (bool) get_parameter('get_agent_status_tooltip');
$get_agents_group_json = (bool) get_parameter('get_agents_group_json'); $get_agents_group_json = (bool) get_parameter('get_agents_group_json');
$get_agents_also_interfaces = (bool) get_parameter('get_agents_also_interfaces');
$get_modules_group_json = (bool) get_parameter('get_modules_group_json'); $get_modules_group_json = (bool) get_parameter('get_modules_group_json');
$filter_modules_group_json = (bool) get_parameter('filter_modules_group_json'); $filter_modules_group_json = (bool) get_parameter('filter_modules_group_json');
$get_modules_group_value_name_json = (bool) get_parameter('get_modules_group_value_name_json'); $get_modules_group_value_name_json = (bool) get_parameter('get_modules_group_value_name_json');
@ -103,15 +104,15 @@ if (is_ajax()) {
// Build filter. // Build filter.
$filter = []; $filter = [];
if (!empty($id_os)) { if (empty($id_os) === false) {
$filter['id_os'] = $id_os; $filter['id_os'] = $id_os;
} }
if (!empty($agent_name)) { if (empty($agent_name) === false) {
$filter['nombre'] = '%'.$agent_name.'%'; $filter['nombre'] = '%'.$agent_name.'%';
} }
if (!empty($agent_alias)) { if (empty($agent_alias) === false) {
$filter['alias'] = '%'.$agent_alias.'%'; $filter['alias'] = '%'.$agent_alias.'%';
} }
@ -147,6 +148,20 @@ if (is_ajax()) {
} }
} }
if ($get_agents_also_interfaces === true) {
$listAgentsWithIface = db_get_all_rows_sql("SELECT DISTINCT id_agente FROM tagente_modulo WHERE nombre LIKE '%_ifOperStatus'");
if (empty($listAgentsWithIface) === false) {
$filter['matchIds'] = array_reduce(
$listAgentsWithIface,
function ($carry, $item) {
$carry[] = $item['id_agente'];
return $carry;
},
[]
);
}
}
// Perform search. // Perform search.
$agents = agents_get_group_agents( $agents = agents_get_group_agents(
// Id_group. // Id_group.
@ -171,7 +186,7 @@ if (is_ajax()) {
(bool) is_metaconsole() (bool) is_metaconsole()
); );
if (empty($agents)) { if (empty($agents) === true) {
$agents = []; $agents = [];
} }

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.760 %define version 7.0NG.760
%define release 220308 %define release 220311
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.760 %define version 7.0NG.760
%define release 220308 %define release 220311
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.760 %define version 7.0NG.760
%define release 220308 %define release 220311
%define httpd_name httpd %define httpd_name httpd
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name apache2 %define httpd_name apache2

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 7.0NG.760-220308 Version: 7.0NG.760-220311
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.760-220308" pandora_version="7.0NG.760-220311"
package_cpan=0 package_cpan=0
package_pandora=1 package_pandora=1

View File

@ -46,7 +46,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.760"; my $pandora_version = "7.0NG.760";
my $pandora_build = "220308"; my $pandora_build = "220311";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash
@ -1388,8 +1388,13 @@ sub pandora_start_log ($){
# Dump all errors to errorlog # Dump all errors to errorlog
open (STDERR, ">> " . $pa_config->{'errorlog_file'}) or die " [ERROR] " . pandora_get_initial_product_name() . " can't write to Errorlog. Aborting : \n $! \n"; open (STDERR, ">> " . $pa_config->{'errorlog_file'}) or die " [ERROR] " . pandora_get_initial_product_name() . " can't write to Errorlog. Aborting : \n $! \n";
my $mode = 0664;
my $file_mode = (stat($pa_config->{'errorlog_file'}))[2] & 0777;
my $min_mode = 0664;
my $mode = $file_mode | $min_mode;
chmod $mode, $pa_config->{'errorlog_file'}; chmod $mode, $pa_config->{'errorlog_file'};
print STDERR strftime ("%Y-%m-%d %H:%M:%S", localtime()) . ' - ' . $pa_config->{'servername'} . " Starting " . pandora_get_initial_product_name() . " Server. Error logging activated.\n"; print STDERR strftime ("%Y-%m-%d %H:%M:%S", localtime()) . ' - ' . $pa_config->{'servername'} . " Starting " . pandora_get_initial_product_name() . " Server. Error logging activated.\n";
} }

View File

@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.760"; my $pandora_version = "7.0NG.760";
my $pandora_build = "220308"; my $pandora_build = "220311";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.760 %define version 7.0NG.760
%define release 220308 %define release 220311
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.760 %define version 7.0NG.760
%define release 220308 %define release 220311
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -9,7 +9,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.760" PI_VERSION="7.0NG.760"
PI_BUILD="220308" PI_BUILD="220311"
MODE=$1 MODE=$1
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then

View File

@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "7.0NG.760 Build 220308"; my $version = "7.0NG.760 Build 220311";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "7.0NG.760 Build 220308"; my $version = "7.0NG.760 Build 220311";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);