function returnProfile($profile) { // Успешная аутентификация global $invalidateAllClientTokens; if ($invalidateAllClientTokens) { invalidateAllTokens($profile['uuid']); } replaceToken($profile['uuid'], $profile['clientToken'], $profile['accessToken']); updateProvider($profile['uuid'], $profile['provider'], $profile['provider'] != "mojang"); // Настало время охуительных историй $profile['uuid'] = logAsHackedProfile($profile['uuid']); $profile['name'] = getProfileName($profile['uuid']); // Выбранный профиль $gameProfile = array("id" => $profile['uuid'], "name" => $profile['name'], "legacy" => 'false'); // Конечный результат $response = array("accessToken" => $profile['accessToken'], "clientToken" => $profile['clientToken'], "selectedProfile" => $gameProfile, "availableProfiles" => array($gameProfile), "provider" => $profile['provider'], "role" => $profile['role']); response($response); }
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://sessionserver.mojang.com/session/minecraft/hasJoined' . '?' . $mojangRequest); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); $mojangResponse = curl_exec($ch); if (curl_errno($ch) == 0) { curl_close($ch); $mojangResponse = json_decode($mojangResponse, true); if (isset($mojangResponse['id'])) { // Было обнаружено, что игрок пытается зайти в игру через лицензионные лаунчер и учётную запись $insert = registerLicenseUUID($mojangResponse['id'], $name); $uuid = $insert['uuid']; $name = $insert['name']; $properties = $mojangResponse['properties']; // Сообщаю системе, что игрок авторизовался через официальный лаунчер updateProvider($uuid, 'mojang', false); } } // Выдернуть информацию о игроке из нашей системы if ($uuid === null) { $query = "SELECT `uuid`, `accessToken`" . " FROM `authserver`.`account_server_joins` AS `j`" . " JOIN `authserver`.`account_access_tokens` AS `t` USING(`accessToken`)" . " WHERE `j`.`serverHash` = '{$serverHash}';"; $result = $authserver->query($query) or responseWithError("InternalDatabaseError", $authserver->error); if ($result->num_rows == 1) { // Информация найдена $row = $result->fetch_assoc(); $uuid = $row['uuid']; $name = getProfileName($uuid); // Удаляю временную строку входа на сервер + очень устаревшие записи cleanupJoins($row['accessToken']); } }