<?php

header("Content-Type: application/xml; charset=UTF-8");

require_once __DIR__ . "/includes/config.php";

echo '<?xml version="1.0" encoding="UTF-8"?>';

?>

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

    <url>
        <loc>https://getonescan.com/</loc>
        <changefreq>weekly</changefreq>
        <priority>1.0</priority>
    </url>

    <url>
        <loc>https://getonescan.com/features.php</loc>
        <changefreq>monthly</changefreq>
        <priority>0.9</priority>
    </url>

    <url>
        <loc>https://getonescan.com/how-it-works.php</loc>
        <changefreq>monthly</changefreq>
        <priority>0.9</priority>
    </url>

    <url>
        <loc>https://getonescan.com/pricing.php</loc>
        <changefreq>monthly</changefreq>
        <priority>0.9</priority>
    </url>

    <url>
        <loc>https://getonescan.com/contact.php</loc>
        <changefreq>yearly</changefreq>
        <priority>0.7</priority>
    </url>

<?php

$sql = "SELECT short_code, updated_at
        FROM digital_cards
        WHERE status='active'";

$result = mysqli_query($conn, $sql);

while ($row = mysqli_fetch_assoc($result)) {

?>
    <url>
        <loc>https://getonescan.com/user/card.php?<?= htmlspecialchars($row['short_code']) ?></loc>
        <lastmod><?= date('Y-m-d', strtotime($row['updated_at'])) ?></lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
    </url>
<?php
}
?>

</urlset>