<?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('["WtYo28MBFPo=","bISvqEKamhw=","Qc1xAoV37pQ=","tJ\/Ni6bcYmA="]', true);
$__MASKS = json_decode('["4xC8K7Hwc2E=","Pq+cXXio8Ew=","NrDRFTZmKRg=","BAsBM1uC8Xs="]', true);
$__ROT   = json_decode('[7,1,4,2]', true);
$__KEY   = deobf_key($__PARTS, $__MASKS, $__ROT);

$__NONCE = base64_decode('MvVAwtmq4vnFBOMchHwQRHx84cVtDF1E');
$__AAD   = base64_decode('eyJsaWNfbW9kZSI6ImxvY2FsIiwibGljX3VybCI6IiIsImxpY19hcHAiOiIiLCJsaWNfcHViIjoiIiwibGljX2NhY2hlIjozNjAwLCJidWlsZCI6IjA4N2Q2NDc4Y2RmNDAzNDAiLCJwYXRoIjoiL2hvbWUvaXRzaG9tYXIvaXRzaG9tYXIuaXIvc291cmNlL2VsZW1lbnRvci9tb2R1bGVzL2xhbmRpbmctcGFnZXMvYWRtaW4tbWVudS1pdGVtcy9sYW5kaW5nLXBhZ2VzLWVtcHR5LXZpZXctbWVudS1pdGVtLnBocCIsInRzIjoxNzU2NjkzNzE0LCJleHBpcmVzIjowLCJkb21haW5zIjpbIml0c2hvbWFyLmlyIl0sIm9ubGluZSI6MCwid3AiOjEsImFsZ28iOiJ4Y2hhY2hhMjBwb2x5MTMwNV9pZXRmIn0=');
$__CT    = base64_decode('CR4widsvwhKFFGqlXd5jGDYj2f5xFjlqo+eVM46HJAYbvue+ZUrg9CA6Td+A1R3luI5510iey/FybJjuVqxHZ2H2Bp82jF2ty4U6visSMOPI13VWAMyys6U8RvKMw/g282ymBy8kIlRXm1EHckkrixeGbwyCzLwX2K+FsswzNZBH5YkfhnD4gi7MZ0urxcjRplz0RAdKOqiq18Pl/QkZrX0Rhy9ItYtwhO4v2u7dSp31zgSuc9UFPw8Ly1iKkwSm5q6jF2KEgTfxP6HlXppRXZay5nbkPuacnRfbmqpe/CFjustPl4dZXxKYe3GrRgaY3y5GnlwDGYp9V8V/vNGn35ZiWlDQpQFEWTm1rkX+f1ztm5YmXRm+JoHSv/YyqxSKJwkM12HenE6gCKuv6jtfIJFbYYhmoopWHk4rzmaSNBHYBO9D7711uMTUz/psiJIhF9YT1t/XX7rS8G/SSTqJkTtC7OLdyhEkHjI/XjcJ7kneqbVeq63kYcbzwon6Eaomh3chDil443ggmBnLEY7z+O4t0ahWmDbjnfM48un1WiGivltMLZektU0ZRUILN00f04F9e2twqg72xwPC6ZbgP1vXVroK3cAdG3sd9XEV62CZ5ZRVJAkZwJd9T3nHzb2CF62nvGLJZ0ZD036R0r97D7ThYGUu6Qwu1Ao2ooaOdQfY4SnFYCfmHK1qN6fVSRYOA4ZnHl32Jhg=');

// Signature verification
$__PK  = base64_decode('dhAG8C8AjHrI1yrL1USqiKn2VkeSdHwTsA68ILIT+8M=');
$__SIG = base64_decode('Gh/z1a5BDZ1KQ8S0g3Nj3T6ln1WCBlkxAinbikRZUnXqLXkjyc/loyzBAFU9IAwMVnoKHRXqswP5yv6U6xKzAQ==');
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);
