diff --git a/pandora_console/extras/mr/48.sql b/pandora_console/extras/mr/48.sql index b5410f5bc1..b65846c487 100644 --- a/pandora_console/extras/mr/48.sql +++ b/pandora_console/extras/mr/48.sql @@ -1,5 +1,6 @@ START TRANSACTION; +ALTER TABLE `tmetaconsole_setup` ADD COLUMN `unified` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0; ALTER TABLE `tlayout` ADD COLUMN `auto_adjust` INTEGER UNSIGNED NOT NULL default 0; ALTER TABLE `tlayout_data` ADD COLUMN `title` TEXT default ''; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 92d2f3685c..f3c32bd806 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -418,6 +418,8 @@ ALTER TABLE `tmetaconsole_setup` MODIFY COLUMN `meta_dbuser` text NULL, ALTER TABLE `tmetaconsole_setup` ADD COLUMN `server_uid` TEXT NOT NULL default ''; +ALTER TABLE `tmetaconsole_setup` ADD COLUMN `unified` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0; + -- --------------------------------------------------------------------- -- Table `tprofile_view` -- --------------------------------------------------------------------- diff --git a/pandora_console/general/node_deactivated.php b/pandora_console/general/node_deactivated.php new file mode 100644 index 0000000000..c88f4f599e --- /dev/null +++ b/pandora_console/general/node_deactivated.php @@ -0,0 +1,79 @@ +<?php +/** + * Static page to lock access to console + * + * @category Wizard + * @package Pandora FMS + * @subpackage Applications.VMware + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ + +// Begin. +ui_require_css_file('maintenance'); +?> +<html> +<body> + + <div class="responsive center padding-6"> + <p><?php echo __('You cannot use this node until system is unified'); ?></p> + <br> + <br> + + <?php + html_print_image( + 'images/maintenance.png', + false, + [ + 'class' => 'responsive', + 'width' => 800, + ] + ); + ?> + + <br> + <br> + <p> + <?php + echo __( + 'Please navigate to %s to unify system', + '<a href="'.ui_get_meta_url( + 'index.php?sec=advanced&sec2=advanced/command_center' + ).'" target="_new">'.__('command center').'</a>' + ); + ?> + </p> + <br> + <p><?php echo __('You will be automatically redirected when all tasks finish'); ?></p> + </div> +</body> + +<script type="text/javascript"> + $(document).ready(function() { + setTimeout( + function() { + location.reload(); + }, + 10000 + ); + }) +</script> + +</html> \ No newline at end of file diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 7c8fa7612c..45fbcf1077 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -1752,11 +1752,27 @@ function has_metaconsole() * @return boolean */ function is_management_allowed($hkey='') +{ + return ( (is_metaconsole() && is_centrallised()) + || (!is_metaconsole() && !is_centrallised()) + || (!is_metaconsole() && is_centrallised()) && $hkey == generate_hash_to_api()); +} + + +/** + * Return true if is a centrallised environment. + * + * @return boolean + */ +function is_centrallised() { global $config; - return ( (is_metaconsole() && $config['centralized_management']) - || (!is_metaconsole() && !$config['centralized_management']) - || (!is_metaconsole() && $config['centralized_management']) && $hkey == generate_hash_to_api()); + + if (isset($config['centralized_management']) === false) { + return false; + } + + return (bool) $config['centralized_management']; } @@ -1768,8 +1784,7 @@ function is_management_allowed($hkey='') */ function is_central_policies() { - global $config; - return is_metaconsole() && $config['centralized_management']; + return is_metaconsole() && is_centrallised(); } diff --git a/pandora_console/include/styles/maintenance.css b/pandora_console/include/styles/maintenance.css index c0c6623a20..821a30dced 100644 --- a/pandora_console/include/styles/maintenance.css +++ b/pandora_console/include/styles/maintenance.css @@ -22,8 +22,12 @@ h1 { color: #83b92f; } +p a { + font-size: 1rem; +} + p { - font-size: 2rem; + font-size: 1rem; margin-bottom: 0.5rem; letter-spacing: 1.5px; font-weight: lighter; diff --git a/pandora_console/index.php b/pandora_console/index.php index e2af257836..6d986c8c3a 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -1040,6 +1040,30 @@ if (isset($_GET['bye'])) { clear_pandora_error_for_header(); +if ((bool) $config['node_deactivated'] === true) { + // Prevent access node if not merged. + include 'general/node_deactivated.php'; + + while (ob_get_length() > 0) { + ob_end_flush(); + } + + exit('</html>'); +} + +if ((bool) $config['maintenance_mode'] === true + && (bool) users_is_admin() === false +) { + // Show maintenance web-page. For non-admin users only. + include 'general/maintenance.php'; + + while (ob_get_length() > 0) { + ob_end_flush(); + } + + exit('</html>'); +} + /* * ---------------------------------------------------------------------- * EXTENSIONS @@ -1087,21 +1111,6 @@ if (get_parameter('login', 0) !== 0) { } } - -if ((bool) $config['maintenance_mode'] === true - && (bool) users_is_admin() === false -) { - // Show maintenance web-page. For non-admin users only. - include 'general/maintenance.php'; - - while (ob_get_length() > 0) { - ob_end_flush(); - } - - exit('</html>'); -} - - // Header. if ($config['pure'] == 0) { echo '<div id="container"><div id="head">'; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 99a85f9358..daa3c98746 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -2747,8 +2747,9 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_setup` ( `auth_token` text, `id_group` int(10) unsigned NOT NULL default 0, `api_password` text NOT NULL, - `disabled` tinyint(1) unsigned NOT NULL default '0', - `last_event_replication` bigint(20) default '0', + `disabled` tinyint(1) unsigned NOT NULL default 0, + `unified` tinyint(1) unsigned NOT NULL default 0, + `last_event_replication` bigint(20) default 0, `server_uid` text NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=InnoDB