<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
        xmlns:xhtml="http://www.w3.org/1999/xhtml">
  
  <!-- 手动配置核心页面 -->
  <url>
    <loc>https://xindongfeng.com/</loc>
    <lastmod>2025-05-28</lastmod>
    <changefreq>daily</changefreq>
    <priority>1.0</priority>
  </url>

  <url>
    <loc>https://xindongfeng.com/about</loc>
    <lastmod>2025-05-20</lastmod>
    <priority>0.8</priority>
  </url>

  <!-- 动态生成内容 -->
  <?php
  // 以下PHP代码需要保存为 /sitemap.php
  header('Content-Type: application/xml; charset=utf-8');
  
  // 数据库连接（使用PbootCMS配置）
  require_once 'config/database.php';
  $conn = new mysqli(DB_HOST, DB_USER, DB_PWD, DB_NAME);
  
  // 生成栏目页
  $columns = $conn->query("SELECT * FROM ".DB_PREFIX."content WHERE type='column'");
  while($col = $columns->fetch_assoc()){
    echo "<url>
            <loc>https://xindongfeng.com/".$col['scode']."/</loc>
            <lastmod>".date('Y-m-d', strtotime($col['update_time']))."</lastmod>
            <priority>0.7</priority>
          </url>";
  }

  // 生成文章页（最近500篇）
  $articles = $conn->query("SELECT * FROM ".DB_PREFIX."content 
                          WHERE type='content' 
                          ORDER BY update_time DESC LIMIT 500");
  while($art = $articles->fetch_assoc()){
    echo "<url>
            <loc>https://xindongfeng.com/article/".$art['id'].".html</loc>
            <lastmod>".date('Y-m-d', strtotime($art['update_time']))."</lastmod>
            <news:news>
              <news:publication_date>".date('c', strtotime($art['date']))."</news:publication_date>
              <news:title><![CDATA[".htmlspecialchars($art['title'])."]]></news:title>
            </news:news>
          </url>";
  }
  
  $conn->close();
  ?>
  
  <!-- 静态资源 -->
  <url>
    <loc>https://xindongfeng.com/favicon.ico</loc>
    <lastmod>2025-01-11</lastmod>
  </url>
  
</urlset>