Writes the given sitemap to the filesystem.  The filename pattern is:
{MD5_Hash}.{Class_Name}.{Index}.xml
@param string          $groupName
@param AbstractSitemap $sitemap
@return string The filename of the sitemap written
547634
protected function writeSitemap($groupName, AbstractSitemap $sitemap)
    {
        static $index = 0;

        $className = (new \ReflectionClass($sitemap))->getShortName();
        $fileName = "{$groupName}.{$className}.{$index}.xml";
        $this->filesystem->write($fileName, $sitemap->toString());
        array_push($this->filesCreated, $fileName);
        $index++;

        return $fileName;
    }
976149
private JCheckBox getChkParseSitemapXml() {
		if (parseSitemapXml == null) {
			parseSitemapXml = new JCheckBox();
			parseSitemapXml.setText(Constant.messages.getString("spider.options.label.sitemapxml"));
		}
		return parseSitemapXml;
	}
110391
def read_component_sitemap(
            self, sitemapindex_uri, sitemap_uri, sitemap, sitemapindex_is_file):
        
        if (sitemapindex_is_file):
            if (not self.is_file_uri(sitemap_uri)):
                # Attempt to map URI to local file
                remote_uri = sitemap_uri
                sitemap_uri = self.mapper.src_to_dst(remote_uri)
                self.logger.info(
                    "Mapped %s to local file %s" %
                    (remote_uri, sitemap_uri))
            else:
                # The individual sitemaps should be at a URL (scheme/server/path)
                # that the sitemapindex URL can speak authoritatively about
                if (self.check_url_authority and
                        not UrlAuthority(sitemapindex_uri).has_authority_over(sitemap_uri)):
                    raise ListBaseIndexError(
                        "The sitemapindex (%s) refers to sitemap at a location it does not have authority over (%s)" %
                        (sitemapindex_uri, sitemap_uri))
        try:
            fh = URLopener().open(sitemap_uri)
            self.num_files += 1
        except IOError as e:
            raise ListBaseIndexError(
                "Failed to load sitemap from %s listed in sitemap index %s (%s)" %
                (sitemap_uri, sitemapindex_uri, str(e)))
        # Get the Content-Length if we can (works fine for local files)
        try:
            self.content_length = int(fh.info()['Content-Length'])
            self.bytes_read += self.content_length
        except KeyError:
            # If we don't get a length then c'est la vie
            pass
        self.logger.info(
            "Reading sitemap from %s (%d bytes)" %
            (sitemap_uri, self.content_length))
        component = sitemap.parse_xml(fh=fh, sitemapindex=False)
        # Copy resources into self, check any metadata
        for r in component:
            self.resources.add(r)
1048880
private function dumpProviderSitemap($alias, PortalInformation $portalInformation, $scheme)
    {
        $maxPage = $this->sitemapProviderPool->getProvider($alias)->getMaxPage();
        for ($page = 1; $page <= $maxPage; ++$page) {
            $sitemap = $this->sitemapRenderer->renderSitemap(
                $alias,
                $page,
                $portalInformation->getLocale(),
                $portalInformation->getPortal(),
                $portalInformation->getHost(),
                $scheme
            );

            $this->dumpFile(
                $this->getDumpPath(
                    $scheme,
                    $portalInformation->getWebspaceKey(),
                    $portalInformation->getLocale(),
                    $portalInformation->getHost(),
                    $alias,
                    $page
                ),
                $sitemap
            );
        }
    }
1166213
function recursive_groups($group, $cache_only = FALSE) {
        $this->_debug_message = "";
        $this->_warning_message = "";
        if ($group==NULL){ return (false); }

        $ret_groups=array();
        $ret_data = FALSE;

/*
    echo "DEBUG GROUP is group $group in cache ?\n";
    print_r($this->_cache_recursive_groups);
*/

        clearstatcache();
        
		if ($this->_cache_support) {
            if ("" != $this->get_cache_folder()) {
                if (file_exists($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache")) {
                    if ((filemtime($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache") + $this->get_cache_timeout()) > time()) {
                        if ($cache_handle = fopen($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache", "rb")) {
                            $ret_groups = unserialize(fgets($cache_handle));
                            $ret_data = TRUE;
                            fclose($cache_handle);
                            @touch($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache");
                        }
                    }
                }
            } elseif (isset($this->_cache_recursive_groups[$group])) {
                $ret_groups = $this->_cache_recursive_groups[$group];
                $ret_data = TRUE;
            }
        }

    	if (!$ret_data) {
            if (!$cache_only) {
    			$groups=$this->group_info($group,array($this->_group_attribute));
    			
    			// Additional test by SysCo/al
    			if (isset($groups[0][$this->_group_attribute]))
    			{
    				$groups=$groups[0][$this->_group_attribute];

    				if ($groups){
    					$group_names=$this->nice_names($groups);

    					$ret_groups=array_merge($ret_groups,$group_names); //final groups to return
    					
    					foreach ($group_names as $id => $group_name){
    						$child_groups=$this->recursive_groups($group_name);
    						$ret_groups=array_merge($ret_groups,$child_groups);
    					}
    				}
    			}
    			if ($this->_cache_support) {
                    if ("" != $this->get_cache_folder()) {
                        if (file_exists($this->get_cache_folder())) {
                            if ($cache_handle = fopen($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache", "wb")) {
                                fwrite($cache_handle, serialize($ret_groups));
                                fclose($cache_handle);
                                @chmod($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache", octdec($this->_linux_file_mode));
                            }
                        }
                    } else {
        				$this->_cache_recursive_groups[$group] = $ret_groups;
                    }
    			}
            } else {
                $this->_debug_message = "The requested group $group is not in cache.";
            }
        }
        return ($ret_groups);
    }
674179
function getSitesHtml(sites, groupsize) {
  var html = '';
  var groupsize = getType(groupsize) === 'number' && groupsize !== 0 ? groupsize : 0;
  for (var i = 0, length = sites.length; i < length; i++) {
    if (groupsize && i % groupsize === 0) {
      html += '<div class="soshm-group group' + ((i / groupsize) + 1) + '">';
    }

    var key = sites[i];
    var siteObj = sitesObj[key];
    if (siteObj) {
      html += templateStr.
        replace(/\{\{site\}\}/g, key)
        .replace(/\{\{icon\}\}/g, siteObj.icon)
        .replace(/\{\{name\}\}/g, siteObj.name);
    } else {
      console.warn('site [' + key + '] not exist.');
    }

    if (groupsize && (i % groupsize === groupsize - 1 || i === length - 1)) {
      html += '</div>';
    }
  }
  return html;
}
1078750
public function createHashFileName(string $filename, string $extension = '.php'): string
    {
        return sprintf('%s%s', hash('sha256', $filename, false), $extension);
    }
534688
function _setFileName($id, $group)
    {
        
        if ($this->_fileNameProtection) {
            $suffix = 'cache_'.md5($group).'_'.md5($id);
        } else {
            $suffix = 'cache_'.$group.'_'.$id;
        }
        $root = $this->_cacheDir;
        if ($this->_hashedDirectoryLevel>0) {
            $hash = md5($suffix);
            for ($i=0 ; $i<$this->_hashedDirectoryLevel ; $i++) {
                $root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
            }   
        }
        $this->_fileName = $suffix;
        $this->_file = $root.$suffix;
    }
712156
public function save($targetDir, $gzip = false)
    {
        $this->initializeFileHandler();
        $filename = realpath($targetDir) . '/' . basename($this->getLoc());
        $sitemapFile = fopen($filename, 'w+');
        $structureXml = $this->getStructureXml();

        // since header may contain namespaces which may get added when adding URLs
        // we can't prepare the header beforehand, so here we just take it and add to the beginning of the file
        $header = substr($structureXml, 0, strpos($structureXml, 'URLS</urlset>'));
        fwrite($sitemapFile, $header);

        // append body file to sitemap file (after the header)
        fflush($this->bodyFile);
        fseek($this->bodyFile, 0);

        while (!feof($this->bodyFile)) {
            fwrite($sitemapFile, fread($this->bodyFile, 65536));
        }
        fwrite($sitemapFile, '</urlset>');

        $streamInfo = stream_get_meta_data($this->bodyFile);
        fclose($this->bodyFile);
        // removing temporary file
        unlink($streamInfo['uri']);

        if ($gzip) {
            $this->loc .= '.gz';
            $filenameGz = $filename . '.gz';
            fseek($sitemapFile, 0);
            $sitemapFileGz = gzopen($filenameGz, 'wb9');
            while (!feof($sitemapFile)) {
                gzwrite($sitemapFileGz, fread($sitemapFile, 65536));
            }
            gzclose($sitemapFileGz);
        }

        fclose($sitemapFile);
        if ($gzip) {
            unlink($filename);
        }
    }
796800
protected function createOutputPlaceholderFile()
    {
        $filePath = $this->getFullFilePath();

        if (true === \file_exists($filePath)) {
            throw new SitemapException(
                \sprintf('Cannot create sitemap. File \'%s\' already exists.', $filePath)
            );
        }

        return \touch($filePath);
    }
21681
public function write(SitemapIndexInterface $sitemapIndex, \XMLWriter $xmlWriter = null)
    {
        $xmlWriter = $xmlWriter ?: new \XMLWriter();

        $xmlWriter->openMemory();
        $xmlWriter->startDocument('1.0', 'UTF-8');

        $xmlWriter->startElement('sitemapindex');
        $xmlWriter->writeAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');

        foreach ($sitemapIndex->sitemaps() as $sitemap) {
            $this->sitemapWriter->write($sitemap, $xmlWriter);
        }

        $xmlWriter->endElement();

        $xmlWriter->endDocument();

        return $xmlWriter->outputMemory();
    }
1241845
private function sendSitemap(): void
    {
        $this->addUrl(hu);

        $rs = safe_rows_start(
            'name',
            'txp_section',
            "name != 'default' and rah_sitemap_include_in = 1 order by name asc"
        );

        if ($rs) {
            while ($a = nextRow($rs)) {
                $this->addUrl(pagelinkurl(['s' => $a['name']]));
            }
        }

        $rs = safe_rows_start(
            'name, type',
            'txp_category',
            "name != 'root' and rah_sitemap_include_in = 1 order by name asc"
        );

        if ($rs) {
            while ($a = nextRow($rs)) {
                $this->addUrl(pagelinkurl([
                    'c' => $a['name'],
                    'context' => $a['type'],
                ]));
            }
        }

        $sql = ['Status >= 4'];

        foreach (do_list(get_pref('rah_sitemap_exclude_fields')) as $field) {
            if ($field) {
                $f = explode(':', $field);
                $n = strtolower(trim($f[0]));

                if (isset($this->articleFields[$n])) {
                    $sql[] = $this->articleFields[$n]." NOT LIKE '".doSlash(trim(implode(':', array_slice($f, 1))))."'";
                }
            }
        }

        if (get_pref('rah_sitemap_exclude_sticky_articles')) {
            $sql[] = 'Status != 5';
        }

        if (!get_pref('rah_sitemap_future_articles')) {
            $sql[] = 'Posted <= now()';
        }

        if (!get_pref('rah_sitemap_past_articles')) {
            $sql[] = 'Posted >= now()';
        }

        if (!get_pref('rah_sitemap_expired_articles')) {
            $sql[] = "(Expires = ".NULLDATETIME." or Expires >= now())";
        }

        $rs = safe_rows_start(
            '*, unix_timestamp(Posted) as posted, unix_timestamp(LastMod) as uLastMod',
            'textpattern',
            implode(' and ', $sql) . ' order by Posted desc'
        );

        if ($rs) {
            while ($a = nextRow($rs)) {
                $this->addUrl(permlinkurl($a), (int) max($a['uLastMod'], $a['posted']));
            }
        }

        foreach (do_list(get_pref('rah_sitemap_urls')) as $url) {
            if ($url) {
                $this->addUrl($url);
            }
        }

        $urlset = [];
        callback_event_ref('rah_sitemap.urlset', '', 0, $urlset);

        if ($urlset && is_array($urlset)) {
            foreach ($urlset as $url => $lastmod) {
                $this->addUrl($url, $lastmod);
            }
        }

        $xml =
            '<?xml version="1.0" encoding="utf-8"?>'.
            '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'.
            implode('', array_slice($this->addUrlset, 0, self::URL_LIMIT)).
            '</urlset>';

        ob_clean();
        txp_status_header('200 OK');
        header('Content-type: text/xml; charset=utf-8');

        if (get_pref('rah_sitemap_compress') &&
            strpos(serverSet('HTTP_ACCEPT_ENCODING'), 'gzip') !== false
        ) {
            header('Content-Encoding: gzip');
            $xml = gzencode($xml);
        }

        echo $xml;
        exit;
    }
78013
public function add( SiteMapUrl $sitemap )
    {
        $key           = $this->key();
        $this->nodes[] = $sitemap;
        $this->next();

        return $key;
    }
1369260
protected function deleteExistingSitemaps($targetDir)
    {
        foreach ($this->urlsets as $urlset) {
            $basename = basename($urlset->getLoc());
            if (preg_match('/(.*)_[\d]+\.xml(?:\.gz)?$/', $basename)) {
                continue; // skip numbered files
            }
            // pattern is base name of sitemap file (with .xml cut) optionally followed by _X for numbered files
            $basename = preg_replace('/\.xml(?:\.gz)?$/', '', $basename); // cut .xml|.xml.gz
            $pattern = '/' . preg_quote($basename, '/') . '(_\d+)?\.xml(?:\.gz)?$/';
            foreach (Finder::create()->in($targetDir)->depth(0)->name($pattern)->files() as $file) {
                $this->filesystem->remove($file);
            }
        }
    }
711432
protected function createSitemapPage()
    {
        $ret = '<?xml version="1.0" encoding="UTF-8"?>';
        $ret .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"';
        $ret .= ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"';
        $ret .= ' xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9';
        $ret .= ' http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">';

        $pagePriorityDefaultValue     = (float)GeneralUtility::getRootSettingValue('sitemap_priority', 0);
        $pagePriorityDepthMultiplier  = (float)GeneralUtility::getRootSettingValue(
            'sitemap_priority_depth_multiplier',
            0
        );
        $pagePriorityDepthModificator = (float)GeneralUtility::getRootSettingValue(
            'sitemap_priority_depth_modificator',
            0
        );

        if ($pagePriorityDefaultValue == 0) {
            $pagePriorityDefaultValue = 1;
        }

        if ($pagePriorityDepthMultiplier == 0) {
            $pagePriorityDepthMultiplier = 1;
        }

        if ($pagePriorityDepthModificator == 0) {
            $pagePriorityDepthModificator = 1;
        }


        // #####################
        // SetupTS conf
        // #####################

        foreach ($this->sitemapPages as $sitemapPage) {
            if (empty($this->pages[$sitemapPage['page_uid']])) {
                // invalid page
                continue;
            }

            $page = $this->pages[$sitemapPage['page_uid']];

            // #####################################
            // Page priority
            // #####################################
            $pageDepth     = $sitemapPage['page_depth'];
            $pageDepthBase = 1;

            if (!empty($sitemapPage['page_hash'])) {
                // page has module-content - trade as subpage
                ++$pageDepth;
            }

            $pageDepth -= $pagePriorityDepthModificator;


            if ($pageDepth > 0.1) {
                $pageDepthBase = 1 / $pageDepth;
            }

            $pagePriority = $pagePriorityDefaultValue * ($pageDepthBase * $pagePriorityDepthMultiplier);
            if (!empty($page['tx_metaseo_priority'])) {
                $pagePriority = $page['tx_metaseo_priority'] / 100;
            }

            $pagePriority = number_format($pagePriority, 2);

            if ($pagePriority > 1) {
                $pagePriority = '1.00';
            } elseif ($pagePriority <= 0) {
                $pagePriority = '0.00';
            }

            // #####################################
            // Page information
            // #####################################

            // page Url
            $pageUrl = GeneralUtility::fullUrl($sitemapPage['page_url']);

            // Page modification date
            $pageModificationDate = date('c', $sitemapPage['tstamp']);

            // Page change frequency
            $pageChangeFrequency = null;
            if (!empty($page['tx_metaseo_change_frequency'])) {
                // from page
                $pageChangeFrequency = (int)$page['tx_metaseo_change_frequency'];
            } elseif (!empty($sitemapPage['page_change_frequency'])) {
                // from sitemap settings
                $pageChangeFrequency = (int)$sitemapPage['page_change_frequency'];
            } elseif (!empty($this->tsSetup['changeFrequency'])) {
                // default from SetupTS
                $pageChangeFrequency = (int)$this->tsSetup['changeFrequency'];
            }

            // translate change frequency
            if (!empty($pageChangeFrequency) && !empty($this->pageChangeFrequency[$pageChangeFrequency])) {
                $pageChangeFrequency = $this->pageChangeFrequency[$pageChangeFrequency];
            } else {
                $pageChangeFrequency = null;
            }

            // #####################################
            // Sitemal page output
            // #####################################
            $ret .= '<url>';
            $ret .= '<loc>' . htmlspecialchars($pageUrl) . '</loc>';

            if ($this->tsSetup['enableLastMod']) {
                $ret .= '<lastmod>' . $pageModificationDate . '</lastmod>';
            }

            if (!empty($pageChangeFrequency)) {
                $ret .= '<changefreq>' . htmlspecialchars($pageChangeFrequency) . '</changefreq>';
            }

            if ($this->tsSetup['enablePriority']) {
                $ret .= '<priority>' . $pagePriority . '</priority>';
            }

            $ret .= '</url>';
        }


        $ret .= '</urlset>';

        // Call hook
        GeneralUtility::callHookAndSignal(__CLASS__, 'sitemapXmlPageOutput', $this, $ret);

        return $ret;
    }
422534
public function sitemap()
    {
        //Checks if the sitemap exist and is not expired
        if (is_readable(SITEMAP)) {
            $time = Time::createFromTimestamp(filemtime(SITEMAP));

            if (!$time->modify(getConfigOrFail('main.sitemap_expiration'))->isPast()) {
                $sitemap = file_get_contents(SITEMAP);
            }
        }

        if (empty($sitemap)) {
            $sitemap = gzencode(Sitemap::generate(), 9);

            (new File(SITEMAP, true, 0777))->write($sitemap);
        }

        return $this->response->withFile(SITEMAP);
    }
465576
public function getSiteMap()
    {
        $sitemap = $this->getCacheItem('site-map');

        if (null === $sitemap) {
            /* @var $menuService MenuService */
            $menuService = $this->getService(MenuService::class);

            $navigation = $menuService->getPages();

            $argv = $this->prepareEventArguments(compact('navigation'));
            $this->getEventManager()->trigger('uthando.site-map', $this, $argv);

            $sitemap = $this->getService('ViewHelperManager')
                ->get(Navigation::class)
                ->setRole('guest')
                ->sitemap($navigation)
                ->render();

            $this->setCacheItem('site-map', $sitemap);
        }

        return $sitemap;
    }