<?php
    include '_ntv/db.php';
    $statement = $mysqli->prepare("
        select 't' as page, team_uid as uid
        from team
        union all
        select 's' as page, sting_uid as uid
        from sting
        ");
    $statement->execute();
    $result = $statement->get_result();
    header('Content-Type: application/xml');
    print '<?xml version="1.0" encoding="UTF-8"?>';
    print "\r\n";
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url>
        <loc>https://www.nonce.tv/</loc>
        <changefreq>always</changefreq>
    </url>
    <url>
        <loc>https://www.nonce.tv/?p=stings</loc>
        <changefreq>always</changefreq>
    </url>
    <url>
        <loc>https://www.nonce.tv/?p=teams</loc>
        <changefreq>always</changefreq>
    </url>
    <url>
        <loc>https://www.nonce.tv/?p=stats</loc>
        <changefreq>always</changefreq>
    </url>
<?php
    foreach($result as $d) {
        $page = $d['page'];
        $uid = $d['uid'];
        switch ($d['page']) {
            case 't': 
                $changefreq = 'daily';
                break;
            case 's': 
                $changefreq = 'monthly';
                break;
            case '':
            default:
                $changefreq = 'never';
                break;
        }
        print "
    <url>
        <loc>https://www.nonce.tv/p=$page&amp;u=$uid</loc>
        <changefreq>$changefreq</changefreq>
    </url>";
    }
?>
</urlset>