From 4e3bfe4accb8424281dc2ed8618a6ce45a217c92 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Thu, 10 Dec 2020 14:56:31 +0100 Subject: [PATCH] Add support for ionCube Loader --- data/supported-extensions | 1 + install-php-extensions | 33 +++++++++++++++++++++++++++ scripts/check-installed-extension.php | 3 ++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/data/supported-extensions b/data/supported-extensions index df7bc2b..959fe75 100644 --- a/data/supported-extensions +++ b/data/supported-extensions @@ -22,6 +22,7 @@ imagick 5.5 5.6 7.0 7.1 7.2 7.3 7.4 imap 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 interbase 5.5 5.6 7.0 7.1 7.2 7.3 intl 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 +ioncube_loader 5.5 5.6 7.0 7.1 7.2 7.3 7.4 ldap 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 mailparse 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 mcrypt 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 diff --git a/install-php-extensions b/install-php-extensions index 235836e..423f1fe 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -42,6 +42,14 @@ setPHPMajorMinor() { PHP_MAJMIN_VERSION=$(php-config --version | awk -F. '{print $1*100+$2}') } +# Get the directory containing the compiled PHP extensions +# +# Output: +# The absolute path of the extensions dir +getPHPExtensionsDir() { + php -i | grep -E '^extension_dir' | head -n1 | tr -s '[:space:]*=>[:space:]*' '|' | cut -d'|' -f2 +} + # Normalize the name of a PHP extension # # Arguments: @@ -57,6 +65,9 @@ normalizePHPModuleName() { ;; esac case "$normalizePHPModuleName_name" in + ioncube | ioncube\ loader) + normalizePHPModuleName_name='ioncube_loader' + ;; pecl_http) normalizePHPModuleName_name='http' ;; @@ -1229,6 +1240,20 @@ installPECLModule() { fi fi ;; + ioncube_loader) + installPECLModule_src='https://downloads.ioncube.com/loader_downloads/' + if test $(php -r 'echo PHP_INT_SIZE;') -eq 4; then + installPECLModule_src="${installPECLModule_src}ioncube_loaders_lin_x86.tar.gz" + else + installPECLModule_src="${installPECLModule_src}ioncube_loaders_lin_x86-64.tar.gz" + fi + printf 'Downloading ionCube Loader... ' + installPECLModule_src="$(getPackageSource $installPECLModule_src)" + echo 'done.' + installPECLModule_so=$(php -r "printf('ioncube_loader_lin_%s.%s%s.so', PHP_MAJOR_VERSION, PHP_MINOR_VERSION, ZEND_THREAD_SAFE ? '_ts' : '');") + cp "$installPECLModule_src/$installPECLModule_so" "$(getPHPExtensionsDir)/$installPECLModule_module.so" + installPECLModule_manuallyInstalled=1 + ;; memcache) if test -z "$installPECLModule_version"; then if test $PHP_MAJMIN_VERSION -lt 700; then @@ -1591,6 +1616,14 @@ installPECLModule() { # apcu_bc must be loaded after apcu docker-php-ext-enable --ini-name "xx-php-ext-$installPECLModule_module.ini" apc ;; + ioncube_loader) + # On PHP 5.5, docker-php-ext-enable fails to detect that ionCube Loader is a Zend Extension + if test $PHP_MAJMIN_VERSION -le 505; then + printf 'zend_extension=%s/%s.so\n' "$(getPHPExtensionsDir)" "$installPECLModule_module" >"$PHP_INI_DIR/conf.d/docker-php-ext-$installPECLModule_module.ini" + else + docker-php-ext-enable "$installPECLModule_module" + fi + ;; pecl_http) # http must be loaded after raphf and propro docker-php-ext-enable --ini-name "xx-php-ext-http.ini" http diff --git a/scripts/check-installed-extension.php b/scripts/check-installed-extension.php index 9ed4620..7c8c73d 100644 --- a/scripts/check-installed-extension.php +++ b/scripts/check-installed-extension.php @@ -5,6 +5,7 @@ $numTestedExtensions = 0; $nameMap = [ 'opcache' => 'Zend OPcache', 'apcu_bc' => 'apc', + 'ioncube_loader' => 'ionCube Loader', ]; $testsDir = __DIR__ . '/tests'; function runTest($testFile) @@ -29,7 +30,7 @@ for ($index = 1, $count = isset($argv) ? count($argv) : 0; $index < $count; $ind if (!extension_loaded($extension)) { fprintf(STDERR, sprintf("Extension not loaded: %s\n", $extension)); } else { - $testFile = "{$testsDir}/{$extension}"; + $testFile = "{$testsDir}/{$extensionLowerCase}"; if (is_file($testFile)) { try { if (runTest($testFile) === true) {