">
//
//
//후기 끝
/* -------------------------------------------------
* 8) 공지 처리
* ------------------------------------------------- */
if (!$is_search_bbs) {
$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 = '".sql_escape_string($arr_notice[$k])."'");
if (empty($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;
}
}
/* -------------------------------------------------
* 9) 페이지 계산 및 공지 반영
* ------------------------------------------------- */
$total_page = (int)ceil($total_count / $page_rows);
$from_record = ($page - 1) * $page_rows;
if(!empty($notice_array)) {
$from_record -= count($notice_array);
if($from_record < 0) $from_record = 0;
if($notice_count > 0) $page_rows -= $notice_count;
if($page_rows < 0) $page_rows = $list_page_rows;
}
/* -------------------------------------------------
* 10) LIST 쿼리
* ------------------------------------------------- */
$notice_ex = '';
if (!empty($notice_array)) {
$notice_in = implode(', ', array_map('intval',$notice_array));
$notice_ex = " AND gwc.wr_id NOT IN ({$notice_in})";
}
if ($is_counselor) {
// 외부 where(회원 상태) 보강용
$outer_state_where = '';
if (!empty($state_list)) {
$outer_state_where = " AND m2.state IN ('".implode("','", $state_list)."')";
}
if ($bo_table == 'counselor'){
$sql_list = "
SELECT p.*, m2.*, rc2.afcnt
FROM (
SELECT gwc.wr_parent
FROM {$write_table} AS gwc
LEFT JOIN g5_member AS m ON m.mb_id = gwc.mb_id
LEFT JOIN ({$review_count_sql}) AS rc ON rc.wr_1 = gwc.mb_id
WHERE {$where_alias}
GROUP BY gwc.wr_parent
ORDER BY {$order_expr_c}
LIMIT {$from_record}, {$page_rows}
) ids
JOIN {$write_table} p ON p.wr_id = ids.wr_parent
LEFT JOIN g5_member m2 ON m2.mb_id = p.mb_id
LEFT JOIN ({$review_count_sql}) rc2 ON rc2.wr_1 = p.mb_id
WHERE 1=1 AND NOT (m2.use_phone = 'N' AND m2.use_chat = 'N') {$outer_state_where}
";
} else
$sql_list = "
SELECT p.*, m2.*, rc2.afcnt
FROM (
SELECT gwc.wr_parent
FROM {$write_table} AS gwc
LEFT JOIN g5_member AS m ON m.mb_id = gwc.mb_id
LEFT JOIN ({$review_count_sql}) AS rc ON rc.wr_1 = gwc.mb_id
WHERE {$where_alias}
GROUP BY gwc.wr_parent
ORDER BY {$order_expr_c}
LIMIT {$from_record}, {$page_rows}
) ids
JOIN {$write_table} p ON p.wr_id = ids.wr_parent
LEFT JOIN g5_member m2 ON m2.mb_id = p.mb_id
LEFT JOIN ({$review_count_sql}) rc2 ON rc2.wr_1 = p.mb_id
WHERE 1=1 {$outer_state_where}
";
} else {
$sql_list = "
SELECT gwc.*
FROM {$write_table} gwc
LEFT JOIN
g5_member as m
on
gwc.mb_id = m.mb_id
WHERE {$where_simple}
{$notice_ex}
ORDER BY {$order_expr_simple}
LIMIT {$from_record}, {$page_rows}
";
// if($_SERVER['REMOTE_ADDR'] == '115.93.39.5'){
// echo "===>".$sql_list;
// }
}
dbg('LIST_SQL', $sql_list);
/* -------------------------------------------------
* 11) 결과 가공
* ------------------------------------------------- */
$result = sql_query($sql_list);
$k = 0;
while ($row = sql_fetch_array($result)) {
$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;
// 신고/차단 마스킹
if (!empty($member['mb_id'])) {
$rsql = "
SELECT * FROM g5_board_singo
WHERE mb_id='".sql_escape_string($member['mb_id'])."'
AND bo_table='".sql_escape_string($bo_table)."'
AND wr_id='".intval($list[$i]['wr_id'])."'
";
$rrt = sql_fetch($rsql);
if(!empty($rrt['no']) && $rrt['mode'] == '2'){
$list[$i]["subject"] = "회원님이 차단하신 글입니다";
$list[$i]["wr_subject"] = "회원님이 차단하신 글입니다";
$list[$i]["wr_content"] = "회원님이 차단하신 글입니다";
$list[$i]["href"] = "";
$list[$i]["sing_flag"] = true;
}
}
$i++; $k++;
}
/* -------------------------------------------------
* 12) 캐시/페이징 링크 등 마무리
* ------------------------------------------------- */
g5_latest_cache_data($board['bo_table'], $list);
$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=')
);
$list_href = '';
$prev_part_href = '';
$next_part_href = '';
if ($is_search_bbs) {
$list_href = get_pretty_url($bo_table);
$patterns = ['#&page=[0-9]*#', '#&spt=[0-9\-]*#'];
$prev_spt = $spt - $config['cf_search_part'];
if (isset($min_spt) && $prev_spt >= $min_spt) {
$qstr1 = preg_replace($patterns, '', $qstr);
$prev_part_href = get_pretty_url($bo_table, 0, $qstr1.'&spt='.$prev_spt.'&page=1');
$write_pages = page_insertbefore($write_pages, '
이전검색');
}
$next_spt = $spt + $config['cf_search_part'];
if ($next_spt < 0) {
$qstr1 = preg_replace($patterns, '', $qstr);
$next_part_href = get_pretty_url($bo_table, 0, $qstr1.'&spt='.$next_spt.'&page=1');
$write_pages = page_insertafter($write_pages, '
다음검색');
}
}
$write_href = '';
if (!empty($member['mb_level']) && $member['mb_level'] >= $board['bo_write_level']) {
$write_href = short_url_clean(G5_BBS_URL . '/write.php?bo_table=' . $bo_table);
}
$nobr_begin = $nobr_end = '';
if (!empty($_SERVER['HTTP_USER_AGENT']) && preg_match("/gecko|firefox/i", $_SERVER['HTTP_USER_AGENT'])) {
$nobr_begin = '
';
$nobr_end = '';
}
$rss_href = '';
if (!empty($board['bo_use_rss_view'])) {
$rss_href = G5_BBS_URL.'/rss.php?bo_table='.$bo_table;
}
$stx = get_text(stripslashes($stx));
/* -------------------------------------------------
* 13) 최종 스킨
* ------------------------------------------------- */
include_once($board_skin_path.'/list.skin.php');