[OPS그누보드] 5. 나테스트??? latest 최신글(3부) > 오픈소스

오픈소스

[OPS그누보드] 5. 나테스트??? latest 최신글(3부) 정보

오픈소스 [OPS그누보드] 5. 나테스트??? latest 최신글(3부)

본문

^^ 오늘은 새벽에 글을 쓰네요.

다들 존 꿈 꾸시길. ^^

 

정규식 좀 배워봤는지 모르겠네염,,

돈 되는 것이니 쉴틈없이 공부하십시요 ^^

 

 

var_dump 함수돌리묜 !

array(2) { [0]=> string(11) "theme/basic" [1]=> string(5) "basic" } 

theme 하위 디렉토리 이름을 배열 인덱스 1 공간에 쳐박아두고, 다음의 질문을 던지네염.

 

if (G5_IS_MOBILE) { 

우리는 앞으로 이 상수를 겁나게 많이 쓸 겁니다. 중요한것이겠죠.

모바일 버전이냐? PC버전이냐? 를 물어보고 있습니다.

 

모바일 버전일때는 

$latest_skin_path = G5_THEME_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1]; 

$latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path); 

절대경로와 상대경로를 담은 변수를 만들어줍니다.

 

혹시 아시나요?

css 나 js 불러올때 $latest_skin_url <- 요 변수쓰죵~~~~ ㅋㅋㅋ

 

요기부터 

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;

        }

 

    }

 

요기까정은 절대경로와 상대경로를 만들기 위한 것입니다.

스킨을 불러올려면... 디렉토리를 알아야 하고, 디렉토리 알았다면, 그 경로를 정확하게 불러올 수 있는 경로를 만들어야 include 하건 src="" 이미지 또는 CSS JS를 불러오겠죠.

 

이거 없으면. ㅋㅋㅋ 멀 불러서 쓰나. ㅎㅎ

상수에 대해서는 common.php 에 있으니.. 함 검토해보세염.

 

다음소스는 시간을 만드는 것 같네염.

최신글을 시간을 지정해서 딱 나타나는 것 같군욤..

그런데.. 솔직히 전 필요성이 없어서 패쑤하겠습니다.

 

$cache_fwrite = false;

    if(G5_USE_CACHE) {

        $cache_file = G5_DATA_PATH."/cache/latest-{$bo_table}-{$skin_dir}-{$rows}-{$subject_len}.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)

                include($cache_file);

        }

    }

 

캐시폴더 안에 파일을 만들어서 리딩처리하는 것 같습니다.

 

 

마지막으로 데이터를 불러오는 쿼리문이네염.

 

$list = array();

 

        $sql = " select * from {$g5['board_table']} where bo_table = '{$bo_table}' ";

        $board = sql_fetch($sql);

        $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++) {

            $list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);

        }

 

기본값이 $rows=10 이니 10개를 불러오겠네염 ^^

만약 메인 또는 서브페이지에 latest("스킨디렉토리명", "게시판테이블명", 3, 10); 이렇게 메세지를 보내면 $rows=10 얘는 3으로 변하고 3개를 불러오겠네염

 

내일은 요넘아로 가겠습니다. get_list() 메소드 

 

 

 

 

 

추천
0

댓글 0개

전체 75 |RSS
오픈소스 내용 검색

회원로그인

진행중 포인트경매

  1. 참여3 회 시작24.04.25 20:23 종료24.05.02 20:23
(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT