한 게시물에 다중으로 생성된 썸네일을 삭제하고자 합니다 정보
한 게시물에 다중으로 생성된 썸네일을 삭제하고자 합니다첨부파일
본문
P.S; 도움좀 부탁드립니다. 등록된 스킨의 추가 수정작업이 필요한데 며칠째 작업진행이 안되네요 -_- ;;
정말 혼자서는 너무 무리라서 도움을 요청합니다
-- 관련스킨을 첨부합니다
-- 아래 코드의 내용은 스킨 내용의 일부입니다
앞서 올린 질문글들에 대한 도움으로 좀더 응용해서 한 게시물에 여러 이미지파일을 등록시에
첫번째,두번째 등록이미지의 썸네일을 생성하도록 list.skin.php에서 코드를 만들었습니다
원래는 게시물당 등록되는 이미지를 루프형식으로 임의의 변수값설정을 통해서 원하는 만큼
썸네일을 만들어 내는것이 목적인데 ... 그냥 첫번째, 두번째만 수동으로 생성합니다
여기까지, 썸네일 생성과 관련해서는 잘됩니다.
★★★★★ 문제는 생성된 썸네일들을 삭제할수가 없습니다 ★★★★
★ 생성되는 썸네일의 타입이 wr_id값이 아닌 원본이미지의 축소형식으로 jpg방식으로 생성됩니다
wr_id형태로 썸네일을 생성하면 하나밖에 생성이 안되서 등록게시물의 파일명을이용해서
jpg파일을 압축해서 그대로 썸네일로 저장하는 팁을 응용해서 작업한건데 ....
★★★★★ 게시물의 이미지를 변경하여 등록 or 삭제하거나 or 리스트에서 선택삭제시
★★★★★ 어떠한경우에도 기존의 썸네일은 삭제가 되지 않고 쌓이기만 합니다
★★ 현재 게시물당 두개의 이미지가 출력되도록 설정되어 있습니다
★★ 게시물의 수정및 삭제시 썸네일도 삭제및 수정반영이 되도록 했으면 합니다
첨부된 delete.skin.php / delete_all.skin.php / wrtie_update.skin.php 의 경우
wr_id 방식으로 생성된 썸네일을 삭제하는 관련 코드입니다
이걸 jpg방식으로 2개이상 만들어진 썸네일을 삭제할수 있도록 변경이 되어야할거같은데
★★ 코드자체를 새로 만들거나 수정할 능력이 안되는군요.
정~~~~~~~~~말 혼자서는 힘이 드네요.......해결할수 있는 코드좀 부탁드립니다
<!-- ############## list.skin.php 에서 썸네일과 관련한 코드 -->
<?
if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.", $admin_href);
// 썸네일 사이즈(가로|세로) 지정
// $thu_width = '150'; //썸네일 폭 $thu_height = '110';
list($thu_width, $thu_height) = explode("|", $board[bo_4]);
$thu_quality = '98'; //썸네일 퀄리티_100 이하
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb';
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
$mod = $board[bo_gallery_cols];
$td_width = (int)(100 / $mod);
?>
<? //-------------------- 썸네일 생성 (첫번째, 두번째)
for ($i=0; $i<count($list); $i++) {
if ($i && $i%$mod==0)
echo "</tr><td colspan='{$mod}' height=5></td></tr>";
$img_cnt = array() ;
for ($k=0,$img_num=0; $k<$list[$i][file][count]; $k++) {
if($list[$i][file][$k][file]) { //break;
$img_cnt[$img_num]=$list[$i][file][$k][file] ;
$img_num ++;
}
}
$max_img_cnt = count($img_cnt);
$image = $img_cnt[0];
//$image = $list[$i][file][0][file]; -- 위의것으로 대체
$thumbnail_img = "<img src='$board_skin_path/img/no_image.gif' border=0 width='$thu_width' height='$thu_height' title='이미지 없음' style='border:0px solid #333333;'>";
$thumbnail_img2 = "<img src='$board_skin_path/img/no_image.gif' border=0 width='$thu_width' height='$thu_height' title='이미지 없음' style='border:0px solid #333333;'>";
$thumb = $thumb_path.'/'.$list[$i][file][0][file];
$thumb2 = $thumb_path.'/'.$list[$i][file][1][file];
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
continue;
$rate = $thu_width / $size[0];
$height = (int)($size[1] * $rate);
if ($height < $thu_height)
$dst = imagecreatetruecolor($thu_width, $height);
else
$dst = imagecreatetruecolor($thu_width, $thu_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $thu_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][file][0][file], $thu_quality);
chmod($thumb_path.'/'.$list[$i][file][0][file], 0707);
}
}
if (file_exists($thumb)) {
$thumbnail_img = "<img src='$thumb' width='$thu_width' height='$thu_height' border=0 style='border:3px solid #333333;'>";
}
if (!file_exists($thumb2)) {
$file2 = $list[$i][file][1][path] .'/'. $list[$i][file][1][file];
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file2) && file_exists($file2)) {
$size = @getimagesize($file2);
if ($size[2] == 1)
$src = imagecreatefromgif($file2);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file2);
else if ($size[2] == 3)
$src = imagecreatefrompng($file2);
else
continue;
$rate = $thu_width / $size[0];
$height = (int)($size[1] * $rate);
if ($height < $thu_height)
$dst = imagecreatetruecolor($thu_width, $height);
else
$dst = imagecreatetruecolor($thu_width, $thu_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $thu_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][file][1][file], $thu_quality);
chmod($thumb_path.'/'.$list[$i][file][1][file], 0707);
}
}
if (file_exists($thumb2)) {
$thumbnail_img2 = "<img src='$thumb2' width='$thu_width' height='$thu_height' border=0 style='border:3px solid #333333;'>";
}
?> <!-- 썸네일 생성 end -->
<? /* ------ 이미지 정보출력 start --- */
echo "<div>";
echo "{$view_img}";
echo $thumbnail_img ." ". $thumbnail_img2 ;
echo "</a>";
echo "</div>";
echo "<div style='clear:both; text-align:center;'>";
echo "{$checkbox} {$view_href}";
echo "<span style='letter-spacing:-1px'>{$subject}</span></a> ";
echo $comment_cnt;
echo "</div>";
echo "<div>";
if($board[bo_3] !== '3') {
echo "<span style='font-family:gulim, AppleGothic, sans-serif; font-size:12px;letter-spacing:-1px;'><font color='{$fcolor}'>이미지수 : {$max_img_cnt}</font> <font color='#888888'>조회 : {$list[$i][wr_hit]}</font></span>";
}
echo "</div>";
/* ------ 이미지 정보출력 end --- */
?>
<!-- ############## list.skin.php 끝 -->
<!-- ############## delete.skin.php 에서 썸네일 삭제와 관련한 코드 -->
<?
// 글보기 작성에서 글 삭제시 썸네일 삭제처리
@unlink("$g4[path]/data/file/$bo_table/thumb/$write[wr_id]");
?>
<!-- ############## delete_all.skin.php 에서 썸네일 삭제와 관련한 코드 -->
<?
// 리스트에서 게시글을 체크박스로 여러파일 선택삭제시 썸네일 삭제
for ($i=count($tmp_array)-1; $i>=0; $i--) {
@unlink("$g4[path]/data/file/$bo_table/thumb/$tmp_array[$i]");
}
?>
<!-- ############## write_update.skin.php 에서 썸네일 삭제와 관련한 코드 -->
<?
// --- [★★★ 기능] Thumbnail 삭제 - 글수정에서 이미지파일 변경시 기존썸네일 삭제
@unlink("$g4[path]/data/file/$bo_table/thumb/$write[wr_id]");
?>
정말 혼자서는 너무 무리라서 도움을 요청합니다
-- 관련스킨을 첨부합니다
-- 아래 코드의 내용은 스킨 내용의 일부입니다
앞서 올린 질문글들에 대한 도움으로 좀더 응용해서 한 게시물에 여러 이미지파일을 등록시에
첫번째,두번째 등록이미지의 썸네일을 생성하도록 list.skin.php에서 코드를 만들었습니다
원래는 게시물당 등록되는 이미지를 루프형식으로 임의의 변수값설정을 통해서 원하는 만큼
썸네일을 만들어 내는것이 목적인데 ... 그냥 첫번째, 두번째만 수동으로 생성합니다
여기까지, 썸네일 생성과 관련해서는 잘됩니다.
★★★★★ 문제는 생성된 썸네일들을 삭제할수가 없습니다 ★★★★
★ 생성되는 썸네일의 타입이 wr_id값이 아닌 원본이미지의 축소형식으로 jpg방식으로 생성됩니다
wr_id형태로 썸네일을 생성하면 하나밖에 생성이 안되서 등록게시물의 파일명을이용해서
jpg파일을 압축해서 그대로 썸네일로 저장하는 팁을 응용해서 작업한건데 ....
★★★★★ 게시물의 이미지를 변경하여 등록 or 삭제하거나 or 리스트에서 선택삭제시
★★★★★ 어떠한경우에도 기존의 썸네일은 삭제가 되지 않고 쌓이기만 합니다
★★ 현재 게시물당 두개의 이미지가 출력되도록 설정되어 있습니다
★★ 게시물의 수정및 삭제시 썸네일도 삭제및 수정반영이 되도록 했으면 합니다
첨부된 delete.skin.php / delete_all.skin.php / wrtie_update.skin.php 의 경우
wr_id 방식으로 생성된 썸네일을 삭제하는 관련 코드입니다
이걸 jpg방식으로 2개이상 만들어진 썸네일을 삭제할수 있도록 변경이 되어야할거같은데
★★ 코드자체를 새로 만들거나 수정할 능력이 안되는군요.
정~~~~~~~~~말 혼자서는 힘이 드네요.......해결할수 있는 코드좀 부탁드립니다
<!-- ############## list.skin.php 에서 썸네일과 관련한 코드 -->
<?
if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.", $admin_href);
// 썸네일 사이즈(가로|세로) 지정
// $thu_width = '150'; //썸네일 폭 $thu_height = '110';
list($thu_width, $thu_height) = explode("|", $board[bo_4]);
$thu_quality = '98'; //썸네일 퀄리티_100 이하
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb';
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
$mod = $board[bo_gallery_cols];
$td_width = (int)(100 / $mod);
?>
<? //-------------------- 썸네일 생성 (첫번째, 두번째)
for ($i=0; $i<count($list); $i++) {
if ($i && $i%$mod==0)
echo "</tr><td colspan='{$mod}' height=5></td></tr>";
$img_cnt = array() ;
for ($k=0,$img_num=0; $k<$list[$i][file][count]; $k++) {
if($list[$i][file][$k][file]) { //break;
$img_cnt[$img_num]=$list[$i][file][$k][file] ;
$img_num ++;
}
}
$max_img_cnt = count($img_cnt);
$image = $img_cnt[0];
//$image = $list[$i][file][0][file]; -- 위의것으로 대체
$thumbnail_img = "<img src='$board_skin_path/img/no_image.gif' border=0 width='$thu_width' height='$thu_height' title='이미지 없음' style='border:0px solid #333333;'>";
$thumbnail_img2 = "<img src='$board_skin_path/img/no_image.gif' border=0 width='$thu_width' height='$thu_height' title='이미지 없음' style='border:0px solid #333333;'>";
$thumb = $thumb_path.'/'.$list[$i][file][0][file];
$thumb2 = $thumb_path.'/'.$list[$i][file][1][file];
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
continue;
$rate = $thu_width / $size[0];
$height = (int)($size[1] * $rate);
if ($height < $thu_height)
$dst = imagecreatetruecolor($thu_width, $height);
else
$dst = imagecreatetruecolor($thu_width, $thu_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $thu_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][file][0][file], $thu_quality);
chmod($thumb_path.'/'.$list[$i][file][0][file], 0707);
}
}
if (file_exists($thumb)) {
$thumbnail_img = "<img src='$thumb' width='$thu_width' height='$thu_height' border=0 style='border:3px solid #333333;'>";
}
if (!file_exists($thumb2)) {
$file2 = $list[$i][file][1][path] .'/'. $list[$i][file][1][file];
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file2) && file_exists($file2)) {
$size = @getimagesize($file2);
if ($size[2] == 1)
$src = imagecreatefromgif($file2);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file2);
else if ($size[2] == 3)
$src = imagecreatefrompng($file2);
else
continue;
$rate = $thu_width / $size[0];
$height = (int)($size[1] * $rate);
if ($height < $thu_height)
$dst = imagecreatetruecolor($thu_width, $height);
else
$dst = imagecreatetruecolor($thu_width, $thu_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $thu_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][file][1][file], $thu_quality);
chmod($thumb_path.'/'.$list[$i][file][1][file], 0707);
}
}
if (file_exists($thumb2)) {
$thumbnail_img2 = "<img src='$thumb2' width='$thu_width' height='$thu_height' border=0 style='border:3px solid #333333;'>";
}
?> <!-- 썸네일 생성 end -->
<? /* ------ 이미지 정보출력 start --- */
echo "<div>";
echo "{$view_img}";
echo $thumbnail_img ." ". $thumbnail_img2 ;
echo "</a>";
echo "</div>";
echo "<div style='clear:both; text-align:center;'>";
echo "{$checkbox} {$view_href}";
echo "<span style='letter-spacing:-1px'>{$subject}</span></a> ";
echo $comment_cnt;
echo "</div>";
echo "<div>";
if($board[bo_3] !== '3') {
echo "<span style='font-family:gulim, AppleGothic, sans-serif; font-size:12px;letter-spacing:-1px;'><font color='{$fcolor}'>이미지수 : {$max_img_cnt}</font> <font color='#888888'>조회 : {$list[$i][wr_hit]}</font></span>";
}
echo "</div>";
/* ------ 이미지 정보출력 end --- */
?>
<!-- ############## list.skin.php 끝 -->
<!-- ############## delete.skin.php 에서 썸네일 삭제와 관련한 코드 -->
<?
// 글보기 작성에서 글 삭제시 썸네일 삭제처리
@unlink("$g4[path]/data/file/$bo_table/thumb/$write[wr_id]");
?>
<!-- ############## delete_all.skin.php 에서 썸네일 삭제와 관련한 코드 -->
<?
// 리스트에서 게시글을 체크박스로 여러파일 선택삭제시 썸네일 삭제
for ($i=count($tmp_array)-1; $i>=0; $i--) {
@unlink("$g4[path]/data/file/$bo_table/thumb/$tmp_array[$i]");
}
?>
<!-- ############## write_update.skin.php 에서 썸네일 삭제와 관련한 코드 -->
<?
// --- [★★★ 기능] Thumbnail 삭제 - 글수정에서 이미지파일 변경시 기존썸네일 삭제
@unlink("$g4[path]/data/file/$bo_table/thumb/$write[wr_id]");
?>
댓글 전체
<!-- ############## delete.skin.php 에서 썸네일 삭제와 관련한 코드 -->
<?
// 업로드된 파일이 있다면 파일삭제
$sql = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' ";
$result = sql_query($sql);
while ($row = sql_fetch_array($result)){
@unlink("$g4[path]/data/file/$bo_table/thumb/$row_a[bf_file]");
}
?>
<!-- ############## delete_all.skin.php 에서 썸네일 삭제와 관련한 코드 -->
<?
for ($i=count($tmp_array)-1; $i>=0; $i--) {
// 업로드된 복사본파일이 있다면 파일삭제
$sqls = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$tmp_array[$i]' ";
$results = sql_query($sqls);
while ($rows = sql_fetch_array($results)){
@unlink("$g4[path]/data/file/$bo_table/thumb/$rows[bf_file]");
}
}
?>
<!-- ############## write_update.skin.php 에서 썸네일 삭제와 관련한 코드 -->
<?
$filecnt = count($_FILES[bf_file][name]);
for ($i=0; $i< $filecnt; $i++)
{
if ($_POST[bf_file_del][$i])
{
$rows = sql_fetch("select bf_file from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_no = '$i'");
@unlink("$g4[path]/data/file/$bo_table/thumb/$rows[bf_file]");
}
}
?>
<?
// 업로드된 파일이 있다면 파일삭제
$sql = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' ";
$result = sql_query($sql);
while ($row = sql_fetch_array($result)){
@unlink("$g4[path]/data/file/$bo_table/thumb/$row_a[bf_file]");
}
?>
<!-- ############## delete_all.skin.php 에서 썸네일 삭제와 관련한 코드 -->
<?
for ($i=count($tmp_array)-1; $i>=0; $i--) {
// 업로드된 복사본파일이 있다면 파일삭제
$sqls = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$tmp_array[$i]' ";
$results = sql_query($sqls);
while ($rows = sql_fetch_array($results)){
@unlink("$g4[path]/data/file/$bo_table/thumb/$rows[bf_file]");
}
}
?>
<!-- ############## write_update.skin.php 에서 썸네일 삭제와 관련한 코드 -->
<?
$filecnt = count($_FILES[bf_file][name]);
for ($i=0; $i< $filecnt; $i++)
{
if ($_POST[bf_file_del][$i])
{
$rows = sql_fetch("select bf_file from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_no = '$i'");
@unlink("$g4[path]/data/file/$bo_table/thumb/$rows[bf_file]");
}
}
?>
리플감사합니다..
테스트를 해보니, 리스트화면에서 다중선택삭제인 delete_all.skin.php 부분만 되고
- delete.skin.php , ★ write_update.skin.php 부분은 작동이 되지를 않는거 같습니다
- 그래서 delee.skin.php의 경우는 아래처럼 하니까 되는군요 (변수코드가 잘못된듯~)
------------ delete.skin.php ---------------------
// 뷰화면(view.skin.php)에서 게시물 삭제시, 썸네일파일도 함께 삭제
$sql_thumb = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' ";
$result_thumb = sql_query($sql_thumb);
while ($thumb_row = sql_fetch_array($result_thumb)){
@unlink("$g4[path]/data/file/$bo_table/thumb/$thumb_row[bf_file]");
}
★★ ★ 글수정에서 파일변경시 처리되는 write_update.skin.php 부분만 해결되면 될듯합니다
★★ ★ write_update.skin.php 코드를 한번더 봐주시겠습니까??
테스트를 해보니, 리스트화면에서 다중선택삭제인 delete_all.skin.php 부분만 되고
- delete.skin.php , ★ write_update.skin.php 부분은 작동이 되지를 않는거 같습니다
- 그래서 delee.skin.php의 경우는 아래처럼 하니까 되는군요 (변수코드가 잘못된듯~)
------------ delete.skin.php ---------------------
// 뷰화면(view.skin.php)에서 게시물 삭제시, 썸네일파일도 함께 삭제
$sql_thumb = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' ";
$result_thumb = sql_query($sql_thumb);
while ($thumb_row = sql_fetch_array($result_thumb)){
@unlink("$g4[path]/data/file/$bo_table/thumb/$thumb_row[bf_file]");
}
★★ ★ 글수정에서 파일변경시 처리되는 write_update.skin.php 부분만 해결되면 될듯합니다
★★ ★ write_update.skin.php 코드를 한번더 봐주시겠습니까??
<!-- ############## list.skin.php 에서 썸네일과 관련한 코드 -->
<?
if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.", $admin_href);
// 썸네일 사이즈(가로|세로) 지정
// $thu_width = '150'; //썸네일 폭 $thu_height = '110';
list($thu_width, $thu_height) = explode("|", $board[bo_4]);
$thu_quality = '98'; //썸네일 퀄리티_100 이하
$data_path = $g4[path]."/data/file/$bo_table";
for(i=0;i<2;i++){
$thumb_path[$i] = $data_path.'/thumb'.$i+2; // thumb'.$i+2 <<안먹힐수도.ㅋ;
@mkdir($thumb_path[$i], 0707);
@chmod($thumb_path[$i], 0707);
}
$mod = $board[bo_gallery_cols];
$td_width = (int)(100 / $mod);
?>
<? //-------------------- 썸네일 생성 (첫번째, 두번째)
for ($i=0; $i<count($list); $i++) {
if ($i && $i%$mod==0)
echo "</tr><td colspan='{$mod}' height=5></td></tr>";
$img_cnt = array() ;
for ($k=0,$img_num=0; $k<$list[$i][file][count]; $k++) {
if($list[$i][file][$k][file]) { //break;
$img_cnt[$img_num]=$list[$i][file][$k][file] ;
$img_num ++;
}
}
$max_img_cnt = count($img_cnt);
$image = $img_cnt[0];
//$image = $list[$i][file][0][file]; -- 위의것으로 대체
for(i=0;i<2;i++){
$thumbnail_img[$i] = "<img src='$board_skin_path/img/no_image.gif' border=0 width='$thu_width' height='$thu_height' title='이미지 없음' style='border:0px solid #333333;'>";
$t_thumb[$i] = $thumb_path.'/'.$list[$i][file][$i][file];
if (!file_exists($t_thumb)) {
$file = $list[$i][file][$i][path] .'/'. $list[$i][file][$i][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
continue;
$rate = $thu_width / $size[0];
$height = (int)($size[1] * $rate);
if ($height < $thu_height)
$dst = imagecreatetruecolor($thu_width, $height);
else
$dst = imagecreatetruecolor($thu_width, $thu_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $thu_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path[$i].'/'.$list[$i][file][$i][file], $thu_quality);
chmod($thumb_path[$i].'/'.$list[$i][file][$i][file], 0707);
}
}
if (file_exists($t_thumb[$i])) {
$thumbnail_img[$i] = "<img src='$t_thumb[$i]' width='$thu_width' height='$thu_height' border=0 style='border:3px solid #333333;'>";
}
}
?> <!-- 썸네일 생성 end -->
<? /* ------ 이미지 정보출력 start --- */
echo "<div>";
echo "{$view_img}";
echo $thumbnail_img[0] ." ". $thumbnail_img[1] ;
echo "</a>";
echo "</div>";
echo "<div style='clear:both; text-align:center;'>";
echo "{$checkbox} {$view_href}";
echo "<span style='letter-spacing:-1px'>{$subject}</span></a> ";
echo $comment_cnt;
echo "</div>";
echo "<div>";
if($board[bo_3] !== '3') {
echo "<span style='font-family:gulim, AppleGothic, sans-serif; font-size:12px;letter-spacing:-1px;'><font color='{$fcolor}'>이미지수 : {$max_img_cnt}</font> <font color='#888888'>조회 : {$list[$i][wr_hit]}</font></span>";
}
echo "</div>";
/* ------ 이미지 정보출력 end --- */
?>
<!-- ############## list.skin.php 끝 -->
<!-- ############## delete.skin.php 에서 썸네일 삭제와 관련한 코드 -->
<?
// 글보기 작성에서 글 삭제시 썸네일 삭제처리
@unlink("$g4[path]/data/file/$bo_table/thumb/$write[wr_id]");
@unlink("$g4[path]/data/file/$bo_table/thumb2/$write[wr_id]");
?>
<!-- ############## delete_all.skin.php 에서 썸네일 삭제와 관련한 코드 -->
<?
// 리스트에서 게시글을 체크박스로 여러파일 선택삭제시 썸네일 삭제
for ($i=count($tmp_array)-1; $i>=0; $i--) {
@unlink("$g4[path]/data/file/$bo_table/thumb/$tmp_array[$i]");
@unlink("$g4[path]/data/file/$bo_table/thumb2/$tmp_array[$i]");
}
?>
<!-- ############## write_update.skin.php 에서 썸네일 삭제와 관련한 코드 -->
<?
// --- [★★★ 기능] Thumbnail 삭제 - 글수정에서 이미지파일 변경시 기존썸네일 삭제
@unlink("$g4[path]/data/file/$bo_table/thumb/$write[wr_id]");
@unlink("$g4[path]/data/file/$bo_table/thumb2/$write[wr_id]");
?>
수정해봤어요...확인못해봐서 오류날수도 있구여....
오류나시면....다시.ㅋ;
delete.skin.php delete_all.skin.php 의 파일명은 bbs/delete.php bbs/delete_all.php 상단에 인클루드하는 스킨파일명과 맞춰주시면됩니다~
그리고 원하는 수만큼 썸네일 생성은 상단과 썸넬부분에 포문 for(i=0;i<$board[bo_숫자];i++){
$board[bo_숫자] 게시판설정에서 원하는 여분필드 맞춰서 수넣으시면 됩니다~
출력도 머 $board[bo_숫자]만큼 포문돌려서 출력하시면 되겠죠~
<?
if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.", $admin_href);
// 썸네일 사이즈(가로|세로) 지정
// $thu_width = '150'; //썸네일 폭 $thu_height = '110';
list($thu_width, $thu_height) = explode("|", $board[bo_4]);
$thu_quality = '98'; //썸네일 퀄리티_100 이하
$data_path = $g4[path]."/data/file/$bo_table";
for(i=0;i<2;i++){
$thumb_path[$i] = $data_path.'/thumb'.$i+2; // thumb'.$i+2 <<안먹힐수도.ㅋ;
@mkdir($thumb_path[$i], 0707);
@chmod($thumb_path[$i], 0707);
}
$mod = $board[bo_gallery_cols];
$td_width = (int)(100 / $mod);
?>
<? //-------------------- 썸네일 생성 (첫번째, 두번째)
for ($i=0; $i<count($list); $i++) {
if ($i && $i%$mod==0)
echo "</tr><td colspan='{$mod}' height=5></td></tr>";
$img_cnt = array() ;
for ($k=0,$img_num=0; $k<$list[$i][file][count]; $k++) {
if($list[$i][file][$k][file]) { //break;
$img_cnt[$img_num]=$list[$i][file][$k][file] ;
$img_num ++;
}
}
$max_img_cnt = count($img_cnt);
$image = $img_cnt[0];
//$image = $list[$i][file][0][file]; -- 위의것으로 대체
for(i=0;i<2;i++){
$thumbnail_img[$i] = "<img src='$board_skin_path/img/no_image.gif' border=0 width='$thu_width' height='$thu_height' title='이미지 없음' style='border:0px solid #333333;'>";
$t_thumb[$i] = $thumb_path.'/'.$list[$i][file][$i][file];
if (!file_exists($t_thumb)) {
$file = $list[$i][file][$i][path] .'/'. $list[$i][file][$i][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
continue;
$rate = $thu_width / $size[0];
$height = (int)($size[1] * $rate);
if ($height < $thu_height)
$dst = imagecreatetruecolor($thu_width, $height);
else
$dst = imagecreatetruecolor($thu_width, $thu_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $thu_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path[$i].'/'.$list[$i][file][$i][file], $thu_quality);
chmod($thumb_path[$i].'/'.$list[$i][file][$i][file], 0707);
}
}
if (file_exists($t_thumb[$i])) {
$thumbnail_img[$i] = "<img src='$t_thumb[$i]' width='$thu_width' height='$thu_height' border=0 style='border:3px solid #333333;'>";
}
}
?> <!-- 썸네일 생성 end -->
<? /* ------ 이미지 정보출력 start --- */
echo "<div>";
echo "{$view_img}";
echo $thumbnail_img[0] ." ". $thumbnail_img[1] ;
echo "</a>";
echo "</div>";
echo "<div style='clear:both; text-align:center;'>";
echo "{$checkbox} {$view_href}";
echo "<span style='letter-spacing:-1px'>{$subject}</span></a> ";
echo $comment_cnt;
echo "</div>";
echo "<div>";
if($board[bo_3] !== '3') {
echo "<span style='font-family:gulim, AppleGothic, sans-serif; font-size:12px;letter-spacing:-1px;'><font color='{$fcolor}'>이미지수 : {$max_img_cnt}</font> <font color='#888888'>조회 : {$list[$i][wr_hit]}</font></span>";
}
echo "</div>";
/* ------ 이미지 정보출력 end --- */
?>
<!-- ############## list.skin.php 끝 -->
<!-- ############## delete.skin.php 에서 썸네일 삭제와 관련한 코드 -->
<?
// 글보기 작성에서 글 삭제시 썸네일 삭제처리
@unlink("$g4[path]/data/file/$bo_table/thumb/$write[wr_id]");
@unlink("$g4[path]/data/file/$bo_table/thumb2/$write[wr_id]");
?>
<!-- ############## delete_all.skin.php 에서 썸네일 삭제와 관련한 코드 -->
<?
// 리스트에서 게시글을 체크박스로 여러파일 선택삭제시 썸네일 삭제
for ($i=count($tmp_array)-1; $i>=0; $i--) {
@unlink("$g4[path]/data/file/$bo_table/thumb/$tmp_array[$i]");
@unlink("$g4[path]/data/file/$bo_table/thumb2/$tmp_array[$i]");
}
?>
<!-- ############## write_update.skin.php 에서 썸네일 삭제와 관련한 코드 -->
<?
// --- [★★★ 기능] Thumbnail 삭제 - 글수정에서 이미지파일 변경시 기존썸네일 삭제
@unlink("$g4[path]/data/file/$bo_table/thumb/$write[wr_id]");
@unlink("$g4[path]/data/file/$bo_table/thumb2/$write[wr_id]");
?>
수정해봤어요...확인못해봐서 오류날수도 있구여....
오류나시면....다시.ㅋ;
delete.skin.php delete_all.skin.php 의 파일명은 bbs/delete.php bbs/delete_all.php 상단에 인클루드하는 스킨파일명과 맞춰주시면됩니다~
그리고 원하는 수만큼 썸네일 생성은 상단과 썸넬부분에 포문 for(i=0;i<$board[bo_숫자];i++){
$board[bo_숫자] 게시판설정에서 원하는 여분필드 맞춰서 수넣으시면 됩니다~
출력도 머 $board[bo_숫자]만큼 포문돌려서 출력하시면 되겠죠~
댓글 감사합니다만, 알려주신 방법은 작동을 하지 않는군요.
그리고 썸네일폴더를 2개씩 별도로 만들필요는 없을듯합니다
위 앞선 댓글의 write_update.skin.php 부분만 해결되면 될듯합니다..
글수정에서 업로드된 파일을 수정변경시 썸네일삭제만 현재 되지를 않는군요(write_update.skin.php )
<!-- ############## write_update.skin.php 에서 썸네일 삭제와 관련한 코드 : 해결안된 부분 -->
<?
$filecnt = count($_FILES[bf_file][name]);
for ($i=0; $i< $filecnt; $i++)
{
if ($_POST[bf_file_del][$i])
{
$rows = sql_fetch("select bf_file from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_no = '$i'");
@unlink("$g4[path]/data/file/$bo_table/thumb/$rows[bf_file]");
}
}
?>
그리고 썸네일폴더를 2개씩 별도로 만들필요는 없을듯합니다
위 앞선 댓글의 write_update.skin.php 부분만 해결되면 될듯합니다..
글수정에서 업로드된 파일을 수정변경시 썸네일삭제만 현재 되지를 않는군요(write_update.skin.php )
<!-- ############## write_update.skin.php 에서 썸네일 삭제와 관련한 코드 : 해결안된 부분 -->
<?
$filecnt = count($_FILES[bf_file][name]);
for ($i=0; $i< $filecnt; $i++)
{
if ($_POST[bf_file_del][$i])
{
$rows = sql_fetch("select bf_file from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_no = '$i'");
@unlink("$g4[path]/data/file/$bo_table/thumb/$rows[bf_file]");
}
}
?>
if ($_POST[bf_file_del][$i]) 를 if ($upload[$i][del_check] || $upload[$i][file]) 일케 바꿔보심이...
올려진 파일로 한번 테스트를 해보고 댓글 달아주시면 참~~~ 좋을듯하군요 ... -_- ;;
-- 안됩니다
-- 안됩니다
수정이던 삭제던 delete_all과 똑같은 방법으로 해버리면 됩니다
다른점은 for문이 없어지고 $wr_id를 넣는거죠
$sqls = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' ";
$results = sql_query($sqls);
while ($rows = sql_fetch_array($results))
@unlink("$g4[path]/data/file/$bo_table/thumb/$rows[bf_file]");
수정시 몇번째 첨부화일을 수정했느냐를 찾아서 해당 썸네일을 지우고 어쩌고 복잡하게 할 필요없이
수정하면 해당 게시물 썸네일은 몽땅 지워버리면 다시 생성 되니까 간단하죠
이렇게 해도 무방한 이유는 수정이 빈번하게 일어나는 상황이 아니기 때문입니다
그리고 위 소스로는기껏해야 두개 다시 만드는 것이니까요
다른점은 for문이 없어지고 $wr_id를 넣는거죠
$sqls = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' ";
$results = sql_query($sqls);
while ($rows = sql_fetch_array($results))
@unlink("$g4[path]/data/file/$bo_table/thumb/$rows[bf_file]");
수정시 몇번째 첨부화일을 수정했느냐를 찾아서 해당 썸네일을 지우고 어쩌고 복잡하게 할 필요없이
수정하면 해당 게시물 썸네일은 몽땅 지워버리면 다시 생성 되니까 간단하죠
이렇게 해도 무방한 이유는 수정이 빈번하게 일어나는 상황이 아니기 때문입니다
그리고 위 소스로는기껏해야 두개 다시 만드는 것이니까요
지금 제가 적용해본 결과입니다....
말씀하신대로 아래처럼 한번 적용을 해봤습니다
변경해서 넣어봤지만 여전히 jpg로 생성된 썸네일은 삭제가 되지를 않습니다. 뭐가 문제인지 정말 파악이 안되는군요 -_- ;;
---------------- delete.skin.php
$sqls = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' ";
$results = sql_query($sqls);
while ($rows = sql_fetch_array($results))
@unlink("$g4[path]/data/file/$bo_table/thumb/$rows[bf_file]");
---------------- delete.skin.php
$sqls = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' ";
$results = sql_query($sqls);
while ($rows = sql_fetch_array($results))
@unlink("$g4[path]/data/file/$bo_table/thumb/$rows[bf_file]");
---------------- write_update.skin.php
$sqls = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' ";
$results = sql_query($sqls);
while ($rows = sql_fetch_array($results))
@unlink("$g4[path]/data/file/$bo_table/thumb/$rows[bf_file]");
도저히 모르겠군요 -_- ;;
말씀하신대로 아래처럼 한번 적용을 해봤습니다
변경해서 넣어봤지만 여전히 jpg로 생성된 썸네일은 삭제가 되지를 않습니다. 뭐가 문제인지 정말 파악이 안되는군요 -_- ;;
---------------- delete.skin.php
$sqls = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' ";
$results = sql_query($sqls);
while ($rows = sql_fetch_array($results))
@unlink("$g4[path]/data/file/$bo_table/thumb/$rows[bf_file]");
---------------- delete.skin.php
$sqls = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' ";
$results = sql_query($sqls);
while ($rows = sql_fetch_array($results))
@unlink("$g4[path]/data/file/$bo_table/thumb/$rows[bf_file]");
---------------- write_update.skin.php
$sqls = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' ";
$results = sql_query($sqls);
while ($rows = sql_fetch_array($results))
@unlink("$g4[path]/data/file/$bo_table/thumb/$rows[bf_file]");
도저히 모르겠군요 -_- ;;