<?php
header('Content-Type: application/xml; charset=utf-8');
$scheme = 'http';
if ((isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === 'on' || $_SERVER['HTTPS'] === '1')) || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')) {
    $scheme = 'https';
}
$host = $_SERVER['HTTP_HOST'] ?? ($_SERVER['SERVER_NAME'] ?? '');
$host = preg_replace('/[^A-Za-z0-9\.\-\:\[\]]/', '', $host);
$base = $scheme . '://' . $host;
$today = date('Y-m-d');
$urls = [
    '/',
    '/video/',
    '/news/',
    '/topics/',
    '/authors/',
    '/contact/',
    '/about/',
    '/articles/meiridasa-video-guide/',
    '/articles/meiridasa-hot-topics/',
    '/articles/meiridasa-mobile-experience/',
    '/articles/meiridasa-ai-observation/',
    '/articles/meiridasa-topic-review/'
];
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php foreach ($urls as $url): ?>
  <url>
    <loc><?= htmlspecialchars($base . $url, ENT_XML1, 'UTF-8') ?></loc>
    <lastmod><?= $today ?></lastmod>
    <changefreq><?= $url === '/' ? 'daily' : 'weekly' ?></changefreq>
    <priority><?= $url === '/' ? '1.0' : '0.8' ?></priority>
  </url>
<?php endforeach; ?>
</urlset>
