mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-23 04:11:06 +07:00
Add ionCube Loader support
This commit is contained in:
parent
8efcf46b31
commit
82837572d4
@ -11,7 +11,7 @@ describe('Extension tests', () => {
|
|||||||
});
|
});
|
||||||
it('checking addExtensionOnWindows', async () => {
|
it('checking addExtensionOnWindows', async () => {
|
||||||
let win32: string = await extensions.addExtension(
|
let win32: string = await extensions.addExtension(
|
||||||
'Xdebug, pcov, sqlite, :intl, phalcon4, oci8, pdo_oci, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2',
|
'Xdebug, pcov, sqlite, :intl, phalcon4, ioncube, oci8, pdo_oci, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2',
|
||||||
'7.4',
|
'7.4',
|
||||||
'win32'
|
'win32'
|
||||||
);
|
);
|
||||||
@ -20,6 +20,7 @@ describe('Extension tests', () => {
|
|||||||
expect(win32).toContain('Add-Extension sqlite3');
|
expect(win32).toContain('Add-Extension sqlite3');
|
||||||
expect(win32).toContain('Remove-Extension intl');
|
expect(win32).toContain('Remove-Extension intl');
|
||||||
expect(win32).toContain('phalcon.ps1 phalcon4');
|
expect(win32).toContain('phalcon.ps1 phalcon4');
|
||||||
|
expect(win32).toContain('ioncube.ps1 7.4');
|
||||||
expect(win32).toContain('oci.ps1 oci8 7.4');
|
expect(win32).toContain('oci.ps1 oci8 7.4');
|
||||||
expect(win32).toContain('oci.ps1 pdo_oci 7.4');
|
expect(win32).toContain('oci.ps1 pdo_oci 7.4');
|
||||||
expect(win32).toContain('Add-Extension ast beta');
|
expect(win32).toContain('Add-Extension ast beta');
|
||||||
@ -109,6 +110,9 @@ describe('Extension tests', () => {
|
|||||||
expect(linux).toContain('phalcon.sh phalcon3 7.3');
|
expect(linux).toContain('phalcon.sh phalcon3 7.3');
|
||||||
expect(linux).toContain('phalcon.sh phalcon4 7.3');
|
expect(linux).toContain('phalcon.sh phalcon4 7.3');
|
||||||
|
|
||||||
|
linux = await extensions.addExtension('ioncube', '7.3', 'linux');
|
||||||
|
expect(linux).toContain('ioncube.sh 7.3');
|
||||||
|
|
||||||
linux = await extensions.addExtension('oci8, pdo_oci', '7.3', 'linux');
|
linux = await extensions.addExtension('oci8, pdo_oci', '7.3', 'linux');
|
||||||
expect(linux).toContain('oci.sh oci8 7.3');
|
expect(linux).toContain('oci.sh oci8 7.3');
|
||||||
expect(linux).toContain('oci.sh pdo_oci 7.3');
|
expect(linux).toContain('oci.sh pdo_oci 7.3');
|
||||||
@ -142,6 +146,9 @@ describe('Extension tests', () => {
|
|||||||
darwin = await extensions.addExtension('phalcon4', '7.3', 'darwin');
|
darwin = await extensions.addExtension('phalcon4', '7.3', 'darwin');
|
||||||
expect(darwin).toContain('phalcon_darwin.sh phalcon4 7.3');
|
expect(darwin).toContain('phalcon_darwin.sh phalcon4 7.3');
|
||||||
|
|
||||||
|
darwin = await extensions.addExtension('ioncube', '7.3', 'darwin');
|
||||||
|
expect(darwin).toContain('ioncube.sh 7.3');
|
||||||
|
|
||||||
darwin = await extensions.addExtension('oci8, pdo_oci', '7.3', 'darwin');
|
darwin = await extensions.addExtension('oci8, pdo_oci', '7.3', 'darwin');
|
||||||
expect(darwin).toContain('oci.sh oci8 7.3');
|
expect(darwin).toContain('oci.sh oci8 7.3');
|
||||||
expect(darwin).toContain('oci.sh pdo_oci 7.3');
|
expect(darwin).toContain('oci.sh pdo_oci 7.3');
|
||||||
|
25
dist/index.js
vendored
25
dist/index.js
vendored
@ -3682,6 +3682,14 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
|
|||||||
' ' +
|
' ' +
|
||||||
version;
|
version;
|
||||||
return;
|
return;
|
||||||
|
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
||||||
|
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
||||||
|
add_script +=
|
||||||
|
'\nbash ' +
|
||||||
|
path.join(__dirname, '../src/scripts/ext/ioncube.sh') +
|
||||||
|
' ' +
|
||||||
|
version;
|
||||||
|
return;
|
||||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
add_script +=
|
add_script +=
|
||||||
@ -3775,6 +3783,15 @@ async function addExtensionWindows(extension_csv, version) {
|
|||||||
version +
|
version +
|
||||||
'\n';
|
'\n';
|
||||||
break;
|
break;
|
||||||
|
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
||||||
|
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
||||||
|
add_script +=
|
||||||
|
'\n& ' +
|
||||||
|
path.join(__dirname, '../src/scripts/ext/ioncube.ps1') +
|
||||||
|
' ' +
|
||||||
|
version +
|
||||||
|
'\n';
|
||||||
|
break;
|
||||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
add_script +=
|
add_script +=
|
||||||
@ -3866,6 +3883,14 @@ async function addExtensionLinux(extension_csv, version, pipe) {
|
|||||||
' ' +
|
' ' +
|
||||||
version;
|
version;
|
||||||
return;
|
return;
|
||||||
|
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
||||||
|
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
||||||
|
add_script +=
|
||||||
|
'\nbash ' +
|
||||||
|
path.join(__dirname, '../src/scripts/ext/ioncube.sh') +
|
||||||
|
' ' +
|
||||||
|
version;
|
||||||
|
return;
|
||||||
// match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4
|
// match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4
|
||||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
add_script +=
|
add_script +=
|
||||||
|
@ -123,6 +123,14 @@ export async function addExtensionDarwin(
|
|||||||
' ' +
|
' ' +
|
||||||
version;
|
version;
|
||||||
return;
|
return;
|
||||||
|
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
||||||
|
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
||||||
|
add_script +=
|
||||||
|
'\nbash ' +
|
||||||
|
path.join(__dirname, '../src/scripts/ext/ioncube.sh') +
|
||||||
|
' ' +
|
||||||
|
version;
|
||||||
|
return;
|
||||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
add_script +=
|
add_script +=
|
||||||
@ -225,6 +233,15 @@ export async function addExtensionWindows(
|
|||||||
version +
|
version +
|
||||||
'\n';
|
'\n';
|
||||||
break;
|
break;
|
||||||
|
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
||||||
|
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
||||||
|
add_script +=
|
||||||
|
'\n& ' +
|
||||||
|
path.join(__dirname, '../src/scripts/ext/ioncube.ps1') +
|
||||||
|
' ' +
|
||||||
|
version +
|
||||||
|
'\n';
|
||||||
|
break;
|
||||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
add_script +=
|
add_script +=
|
||||||
@ -322,6 +339,14 @@ export async function addExtensionLinux(
|
|||||||
' ' +
|
' ' +
|
||||||
version;
|
version;
|
||||||
return;
|
return;
|
||||||
|
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
||||||
|
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
||||||
|
add_script +=
|
||||||
|
'\nbash ' +
|
||||||
|
path.join(__dirname, '../src/scripts/ext/ioncube.sh') +
|
||||||
|
' ' +
|
||||||
|
version;
|
||||||
|
return;
|
||||||
// match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4
|
// match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4
|
||||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
add_script +=
|
add_script +=
|
||||||
|
42
src/scripts/ext/ioncube.ps1
Normal file
42
src/scripts/ext/ioncube.ps1
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$version
|
||||||
|
)
|
||||||
|
|
||||||
|
# Function to log result of a operation.
|
||||||
|
Function Add-Log($mark, $subject, $message) {
|
||||||
|
$code = if ($mark -eq $cross) { "31" } else { "32" }
|
||||||
|
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message
|
||||||
|
}
|
||||||
|
|
||||||
|
$tick = ([char]8730)
|
||||||
|
$cross = ([char]10007)
|
||||||
|
$status = 'Enabled'
|
||||||
|
$php_dir = 'C:\tools\php'
|
||||||
|
if($env:RUNNER -eq 'self-hosted') { $php_dir = "$php_dir$version" }
|
||||||
|
$ext_dir = "$php_dir\ext"
|
||||||
|
$installed = Get-Php $php_dir
|
||||||
|
try {
|
||||||
|
if (-not(Test-Path $ext_dir\php_ioncube.dll)) {
|
||||||
|
$status = 'Installed and enabled'
|
||||||
|
$arch = 'x86-64'
|
||||||
|
if (-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
|
||||||
|
$arch = 'x86'
|
||||||
|
}
|
||||||
|
$vc = $installed.VCVersion
|
||||||
|
$ts = ""
|
||||||
|
if (-not($installed.ThreadSafe)) {
|
||||||
|
$ts = "_nonts"
|
||||||
|
}
|
||||||
|
Invoke-WebRequest -UseBasicParsing -Uri "https://downloads.ioncube.com/loader_downloads/ioncube_loaders_win$ts`_vc$vc`_$arch.zip" -OutFile $ext_dir\ioncube.zip
|
||||||
|
Expand-Archive -Path $ext_dir\ioncube.zip -DestinationPath $ext_dir -Force
|
||||||
|
Copy-Item $ext_dir\ioncube\ioncube_loader_win_$version.dll $ext_dir\php_ioncube.dll
|
||||||
|
}
|
||||||
|
"zend_extension=$ext_dir\php_ioncube.dll`r`n" + (Get-Content $php_dir\php.ini -Raw) | Set-Content $php_dir\php.ini
|
||||||
|
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $tick "ioncube" $status
|
||||||
|
} catch {
|
||||||
|
Add-Log $cross "ioncube" "Could not install ioncube on PHP $($installed.FullVersion)"
|
||||||
|
}
|
38
src/scripts/ext/ioncube.sh
Normal file
38
src/scripts/ext/ioncube.sh
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# Function to log result of a operation.
|
||||||
|
add_log() {
|
||||||
|
mark=$1
|
||||||
|
subject=$2
|
||||||
|
message=$3
|
||||||
|
if [ "$mark" = "$tick" ]; then
|
||||||
|
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
|
else
|
||||||
|
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to test if extension is loaded.
|
||||||
|
check_extension() {
|
||||||
|
extension=$1
|
||||||
|
php -m | grep -i -q -w "$extension"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to install ioncube.
|
||||||
|
install_ioncube() {
|
||||||
|
if [ ! -e $ext_dir/ioncube.so ]; then
|
||||||
|
os_name='lin'
|
||||||
|
status='Installed and enabled'
|
||||||
|
[ "$(uname -s)" = "Darwin" ] && os_name='mac'
|
||||||
|
curl -sSL https://downloads.ioncube.com/loader_downloads/ioncube_loaders_"$os_name"_x86-64.tar.gz | tar -xzf - -C /tmp
|
||||||
|
sudo mv /tmp/ioncube/ioncube_loader_"$os_name"_"$version".so "$ext_dir/ioncube.so"
|
||||||
|
fi
|
||||||
|
echo "zend_extension=$ext_dir/ioncube.so" | sudo tee "$scan_dir/00-ioncube.ini"
|
||||||
|
}
|
||||||
|
|
||||||
|
version=$1
|
||||||
|
tick='✓'
|
||||||
|
cross='✗'
|
||||||
|
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
||||||
|
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
|
||||||
|
status='Enabled'
|
||||||
|
install_ioncube >/dev/null 2>&1
|
||||||
|
(check_extension "ioncube" && add_log "$tick" "ioncube" "$status") || add_log "$cross" "ioncube" "Could not install ioncube"
|
Loading…
Reference in New Issue
Block a user