<?php

use Mnv\Core\Config;

require_once('../includes/visitor.inc.php');

	$rewrite = request()->get('rewrite');
	
	/* caching procedures */
	if (!empty(Config::getValue('cache_enabled_sitemap'))) {
        $smarty->caching( 2, Config::getValue('cache_time_sitemap') * Config::getValue('cache_period_sitemap'));
	}

	/* checking whether we in rewrite mode */
	if($rewrite != Config::getValue('rewrite')){
		header("HTTP/1.0 301 Moved Permanently");
		header("Location: ".SITE_URL.'/sitemap.xml');

		/* saving visit */
		writeErrorVisit(301);
		exit;
	}
	
	/* saving visit */
	writeVisit(9);

	header('Content-Type: text/xml');
	$smarty->display('sitemap-xml.tpl', SITE_LANG);

	/* precise load time */
	updateLoadTime();
?>