<?php
require_once __DIR__ . '/bootstrap_path.php';
require_once APP_ROOT . '/app/bootstrap.php';
header('Content-Type: application/xml; charset=utf-8');
$base = rtrim($config['app']['base_url'] ?? '', '/');
if ($base === '') {
    $scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
    $base = $scheme . '://' . $_SERVER['HTTP_HOST'];
}
$urls = [
    '/',
    '/appointment/new.php',
];
$groomers = $db->query('SELECT id FROM groomers WHERE is_active = 1')->fetchAll();
foreach ($groomers as $g) {
    $urls[] = '/groomer.php?id=' . (int)$g['id'];
}

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php foreach ($urls as $path): ?>
  <url>
    <loc><?= e($base . $path) ?></loc>
  </url>
<?php endforeach; ?>
</urlset>
