첨부파일 순서

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

1번 첨부파일을 삭제하면

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

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

어케 진행해야할지 ㅠㅠ
|

댓글 9개

common.lib.php의
get_file 함수에서
sql문에 where 로 file명이 null이 아닌것을 찾으면 되겠죠^^
킁...ㅠㅠ 아무것도 모르다보니 제자신이 참 답답하네요 ㅎㅎ
list 스킨 소스를 봐야 수정 해주던지 하죠
<?
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;"> </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를 섬네일로 하려면..또 어케해야하는지...
$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
부분에서 0 을 존재하는 bf_no 로 바꾸는 작업이 필요합니다.
약간 구조만 알면 쉽게 됩니다.
$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 파일 안에 내용은 말씀하신대로 이미 되어있는데요 ㅠㅠ
wr_id = '$wr_id' and bf_file != ''
이런식으로 더 추가를 하셔야 한다는 거죠 ㅜㅜ;;
컹...cheditor5가 서버에 등록되어있는데...소스들은 다 cheditor4의 경로로 되어있네요? ㅠㅠ
댓글을 작성하시려면 로그인이 필요합니다.

그누4 질문답변

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

+
제목 글쓴이 날짜 조회
12년 전 조회 1,581
12년 전 조회 1,875
12년 전 조회 1,562
12년 전 조회 1,724
12년 전 조회 1,642
12년 전 조회 1,628
12년 전 조회 947
12년 전 조회 1,572
12년 전 조회 1,595
12년 전 조회 1,762
12년 전 조회 1,731
12년 전 조회 1,639
12년 전 조회 1,588
12년 전 조회 2,592
12년 전 조회 1,668
12년 전 조회 831
12년 전 조회 1,056
12년 전 조회 932
12년 전 조회 1,577
12년 전 조회 1,558