MANDO가 쓰는 gblog_new_post.php 정보
MANDO가 쓰는 gblog_new_post.php
본문
gblog_new_post.php
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<!-- 새로 올라온 글 시작 -->
<table width='100%' cellpadding=0 cellspacing=0 align=center>
<?
$main = get_blog_main($dv_id, $st, $sv, 15);
for($i=0; $i<sizeof($main); $i++)
{
$row = $main[$i];
// 첨부사진
$t_width=100;//섬네일 최대폭
$t_height=70;//섬네일 최대높이
$quality = 100;
$sql4 = " select * from {$gb4['file_table']} where blog_id = '$row[blog_id]' and post_id = '$row[id]' ";
$row4 = sql_fetch($sql4);
$thumb = $g4[path]."/data/blog/file/".$row[mb_id]."/".$row4[save_name]."_thumb";
if (!file_exists($thumb))
{
$file = $g4[path]."/data/blog/file/".$row[mb_id]."/".$row4[save_name];
//echo "<tr><td height=5>".$file ."</td></tr>";
// 업로드된 파일이 이미지라면
$size = @getimagesize($file);
if(is_array($size) && !is_file($thumb)) {
switch($size[2]) {
case(1) :
if(function_exists('ImageCreateFromGif')) $im = ImageCreateFromGif($file);
break;
case(2) :
if(function_exists('ImageCreateFromJpeg')) $im = ImageCreateFromJpeg($file);
break;
case(3) :
if(function_exists('ImageCreateFromPng')) $im = ImageCreateFromPng($file);
break;
}
$fixsize = mando_image_size($size[0], $size[1], $t_width, $t_height);
if($im) {
if($i==0) @exec("rm ".dirname($_SERVER[SCRIPT_FILENAME])."/data/blog/file/".$row[mb_id]."/".$row4[save_name]."_thumb-rf");
if(function_exists('ImageCreateTrueColor')) $newim = ImageCreateTrueColor($fixsize[x],$fixsize[y]);
else $newim = ImageCreate($fixsize[x],$fixsize[y]);
if(function_exists('ImageCopyResampled')) ImageCopyResampled($newim,$im,0,0,0,0,$fixsize[x],$fixsize[y],$size[0],$size[1]);
else ImageCopyResized($newim,$im,0,0,0,0,$fixsize[x],$fixsize[y],$size[0],$size[1]);
ImageDestroy($im);
ImageJpeg($newim, $thumb, 100);
ImageDestroy($newim);
unset($im, $newim);
}
$list[$i][img][x] = $fixsize[x];
$list[$i][img][y] = $fixsize[y];
} else {
if(is_file($thumb)) {
$size = @getimagesize($thumb);
$list[$i][img][x] = $size[0];
$list[$i][img][y] = $size[1];
} else {
$no_img = "$board_skin_path/img/no_img.jpg";
$size = @getimagesize($no_img);
$list[$i][img][x] = $size[0];
$list[$i][img][y] = $size[1];
}
}
if(is_file($thumb))$file = $thumb;
}
if (file_exists($thumb)){
$img = "<img src='$thumb' border=0 height='$t_height'>";
}
// echo "<tr><td height=5>".$img ."</td></tr>";
//echo "<tr><td height=5>".$row4[real_name] ."</td></tr>";
// 첨부사진 끝
if ($i>0) {
echo "<tr><td height=5 ></td></tr>";
echo "<tr><td height=1 bgcolor=#d2d2d2 ></td></tr>";
echo "<tr><td height=5 ></td></tr>";
}
echo "<tr><td height=25 >";
echo "<table width=100% cellpadding=0 cellspacing=0 align=center><tr><td width='70%' height=25 >";
echo "<span style='font-size:11pt;font-weight:bold;letter-spacing:-1px;'><a href='".get_post_url($row[id],$row[mb_id])."'>".$row[title]."</a></span>";
echo ":<span>".$row[writer]."</span> <span style='color:#999999''>님이 작성</span> ";
echo "<span style='color:#999999'' class='small'>(".$row[post_date].", ".$row[category_name].")</span></td></tr></table></td></tr>";
// 첨부사진
if($img){
if($row[id] == $row4[post_id]){
echo "<tr><td>";
echo "<table width=100% cellpadding=0 cellspacing=0 align=center><tr><td height=5 width=50 valign=top style='padding:3px;border:1px solid #777777'>".$img ."</td>";
echo "<td class=lh style='word-break:break-all;padding-left:5px;color:#999999'><div style='color:#999999''>".$row[content]."</div></td></tr></table>";
echo "</td></tr>";
// 첨부사진 끝
}else{
echo "<tr><td class=lh style='word-break:break-all;'><div style='color:#999999''>".$row[content]."</div>";
echo "</td></tr>";
}
}
}
if ($i==0) {
echo "<tr><td height=100 >새로 올라온 글이 아직 없습니다.</td></tr>";
}
?>
<tr><td height=5 ></td></tr>
<tr><td height=1 bgcolor=#d2d2d2 ></td></tr>
</table>
<!-- 새로 올라온 글 종료 -->
댓글 전체

<?
if (!defined('_GNUBOARD_')) exit;
function mando_image_size($x, $y, $thumbx, $thumby) {
if($x > $thumbx) {
$overx = ($x - $thumbx) / $x;
$x = $thumbx;
$y = intval($y - ($y * $overx));
}
if($y > $thumby) {
$overy = ($y - $thumby) / $y;
$y = $thumby;
$x = intval($x - ($x * $overy));
}
return array('x'=>$x, 'y'=>$y);
}
?>

만약 width가 100보다 크다면 100 리사이즈 손톱이미지 만들고, height가 70 보다 크다면 70을 기준으로 잘라서 보기가 흉합니다.
도움... 바랍니다. 감사합니다.
물론 제일 아래 쪽에 if (file_exists($thumb)){
$img = "<img src='$thumb' border=0 height='$t_height' width='$t_width' >"; 로 해결이 됩니다만 정식이 아니라서......

당근 이미지가 있으면 내용도 같이 출력이 되나 이미지가 없는 경우 : 제일 처음 불러오는 포스트가 이미지가 없을 경우 - 내용물이 출력이 되지 않습니다.
그러나, 첫포스트에 이미지가 있을 경우에는 2, 3, 4, 5, 내용물이 출력이 됩니다.
그리고 페이지가 바뀐 상태에서도 마찬가지 입니다.
이거이 뭐가 잘못 되었을까요?
고수님의 한 수 지도, 편달을 바랍니다.
if($img){
if($row[id] == $row4[post_id]){
echo "사진";
echo "내용물";
}else{
echo "내용물";
}
}
}
if ($i==0) {
echo "새로 올라온 글이 아직 없습니다.";
}
?>
<!-- 새로 올라온 글 종료 -->

}else{
echo "내용물";
}
}
밑에다가 else 한번 더 ~~~~
else {
echo "내용물";
}