<?php
// sitemap.xml.php
require_once 'includes/config.php';
header("Content-Type: application/xml; charset=utf-8");

echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';

// Add Home Page
echo '<url><loc>https://adliko.com/</loc><changefreq>daily</changefreq><priority>1.0</priority></url>';

// Add Categories from DB
$stmt = $conn->query("SELECT slug FROM categories");
while ($row = $stmt->fetch()) {
    echo '<url><loc>https://adliko.com/category.php?slug='.$row['slug'].'</loc><changefreq>weekly</changefreq><priority>0.7</priority></url>';
}

// Add Images from DB
$stmt = $conn->query("SELECT id FROM images");
while ($row = $stmt->fetch()) {
    echo '<url><loc>https://adliko.com/index.php?id='.$row['id'].'</loc><changefreq>weekly</changefreq><priority>0.5</priority></url>';
}

echo '</urlset>';
?>