5.4 버전 내용 적용
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit;
|
||||
@include_once(G5_LIB_PATH.'/thumbnail.lib.php');
|
||||
|
||||
// 최신글 추출
|
||||
// $cache_time 캐시 갱신시간
|
||||
@ -30,46 +31,26 @@ function latest($skin_dir='', $bo_table, $rows=10, $subject_len=40, $cache_time=
|
||||
}
|
||||
}
|
||||
|
||||
$cache_fwrite = false;
|
||||
$caches = null;
|
||||
|
||||
if(G5_USE_CACHE) {
|
||||
$cache_file = G5_DATA_PATH."/cache/latest-{$bo_table}-{$skin_dir}-{$rows}-{$subject_len}-serial.php";
|
||||
|
||||
if(!file_exists($cache_file)) {
|
||||
$cache_fwrite = true;
|
||||
} else {
|
||||
if($cache_time > 0) {
|
||||
$filetime = filemtime($cache_file);
|
||||
if($filetime && $filetime < (G5_SERVER_TIME - 3600 * $cache_time)) {
|
||||
@unlink($cache_file);
|
||||
$cache_fwrite = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$cache_fwrite) {
|
||||
try{
|
||||
$file_contents = file_get_contents($cache_file);
|
||||
$file_ex = explode("\n\n", $file_contents);
|
||||
$caches = unserialize(base64_decode($file_ex[1]));
|
||||
|
||||
$list = (is_array($caches) && isset($caches['list'])) ? $caches['list'] : array();
|
||||
$bo_subject = (is_array($caches) && isset($caches['bo_subject'])) ? $caches['bo_subject'] : '';
|
||||
} catch(Exception $e){
|
||||
$cache_fwrite = true;
|
||||
$list = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
$cache_file_name = "latest-{$bo_table}-{$skin_dir}-{$rows}-{$subject_len}-".g5_cache_secret_key();
|
||||
$caches = g5_get_cache($cache_file_name);
|
||||
$cache_list = isset($caches['list']) ? $caches['list'] : array();
|
||||
g5_latest_cache_data($bo_table, $cache_list);
|
||||
}
|
||||
|
||||
if(!G5_USE_CACHE || $cache_fwrite) {
|
||||
if( $caches === false ){
|
||||
|
||||
$list = array();
|
||||
|
||||
$sql = " select * from {$g5['board_table']} where bo_table = '{$bo_table}' ";
|
||||
$board = sql_fetch($sql);
|
||||
$board = get_board_db($bo_table, true);
|
||||
|
||||
$bo_subject = get_text($board['bo_subject']);
|
||||
|
||||
$tmp_write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
|
||||
$sql = " select * from {$tmp_write_table} where wr_is_comment = 0 order by wr_num limit 0, {$rows} ";
|
||||
|
||||
$result = sql_query($sql);
|
||||
for ($i=0; $row = sql_fetch_array($result); $i++) {
|
||||
try {
|
||||
@ -82,22 +63,38 @@ function latest($skin_dir='', $bo_table, $rows=10, $subject_len=40, $cache_time=
|
||||
$row['file'] = array('count'=>0);
|
||||
}
|
||||
$list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);
|
||||
}
|
||||
|
||||
if($cache_fwrite) {
|
||||
$handle = fopen($cache_file, 'w');
|
||||
$list[$i]['first_file_thumb'] = (isset($row['wr_file']) && $row['wr_file']) ? get_board_file_db($bo_table, $row['wr_id'], 'bf_file, bf_content', "and bf_type between '1' and '3'", true) : array('bf_file'=>'', 'bf_content'=>'');
|
||||
$list[$i]['bo_table'] = $bo_table;
|
||||
// 썸네일 추가
|
||||
if($options && is_string($options)) {
|
||||
$options_arr = explode(',', $options);
|
||||
$thumb_width = $options_arr[0];
|
||||
$thumb_height = $options_arr[1];
|
||||
$thumb = get_list_thumbnail($bo_table, $row['wr_id'], $thumb_width, $thumb_height, false, true);
|
||||
// 이미지 썸네일
|
||||
if($thumb['src']) {
|
||||
$img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" width="'.$thumb_width.'" height="'.$thumb_height.'">';
|
||||
$list[$i]['img_thumbnail'] = '<a href="'.$list[$i]['href'].'" class="lt_img">'.$img_content.'</a>';
|
||||
// } else {
|
||||
// $img_content = '<img src="'. G5_IMG_URL.'/no_img.png'.'" alt="'.$thumb['alt'].'" width="'.$thumb_width.'" height="'.$thumb_height.'" class="no_img">';
|
||||
}
|
||||
}
|
||||
}
|
||||
g5_latest_cache_data($bo_table, $list);
|
||||
|
||||
if(G5_USE_CACHE) {
|
||||
|
||||
$caches = array(
|
||||
'list' => $list,
|
||||
'bo_subject' => sql_escape_string($bo_subject),
|
||||
);
|
||||
$cache_content = "<?php if (!defined('_GNUBOARD_')) exit; ?>\n\n";
|
||||
$cache_content .= base64_encode(serialize($caches)); //serialize
|
||||
);
|
||||
|
||||
fwrite($handle, $cache_content);
|
||||
fclose($handle);
|
||||
|
||||
@chmod($cache_file, 0640);
|
||||
g5_set_cache($cache_file_name, $caches, 3600 * $cache_time);
|
||||
}
|
||||
} else {
|
||||
$list = $cache_list;
|
||||
$bo_subject = (is_array($caches) && isset($caches['bo_subject'])) ? $caches['bo_subject'] : '';
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
Reference in New Issue
Block a user