<?php
// sitemap.xml - 蘑菇视频官网 - 域名动态获取
header('Content-Type: application/xml; charset=UTF-8');
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost';
$base = $protocol . '://' . $host;
$today = date('Y-m-d');

$urls = [
  ['loc' => '/', 'changefreq' => 'daily', 'priority' => '1.0'],
  ['loc' => '/download/', 'changefreq' => 'weekly', 'priority' => '0.9'],
  ['loc' => '/product/', 'changefreq' => 'weekly', 'priority' => '0.9'],
  ['loc' => '/solution/', 'changefreq' => 'weekly', 'priority' => '0.8'],
  ['loc' => '/cases/', 'changefreq' => 'weekly', 'priority' => '0.8'],
  ['loc' => '/news/', 'changefreq' => 'daily', 'priority' => '0.8'],
  ['loc' => '/faq/', 'changefreq' => 'weekly', 'priority' => '0.7'],
  ['loc' => '/video/', 'changefreq' => 'daily', 'priority' => '0.9'],
  ['loc' => '/about/', 'changefreq' => 'monthly', 'priority' => '0.6'],
  ['loc' => '/contact/', 'changefreq' => 'monthly', 'priority' => '0.6'],
];
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
        http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<?php foreach($urls as $url): ?>
  <url>
    <loc><?php echo htmlspecialchars($base . $url['loc']); ?></loc>
    <lastmod><?php echo $today; ?></lastmod>
    <changefreq><?php echo $url['changefreq']; ?></changefreq>
    <priority><?php echo $url['priority']; ?></priority>
  </url>
<?php endforeach; ?>
</urlset>
