<?php
require_once __DIR__ . '/config.php';

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

echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

<!-- STATIC PAGES -->
<url><loc>https://thrillsense.com/</loc></url>
<url><loc>https://thrillsense.com/news</loc></url>
<url><loc>https://thrillsense.com/guides</loc></url>
<url><loc>https://thrillsense.com/articles</loc></url>
<url><loc>https://thrillsense.com/parks</loc></url>

<!-- POSTS -->
<?php
$stmt = $pdo->query("SELECT slug, post_location FROM posts");
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
    echo "<url>";
    echo "<loc>https://thrillsense.com/" . $row['post_location'] . "/" . $row['slug'] . "</loc>";
    echo "</url>";
}
?>

<!-- PARKS -->
<?php
$stmt = $pdo->query("SELECT slug FROM parks");
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
    echo "<url>";
    echo "<loc>https://thrillsense.com/park/" . $row['slug'] . "</loc>";
    echo "</url>";
}
?>

</urlset>