diff --git a/plugins/example.json b/plugins/example.json index fc2fcbde..88276648 100644 --- a/plugins/example.json +++ b/plugins/example.json @@ -11,6 +11,7 @@ "php_": ">5.4,<7.0", // support for defining versions like in composer (since 0.8) "database": "21", "php-ext": "curl", // php extension needs to be installed (since 0.8) + "ext-curl": ">5.0", // php extension with version specifiec (since 0.8) "table": "accounts", // table need to exist in database (since 0.8) "column": "players.online" // column need to exist in database (since 0.8) }, diff --git a/system/libs/plugins.php b/system/libs/plugins.php index 016fa526..c39a3076 100644 --- a/system/libs/plugins.php +++ b/system/libs/plugins.php @@ -66,6 +66,8 @@ function is_sub_dir($path = NULL, $parent_folder = SITE_PATH) { return FALSE; } +use Composer\Semver\Semver; + class Plugins { private static $warnings = array(); private static $error = null; @@ -126,7 +128,7 @@ class Plugins { $myaac_satified = true; if(isset($require['myaac_'])) { $require_myaac = $require['myaac_']; - if(!Composer\Semver\Semver::satisfies(MYAAC_VERSION, $require_myaac)) { + if(!Semver::satisfies(MYAAC_VERSION, $require_myaac)) { $myaac_satified = false; } } @@ -145,7 +147,7 @@ class Plugins { $php_satified = true; if(isset($require['php_'])) { $require_php = $require['php_']; - if(!Composer\Semver\Semver::satisfies(phpversion(), $require_php)) { + if(!Semver::satisfies(phpversion(), $require_php)) { $php_satified = false; } } @@ -164,7 +166,7 @@ class Plugins { $database_satified = true; if(isset($require['database_'])) { $require_database = $require['database_']; - if(!Composer\Semver\Semver::satisfies(DATABASE_VERSION, $require_database)) { + if(!Semver::satisfies(DATABASE_VERSION, $require_database)) { $database_satified = false; } } @@ -211,6 +213,16 @@ class Plugins { } } } + else if(strpos($req, 'ext-') !== false) { + $tmp = explode('-', $req); + if(count($tmp) == 2) { + if(!extension_loaded($tmp[1]) || !Semver::satisfies(phpversion($tmp[1]), $version)) { + self::$error = "This plugin requires php extension: " . $tmp[1] . ", version " . $version . " to be installed."; + $continue = false; + break; + } + } + } else if(!self::is_installed($req, $version)) { self::$error = "This plugin requires another plugin to run correctly. The another plugin is: " . $req . ", with version " . $version . "."; $continue = false; @@ -361,7 +373,7 @@ class Plugins { return false; } - return Composer\Semver\Semver::satisfies($plugin_info['version'], $version); + return Semver::satisfies($plugin_info['version'], $version); } public static function getWarnings() {