Add option to limit the size of documents and comments

지나치게 용량이 큰 글을 등록하여 서버 과부하나 트래픽을 유발하는 경우가 있음.
예: ㅋㅋㅋ를 1000만 번쯤 복사해서 넣는다거나...

이런 문제를 막기 위해 게시판에서 글과 댓글의 용량을 제한할 수 있도록 함.
지저분한 태그가 많이 붙은 HTML 콘텐츠을 복붙하는 경우에 대비하여
기본값은 글 1024KB, 댓글 128KB로 여유있게 책정하였으며
사이트 특성에 따라 줄이면 됨.
This commit is contained in:
Kijin Sung 2018-03-07 15:51:36 +09:00
parent f11d3053f3
commit adb93006b4
4 changed files with 44 additions and 0 deletions

View file

@ -38,6 +38,13 @@ class boardController extends board
return $this->setError('msg_empty_content');
}
// Return error if content is too large.
$document_length_limit = ($this->module_info->document_length_limit ?: 1024) * 1024;
if (strlen($obj->content) > $document_length_limit && !$this->grant->manager)
{
return $this->setError('msg_content_too_long');
}
// unset document style if not manager
if(!$this->grant->manager)
{
@ -356,7 +363,20 @@ class boardController extends board
// get the relevant data for inserting comment
$obj = Context::getRequestVars();
$obj->module_srl = $this->module_srl;
// Return error if content is empty.
if (is_empty_html_content($obj->content))
{
return $this->setError('msg_empty_content');
}
// Return error if content is too large.
$comment_length_limit = ($this->module_info->comment_length_limit ?: 128) * 1024;
if (strlen($obj->content) > $comment_length_limit && !$this->grant->manager)
{
return $this->setError('msg_content_too_long');
}
if(!$this->module_info->use_status) $this->module_info->use_status = 'PUBLIC';
if(!is_array($this->module_info->use_status))
{