<?php
header('Content-Type: application/xml; charset=utf-8');

$base = 'https://home-leads.com';
$today = date('Y-m-d');

// Static pages
$static_pages = [
    ['url' => '/', 'priority' => '1.0', 'changefreq' => 'weekly'],
    ['url' => '/services', 'priority' => '0.9', 'changefreq' => 'monthly'],
    ['url' => '/creation-site-vitrine', 'priority' => '0.8', 'changefreq' => 'monthly'],
    ['url' => '/creation-site-sur-mesure', 'priority' => '0.8', 'changefreq' => 'monthly'],
    ['url' => '/creation-site-ecommerce', 'priority' => '0.8', 'changefreq' => 'monthly'],
    ['url' => '/creation-blog', 'priority' => '0.8', 'changefreq' => 'monthly'],
    ['url' => '/referencement-seo', 'priority' => '0.8', 'changefreq' => 'monthly'],
    ['url' => '/hebergement-maintenance', 'priority' => '0.8', 'changefreq' => 'monthly'],
    ['url' => '/creation-site-internet', 'priority' => '0.9', 'changefreq' => 'monthly'],
    ['url' => '/realisations', 'priority' => '0.7', 'changefreq' => 'monthly'],
    ['url' => '/simulateur-prix', 'priority' => '0.8', 'changefreq' => 'monthly'],
    ['url' => '/contact', 'priority' => '0.8', 'changefreq' => 'monthly'],
    ['url' => '/villes', 'priority' => '0.7', 'changefreq' => 'weekly'],
];

// Load cities for dynamic pages
$cities = json_decode(file_get_contents(__DIR__ . '/data/cities_france.json'), true);

echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php foreach ($static_pages as $page): ?>
    <url>
        <loc><?= $base . $page['url'] ?></loc>
        <lastmod><?= $today ?></lastmod>
        <changefreq><?= $page['changefreq'] ?></changefreq>
        <priority><?= $page['priority'] ?></priority>
    </url>
<?php endforeach; ?>
<?php if ($cities): foreach ($cities as $c): ?>
    <url>
        <loc><?= $base ?>/creation-site-internet-<?= htmlspecialchars($c['slug']) ?></loc>
        <lastmod><?= $today ?></lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.6</priority>
    </url>
<?php endforeach; endif; ?>
</urlset>