time(); } function raijuAccessAssetPath(string $path): string { $path = trim($path); if ($path === '') { return ''; } if (preg_match('#^https?://#i', $path)) { return ''; } return '/' . ltrim($path, '/'); } function raijuAccessResolveBrandAsset(array $settings, string $asset): string { if ($asset === 'favicon') { return raijuAccessAssetPath((string)($settings['favicon'] ?? '/assets/images/favicon.svg')); } if ($asset === 'logo') { $logo = (string)($settings['branding']['logo'] ?? ''); return raijuAccessAssetPath($logo !== '' ? $logo : (string)($settings['favicon'] ?? '/assets/images/favicon.svg')); } return ''; } function raijuAccessCssUrl(string $path): string { return str_replace(["\\", "\"", "\n", "\r"], ["\\\\", "\\\"", "", ""], $path); } function raijuAccessImageLayout(string $layout): string { if ($layout === 'split') { return 'left'; } return in_array($layout, ['none', 'background', 'left', 'right'], true) ? $layout : 'none'; } function raijuAccessRgbaFromHex(string $hex, int $opacity): string { if (!preg_match('/^#[0-9a-fA-F]{6}$/', $hex)) { return ''; } $opacity = max(0, min(100, $opacity)); $red = hexdec(substr($hex, 1, 2)); $green = hexdec(substr($hex, 3, 2)); $blue = hexdec(substr($hex, 5, 2)); $alpha = rtrim(rtrim(sprintf('%.2F', $opacity / 100), '0'), '.'); return "rgba($red, $green, $blue, $alpha)"; } function raijuAccessRenderStandalonePage(array $options): void { $status = (int)($options['status'] ?? 503); http_response_code($status); if ($status === 503 && !empty($options['retryAfter'])) { header('Retry-After: ' . (int)$options['retryAfter']); } header('Content-Type: text/html; charset=utf-8'); header('X-Robots-Tag: noindex, nofollow', false); $title = htmlspecialchars((string)($options['title'] ?? 'Temporarily unavailable'), ENT_QUOTES, 'UTF-8'); $text = nl2br(htmlspecialchars((string)($options['text'] ?? ''), ENT_QUOTES, 'UTF-8')); $mode = htmlspecialchars((string)($options['mode'] ?? 'maintenance'), ENT_QUOTES, 'UTF-8'); $until = htmlspecialchars((string)($options['until'] ?? ''), ENT_QUOTES, 'UTF-8'); $showCountdown = !empty($options['showCountdown']) && $until !== ''; $brandAsset = raijuAccessAssetPath((string)($options['brandAssetPath'] ?? '')); $image = raijuAccessAssetPath((string)($options['image'] ?? '')); $imageLayout = $image !== '' ? raijuAccessImageLayout((string)($options['imageLayout'] ?? 'none')) : 'none'; $bodyClass = 'rj-lock-page'; if ($imageLayout === 'background') { $bodyClass .= ' rj-lock-page--background'; } elseif ($imageLayout === 'left') { $bodyClass .= ' rj-lock-page--split rj-lock-page--image-left'; } elseif ($imageLayout === 'right') { $bodyClass .= ' rj-lock-page--split rj-lock-page--image-right'; } $cssImage = raijuAccessCssUrl($image); $overlayColor = trim((string)($options['overlayColor'] ?? '')); $overlayOpacity = (int)($options['overlayOpacity'] ?? 88); $overlayRgba = raijuAccessRgbaFromHex($overlayColor, $overlayOpacity); $overlayStyle = $overlayColor !== '' && preg_match('/^#[0-9a-fA-F]{6}$/', $overlayColor) ? '; --rj-lock-overlay-color: ' . htmlspecialchars($overlayRgba, ENT_QUOTES, 'UTF-8') : ''; ?>