<?php
/**
 * 9K CLUB - XML Sitemap
 * Dynamic sitemap generator with caching
 */

// Include configuration
require_once dirname(__FILE__) . '/includes/config.php';

// Set content type to XML
header('Content-Type: application/xml; charset=utf-8');

// Enable caching
$cacheFile = CACHE_PATH . '/sitemap.xml';
$cacheTime = 86400; // 24 hours

// Check if cache exists and is valid
if (CACHE_ENABLED && file_exists($cacheFile) && (time() - filemtime($cacheFile) < $cacheTime)) {
    readfile($cacheFile);
    exit;
}

// Generate sitemap
$sitemap = generateSitemap();

// Save to cache
if (CACHE_ENABLED) {
    file_put_contents($cacheFile, $sitemap);
}

// Output sitemap
echo $sitemap;
?>