get('PATHFINDER.CACHE.CHARACTER_LOG_INACTIVE'); return ($logInactiveTime >= 0) ? $logInactiveTime : self::CHARACTER_LOG_INACTIVE; } /** * delete all character log data that have not changed since X seconds * -> see deactivateLogData() * >> php index.php "/cron/deleteLogData" * @param \Base $f3 * @throws \Exception */ function deleteLogData(\Base $f3){ $this->setMaxExecutionTime(); DB\Database::instance()->getDB('PF'); $logInactiveTime = $this->getCharacterLogInactiveTime($f3); /** * @var $characterLogModel Model\CharacterLogModel */ $characterLogModel = Model\BasicModel::getNew('CharacterLogModel'); // find character logs that were not checked recently and update $characterLogs = $characterLogModel->find([ 'TIMESTAMPDIFF(SECOND, updated, NOW() ) > :lifetime', ':lifetime' => $logInactiveTime ], [ 'order' => 'updated asc', 'limit' => self::CHARACTERS_UPDATE_LOGS_MAX ]); if(is_object($characterLogs)){ foreach($characterLogs as $characterLog){ /** * @var $characterLog Model\CharacterLogModel */ if(is_object($characterLog->characterId)){ // force characterLog as "updated" even if no changes were made $characterLog->characterId->updateLog([ 'markUpdated' => true, 'suppressHTTPErrors' => true ]); }else{ // character_log does not have a character assigned -> delete $characterLog->erase(); } } } } /** * clean up outdated character data e.g. kicked until status * >> php index.php "/cron/cleanUpCharacterData" * @param \Base $f3 * @throws \Exception */ function cleanUpCharacterData(\Base $f3){ $this->setMaxExecutionTime(); DB\Database::instance()->getDB('PF'); /** * @var $characterModel Model\CharacterModel */ $characterModel = Model\BasicModel::getNew('CharacterModel'); $characters = $characterModel->find([ 'active = :active AND TIMESTAMPDIFF(SECOND, kicked, NOW() ) > 0', ':active' => 1 ]); if(is_object($characters)){ foreach($characters as $character){ /** * @var $character Model\CharacterModel */ $character->kick(); $character->save(); } } } /** * delete expired character authentication data * authentication data is used for cookie based login * >> php index.php "/cron/deleteAuthenticationData" * @param \Base $f3 * @throws \Exception */ function deleteAuthenticationData(\Base $f3){ $this->setMaxExecutionTime(); DB\Database::instance()->getDB('PF'); /** * @var $authenticationModel Model\CharacterAuthenticationModel */ $authenticationModel = Model\BasicModel::getNew('CharacterAuthenticationModel'); // find expired authentication data $authentications = $authenticationModel->find([ '(expires - NOW()) <= 0' ]); if(is_object($authentications)){ foreach($authentications as $authentication){ $authentication->erase(); } } } }