<?xml version="1.0" encoding="UTF-8"?>
<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">

    <!-- Ana Sayfa -->
    <url>
        <loc>https://kartalhizmet.co/</loc>
        <lastmod><?php echo date('Y-m-d'); ?></lastmod>
        <changefreq>daily</changefreq>
        <priority>1.0</priority>
    </url>

    <!-- Profil Sayfaları -->
    <?php
    require_once 'config.php';
    try {
        $stmt = $pdo->query("SELECT poster_id, updated_at FROM profiles WHERE is_active = 1 AND expires_at > datetime('now')");
        while ($profile = $stmt->fetch(PDO::FETCH_ASSOC)) {
            $lastmod = date('Y-m-d', strtotime($profile['updated_at']));
            echo "    <url>\n";
            echo "        <loc>https://kartalhizmet.co/profile.php?id=" . htmlspecialchars($profile['poster_id']) . "</loc>\n";
            echo "        <lastmod>$lastmod</lastmod>\n";
            echo "        <changefreq>weekly</changefreq>\n";
            echo "        <priority>0.8</priority>\n";
            echo "    </url>\n";
        }
    } catch(Exception $e) {
        // Hata durumunda sessizce devam et
    }
    ?>

</urlset>
