/** * Handle sitemap delivery * * @author Michael Hamann <*****@*****.**> */ function act_sitemap($act) { global $conf; if ($conf['sitemap'] < 1 || !is_numeric($conf['sitemap'])) { header("HTTP/1.0 404 Not Found"); print "Sitemap generation is disabled."; exit; } $sitemap = Sitemapper::getFilePath(); if (strrchr($sitemap, '.') === '.gz') { $mime = 'application/x-gzip'; } else { $mime = 'application/xml; charset=utf-8'; } // Check if sitemap file exists, otherwise create it if (!is_readable($sitemap)) { Sitemapper::generate(); } if (is_readable($sitemap)) { // Send headers header('Content-Type: ' . $mime); header('Content-Disposition: attachment; filename=' . basename($sitemap)); http_conditionalRequest(filemtime($sitemap)); // Send file //use x-sendfile header to pass the delivery to compatible webservers if (http_sendfile($sitemap)) { exit; } readfile($sitemap); exit; } header("HTTP/1.0 500 Internal Server Error"); print "Could not read the sitemap file - bad permissions?"; exit; }
/** * Builds a Google Sitemap of all public pages known to the indexer * * The map is placed in the root directory named sitemap.xml.gz - This * file needs to be writable! * * @author Andreas Gohr * @link https://www.google.com/webmasters/sitemaps/docs/en/about.html */ function runSitemapper() { print "runSitemapper(): started" . NL; $result = Sitemapper::generate() && Sitemapper::pingSearchEngines(); print 'runSitemapper(): finished' . NL; return $result; }
/** * Handle sitemap delivery * * @author Michael Hamann <*****@*****.**> * * @param string $act action command */ function act_sitemap($act) { global $conf; if ($conf['sitemap'] < 1 || !is_numeric($conf['sitemap'])) { http_status(404); print "Sitemap generation is disabled."; exit; } $sitemap = Sitemapper::getFilePath(); if (Sitemapper::sitemapIsCompressed()) { $mime = 'application/x-gzip'; } else { $mime = 'application/xml; charset=utf-8'; } // Check if sitemap file exists, otherwise create it if (!is_readable($sitemap)) { Sitemapper::generate(); } if (is_readable($sitemap)) { // Send headers header('Content-Type: ' . $mime); header('Content-Disposition: attachment; filename=' . utf8_basename($sitemap)); http_conditionalRequest(filemtime($sitemap)); // Send file //use x-sendfile header to pass the delivery to compatible webservers http_sendfile($sitemap); readfile($sitemap); exit; } http_status(500); print "Could not read the sitemap file - bad permissions?"; exit; }