From 1ddd26c8a1f842b9df745606bd2d06fdd804d9fa Mon Sep 17 00:00:00 2001 From: hide_d Date: Sun, 1 Apr 2018 01:20:35 +0900 Subject: [PATCH] =?UTF-8?q?NPC=20=EC=83=9D=EC=84=B1=EC=8B=9C=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=EC=88=98=EC=A0=95=20=EC=84=9C=EB=B2=84=20=EB=A6=AC?= =?UTF-8?q?=EC=85=8B=EB=90=98=EC=97=88=EC=9D=84=20=EB=95=8C=20=EC=84=B8?= =?UTF-8?q?=EC=85=98=20=EA=B0=92=20=EC=95=88=EC=A0=95=EC=9D=84=20=EC=9C=84?= =?UTF-8?q?=ED=95=B4=20serverID=20=EA=B0=9C=EB=85=90=EC=9D=84=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sammo/Session.php | 35 ++++++++++++++++-------------- twe/d_setting/UniqueConst.orig.php | 9 ++++++++ twe/func.php | 1 + twe/j_install.php | 22 +++++++++++++++---- twe/j_install_db.php | 6 +++++ twe/j_server_basic_info.php | 21 +++++++----------- twe/logs/.htaccess | 1 + twe/sammo/Scenario/NPC.php | 1 + twe/sql/schema.sql | 2 +- 9 files changed, 64 insertions(+), 34 deletions(-) create mode 100644 twe/d_setting/UniqueConst.orig.php create mode 100644 twe/logs/.htaccess diff --git a/src/sammo/Session.php b/src/sammo/Session.php index 95b854b0..61bc6654 100644 --- a/src/sammo/Session.php +++ b/src/sammo/Session.php @@ -145,7 +145,10 @@ class Session { if($this->writeClosed){ $this->restart(); } - $this->logoutGame(); + if(class_exists('\\sammo\\UniqueConst')){ + $this->logoutGame(); + } + $this->set('userID', null); $this->set('userName', null); $this->set('userGrade', null); @@ -162,20 +165,20 @@ class Session { return $this; } - if(!class_exists('\\sammo\\DB')){ + if(!class_exists('\\sammo\\DB') || !class_exists('\\sammo\\UniqueConst')){ if($result !== null){ $result = false; } return $this; } - $prefix = DB::prefix(); + $serverID = UniqueConst::$serverID; $db = DB::db(); - $loginDate = $this->get($prefix.static::GAME_KEY_DATE); - $generalID = $this->get($prefix.static::GAME_KEY_GENERAL_ID); - $generalName = $this->get($prefix.static::GAME_KEY_GENERAL_NAME); - $deadTime = $this->get($prefix.static::GAME_KEY_EXPECTED_DEADTIME); + $loginDate = $this->get($serverID.static::GAME_KEY_DATE); + $generalID = $this->get($serverID.static::GAME_KEY_GENERAL_ID); + $generalName = $this->get($serverID.static::GAME_KEY_GENERAL_NAME); + $deadTime = $this->get($serverID.static::GAME_KEY_EXPECTED_DEADTIME); $now = time(); if( @@ -220,21 +223,21 @@ class Session { } - $this->set($prefix.static::GAME_KEY_DATE, $now); - $this->set($prefix.static::GAME_KEY_GENERAL_ID, $generalID); - $this->set($prefix.static::GAME_KEY_GENERAL_NAME, $generalName); - $this->set($prefix.static::GAME_KEY_EXPECTED_DEADTIME, $deadTime); + $this->set($serverID.static::GAME_KEY_DATE, $now); + $this->set($serverID.static::GAME_KEY_GENERAL_ID, $generalID); + $this->set($preserverIDfix.static::GAME_KEY_GENERAL_NAME, $generalName); + $this->set($serverID.static::GAME_KEY_EXPECTED_DEADTIME, $deadTime); } public function logoutGame(): Session{ if($this->writeClosed){ $this->restart(); } - $prefix = DB::prefix(); - $this->set($prefix.static::GAME_KEY_DATE, null); - $this->set($prefix.static::GAME_KEY_GENERAL_ID, null); - $this->set($prefix.static::GAME_KEY_GENERAL_NAME, null); - $this->set($prefix.static::GAME_KEY_EXPECTED_DEADTIME, null); + $serverID = UniqueConst::$serverID; + $this->set($serverID.static::GAME_KEY_DATE, null); + $this->set($serverID.static::GAME_KEY_GENERAL_ID, null); + $this->set($serverID.static::GAME_KEY_GENERAL_NAME, null); + $this->set($serverID.static::GAME_KEY_EXPECTED_DEADTIME, null); return $this; } diff --git a/twe/d_setting/UniqueConst.orig.php b/twe/d_setting/UniqueConst.orig.php new file mode 100644 index 00000000..d4891c3a --- /dev/null +++ b/twe/d_setting/UniqueConst.orig.php @@ -0,0 +1,9 @@ +query('UPDATE game set refresh=refresh+%i where `no`=1', $cnt); diff --git a/twe/j_install.php b/twe/j_install.php index ec18dd31..331964b1 100644 --- a/twe/j_install.php +++ b/twe/j_install.php @@ -80,12 +80,19 @@ if(!is_writable(__dir__.'/data')){ ]); } -if(!file_exists(ROOT.'/logs/.htaccess')){ - @file_put_contents(ROOT.'/logs/.htaccess', 'Deny from all'); +if(!is_writable(__dir__.'/d_setting')){ + Json::die([ + 'result'=>false, + 'reason'=>'d_setting 디렉토리의 쓰기 권한이 없습니다' + ]); } -if(!file_exists(ROOT.'/data/.htaccess')){ - @file_put_contents(ROOT.'/data/.htaccess', 'Deny from all'); +if(!file_exists(__dir__.'/logs/.htaccess')){ + @file_put_contents(__dir__.'/logs/.htaccess', 'Deny from all'); +} + +if(!file_exists(__dir__.'/data/.htaccess')){ + @file_put_contents(__dir__.'/data/.htaccess', 'Deny from all'); } @@ -99,6 +106,13 @@ $startyear = $scenarioObj->getYear(); FileUtil::delInDir("logs"); FileUtil::delInDir("data"); +$result = Util::generateFileUsingSimpleTemplate( + __DIR__.'/d_setting/UniqueConst.orig.php', + __DIR__.'/d_setting/UniqueConst.php',[ + 'serverID'=>DB::prefix().'_'.Util::randomStr(8) + ], true +); + if($mysqli_obj->multi_query(file_get_contents(__dir__.'/sql/reset.sql'))){ while(true){ if (!$mysqli_obj->more_results()) { diff --git a/twe/j_install_db.php b/twe/j_install_db.php index 837a9eab..0594f99d 100644 --- a/twe/j_install_db.php +++ b/twe/j_install_db.php @@ -43,6 +43,12 @@ if($fullReset && class_exists('\\sammo\\DB')){ if($fullReset){ FileUtil::delInDir(__dir__."/logs"); FileUtil::delInDir(__dir__."/data"); + if(file_exists(__dir__.'/d_setting/DB.php')){ + @unlink(__dir__.'/d_setting/DB.php'); + } + if(file_exists(__dir__.'/d_setting/UniqueConst.php')){ + @unlink(__dir__.'/d_setting/UniqueConst.php'); + } } function dbConnFail($params){ diff --git a/twe/j_server_basic_info.php b/twe/j_server_basic_info.php index 741812fa..4ff1fcf3 100644 --- a/twe/j_server_basic_info.php +++ b/twe/j_server_basic_info.php @@ -25,21 +25,16 @@ $game['userCnt'] = $genCnt; $game['npcCnt'] = $npcCnt; $game['nationCnt'] = $nationCnt; -$generalID = getGeneralID(false, false); -$userGrade = $session->userGrade; -$me = [ -]; +$me = []; -if($generalID){ - $general = $db->queryFirstRow('SELECT name, picture, imgsvr from general where no=%i', $generalID); - if($general){ - $me['name'] = $general['name']; +$general = $db->queryFirstRow('SELECT name, picture, imgsvr from general where owner=%i', $session->userID); +if($general){ + $me['name'] = $general['name']; - if($general['imgsvr'] == 0) { - $me['picture'] = '../../image/'.$general['picture']; - } else { - $me['picture'] = '../d_pic/'.$general['picture']; - } + if($general['imgsvr'] == 0) { + $me['picture'] = '../../image/'.$general['picture']; + } else { + $me['picture'] = '../d_pic/'.$general['picture']; } } diff --git a/twe/logs/.htaccess b/twe/logs/.htaccess new file mode 100644 index 00000000..698196ae --- /dev/null +++ b/twe/logs/.htaccess @@ -0,0 +1 @@ +Deny from all \ No newline at end of file diff --git a/twe/sammo/Scenario/NPC.php b/twe/sammo/Scenario/NPC.php index 12836837..be694073 100644 --- a/twe/sammo/Scenario/NPC.php +++ b/twe/sammo/Scenario/NPC.php @@ -73,6 +73,7 @@ class NPC{ $year = $env['year']; $month = $env['month']; $age = $year - $this->birth; + $name = $this->name; if($this->death < $year){ return true; //죽었으니 넘어간다. diff --git a/twe/sql/schema.sql b/twe/sql/schema.sql index b318843c..4220d291 100644 --- a/twe/sql/schema.sql +++ b/twe/sql/schema.sql @@ -4,7 +4,7 @@ CREATE TABLE `general` ( `no` INT(11) NOT NULL AUTO_INCREMENT, - `owner` INT(11) NOT NULL DEFAULT '-1', + `owner` INT(11) NOT NULL DEFAULT '0', `conmsg` CHAR(255) NOT NULL DEFAULT '', `npcmsg` CHAR(255) NULL DEFAULT '', `npcid` INT(5) NULL DEFAULT NULL,