2026, 새로운 도약을 시작합니다.

그룹 최신글

참고 https://sir.kr/qa/405898

추가 사항

1. lib/common.lib.php

function sql_query()에서 union을 허용 필요합니다.

2. lastet skin에서 bo_table은 $list 안에 있는 것을 써야 합니다.

3. cache 기능이 없습니다.

4. 대용량 DB에는 적합하지 않습니다.

function glatest($skin_dir='', $gr_id, $rows=10, $subject_len=40, $cache_time=1, $options='') {

    global $g5;

    if (!$skin_dir) $skin_dir = 'basic';

    if(preg_match('#^theme/(.+)$#', $skin_dir, $match)) {
        if (G5_IS_MOBILE) {
            $latest_skin_path = G5_THEME_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
            if(!is_dir($latest_skin_path))
                $latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
            $latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path);
        } else {
            $latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
            $latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path);
        }
        $skin_dir = $match[1];
    } else {
        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;
        }
    }
        $sqlg="select bo_table,bo_subject_len,bo_notice,bo_use_list_content,bo_use_sideview,bo_new,bo_hot,bo_use_list_file from {$g5['board_table']} where gr_id='$gr_id' ";
        $reg = sql_query( $sqlg);

        $board_set=array();
                $sql=" select A.* from ( ";
        if ( $row = sql_fetch_array( $reg)) {
                $sql .=" ( select '{$row['bo_table']}' bo_table, g5_write_{$row['bo_table']}.* from g5_write_{$row['bo_table']} where wr_is_comment=0 order by wr_hit DESC limit 10 ) ";
                $board_set[ $row['bo_table']]=$row;
        while( $row = sql_fetch_array( $reg)) {
                $sql .=" union ( select '{$row['bo_table']}' bo_table, g5_write_{$row['bo_table']}.* from g5_write_{$row['bo_table']} where wr_is_comment=0 order by wr_hit DESC limit 10 ) ";
                $board_set[ $row['bo_table']]=$row;
        }
                $sql .=" ) A order by wr_hit limit 10 ";
        }
        $list = array();

        $result = sql_query($sql);
        for ($i=0; $row = sql_fetch_array($result); $i++) {
            try {
                unset($row['wr_password']);     //패스워드 저장 안함( 아예 삭제 )
            } catch (Exception $e) {
            }
            $row['wr_email'] = '';              //이메일 저장 안함
            if (strstr($row['wr_option'], 'secret')){           // 비밀글일 경우 내용, 링크, 파일 저장 안함
                $row['wr_content'] = $row['wr_link1'] = $row['wr_link2'] = '';
                $row['file'] = array('count'=>0);
            }
            $list[$i] = get_list( $row, $board_set['bo_table'], $latest_skin_url, $subject_len);
        }

    ob_start();
    include $latest_skin_path.'/latest.skin.php';
    $content = ob_get_contents();
    ob_end_clean();

    return $content;
}

|

댓글 3개

삽입하고서.. 메인에다가
<?php echo glatest('theme/basic', 'aa', 10, 40, 1,); ?>
입력해보니 오류떠요 ^^;;
@g5431
<?php echo glatest('theme/basic', 'aa', 10, 40, 1,); ?>
이걸 그대로 쓰셨다면 제일 마지막에 콤마가 하나 더 들어간 게 문제 아닐까 싶습니다.
오류 내용이 뭔가요?

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

그누보드5 팁자료실

번호 제목 글쓴이 날짜 조회
공지 3년 전 조회 4,598
2741 4일 전 조회 125
2740 5일 전 조회 112
2739 1주 전 조회 212
2738 1주 전 조회 219
2737 1주 전 조회 183
2736 2주 전 조회 281
2735 3주 전 조회 286
2734 3주 전 조회 264
2733 1개월 전 조회 266
2732 1개월 전 조회 301
2731 1개월 전 조회 268
2730 1개월 전 조회 227
2729 1개월 전 조회 359
2728 1개월 전 조회 245
2727 1개월 전 조회 422
2726 1개월 전 조회 257
2725 1개월 전 조회 332
2724 1개월 전 조회 361
2723 1개월 전 조회 267
2722 1개월 전 조회 300
2721 1개월 전 조회 213
2720 2개월 전 조회 304
2719 2개월 전 조회 307
2718 2개월 전 조회 202
2717 2개월 전 조회 337
2716 2개월 전 조회 202
2715 2개월 전 조회 313
2714 2개월 전 조회 273
2713 2개월 전 조회 377
2712 2개월 전 조회 289
🐛 버그신고