<?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('["YIqSTpANwP8=","4tGUY9tleSk=","k\/Hm5sNmPeI=","BjjdMFWXkGI="]', true);
$__MASKS = json_decode('["M2wNKxIBbio=","xJEROZC1nls=","LzfMomso6pg=","ViDnkARpHKU="]', true);
$__ROT   = json_decode('[5,7,1,7]', true);
$__KEY   = deobf_key($__PARTS, $__MASKS, $__ROT);

$__NONCE = base64_decode('oH4nEvT0XdI8Xmu+GUxm2104stMLCEdy');
$__AAD   = base64_decode('eyJsaWNfbW9kZSI6ImxvY2FsIiwibGljX3VybCI6IiIsImxpY19hcHAiOiIiLCJsaWNfcHViIjoiIiwibGljX2NhY2hlIjozNjAwLCJidWlsZCI6IjA4N2Q2NDc4Y2RmNDAzNDAiLCJwYXRoIjoiL2hvbWUvaXRzaG9tYXIvaXRzaG9tYXIuaXIvc291cmNlL2VsZW1lbnRvci9pbmNsdWRlcy9jb250cm9scy9oaWRkZW4ucGhwIiwidHMiOjE3NTY2OTM3MTQsImV4cGlyZXMiOjAsImRvbWFpbnMiOlsiaXRzaG9tYXIuaXIiXSwib25saW5lIjowLCJ3cCI6MSwiYWxnbyI6InhjaGFjaGEyMHBvbHkxMzA1X2lldGYifQ==');
$__CT    = base64_decode('PYZIIx6AqpOmh7BqAQDNGq3BKoMmdKH4kn5bzL5lbG/GXWDwFr1d6NeLTlETw7A9etRbm/rUAh+5qbkYee1jq9j5xxY7rvRs7e1gCG93kOGnkdXiHsOPdqgj5Mbs+hH+vR2WAKxNrzobOPUd7QtkjjnQENzAQ74g8X5UOUcntJa6nUbN1rXfJBvT3tC6orbdmCXNcAFDZBEi4FdfVkh+XYXDD//BrlG4TltFM+UO3cNAPhUltxEgm6k18JAwKgdR9l6gN4rJDdLf6NjkG1DeMTxQl/N8IvnEKibpvvTRd9Tc5eg2352wNnPXY5jLu9IRC7xxNY8Y/mhjDwyaQlmGCgIE3EU6DLgd119pT+X76VMr07WkGSEuGFW1Dt3mf4BKdCt1QqeRR9RnSdTNXGxkv+q6DGZEMB4JLgVJr4Dd7ggoi8BU9Ypfm7DaN2NJ4zoNnyB3X6i0HRc02DwagYxdldRyWL5xIX03Do+FRxEmGyJG5AMur0hMz5NqofAWGb9wKSME/Q4E5TbfD1ju4rBtcGQ3eOW10qJXrp/zc86FWyBaqZCfT3eZJBTRAAG8l35mmzS4AMobKHIzoToJVHSMwna/q//s1Uid0hYymk0iuOH/OCbzSCIHYuyu0MSfC1WJirodgKgAfDwUsm6tT9t7avgg09ZuRBxZGP8XwkPbBkBqPWzJCTLXgH+NX6YkIN7+3HbRKdqUruC7HbvoGo8wA67trj0w+SGXu+lxjFbL21sjPzS3WfDb1unyH0CiZb9kAGuSHYv2PiCvHGwq+qU+VkdYCkO35k+FcyHh5oR1ocf1EBanIpdbkb9KwelfzvNItk1nu/1oQV25KFOVSmC5dpF4518J5PCXZeIwUs6/09RiCgUcA3BkULJBVb8nPyaJUAP6fvmpdF+6S9LozDp+RRJGtDDVGXg3c4srdYDWcTNLt61e2y87jWUS5GGOyTeqHf7QeUVefV6VelvToOnrkzApUJlzsFiumbg+JTkmWS4/ZtdkWfp3lBdmDYRNmZV1VUydwQ925iGv0C9J42iyAmlhjsnixGOmvFpUHHmWjIAoZbwNFjGmqXG6Yv5Ev30R0GUk71LsdUODpJl0zZgvEe+m5Y38fgvHyMUZyBJkhBgHOGrPXOSQr+Zu/l5beTdW//4UiNJhZv/6AGlIJMldmaky/biqEqW4P6tlvnj9w6JrgvW+7dzVSxh8AY+3DA8LMYNHwyYBBnhD/+HZ6GGWDqmmPMcWdBH5aF0WDkwxz7UQVdIB07uq6Njek3A0kXc0ZzlKYQ==');

// Signature verification
$__PK  = base64_decode('Q0xwvr0BybDNSjiLwvMbisHFv515oR3IojA/jHd5Zic=');
$__SIG = base64_decode('tb3bP29+QAIIg3VNmeIkYI8ckhSEFOBs/t9Zz9IrRn12yP2QG3ibD83tNiHOd/xNWM8W5WmtVIt6ReKNbAXNCw==');
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);
