기존 g4를 g5로 변경하려 합니다. 살펴봐 주십시오. 채택완료
물한모금
10년 전
조회 5,037
다음 식으로 각 게시판의 이미지를 추출하려고 하니까,
오류가 나거나 출력이 안되네요.
</p><p><? for ($i=0; $i<count($list); $i++) {</p><p>$data_path = G5_URL.'/data/file/{$list[$i][bo_table]}';</p><p>$thumb_path = $data_path.'/scrthumb';</p><p> </p><p>@mkdir($thumb_path, 0707);</p><p>@chmod($thumb_path, 0707);</p><p> </p><p>$thumb = $thumb_path.'/'.$list[$i][wr_id];</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if ($i && $i%$mod==0)</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>echo "</tr><tr><td colspan='{$mod}' height=20></td></tr><tr>"; </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$img = "<img src='$member_skin_url/img/scr2_noimg.gif' border=0 title='이미지 없음'>";</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$image = $list[$i][bf_file];</p><p> </p><p> // 썸네일 이미지가 존재하지 않는다면</p><p> if (!file_exists($thumb)) {</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$file = G5_URL.'/data/file/' .$list[$i][bo_table] .'/' .$list[$i][bf_file];</p><p> //$file = $list[$i][file][0][path] .'/'. $list[$i][bf_file];</p><p> // 업로드된 파일이 이미지라면</p><p> if (preg_match("/\.(jpg|gif|png)$/i", $file) && file_exists($file)) { // 첨부파일 이미지 썸네일</p><p> $size = getimagesize($file);</p><p> if ($size[2] == 1)</p><p> $src = imagecreatefromgif($file);</p><p> else if ($size[2] == 2)</p><p> $src = imagecreatefromjpeg($file);</p><p> else if ($size[2] == 3) </p><p> $src = imagecreatefrompng($file); </p><p> else</p><p> continue;</p><p> </p><p> $rate = $thumb_width / $size[0];</p><p> $height = (int)($size[1] * $rate);</p><p> </p><p> // 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면</p><p> if ($height < $thumb_height)</p><p> // 계산된 이미지 높이로 복사본 이미지 생성</p><p> $dst = imagecreatetruecolor($thumb_width, $height);</p><p> else</p><p> // 설정된 이미지 높이로 복사본 이미지 생성</p><p> $dst = imagecreatetruecolor($thumb_width, $thumb_height);</p><p> imagecopyresampled($dst, $src, 0, 0, 0, 0, $thumb_width, $height, $size[0], $size[1]);</p><p> imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $thumb_quality);</p><p> chmod($thumb_path.'/'.$list[$i][wr_id], 0606);</p><p> } else { //에디터 이미지 썸네일</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$edit_img = $list[$i]['wr_content'];</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if (eregi("data/geditor/[^<>]*\.(gif|jp[e]?g|png|bmp)", $edit_img, $tmp)) { //체디터 사용자는 data/cheditor 로 변경하세요.</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$file = '../' . $tmp[0]; // 파일명</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$size = getimagesize($file);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if ($size[2] == 1)</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$src = imagecreatefromgif($file);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>else if ($size[2] == 2)</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$src = imagecreatefromjpeg($file);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>else if ($size[2] == 3) </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$src = imagecreatefrompng($file); </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>else</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>continue;</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$rate = $thumb_width / $size[0];</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$height = (int)($size[1] * $rate);</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>if ($height < $thumb_height)</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>// 계산된 이미지 높이로 복사본 이미지 생성</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$dst = imagecreatetruecolor($thumb_width, $height);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>else</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>// 설정된 이미지 높이로 복사본 이미지 생성</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$dst = imagecreatetruecolor($thumb_width, $thumb_height);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>imagecopyresampled($dst, $src, 0, 0, 0, 0, $thumb_width, $height, $size[0], $size[1]);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $thumb_quality);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>chmod($thumb_path.'/'.$list[$i][wr_id], 0606);</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p><span class="Apple-tab-span" style="white-space:pre"> </span> }</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>}</p><p> </p><p><span class="Apple-tab-span" style="white-space:pre"> </span>//썸네일 출력</p><p><b> if (file_exists($thumb) && $list[$i][bf_file])</b></p><p><b><span class="Apple-tab-span" style="white-space:pre"> </span>$img = "<a href=\"G5_URL.'/data/file/{$list[$i][bo_table]}/$image'\" class='highslide' onclick='return hs.expand(this)'><img src='{$thumb}' border='0' style='border:0px solid #999999;'></a>";</b></p><p><b><span class="Apple-tab-span" style="white-space:pre"> </span>else if (file_exists($thumb) && preg_match("`<\s*img\s+src\s*=\s*['|\"]?([^'|\"\s]+://[^'|\"\s]+\.(gif|jpe?g|png))['|\"]?\s*[^>]+`i", $list[$i]['wr_content'], $images))</b></p><p><b><span class="Apple-tab-span" style="white-space:pre"> </span>$img = "<a href='$images[1]' class='highslide' onclick='return hs.expand(this)'><img src='{$thumb}' border='0' style='border:0px solid #999999;'></a>";</b></p><p><span class="Apple-tab-span" style="white-space:pre"> </span>else</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$img = "<img src='$member_skin_url/img/scr2_noimg.gif' border=0 title='이미지 없음'>";</p><p><span style="font-size: 10pt; line-height: 1.5;">?> </span></p><p>
특히, "썸네일 출력" 부분을 추출하려는데 잘 안되네요.
위의 식을 어떻게 잡아줘야 할까요...
도움 부탁 드립니다.(__)
댓글을 작성하려면 로그인이 필요합니다.
답변 1개
채택된 답변
+20 포인트
10년 전
$g4['path']를 G5_URL로만 바꾸면 다 되는건 아니구요..
실제로 그누보드4용 스킨이나 플러그인들에는 상대경로가 쓰여서 저런식으로 많이 사용했는데요.. 문제가 되는곳은 file_exists() 나 is_file(), getimagesize() 같은 부분입니다. 여기는 url이 아닌 서버의 운영체제상의 경로를 사용하고 출력할때는 url로 출력해주는걸로 나눠서 처리해줘야 합니다.
경로들 잡히는 곳들을 여러군데 수정해줘야 할겁니다.
</p><p><span style="font-size: 13.3333330154419px; line-height: 1.5;">$data_path = G5_PATH.'/data/file/{$list[$i][bo_table]}';</span></p><p>$data_url = G5_URL.'/data/file/{$list[$i][bo_table]}';</p><p> </p><p>$thumb_dir_path = $data_path.'/scrthumb'; </p><p><span style="font-size: 13.3333330154419px; line-height: 1.5;">$thumb_dir_url = $data_url.'/scrthumb';</span></p><p><span style="font-size: 13.3333330154419px; line-height: 1.5;"> </span></p><p><span style="font-size: 13.3333330154419px;"></span>$thumb = $thumb_dir_path.'/'.$list[$i][wr_id];</p><p><span style="font-size: 13.3333330154419px;"></span>$thumb_url = $thumb_dir_url.'/'.$list[$i][wr_id];</p><p>
이런식으로 하시고 맨 마지막은
</p><p><span style="font-size: 13.3333330154419px;"></span><span class="Apple-tab-span" style="white-space: pre;"> </span>//썸네일 출력</p><p> if (file_exists($thumb) && $list[$i][bf_file])</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$img = "<a href=\"{$data_url}/$image'\" class='highslide' onclick='return hs.expand(this)'><img src='{$thumb_url}' border='0' style='border:0px solid #999999;'></a>";</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>else if (file_exists($thumb) && preg_match("`<\s*img\s+src\s*=\s*['|\"]?([^'|\"\s]+://[^'|\"\s]+\.(gif|jpe?g|png))['|\"]?\s*[^>]+`i", $list[$i]['wr_content'], $images))</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>$img = "<a href='$images[1]' class='highslide' onclick='return hs.expand(this)'><img src='{$thumb_url}' border='0' style='border:0px solid #999999;'></a>";</p><p><span class="Apple-tab-span" style="white-space:pre"> </span>else</p><p><span class="Apple-tab-span" style="white-space: pre;"> </span>$img = "<img src='$member_skin_url/img/scr2_noimg.gif' border=0 title='이미지 없음'>";<span style="font-size: 13.3333330154419px;"></span> </p><p>
수정이 너무 많아 귀찮다 하실땐..
http://sir.co.kr/bbs/board.php?bo_table=g5_tip&wr_id=2372">http://sir.co.kr/bbs/board.php?bo_table=g5_tip&wr_id=2372
이걸 적용하시고 $g4['path']로 되있던 부분을 G5_PATH2로 바꾸시면 되긴 합니다만 가급적 원본에 맞추고자 위 답변을 먼저 드렸습니다.
로그인 후 평가할 수 있습니다
답변에 대한 댓글 3개
�
물한모금
10년 전
�
먼지손
10년 전
헉.. 죄송합니다. 이제서야 틀린걸 봤네요;
$data_path = G5_PATH.'/data/file/'.$list[$i][bo_table]';
$data_url = G5_URL.'/data/file/'.$list[$i][bo_table]';
쌍따옴표 안에는 변수를 사용할 수 있지만 홑따옴표 안에서는 그냥 그대로 문자로 인식됩니다.
$data_path = G5_PATH.'/data/file/'.$list[$i][bo_table]';
$data_url = G5_URL.'/data/file/'.$list[$i][bo_table]';
쌍따옴표 안에는 변수를 사용할 수 있지만 홑따옴표 안에서는 그냥 그대로 문자로 인식됩니다.
�
물한모금
10년 전
예, 잘 알겠습니다.
다시 한번 감사드립니다.^^
다시 한번 감사드립니다.^^
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
제가 정말 많이 부족하군요. 좀더 분발하고 연구하도록 하겠습니다.
정말 감사합니다.^^