From 0cec3afba0af09789542ff52eaf43c3592df61cd Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 19 Jul 2021 13:47:43 +0200 Subject: [PATCH] Deactivated nodes if not unified --- pandora_console/extras/mr/48.sql | 1 + .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 + pandora_console/general/node_deactivated.php | 79 +++++++++++++++++++ pandora_console/include/functions.php | 25 ++++-- .../include/styles/maintenance.css | 6 +- pandora_console/index.php | 39 +++++---- pandora_console/pandoradb.sql | 5 +- 7 files changed, 134 insertions(+), 23 deletions(-) create mode 100644 pandora_console/general/node_deactivated.php 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 @@ + + + + +
+

+
+
+ + 'responsive', + 'width' => 800, + ] + ); + ?> + +
+
+

+ '.__('command center').'' + ); + ?> +

+
+

+
+ + + + + \ 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(''); +} + +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(''); +} + /* * ---------------------------------------------------------------------- * 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(''); -} - - // Header. if ($config['pure'] == 0) { echo '