시그너스님과 다른 썸네일--블로그-최신글에서 정보
시그너스님과 다른 썸네일--블로그-최신글에서본문
<!-- 신규포스트 시작 -->
<table width="441" height="284" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" width="441">
<table width=95% cellpadding=0 cellspacing=0 align=center>
<?
//섬네일 관련 설정
$t_width=100;//섬네일 최대폭
$t_height=70;//섬네일 최대높이
$quality = 80;
<table width="441" height="284" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" width="441">
<table width=95% cellpadding=0 cellspacing=0 align=center>
<?
//섬네일 관련 설정
$t_width=100;//섬네일 최대폭
$t_height=70;//섬네일 최대높이
$quality = 80;
$sql = " select * from {$gb4['post_table']} where secret=1 order by id desc limit 7 ";
$result = sql_query($sql);
for($i=0;$row=sql_fetch_array($result);$i++) {
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>";
}
$sql2 = " select mb_id, writer from {$gb4['blog_table']} where id = '$row[blog_id]' ";
$row2 = sql_fetch($sql2);
$sql3 = " select category_name from {$gb4['category_table']} where id = '$row[category_id]' ";
$row3 = sql_fetch($sql3);
if( empty($row3[category_name]) ) $row3[category_name] = '전체';
$result = sql_query($sql);
for($i=0;$row=sql_fetch_array($result);$i++) {
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>";
}
$sql2 = " select mb_id, writer from {$gb4['blog_table']} where id = '$row[blog_id]' ";
$row2 = sql_fetch($sql2);
$sql3 = " select category_name from {$gb4['category_table']} where id = '$row[category_id]' ";
$row3 = sql_fetch($sql3);
if( empty($row3[category_name]) ) $row3[category_name] = '전체';
$title = $row[title];
$title = cut_str($title, 35);
$content = $row[content];
$content = strip_tags($content);
$content = cut_str($content, 230);
//$yymmdd = date("y-m-d", strtotime($row[post_date]));
$yymmdd2 = date("y-m-d", strtotime($row[real_date]));
$sql4 = " select * from {$gb4['file_table']} where blog_id = '$row[blog_id]' and post_id = '$row[id]' ";
$row4 = sql_fetch($sql4);
$title = cut_str($title, 35);
$content = $row[content];
$content = strip_tags($content);
$content = cut_str($content, 230);
//$yymmdd = date("y-m-d", strtotime($row[post_date]));
$yymmdd2 = date("y-m-d", strtotime($row[real_date]));
$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/".$row2[mb_id]."/".$row4[save_name]."_thumb";
if (!file_exists($thumb))
{
$file = $g4[path]."/data/blog/file/".$row2[mb_id]."/".$row4[save_name];
// 업로드된 파일이 이미지라면
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;
{
$file = $g4[path]."/data/blog/file/".$row2[mb_id]."/".$row4[save_name];
// 업로드된 파일이 이미지라면
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 = $t_width / $size[0];
$height = (int)($size[1] * $rate);
$height = (int)($size[1] * $rate);
@unlink($thumb);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $t_height){
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($t_width, $height);
} else {
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($t_width, $t_height);
}
imagecopyresampled($dst, $src, 0, 0, 0, 0, $t_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb, $quality);
chmod($thumb, 0606);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $t_height){
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($t_width, $height);
} else {
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($t_width, $t_height);
}
imagecopyresampled($dst, $src, 0, 0, 0, 0, $t_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb, $quality);
chmod($thumb, 0606);
}
}
}
if (file_exists($thumb)){
$img = "<img src='$thumb' border=0 width='100'>";
}
$img = "<img src='$thumb' border=0 width='100'>";
}
echo "<tr><td height=30 valign=middle>";
echo "<img src='$gb4[blog_path]/img/id_title2.gif' border=0 align=absmiddle> <span class='cloudy small'>[ </span><a style='cloudy small' href='".get_blog_url($row2[mb_id])."'>$row2[writer]님 Blog </a><span class='cloudy small'> / </span><a class='cloudy small' href='".get_category_url($row3[category_name], $row[mb_id])."'>$row3[category_name]</a><span class='cloudy small'> ]</span> ";
echo "<span style='font-weight:bold;letter-spacing:-1px;'><a href='".get_post_url($row[id],$row2[mb_id])."'>$title</a> <span class='small cloudy'>$yymmdd2</td></tr>";
//echo "<tr><td height=15 valign=middle>";
//echo "<span class='small cloudy'><img src='$gb4[blog_path]/img/update2.gif' border=0> $yymmdd2 <img src='$gb4[blog_path]/img/update.gif' border=0> $yymmdd </span> ";
//echo " <span class='small cloudy'><img src='$gb4[blog_path]/img/ico_hit.gif' border=0> $row[hit] <img src='$gb4[blog_path]/img/ico_reply.gif' border=0> $row[comment_count] <img src='$gb4[blog_path]/img/ico_tb.gif' border=0> $row[trackback_count] </span>";
//echo "</td></tr>";
//echo "<tr><td height=5></td></tr>";
if ($img) {
if($row[id] == $row4[post_id]){
echo "</table><table width=95% cellpadding=0 cellspacing=0 align=center>";
echo "<tr><td width=100 style='border:1px solid #CCCCCC; padding:3px'>{$img}</td><td width=10></td><td valign=top><span style='small'>{$content}</span></td></tr></table><table width=95% cellpadding=0 cellspacing=0 align=center>";
} else {
echo "<tr><td><span style='small'>{$content}</span></td></tr>";
}
}
else {
echo "<tr><td><span style='small'>{$content}</span></td></tr>";
}
echo "<tr><td height=10></td></tr>";
echo "<tr><td height=1 bgcolor=#d2d2d2></td></tr>";
//echo "<tr><td height=10></td></tr>";
}
if ($i==0) {
echo "<tr><td height=100>새로 올라온 글이 아직 없습니다.</td></tr>";
}
?>
</table>
</td>
</tr>
</table>
<!-- 신규포스트 끝 -->
echo "<img src='$gb4[blog_path]/img/id_title2.gif' border=0 align=absmiddle> <span class='cloudy small'>[ </span><a style='cloudy small' href='".get_blog_url($row2[mb_id])."'>$row2[writer]님 Blog </a><span class='cloudy small'> / </span><a class='cloudy small' href='".get_category_url($row3[category_name], $row[mb_id])."'>$row3[category_name]</a><span class='cloudy small'> ]</span> ";
echo "<span style='font-weight:bold;letter-spacing:-1px;'><a href='".get_post_url($row[id],$row2[mb_id])."'>$title</a> <span class='small cloudy'>$yymmdd2</td></tr>";
//echo "<tr><td height=15 valign=middle>";
//echo "<span class='small cloudy'><img src='$gb4[blog_path]/img/update2.gif' border=0> $yymmdd2 <img src='$gb4[blog_path]/img/update.gif' border=0> $yymmdd </span> ";
//echo " <span class='small cloudy'><img src='$gb4[blog_path]/img/ico_hit.gif' border=0> $row[hit] <img src='$gb4[blog_path]/img/ico_reply.gif' border=0> $row[comment_count] <img src='$gb4[blog_path]/img/ico_tb.gif' border=0> $row[trackback_count] </span>";
//echo "</td></tr>";
//echo "<tr><td height=5></td></tr>";
if ($img) {
if($row[id] == $row4[post_id]){
echo "</table><table width=95% cellpadding=0 cellspacing=0 align=center>";
echo "<tr><td width=100 style='border:1px solid #CCCCCC; padding:3px'>{$img}</td><td width=10></td><td valign=top><span style='small'>{$content}</span></td></tr></table><table width=95% cellpadding=0 cellspacing=0 align=center>";
} else {
echo "<tr><td><span style='small'>{$content}</span></td></tr>";
}
}
else {
echo "<tr><td><span style='small'>{$content}</span></td></tr>";
}
echo "<tr><td height=10></td></tr>";
echo "<tr><td height=1 bgcolor=#d2d2d2></td></tr>";
//echo "<tr><td height=10></td></tr>";
}
if ($i==0) {
echo "<tr><td height=100>새로 올라온 글이 아직 없습니다.</td></tr>";
}
?>
</table>
</td>
</tr>
</table>
<!-- 신규포스트 끝 -->
gblog.index.php에서 새글 올라온 것에 이미지가 있다면 생성하고 보여주기
시그너스님은 썸네일 엔진이 별도로 필요해서 그냥 그누보드 기본 스킨에 나온
내용을 토대로 제구성하였습니다.
필요하신분은 적용해 보세요..
댓글 전체
사용방법은
gblog.index.php에 맞게 새로운 글 출력하는 부분에 복사해서 넣으시면 됩니다.
gblog.index.php에 맞게 새로운 글 출력하는 부분에 복사해서 넣으시면 됩니다.
GOOOOOOOD!
굳이네요..잘 쓰겠습니다.
좋아요 고맙습니다 ^^
<a class='cloudy small' href='".get_category_url($row3[category_name], $row[mb_id])."'>$row3[category_name]</a>
에러납니다...
에러납니다...
최신글
감사합니다.