<?php
header('Content-Type: application/xml; charset=UTF-8');
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
$currentHostRaw = $_SERVER['HTTP_HOST'] ?? '';
$baseUrl = $currentHostRaw ? $scheme . '://' . $currentHostRaw : '';
$urls = ['/', '/topics/', '/boards/', '/discover/', '/ranking/', '/me/', '/story/', '/recommendations/', '/help/', '/rules/', '/updates/', '/activities/'];
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php foreach ($urls as $u): ?>
  <url><loc><?php echo htmlspecialchars($baseUrl . $u, ENT_QUOTES, 'UTF-8'); ?></loc><changefreq>daily</changefreq><priority><?php echo $u === '/' ? '1.0' : '0.8'; ?></priority></url>
<?php endforeach; ?>
</urlset>
