<?php
// sitemap.php — Dynamically generates XML sitemap including root, category slugs, and unique venue profile pages.
header('Content-Type: application/xml; charset=utf-8');

$eventsFile = __DIR__ . '/events.json';
$venues = [];
$categories = ['music', 'nightlife', 'karaoke', 'food', 'arts', 'community', 'business', 'family'];

if (file_exists($eventsFile)) {
    $raw = @file_get_contents($eventsFile);
    $events = json_decode($raw, true);
    if (is_array($events)) {
        foreach ($events as $ev) {
            if (!empty($ev['venue'])) {
                $vClean = trim($ev['venue']);
                if (strcasecmp($vClean, 'message for location') !== 0 && strcasecmp($vClean, 'San Antonio') !== 0) {
                    $venues[$vClean] = true;
                }
            }
        }
    }
}

$today = date('Y-m-d');

echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://phlyrr.com/</loc>
    <lastmod><?php echo $today; ?></lastmod>
    <changefreq>hourly</changefreq>
    <priority>1.0</priority>
  </url>
<?php foreach ($categories as $cat): ?>
  <url>
    <loc>https://phlyrr.com/<?php echo $cat; ?>/today</loc>
    <lastmod><?php echo $today; ?></lastmod>
    <changefreq>daily</changefreq>
    <priority>0.9</priority>
  </url>
<?php endforeach; ?>
<?php foreach (array_keys($venues) as $venueName): ?>
  <url>
    <loc>https://phlyrr.com/?venue=<?php echo urlencode($venueName); ?></loc>
    <lastmod><?php echo $today; ?></lastmod>
    <changefreq>daily</changefreq>
    <priority>0.8</priority>
  </url>
<?php endforeach; ?>
</urlset>
```
eof

### Summary of What Was Generated:
1. **`index.html`**: Completely self-contained and stable single-file web application. It now supports category slug paths (e.g. `phlyrr.com/karaoke/today`), district filters, venue profile pages, and unblocked native links.
2. **`sitemap.php`**: An automated XML sitemap generator that outputs your root URL, all category slug pages, and every unique venue directory page automatically for Google.