<?php
$host = $_SERVER['HTTP_HOST'] ?? ($_SERVER['SERVER_NAME'] ?? '');
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
$origin = $host ? ($scheme . '://' . htmlspecialchars($host, ENT_QUOTES, 'UTF-8')) : '';
header('Content-Type: application/xml; charset=UTF-8');
$paths = ['/', '/selected/', '/topics/', '/creator/', '/guide/', '/announcements/', '/help/', '/rules/', '/submit/', '/contact/'];
echo '<?xml version="1.0" encoding="UTF-8"?>' . "
";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "
";
foreach ($paths as $p) {
  echo '  <url><loc>' . $origin . $p . '</loc><lastmod>' . date('Y-m-d') . '</lastmod><changefreq>weekly</changefreq><priority>' . ($p === '/' ? '1.0' : '0.8') . '</priority></url>' . "
";
}
echo '</urlset>' . "
";
?>
