403 Forbidden

Access denied.

", 403); } $ext = pathinfo($realPath, PATHINFO_EXTENSION); if (in_array($ext, ['php', 'html', 'md'])) { ob_start(); if ($ext === 'md') { if (!class_exists('Parsedown')) { require_once __DIR__ . '/vendor/Parsedown.php'; } echo '
' . (new Parsedown())->text(file_get_contents($realPath)) . '
'; } else { include $realPath; } $content = ob_get_clean(); // Build navigation for templates $navigation = buildNavigation($contentDir, $currentLang, $defaultLang); // Load metadata for current page/directory $pageDir = dirname($realPath); $pageMetadata = loadMetadata($pageDir, $currentLang, $defaultLang); $pageTitle = $pageMetadata['title'] ?? null; // Load frontpage metadata for home button label $frontpageMetadata = loadMetadata($contentDir, $currentLang, $defaultLang); $homeLabel = $frontpageMetadata['slug'] ?? 'Home'; // Load translations $translations = loadTranslations($currentLang); // Wrap content with page template ob_start(); include $pageTemplate; $content = ob_get_clean(); // Wrap with base template include $baseTemplate; exit; } // Serve other file types directly header('Content-Type: ' . (mime_content_type($realPath) ?: 'application/octet-stream')); readfile($realPath); exit; } function renderMultipleFiles(array $filePaths, string $pageDir): void { global $baseTemplate, $pageTemplate, $contentDir, $currentLang, $defaultLang; // Validate all files are safe foreach ($filePaths as $filePath) { $realPath = realpath($filePath); if (!$realPath || !str_starts_with($realPath, $contentDir) || !is_readable($realPath)) { renderTemplate("

403 Forbidden

Access denied.

", 403); } } // Render all content files in order $content = ''; foreach ($filePaths as $filePath) { $ext = pathinfo($filePath, PATHINFO_EXTENSION); ob_start(); if ($ext === 'md') { if (!class_exists('Parsedown')) { require_once __DIR__ . '/vendor/Parsedown.php'; } echo '
' . (new Parsedown())->text(file_get_contents($filePath)) . '
'; } elseif ($ext === 'html') { include $filePath; } elseif ($ext === 'php') { include $filePath; } $content .= ob_get_clean(); } // Build navigation for templates $navigation = buildNavigation($contentDir, $currentLang, $defaultLang); // Load metadata for current page/directory $pageMetadata = loadMetadata($pageDir, $currentLang, $defaultLang); $pageTitle = $pageMetadata['title'] ?? null; // Load frontpage metadata for home button label $frontpageMetadata = loadMetadata($contentDir, $currentLang, $defaultLang); $homeLabel = $frontpageMetadata['slug'] ?? 'Home'; // Load translations $translations = loadTranslations($currentLang); // Wrap content with page template ob_start(); include $pageTemplate; $content = ob_get_clean(); // Wrap with base template include $baseTemplate; exit; }