<?php
/**
 * Sitemap XML dinâmico
 * Gera URLs absolutas automaticamente baseado no domínio atual
 */

require_once __DIR__ . '/includes/config.php';

header('Content-Type: application/xml; charset=utf-8');

$pages = [
    [
        'url' => SITE_URL . '/',
        'lastmod' => date('Y-m-d'),
        'changefreq' => 'weekly',
        'priority' => '1.0'
    ],
    [
        'url' => SITE_URL . '/index.php',
        'lastmod' => date('Y-m-d'),
        'changefreq' => 'weekly',
        'priority' => '1.0'
    ],
    [
        'url' => SITE_URL . '/sobre.php',
        'lastmod' => date('Y-m-d'),
        'changefreq' => 'monthly',
        'priority' => '0.8'
    ],
    [
        'url' => SITE_URL . '/areas-atuacao.php',
        'lastmod' => date('Y-m-d'),
        'changefreq' => 'monthly',
        'priority' => '0.9'
    ],
    [
        'url' => SITE_URL . '/contato.php',
        'lastmod' => date('Y-m-d'),
        'changefreq' => 'monthly',
        'priority' => '0.8'
    ]
];

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

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

echo "</urlset>\n";
?>
