<commit_before><?php

class pluginSitemap extends Plugin {

	private function createXML()
	{
		global $Site;
		global $dbPages;
		global $dbPosts;
		global $Url;

		$doc = new DOMDocument('1.0', 'UTF-8');

		// Friendly XML code
		$doc->formatOutput = true;

		// Create urlset element
		$urlset = $doc->createElement('urlset');
		$attribute = $doc->createAttribute('xmlns');
		$attribute->value = 'http://www.sitemaps.org/schemas/sitemap/0.9';
		$urlset->appendChild($attribute);

		// --- Base URL ---

		// Create url, loc and lastmod elements
		$url 		= $doc->createElement('url');
		$loc 		= $doc->createElement('loc', $Site->url());
		$lastmod	= $doc->createElement('lastmod', Date::current(SITEMAP_DATE_FORMAT));

		// Append loc and lastmod -> url
		$url->appendChild($loc);
		$url->appendChild($lastmod);

		// Append url -> urlset
		$urlset->appendChild($url);

		// --- Pages and Posts ---
		$all = array();
		$url = trim($Site->url(),'/');

		// --- Pages ---
		$filter = trim($Url->filters('page'),'/');
		$pages = $dbPages->getDB();
		unset($pages['error']);
		foreach($pages as $key=>$db)
		{
			if($db['status']=='published')
			{
				$permalink = empty($filter) ? $url.'/'.$key : $url.'/'.$filter.'/'.$key;
				$date = Date::format($db['date'], DB_DATE_FORMAT, SITEMAP_DATE_FORMAT);
				array_push($all, array('permalink'=>$permalink, 'date'=>$date));
			}
		}

		// --- Posts ---
		$filter = rtrim($Url->filters('post'),'/');
		$posts = $dbPosts->getDB();
		foreach($posts as $key=>$db)
		{
			if($db['status']=='published')
			{
				$permalink = empty($filter) ? $url.'/'.$key : $url.'/'.$filter.'/'.$key;
				$date = Date::format($db['date'], DB_DATE_FORMAT, SITEMAP_DATE_FORMAT);
				array_push($all, array('permalink'=>$permalink, 'date'=>$date));
			}
		}

		// Generate the XML for posts and pages
		foreach($all as $db)
		{
			// Create url, loc and lastmod elements
			$url 		= $doc->createElement('url');
			$loc 		= $doc->createElement('loc', $db['permalink']);
			$lastmod	= $doc->createElement('lastmod', $db['date']);

			// Append loc and lastmod -> url
			$url->appendChild($loc);
			$url->appendChild($lastmod);

			// Append url -> urlset
			$urlset->appendChild($url);
		}

		// Append urlset -> XML
		$doc->appendChild($urlset);

		$doc->save(PATH_PLUGINS_DATABASES.$this->directoryName.DS.'sitemap.xml');
	}

	public function install($position = 0)
	{
		parent::install($position);

		$this->createXML();
	}

	public function afterPostCreate()
	{
		$this->createXML();
	}

	public function afterPageCreate()
	{
		$this->createXML();
	}

	public function afterPostModify()
	{
		$this->createXML();
	}

	public function afterPageModify()
	{
		$this->createXML();
	}

	public function afterPostDelete()
	{
		$this->createXML();
	}

	public function afterPageDelete()
	{
		$this->createXML();
	}

	public function beforeRulesLoad()
	{
		global $Url;

		if( $Url->uri() === HTML_PATH_ROOT.'sitemap.xml' )
		{
			// Send XML header
			header('Content-type: text/xml');

			// New DOM document
			$doc = new DOMDocument();

			// Load XML
			$doc->load(PATH_PLUGINS_DATABASES.$this->directoryName.DS.'sitemap.xml');

			// Print the XML
			echo $doc->saveXML();

			// Stop Bludit running
			exit;
		}
	}
<commit_msg>Added libxml_disable_entity_loader calls<commit_after><?php

class pluginSitemap extends Plugin {

	private function createXML()
	{
		global $Site;
		global $dbPages;
		global $dbPosts;
		global $Url;

		$doc = new DOMDocument('1.0', 'UTF-8');

		// Friendly XML code
		$doc->formatOutput = true;

		// Create urlset element
		$urlset = $doc->createElement('urlset');
		$attribute = $doc->createAttribute('xmlns');
		$attribute->value = 'http://www.sitemaps.org/schemas/sitemap/0.9';
		$urlset->appendChild($attribute);

		// --- Base URL ---

		// Create url, loc and lastmod elements
		$url 		= $doc->createElement('url');
		$loc 		= $doc->createElement('loc', $Site->url());
		$lastmod	= $doc->createElement('lastmod', Date::current(SITEMAP_DATE_FORMAT));

		// Append loc and lastmod -> url
		$url->appendChild($loc);
		$url->appendChild($lastmod);

		// Append url -> urlset
		$urlset->appendChild($url);

		// --- Pages and Posts ---
		$all = array();
		$url = trim($Site->url(),'/');

		// --- Pages ---
		$filter = trim($Url->filters('page'),'/');
		$pages = $dbPages->getDB();
		unset($pages['error']);
		foreach($pages as $key=>$db)
		{
			if($db['status']=='published')
			{
				$permalink = empty($filter) ? $url.'/'.$key : $url.'/'.$filter.'/'.$key;
				$date = Date::format($db['date'], DB_DATE_FORMAT, SITEMAP_DATE_FORMAT);
				array_push($all, array('permalink'=>$permalink, 'date'=>$date));
			}
		}

		// --- Posts ---
		$filter = rtrim($Url->filters('post'),'/');
		$posts = $dbPosts->getDB();
		foreach($posts as $key=>$db)
		{
			if($db['status']=='published')
			{
				$permalink = empty($filter) ? $url.'/'.$key : $url.'/'.$filter.'/'.$key;
				$date = Date::format($db['date'], DB_DATE_FORMAT, SITEMAP_DATE_FORMAT);
				array_push($all, array('permalink'=>$permalink, 'date'=>$date));
			}
		}

		// Generate the XML for posts and pages
		foreach($all as $db)
		{
			// Create url, loc and lastmod elements
			$url 		= $doc->createElement('url');
			$loc 		= $doc->createElement('loc', $db['permalink']);
			$lastmod	= $doc->createElement('lastmod', $db['date']);

			// Append loc and lastmod -> url
			$url->appendChild($loc);
			$url->appendChild($lastmod);

			// Append url -> urlset
			$urlset->appendChild($url);
		}

		// Append urlset -> XML
		$doc->appendChild($urlset);

		$doc->save(PATH_PLUGINS_DATABASES.$this->directoryName.DS.'sitemap.xml');
	}

	public function install($position = 0)
	{
		parent::install($position);

		$this->createXML();
	}

	public function afterPostCreate()
	{
		$this->createXML();
	}

	public function afterPageCreate()
	{
		$this->createXML();
	}

	public function afterPostModify()
	{
		$this->createXML();
	}

	public function afterPageModify()
	{
		$this->createXML();
	}

	public function afterPostDelete()
	{
		$this->createXML();
	}

	public function afterPageDelete()
	{
		$this->createXML();
	}

	public function beforeRulesLoad()
	{
		global $Url;

		if( $Url->uri() === HTML_PATH_ROOT.'sitemap.xml' )
		{
			// Send XML header
			header('Content-type: text/xml');

			// New DOM document
			$doc = new DOMDocument();

			// Load XML
			libxml_disable_entity_loader(false);
			$doc->load(PATH_PLUGINS_DATABASES.$this->directoryName.DS.'sitemap.xml');
			libxml_disable_entity_loader(true);

			// Print the XML
			echo $doc->saveXML();

			// Stop Bludit running
			exit;
		}
	}

{'fraction_non_alphanumeric': 0.20660405937594667, 'fraction_numerical': 0.0018176310209027568, 'mean_word_length': 3.4948944860449287, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 99, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 13}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4013179', 'n_tokens_mistral': 2642, 'n_tokens_neox': 2315, 'n_words': 426}