Compare commits

..
14 Commits
28 changed files with 155 additions and 67 deletions
+14 -2
View File
@@ -88,19 +88,28 @@ function getExceptionTraceAsString($exception) {
return $rtn;
}
function logError(string $err, string $errstr, array $trace){
function logError(string $err, string $errstr, string $errpath, array $trace){
$fdb = FileDB::db(ROOT.'/d_log/err_log.sqlite3', ROOT.'/f_install/sql/err_log.sql');
$date = date("Ymd_His");
$errpath = str_replace(ROOT, '{ROOT}', $errpath);
$trace = array_map(function(string $text){
return str_replace(ROOT, '{ROOT}', $text);
}, $trace);
$owner = Util::get_client_ip();
$session = Session::getInstance();
if($session->isLoggedIn(true)){
$owner .= '('.$session->getUserID().','.$session->userName.')';
}
$fdb->insert('err_log', [
'date'=>$date,
'err'=>$err,
'errstr'=>$errstr,
'trace'=>Json::encode($trace)
'errpath'=>$errpath,
'trace'=>Json::encode($trace),
'webuser'=>$owner
]);
}
@@ -116,6 +125,7 @@ function logErrorByCustomHandler(int $errno, string $errstr, string $errfile, in
logError(
getFriendlyErrorType($errno),
$errstr,
$errfile.':'.$errline,
getExceptionTraceAsString($e)
);
}
@@ -123,9 +133,11 @@ set_error_handler("\sammo\logErrorByCustomHandler");
function logExceptionByCustomHandler(\Throwable $e){
logError(
get_class($e),
$e->getMessage(),
$e->getFile().':'.$e->getLine(),
getExceptionTraceAsString($e)
);
+3 -1
View File
@@ -3,7 +3,9 @@ CREATE TABLE IF NOT EXISTS `err_log` (
`date` TEXT NOT NULL,
`err` TEXT NOT NULL,
`errstr` TEXT NOT NULL,
`trace` TEXT NOT NULL
`errpath` TEXT NOT NULL,
`trace` TEXT NOT NULL,
`webuser` TEXT NULL
);
CREATE INDEX IF NOT EXISTS `date` ON `err_log` (
`date` DESC
+1 -1
View File
@@ -87,4 +87,4 @@ case "락풀기":
break;
}
header('Location:_119.php');
header('Location:_119.php', true, 303);
+1
View File
@@ -282,6 +282,7 @@ for($j=0; $j < $gencount; $j++) {
$generalsFormat[] = [
'ourGeneral'=>$ourGeneral,
'iconPath'=>GetImageURL($general['imgsvr']).'/'.$general['picture'],
'isNPC'=>$isNPC,
'wounded'=>$wounded,
'name'=>$name,
+2 -2
View File
@@ -23,11 +23,11 @@ $me = $db->queryFirstRow('SELECT `no`,nation,`level`,permission,penalty FROM gen
//내가 수뇌부이어야함
$permission = checkSecretPermission($me);
if($permission < 0){
header('location:b_myBossInfo.php');
header('location:b_myBossInfo.php', true, 303);
exit();
}
else if ($me['level'] < 5 && $permission != 4) {
header('location:b_myBossInfo.php');
header('location:b_myBossInfo.php', true, 303);
exit();
}
+5 -5
View File
@@ -55,7 +55,7 @@ if($command == 46) {
$query['turn'.$turnIdx] = $comStr;
}
$db->update('general', $query, 'owner=%i', $userID);
header('Location:./');
header('Location:./', true, 303);
die();
}
@@ -82,7 +82,7 @@ if($command == 53) {
$query = "update nation set {$str} where nation='{$me['nation']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
}
header('location:b_chiefcenter.php');
header('location:b_chiefcenter.php', true, 303);
die();
}
@@ -102,7 +102,7 @@ if($command == 61) {
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
}
header('location:b_chiefcenter.php');
header('location:b_chiefcenter.php', true, 303);
die();
}
@@ -126,7 +126,7 @@ if($command == 23 || $command == 24 || $command == 27 || $command == 51 || $comm
$query = "update nation set {$str} where nation='{$me['nation']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
}
header('location:b_chiefcenter.php');
header('location:b_chiefcenter.php', true, 303);
die();
}
@@ -136,5 +136,5 @@ foreach($turn as $turnIdx){
$query['turn'.$turnIdx] = $comStr;
}
$db->update('general', $query, 'owner=%i', $userID);
header('Location:./');
header('Location:./', true, 303);
+14 -14
View File
@@ -32,7 +32,7 @@ $ruler = MYDB_fetch_array($result);
//수뇌가 아니면 아무것도 할 수 없음
if($meLevel < 5){
header('location:b_myBossInfo.php');
header('location:b_myBossInfo.php', true, 303);
exit();
}
@@ -45,18 +45,18 @@ if($btn == "임명") {
}
if($genlist != 0 && !$general){
header('location:b_myBossInfo.php');
header('location:b_myBossInfo.php', true, 303);
exit();
}
//임명할사람이 군주이면 불가, 내가 수뇌부이어야함, 공석아닌때는 국가가 같아야함
if($meLevel < 5 || ($genlist != 0 && $general['nation'] != $me['nation']) || ($genlist != 0 && $general['level'] == 12)) {
header('location:b_myBossInfo.php');
header('location:b_myBossInfo.php', true, 303);
exit();
}
} elseif($btn == "추방") {
if(!$outlist){
header('location:b_myBossInfo.php');
header('location:b_myBossInfo.php', true, 303);
exit();
}
$query = "select no,name,gold,rice,nation,troop,level,npc,picture,imgsvr,permission,penalty,belong from general where no='$outlist'";
@@ -64,33 +64,33 @@ if($btn == "임명") {
$general = MYDB_fetch_array($result);
if(!$general){
header('location:b_myBossInfo.php');
header('location:b_myBossInfo.php', true, 303);
exit();
}
//추방할사람이 군주이면 불가, 내가 수뇌부이어야함, 공석아닌때는 국가가 같아야함
if($general['level'] == 12 || $meLevel < 5 || ($general['nation'] != $me['nation'] && $outlist != 0)) {
header('location:b_myBossInfo.php');
header('location:b_myBossInfo.php', true, 303);
exit();
}
//추방할사람이 외교권자이면 불가
$permission = checkSecretPermission($general);
if($permission == 4){
header('location:b_myBossInfo.php');
header('location:b_myBossInfo.php', true, 303);
exit();
}
//NPC 부대장 추방 불가
if($general['npc'] == 5){
header('location:b_myBossInfo.php');
header('location:b_myBossInfo.php', true, 303);
exit();
}
}
//나와 대상 장수는 국가가 같아야 함
if($genlist != 0 && $me['nation'] != $general['nation']){
header('location:b_myBossInfo.php');
header('location:b_myBossInfo.php', true, 303);
exit();
}
@@ -252,7 +252,7 @@ if($btn == "추방") {
pushGenLog($general, $log);
pushGeneralPublicRecord($alllog, $year, $month);
}
header('location:b_myBossInfo.php');
header('location:b_myBossInfo.php', true, 303);
die();
}
@@ -303,7 +303,7 @@ if($btn == "임명" && $level >= 5 && $level <= 11) {
}
}
}
header('location:b_myBossInfo.php');
header('location:b_myBossInfo.php', true, 303);
die();
}
@@ -319,7 +319,7 @@ if($btn == "임명" && $level >= 2 && $level <= 4 && $citylist > 0) {
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$city = MYDB_fetch_array($result);
if(!$city){
header('location:b_myBossInfo.php');
header('location:b_myBossInfo.php', true, 303);
die();
}
$oldlist = $city[$genlv];
@@ -366,11 +366,11 @@ if($btn == "임명" && $level >= 2 && $level <= 4 && $citylist > 0) {
}
}
}
header('location:b_myBossInfo.php');
header('location:b_myBossInfo.php', true, 303);
die();
}
header('location:b_myBossInfo.php');
header('location:b_myBossInfo.php', true, 303);
+1 -1
View File
@@ -63,4 +63,4 @@ if($btn == "부 대 창 설" && $name != "" && $me['troop'] == 0) {
}
}
header('Location:b_troop.php');
header('Location:b_troop.php', true, 303);
+1 -1
View File
@@ -17,5 +17,5 @@ $db->update('general', [
], 'owner=%i', $userID);
header('location:b_myPage.php');
header('location:b_myPage.php', true, 303);
+2 -2
View File
@@ -49,7 +49,7 @@ else if($btn == "댓글" && trim($comment) != "") {
}
if(!$isVoteAdmin){
header('location:a_vote.php');
header('location:a_vote.php', true, 303);
die();
}
@@ -85,4 +85,4 @@ if($btn == "수정") {
$gameStor->voteopen = 2;
}
header('location:a_vote.php');
header('location:a_vote.php', true, 303);
+7 -1
View File
@@ -2250,7 +2250,13 @@ function uniqueItem($general, $log, $vote=0) {
//아이템 습득 상황
if(rand() % $prob == 0) {
//셋중 선택
$sel = rand() % 4;
$selGroup = [
20 - $db->queryFirstField('SELECT count(*) from general where weap > 6'),
20 - $db->queryFirstField('SELECT count(*) from general where book > 6'),
20 - $db->queryFirstField('SELECT count(*) from general where horse > 6'),
20 - $db->queryFirstField('SELECT count(*) from general where item > 6')
];
$sel = Util::choiceRandomUsingWeight($selGroup);
switch($sel) {
case 0: $type = "weap"; break;
case 1: $type = "book"; break;
+3 -3
View File
@@ -707,7 +707,7 @@ where nation='{$general['nation']}'
function command_Single($turn, $command) {
if(!$turn){
header('location:commandlist.php');
header('location:commandlist.php', true, 303);
return;
}
@@ -722,7 +722,7 @@ function command_Single($turn, $command) {
}
$db->update('general', $setValues, 'owner=%i',$userID);
header('location:commandlist.php');
header('location:commandlist.php', true, 303);
}
function command_Chief($turn, $command) {
@@ -745,7 +745,7 @@ function command_Chief($turn, $command) {
$query = "update nation set {$str} where nation='{$me['nation']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
}
header('location:b_chiefcenter.php');
header('location:b_chiefcenter.php', true, 303);
}
function command_Other($turn, $commandtype) {
+1 -1
View File
@@ -1043,7 +1043,7 @@ function updateNationState() {
while($genStep > 0){
$lastAssemblerID += 1;
$npcObj = new Scenario\NPC(
999, '부대장'.$lastAssemblerID, null, $nation['nation'], null,
999, sprintf('부대장%3d',$lastAssemblerID), null, $nation['nation'], null,
10, 10, 10, 1, $admin['year'] - 15, $admin['year'] + 15, '은둔', '척사'
);
$npcObj->npc = 5;
+3 -1
View File
@@ -220,6 +220,8 @@ function processAI($no) {
}
else{
$newKillTurn = ($general['killturn'] + Util::randRangeInt(1, 4)) % 5;
$newKillTurn += 70;
$command = EncodeCommand(0, 0, 0, 26); //집합
$db->update('general', [
'turn0'=>$command,
@@ -228,7 +230,7 @@ function processAI($no) {
'turn3'=>$command,
'turn4'=>$command,
'turn5'=>$command,
'killturn'=>rand(70,75),
'killturn'=>$newKillTurn,
], 'no=%i', $general['no']);
}
+26 -6
View File
@@ -273,8 +273,15 @@ function process_1(&$general, $type) {
$exp = CharExperience($exp, $general['personal']);
$ded = CharDedication($ded, $general['personal']);
if($city['front'] == 1 && $city['city'] != $nation['capital']){
$score *= 0.5;
if($city['front'] == 1){
if($city['city'] == $nation['capital']){
$degrade = 1 - ($admin['year'] - $admin['startyear'] - 5) * 0.025;
$score *= Util::valueFit($degrade, 0.5, 1);
}
else{
$score *= 0.5;
}
}
$score += $city["$stype"];
@@ -571,14 +578,27 @@ function process_5(&$general, $type) {
$exp = $score * 0.7;
$ded = $score * 1.0;
if($city['front'] == 1 && $city['city'] != $nation['capital']){
if($stype == 'def'){
$score *= 0.5;
if($city['front'] == 1){
if($city['city'] == $nation['capital']){
if($stype == 'def'){
$degrade = 1 - ($admin['year'] - $admin['startyear'] - 5) * 0.025;
$score *= Util::valueFit($degrade, 0.5, 1);
}
else{
$degrade = 1 - ($admin['year'] - $admin['startyear'] - 5) * 0.0375;
$score *= Util::valueFit($degrade, 0.25, 1);
}
}
else{
$score *= 0.25;
if($stype == 'def'){
$score *= 0.5;
}
else{
$score *= 0.25;
}
}
}
// 성격 보정
+25 -6
View File
@@ -1968,7 +1968,9 @@ function process_76(&$general) {
$avgNation = MYDB_fetch_array($result);
$gencount = 5 + Util::round($avgNation['gennum'] / 10);
$avgGen = $db->queryFirstRow('SELECT max(leader+power+intel) as lpi, avg(dedication) as ded,avg(experience) as exp, avg(dex0+dex10+dex20+dex30) / 4 as dex_t, avg(age) as age, avg(dex40) as dex40 from general where npc < 5 and nation = %i', $general['nation']);
$avgGen = $db->queryFirstRow('SELECT max(leader+power+intel) as lpi, avg(dedication) as ded,avg(experience) as exp, avg(dex0+dex10+dex20+dex30) as dex_t, avg(age) as age, avg(dex40) as dex40 from general where npc < 5 and nation = %i', $general['nation']);
$dexTotal = $avgGen['dex_t'];
//의병추가
$npc = 4;
@@ -1979,25 +1981,42 @@ function process_76(&$general) {
$stat_tier3 = GameConst::$defaultStatMin + rand()%6;
$stat_tier2 = GameConst::$defaultStatTotal - $stat_tier1 - $stat_tier3;
$type = Util::choiceRandomUsingWeight([
'power'=>5,
'intel'=>5,
'power0'=>1,
'power1'=>1,
'power2'=>1,
'intel'=>3,
'neutral'=>0
]);
switch($type){
case 'power':
case 'power0':
$leader = $stat_tier1;
$power = $stat_tier2;
$intel = $stat_tier3;
$dexVal = [$dexTotal*5/8, $dexTotal/8, $dexTotal/8, $dexTotal/8];
break;
case 'power1':
$leader = $stat_tier1;
$power = $stat_tier2;
$intel = $stat_tier3;
$dexVal = [$dexTotal/8, $dexTotal*5/8, $dexTotal/8, $dexTotal/8];
break;
case 'power2':
$leader = $stat_tier1;
$power = $stat_tier2;
$intel = $stat_tier3;
$dexVal = [$dexTotal/8, $dexTotal/8, $dexTotal*5/8, $dexTotal/8];
break;
case 'intel':
$leader = $stat_tier1;
$power = $stat_tier3;
$intel = $stat_tier2;
$dexVal = [$dexTotal/8, $dexTotal/8, $dexTotal/8, $dexTotal*5/8];
break;
case 'neutral':
default:
$leader = $stat_tier3;
$power = $stat_tier1;
$intel = $stat_tier2;
$dexVal = [$dexTotal/4, $dexTotal/4, $dexTotal/4, $dexTotal/4];
break;
}
// 국내 최고능치 기준으로 랜덤성 스케일링
@@ -2071,7 +2090,7 @@ function process_76(&$general) {
'1','100','100','0','".GameUnitConst::DEFAULT_CREWTYPE."','0','0','0',
'0','0','0','$turntime','$killturn','{$avgGen['age']}','1','$personal','0','0','0','0','',
'0','$bornyear','$deadyear',
'{$avgGen['dex_t']}','{$avgGen['dex_t']}','{$avgGen['dex_t']}','{$avgGen['dex_t']}','{$avgGen['dex40']}'
'{$dexVal[0]}','{$dexVal[1]}','{$dexVal[2]}','{$dexVal[3]}','{$avgGen['dex40']}'
)",
$connect
) or Error(__LINE__.MYDB_error($connect),"");
+26 -7
View File
@@ -389,32 +389,51 @@ function process_29(&$general) {
$alllog[] = "<C>●</>{$admin['month']}월:<Y>{$general['name']}</>{$josaYi} <Y>$name</>{$josaRa}는 <C>인재</>를 {$scoutType}하였습니다!";
pushGeneralHistory($general, "<C>●</>{$admin['year']}{$admin['month']}월:<Y>$name</>{$josaRa}는 <C>인재</>를 {$scoutType}");
$avgGen = $db->queryFirstRow('SELECT max(leader+power+intel) as lpi, avg(dedication) as ded,avg(experience) as exp, avg(dex0+dex10+dex20+dex30) / 4 as dex_t, avg(dex40) as dex40 from general where npc < 5 and nation = %i', $general['nation']);
$avgGen = $db->queryFirstRow('SELECT max(leader+power+intel) as lpi, avg(dedication) as ded,avg(experience) as exp, avg(dex0+dex10+dex20+dex30) as dex_t, avg(dex40) as dex40 from general where npc < 5 and nation = %i', $general['nation']);
$dexTotal = $avgGen['dex_t'];
//무장 40%, 지장 40%, 무지장 20%
$stat_tier1 = GameConst::$defaultStatMax - 10 + rand()%11;
$stat_tier3 = GameConst::$defaultStatMin + rand()%6;
$stat_tier2 = GameConst::$defaultStatTotal - $stat_tier1 - $stat_tier3;
$type = Util::choiceRandomUsingWeight([
'power'=>4,
'intel'=>4,
'neutral'=>2
'power0'=>2,
'power1'=>2,
'power2'=>2,
'intel'=>6,
'neutral'=>3
]);
switch($type){
case 'power':
case 'power0':
$leader = $stat_tier1;
$power = $stat_tier2;
$intel = $stat_tier3;
$dexVal = [$dexTotal*5/8, $dexTotal/8, $dexTotal/8, $dexTotal/8];
break;
case 'power1':
$leader = $stat_tier1;
$power = $stat_tier2;
$intel = $stat_tier3;
$dexVal = [$dexTotal/8, $dexTotal*5/8, $dexTotal/8, $dexTotal/8];
break;
case 'power2':
$leader = $stat_tier1;
$power = $stat_tier2;
$intel = $stat_tier3;
$dexVal = [$dexTotal/8, $dexTotal/8, $dexTotal*5/8, $dexTotal/8];
break;
case 'intel':
$leader = $stat_tier1;
$power = $stat_tier3;
$intel = $stat_tier2;
$dexVal = [$dexTotal/8, $dexTotal/8, $dexTotal/8, $dexTotal*5/8];
break;
case 'neutral':
default:
$leader = $stat_tier3;
$power = $stat_tier1;
$intel = $stat_tier2;
$dexVal = [$dexTotal/4, $dexTotal/4, $dexTotal/4, $dexTotal/4];
break;
}
@@ -497,7 +516,7 @@ function process_29(&$general) {
'$scoutLevel','100','100','0','".GameUnitConst::DEFAULT_CREWTYPE."','0','0','0',
'0','0','0','$turntime','$killturn','$age','1','$personal','0','$specage','0','$specage2','',
'0','$bornyear','$deadyear',
'{$avgGen['dex_t']}','{$avgGen['dex_t']}','{$avgGen['dex_t']}','{$avgGen['dex_t']}','{$avgGen['dex40']}'
'{$dexVal[0]}','{$dexVal[1]}','{$dexVal[2]}','{$dexVal[3]}','{$avgGen['dex40']}'
)",
$connect
) or Error(__LINE__.MYDB_error($connect),"");
+1 -1
View File
@@ -26,7 +26,7 @@ function refreshing(obj, arg1, arg2) {
}
// if(term <= 0) {
switch(arg1) {
case 0: location.reload(); break;
case 0: document.location.reload(); break;
case 2: turn(arg2); break;
case 3: arg2.submit(); break;
case 4:
+1 -1
View File
@@ -385,7 +385,7 @@ function reloadWorldMap(option){
//터치스크린 탭
if(is_touch_device()){
if(!option.neutralView && is_touch_device()){
$objs.on('touchstart', function(e){
if(window.sam_toggleSingleTap){
return true;
+2 -1
View File
@@ -33,7 +33,8 @@ function Error($message='', $url="")
if (!$url) {
$url = $_SERVER['REQUEST_URI'];
}
file_put_contents(__dir__."/logs/".UniqueConst::$serverID."/_db_bug.txt", "{\"url\":\"$url\",\"msg\":\"$message\"}\n", FILE_APPEND);
$e = new \Exception();
logError("aux_err", $message, '', getExceptionTraceAsString($e));
$templates = new \League\Plates\Engine(__dir__.'/templates');
+1 -1
View File
@@ -17,7 +17,7 @@ $commandtype = Util::getReq('commandtype', 'int');
increaseRefresh("턴입력", 1);
if(!$turn || $commandtype === null || $sel === null){
header('location:commandlist.php');
header('location:commandlist.php', true, 303);
die();
}
+2 -2
View File
@@ -9,7 +9,7 @@ $commandtype = Util::getReq('commandtype', 'int');
$turn = Util::getReq('turn', 'array_int');
if(!$turn || $commandtype === null){
header('location:commandlist.php');
header('location:commandlist.php', true, 303);
die();
}
@@ -196,7 +196,7 @@ function command_99($turn) {
}
}
header('location:b_chiefcenter.php');
header('location:b_chiefcenter.php', true, 303);
}
function command_11($turn, $command, bool $is모병 = false) {
+1 -1
View File
@@ -20,7 +20,7 @@
data-general-nation="<?=$nation?>"
data-general-nation-name="<?=$nationName?>"
>
<td height="64"></td>
<td height="64"><img class='generalIcon' width='64' height='64' src='<?=$iconPath?>'></td>
<td><?=$nameText?></td>
<td><?=$leadershipText?><?=$leadershipBonusText?></td>
<td><?=$powerText?></td>
+2 -2
View File
@@ -25,7 +25,7 @@ $myActionCnt = $db->queryFirstField('SELECT con FROM general WHERE `owner`=%i',
$con = checkLimit($myActionCnt);
if($con >= 2) {
header('location:commandlist.php');
header('location:commandlist.php', true, 303);
exit();
}
@@ -62,4 +62,4 @@ case 2:
break;
}
header('location:commandlist.php');
header('location:commandlist.php', true, 303);
+1 -1
View File
@@ -16,4 +16,4 @@ $me = MYDB_fetch_array($result);
updateCommand($me['no'], 2);
header('location:b_chiefcenter.php');
header('location:b_chiefcenter.php', true, 303);
+1 -1
View File
@@ -16,4 +16,4 @@ $me = MYDB_fetch_array($result);
backupdateCommand($me['no'], 2);
header('location:b_chiefcenter.php');
header('location:b_chiefcenter.php', true, 303);
+1 -1
View File
@@ -76,7 +76,7 @@ function kakaoOAuthCheck(array $userInfo) : ?array {
$refreshTokenValidUntil = TimeUtil::DatetimeFromNowSecond($refreshResult['refresh_token_expires_in']);
$oauthInfo['refreshToken'] = $refreshToken;
$oauthInfo['refresh_token_expires_in'] = $refresh_token_expires_in;
$oauthInfo['refresh_token_expires_in'] = $refreshTokenValidUntil;
}
RootDB::db()->update('member', [
+7 -1
View File
@@ -29,7 +29,9 @@ $err_logs = $fdb->select('err_log', [
'date',
'err',
'errstr',
'trace'
'errpath',
'trace',
'webuser'
], [
'ORDER'=>['id'=>'DESC'],
'LIMIT'=>100
@@ -61,9 +63,13 @@ $err_logs = $fdb->select('err_log', [
<div class="card-body">
<div class="card-title"><?=htmlspecialchars($err['errstr'])?></div>
<ul class="list-group list-group-flush">
<?php if($err['errpath']): ?>
<li class="list-group-item"><?=htmlspecialchars($err['errpath'])?></li>
<?php endif; ?>
<?php foreach(Json::decode($err['trace']) as $trace): ?>
<li class="list-group-item"><?=htmlspecialchars($trace)?></li>
<?php endforeach; ?>
<li class="list-group-item"><?=htmlspecialchars($err['webuser'])?></li>
</ul>
</div>
</div>