<?php
ob_clean();
header("Content-Type: application/xml; charset=UTF-8");

$domain = 'https://iniprimbons.com';

$sitemaps = [
    'sitemap-konsultasi.php',
    'sitemap-artimimpi.php',
    'sitemap-artinama.php',
    'sitemap-ramalanharian.php',
    'sitemap-ramalanjodoh.php'
];

echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
echo '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL;

foreach ($sitemaps as $file) {

    $path = __DIR__ . '/' . $file;

    if (file_exists($path)) {
        $lastmod = date('Y-m-d', filemtime($path));
    } else {
        $lastmod = date('Y-m-d');
    }

    echo "<sitemap>\n";
    echo "<loc>$domain/$file</loc>\n";
    echo "<lastmod>$lastmod</lastmod>\n";
    echo "</sitemap>\n";
}

echo '</sitemapindex>';
exit;
?>