<?php

define("ATTPHP",1);
require_once("sources/sql-connect.php");
require_once("sources/booker.php");
require_once("sources/functions_text.php");

//
$products = array();
$types = array();
$typesfordest = array();
$destinations = array();
$lastmod = date("Y-m-d");

$result = mysql_query("SELECT DISTINCT `id`, `type_id`, `destination_id`, `specialpage` FROM `brochure_products` WHERE `to` > NOW() AND `wwwpublish` = '1' ");

while (list($id,$type_id,$destination_id,$specialpage) = mysql_fetch_row($result)) {
	$iresult = mysql_query("SELECT `type` FROM `brochure_product_types` WHERE `uniqueid` = '$type_id' AND `language_code` = 'fr' LIMIT 1");
	list($type) = mysql_fetch_row ($iresult);
	if (!in_array ($type_id,$types)) {
		$types[] = $type_id;
		
		$sitemap .= "   <url>
		    <loc>http://www.attitude-travels.com/gay/".(urlencode(formatName($type,"-")))."</loc>
		    <lastmod>$lastmod</lastmod>
		    <changefreq>weekly</changefreq>
		    <priority>0.8</priority>
		   </url>\n";
	}
	if (!in_array ($destination_id,$destinations)) {
		$destinations[] = $destination_id;
		$sitemap .= "   <url>
		    <loc>http://www.attitude-travels.com/gay/".(urlencode(formatName(getDescriptions("destination",$destination_id,"fr"),"-")))."</loc>
		    <lastmod>$lastmod</lastmod>
		    <changefreq>weekly</changefreq>
		    <priority>0.8</priority>
		   </url>\n";
	}
	if (!in_array ($id,$products)) {
		$products[] = $id;
		$sitemap .= "   <url>
		    <loc>http://www.attitude-travels.com/gay/".(urlencode(formatName($type,"-")))."/".(urlencode(formatName(getDescriptions("destination",$destination_id,"fr"),"-")))."/$id</loc>
		    <lastmod>$lastmod</lastmod>
		    <changefreq>weekly</changefreq>
		    <priority>0.6</priority>
		   </url>\n";
		if (!empty($specialpage)) {
			$sitemap .= "   <url>
			    <loc>http://www.attitude-travels.com/$specialpage</loc>
			    <lastmod>$lastmod</lastmod>
			    <changefreq>weekly</changefreq>
			    <priority>0.7</priority>
			   </url>\n";
		}
	}
	
	// tous les hébergements
	$iresult = mysql_query("SELECT `id`, `service_id` FROM `brochure_product_components` WHERE `product_id` = '$id' AND `category_id` = '1'");
	while (list($component_id,$service_id) = mysql_fetch_row($iresult)) {
		$sitemap .= "   <url>
		    <loc>http://www.attitude-travels.com/gay/".(urlencode(formatName($type,"-")))."/".(urlencode(formatName(getDescriptions("destination",$destination_id,"fr"),"-")))."/$id/".(urlencode(formatName(getDescriptions("service",$service_id,"fr","title"),"-")))."/$component_id</loc>
		    <lastmod>$lastmod</lastmod>
		    <changefreq>weekly</changefreq>
		    <priority>0.5</priority>
		   </url>\n";
	}
}

//
$sitemap .= "   <url>
    <loc>http://www.attitude-travels.com/</loc>
    <lastmod>$lastmod</lastmod>
    <changefreq>monthly</changefreq>
    <priority>1</priority>
   </url>
   <url>
    <loc>http://www.attitude-travels.com/contact/cgv.php</loc>
    <lastmod>$lastmod</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.9</priority>
   </url>
   <url>
    <loc>http://www.attitude-travels.com/contact/assurances.php</loc>
    <lastmod>$lastmod</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.9</priority>
   </url>
   <url>
    <loc>http://www.attitude-travels.com/contact/brochure.php</loc>
    <lastmod>$lastmod</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.9</priority>
   </url>
   <url>
    <loc>http://www.attitude-travels.com/contact/newsletter.php</loc>
    <lastmod>$lastmod</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.9</priority>
   </url>
   <url>
    <loc>http://www.attitude-travels.com/contact/reserver.php</loc>
    <lastmod>$lastmod</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.9</priority>
   </url>
   <url>
    <loc>http://www.attitude-travels.com/contact/download.php</loc>
    <lastmod>$lastmod</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.9</priority>
   </url>
   <url>
    <loc>http://www.attitude-travels.com/contact/credit.php</loc>
    <lastmod>$lastmod</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.9</priority>
   </url>
   <url>
    <loc>http://www.attitude-travels.com/contact/contact.php</loc>
    <lastmod>$lastmod</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.9</priority>
   </url>
   <url>
    <loc>http://www.attitude-travels.com/contact/mentions.php</loc>
    <lastmod>$lastmod</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.9</priority>
   </url>
   <url>
    <loc>http://www.attitude-travels.com/contact/attitude.php</loc>
    <lastmod>$lastmod</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.9</priority>
   </url>
   <url>
    <loc>http://www.attitude-travels.com/newsletter</loc>
    <lastmod>$lastmod</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.9</priority>
   </url>\n";


echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
  <urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">
   $sitemap
  </urlset>";
?>
