PHP 7 버전 그누보드 사이트맵 만들기

다운로드

원본출처: https://sir.kr/g5_plugin/410

해당 그누보드 페이지 내 sinbi님이 올려주신 댓글을 인용하였습니다
해당 링크를 들어가서 m3googlesitemap.php 를 받거나, 메모장을 열어서 m3googlestiemap.php 이름으로 저장합니다

저장 위치는 그누보드 설치 루트에 저장합니다

호환성

현재 사이트맵 사용 시 7.4 버전까지 사용이 가능한 것을 확인하였습니다

호환성 목록

  • 7.2
  • 7.3
  • 7.4

원본 소스

m3googlesitemap.php 전체를 삭제하고 아래 소스를 복사하여 붙여넣습니다

<?php
// m3 google sitemap ver 1.23 by mahler83 2009-11-16
// please give feedbacks to bomool.net
include_once("./_common.php");

$charset = $g5['charset'];
$url = "http://127.0.0.1/gnu54"; // G5 루트 경로

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="https://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'];
}

$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_datetime from `{$g5['write_prefix']}{$bo}` order by wr_datetime DESC");
$lastmod = str_replace(" ", "T", substr($temp['wr_datetime'], 0, 30))."+00:00";

// if
if(!$lastmod || strlen($lastmod) < 25 || strcmp($lastmod, "+00:00")) $lastmod = "2014-10-10T00:00:00+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)) {
// 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_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.5</priority>";
echo "</url>\n";
}
$i++;
}
?>
</urlset>

소스 수정

7번 라인의 $url = “http://127.0.0.1/gnu54”; // G5 루트 경로는 현재 웹사이트의 주소를 입력하면 됩니다

완성되면 http://127.0.0.1/gnu54/m3googlesitemap.php 를 입력하여 정상적으로 xml이 생성되는지 확인합니다

서치 콘솔, 네이버 서치어드바이저, 다음 웹마스터 , MS BING 등에 사이트맵 제출 시에는 http://127.0.0.1/gnu54/m3googlesitemap.php 를 제출하시면 됩니다

그리고 구글 서치 콘솔에 제출하면 urlset 오류가 발생하게 되면 13라인에 https://www.sitemaps.org/schemas/sitemap/0.9/ 를 http://www.sitemaps.org/schemas/sitemap/0.9 변경합니다

댓글 달기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

Scroll to Top