<?php
require_once 'db.php';

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

echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://annantay.in/</loc>
    <priority>1.0</priority>
    <changefreq>weekly</changefreq>
  </url>
  <url>
    <loc>https://annantay.in/retreat.php</loc>
    <priority>0.9</priority>
    <changefreq>weekly</changefreq>
  </url>
  <url>
    <loc>https://annantay.in/workshop.php</loc>
    <priority>0.9</priority>
    <changefreq>weekly</changefreq>
  </url>
  <url>
    <loc>https://annantay.in/catalog.php</loc>
    <priority>0.8</priority>
    <changefreq>weekly</changefreq>
  </url>
  <url>
    <loc>https://annantay.in/values.php</loc>
    <priority>0.7</priority>
    <changefreq>monthly</changefreq>
  </url>
  <url>
    <loc>https://annantay.in/contact.php</loc>
    <priority>0.8</priority>
    <changefreq>monthly</changefreq>
  </url>
  <url>
    <loc>https://annantay.in/privacy-policy.php</loc>
    <priority>0.3</priority>
    <changefreq>yearly</changefreq>
  </url>
  <url>
    <loc>https://annantay.in/terms.php</loc>
    <priority>0.3</priority>
    <changefreq>yearly</changefreq>
  </url>
<?php
$stmt = $pdo->query("SELECT id, title FROM retreats ORDER BY id ASC");
foreach ($stmt as $row) {
    $slug = 'retreat-detail.php?id=' . $row['id'];
    echo "  <url>\n";
    echo "    <loc>https://annantay.in/{$slug}</loc>\n";
    echo "    <priority>0.7</priority>\n";
    echo "    <changefreq>monthly</changefreq>\n";
    echo "  </url>\n";
}

$stmt = $pdo->query("SELECT id, title FROM workshops ORDER BY id ASC");
foreach ($stmt as $row) {
    $slug = 'workshop-detail.php?id=' . $row['id'];
    echo "  <url>\n";
    echo "    <loc>https://annantay.in/{$slug}</loc>\n";
    echo "    <priority>0.7</priority>\n";
    echo "    <changefreq>monthly</changefreq>\n";
    echo "  </url>\n";
}

$stmt = $pdo->query("SELECT id, name FROM catalogs ORDER BY id ASC");
foreach ($stmt as $row) {
    $slug = 'catalog-detail.php?id=' . $row['id'];
    echo "  <url>\n";
    echo "    <loc>https://annantay.in/{$slug}</loc>\n";
    echo "    <priority>0.6</priority>\n";
    echo "    <changefreq>monthly</changefreq>\n";
    echo "  </url>\n";
}

$stmt = $pdo->query("SELECT id, title FROM values_table ORDER BY id ASC");
foreach ($stmt as $row) {
    $slug = 'value-detail.php?id=' . $row['id'];
    echo "  <url>\n";
    echo "    <loc>https://annantay.in/{$slug}</loc>\n";
    echo "    <priority>0.5</priority>\n";
    echo "    <changefreq>monthly</changefreq>\n";
    echo "  </url>\n";
}
?>
</urlset>
