diff --git a/modules/spamfilter/spamfilter.controller.php b/modules/spamfilter/spamfilter.controller.php index 2cbe50f7f..2bfaee8a8 100644 --- a/modules/spamfilter/spamfilter.controller.php +++ b/modules/spamfilter/spamfilter.controller.php @@ -155,6 +155,88 @@ **/ function insertIP($ipaddress) { $args->ipaddress = $ipaddress; + $args->search_target = 'ipaddress'; + Context::set('search_target', 'ipaddress'); + $args->search_keyword = $ipaddress; + Context::set('search_keyword', $ipaddress); + $args->start_date = ((int)date('Ymd')-2).'0000'; // 이틀 전 + $oDocumentModel = &getModel('document'); + $output = $oDocumentModel->getDocumentList($args); + $document_list = $output->data; + + // begin transaction + $oDB = &DB::getInstance(); + $oDB->begin(); + + if(is_array($document_list)) { + foreach($document_list as $oDocument) { + if($oDocument->isExists()) { + // 글 삭제 + $args->document_srl = $oDocument->document_srl; + $output = executeQuery('document.deleteDocument', $args); + if(!$output->toBool()) { + $oDB->rollback(); + return $output; + } + + // 카테고리가 있으면 카테고리 정보 변경 + if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); + + // 신고 삭제 + executeQuery('document.deleteDeclared', $args); + + // 썸네일 파일 제거 + FileHandler::removeDir(sprintf('files/cache/thumbnails/%s',getNumberingPath($document_srl, 3))); + + // commit + $oDB->commit(); + } + } + } + $oCommentModel = &getModel('comment'); + $output = $oCommentModel->getTotalCommentList($args); + $comment_list = $output->data; + if(is_array($comment_list)) { + foreach($comment_list as $oComment) { + $comment_srl = $oComment->comment_srl; + $comment = $oCommentModel->getComment($comment_srl); + if($comment->comment_srl != $comment_srl) return new Object(-1, 'msg_invalid_request'); + $document_srl = $comment->document_srl; + + // 해당 댓글에 child가 있는지 확인 + $child_count = $oCommentModel->getChildCommentCount($comment_srl); + if($child_count==0) { + + // begin transaction + $oDB = &DB::getInstance(); + $oDB->begin(); + + // 삭제 + $args->comment_srl = $comment_srl; + $output = executeQuery('comment.deleteComment', $args); + if(!$output->toBool()) { + $oDB->rollback(); + } + + $output = executeQuery('comment.deleteCommentList', $args); + + // 댓글 수를 구해서 업데이트 + $comment_count = $oCommentModel->getCommentCount($document_srl); + + // document의 controller 객체 생성 + $oDocumentController = &getController('document'); + + // 해당글의 댓글 수를 업데이트 + $output = $oDocumentController->updateCommentCount($document_srl, $comment_count, null, false); + if(!$output->toBool()) { + $oDB->rollback(); + } + + // commit + $oDB->commit(); + } + } + } return executeQuery('spamfilter.insertDeniedIP', $args); }