Skip to content
On this page

사이트맵 만들기

사이트맵 아래 소스 참고해서 넣어주면 된다.

php
<?php
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
$query = sql_query("select bo_table from `{$g5['board_table']}` where bo_read_level=1");
while($temp = sql_fetch_array($query)) {
    $bo_arr[] = $temp['bo_table'];
}
  
foreach($bo_arr as $bo) {
    $bbs_url = get_pretty_url($bo);
    echo "<url>\n";
    echo "<loc>$bbs_url</loc>\n";
    $temp = sql_fetch("select wr_datetime from `{$g5['write_prefix']}$bo` order by wr_datetime DESC");
    $lastmod = str_replace(" ", "T", substr($temp['wr_datetime'], 0, 30))."+00:00";
     
    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_datetime from `{$g5['write_prefix']}$bo` where wr_is_comment='0' AND wr_option NOT LIKE '%secret%'");
    while($row = sql_fetch_array($query)) {
        $bbs_url = get_pretty_url($bo,$row['wr_id']);
        echo "<url>";
        echo "<loc>$bbs_url</loc>";
        $temp = sql_fetch("select wr_datetime from `{$g5['write_prefix']}$bo` where wr_parent='{$row['wr_id']}' order by wr_id DESC");
        $lastmod = str_replace(" ", "T", substr($temp['wr_datetime'], 0, 30))."+00:00";
        if(!$lastmod) {
            $temp = sql_fetch("select wr_datetime from `{$g5['write_prefix']}$bo` where wr_id='{$row['wr_id']}'");
            $lastmod = str_replace(" ", "T", substr($temp['wr_datetime'], 0, 30))."+00:00";
        }
        if(!$lastmod) $lastmod = G5_TIME_YMD;
        echo "<lastmod>$lastmod</lastmod>";
        echo "<changefreq>weekly</changefreq>";
        echo "<priority>0.8</priority>";
        echo "</url>\n";
    }
}
?>
</urlset>