check php-extension requirements not only on installation (e.g. when php version was changed)

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2023-11-26 22:22:39 +01:00
parent b13b1e8ac7
commit 4f79d7cf4b
4 changed files with 64 additions and 22 deletions

View File

@@ -65,6 +65,7 @@ use Froxlor\UI\Linker;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
use Froxlor\Install\Requirements;
// include MySQL-tabledefinitions
require Froxlor::getInstallDir() . '/lib/tables.inc.php';
@@ -126,6 +127,24 @@ if ($_SERVER['SERVER_NAME'] != Settings::Get('system.hostname') &&
die();
}
// validate php-extensions requirements
$loadedExtensions = get_loaded_extensions();
$missingExtensions = [];
foreach (Requirements::REQUIRED_EXTENSIONS as $requiredExtension) {
if (in_array($requiredExtension, $loadedExtensions)) {
continue;
}
$missingExtensions[] = $requiredExtension;
}
if (!empty($missingExtensions)) {
UI::twig()->addGlobal('install_mode', '1');
echo UI::twig()->render($_deftheme . '/misc/missingextensionhint.html.twig', [
'phpversion' => phpversion(),
'missing_extensions' => implode(", ", $missingExtensions),
]);
die();
}
// set error-handler
@set_error_handler([
'\\Froxlor\\PhpHelper',