24시간 내 게시판의 최신 글 개수 불러오는 방법 > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

24시간 내 게시판의 최신 글 개수 불러오는 방법 정보

24시간 내 게시판의 최신 글 개수 불러오는 방법

본문

만약 A, B, C 라는 게시판이 3개 존재하는 사이트가 있다면
위처럼 '게시판명 (24시간 내 최신글 개수)' 이런식으로 출력할 수 있는 방법이 있나요?

최신글 스킨을 찾아보아도 이런 형식은 없는 것 같아서요 ㅠㅠ
  • 복사

댓글 전체

<?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;
}
?>


해당소스 참조하시면 쉽게 결론 도출하실수잇어요.
© SIRSOFT
현재 페이지 제일 처음으로