<?php
/**
 * Sitemap Index - Ana Dosya
 * Tüm sitemap dosyalarını listeler
 */

header('Content-Type: application/xml; charset=utf-8');

$baseUrl = 'https://ikdanismanlik.com.tr';
$today = date('Y-m-d');

echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
echo '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";

// Sitemap dosyaları
$sitemaps = [
    [
        'loc' => '/sitemap.xml.php',
        'lastmod' => $today,
        'desc' => 'Ana sayfalar ve statik içerik'
    ],
    [
        'loc' => '/sitemap-ilanlar.xml.php',
        'lastmod' => $today,
        'desc' => 'Aktif iş ilanları (günlük güncellenir)'
    ],
    [
        'loc' => '/sitemap-sehirler.xml.php',
        'lastmod' => date('Y-m-d', strtotime('-1 day')),
        'desc' => '81 il + sektör kombinasyonları (891 sayfa)'
    ]
];

// Blog varsa ekle
if (file_exists(__DIR__ . '/sitemap-blog.xml.php')) {
    $sitemaps[] = [
        'loc' => '/sitemap-blog.xml.php',
        'lastmod' => date('Y-m-d', strtotime('-7 days')),
        'desc' => 'Blog yazıları'
    ];
}

foreach ($sitemaps as $sitemap) {
    echo "  <sitemap>\n";
    echo "    <loc>{$baseUrl}{$sitemap['loc']}</loc>\n";
    echo "    <lastmod>{$sitemap['lastmod']}</lastmod>\n";
    echo "  </sitemap>\n";
}

echo '</sitemapindex>';
