<?php
include_once('includes/config.inc.php');

$website_url = 'http://'.$_SERVER['HTTP_HOST'];  
header('Content-Type: application/xml');

echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
print<<<end
 <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">

end;

$query = "SELECT *  FROM ".PAGES_TABLE;

	if (!($result = mysqli_query($connection,$query)))
             		show_mysqli_error('sitemap');

	while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)) {
	
print<<<end
<url>
   <loc>$website_url/content/$row[alias_url]</loc>
   <changefreq>monthly</changefreq>
</url>

end;
	}


print<<<end
<url>
   <loc>$website_url/contact-us</loc>
   <changefreq>yearly</changefreq>
</url>
</urlset>
end;

?>


