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

[재]그누보드 검색했을때 공지사항이 가장먼저 나오게~ 채택완료

one9601 4년 전 조회 1,946

안녕하세요 ㅎ..

 

https://sir.kr/g4_qa/187392

 

이런 글이있어서 따라해보려고 합니다만

 

그누보드 버전이 달라서그런지 조금 다르더라구요

 

if (!$is_search_bbs) 이거를 if(1)로 변경해봤지만 되지않더군요 ㅠㅠ

 

저는 그누보드 5.3을 이용하고 있습니다.

 

도움 부탁드립니다! 초보입니다 ㅠ

 

bbs/list.php 입니다

</p>

<p> </p>

<p><?php</p>

<p>if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가</p>

<p> </p>

<p>// 분류 사용 여부</p>

<p>$is_category = false;</p>

<p>$category_option = '';</p>

<p>if ($board['bo_use_category']) {</p>

<p>    $is_category = true;</p>

<p>    $category_href = get_pretty_url($bo_table);</p>

<p> </p>

<p>    $category_option .= '<li><a href="'.$category_href.'"';</p>

<p>    if ($sca=='')</p>

<p>        $category_option .= ' id="bo_cate_on"';</p>

<p>    $category_option .= '>전체</a></li>';</p>

<p> </p>

<p>    $categories = explode('|', $board['bo_category_list']); // 구분자가 , 로 되어 있음</p>

<p>    for ($i=0; $i<count($categories); $i++) {</p>

<p>        $category = trim($categories[$i]);</p>

<p>        if ($category=='') continue;</p>

<p>        $category_option .= '<li><a href="'.(get_pretty_url($bo_table,'','sca='.urlencode($category))).'"';</p>

<p>        $category_msg = '';</p>

<p>        if ($category==$sca) { // 현재 선택된 카테고리라면</p>

<p>            $category_option .= ' id="bo_cate_on"';</p>

<p>            $category_msg = '<span class="sound_only">열린 분류 </span>';</p>

<p>        }</p>

<p>        $category_option .= '>'.$category_msg.$category.'</a></li>';</p>

<p>    }</p>

<p>}</p>

<p> </p>

<p>$sop = strtolower($sop);</p>

<p>if ($sop != 'and' && $sop != 'or')</p>

<p>    $sop = 'and';</p>

<p> </p>

<p>// 분류 선택 또는 검색어가 있다면</p>

<p>$stx = trim($stx);</p>

<p>//검색인지 아닌지 구분하는 변수 초기화</p>

<p>$is_search_bbs = false;</p>

<p> </p>

<p>if ($sca || $stx || $stx === '0') {     //검색이면</p>

<p>    $is_search_bbs = true;      //검색구분변수 true 지정</p>

<p>    $sql_search = get_sql_search($sca, $sfl, $stx, $sop);</p>

<p> </p>

<p>    // 가장 작은 번호를 얻어서 변수에 저장 (하단의 페이징에서 사용)</p>

<p>    $sql = " select MIN(wr_num) as min_wr_num from {$write_table} ";</p>

<p>    $row = sql_fetch($sql);</p>

<p>    $min_spt = (int)$row['min_wr_num'];</p>

<p> </p>

<p>    if (!$spt) $spt = $min_spt;</p>

<p> </p>

<p>    $sql_search .= " and (wr_num between {$spt} and ({$spt} + {$config['cf_search_part']})) ";</p>

<p> </p>

<p>    // 원글만 얻는다. (코멘트의 내용도 검색하기 위함)</p>

<p>    // 라엘님 제안 코드로 대체 <a href="http://sir.kr/g5_bug/2922" target="_blank" rel="noopener noreferrer">http://sir.kr/g5_bug/2922</a></p>

<p>    $sql = " SELECT COUNT(DISTINCT `wr_parent`) AS `cnt` FROM {$write_table} WHERE {$sql_search} ";</p>

<p>    $row = sql_fetch($sql);</p>

<p>    $total_count = $row['cnt'];</p>

<p>    /*</p>

<p>    $sql = " select distinct wr_parent from {$write_table} where {$sql_search} ";</p>

<p>    $result = sql_query($sql);</p>

<p>    $total_count = sql_num_rows($result);</p>

<p>    */</p>

<p>} else {</p>

<p>    $sql_search = "";</p>

<p> </p>

<p>    $total_count = $board['bo_count_write'];</p>

<p>}</p>

<p> </p>

<p>if(G5_IS_MOBILE) {</p>

<p>    $page_rows = $board['bo_mobile_page_rows'];</p>

<p>    $list_page_rows = $board['bo_mobile_page_rows'];</p>

<p>} else {</p>

<p>    $page_rows = $board['bo_page_rows'];</p>

<p>    $list_page_rows = $board['bo_page_rows'];</p>

<p>}</p>

<p> </p>

<p>if ($page < 1) { $page = 1; } // 페이지가 없으면 첫 페이지 (1 페이지)</p>

<p> </p>

<p>// 년도 2자리</p>

<p>$today2 = G5_TIME_YMD;</p>

<p> </p>

<p>$list = array();</p>

<p>$i = 0;</p>

<p>$notice_count = 0;</p>

<p>$notice_array = array();</p>

<p> </p>

<p>// 공지 처리</p>

<p>if (!$is_search_bbs) {</p>

<p>    $arr_notice = explode(',', trim($board['bo_notice']));</p>

<p>    $from_notice_idx = ($page - 1) * $page_rows;</p>

<p>    if($from_notice_idx < 0)</p>

<p>        $from_notice_idx = 0;</p>

<p>    $board_notice_count = count($arr_notice);</p>

<p> </p>

<p>    for ($k=0; $k<$board_notice_count; $k++) {</p>

<p>        if (trim($arr_notice[$k]) == '') continue;</p>

<p> </p>

<p>        $row = sql_fetch(" select * from {$write_table} where wr_id = '{$arr_notice[$k]}' ");</p>

<p> </p>

<p>        if (!$row['wr_id']) continue;</p>

<p> </p>

<p>        $notice_array[] = $row['wr_id'];</p>

<p> </p>

<p>        if($k < $from_notice_idx) continue;</p>

<p> </p>

<p>        $list[$i] = get_list($row, $board, $board_skin_url, G5_IS_MOBILE ? $board['bo_mobile_subject_len'] : $board['bo_subject_len']);</p>

<p>        $list[$i]['is_notice'] = true;</p>

<p>        $list[$i]['num'] = 0;</p>

<p>        $i++;</p>

<p>        $notice_count++;</p>

<p> </p>

<p>        if($notice_count >= $list_page_rows)</p>

<p>            break;</p>

<p>    }</p>

<p>}</p>

<p> </p>

<p>$total_page  = ceil($total_count / $page_rows);  // 전체 페이지 계산</p>

<p>$from_record = ($page - 1) * $page_rows; // 시작 열을 구함</p>

<p> </p>

<p>// 공지글이 있으면 변수에 반영</p>

<p>if(!empty($notice_array)) {</p>

<p>    $from_record -= count($notice_array);</p>

<p> </p>

<p>    if($from_record < 0)</p>

<p>        $from_record = 0;</p>

<p> </p>

<p>    if($notice_count > 0)</p>

<p>        $page_rows -= $notice_count;</p>

<p> </p>

<p>    if($page_rows < 0)</p>

<p>        $page_rows = $list_page_rows;</p>

<p>}</p>

<p> </p>

<p>// 관리자라면 CheckBox 보임</p>

<p>$is_checkbox = false;</p>

<p>if ($is_member && ($is_admin == 'super' || $group['gr_admin'] == $member['mb_id'] || $board['bo_admin'] == $member['mb_id']))</p>

<p>    $is_checkbox = true;</p>

<p> </p>

<p>// 정렬에 사용하는 QUERY_STRING</p>

<p>$qstr2 = 'bo_table='.$bo_table.'&sop='.$sop;</p>

<p> </p>

<p>// 0 으로 나눌시 오류를 방지하기 위하여 값이 없으면 1 로 설정</p>

<p>$bo_gallery_cols = $board['bo_gallery_cols'] ? $board['bo_gallery_cols'] : 1;</p>

<p>$td_width = (int)(100 / $bo_gallery_cols);</p>

<p> </p>

<p>// 정렬</p>

<p>// 인덱스 필드가 아니면 정렬에 사용하지 않음</p>

<p>//if (!$sst || ($sst && !(strstr($sst, 'wr_id') || strstr($sst, "wr_datetime")))) {</p>

<p>if (!$sst) {</p>

<p>    if ($board['bo_sort_field']) {</p>

<p>        $sst = $board['bo_sort_field'];</p>

<p>    } else {</p>

<p>        $sst  = "wr_num, wr_reply";</p>

<p>        $sod = "";</p>

<p>    }</p>

<p>} else {</p>

<p>    $board_sort_fields = get_board_sort_fields($board, 1);</p>

<p>    if (!$sod && array_key_exists($sst, $board_sort_fields)) {</p>

<p>        $sst = $board_sort_fields[$sst];</p>

<p>    } else {</p>

<p>        // 게시물 리스트의 정렬 대상 필드가 아니라면 공백으로 (nasca 님 09.06.16)</p>

<p>        // 리스트에서 다른 필드로 정렬을 하려면 아래의 코드에 해당 필드를 추가하세요.</p>

<p>        // $sst = preg_match("/^(wr_subject|wr_datetime|wr_hit|wr_good|wr_nogood)$/i", $sst) ? $sst : "";</p>

<p>        $sst = preg_match("/^(wr_datetime|wr_hit|wr_good|wr_nogood)$/i", $sst) ? $sst : "";</p>

<p>    }</p>

<p>}</p>

<p> </p>

<p>if(!$sst)</p>

<p>    $sst  = "wr_num, wr_reply";</p>

<p> </p>

<p>if ($sst) {</p>

<p>    $sql_order = " order by {$sst} {$sod} ";</p>

<p>}</p>

<p> </p>

<p>if ($is_search_bbs) {</p>

<p>    $sql = " select distinct wr_parent from {$write_table} where {$sql_search} {$sql_order} limit {$from_record}, $page_rows ";</p>

<p>} else {</p>

<p>    $sql = " select * from {$write_table} where wr_is_comment = 0 ";</p>

<p>    if(!empty($notice_array))</p>

<p>        $sql .= " and wr_id not in (".implode(', ', $notice_array).") ";</p>

<p>    $sql .= " {$sql_order} limit {$from_record}, $page_rows ";</p>

<p>}</p>

<p> </p>

<p>// 페이지의 공지개수가 목록수 보다 작을 때만 실행</p>

<p>if($page_rows > 0) {</p>

<p>    $result = sql_query($sql);</p>

<p> </p>

<p>    $k = 0;</p>

<p> </p>

<p>    while ($row = sql_fetch_array($result))</p>

<p>    {</p>

<p>        // 검색일 경우 wr_id만 얻었으므로 다시 한행을 얻는다</p>

<p>        if ($is_search_bbs)</p>

<p>            $row = sql_fetch(" select * from {$write_table} where wr_id = '{$row['wr_parent']}' ");</p>

<p> </p>

<p>        $list[$i] = get_list($row, $board, $board_skin_url, G5_IS_MOBILE ? $board['bo_mobile_subject_len'] : $board['bo_subject_len']);</p>

<p>        if (strstr($sfl, 'subject')) {</p>

<p>            $list[$i]['subject'] = search_font($stx, $list[$i]['subject']);</p>

<p>        }</p>

<p>        $list[$i]['is_notice'] = false;</p>

<p>        $list_num = $total_count - ($page - 1) * $list_page_rows - $notice_count;</p>

<p>        $list[$i]['num'] = $list_num - $k;</p>

<p> </p>

<p>        $i++;</p>

<p>        $k++;</p>

<p>    }</p>

<p>}</p>

<p> </p>

<p>g5_latest_cache_data($board['bo_table'], $list);</p>

<p> </p>

<p>$write_pages = get_paging(G5_IS_MOBILE ? $config['cf_mobile_pages'] : $config['cf_write_pages'], $page, $total_page, get_pretty_url($bo_table, '', $qstr.'&page='));</p>

<p> </p>

<p>$list_href = '';</p>

<p>$prev_part_href = '';</p>

<p>$next_part_href = '';</p>

<p>if ($is_search_bbs) {</p>

<p>    $list_href = get_pretty_url($bo_table);</p>

<p> </p>

<p>    $patterns = array('#&page=[0-9]*#', '#&spt=[0-9\-]*#');</p>

<p> </p>

<p>    //if ($prev_spt >= $min_spt)</p>

<p>    $prev_spt = $spt - $config['cf_search_part'];</p>

<p>    if (isset($min_spt) && $prev_spt >= $min_spt) {</p>

<p>        $qstr1 = preg_replace($patterns, '', $qstr);</p>

<p>        $prev_part_href = get_pretty_url($bo_table,0,$qstr1.'&spt='.$prev_spt.'&page=1');</p>

<p>        $write_pages = page_insertbefore($write_pages, '<a href="'.$prev_part_href.'" class="pg_page pg_search pg_prev">이전검색</a>');</p>

<p>    }</p>

<p> </p>

<p>    $next_spt = $spt + $config['cf_search_part'];</p>

<p>    if ($next_spt < 0) {</p>

<p>        $qstr1 = preg_replace($patterns, '', $qstr);</p>

<p>        $next_part_href = get_pretty_url($bo_table,0,$qstr1.'&spt='.$next_spt.'&page=1');</p>

<p>        $write_pages = page_insertafter($write_pages, '<a href="'.$next_part_href.'" class="pg_page pg_search pg_next">다음검색</a>');</p>

<p>    }</p>

<p>}</p>

<p>

 </p>

<p>$write_href = '';</p>

<p>if ($member['mb_level'] >= $board['bo_write_level']) {</p>

<p>    $write_href = short_url_clean(G5_BBS_URL.'/write.php?bo_table='.$bo_table);</p>

<p>}</p>

<p> </p>

<p>$nobr_begin = $nobr_end = "";</p>

<p>if (preg_match("/gecko|firefox/i", $_SERVER['HTTP_USER_AGENT'])) {</p>

<p>    $nobr_begin = '<nobr>';</p>

<p>    $nobr_end   = '</nobr>';</p>

<p>}</p>

<p> </p>

<p>// RSS 보기 사용에 체크가 되어 있어야 RSS 보기 가능 061106</p>

<p>$rss_href = '';</p>

<p>if ($board['bo_use_rss_view']) {</p>

<p>    $rss_href = G5_BBS_URL.'/rss.php?bo_table='.$bo_table;</p>

<p>}</p>

<p> </p>

<p>$stx = get_text(stripslashes($stx));</p>

<p>include_once($board_skin_path.'/list.skin.php');</p>

<p> </p>

<p>

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

답변 1개

채택된 답변
+20 포인트
// 공지 처리
if (!$is_search_bbs) {
여기를
if( true) {
이렇게 바꾸었는데도 아래가 실행이 안 될 리가 없을 텐데요.
    $arr_notice = explode(',', trim($board['bo_notice']));
    $from_notice_idx = ($page - 1) * $page_rows;
    if($from_notice_idx < 0)
        $from_notice_idx = 0;
    $board_notice_count = count($arr_notice);
 
    for ($k=0; $k<$board_notice_count; $k++) {
        if (trim($arr_notice[$k]) == '') continue;
 
        $row = sql_fetch(" select * from {$write_table} where wr_id = '{$arr_notice[$k]}' ");
 
        if (!$row['wr_id']) continue;
 
        $notice_array[] = $row['wr_id'];
 
        if($k < $from_notice_idx) continue;
 
        $list[$i] = get_list($row, $board, $board_skin_url, G5_IS_MOBILE ? $board['bo_mobile_subject_len'] : $board['bo_subject_len']);
        $list[$i]['is_notice'] = true;
        $list[$i]['num'] = 0;
        $i++;
        $notice_count++;
 
        if($notice_count >= $list_page_rows)
            break;
    }
}
로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

o
one9601
4년 전
테스트 해보니.. 일반 스킨에서는 되네요 ㅠ 제 스킨에 문제가있었나봅니다~ 감사합니다!

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

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

로그인