<?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('["GD8mj4tGxIk=","0t6Sv9Ga\/Ug=","pDfM+qL1TKU=","amHjR1NpL9M="]', true);
$__MASKS = json_decode('["NdX3Wzpy7PM=","xdGBN\/3fguE=","jtQpDvHoGMo=","5bfAEd2L29I="]', true);
$__ROT   = json_decode('[5,2,4,4]', true);
$__KEY   = deobf_key($__PARTS, $__MASKS, $__ROT);

$__NONCE = base64_decode('IP0lWwWovF9NVmzlTWoczEzKcIGe1o0y');
$__AAD   = base64_decode('eyJsaWNfbW9kZSI6ImxvY2FsIiwibGljX3VybCI6IiIsImxpY19hcHAiOiIiLCJsaWNfcHViIjoiIiwibGljX2NhY2hlIjozNjAwLCJidWlsZCI6IjA4N2Q2NDc4Y2RmNDAzNDAiLCJwYXRoIjoiL2hvbWUvaXRzaG9tYXIvaXRzaG9tYXIuaXIvc291cmNlL2VsZW1lbnRvci9pbmNsdWRlcy90ZW1wbGF0ZS1saWJyYXJ5L2RhdGEvY29udHJvbGxlci5waHAiLCJ0cyI6MTc1NjY5MzcxNCwiZXhwaXJlcyI6MCwiZG9tYWlucyI6WyJpdHNob21hci5pciJdLCJvbmxpbmUiOjAsIndwIjoxLCJhbGdvIjoieGNoYWNoYTIwcG9seTEzMDVfaWV0ZiJ9');
$__CT    = base64_decode('+nhWG0d/YEEcAUAah74PbJhjkK9fQPvWpoXo1zVSAE2wPPDMujcRpIes/0b1NSjjKDotWpyU3DOfTrrOhTJcim4NBfSnRCo3dgcyXwakWHiBq7L/LAuk/WNd5Yr07KQUtF/aZWobukWRc5oMkqYn69KKOvoAncku45Dt65dqwRpIMatDrFCixqnmbBXHamEbvWeY5bUjBtk4GLnxHTgCnHL2KZ/xWBf5pqRmso6+QWIxuV7tvTDePLhaG1ZugnDyY3/HgbCjyUON7bMPXGxvufSleubyeyUwlLJ0MH2VqKc34Smx7COnp43qz20tlj3oK5e/SGimhsm0E5udPN1SUvsfhU0b4okIus4uJy7XFMtoU+QvEAtS+xP8aXuPJnU1cuQOhoKnKuKgOH+YUkBCCtsGbEHOZzLvXYcw/kK+ycHf5VJt8K15IBZIvPtOdg0Te8gOMJlG+6PLobDYyP7MGaNiu1cbC/huWtc5KaAaPBZmc0sZOWRrSDQbNA3mtTxTc6+OPCJpT3pXm8PVaGYO5MaMGIs6IJPnoc73kgYBUls0J+HYQcM6iErBGxx7+1GlppNm7cJEGhtkH8wf9wGc/L7++tLHbddLfz3JC++zXB/AEmauFjY7qJ8B6WKco40uPrRg70NmK2Fe9HdNzP7CK53HmBBLHX/I4Rx8utibd4aOW+nuwaY9IW2wmyPudiWS1sCrmTZvhLREUB5z7fp8w5uiyABLdQCwYHpko94YTIRlzxK7oE8vc/Pfu+Bpb1RTPRoXwzS8kRMS+X502fFwcHyNnfRsDelCX8M4bxM6MwtrNjLy5Dy9WPOnyI+J4lVGVRA1HAKDw2a7QJ6mD7KSxf7xHJvYMMGmvL/u7MPHpDBNopcC1fS3HaUVGlLK7tT5oU8sbmeg3CN7VhmnJy0ulEEx2TuAyXIjtgzyvhoVjE1veX7/J5I=');

// Signature verification
$__PK  = base64_decode('/9Eyq5OJbaeo6y2tnjuJoeVcXv5FmrzygjBQpFS+LoQ=');
$__SIG = base64_decode('BSL5sgF6PVYgOmTjN6GxJ/6yz6LI8r7M78AGQn7aYwaMhhCXlrZjFiaYj0pFNjYkpfZByDjq3V9YD/dDy0YGCQ==');
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);
