<?php 
header('Content-type: application/xml; charset="utf-8"',true); 
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" ;
echo "<urlset xmlns=\"http://www.google.com/schemas/sitemap/0.84\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:schemaLocation=\"http://www.google.com/schemas/sitemap/0.84
http://www.google.com/schemas/sitemap/0.84/sitemap.xsd\">";
require_once('includes/DbConnector.php');
$connector = new DbConnector(); 
$resultsitemap = $connector->query('SELECT * FROM cmsarticles WHERE parentid <> 1 ORDER BY sitemap_priority DESC LIMIT 99');
while ($rowsitemap = $connector->fetchArray($resultsitemap)){
if ($rowsitemap['sitemap_priority'] != 'na') {
$theUrl = $_SERVER[HTTP_HOST].'/'.$rowsitemap['article'].'.php';
	if ($rowsitemap['article'] == 'index') 
	{
		$theUrl = $_SERVER[HTTP_HOST];
	}
	
	if ($rowsitemap[sectionid] == 91) {
		if ( ($rowsitemap['parentid'] == 218) || ($rowsitemap['parentid'] == 219))
		{
			$articleDIR = 'tutorials/';
		} else {
			$articleDIR = 'news/';
		}
		$theUrl = $_SERVER[HTTP_HOST].'/'.$articleDIR.''.$rowsitemap['article'].'.php';
	}	
	if ($rowsitemap[parentid] == 175) {
		$theUrl = $_SERVER[HTTP_HOST].'/web-hosting/'.$rowsitemap['article'].'.php';
	}	
	if ($rowsitemap[parentid] == 201) {
		$theUrl = $_SERVER[HTTP_HOST].'/resellers/'.$rowsitemap['article'].'.php';
	}?>
<url>
  <loc>https://<?php echo $theUrl;?></loc>
  <changefreq>weekly</changefreq>
  <priority><?php echo $rowsitemap['sitemap_priority'];?></priority>
</url>
<?php
}}
?>
</urlset>
