<?php 
// m3 google sitemap ver 1.22 by mahler83 2009-07-30 
// please give feedbacks to bomool.net 
// Edit by happyjung.com  2017-01-17  http://sir.kr/g5_tip/4961 
include_once("./_common.php"); 

header("Content-type: text/xml;charset=utf-8"); 
header("Cache-Control: no-cache, must-revalidate"); 
header("Pragma: no-cache"); 

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; 
?> 
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 
    <?php 
    // °Ô½ÃÆÇ 
    $sql = "select bo_table from ".$g5['board_table']." where bo_read_level='1' order by bo_order asc"; 
    //$sql = "select bo_table from ".$g5['board_table']." where bo_read_level='1' and bo_use_search='1' order by bo_order asc"; 
    $tot = sql_num_rows(sql_query($sql)); 
    if ($tot > 1) { 
        $query = sql_query($sql); 
        while($temp = sql_fetch_array($query)) { 
            $bo_arr[] = $temp['bo_table']; 
        } 
        $i = 1; 
        foreach($bo_arr as $bo) { 
        // list of bo_table 
    ?> 
            <url> 
                <loc><?php echo G5_BBS_URL ?>/board.php?bo_table=<?php echo $bo; ?></loc> 
                <?php 
                $temp = sql_fetch("select wr_last,wr_datetime from ".$g5['write_prefix'].$bo." order by wr_last DESC"); 
                //$wr_last = $temp['wr_last']; 
                //$wr_datetime = $temp['wr_datetime']; 
                if ($temp['wr_last']) { 
                    $lastmod = substr($temp['wr_last'], 0, 10); 
                } elseif ($temp['wr_datetime']) { 
                    $lastmod = substr($temp['wr_datetime'], 0, 10); 
                } else { 
                    $lastmod = date(Y)."-".date(m)."-".date(d); 
                } 
                ?> 
                <lastmod><?php echo $lastmod; ?></lastmod> 
                <changefreq>monthly</changefreq> 
                <priority>1.0</priority> 
            </url> 
            
            <?php 
            if($bo = "sale") {
            $query = sql_query("select wr_id, wr_last from ".$g5['write_prefix'].$bo." where wr_is_comment = 0 and wr_open LIKE '°ø°³%' and wr_status in ('Á¤»ó', '°è¾à') AND wr_option NOT LIKE '%secret%' order by wr_id DESC limit 100 "); 
            } else {
            $query = sql_query("select wr_id, wr_last from ".$g5['write_prefix'].$bo." where wr_is_comment='0' AND wr_option NOT LIKE '%secret%' order by wr_id DESC limit 100 "); 
            }
            while($row = sql_fetch_array($query)) { 
            // list of each article 
            ?> 
            <url> 
                <loc><?php echo G5_BBS_URL; ?>/board.php?bo_table=<?php echo $bo;?>&amp;wr_id=<?php echo $row['wr_id']; ?></loc> 
                <?php 
                $temp = sql_fetch("select wr_last from ".$g5['write_prefix'].$bo." where wr_parent='".$row['wr_id']."' order by wr_id DESC"); 
                $lastmod = substr($temp['wr_last'], 0, 10); // 2016-01-16 
                if(!$lastmod) { 
                    $temp = sql_fetch("select wr_datetime from ".$g5['write_prefix'].$bo." where wr_id='".$row['wr_id']."'"); 
                    $lastmod = substr($temp['wr_datetime'], 0, 10); 
                } 
                ?> 
                <lastmod><?php echo $lastmod; ?></lastmod> 
                <changefreq>daily</changefreq> 
                <priority>1.0</priority> 
            </url> 
            <?php 
            } 
            $i++; 
        } 
    } 
    ?> 
</urlset> 
