본문으로 건너뛰기

- [게시판] 비회원 글쓰기 보안 강화

PHP 7 · GODO25
변경 파일 수: 2개
변경 파일 목록
총 2개
변경 파일 코드
추가삭제
Component/Board/Board.php+17
변경 전Board.php
const TEXT_INSUFFICIENT_INPUTDATA = '입력 정보가 부족합니다';
const TEXT_NOTMATCH_PASSWORD = '비밀번호가 일치하지 않습니다';
const TEXT_NOTHAVE_AUTHORITY = '%s권한이 없습니다.';
 
const TEXT_UPLOAD_IMPOSSIBLE = '업로드가 불가능합니다';
const EXCEPTION_CODE_AUTH = 700;
const UPLOAD_DEFAULT_MAX_SIZE = 5; //업로드 최대용량 디플트 값(mb)
if($result['cnt']>0) {
throw new \Exception(__("중복된 게시물을 연속으로 등록할 수 없습니다. \n중복 게시물이 아닌 경우, 잠시 후 다시 등록하시기 바랍니다."));
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
}
return true;
}
 
변경 후Board.php
const TEXT_INSUFFICIENT_INPUTDATA = '입력 정보가 부족합니다';
const TEXT_NOTMATCH_PASSWORD = '비밀번호가 일치하지 않습니다';
const TEXT_NOTHAVE_AUTHORITY = '%s권한이 없습니다.';
const TEXT_GUEST_WRITE_RATE_LIMIT = '잠시 후 다시 등록해 주세요. (1분 이내 연속 등록 제한)';
const TEXT_UPLOAD_IMPOSSIBLE = '업로드가 불가능합니다';
const EXCEPTION_CODE_AUTH = 700;
const UPLOAD_DEFAULT_MAX_SIZE = 5; //업로드 최대용량 디플트 값(mb)
if($result['cnt']>0) {
throw new \Exception(__("중복된 게시물을 연속으로 등록할 수 없습니다. \n중복 게시물이 아닌 경우, 잠시 후 다시 등록하시기 바랍니다."));
}
 
}
 
// 비회원(memNo=0) 게시글/답변 연속 등록 제한: 동일 IP 60초 이내 재등록 차단 (제목 무관)
if (in_array($this->req['mode'], ['write', 'reply'], true) && (int) $this->member['memNo'] === 0) {
$remoteAddr = Request::getRemoteAddress();
$guestBind = [];
$this->db->bind_param_push($guestBind, 's', $remoteAddr);
$guestResult = $this->db->query_fetch("SELECT count(*) as cnt FROM " . DB_BD_ . $this->cfg['bdId'] . " WHERE memNo = 0 AND writerIp = ? AND regDt >= (now() - INTERVAL 60 SECOND) ", $guestBind, false);
if ($guestResult['cnt'] > 0) {
try {
\Logger::channel('board')->warning('[Board] 비회원 연속 등록 제한', ['bdId' => $this->cfg['bdId'], 'writerIp' => $remoteAddr]);
} catch (\Throwable $e) {
}
throw new \Exception(__(self::TEXT_GUEST_WRITE_RATE_LIMIT));
}
}
return true;
}
 
Controller/Mobile/Board/BoardPsController.php+6
변경 전BoardPsController.php
use Component\Member\MemberReport;
use Component\Validator\Validator;
use Framework\Debug\Exception\AlertBackException;
 
use Framework\ObjectStorage\Service\ImageUploadService;
use function GuzzleHttp\Psr7\parse_query;
use View\Template;
exit;
 
} catch (\Exception $e) {
 
 
 
 
 
throw new AlertBackException($e->getMessage());
}
break;
 
변경 후BoardPsController.php
use Component\Member\MemberReport;
use Component\Validator\Validator;
use Framework\Debug\Exception\AlertBackException;
use Framework\Debug\Exception\AlertRedirectException;
use Framework\ObjectStorage\Service\ImageUploadService;
use function GuzzleHttp\Psr7\parse_query;
use View\Template;
exit;
 
} catch (\Exception $e) {
// 비밀글은 글 상세가 POST로 열리므로 답글 실패 후 뒤로가기 시 양식 재전송 확인 페이지가 노출됨
$isListReturn = gd_isset($req['gboard']) != 'y' && gd_isset($req['gboard']) != 'r';
if ($req['mode'] == 'reply' && $isListReturn && isset($boardAct) && $boardAct->cfg['bdSecretFl'] != '2') {
throw new AlertRedirectException($e->getMessage(), 0, null, '../board/list.php?' . $req['returnUrl']);
}
throw new AlertBackException($e->getMessage());
}
break;