From 4db1a4b32e384f2b50686d7398abc47281716c74 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Thu, 23 Feb 2023 00:25:44 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=A0=91=EC=86=8D=EC=9E=90,=20=EC=A0=91?= =?UTF-8?q?=EC=86=8D=EB=9F=89=20=EA=B3=84=EC=82=B0=EC=97=90=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=EA=B0=80=20=EC=9E=88=EB=8D=98=20=EB=B6=80=EB=B6=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/a_traffic.php | 2 +- hwe/func.php | 73 ++++++++++++++++------------------------------- 2 files changed, 25 insertions(+), 50 deletions(-) diff --git a/hwe/a_traffic.php b/hwe/a_traffic.php index c1542baf..36c94111 100644 --- a/hwe/a_traffic.php +++ b/hwe/a_traffic.php @@ -8,7 +8,7 @@ include "func.php"; $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); -increaseRefresh("갱신정보", 2); +increaseRefresh("갱신정보", 1); $admin = $gameStor->getValues(['year', 'month', 'refresh', 'maxrefresh', 'maxonline']); diff --git a/hwe/func.php b/hwe/func.php index ec2bddc5..cb12a464 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -886,7 +886,7 @@ function generalInfo2(General $generalObj) function getOnlineNum(): int { - return KVStorage::getStorage(DB::db(), 'game_env')->getValue('online') ?? 0; + return KVStorage::getStorage(DB::db(), 'game_env')->getValue('online_user_cnt') ?? 0; } function onlinegen(General $general) @@ -1003,19 +1003,31 @@ function increaseRefresh($type = "", $cnt = 1) $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); - $gameStor->refresh = $gameStor->refresh + $cnt; //TODO: +로 증가하는 값은 별도로 분리 $isunited = $gameStor->isunited; $opentime = $gameStor->opentime; - if ($isunited != 2 && $generalID && $userGrade < 6 && $opentime <= TimeUtil::now()) { - $db->update('general', [ - 'lastrefresh' => $date, - 'con' => $db->sqleval('con + %i', $cnt), - 'connect' => $db->sqleval('connect + %i', $cnt), - 'refcnt' => $db->sqleval('refcnt + %i', $cnt), - 'refresh' => $db->sqleval('refresh + %i', $cnt) - ], 'owner=%i', $userID); + if($userGrade == 6){ + return; } + if($isunited == 2){ + return; + } + if(!$generalID){ + return; + } + if($opentime > $date){ + return; + } + + $gameStor->refresh = $gameStor->refresh + $cnt; //TODO: +로 증가하는 값은 별도로 분리 + + $db->update('general', [ + 'lastrefresh' => $date, + 'con' => $db->sqleval('con + %i', $cnt), + 'connect' => $db->sqleval('connect + %i', $cnt), + 'refcnt' => $db->sqleval('refcnt + %i', $cnt), + 'refresh' => $db->sqleval('refresh + %i', $cnt) + ], 'owner=%i', $userID); $date = date('Y_m_d H:i:s'); $date2 = substr($date, 0, 10); @@ -1033,42 +1045,6 @@ function increaseRefresh($type = "", $cnt = 1) ), FILE_APPEND ); - - $proxy_headers = array( - 'HTTP_VIA', - 'HTTP_X_FORWARDED_FOR', - 'HTTP_FORWARDED_FOR', - 'HTTP_X_FORWARDED', - 'HTTP_FORWARDED', - 'HTTP_CLIENT_IP', - 'HTTP_FORWARDED_FOR_IP', - 'VIA', - 'X_FORWARDED_FOR', - 'FORWARDED_FOR', - 'X_FORWARDED', - 'FORWARDED', - 'CLIENT_IP', - 'FORWARDED_FOR_IP', - 'HTTP_PROXY_CONNECTION' - ); - - $str = ""; - foreach ($proxy_headers as $x) { - if (isset($_SERVER[$x])) $str .= "//{$x}:{$_SERVER[$x]}"; - } - if ($str != "") { - file_put_contents( - __DIR__ . "/logs/" . UniqueConst::$serverID . "/_{$date2}_ipcheck.txt", - sprintf( - "%s, %s, %s%s\n", - $session->userName, - $session->generalName, - $_SERVER['REMOTE_ADDR'], - $str - ), - FILE_APPEND - ); - } } function updateTraffic() @@ -1223,10 +1199,9 @@ function updateOnline() $nationname[$nation['nation']] = $nation['name']; } - //동접수 - $before5Min = TimeUtil::nowAddMinutes(-5); - $onlineUser = $db->query('SELECT no,name,nation FROM general WHERE lastrefresh > %s AND npc < 2', $before5Min); + $startTurn = cutTurn($gameStor->turntime, $gameStor->turnterm, false); + $onlineUser = $db->query('SELECT no,name,nation FROM general WHERE lastrefresh >= %s AND npc < 2', $startTurn); $onlineNum = count($onlineUser); $onlineNationUsers = Util::arrayGroupBy($onlineUser, 'nation');