<?php echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; ?>
<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">
	<url>
		<loc>http://www.bsjlawfirm.com/</loc>
		<lastmod><?php echo gmdate('Y-m-d', filemtime($_SERVER['DOCUMENT_ROOT'].'/index.php')); ?></lastmod>
		<changefreq>monthly</changefreq>
		<priority>1.0</priority>
	</url>
	<url>
		<loc>http://www.bsjlawfirm.com/index.php</loc>
		<lastmod><?php echo gmdate('Y-m-d', filemtime($_SERVER['DOCUMENT_ROOT'].'/index.php')); ?></lastmod>
		<changefreq>monthly</changefreq>
		<priority>1.0</priority>
	</url>
	<url>
		<loc>http://www.bsjlawfirm.com/services/</loc>
		<lastmod><?php echo gmdate('Y-m-d', filemtime($_SERVER['DOCUMENT_ROOT'].'/services/index.php')); ?></lastmod>
		<changefreq>monthly</changefreq>
		<priority>1.0</priority>
	</url>
<?php
$db = new dbFuncs(true);
$sql = "SELECT name FROM practice_areas ORDER BY priority ASC, name ASC";
$result = $db->queryDb($sql);
if($result !== false && $result->num_rows > 0) {
	// do links to practice areas
	while($row = $result->fetch_assoc()) {
?>
	<url>
		<loc>http://www.bsjlawfirm.com/services/<?php echo strtolower(str_replace(' ', '_', $row['name'])), '/'; ?></loc>
		<lastmod><?php echo gmdate('Y-m-d', filemtime($_SERVER['DOCUMENT_ROOT'].'/services/index.php')); ?></lastmod>
		<changefreq>monthly</changefreq>
		<priority>1.0</priority>
	</url>
<?php
	}
	$result->free();
}

$sql = "SELECT articleID, date, title FROM articles ORDER BY date DESC";
$result = $db->queryDb($sql);
if($result !== false && $result->num_rows > 0) {
	$date = '1980-01-01 00:00:00'; // set fake date for comparing
	// do links to articles
	while($row = $result->fetch_assoc()) {
		if($row['date'] > $date) $date = $row['date'];
?>
	
	<url>
		<loc>http://www.bsjlawfirm.com/articles/<?php echo $row['articleID'], '/', strtolower(str_replace(' ', '_', trim(preg_replace('/[^a-z_\-\d\s]/i', '', strip_tags($row['title']))))), '/'; ?></loc>
		<lastmod><?php echo gmdate('Y-m-d', strtotime($row['date'])); ?></lastmod>
		<changefreq>never</changefreq>
		<priority>1.0</priority>
	</url>
<?php
	}
	$result->free();
	unset($row);
}
?>

	<url>
		<loc>http://www.bsjlawfirm.com/articles/</loc>
		<lastmod><?php echo gmdate('Y-m-d', strtotime($date)); ?></lastmod>
		<changefreq>monthly</changefreq>
		<priority>1.0</priority>
	</url>
	<url>
		<loc>http://www.bsjlawfirm.com/contact/contact.php</loc>
		<lastmod><?php echo gmdate('Y-m-d', filemtime($_SERVER['DOCUMENT_ROOT'].'/contact/contact.php')); ?></lastmod>
		<changefreq>monthly</changefreq>
		<priority>0.2</priority>
	</url>
	<url>
		<loc>http://www.bsjlawfirm.com/sitemap.php</loc>
		<lastmod><?php echo gmdate('Y-m-d', filemtime($_SERVER['DOCUMENT_ROOT'].'/sitemap.php')); ?></lastmod>
		<changefreq>yearly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>http://www.bsjlawfirm.com/about.php</loc>
		<lastmod><?php echo gmdate('Y-m-d', filemtime($_SERVER['DOCUMENT_ROOT'].'/about.php')); ?></lastmod>
		<changefreq>monthly</changefreq>
		<priority>1.0</priority>
	</url>
	<url>
		<loc>http://www.bsjlawfirm.com/articles/</loc>
		<lastmod><?php echo gmdate('Y-m-d', filemtime($_SERVER['DOCUMENT_ROOT'].'/articles/index.php')); ?></lastmod>
		<changefreq>monthly</changefreq>
		<priority>1.0</priority>
	</url>
	<url>
		<loc>http://www.bsjlawfirm.com/legal/siteuse.php</loc>
		<lastmod><?php echo gmdate('Y-m-d', filemtime($_SERVER['DOCUMENT_ROOT'].'/legal/siteuse.php')); ?></lastmod>
		<changefreq>monthly</changefreq>
		<priority>0.2</priority>
	</url>
	<url>
		<loc>http://www.bsjlawfirm.com/legal/privacy.php</loc>
		<lastmod><?php echo gmdate('Y-m-d', filemtime($_SERVER['DOCUMENT_ROOT'].'/legal/privacy.php')); ?></lastmod>
		<changefreq>monthly</changefreq>
		<priority>0.2</priority>
	</url>
</urlset>
