<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php
// sitemap.xml - Dynamic sitemap for SEO
$csv = fopen('farmaciasout.csv', 'r');
$header = null;
$count = 0;
$max = 1000; // For demo, limit to 1000 pharmacies
while (($row = fgetcsv($csv)) !== false) {
    if (!$header) { $header = $row; continue; }
    $pharmacy = array_combine($header, $row);
    $id = urlencode($pharmacy['input_id']);
    $url = 'https://' . $_SERVER['HTTP_HOST'] . '/farmacia.php?id=' . $id;
    echo "  <url>\n    <loc>$url</loc>\n    <changefreq>monthly</changefreq>\n    <priority>0.8</priority>\n  </url>\n";
    $count++;
    if ($count >= $max) break;
}
fclose($csv);
?>
</urlset>
