Skip to content

Instantly share code, notes, and snippets.

@rangerz
Last active November 17, 2022 07:51
Show Gist options
  • Save rangerz/271504c282ea254779ddb730605fd662 to your computer and use it in GitHub Desktop.
Save rangerz/271504c282ea254779ddb730605fd662 to your computer and use it in GitHub Desktop.
Install PHP ionCube Loader Script
#!/bin/bash
! hash php 2>/dev/null && echo "PHP Required" && exit
# Download Official Loader Wizard for
curl -O https://www.ioncube.com/loader-wizard/loader-wizard.tgz
tar zxvf loader-wizard.tgz
cat ./ioncube/loader-wizard.php | sed 's/run();/#run();/g' | sed "s/'mac'/'dar'/g" > ./loader-wizard.php
# PHP Setting
echo '<?php
require_once("loader-wizard.php");
$_SERVER["SERVER_SOFTWARE"] = "";
$_SERVER["HTTP_USER_AGENT"] = "";
if (is_ms_windows()) {
$basename = windows_package_name();
} else {
list($basename, $multiple_os_versions) = unix_package_name();
}
$download = IONCUBE_DOWNLOADS_SERVER . "/$basename.tar.gz";
$loader_name = get_loader_name();
$ext_so_dir = extension_dir_path();
$sys_info = ic_system_info();
$ext_ini_dir = $sys_info["PHP_INI_DIR"];
' > lib.php
IONCUBE_DL_URL=`php -r 'require_once("lib.php"); echo $download;' | sed 's/downloads3/downloads/'`
LOADER_NAME=`php -r 'require_once("lib.php"); echo $loader_name;'`
PHP_SO_DIR=`php -r 'require_once("lib.php"); echo $ext_so_dir;'`
PHP_INI_DIR=`php -r 'require_once("lib.php"); echo $ext_ini_dir;'`
PHP_INI_PATH=`php -r 'echo php_ini_loaded_file();'`
# Download ionCube loader
curl $IONCUBE_DL_URL -o ioncube_loaders.tar.gz
tar zxvf ioncube_loaders.tar.gz
# Install ionCube
[ -z "$PHP_SO_DIR" ] && echo "Failed to find extension folder" && exit
[[ ! -d $PHP_SO_DIR ]] && mkdir -p "$PHP_SO_DIR"
cp "ioncube/${LOADER_NAME}" "$PHP_SO_DIR/ioncube.so"
[ $? != 0 ] && echo "Failed to copy ioncube.so [$PHP_SO_DIR]" && exit
if hash docker-php-ext-enable 2>/dev/null; then
docker-php-ext-enable ioncube
elif [ -z "$PHP_INI_DIR" ]; then
[[ ! -f $PHP_INI_PATH ]] && echo "Failed to find php.ini" && exit
echo "zend_extension=\"${PHP_SO_DIR}/ioncube.so\"" | sudo tee -a $PHP_INI_PATH
else
[[ ! -d $PHP_INI_DIR ]] && mkdir -p "$PHP_INI_DIR"
echo 'zend_extension="ioncube.so"' > ${PHP_INI_DIR}/00-ioncube.ini
fi
# Clean up
rm -f loader-wizard.tgz loader-wizard.php ioncube_loaders.tar.gz lib.php
rm -rf ./ioncube
php -v
#!/bin/bash
curl https://www.ioncube.com/loader-wizard/loader-wizard.tgz -o loader-wizard.tgz
tar zxvf loader-wizard.tgz
php -S localhost:8000
# open http://localhost:8000/ioncube/loader-wizard.php
# Extension scan folder (*.ini)
# php -r "echo PHP_CONFIG_FILE_SCAN_DIR;"
# Extension folder (*.so)
# php-config --extension-dir
# php -i | grep "^extension_dir =>" | cut -d ' ' -f3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment