<?php
header('Content-Type: application/xml; charset=utf-8');
require_once __DIR__ . '/../includes/config.php';

echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";

$pages = [
    ['loc' => '', 'priority' => '1.0', 'changefreq' => 'weekly'],
    ['loc' => 'about.php', 'priority' => '0.8', 'changefreq' => 'monthly'],
    ['loc' => 'destinations.php', 'priority' => '0.8', 'changefreq' => 'monthly'],
    ['loc' => 'packages.php', 'priority' => '0.9', 'changefreq' => 'weekly'],
    ['loc' => 'blog.php', 'priority' => '0.7', 'changefreq' => 'weekly'],
    ['loc' => 'gallery.php', 'priority' => '0.6', 'changefreq' => 'monthly'],
    ['loc' => 'contact.php', 'priority' => '0.7', 'changefreq' => 'monthly'],
    ['loc' => 'terms.php', 'priority' => '0.3', 'changefreq' => 'yearly'],
    ['loc' => 'privacy.php', 'priority' => '0.3', 'changefreq' => 'yearly'],
    ['loc' => 'search.php', 'priority' => '0.4', 'changefreq' => 'monthly'],
    ['loc' => 'wishlist.php', 'priority' => '0.3', 'changefreq' => 'monthly'],
];

foreach ($pages as $p) {
    echo '  <url>' . "\n";
    echo '    <loc>' . $site_url . '/' . $p['loc'] . '</loc>' . "\n";
    echo '    <priority>' . $p['priority'] . '</priority>' . "\n";
    echo '    <changefreq>' . $p['changefreq'] . '</changefreq>' . "\n";
    echo '  </url>' . "\n";
}

foreach ($tours as $id => $t) {
    echo '  <url>' . "\n";
    echo '    <loc>' . $site_url . '/package-detail.php?id=' . $id . '</loc>' . "\n";
    echo '    <priority>0.8</priority>' . "\n";
    echo '    <changefreq>monthly</changefreq>' . "\n";
    echo '  </url>' . "\n";
}

if (!empty($blogs)) {
    foreach ($blogs as $id => $b) {
        echo '  <url>' . "\n";
        echo '    <loc>' . $site_url . '/blog-detail.php?id=' . $id . '</loc>' . "\n";
        echo '    <priority>0.6</priority>' . "\n";
        echo '    <changefreq>monthly</changefreq>' . "\n";
        echo '  </url>' . "\n";
    }
}

echo '</urlset>' . "\n";
?>
