최근글페이징처리에서 사진이안불러와져요 정보
최근글페이징처리에서 사진이안불러와져요
본문
http://superface.cafe24.com/smm.php
보시면 최근글을불러오는스킨을 그누회원님들께서 많이 도와줘서만들었는데
썸네일사진경로까지는 잘이동하는데 이미지를 못불러오고있습니다.
아래는해당소스입니다.
<?
$g4_path = ".";
include_once("./_common.php");
include_once("./_head.php");
$sql_common = " from g4_write_story";
$sql_search = " WHERE (1)";
if ($stx) {
$sql_search .= " and ( ";
switch ($sfl) {
case "mb_point" :
$sql_search .= " ($sfl >= '$stx') ";
break;
default :
$sql_search .= " ($sfl like '%$stx%') ";
break;
}
$sql_search .= " ) ";
}
if (!$sst) {
$sst = "wr_id";
$sod = "desc";
}
$sql_order = " order by $sst $sod ";
$sql = " select count(*) as cnt
$sql_common
$sql_search
$sql_order ";
$row = sql_fetch($sql);
$total_count = $row[cnt];
$rows =5;
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함
$listall = "<a href='$_SERVER[PHP_SELF]' class=tt>처음</a>";
$sql = " select *
$sql_common
$sql_search
$sql_order
limit $from_record, $rows";
$result = sql_query($sql);
$colspan = 5;
//for ($i=0; $row=sql_fetch_array($result); $i++) {
//echo "<a href='/bbs/board.php?bo_table=story&wr_id=".$row[wr_id]."'>$row[wr_hit].$row[wr_name]." " .$row[wr_subject]."</a><br>";
//echo "<a href='/bbs/board.php? bo_table=story&wr_id=".$row[wr_id]."'>".$row[wr_hit].$row[wr_name]." " .$row[wr_subject]."</a><br>";
//}
$img_width = 60;
$img_height = 45;
$img_quality = 99;
if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.");
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path."thumbnail/$row[wr_id]";
$ym = date("ym", $g4[server_time]);
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
?>
<style>
.dm-subject { font:bold; font-size:18px; color:#000000; padding:5 10 5 5; }
.dm-hit { text-align:center; font:bold; font-size:14px; color:#e95eee; }
</style>
<? $pagelist = get_paging($config[cf_write_pages], $page, $total_page, "?$qstr=$cp_cd1&page="); ?>
<div align="center">
<table width="550" border="0" cellspacing="0" cellpadding="0" align="center">
<tr> <td>
<div id="pagingNew"></div>
</td>
</tr>
</table>
<table width="550" border="0" cellspacing="0" cellpadding="0" align="center">
<tr> <td> </td> </tr>
<? for ($i=0; $row=sql_fetch_array($result); $i++) { ?>
<tr>
<td width="10%" height="60" valign="middle">
<table width="50" border="0" cellspacing="0" cellpadding="5">
<tr>
<td height="40" background="<?=$latest_skin_path?>/img/hit_bg.gif"><div class="dm-hit"><?=$row[wr_hit]?></div></td>
</tr>
</table>
</td>
<td style="padding:5 5 5 5;" width="80%">
<div style="margin-bottom:5px;"><span class="dm-subject">
<a href="/bbs/board.php? bo_table=story&wr_id=<?=$row[wr_id]?>"><?=$row[wr_subject]?></a></span>
<span style="color:#FF6633; font-size:10px">
<?=$result[$i]['comment_cnt']?>
</span>
<?
echo $result[$i]['icon_file'] . " ";
echo " " . $result[$i]['icon_new'];
echo " " . $result[$i]['icon_link'];
echo " " . $result[$i]['icon_hot'];
?>
</div>
<div>
<span style="color:#8f8f8f; padding:0 5 5 5;"><?=$row[wr_name]?> </span>
</div>
</td>
<td width="10%" align="center" valign="middle">
<?
//썸네일 생성
$thumfile = "";
$thumb = $thumb_path.'/'.$row[wr_id];
// 썸네일 이미지가 존재하지 않는다면
if (!file_exists($thumb)) {
$file = $row[$i][file][0][path] .'/'. $row[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;
$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.'/'.$result[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$result[$i][wr_id], 0606);
}
}
if (file_exists($thumb))
$thumfile = "<img src='$thumb' width='{$img_width}' height='{$img_height}' border='0' style='border:0 #eee solid' onmouseover=this.style.filter='alpha(opacity=80)' onmouseout=this.style.filter=''></a>";
else
//이미지가 없으면
$thumfile="<img src='$latest_skin_path/img/noimg.gif' width='{$img_width}' height='{$img_height}' style='border:0 #E7E7E7 solid'></a>";
//이미지가 아니네
if(preg_match("/\.(swf|wma|asf)$/i","$file") && file_exists($file))
{ $thumfile = "<script>doc_write(flash_movie('$file', 'flash$i', '$img_width', '$img_height', 'transparent'));</script>"; }
?><a href="/bbs/board.php? bo_table=story&wr_id=<?=$row[wr_id]?>"><?=$thumfile?></a>
<!--<a href='/bbs/board.php? bo_table=story&wr_id=".$row[wr_id]."'> -->
</td>
</tr>
<tr><td colspan="3" height="1" bgcolor="#f3f3f3"></td></tr>
<? } ?>
<? if (count($result) == 0) { echo "<tr><td align=center height=50><font color=#6A6A6A>오늘 등록된 게시물이 없습니다.</a></td></tr>"; } ?>
</table>
</div>
<div id="pagingNew">
<table width="550" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><p>
<?=$pagelist?>
</p>
</td>
</tr>
</table>
</div>
어디부분을수정해야할까요 ?
풍성한 추석보내세요~
보시면 최근글을불러오는스킨을 그누회원님들께서 많이 도와줘서만들었는데
썸네일사진경로까지는 잘이동하는데 이미지를 못불러오고있습니다.
아래는해당소스입니다.
<?
$g4_path = ".";
include_once("./_common.php");
include_once("./_head.php");
$sql_common = " from g4_write_story";
$sql_search = " WHERE (1)";
if ($stx) {
$sql_search .= " and ( ";
switch ($sfl) {
case "mb_point" :
$sql_search .= " ($sfl >= '$stx') ";
break;
default :
$sql_search .= " ($sfl like '%$stx%') ";
break;
}
$sql_search .= " ) ";
}
if (!$sst) {
$sst = "wr_id";
$sod = "desc";
}
$sql_order = " order by $sst $sod ";
$sql = " select count(*) as cnt
$sql_common
$sql_search
$sql_order ";
$row = sql_fetch($sql);
$total_count = $row[cnt];
$rows =5;
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함
$listall = "<a href='$_SERVER[PHP_SELF]' class=tt>처음</a>";
$sql = " select *
$sql_common
$sql_search
$sql_order
limit $from_record, $rows";
$result = sql_query($sql);
$colspan = 5;
//for ($i=0; $row=sql_fetch_array($result); $i++) {
//echo "<a href='/bbs/board.php?bo_table=story&wr_id=".$row[wr_id]."'>$row[wr_hit].$row[wr_name]." " .$row[wr_subject]."</a><br>";
//echo "<a href='/bbs/board.php? bo_table=story&wr_id=".$row[wr_id]."'>".$row[wr_hit].$row[wr_name]." " .$row[wr_subject]."</a><br>";
//}
$img_width = 60;
$img_height = 45;
$img_quality = 99;
if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.");
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path."thumbnail/$row[wr_id]";
$ym = date("ym", $g4[server_time]);
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
?>
<style>
.dm-subject { font:bold; font-size:18px; color:#000000; padding:5 10 5 5; }
.dm-hit { text-align:center; font:bold; font-size:14px; color:#e95eee; }
</style>
<? $pagelist = get_paging($config[cf_write_pages], $page, $total_page, "?$qstr=$cp_cd1&page="); ?>
<div align="center">
<table width="550" border="0" cellspacing="0" cellpadding="0" align="center">
<tr> <td>
<div id="pagingNew"></div>
</td>
</tr>
</table>
<table width="550" border="0" cellspacing="0" cellpadding="0" align="center">
<tr> <td> </td> </tr>
<? for ($i=0; $row=sql_fetch_array($result); $i++) { ?>
<tr>
<td width="10%" height="60" valign="middle">
<table width="50" border="0" cellspacing="0" cellpadding="5">
<tr>
<td height="40" background="<?=$latest_skin_path?>/img/hit_bg.gif"><div class="dm-hit"><?=$row[wr_hit]?></div></td>
</tr>
</table>
</td>
<td style="padding:5 5 5 5;" width="80%">
<div style="margin-bottom:5px;"><span class="dm-subject">
<a href="/bbs/board.php? bo_table=story&wr_id=<?=$row[wr_id]?>"><?=$row[wr_subject]?></a></span>
<span style="color:#FF6633; font-size:10px">
<?=$result[$i]['comment_cnt']?>
</span>
<?
echo $result[$i]['icon_file'] . " ";
echo " " . $result[$i]['icon_new'];
echo " " . $result[$i]['icon_link'];
echo " " . $result[$i]['icon_hot'];
?>
</div>
<div>
<span style="color:#8f8f8f; padding:0 5 5 5;"><?=$row[wr_name]?> </span>
</div>
</td>
<td width="10%" align="center" valign="middle">
<?
//썸네일 생성
$thumfile = "";
$thumb = $thumb_path.'/'.$row[wr_id];
// 썸네일 이미지가 존재하지 않는다면
if (!file_exists($thumb)) {
$file = $row[$i][file][0][path] .'/'. $row[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;
$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.'/'.$result[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$result[$i][wr_id], 0606);
}
}
if (file_exists($thumb))
$thumfile = "<img src='$thumb' width='{$img_width}' height='{$img_height}' border='0' style='border:0 #eee solid' onmouseover=this.style.filter='alpha(opacity=80)' onmouseout=this.style.filter=''></a>";
else
//이미지가 없으면
$thumfile="<img src='$latest_skin_path/img/noimg.gif' width='{$img_width}' height='{$img_height}' style='border:0 #E7E7E7 solid'></a>";
//이미지가 아니네
if(preg_match("/\.(swf|wma|asf)$/i","$file") && file_exists($file))
{ $thumfile = "<script>doc_write(flash_movie('$file', 'flash$i', '$img_width', '$img_height', 'transparent'));</script>"; }
?><a href="/bbs/board.php? bo_table=story&wr_id=<?=$row[wr_id]?>"><?=$thumfile?></a>
<!--<a href='/bbs/board.php? bo_table=story&wr_id=".$row[wr_id]."'> -->
</td>
</tr>
<tr><td colspan="3" height="1" bgcolor="#f3f3f3"></td></tr>
<? } ?>
<? if (count($result) == 0) { echo "<tr><td align=center height=50><font color=#6A6A6A>오늘 등록된 게시물이 없습니다.</a></td></tr>"; } ?>
</table>
</div>
<div id="pagingNew">
<table width="550" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><p>
<?=$pagelist?>
</p>
</td>
</tr>
</table>
</div>
어디부분을수정해야할까요 ?
풍성한 추석보내세요~
댓글 전체
썸네일 생성시 파일명이 wr_id로 되어 있네요...
서버에서 이미지로 인식할 수 있는 .jpg, .gif, .png 등의 확장자가 없이 아마 1, 2, 3... 이런식으로 이미지가 생성되는 것 같은데, 이런 파일들을 이미지로 인식한다는게....
코드를 대충 봐서 이 부분이 맞는지 모르겠지만 썸네일 생성 부분에서
$thumb = $thumb_path.'/'.$row[wr_id];
를
$thumb = $thumb_path.'/'.$row[wr_id].'.jpg'; 등으로 원하는 확장자를 넣어서 바꿔 보시기 바랍니다.
썸네일 폴더에 이미지 확장자로 저장이 되었는지 확인을 ^^:
서버에서 이미지로 인식할 수 있는 .jpg, .gif, .png 등의 확장자가 없이 아마 1, 2, 3... 이런식으로 이미지가 생성되는 것 같은데, 이런 파일들을 이미지로 인식한다는게....
코드를 대충 봐서 이 부분이 맞는지 모르겠지만 썸네일 생성 부분에서
$thumb = $thumb_path.'/'.$row[wr_id];
를
$thumb = $thumb_path.'/'.$row[wr_id].'.jpg'; 등으로 원하는 확장자를 넣어서 바꿔 보시기 바랍니다.
썸네일 폴더에 이미지 확장자로 저장이 되었는지 확인을 ^^:

안녕하세요 ~쿠츠님~
해봤는데 아직도 썸네일을 못불러오네요 .
해봤는데 아직도 썸네일을 못불러오네요 .
썸네일 폴더에 이미지명이 어떻게 저장이 되나요?
폴더 경로를 $bo_table로 하셨는데 smm.php에서 $bo_table이 할당된게 없네요..
썸네일 폴더에 저장된 이미지와 브라우저에 썸네일이 없으면 출력되는 이미지가 아닌 썸네일 출력시 html 코드에 이미지 경로가 맞는지요?
정상적으로 이미지 확장자를 가진 파일이 생성 되었다면 브라우저의 소스보기를 하셔서 썸네일이 나오는 html 코드의 경로를 확인해 보시면 될것 같네요
폴더 경로를 $bo_table로 하셨는데 smm.php에서 $bo_table이 할당된게 없네요..
썸네일 폴더에 저장된 이미지와 브라우저에 썸네일이 없으면 출력되는 이미지가 아닌 썸네일 출력시 html 코드에 이미지 경로가 맞는지요?
정상적으로 이미지 확장자를 가진 파일이 생성 되었다면 브라우저의 소스보기를 하셔서 썸네일이 나오는 html 코드의 경로를 확인해 보시면 될것 같네요