<?php
include_once "./_core.php";

$basic_date = '2024-02-01 00:00:00';
$_http = $_SERVER['HTTPS']=='on' ? 'https://' : 'http://';
$domain = $_http.$_SERVER['SERVER_NAME'];

$xml_arr = array();
$xml_arr[] = array('', '');

//기사 리스트
$_arr['where'] = " and (`wr_p_code`='' or `wr_p_code` is null)";
$__menu_array = $netfu_util->get_cate_code_array('section', $_arr);

if(is_array($__menu_array)) { foreach($__menu_array as $k=>$v) {	

	$xml_arr[] = array('/news/index.php?code='.$k);

	if(is_array($netfu_util->get_cate['section'][$k])) { foreach($netfu_util->get_cate['section'][$k] as $k2=>$v2) {

		$xml_arr[] = array('/news/index.php?code='.$k.'&d_code='.$k2);

		if(is_array($netfu_util->get_cate['section'][$k2])) { foreach($netfu_util->get_cate['section'][$k2] as $k3=>$v3) {

			$xml_arr[] = array('/news/index.php?code='.$k.'&d_code='.$k2.'&ds_code='.$k3);

		} }

	} }

} }

//기사 상세페이지
$news_view_xml = '';
$news_view_query = $db->_query("select no, wr_regist_date from snow_news where `wr_is_regist`=1 and `wr_is_delete`=0 and `wr_read_level`=1 order by `no` asc");
$cnt = 0;
while($row=$db->afetch($news_view_query)) {
	$xml_url = '/news/view.php?no='.$row['no'];
	$news_view_xml .= '<url>
<loc><![CDATA['.$domain.$xml_url.']]></loc>
<lastmod>'.date(DATE_ATOM, strtotime($row['wr_regist_date'])).'</lastmod>
<changefreq>always</changefreq>
<priority>0.0</priority>
</url>';
	$cnt++;
}


//공지사항 상세페이지
$notice_xml = '';
$notice_query = $db->_query("select * from snow_notice order by `no` asc");
$cnt = 0;
while($row=$db->afetch($notice_query)) {
	$xml_url = '/board/notice_view.php?no='.$row['no'];
	$notice_xml .= '<url>
<loc><![CDATA['.$domain.$xml_url.']]></loc>
<lastmod>'.date(DATE_ATOM, strtotime($row['wr_date'])).'</lastmod>
<changefreq>always</changefreq>
<priority>0.0</priority>
</url>';
	$cnt++;
}


// : xml태그 만들기
Header("Content-type: text/xml charset=UTF-8");
ob_start();
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php
if(is_array($xml_arr)) { foreach($xml_arr as $k=>$v) {
	if(!$v[1]) $v[1] = $basic_date;
	$time = date(DATE_ATOM, strtotime($v[1]));
?>
<url>
<loc><![CDATA[<?php echo $domain.$v[0];?>]]></loc>
<lastmod><?php echo $time;?></lastmod>
<changefreq>always</changefreq>
<priority>0.0</priority>
</url>
<?php
} }
echo $news_view_xml;
echo $notice_xml;
?>
</urlset>
<?php
$xml = ob_get_clean();
echo $xml;
?>

