- 안내 -
1. Latest.lib.php가 1.0.1 버전으로 업데이트 되었습니다.
2. 불필요한 쿼리를 제거하여 서버 부하를 3/1 줄였습니다.
3. 기존 그누 latest.lib.php 대비 속도차이가 전무합니다.
4. 보다 진보된 캐시관리가 추가된 latest.lib.php 입니다.
- 유저가 100명, 1000명, 10000명이라도 실질적으로 분당 최근게시물 추출하는 쿼리는
오직 한번만 나가고 나머지는 1분간 한개의 케시파일에서 데이터를 추출 받습니다.
5. 그룹스킨 타이틀을 지정할 수 있습니다.
- 사용방법 -
공통사항
[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.01 사용 時
[code]<?=latest('basic','freeboard',5,60)?>
<?=latest('basic','freeboard;humorboard',5,60)?>
<?=latest('basic','freeboard;humorboard',5,60,"최근게시물 제목! bo_subject")?>
이전 보다 확장된 Latest 기능을 사용하실 수 있습니다.[/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_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]
1. Latest.lib.php가 1.0.1 버전으로 업데이트 되었습니다.
2. 불필요한 쿼리를 제거하여 서버 부하를 3/1 줄였습니다.
3. 기존 그누 latest.lib.php 대비 속도차이가 전무합니다.
4. 보다 진보된 캐시관리가 추가된 latest.lib.php 입니다.
- 유저가 100명, 1000명, 10000명이라도 실질적으로 분당 최근게시물 추출하는 쿼리는
오직 한번만 나가고 나머지는 1분간 한개의 케시파일에서 데이터를 추출 받습니다.
5. 그룹스킨 타이틀을 지정할 수 있습니다.
- 사용방법 -
공통사항
[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.01 사용 時
[code]<?=latest('basic','freeboard',5,60)?>
<?=latest('basic','freeboard;humorboard',5,60)?>
<?=latest('basic','freeboard;humorboard',5,60,"최근게시물 제목! bo_subject")?>
이전 보다 확장된 Latest 기능을 사용하실 수 있습니다.[/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_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]
게시글 목록
| 번호 | 제목 |
|---|---|
| 14227 | |
| 14211 | |
| 14207 | |
| 14198 | |
| 14192 | |
| 14178 | |
| 14170 | |
| 14149 | |
| 14134 | |
| 14123 | |
| 14108 | |
| 14094 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기