[필수설치] Latest.lib.php 1.02 - 다중게시판 출력 가능 ( 기존스킨 100% 호환 ) 정보
[필수설치] Latest.lib.php 1.02 - 다중게시판 출력 가능 ( 기존스킨 100% 호환 )관련링크
http://jeongum.com/
481회 연결
http://new.jeongum.com/
411회 연결
첨부파일
본문
- 안내 -
1. Latest.lib.php가 1.0.1 버전으로 업데이트 되었습니다.
2. 불필요한 쿼리를 제거하여 서버 부하를 3/1 줄였습니다.
3. 기존 그누 latest.lib.php 대비 속도차이가 전무합니다.
4. 보다 진보된 캐시관리가 추가된 latest.lib.php 입니다.
- 유저가 100명, 1000명, 10000명이라도 실질적으로 분당 최근게시물 추출하는 쿼리는
오직 한번만 나가고 나머지는 1분간 한개의 케시파일에서 데이터를 추출 받습니다.
5. 그룹스킨 타이틀을 지정할 수 있습니다.
- 사용방법 -
공통사항
그누보드5 latest.lib.php 사용 時
Latest.lib.php 1.01 사용 時
내부 소스
1. Latest.lib.php가 1.0.1 버전으로 업데이트 되었습니다.
2. 불필요한 쿼리를 제거하여 서버 부하를 3/1 줄였습니다.
3. 기존 그누 latest.lib.php 대비 속도차이가 전무합니다.
4. 보다 진보된 캐시관리가 추가된 latest.lib.php 입니다.
- 유저가 100명, 1000명, 10000명이라도 실질적으로 분당 최근게시물 추출하는 쿼리는
오직 한번만 나가고 나머지는 1분간 한개의 케시파일에서 데이터를 추출 받습니다.
5. 그룹스킨 타이틀을 지정할 수 있습니다.
- 사용방법 -
공통사항
<?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되어 있어야합니다.
그누보드5 latest.lib.php 사용 時
<?=latest('basic','freeboard',5,60)?>
Latest.lib.php 1.01 사용 時
<?=latest('basic','freeboard',5,60)?>
<?=latest('basic','freeboard;humorboard',5,60)?>
<?=latest('basic','freeboard;humorboard',5,60,"최근게시물 제목! bo_subject")?>
이전 보다 확장된 Latest 기능을 사용하실 수 있습니다.
내부 소스
<?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_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;
}
?>
추천
7
7
댓글 전체
고생하셨네요.
선 추천, 후 다운 할께요~^^
선 추천, 후 다운 할께요~^^
감사합니다.
좋은 소스 감사합니다..
감사합니다.....
------------------
<?=latest('basic','freeboard;humorboard',5,60,"최근게시물 제목! bo_subject")?> <--- bo_subject 가 테이블명을 호출할수 있는건가요?
------------------
<?=latest('basic','freeboard;humorboard',5,60,"최근게시물 제목! bo_subject")?> <--- bo_subject 가 테이블명을 호출할수 있는건가요?
테이블명을 별도로 지정하고 싶을때 사용하는겁니다.
입력안하면 기존스킨의 최근게시물 타이틀이 그대로 출력됩니다
입력안하면 기존스킨의 최근게시물 타이틀이 그대로 출력됩니다
그누xe빌더에 함 적용해볼라꼬 하는데
select a.* from ( select *,'0' as `bo_table` from g5_write_0 ) a where `wr_is_comment` = 0 order by `wr_datetime` DESC limit 8
1146 : Table 'ryogolf_1.g5_write_0' doesn't exist
error file : /gnuxe/index.php
요런 에러가 납니다...... 1146이면 db table이 없다는 에러라는데.....우짜하는쥐..
select a.* from ( select *,'0' as `bo_table` from g5_write_0 ) a where `wr_is_comment` = 0 order by `wr_datetime` DESC limit 8
1146 : Table 'ryogolf_1.g5_write_0' doesn't exist
error file : /gnuxe/index.php
요런 에러가 납니다...... 1146이면 db table이 없다는 에러라는데.....우짜하는쥐..
네 bo_table값을 제대로 적용시켜주면 될겁니다. 양식 맞추셧나요?
if (!G5_USE_CACHE || !file_exists($cache_file)) {
이 구문이 맞는 건가요? $cache_file 변수가 쓰인 곳이 없는데요.. ^^
이 구문이 맞는 건가요? $cache_file 변수가 쓰인 곳이 없는데요.. ^^
$cache_newfile 입니다. 수정해서 업로드할게요 지적감사합니다. ㅎ
감사합니다
다중 최신글 긁어오기