<?php
require 'config.php';

header('Content-Type: application/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xhtml="http://www.w3.org/1999/xhtml">
    
    <!-- Pagina principală -->
    <url>
        <loc>https://retete.ardetot.ro/</loc>
        <changefreq>daily</changefreq>
        <priority>1.0</priority>
        <lastmod><?= date('Y-m-d') ?></lastmod>
    </url>
    
    <?php
    // Toate rețetele
    $stmt = $pdo->query("SELECT id, data_adaugare FROM retete");
    while ($row = $stmt->fetch()) {
        echo '
    <url>
        <loc>https://retete.ardetot.ro/?id=' . $row['id'] . '</loc>
        <changefreq>weekly</changefreq>
        <priority>0.8</priority>
        <lastmod>' . date('Y-m-d', strtotime($row['data_adaugare'])) . '</lastmod>
    </url>';
    }
    ?>
</urlset>