From 4db0f75763883559b791fee9a5c1b1173f66f84e Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 14 Jun 2021 14:54:07 +0200 Subject: [PATCH] Refresh & delete collections Async - synchronization --- pandora_console/include/api.php | 4 +++- pandora_console/include/lib/Tools/Files.php | 19 ++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/pandora_console/include/api.php b/pandora_console/include/api.php index 0014e0a155..c5d5038b32 100644 --- a/pandora_console/include/api.php +++ b/pandora_console/include/api.php @@ -98,7 +98,9 @@ if (empty($apiPassword) === true && (enterprise_hook('metaconsole_validate_origin', [get_parameter('server_auth')]) === true || enterprise_hook('console_validate_origin', [get_parameter('server_auth')]) === true) ) { - // Allow internal direct node -> metaconsole connection. + // Allow internal direct node -> metaconsole connection + // or node -> own console connection. + $config['__internal_call'] = true; $config['id_usuario'] = 'admin'; // Compat. $config['id_user'] = 'admin'; diff --git a/pandora_console/include/lib/Tools/Files.php b/pandora_console/include/lib/Tools/Files.php index b57fb041a6..3c67cea103 100644 --- a/pandora_console/include/lib/Tools/Files.php +++ b/pandora_console/include/lib/Tools/Files.php @@ -55,6 +55,10 @@ class Files (\ZipArchive::CREATE | \ZipArchive::OVERWRITE) ); + if (substr($path, (strlen($path) - 1), 1) !== '/') { + $path .= '/'; + } + $rdi = new \RecursiveDirectoryIterator( $path ); @@ -70,9 +74,10 @@ class Files // Get real and relative // path for current file. $filePath = $file->getRealPath(); - $relativePath = substr( - $filePath, - (strlen($path) + 1) + $relativePath = str_replace( + $path, + '', + $filePath ); // Add current file to archive. @@ -166,22 +171,14 @@ class Files $pf = $folder.$pf; if (is_dir($pf) === true) { - echo $pf.'/'."\n"; // It's a directory. if (in_array($pf.'/', $exclusions) === false) { - echo ' => borro'."\n"; self::rmrf($pf.'/'); - } else { - echo ' => no borro'."\n"; } } else { - echo $pf."\n"; // It's a file. if (in_array($pf, $exclusions) === false) { - echo ' => borro'."\n"; unlink($pf); - } else { - echo ' => no borro'."\n"; } } }