<?php
declare(strict_types=1);
header('Content-Type: application/xml; charset=UTF-8');
$https = $_SERVER['HTTPS'] ?? '';
$scheme = (!empty($https) && $https !== 'off') ? 'https' : 'http';
$host = htmlspecialchars($_SERVER['HTTP_HOST'] ?? '', ENT_XML1, 'UTF-8');
$origin = $host === '' ? '' : $scheme . '://' . $host;
$today = date('Y-m-d');
$paths = ['/', '/features/', '/tutorials/', '/updates/', '/help/', '/tips/', '/faq/', '/contact/'];
echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php foreach ($paths as $path): ?>
  <url>
    <loc><?= $origin . $path ?></loc>
    <lastmod><?= $today ?></lastmod>
    <changefreq><?= $path === '/' ? 'daily' : 'weekly' ?></changefreq>
    <priority><?= $path === '/' ? '1.0' : '0.8' ?></priority>
  </url>
<?php endforeach; ?>
</urlset>
