<?php
header('Content-Type: application/xml; charset=utf-8');
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
$host = isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST'] !== '' ? $_SERVER['HTTP_HOST'] : '';
$base = $scheme . '://' . $host;
$today = date('Y-m-d');
$ns = 'http://' . 'www.' . 'sitemaps' . '.org/schemas/sitemap/0.9';
$pages = [
  '/',
  '/insights/',
  '/video-guides/',
  '/topics/',
  '/creator-center/',
  '/community/',
  '/submit/',
  '/help/',
  '/contact/',
  '/rules/',
  '/authors/',
  '/updates/',
  '/articles/video-guide-1/',
  '/articles/video-guide-2/',
  '/articles/video-guide-3/',
  '/articles/video-guide-4/'
];
echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
?>
<urlset xmlns="<?php echo $ns; ?>">
<?php foreach ($pages as $page): ?>
  <url>
    <loc><?php echo htmlspecialchars($base . $page, ENT_XML1, 'UTF-8'); ?></loc>
    <lastmod><?php echo $today; ?></lastmod>
    <changefreq><?php echo $page === '/' ? 'daily' : 'weekly'; ?></changefreq>
    <priority><?php echo $page === '/' ? '1.0' : '0.8'; ?></priority>
  </url>
<?php endforeach; ?>
</urlset>
