true, 'error' => '', 'demo' => true]; } if (session_status() !== PHP_SESSION_ACTIVE) { session_start(); } $admin_key = (string) ($config['admin_key'] ?? ''); $session_key = $_SESSION['gridtv_admin_unlocked'] ?? ''; $error = ''; if ($admin_key !== '' && hash_equals($admin_key, (string) $session_key)) { return ['unlocked' => true, 'error' => '', 'demo' => false]; } if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['admin_key_input'])) { $submitted = trim((string) ($_POST['admin_key_input'] ?? '')); if ($admin_key !== '' && hash_equals($admin_key, $submitted)) { $_SESSION['gridtv_admin_unlocked'] = $admin_key; header('Location: ' . strtok($_SERVER['REQUEST_URI'], '?')); exit; } $error = 'Invalid admin key.'; } http_response_code(401); echo '