if (file_exists('./google_sitemap.xsl')) {
        echo '<?xml-stylesheet type="text/xsl" href="google_sitemap.xsl"?>' . PHP_EOL;
    }
    echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
}
// Get public WB pages
// *******************
// Get all pages from db except of the module menu_link
$sql = "SELECT p.`link`, p.`modified_when`, p.`parent`, p.`position`, s.`section_id`, s.`module`\r\n\t\tFROM `" . TABLE_PREFIX . "pages` p\r\n\t\tJOIN `" . TABLE_PREFIX . "sections` s\r\n\t\tON p.`page_id` = s.`page_id`\r\n\t\tWHERE (p.`visibility` = 'public')\r\n\t\t\tAND s.`module` != 'menu_link'\r\n\t\t\tAND (s.`publ_start` = '0' OR s.`publ_start` <= {$ts})\r\n\t\t\tAND (s.`publ_end` = '0' OR s.`publ_end` >= {$ts})\r\n\t\tORDER BY p.`parent`, p.`position` ASC";
$result = $database->query($sql);
// Loop through the pages
if ($result && $result->numRows() > 0) {
    while ($page = $result->fetchRow()) {
        $checked = check_link($page['link'], $exclude);
        if ($checked === true) {
            $link = htmlspecialchars($wb->page_link($page['link']));
            $lastmod = gmdate("Y-m-d", $page['modified_when'] + TIMEZONE);
            $freq = $page_frequency;
            $pri = $page_priority;
            if ($page['parent'] == 0) {
                if ($page['position'] == 1) {
                    $pri = $page_home_priority;
                    // Should be the homepage
                    $link = WB_URL . '/';
                } else {
                    $pri = $page_root_priority;
                    // Root level pages
                }
            }
            output_xml($link, $lastmod, $freq, $pri);
            $counter++;