<?php
	include_once("includes/constants.inc");
	include_once("includes/ez_sql.php");
	include_once("includes/errorhandler.php");
	
	echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
	echo "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
	
			if($navigations=$db->get_results("SELECT * FROM navigations WHERE navigation_parent=0 AND navigation_enable = 'Yes' ORDER BY navigation_order")){  // AND navigation_visible = 'Yes' 
		foreach($navigations as $navigation){
		
		 if(stripslashes($navigation->navigation_type) == 'Page' && stripslashes($navigation->navigation_visible) == 'Yes'){ 
		 
		 echo "<url><loc>".$GLOBALS['URL']."/".urlencode(stripslashes($navigation->navigation_title))."</loc><changefreq>monthly</changefreq><priority>1</priority></url>\n";
		 
		 }

			if($navigations2=$db->get_results("SELECT * FROM navigations WHERE navigation_parent=$navigation->navigation_id  AND navigation_enable = 'Yes' ORDER BY navigation_order")){ //AND navigation_visible = 'Yes'
			
				foreach($navigations2 as $navigation2){
					
					
					echo "<url><loc>".$GLOBALS['URL']."/".urlencode(stripslashes($navigation->navigation_title))."/".urlencode(stripslashes($navigation2->navigation_title))."</loc><changefreq>monthly</changefreq><priority>1</priority></url>\n";
					
				}
			
         
					if($navigations3=$db->get_results("SELECT * FROM navigations WHERE navigation_parent=$navigation2->navigation_id  AND navigation_enable = 'Yes' ORDER BY navigation_order")){ //AND navigation_visible = 'Yes'
					
						foreach($navigations3 as $navigation3){
							
							
						echo "<url><loc>".$GLOBALS['URL']."/".urlencode(stripslashes($navigation->navigation_title))."/".urlencode(stripslashes($navigation2->navigation_title))."/".urlencode(stripslashes($navigation3->navigation_title))."</loc><changefreq>monthly</changefreq><priority>1</priority></url>\n";

							
					}
					
				}
			
			}
			
		}
	}
	
	if($news_cats=$db->get_results("SELECT * FROM news_categories")){
		foreach($news_cats as $citem){
		
		$catid = $citem->id;
		$catname = $citem->name;
	
			if($news_items=$db->get_results("SELECT news_item_title,news_item_category FROM news_items WHERE news_item_category='".$catid."' AND news_enable='Yes' ORDER BY news_item_date DESC LIMIT 200")){
					foreach($news_items as $item){
						echo "<url><loc>".$GLOBALS['URL']."/".urlencode($catname)."/".urlencode(stripslashes($item->news_item_title))."</loc><changefreq>weekly</changefreq><priority>1</priority></url>\n";
					}
			}
		} 
	}
	
	
	echo "</urlset>";
?>