MANDO가 쓰는 gblog_new_post.php > 팁

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>
<!-- 새로 올라온 글 종료 -->

댓글 전체

extend/image.lib.php

<?
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);
}
?>
손톱이미지를 만들긴 하는데 가로 세로 각 100, 또는 70이 넘을 때 그 기준으로 저장되기 때문에 보기가 흉합니다.

만약 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 "내용물";
            }
전체 69
팁 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT