prepare("SELECT * FROM galleries WHERE id = ?"); $stmt->execute([$id]); $g = $stmt->fetch(PDO::FETCH_ASSOC); if (!$g) { die("Gallery not found locally."); } // Decode JSON page paths array and prefix with leading slash for web routing $pages = json_decode($g['pages_paths'], true) ?: []; foreach ($pages as &$p) { $p = '/' . $p; } $pagesJson = localnh_script_json($pages); $title = htmlspecialchars($g['title']); // Open Graph metadata for rich link previews (Discord, Telegram, Twitter) $cover = htmlspecialchars('/' . $g['cover_path']); $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http"; $host = $_SERVER['HTTP_HOST']; $ogUrl = "{$protocol}://{$host}/g/{$id}/" . (isset($pageParam) ? $pageParam : 1); $ogImage = "{$protocol}://{$host}/" . $g['cover_path']; $titleHtml = htmlspecialchars($g['title']); // Reading direction preference (LTR or RTL manga mode) $flipPageOrder = (isset($_COOKIE['flip_page_order']) && in_array($_COOKIE['flip_page_order'], ['ltr', 'rtl'])) ? $_COOKIE['flip_page_order'] : 'ltr'; $themeCss = getThemeVars(); ?>