<?php
header("Content-Type: application/xml; charset=utf-8");

require_once __DIR__ . '/config/db.php';

echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

  <!-- Static pages -->
  <url>
    <loc>https://hotelssl.com/</loc>
    <changefreq>daily</changefreq>
    <priority>1.0</priority>
  </url>

  <url>
    <loc>https://hotelssl.com/hotels.php</loc>
    <changefreq>daily</changefreq>
    <priority>0.9</priority>
  </url>

  <url>
    <loc>https://hotelssl.com/about.php</loc>
    <priority>0.6</priority>
  </url>

  <url>
    <loc>https://hotelssl.com/contact.php</loc>
    <priority>0.6</priority>
  </url>

<?php
$stmt = $pdo->query("SELECT id, updated_at FROM hotels");
while ($hotel = $stmt->fetch(PDO::FETCH_ASSOC)):
?>
  <url>
    <loc>https://hotelssl.com/hotel.php?id=<?= $hotel['id'] ?></loc>
    <lastmod><?= date('Y-m-d', strtotime($hotel['updated_at'] ?? 'now')) ?></lastmod>
    <changefreq>weekly</changefreq>
    <priority>0.8</priority>
  </url>
<?php endwhile; ?>

</urlset>
