<?php
    require './core/core.php';
    require './scripts/functions.php';
    header('content-type: text/xml');
    echo '<?xml version="1.0" encoding="UTF-8"?>'; echo "\r\n";
    echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';  echo "\r\n";
    $request = $db->prepare('SELECT `id` FROM ' . DB_PREFIX . '_map WHERE `deleted`=0 and `hidden`=0 and `system`=0  and `access`=1');
    $request->execute();    
    $urls = $request->fetchAll(PDO::FETCH_ASSOC);   
    foreach($urls as $url){
        $current_url = GetURL($url['id']);
        if($current_url == '/404/') continue;
        if($current_url == '/index/') $current_url = '/';
        echo "\t";
        echo '<url>';
        echo '<loc>http://'.$_SERVER['HTTP_HOST'].$current_url.'</loc>';
        echo '</url>'; 
        echo "\r\n";
    }
    echo '</urlset>'; echo "\r\n";
?>

