linux + utf-8 환경에서 분류,검색어 등에 한글이 포함될경우
$sql_search = get_sql_search($sca_qq, $sfl_qq, $stx_qq, $sop); // 변수명들에 _qq 꼬리를 붙여줌......
분류명이 "타이틀"일경우 "타이\틀" 처럼 한글이 깨는 문제에 관해
해결방안을 찾아보았습니다.
(개인적 참고용으로 올립니다. 그누보드4.34.10 기준이며, 오류가 있을 수 있습니다. : 적용시 주의)
./common.php
if (isset($sca)) {
$sca_qq = mysql_real_escape_string($sca); // _qq라는 꼬리말이 붙은 $sca_qq라는 새로운 변수 생성
$sca = stripslashes($sca); // $sca에는 슬래쉬가 제거된 문자열을 저장
$qstr .= '&sca=' . urlencode($sca);
}
if (isset($sfl)) {
$sfl_qq = mysql_real_escape_string($sfl);
$sfl = stripslashes($sfl);
$qstr .= '&sfl=' . urlencode($sfl);
}
if (isset($stx)) { // search text (검색어)
$stx_qq = mysql_real_escape_string($stx);
$stx = stripslashes($stx);
$qstr .= '&stx=' . urlencode($stx);
}
if (isset($sst)) {
$sst_qq = mysql_real_escape_string($sst);
$sst = stripslashes($sst);
$qstr .= '&sst=' . urlencode($sst);
}
./bbs/list.php
if ($sca || $stx)
{
$sql_search = get_sql_search($sca_qq, $sfl_qq, $stx_qq, $sop); // 변수명들에 _qq 꼬리를 붙여줌
....
}
....
$stx = get_text($stx); // $stx = get_text(stripslashes($stx)); 이었던것을 수정해줌
include_once("$board_skin_path/list.skin.php");
./bbs/view.php
if ($sca || $stx) {
.......
}
./skin/board/*/list.skin.php (모든 스킨들의 list.skin.php 파일)
<input name="stx" class="stx" maxlength="15" itemname="검색어" required value='<?=stripslashes($stx)?>
위처럼 사용했던 것을 아래와 같이 변경해줌
<input name="stx" class="stx" maxlength="15" itemname="검색어" required value='<?=$stx?>'>
오류, 보안 허점 지적해 주시면 감사하겠습니다.
댓글 5개
게시글 목록
| 번호 | 제목 |
|---|---|
| 34292 | |
| 34279 | |
| 34278 | |
| 34264 | |
| 34251 | |
| 34231 | |
| 34196 | |
| 34184 | |
| 34166 | |
| 34151 | |
| 34143 | |
| 34142 | |
| 34134 | |
| 34132 | |
| 34131 | |
| 34125 | |
| 34093 | |
| 34076 | |
| 34060 | |
| 34031 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기