123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407 |
- #!/bin/sh
- encoder=""
- fullEncoder="Current (v9.0)"
- language=""
- selectedArch=""
- sysArch=""
- encoderOptions=""
- encoderPath=""
- warning=""
- isFreeBSD="" # Whether the script is running on FreeBSD which does not have any 64-bit encoders.
- currentV="9.0"
- legacyV="8.3"
- obsoleteV="7.0"
- # Encoder-Arch-Language
- encodersForV9="C-64-5.3 C-64-5.4 C-64-5.5 C-64-5.6
- C-32-4 C-32-5 C-32-5.3 C-32-5.4 C-32-5.5 C-32-5.6
- L-32-4 L-32-5 L-32-5.3 L-32-5.4 L-32-5.5
- L-64-5.3 L-64-5.4 L-64-5.5
- O-32-4 O-32-5 O-32-53"
- fail() {
- echo $*
- exit 1
- }
- checkSelectionCompatibility() {
-
- var="$encoder-$selectedArch-$language"
- #echo "$var"
-
- #check if 64-bit Legacy or obsolete is selected.
- if [ "$encoder-$selectedArch" = "O-64" ] ; then
- echo O64
- return
- fi
- # check if selected encoder, arch and language combination is valid.
- for validEncoder in $encodersForV9; do
- [ "$validEncoder" = "$var" ] && echo valid & return
- done
- #else it is invalid.
- echo invalid
- }
- checkSystemCompatibility() {
-
- # check for 64-bit Encoder running on FreeBSD which does not have any 64-bit encoders.
- [ "$selectedArch" = "64" ] && [ "$isFreeBSD" = 1 ] && fail "64-bit ionCube Encoders do not exist for FreeBSD. Please use the 32-bit Encoders."
- # check for 64-bit Encoder running on a 32-bit system.
- [ "$selectedArch" = "64" ] && [ "$sysArch" = "32" ] && fail "You cannot run the 64-bit ionCube Encoder on a 32-bit system."
- # check for 32-bit Encoder running on a 64-bit system.
- [ "$selectedArch" = "32" ] && [ "$sysArch" = "64" ] && warning="Warning: you are running the 32-bit ionCube Encoder on a 64-bit system."
- }
- setEncoder() {
- if [ "$encoder" = "" ] ; then
- encoder="$1"
- [ "$1" = "C" ] && fullEncoder="Current (v9.0)"
- [ "$1" = "L" ] && fullEncoder="Legacy (v8.3)"
- [ "$1" = "O" ] && fullEncoder="Obsolete (v7.0)"
- else
- fail "You cannot set more than one Encoder version."
- fi
- }
- setLanguage() {
- if [ "$language" = "" ] ; then
- language="$1"
- else
- fail "You cannot set more than one Encoding language."
- fi
- }
- setArch() {
- if [ "$selectedArch" = "" ] ; then
- selectedArch="$1"
- else
- fail "You cannot set more than one architecture type"
- fi
- }
- setSysArch() {
- localArch=`uname -m`
- isFreeBSD=`uname -s | grep -ic "FreeBSD"`
- sysArch="32"
- if [ "$isFreeBSD" = "1" ]
- then
- # AJT FreeBSD only has 32-bit Encoders presently.
- sysArch="32"
- else
- #echo "$localArch"
- case "$localArch" in
- "i686" | "i386")
- sysArch="32"
- ;;
- "x86_64" | "amd64")
- sysArch="64"
- ;;
- esac
- fi
- }
- checkLanguage() {
- if [ "$language" = "" ] ; then
- echo notSet
- else
- echo set
- fi
- }
- printHelp32() {
- echo "
- The following is a summary of command options for this script and its basic usage.
- Usage: ioncube_encoder.sh [-C | -L | -O] [-4 | -5 | -53 | -54 | -55 | -56 ] [-x86] <encoder options>
- Encoder Version (optional):
- -O : Use Obsolete Encoder (v7.0)
- -L : Use Legacy Encoder (v8.3)
- -C : Use Current Encoder (v9.0) - Default
- PHP Languages:
- -4 : Encode file in PHP 4
- -5 : Encode file in PHP 5
- -53 : Encode file in PHP 53
- -54 : Encode file in PHP 54
- -55 : Encode file in PHP 55
- -56 : Encode file in PHP 56
- Architecture (optional):
- -x86 : Run the 32-bit Encoder
- -h : Display this help and exit.
- If -h is specified before a language has been selected, help will be displayed by the script.
- if -h is specified after a language has been selected, help will be displayed by the Encoder.
- If an Encoder version is not selected, the Current Encoder (9.0) will be selected.
- If a PHP language is not selected, the script will exit.
- If an architecture is not selected, the script will run the Encoder that matches your system architecture.
- Once an unknown option is selected, the script will pass the remaining options to the Encoder.
- You cannot select more than one Encoder version, PHP language or Architecture.
- Usage examples:
- Current Encoder, encoded in PHP 5.6
- ./ioncube_encoder.sh -C -56 source_file.php -o target_file.php
- Current Encoder, encoded in PHP 5.4. Encoder displays help.
- ./ioncube_encoder.sh -C -54 -h
- Legacy Encoder, encoded in PHP 5.3
- ./ioncube_encoder.sh -L -53
- "
- exit
- }
- printHelp64() {
- echo "
- The following is a summary of command options for this script and its basic usage.
- Usage: ioncube_encoder.sh [-C | -L | -O] [-4 | -5 | -53 | -54 | -55 | -56 ] [-x86 | -x86-64] <encoder options>
- Encoder Version (optional):
- -O : Use Obsolete Encoder (v7.0)
- -L : Use Legacy Encoder (v8.3)
- -C : Use Current Encoder (v9.0) - Default
- PHP Languages:
- -4 : Encode file in PHP 4
- -5 : Encode file in PHP 5
- -53 : Encode file in PHP 53
- -54 : Encode file in PHP 54
- -55 : Encode file in PHP 55
- -56 : Encode file in PHP 56
- Architecture (optional):
- -x86 : Run the 32-bit Encoder
- -x86-64 : Run the 64-bit Encoder
- -h : Display this help and exit.
- If -h is specified before a language has been selected, help will be displayed by the script.
- if -h is specified after a language has been selected, help will be displayed by the Encoder.
- If an Encoder version is not selected, the Current Encoder (9.0) will be selected.
- If a PHP language is not selected, the script will exit.
- If an architecture is not selected, the script will run the Encoder that matches your system architecture.
- Once an unknown option is selected, the script will pass the remaining options to the Encoder.
- You cannot select more than one Encoder version, PHP language or Architecture.
- Script will exit should you try to run the 64-bit Encoder on a 32-bit system.
- Usage examples:
- Current 64-bit Encoder, encoded in PHP 5.6
- ./ioncube_encoder.sh -C -x86-64 -56 source_file.php -o target_file.php
- Current 64-bit Encoder, encoded in PHP 5.4. Encoder displays help.
- ./ioncube_encoder.sh -C -x86-64 -54 -h
- Legacy 32-bit Encoder, encoded in PHP 5.3
- ./ioncube_encoder.sh -L -x86 -53
- "
- exit
- }
- printHelp() {
- if [ "$sysArch" = "64" ]
- then
- printHelp64
- else
- printHelp32
- fi
- }
- setEncoderFilePath() {
- # AJT 20150423 Change so that all executables go in a bin directory but are suffixed with version number and, if 64 bit, "_64".
- encoderPath=`cd \`dirname $0\` ; pwd`/bin/
- case "$language" in
- 4)
- encoderPath="$encoderPath""ioncube_encoder4"
- ;;
- 5)
- encoderPath="$encoderPath""ioncube_encoder5"
- ;;
- 5.3)
- encoderPath="$encoderPath""ioncube_encoder53"
- ;;
- 5.4)
- encoderPath="$encoderPath""ioncube_encoder54"
- ;;
- 5.5)
- encoderPath="$encoderPath""ioncube_encoder55"
- ;;
- 5.6)
- encoderPath="$encoderPath""ioncube_encoder56"
- ;;
- esac
- case "$encoder" in
- C)
- encoderPath="$encoderPath""_""$currentV"
- ;;
- L)
- encoderPath="$encoderPath""_""$legacyV"
- ;;
- O)
- encoderPath="$encoderPath""_""$obsoleteV"
- ;;
- esac
- # AJT 20150423 Now just suffix 64-bit with "_64".
- case "$selectedArch" in
- 32)
- encoderPath="$encoderPath"
- ;;
- 64)
- encoderPath="$encoderPath""_64"
- ;;
- esac
- }
- checkEncoderExists() {
-
- if [ -f $encoderPath ] ; then
- if [ -x $encoderPath ] ; then
- true
- else
- fail "The Encoder is not executable."
- fi
- else
- fail "The Encoder does not exist at the path: $encoderPath"
- fi
- }
- setSysArch
- if [ $# -eq 0 ] ; then
- printHelp
- fi
- #while [ "$1" ]
- for var in "$@"
- do
- case "$var" in
- -L)
- setEncoder "L"
- ;;
- -O)
- setEncoder "O"
- ;;
- -C)
- setEncoder "C"
- ;;
- -4)
- setLanguage "4"
- ;;
- -5)
- setLanguage "5"
- ;;
- -53)
- setLanguage "5.3"
- ;;
- -54)
- setLanguage "5.4"
- ;;
- -55)
- setLanguage "5.5"
- ;;
- -56)
- setLanguage "5.6"
- ;;
- -x86)
- setArch "32"
- ;;
- -x86-64)
- setArch "64"
- ;;
- -h)
- if [ "$language" ] ; then
- break
- else
- printHelp
- fi;
- ;;
-
- *)
- break;
- ;;
-
- esac
- shift
- done
- [ "$language" = "" ] && fail "You must set an Encoding language. Enter -h for help."
- [ "$encoder" = "" ] && encoder="C"
- [ "$selectedArch" = "" ] && selectedArch="$sysArch"
- #checkSelectionCompatibility
- selection="$(checkSelectionCompatibility)"
- if [ "$selection" = "valid" ] ; then
- true
- elif [ "$selection" = "invalid" ] ; then
- fail "The PHP language ($language) you have selected is not supported by the $fullEncoder $selectedArch-bit ionCube Encoder. Enter -h for help."
- elif [ "$selection" = "O64" ] ; then
- fail "There is no 64-bit version of the $fullEncoder ionCube Encoder. Enter -H for help."
- fi
- checkSystemCompatibility
- #echo "$encoder $language $selectedArch"
- setEncoderFilePath
- #echo "encoder options: $@"
- #echo "path: $encoderPath"
- checkEncoderExists
- [ "$warning" != "" ] && echo "$warning"
- exec $encoderPath "$@"
|