<?php
ob_start();
error_reporting(0);

header('Content-Type: application/xml; charset=UTF-8');

$base_url = "https://smartstudyweb.com";

$posts = [];
if (file_exists(__DIR__ . '/data/posts.php')) {
    require __DIR__ . '/data/posts.php';
}

echo '<?xml version="1.0" encoding="UTF-8"?>';
?>

<urlset 
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">

  <url>
    <loc><?= $base_url ?>/</loc>
    <lastmod><?= date('c') ?></lastmod>
    <changefreq>daily</changefreq>
    <priority>1.0</priority>
  </url>

<?php if (!empty($posts) && is_array($posts)): ?>
<?php foreach ($posts as $post): ?>
<?php 
    if (empty($post['slug'])) continue;
    $slug = htmlspecialchars($post['slug'], ENT_XML1, 'UTF-8');
    $lastmod = !empty($post['date']) ? date('c', strtotime($post['date'])) : date('c');
?>

  <url>
    <loc><?= $base_url ?>/<?= $slug ?>.html</loc>
    <lastmod><?= $lastmod ?></lastmod>
    <changefreq>daily</changefreq>
    <priority>0.8</priority>
  </url>

  <url>
    <loc><?= $base_url ?>/amp/<?= $slug ?>.html</loc>
    <lastmod><?= $lastmod ?></lastmod>
    <changefreq>daily</changefreq>
    <priority>0.6</priority>
  </url>
  
  <url>
<loc>https://smartstudyweb.com/mbbs-admission-india.html</loc>
</url>
 <url>
<loc>https://smartstudyweb.com/fmge-exam-india-eligibility.html</loc>
</url>
<url>
<loc>https://smartstudyweb.com/mbbs/mbbs-admission-in-india.html</loc>
</url>


<?php endforeach; ?>
<?php endif; ?>

</urlset>
<?php ob_end_flush(); ?>
