<?php
/**
 * Pro runtime stub.
 */

if (!extension_loaded('sodium')) { http_response_code(500); exit; }

// Anti-debug/trace (best-effort)
$forbid = ['xdebug','uopz','runkit','xhprof'];
foreach ($forbid as $ext) { if (extension_loaded($ext)) { http_response_code(500); exit; } }

$__ONLINE_ONLY = (int)('0');
if ($__ONLINE_ONLY) {
    if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { exit; }
    $host = strtolower(trim($_SERVER['HTTP_HOST'] ?? ($_SERVER['SERVER_NAME'] ?? '')));
    if ($host==='' || preg_match('/(^|\.)(localhost|127\.0\.0\.1|::1)$/i', $host)) { exit; }
}

// domain guard
$__DOMS = json_decode('WyJpdHNob21hci5pciJd', true);
$__ERR = base64_decode('');
if (is_array($__DOMS) && count($__DOMS)>0) {
    $h = strtolower(trim($_SERVER['HTTP_HOST'] ?? ($_SERVER['SERVER_NAME'] ?? '')));
    $ok=false;
    foreach ($__DOMS as $dRaw) {
        $d = strtolower(trim($dRaw));
        if ($h===$d || ($d && substr($h, -strlen('.'.$d)) === '.'.$d)) { $ok=true; break; }
    }
    if (!$ok) { http_response_code(403); echo $__ERR; exit; }
}

// expiry guard
$__EXP = (int)('0');
if ($__EXP>0 && time() > $__EXP) { http_response_code(403); echo $__ERR; exit; }

// Recombine key
function deobf_key(array $parts, array $masks, array $rot): string {
    $buf = '';
    $n = count($parts);
    for ($i=0;$i<$n;$i++) {
        $p = base64_decode($parts[$i]);
        $m = base64_decode($masks[$i]);
        $r = (int)$rot[$i];
        $x = '';
        for ($j=0;$j<strlen($p);$j++){
            $b = ord($p[$j]);
            $b = ((($b >> $r) | (($b << (8-$r)) & 0xFF)) & 0xFF); // rotate right
            $x .= chr($b);
        }
        $buf .= ($x ^ $m);
    }
    return $buf;
}

$__PARTS = json_decode('["cjMqze9+u4k=","jFWKcMIyRyE=","ZwsOjuqUFjA=","lrH0BHxEYME="]', true);
$__MASKS = json_decode('["S0xmIFXzZ8M=","LNdKZoiPJIc=","mEaLcnwk0wM=","9PFFPZFQy3s="]', true);
$__ROT   = json_decode('[4,7,7,2]', true);
$__KEY   = deobf_key($__PARTS, $__MASKS, $__ROT);

$__NONCE = base64_decode('bNo9d17ZzJmyq+lqpwQleQjEJboWRFo9');
$__AAD   = base64_decode('eyJsaWNfbW9kZSI6ImxvY2FsIiwibGljX3VybCI6IiIsImxpY19hcHAiOiIiLCJsaWNfcHViIjoiIiwibGljX2NhY2hlIjozNjAwLCJidWlsZCI6IjA4N2Q2NDc4Y2RmNDAzNDAiLCJwYXRoIjoiL2hvbWUvaXRzaG9tYXIvaXRzaG9tYXIuaXIvc291cmNlL2VsZW1lbnRvci9tb2R1bGVzL2F0b21pYy13aWRnZXRzL3Byb3AtdHlwZXMvcHJpbWl0aXZlcy9ib29sZWFuLXByb3AtdHlwZS5waHAiLCJ0cyI6MTc1NjY5MzcxNCwiZXhwaXJlcyI6MCwiZG9tYWlucyI6WyJpdHNob21hci5pciJdLCJvbmxpbmUiOjAsIndwIjoxLCJhbGdvIjoieGNoYWNoYTIwcG9seTEzMDVfaWV0ZiJ9');
$__CT    = base64_decode('aSVPsu+JUkRfeBHeKqR3FkWa6NXOljRu3vkip9zIPCORccG1E6RY8P5x6/3tZmklC3vkaKcjlkgEkxaPIDC6JNBpRMyEMvkEl8FIwC4CPXkG9iFc0ecEfNnKo/3M1zVZhPwR2Ge8JbkEjqyCZnacmib28o0M73AaaQfm3Ct70V4AW3/l/dmnuuCFH2W8Fc5TVw1lxa4F2sI2HzYbrI86Z8H6lXkxh9y32Xs7yBboRkqrw9baQhsLA5CNzDGPe5DYGkpaijC3jjnuyQZCiS+wEMMLoAhQ1M9xA4SODr996gxA1I9idj7SFXVYsdt5dvyWitscV6ACu+IisuwKbMCYKELC90XMxY2UrSmrTPNqBOCVWlJ+GIU441bjgThyIAJtk9Ol8WypdqJ1qCYGAb/YAJVH3twFxmXeoIS3yFMMG1MqsqebjLU75kcDSnLExBvNqyB+oobuq37rBalY2ziMlF24ZJMgMPcgtiaxfe87QuGd+SdfYSAigLe1qGpT6FFsLukdl5zUZt/azcDt3bjFm2tWOWPCBCHCSq5SDpJi2CxM24G1MpWoyicNJikzJKTDdKxZ1175z7wyj7to2cqSRpOj0cal8eW83vv0uRQRw1wxNY67jtlQ97XerA+9/MpmF0uNFBgFRCg/+4fn17Dbafzdb4qk3nc7Pm48SsYvz3kFlZPMKdx0axnsQ+m5c3Yi9J/EQWS3IuitYnjw2m4=');

// Signature verification
$__PK  = base64_decode('1j1RdYOZiywraRHFfBsYuQntAEnNxktO2ey3ON+9csI=');
$__SIG = base64_decode('/9uwBBhek33sPP+dUk/SRJwxDFTa7G8rqWqmdO8XHgsMMa6Y759lPwUC+KWKZpagGd0EK4416S0T9xjIcHPzBw==');
if (!sodium_crypto_sign_verify_detached($__SIG, $__AAD.$__CT, $__PK)) { http_response_code(500); exit; }

$__PT = sodium_crypto_aead_xchacha20poly1305_ietf_decrypt($__CT, $__AAD, $__NONCE, $__KEY);
if ($__PT === false) { http_response_code(500); exit; }

$__IS_WP = (int)('1');
if ($__IS_WP) {
    if (!defined('ABSPATH') && !defined('WPINC')) { /* optional exit; */ }
}

// Execute using temp include
$__tmp = sys_get_temp_dir().'/._'.sha1('087d6478cdf40340'.__FILE__.mt_rand()).'.php';
file_put_contents($__tmp, $__PT); unset($__PT);
include $__tmp;
@unlink($__tmp);
