diff --git a/hwe/j_install.php b/hwe/j_install.php index 48a3966a..2c5c66d8 100644 --- a/hwe/j_install.php +++ b/hwe/j_install.php @@ -51,14 +51,17 @@ $reserve_open = Util::getReq('reserve_open'); if($reserve_open){ $reserve_open = new \DateTime($reserve_open); $db = DB::db(); - + ResetHelper::clearDB(); + $scenarioObj = new Scenario($scenario, true); + $db->delete('reserved_open', true); $db->insert('reserved_open', [ 'options'=>Json::encode([ 'turnterm'=>$turnterm, 'sync'=>$sync, 'scenario'=>$scenario, + 'scenarioName'=>$scenarioObj->getTitle(), 'fiction'=>$fiction, 'extend'=>$extend, 'npcmode'=>$npcmode, diff --git a/hwe/j_server_basic_info.php b/hwe/j_server_basic_info.php index 480978bb..a4340280 100644 --- a/hwe/j_server_basic_info.php +++ b/hwe/j_server_basic_info.php @@ -4,15 +4,49 @@ namespace sammo; include "lib.php"; $session = Session::requireLogin([ - 'game'=>'x', + 'game'=>null, 'me'=>null ])->setReadOnly(); $userID = Session::getUserID(); +if(!class_exists('\\sammo\\DB')){ + Json::die([ + 'game'=>null, + 'me'=>null + ]); +} + $db = DB::db(); $game = $db->queryFirstRow('SELECT isUnited, npcMode, year, month, scenario, scenario_text, maxgeneral as maxUserCnt, turnTerm from game where `no`=1'); +if(!$game){ + $reserved = $db->queryFirstRow( + 'SELECT * FROM reserved_open ORDER BY `date` ASC LIMIT 1' + ); + if(!$reserved){ + Json::die([ + 'game'=>null, + 'me'=>null + ]); + } + + $options = Json::decode($reserved['options']); + + Json::die([ + 'reserved'=>[ + 'scenarioName'=>$options['scenarioName'], + 'turnterm'=>$options['turnterm'], + 'fictionMode'=>($options['fiction']?'연의':'가상'), + 'npcMode'=>($options['npcmode']?'가능':'불가'), + 'openDatetime'=>$reserved['date'] + ], + 'game'=>null, + 'me'=>null + ]); + +} + $nationCnt = $db->queryFirstField('SELECT count(`nation`) from nation where `level` > 0'); $genCnt = $db->queryFirstField('SELECT count(`no`) from general where `npc` < 2'); $npcCnt = $db->queryFirstField('SELECT count(`no`) from general where `npc` >= 2'); diff --git a/hwe/sql/schema.sql b/hwe/sql/schema.sql index a0810ca1..0ecc986a 100644 --- a/hwe/sql/schema.sql +++ b/hwe/sql/schema.sql @@ -643,4 +643,16 @@ CREATE TABLE `general_public_record` ( ) DEFAULT CHARSET=utf8mb4 ENGINE=InnoDB -; \ No newline at end of file +; + +###### +# 예약 오픈 테이블 +CREATE TABLE `reserved_open` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `options` TEXT NULL DEFAULT NULL, + `date` DATETIME NULL DEFAULT NULL, + PRIMARY KEY (`id`), + INDEX `date` (`date`) +) +DEFAULT CHARSET=utf8mb4 +ENGINE=MyISAM; diff --git a/i_entrance/j_server_get_status.php b/i_entrance/j_server_get_status.php index 1110f3f2..b78448e9 100644 --- a/i_entrance/j_server_get_status.php +++ b/i_entrance/j_server_get_status.php @@ -12,6 +12,7 @@ foreach(AppConf::getList() as $setting){ 'color'=>$setting->getColor(), 'korName'=>$setting->getKorName(), 'name'=>$setting->getShortName(), + 'exists'=>$setting->isExists(), 'enable'=>$setting->isRunning() ]; diff --git a/js/entrance.js b/js/entrance.js index 93b47a18..07f8b800 100644 --- a/js/entrance.js +++ b/js/entrance.js @@ -42,6 +42,14 @@ var serverLoginTemplate = "\ \ "; + +var serverReservedTemplate = "\ +\ +- 오픈 일시 : <%openDatetime%> -
\ +<%scenarioName%> <%turnterm%>분 턴 서버
\ +(연의 모드:<%fictionMode%>), (빙의 여부:<%npcMode%>)\ +"; + $(function(){ $("#btn_logout").click(Entrance_Logout); Entrance_UpdateServer(); @@ -64,7 +72,7 @@ function Entrance_drawServerList(serverInfos){ $.each(serverInfos, function(idx, serverInfo){ var $serverHtml = $(TemplateEngine(serverListTemplate, serverInfo)); $serverList.append($serverHtml); - if(!serverInfo.enable){ + if(!serverInfo.exists){ return true; } @@ -72,6 +80,14 @@ function Entrance_drawServerList(serverInfos){ $.getJSON("../"+serverInfo.name+'/j_server_basic_info.php',{}, function(result){ + if(result.reserved){ + $serverHtml.find('.server_down').detach(); + $serverHtml.append( + TemplateEngine(serverReservedTemplate, result.reserved) + ); + return; + } + if(!result.game){ return; } diff --git a/src/run_daemon.py b/src/run_daemon.py index 9e00ebf3..78d0268f 100644 --- a/src/run_daemon.py +++ b/src/run_daemon.py @@ -27,17 +27,28 @@ def main(): break servList = [] + autoResetList = [] for path in glob.glob(basepath+'/*/d_setting/DB.php'): servPath = os.path.dirname(os.path.dirname(path)) + servRelPath = os.path.relpath(servPath, basepath) + + resetAbsPath = servPath + '/j_autoreset.php' + resetPath = webBase + '/' + servRelPath + '/j_autoreset.php' + if os.path.exists(resetAbsPath): + autoResetList.append(resetPath) + if servPath in hiddenList: continue - servRelPath = os.path.relpath(servPath, basepath) webPath = webBase + '/' + servRelPath + '/proc.php' + servList.append(webPath) with concurrent.futures.ThreadPoolExecutor(max_workers=len(servList)) as executor: waiters=[] + for resetPath in autoResetList: + future = executor.submit(run, resetPath) + waiters.append(future) for _ in range(4): for webPath in servList: future = executor.submit(run, webPath) diff --git a/src/sammo/templates/block_htaccess.php b/src/sammo/templates/block_htaccess.php index d3c18fb2..174f1338 100644 --- a/src/sammo/templates/block_htaccess.php +++ b/src/sammo/templates/block_htaccess.php @@ -7,4 +7,17 @@ Deny from all SetEnvIf X-Forwarded-For ^ env_allow_1 Allow from env=env_allow_1 Allow from - \ No newline at end of file + + + + Allow from all + + + Allow from all + + + Allow from all + + + Allow from all + \ No newline at end of file