function getSitemapIndexLinks()
{
    global $_zp_gallery, $sitemap_number;
    $data = '';
    if ($sitemap_number < 2) {
        set_context(ZP_INDEX);
        $albums_per_page = getOption('albums_per_page');
        if (getOption('sitemap_galleryindex')) {
            $galleryindex_mod = _PAGE_ . '/' . getOption('sitemap_galleryindex');
            $galleryindex_nomod = 'index.php?p=' . getOption('sitemap_galleryindex') . '&amp;page=';
        } else {
            $galleryindex_mod = '';
            $galleryindex_nomod = 'index.php?page=';
        }
        $toplevelpages = getTotalPages();
        $data .= sitemap_echonl('<?xml version="1.0" encoding="UTF-8"?>');
        $data .= sitemap_echonl('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
        $sitemap_locales = generateLanguageList();
        $changefreq = sitemap_getChangefreq(getOption('sitemap_changefreq_index'));
        // normal index/homepage we need in any case always
        switch (SITEMAP_LOCALE_TYPE) {
            case 1:
                foreach ($sitemap_locales as $locale) {
                    $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . seo_locale::localePath(true, $locale) . "/</loc>\n\t\t<lastmod>" . sitemap_getISO8601Date() . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                }
                break;
            case 2:
                foreach ($sitemap_locales as $locale) {
                    $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . dynamic_locale::fullHostPath($locale) . "/</loc>\n\t\t<lastmod>" . sitemap_getISO8601Date() . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                }
                break;
            default:
                $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . FULLWEBPATH . "</loc>\n\t\t<lastmod>" . sitemap_getISO8601Date() . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                break;
        }
        // the extra ones if we have a custom gallery index
        if (getOption('sitemap_galleryindex')) {
            switch (SITEMAP_LOCALE_TYPE) {
                case 1:
                    foreach ($sitemap_locales as $locale) {
                        $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . seo_locale::localePath(true, $locale) . '/' . $galleryindex_mod . "</loc>\n\t\t<lastmod>" . sitemap_getISO8601Date() . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                    }
                    break;
                case 2:
                    foreach ($sitemap_locales as $locale) {
                        $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . rewrite_path(dynamic_locale::fullHostPath($locale) . '/' . $galleryindex_mod, dynamic_locale::fullHostPath($locale) . '/' . $galleryindex_nomod) . "</loc>\n\t\t<lastmod>" . sitemap_getISO8601Date() . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                    }
                    break;
                default:
                    $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . rewrite_path($galleryindex_mod, $galleryindex_nomod, FULLWEBPATH) . "</loc>\n\t\t<lastmod>" . sitemap_getISO8601Date() . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                    break;
            }
        }
        // print further index pages if available
        if ($toplevelpages) {
            if (getOption('sitemap_galleryindex')) {
                $galleryindex_mod = $galleryindex_mod . '/';
            } else {
                $galleryindex_mod = $galleryindex_mod . _PAGE_ . '/';
            }
            for ($x = 2; $x <= $toplevelpages; $x++) {
                switch (SITEMAP_LOCALE_TYPE) {
                    case 1:
                        foreach ($sitemap_locales as $locale) {
                            $url = seo_locale::localePath(true, $locale) . '/' . $galleryindex_mod . $x;
                            $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . sitemap_getISO8601Date() . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                        }
                        break;
                    case 2:
                        foreach ($sitemap_locales as $locale) {
                            $url = rewrite_path($galleryindex_mod . $x, $galleryindex_nomod . $x, dynamic_locale::fullHostPath($locale));
                            $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . sitemap_getISO8601Date() . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                        }
                        break;
                    default:
                        $url = rewrite_path($galleryindex_mod . $x, $galleryindex_nomod . $x, FULLWEBPATH);
                        $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . sitemap_getISO8601Date() . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                        break;
                }
            }
        }
        $data .= sitemap_echonl('</urlset>');
        // End off the <urlset> tag
        restore_context();
        return $data;
    }
    // sitemap number end
}
function getSitemapIndexLinks()
{
    global $_zp_gallery, $sitemap_number;
    $data = '';
    if ($sitemap_number < 2) {
        set_context(ZP_INDEX);
        $albums_per_page = getOption('albums_per_page');
        /* Not used right now
        		if(!empty($albumsperpage)) {
        			setOption('albums_per_page',sanitize_numeric($albumsperpage),false);
        		} else {
        			setOption('albums_per_page',$albums_per_page);
        		} */
        $toplevelpages = getTotalPages();
        $data .= sitemap_echonl('<?xml version="1.0" encoding="UTF-8"?>');
        $data .= sitemap_echonl('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
        $sitemap_locales = generateLanguageList();
        if (empty($changefreq)) {
            $changefreq = getOption('sitemap_changefreq_index');
        } else {
            $changefreq = sitemap_getChangefreq($changefreq);
        }
        if (sitemap_multilingual()) {
            foreach ($sitemap_locales as $locale) {
                $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . FULLWEBPATH . "/" . $locale . "/</loc>\n\t\t<lastmod>" . sitemap_getISO8601Date() . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
            }
        } else {
            $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . FULLWEBPATH . "</loc>\n\t\t<lastmod>" . sitemap_getISO8601Date() . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
        }
        // print further index pages if avaiable
        if ($toplevelpages) {
            for ($x = 2; $x <= $toplevelpages; $x++) {
                if (sitemap_multilingual()) {
                    foreach ($sitemap_locales as $locale) {
                        $url = FULLWEBPATH . '/' . rewrite_path($locale . '/page/' . $x, 'index.php?page=' . $x, false);
                        $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . sitemap_getISO8601Date() . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                    }
                } else {
                    $url = FULLWEBPATH . '/' . rewrite_path('page/' . $x, 'index.php?page=' . $x, false);
                    $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . sitemap_getISO8601Date() . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                }
            }
        }
        $data .= sitemap_echonl('</urlset>');
        // End off the <urlset> tag
        restore_context();
        return $data;
    }
    // sitemap number end
}