<?php
include("includes/config.php");
include_once($doc_path."includes/functions.php");
header("Content-Type: text/xml"); 
open_db();?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
	<loc><?=$url_path?></loc>
	<priority>1</priority>
</url>
<url>
	<loc><?=$url_path?>about.php</loc>
	<priority>0.3</priority>
</url>
<url>
	<loc><?=$url_path?>view-listings.php</loc>
	<priority>1</priority>
</url>
<url>
	<loc><?=$url_path?>news.php</loc>
	<priority>0.6</priority>
</url>
<url>
	<loc><?=$url_path?>links.php</loc>
	<priority>0.1</priority>
</url>
<url>
	<loc><?=$url_path?>contact.php</loc>
	<priority>0.1</priority>
</url>
<url>
	<loc><?=$url_path?>services.php</loc>
	<priority>1</priority>
</url>
<?php		
// services		
$sql_s="SELECT * FROM services WHERE visible=1 ORDER BY ordernum ASC";
$res_s=mysql_query($sql_s);
if(mysql_num_rows($res_s))
{
	while($row_s=mysql_fetch_array($res_s))
	{
		?><url><loc><?=$url_path?>service/<?=url_clean($row_s['title'])?>/<?=$row_s['serviceID']?>/</loc><priority>0.8</priority></url><?php
	}
}

// property regions
$sql = 'SELECT COUNT(*) AS numProperties, regions.* FROM regions 
	INNER JOIN properties ON regionID = properties.region 
	WHERE properties.visible = 1 
	GROUP BY regionID 
	ORDER BY regions.region ASC';
	
$navRegions = mysql_query($sql);
if (mysql_num_rows($navRegions))
{
	while ($navRegion = mysql_fetch_assoc($navRegions))
	{
		?><url><loc><?=$url_path?>property/<?=$navRegion['url']?>/</loc><priority>0.9</priority></url><?php
	}
}

// properties
$sql_s="SELECT properties.*, regions.url FROM properties INNER JOIN regions ON regionID = properties.region WHERE visible=1 ORDER BY propertyID DESC";
$res_s=mysql_query($sql_s);
if(mysql_num_rows($res_s))
{
	while($row_s=mysql_fetch_array($res_s))
	{
		?><url><loc><?=$url_path?>property/<?=$row_s['url']?>/<?=url_clean($row_s['name'])?>/<?=$row_s['propertyID']?>/</loc><priority>0.9</priority></url><?php
	}
}
?>
</urlset>