GeneralPublicRecord 추가
This commit is contained in:
+171
-31
@@ -1,13 +1,142 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
function getHistory($year, $month) {
|
||||
|
||||
|
||||
function pushTrickLog($log) {
|
||||
$size = count($log);
|
||||
if($size > 0) {
|
||||
$fp = fopen("logs/_tricklog.txt", "a");
|
||||
for($i=0; $i < $size; $i++) {
|
||||
fwrite($fp, $log[$i]."\n");
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
function pushProcessLog($log) {
|
||||
$size = count($log);
|
||||
if($size > 0) {
|
||||
$date = date('Y_m_d');
|
||||
$fp = fopen("logs/_{$date}_processlog.txt", "a");
|
||||
for($i=0; $i < $size; $i++) {
|
||||
fwrite($fp, $log[$i]."\n");
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
function delStepLog() {
|
||||
$date = date('Y_m_d');
|
||||
@unlink("logs/_{$date}_steplog.txt");
|
||||
}
|
||||
|
||||
function pushStepLog($log) {
|
||||
$date = date('Y_m_d');
|
||||
$fp = fopen("logs/_{$date}_steplog.txt", "a");
|
||||
fwrite($fp, $log."\n");
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
function pushLockLog($log) {
|
||||
$size = count($log);
|
||||
if($size > 0) {
|
||||
$date = date('Y_m_d');
|
||||
$fp = fopen("logs/_{$date}_locklog.txt", "a");
|
||||
for($i=0; $i < $size; $i++) {
|
||||
fwrite($fp, $log[$i]."\n");
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
function pushAdminLog($log) {
|
||||
$size = count($log);
|
||||
if($size > 0) {
|
||||
$fp = fopen("logs/_adminlog.txt", "a");
|
||||
for($i=0; $i < $size; $i++) {
|
||||
fwrite($fp, $log[$i]."\n");
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
function pushAuctionLog($log) {
|
||||
$size = count($log);
|
||||
if($size > 0) {
|
||||
$fp = fopen("logs/_auctionlog.txt", "a");
|
||||
for($i=0; $i < $size; $i++) {
|
||||
fwrite($fp, $log[$i]."\n");
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
function pushGenLog($general, $log) {
|
||||
$size = count($log);
|
||||
if($size > 0) {
|
||||
$fp = fopen("logs/gen{$general['no']}.txt", "a");
|
||||
for($i=0; $i < $size; $i++) {
|
||||
fwrite($fp, $log[$i]."\n");
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
function pushBatRes($general, $log) {
|
||||
$size = count($log);
|
||||
if($size > 0) {
|
||||
$fp = fopen("logs/batres{$general['no']}.txt", "a");
|
||||
for($i=0; $i < $size; $i++) {
|
||||
fwrite($fp, $log[$i]."\n");
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
function pushBatLog($general, $log) {
|
||||
$size = count($log);
|
||||
if($size > 0) {
|
||||
$fp = fopen("logs/batlog{$general['no']}.txt", "a");
|
||||
for($i=0; $i < $size; $i++) {
|
||||
fwrite($fp, $log[$i]."\n");
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function pushWorldHistory(array $history, $year=null, $month=null) {
|
||||
$db = DB::db();
|
||||
if($year === null || $month === null){
|
||||
$game = $db->queryFirstRow('SELECT year, month FROM game LIMIT 1');
|
||||
$year = $game['year'];
|
||||
$month = $game['month'];
|
||||
}
|
||||
$request = array_map(function($text) use ($year, $month) {
|
||||
return ['year'=>$year, 'month'=>$month, 'text'=>$text];
|
||||
}, array_values($history));
|
||||
$db->insert('world_history', $request);
|
||||
}
|
||||
|
||||
function getWorldHistoryRecent(int $count) {
|
||||
$db = DB::db();
|
||||
|
||||
$texts = [];
|
||||
foreach($db->queryFirstColumn('SELECT `text` from world_history order by id desc limit %i', $count) as $text){
|
||||
$texts[] = ConvertLog($text);
|
||||
}
|
||||
return join('<br>', $texts);
|
||||
}
|
||||
|
||||
function getWorldHistoryWithDate($year, $month) {
|
||||
$db = DB::db();
|
||||
|
||||
$texts = [];
|
||||
foreach(
|
||||
$db->queryFirstColumn(
|
||||
'SELECT `text` from full_history where year = %i and month = %i order by id desc',
|
||||
'SELECT `text` from world_history where year = %i and month = %i order by id desc',
|
||||
$year,
|
||||
$month
|
||||
) as $text
|
||||
@@ -22,36 +151,47 @@ function getHistory($year, $month) {
|
||||
return join('<br>', $texts);
|
||||
}
|
||||
|
||||
function getGenHistory($count, $year, $month, $isFirst=0) {
|
||||
$fp = @fopen("logs/_alllog.txt", "r");
|
||||
@fseek($fp, -$count*300, SEEK_END);
|
||||
$file = @fread($fp, $count*300);
|
||||
@fclose($fp);
|
||||
$log = explode("\n",$file);
|
||||
|
||||
$str = "";
|
||||
$prefix = "</>{$month}월:";
|
||||
$year -= 1;
|
||||
$prefixYear = "</>{$month}월:<C>{$year}</>";
|
||||
for($i=0; $i < $count; $i++) {
|
||||
$line = $log[count($log)-2-$i];
|
||||
if($line == "") {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(strpos($line, $prefixYear)) {
|
||||
break;
|
||||
} elseif(strpos($line, $prefix) || $isFirst == 1) {
|
||||
$str = ConvertLog($line).'<br>'.$str;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
function pushGeneralPublicRecord(array $history, $year=null, $month=null) {
|
||||
$db = DB::db();
|
||||
if($year === null || $month === null){
|
||||
$game = $db->queryFirstRow('SELECT year, month FROM game LIMIT 1');
|
||||
$year = $game['year'];
|
||||
$month = $game['month'];
|
||||
}
|
||||
if($str == "") {
|
||||
$str = "<C>●</>{$month}월: 기록 없음";
|
||||
$str = ConvertLog($str);
|
||||
$request = array_map(function($text) use ($year, $month) {
|
||||
return ['year'=>$year, 'month'=>$month, 'text'=>$text];
|
||||
}, array_values($history));
|
||||
$db->insert('general_public_record', $request);
|
||||
}
|
||||
|
||||
function getGeneralPublicRecordRecent($count) {
|
||||
$db = DB::db();
|
||||
|
||||
$texts = [];
|
||||
foreach($db->queryFirstColumn('SELECT `text` from general_public_record order by id desc limit %i', $count) as $text){
|
||||
$texts[] = ConvertLog($text);
|
||||
}
|
||||
return join('<br>', $texts);
|
||||
}
|
||||
|
||||
function getGeneralPublicRecordWithDate($count, $year, $month, $isFirst=0) {
|
||||
$db = DB::db();
|
||||
|
||||
$texts = [];
|
||||
foreach(
|
||||
$db->queryFirstColumn(
|
||||
'SELECT `text` from general_public_record where year = %i and month = %i order by id desc',
|
||||
$year,
|
||||
$month
|
||||
) as $text
|
||||
){
|
||||
$texts[] = ConvertLog($text);
|
||||
}
|
||||
|
||||
if(!$texts){
|
||||
return ConvertLog("<C>●</>{$month}월: 기록 없음");
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
function LogHistory($isFirst=0) {
|
||||
@@ -87,8 +227,8 @@ function LogHistory($isFirst=0) {
|
||||
|
||||
$map_json = json_encode($map, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
$log = getHistory($year, $month);
|
||||
$genlog = getGenHistory(50, $year, $month, $isFirst);
|
||||
$log = getWorldHistoryWithDate($year, $month);
|
||||
$genlog = getGeneralPublicRecordWithDate(50, $year, $month, $isFirst);
|
||||
|
||||
$nationStr = "";
|
||||
$powerStr = "";
|
||||
|
||||
Reference in New Issue
Block a user