diff --git a/core/composer.json b/core/composer.json index e32736730a..1d0de96d8d 100644 --- a/core/composer.json +++ b/core/composer.json @@ -75,6 +75,7 @@ "phpmailer/phpmailer": "7.*", "phpoption/phpoption": "*", "predis/predis": "*", + "rosell-dk/exec-with-fallback": "*", "rosell-dk/webp-convert": "*", "secondnetwork/blade-tabler-icons": "^3.46", "simplepie/simplepie": "1.*", diff --git a/core/src/Console/Packages/ExtrasCommand.php b/core/src/Console/Packages/ExtrasCommand.php index 098db6b85d..1679a156e7 100644 --- a/core/src/Console/Packages/ExtrasCommand.php +++ b/core/src/Console/Packages/ExtrasCommand.php @@ -1,8 +1,7 @@ NUL 2>NUL' : 'command -v ' . escapeshellarg($command) . ' >/dev/null 2>&1'; - exec($probe, $output, $exitCode); + ExecWithFallback::exec($probe, $output, $exitCode); return (int) $exitCode === 0; } @@ -1009,7 +1010,7 @@ protected function normalizeUpdateRepository(string $repository): string protected function runCoreShellCommand(string $command): void { $fullCommand = 'cd ' . escapeshellarg(EVO_CORE_PATH) . ' && ' . $command . ' 2>&1'; - exec($fullCommand, $output, $exitCode); + ExecWithFallback::exec($fullCommand, $output, $exitCode); if ((int) $exitCode !== 0) { $message = 'Command failed: ' . $command; diff --git a/install/cli-install.php b/install/cli-install.php index 4bd63c2294..560e3bae8e 100644 --- a/install/cli-install.php +++ b/install/cli-install.php @@ -1,5 +1,6 @@ &1', $out, $exitCode); - echo implode(PHP_EOL, $out), PHP_EOL; - } elseif (!in_array('shell_exec', $disabled, true)) { - $output = shell_exec($cmd . ' 2>&1'); - $exitCode = (is_string($output) && $output !== '') ? 0 : 1; - echo $output; - } else { - info('- The passthru/exec/shell_exec functions are disabled in php.ini.'); - warning('⚠ Run "composer update" manually.'); - return; - } - - if ($exitCode === 0) { - success('✔ Dependencies updated successfully.'); - } else { - error("✖ Composer finished with the code {$exitCode}."); - warning('⚠ Make sure you have execute permissions and try "composer update" manually.'); - } + $this->runComposerUpdate($cmd); } public function realInstall() diff --git a/manager/actions/bkmanager.static.php b/manager/actions/bkmanager.static.php index c76b81ba5c..b69a6c6956 100755 --- a/manager/actions/bkmanager.static.php +++ b/manager/actions/bkmanager.static.php @@ -6,6 +6,8 @@ EvolutionCMS()->webAlertAndQuit($_lang["error_no_privileges"]); } +use ExecWithFallback\ExecWithFallback; + $dbase = EvolutionCMS()->getDatabase()->getConfig('database'); if (!EvolutionCMS()->getConfig('snapshot_path')) { @@ -44,7 +46,7 @@ file_put_contents($tempfile_path, file_get_contents($_FILES['sqlfile']['tmp_name'])); $dump_request = 'PGPASSWORD="'.EvolutionCMS()->getDatabase()->getConfig('password').'" psql --host '.EvolutionCMS()->getDatabase()->getConfig('host').' --username ' . EvolutionCMS()->getDatabase()->getConfig('username') . ' --dbname ' . $dbase . ' < '.$tempfile_path; - exec($dump_request, $data, $data_second); + ExecWithFallback::exec($dump_request, $data, $data_second); unlink($tempfile_path); break; default: @@ -61,7 +63,7 @@ switch ($driver) { case 'pgsql': $dump_request = 'PGPASSWORD="'.EvolutionCMS()->getDatabase()->getConfig('password').'" psql --host '.EvolutionCMS()->getDatabase()->getConfig('host').' --username ' . EvolutionCMS()->getDatabase()->getConfig('username') . ' --dbname ' . $dbase . ' < '.$path; - exec($dump_request, $data, $data_second); + ExecWithFallback::exec($dump_request, $data, $data_second); break; default : import_sql_from_file($path); @@ -99,7 +101,7 @@ $dump_request = 'pg_dump postgresql://' . EvolutionCMS()->getDatabase()->getConfig('username') . ':'.EvolutionCMS()->getDatabase()->getConfig('password').'@'.EvolutionCMS()->getDatabase()->getConfig('host').'/' . $dbase . ' --clean --inserts --no-owner --no-privileges '. $table_str .'> ' . $tempfile_path; - exec($dump_request, $data, $data_second); + ExecWithFallback::exec($dump_request, $data, $data_second); dumpSql($tempfile_path); break; case 'sqlite':