<?php
declare(strict_types=1);

require_once __DIR__ . '/api/profile-helpers.php';

header('Content-Type: application/xml; charset=utf-8');
header('Cache-Control: public, max-age=3600');

$profiles = fetchActiveProfileIds();
$today = date('Y-m-d');

echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";

foreach ($profiles as $profile) {
    $loc = profileUrl($profile['id'], $profile['name']);
    echo "  <url>\n";
    echo '    <loc>' . h($loc) . "</loc>\n";
    echo '    <lastmod>' . $today . "</lastmod>\n";
    echo "    <changefreq>weekly</changefreq>\n";
    echo "    <priority>0.70</priority>\n";
    echo "  </url>\n";
}

echo "</urlset>\n";
