diff --git a/hwe/_admin7.php b/hwe/_admin7.php
index f46838cd..a51290fc 100644
--- a/hwe/_admin7.php
+++ b/hwe/_admin7.php
@@ -146,10 +146,10 @@ $generalObj = General::createGeneralObjFromDB($gen);
|
- =getGenLogRecent($gen, 24)?>
+ =formatHistoryToHTML(getGenLogRecent($gen, 24))?>
|
- =getBatLogRecent($gen, 24)?>
+ =formatHistoryToHTML(getBatLogRecent($gen, 24))?>
|
@@ -158,10 +158,10 @@ $generalObj = General::createGeneralObjFromDB($gen);
|
- =getGeneralHistoryAll($gen)?>
+ =formatHistoryToHTML(getGeneralHistoryAll($gen))?>
|
- =getBatResRecent($gen, 24)?>
+ =formatHistoryToHTML(getBatResRecent($gen, 24))?>
|
diff --git a/hwe/a_emperior2.php b/hwe/a_emperior2.php
index 09eb37d1..e0d10a8e 100644
--- a/hwe/a_emperior2.php
+++ b/hwe/a_emperior2.php
@@ -195,7 +195,7 @@ if ($select == 0) {
| 역 사 기 록 |
- ".ConvertLog($emperior['history'], 1)." |
+ ".formatHistoryToHTML(Json::decode($emperior['history']))." |
";
diff --git a/hwe/a_emperior_detail.php b/hwe/a_emperior_detail.php
index 6daabeb5..69d4a050 100644
--- a/hwe/a_emperior_detail.php
+++ b/hwe/a_emperior_detail.php
@@ -153,7 +153,7 @@ if($emperior):
| 역 사 기 록 |
- =ConvertLog($emperior['history'], 1)?> |
+ =formatHistoryToHTML(Json::decode($emperior['history']))?> |
diff --git a/hwe/a_history.php b/hwe/a_history.php
index c0c43f83..2625fc82 100644
--- a/hwe/a_history.php
+++ b/hwe/a_history.php
@@ -148,13 +148,13 @@ var selectMonth = =$month?>;
| 중 원 정 세 |
|
- =$history['log']?>
+ =formatHistoryToHTML(Json::decode($history['log']))?>
|
| 장 수 동 향 |
|
- =$history['genlog']?>
+ =formatHistoryToHTML(Json::decode($history['genlog']))?>
|
diff --git a/hwe/a_status.php b/hwe/a_status.php
index a7178e4d..f16e9951 100644
--- a/hwe/a_status.php
+++ b/hwe/a_status.php
@@ -64,7 +64,7 @@ $(function(){
|
- =getGeneralPublicRecordRecent(34)?>
+ =formatHistoryToHTML(getGeneralPublicRecordRecent(34))?>
|
=getMapHtml($mapTheme)?>
@@ -72,7 +72,7 @@ $(function(){
|
|
- =getWorldHistoryRecent(34)?>
+ =formatHistoryToHTML(getWorldHistoryRecent(34))?>
|
diff --git a/hwe/b_battleCenter.php b/hwe/b_battleCenter.php
index 888956ec..851bfbdd 100644
--- a/hwe/b_battleCenter.php
+++ b/hwe/b_battleCenter.php
@@ -174,7 +174,7 @@ $showGeneral = General::createGeneralObjFromDB($gen);
- =getGeneralHistoryAll($gen)?>
+ =formatHistoryToHTML(getGeneralHistoryAll($gen))?>
|
@@ -183,10 +183,10 @@ $showGeneral = General::createGeneralObjFromDB($gen);
|
- =getBatLogRecent($gen, 24)?>
+ =formatHistoryToHTML(getBatLogRecent($gen, 24))?>
|
- =getBatResRecent($gen, 24)?>
+ =formatHistoryToHTML(getBatResRecent($gen, 24))?>
|
1 || $permission >= 2): ?>
@@ -196,7 +196,7 @@ $showGeneral = General::createGeneralObjFromDB($gen);
|
- =getGenLogRecent($gen, 24)?>
+ =formatHistoryToHTML(getGenLogRecent($gen, 24))?>
|
|
diff --git a/hwe/b_myKingdomInfo.php b/hwe/b_myKingdomInfo.php
index a0787052..1e87b8d2 100644
--- a/hwe/b_myKingdomInfo.php
+++ b/hwe/b_myKingdomInfo.php
@@ -43,7 +43,7 @@ if($nationID == 0) {
queryFirstRow('SELECT nation,gennum,power,rate,bill,type,gold,rice,color,name,level,tech,history,capital FROM nation WHERE nation=%i', $nationID); //국가정보
+$nation = $db->queryFirstRow('SELECT nation,gennum,power,rate,bill,type,gold,rice,color,name,level,tech,capital FROM nation WHERE nation=%i', $nationID); //국가정보
$cityList = $db->query('SELECT * FROM city WHERE nation=%i', $nationID);
$currPop = 0;
@@ -146,7 +146,7 @@ if ($budgetricediff > 0) {
| 국가열전 |
- =ConvertLog($nation['history'])?> |
+ =formatHistoryToHTML(getNationHistoryAll($nation['nation']))?> |
diff --git a/hwe/b_myPage.php b/hwe/b_myPage.php
index fcb5ed4d..ff321313 100644
--- a/hwe/b_myPage.php
+++ b/hwe/b_myPage.php
@@ -161,10 +161,10 @@ $('#die_immediately').click(function(){
|
- =getGenLogRecent($generalID, 24)?>
+ =formatHistoryToHTML(getGenLogRecent($generalID, 24))?>
|
- =getBatLogRecent($generalID, 24)?>
+ =formatHistoryToHTML(getBatLogRecent($generalID, 24))?>
|
@@ -173,10 +173,10 @@ $('#die_immediately').click(function(){
|
- =getGeneralHistoryAll($generalID)?>
+ =formatHistoryToHTML(getGeneralHistoryAll($generalID))?>
|
- =getBatResRecent($generalID, 24)?>
+ =formatHistoryToHTML(getBatResRecent($generalID, 24))?>
|
diff --git a/hwe/func.php b/hwe/func.php
index 669dc1fd..8f97606a 100644
--- a/hwe/func.php
+++ b/hwe/func.php
@@ -1566,6 +1566,7 @@ function deleteNation(General $general) {
$oldNationGenerals = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $nationID);
$oldNation['generals'] = $oldNationGenerals;
$oldNation['aux'] = Json::decode($oldNation['aux']);
+ $oldNation['history'] = getNationHistoryAll($nationID);
$general->setVar('belong', 0);
$general->setVar('troop', 0);
diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php
index af9e0f44..e30667fe 100644
--- a/hwe/func_gamerule.php
+++ b/hwe/func_gamerule.php
@@ -651,6 +651,7 @@ function checkMerge() {
$oldNationGenerals = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $me['nation']);
$oldNation['generals'] = $oldNationGenerals;
$oldNation['aux'] = Json::decode($oldNation['aux']);
+ $oldNation['history'] = getNationHistoryAll($me['nation']);
// 자금 통합, 외교제한 5년, 기술유지
$db->update('nation', [
@@ -801,6 +802,7 @@ function checkSurrender() {
$oldNationGenerals = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $me['nation']);
$oldNation['generals'] = $oldNationGenerals;
$oldNation['aux'] = Json::decode($oldNation['aux']);
+ $oldNation['history'] = getNationHistoryAll($me['nation']);
$newGenCount = $gencount + $gencount2;
$newTech = ($younation['tech'] * $gencount + $mynation['tech'] * $gencount2) / $newGenCount;
@@ -1186,6 +1188,7 @@ function checkStatistic() {
function convForOldGeneral(array $general, int $year, int $month){
+ $general['history'] = getGeneralHistoryAll($general['no']);
return [
'server_id'=>UniqueConst::$serverID,
'general_no'=>$general['no'],
@@ -1345,6 +1348,7 @@ function checkEmperior() {
$oldNation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $nation['nation']);
$oldNation['generals'] = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $nation['nation']);
$oldNation['aux'] = Json::decode($oldNation['aux']);
+ $oldNation['history'] = getNationHistoryAll($nation['nation']);
storeOldGenerals(0, $admin['year'], $admin['month']);
storeOldGenerals($nation['nation'], $admin['year'], $admin['month']);
@@ -1366,7 +1370,7 @@ function checkEmperior() {
])
]);
- $nationHistory = DB::db()->queryFirstField('SELECT `history` FROM `nation` WHERE `nation` = %i', $nation['nation']);
+ $nationHistory = JSON::encode(getNationHistoryAll($nation['nation']));
$serverCnt = $db->queryFirstField('SELECT count(*) FROM ng_games');
$serverName = UniqueConst::$serverName;
diff --git a/hwe/func_history.php b/hwe/func_history.php
index 6b2e94b8..6674bf79 100644
--- a/hwe/func_history.php
+++ b/hwe/func_history.php
@@ -129,7 +129,13 @@ function pushOldNationStop(int $no, int $nationNo){
}
//DB-based
-
+function formatHistoryToHTML(array $history):string{
+ $result = [];
+ foreach($history as $item){
+ $result[] = ConvertLog($item);
+ }
+ return join('
', $result);
+}
function pushGenLog(int $generalID, ?array $history, ?int $year=null, ?int $month=null) {
if(!$history){
@@ -153,19 +159,13 @@ function pushGenLog(int $generalID, ?array $history, ?int $year=null, ?int $mont
$db->insert('general_record', $request);
}
-function getGenLogRecent(int $generalID, int $count) {
+function getGenLogRecent(int $generalID, int $count):array{
$db = DB::db();
- $texts = [];
- foreach(
- $db->queryFirstColumn(
- 'SELECT `text` from general_record WHERE general_id = %i AND log_type = "action" order by id desc LIMIT %i',
- $generalID, $count
- ) as $text
- ){
- $texts[] = ConvertLog($text);
- }
- return join('
', $texts);
+ return $db->queryFirstColumn(
+ 'SELECT `text` from general_record WHERE general_id = %i AND log_type = "action" order by id desc LIMIT %i',
+ $generalID, $count
+ );
}
function pushBatRes(int $generalID, array $history, ?int $year=null, ?int $month=null) {
@@ -190,19 +190,13 @@ function pushBatRes(int $generalID, array $history, ?int $year=null, ?int $month
$db->insert('general_record', $request);
}
-function getBatResRecent(int $generalID, int $count) {
+function getBatResRecent(int $generalID, int $count):array {
$db = DB::db();
- $texts = [];
- foreach(
- $db->queryFirstColumn(
- 'SELECT `text` from general_record WHERE general_id = %i AND log_type = "battle_brief" order by id desc LIMIT %i',
- $generalID, $count
- ) as $text
- ){
- $texts[] = ConvertLog($text);
- }
- return join('
', $texts);
+ return $db->queryFirstColumn(
+ 'SELECT `text` from general_record WHERE general_id = %i AND log_type = "battle_brief" order by id desc LIMIT %i',
+ $generalID, $count
+ );
}
function pushBatLog(int $generalID, array $history, ?int $year=null, ?int $month=null) {
@@ -227,19 +221,13 @@ function pushBatLog(int $generalID, array $history, ?int $year=null, ?int $month
$db->insert('general_record', $request);
}
-function getBatLogRecent(int $generalID, int $count) {
+function getBatLogRecent(int $generalID, int $count):array {
$db = DB::db();
- $texts = [];
- foreach(
- $db->queryFirstColumn(
- 'SELECT `text` from general_record WHERE general_id = %i AND log_type = "battle" order by id desc LIMIT %i',
- $generalID, $count
- ) as $text
- ){
- $texts[] = ConvertLog($text);
- }
- return join('
', $texts);
+ return $db->queryFirstColumn(
+ 'SELECT `text` from general_record WHERE general_id = %i AND log_type = "battle" order by id desc LIMIT %i',
+ $generalID, $count
+ );
}
@@ -266,19 +254,13 @@ function pushGeneralHistory(int $generalID, ?array $history, $year=null, $month=
}
-function getGeneralHistoryAll(int $generalID) {
+function getGeneralHistoryAll(int $generalID):array {
$db = DB::db();
- $texts = [];
- foreach(
- $db->queryFirstColumn(
- 'SELECT `text` from general_record WHERE general_id = %i AND log_type = "history" order by id desc',
- $generalID
- ) as $text
- ){
- $texts[] = ConvertLog($text);
- }
- return join('
', $texts);
+ return $db->queryFirstColumn(
+ 'SELECT `text` from general_record WHERE general_id = %i AND log_type = "history" order by id desc',
+ $generalID
+ );
}
@@ -298,6 +280,15 @@ function pushNationHistory(int $nationID, ?array $history, ?int $year=null, ?int
$db->insert('world_history', $request);
}
+function getNationHistoryAll(int $nationID):array {
+ $db = DB::db();
+
+ return $db->queryFirstColumn(
+ 'SELECT `text` from world_history WHERE nation_id = %i order by id desc',
+ $nationID
+ );
+}
+
function pushWorldHistory(?array $history, $year=null, $month=null) {
if(!$history){
@@ -315,35 +306,25 @@ function pushWorldHistory(?array $history, $year=null, $month=null) {
$db->insert('world_history', $request);
}
-function getWorldHistoryRecent(int $count) {
+function getWorldHistoryRecent(int $count):array {
$db = DB::db();
- $texts = [];
- foreach($db->queryFirstColumn('SELECT `text` from world_history WHERE nation_id = 0 order by id desc limit %i', $count) as $text){
- $texts[] = ConvertLog($text);
- }
- return join('
', $texts);
+ return $db->queryFirstColumn('SELECT `text` from world_history WHERE nation_id = 0 order by id desc limit %i', $count);
}
-function getWorldHistoryWithDate(int $year, int $month) {
+function getWorldHistoryWithDate(int $year, int $month):array {
$db = DB::db();
- $texts = [];
- foreach(
- $db->queryFirstColumn(
- 'SELECT `text` from world_history where nation_id = 0 AND year = %i and month = %i order by id desc',
- $year,
- $month
- ) as $text
- ){
- $texts[] = ConvertLog($text);
- }
+ $texts = $db->queryFirstColumn(
+ 'SELECT `text` from world_history where nation_id = 0 AND year = %i and month = %i order by id desc',
+ $year,
+ $month
+ );
if(!$texts){
- return ConvertLog("●>{$year}년 {$month}월: 기록 없음");
+ return ["●>{$year}년 {$month}월: 기록 없음"];
}
-
- return join('
', $texts);
+ return $texts;
}
@@ -363,39 +344,28 @@ function pushGeneralPublicRecord(?array $history, ?int $year=null, ?int $month=n
$db->insert('general_record', $request);
}
-function getGeneralPublicRecordRecent(int $count) {
+function getGeneralPublicRecordRecent(int $count):array {
$db = DB::db();
- $texts = [];
- foreach(
- $db->queryFirstColumn(
- 'SELECT `text` from general_record WHERE general_id = 0 AND log_type = "history" order by id desc limit %i',
- $count
- ) as $text
- ){
- $texts[] = ConvertLog($text);
- }
- return join('
', $texts);
+ return $db->queryFirstColumn(
+ 'SELECT `text` from general_record WHERE general_id = 0 AND log_type = "history" order by id desc limit %i',
+ $count
+ );
}
-function getGeneralPublicRecordWithDate(int $year, int $month) {
+function getGeneralPublicRecordWithDate(int $year, int $month):array {
$db = DB::db();
- $texts = [];
- foreach(
- $db->queryFirstColumn(
- 'SELECT `text` from general_record where general_id = 0 AND log_type = "history" AND year = %i and month = %i order by id desc',
- $year,
- $month
- ) as $text
- ){
- $texts[] = ConvertLog($text);
- }
+ $texts = $db->queryFirstColumn(
+ 'SELECT `text` from general_record where general_id = 0 AND log_type = "history" AND year = %i and month = %i order by id desc',
+ $year,
+ $month
+ );
if(!$texts){
- return ConvertLog("●>{$month}월: 기록 없음");
+ return "●>{$month}월: 기록 없음";
}
- return join('
', $texts);
+ return $texts;
}
function LogHistory($isFirst=0) {
@@ -432,8 +402,8 @@ function LogHistory($isFirst=0) {
$map_json = Json::encode($map);
- $log = getWorldHistoryWithDate($year, $month);
- $genlog = getGeneralPublicRecordWithDate($year, $month);
+ $log = Json::encode(getWorldHistoryWithDate($year, $month));
+ $genlog = Json::encode(getGeneralPublicRecordWithDate($year, $month));
$nationStr = "";
$powerStr = "";
diff --git a/hwe/index.php b/hwe/index.php
index 1d40b230..fd3c85c0 100644
--- a/hwe/index.php
+++ b/hwe/index.php
@@ -318,11 +318,11 @@ else if($session->userGrade == 4){
개인 기록 |
- | =getGeneralPublicRecordRecent(15)?> |
- =getGenLogRecent($me['no'], 15)?> |
+ =formatHistoryToHTML(getGeneralPublicRecordRecent(15))?> |
+ =formatHistoryToHTML(getGenLogRecent($me['no'], 15))?> |
| 중원 정세 |
- | =getWorldHistoryRecent(15)?> |
+ | =formatHistoryToHTML(getWorldHistoryRecent(15))?> |