<?	// *********************************************************************************************
	// rijbewijsgarant.nl sitemap.xml
	include('../db.inc.php');
	include('include/php/rewrite.inc.php');

	echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
	echo "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
	
	echo "\t<url>\n";
	echo "\t\t<loc>" . HOME_DIR . "/index.php</loc>\n";
	echo "\t\t<changefreq>monthly</changefreq>\n";
	echo "\t\t<priority>0.8</priority>\n";
   	echo "\t</url>\n";
	
	// rijopleidingen
	$strSQL = "SELECT opleiding.CatID AS Type, opleiding.Rewrite, opleiding.Header, opleidingcat.Rewrite AS CatRewrite, opleidingcat.Header AS CatHeader";
    $strSQL .= " FROM opleiding";
	$strSQL .= " LEFT JOIN opleidingcat on opleidingcat.ID = opleiding.CatID";
	$strSQL .= " WHERE opleiding.Online = 1";
    $strSQL .= " ORDER BY opleidingcat.Sort ASC, opleiding.Sort Asc";

	$result = mysql_query( $strSQL );
	if( mysql_num_rows( $result )>0 ) {
    	while( $row=mysql_fetch_array($result)) {

			if ( $row['Type'] != $OldType ) {
				echo "\t<url>\n";
				echo "\t\t<loc>" . HOME_DIR . "/rijopleiding/" . GetRewrite($row['CatHeader']) . "/" . $row['CatRewrite'] . ".php</loc>\n";
				echo "\t\t<changefreq>monthly</changefreq>\n";
				echo "\t\t<priority>0.9</priority>\n";
				echo "\t</url>\n";		
			}

			echo "\t<url>\n";
			echo "\t\t<loc>" . HOME_DIR . "/rijopleiding/" . GetRewrite($row['CatHeader']) . "/" . $row['Rewrite'] . ".php</loc>\n";
			echo "\t\t<changefreq>monthly</changefreq>\n";
			echo "\t\t<priority>1</priority>\n";
			echo "\t</url>\n";

			$OldType = $row['Type'];
		}
	}

	echo "\t<url>\n";
	echo "\t\t<loc>" . HOME_DIR . "/rijtest.php</loc>\n";
	echo "\t\t<changefreq>monthly</changefreq>\n";
	echo "\t\t<priority>0.5</priority>\n";
	echo "\t</url>\n";

	echo "\t<url>\n";
	echo "\t\t<loc>" . HOME_DIR . "/theorie.php</loc>\n";
	echo "\t\t<changefreq>monthly</changefreq>\n";
	echo "\t\t<priority>0.5</priority>\n";
   	echo "\t</url>\n";

	echo "\t<url>\n";
	echo "\t\t<loc>" . HOME_DIR . "/voordelen.php</loc>\n";
	echo "\t\t<changefreq>monthly</changefreq>\n";
	echo "\t\t<priority>0.1</priority>\n";
   	echo "\t</url>\n";

	echo "\t<url>\n";
	echo "\t\t<loc>" . HOME_DIR . "/kosten.php</loc>\n";
	echo "\t\t<changefreq>monthly</changefreq>\n";
	echo "\t\t<priority>0.3</priority>\n";
   	echo "\t</url>\n";

	echo "\t<url>\n";
	echo "\t\t<loc>" . HOME_DIR . "/aanmelden_cursist.php</loc>\n";
	echo "\t\t<changefreq>monthly</changefreq>\n";
	echo "\t\t<priority>0.5</priority>\n";
   	echo "\t</url>\n";

	echo "\t<url>\n";
	echo "\t\t<loc>" . HOME_DIR . "/aanmelden_rijtest.php</loc>\n";
	echo "\t\t<changefreq>monthly</changefreq>\n";
	echo "\t\t<priority>0.5</priority>\n";
   	echo "\t</url>\n";

	echo "\t<url>\n";
	echo "\t\t<loc>" . HOME_DIR . "/aamelden_instructeur.php</loc>\n";
	echo "\t\t<changefreq>monthly</changefreq>\n";
	echo "\t\t<priority>0.3</priority>\n";
   	echo "\t</url>\n";

	echo "\t<url>\n";
	echo "\t\t<loc>" . HOME_DIR . "/contact.php</loc>\n";
	echo "\t\t<changefreq>monthly</changefreq>\n";
	echo "\t\t<priority>0.3</priority>\n";
   	echo "\t</url>\n";

	// faq
	$strSQL = "SELECT faqcat.ID, faqcat.Rewrite, faqcat.Header, COUNT(faq.ID) AS Aantal";
    $strSQL .= " FROM faqcat";
	$strSQL .= " JOIN faq ON faq.CatID = faqcat.ID";
	$strSQL .= " GROUP BY faqcat.ID";
    $strSQL .= " ORDER BY faqcat.Sort ASC, faqcat.Header ASC";

	$result = mysql_query( $strSQL );
	if( mysql_num_rows( $result )>0 ) {	
    	while( $row=mysql_fetch_array($result)) {

			echo "\t<url>\n";
			echo "\t\t<loc>" . HOME_DIR . "/faq/" . $row['Rewrite'] . ".php</loc>\n";
			echo "\t\t<changefreq>monthly</changefreq>\n";
			echo "\t\t<priority>0.7</priority>\n";
			echo "\t</url>\n";
		}
	}	

	// rijschool locaties
	$strSQL = "SELECT Header, Rewrite";
	$strSQL .= " FROM locatie";
	$strSQL .= " ORDER BY Header ASC";
		
	$result = mysql_query( $strSQL );
	if( mysql_num_rows( $result )>0 ) {


		echo "\t<url>\n";
		echo "\t\t<loc>" . HOME_DIR . "/rijles.php</loc>\n";
		echo "\t\t<changefreq>monthly</changefreq>\n";
		echo "\t\t<priority>0.6</priority>\n";
		echo "\t</url>\n";
		
		while( $row=mysql_fetch_array($result)) {

			echo "\t<url>\n";
			echo "\t\t<loc>" . HOME_DIR . "/rijlessen/" . $row['Rewrite'] . ".php</loc>\n";
			echo "\t\t<changefreq>monthly</changefreq>\n";
			echo "\t\t<priority>0.7</priority>\n";
			echo "\t</url>\n";
		}
	}

	// disclaimer
	echo "\t<url>\n";
	echo "\t\t<loc>" . HOME_DIR . "/disclaimer.php</loc>\n";
	echo "\t\t<changefreq>monthly</changefreq>\n";
	echo "\t\t<priority>0.1</priority>\n";
	echo "\t</url>\n";

	echo "</urlset>";
?>