정리해서 여쭤보겠습니다.. 최근갤러리.. 살려주세요ㅠㅠ > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

정리해서 여쭤보겠습니다.. 최근갤러리.. 살려주세요ㅠㅠ 정보

정리해서 여쭤보겠습니다.. 최근갤러리.. 살려주세요ㅠㅠ

본문

/lib/latest.lib.php에서...


latest.lib.php에다가 다수의 게시판을 한대 묶어서 하나의 최근 게시물을 보여주는 그런 최근 갤러리 게시물을 만들려고 합니다..

<?
if (!defined('_GNUBOARD_')) exit;

// 최신글 추출
function latest($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="")
{
    global $g4;

    if ($skin_dir)
        $latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
    else
        $latest_skin_path = "$g4[path]/skin/latest/basic";

    $list = array();

    $sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
    $board = sql_fetch($sql);

    $tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
    //$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_id desc limit 0, $rows ";
    // 위의 코드 보다 속도가 빠름
    $sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_num limit 0, $rows ";
    //explain($sql);
    $result = sql_query($sql);
    for ($i=0; $row = sql_fetch_array($result); $i++)
        $list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
   
    ob_start();
    include "$latest_skin_path/latest.skin.php";
    $content = ob_get_contents();
    ob_end_clean();

    return $content;
}

// By Cysn 2009-06-18 최근게시물에 2개이상의 게시판 을 최근순서대로 불러올때..
function latest2($skin_dir="", $bo_table1,$bo_table2,$bo_table3,$bo_table4,$bo_table5,$bo_table6,$bo_table7,$bo_table8, $rows=10, $subject_len=40, $options="")
//$bo_table1,$bo_table2,$bo_table3,$bo_table4, 는 몇개 불러올지.. 맘대로 늘리시면 됩니다.
{
global $g4;

if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/basic";

$sql_common = " from $g4[board_new_table] a, $g4[board_table] b
where a.bo_table = b.bo_table and a.bo_table in('$bo_table1', '$bo_table2', '$bo_table3', '$bo_table4', '$bo_table5', '$bo_table6', '$bo_table7', '$bo_table8') ";
// '$bo_table1', '$bo_table2', '$bo_table3', '$bo_table4' 역시 몇개 불러올건지.. 위에 맞게 수정하시면 되겠습니다.

$sql_common .= " and a.wr_id = a.wr_parent ";
// 요건 원본글만 불러온다는 말이죠..
$sql_order = " order by a.bn_id desc ";
// 요건 new테이블에 저장된 최근 순서대로..

$sql_select = " b.gr_id, a.bo_table, a.wr_id, a.wr_parent, a.bn_datetime, b.bo_subject ";
$list = array();

$sql = " select $sql_select, b.bo_subject
$sql_common
$sql_order
limit $rows ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
    $tmp_write_table = $g4[write_prefix] . $row[bo_table];

        $comment = "";
        $comment_link = "";
        $row2 = sql_fetch(" select * from $tmp_write_table where wr_id = '$row[wr_id]' ");
        $list[$i] = $row2;

 
    $list[$i] = get_list($row2, $board, $latest_skin_path, $subject_len);
 $bo_herf[$i] = $row[bo_table];
 $bo_name[$i] = $row[bo_subject];
 $list[$i][wr_date] = $row2[wr_datetime];
}

ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();

return $content;
}

?>

이건 latest.lib.php 내용입니다..





다음은 출력하는 방법인데요.. index.php에 인크루드 하는 방법입니다..

<?=latest2('gallery', 'bd0301','bd0302','bd0303','bd0304','bd0305','bd0306','bd0307','bd0308', 3, 20);?>

입니다.. 이렇게 여러개의 게시판을 인크루드 할 수 있구요..


/skin/latest/gallery/latest.skin.php 내용입니다..

현재 링크와 글 제목은 정상적으로 출력이 되고 있습니다..

썸네일을 인식해서 사진을 가지고 오는 것 같은데요....


증상1) 첫번째 사진은 한번에 안뜸(엑박..)
증상2) 두번째 사진을 올리면 첫번째 업로드한 사진이 뜸.. 두번째 사진은 역시 안뜸..


뭐 이런식의 썸네일 생성 오류나 사진링크가 이상한건지... 나오질 않고 있습니다..

게시판 인식까지는 가능한데.. 파일을 가지고 올 수가 없는 것 같습니다..

<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<?
//스킨제작자
//=========================================
//http://www.soccerdb.co.kr
//=========================================


//사용자가 설정하는 부분입니다!! 이부분만 수정하셔요!!
//=========================================
$cols=3; //  이미지 가로갯수
$imgwidth=110; //표시할 이미지의 가로사이즈
$imgheight=75; //표시할 이미지의 세로사이즈
//=========================================
?>
<table width=100% border=0 cellpadding='0' cellspacing='0' align='center'>

<?

for ($i=0; $i<count($list); $i++) {
        $bo_table = $bo_herf[$i];

        $board['bo_table'] = $bo_table;

$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb'; //썸네일 이미지 생성 디렉토리
    $title = get_text($list[$i][wr_subject]);
    $content = cut_str(get_text($list[$i][wr_content]), 80);
    $href = "$g4[bbs_path]/board.php?bo_table=$bo_table";


        if($i % $cols == 0 || $i==0){echo "<tr>";} //테이블 열바꿈 관련




    //이미지 없을때 표시할 이미지 설정
    // if (!file_exists($img) || !$list[$i][file][0][file])$img = "$latest_skin_path/img/noimage.gif";

$thumb = $thumb_path.'/'.$list[$i][wr_id];
if (!file_exists($thumb)) {
$file = $list[$i][file][0][path] .'/'. $list[$i][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]);
imagepng($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
}
}

if (file_exists($thumb)){
$img = "$thumb";
}


echo <<<HEREDOC
    <td valign='top' align='center'>
        <table width="100%" border='0' cellpadding='0' cellspacing='0' align='center'>
            <tr>
                <td align='center'><a href='$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id={$list[$i][wr_id]}'><img src='{$img}' width='{$imgwidth}' height='{$imgheight}' border='0' align='absmiddle' title='$title'></a></td>
            </tr>
            <tr>
                <td height='20' align='center' valign='middle'>{$list[$i][subject]}</td>
            </tr>
        </table>
    </td>
HEREDOC;
    if($i%$cols == ($cols-1)&& $i>0){ echo "</tr>";} //테이블 열바꿈 관련
}

?>

    </tr>
</table>
<? if (count($list) == 0) { ?>
<br>
<center>
  등록된 게시물이 없습니다.
</center>
<? } ?>

댓글 전체

전체 9 |RSS
그누4 질문답변 내용 검색

회원로그인

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