diff --git a/hwe/a_traffic.php b/hwe/a_traffic.php index b14e35f9..f66f39ad 100644 --- a/hwe/a_traffic.php +++ b/hwe/a_traffic.php @@ -2,6 +2,8 @@ namespace sammo; +use sammo\Enums\GeneralAccessLogColumn; + include "lib.php"; include "func.php"; @@ -193,12 +195,19 @@ if ($admin['maxonline'] < $curonline) { queryFirstRow('SELECT sum(refresh) as refresh, sum(`connect`) as `connect` from general'); - $max_refresh['name'] = '접속자 총합'; + $totalRefresh = [ + 'connect' => $db->queryFirstField('SELECT sum(`connect`) as `connect` from general'), + 'refresh' => $db->queryFirstField('SELECT sum(`refresh`) as `refresh` from general_access_log'), + 'name' => '접속자 총합' + ]; - $refresh_result = array_merge([$max_refresh], $db->query('SELECT `name`,refresh,`connect` FROM general ORDER BY refresh DESC LIMIT 5')); + $top5Refresh = $db->query( + 'SELECT `name`, `log`.`refresh`, `connect` FROM `general_access_log` AS `log` + INNER JOIN `general` ON `log`.`general_id` = `general`.`no` ORDER BY `log`.`refresh` DESC LIMIT 5'); - foreach ($refresh_result as $i => $user) { + $refresh_result = array_merge([$max_refresh], $db->query('SELECT `no`,`name`,refresh,`connect` FROM general ORDER BY refresh DESC LIMIT 5')); + + foreach (array_merge([$totalRefresh], $top5Refresh) as $i => $user) { $w = round($user['refresh'] / max(1, $max_refresh['refresh']) * 100, 1); $w2 = round(100 - $w, 1); $color = getTrafficColor($w); diff --git a/hwe/func.php b/hwe/func.php index 9f253179..8ab5cc54 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -1069,9 +1069,6 @@ function updateTraffic() $admin = $gameStor->getValues(['year', 'month', 'refresh', 'maxonline', 'maxrefresh']); /** @var array{year:int,month:int,refresh:int,maxonline:int,maxrefresh:int} $admin */ - //최다갱신자 - $user = $db->queryFirstRow('select name,refresh from general order by refresh desc limit 1'); - if ($admin['maxrefresh'] < $admin['refresh']) { $admin['maxrefresh'] = $admin['refresh']; } @@ -1082,22 +1079,7 @@ function updateTraffic() $gameStor->maxrefresh = $admin['maxrefresh']; $gameStor->maxonline = $admin['maxonline']; - $db->update('general', ['refresh' => 0], true); - - $date = TimeUtil::now(); - //일시|년|월|총갱신|접속자|최다갱신자 - file_put_contents( - __DIR__ . "/logs/" . UniqueConst::$serverID . "/_traffic.txt", - Json::encode([ - $date, - $admin['year'], - $admin['month'], - $admin['refresh'], - $online, - $user['name'] . "(" . $user['refresh'] . ")" - ]) . "\n", - FILE_APPEND - ); + $db->update('general_access_log', ['refresh' => 0], true); } function CheckOverhead() diff --git a/hwe/sammo/API/General/Join.php b/hwe/sammo/API/General/Join.php index 91087876..d4713ddb 100644 --- a/hwe/sammo/API/General/Join.php +++ b/hwe/sammo/API/General/Join.php @@ -430,7 +430,6 @@ class Join extends \sammo\BaseAPI $db->insert('general_access_log', [ GeneralAccessLogColumn::generalID->value => $generalID, GeneralAccessLogColumn::userID->value => $userID, - GeneralAccessLogColumn::nationID->value => 1, GeneralAccessLogColumn::lastRefresh->value => $now, ]); diff --git a/hwe/sammo/DTO/GeneralAccessLog.php b/hwe/sammo/DTO/GeneralAccessLog.php index 6e4924b8..fac2424b 100644 --- a/hwe/sammo/DTO/GeneralAccessLog.php +++ b/hwe/sammo/DTO/GeneralAccessLog.php @@ -19,21 +19,10 @@ class GeneralAccessLog extends \LDTO\DTO #[RawName('user_id')] public ?int $userID, - #[RawName('nation_id')] - #[NullIsUndefined] - public ?int $nationID, - #[RawName('last_refresh')] #[Convert(DateTimeConverter::class)] public \DateTimeImmutable $lastRefresh, - #[RawName('last_connect')] - #[Convert(DateTimeConverter::class)] - public ?\DateTimeImmutable $lastConnect, - - #[RawName('login_total')] - public int $loginTotal, - public int $refresh, #[RawName('refresh_total')] diff --git a/hwe/sammo/Enums/GeneralAccessLogColumn.php b/hwe/sammo/Enums/GeneralAccessLogColumn.php index cec80081..21290e3d 100644 --- a/hwe/sammo/Enums/GeneralAccessLogColumn.php +++ b/hwe/sammo/Enums/GeneralAccessLogColumn.php @@ -6,10 +6,7 @@ enum GeneralAccessLogColumn: string { case id = 'id'; case generalID = 'general_id'; case userID = 'user_id'; - case nationID = 'nation_id'; case lastRefresh = 'last_refresh'; - case lastConnect = 'last_connect'; - case loginTotal = 'login_total'; case refresh = 'refresh'; case refreshTotal = 'refresh_total'; } \ No newline at end of file diff --git a/hwe/sammo/Enums/GeneralColumn.php b/hwe/sammo/Enums/GeneralColumn.php index c312e0f2..ebdefcd6 100644 --- a/hwe/sammo/Enums/GeneralColumn.php +++ b/hwe/sammo/Enums/GeneralColumn.php @@ -17,9 +17,6 @@ enum GeneralColumn: string{ case newmsg = 'newmsg'; case con = 'con'; case connect = 'connect'; - case refresh = 'refresh'; - case logcnt = 'logcnt'; - case refcnt = 'refcnt'; case picture = 'picture'; case imgsvr = 'imgsvr'; case name = 'name'; diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index 55d699d7..fbbd806c 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -793,12 +793,6 @@ class General implements iAction 'nation_id' => $updateVals['nation'] ], 'general_id = %i', $generalID); $result = true; - - if($this->getNPCType() < 2){ - $db->update('general_access_log', [ - GeneralAccessLogColumn::nationID->value => $updateVals['nation'] - ], '%b = %i', GeneralAccessLogColumn::generalID->value, $generalID); - } } $this->flushUpdateValues(); } diff --git a/hwe/sql/schema.sql b/hwe/sql/schema.sql index ba84682c..c335de84 100644 --- a/hwe/sql/schema.sql +++ b/hwe/sql/schema.sql @@ -13,9 +13,6 @@ CREATE TABLE `general` ( `newmsg` INT(1) NULL DEFAULT '0', `con` INT(6) NOT NULL DEFAULT '0', `connect` INT(6) NOT NULL DEFAULT '0', - `refresh` INT(6) NOT NULL DEFAULT '0', - `logcnt` INT(6) NULL DEFAULT '1', - `refcnt` INT(6) NULL DEFAULT '1', `picture` VARCHAR(40) NOT NULL, `imgsvr` INT(1) NOT NULL DEFAULT '0', `name` VARCHAR(32) NOT NULL COLLATE 'utf8mb4_bin', @@ -54,7 +51,6 @@ CREATE TABLE `general` ( `recent_war` DATETIME(6) NULL DEFAULT NULL, `makelimit` INT(2) NULL DEFAULT '0', `killturn` INT(3) NULL DEFAULT NULL, - `ip` VARCHAR(40) NULL DEFAULT '', `block` INT(1) NULL DEFAULT '0', `dedlevel` INT(2) NULL DEFAULT '0', `explevel` INT(2) NULL DEFAULT '0', @@ -103,15 +99,11 @@ CREATE TABLE `general_access_log` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `general_id` INT(11) NOT NULL, `user_id` INT(11) NULL DEFAULT NULL, - `nation_id` INT(11) NULL DEFAULT NULL, `last_refresh` DATETIME NULL DEFAULT NULL, - `last_connect` DATETIME NULL DEFAULT NULL, - `login_total` INT(11) NOT NULL DEFAULT '0', `refresh` INT(11) NOT NULL DEFAULT '0', `refresh_total` INT(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE INDEX `general_id` (`general_id`), - INDEX `nation_id` (`nation_id`) ) COLLATE='utf8mb4_general_ci' ENGINE=Aria diff --git a/src/sammo/Session.php b/src/sammo/Session.php index b04e4d92..e10a7f28 100644 --- a/src/sammo/Session.php +++ b/src/sammo/Session.php @@ -288,12 +288,6 @@ class Session } } - $db->update('general', [ - 'logcnt' => $db->sqleval('logcnt+1'), - 'ip' => Util::get_client_ip(true), - 'lastConnect' => TimeUtil::now() - ], 'owner = %i', $userID); - $this->set($serverID.static::GAME_KEY_DATE, $now); $this->set($serverID.static::GAME_KEY_GENERAL_ID, $generalID); $this->set($serverID.static::GAME_KEY_GENERAL_NAME, $generalName);