<?header("Content-type: TEXT/XML");?><?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
<?

    //config
	$includes_dir = opendir("./cfg");
	$files = array();
	
	while ( ($inc_file = readdir($includes_dir)) != false )
		if (strstr($inc_file,".php"))
		{
			$files[] = $inc_file;
		}
	sort($files);
	foreach ($files as $fl)
	{
		require_once "./cfg/".$fl;
	}
    //core
	require_once START_URL."/core/init.php";
	

	$query = "select * from site_lang";
	$langs = array();
	$rows = pdo_query($query);
	foreach ($rows as $row) {
		$langs[$row['site_lang_id']] =	strtolower($row['site_lang_abbreviation']);
	}
	echo "<url>\n<loc>http://".START_SITE_ADDRES."</loc>\n</url>\n";
	foreach($langs as $k => $v){
		if ($k == SITE_DEFAULT_LANG) continue;
		echo "<url>\n<loc>http://".START_SITE_ADDRES."/{$v}/</loc>\n</url>\n";
	}


	$query = "
		select `pl`.*, `p`.`page_type` from `page_site_lang` as `pl` 
		left join `page` as `p` on `p`.`page_id` = `pl`.`page_id`
		where `p`.`page_visible` = 1
		and `pl`.`lang_visible` = 1
		and ((`section`= 0 and `page_parent` = 0)
			or `p`.`page_parent` in (select `p`.`page_id` from `page_site_lang` as `pl` 
									left join `page` as `p` on `p`.`page_id` = `pl`.`page_id`
									where `p`.`page_visible` = 1
									and `pl`.`lang_visible` = 1
									and `section`= 0 and `page_parent` = 0)
			)
	";
	$rows = pdo_query($query);
	foreach ($rows as $row) {
		echo "<url>\n<loc>http://".START_SITE_ADDRES."/{$row['path_lang']}</loc>\n</url>\n";
		if($row['page_type'] == 299){
			for($i=1;$i<5;$i++)
				for($j=1;$j<9;$j++){
					if($i == 4 && $j > 4) continue;
					echo "<url>\n<loc>http://".START_SITE_ADDRES."/{$row['path_lang']}{$i}/{$j}</loc>\n</url>\n";
				}
		}
	}

?>
</urlset>