그누보드의 중규모이상 커뮤니티를 위한 커스트마이징(관리자페이지) > 그누4 팁자료실

그누4 팁자료실

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요.
나누면 즐거움이 커집니다.

그누보드의 중규모이상 커뮤니티를 위한 커스트마이징(관리자페이지) 정보

그누보드의 중규모이상 커뮤니티를 위한 커스트마이징(관리자페이지)

본문

2109149484_3b1d7305_admin1.jpg

이 로직들은 실제로 동접자수가 많은 시네스트(국내 최대자막사이트)를 제작
 
하면서 적용한 팁입니다.

중규모이상 커뮤니티를 운영하시는분이라면 느끼실 부분들을 적어봅니다.

아마도 그냥 글만 보셔도 이해되시리라 생각합니다.

일반적인 홈페이지를 만드신분들은 그냥 쓰시는게 유지보수상 더 낫습니다.
 
1. 썸네일 파일과 스킨확장을 위한 커스트마이징
 
대부분의 그누보드 스킨들이 썸네일파일을 생성하고 있으나 보드자체에서 생성하는게 아닌
 
스킨부분에서 생성을 하게 되고 또한 list.skin.php상에서 썸네일파일이 생성되어져 있나 체크하여
 
생성하는 구조형태로 제작되어 지고 있습니다.
 
이부분에서는 접속자가 많으면 당연히 불필요한 썸네일 파일체크부분이 들어가게 됨으로써
 
속도 저하를 가져오게 됩니다. 이 부분을 해결하기 위해서 list.skin.php가 아닌
 
write_update.skin.php 상에서 썸네일 파일을 생성하게끔 처리하여야 하고
 
이부분관 게시판 리스트, 게시판 보기, 최신글등에서 이미지 파일 첨부가 되지 않는 경우
 
불필요한 파일테이블에 대한 쿼리를 유발하게 됩니다. 이부분을 해결하기 위하여 관리자
 
페이지에서 해당 파일테이블($g4[file_table])을 쿼리를 체크할지 안할지를 선택하게 함으로써
 
게시판 리스트 출력시 불필요한 파일테이블에 대한 쿼리를 줄임으로써 db부하를 줄이는데
 
있습니다.
 
2. 리스트 스킨 쿼리 사용 여부
 
스킨부분에 확장을 하다보면 여분 필드를 사용하면 되지만 필드를 확장하고 검색부분등 다양한
 
구조로 들어가게되면 해당 그누보드의 기본 게시판로직에 너무 중복되고 불필요한 로직들이
 
많이 들어가게 됩니다.
 
이부분을 해결하기 위해서는 관리자페이지쪽에서 그누보드 기본 쿼리를 사용할껀지
 
스킨쪽에서 할껀지 사용여부를 체크하고 스킨쪽에서 쿼리를 사용시에는
 
bbs/list.php, board.php상에서 해당 게시판에대한 DB에 대한 작업을 중지하고
 
skin/board/basic/list.skin.php, write.skin.php, view.skin.php 스킨에서 해당 게시판에 대한
 
쿼리코드를 전부 작성함으로서 속도와 호환성 그리고 좀더 폭넓고 다양한 기능을 가진 스킨들을
 
제작가능하게 합니다.
 
3. 관리자페이지에서 썸네일 일괄생성
 
이부분은 이미 빠진 파일들에 대해서 관리자 페이지에서 일괄 썸네일 파일을 생성할려는데 목적이
 
있습니다.


lib/chameleon.thumb_nail.lib.php
<?
//############################################################
//##
//##  카멜레온 썸네일 생성 라이브러리 2007-10-25
//##
//##  P/G : ⓒⓒⓒ
//##  사이트 :  http://cm-builder.com
//##  mail : *** 개인정보보호를 위한 이메일주소 노출방지 ***
//##
//##  이 주석을 삭제하지 않는 상태에서 어떠한 수정/배포도 가능합니다.
//## 
//############################################################
function get_image_ratio($filename,$width,$height) {
    $s_size = @getimagesize($filename);
    if  ( ($s_size[0] > 0) &&  ($s_size[1] > 0) ) {
        if($s_size[0]>$width||$s_size[1]>$height) {
            if ($s_size[0] > $s_size[1])    $ratio = $width/$s_size[0];
            else                            $ratio = $height/$s_size[1];
            $img[width]  = intval($s_size[0]*$ratio);
            $img[height] = intval($s_size[1]*$ratio);
        } else {
            $img[width]  = $s_size[0];
            $img[height] = $s_size[1];
        }
    }
    return $img;
}
function cm_thumb($bo_table, $wr_id, $file, $image_width, $image_height, $quality='80')
{
    global $g4;
    $file_path = $g4[path].'/data/file/'.$bo_table;
    $file_name = $g4[path].'/data/file/'.$bo_table.'/'.$file;
    $thumb_path = $file_path.'/thumb';
    @mkdir($thumb_path, 0707);
    @chmod($thumb_path, 0707);
    $thumb = "$thumb_path/$wr_id";
   
    $return = FALSE;
    if (!file_exists($thumb)) {
        if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file_name) && file_exists($file_name)) {
            $size = getimagesize($file_name);
            if ($size[2] == 1)
                $src = imagecreatefromgif($file_name);
            else if ($size[2] == 2)
                $src = imagecreatefromjpeg($file_name);
            else if ($size[2] == 3)
                $src = imagecreatefrompng($file_name);
            else
                break;

            // 비율에 맞추어 썸네일 파일 생성
            $img_size = get_image_ratio($file_name, $image_width, $image_height);
           
            $dst = imagecreatetruecolor($img_size[width], $img_size[height]);
            imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_size[width], $img_size[height], $size[0], $size[1]);
            imagejpeg($dst, $thumb, $quality);
            chmod($thumb, 0606);
            $return = TRUE;
        }
    } else $return = TRUE;
    return $return;
}
function cm_thumb_nail($bo_table, $i, $list, $image_width, $image_height, $quality='80')
{
    global $g4;
    $thumb_path = $g4[path].'/data/file/'.$bo_table.'/thumb';
    @mkdir($thumb_path, 0707);
    @chmod($thumb_path, 0707);
    $thumb = $thumb_path.'/'.$list[$i][wr_id];
   
    $return = FALSE;
    if (!file_exists($thumb)) {
        $file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
        if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file)) {
            $size = getimagesize($file);
            if ($size[2] == 1)
                $src = imagecreatefromgif($file);
            else if ($size[2] == 2)
                $src = imagecreatefromjpeg($file);
            else if ($size[2] == 3)
                $src = imagecreatefrompng($file);
            else
                break;
            // 비율에 맞추어 썸네일 파일 생성
            $img_size = get_image_ratio($file, $image_width, $image_height);
           
    //            $rate = $image_width / $size[0];
    //            $height = (int)($size[1] * $rate);
            $dst = imagecreatetruecolor($img_size[width], $img_size[height]);
            imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_size[width], $img_size[height], $size[0], $size[1]);
            imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], 80);
            chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
            $return = TRUE;
        }
    } else $return = TRUE;
  
    return $return;
}
?>




skin/board/basic/write_update.skin.php
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
include_once("$g4[path]/lib/chameleon.thumb_nail.lib.php");   
for ($i=0; $i<count($upload); $i++)
{
        cm_thumb($bo_table, $wr_id, $upload[$i][file], $board['bo_img_thumb_width'], $board['bo_img_thumb_height'], 80);
}
?>


adm/board_form.php   수정해야할부분 카운트 조정이후에 추가
<tr><td colspan=3 class='line2'></td></tr>
<tr class='ht'>
    <td></td>
    <td>리스트 스킨 쿼리사용</td>
    <td>
        <select name=bo_query_use>
            <option value='' <?=($board[bo_query_use]=='')?'selected':'';?>>기본구조사용</option>
            <option value='1' <?=($board[bo_query_use])?'selected':'';?>>스킨에서 쿼리생성</option>
        </select>
        <?=help("기능확장을 위하여 스킨에서 쿼리생성시 설정하여 중복 실행에 따른 속도 저하 방지")?>
    </td>
</tr>
<tr class='ht'>
    <td></td>
    <td>List 출력시 파일사용</td>
    <td>
        <select name=bo_list_file_use>
            <option value='' <?=($board[bo_list_file_use]=='')?'selected':'';?>>미사용</option>
            <option value='1' <?=($board[bo_list_file_use])?'selected':'';?>>사용</option>
        </select>
        <?=help("리스트 항목 추출시 파일 쿼리를 사용하지 않음으로써 불필요한 DB부하방지")?>
    </td>
</tr>
<tr class='ht'>
    <td></td>
    <td>View 출력시 파일사용</td>
    <td>
        <select name=bo_view_file_use>
            <option value='' <?=($board[bo_view_file_use]=='')?'selected':'';?>>미사용</option>
            <option value='1' <?=($board[bo_view_file_use])?'selected':'';?>>사용</option>
        </select>
        <?=help("View 시 파일 쿼리를 사용하지 않음으로써 불필요한 DB부하방지 ")?>
    </td>
</tr>
<tr class='ht'>
    <td></td>
    <td>IMG Upload Thumb생성</td>
    <td>
        <select name=bo_write_img_thumb_use>
            <option value='' <?=($board[bo_write_img_thumb_use]=='')?'selected':'';?>>미생성</option>
            <option value='1' <?=($board[bo_write_img_thumb_use])?'selected':'';?>>생성</option>
        </select>
        WIDTH : <input type=text name=bo_img_thumb_width value='<?=$board[bo_img_thumb_width]?>' size=3>px, 
        HEIGHT : <input type=text name=bo_img_thumb_height value='<?=$board[bo_img_thumb_height]?>' size=3>px
        <input type=button name=썸네일생성 value='전체생성' onclick="document.location.href='./board_thumb_nail.php?bo_table=<?=$bo_table?>';">
        <?=help("이미지파일 업로드시 썸네일파일을 자동으로 생성합니다.")?>
    </td>
</tr>
<tr><td colspan=3 class='line2'></td></tr>


adm/board_form_update.php   쿼리부분에 추가
$sql_common = " gr_id               = '$_POST[gr_id]',
                bo_subject          = '$bo_subject',
                bo_admin            = '$bo_admin',
                bo_list_level       = '$bo_list_level',
                bo_read_level       = '$bo_read_level',
                bo_write_level      = '$bo_write_level',
                bo_reply_level      = '$bo_reply_level',
                bo_comment_read_level = '$bo_comment_read_level',
                bo_comment_level    = '$bo_comment_level',
                bo_html_level       = '$bo_html_level',
                bo_link_level       = '$bo_link_level',
                bo_trackback_level  = '$bo_trackback_level',
                bo_count_modify     = '$bo_count_modify',
                bo_count_delete     = '$bo_count_delete',
                bo_upload_level     = '$bo_upload_level',
                bo_download_level   = '$bo_download_level',
                bo_read_point       = '$bo_read_point',
                bo_write_point      = '$bo_write_point',
                bo_comment_point    = '$bo_comment_point',
                bo_download_point   = '$bo_download_point',
                bo_use_category     = '$bo_use_category',
                bo_category_list    = '$bo_category_list',
                bo_disable_tags     = '$bo_disable_tags',
                bo_use_sideview     = '$bo_use_sideview',
                bo_use_file_content = '$bo_use_file_content',
                bo_use_secret       = '$bo_use_secret',
                bo_use_dhtml_editor = '$bo_use_dhtml_editor',
                bo_use_rss_view     = '$bo_use_rss_view',
                bo_use_comment      = '$bo_use_comment',
                bo_use_good         = '$bo_use_good',
                bo_use_nogood       = '$bo_use_nogood',
                bo_use_name         = '$bo_use_name',
                bo_use_signature    = '$bo_use_signature',
                bo_use_ip_view      = '$bo_use_ip_view',
                bo_use_trackback    = '$bo_use_trackback',
                bo_use_list_view    = '$bo_use_list_view',
                bo_use_list_content = '$bo_use_list_content',
                bo_use_email        = '$bo_use_email',
                bo_table_width      = '$bo_table_width',
                bo_subject_len      = '$bo_subject_len',
                bo_page_rows        = '$bo_page_rows',
                bo_new              = '$bo_new',
                bo_hot              = '$bo_hot',
                bo_image_width      = '$bo_image_width',
                bo_skin             = '$bo_skin',
                bo_include_head     = '$bo_include_head',
                bo_include_tail     = '$bo_include_tail',
                bo_content_head     = '$bo_content_head',
                bo_content_tail     = '$bo_content_tail',
                bo_insert_content   = '$bo_insert_content',
                bo_gallery_cols     = '$bo_gallery_cols',
                bo_upload_count     = '$bo_upload_count',
                bo_upload_size      = '$bo_upload_size',
                bo_reply_order      = '$bo_reply_order',
                bo_use_search       = '$bo_use_search',
                bo_order_search     = '$bo_order_search',
                bo_write_min        = '$bo_write_min',
                bo_write_max        = '$bo_write_max',
                bo_comment_min      = '$bo_comment_min',
                bo_comment_max      = '$bo_comment_max',
                bo_sort_field       = '$bo_sort_field',
                bo_query_use        = '$bo_query_use',    // 추가됨
                bo_list_file_use    = '$bo_list_file_use',     // 추가됨
                bo_view_file_use    = '$bo_view_file_use',  // 추가됨
                bo_write_img_thumb_use = '$bo_write_img_thumb_use',  //추가됨
                bo_img_thumb_width  = '$bo_img_thumb_width',   //추가됨
                bo_img_thumb_height = '$bo_img_thumb_height'   // 추가됨
                ";




adm/board_thumb_nail.php
<?
$sub_menu = "300100";
include_once("./_common.php");
$g4[title] = $html_title;
include_once ("./admin.head.php");
//############################################################
//##
//##  카멜레온 썸네일 생성 2007-10-25
//##  P/G : ⓒⓒⓒ
//##  mail : http://cm-builder.com
//##  이 주석을 삭제하지 않는 상태에서 어떠한 수정/배포도 가능합니다.
//##
//############################################################
auth_check($auth[$sub_menu], "w");
function get_image_ratio($filename,$width,$height) {
    $s_size = @getimagesize($filename);
    if  ( ($s_size[0] > 0) &&  ($s_size[1] > 0) ) {
        if($s_size[0]>$width||$s_size[1]>$height) {
            if ($s_size[0] > $s_size[1])    $ratio = $width/$s_size[0];
            else                            $ratio = $height/$s_size[1];
            $img[width]  = intval($s_size[0]*$ratio);
            $img[height] = intval($s_size[1]*$ratio);
        } else {
            $img[width]  = $s_size[0];
            $img[height] = $s_size[1];
        }
    }
    return $img;
}
$board_path = "$g4[path]/data/file/$bo_table";
$thumb_path = $board_path."/thumb";
// 게시판 디렉토리 생성
@mkdir($board_path, 0707);
@chmod($board_path, 0707);
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);

$sql = " select * FROM {$g4['board_file_table']} WHERE bo_table = '$bo_table' and bf_no = '0' ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) {
    $file_name = $board_path.'/'.$row[bf_file];
    $thumb = $thumb_path.'/'.$row[wr_id];
    @unlink($thumb);
    if (preg_match("/\.(jp[e]?g|gif|png)$/i", $row[bf_file])) {
        $size = getimagesize($file_name);
        if ($size[2] == 1)
            $src = imagecreatefromgif($file_name);
        else if ($size[2] == 2)
            $src = imagecreatefromjpeg($file_name);
        else if ($size[2] == 3)
            $src = imagecreatefrompng($file_name);
        else
//            break;
        echo $thumb;
        // 비율에 맞추어 썸네일 파일 생성
        $img_size = get_image_ratio($file_name, $board[bo_img_thumb_width], $board[bo_img_thumb_height]);
       
        $dst = imagecreatetruecolor($img_size[width], $img_size[height]);
        imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_size[width], $img_size[height], $size[0], $size[1]);
        imagejpeg($dst, $thumb, 80);
        chmod($thumb, 0606);
        echo $thumb.'<br>';
    }
}
echo "------------- 게시판 전체 썸네일 생성 완료----------<br>";
?>
<p align=center>
    <input type=button class=btn1 value='  수정모드  ' onclick="document.location.href='./board_form.php?bo_table=<?=$bo_table?>';"> 
    <input type=button class=btn1 value='  목  록  ' onclick="document.location.href='./board_list.php?<?=$qstr?>';"> 
</p>
<?
include_once ("./admin.tail.php");
?>




작성자 : http://cm-builder.com 시시시
추천
1

댓글 6개

thumb/ 폴더안에 1 이라는 파일로 썸네일이 생성되는데요,
그럼 리스트에서 썸네일 파일을 불러올려면 어떻게 해야하나요?
<?
$image = urlencode($list[$i][file][0][file]); // 첫번째 파일이 이미지라면 
if (preg_match("/\.(gif|jpg|png)$/i", $image)) {
$thumbimg="$g4[path]/data/file/$bo_table/thumb/" . $list[$i][wr_id];
echo "<img src='$thumbimg' height='52' border='0' style='border:1px solid; border-color:#666666; margin:0 5px 0 0;'>";
}
else if (file_exists($list[$i][file_image1])) {
echo "<img src='$g4[path]/data/file/$bo_table/$image' height='52' border='0' style='border:1px solid; border-color:#666666; margin:0 5px 0 0;'>";
}
else {echo "";}
?>

썸네일 불러오기는 어떻게 다른 스킨소스 적용해보니깐 되는데요,,
위에서 else if 다음에는 저렇게 하면 되는건가요?
이미지가 없을경우에는 그냥 사이즈 없이 파일 안불러오게 할려면요???
그런데,,,

이미지를 업로드후에 글수정에서 이미지를 바꾸면 바뀐 이미지로 썸네일이 업데이트 되는건가요?
이전 썸네일이 나오네요 ㅠㅠ
전체 3,313 |RSS
그누4 팁자료실 내용 검색

회원로그인

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