<?php
require_once __DIR__ . '/importante.php';
header('Content-Type: application/xml; charset=UTF-8');
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <!-- Páginas principais -->
  <url>
    <loc>https://magnificafantasias.com.br/</loc>
    <lastmod><?php echo date('Y-m-d'); ?></lastmod>
    <changefreq>daily</changefreq>
    <priority>1.0</priority>
  </url>
  <url>
    <loc>https://magnificafantasias.com.br/sobre.php</loc>
    <lastmod><?php echo date('Y-m-d'); ?></lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.8</priority>
  </url>
  <url>
    <loc>https://magnificafantasias.com.br/contato.php</loc>
    <lastmod><?php echo date('Y-m-d'); ?></lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.8</priority>
  </url>
  <?php
  // Categorias
  $categorias = $pdo->query("SELECT id FROM categorias WHERE nome != 'Todas' ORDER BY nome")->fetchAll(PDO::FETCH_ASSOC);
  foreach ($categorias as $cat) {
      echo "  <url>\n";
      echo "    <loc>https://magnificafantasias.com.br/category.php?id=" . $cat['id'] . "</loc>\n";
      echo "    <lastmod>" . date('Y-m-d') . "</lastmod>\n";
      echo "    <changefreq>weekly</changefreq>\n";
      echo "    <priority>0.6</priority>\n";
      echo "  </url>\n";
  }
  // Produtos
  $produtos = $pdo->query("SELECT id FROM produtos ORDER BY id")->fetchAll(PDO::FETCH_ASSOC);
  foreach ($produtos as $prod) {
      echo "  <url>\n";
      echo "    <loc>https://magnificafantasias.com.br/product.php?id=" . $prod['id'] . "</loc>\n";
      echo "    <lastmod>" . date('Y-m-d') . "</lastmod>\n";
      echo "    <changefreq>monthly</changefreq>\n";
      echo "    <priority>0.5</priority>\n";
      echo "  </url>\n";
  }
  ?>
</urlset>
