답변 2개
외부 서비스에 의존하지 않고
simplexml_load_file()을 활용한 커스텀 스크립트로
각각를 병합하여 통합 RSS를 생성하시길 권장드립니다.
ㅡ그누 순정 구조 기준, 예시를 찾아봄 ㅡ
***/bbs/rss_all.php로 통합 ***
<?php
// /bbs/rss_all.php (BOM 없이 저장)
include_once __DIR__ . '/_common.php';
// 1) 설정
header('Content-Type: application/rss+xml; charset=UTF-8');
$boards = ['notice','qna','free']; // 통합 대상 bo_table
$per_board = 30; // 보드별 가져올 최대 수
$max_items = 100; // 최종 RSS 항목 상한
$feed_title = '사이트 통합 RSS';
$feed_link = G5_URL.'/';
$feed_desc = '그누보드 통합 RSS';
$self_feed_url = G5_URL.'/bbs/rss_all.php';
// 2) 수집
$items = [];
foreach ($boards as $bo_table) {
// 각 보드 write 테이블
$write_table = $g5['write_prefix'] . $bo_table;
// 존재 확인
if (!sql_query("SHOW TABLES LIKE '{$write_table}'", false)) continue;
$sql = "
SELECT wr_id, wr_subject, wr_content, wr_datetime, wr_option
FROM {$write_table}
WHERE wr_is_comment = 0
ORDER BY wr_datetime DESC
LIMIT {$per_board}
";
$q = sql_query($sql, false);
if (!$q) continue;
while ($row = sql_fetch_array($q)) {
// 링크 생성 (pretty-url 우선)
if (function_exists('get_pretty_url')) {
$link = get_pretty_url($bo_table, $row['wr_id']);
} else {
$link = G5_BBS_URL.'/board.php?bo_table='.$bo_table.'&wr_id='.$row['wr_id'];
}
// 제목·본문 정리
$title = get_text($row['wr_subject']);
// 옵션 기반 본문 처리(HTML 허용시 conv_content 사용)
$content_raw = isset($row['wr_option']) && strpos($row['wr_option'], 'html') !== false
? conv_content($row['wr_content'], $row['wr_option'])
: get_text($row['wr_content'], 0); // 텍스트화
// 길이 제한(요약)
$desc = cut_str(strip_tags($content_raw), 300, '…');
// 중복 방지: 링크를 키로 사용
$items[$link] = [
'title' => $title,
'link' => $link,
'desc' => $desc,
'pub_ts' => strtotime($row['wr_datetime']) ?: G5_SERVER_TIME,
];
}
}
// 3) 최신순 정렬 및 상한
usort($items, fn($a,$b) => $b['pub_ts'] <=> $a['pub_ts']);
$items = array_slice($items, 0, $max_items);
// 4) 출력
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title><?= htmlspecialchars($feed_title, ENT_XML1) ?></title>
<link><?= htmlspecialchars($feed_link, ENT_XML1) ?></link>
<description><?= htmlspecialchars($feed_desc, ENT_XML1) ?></description>
<language>ko</language>
<lastBuildDate><?= gmdate(DATE_RSS) ?></lastBuildDate>
<atom:link href="<?= htmlspecialchars($self_feed_url, ENT_XML1) ?>" rel="self" type="application/rss+xml"/>
<?php foreach ($items as $i): ?>
<item>
<title><![CDATA[<?= $i['title'] ?>]]></title>
<link><?= htmlspecialchars($i['link'], ENT_XML1) ?></link>
<guid isPermaLink="true"><?= htmlspecialchars($i['link'], ENT_XML1) ?></guid>
<description><![CDATA[<?= $i['desc'] ?>]]></description>
<pubDate><?= gmdate(DATE_RSS, $i['pub_ts']) ?></pubDate>
</item>
<?php endforeach; ?>
</channel>
</rss>
댓글을 작성하려면 로그인이 필요합니다.
통합이 아니라 개별적으로 제출이 더 좋은 것으로 알려져 있습니다.
Rss 자체는 1개만 제출이 가능한게 아닙니다.
따라서 게시판 별로 따로 제출하시면 더 좋은 결과를 얻으실 수 있으며
사이트 전체에 제출하는건 rss가 아니라 사이트 맵입니다.
사이트맵과 게시판별 rss 제출하시면 될 것 같습니다
답변에 대한 댓글 2개
https://sir.kr/g5_plugin/5982
플러그인 활용해보십시요
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인