<?php
/**
 * FILE: /public_html/sitemap.xml
 */

require_once __DIR__ . '/config/config.php';

// 🚫 DO NOT LOAD schema.php OR db.php HERE

if (defined('APP_ENV') && APP_ENV !== 'prod') {
    header('Content-Type: application/xml; charset=UTF-8');
    echo '<?xml version="1.0" encoding="UTF-8"?>';
    echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>';
    exit;
}

header('Content-Type: application/xml; charset=UTF-8');

$urls = [
    ['loc' => BASE_URL . '/', 'changefreq' => 'weekly', 'priority' => '1.0'],
    ['loc' => BASE_URL . '/pages/about.php', 'changefreq' => 'monthly', 'priority' => '0.9'],
    ['loc' => BASE_URL . '/pages/listings.php', 'changefreq' => 'weekly', 'priority' => '0.9'],
    ['loc' => BASE_URL . '/pages/coaching.php', 'changefreq' => 'monthly', 'priority' => '0.8'],
    ['loc' => BASE_URL . '/pages/contact.php', 'changefreq' => 'monthly', 'priority' => '0.8'],
];

echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php foreach ($urls as $url): ?>
    <url>
        <loc><?= htmlspecialchars($url['loc'], ENT_XML1) ?></loc>
        <changefreq><?= $url['changefreq'] ?></changefreq>
        <priority><?= $url['priority'] ?></priority>
    </url>
<?php endforeach; ?>
</urlset>
