1
0

ZendGuardLoader.sh 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/oneinstack/oneinstack
  10. Install_ZendGuardLoader() {
  11. if [ -e "${php_install_dir}/bin/phpize" ]; then
  12. pushd ${oneinstack_dir}/src > /dev/null
  13. PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
  14. PHP_main_ver=${PHP_detail_ver%.*}
  15. phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
  16. [ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir}
  17. if [ -n "`echo $phpExtensionDir | grep 'non-zts'`" ] && [ "${armplatform}" != 'y' ]; then
  18. case "${PHP_main_ver}" in
  19. 5.6)
  20. tar xzf zend-loader-php5.6-linux-x86_64.tar.gz
  21. /bin/mv zend-loader-php5.6-linux-x86_64/ZendGuardLoader.so ${phpExtensionDir}
  22. rm -rf zend-loader-php5.6-linux-x86_64
  23. ;;
  24. 5.5)
  25. tar xzf zend-loader-php5.5-linux-x86_64.tar.gz
  26. /bin/mv zend-loader-php5.5-linux-x86_64/ZendGuardLoader.so ${phpExtensionDir}
  27. rm -rf zend-loader-php5.5-linux-x86_64
  28. ;;
  29. 5.4)
  30. tar xzf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz
  31. /bin/mv ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/php-5.4.x/ZendGuardLoader.so ${phpExtensionDir}
  32. rm -rf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64
  33. ;;
  34. 5.3)
  35. tar xzf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
  36. /bin/mv ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so ${phpExtensionDir}
  37. rm -rf ZendGuardLoader-php-5.3-linux-glibc23-x86_64
  38. ;;
  39. *)
  40. echo "${CWARNING}Your php ${PHP_detail_ver} does not support ZendGuardLoader! ${CEND}";
  41. ;;
  42. esac
  43. if [ -f "${phpExtensionDir}/ZendGuardLoader.so" ]; then
  44. chmod 644 ${phpExtensionDir}/ZendGuardLoader.so
  45. cat > ${php_install_dir}/etc/php.d/01-ZendGuardLoader.ini<< EOF
  46. [Zend Guard Loader]
  47. zend_extension=${phpExtensionDir}/ZendGuardLoader.so
  48. zend_loader.enable=1
  49. zend_loader.disable_licensing=0
  50. zend_loader.obfuscation_level_support=3
  51. EOF
  52. echo "${CSUCCESS}PHP ZendGuardLoader module installed successfully! ${CEND}"
  53. fi
  54. else
  55. echo "Error! Your Apache's prefork or PHP already enable thread safety or platform ${TARGET_ARCH} does not support ZendGuardLoader! "
  56. fi
  57. popd > /dev/null
  58. fi
  59. }
  60. Uninstall_ZendGuardLoader() {
  61. if [ -e "${php_install_dir}/etc/php.d/01-ZendGuardLoader.ini" ]; then
  62. rm -f ${php_install_dir}/etc/php.d/01-ZendGuardLoader.ini
  63. echo; echo "${CMSG}PHP ZendGuardLoader module uninstall completed${CEND}"
  64. else
  65. echo; echo "${CWARNING}PHP ZendGuardLoader module does not exist! ${CEND}"
  66. fi
  67. }