<?php
	require_once('inc/util.inc.php');
	header("Content-type: text/xml");
	echo'<?xml version=\'1.0\' encoding=\'UTF-8\'?>';
	echo'   <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
					xmlns:xhtml="http://www.w3.org/1999/xhtml">
				<url>
					<loc>https://v-no.ca/</loc>
					<changefreq>weekly</changefreq>
					<priority>1</priority>
					<xhtml:link rel="alternate" hreflang="en" href="https://v-no.ca/en/" />
					<xhtml:link rel="alternate" hreflang="fr" href="https://v-no.ca/fr/" />
				</url>
				<url>
					<loc>https://v-no.ca/fr/</loc>
					<changefreq>weekly</changefreq>
					<priority>1</priority>
					<xhtml:link rel="alternate" hreflang="en" href="https://v-no.ca/en/" />
					<xhtml:link rel="alternate" hreflang="fr" href="https://v-no.ca/fr/" />					
				</url>
				<url>
					<loc>https://v-no.ca/en/</loc>
					<changefreq>weekly</changefreq>
					<priority>1</priority>
					<xhtml:link rel="alternate" hreflang="en" href="https://v-no.ca/en/" />
					<xhtml:link rel="alternate" hreflang="fr" href="https://v-no.ca/fr/" />					
				</url>';
	$con=ConnectionBD(); 		
	$result = $con->query('SELECT wid, nom, categorie,categorie_b,greatest(timestamp(\'2015-06-02 12:30:00\'),date_maj) as date_maj FROM w_vin_en order by ordre desc limit 20000 ');
	while($row = mysqli_fetch_array($result))
	{
		echo'<url>
				<loc>https://v-no.ca/en/' . GenerateUrl($row['categorie']). '/' .GenerateUrl($row['nom']) . '-'.$row['wid'] . '/</loc>
				<xhtml:link rel="alternate" hreflang="en" href="https://v-no.ca/en/' . GenerateUrl($row['categorie']). '/' .GenerateUrl($row['nom']) . '-'.$row['wid'] . '/" />
				<xhtml:link rel="alternate" hreflang="fr" href="https://v-no.ca/fr/' . GenerateUrl($row['categorie_b']). '/' .GenerateUrl($row['nom']) . '-'.$row['wid'] . '/" />
				<lastmod>' . gmdate(DATE_W3C,strtotime($row['date_maj'])) . '</lastmod>
				<changefreq>monthly</changefreq>
				<priority>0.8</priority>
			</url>
			<url>
				<loc>https://v-no.ca/fr/' . GenerateUrl($row['categorie_b']). '/' .GenerateUrl($row['nom']) . '-'.$row['wid'] . '/</loc>
				<xhtml:link rel="alternate" hreflang="en" href="https://v-no.ca/en/' . GenerateUrl($row['categorie']). '/' .GenerateUrl($row['nom']) . '-'.$row['wid'] . '/" />
				<xhtml:link rel="alternate" hreflang="fr" href="https://v-no.ca/fr/' . GenerateUrl($row['categorie_b']). '/' .GenerateUrl($row['nom']) . '-'.$row['wid'] . '/" />
				<lastmod>' . gmdate(DATE_W3C,strtotime($row['date_maj'])) . '</lastmod>		 
				<changefreq>monthly</changefreq>
				<priority>0.8</priority>
			</url>';
	}
	$con->close();  
	echo'</urlset>';
?>
