테스트 사이트 - 개발 중인 베타 버전입니다

갤러리 최신글 랜덤 추출 방법좀 알려주세요 (소스 포함) 채택완료

정진님 11년 전 조회 4,762
이천이지님의 최신글 갤러리 스킨을 사용하고 있습니다. (이천이지님 감사^.^*)
 
 
위의 자료를 사용중입니다.
 
최신글 갤러리에서 이미지와 제목만 나오게 변경을 했는데요 여기에서 최신글을 랜덤으로 게시판에서 추출하여
 
이미지와 제목만 표시되게 하려 합니다.
 
 
 
/*  *     latest.skin Gallery for Gnuboard4  *      latest.skin.php  *       *      Copyright 2011 Man Hyung, cho  *       *      File encoding: Korean(EUC-KR)  *  */
$cols  = 6; //  이미지 가로갯수 //  이미지 세로 갯수는 메인에서 지정(총 이미지 수) $image_h  = 15; // 이미지 상하 간격 $is_crop = 1; // $is_crop     : 세로 높이가 $height를 넘을 때 crop 할 것인지를 결정 //                0 : crop 하지 않습니다 //                1 : 기본 crop //                2 : 중간을 기준으로 crop $col_width = (int)(99 / $cols);
//불당썸---------------------------------------------------------------// $img_width = 80; //표시할 이미지의 가로사이즈 $img_height = 110; //표시할 이미지의 세로사이즈
//언샾마스트 퀄리티(썸 노이즈바지) $filter[type] = 99; $filter[arg1] = 100; $filter[arg2] = 1; $filter[arg3] = 2;
$data_path = $g4[path]."/data/file/$bo_table"; $thumb_path = $data_path.'/thumb'; $no_img = $latest_skin_path."/img/no_img.gif";
// 불당썸을 include include_once("$g4[path]/lib/thumb.lib.php"); //불당썸---------------------------------------------------------------//
// $list_content = "40"; //내용길이 ?>
 
 0 && $i%$cols==0) {     echo "
";    }  ?>
 
      ";  }  ?>    게시물이 없습니다."; } ?>    
                                            
  
 
          
  
  //$file = "$g4[path]/data/file/$bo_table/".urlencode($list[$i][file][0][file]);   $file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];   //$noimg = "$latest_skin_path/img/noimg.gif";
  // 업로드된 파일이 이미지라면   //if (preg_match("/\.(gif|jp[e]?g|png|bmp)$/i", $file) && file_exists($file)) {
  if (preg_match("/\.(jpg|gif|png|bmp)$/i", $file) && file_exists($file)) {    //$img=thumbnail($data_path. "/".$image, $imgwidth, $imgheight, 0, 1);  //썸네일이 없을경우 원본출력    $thumb = thumbnail($file, $img_width, $img_height, 0, $is_crop, 90, 0, "",  $filter, $noimg); //언샾마스크추가
 
  } else { //에디터에서 삽입한 이미지    $edit_img = $list[$i]['wr_content'];    if (eregi("data/cheditor4[^<>]*\.(gif|jp[e]?g|png|bmp)", $edit_img, $tmp)) { // data/cheditor------    $file = $g4[path].'/' . $tmp[0]; // 파일명    $thumb=thumbnail($file, $img_width, $img_height, 0, $is_crop, 90, 0, "",  $filter, $noimg); //언샾마스크추가
   }   }
  //if (file_exists($thumb)) {     //$thumfile = "";
  if (preg_match("/\.(jpg|gif|png|bmp)$/i", $thumb) && file_exists($thumb)) {    echo "";    echo "";    echo "
";    echo "";    echo "
{$list[$i]['subject']}";    echo "
";    }
  else if (!file_exists($list[$i][file_image0])){ // no img    echo "";    echo "";    echo "
";    echo "";    echo "
{$list[$i]['subject']}";    echo "
";   }
  ?>   
 
 
이 소스를 어떻게 고쳐야 랜덤으로 추출되는지를 알고싶습니다.
 
팁게 보니까 랜덤추출글 있는데 좀 복잡하고 이미지도 뽑아오는지 모르겠어서요~
 
댓글을 작성하려면 로그인이 필요합니다.

답변 1개

채택된 답변
+20 포인트
11년 전

스킨은 수정할 필요 없구요.

/lib/latest.lib.php 파일을 수정하셔야 되요.

최신글 함수 다음에 밑에 함수 붙어 넣고

최신글 불러 올때는  

이걸 쓰시면 됩니다.

// 최신글 추출 function latest_rand($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 rand() limit 0, $rows ";     // 위의 코드 보다 속도가 빠름     $sql = " select * from $tmp_write_table where wr_is_comment = 0 order by rand() 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; }

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인