security update for uuid xmlsitemap file_field_path

This commit is contained in:
2018-10-13 16:01:24 +02:00
parent f7ae17e6c4
commit a163542966
109 changed files with 5458 additions and 1952 deletions

View File

@@ -5,36 +5,69 @@
* XML sitemap integration functions for xmlsitemap.module.
*/
class XMLSitemapException extends Exception {}
/**
* Class for XML Sitemap Exception.
*/
class XMLSitemapException extends Exception {
class XMLSitemapGenerationException extends XMLSitemapException {}
}
/**
* Class for XML Sitemap Generation Exception.
*/
class XMLSitemapGenerationException extends XMLSitemapException {
}
/**
* Extended class for writing XML sitemap files.
*/
class XMLSitemapWriter extends XMLWriter {
protected $uri = NULL;
protected $sitemapElementCount = 0;
protected $linkCountFlush = 500;
protected $sitemap = NULL;
/**
* Sitemap Page.
*
* @var string
*
* @codingStandardsIgnoreStart
*/
protected $sitemap_page = NULL;
/**
* Root Element.
*
* @var string.
*
* @codingStandardsIgnoreEnd
*/
protected $rootElement = 'urlset';
/**
* Constructor.
*
* @param $sitemap
* @param array $sitemap
* The sitemap array.
* @param $page
* @param string $page
* The current page of the sitemap being generated.
*
* @codingStandardsIgnoreStart
*/
function __construct(stdClass $sitemap, $page) {
public function __construct(stdClass $sitemap, $page) {
// @codingStandardsIgnoreEnd
$this->sitemap = $sitemap;
$this->sitemap_page = $page;
$this->uri = xmlsitemap_sitemap_get_file($sitemap, $page);
$this->openUri($this->uri);
}
/**
* Open URI.
*/
public function openUri($uri) {
$return = parent::openUri($uri);
if (!$return) {
@@ -43,6 +76,9 @@ class XMLSitemapWriter extends XMLWriter {
return $return;
}
/**
* Start Document.
*/
public function startDocument($version = '1.0', $encoding = 'UTF-8', $standalone = NULL) {
$this->setIndent(FALSE);
$result = parent::startDocument($version, $encoding);
@@ -56,11 +92,15 @@ class XMLSitemapWriter extends XMLWriter {
return $result;
}
/**
* Get Sitemap URL.
*/
public function getSitemapUrl($path, array $options = array()) {
global $base_url;
$options += $this->sitemap->uri['options'];
$options += array(
'absolute' => TRUE,
'base_url' => variable_get('xmlsitemap_base_url', $GLOBALS['base_url']),
'base_url' => variable_get('xmlsitemap_base_url', $base_url),
'language' => language_default(),
'alias' => TRUE,
);
@@ -72,9 +112,12 @@ class XMLSitemapWriter extends XMLWriter {
/**
* Add the XML stylesheet to the XML page.
*
* @codingStandardsIgnoreStart
*/
public function writeXSL() {
$this->writePi('xml-stylesheet', 'type="text/xsl" href="' . $this->getSitemapUrl('sitemap.xsl', array('protocol_relative' => TRUE)) . '"');
// @codingStandardsIgnoreEnd
$this->writePi('xml-stylesheet', 'type="text/xsl" href="' . $this->getSitemapUrl('sitemap.xsl', array('absolute' => FALSE)) . '"');
$this->writeRaw(PHP_EOL);
}
@@ -93,10 +136,19 @@ class XMLSitemapWriter extends XMLWriter {
return $attributes;
}
/**
* Generate XML.
*
* @codingStandardsIgnoreStart
*/
public function generateXML() {
// @codingStandardsIgnoreEnd
return xmlsitemap_generate_chunk($this->sitemap, $this, $this->sitemap_page);
}
/**
* Start Element.
*/
public function startElement($name, $root = FALSE) {
parent::startElement($name);
@@ -111,9 +163,9 @@ class XMLSitemapWriter extends XMLWriter {
/**
* Write an full XML sitemap element tag.
*
* @param $name
* @param string $name
* The element name.
* @param $element
* @param array $element
* An array of the elements properties and values.
*/
public function writeSitemapElement($name, array &$element) {
@@ -152,14 +204,26 @@ class XMLSitemapWriter extends XMLWriter {
}
}
/**
* Get URI.
*
* @codingStandardsIgnoreStart
*/
public function getURI() {
// @codingStandardsIgnoreEnd
return $this->uri;
}
/**
* Get Count Sitemap Element.
*/
public function getSitemapElementCount() {
return $this->sitemapElementCount;
}
/**
* Document.
*/
public function endDocument() {
$return = parent::endDocument();
@@ -167,22 +231,34 @@ class XMLSitemapWriter extends XMLWriter {
throw new XMLSitemapGenerationException(t('Unknown error occurred while writing to file @file.', array('@file' => $this->uri)));
}
//if (xmlsitemap_var('gz')) {
// @code
// If (xmlsitemap_var('gz')) {
// $file_gz = $file . '.gz';
// file_put_contents($file_gz, gzencode(file_get_contents($file), 9));
//}
// }
// @endcode
return $return;
}
}
/**
* XML Sitemap Index Writer.
*/
class XMLSitemapIndexWriter extends XMLSitemapWriter {
protected $rootElement = 'sitemapindex';
function __construct(stdClass $sitemap, $page = 'index') {
/**
* Construct.
*/
public function __construct(stdClass $sitemap, $page = 'index') {
parent::__construct($sitemap, 'index');
}
/**
* Get Root Attributes.
*/
public function getRootAttributes() {
$attributes['xmlns'] = 'http://www.sitemaps.org/schemas/sitemap/0.9';
if (variable_get('xmlsitemap_developer_mode', 0)) {
@@ -195,7 +271,13 @@ class XMLSitemapIndexWriter extends XMLSitemapWriter {
return $attributes;
}
/**
* Generate XML.
*
* @codingStandardsIgnoreStart
*/
public function generateXML() {
// @codingStandardsIgnoreEnd
$lastmod_format = variable_get('xmlsitemap_lastmod_format', XMLSITEMAP_LASTMOD_MEDIUM);
for ($i = 1; $i <= $this->sitemap->chunks; $i++) {
@@ -207,6 +289,7 @@ class XMLSitemapIndexWriter extends XMLSitemapWriter {
$this->writeSitemapElement('sitemap', $element);
}
}
}
/**
@@ -285,7 +368,7 @@ function xmlsitemap_xmlsitemap_sitemap_operations() {
/**
* XML sitemap operation callback; regenerate sitemap files using the batch API.
*
* @param $smids
* @param array $smids
* An array of XML sitemap IDs.
*
* @see xmlsitemap_regenerate_batch()