Merge branch 'develop' into 'ent-9376-Discovery-SNMP-Host-Filtro-por-interfaces-no-operativas'

# Conflicts:
#   pandora_console/extras/mr/58.sql
This commit is contained in:
Alejandro Campos 2022-10-31 10:46:44 +00:00
commit 0889bcf142
67 changed files with 2141 additions and 175 deletions

View File

@ -170,7 +170,7 @@ http://rpms.remirepo.net/enterprise/remi-release-7.rpm \
https://repo.percona.com/yum/percona-release-latest.noarch.rpm"
execute_cmd "yum install -y $extra_repos" "Installing extra repositories"
execute_cmd "yum-config-manager --enable remi-php74" "Configuring PHP"
execute_cmd "yum-config-manager --enable remi-php80" "Configuring PHP"
# Install percona Database
#[ -f /etc/my.cnf ] && rm -rf /etc/my.cnf

View File

@ -20,7 +20,7 @@ LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
# define default variables
[ "$TZ" ] || TZ="Europe/Madrid"
[ "$MYVER" ] || MYVER=57
[ "$PHPVER" ] || PHPVER=7
[ "$PHPVER" ] || PHPVER=8
[ "$DBHOST" ] || DBHOST=127.0.0.1
[ "$DBNAME" ] || DBNAME=pandora
[ "$DBUSER" ] || DBUSER=pandora

View File

@ -21,7 +21,7 @@ LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log"
# define default variables
[ "$TZ" ] || TZ="Europe/Madrid"
[ "$PHPVER" ] || PHPVER=7.4
[ "$PHPVER" ] || PHPVER=8.0
[ "$DBHOST" ] || DBHOST=127.0.0.1
[ "$DBNAME" ] || DBNAME=pandora
[ "$DBUSER" ] || DBUSER=pandora
@ -138,6 +138,9 @@ check_root_permissions
# Connectivity
check_repo_connection
#Install awk, sed, grep if not present
execute_cmd "apt install -y gawk sed grep" 'Installing needed tools'
# Systemd
execute_cmd "systemctl --version" "Checking SystemD" 'This is not a SystemD enable system, if tryng to use in a docker env please check: https://github.com/pandorafms/pandorafms/tree/develop/extras/docker/centos8'
@ -155,7 +158,7 @@ execute_cmd "timedatectl set-timezone $TZ" "Setting Timezone $TZ"
execute_cmd "awk --version" 'Checking needed tools: awk'
execute_cmd "grep --version" 'Checking needed tools: grep'
execute_cmd "sed --version" 'Checking needed tools: sed'
execute_cmd "apt --version" 'Checking needed tools: dnf'
execute_cmd "apt --version" 'Checking needed tools: apt'
# Creating working directory
rm -rf "$WORKDIR" &>> "$LOGFILE"

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.765-221027
Version: 7.0NG.765-221031
Architecture: all
Priority: optional
Section: admin

View File

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

View File

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

View File

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

View File

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

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.765"
PI_BUILD="221027"
PI_BUILD="221031"
OS_NAME=`uname -s`
FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{221027}
{221031}
ViewReadme
{Yes}

View File

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

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.765-221027
Version: 7.0NG.765-221031
Architecture: all
Priority: optional
Section: admin

View File

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

View File

@ -1,6 +1,9 @@
START TRANSACTION;
ALTER TABLE `trecon_task` ADD COLUMN `snmp_skip_non_enabled_ifs` TINYINT UNSIGNED DEFAULT 1;
ALTER TABLE `tlayout` ADD COLUMN `maintenance_mode` TEXT;
ALTER TABLE `tusuario` ADD COLUMN `auth_token_secret` VARCHAR(45) DEFAULT NULL;
ALTER TABLE `tmodule_inventory` ADD COLUMN `script_mode` INT NOT NULL DEFAULT 2;
@ -8,4 +11,6 @@ ALTER TABLE `tmodule_inventory` ADD COLUMN `script_path` VARCHAR(1000) DEFAULT '
ALTER TABLE `tevent_filter` ADD COLUMN `search_recursive_groups` INT NOT NULL DEFAULT 0;
ALTER TABLE `tcredential_store` MODIFY COLUMN `product` ENUM('CUSTOM', 'AWS', 'AZURE', 'GOOGLE', 'SAP', 'WMI', 'SNMP') DEFAULT 'CUSTOM';
COMMIT;

View File

@ -167,7 +167,7 @@ if (!$double_auth_enabled
resizable: true,
draggable: true,
modal: true,
title: "<?php echo __('Double autentication activation'); ?>",
title: "<?php echo __('Double authentication activation'); ?>",
overlay: {
opacity: 0.5,
background: "black"

View File

@ -140,6 +140,49 @@ if ($id_module_type >= 6 && $id_module_type <= 7) {
push_table_simple($data, 'target_ip');
$user_groups = users_get_groups(false, 'AR');
if (users_is_admin() === true || isset($user_groups[0]) === true) {
$credentials = db_get_all_rows_sql(
'SELECT identifier FROM tcredential_store WHERE product LIKE "SNMP"'
);
} else {
$credentials = db_get_all_rows_sql(
sprintf(
'SELECT identifier FROM tcredential_store WHERE product LIKE "SNMP" AND id_group IN (%s)',
implode(',', array_keys($user_groups))
)
);
}
if (empty($credentials) === false) {
$fields = [];
foreach ($credentials as $key => $value) {
$fields[$value['identifier']] = $value['identifier'];
}
$data = [];
$data[0] = __('Credential store');
$data[1] = html_print_select(
$fields,
'credentials',
0,
'',
__('None'),
0,
true,
false,
false,
'',
false,
false,
'',
false
);
push_table_simple($data, 'snmp_credentials');
}
$snmp_versions['1'] = 'v. 1';
$snmp_versions['2'] = 'v. 2';
$snmp_versions['2c'] = 'v. 2c';
@ -316,6 +359,7 @@ if ($id_module_type < 15 || $id_module_type > 18) {
// NOT SNMP.
$table_simple->rowstyle['snmp_1'] = 'display: none';
$table_simple->rowstyle['snmp_2'] = 'display: none';
$table_simple->rowstyle['snmp_credentials'] = 'display: none';
}
// For a policy.
@ -569,6 +613,49 @@ $(document).ready (function () {
$(this).css ("width", "180px");
});
$("#credentials").change (function() {
if ($('#credentials').val() !== '0') {
$.ajax({
method: "post",
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
data: {
page: "godmode/agentes/agent_wizard",
method: "getCredentials",
identifier: $('#credentials').val()
},
datatype: "json",
success: function(data) {
data = JSON.parse(data);
extra = JSON.parse(data['extra_1']);
$('#snmp_version').val(extra['version']);
$('#snmp_version').trigger('change');
$('#text-snmp_community').val(extra['community']);
if (extra['version'] === '3') {
$('#snmp3_security_level').val(extra['securityLevelV3']);
$('#snmp3_security_level').trigger('change');
$('#text-snmp3_auth_user').val(extra['authUserV3']);
if (extra['securityLevelV3'] === 'authNoPriv' || extra['securityLevelV3'] === 'authPriv') {
$('#snmp3_auth_method').val(extra['authMethodV3']);
$('#snmp3_auth_method').trigger('change');
$('#password-snmp3_auth_pass').val(extra['authPassV3']);
if (extra['securityLevelV3'] === 'authPriv') {
$('#snmp3_privacy_method').val(extra['privacyMethodV3']);
$('#snmp3_privacy_method').trigger('change');
$('#password-snmp3_privacy_pass').val(extra['privacyPassV3']);
}
}
}
},
error: function(e) {
console.error(e);
}
});
}
});
$("#id_module_type").click (
function () {
$(this).css ("width", "auto");

View File

@ -141,6 +141,7 @@ if ($table !== null) {
unset($table);
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox filters';
$table->data = [];

View File

@ -0,0 +1,717 @@
<?php
/**
* View for edit users in Massive Operations
*
* @category Configuration
* @package Pandora FMS
* @subpackage Massive Operations
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
check_login();
global $config;
if (users_is_admin() === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access massive edit users'
);
include 'general/noaccess.php';
return;
}
if (is_management_allowed() === false) {
if (is_metaconsole() === false) {
$url = '<a target="_blank" href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/users_setup&tab=profile&pure='.(int) $config['pure']
).'">'.__('metaconsole').'</a>';
} else {
$url = __('any node');
}
ui_print_warning_message(
__(
'This node is configured with centralized mode. All profiles user information is read only. Go to %s to manage it.',
$url
)
);
return;
}
if (is_metaconsole() === true) {
include_once $config['homedir'].'/include/functions_visual_map.php';
open_meta_frame();
}
$edit_users = (int) get_parameter('edit_users');
if ($edit_users === 1) {
$users = get_parameter('id_users', false, false);
if ($users !== false) {
$update = [];
$language = (string) get_parameter('language', '-1');
if ($language !== '-1') {
$update['language'] = $language;
}
$block_size_change = (int) get_parameter('block_size_change');
if ($block_size_change === 0) {
$block_size = (int) get_parameter('block_size', -1);
if ($block_size !== -1) {
$update['block_size'] = $block_size;
}
}
$section = get_parameter('section', '-1');
if ($section !== '-1') {
$update['section'] = $section;
}
$data_section = get_parameter('data_section', '');
$dashboard = get_parameter('dashboard', '');
$visual_console = get_parameter('visual_console', '');
$section = io_safe_output($section);
if (($section === 'Event list') || ($section === 'Group view')
|| ($section === 'Alert detail') || ($section === 'Tactical view')
|| ($section === 'Default')
) {
$update['data_section'] = '';
} else if ($section === 'Dashboard') {
$update['data_section'] = $dashboard;
} else if ($section === 'Visual console') {
$update['data_section'] = $visual_console;
}
$event = (int) get_parameter('event_filter', -1);
if ($event !== -1) {
$update['default_event_filter'] = $event;
}
$autorefresh_list = get_parameter_post('autorefresh_list', [0 => '-1']);
if ($autorefresh_list[0] !== '-1') {
if (($autorefresh_list[0] === '') || ($autorefresh_list[0] === '0')) {
$update['autorefresh_white_list'] = '';
} else {
$update['autorefresh_white_list'] = json_encode($autorefresh_list);
}
}
$time_autorefresh = (int) get_parameter('time_autorefresh', -1);
if ($time_autorefresh !== -1) {
$update['time_autorefresh'] = $time_autorefresh;
}
$timezone = (string) get_parameter('timezone', '-1');
if ($timezone !== '-1') {
$update['timezone'] = $timezone;
}
$disabled = (int) get_parameter('disabled', -1);
if ($disabled !== -1) {
$update['disabled'] = $disabled;
}
$error = [];
$success = [];
foreach ($users as $key => $user) {
if (empty($update) === false) {
$result = update_user($user, $update);
if ($result === false) {
$error[] = $user;
} else {
$success[] = $user;
}
} else {
$error[] = $user;
}
}
if (empty($success) === false) {
ui_print_success_message(
__(
'Users updated successfully (%s)',
implode(
',',
$success
)
)
);
}
if (empty($error) === false) {
ui_print_error_message(
__(
'Users cannot be updated (%s)',
implode(',', $error)
)
);
}
}
}
if (is_metaconsole() === false) {
include 'include/javascript/timezonepicker/includes/parser.inc';
// Read in options for map builder.
$bases = [
'gray' => 'Gray',
'blue-marble' => 'Blue marble',
'night-electric' => 'Night Electric',
'living' => 'Living Earth',
];
$local_file = 'include/javascript/timezonepicker/images/gray-400.png';
// Dimensions must always be exact since the imagemap does not scale.
$array_size = getimagesize($local_file);
$map_width = $array_size[0];
$map_height = $array_size[1];
$timezones = timezone_picker_parse_files(
$map_width,
$map_height,
'include/javascript/timezonepicker/tz_world.txt',
'include/javascript/timezonepicker/tz_islands.txt'
);
}
$get_users = get_users();
$users = [];
if (empty($get_users) === false) {
foreach ($get_users as $key => $value) {
$users[$key] = $key;
}
}
$users_div = '<div class="label_select"><p class="edit_user_labels">'.__('Users').'</p>';
$users_div .= html_print_select(
$users,
'id_users[]',
0,
false,
'',
'',
true,
true,
true,
'',
false,
'',
false,
false,
false,
'',
false,
false,
false,
false,
true,
true,
true
).'</div>';
echo '<form method="post" id="form_profiles" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_users&option=edit_users">';
echo '<div class="user_edit_second_row white_box">';
echo '<div class="" style="width:65%">'.$users_div.'</div>';
echo '</div>';
// Language.
$language_db = db_get_all_rows_sql('SELECT id_language, name FROM tlanguage');
array_unshift($language_db, ['id_language' => 'default', 'name' => __('Default')]);
$language_list = [];
foreach ($language_db as $key => $value) {
$language_list[$value['id_language']] = $value['name'];
}
$language = '<div class="label_select"><p class="edit_user_labels">'.__('Language').'</p>';
$language .= html_print_select(
$language_list,
'language',
'',
'',
__('No change'),
-1,
true,
false,
false
).'</div>';
// Pagination.
$block_size = $config['global_block_size'];
$size_pagination = '<div class="label_select_simple"><p class="edit_user_labels">'.__('Block size for pagination').'</p>';
$size_pagination .= html_print_input_text('block_size', $block_size, '', 5, 5, true);
$size_pagination .= html_print_checkbox_switch('block_size_change', 1, 1, true);
$size_pagination .= '<span>'.__('No change').'</span>';
$size_pagination .= '</div>';
// Home screen.
$home_screen = '<div class="label_select"><p class="edit_user_labels">'.__('Home screen').ui_print_help_tip(__('User can customize the home page. By default, will display \'Agent Detail\'. Example: Select \'Other\' and type index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=1 to show agent detail view'), true).'</p>';
$values = [
'-1' => __('No change'),
'Default' => __('Default'),
'Visual console' => __('Visual console'),
'Event list' => __('Event list'),
'Group view' => __('Group view'),
'Tactical view' => __('Tactical view'),
'Alert detail' => __('Alert detail'),
'Other' => __('Other'),
'Dashboard' => __('Dashboard'),
];
$home_screen .= html_print_select(
$values,
'section',
'',
'show_data_section();',
'',
-1,
true,
false,
false,
'',
false,
'',
'',
10
).'</div>';
$dashboards = get_user_dashboards($config['id_user']);
$dashboards_aux = [];
if ($dashboards === false) {
$dashboards = ['None' => 'None'];
} else {
foreach ($dashboards as $key => $dashboard) {
$dashboards_aux[$dashboard['id']] = $dashboard['name'];
}
}
$home_screen .= '<div id="show_db" style="display: none; width: 100%;">';
$home_screen .= html_print_select($dashboards_aux, 'dashboard', '', '', '', '', true, false, false, '');
$home_screen .= '</div>';
$layouts = visual_map_get_user_layouts($config['id_user'], true);
$layouts_aux = [];
if (empty($layouts) === true) {
$layouts_aux = ['None' => 'None'];
} else {
foreach ($layouts as $layout) {
$layouts_aux[$layout] = $layout;
}
}
$home_screen .= '<div id="show_vc" style="display: none; width: 100%;">';
$home_screen .= html_print_select($layouts_aux, 'visual_console', '', '', '', '', true);
$home_screen .= '</div>';
$home_screen .= html_print_input_text('data_section', '', '', 60, 255, true, false);
// Event filter.
$user_groups = implode(',', array_keys((users_get_groups($config['id_user'], 'AR', true))));
$event_list = db_get_all_rows_sql('SELECT id_filter, id_name AS name FROM tevent_filter WHERE id_group_filter IN ('.$user_groups.')');
if (empty($event_list) === true) {
$event_list = [];
}
array_unshift($event_list, ['id_filter' => 'none', 'name' => __('None')]);
$event_filter = '<div class="label_select"><p class="edit_user_labels">'.__('Event filter').'</p>';
$event_filter .= html_print_select(
$event_list,
'event_filter',
'',
'',
__('No change'),
-1,
true,
false,
false
).'</div>';
// Autorefresh.
$autorefresh_list_out = [];
if (is_metaconsole() === false || is_centralized() === true) {
$autorefresh_list_out['operation/agentes/estado_agente'] = 'Agent detail';
$autorefresh_list_out['operation/agentes/alerts_status'] = 'Alert detail';
$autorefresh_list_out['enterprise/operation/cluster/cluster'] = 'Cluster view';
$autorefresh_list_out['operation/gis_maps/render_view'] = 'Gis Map';
$autorefresh_list_out['operation/reporting/graph_viewer'] = 'Graph Viewer';
$autorefresh_list_out['operation/snmpconsole/snmp_view'] = 'SNMP console';
if (enterprise_installed()) {
$autorefresh_list_out['general/sap_view'] = 'SAP view';
}
}
$autorefresh_list_out['operation/agentes/tactical'] = 'Tactical view';
$autorefresh_list_out['operation/agentes/group_view'] = 'Group view';
$autorefresh_list_out['operation/agentes/status_monitor'] = 'Monitor detail';
$autorefresh_list_out['enterprise/operation/services/services'] = 'Services';
$autorefresh_list_out['operation/dashboard/dashboard'] = 'Dashboard';
$autorefresh_list_out['operation/agentes/pandora_networkmap'] = 'Network map';
$autorefresh_list_out['operation/visual_console/render_view'] = 'Visual console';
$autorefresh_list_out['operation/events/events'] = 'Events';
$autorefresh_show = '<p class="edit_user_labels">'._('Autorefresh').ui_print_help_tip(
__('This will activate autorefresh in selected pages'),
true
).'</p>';
$select_out = html_print_select(
$autorefresh_list_out,
'autorefresh_list_out[]',
'',
'',
'',
'',
true,
true,
true,
'',
false,
'width:100%;min-height: 150px;'
);
$arrows = ' ';
$autorefresh_list = [];
$autorefresh_list['-1'] = __('No change');
$autorefresh_list[] = __('None');
$select_in = html_print_select(
$autorefresh_list,
'autorefresh_list[]',
'-1',
'',
'',
'',
true,
true,
true,
'',
false,
'width:100%;min-height: 150px;'
);
$table_ichanges = '<div class="autorefresh_select">
<div class="autorefresh_select_list_out">
<p class="autorefresh_select_text">'.__('Full list of pages').': </p>
<div>'.$select_out.'</div>
</div>
<div class="autorefresh_select_arrows" style="display:grid">
<a href="javascript:">'.html_print_image(
'images/darrowright_green.png',
true,
[
'id' => 'right_autorefreshlist',
'alt' => __('Push selected pages into autorefresh list'),
'title' => __('Push selected pages into autorefresh list'),
]
).'</a>
<a href="javascript:">'.html_print_image(
'images/darrowleft_green.png',
true,
[
'id' => 'left_autorefreshlist',
'alt' => __('Pop selected pages out of autorefresh list'),
'title' => __('Pop selected pages out of autorefresh list'),
]
).'</a>
</div>
<div class="autorefresh_select_list">
<p class="autorefresh_select_text">'.__('List of pages with autorefresh').': </p>
<div>'.$select_in.'</div>
</div>
</div>';
$autorefresh_show .= $table_ichanges;
// Time autorefresh.
$times = get_refresh_time_array();
$time_autorefresh = '<div class="label_select"><p class="edit_user_labels">'.__('Time autorefresh');
$time_autorefresh .= ui_print_help_tip(
__('Interval of autorefresh of the elements, by default they are 30 seconds, needing to enable the autorefresh first'),
true
).'</p>';
$time_autorefresh .= html_print_select(
$times,
'time_autorefresh',
'',
'',
__('No change'),
'-1',
true,
false,
false
).'</div>';
$timezone = '<div class="label_select"><p class="edit_user_labels">'.__('Timezone').ui_print_help_tip(__('The timezone must be that of the associated server.'), true).'</p>';
$timezone .= html_print_timezone_select('timezone', '-1', __('No change'), '-1').'</div>';
$timezone_map = '';
if (is_metaconsole() === false) {
foreach ($timezones as $timezone_name => $tz) {
if ($timezone_name == 'America/Montreal') {
$timezone_name = 'America/Toronto';
} else if ($timezone_name == 'Asia/Chongqing') {
$timezone_name = 'Asia/Shanghai';
}
$area_data_timezone_polys .= '';
foreach ($tz['polys'] as $coords) {
$area_data_timezone_polys .= '<area data-timezone="'.$timezone_name.'" data-country="'.$tz['country'].'" data-pin="'.implode(',', $tz['pin']).'" data-offset="'.$tz['offset'].'" shape="poly" coords="'.implode(',', $coords).'" />';
}
$area_data_timezone_rects .= '';
foreach ($tz['rects'] as $coords) {
$area_data_timezone_rects .= '<area data-timezone="'.$timezone_name.'" data-country="'.$tz['country'].'" data-pin="'.implode(',', $tz['pin']).'" data-offset="'.$tz['offset'].'" shape="rect" coords="'.implode(',', $coords).'" />';
}
}
$timezone_map = '<div id="timezone-picker" style="width:0px">
<img id="timezone-image" src="'.$local_file.'" width="'.$map_width.'" height="'.$map_height.'" usemap="#timezone-map" />
<img class="timezone-pin pdd_t_4px" src="include/javascript/timezonepicker/images/pin.png" />
<map name="timezone-map" id="timezone-map">'.$area_data_timezone_polys.$area_data_timezone_rects.'</map>
</div>';
}
// Status (Disable / Enable).
$status = '</br>';
$status .= '<div class="label_select"><p class="edit_user_labels">'.__('Status').'</p>';
$table = new StdClass();
$table->width = '100%';
$table->class = 'databox filters';
$table->data[0][0] = __('No change');
$table->data[0][0] .= html_print_radio_button_extended(
'disabled',
-1,
'',
-1,
false,
'',
'class="mrgn_right_40px"',
true
);
$table->data[0][0] .= __('Disable');
$table->data[0][0] .= html_print_radio_button_extended(
'disabled',
1,
'',
'',
false,
'',
'class="mrgn_right_40px"',
true
);
$table->data[0][0] .= __('Enable');
$table->data[0][0] .= html_print_radio_button_extended(
'disabled',
0,
'',
'',
false,
'',
'class="mrgn_right_40px"',
true
);
$status .= html_print_table($table, true);
echo '<div id="users_options" class="user_edit_second_row white_box" style="display: none">';
echo sprintf(
'<div class="edit_user_options">%s %s %s %s %s %s %s %s %s %s</div>',
$language,
$size_pagination,
$skin,
$home_screen,
$event_filter,
$autorefresh_show,
$time_autorefresh,
$timezone,
$timezone_map,
$status
);
echo '</div>';
attachActionButton('edit_users', 'update', '100%');
echo '</form>';
if (is_metaconsole() === false) {
// Include OpenLayers and timezone user map library.
echo '<script type="text/javascript" src="'.ui_get_full_url('include/javascript/timezonepicker/lib/jquery.timezone-picker.min.js').'"></script>'."\n\t";
echo '<script type="text/javascript" src="'.ui_get_full_url('include/javascript/timezonepicker/lib/jquery.maphilight.min.js').'"></script>'."\n\t";
// Closes no meta condition.
?>
<style>
/* Styles for timezone map */
#timezone-picker div.timezone-picker {
margin: 0 auto;
}
</style>
<script language="javascript" type="text/javascript">
$(document).ready (function () {
// Set up the picker to update target timezone and country select lists.
$('#timezone-image').timezonePicker({
target: '#timezone',
});
// Optionally an auto-detect button to trigger JavaScript geolocation.
$('#timezone-detect').click(function() {
$('#timezone-image').timezonePicker('detectLocation');
});
});
</script>
<?php
} else {
close_meta_frame();
}
?>
<script type="text/javascript">
$(document).ready(function() {
show_data_section();
$('#id_users').change(function() {
const users = $("#id_users option:selected").length;
if (users === 0) {
$('#users_options').hide();
} else {
$('#users_options').show();
}
});
$("#right_autorefreshlist").click (function () {
jQuery.each($("select[name='autorefresh_list_out[]'] option:selected"), function (key, value) {
imodule_name = $(value).html();
if (imodule_name != <?php echo "'".__('None')."'"; ?> || imodule_name != <?php echo "'".__('No change')."'"; ?>) {
id_imodule = $(value).attr('value');
$("select[name='autorefresh_list[]']").append($("<option></option>").val(id_imodule).html('<i>' + imodule_name + '</i>'));
// $("select[name='autorefresh_list[]']").val(id_imodule).prop("selected", "selected");
$("#autorefresh_list_out").find("option[value='" + id_imodule + "']").remove();
$("#autorefresh_list").find("option[value='-1']").remove();
$("#autorefresh_list").find("option[value='0']").remove();
if($("#autorefresh_list_out option").length == 0) {
$("select[name='autorefresh_list_out[]']").append($("<option></option>").val('0').html('<i><?php echo __('None'); ?></i>'));
}
}
});
$('#autorefresh_list option').prop('selected', true);
});
$("#left_autorefreshlist").click (function () {
jQuery.each($("select[name='autorefresh_list[]'] option:selected"), function (key, value) {
imodule_name = $(value).html();
if (imodule_name != <?php echo "'".__('None')."'"; ?> || imodule_name != <?php echo "'".__('No change')."'"; ?>) {
id_imodule = $(value).attr('value');
$("#autorefresh_list").find("option[value='" + id_imodule + "']").remove();
$("#autorefresh_list_out").find("option[value='0']").remove();
$("select[name='autorefresh_list_out[]']").append($("<option><option>").val(id_imodule).html('<i>' + imodule_name + '</i>'));
$("#autorefresh_list_out option").last().remove();
if($("#autorefresh_list option").length == 0) {
$("select[name='autorefresh_list[]']").append($("<option></option>").val('-1').html('<i><?php echo __('No change'); ?></i>'));
$("select[name='autorefresh_list[]']").append($("<option></option>").val('0').html('<i><?php echo __('None'); ?></i>'));
$('#autorefresh_list').val('-1').prop('selected', true);
}
}
});
});
});
function show_data_section () {
section = $("#section").val();
switch (section) {
case <?php echo "'".'Dashboard'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "inline-grid");
break;
case <?php echo "'".'Visual console'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "");
$("#show_vc").css("display", "inline-grid");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Event list'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Group view'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Tactical view'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Alert detail'."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
case <?php echo "'".'Other'."'"; ?>:
$("#text-data_section").css("display", "");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
default:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
$("#show_vc").css("display", "none");
$("#show_db").css("display", "none");
break;
}
}
</script>

View File

@ -70,10 +70,16 @@ $options_agents = [
];
if (check_acl($config['id_user'], 0, 'UM')) {
$options_users = [
'add_profiles' => __('Bulk profile add'),
'delete_profiles' => __('Bulk profile delete'),
];
if (is_metaconsole() === false) {
$options_users = [
'add_profiles' => __('Bulk profile add'),
'delete_profiles' => __('Bulk profile delete'),
];
}
if (users_is_admin() === true) {
$options_users['edit_users'] = __('Edit users in bulk');
}
} else {
$options_users = [];
}
@ -479,6 +485,10 @@ switch ($option) {
include_once $config['homedir'].'/godmode/massive/massive_edit_plugins.php';
break;
case 'edit_users':
include_once $config['homedir'].'/godmode/massive/massive_edit_users.php';
break;
default:
if (!enterprise_hook('massive_operations', [$option])) {
include_once $config['homedir'].'/godmode/massive/massive_config.php';

View File

@ -1971,7 +1971,7 @@ function show_double_auth_activation () {
resizable: true,
draggable: true,
modal: true,
title: "<?php echo __('Double autentication activation'); ?>",
title: "<?php echo __('Double authentication activation'); ?>",
overlay: {
opacity: 0.5,
background: "black"
@ -2049,7 +2049,7 @@ function show_double_auth_deactivation () {
resizable: true,
draggable: true,
modal: true,
title: "<?php echo __('Double autentication activation'); ?>",
title: "<?php echo __('Double authentication activation'); ?>",
overlay: {
opacity: 0.5,
background: "black"

View File

@ -37,6 +37,7 @@ $ajax = true;
$render_map = (bool) get_parameter('render_map', false);
$graph_javascript = (bool) get_parameter('graph_javascript', false);
$force_remote_check = (bool) get_parameter('force_remote_check', false);
$update_maintanance_mode = (bool) get_parameter('update_maintanance_mode', false);
$load_css_cv = (bool) get_parameter('load_css_cv', false);
if ($render_map) {
@ -99,3 +100,29 @@ if ($load_css_cv === true) {
echo $output;
return;
}
if ($update_maintanance_mode === true) {
$idVisualConsole = (int) get_parameter('idVisualConsole', 0);
$mode = (bool) get_parameter('mode', false);
$values = [];
if ($mode === true) {
$values['maintenance_mode'] = json_encode(
[
'user' => $config['id_user'],
'timestamp' => time(),
]
);
} else {
$values['maintenance_mode'] = null;
}
$result = db_process_sql_update(
'tlayout',
$values,
['id' => $idVisualConsole]
);
echo json_encode(['result' => $result]);
return;
}

View File

@ -33,6 +33,7 @@ global $config;
require_once $config['homedir'].'/include/class/HTML.class.php';
require_once $config['homedir'].'/include/functions_snmp_browser.php';
require_once $config['homedir'].'/include/functions_wmi.php';
require_once $config['homedir'].'/include/class/CredentialStore.class.php';
use PandoraFMS\Module;
@ -696,6 +697,43 @@ class AgentWizard extends HTML
'return' => true,
],
];
$user_groups = users_get_groups(false, 'AR');
if (users_is_admin() === true || isset($user_groups[0]) === true) {
$credentials = db_get_all_rows_sql(
'SELECT identifier FROM tcredential_store WHERE product LIKE "WMI"'
);
} else {
$credentials = db_get_all_rows_sql(
sprintf(
'SELECT identifier FROM tcredential_store WHERE product LIKE "WMI" AND id_group IN (%s)',
implode(',', array_keys($user_groups))
)
);
}
if (empty($credentials) === false) {
$fields = [];
foreach ($credentials as $key => $value) {
$fields[$value['identifier']] = $value['identifier'];
}
$inputs[] = [
'label' => __('Credential store'),
'id' => 'slc-credential',
'arguments' => [
'name' => 'credential',
'input_class' => 'flex-row',
'type' => 'select',
'nothing' => __('None'),
'nothing_value' => 0,
'fields' => $fields,
'class' => '',
'return' => true,
'sort' => true,
],
];
}
}
$hint_server = '&nbsp;';
@ -716,6 +754,43 @@ class AgentWizard extends HTML
];
if ($this->actionType === 'snmp') {
$user_groups = users_get_groups(false, 'AR');
if (users_is_admin() === true || isset($user_groups[0]) === true) {
$credentials = db_get_all_rows_sql(
'SELECT identifier FROM tcredential_store WHERE product LIKE "SNMP"'
);
} else {
$credentials = db_get_all_rows_sql(
sprintf(
'SELECT identifier FROM tcredential_store WHERE product LIKE "SNMP" AND id_group IN (%s)',
implode(',', array_keys($user_groups))
)
);
}
if (empty($credentials) === false) {
$fields = [];
foreach ($credentials as $key => $value) {
$fields[$value['identifier']] = $value['identifier'];
}
$inputs[] = [
'label' => __('Credential store'),
'id' => 'slc-credential',
'arguments' => [
'name' => 'credential',
'input_class' => 'flex-row',
'type' => 'select',
'nothing' => __('None'),
'nothing_value' => 0,
'fields' => $fields,
'class' => '',
'return' => true,
'sort' => true,
],
];
}
$inputs[] = [
'label' => __('SNMP community'),
'id' => 'txt-community',
@ -1336,6 +1411,21 @@ class AgentWizard extends HTML
}
/**
* Build an array with Product credentials.
*
* @return array with credentials (pass and id).
*/
public function getCredentials(string $identifier='')
{
if (empty($identifier) === true) {
$identifier = get_parameter('identifier', '');
}
echo json_encode(credentialStore::getKey($identifier));
}
/**
* Prepare data module to create.
*
@ -5813,6 +5903,58 @@ class AgentWizard extends HTML
filterInterfaces();
});
$('#credential').change(function() {
if ($('#credential').val() !== '0') {
$.ajax({
method: "post",
url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
data: {
page: "<?php echo $this->ajaxController; ?>",
method: "getCredentials",
identifier: $('#credential').val()
},
datatype: "json",
success: function(data) {
data = JSON.parse(data);
if ($('#text-namespaceWMI').length > 0) {
// WMI.
$('#text-namespaceWMI').val(data['extra_1']);
$('#text-usernameWMI').val(data['username']);
$('#password-passwordWMI').val(data['password']);
} else {
// SNMP.
extra = JSON.parse(data['extra_1']);
$('#version').val(extra['version']);
$('#version').trigger('change');
$('#text-community').val(extra['community']);
if (extra['version'] === '3') {
$('#securityLevelV3').val(extra['securityLevelV3']);
$('#securityLevelV3').trigger('change');
$('#text-authUserV3').val(extra['authUserV3']);
if (extra['securityLevelV3'] === 'authNoPriv' || extra['securityLevelV3'] === 'authPriv') {
$('#authMethodV3').val(extra['authMethodV3']);
$('#authMethodV3').trigger('change');
$('#password-authPassV3').val(extra['authPassV3']);
if (extra['securityLevelV3'] === 'authPriv') {
$('#privacyMethodV3').val(extra['privacyMethodV3']);
$('#privacyMethodV3').trigger('change');
$('#password-privacyPassV3').val(extra['privacyPassV3']);
}
}
}
}
},
error: function(e) {
showMsg(e);
}
});
}
});
// Loading.
$('#submit-sub-protocol').click(function() {
$('.wizard-result').remove();

View File

@ -617,33 +617,71 @@ class CredentialStore extends Wizard
$password = $google_creds->private_key_id;
}
if (empty($identifier) === true) {
$error = __('Key identifier is required');
} else if ($id_group === null) {
$error = __('You must select a group where store this key!');
} else if (empty($product) === true) {
$error = __('You must specify a product type');
} else if (empty($username) === true || (empty($password) === true)) {
$error = __('You must specify a username and/or password');
} else if (evaluate_ascii_valid_string(io_safe_output($identifier)) === false) {
$error = __('Identifier with forbidden characters. Check the documentation.');
}
if ($product !== 'SNMP') {
if (empty($identifier) === true) {
$error = __('Key identifier is required');
} else if ($id_group === null) {
$error = __('You must select a group where store this key!');
} else if (empty($product) === true) {
$error = __('You must specify a product type');
} else if (empty($username) === true || (empty($password) === true)) {
$error = __('You must specify a username and/or password');
} else if (evaluate_ascii_valid_string(io_safe_output($identifier)) === false) {
$error = __('Identifier with forbidden characters. Check the documentation.');
}
if (isset($error) === true) {
$this->ajaxMsg('error', $error);
exit;
}
if (isset($error) === true) {
$this->ajaxMsg('error', $error);
exit;
}
// Encrypt content (if needed).
$values = [
'identifier' => $identifier,
'id_group' => $id_group,
'product' => $product,
'username' => io_input_password(io_safe_output($username)),
'password' => io_input_password(io_safe_output($password)),
'extra_1' => io_input_password(io_safe_output($extra_1)),
'extra_2' => io_input_password(io_safe_output($extra_2)),
];
// Encrypt content (if needed).
$values = [
'identifier' => $identifier,
'id_group' => $id_group,
'product' => $product,
'username' => io_input_password(io_safe_output($username)),
'password' => io_input_password(io_safe_output($password)),
'extra_1' => io_input_password(io_safe_output($extra_1)),
'extra_2' => io_input_password(io_safe_output($extra_2)),
];
} else {
$values = [
'identifier' => $identifier,
'id_group' => $id_group,
'product' => $product,
];
$community = (string) get_parameter('community', '');
$version = (string) get_parameter('version', '1');
$extra_json = [
'community' => $community,
'version' => $version,
];
if ($version === '3') {
$securityLevelV3 = (string) get_parameter('securityLevelV3', 'authNoPriv');
$extra_json['securityLevelV3'] = $securityLevelV3;
$authUserV3 = (string) get_parameter('authUserV3', '');
$extra_json['authUserV3'] = $authUserV3;
if ($securityLevelV3 === 'authNoPriv' || $securityLevelV3 === 'authPriv') {
$authUserV3 = (string) get_parameter('authUserV3', '');
$extra_json['authUserV3'] = $authUserV3;
$authMethodV3 = (string) get_parameter('authMethodV3', 'MD5');
$extra_json['authMethodV3'] = $authMethodV3;
$authPassV3 = (string) get_parameter('authPassV3', '');
$extra_json['authPassV3'] = $authPassV3;
if ($securityLevelV3 === 'authPriv') {
$privacyMethodV3 = (string) get_parameter('privacyMethodV3', 'AES');
$extra_json['privacyMethodV3'] = $privacyMethodV3;
$privacyPassV3 = (string) get_parameter('privacyPassV3', '');
$extra_json['privacyPassV3'] = $privacyPassV3;
}
}
}
$values['extra_1'] = json_encode($extra_json);
}
// Spaces are not allowed.
$values['identifier'] = \io_safe_input(
@ -947,6 +985,8 @@ class CredentialStore extends Wizard
'AZURE' => __('Azure'),
'SAP' => __('SAP'),
'GOOGLE' => __('Google'),
'WMI' => __('WMI'),
'SNMP' => __('SNMP'),
],
'selected' => (isset($values['product']) ? $values['product'] : 'CUSTOM'),
'disabled' => (bool) $values['product'],
@ -989,6 +1029,19 @@ class CredentialStore extends Wizard
$extra1_type = 'textarea';
break;
case 'WMI':
$extra_1_label = __('Namespace');
$extra1 = true;
$extra2 = false;
break;
case 'SNMP':
$user = false;
$pass = false;
$extra1 = false;
$extra2 = false;
break;
case 'CUSTOM':
case 'SAP':
$user_label = __('Account ID');
@ -1059,6 +1112,141 @@ class CredentialStore extends Wizard
];
}
if ($values['product'] === 'SNMP') {
$json_values = json_decode($values['extra_1'], true);
$inputs[] = [
'label' => __('SNMP community'),
'id' => 'li_snmp_1',
'arguments' => [
'name' => 'community',
'input_class' => 'flex-row',
'type' => 'text',
'value' => $json_values['community'],
'return' => true,
],
];
$inputs[] = [
'label' => __('SNMP version'),
'id' => 'li_snmp_2',
'arguments' => [
'name' => 'version',
'input_class' => 'flex-row',
'type' => 'select',
'script' => 'showVersion()',
'fields' => [
'1' => __('1'),
'2' => __('2'),
'2c' => __('2c'),
'3' => __('3'),
],
'selected' => (isset($json_values['version']) ? $json_values['version'] : '1'),
'return' => true,
],
];
$inputs[] = [
'label' => __('Security level'),
'id' => 'li_snmp_3',
'style' => ($json_values['version'] !== '3') ? 'display: none;' : '',
'arguments' => [
'name' => 'securityLevelV3',
'input_class' => 'flex-row',
'type' => 'select',
'script' => 'showSecurity()',
'fields' => [
'authNoPriv' => __('Authenticated and non-private method'),
'authPriv' => __('Authenticated and private method'),
'noAuthNoPriv' => __('Non-authenticated and non-private method'),
],
'selected' => (isset($json_values['securityLevelV3']) ? $json_values['securityLevelV3'] : 'authNoPriv'),
'return' => true,
],
];
$inputs[] = [
'label' => __('User authentication'),
'id' => 'li_snmp_4',
'style' => ($json_values['version'] !== '3') ? 'display: none;' : '',
'arguments' => [
'name' => 'authUserV3',
'input_class' => 'flex-row',
'type' => 'text',
'value' => $json_values['authUserV3'],
'return' => true,
],
];
$authNoPrivate = (
isset($json_values['securityLevelV3']) &&
($json_values['securityLevelV3'] === 'authNoPriv' || $json_values['securityLevelV3'] === 'authPriv')
) ? '' : 'display: none;';
$inputs[] = [
'label' => __('Authentication method'),
'id' => 'li_snmp_5',
'style' => $authNoPrivate,
'arguments' => [
'name' => 'authMethodV3',
'input_class' => 'flex-row',
'type' => 'select',
'fields' => [
'MD5' => __('MD5'),
'SHA' => __('SHA'),
],
'selected' => (isset($json_values['authMethodV3']) ? $json_values['authMethodV3'] : 'MD5'),
'return' => true,
],
];
$inputs[] = [
'label' => __('Password authentication'),
'id' => 'li_snmp_6',
'style' => $authNoPrivate,
'arguments' => [
'name' => 'authPassV3',
'input_class' => 'flex-row',
'type' => 'password',
'value' => $json_values['authPassV3'],
'return' => true,
],
];
$authPrivate = (isset($json_values['securityLevelV3']) && $json_values['securityLevelV3'] === 'authPriv')
? ''
: 'display: none;';
$inputs[] = [
'label' => __('Privacy method'),
'id' => 'li_snmp_7',
'style' => $authPrivate,
'arguments' => [
'name' => 'privacyMethodV3',
'input_class' => 'flex-row',
'type' => 'select',
'fields' => [
'AES' => __('AES'),
'DES' => __('DES'),
],
'selected' => (isset($json_values['privacyMethodV3']) ? $json_values['privacyMethodV3'] : 'AES'),
'return' => true,
],
];
$inputs[] = [
'label' => __('Privacy pass'),
'id' => 'li_snmp_8',
'style' => $authPrivate,
'arguments' => [
'name' => 'privacyPassV3',
'input_class' => 'flex-row',
'type' => 'password',
'value' => $json_values['privacyPassV3'],
'return' => true,
],
];
}
return $this->printForm(
[
'form' => $form,
@ -1175,9 +1363,248 @@ class CredentialStore extends Wizard
$('<textarea name="extra_1" id="text-extra_1">'+val+'</textarea>')
);
$('#div-extra_1').show();
} else if ($('#product :selected').val() == "WMI") {
$('#div-username label').text('<?php echo __('Username'); ?>');
$('#div-password label').text('<?php echo __('Password'); ?>');
$('#div-extra_1 label').text('<?php echo __('Namespace'); ?>');
$('#div-username').show();
$('#div-password').show();
$('#div-extra_1').show();
$('#div-extra_2').hide();
} else if ($('#product :selected').val() == "SNMP") {
$('#div-username').hide();
$('#div-password').hide();
$('#div-extra_1').hide();
$('#div-extra_2').hide();
if ($('#li_snmp_1').length > 0) {
console.log($('#li_snmp_1').length);
const test = '<?php echo $json_values; ?>';
console.log(test);
} else {
const ul = $('#modal_form').children('ul')[0];
// SNMP community.
const li_community = document.createElement("li");
li_community.id = 'li_snmp_1';
const label_community = document.createElement("label");
label_community.textContent = '<?php echo __('SNMP community'); ?>';
const input_community = document.createElement("input");
input_community.type = 'text';
input_community.className = 'text_input';
input_community.name = 'community';
li_community.append(label_community);
li_community.append(input_community);
ul.append(li_community);
// SNMP version.
const li_version = document.createElement("li");
li_version.id = 'li_snmp_2';
const label_version = document.createElement("label");
label_version.textContent = '<?php echo __('SNMP version'); ?>';
const select_version = document.createElement("select");
select_version.name = 'version';
select_version.id = 'version';
select_version.onchange = function() {
showVersion();
};
let option1 = document.createElement("option");
let option2 = document.createElement("option");
let option2c = document.createElement("option");
let option3 = document.createElement("option");
option1.value = '1';
option1.text = '1';
option2.value = '2';
option2.text = '2';
option2c.value = '2c';
option2c.text = '2c';
option3.value = '3';
option3.text = '3';
select_version.appendChild(option1);
select_version.appendChild(option2);
select_version.appendChild(option2c);
select_version.appendChild(option3);
li_version.append(label_version);
li_version.append(select_version);
ul.append(li_version);
$("#version").select2();
// Security.
const li_security = document.createElement("li");
li_security.id = 'li_snmp_3';
const label_security = document.createElement("label");
label_security.textContent = '<?php echo __('Security level'); ?>';
const select_security = document.createElement("select");
select_security.name = 'securityLevelV3';
select_security.id = 'securityLevelV3';
select_security.onchange = function() {
showSecurity();
}
option1 = document.createElement("option");
option2 = document.createElement("option");
option3 = document.createElement("option");
option1.value = 'authNoPriv';
option1.text = '<?php echo __('Authenticated and non-private method'); ?>';
option2.value = 'authPriv';
option2.text = '<?php echo __('Authenticated and private method'); ?>';
option3.value = 'noAuthNoPriv';
option3.text = '<?php echo __('Non-authenticated and non-private method'); ?>';
select_security.appendChild(option1);
select_security.appendChild(option2);
select_security.appendChild(option3);
li_security.append(label_security);
li_security.append(select_security);
ul.append(li_security);
$("#securityLevelV3").select2();
// User.
const li_user = document.createElement("li");
li_user.id = 'li_snmp_4';
const label_user = document.createElement("label");
label_user.textContent = '<?php echo __('User authentication'); ?>';
const input_user = document.createElement("input");
input_user.type = 'text';
input_user.className = 'text_input';
input_user.name = 'authUserV3';
li_user.append(label_user);
li_user.append(input_user);
ul.append(li_user);
// Authentication method.
const li_method = document.createElement("li");
li_method.id = 'li_snmp_5';
const label_method = document.createElement("label");
label_method.textContent = '<?php echo __('Authentication method'); ?>';
const select_method = document.createElement("select");
select_method.name = 'authMethodV3';
select_method.id = 'method';
option1 = document.createElement("option");
option2 = document.createElement("option");
option1.value = 'MD5';
option1.text = '<?php echo __('MD5'); ?>';
option2.value = 'SHA';
option2.text = '<?php echo __('SHA'); ?>';
select_method.appendChild(option1);
select_method.appendChild(option2);
li_method.append(label_method);
li_method.append(select_method);
ul.append(li_method);
$("#method").select2();
// Password.
const li_password = document.createElement("li");
li_password.id = 'li_snmp_6';
const label_password = document.createElement("label");
label_password.textContent = '<?php echo __('Password authentication'); ?>';
const input_password = document.createElement("input");
input_password.type = 'password';
input_password.className = 'text_input';
input_password.name = 'authPassV3';
li_password.append(label_password);
li_password.append(input_password);
ul.append(li_password);
// Privacy method.
const li_privacy = document.createElement("li");
li_privacy.id = 'li_snmp_7';
const label_privacy = document.createElement("label");
label_privacy.textContent = '<?php echo __('Privacy method'); ?>';
const select_privacy = document.createElement("select");
select_privacy.name = 'privacyMethodV3';
select_privacy.id = 'privacy';
option1 = document.createElement("option");
option2 = document.createElement("option");
option1.value = 'AES';
option1.text = '<?php echo __('AES'); ?>';
option2.value = 'DES';
option2.text = '<?php echo __('DES'); ?>';
select_privacy.appendChild(option1);
select_privacy.appendChild(option2);
li_privacy.append(label_privacy);
li_privacy.append(select_privacy);
ul.append(li_privacy);
$("#privacy").select2();
// Privacy pass.
const li_privacyPassV3 = document.createElement("li");
li_privacyPassV3.id = 'li_snmp_8';
const label_privacyPassV3 = document.createElement("label");
label_privacyPassV3.textContent = '<?php echo __('Privacy pass'); ?>';
const input_privacyPassV3 = document.createElement("input");
input_privacyPassV3.type = 'password';
input_privacyPassV3.className = 'text_input';
input_privacyPassV3.name = 'privacyPassV3';
li_privacyPassV3.append(label_privacyPassV3);
li_privacyPassV3.append(input_privacyPassV3);
ul.append(li_privacyPassV3);
$('#li_snmp_3').hide();
$('#li_snmp_4').hide();
$('#li_snmp_5').hide();
$('#li_snmp_6').hide();
$('#li_snmp_7').hide();
$('#li_snmp_8').hide();
}
}
}
function showVersion() {
if ($('#version').val() === '3') {
$('#li_snmp_3').show();
$('#li_snmp_4').show();
$('#li_snmp_5').show();
$('#li_snmp_6').show();
} else {
$('#li_snmp_3').hide();
$('#li_snmp_4').hide();
$('#li_snmp_5').hide();
$('#li_snmp_6').hide();
$('#li_snmp_7').hide();
$('#li_snmp_8').hide();
}
}
function showSecurity() {
const value = $('#securityLevelV3').val();
switch (value) {
case 'noAuthNoPriv':
$('#li_snmp_4').show();
$('#li_snmp_5').hide();
$('#li_snmp_6').hide();
$('#li_snmp_7').hide();
$('#li_snmp_8').hide();
break;
case 'authPriv':
$('#li_snmp_4').show();
$('#li_snmp_5').show();
$('#li_snmp_6').show();
$('#li_snmp_7').show();
$('#li_snmp_8').show();
break;
case 'authNoPriv':
default:
$('#li_snmp_4').show();
$('#li_snmp_5').show();
$('#li_snmp_6').show();
$('#li_snmp_7').hide();
$('#li_snmp_8').hide();
break;
}
}
function hideSNMP() {
$('#li_snmp_1').hide();
$('#li_snmp_2').hide();
$('#li_snmp_3').hide();
$('#li_snmp_4').hide();
$('#li_snmp_5').hide();
$('#li_snmp_6').hide();
$('#li_snmp_7').hide();
$('#li_snmp_8').hide();
}
/**
* Process ajax responses and shows a dialog with results.
*/

View File

@ -485,6 +485,10 @@ class HTML
$class = '';
}
if (empty($input['style']) === false) {
$style_li = $input['style'];
}
if (isset($input['class']) === true) {
$class = $input['class'].$class;
}
@ -498,7 +502,7 @@ class HTML
}
// Print independent block of inputs.
$output .= '<li id="li-'.($input['block_id'] ?? '').'" class="'.$class.'">';
$output .= '<li id="li-'.($input['block_id'] ?? '').'" class="'.$class.'" style="'.$style_li.'">';
if (isset($input['wrapper']) === true) {
$output .= '<'.$input['wrapper'].' id="'.($input['block_id'] ?? '').'" class="'.$class.'">';
@ -562,7 +566,7 @@ class HTML
}
if (!$direct) {
$output .= '<li id="'.($input['id'] ?? '').'" class="'.$class.'">';
$output .= '<li id="'.($input['id'] ?? '').'" class="'.$class.'" style="'.$style_li.'">';
}
if (isset($input['label']) === true) {

View File

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

View File

@ -359,10 +359,12 @@ function mysql_db_get_all_rows_in_table($table, $order_field='', $order='ASC')
*
* @return mixed False in case of error or invalid values passed. Affected rows otherwise
*/
function mysql_db_process_sql_insert($table, $values)
function mysql_db_process_sql_insert($table, $values, $sqltostring=false)
{
// Empty rows or values not processed
if (empty($values)) {
global $config;
// Empty rows or values not processed.
if (empty($values) === true) {
return false;
}
@ -374,7 +376,7 @@ function mysql_db_process_sql_insert($table, $values)
$i = 1;
$max = count($values);
foreach ($values as $field => $value) {
// Add the correct escaping to values
// Add the correct escaping to values.
if ($field[0] != '`') {
$field = '`'.$field.'`';
}
@ -402,7 +404,30 @@ function mysql_db_process_sql_insert($table, $values)
$query .= ' VALUES ('.$values_str.')';
return db_process_sql($query, 'insert_id');
$values_insert = [];
if (enterprise_hook('is_metaconsole') === true
&& isset($config['centralized_management']) === true
&& (bool) $config['centralized_management'] === true
) {
$values_insert = [
'table' => $table,
'values' => $values,
];
}
if ($sqltostring === true) {
return $query;
}
return db_process_sql(
$query,
'insert_id',
'',
true,
$status,
true,
$values_insert
);
}

View File

@ -1338,30 +1338,42 @@ function db_get_cached_queries()
* This function comes back with an array in case of SELECT
* in case of UPDATE, DELETE etc. with affected rows
* an empty array in case of SELECT without results
* Queries that return data will be cached so queries don't get repeated
* Queries that return data will be cached so queries don't get repeated.
*
* @param string SQL statement to execute
* @param string $sql SQL statement to execute.
* @param string $rettype What type of info to return in case of INSERT/UPDATE.
* 'affected_rows' will return mysql_affected_rows (default value)
* 'insert_id' will return the ID of an autoincrement value
* 'info' will return the full (debug) information of a query.
* @param string $dbconnection Info conecction.
* @param boolean $cache Cache.
* @param string $status The status and type of query (support only postgreSQL).
* @param boolean $autocommit Set autocommit transaction mode true/false (Only oracle).
* @param array $values Values (Only type insert).
*
* @param string What type of info to return in case of INSERT/UPDATE.
* 'affected_rows' will return mysql_affected_rows (default value)
* 'insert_id' will return the ID of an autoincrement value
* 'info' will return the full (debug) information of a query
*
* @param string $status The status and type of query (support only postgreSQL).
*
* @param boolean $autocommit (Only oracle) Set autocommit transaction mode true/false
*
* @return mixed An array with the rows, columns and values in a multidimensional array or false in error
* @return mixed An array with the rows, columns and values in a multidimensional array or false in error.
*/
function db_process_sql($sql, $rettype='affected_rows', $dbconnection='', $cache=true, &$status=null, $autocommit=true)
{
function db_process_sql(
$sql,
$rettype='affected_rows',
$dbconnection='',
$cache=true,
&$status=null,
$autocommit=true,
$values_insert=[]
) {
global $config;
$rc = false;
switch ($config['dbtype']) {
case 'mysql':
default:
$rc = @mysql_db_process_sql($sql, $rettype, $dbconnection, $cache);
$rc = @mysql_db_process_sql(
$sql,
$rettype,
$dbconnection,
$cache
);
break;
case 'postgresql':
@ -1373,7 +1385,13 @@ function db_process_sql($sql, $rettype='affected_rows', $dbconnection='', $cache
break;
}
db_sync($dbconnection, $sql, $rc);
db_sync(
$dbconnection,
$sql,
$rc,
$rettype,
$values_insert
);
return $rc;
}
@ -1388,8 +1406,13 @@ function db_process_sql($sql, $rettype='affected_rows', $dbconnection='', $cache
*
* @return void
*/
function db_sync($dbconnection, $sql, $rc)
{
function db_sync(
$dbconnection,
$sql,
$rc,
$rettype='affected_rows',
$values_insert=[]
) {
global $config;
if (enterprise_hook('is_metaconsole') === true
&& isset($config['centralized_management']) === true
@ -1401,6 +1424,16 @@ function db_sync($dbconnection, $sql, $rc)
// Synchronize changes to nodes if needed.
$sync = new Synchronizer();
if ($sync !== null) {
if ($rettype === 'insert_id') {
$forceSql = $sync->updateInsertQueryAddPrimaryKey(
$values_insert,
$rc
);
if (empty($forceSql) === false) {
$sql = $forceSql;
}
}
if ($sync->queue($sql, $rc) === false) {
// Launch events per failed query.
$errors = $sync->getLatestErrors();
@ -1696,13 +1729,13 @@ function db_process_delete_temp($table, $row, $value, $custom_value=false)
*
* @return mixed False in case of error or invalid values passed. Affected rows otherwise
*/
function db_process_sql_insert($table, $values, $autocommit=true)
function db_process_sql_insert($table, $values, $autocommit=true, $sqltostring=false)
{
global $config;
switch ($config['dbtype']) {
case 'mysql':
return mysql_db_process_sql_insert($table, $values);
return mysql_db_process_sql_insert($table, $values, $sqltostring);
break;
case 'postgresql':

View File

@ -4735,12 +4735,12 @@ function html_print_autocomplete_modules(
*
* @return string HTML code
*/
function html_print_timezone_select($name, $selected='')
function html_print_timezone_select($name, $selected='', $nothing='', $nothing_value='')
{
$timezones_index = timezone_identifiers_list();
$timezones = timezone_identifiers_list();
$timezones = array_combine($timezones_index, $timezones);
return html_print_select($timezones, $name, $selected, '', __('None'), '', true, false, false);
$timezones = array_combine($timezones, $timezones);
$timezones = (['' => __('none')] + $timezones);
return html_print_select($timezones, $name, $selected, '', $nothing, $nothing_value, true, false, false);
}

View File

@ -3708,6 +3708,8 @@ function visual_map_print_visual_map(
// End function
// Start function
/**
* Get a list with the layouts for a user.
*
@ -3719,8 +3721,6 @@ function visual_map_print_visual_map(
*
* @return array A list of layouts the user can see.
*/
function visual_map_get_user_layouts(
$id_user=0,
$only_names=false,
@ -3729,6 +3729,7 @@ function visual_map_get_user_layouts(
$favourite=false,
$check_user_groups=true
) {
$where = '';
if (! is_array($filter)) {
$filter = [];
} else {
@ -3819,17 +3820,19 @@ function visual_map_get_user_layouts(
$retval[$layout['id']] = $layout;
}
// add_perms
if (isset($groups[$layout['id_group']]['vconsole_view'])) {
$retval[$layout['id']]['vr'] = $groups[$layout['id_group']]['vconsole_view'];
}
if ($only_names === false) {
// Aad_perms.
if (isset($groups[$layout['id_group']]['vconsole_view'])) {
$retval[$layout['id']]['vr'] = $groups[$layout['id_group']]['vconsole_view'];
}
if (isset($groups[$layout['id_group']]['vconsole_edit'])) {
$retval[$layout['id']]['vw'] = $groups[$layout['id_group']]['vconsole_edit'];
}
if (isset($groups[$layout['id_group']]['vconsole_edit'])) {
$retval[$layout['id']]['vw'] = $groups[$layout['id_group']]['vconsole_edit'];
}
if (isset($groups[$layout['id_group']]['vconsole_management'])) {
$retval[$layout['id']]['vm'] = $groups[$layout['id_group']]['vconsole_management'];
if (isset($groups[$layout['id_group']]['vconsole_management'])) {
$retval[$layout['id']]['vm'] = $groups[$layout['id_group']]['vconsole_management'];
}
}
}

View File

@ -1386,6 +1386,12 @@ function dashboardLoadVC(settings) {
: "dashboard"
);
if (settings.props.maintenanceMode != null) {
if (settings.props.maintenanceMode.user !== settings.id_user) {
visualConsoleManager.visualConsole.enableMaintenanceMode();
}
}
if (settings.mobile_view_orientation_vc === true) {
$(window).on("orientationchange", function() {
$(container).width($(window).height());

View File

@ -13,20 +13,26 @@ function configure_modules_form() {
$("#id_module_type").change(function() {
if (id_modules_icmp.in_array(this.value)) {
$(
"tr#simple-snmp_1, tr#simple-snmp_2, tr#simple-tcp_send, tr#simple-tcp_receive"
"tr#simple-snmp_1, tr#simple-snmp_2, tr#simple-snmp_credentials, tr#simple-tcp_send, tr#simple-tcp_receive"
).hide();
$("#text-tcp_port").attr("disabled", "1");
} else if (id_modules_snmp.in_array(this.value)) {
$("tr#simple-snmp_1, tr#simple-snmp_2").show();
$(
"tr#simple-snmp_1, tr#simple-snmp_2, tr#simple-snmp_credentials"
).show();
$("tr#simple-tcp_send, tr#simple-tcp_receive").hide();
$("#text-tcp_port").removeAttr("disabled");
} else if (id_modules_tcp.in_array(this.value)) {
$("tr#simple-snmp_1, tr#simple-snmp_2").hide();
$(
"tr#simple-snmp_1, tr#simple-snmp_2, tr#simple-snmp_credentials"
).hide();
$("tr#simple-tcp_send, tr#simple-tcp_receive").show();
$("#text-tcp_port").removeAttr("disabled");
} else if (id_modules_exec.in_array(this.value)) {
$("tr#simple-tcp_send, tr#simple-tcp_receive").hide();
$("tr#simple-snmp_1, tr#simple-snmp_2").hide();
$(
"tr#simple-snmp_1, tr#simple-snmp_2, tr#simple-snmp_credentials"
).hide();
$("#text-tcp_port").attr("disabled", false);
}
});

View File

@ -117,6 +117,15 @@ function createVisualConsole(
visualConsole.updateElements(items);
}
if (
visualConsole.props.maintenanceMode != null &&
visualConsole.props.maintenanceMode.user !== id_user
) {
visualConsole.enableMaintenanceMode();
} else {
visualConsole.disableMaintenanceMode();
}
// Emit the VC update event.
if (onUpdate) onUpdate(prevProps, visualConsole.props);
} catch (ignored) {} // eslint-disable-line no-empty
@ -159,6 +168,7 @@ function createVisualConsole(
// Initialize the Visual Console.
try {
visualConsole = new VisualConsole(container, props, items);
// VC Item clicked.
visualConsole.onItemClick(function(e) {
var data = e.item.props || {};
@ -357,7 +367,6 @@ function createVisualConsole(
})
.init();
});
// VC Item resized.
visualConsole.onItemResized(function(e) {
var item = e.item;
@ -473,6 +482,11 @@ function createVisualConsole(
updateVisualConsole(visualConsole.props.id, interval, null, dimensions);
}
},
forceUpdateVisualConsole: function() {
asyncTaskManager.cancel("visual-console");
asyncTaskManager.cancel("visual-console-start");
updateVisualConsole(visualConsole.props.id);
},
createItem: function(typeString) {
var type;
switch (typeString) {

View File

@ -90,6 +90,7 @@ final class Container extends Model
'backgroundURL' => static::extractBackgroundUrl($data),
'relationLineWidth' => (int) $data['relationLineWidth'],
'hash' => static::extractHash($data),
'maintenanceMode' => static::extractMaintenanceMode($data),
];
}
@ -238,6 +239,45 @@ final class Container extends Model
}
/**
* Extract a background color value.
*
* @param array $data Unknown input data structure.
*
* @return mixed String representing the color (not empty) or null.
*/
private static function extractMaintenanceMode(array $data)
{
global $config;
$maintenance_mode = static::notEmptyStringOr(
static::issetInArray(
$data,
[
'maintenanceMode',
'maintenance_mode',
]
),
null
);
$result = null;
if ($maintenance_mode !== null) {
$result = json_decode($maintenance_mode, true);
$result['date'] = date(
$config['date_format'],
$result['timestamp']
);
$result['timestamp'] = human_time_description_raw(
(time() - $result['timestamp'])
);
}
return $result;
}
/**
* Extract the "is favorite" switch value.
*

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

View File

@ -7,6 +7,14 @@
margin-top: 5px;
}
.is-maintenance {
background-image: url(maintenanceMode.png) !important;
}
.is-maintenance :nth-child(1) {
display: none;
}
.visual-console-item {
position: absolute;
display: flex;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -546,6 +546,7 @@ if (isset($config['id_user']) === false) {
if ((!isset($double_auth_success)
|| !$double_auth_success)
&& is_double_auth_enabled($nick_in_db)
&& (bool) $config['double_auth_enabled'] === true
) {
// Store this values in the session to know if the user login
// was correct.

View File

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

View File

@ -358,6 +358,7 @@ class Visualmap
'uniq' => $uniq,
'mobile' => true,
'vcId' => $visualConsoleId,
'id_user' => $config['id_user'],
'mobile_view_orientation_vc' => (bool) !$config['mobile_view_orientation_vc'],
]
);

View File

@ -425,7 +425,7 @@ $timezone .= html_print_timezone_select('timezone', $user_info['timezone']).'</d
// Double auth.
$double_auth_enabled = (bool) db_get_value('id', 'tuser_double_auth', 'id_user', $config['id_user']);
if ($config['double_auth_enabled'] || ($config['double_auth_enabled'] == '' && $double_auth_enabled)) {
if ((bool) $config['double_auth_enabled'] === true) {
$double_authentication = '<div class="label_select_simple"><p class="edit_user_labels">'.__('Double authentication').'</p>';
if (($config['2FA_all_users'] == '' && !$double_auth_enabled)
|| ($config['2FA_all_users'] != '' && !$double_auth_enabled)
@ -437,9 +437,6 @@ if ($config['double_auth_enabled'] || ($config['double_auth_enabled'] == '' && $
// Dialog.
$double_authentication .= '<div id="dialog-double_auth"class="invisible"><div id="dialog-double_auth-container"></div></div>';
}
if ($double_auth_enabled && $config['double_auth_enabled']) {
$double_authentication .= html_print_button(__('Show information'), 'show_info', false, 'javascript:show_double_auth_info();', '', true);
}
@ -1166,7 +1163,7 @@ function show_double_auth_activation () {
resizable: true,
draggable: true,
modal: true,
title: "<?php echo __('Double autentication activation'); ?>",
title: "<?php echo __('Double authentication activation'); ?>",
overlay: {
opacity: 0.5,
background: "black"
@ -1242,7 +1239,7 @@ function show_double_auth_deactivation () {
resizable: true,
draggable: true,
modal: true,
title: "<?php echo __('Double autentication activation'); ?>",
title: "<?php echo __('Double authentication activation'); ?>",
overlay: {
opacity: 0.5,
background: "black"

View File

@ -281,6 +281,12 @@ $visualConsoleItems = VisualConsole::getItemsFromDB(
"<?php echo get_parameter('hash', ''); ?>"
);
if(props.maintenanceMode != null) {
if(props.maintenanceMode.user !== '<?php echo $config['id_user']; ?>') {
visualConsoleManager.visualConsole.enableMaintenanceMode();
}
}
var controls = document.getElementById('vc-controls');
autoHideElement(controls, 1000);

View File

@ -33,7 +33,6 @@ global $config;
check_login();
require_once $config['homedir'].'/vendor/autoload.php';
// TODO: include file functions.
require_once $config['homedir'].'/include/functions_visual_map.php';
@ -103,6 +102,9 @@ $aclRead = (bool) check_acl_restricted_all($config['id_user'], $groupId, 'VR')
$aclWrite = (bool) check_acl_restricted_all($config['id_user'], $groupId, 'VW');
$aclManage = (bool) check_acl_restricted_all($config['id_user'], $groupId, 'VM');
// Maintenance Mode.
$maintenanceMode = $visualConsoleData['maintenanceMode'];
if ($aclRead === false && $aclWrite === false && $aclManage === false) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
@ -398,18 +400,54 @@ if ($pure === false) {
echo '</div>';
if ($aclWrite === true || $aclManage === true) {
if (!is_metaconsole()) {
echo '<a id ="force_check" href="" style="margin-right: 25px;">'.html_print_image(
echo '<div class="flex-row" style="width:220px;">';
if (is_metaconsole() === false) {
echo '<div id="force_check_control" class="flex-column">';
echo html_print_label(__('Force'), 'force-mode', true);
echo '<a id ="force_check" href="">';
echo html_print_image(
'images/target.png',
true,
[
'title' => __('Force remote checks'),
'class' => 'invert_filter',
]
).'</a>';
);
echo '</a>';
echo '</div>';
}
echo html_print_checkbox_switch('edit-mode', 1, false, true);
$disabled_edit_mode = false;
if ($aclManage === true) {
$value_maintenance_mode = true;
if ($maintenanceMode === null) {
$value_maintenance_mode = false;
} else {
if ($maintenanceMode['user'] !== $config['id_user']) {
$disabled_edit_mode = true;
}
}
echo '<div id="maintenance-mode-control" class="flex-column">';
echo html_print_label(
__('Maintenance'),
'maintenance-mode',
true
);
echo html_print_checkbox_switch(
'maintenance-mode',
1,
$value_maintenance_mode,
true
);
echo '</div>';
}
echo '<div id="edit-mode-control" class="flex-column">';
echo html_print_label(__('Edit'), 'edit-mode', true);
echo html_print_checkbox_switch('edit-mode', 1, false, true, $disabled_edit_mode);
echo '</div>';
echo '</div>';
}
echo '</div>';
@ -661,6 +699,18 @@ ui_require_css_file('form');
window.history.replaceState({}, document.title, href);
}
}
if(newProps.maintenanceMode != null) {
$('input[name=maintenance-mode]').prop('checked', true);
if(newProps.maintenanceMode.user !== '<?php echo $config['id_user']; ?>') {
$('input[name=edit-mode]').prop('disabled', true);
} else {
$('input[name=edit-mode]').prop('disabled', false);
}
} else {
$('input[name=maintenance-mode]').prop('checked', false);
$('input[name=edit-mode]').prop('disabled', false);
}
}
// Add the datetime when the item was received.
@ -676,26 +726,88 @@ ui_require_css_file('form');
items,
baseUrl,
<?php echo ($refr * 1000); ?>,
handleUpdate
handleUpdate,
false,
undefined,
'<?php echo $config['id_user']; ?>',
);
if(props.maintenanceMode != null) {
if(props.maintenanceMode.user !== '<?php echo $config['id_user']; ?>') {
visualConsoleManager.visualConsole.enableMaintenanceMode();
}
}
<?php
if ($edit_capable === true) {
?>
// Enable/disable the edition mode.
$('input[name=edit-mode]').change(function(event) {
var maintenanceMode = visualConsoleManager.visualConsole.props.maintenanceMode;
if ($(this).prop('checked')) {
visualConsoleManager.visualConsole.enableEditMode();
visualConsoleManager.changeUpdateInterval(0);
$('#force_check').hide();
$('#edit-controls').css('visibility', '');
} else {
visualConsoleManager.visualConsole.disableEditMode();
visualConsoleManager.visualConsole.unSelectItems();
visualConsoleManager.changeUpdateInterval(<?php echo ($refr * 1000); ?>); // To ms.
$('#edit-controls').css('visibility', 'hidden');
$('#force_check').show();
}
resetInterval();
});
// Enable/disable the maintenance mode.
$('input[name=maintenance-mode]').click(function(event) {
event.preventDefault();
const idVisualConsole = '<?php echo $visualConsoleId; ?>';
const mode = ($(this).prop('checked') === true) ? 1 : 0;
var maintenanceMode = visualConsoleManager.visualConsole.props.maintenanceMode;
var msg = '';
if(maintenanceMode == null) {
msg = '<?php echo __('Are you sure you wish to set the visual console in maintenance mode'); ?>';
msg += '?';
} else if (maintenanceMode.user === '<?php echo $config['id_user']; ?>') {
msg += '<?php echo __('Are you sure you wish to disable maintenance mode'); ?>';
msg += '?';
} else {
msg = '<?php echo __('The visual console was set to maintenance mode'); ?>';
msg += ' ' + '<span title="'+maintenanceMode.date+'">' + maintenanceMode.timestamp + '</span>';
msg += ' ' + '<?php echo __('ago by user'); ?>';
msg += ' ' + maintenanceMode.user;
msg += '. ' + '<?php echo __('Are you sure you wish to disable maintenance mode'); ?>';
msg += '?';
}
confirmDialog({
title: '<?php echo __('Maintenance mode'); ?>',
message: msg,
onAccept: function() {
$.ajax({
type: "POST",
url: "ajax.php",
dataType: "json",
data: {
page: "include/ajax/visual_console.ajax",
update_maintanance_mode: true,
idVisualConsole: idVisualConsole,
mode: mode
},
success: function (data) {
if(data.result) {
$('input[name=maintenance-mode]').prop('checked', mode);
$('input[name=maintenance-mode]').trigger('change');
resetInterval();
}
},
error: function (err) {
console.error(err);
}
});
}
});
});
<?php
}
@ -797,6 +909,7 @@ if ($edit_capable === true) {
function resetInterval() {
visualConsoleManager.changeUpdateInterval(<?php echo ($refr * 1000); ?>);
visualConsoleManager.forceUpdateVisualConsole();
}
/**

View File

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

View File

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

View File

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

View File

@ -764,7 +764,7 @@ CREATE TABLE IF NOT EXISTS `tgrupo` (
CREATE TABLE IF NOT EXISTS `tcredential_store` (
`identifier` VARCHAR(100) NOT NULL,
`id_group` MEDIUMINT UNSIGNED NOT NULL DEFAULT 0,
`product` ENUM('CUSTOM', 'AWS', 'AZURE', 'GOOGLE', 'SAP') DEFAULT 'CUSTOM',
`product` ENUM('CUSTOM', 'AWS', 'AZURE', 'GOOGLE', 'SAP', 'WMI', 'SNMP') DEFAULT 'CUSTOM',
`username` TEXT,
`password` TEXT,
`extra_1` TEXT,
@ -1679,6 +1679,7 @@ CREATE TABLE IF NOT EXISTS `tlayout` (
`background_color` VARCHAR(50) NOT NULL DEFAULT '#FFF',
`is_favourite` INT UNSIGNED NOT NULL DEFAULT 0,
`auto_adjust` INT UNSIGNED NOT NULL DEFAULT 0,
`maintenance_mode` TEXT,
PRIMARY KEY(`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;

View File

@ -1335,18 +1335,18 @@ UPDATE `tnotification_source` SET `enabled`=1 WHERE `description` = 'System&#x20
--
INSERT INTO `tlayout`
VALUES
(1, 'Demo&#x20;visual console', 0, 'fondo.jpg', 1080, 1920, 'white', 0, 0),
(2,'Demo&#x20;visual console 2',0,'fondo-keep-alive.jpg',1080,1920,'#FFF',0, 0),
(3,'Worldmap',0,'map_world.jpg',1080,1920,'white',0, 0),
(4,'Europe',0,'map_europe_1.jpg',1080,1920,'white',0, 0),
(5,'USA',0,'map_USA.jpg',1080,1920,'white',0, 0),
(6,'Spain',0,'map_spain.jpg',1080,1920,'white',0, 0),
(7,'Madrid',0,'map_madrid.jpg',1080,1920,'white',0, 0),
(8,'Germany',0,'map_germany_1.jpg',1080,1920,'white',0, 0),
(9,'France',0,'map_france.jpg',1080,1920,'white',0, 0),
(10,'Catalonia',0,'map_catalonia.jpg',1080,1920,'white',0, 0),
(11,'Basque&#x20;Country',0,'map_basque-country.jpg',1080,1920,'white',0, 0),
(12,'Andalusia',0,'map_andalusia.jpg',1080,1920,'white',0, 0)
(1, 'Demo&#x20;visual console', 0, 'fondo.jpg', 1080, 1920, 'white', 0, 0, null),
(2,'Demo&#x20;visual console 2',0,'fondo-keep-alive.jpg',1080,1920,'#FFF',0, 0, null),
(3,'Worldmap',0,'map_world.jpg',1080,1920,'white',0, 0, null),
(4,'Europe',0,'map_europe_1.jpg',1080,1920,'white',0, 0, null),
(5,'USA',0,'map_USA.jpg',1080,1920,'white',0, 0, null),
(6,'Spain',0,'map_spain.jpg',1080,1920,'white',0, 0, null),
(7,'Madrid',0,'map_madrid.jpg',1080,1920,'white',0, 0, null),
(8,'Germany',0,'map_germany_1.jpg',1080,1920,'white',0, 0, null),
(9,'France',0,'map_france.jpg',1080,1920,'white',0, 0, null),
(10,'Catalonia',0,'map_catalonia.jpg',1080,1920,'white',0, 0, null),
(11,'Basque&#x20;Country',0,'map_basque-country.jpg',1080,1920,'white',0, 0, null),
(12,'Andalusia',0,'map_andalusia.jpg',1080,1920,'white',0, 0, null)
;
--

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 7.0NG.765-221027
Version: 7.0NG.765-221031
Architecture: all
Priority: optional
Section: admin

View File

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

View File

@ -46,7 +46,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.765";
my $pandora_build = "221027";
my $pandora_build = "221031";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash

View File

@ -113,6 +113,10 @@ our @EXPORT = qw(
get_agentmodule_status_str
get_agentmodule_data
set_ssl_opts
db_synch_insert
db_synch_update
db_synch_delete
db_synch
$RDBMS
$RDBMS_QUOTE
$RDBMS_QUOTE_STRING
@ -1672,6 +1676,78 @@ sub set_ssl_opts($) {
}
}
########################################################################
## Synch insert query with nodes.
########################################################################
sub db_synch_insert ($$$$$@) {
my ($dbh, $pa_config, $table, $query, $result, @values) = @_;
my $substr = "\"\%s\"";
$query =~ s/\?/$substr/g;
my $query_string = sprintf($query, @values);
db_synch($dbh, $pa_config, 'INSERT INTO', $table, $query_string, $result);
}
########################################################################
## Synch update query with nodes.
########################################################################
sub db_synch_update ($$$$$@) {
my ($dbh, $pa_config, $table, $query, $result, @values) = @_;
my $substr = "\"\%s\"";
$query =~ s/\?/$substr/g;
my $query_string = sprintf($query, @values);
db_synch($dbh, $pa_config, 'UPDATE', $table, $query_string, $result);
}
########################################################################
## Synch delete query with nodes.
########################################################################
sub db_synch_delete ($$$$@) {
my ($dbh, $pa_config, $table, $result, @parameters) = @_;
#Build query string.
my $query = $dbh->{Statement};
my $substr = "\"\%s\"";
$query =~ s/\?/$substr/g;
my $query_string = sprintf($query, @parameters);
db_synch($dbh, $pa_config, 'DELETE FROM', $table, $query_string, $result);
}
########################################################################
## Synch queries with nodes.
########################################################################
sub db_synch ($$$$$$) {
my ($dbh, $pa_config, $type, $table, $query, $result) = @_;
my @nodes = get_db_rows($dbh, 'SELECT * FROM tmetaconsole_setup');
foreach my $node (@nodes) {
eval {
local $SIG{__DIE__};
my @values_queue = (
safe_input($query),
$node->{'id'},
time(),
$type,
$table,
'',
$result
);
my $query_queue = 'INSERT INTO tsync_queue (`sql`, `target`, `utimestamp`, `operation`, `table`, `error`, `result`) VALUES (?, ?, ?, ?, ?, ?, ?)';
db_insert ($dbh, 'id', $query_queue, @values_queue);
};
if ($@) {
logger($pa_config, "Error add sync_queue: $@", 10);
return;
}
}
}
# End of function declaration
# End of defined Code

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv;
# version: define current version
my $version = "7.0NG.765 Build 221027";
my $version = "7.0NG.765 Build 221031";
# save program name for logging
my $progname = basename($0);
@ -539,8 +539,27 @@ sub pandora_add_profile_to_user ($$$;$) {
$group_id = 0 unless defined($group_id);
db_do ($dbh, 'INSERT INTO tusuario_perfil (id_usuario, id_perfil, id_grupo)
VALUES (?, ?, ?)', safe_input($user_id), $profile_id, $group_id);
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
if(is_metaconsole($conf) != 1 && $centralized) {
print_log "[ERROR] This node is configured with centralized mode. To create a user go to metaconsole. \n\n";
exit;
}
my $query = 'INSERT INTO tusuario_perfil (id_usuario, id_perfil, id_grupo) VALUES (?, ?, ?)';
my @values = (
safe_input($user_id),
$profile_id,
$group_id
);
my $res = db_do ($dbh, $query, @values);
if(is_metaconsole($conf) == 1 && $centralized) {
db_synch_insert($dbh, $conf, 'tusuario_perfil', $query, $res, @values);
}
return $res;
}
@ -568,13 +587,29 @@ sub cli_create_snmp_trap ($$) {
sub pandora_create_user ($$$$$) {
my ($dbh, $name, $password, $is_admin, $comments) = @_;
if(is_metaconsole($conf) != 1 && pandora_get_tconfig_token ($dbh, 'centralized_management', '')) {
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
if(is_metaconsole($conf) != 1 && $centralized) {
print_log "[ERROR] This node is configured with centralized mode. To create a user go to metaconsole. \n\n";
exit;
}
my $query = 'INSERT INTO tusuario (id_user, fullname, password, comments, is_admin) VALUES (?, ?, ?, ?, ?)';
my @values = (
safe_input($name),
safe_input($name),
$password,
decode_entities($comments),
$is_admin ? '1' : '0'
);
return db_insert ($dbh, 'id_user', 'INSERT INTO tusuario (id_user, fullname, password, is_admin, comments)
VALUES (?, ?, ?, ?, ?)', safe_input($name), safe_input($name), $password, $is_admin ? '1' : '0', decode_entities($comments));
my $res = db_insert($dbh, 'id_user', $query, @values);
if(is_metaconsole($conf) == 1 && $centralized) {
db_synch_insert($dbh, $conf, 'tusuario', $query, $res, @values);
}
return $res;
}
##########################################################################
@ -583,17 +618,27 @@ sub pandora_create_user ($$$$$) {
sub pandora_delete_user ($$) {
my ($dbh, $name) = @_;
if(is_metaconsole($conf) != 1 && pandora_get_tconfig_token ($dbh, 'centralized_management', '')) {
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
if(is_metaconsole($conf) != 1 && $centralized) {
print_log "[ERROR] This node is configured with centralized mode. To delete a user go to metaconsole. \n\n";
exit;
}
# Delete user profiles
db_do ($dbh, 'DELETE FROM tusuario_perfil WHERE id_usuario = ?', $name);
my $result_profile = db_do ($dbh, 'DELETE FROM tusuario_perfil WHERE id_usuario = ?', $name);
if(is_metaconsole($conf) == 1 && $centralized) {
db_synch_delete($dbh, $conf, 'tusuario_perfil', $result_profile, $name);
}
# Delete the user
my $return = db_do ($dbh, 'DELETE FROM tusuario WHERE id_user = ?', $name);
if(is_metaconsole($conf) == 1 && $centralized) {
db_synch_delete($dbh, $conf, 'tusuario', $return, $name);
}
if($return eq '0E0') {
return -1;
}
@ -623,25 +668,79 @@ else {
## Assign a profile to the given user/group.
##########################################################################
sub pandora_create_user_profile ($$$$) {
my ($dbh, $user_id, $profile_id, $group_id) = @_;
return db_insert ($dbh, 'id_up', 'INSERT INTO tusuario_perfil (id_usuario, id_perfil, id_grupo) VALUES (?, ?, ?)', $user_id, $profile_id, $group_id);
my ($dbh, $user_id, $profile_id, $group_id) = @_;
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
if(is_metaconsole($conf) != 1 && $centralized) {
print_log "[ERROR] This node is configured with centralized mode. To create a user go to metaconsole. \n\n";
exit;
}
my $query = 'INSERT INTO tusuario_perfil (id_usuario, id_perfil, id_grupo) VALUES (?, ?, ?)';
my @values = (
safe_input($user_id),
$profile_id,
$group_id
);
my $res = db_insert ($dbh, 'id_up', $query, @values);
if(is_metaconsole($conf) == 1 && $centralized) {
db_synch_insert($dbh, $conf, 'tusuario_perfil', $query, $res, @values);
}
return $res;
}
##########################################################################
## Create profile.
##########################################################################
sub pandora_create_profile ($$$$$$$$$$$$$$$$$$$$$$) {
my ($dbh, $profile_name, $agent_view,
my ($dbh, $profile_name, $agent_view,
$agent_edit, $agent_disable, $alert_edit, $alert_management, $user_management, $db_management,
$event_view, $event_edit, $event_management, $report_view, $report_edit, $report_management,
$map_view, $map_edit, $map_management, $vconsole_view, $vconsole_edit, $vconsole_management, $pandora_management) = @_;
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
return db_insert ($dbh, 'id_up', 'INSERT INTO tperfil (name,agent_view,agent_edit,agent_disable,alert_edit,alert_management,user_management,db_management,event_view,event_edit,event_management,report_view,report_edit,report_management,map_view,map_edit,map_management,vconsole_view,vconsole_edit,vconsole_management,pandora_management) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);',
safe_input($profile_name), $agent_view,
$agent_edit, $agent_disable, $alert_edit, $alert_management, $user_management, $db_management,
$event_view, $event_edit, $event_management, $report_view, $report_edit, $report_management,
$map_view, $map_edit, $map_management, $vconsole_view, $vconsole_edit, $vconsole_management, $pandora_management);
if(is_metaconsole($conf) != 1 && $centralized) {
print_log "[ERROR] This node is configured with centralized mode. To create a user go to metaconsole. \n\n";
exit;
}
my $query = 'INSERT INTO tperfil (name,agent_view,agent_edit,agent_disable,alert_edit,alert_management,user_management,db_management,event_view,event_edit,event_management,report_view,report_edit,report_management,map_view,map_edit,map_management,vconsole_view,vconsole_edit,vconsole_management,pandora_management) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);';
my @values = (
safe_input($profile_name),
$agent_view,
$agent_edit,
$agent_disable,
$alert_edit,
$alert_management,
$user_management,
$db_management,
$event_view,
$event_edit,
$event_management,
$report_view,
$report_edit,
$report_management,
$map_view,
$map_edit,
$map_management,
$vconsole_view,
$vconsole_edit,
$vconsole_management,
$pandora_management
);
my $res = db_insert ($dbh, 'id_perfil', $query, @values);
if(is_metaconsole($conf) == 1 && $centralized) {
db_synch_insert($dbh, $conf, 'tperfil', $query, $res, @values);
}
return $res;
}
##########################################################################
@ -653,11 +752,33 @@ sub pandora_update_profile ($$$$$$$$$$$$$$$$$$$$$$) {
$event_view, $event_edit, $event_management, $report_view, $report_edit, $report_management,
$map_view, $map_edit, $map_management, $vconsole_view, $vconsole_edit, $vconsole_management, $pandora_management) = @_;
return db_update ($dbh, 'UPDATE tperfil SET agent_view = ?, agent_edit = ?, agent_disable = ?, alert_edit = ?, alert_management = ?, user_management = ?, db_management = ?, event_view = ?, event_edit = ?, event_management = ?, report_view = ?, report_edit = ?, report_management = ?, map_view = ?, map_edit = ?, map_management = ?, vconsole_view = ?, vconsole_edit = ?, vconsole_management = ?, pandora_management = ? WHERE name=?;',
$agent_view,
$agent_edit, $agent_disable, $alert_edit, $alert_management, $user_management, $db_management,
$event_view, $event_edit, $event_management, $report_view, $report_edit, $report_management,
$map_view, $map_edit, $map_management, $vconsole_view, $vconsole_edit, $vconsole_management, $pandora_management, safe_input($profile_name));
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
if(is_metaconsole($conf) != 1 && $centralized) {
print_log "[ERROR] This node is configured with centralized mode. To create a user go to metaconsole. \n\n";
exit;
}
my @parameters = (
$agent_view, $agent_edit, $agent_disable,
$alert_edit, $alert_management,
$user_management, $db_management,
$event_view, $event_edit, $event_management,
$report_view, $report_edit, $report_management,
$map_view, $map_edit, $map_management,
$vconsole_view, $vconsole_edit, $vconsole_management,
$pandora_management, safe_input($profile_name)
);
my $query = 'UPDATE tperfil SET agent_view = ?, agent_edit = ?, agent_disable = ?, alert_edit = ?, alert_management = ?, user_management = ?, db_management = ?, event_view = ?, event_edit = ?, event_management = ?, report_view = ?, report_edit = ?, report_management = ?, map_view = ?, map_edit = ?, map_management = ?, vconsole_view = ?, vconsole_edit = ?, vconsole_management = ?, pandora_management = ? WHERE name=?;';
my $result = db_update ($dbh, $query, @parameters);
if(is_metaconsole($conf) == 1 && $centralized) {
db_synch_update($dbh, $conf, 'tperfil', $query, $result, @parameters);
}
return $result;
}
##########################################################################
@ -665,8 +786,28 @@ sub pandora_update_profile ($$$$$$$$$$$$$$$$$$$$$$) {
##########################################################################
sub pandora_delete_user_profile ($$$$) {
my ($dbh, $user_id, $profile_id, $group_id) = @_;
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
if(is_metaconsole($conf) != 1 && $centralized) {
print_log "[ERROR] This node is configured with centralized mode. To delete a user go to metaconsole. \n\n";
exit;
}
my @parameters = (
$user_id,
$profile_id,
$group_id
);
# Delete the user
my $return = db_do ($dbh, 'DELETE FROM tusuario_perfil WHERE id_usuario=? AND id_perfil=? AND id_grupo=?', @parameters);
if(is_metaconsole($conf) == 1 && $centralized) {
db_synch_delete($dbh, $conf, 'tusuario_perfil', $return, @parameters);
}
return db_do ($dbh, 'DELETE FROM tusuario_perfil WHERE id_usuario=? AND id_perfil=? AND id_grupo=?', $user_id, $profile_id, $group_id);
return $return;
}
##########################################################################
@ -816,9 +957,18 @@ sub pandora_validate_event_id ($$$) {
##########################################################################
sub pandora_update_user_from_hash ($$$$) {
my ($parameters, $where_column, $where_value, $dbh) = @_;
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
my $result = db_process_update($dbh, 'tusuario', $parameters, {$where_column => $where_value});
if(is_metaconsole($conf) == 1 && $centralized) {
my @values = (
values %$parameters,
$where_value
);
my $user_id = db_process_update($dbh, 'tusuario', $parameters, {$where_column => $where_value});
return $user_id;
db_synch_update($dbh, $conf, 'tusuario', $dbh->{Statement}, $result, @values);
}
return $result;
}
##########################################################################
@ -6235,8 +6385,10 @@ sub cli_disable_double_auth () {
sub cli_user_enable () {
my $user_id = @ARGV[2];
if(is_metaconsole($conf) != 1 && pandora_get_tconfig_token ($dbh, 'centralized_management', '')) {
print_log "[ERROR] This node is configured with centralized mode. To enable a user go to metaconsole. \n\n";
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
if(is_metaconsole($conf) != 1 && $centralized) {
print_log "[ERROR] This node is configured with centralized mode. To create a user go to metaconsole. \n\n";
exit;
}
@ -6253,9 +6405,14 @@ sub cli_user_enable () {
$user_id = safe_input($user_id);
db_do ($dbh, "UPDATE tusuario SET disabled = '0' WHERE id_user = '$user_id'");
exit;
my $result = db_do ($dbh, "UPDATE tusuario SET disabled = '0' WHERE id_user = '$user_id'");
if(is_metaconsole($conf) == 1 && $centralized) {
my @values;
db_synch_update($dbh, $conf, 'tusuario', $dbh->{Statement}, $result, @values);
}
exit;
}
###############################################################################
@ -6265,8 +6422,10 @@ sub cli_user_enable () {
sub cli_user_disable () {
my $user_id = @ARGV[2];
if(is_metaconsole($conf) != 1 && pandora_get_tconfig_token ($dbh, 'centralized_management', '')) {
print_log "[ERROR] This node is configured with centralized mode. To disable a user go to metaconsole. \n\n";
my $centralized = pandora_get_tconfig_token ($dbh, 'centralized_management', '');
if(is_metaconsole($conf) != 1 && $centralized) {
print_log "[ERROR] This node is configured with centralized mode. To create a user go to metaconsole. \n\n";
exit;
}
@ -6283,9 +6442,14 @@ sub cli_user_disable () {
$user_id = safe_input($user_id);
db_do ($dbh, "UPDATE tusuario SET disabled = '1' WHERE id_user = '$user_id'");
my $result = db_do ($dbh, "UPDATE tusuario SET disabled = '1' WHERE id_user = '$user_id'");
if(is_metaconsole($conf) == 1 && $centralized) {
my @values;
db_synch_update($dbh, $conf, 'tusuario', $dbh->{Statement}, $result, @values);
}
exit;
exit;
}
###############################################################################

View File

@ -591,6 +591,9 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
});
// Metadata state.
if (this.meta.maintenanceMode) {
box.classList.add("is-maintenance");
}
if (this.meta.editMode) {
box.classList.add("is-editing");
}
@ -877,8 +880,12 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
}
// Change metadata related things.
if (!prevMeta || prevMeta.editMode !== this.meta.editMode) {
if (this.meta.editMode) {
if (
!prevMeta ||
prevMeta.editMode !== this.meta.editMode ||
prevMeta.maintenanceMode !== this.meta.maintenanceMode
) {
if (this.meta.editMode && this.meta.maintenanceMode === false) {
this.elementRef.classList.add("is-editing");
} else {
this.elementRef.classList.remove("is-editing");

View File

@ -159,6 +159,12 @@ export interface VisualConsoleProps extends Size {
backgroundColor: string | null;
isFavorite: boolean;
relationLineWidth: number;
maintenanceMode: MaintenanceModeInterface | null;
}
export interface MaintenanceModeInterface {
user: string;
timestamp: number;
}
/**
@ -181,7 +187,8 @@ export function visualConsolePropsDecoder(
backgroundURL,
backgroundColor,
isFavorite,
relationLineWidth
relationLineWidth,
maintenanceMode
} = data;
if (id == null || isNaN(parseInt(id))) {
@ -202,6 +209,7 @@ export function visualConsolePropsDecoder(
backgroundColor: notEmptyStringOr(backgroundColor, null),
isFavorite: parseBoolean(isFavorite),
relationLineWidth: parseIntOr(relationLineWidth, 0),
maintenanceMode: maintenanceMode,
...sizePropsDecoder(data)
};
}
@ -1222,6 +1230,28 @@ export default class VisualConsole {
this.containerRef.classList.remove("is-editing");
}
/**
* Enable the maintenance mode.
*/
public enableMaintenanceMode(): void {
this.elements.forEach(item => {
item.meta = { ...item.meta, maintenanceMode: true };
});
this.containerRef.classList.add("is-maintenance");
this.containerRef.classList.remove("is-editing");
}
/**
* Disable the maintenance mode.
*/
public disableMaintenanceMode(): void {
this.elements.forEach(item => {
item.meta = { ...item.meta, maintenanceMode: false };
});
this.containerRef.classList.remove("is-maintenance");
this.containerRef.classList.add("is-editing");
}
/**
* Select an item.
* @param itemId Item Id.

View File

@ -275,6 +275,7 @@ export function itemMetaDecoder(data: UnknownObject): ItemMeta | never {
receivedAt,
error,
editMode: parseBoolean(data.editMode),
maintenanceMode: parseBoolean(data.maintenanceMode),
isFromCache: parseBoolean(data.isFromCache),
isFetching: false,
isUpdating: false,

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

View File

@ -133,6 +133,7 @@ describe("itemMetaDecoder function", () => {
isFetching: false,
isUpdating: false,
editMode: false,
maintenanceMode: false,
isBeingMoved: false,
isBeingResized: false,
isSelected: false,
@ -154,6 +155,7 @@ describe("itemMetaDecoder function", () => {
isFetching: false,
isUpdating: false,
editMode: true,
maintenanceMode: false,
isBeingMoved: false,
isBeingResized: false,
isSelected: false,

View File

@ -61,5 +61,6 @@ export interface ItemMeta {
isBeingMoved: boolean;
isBeingResized: boolean;
editMode: boolean;
maintenanceMode: boolean;
lineMode: boolean;
}

View File

@ -7,6 +7,14 @@
margin-top: 5px;
}
.is-maintenance {
background-image: url(./lib/maintenanceMode.png) !important;
}
.is-maintenance :nth-child(1) {
display: none;
}
.visual-console-item {
position: absolute;
display: flex;