From aaa590b65fd8ac0ee75e4b2e0ca52c9f7ecca8e6 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 7 Nov 2023 09:20:48 +0100 Subject: [PATCH] VC Public links pandora_enterprise#12329 --- pandora_console/ajax.php | 4 +- .../javascript/pandora_visual_console.js | 4 +- .../rest-api/models/VisualConsole/Item.php | 8 ++-- .../operation/visual_console/public_view.php | 48 +++++++++---------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/pandora_console/ajax.php b/pandora_console/ajax.php index b3b9463ee6..a5dcf2cb0d 100644 --- a/pandora_console/ajax.php +++ b/pandora_console/ajax.php @@ -183,7 +183,9 @@ if (isset($config['force_instant_logout']) === true $_SESSION = []; session_destroy(); header_remove('Set-Cookie'); - setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/'); + if (isset($_COOKIE[session_name()]) === true) { + setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/'); + } if ($config['auth'] === 'saml' && empty($public_hash) === true) { include_once $config['saml_path'].'simplesamlphp/lib/_autoload.php'; diff --git a/pandora_console/include/javascript/pandora_visual_console.js b/pandora_console/include/javascript/pandora_visual_console.js index adcbd3ce0c..0e16bb303f 100755 --- a/pandora_console/include/javascript/pandora_visual_console.js +++ b/pandora_console/include/javascript/pandora_visual_console.js @@ -808,8 +808,8 @@ function loadVisualConsoleData( getVisualConsoleItems: 1, size: size, visualConsoleId: vcId, - id_user: typeof id_user == undefined ? id_user : null, - auth_hash: typeof hash == undefined ? hash : null, + id_user: typeof id_user !== undefined ? id_user : null, + auth_hash: typeof hash !== undefined ? hash : null, mode: mode, widthScreen: widthScreen }, diff --git a/pandora_console/include/rest-api/models/VisualConsole/Item.php b/pandora_console/include/rest-api/models/VisualConsole/Item.php index 0db9d999c2..411d605c0e 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Item.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Item.php @@ -1196,7 +1196,7 @@ class Item extends CachedModel 'operation/visual_console/view', ['id' => $vcId], // No autologin from the public view. - !$config['public_view'], + !$config['public_access'], $mobile_navigation, [ 'page' => 'visualmap', @@ -1302,7 +1302,7 @@ class Item extends CachedModel 'enterprise/operation/services/services', ['id_service' => $serviceId], // No autologin from the public view. - !$config['public_view'] + !$config['public_access'] ); } else { // A regular module. @@ -1312,7 +1312,7 @@ class Item extends CachedModel 'operation/agentes/status_monitor', ['id_module' => $moduleId], // No autologin from the public view. - !((isset($config['public_view']) === true) ? $config['public_view'] : false), + !((isset($config['public_access']) === true) ? $config['public_access'] : false), $mobile_navigation, [ 'id' => $moduleId, @@ -1377,7 +1377,7 @@ class Item extends CachedModel 'operation/agentes/ver_agente', ['id_agente' => $agentId], // No autologin from the public view. - !$config['public_view'], + !$config['public_access'], $mobile_navigation, [ 'id' => $agentId, diff --git a/pandora_console/operation/visual_console/public_view.php b/pandora_console/operation/visual_console/public_view.php index 46dd4e43b4..64529133b4 100644 --- a/pandora_console/operation/visual_console/public_view.php +++ b/pandora_console/operation/visual_console/public_view.php @@ -33,7 +33,7 @@ require_once $config['homedir'].'/vendor/autoload.php'; ui_require_css_file('register', 'include/styles/', true); // Connection lost alert. -ui_require_javascript_file('connection_check', 'include/javascript/', true); +// ui_require_javascript_file('connection_check', 'include/javascript/', true); set_js_value('absolute_homeurl', ui_get_full_url(false, false, false, false)); $conn_title = __('Connection with console has been lost'); $conn_text = __('Connection to the console has been lost. Please check your internet connection.'); @@ -47,7 +47,7 @@ global $vc_public_view; global $config; $vc_public_view = true; -$config['public_view'] = true; +$config['public_access'] = true; // This starts the page head. In the call back function, // things from $page['head'] array will be processed into the head. @@ -62,12 +62,6 @@ require_once 'include/functions_visual_map.php'; $hash = (string) get_parameter('hash'); -// For public link issue. -$force_instant_logout = true; -if (isset($config['id_user']) === true) { - $force_instant_logout = false; -} - // Check input hash. // DO NOT move it after of get parameter user id. if (User::validatePublicHash($hash) !== true) { @@ -256,17 +250,17 @@ $visualConsoleItems = VisualConsole::getItemsFromDB( if (menuLinks !== null) { menuLinks.forEach(function (menuLink) { menuLink.href = menuLink.href.replace(regex, replacement); - menuLink.href = menuLink.href.replace( - regex_hash, - replacement_hash - ); + //menuLink.href = menuLink.href.replace( + // regex_hash, + // replacement_hash + //); }); } // Change the URL (if the browser has support). if ("history" in window) { var href = window.location.href.replace(regex, replacement); - href = href.replace(regex_hash, replacement_hash); + //href = href.replace(regex_hash, replacement_hash); window.history.replaceState({}, document.title, href); } } @@ -321,20 +315,24 @@ $visualConsoleItems = VisualConsole::getItemsFromDB( } } }); - - - // No click enabled when user not logged. - $( "a" ).on( "click", function( event ) { - event.preventDefault(); - $('#visual-console-container').removeClass('is-updating'); - $('.div-visual-console-spinner').remove(); - }); - 0) { + ob_end_flush(); } \ No newline at end of file