게임 오픈 시 logs에 서브 디렉토리를 사용하도록 변경

This commit is contained in:
2018-06-25 01:45:23 +09:00
parent 3d9f38f1e3
commit 0e95259b14
7 changed files with 60 additions and 27 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
"**/.hg": true, "**/.hg": true,
"**/CVS": true, "**/CVS": true,
"**/.DS_Store": true, "**/.DS_Store": true,
"**/logs/*.txt": true, "**/logs/**/*.txt": true,
"**/session/sess*":true, "**/session/sess*":true,
"/che":true, "/che":true,
"/kwe":true, "/kwe":true,
+1 -1
View File
@@ -12,7 +12,7 @@ increaseRefresh("갱신정보", 2);
$admin = $gameStor->getValues(['year','month','refresh','maxrefresh','maxonline']); $admin = $gameStor->getValues(['year','month','refresh','maxrefresh','maxonline']);
$log = getRawFileLogRecent(__dir__.'/logs/_traffic.txt', 11, 100); $log = getRawFileLogRecent(__dir__.'/logs/'.UniqueConst::$serverID.'/_traffic.txt', 11, 100);
$date = []; $date = [];
$year = []; $year = [];
+3 -3
View File
@@ -1266,7 +1266,7 @@ function increaseRefresh($type="", $cnt=1) {
$date2 = substr($date, 0, 10); $date2 = substr($date, 0, 10);
$online = getOnlineNum(); $online = getOnlineNum();
file_put_contents( file_put_contents(
__dir__."/logs/_{$date2}_refresh.txt", __dir__."/logs/".UniqueConst::$serverID."/_{$date2}_refresh.txt",
sprintf( sprintf(
"%s, %s, %s, %s, %s, %d\n", "%s, %s, %s, %s, %s, %d\n",
$date, $date,
@@ -1303,7 +1303,7 @@ function increaseRefresh($type="", $cnt=1) {
} }
if($str != "") { if($str != "") {
file_put_contents( file_put_contents(
__dir__."/logs/_{$date2}_ipcheck.txt", __dir__."/logs/".UniqueConst::$serverID."/_{$date2}_ipcheck.txt",
sprintf( sprintf(
"%s, %s, %s%s\n", "%s, %s, %s%s\n",
$session->userName, $session->userName,
@@ -1338,7 +1338,7 @@ function updateTraffic() {
$date = date('Y-m-d H:i:s'); $date = date('Y-m-d H:i:s');
//일시|년|월|총갱신|접속자|최다갱신자 //일시|년|월|총갱신|접속자|최다갱신자
file_put_contents(__dir__."/logs/_traffic.txt", file_put_contents(__dir__."/logs/".UniqueConst::$serverID."/_traffic.txt",
Json::encode([ Json::encode([
$date, $date,
$admin['year'], $admin['year'],
+18 -18
View File
@@ -5,7 +5,7 @@ namespace sammo;
function delStepLog() { function delStepLog() {
$date = date('Y_m_d'); $date = date('Y_m_d');
@unlink(__dir__."/logs/_{$date}_steplog.txt"); @unlink(__dir__."/logs/".UniqueConst::$serverID."/_{$date}_steplog.txt");
} }
function pushRawFileLog($path, $lines){ function pushRawFileLog($path, $lines){
@@ -50,81 +50,81 @@ function eraseTnmtFightLogAll(){
} }
function eraseTnmtFightLog(int $group){ function eraseTnmtFightLog(int $group){
$filepath = __dir__."/logs/fight{$group}.txt"; $filepath = __dir__."/logs/".UniqueConst::$serverID."/fight{$group}.txt";
if(file_exists($filepath)){ if(file_exists($filepath)){
@unlink($filepath); @unlink($filepath);
} }
} }
function pushTnmtFightLog(int $group, $log) { function pushTnmtFightLog(int $group, $log) {
pushRawFileLog(__dir__."/logs/fight{$group}.txt", $log); pushRawFileLog(__dir__."/logs/".UniqueConst::$serverID."/fight{$group}.txt", $log);
} }
function getTnmtFightLogAll(int $group) { function getTnmtFightLogAll(int $group) {
return join('<br>',getFormattedFileLogAll(__dir__."/logs/fight{$group}.txt")); return join('<br>',getFormattedFileLogAll(__dir__."/logs/".UniqueConst::$serverID."/fight{$group}.txt"));
} }
function pushSabotageLog($log) { function pushSabotageLog($log) {
pushRawFileLog(__dir__."/logs/_sabotagelog.txt", $log); pushRawFileLog(__dir__."/logs/".UniqueConst::$serverID."/_sabotagelog.txt", $log);
} }
function getSabotageLogRecent($count) { function getSabotageLogRecent($count) {
return join('<br>', getFormattedFileLogRecent(__dir__."/logs/_sabotagelog.txt", $count, 150)); return join('<br>', getFormattedFileLogRecent(__dir__."/logs/".UniqueConst::$serverID."/_sabotagelog.txt", $count, 150));
} }
function pushProcessLog($log) { function pushProcessLog($log) {
$date = date('Y_m_d'); $date = date('Y_m_d');
pushRawFileLog(__dir__."/logs/_{$date}_processlog.txt", $log); pushRawFileLog(__dir__."/logs/".UniqueConst::$serverID."/_{$date}_processlog.txt", $log);
} }
function pushStepLog($log) { function pushStepLog($log) {
$date = date('Y_m_d'); $date = date('Y_m_d');
pushRawFileLog(__dir__."/logs/_{$date}_steplog.txt", $log); pushRawFileLog(__dir__."/logs/".UniqueConst::$serverID."/_{$date}_steplog.txt", $log);
} }
function pushLockLog($log) { function pushLockLog($log) {
$date = date('Y_m_d'); $date = date('Y_m_d');
pushRawFileLog(__dir__."/logs/_{$date}_locklog.txt", $log); pushRawFileLog(__dir__."/logs/".UniqueConst::$serverID."/_{$date}_locklog.txt", $log);
} }
function pushAdminLog($log) { function pushAdminLog($log) {
pushRawFileLog(__dir__."/logs/_adminlog.txt", $log); pushRawFileLog(__dir__."/logs/".UniqueConst::$serverID."/_adminlog.txt", $log);
} }
function pushAuctionLog($log) { function pushAuctionLog($log) {
pushRawFileLog(__dir__."/logs/_auctionlog.txt", $log); pushRawFileLog(__dir__."/logs/".UniqueConst::$serverID."/_auctionlog.txt", $log);
} }
function getAuctionLogRecent(int $count) { function getAuctionLogRecent(int $count) {
return join('<br>', array_reverse(getFormattedFileLogRecent(__dir__."/logs/_auctionlog.txt", $count, 300))); return join('<br>', array_reverse(getFormattedFileLogRecent(__dir__."/logs/".UniqueConst::$serverID."/_auctionlog.txt", $count, 300)));
} }
function pushGenLog($general, $log) { function pushGenLog($general, $log) {
$no = Util::toInt($general['no']); $no = Util::toInt($general['no']);
pushRawFileLog(__dir__."/logs/gen{$no}.txt", $log); pushRawFileLog(__dir__."/logs/".UniqueConst::$serverID."/gen{$no}.txt", $log);
} }
function getGenLogRecent(int $no, int $count) { function getGenLogRecent(int $no, int $count) {
return join('<br>', array_reverse(getFormattedFileLogRecent(__dir__."/logs/gen{$no}.txt", $count, 300))); return join('<br>', array_reverse(getFormattedFileLogRecent(__dir__."/logs/".UniqueConst::$serverID."/gen{$no}.txt", $count, 300)));
} }
function pushBatRes($general, $log) { function pushBatRes($general, $log) {
$no = Util::toInt($general['no']); $no = Util::toInt($general['no']);
pushRawFileLog(__dir__."/logs/batres{$no}.txt", $log); pushRawFileLog(__dir__."/logs/".UniqueConst::$serverID."/batres{$no}.txt", $log);
} }
function getBatResRecent(int $no, int $count) { function getBatResRecent(int $no, int $count) {
return join('<br>', array_reverse(getFormattedFileLogRecent(__dir__."/logs/batres{$no}.txt", $count, 300))); return join('<br>', array_reverse(getFormattedFileLogRecent(__dir__."/logs/".UniqueConst::$serverID."/batres{$no}.txt", $count, 300)));
} }
function pushBatLog($general, $log) { function pushBatLog($general, $log) {
$no = Util::toInt($general['no']); $no = Util::toInt($general['no']);
pushRawFileLog(__dir__."/logs/batlog{$no}.txt", $log); pushRawFileLog(__dir__."/logs/".UniqueConst::$serverID."/batlog{$no}.txt", $log);
} }
function getBatLogRecent(int $no, int $count) { function getBatLogRecent(int $no, int $count) {
return join('<br>', array_reverse(getFormattedFileLogRecent(__dir__."/logs/batlog{$no}.txt", $count, 300))); return join('<br>', array_reverse(getFormattedFileLogRecent(__dir__."/logs/".UniqueConst::$serverID."/batlog{$no}.txt", $count, 300)));
} }
//DB-based //DB-based
+1 -1
View File
@@ -35,7 +35,7 @@ function Error($message='', $url="")
if (!$url) { if (!$url) {
$url = $_SERVER['REQUEST_URI']; $url = $_SERVER['REQUEST_URI'];
} }
file_put_contents(__dir__."/logs/_db_bug.txt", "{\"url\":\"$url\",\"msg\":\"$message\"}\n", FILE_APPEND); file_put_contents(__dir__."/logs/".UniqueConst::$serverID."/_db_bug.txt", "{\"url\":\"$url\",\"msg\":\"$message\"}\n", FILE_APPEND);
$templates = new \League\Plates\Engine(__dir__.'/templates'); $templates = new \League\Plates\Engine(__dir__.'/templates');
+5 -3
View File
@@ -55,13 +55,15 @@ class ResetHelper{
$db = DB::db(); $db = DB::db();
$mysqli_obj = $db->get(); $mysqli_obj = $db->get();
FileUtil::delInDir($servRoot."/logs"); $serverID = DB::prefix().'_'.Util::randomStr(12);
FileUtil::delInDir($servRoot."/data");
mkdir($servRoot.'/logs/'.$serverID, 0644);
mkdir($servRoot.'/data/'.$serverID, 0644);
$result = Util::generateFileUsingSimpleTemplate( $result = Util::generateFileUsingSimpleTemplate(
$servRoot.'/d_setting/UniqueConst.orig.php', $servRoot.'/d_setting/UniqueConst.orig.php',
$servRoot.'/d_setting/UniqueConst.php',[ $servRoot.'/d_setting/UniqueConst.php',[
'serverID'=>DB::prefix().'_'.Util::randomStr(8), 'serverID'=>$serverID,
'serverName'=>AppConf::getList()[$prefix]->getKorName(), 'serverName'=>AppConf::getList()[$prefix]->getKorName(),
], true ], true
); );
+31
View File
@@ -376,9 +376,40 @@ create table if not exists hall (
UNIQUE INDEX `type` (`type`, `rank`) UNIQUE INDEX `type` (`type`, `rank`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4; ) ENGINE=INNODB DEFAULT CHARSET=utf8mb4;
CREATE TABLE if not exists `ng_hall` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`server_id` CHAR(20) NOT NULL,
`scenario` INT(11) NOT NULL,
`general_no` INT(11) NOT NULL,
`type` INT(11) NOT NULL,
`value` INT(11) NOT NULL,
`owner` INT(11) NULL DEFAULT NULL,
`aux` TEXT NOT NULL DEFAULT '{}',
PRIMARY KEY (`id`),
UNIQUE INDEX `server_general` (`server_id`, `type`, `general_no`),
UNIQUE INDEX `owner` (`owner`, `server_id`),
INDEX `server_show` (`server_id`, `type`, `value`),
INDEX `scenario` (`scenario`, `type`, `value`)
)
ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
########################################################################### ###########################################################################
## ##
########################################################################### ###########################################################################
CREATE TABLE if not exists `ng_games` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`server_id` CHAR(20) NOT NULL,
`date` DATETIME NOT NULL,
`united` INT(1) NOT NULL DEFAULT '0',
`aux` TEXT NOT NULL COMMENT 'json',
PRIMARY KEY (`id`),
UNIQUE INDEX `server_id` (`server_id`),
INDEX `date` (`date`)
)
ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
create table if not exists emperior ( create table if not exists emperior (
no int(6) not null auto_increment, no int(6) not null auto_increment,
phase char(255) default '', phase char(255) default '',