게시물 코드
This commit is contained in:
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
|
include "lib.php";
|
||||||
|
include "func.php";
|
||||||
|
//로그인 검사
|
||||||
|
$session = Session::requireGameLogin()->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'
|
||||||
|
]);
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
|
include "lib.php";
|
||||||
|
include "func.php";
|
||||||
|
//로그인 검사
|
||||||
|
$session = Session::requireGameLogin()->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'
|
||||||
|
]);
|
||||||
+2
-1
@@ -19,6 +19,7 @@ function submitArticle(){
|
|||||||
url:'j_add_board_article.php',
|
url:'j_add_board_article.php',
|
||||||
dataType:'json',
|
dataType:'json',
|
||||||
data:{
|
data:{
|
||||||
|
isSecret:isSecretBoard,
|
||||||
title:title,
|
title:title,
|
||||||
text:text
|
text:text
|
||||||
}
|
}
|
||||||
@@ -137,7 +138,7 @@ function loadArticles(){
|
|||||||
url:'j_get_board_articles.php',
|
url:'j_get_board_articles.php',
|
||||||
dataType:'json',
|
dataType:'json',
|
||||||
data:{
|
data:{
|
||||||
isSecretBoard:isSecretBoard, //첫 버전이니까 전체 다 불러오자
|
isSecret:isSecretBoard, //첫 버전이니까 전체 다 불러오자
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user