<?php
// Set header so the browser/Google sees it as XML
header("Content-Type: application/xml; charset=utf-8");
require_once 'config.php'; 

echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url><loc><?= BASE_URL ?></loc><priority>1.0</priority></url>
    <url><loc><?= BASE_URL ?>about.php</loc><priority>0.8</priority></url>
    <url><loc><?= BASE_URL ?>howitworks.php</loc><priority>0.9</priority></url>
    <url><loc><?= BASE_URL ?>contact.php</loc><priority>0.7</priority></url>
    <url><loc><?= BASE_URL ?>privacy.php</loc><priority>0.5</priority></url>

    <?php foreach ($apps as $id => $app): 
        $path = isset($app['url']) ? $app['url'] : "app.php?id=$id";
    ?>
    <url>
        <loc><?= BASE_URL . $path ?></loc>
        <changefreq>weekly</changefreq>
        <priority>0.7</priority>
    </url>
    <?php endforeach; ?>
</urlset>