diff --git a/core/include/checkup.php b/core/include/checkup.php index dadefb98..54cc4253 100644 --- a/core/include/checkup.php +++ b/core/include/checkup.php @@ -3,26 +3,23 @@ /** * Vérification de la version de PHP */ - -if(version_compare(PHP_VERSION, '7.2.0', '<') ) { - exit('PHP 7.2+ mini requis - PHP 7.2+ mini required'); - +if (version_compare(PHP_VERSION, '7.2.0', '<')) { + displayErrorPage('PHP 7.2+ mini requis - PHP 7.2+ mini required'); } -if ( version_compare(PHP_VERSION, '8.4.999', '>') ) { - exit('PHP 8.3 pas encore supporté, installez PHP 7.n ou PHP 8.1.n - PHP 8.3 not yet supported, install PHP 7.n or PHP 8.1.n'); +if (version_compare(PHP_VERSION, '8.3.999', '>')) { + displayErrorPage('PHP 8.3 pas encore supporté, installez PHP 7.n ou PHP 8.1.n - PHP 8.3 not yet supported, install PHP 7.n or PHP 8.1.n'); } /** * Check les modules installés */ - $e = [ 'gd', 'json', 'date', 'mbstring', - 'zip', + 'zip', 'intl', 'exif', 'Phar', @@ -31,26 +28,57 @@ $e = [ ]; $m = get_loaded_extensions(); $b = false; +$missingModules = []; foreach ($e as $k => $v) { - if (array_search($v,$m) === false) { + if (array_search($v, $m) === false) { $b = true; - echo '

Module PHP : ' . $v . ' manquant - Module PHP ' . $v . ' missing.

'; + $missingModules[] = $v; } } -if ($b) - exit('

ZwiiCMS ne peut pas démarrer ; activez les extensions requises dans PHP.ini- ZwiiCMS cannot start, enabled PHP missing extensions into PHP.ini

'); -/** - * Contrôle les htacess - */ +if ($b) { + $errorMessage = 'ZwiiCMS ne peut pas démarrer ; les modules PHP suivants sont manquants : ' . implode(', ', $missingModules) . '
'; + $errorMessage .= 'ZwiiCMS cannot start, the following PHP modules are missing: ' . implode(', ', $missingModules); + displayErrorPage($errorMessage); +} +/** + * Contrôle les htaccess + */ $d = [ '', 'site/data/', 'site/backup/', 'site/tmp/', - // 'site/i18n/', pas contrôler pour éviter les pbs de mise à jour + // 'site/i18n/', pas contrôler pour éviter les pbs de mise à jour ]; foreach ($d as $key) { - if (file_exists($key . '.htaccess') === false) - exit('
ZwiiCMS ne peut pas démarrer, le fichier ' .$key . '.htaccess est manquant.
ZwiiCMS cannot start, file ' . $key . '.htaccess is missing.
' ); + if (file_exists($key . '.htaccess') === false) { + $errorMessage = 'ZwiiCMS ne peut pas démarrer, le fichier ' . $key . '.htaccess est manquant.
'; + $errorMessage .= 'ZwiiCMS cannot start, file ' . $key . '.htaccess is missing.'; + displayErrorPage($errorMessage); + } +} + + +/** + * Fonction pour afficher une page d'erreur stylisée + */ +function displayErrorPage($message) +{ + echo ' + + + + + Erreur - ZwiiCMS + + + +
+

Erreur

+

' . $message . '

+
+ +'; + exit; } diff --git a/core/layout/error.css b/core/layout/error.css new file mode 100644 index 00000000..1129f7ae --- /dev/null +++ b/core/layout/error.css @@ -0,0 +1,22 @@ +body { + color: #000; + font: 75%/1.7em "Helvetica Neue", Helvetica, arial, sans-serif; + margin: 0; + padding: 80px; + background: url('../vendor/zwiico/png/error.png') 30px 30px no-repeat #fff; +} + +h1 { + font-weight: bold; + color: #000; + font-size: 300%; + margin: 20px 0; + padding: 0; +} + +p { + margin: 10px 0; + color: #777; + font-size: 16px; + line-height: 1.6; +} \ No newline at end of file diff --git a/core/vendor/zwiico/png/error.png b/core/vendor/zwiico/png/error.png new file mode 100644 index 00000000..777e541a Binary files /dev/null and b/core/vendor/zwiico/png/error.png differ