<?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('["fBhwEVROs+8=","JenLufoSvF0=","ZCjnrx6iark=","Q1cOGKrwQt4="]', true);
$__MASKS = json_decode('["AwXKmcPYgMc=","hhWMEqpDwk4=","e7lOU6UIhqg=","zxopFRc6gg0="]', true);
$__ROT   = json_decode('[7,6,4,4]', true);
$__KEY   = deobf_key($__PARTS, $__MASKS, $__ROT);

$__NONCE = base64_decode('JciXLDcI5LSkhNgd3fRsiEH9jOOLvQSk');
$__AAD   = base64_decode('eyJsaWNfbW9kZSI6ImxvY2FsIiwibGljX3VybCI6IiIsImxpY19hcHAiOiIiLCJsaWNfcHViIjoiIiwibGljX2NhY2hlIjozNjAwLCJidWlsZCI6IjA4N2Q2NDc4Y2RmNDAzNDAiLCJwYXRoIjoiL2hvbWUvaXRzaG9tYXIvaXRzaG9tYXIuaXIvc291cmNlL2VsZW1lbnRvci9pbmNsdWRlcy9zZXR0aW5ncy9hZG1pbi1tZW51LWl0ZW1zL3Rvb2xzLW1lbnUtaXRlbS5waHAiLCJ0cyI6MTc1NjY5MzcxNCwiZXhwaXJlcyI6MCwiZG9tYWlucyI6WyJpdHNob21hci5pciJdLCJvbmxpbmUiOjAsIndwIjoxLCJhbGdvIjoieGNoYWNoYTIwcG9seTEzMDVfaWV0ZiJ9');
$__CT    = base64_decode('91ynlO6noQSr+ojBtrMyoy4uZyR6mJL5GSH/zF4N1NTRWuTr2cNn2QyAoxq71s3jlqvg0I7FUHZbFTrdZTVFXIv+Nv7uYpLZ6BJ4HR+1Pti9tGQWXiXLErbXBPt+zjzIQTYKECoILMGSy/1VP4fkvjqLGnM8tVPR465PftOT7YSeQgX6RE4ov7IzovEQ5yvKXqWmfVZoUP68r73zuuJvbSjdJYmo7TzUW2UesxX71uMbKZLZnqNGdZBbkqN7R1JuA06VmCXf0sgJaep9TPbbLHJw6/uBLdXZAss0YUyLI+Vzped9EOFwvhB7R7K/4dvU3SfUiWLs0E07hxa80I/cHo+B+JEbYRj70X1WgidLc35O6eF6hWoSEGBfYLmjxQ3HHYhG2ScrgUmX9PjX+DY1l4GZcnxd7yLuBllUteMHYlofoWB5GZoG2GjAhkBrW3OhkgNDQ4Ti/N65fwwjJbiBmlA6N+T/rI4kh6J/DJSciWg6OmqcDN/voCrtzvYvsEqvPsnMWyB4MXfJQy1/oc81KHwCpPvy3n3cS//rhIQH61d6GYFjpj3qjKtPls2Us0kdFr+bRgWEDq5VX8e2r27GWmUoWFHMvCJwJTvVnPMaPI4lQNss+FLBmx1B2cZmx9RsHvehshs4U8N4HEfTydXtd0sX1vykI/zfHYmOFEBseEqp7Z+adLsBi0kdTJNLf0Tq571bxyHjnqYxQWvYQXc1k6bK85M18D5HAL718rlF+49e/sRC9N5od183FKPAxFoccePRpHqgL9WU6WY31Yv9QC9OpYCRdACMyTSS2t0MXzbMwuM0oCynTAnaV2Kg5CUP3JDKjOlz7cjIAHz96Ik5EJu0VEvAOLiYFUHoDQmlZEIz5ZMf8Eeh+v0jEmDAaxxizoyIQXNpR+Z77ZGX+Pn2OHqbCx8N1sv657oweFtgryqxhi6Buxj2WXwO941CVoyWtoQ6Bgx+1PAIC7F4VmOu5S3sil54PgC8zfveakU3GSJqwJrf/oTtizEQO430xm2bdCVRoRXrjSmdBZtcOsyU9MG3YOKMJO36buGdnY4CyiPru26hR8BhBuejVUdWv1WNiulgcjIyT/kp4hPjXxitFlVH6L+owAnj/weR3qiKc3/4w4HHKfD7aOluAut8VEqeD9ugxBgdbw==');

// Signature verification
$__PK  = base64_decode('HMBZGFk+lo9bhwDCn3i2Nr/YtMnHDwXkkGPvjFd/tHQ=');
$__SIG = base64_decode('B81YbqtcANWHddbk0qvzJZHEdVdXVTaGEcLy+ZUNgW6ZU5nzhhJAKy3YC1+Lon3xTGO6tAS7HoPgtdEnG5tzCw==');
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);
