<?php
header('Content-Type: application/xml; charset=UTF-8');
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
$currentHostRaw = $_SERVER['HTTP_HOST'] ?? ($_SERVER['SERVER_NAME'] ?? '');
$currentHost = preg_replace('/[^A-Za-z0-9\.\-:]/', '', $currentHostRaw);
$baseUrl = $currentHost ? $scheme . '://' . $currentHost : '';
$today = date('Y-m-d');
$paths = ['/', '/guofeng/', '/life/', '/video/', '/yaji/', '/creator/', '/contact/', '/shuimo-yaji/', '/guofeng-diary/', '/yijing-guan/', '/shici-space/', '/yazhi-qiwu/'];
function xe($value) { return htmlspecialchars((string)$value, ENT_XML1 | ENT_QUOTES, 'UTF-8'); }
echo "<?xml version="1.0" encoding="UTF-8"?>
";
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php foreach ($paths as $path): ?>
  <url>
    <loc><?= xe($baseUrl . $path) ?></loc>
    <lastmod><?= xe($today) ?></lastmod>
    <changefreq><?= $path === '/' ? 'daily' : 'weekly' ?></changefreq>
    <priority><?= $path === '/' ? '1.0' : '0.8' ?></priority>
  </url>
<?php endforeach; ?>
</urlset>
