<?
// m3 google sitemap ver 1.22 by mahler83 2009-07-30
// please give feedbacks to bomool.net
include_once("./_common.php");

$charset = $g4[charset];
$url = $g4[url]; // adjust if gnuboard is not installed in the root directory

header("Content-type: text/xml;charset=$charset");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");

echo "<?xml version=\"1.0\" encoding=\"$charset\"?>\n";
?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
<?
$query = sql_query("select bo_table from `$g4[board_table]` where bo_read_level='1'");
while($temp = sql_fetch_array($query)) {
	$bo_arr[] = $temp[bo_table];
}

$i = 1;
foreach($bo_arr as $bo) {
	// list of bo_table
	echo "<url>\n";
	echo "<loc>$url/bbs/board.php?bo_table=$bo</loc>\n";
	$temp = sql_fetch("select wr_last from `$g4[write_prefix]$bo` order by wr_last DESC");
	$lastmod = substr($temp[wr_last], 0, 10);
	echo "<lastmod>$lastmod</lastmod>\n";
	echo "<changefreq>daily</changefreq>\n";
	echo "<priority>0.9</priority>\n";
	echo "</url>\n";

	$query = sql_query("select wr_id, wr_last from `$g4[write_prefix]$bo` where wr_is_comment='0' AND wr_option NOT LIKE '%secret%'");
	while($row = sql_fetch_array($query)) {
		// list of each article
		echo "<url>";
		echo "<loc>$url/bbs/board.php?bo_table=$bo&amp;wr_id=$row[wr_id]</loc>";
		$temp = sql_fetch("select wr_last from `$g4[write_prefix]$bo` where wr_parent='$row[wr_id]' order by wr_id DESC");
		$lastmod = substr($temp[wr_last], 0, 10);
		if(!$lastmod) {
			$temp = sql_fetch("select wr_datetime from `$g4[write_prefix]$bo` where wr_id='$row[wr_id]'");
			$lastmod = substr($temp[wr_datetime], 0, 10);
		}
		echo "<lastmod>$lastmod</lastmod>";
		echo "<changefreq>monthly</changefreq>";
		echo "<priority>0.5</priority>";
		echo "</url>\n";
	}
	$i++;
}
?>
</urlset>
