From c11b41c6bad51ffb3ed131ba0a651857d56ac831 Mon Sep 17 00:00:00 2001 From: hide_d Date: Mon, 21 Jan 2019 02:00:48 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=8C=EC=8B=9C=EB=AC=BC=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/j_add_board_article.php | 73 +++++++++++++++++++++++++++++++++ hwe/j_add_board_comment.php | 81 +++++++++++++++++++++++++++++++++++++ hwe/js/board.js | 3 +- 3 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 hwe/j_add_board_article.php create mode 100644 hwe/j_add_board_comment.php diff --git a/hwe/j_add_board_article.php b/hwe/j_add_board_article.php new file mode 100644 index 00000000..5d78c074 --- /dev/null +++ b/hwe/j_add_board_article.php @@ -0,0 +1,73 @@ +setReadOnly(); +$userID = Session::getUserID(); + +$db = DB::db(); + +$isSecretBoard = Util::getReq('isSecret', 'bool', false); +$title = Util::getReq('title'); +$text = Util::getReq('text'); + +increaseRefresh("회의실", 1); + +$me = $db->queryFirstRow('SELECT no, nation, level, permission, con, turntime, belong, penalty FROM general WHERE owner=%i', $userID); + +$con = checkLimit($me['con']); +if ($con >= 2) { + Json::die([ + 'result'=>false, + 'reason'=>'접속 제한입니다.' + ]); +} + +if($title === null || $text === null){ + Json::die([ + 'result'=>false, + 'reason'=>'올바르지 않은 입력입니다.' + ]); +} + +$title = trim($title); +$text = trim($text); + +if(!$title && !$text){ + Json::die([ + 'result'=>false, + 'reason'=>'제목과 내용이 둘다 비어있습니다.' + ]); +} + +$permission = checkSecretPermission($me); +if($permission < 0){ + Json::die([ + 'result'=>false, + 'reason'=>'국가에 소속되어있지 않습니다.' + ]); + +} +else if ($isSecretBoard && $permission < 2) { + Json::die([ + 'result'=>false, + 'reason'=>'권한이 부족합니다. 수뇌부가 아닙니다.' + ]); +} + +$db->insert('board', [ + 'nation_no'=>$me['nation'], + 'is_secret'=>$isSecretBoard, + 'date'=>TimeUtil::DatetimeNow(), + 'general_no'=>$me['no'], + 'author'=>$me['name'], + 'title'=>$title, + 'text'=>$text +]); + +Json::die([ + 'result'=>false, + 'reason'=>'success' +]); \ No newline at end of file diff --git a/hwe/j_add_board_comment.php b/hwe/j_add_board_comment.php new file mode 100644 index 00000000..f5f8a04d --- /dev/null +++ b/hwe/j_add_board_comment.php @@ -0,0 +1,81 @@ +setReadOnly(); +$userID = Session::getUserID(); + +$db = DB::db(); + +$articleNo = Util::getReq('articleNo', 'int'); +$text = Util::getReq('text'); + +increaseRefresh("회의실", 1); + +$me = $db->queryFirstRow('SELECT no, nation, level, permission, con, turntime, belong, penalty FROM general WHERE owner=%i', $userID); + +$con = checkLimit($me['con']); +if ($con >= 2) { + Json::die([ + 'result'=>false, + 'reason'=>'접속 제한입니다.' + ]); +} + +if($articleNo === null || $text === null){ + Json::die([ + 'result'=>false, + 'reason'=>'올바르지 않은 입력입니다.' + ]); +} + +$text = trim($text); + +if(!$text){ + Json::die([ + 'result'=>false, + 'reason'=>'내용이 비어있습니다.' + ]); +} + +$article = $db->queryFirstRow('SELECT * FROM board WHERE no = %i AND nation_no = %i', $articleNo, $me['nation']); +if(!$article){ + Json::die([ + 'result'=>false, + 'reason'=>'게시물이 없습니다.' + ]); +} + +$isSecretBoard = $article['is_secret']; + +$permission = checkSecretPermission($me); +if($permission < 0){ + Json::die([ + 'result'=>false, + 'reason'=>'국가에 소속되어있지 않습니다.' + ]); + +} +else if ($isSecretBoard && $permission < 2) { + Json::die([ + 'result'=>false, + 'reason'=>'권한이 부족합니다. 수뇌부가 아닙니다.' + ]); +} + +$db->insert('comment', [ + 'nation_no'=>$me['nation'], + 'is_secret'=>$isSecretBoard, + 'date'=>TimeUtil::DatetimeNow(), + 'document_no'=>$articleNo, + 'general_no'=>$me['no'], + 'author'=>$me['name'], + 'text'=>$text +]); + +Json::die([ + 'result'=>false, + 'reason'=>'success' +]); \ No newline at end of file diff --git a/hwe/js/board.js b/hwe/js/board.js index 1a51c8bc..bee0dbb6 100644 --- a/hwe/js/board.js +++ b/hwe/js/board.js @@ -19,6 +19,7 @@ function submitArticle(){ url:'j_add_board_article.php', dataType:'json', data:{ + isSecret:isSecretBoard, title:title, text:text } @@ -137,7 +138,7 @@ function loadArticles(){ url:'j_get_board_articles.php', dataType:'json', data:{ - isSecretBoard:isSecretBoard, //첫 버전이니까 전체 다 불러오자 + isSecret:isSecretBoard, //첫 버전이니까 전체 다 불러오자 } }); }