[전체게시판] 일일/주간/월간 인기 게시물 정보
[전체게시판] 일일/주간/월간 인기 게시물관련링크
첨부파일
본문
[전체게시판] 일일/주간/월간 인기 게시물 (원본: 미니님a)
// 출력할 게시물 수
$rows = 10;// 각 기간별 게시물을 가져오는 함수
function get_popular_posts($period, $rows) {
global $g5;
$today = date('Y-m-d');
switch($period) {
case 'daily':
$start_date = date('Y-m-d', strtotime('-3 day'));
break;
case 'weekly':
$start_date = date('Y-m-d', strtotime('-7 days'));
break;
case 'monthly':
$start_date = date('Y-m-d', strtotime('-30 days'));
break;
default:
$start_date = date('Y-m-d', strtotime('-3 day'));
}
$list = array();
// 모든 게시판 가져오기
$board_sql = "SELECT bo_table FROM {$g5['board_table']} WHERE bo_use_search = 1";
$board_result = sql_query($board_sql);
// 모든 게시판의 인기글을 통합하여 가져옴
$sql = " SELECT
a.bo_table,
a.wr_id,
a.wr_subject,
a.wr_comment,
a.wr_hit,
a.wr_datetime
FROM (";
$union_sql = array();
while ($board = sql_fetch_array($board_result)) {
$bo_table = $board['bo_table'];
// 게시판 테이블이 존재하는지 확인
$table_exists = sql_query("SHOW TABLES LIKE '{$g5['write_prefix']}{$bo_table}'", false);
if (sql_num_rows($table_exists) == 0) continue;
$union_sql[] = " SELECT
'{$bo_table}' as bo_table,
wr_id,
wr_subject,
wr_comment,
wr_hit,
wr_datetime
FROM {$g5['write_prefix']}{$bo_table}
WHERE wr_is_comment = 0
AND wr_datetime BETWEEN '{$start_date} 00:00:00' AND '{$today} 23:59:59'";
}
// UNION ALL 쿼리 생성
if (count($union_sql) > 0) {
$sql .= implode(" UNION ALL ", $union_sql);
$sql .= ") a ORDER BY a.wr_hit DESC, a.wr_comment DESC LIMIT 0, {$rows} ";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {
$list[$i]['bo_table'] = $row['bo_table'];
$list[$i]['wr_id'] = $row['wr_id'];
$list[$i]['subject'] = $row['wr_subject'];
$list[$i]['comment_cnt'] = $row['wr_comment'];
$list[$i]['hit'] = $row['wr_hit'];
$list[$i]['datetime'] = $row['wr_datetime'];
// 게시판 제목 가져오기
$board_info = sql_fetch("SELECT bo_subject FROM {$g5['board_table']} WHERE bo_table = '{$row['bo_table']}'");
$list[$i]['bo_subject'] = $board_info['bo_subject'];
}
}
return $list;
}
2
댓글 6개

태글은 아닙니다.
미니님 스킨하고 차이점은 무엇인가요?
아무 설명 없이 함수만 있어서 두 스킨의 차이점이 궁금합니다.
@무와보
안녕하세요. 미나님의 스킨은 일정게시판을 추가하면서 인기게시물을 뽑는 함수인데
저는 이를 변형해서 모든(개설된 전체)게시판에서 인기게시물로 뽑는 함수로 변경하였습니다.
자세한 설명이 없었네요...

@모아비즈 아~ 이해 했습니다 :)
@무와보 네...감사합니다...^.^~

감사합니다.
@DawnDew 감사합니다...~~~!!!