통합 갤러리 최근게시물 - 에디터 이미지, 이미지 없는 글 필터 정보
통합 갤러리 최근게시물 - 에디터 이미지, 이미지 없는 글 필터본문
여러 게시판에 업로드된 이미지만을 추출하여 최근게시물로 만들고자 합니다.
http://sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=133134
이 스킨이 해당 기능을 지원해서 이용하려고 하는데요.
cheditor를 통해 업로드한 이미지를 불러오지 못하고,
이미지 없는 글 또는 이미지가 아닌 파일이 업로드된 글은 필터를 하지 못하고 있습니다.
이런저런 다른 스킨을 통해 소스를 얻고 짜깁기를 해서 latest.skin.php를 수정해보았는데요.
if ($edit_img = $list[$i]['wr_content'])
if (eregi("data/cheditor4[^<>]*\.(gif|jp[e]?g|png|bmp)", $edit_img, $tmp))
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $image))
이런 소스를 이용해서 cheditor를 통한 업로드 파일 추출과 필터링에는 성공은 했습니다만
이 스킨은 자체 lib 파일을 통해 전체 최신글을 추출하는 새로운 함수를 쓰고 있는 구조다보니
5개를 추출하고자 해도 필터를 거치면 5개 이하로만 출력이 되더군요.
애초에 최신글을 5개만 불러오고 그 중에 필터를 거치기 때문인 것 같아서
새로운 함수가 저장된 total_gallery.lib.php 파일을 수정하여
애초에 필터를 거쳐서 5개를 추출하도록 해야하는 것 같아요.
근데 어떻게 수정해야하는지 막막합니다.
원본 소스는 새로운 글 테이블에서 정보를 불러오고 있는데
첨부파일 테이블에서 정보를 불러오고자 해보니 cheditor를 통한 파일은 해당 테이블에 저장이 안되더라고요.
그래서 그렇게는 하기 힘든 것 같고....
한 번에 한 20개 불러오고 그 중 5개만 남겨볼까 싶었는데
이미지가 잘 올라오지 않는 게시판까지 같이 쓰고 싶어서 애매한 것 같고요.
도움 좀 부탁드립니다.
---------------------- total_gallery.lib.php ---------------------------------------
<?
if (!defined('_GNUBOARD_')) exit;
/*------------------------------------------------------------------------------------------------
배열을 이용해 특정 게시판에서 최신글 뽑아오기 - 라이브러리
작성자 : 휴온 박성광
수정일 : 2008.10.02
http://www.huon.kr
------------------------------------------------------------------------------------------------*/
// 최신글 추출
function arr_new_gallery($skin_dir="", $board_arr=array(), $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();
$board_list = array();
//검색조건
if(count($board_arr)>0){
$qry_bo_search=" bo_table in(";
for($i=0; $i<count($board_arr); $i++) {
$bo_table=$board_arr[$i];
$qry_bo_search .= "'$bo_table'";
if($i<count($board_arr)-1) $qry_bo_search .= ", ";
}
$qry_bo_search .= ")";
} else {
$qry_bo_search="(1)";
}
//echo $qry_bo_search;
//new에서 해당되는 게시판의 최신글 뽑아오기
$sql = "select bo_table, wr_id from $g4[board_new_table]
where wr_id = wr_parent and $qry_bo_search order by bn_datetime desc LIMIT 0,$rows";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {
$bo_table=$row[bo_table];
$write_table=$g4['write_prefix'].$bo_table;
$board_sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
$board_list[$i]=sql_fetch($board_sql);
$list[$i]=sql_fetch("select * from $write_table where wr_id='$row[wr_id]' ");
//파일 뽑기
//$img_file_info = "select bf_file from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$row[wr_id]' and bf_no = 0";
// 이미지 정보 가져오기
//$list[$i]['file'] =$img_file_info;
$list[$i]['file'] = get_file($board_list[$i][bo_table], $list[$i][wr_id]);
//기타 설정
if ($subject_len)
$list[$i]['subject'] = conv_subject($list[$i]['wr_subject'], $subject_len, "…");
else
$list[$i]['subject'] = conv_subject($list[$i]['wr_subject'], $board_list[$i]['bo_subject_len'], "…");
$list[$i][href]="$g4[bbs_path]/board.php?bo_table={$board_list[$i][bo_table]}&wr_id={$list[$i][wr_id]}".$qstr;
//$list[$i]['is_notice'] = preg_match("/[^0-9]{0,1}{$list[$i]['wr_id']}[\r]{0,1}/", $board_list[$i]['bo_notice']);
$list[$i]['is_notice']=false;
$arr_notice = split("\n", trim($board_list[$i]['bo_notice']));
if(in_array($list[$i]['wr_id'], $arr_notice)) $list[$i]['is_notice']=true;
echo "<!--".$board_list[$i]['bo_table']."/".$board_list[$i]['bo_notice']."-->";
$list[$i]['icon_new'] = "";
if ($list[$i]['wr_datetime'] >= date("Y-m-d H:i:s", $g4['server_time'] - ($board_list[$i]['bo_new'] * 3600)))
$list[$i]['icon_new'] = "<img src='$latest_skin_path/img/icon_new.gif' align='absmiddle'>";
$list[$i]['comment_cnt'] = "";
if ($list[$i]['wr_comment'])
$list[$i]['comment_cnt'] = "({$list[$i][wr_comment]})";
if ($board_list[$i]['bo_use_comment'])
$list[$i]['comment_href'] = "javascript:win_comment('$g4[bbs_path]/board.php?bo_table=$board_list[$i][bo_table]&wr_id=$list[$i][wr_id]&cwin=1');";
else
$list[$i]['comment_href'] = $list[$i]['href'];
$list[$i]['icon_secret'] = "";
if (strstr($list[$i]['wr_option'], "secret"))
$list[$i]['icon_secret'] = "<img src='$latest_skin_path/img/icon_secret.gif' align='absmiddle'>";
$list[$i]['datetime'] = substr($list[$i]['wr_datetime'],0,10);
$list[$i]['datetime2'] = $list[$i]['wr_datetime'];
if ($list[$i]['datetime'] == $g4['time_ymd'])
$list[$i]['datetime2'] = substr($list[$i]['datetime2'],11,5);
else
$list[$i]['datetime2'] = substr($list[$i]['datetime2'],5,5);
// 삭제할 코드
//$list[$i]['file'] = get_file($bo_table, $list[$i]['wr_id']);
}
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
-------------------------------------------------------------------------
http://sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=133134
이 스킨이 해당 기능을 지원해서 이용하려고 하는데요.
cheditor를 통해 업로드한 이미지를 불러오지 못하고,
이미지 없는 글 또는 이미지가 아닌 파일이 업로드된 글은 필터를 하지 못하고 있습니다.
이런저런 다른 스킨을 통해 소스를 얻고 짜깁기를 해서 latest.skin.php를 수정해보았는데요.
if ($edit_img = $list[$i]['wr_content'])
if (eregi("data/cheditor4[^<>]*\.(gif|jp[e]?g|png|bmp)", $edit_img, $tmp))
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $image))
이런 소스를 이용해서 cheditor를 통한 업로드 파일 추출과 필터링에는 성공은 했습니다만
이 스킨은 자체 lib 파일을 통해 전체 최신글을 추출하는 새로운 함수를 쓰고 있는 구조다보니
5개를 추출하고자 해도 필터를 거치면 5개 이하로만 출력이 되더군요.
애초에 최신글을 5개만 불러오고 그 중에 필터를 거치기 때문인 것 같아서
새로운 함수가 저장된 total_gallery.lib.php 파일을 수정하여
애초에 필터를 거쳐서 5개를 추출하도록 해야하는 것 같아요.
근데 어떻게 수정해야하는지 막막합니다.
원본 소스는 새로운 글 테이블에서 정보를 불러오고 있는데
첨부파일 테이블에서 정보를 불러오고자 해보니 cheditor를 통한 파일은 해당 테이블에 저장이 안되더라고요.
그래서 그렇게는 하기 힘든 것 같고....
한 번에 한 20개 불러오고 그 중 5개만 남겨볼까 싶었는데
이미지가 잘 올라오지 않는 게시판까지 같이 쓰고 싶어서 애매한 것 같고요.
도움 좀 부탁드립니다.
---------------------- total_gallery.lib.php ---------------------------------------
<?
if (!defined('_GNUBOARD_')) exit;
/*------------------------------------------------------------------------------------------------
배열을 이용해 특정 게시판에서 최신글 뽑아오기 - 라이브러리
작성자 : 휴온 박성광
수정일 : 2008.10.02
http://www.huon.kr
------------------------------------------------------------------------------------------------*/
// 최신글 추출
function arr_new_gallery($skin_dir="", $board_arr=array(), $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();
$board_list = array();
//검색조건
if(count($board_arr)>0){
$qry_bo_search=" bo_table in(";
for($i=0; $i<count($board_arr); $i++) {
$bo_table=$board_arr[$i];
$qry_bo_search .= "'$bo_table'";
if($i<count($board_arr)-1) $qry_bo_search .= ", ";
}
$qry_bo_search .= ")";
} else {
$qry_bo_search="(1)";
}
//echo $qry_bo_search;
//new에서 해당되는 게시판의 최신글 뽑아오기
$sql = "select bo_table, wr_id from $g4[board_new_table]
where wr_id = wr_parent and $qry_bo_search order by bn_datetime desc LIMIT 0,$rows";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {
$bo_table=$row[bo_table];
$write_table=$g4['write_prefix'].$bo_table;
$board_sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
$board_list[$i]=sql_fetch($board_sql);
$list[$i]=sql_fetch("select * from $write_table where wr_id='$row[wr_id]' ");
//파일 뽑기
//$img_file_info = "select bf_file from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$row[wr_id]' and bf_no = 0";
// 이미지 정보 가져오기
//$list[$i]['file'] =$img_file_info;
$list[$i]['file'] = get_file($board_list[$i][bo_table], $list[$i][wr_id]);
//기타 설정
if ($subject_len)
$list[$i]['subject'] = conv_subject($list[$i]['wr_subject'], $subject_len, "…");
else
$list[$i]['subject'] = conv_subject($list[$i]['wr_subject'], $board_list[$i]['bo_subject_len'], "…");
$list[$i][href]="$g4[bbs_path]/board.php?bo_table={$board_list[$i][bo_table]}&wr_id={$list[$i][wr_id]}".$qstr;
//$list[$i]['is_notice'] = preg_match("/[^0-9]{0,1}{$list[$i]['wr_id']}[\r]{0,1}/", $board_list[$i]['bo_notice']);
$list[$i]['is_notice']=false;
$arr_notice = split("\n", trim($board_list[$i]['bo_notice']));
if(in_array($list[$i]['wr_id'], $arr_notice)) $list[$i]['is_notice']=true;
echo "<!--".$board_list[$i]['bo_table']."/".$board_list[$i]['bo_notice']."-->";
$list[$i]['icon_new'] = "";
if ($list[$i]['wr_datetime'] >= date("Y-m-d H:i:s", $g4['server_time'] - ($board_list[$i]['bo_new'] * 3600)))
$list[$i]['icon_new'] = "<img src='$latest_skin_path/img/icon_new.gif' align='absmiddle'>";
$list[$i]['comment_cnt'] = "";
if ($list[$i]['wr_comment'])
$list[$i]['comment_cnt'] = "({$list[$i][wr_comment]})";
if ($board_list[$i]['bo_use_comment'])
$list[$i]['comment_href'] = "javascript:win_comment('$g4[bbs_path]/board.php?bo_table=$board_list[$i][bo_table]&wr_id=$list[$i][wr_id]&cwin=1');";
else
$list[$i]['comment_href'] = $list[$i]['href'];
$list[$i]['icon_secret'] = "";
if (strstr($list[$i]['wr_option'], "secret"))
$list[$i]['icon_secret'] = "<img src='$latest_skin_path/img/icon_secret.gif' align='absmiddle'>";
$list[$i]['datetime'] = substr($list[$i]['wr_datetime'],0,10);
$list[$i]['datetime2'] = $list[$i]['wr_datetime'];
if ($list[$i]['datetime'] == $g4['time_ymd'])
$list[$i]['datetime2'] = substr($list[$i]['datetime2'],11,5);
else
$list[$i]['datetime2'] = substr($list[$i]['datetime2'],5,5);
// 삭제할 코드
//$list[$i]['file'] = get_file($bo_table, $list[$i]['wr_id']);
}
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
-------------------------------------------------------------------------
댓글 전체