<?php
/**
 * DYNAMIC XML SITEMAP GENERATOR
 * File: sitemap.php
 */

// Set proper XML content type header
header("Content-Type: application/xml; charset=utf-8");

require_once "config/database.php";

$baseUrl = "https://micromagic.in";

// Array of public static pages with their priority and change frequency
$pages = [
    ['loc' => '/',               'priority' => '1.0', 'changefreq' => 'daily'],
    ['loc' => '/index.php',       'priority' => '1.0', 'changefreq' => 'daily'],
    ['loc' => '/games.php',       'priority' => '0.9', 'changefreq' => 'weekly'],
    ['loc' => '/stories.php',     'priority' => '0.9', 'changefreq' => 'weekly'],
    ['loc' => '/study.php',       'priority' => '0.8', 'changefreq' => 'weekly'],
    ['loc' => '/activities.php',  'priority' => '0.8', 'changefreq' => 'weekly'],
    ['loc' => '/shop.php',        'priority' => '0.8', 'changefreq' => 'daily'],
    ['loc' => '/quiz.php',        'priority' => '0.7', 'changefreq' => 'weekly'],
    ['loc' => '/poems.php',       'priority' => '0.7', 'changefreq' => 'monthly'],
    ['loc' => '/why-zone.php',    'priority' => '0.7', 'changefreq' => 'monthly'],
    ['loc' => '/stickers.php',    'priority' => '0.6', 'changefreq' => 'monthly'],
    ['loc' => '/contact.php',     'priority' => '0.5', 'changefreq' => 'monthly'],
];

echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    
    <?php foreach ($pages as $page): ?>
    <url>
        <loc><?= $baseUrl . $page['loc'] ?></loc>
        <lastmod><?= date('Y-m-d') ?></lastmod>
        <changefreq><?= $page['changefreq'] ?></changefreq>
        <priority><?= $page['priority'] ?></priority>
    </url>
    <?php endforeach; ?>

</urlset>