<?php
require_once __DIR__ . '/config/site.php';
header('Content-Type: application/xml; charset=utf-8');
$base = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || (($_SERVER['SERVER_PORT'] ?? '') == 443) ? 'https' : 'http') . '://' . ($_SERVER['HTTP_HOST'] ?? 'localhost');
$pages = [
    '/index.php',
    '/consumenten.php',
    '/zakelijk.php',
    '/educatie.php',
    '/reparatie.php',
    '/xelion.php',
    '/contact.php'
];
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo '<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9">';
foreach ($pages as $page) {
    echo '<url><loc>' . htmlspecialchars($base . $page, ENT_QUOTES, 'UTF-8') . '</loc></url>';
}
foreach ($site['landing_services'] as $dienstSlug => $service) {
    foreach ($site['service_areas'] as $plaatsSlug => $plaats) {
        echo '<url><loc>' . htmlspecialchars($base . '/landings/' . $dienstSlug . '/' . $plaatsSlug, ENT_QUOTES, 'UTF-8') . '</loc></url>';
    }
}
echo '</urlset>';
