<?php

function getAbsoluteUrl($url)
{
    return preg_replace('/([\w\.\-]+.php)/', $url, ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? "https://" : "http://") . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}

function writeSite($path)
{
	$time = filemtime($path);
	if ($time) {
		echo '\t<url>\n';
		echo '\t\t<loc>' . getAbsolutePath($path) . '</loc>\n';
		echo '\t\t<lastmod>' . date("c", $time) . '</lastmod>\n';
		echo '\t</url>\n';
	}
}

echo '<?xml version="1.0" encoding="UTF-8"?>\n';
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">\n';
//writeSite('index.html');
echo '</urlset>\n';
