<?php
/**
 * SMART FRIENDS — F: Dynamic Sitemap (XML)
 * URL: https://smartfriends.online/sitemap.xml
 */
header('Content-Type: application/xml; charset=UTF-8');
header('Cache-Control: public, max-age=86400');

require_once __DIR__ . '/config/database.php';
require_once __DIR__ . '/config/functions.php';

$base    = defined('SITE_URL') ? rtrim(SITE_URL, '/') : 'https://smartfriends.online';
$today   = date('Y-m-d');
$lastMod = date('Y-m-d', filemtime(__FILE__));

// Core public pages
$urls = [
    ['loc' => $base . '/',             'priority' => '1.0', 'freq' => 'weekly',  'mod' => $today],
    ['loc' => $base . '/index.php',    'priority' => '0.8', 'freq' => 'monthly', 'mod' => $today],
    ['loc' => $base . '/landing.php',  'priority' => '0.9', 'freq' => 'weekly',  'mod' => $today],
    ['loc' => $base . '/verify/',      'priority' => '0.5', 'freq' => 'yearly',  'mod' => $today],
];

echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
foreach ($urls as $u):
?>
  <url>
    <loc><?= htmlspecialchars($u['loc']) ?></loc>
    <lastmod><?= $u['mod'] ?></lastmod>
    <changefreq><?= $u['freq'] ?></changefreq>
    <priority><?= $u['priority'] ?></priority>
  </url>
<?php endforeach; ?>
</urlset>
