테스트 사이트 - 개발 중인 베타 버전입니다

[필수설치] Latest 1.0.3 - 확장 최근게시물 추출 ( 다중게시판 추출 지원 )

· 11년 전 · 10427 · 5
e01.PNG
- 안내 -
1. Latest.lib.php가 1.0.3 버전으로 업데이트 되었습니다.
2. 다중게시판을 무한대로 추가 할 수 있도록 업데이트 하였습니다.

- 사용방법 -
공통사항
[code]<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

include_once(G5_PATH.'/head.sub.php');
include_once(G5_LIB_PATH.'/latest.lib.php');
include_once(G5_LIB_PATH.'/outlogin.lib.php');
include_once(G5_LIB_PATH.'/poll.lib.php');
include_once(G5_LIB_PATH.'/visit.lib.php');
include_once(G5_LIB_PATH.'/connect.lib.php');
include_once(G5_LIB_PATH.'/popular.lib.php');

if (G5_IS_MOBILE) {
include_once(G5_MOBILE_PATH.'/head.php');
return;
}
...
head파일에는 위와 같이 latest.lib.php 가 include되어 있어야합니다.[/code]


그누보드5 latest.lib.php 사용 時
[code]<?=latest('basic','freeboard',5,60)?>[/code]

Latest.lib.php 1.0.3 사용 時
[code]<?=latest('basic','freeboard',5,60)?>
<?=latest('basic','freeboard;humorboard',5,60)?>
<?=latest('basic','freeboard;humorboard',5,60,"최근게시물 제목! bo_subject")?>
이전 보다 확장된 Latest 기능을 사용하실 수 있습니다.[/code]




------------------------------------
홈페이지 전체 게시물 추출시
[code]<?php
// 최신글
$sql = " select bo_table from `{$g5['board_table']}` a left join `{$g5['group_table']}` b on (a.gr_id=b.gr_id) where a.bo_device <> 'mobile' order by b.gr_order, a.bo_order ";
$result = sql_query($sql);
$bo_table_list = "";
for ($i=0; $row=sql_fetch_array($result); $i++) {
if($i != 0) $bo_table_list .= ";";
$bo_table_list .= $row['bo_table'];
}
echo latest("basic",$bo_table_list,6,40,"전체 최근 게시물");
?>[/code]






내부 소스
[code]<?php
if (!defined('_GNUBOARD_')) exit;

/* 다중게시판 최신글 추출 Latest */
/* 제작 : SIR 내컴퓨터 */
/* 버전 : 1.0.2 */
/* 마스타님께서 if (!G5_USE_CACHE || !file_exists($cache_file)) { 부분 이상 검출 */

function latest($skin_dir='basic', $bo_table=false, $rows=10, $subject_len=40,$bo_title=false)
{
global $g5;
static $css = array();
$bo_table = explode(';' , $bo_table);

/* 모바일 스킨 디렉토리 */
if(G5_IS_MOBILE) {
$latest_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;
$latest_skin_url = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;
}
/* 데스크탑 스킨 디렉토리 */
else {
$latest_skin_path = G5_SKIN_PATH.'/latest/'.$skin_dir;
$latest_skin_url = G5_SKIN_URL.'/latest/'.$skin_dir;
}

/* Latest 케시파일 생성 */
$cache_botable = "";
$cache_time = date("Ymdhi");
for($y=0;$y<count($bo_table);$y++){
$cache_botable .= $bo_table[$y];
}
$cache_botable = md5($cache_botable);
$cache_newfile = G5_DATA_PATH."/cache/latest-{$cache_botable}-{$skin_dir}-{$rows}-{$subject_len}-{$cache_time}.php";

/* 최근 1분간 새로 등록된 케시가 없을경우 DB에서 데이터 추출후 신규 케시 생성 */
if (!G5_USE_CACHE || !file_exists($cache_newfile)) {
/* 다중 게시판 게시물 추출 */
$sql = "select a.* from ";
for($y=0;$y<count($bo_table);$y++){
if($y!=0) $sql .= "union all ";
else $sql .= "( ";
$tmp_write_table = $g5['write_prefix'] . $bo_table[$y]; // 게시판 테이블 전체이름
$sql .= "select *,'{$bo_table[$y]}' as `bo_table` from {$tmp_write_table} "; //
if($y+1==count($bo_table)) $sql .= ") ";
}
$sql .= "a where `wr_is_comment` = 0 order by `wr_datetime` DESC limit ".$rows." ";
$result = sql_query($sql);

/* 다중 게시판 게시물 리스트 추출 */
$list = array();
for ($i=0; $row = sql_fetch_array($result); $i++) {
/* 추출된 게시물이 등록된 게시판 매칭 */
for($y=0;$y<count($bo_table);$y++){
if ($bo_table[$y]==$row['bo_table']){
$sql = "select * from `{$g5['board_table']}` where `bo_table` = '{$bo_table[$y]}' ";
$board = sql_fetch($sql);
}
}
$list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);
}

/* 기존에 등록된 케시파일을 삭제 */
$files = glob(G5_DATA_PATH."/cache/latest-{$cache_botable}-{$skin_dir}-{$rows}-{$subject_len}-*");
if (is_array($files)) {
$cnt=0;
foreach ($files as $cache_oldfile) {
$cnt++;
unlink($cache_oldfile);
}
}

/* 케시파일 신규 생성 */
$handle = fopen($cache_newfile, 'w');
$cache_content = "<?php\nif (!defined('_GNUBOARD_')) exit;\n\$bo_subject=\"".get_text($board['bo_subject'])."\";\n\$list=".var_export($list, true)."?>";
fwrite($handle, $cache_content);
fclose($handle);
}

/* 케시파일 로드 */
include_once($cache_newfile);

/* List에서 사용할 Board 데이터 추출 */
$bo_table = $bo_table[0];
if($bo_title) $bo_subject = $bo_title;

/* 스킨연결 */
ob_start();
include $latest_skin_path.'/latest.skin.php';
$content = ob_get_contents();
ob_end_clean();

return $content;
}
?>[/code]

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 5개

고맙습니다.
어디다가 파일을 넣는거에요/>
11년 전
감사합니다.
좋은 플러그인 만들어 주셔서 감사합니다.

질문이 있는데요 플러그인을 적용하고 갤러리 게시판 3개를 설정했는데 타이틀은 잘 나오나 이미지는 1개의 게시판만 나오고 나머지 게시판의 이미지는 노출이 안됩니다.

어떻게 해결해야 할까요? 따로 요 플러그인의 스킨이 있어야 하는건가요?

혹시 다른 방법이 있으면 부탁드립니다. ^^
11년 전
제가 그부분을 간과했네요. ㅎㅎ!

나중에 이번 의뢰 끝나고 한번 업데이트 하도록하겟습니다.