if(@strlen($_GET[wr_id]) > 0){ // View
$sql_search = "";
// 검색이면
if ($sca || $stx || $stx === '0' || count($arr_search) > 0) {
$se_arr = array();
$se_arr = $arr_search;
// where 문을 얻음
$sql_search = get_sql_search_all($sca, $sfl, $stx, $sop, $se_arr);
$search_href = get_pretty_url($bo_table,'','&page='.$page.$qstr);
$list_href = get_pretty_url($bo_table);
} else {
$search_href = '';
$list_href = get_pretty_url($bo_table,'',$qstr);
}
if (!$board['bo_use_list_view']) {
if ($sql_search)
$sql_search = " and " . $sql_search;
// 윗글을 얻음
$sql = " select wr_id, wr_subject, wr_hit from {$write_table} where wr_is_comment = 0 and wr_num = '{$write['wr_num']}' and wr_reply < '{$write['wr_reply']}' {$sql_search} order by wr_num desc, wr_reply desc limit 1 ";
$prev = sql_fetch($sql);
// 위의 쿼리문으로 값을 얻지 못했다면
if (!$prev['wr_id']) {
$sql = " select wr_id, wr_subject, wr_hit from {$write_table} where wr_is_comment = 0 and wr_num < '{$write['wr_num']}' {$sql_search} order by wr_num desc, wr_reply desc limit 1 ";
$prev = sql_fetch($sql);
}
// 아래글을 얻음
$sql = " select wr_id, wr_subject, wr_hit from {$write_table} where wr_is_comment = 0 and wr_num = '{$write['wr_num']}' and wr_reply > '{$write['wr_reply']}' {$sql_search} order by wr_num, wr_reply limit 1 ";
$next = sql_fetch($sql);
// 위의 쿼리문으로 값을 얻지 못했다면
if (!$next['wr_id']) {
$sql = " select wr_id, wr_subject, wr_hit from {$write_table} where wr_is_comment = 0 and wr_num > '{$write['wr_num']}' {$sql_search} order by wr_num, wr_reply limit 1 ";
$next = sql_fetch($sql);
}
}
// 이전글 링크
$prev_href = '';
if (isset($prev['wr_id']) && $prev['wr_id']) {
$prev_wr_subject = get_text(cut_str($prev['wr_subject'], 255));
$prev_href = get_pretty_url($bo_table, $prev['wr_id'], $qstr);
$prev_wr_date = $prev['wr_hit'];
}
// 다음글 링크
$next_href = '';
if (isset($next['wr_id']) && $next['wr_id']) {
$next_wr_subject = get_text(cut_str($next['wr_subject'], 255));
$next_href = get_pretty_url($bo_table, $next['wr_id'], $qstr);
$next_wr_date = $next['wr_hit'];
}
// 쓰기 링크
$write_href = '';
if ($member['mb_level'] >= $board['bo_write_level']) {
$write_href = short_url_clean(G5_BBS_URL.'/write.php?bo_table='.$bo_table);
}
// 답변 링크
$reply_href = '';
if ($member['mb_level'] >= $board['bo_reply_level']) {
$reply_href = short_url_clean(G5_BBS_URL.'/write.php?w=r&bo_table='.$bo_table.'&wr_id='.$wr_id.$qstr);
}
// 수정, 삭제 링크
$update_href = $delete_href = '';
// 로그인중이고 자신의 글이라면 또는 관리자라면 비밀번호를 묻지 않고 바로 수정, 삭제 가능
if (($member['mb_id'] && ($member['mb_id'] === $write['mb_id'])) || $is_admin) {
$update_href = short_url_clean(G5_BBS_URL.'/write.php?w=u&bo_table='.$bo_table.'&wr_id='.$wr_id.'&page='.$page.$qstr);
set_session('ss_delete_token', $token = uniqid(time()));
$delete_href = G5_BBS_URL.'/delete.php?bo_table='.$bo_table.'&wr_id='.$wr_id.'&token='.$token.'&page='.$page.urldecode($qstr);
}
else if (!$write['mb_id']) { // 회원이 쓴 글이 아니라면
$update_href = G5_BBS_URL.'/password.php?w=u&bo_table='.$bo_table.'&wr_id='.$wr_id.'&page='.$page.$qstr;
$delete_href = G5_BBS_URL.'/password.php?w=d&bo_table='.$bo_table.'&wr_id='.$wr_id.'&page='.$page.$qstr;
}
// 최고, 그룹관리자라면 글 복사, 이동 가능
$copy_href = $move_href = '';
if ($write['wr_reply'] == '' && ($is_admin == 'super' || $is_admin == 'group')) {
$copy_href = G5_BBS_URL.'/move.php?sw=copy&bo_table='.$bo_table.'&wr_id='.$wr_id.'&page='.$page.$qstr;
$move_href = G5_BBS_URL.'/move.php?sw=move&bo_table='.$bo_table.'&wr_id='.$wr_id.'&page='.$page.$qstr;
}
$scrap_href = '';
$good_href = '';
$nogood_href = '';
if ($is_member) {
// 스크랩 링크
$scrap_href = G5_BBS_URL.'/scrap_popin.php?bo_table='.$bo_table.'&wr_id='.$wr_id;
// 추천 링크
if ($board['bo_use_good'])
$good_href = G5_BBS_URL.'/good.php?bo_table='.$bo_table.'&wr_id='.$wr_id.'&good=good';
// 비추천 링크
if ($board['bo_use_nogood'])
$nogood_href = G5_BBS_URL.'/good.php?bo_table='.$bo_table.'&wr_id='.$wr_id.'&good=nogood';
}
}
쿼리문을 이런식으로 다시 돌리고 있긴 하네요.... 근데 datetime부분을 hit으로 바꿨는데도 적용이 안되네요 ㅠ