PublicRecord 함수 수정, json_encode, json_deocde를 Json로 통합

This commit is contained in:
2018-04-01 19:16:00 +09:00
parent 1f5f7e3591
commit 6ee8066c80
15 changed files with 47 additions and 38 deletions
+2 -2
View File
@@ -65,12 +65,12 @@ $rootDB->insert('member_log', [
'member_no'=>$userID,
'date'=>$nowDate,
'action_type'=>'reg',
'action'=>json_encode([
'action'=>Json::encode([
'type'=>'none',
'aux'=>'admin',
'id'=>$username,
'name'=>$nickname
], JSON_UNESCAPED_UNICODE)
])
]);
Json::die([
+3 -3
View File
@@ -175,7 +175,7 @@ function getGeneralPublicRecordRecent($count) {
return join('<br>', $texts);
}
function getGeneralPublicRecordWithDate($count, $year, $month, $isFirst=0) {
function getGeneralPublicRecordWithDate($year, $month) {
$db = DB::db();
$texts = [];
@@ -225,10 +225,10 @@ function LogHistory($isFirst=0) {
$year = $map['year'];
$month = $map['month'];
$map_json = json_encode($map, JSON_UNESCAPED_UNICODE);
$map_json = Json::encode($map);
$log = getWorldHistoryWithDate($year, $month);
$genlog = getGeneralPublicRecordWithDate(50, $year, $month, $isFirst);
$genlog = getGeneralPublicRecordWithDate($year, $month);
$nationStr = "";
$powerStr = "";
+1 -1
View File
@@ -34,7 +34,7 @@ function getHistoryMap($year, $month){
return ['result'=>false, 'reason'=>'연감이 저장되지 않음'];
}
return json_decode($map, true);//까짓거 json_decode, json_encode 두번하지 뭐.
return Json::decode($map);//까짓거 json_decode, json_encode 두번하지 뭐.
}
/**
+4 -4
View File
@@ -130,7 +130,7 @@ function sendRawMessage($msgType, $isSender, $mailbox, $src, $dest, $msg, $date,
unset($msgOption['alert']);
}
DB::db()->insert('message', array(
DB::db()->insert('message', [
'address' => $dest,
'type' => $msgType,
'is_sender' => $isSender,
@@ -138,13 +138,13 @@ function sendRawMessage($msgType, $isSender, $mailbox, $src, $dest, $msg, $date,
'dest' => $dest['id'],
'time' => $date,
'valid_until' => $validUntil,
'message' => json_encode(Util::eraseNullValue([
'message' => Json::encode([
'src' => $src,
'dest' =>$dest,
'text' => $msg,
'option' => $msgOption
]))
));
], Json::DELETE_NULL)
]);
}
function sendMessage($msgType, $src, $dest, $msg, $date = null, $validUntil = null, $msgOption = null){
+3 -3
View File
@@ -62,13 +62,13 @@ if ($validUntil < $date) {
]);
}
$msgOption = json_decode(Util::array_get($messageInfo['option'], '{}'));
$msgOption = Json::decode(Util::array_get($messageInfo['option'], '{}'));
$msgAction = Util::array_get($msgOption['action'], null);
$messageInfo['option'] = $msgOption;
$msgSrc = json_decode($messageInfo['src']);
$msgSrc = Json::decode($messageInfo['src']);
$messageInfo['src'] = $msgSrc;
$msgDest = json_decode($messageInfo['dest']);
$msgDest = Json::decode($messageInfo['dest']);
$messageInfo['dest'] = $msgDest;
if (!$msgAction) {
+2 -2
View File
@@ -32,7 +32,7 @@ if(!$db->affectedRows()){
$db->insert('member_log', [
'member_no'=>$session->userID,
'action_type'=>'change_pw',
'action'=>json_encode([
'action'=>Json::encode([
'type'=>'plain',
'result'=>false
])
@@ -47,7 +47,7 @@ if(!$db->affectedRows()){
$db->insert('member_log', [
'member_no'=>$session->userID,
'action_type'=>'change_pw',
'action'=>json_encode([
'action'=>Json::encode([
'type'=>'plain',
'result'=>true
])
+1 -1
View File
@@ -93,4 +93,4 @@ function doAdminPost($action, $notice, $server){
$response = doAdminPost($action, $notice, $server);
echo json_encode($response);
Json::die($response);
+2 -2
View File
@@ -100,11 +100,11 @@ RootDB::db()->insert('member_log', [
'member_no'=>$userID,
'date'=>$nowDate,
'action_type'=>'change_pw',
'action'=>json_encode([
'action'=>Json::encode([
'type'=>'kakao',
'no'=>$userID,
'token'=>$access_token
], JSON_UNESCAPED_UNICODE)
])
]);
RootDB::db()->query("unlock tables");
+3 -3
View File
@@ -108,7 +108,7 @@ $kakaoID = Util::array_get($signupResult['id']);
if(!$kakaoID && Util::array_get($signupResult['msg'])!='already registered'){
Json::die([
'result'=>false,
'reason'=>'카카오 로그인 과정 중 앱 연결 절차를 실패했습니다'.json_encode($signupResult)
'reason'=>'카카오 로그인 과정 중 앱 연결 절차를 실패했습니다'.Json::encode($signupResult)
]);
}
@@ -158,11 +158,11 @@ RootDB::db()->insert('member_log', [
'member_no'=>$userID,
'date'=>$nowDate,
'action_type'=>'reg',
'action'=>json_encode([
'action'=>Json::encode([
'type'=>'kakao',
'id'=>$kakaoID,
'email'=>$email, 'name'=>$nickname
], JSON_UNESCAPED_UNICODE)
])
]);
Json::die([
+1 -1
View File
@@ -37,7 +37,7 @@ else{
die('알 수 없는 에러:'.$me['msg']);
}
$_SESSION['tmpx'] = json_encode($result,JSON_UNESCAPED_UNICODE);
$_SESSION['tmpx'] = Json::encode($result);
//echo "<br>\n";
$me = $restAPI->meWithEmail();
+18 -9
View File
@@ -2,29 +2,38 @@
namespace sammo;
class Json{
public static function encode($value, $pretty = false){
if($pretty){
$flag = JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT;
const PRETTY = 1;
const DELETE_NULL = 2;
const NO_CACHE = 4;
public static function encode($value, $flag = 0){
$rawFlag = JSON_UNESCAPED_UNICODE;
if($flag & static::PRETTY){
$rawFlag |= JSON_PRETTY_PRINT;
}
else{
$flag = JSON_UNESCAPED_UNICODE;
if($flag & static::DELETE_NULL){
$value = Util::eraseNullValue($value);
}
return json_encode($value, $flag);
return json_encode($value, $rawFlag);
}
public static function encodePack($value, $pretty = false){
}
public static function decode($value){
return json_decode($value, true);
}
public static function die($value, $noCache = true, $pretty = false, $die = true){
public static function die($value, $flag = NO_CACHE){
//NOTE: REST 형식에 맞게, ok(), fail()로 쪼개는게 낫지 않을까 생각해봄.
if($noCache){
if($flag & static::NO_CACHE){
WebUtil::setHeaderNoCache();
}
header('Content-Type: application/json');
echo Json::encode($value, $pretty);
echo Json::encode($value, $flag);
if($die){
die();
}
+1 -1
View File
@@ -28,7 +28,7 @@ class WebUtil{
$content = trim(file_get_contents("php://input"));
//Attempt to decode the incoming RAW post data from JSON.
$decoded = json_decode($content, true);
$decoded = Json::decode($content);
$jsonError = json_last_error();
+2 -2
View File
@@ -4,8 +4,8 @@ require('../twe/lib.php');
$jsonPost = WebUtil::parseJsonPost();
echo json_encode([
Json::die([
'result'=>true,
'reason'=>'success',
'msgID'=>1997
], JSON_UNESCAPED_UNICODE);
]);
+2 -2
View File
@@ -18,8 +18,8 @@ function relayJson($filepath, $noCache = true, $die = true){
header('Pragma: no-cache');
}
$json = json_decode(file_get_contents($filepath));
echo json_encode($json,JSON_UNESCAPED_UNICODE);
$json = Json::decode(file_get_contents($filepath));
echo Json::encode($json);
if($die){
die();
+2 -2
View File
@@ -4,7 +4,7 @@ require('../twe/lib.php');
$jsonPost = WebUtil::parseJsonPost();
echo json_encode([
Json::die([
'result'=>true,
'reason'=>'success'
], JSON_UNESCAPED_UNICODE);
]);