/*
<?xml version="1.0" encoding="UTF-8"?>
   <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <sitemap>
      <loc>http://www.example.com/sitemap1.xml.gz</loc>
      <lastmod>2004-10-01T18:23:17+00:00</lastmod>
   </sitemap>
   <sitemap>
      <loc>http://www.example.com/sitemap2.xml.gz</loc>
      <lastmod>2005-01-01</lastmod>
   </sitemap>
   </sitemapindex>
*/
if ($success && is_array($index)) {
    cw_flush('Sitemap Index');
    $_filename = cw_sitemap_name('index', false);
    if (($filename = cw_allow_file($_filename, true)) && ($file = cw_fopen($_filename, 'w', true))) {
        $xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
        $xml .= '<?xml-stylesheet type="text/xsl" href="' . $smarty->get_template_vars('SkinDir') . '/addons/sitemap_xml/style.xsl"?>' . "\n";
        $xml .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . "\n";
        $xml .= '//<![CDATA[#Generated by sitemap_xml generator by CartWorks software, http://www.cartworks.com //]]>' . "\n";
        fwrite($file, $xml);
        foreach ($index as $sitemap) {
            $xml = '<sitemap><loc>' . $sitemap . '</loc><lastmod>' . $today . '</lastmod></sitemap>' . "\n";
            fwrite($file, $xml);
        }
        fwrite($file, '</sitemapindex>');
        fclose($file);
        if ($config['sitemap_xml']['sm_pack_result'] == 'Y') {
            @unlink($filename . '.gz');
            exec("gzip --suffix .gz {$filename}");
function cw_sitemap_filename($name, $pack = true)
{
    global $app_dir;
    return $app_dir . '/' . cw_sitemap_name($name, $pack);
}