From: Alan Date: Mon, 24 Jul 2023 07:20:42 +0000 (+0800) Subject: add extension checking to config X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=commitdiff_plain;h=b4073c824a9518a696f71b390ffd1b2dce83f8c6 add extension checking to config --- diff --git a/Config.php b/Config.php index 25595a73..37f2da9c 100644 --- a/Config.php +++ b/Config.php @@ -10,6 +10,14 @@ class Pman_Core_Config { var $defaults = array( ); // override... + // note if other extended 'config's require more, then you porbably need to include these first. + var $required_extensions = array( + 'json', + 'curl', + 'gd', + 'mbstring' + ); + function init($ff, $cfg) { @@ -22,6 +30,7 @@ class Pman_Core_Config { } } + $this->verifyExtensions(); return $cfg; } @@ -73,6 +82,23 @@ class Pman_Core_Config { return $cfg; } - + function verifyExtensions() + { + $error = array(); + + foreach ($this->required_extensions as $e){ + + if(empty($e) || extension_loaded($e)) { + continue; + } + + $error[] = "Error: Please install php extension: {$e}"; + } + + if(empty($error)){ + return true; + } + die(implode('\n', $error)); + } } diff --git a/UpdateDatabase.php b/UpdateDatabase.php index 043a5188..f7ac3033 100644 --- a/UpdateDatabase.php +++ b/UpdateDatabase.php @@ -161,7 +161,8 @@ class Pman_Core_UpdateDatabase extends Pman var $required_extensions = array( 'curl', - 'gd' + 'gd', + 'mstring' ); function getAuth() {