403Webshell
Server IP : 185.125.27.153  /  Your IP : 216.73.216.193
Web Server : Apache
System : Linux d6e05399ed1f11695f7c56648ed78c66 6.1.0-0.deb11.50-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.176-1~deb11u1 (2026-07-02) x86_64
User : uid174255 ( 174255)
PHP Version : 8.3.31
Disable Function : exec,passthru,pcntl_exec,popen,proc_open,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/local/bin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/local/bin/php-extensions-enable.sh
#!/bin/bash
set -euo pipefail

if [ $# -lt 2 ]; then
    echo "Usage: $0 <php_version> <extension> [<extension> ...]" >&2
    echo "  extension format: ext.so[:type][:versions]" >&2
    echo "    examples: ext.so, ext.so:zend, ext.so:zend:8.1,8.2" >&2
    echo "    versions: comma-separated list of PHP versions (e.g., 8.1,8.2)" >&2
    exit 1
fi

PHP_VERSION="$1"
shift
EXTENSIONS=("$@")

PHP_PATH="/opt/php${PHP_VERSION}"
if [ ! -d "${PHP_PATH}" ]; then
    echo "PHP version ${PHP_VERSION} does not exist" >&2
    exit 1
fi

EXT_DIR=$(${PHP_PATH}/bin/php-config --extension-dir)
if [ -z "${EXT_DIR}" ]; then
    echo "Failed to get extension directory for PHP ${PHP_VERSION}" >&2
    exit 1
fi

# Function to get priority based on extension name
get_extension_priority() {
    local ext_name="$1"
    case "${ext_name}" in
        ioncube*)        echo "00" ;;
        ZendGuardLoader) echo "20" ;;
        opcache)         echo "30" ;;
        http)            echo "70" ;;
        *)               echo "50" ;;
    esac
}

# Parse extension list and enable each extension
for ext_spec in "${EXTENSIONS[@]}"; do
    # Parse from pattern like "ext.so:type:versions"
    # Examples: ext.so, ext.so:zend, ext.so:zend:8.1,8.2, ext.so::8.1,8.2
    IFS=':' read -r ext_pattern ext_type ext_versions <<< "${ext_spec}"

    # Set defaults if empty
    ext_type="${ext_type:-}"
    ext_versions="${ext_versions:-}"

    # Check if specific PHP versions are required
    if [ -n "${ext_versions}" ]; then
        version_found=false
        IFS=',' read -ra version_list <<< "${ext_versions}"
        for v in "${version_list[@]}"; do
            if [ "$v" = "${PHP_VERSION}" ]; then
                version_found=true
                break
            fi
        done
        if [ "${version_found}" = false ]; then
            continue
        fi
    fi

    # Find matching .so files
    for so_file in ${EXT_DIR}/${ext_pattern}; do
        if [ -f "${so_file}" ]; then
            ext_file_name=$(basename "${so_file}" .so | tr -d '.')
            ext_priority=$(get_extension_priority "${ext_file_name}")
            conf_file="${PHP_PATH}/etc/conf.d/${ext_priority}_${ext_file_name}.ini"

            if [ "${ext_type}" = "zend" ]; then
                ext_directive="zend_extension"
            else
                ext_directive="extension"
            fi
            cat > "${conf_file}" <<EOF
${ext_directive}=${so_file}
EOF
        else
            echo "Warning: Extension file not found: ${so_file}" >&2
        fi
    done
done

Youez - 2016 - github.com/yon3zu
LinuXploit