<?php
/**
 * Dynamic XML Sitemap Generator
 * Generates sitemap for all pages on the site
 */
header('Content-Type: application/xml; charset=utf-8');

$base_url = 'http://closercade.com';
$current_date = date('Y-m-d');

// Define all pages with their priority and change frequency
$pages = [
    // Main pages (high priority)
    ['url' => '/', 'priority' => '1.0', 'changefreq' => 'weekly', 'lastmod' => $current_date],
    ['url' => '/index.php', 'priority' => '1.0', 'changefreq' => 'weekly', 'lastmod' => $current_date],
    ['url' => '/register-roleplay.php', 'priority' => '0.9', 'changefreq' => 'monthly', 'lastmod' => $current_date],
    ['url' => '/demo-roleplay.php', 'priority' => '0.9', 'changefreq' => 'monthly', 'lastmod' => $current_date],
    ['url' => '/login.php', 'priority' => '0.8', 'changefreq' => 'monthly', 'lastmod' => $current_date],
    
    // Content pages (medium priority)
    ['url' => '/about-us.php', 'priority' => '0.8', 'changefreq' => 'monthly', 'lastmod' => $current_date],
    ['url' => '/careers.php', 'priority' => '0.7', 'changefreq' => 'monthly', 'lastmod' => $current_date],
    ['url' => '/press.php', 'priority' => '0.7', 'changefreq' => 'monthly', 'lastmod' => $current_date],
    
    // Legal pages (lower priority)
    ['url' => '/privacy-policy.php', 'priority' => '0.5', 'changefreq' => 'yearly', 'lastmod' => $current_date],
    ['url' => '/terms-of-service.php', 'priority' => '0.5', 'changefreq' => 'yearly', 'lastmod' => $current_date],
    ['url' => '/cookie-policy.php', 'priority' => '0.5', 'changefreq' => 'yearly', 'lastmod' => $current_date],
];

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

foreach ($pages as $page) {
    echo "  <url>\n";
    echo "    <loc>" . htmlspecialchars($base_url . $page['url']) . "</loc>\n";
    echo "    <lastmod>" . htmlspecialchars($page['lastmod']) . "</lastmod>\n";
    echo "    <changefreq>" . htmlspecialchars($page['changefreq']) . "</changefreq>\n";
    echo "    <priority>" . htmlspecialchars($page['priority']) . "</priority>\n";
    echo "  </url>\n";
}

echo '</urlset>';
?>
