diff --git a/bbs/list.php b/bbs/list.php index c0301b410..b7d37a50c 100644 --- a/bbs/list.php +++ b/bbs/list.php @@ -57,8 +57,10 @@ if ($sca || $stx) { if(G5_IS_MOBILE) { $page_rows = $board['bo_mobile_page_rows']; + $list_page_rows = $board['bo_mobile_page_rows']; } else { $page_rows = $board['bo_page_rows']; + $list_page_rows = $board['bo_page_rows']; } if ($page < 1) { $page = 1; } // 페이지가 없으면 첫 페이지 (1 페이지) @@ -74,33 +76,49 @@ $notice_array = array(); // 공지 처리 if (!$sca && !$stx) { $arr_notice = explode(',', trim($board['bo_notice'])); - for ($k=0; $k= $list_page_rows) + break; } } $total_page = ceil($total_count / $page_rows); // 전체 페이지 계산 $from_record = ($page - 1) * $page_rows; // 시작 열을 구함 -if($page > 1 && $notice_count) - $from_record -= $notice_count; +// 공지글이 있으면 변수에 반영 +if(!empty($notice_array)) { + $from_record -= count($notice_array); -if($page == 1 && $notice_count) - $page_rows -= $notice_count; + if($from_record < 0) + $from_record = 0; + + if($notice_count > 0) + $page_rows -= $notice_count; + + if($page_rows < 0) + $page_rows = $list_page_rows; +} // 관리자라면 CheckBox 보임 $is_checkbox = false; @@ -139,32 +157,34 @@ if ($sca || $stx) { $sql = " select distinct wr_parent from {$write_table} where {$sql_search} {$sql_order} limit {$from_record}, $page_rows "; } else { $sql = " select * from {$write_table} where wr_is_comment = 0 "; - if($notice_count && !empty($notice_array)) + if(!empty($notice_array)) $sql .= " and wr_id not in (".implode(', ', $notice_array).") "; $sql .= " {$sql_order} limit {$from_record}, $page_rows "; } -$result = sql_query($sql); -$k = 0; +// 페이지의 공지개수가 목록수 보다 작을 때만 실행 +if($page_rows > 0) { + $result = sql_query($sql); -while ($row = sql_fetch_array($result)) -{ - // 검색일 경우 wr_id만 얻었으므로 다시 한행을 얻는다 - if ($sca || $stx) - $row = sql_fetch(" select * from {$write_table} where wr_id = '{$row['wr_parent']}' "); + $k = 0; - $list[$i] = get_list($row, $board, $board_skin_url, G5_IS_MOBILE ? $board['bo_mobile_subject_len'] : $board['bo_subject_len']); - if (strstr($sfl, 'subject')) { - $list[$i]['subject'] = search_font($stx, $list[$i]['subject']); + while ($row = sql_fetch_array($result)) + { + // 검색일 경우 wr_id만 얻었으므로 다시 한행을 얻는다 + if ($sca || $stx) + $row = sql_fetch(" select * from {$write_table} where wr_id = '{$row['wr_parent']}' "); + + $list[$i] = get_list($row, $board, $board_skin_url, G5_IS_MOBILE ? $board['bo_mobile_subject_len'] : $board['bo_subject_len']); + if (strstr($sfl, 'subject')) { + $list[$i]['subject'] = search_font($stx, $list[$i]['subject']); + } + $list[$i]['is_notice'] = false; + $list_num = $total_count - ($page - 1) * $list_page_rows - $notice_count; + $list[$i]['num'] = $list_num - $k; + + $i++; + $k++; } - $list[$i]['is_notice'] = false; - $list_num = $total_count - ($page - 1) * $page_rows; - if($page == 1) - $list_num -= $notice_count; - $list[$i]['num'] = $list_num - $k; - - $i++; - $k++; } $write_pages = get_paging(G5_IS_MOBILE ? $config['cf_mobile_pages'] : $config['cf_write_pages'], $page, $total_page, './board.php?bo_table='.$bo_table.$qstr.'&page=');