<?xml version="1.0" encoding="UTF-8"?>
<?php
header('Content-Type: application/xml; charset=utf-8');
$_proto = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
$base   = $_proto . '://' . ($_SERVER['HTTP_HOST'] ?? 'lanstrom.com') . rtrim(dirname($_SERVER['SCRIPT_NAME']), '/');
$today = date('Y-m-d');

// Pages statiques avec leurs priorités et fréquences de mise à jour
$pages = [
    ['/',                               '1.0',  'weekly',  $today],
    ['/services.php',                   '0.9',  'monthly', $today],
    ['/services/pret-personnel.php',    '0.9',  'monthly', $today],
    ['/services/pret-immobilier.php',   '0.9',  'monthly', $today],
    ['/services/pret-automobile.php',   '0.9',  'monthly', $today],
    ['/services/pret-etudiant.php',     '0.9',  'monthly', $today],
    ['/services/pret-professionnel.php','0.9',  'monthly', $today],
    ['/services/rachat-credit.php',     '0.9',  'monthly', $today],
    ['/simulateur.php',                 '0.85', 'monthly', $today],
    ['/form.php',                       '0.85', 'weekly',  $today],
    ['/fonctionnement.php',             '0.8',  'monthly', $today],
    ['/a-propos.php',                   '0.7',  'monthly', $today],
    ['/faq.php',                        '0.75', 'weekly',  $today],
    ['/contact.php',                    '0.7',  'monthly', $today],
    ['/mentions.php',                   '0.3',  'yearly',  $today],
    ['/cgu.php',                        '0.3',  'yearly',  $today],
    ['/politique-confidentialite.php',  '0.3',  'yearly',  $today],
];

echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php foreach ($pages as $p): ?>
    <url>
        <loc><?= $base . htmlspecialchars($p[0]) ?></loc>
        <lastmod><?= $p[3] ?></lastmod>
        <changefreq><?= $p[2] ?></changefreq>
        <priority><?= $p[1] ?></priority>
    </url>
<?php endforeach; ?>
</urlset>
