<?php
// Generar sitemap dinámicamente
header('Content-Type: application/xml; charset=utf-8');

$current_date = date('Y-m-d');
$base_url = 'https://anonymscout.com';
$base_path = __DIR__;

// Obtener fecha de modificación de archivos
function getFileModDate($file, $base_path) {
    $path = $base_path . '/' . $file;
    return file_exists($path) ? date('Y-m-d', filemtime($path)) : date('Y-m-d');
}
?>
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
        xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
        http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
    
    <!-- Homepage -->
    <url>
        <loc><?php echo $base_url; ?>/</loc>
        <lastmod><?php echo getFileModDate('index.php', $base_path); ?></lastmod>
        <changefreq>weekly</changefreq>
        <priority>1.0</priority>
    </url>
    
    <!-- URLs amigables principales -->
    <url>
        <loc><?php echo $base_url; ?>/acerca-de</loc>
        <lastmod><?php echo getFileModDate('about.php', $base_path); ?></lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
    </url>
    
    <url>
        <loc><?php echo $base_url; ?>/contacto</loc>
        <lastmod><?php echo getFileModDate('contact.php', $base_path); ?></lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.7</priority>
    </url>
    
    <url>
        <loc><?php echo $base_url; ?>/precios</loc>
        <lastmod><?php echo getFileModDate('pricing.php', $base_path); ?></lastmod>
        <changefreq>weekly</changefreq>
        <priority>0.9</priority>
    </url>
    
    <url>
        <loc><?php echo $base_url; ?>/como-funciona</loc>
        <lastmod><?php echo getFileModDate('how-it-works.php', $base_path); ?></lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
    </url>
    
    <url>
        <loc><?php echo $base_url; ?>/preguntas-frecuentes</loc>
        <lastmod><?php echo getFileModDate('faq.php', $base_path); ?></lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
    </url>
    
    <url>
        <loc><?php echo $base_url; ?>/requisitos-scout</loc>
        <lastmod><?php echo getFileModDate('scout-requirements.php', $base_path); ?></lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.7</priority>
    </url>
    
    <!-- Páginas de registro y acceso -->
    <url>
        <loc><?php echo $base_url; ?>/registro</loc>
        <lastmod><?php echo getFileModDate('register.php', $base_path); ?></lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.6</priority>
    </url>
    
    <url>
        <loc><?php echo $base_url; ?>/iniciar-sesion</loc>
        <lastmod><?php echo getFileModDate('login.php', $base_path); ?></lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.5</priority>
    </url>
    
    <!-- Páginas legales -->
    <url>
        <loc><?php echo $base_url; ?>/privacidad</loc>
        <lastmod><?php echo getFileModDate('privacy.php', $base_path); ?></lastmod>
        <changefreq>yearly</changefreq>
        <priority>0.3</priority>
    </url>
    
    <url>
        <loc><?php echo $base_url; ?>/terminos</loc>
        <lastmod><?php echo getFileModDate('terms.php', $base_path); ?></lastmod>
        <changefreq>yearly</changefreq>
        <priority>0.3</priority>
    </url>
    
    <url>
        <loc><?php echo $base_url; ?>/cookies</loc>
        <lastmod><?php echo getFileModDate('cookies.php', $base_path); ?></lastmod>
        <changefreq>yearly</changefreq>
        <priority>0.3</priority>
    </url>
    
</urlset>

