첨부파일 순서 > 그누4 질문답변

그누4 질문답변

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

첨부파일 순서 정보

첨부파일 순서

본문

1번 2번 첨부파일 업로드 이후

1번 첨부파일을 삭제하면

리스트 이미지에선 1번이 없기때문에 노이미지가 발생되네요

1번이 없다면 2번이 없다면 3번 이런식으로 갈려면...

어케 진행해야할지 ㅠㅠ

댓글 전체

<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가

$img_width = 80; //썸네일 가로길이
$img_height = 80; //썸네일 세로길이
$img_quality = 100; //퀼리티 100이하로 설정

if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.");

$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb'; //썸네일 이미지 생성 디렉토리

@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);?>

<!-- 게시판 목록 시작 -->
<table width="<?=$width?>" align="center" cellpadding="0" cellspacing="0"><tr><td>
       
    <div class="board_top">
        <div style="float:left;">
            <form name="fcategory" method="get" style="margin:0px;">
            <? if ($is_category) { ?>
            <select name=sca onchange="location='<?=$category_location?>'+this.value;">
            <option value=''>전체</option>
            <?=$category_option?>
            </select>
            <? } ?>
            </form>
        </div>
        <div style="float:right;">
            <img src="<?=$board_skin_path?>/img/icon_total.gif" align="absmiddle" border='0' title="게시물수">
            <span style="color:#888888; font-weight:bold;">Total <?=number_format($total_count)?></span>
            <? if ($rss_href) { ?><a href='<?=$rss_href?>'><img src='<?=$board_skin_path?>/img/btn_rss.gif' border='0' align="absmiddle" title="Rss"></a><?}?>
            <? if ($admin_href) { ?><a href="<?=$admin_href?>"><img src="<?=$board_skin_path?>/img/btn_admin.gif" border='0' title="관리자" align="absmiddle"></a><?}?>
        </div>
    </div>
<div style="height:1px; line-height:1px; font-size:1px; background-color:#dedede; clear:both;">&nbsp;</div>
    <!-- 제목 -->
    <form name="fboardlist" method="post">
    <input type='hidden' name='bo_table' value='<?=$bo_table?>'>
    <input type='hidden' name='sfl'  value='<?=$sfl?>'>
    <input type='hidden' name='stx'  value='<?=$stx?>'>
    <input type='hidden' name='spt'  value='<?=$spt?>'>
    <input type='hidden' name='page' value='<?=$page?>'>
    <input type='hidden' name='sw'  value=''>

<?
$mod = $board[bo_gallery_cols];
$td_width = (int)(100 / $mod);
?>

    <table cellspacing="0" cellpadding="0" class="board_list">
<tr>
    <?
    for ($i=0; $i<count($list); $i++) {
        $bg = $i%2 ? 0 : 1;
    ?>

        <?
        for($j=0; $j<$list[$i][file]["count"]; $j++){
if ($i && $i%$mod==0)
    echo "</tr><tr>";

$img = "";
$thumb = $thumb_path.'/'.$list[$i][wr_id];
// 썸네일 이미지가 존재하지 않는다면
if (!file_exists($thumb))
{
$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];

if(preg_match("/\.(jp[e]?g|gif|png|bmp)$/i", $file) && file_exists($file)){
$file = $file; //파일첨부
}elseif(preg_match("/data\/cheditor4[^<>]*\.(gif|jp[e]?g|png|bmp)/i", $list[$i]['wr_content'], $tmp)){
$file = '../' . $tmp[0]; //에디터 이미지 첨부 및 링크 이미지까지
}else{
$file = "";
}

if ($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;

$rate = $img_width / $size[0];
$height = (int)($size[1] * $rate);

// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
}
}

if (file_exists($thumb)){
$img = "<img src='$thumb' width='$img_width' height='$img_height' style='border:3px solid #eee;'  />";

}

if($list[$i][file][$j][image_type] >= 1 && $list[$i][file][$j][image_type] <= 3) {
$list[$i][thumbnail][path] = $list[$i][file][$j][path];
$list[$i][thumbnail][name] = $list[$i][file][$j][file];
$list[$i][thumbnail][content] = $list[$i][file][$j][bf_content];
$list[$i][thumbnail][href] = $list[$i][thumbnail][path]."/".$list[$i][thumbnail][name];
$list[$i][thumbnail][src] = $list[$i][thumbnail][path]."/thumbnail/".$list[$i][thumbnail][name];
if(!is_file($list[$i][thumbnail][src])){
$list[$i][thumbnail][src] = $list[$i][thumbnail][path]."/".$list[$i][thumbnail][name];
// 이미지 비률 수정및 이미지 포멧방식 체크
list($r_width[$i]) = getimagesize($list[$i][thumbnail][src]);
}
break;
}
}
?>


스타일내용은 제외하고 기재했는데  ㅠㅠ

그리고 첨부파일이 없으면 내용에 이미지를 확인해서 섬네일 생성인 코드도 적용이 안되네요 ㅠㅠ

//에디터 이미지 첨부 및 링크 이미지까지 <--이부분이요

모든 경우에 이미지가 없다면 no_image.gif를 섬네일로 하려면..또 어케해야하는지...
약간 구조만 알면 쉽게 됩니다.
$list배열을 어디서 만드는지와 $list[file]가 어떻게 만들어지는지 이 두가지만 알면됩니다.

리스트 스킨의 $list[$i][file]은
실제적으로 common.lib.php의 get_list()함수에서 get_file()함수를 호출해와서 $list[file]로 만들어 주기때문이죠

리스트 스킨에서 처리를 하려고 하면
for 문으로
$list[$i][file][루프]를 돌려 하나하나 찾아서 다시 위에 분이 말씀하신 0을 존재하는 bf_no로 바꾸어야 하지만

간단하게

common.lib.php의
$sql = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no ";

이 쿼리만 수정해도 된다는 것이죠

저 쿼리 내용이 board_file테이블에서 게시물에 연결된 파일을 다 찾아라 하는 말이니

게시물에 연결된 파일중 파일 명이 있는 파일을 다 찾아라로 바꾸어도 쉽게 처리가 되죠

마지막으로 모든경우에 이미지가 없다면

즉 쿼리에서 결과값이 0
length($list[$i][$file])식으로 스킨에서 뿌린다면

간단하게 처리가 가능합니다.

참 한개의 게시판에만 적용시킬때는
쿼리문 위에 if($bo_table == "게시판명")으로 예외를 걸으셔서 쿼리를 날리셔도 되는것이고요
// 게시글에 첨부된 파일을 얻는다. (배열로 반환)
function get_file($bo_table, $wr_id)
{
    global $g4, $qstr;

    $file["count"] = 0;
    $sql = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no ";
    $result = sql_query($sql);
    while ($row = sql_fetch_array($result))
    {
        $no = $row[bf_no];
        $file[$no][href] = "./download.php?bo_table=$bo_table&wr_id=$wr_id&no=$no" . $qstr;
        $file[$no][download] = $row[bf_download];
        // 4.00.11 - 파일 path 추가
        $file[$no][path] = "$g4[path]/data/file/$bo_table";
        //$file[$no][size] = get_filesize("{$file[$no][path]}/$row[bf_file]");
        $file[$no][size] = get_filesize($row[bf_filesize]);
        //$file[$no][datetime] = date("Y-m-d H:i:s", @filemtime("$g4[path]/data/file/$bo_table/$row[bf_file]"));
        $file[$no][datetime] = $row[bf_datetime];
        $file[$no][source] = addslashes($row[bf_source]);
        $file[$no][bf_content] = $row[bf_content];
        $file[$no][content] = get_text($row[bf_content]);
        //$file[$no][view] = view_file_link($row[bf_file], $file[$no][content]);
        $file[$no][view] = view_file_link($row[bf_file], $row[bf_width], $row[bf_height], $file[$no][content]);
        $file[$no][file] = $row[bf_file];
        // prosper 님 제안
        //$file[$no][imgsize] = @getimagesize("{$file[$no][path]}/$row[bf_file]");
        $file[$no][image_width] = $row[bf_width] ? $row[bf_width] : 640;
        $file[$no][image_height] = $row[bf_height] ? $row[bf_height] : 480;
        $file[$no][image_type] = $row[bf_type];
        $file["count"]++;
    }

    return $file;
}

common.lib.php 파일 안에 내용은 말씀하신대로 이미 되어있는데요 ㅠㅠ
전체 66,554 |RSS
그누4 질문답변 내용 검색

회원로그인

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