diff --git a/webapp/controller/BaseController.class.php b/webapp/controller/BaseController.class.php index 24a86121..7fdd4943 100644 --- a/webapp/controller/BaseController.class.php +++ b/webapp/controller/BaseController.class.php @@ -88,6 +88,20 @@ class BaseController { return phpcommon\getMondaySeconds($time, $this->timeZone); } + public function _inTimeRangeStr($beginTimeStr, $endTimeStr) + { + $beginTimeOffset = myself()->_getDaySecondsOffset(strtotime("2024-6-22 ". $beginTimeStr)); + $endTimeOffset = myself()->_getDaySecondsOffset(strtotime("2024-6-22 ". $endTimeStr)); + $nowTimeOffset = myself()->_getDaySecondsOffset(myself()->_getNowTime()); + error_log(json_encode(array( + 'beginTimeOffset' => $beginTimeOffset, + 'endTimeOffset' => $endTimeOffset, + 'nowTimeOffset' => $nowTimeOffset, + 'isOpen' => $nowTimeOffset >= $beginTimeOffset && $nowTimeOffset <= $endTimeOffset, + ))); + return $nowTimeOffset >= $beginTimeOffset && $nowTimeOffset <= $endTimeOffset; + } + public function _getZid() { $net = getReqVal('_net', ''); diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index 67cfab14..8a1fff3e 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -823,6 +823,13 @@ class BattleController extends BaseAuthedController { myself()->_rspErr(2, 'map mode error'); return; } + if (!mt\MapMode::checkLimitTime($mapModeMeta)) { + error_log(json_encode(array( + 'msg' => 'MapMode::CheckLimitTime error', + 'meta' => $mapModeMeta + ))); + return false; + } $r = myself()->_getRedis($roomUuid); if (!$this->checkTicket($r, $customData, $mapModeMeta)) { myself()->_rspErr(2, 'map mode error'); @@ -1203,38 +1210,14 @@ class BattleController extends BaseAuthedController { private function checkTicket($r, $customData, $mapModeMeta) { - if (!mt\MapMode::checkLimitTime($mapModeMeta)) { - error_log(json_encode(array( - 'msg' => 'MapMode::CheckLimitTime error', - 'meta' => $mapModeMeta - ))); - return false; - } $itemId = $mapModeMeta['admission_item_id']; if (empty($itemId)) { return true; } - if (!$mapModeMeta['is_open']) { - return false; - } $roomUuid = $customData['room_uuid']; if ($r->get(DEC_BATTLE_TICKET . $roomUuid)) { return true; } - if (!empty($mapModeMeta['daily_open_time']) && !empty($mapModeMeta['daily_end_time'])) { - $dailyOpenTimeOffset = myself()->_getDaySecondsOffset(strtotime("2024-6-22 ".$mapModeMeta['daily_open_time'])); - $dailyEndTimeOffset = myself()->_getDaySecondsOffset(strtotime("2024-6-22 ".$mapModeMeta['daily_end_time'])); - $nowTimeOffset = myself()->_getDaySecondsOffset(myself()->_getNowTime()); - error_log(json_encode(array( - 'dailyOpenTimeOffset' => $dailyOpenTimeOffset, - 'dailyEndTimeOffset' => $dailyEndTimeOffset, - 'nowTimeOffset' => $nowTimeOffset, - 'isOpen' => $nowTimeOffset >= $dailyOpenTimeOffset && $nowTimeOffset <= $dailyEndTimeOffset - ))); - if (!($nowTimeOffset >= $dailyOpenTimeOffset && $nowTimeOffset <= $dailyEndTimeOffset)) { - return false; - } - } foreach ($customData['team_list'] as $team) { foreach ($team['members'] as $member) { if (!$member['is_android']) { diff --git a/webapp/mt/MapMode.php b/webapp/mt/MapMode.php index 7ab79385..a0e17dd8 100644 --- a/webapp/mt/MapMode.php +++ b/webapp/mt/MapMode.php @@ -37,6 +37,16 @@ class MapMode public static function checkLimitTime($meta) { + if (!empty($meta['daily_open_time']) && !empty($meta['daily_end_time'])) { + if (myself()->_inTimeRangeStr($meta['daily_open_time'], $meta['daily_end_time'])) { + return false; + } + } + if (!empty($meta['daily_open_time2']) && !empty($meta['daily_end_time2'])) { + if (myself()->_inTimeRangeStr($meta['daily_open_time2'], $meta['daily_end_time2'])) { + return false; + } + } switch ($meta['limit_time']) { case 1: {