<?php
require_once 'config.php';

header("Content-Type: application/xml; charset=utf-8");


?>

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

<url>
    <loc>https://wiselyt.com/</loc>
    <priority>1.0</priority>
</url>

<url>
    <loc>https://wiselyt.com/about.php</loc>
    <priority>0.8</priority>
</url>

<url>
    <loc>https://wiselyt.com/contact.php</loc>
    <priority>0.8</priority>
</url>

<url>
    <loc>https://wiselyt.com/faq.php</loc>
    <priority>0.8</priority>
</url>

<?php
$stmt = $pdo->query("SELECT slug, updated_at FROM blog_posts WHERE status='published'");

while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
?>
<url>
    <loc>https://wiselyt.com/blog/<?php echo htmlspecialchars($row['slug']); ?></loc>
    <lastmod><?php echo date('Y-m-d', strtotime($row['updated_at'])); ?></lastmod>
    <priority>0.9</priority>
</url>
<?php } ?>

<?php
$stmt = $pdo->query("SELECT id, updated_at FROM books WHERE status='published'");

while ($book = $stmt->fetch(PDO::FETCH_ASSOC)) {
?>
<url>
    <loc>https://wiselyt.com/book-detail.php?id=<?php echo $book['id']; ?></loc>
    <lastmod><?php echo date('Y-m-d', strtotime($book['updated_at'])); ?></lastmod>
    <priority>0.8</priority>
</url>
<?php } ?>

</urlset>