서버 리셋에서 디렉토리 초기화 추가
- 서버 선택 창 일부 변경
This commit is contained in:
+2
-2
@@ -11,7 +11,7 @@ var serverListTemplate = "\
|
|||||||
var serverTextInfo = "\
|
var serverTextInfo = "\
|
||||||
<td>\
|
<td>\
|
||||||
서기 <%year%>년 <%month%>월 (<span style='color:orange;'><%scenario%></span>)<br>\
|
서기 <%year%>년 <%month%>월 (<span style='color:orange;'><%scenario%></span>)<br>\
|
||||||
유저 : <%userCnt%> / <%maxUserCnt%>명 <span style='color:cyan;'>NPC : <%npcCnt%>명</span> (<span style='color:limegreen;'><%turnTerm%></span>)\
|
유저 : <%userCnt%> / <%maxUserCnt%>명 <span style='color:cyan;'>NPC : <%npcCnt%>명</span> (<span style='color:limegreen;'><%turnTerm%>분 턴 서버</span>)\
|
||||||
</td>\
|
</td>\
|
||||||
";
|
";
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ function Entrance_drawServerList(serverInfos){
|
|||||||
TemplateEngine(serverTextInfo, game)
|
TemplateEngine(serverTextInfo, game)
|
||||||
);
|
);
|
||||||
|
|
||||||
if(result.me && result.me.length > 1){
|
if(result.me && result.me.name){
|
||||||
var me = result.me;
|
var me = result.me;
|
||||||
me.serverPath = serverPath;
|
me.serverPath = serverPath;
|
||||||
$serverHtml.append(
|
$serverHtml.append(
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
function getTurn($connect, $general, $type, $font=1) {
|
function getTurn($connect, $general, $type, $font=1) {
|
||||||
$turn[0] = $general["turn0"];
|
$turn[0] = $general["turn0"];
|
||||||
|
|||||||
@@ -55,6 +55,40 @@ if(120 % $turnterm != 0){
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!file_exists(__dir__.'/logs') || !file_exists(__dir__.'/data')){
|
||||||
|
if(!is_writable(__dir__)){
|
||||||
|
Json::die([
|
||||||
|
'result'=>false,
|
||||||
|
'reason'=>'logs, data 디렉토리를 생성할 권한이 없습니다.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
mkdir(__dir__.'/logs', 0644);
|
||||||
|
mkdir(__dir__.'/data', 0644);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!is_writable(__dir__.'/logs')){
|
||||||
|
Json::die([
|
||||||
|
'result'=>false,
|
||||||
|
'reason'=>'logs 디렉토리의 쓰기 권한이 없습니다'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!is_writable(__dir__.'/data')){
|
||||||
|
Json::die([
|
||||||
|
'result'=>false,
|
||||||
|
'reason'=>'data 디렉토리의 쓰기 권한이 없습니다'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!file_exists(ROOT.'/logs/.htaccess')){
|
||||||
|
@file_put_contents(ROOT.'/logs/.htaccess', 'Deny from all');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!file_exists(ROOT.'/data/.htaccess')){
|
||||||
|
@file_put_contents(ROOT.'/data/.htaccess', 'Deny from all');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$mysqli_obj = $db->get();
|
$mysqli_obj = $db->get();
|
||||||
|
|
||||||
@@ -62,6 +96,9 @@ $mysqli_obj = $db->get();
|
|||||||
$scenarioObj = new Scenario($scenario, false);
|
$scenarioObj = new Scenario($scenario, false);
|
||||||
$startyear = $scenarioObj->getYear();
|
$startyear = $scenarioObj->getYear();
|
||||||
|
|
||||||
|
FileUtil::delInDir("logs");
|
||||||
|
FileUtil::delInDir("data");
|
||||||
|
|
||||||
if($mysqli_obj->multi_query(file_get_contents(__dir__.'/sql/reset.sql'))){
|
if($mysqli_obj->multi_query(file_get_contents(__dir__.'/sql/reset.sql'))){
|
||||||
while(true){
|
while(true){
|
||||||
if (!$mysqli_obj->more_results()) {
|
if (!$mysqli_obj->more_results()) {
|
||||||
|
|||||||
@@ -4,65 +4,29 @@ namespace sammo;
|
|||||||
include "lib.php";
|
include "lib.php";
|
||||||
include "func.php";
|
include "func.php";
|
||||||
|
|
||||||
if(!Session::getUserID()){
|
$session = Session::Instance()->setReadOnly();
|
||||||
|
if(!$session->userID){
|
||||||
Json::die([
|
Json::die([
|
||||||
'game'=>'x',
|
'game'=>'x',
|
||||||
'me'=>'no'
|
'me'=>'no'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME:Name이 없는 동명의 함수가 있음
|
|
||||||
function getScenarioName($scenario) {
|
|
||||||
switch($scenario) {
|
|
||||||
case 0: $str = "공백지모드"; break;
|
|
||||||
case 1: $str = "역사모드1 : 184년 황건적의 난"; break;
|
|
||||||
case 2: $str = "역사모드2 : 190년 반동탁연합"; break;
|
|
||||||
case 3: $str = "역사모드3 : 194년 군웅할거"; break;
|
|
||||||
case 4: $str = "역사모드4 : 196년 황제는 허도로"; break;
|
|
||||||
case 5: $str = "역사모드5 : 200년 관도대전"; break;
|
|
||||||
case 6: $str = "역사모드6 : 202년 원가의 분열"; break;
|
|
||||||
case 7: $str = "역사모드7 : 207년 적벽대전"; break;
|
|
||||||
case 8: $str = "역사모드8 : 213년 익주 공방전"; break;
|
|
||||||
case 9: $str = "역사모드9 : 219년 삼국정립"; break;
|
|
||||||
case 10: $str = "역사모드10 : 225년 칠종칠금"; break;
|
|
||||||
case 11: $str = "역사모드11 : 228년 출사표"; break;
|
|
||||||
|
|
||||||
case 12: $str = "IF모드1 : 191년 백마장군의 위세"; break;
|
|
||||||
|
|
||||||
case 20: $str = "가상모드1 : 180년 영웅 난무"; break;
|
|
||||||
case 21: $str = "가상모드1 : 180년 영웅 집결"; break;
|
|
||||||
case 22: $str = "가상모드2 : 179년 훼신 집결"; break;
|
|
||||||
case 23: $str = "가상모드3 : 180년 영웅 시대"; break;
|
|
||||||
case 24: $str = "가상모드4 : 180년 결사항전"; break;
|
|
||||||
case 25: $str = "가상모드5 : 180년 영웅독존"; break;
|
|
||||||
case 26: $str = "가상모드6 : 180년 무풍지대"; break;
|
|
||||||
case 27: $str = "가상모드7 : 180년 가요대잔치"; break;
|
|
||||||
case 28: $str = "가상모드8 : 180년 확산성 밀리언 아서"; break;
|
|
||||||
default: $str = "시나리오?"; break;
|
|
||||||
}
|
|
||||||
return $str;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getTurnTerm($term) {
|
|
||||||
return "{$term}분 턴 서버";
|
|
||||||
}
|
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$game = $db->queryFirstRow('SELECT isUnited, npcMode, year, month, scenario, maxgeneral as maxUserCnt, turnTerm from game where `no`=1');
|
$game = $db->queryFirstRow('SELECT isUnited, npcMode, year, month, scenario, scenario_text, maxgeneral as maxUserCnt, turnTerm from game where `no`=1');
|
||||||
|
|
||||||
$nationCnt = $db->queryFirstField('SELECT count(`nation`) from nation where `level` > 0');
|
$nationCnt = $db->queryFirstField('SELECT count(`nation`) from nation where `level` > 0');
|
||||||
$genCnt = $db->queryFirstField('SELECT count(`no`) from general where `npc` < 2');
|
$genCnt = $db->queryFirstField('SELECT count(`no`) from general where `npc` < 2');
|
||||||
$npcCnt = $db->queryFirstField('SELECT count(`no`) from general where `npc` >= 2');
|
$npcCnt = $db->queryFirstField('SELECT count(`no`) from general where `npc` >= 2');
|
||||||
|
|
||||||
$game['turnTerm'] = getTurnTerm($game['turnTerm']);
|
$game['scenario'] = $game['scenario_text'];
|
||||||
$game['scenario'] = getScenarioName($game['scenario']);
|
|
||||||
$game['userCnt'] = $genCnt;
|
$game['userCnt'] = $genCnt;
|
||||||
$game['npcCnt'] = $npcCnt;
|
$game['npcCnt'] = $npcCnt;
|
||||||
$game['nationCnt'] = $nationCnt;
|
$game['nationCnt'] = $nationCnt;
|
||||||
|
|
||||||
$generalID = getGeneralID(false, false);
|
$generalID = getGeneralID(false, false);
|
||||||
$userGrade = Session::getUserGrade();
|
$userGrade = $session->userGrade;
|
||||||
$me = [
|
$me = [
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -82,5 +46,5 @@ if($generalID){
|
|||||||
//TODO: 이를 표현하는 방법은 '이전 버전'의 serverListPost.php를 참고할 것.
|
//TODO: 이를 표현하는 방법은 '이전 버전'의 serverListPost.php를 참고할 것.
|
||||||
Json::die([
|
Json::die([
|
||||||
'game'=>$game,
|
'game'=>$game,
|
||||||
'me'=>$me?$me:null
|
'me'=>$me?:null
|
||||||
]);
|
]);
|
||||||
Reference in New Issue
Block a user