public static Habbo GetHabboById(int UserId) { try { if (GetGame() == null) { return(null); } if (GetGame().GetClientManager() == null) { return(null); } GameClient Client = GetGame().GetClientManager().GetClientByUserID(UserId); if (Client != null) { Habbo User = Client.GetHabbo(); if (User != null && User.Id > 0) { if (_usersCached.ContainsKey(UserId)) { _usersCached.TryRemove(UserId, out User); } return(User); } } else { try { if (_usersCached.ContainsKey(UserId)) { return(_usersCached[UserId]); } else { UserData data = UserDataFactory.GetUserData(UserId); if (data != null) { Habbo Generated = data.user; if (Generated != null) { Generated.InitInformation(data); _usersCached.TryAdd(UserId, Generated); return(Generated); } } } } catch { return(null); } } return(null); } catch { return(null); } }
/// <summary> /// Get's Habbo By The User Id /// </summary> /// <param name="userId">The user identifier.</param> /// <returns>Habbo.</returns> /// Table: users.id internal static Habbo GetHabboById(uint userId) { if (userId == 0) { return(null); } GameClient clientByUserId = GetGame().GetClientManager().GetClientByUserId(userId); if (clientByUserId != null) { Habbo habbo = clientByUserId.GetHabbo(); if (habbo != null && habbo.Id > 0) { UsersCached.AddOrUpdate(userId, habbo, (key, value) => habbo); return(habbo); } } else { if (UsersCached.ContainsKey(userId)) { return(UsersCached[userId]); } UserData userData = UserDataFactory.GetUserData((int)userId); if (userData == null) { return(null); } if (UsersCached.ContainsKey(userId)) { return(UsersCached[userId]); } if (userData.User == null) { return(null); } UsersCached.TryAdd(userId, userData.User); userData.User.InitInformation(userData); return(userData.User); } return(null); }
public static Habbo GetHabboById(int UserId) { try { var Client = Program.GameContext.PlayerController.GetClientByUserId(UserId); if (Client != null) { var User = Client.GetHabbo(); if (User != null && User.Id > 0) { if (_usersCached.ContainsKey(UserId)) { _usersCached.TryRemove(UserId, out User); } return(User); } } else { try { if (_usersCached.ContainsKey(UserId)) { return(_usersCached[UserId]); } var data = UserDataFactory.GetUserData(UserId); if (data != null) { var Generated = data.user; if (Generated != null) { Generated.InitInformation(data); _usersCached.TryAdd(UserId, Generated); return(Generated); } } } catch { return(null); } } return(null); } catch { return(null); } }
internal static Habbo getHabboForId(uint UserId) { Habbo result; try { GameClient clientByUserID = CyberEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId); if (clientByUserID != null) { Habbo habbo = clientByUserID.GetHabbo(); if (habbo != null && habbo.Id > 0u) { if (CyberEnvironment.usersCached.Contains(UserId)) { CyberEnvironment.usersCached.Remove(UserId); } result = habbo; return(result); } } else { if (CyberEnvironment.usersCached.Contains(UserId)) { result = (Habbo)CyberEnvironment.usersCached[UserId]; return(result); } UserData userData = UserDataFactory.GetUserData(checked ((int)UserId)); Habbo user = userData.user; if (user != null) { user.InitInformation(userData); CyberEnvironment.usersCached.Add(UserId, user); result = user; return(result); } } result = null; } catch { result = null; } return(result); }
internal static Habbo getHabboForId(uint UserId) { try { HabboHotel.GameClients.GameClient game = GetGame().GetClientManager().GetClientByUserID(UserId); if (game != null) { Habbo noUser = game.GetHabbo(); if (noUser != null && noUser.Id > 0) { if (usersCached.ContainsKey(UserId)) { usersCached.Remove(UserId); } return(noUser); } } else { if (usersCached.ContainsKey(UserId)) { return(usersCached[UserId]); } else { UserData data = UserDataFactory.GetUserData((int)UserId); Habbo Generated = data.user; if (Generated != null) { Generated.InitInformation(data); usersCached.Add(UserId, Generated); return(Generated); } } } return(null); } catch { return(null); } }
/// <summary> /// Get's Habbo By The User Id /// </summary> /// <param name="userId">The user identifier.</param> /// <returns>Habbo.</returns> /// Table: users.id internal static Habbo GetHabboById(uint userId) { try { var clientByUserId = GetGame().GetClientManager().GetClientByUserId(userId); if (clientByUserId != null) { var habbo = clientByUserId.GetHabbo(); if (habbo != null && habbo.Id > 0) { UsersCached.AddOrUpdate(userId, habbo, (key, value) => habbo); return(habbo); } } else { var userData = UserDataFactory.GetUserData((int)userId); if (UsersCached.ContainsKey(userId)) { return(UsersCached[userId]); } if (userData == null || userData.User == null) { return(null); } UsersCached.TryAdd(userId, userData.User); userData.User.InitInformation(userData); return(userData.User); } } catch (Exception e) { Writer.Writer.LogException("Habbo GetHabboForId: " + e); } return(null); }
public bool TryAuthenticate(string AuthTicket) { try { byte errorCode = 0; UserData userData = UserDataFactory.GetUserData(AuthTicket, out errorCode); if (errorCode == 1 || errorCode == 2) { Disconnect(); return(false); } #region Ban Checking //Let's have a quick search for a ban before we successfully authenticate.. ModerationBan BanRecord = null; if (!string.IsNullOrEmpty(MachineId)) { if (QuasarEnvironment.GetGame().GetModerationManager().IsBanned(MachineId, out BanRecord)) { if (QuasarEnvironment.GetGame().GetModerationManager().MachineBanCheck(MachineId)) { Disconnect(); return(false); } } } if (userData.user != null) { //Now let us check for a username ban record.. BanRecord = null; if (QuasarEnvironment.GetGame().GetModerationManager().IsBanned(userData.user.Username, out BanRecord)) { if (QuasarEnvironment.GetGame().GetModerationManager().UsernameBanCheck(userData.user.Username)) { Disconnect(); return(false); } } } #endregion QuasarEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username); _habbo = userData.user; if (_habbo != null) { userData.user.Init(this, userData); SendMessage(new AuthenticationOKComposer()); SendMessage(new AvatarEffectsComposer(_habbo.Effects().GetAllEffects)); //FurniListNotification -> why? SendMessage(new NavigatorSettingsComposer(_habbo.HomeRoom)); SendMessage(new FavouritesComposer(userData.user.FavoriteRooms)); SendMessage(new FigureSetIdsComposer(_habbo.GetClothing().GetClothingAllParts)); //1984 //2102 SendMessage(new UserRightsComposer(_habbo)); SendMessage(new AvailabilityStatusComposer()); //1044 SendMessage(new AchievementScoreComposer(_habbo.GetStats().AchievementPoints)); //3674 //3437 SendMessage(new CampaignCalendarDataComposer(_habbo.calendarGift)); var habboClubSubscription = new ServerPacket(ServerPacketHeader.HabboClubSubscriptionComposer); habboClubSubscription.WriteString("club_habbo"); habboClubSubscription.WriteInteger(0); habboClubSubscription.WriteInteger(0); habboClubSubscription.WriteInteger(0); habboClubSubscription.WriteInteger(2); habboClubSubscription.WriteBoolean(false); habboClubSubscription.WriteBoolean(false); habboClubSubscription.WriteInteger(0); habboClubSubscription.WriteInteger(0); habboClubSubscription.WriteInteger(0); SendMessage(habboClubSubscription); SendMessage(new BuildersClubMembershipComposer()); SendMessage(new CfhTopicsInitComposer()); SendMessage(new BadgeDefinitionsComposer(QuasarEnvironment.GetGame().GetAchievementManager()._achievements)); SendMessage(new SoundSettingsComposer(_habbo.ClientVolume, _habbo.ChatPreference, _habbo.AllowMessengerInvites, _habbo.FocusPreference, FriendBarStateUtility.GetInt(_habbo.FriendbarState))); //SendMessage(new TalentTrackLevelComposer()); if (!string.IsNullOrEmpty(MachineId)) { if (this._habbo.MachineId != MachineId) { using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `users` SET `machine_id` = @MachineId WHERE `id` = @id LIMIT 1"); dbClient.AddParameter("MachineId", MachineId); dbClient.AddParameter("id", _habbo.Id); dbClient.RunQuery(); } } _habbo.MachineId = MachineId; } PermissionGroup PermissionGroup = null; if (QuasarEnvironment.GetGame().GetPermissionManager().TryGetGroup(_habbo.Rank, out PermissionGroup)) { if (!String.IsNullOrEmpty(PermissionGroup.Badge)) { if (!_habbo.GetBadgeComponent().HasBadge(PermissionGroup.Badge)) { _habbo.GetBadgeComponent().GiveBadge(PermissionGroup.Badge, true, this); } } } SubscriptionData SubData = null; if (QuasarEnvironment.GetGame().GetSubscriptionManager().TryGetSubscriptionData(this._habbo.VIPRank, out SubData)) { if (!String.IsNullOrEmpty(SubData.Badge)) { if (!_habbo.GetBadgeComponent().HasBadge(SubData.Badge)) { _habbo.GetBadgeComponent().GiveBadge(SubData.Badge, true, this); } } } if (!QuasarEnvironment.GetGame().GetCacheManager().ContainsUser(_habbo.Id)) { QuasarEnvironment.GetGame().GetCacheManager().GenerateUser(_habbo.Id); } _habbo.InitProcess(); if (userData.user.GetPermissions().HasRight("mod_tickets")) { SendMessage(new ModeratorInitComposer( QuasarEnvironment.GetGame().GetModerationManager().UserMessagePresets, QuasarEnvironment.GetGame().GetModerationManager().RoomMessagePresets, QuasarEnvironment.GetGame().GetModerationManager().UserActionPresets, QuasarEnvironment.GetGame().GetModerationTool().GetTickets)); } if (!string.IsNullOrWhiteSpace(QuasarEnvironment.GetDBConfig().DBData["welcome_message"])) { SendMessage(new MOTDNotificationComposer(QuasarEnvironment.GetDBConfig().DBData["welcome_message"])); } QuasarEnvironment.GetGame().GetRewardManager().CheckRewards(this); if (GetHabbo()._NUX) { var nuxStatus = new ServerPacket(ServerPacketHeader.NuxUserStatus); nuxStatus.WriteInteger(2); SendMessage(nuxStatus); QuasarEnvironment.GetGame().GetClientManager().StaffAlert(RoomNotificationComposer.SendBubble("bubble_filter", "Er is een nieuwe gebruiker geregistreerd in Habbis!\n\nGebruiker: " + GetHabbo().Username + "", "")); } if (QuasarEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer != null) { SendMessage(QuasarEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer.Serialize()); } return(true); } } catch (Exception e) { Logging.LogCriticalException("Bug during user login: " + e); } return(false); }
public void TryAuthenticate(string AuthTicket) { if (string.IsNullOrEmpty(AuthTicket)) { return; } try { string ip = this.GetConnection().getIp(); UserData userData = UserDataFactory.GetUserData(AuthTicket, ip, this.MachineId); if (userData == null) { return; } else { ButterflyEnvironment.GetGame().GetClientManager().LogClonesOut(userData.userID); this.Habbo = userData.user; this.Langue = this.Habbo.Langue; ButterflyEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.userID, this.Habbo.Username); if (this.Langue == Language.FRANCAIS) { ButterflyEnvironment.onlineUsersFr++; } else if (this.Langue == Language.ANGLAIS) { ButterflyEnvironment.onlineUsersEn++; } else if (this.Langue == Language.PORTUGAIS) { ButterflyEnvironment.onlineUsersBr++; } if (this.Habbo.MachineId != this.MachineId) { using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor()) { queryreactor.SetQuery("UPDATE users SET machine_id = @machineid WHERE id = '" + this.Habbo.Id + "'"); queryreactor.AddParameter("machineid", this.MachineId); queryreactor.RunQuery(); } } this.Habbo.Init(this, userData); this.Habbo.LoadData(userData); this.IsNewUser(); this.SendPacket(new AuthenticationOKComposer()); this.SendPacket(new NavigatorSettingsComposer(this.Habbo.HomeRoom)); this.SendPacket(new FavouritesComposer(this.Habbo.FavoriteRooms)); this.SendPacket(new FigureSetIdsComposer()); this.SendPacket(new UserRightsComposer(this.Habbo.Rank < 2 ? 2 : this.GetHabbo().Rank)); this.SendPacket(new AvailabilityStatusComposer()); this.SendPacket(new AchievementScoreComposer(this.Habbo.AchievementPoints)); this.SendPacket(new BuildersClubMembershipComposer()); this.SendPacket(new ActivityPointsComposer(Habbo.Duckets, Habbo.WibboPoints)); this.SendPacket(new CfhTopicsInitComposer(ButterflyEnvironment.GetGame().GetModerationTool().UserActionPresets)); this.SendPacket(new SoundSettingsComposer(this.Habbo.ClientVolume, false, false, false, 1)); this.SendPacket(new AvatarEffectsComposer(ButterflyEnvironment.GetGame().GetEffectsInventoryManager().GetEffects())); this.Habbo.UpdateActivityPointsBalance(); this.Habbo.UpdateCreditsBalance(); this.Habbo.UpdateDiamondsBalance(); if (this.Habbo.HasFuse("fuse_mod")) { ButterflyEnvironment.GetGame().GetClientManager().AddUserStaff(Habbo.Id); this.SendPacket(ButterflyEnvironment.GetGame().GetModerationTool().SerializeTool()); } return; } } catch (Exception ex) { Logging.LogException("Invalid Dario bug duing user login: " + (ex).ToString()); } }
public bool TryAuthenticate(string AuthTicket) { try { UserData userData = UserDataFactory.GetUserData(AuthTicket, out byte errorCode); if (errorCode == 1 || errorCode == 2) { Disconnect(); return(false); } #region Ban Checking //Let's have a quick search for a ban before we successfully authenticate.. ModerationBan BanRecord; if (!string.IsNullOrEmpty(MachineId)) { if (NeonEnvironment.GetGame().GetModerationManager().IsBanned(MachineId, out BanRecord)) { if (NeonEnvironment.GetGame().GetModerationManager().MachineBanCheck(MachineId)) { Disconnect(); return(false); } } } if (NeonEnvironment.GetGame().GetModerationManager().IsBanned(userData.user.Username, out BanRecord)) { if (NeonEnvironment.GetGame().GetModerationManager().UsernameBanCheck(userData.user.Username)) { Disconnect(); return(false); } } #endregion NeonEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username); _habbo = userData.user; if (_habbo != null) { ssoTicket = AuthTicket; userData.user.Init(this, userData); SendMessage(new AuthenticationOKComposer()); SendMessage(new AvatarEffectsComposer(_habbo.Effects().GetAllEffects)); SendMessage(new NavigatorSettingsComposer(_habbo.HomeRoom)); SendMessage(new FavouritesComposer(userData.user.FavoriteRooms)); SendMessage(new FigureSetIdsComposer(_habbo.GetClothing().GetClothingAllParts)); SendMessage(new UserRightsComposer(_habbo)); SendMessage(new AvailabilityStatusComposer()); SendMessage(new AchievementScoreComposer(_habbo.GetStats().AchievementPoints)); //var habboClubSubscription = new ServerPacket(ServerPacketHeader.HabboClubSubscriptionComposer); //habboClubSubscription.WriteString("club_habbo"); //habboClubSubscription.WriteInteger(0); //habboClubSubscription.WriteInteger(0); //habboClubSubscription.WriteInteger(0); //habboClubSubscription.WriteInteger(2); //habboClubSubscription.WriteBoolean(false); //habboClubSubscription.WriteBoolean(false); //habboClubSubscription.WriteInteger(0); //habboClubSubscription.WriteInteger(0); //habboClubSubscription.WriteInteger(0); //SendMessage(habboClubSubscription); SendMessage(new BuildersClubMembershipComposer()); SendMessage(new CfhTopicsInitComposer()); SendMessage(new BadgeDefinitionsComposer(NeonEnvironment.GetGame().GetAchievementManager()._achievements)); SendMessage(new SoundSettingsComposer(_habbo.ClientVolume, _habbo.ChatPreference, _habbo.AllowMessengerInvites, _habbo.FocusPreference, FriendBarStateUtility.GetInt(_habbo.FriendbarState))); if (GetHabbo().GetMessenger() != null) { GetHabbo().GetMessenger().OnStatusChanged(true); } if (_habbo.Rank < 2 && !NeonStaticGameSettings.HotelOpenForUsers) { SendMessage(new SendHotelAlertLinkEventComposer("Actualmente solo el Equipo Adminsitrativo puede entrar al hotel para comprobar que todo está bien antes de que los usuarios puedan entrar. Vuelve a intentarlo en unos minutos, podrás encontrar más información en nuestro Facebook.", NeonEnvironment.GetDBConfig().DBData["facebook_url"])); Thread.Sleep(10000); Disconnect(); return(false); } if (!string.IsNullOrEmpty(MachineId)) { if (_habbo.MachineId != MachineId) { using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `users` SET `machine_id` = @MachineId WHERE `id` = @id LIMIT 1"); dbClient.AddParameter("MachineId", MachineId); dbClient.AddParameter("id", _habbo.Id); dbClient.RunQuery(); } } _habbo.MachineId = MachineId; } if (NeonEnvironment.GetGame().GetPermissionManager().TryGetGroup(_habbo.Rank, out PermissionGroup PermissionGroup)) { if (!string.IsNullOrEmpty(PermissionGroup.Badge)) { if (!_habbo.GetBadgeComponent().HasBadge(PermissionGroup.Badge)) { _habbo.GetBadgeComponent().GiveBadge(PermissionGroup.Badge, true, this); } } } if (NeonEnvironment.GetGame().GetSubscriptionManager().TryGetSubscriptionData(_habbo.VIPRank, out SubscriptionData SubData)) { if (!string.IsNullOrEmpty(SubData.Badge)) { if (!_habbo.GetBadgeComponent().HasBadge(SubData.Badge)) { _habbo.GetBadgeComponent().GiveBadge(SubData.Badge, true, this); } } } if (!NeonEnvironment.GetGame().GetCacheManager().ContainsUser(_habbo.Id)) { NeonEnvironment.GetGame().GetCacheManager().GenerateUser(_habbo.Id); } _habbo.InitProcess(); GetHabbo()._lastitems = new Dictionary <int, CatalogItem>(); //ICollection<MessengerBuddy> Friends = new List<MessengerBuddy>(); //foreach (MessengerBuddy Buddy in this.GetHabbo().GetMessenger().GetFriends().ToList()) //{ // if (Buddy == null) // continue; // GameClient Friend = NeonEnvironment.GetGame().GetClientManager().GetClientByUserID(Buddy.Id); // if (Friend == null) // continue; // string figure = this.GetHabbo().Look; // Friend.SendMessage(RoomNotificationComposer.SendBubble("usr/look/" + this.GetHabbo().Username + "", this.GetHabbo().Username + " se ha conectado a " + NeonEnvironment.GetDBConfig().DBData["hotel.name"] + ".", "")); //} if (GetHabbo()._NUX) { SendMessage(new MassEventComposer("habbopages/bienvenida.txt")); } else { SendMessage(new MassEventComposer("habbopages/welk.txt?249")); } if (NeonEnvironment.GetDBConfig().DBData["pin.system.enable"] == "0") { GetHabbo().StaffOk = true; } if (GetHabbo().StaffOk) { if (GetHabbo().GetPermissions().HasRight("mod_tickets")) { SendMessage(new ModeratorInitComposer( NeonEnvironment.GetGame().GetModerationManager().UserMessagePresets, NeonEnvironment.GetGame().GetModerationManager().RoomMessagePresets, NeonEnvironment.GetGame().GetModerationManager().GetTickets)); } } if (GetHabbo().Rank > 5 || GetHabbo()._guidelevel > 0) { HelperToolsManager.AddHelper(_habbo.GetClient(), false, true, true); SendMessage(new HandleHelperToolComposer(true)); } //SendMessage(new CampaignCalendarDataComposer(_habbo.calendarGift)); //if (int.Parse(NeonEnvironment.GetDBConfig().DBData["advent.calendar.enable"]) == 1) // Tk Custom By Whats // SendMessage(new MassEventComposer("openView/calendar")); if (NeonEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer != null) { NeonEnvironment.GetGame().GetTargetedOffersManager().Initialize(NeonEnvironment.GetDatabaseManager().GetQueryReactor()); TargetedOffers TargetedOffer = NeonEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer; if (TargetedOffer.Expire > NeonEnvironment.GetIUnixTimestamp()) { if (TargetedOffer.Limit != GetHabbo()._TargetedBuy) { SendMessage(NeonEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer.Serialize()); } } else if (TargetedOffer.Expire == -1) { if (TargetedOffer.Limit != GetHabbo()._TargetedBuy) { SendMessage(NeonEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer.Serialize()); } } else { using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE targeted_offers SET active = 'false'"); } using (IQueryAdapter dbClient2 = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient2.runFastQuery("UPDATE users SET targeted_buy = '0' WHERE targeted_buy > 0"); } } } if (_habbo.MysticBoxes.Count == 0 && _habbo.MysticKeys.Count == 0) { int box = RandomNumber.GenerateRandom(1, 8); string boxcolor = ""; switch (box) { case 1: boxcolor = "purple"; break; case 2: boxcolor = "blue"; break; case 3: boxcolor = "green"; break; case 4: boxcolor = "yellow"; break; case 5: boxcolor = "lilac"; break; case 6: boxcolor = "orange"; break; case 7: boxcolor = "turquoise"; break; case 8: boxcolor = "red"; break; } int key = RandomNumber.GenerateRandom(1, 8); string keycolor = ""; switch (key) { case 1: keycolor = "purple"; break; case 2: keycolor = "blue"; break; case 3: keycolor = "green"; break; case 4: keycolor = "yellow"; break; case 5: keycolor = "lilac"; break; case 6: keycolor = "orange"; break; case 7: keycolor = "turquoise"; break; case 8: keycolor = "red"; break; } _habbo.MysticKeys.Add(keycolor); _habbo.MysticBoxes.Add(boxcolor); using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("INSERT INTO user_mystic_data(user_id, mystic_keys, mystic_boxes) VALUES(" + GetHabbo().Id + ", '" + keycolor + "', '" + boxcolor + "');"); } } SendMessage(new MysteryBoxDataComposer(_habbo.GetClient())); SendMessage(new HCGiftsAlertComposer()); //if(!GetHabbo()._NUX) //{ // DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); // dtDateTime = dtDateTime.AddSeconds(GetHabbo().LastOnline); // if ((DateTime.Now - dtDateTime).TotalDays > 2) // { // //NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(_habbo.GetClient(), "ACH_Login", 1, true); // NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(_habbo.GetClient(), "ACH_RegistrationDuration", 1); // } // else if ((DateTime.Now - dtDateTime).TotalDays > 1 && (DateTime.Now - dtDateTime).TotalDays < 2) // { // NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(_habbo.GetClient(), "ACH_Login", 1); // NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(_habbo.GetClient(), "ACH_RegistrationDuration", 1); // if(GetHabbo().Rank > 2 || GetHabbo()._guidelevel > 0) // { // NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(_habbo.GetClient(), "ACH_GuideEnrollmentLifetime", 1); // } // } //} NeonEnvironment.GetGame().GetRewardManager().CheckRewards(this); if (GetHabbo()._NUX) { NeonEnvironment.GetGame().GetClientManager().StaffAlert(new RoomInviteComposer(int.MinValue, GetHabbo().Username + " acaba de registrarse en Keko.")); GetHabbo()._NUX = false; using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE users SET nux_user = '******' WHERE id = " + GetHabbo().Id + ";"); } } return(true); } } catch (Exception e) { Logging.LogCriticalException("Bug during user login: " + e); } return(false); }
public bool TryAuthenticate(string AuthTicket) { try { byte errorCode = 0; UserData userData = UserDataFactory.GetUserData(AuthTicket, out errorCode); if (errorCode == 1 || errorCode == 2) { Disconnect(true); return(false); } #region Ban Checking //Let's have a quick search for a ban before we successfully authenticate.. ModerationBan BanRecord = null; if (!string.IsNullOrEmpty(MachineId)) { if (PlusEnvironment.GetGame().GetModerationManager().IsBanned(MachineId, out BanRecord)) { if (PlusEnvironment.GetGame().GetModerationManager().MachineBanCheck(MachineId)) { Disconnect(true); return(false); } } } if (userData.user != null) { //Now let us check for a username ban record.. BanRecord = null; if (PlusEnvironment.GetGame().GetModerationManager().IsBanned(userData.user.Username, out BanRecord)) { if (PlusEnvironment.GetGame().GetModerationManager().UsernameBanCheck(userData.user.Username)) { Disconnect(true); return(false); } } } #endregion #region Roleplay Data using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT * FROM `rp_stats` WHERE `id` = '" + userData.userID + "' LIMIT 1"); DataRow UserRPRow = dbClient.getRow(); dbClient.SetQuery("SELECT * FROM `rp_stats_cooldowns` WHERE `id` = '" + userData.userID + "' LIMIT 1"); DataRow UserRPCooldowns = dbClient.getRow(); if (UserRPCooldowns == null) { dbClient.RunQuery("INSERT INTO `rp_stats_cooldowns` (`id`) VALUES ('" + userData.userID + "')"); dbClient.SetQuery("SELECT * FROM `rp_stats_cooldowns` WHERE `id` = '" + userData.userID + "' LIMIT 1"); UserRPCooldowns = dbClient.getRow(); } dbClient.SetQuery("SELECT * FROM `rp_stats_farming` WHERE `id` = '" + userData.userID + "' LIMIT 1"); DataRow UserRPFarming = dbClient.getRow(); if (UserRPFarming == null) { dbClient.RunQuery("INSERT INTO `rp_stats_farming` (`id`) VALUES ('" + userData.userID + "')"); dbClient.SetQuery("SELECT * FROM `rp_stats_farming` WHERE `id` = '" + userData.userID + "' LIMIT 1"); UserRPFarming = dbClient.getRow(); } _roleplay = new RoleplayUser(this, UserRPRow, UserRPCooldowns, UserRPFarming); } #endregion PlusEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username); _habbo = userData.user; if (_habbo != null) { userData.user.Init(this, userData); SendMessage(new AuthenticationOKComposer()); SendMessage(new AvatarEffectsComposer(_habbo.Effects().GetAllEffects)); SendMessage(new NavigatorSettingsComposer(_habbo.HomeRoom)); SendMessage(new FavouritesComposer(userData.user.FavoriteRooms)); SendMessage(new FigureSetIdsComposer(_habbo.GetClothing().GetClothingAllParts)); SendMessage(new UserRightsComposer(this, _habbo.Rank)); SendMessage(new AvailabilityStatusComposer()); SendMessage(new AchievementScoreComposer(_habbo.GetStats().AchievementPoints)); SendMessage(new BuildersClubMembershipComposer()); SendMessage(new CfhTopicsInitComposer()); SendMessage(new BadgeDefinitionsComposer(PlusEnvironment.GetGame().GetAchievementManager()._achievements)); SendMessage(new SoundSettingsComposer(_habbo.ClientVolume, _habbo.ChatPreference, _habbo.AllowMessengerInvites, _habbo.FocusPreference, FriendBarStateUtility.GetInt(_habbo.FriendbarState))); //SendMessage(new TalentTrackLevelComposer()); if (!string.IsNullOrEmpty(MachineId)) { if (this._habbo.MachineId != MachineId) { using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `users` SET `machine_id` = @MachineId WHERE `id` = @id LIMIT 1"); dbClient.AddParameter("MachineId", MachineId); dbClient.AddParameter("id", _habbo.Id); dbClient.RunQuery(); } } _habbo.MachineId = MachineId; } PermissionGroup PermissionGroup = null; if (PlusEnvironment.GetGame().GetPermissionManager().TryGetGroup(_habbo.Rank, out PermissionGroup)) { if (!String.IsNullOrEmpty(PermissionGroup.Badge)) { if (!_habbo.GetBadgeComponent().HasBadge(PermissionGroup.Badge)) { _habbo.GetBadgeComponent().GiveBadge(PermissionGroup.Badge, true, this); } } } SubscriptionData SubData = null; if (PlusEnvironment.GetGame().GetSubscriptionManager().TryGetSubscriptionData(this._habbo.VIPRank, out SubData)) { if (!String.IsNullOrEmpty(SubData.Badge)) { if (!_habbo.GetBadgeComponent().HasBadge(SubData.Badge)) { _habbo.GetBadgeComponent().GiveBadge(SubData.Badge, true, this); } } } if (!PlusEnvironment.GetGame().GetCacheManager().ContainsUser(_habbo.Id)) { PlusEnvironment.GetGame().GetCacheManager().GenerateUser(_habbo.Id); } _habbo.InitProcess(); if (userData.user.GetPermissions().HasRight("mod_tickets")) { SendMessage(new ModeratorInitComposer( PlusEnvironment.GetGame().GetModerationManager().UserMessagePresets, PlusEnvironment.GetGame().GetModerationManager().RoomMessagePresets, PlusEnvironment.GetGame().GetModerationManager().UserActionPresets, PlusEnvironment.GetGame().GetModerationTool().GetTickets)); } if (!string.IsNullOrWhiteSpace(PlusEnvironment.GetDBConfig().DBData["welcome_message"])) { SendMessage(new MOTDNotificationComposer(PlusEnvironment.GetDBConfig().DBData["welcome_message"].Replace("\\r\\n", "\n"))); } PlusEnvironment.GetGame().GetRewardManager().CheckRewards(this); this.AuthTicket = AuthTicket; EventManager.TriggerEvent("OnLogin", this); return(true); } } catch (Exception e) { Logging.LogCriticalException("Erro durante o login do usuário: " + e); } return(false); }
internal bool tryLogin(string AuthTicket) { try { if (GetConnection() == null) { return(false); } var userData = UserDataFactory.GetUserData(AuthTicket); if (userData == null) { this.Disconnect(); return(false); } OtanixEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.user.Id, userData.user.Username); Habbo = userData.user; if (userData.user.Username == null || GetHabbo() == null) { SendBanMessage("Você não possui um nome."); return(false); } userData.user.Init(userData); Habbo.MachineId = MachineId; var response = new QueuedServerMessage(Connection); var authok = new ServerMessage(Outgoing.AuthenticationOK); response.appendResponse(authok); var HomeRoom = new ServerMessage(Outgoing.HomeRoom); HomeRoom.AppendUInt((OtanixEnvironment.GetGame().GetPrisaoManager().estaPreso(GetHabbo().Id)) ? OtanixEnvironment.prisaoId() : GetHabbo().HomeRoom); // first home HomeRoom.AppendUInt((OtanixEnvironment.GetGame().GetPrisaoManager().estaPreso(GetHabbo().Id)) ? OtanixEnvironment.prisaoId() : GetHabbo().HomeRoom); // current home response.appendResponse(HomeRoom); var FavouriteRooms = new ServerMessage(Outgoing.FavouriteRooms); FavouriteRooms.AppendInt32(30); // max rooms FavouriteRooms.AppendInt32(userData.user.FavoriteRooms.Count); foreach (var Id in userData.user.FavoriteRooms.ToArray()) { FavouriteRooms.AppendUInt(Id); } response.appendResponse(FavouriteRooms); var sendClub = new ServerMessage(Outgoing.SerializeClub); sendClub.AppendString("club_habbo"); sendClub.AppendInt32(0); // days left sendClub.AppendInt32(0); // days multiplier sendClub.AppendInt32(0); // months left sendClub.AppendInt32(0); // ??? sendClub.AppendBoolean(true); // HC PRIVILEGE sendClub.AppendBoolean(true); // VIP PRIVILEGE sendClub.AppendInt32(0); // days i have on hc sendClub.AppendInt32(0); // days i've purchased sendClub.AppendInt32(495); // value 4 groups response.appendResponse(sendClub); var roomAccessConfig = new ServerMessage(Outgoing.RoomAccessConfig); roomAccessConfig.AppendBoolean(true); // isOpen roomAccessConfig.AppendBoolean(false); roomAccessConfig.AppendBoolean(true); response.appendResponse(roomAccessConfig); var fuserights = new ServerMessage(Outgoing.Fuserights); fuserights.AppendInt32(2); // normal|hc|vip fuserights.AppendUInt(GetHabbo().Rank); fuserights.AppendBoolean(GetHabbo().HasFuse("fuse_ambassador")); // embajador ? // fuserights.AppendInt32(0); // New Identity (1 == 1 min and Alert!) response.appendResponse(fuserights); var newidentity = new ServerMessage(Outgoing.SendNewIdentityState); newidentity.AppendInt32(GetHabbo().NewIdentity); response.appendResponse(newidentity); var HabboInformation = new ServerMessage(Outgoing.HabboInfomation); HabboInformation.AppendUInt(GetHabbo().Id); HabboInformation.AppendString(GetHabbo().Username); HabboInformation.AppendString(GetHabbo().Look); HabboInformation.AppendString(GetHabbo().Gender.ToUpper()); HabboInformation.AppendString(GetHabbo().Motto); HabboInformation.AppendString(GetHabbo().RealName); HabboInformation.AppendBoolean(false); HabboInformation.AppendUInt(GetHabbo().Respect); HabboInformation.AppendUInt(GetHabbo().DailyRespectPoints); // respect to give away HabboInformation.AppendUInt(GetHabbo().DailyPetRespectPoints); HabboInformation.AppendBoolean(true); HabboInformation.AppendString(OtanixEnvironment.UnixTimeStampToDateTime(GetHabbo().LastOnline).ToString()); HabboInformation.AppendBoolean(GetHabbo().NameChanges < EmuSettings.MAX_NAME_CHANGES); // CHANGENAME - HabboInformation.AppendBoolean((this.GetHabbo().Diamonds<=0||this.GetHabbo().NameChanges>=ButterflyEnvironment.maxNameChanges)?false:true); HabboInformation.AppendBoolean(false); response.appendResponse(HabboInformation); var IsGuide = (Habbo.Rank > 1) ? true : false; var VoteInCompetitions = false; var Trade = true; var Citizien = (Habbo.CitizenshipLevel >= 4) ? true : false; var JudgeChat = (Habbo.Rank > 2) ? true : false; var NavigatorThumbailCamera = false; var navigatorphaseTwo = true; var Camera = true; var CallHelpers = true; var BuilderAtWork = true; var MouseZoom = false; var Allows = new ServerMessage(Outgoing.PerkAllowancesMessageParser); Allows.AppendInt32(11); // count Allows.AppendString("TRADE"); Allows.AppendString((!Trade) ? "requirement.unfulfilled.citizenship_level_3" : ""); Allows.AppendBoolean(Trade); Allows.AppendString("NAVIGATOR_ROOM_THUMBNAIL_CAMERA"); Allows.AppendString((!NavigatorThumbailCamera) ? "" : ""); Allows.AppendBoolean(NavigatorThumbailCamera); Allows.AppendString("NAVIGATOR_PHASE_TWO_2014"); Allows.AppendString((!navigatorphaseTwo) ? "requirement.unfulfilled.feature_disabled" : ""); Allows.AppendBoolean(navigatorphaseTwo); Allows.AppendString("VOTE_IN_COMPETITIONS"); Allows.AppendString((!VoteInCompetitions) ? "requirement.unfulfilled.helper_level_2" : ""); Allows.AppendBoolean(VoteInCompetitions); Allows.AppendString("BUILDER_AT_WORK"); Allows.AppendString((!BuilderAtWork) ? "requirement.unfulfilled.group_membership" : ""); Allows.AppendBoolean(BuilderAtWork); Allows.AppendString("MOUSE_ZOOM"); Allows.AppendString((!MouseZoom) ? "requirement.unfulfilled.feature_disabled" : ""); Allows.AppendBoolean(MouseZoom); Allows.AppendString("CAMERA"); Allows.AppendString((!Camera) ? "requirement.unfulfilled.feature_disabled" : ""); Allows.AppendBoolean(Camera); Allows.AppendString("CALL_ON_HELPERS"); Allows.AppendString((!CallHelpers) ? "requirement.unfulfilled.citizenship_level_1" : ""); Allows.AppendBoolean(CallHelpers); Allows.AppendString("CITIZEN"); Allows.AppendString((!Citizien) ? "requirement.unfulfilled.citizenship_level_3" : ""); Allows.AppendBoolean(Citizien); Allows.AppendString("USE_GUIDE_TOOL"); Allows.AppendString((!IsGuide) ? "requirement.unfulfilled.helper_level_4" : ""); Allows.AppendBoolean(IsGuide); Allows.AppendString("JUDGE_CHAT_REVIEWS"); Allows.AppendString((!JudgeChat) ? "requirement.unfulfilled.citizenship_level_6" : ""); Allows.AppendBoolean(JudgeChat); response.appendResponse(Allows); var enabledBuilderClub = new ServerMessage(Outgoing.EnableBuilderClub); enabledBuilderClub.AppendInt32(GetHabbo().IsPremium() ? GetHabbo().GetPremiumManager().GetRemainingTime() : 0); // Tiempo restante de Constructor (2678400 = 1 mes entero (s)) enabledBuilderClub.AppendUInt(GetHabbo().IsPremium() ? GetHabbo().GetPremiumManager().GetMaxItems() : 50); // Furnis que puedo alquilar enabledBuilderClub.AppendInt32(20000); // Se puede ampliar la alquilación hasta.. enabledBuilderClub.AppendInt32(0); response.appendResponse(enabledBuilderClub); response.appendResponse(GetHabbo().GetUserClothingManager().SerializeClothes()); var achivPoints = new ServerMessage(Outgoing.AchievementPoints); achivPoints.AppendUInt(GetHabbo().AchievementPoints); response.appendResponse(achivPoints); var loadVolumen = new ServerMessage(Outgoing.LoadVolumen); loadVolumen.AppendInt32(int.Parse(GetHabbo().volumenSystem.Split(';')[0])); loadVolumen.AppendInt32(int.Parse(GetHabbo().volumenSystem.Split(';')[1])); loadVolumen.AppendInt32(int.Parse(GetHabbo().volumenSystem.Split(';')[2])); loadVolumen.AppendBoolean(GetHabbo().preferOldChat); loadVolumen.AppendBoolean(GetHabbo().IgnoreRoomInvitations); loadVolumen.AppendBoolean(GetHabbo().DontFocusUser); // fcus user loadVolumen.AppendInt32(0); // loadVolumen.AppendInt32(0); // freeFlowChat response.appendResponse(loadVolumen); var muteUsers = new ServerMessage(Outgoing.SerializeMuteUsers); muteUsers.AppendInt32(GetHabbo().MutedUsers.Count); foreach (string IgnoreName in GetHabbo().MutedUsers) { muteUsers.AppendString(IgnoreName); } response.appendResponse(muteUsers); TargetedOffer to = OtanixEnvironment.GetGame().GetTargetedOfferManager().GetRandomStaticTargetedOffer(); if (to != null) { if (!GetHabbo().TargetedOffers.ContainsKey(to.Id) || GetHabbo().TargetedOffers[to.Id] < to.PurchaseLimit) { response.appendResponse(OtanixEnvironment.GetGame().GetTargetedOfferManager().SerializeTargetedOffer(to)); } } /*var giftOptions = new ServerMessage(Outgoing.NewUserExperienceGiftOfferParser); * giftOptions.AppendInt32(1); // foreach * { * giftOptions.AppendInt32(0); * giftOptions.AppendInt32(0); * giftOptions.AppendInt32(1); // foreach (items?) * { * giftOptions.AppendString("Testeando"); // itemName ?? * giftOptions.AppendInt32(1); // foreach * { * giftOptions.AppendString("a1_kumiankka"); // item 1 * giftOptions.AppendString(""); // item 2 (if is empty == null) * } * } * } * response.appendResponse(giftOptions);*/ response.appendResponse(OtanixEnvironment.GetGame().GetAchievementManager().AchievementPrede); if (GetHabbo().HomeRoom <= 0) { var homeRoom = new ServerMessage(Outgoing.OutOfRoom); response.appendResponse(homeRoom); } else { Room room = OtanixEnvironment.GetGame().GetRoomManager().GetRoom(GetHabbo().HomeRoom); if (room != null) { this.GetMessageHandler().enterOnRoom3(room); } } response.sendResponse(); // Verifica a conta staff if (GetHabbo().Rank > 5) { ServerMessage VerificaSenha = new ServerMessage(Outgoing.MobilePhoneNumero); VerificaSenha.AppendInt32(1); VerificaSenha.AppendInt32(1); SendMessage(VerificaSenha); } // Termina de verificar a conta staff Ban BanReason = OtanixEnvironment.GetGame().GetBanManager().GetBanReason(Habbo.Username, Habbo.MachineId); if (BanReason != null) { SendScrollNotif("Você tem um banimento do tipo: " + BanReason.Type + "\r\nMotivo: " + BanReason.ReasonMessage); Disconnect(); return(false); } GetHabbo().InitMessenger(); if (GetHabbo().GetAvatarEffectsInventoryComponent() != null) { SendMessage(GetHabbo().GetAvatarEffectsInventoryComponent().Serialize()); } SendMessage(OtanixEnvironment.GetGame().GetModerationTool().SerializeCfhTopics()); if (LanguageLocale.welcomeAlertEnabled) { string strAlert = BlackWordsManager.SpecialReplace(LanguageLocale.welcomeAlert, this); if (LanguageLocale.welcomeAlertType == 0) { SendScrollNotif(strAlert); } else if (LanguageLocale.welcomeAlertType == 1) { SendNotif(strAlert); } else if (LanguageLocale.welcomeAlertType == 2) { SendNotifWithImage(strAlert, LanguageLocale.welcomeAlertImage); } } OtanixEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(Habbo.Id, "ACH_EmailVerification", 1); GetHabbo().UpdateCreditsBalance(); GetHabbo().UpdateExtraMoneyBalance(); GetHabbo().setMeOnline(); GetHabbo().InitExtra(); UsersCache.enterProvisionalRoom(this); return(true); } catch (UserDataNotFoundException e) { SendScrollNotif(LanguageLocale.GetValue("login.invalidsso") + "extra data: " + e); } catch (Exception e) { Logging.LogCriticalException("Invalid Dario bug duing user login: "******"Login error: " + e); } return(false); }
/// <summary> /// Tries the login. /// </summary> /// <param name="authTicket">The authentication ticket.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> internal bool TryLogin(string authTicket) { try { string ip = GetConnection().GetIp(); uint errorCode; UserData userData = UserDataFactory.GetUserData(authTicket, out errorCode); if (errorCode == 1 || errorCode == 2) { return(false); } Yupi.GetGame().GetClientManager().RegisterClient(this, userData.UserId, userData.User.UserName); _habbo = userData.User; userData.User.LoadData(userData); string banReason = Yupi.GetGame().GetBanManager().GetBanReason(userData.User.UserName, ip, MachineId); if (!string.IsNullOrEmpty(banReason) || userData.User.UserName == null) { SendNotifWithScroll(banReason); using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor()) { queryReactor.SetQuery($"SELECT ip_last FROM users WHERE id={GetHabbo().Id} LIMIT 1"); string supaString = queryReactor.GetString(); queryReactor.SetQuery($"SELECT COUNT(0) FROM users_bans_access WHERE user_id={_habbo.Id} LIMIT 1"); int integer = queryReactor.GetInteger(); if (integer > 0) { queryReactor.RunFastQuery("UPDATE users_bans_access SET attempts = attempts + 1, ip='" + supaString + "' WHERE user_id=" + GetHabbo().Id + " LIMIT 1"); } else { queryReactor.RunFastQuery("INSERT INTO users_bans_access (user_id, ip) VALUES (" + GetHabbo().Id + ", '" + supaString + "')"); } } return(false); } using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor()) queryReactor.RunFastQuery($"UPDATE users SET ip_last='{ip}' WHERE id={GetHabbo().Id}"); userData.User.Init(this, userData); QueuedServerMessage queuedServerMessage = new QueuedServerMessage(_connection); ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("UniqueMachineIDMessageComposer")); serverMessage.AppendString(MachineId); queuedServerMessage.AppendResponse(serverMessage); queuedServerMessage.AppendResponse(new ServerMessage(LibraryParser.OutgoingRequest("AuthenticationOKMessageComposer"))); ServerMessage serverMessage2 = new ServerMessage(LibraryParser.OutgoingRequest("HomeRoomMessageComposer")); serverMessage2.AppendInteger(_habbo.HomeRoom); serverMessage2.AppendInteger(_habbo.HomeRoom); queuedServerMessage.AppendResponse(serverMessage2); serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("MinimailCountMessageComposer")); serverMessage.AppendInteger(_habbo.MinimailUnreadMessages); queuedServerMessage.AppendResponse(serverMessage); serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("FavouriteRoomsMessageComposer")); serverMessage.AppendInteger(30); if (userData.User.FavoriteRooms == null || !userData.User.FavoriteRooms.Any()) { serverMessage.AppendInteger(0); } else { serverMessage.AppendInteger(userData.User.FavoriteRooms.Count); foreach (uint i in userData.User.FavoriteRooms) { serverMessage.AppendInteger(i); } } queuedServerMessage.AppendResponse(serverMessage); ServerMessage rightsMessage = new ServerMessage(LibraryParser.OutgoingRequest("UserClubRightsMessageComposer")); rightsMessage.AppendInteger(userData.User.GetSubscriptionManager().HasSubscription ? 2 : 0); rightsMessage.AppendInteger(userData.User.Rank); rightsMessage.AppendInteger(0); queuedServerMessage.AppendResponse(rightsMessage); serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("EnableNotificationsMessageComposer")); serverMessage.AppendBool(true); //isOpen serverMessage.AppendBool(false); queuedServerMessage.AppendResponse(serverMessage); serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("EnableTradingMessageComposer")); serverMessage.AppendBool(true); queuedServerMessage.AppendResponse(serverMessage); userData.User.UpdateCreditsBalance(); serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ActivityPointsMessageComposer")); serverMessage.AppendInteger(2); serverMessage.AppendInteger(0); serverMessage.AppendInteger(userData.User.ActivityPoints); serverMessage.AppendInteger(5); serverMessage.AppendInteger(userData.User.Diamonds); queuedServerMessage.AppendResponse(serverMessage); if (userData.User.HasFuse("fuse_mod")) { queuedServerMessage.AppendResponse(Yupi.GetGame().GetModerationTool().SerializeTool(this)); } queuedServerMessage.AppendResponse(Yupi.GetGame().GetAchievementManager().AchievementDataCached); if (!GetHabbo().NuxPassed&& ServerExtraSettings.NewUsersGiftsEnabled) { queuedServerMessage.AppendResponse(new ServerMessage(LibraryParser.OutgoingRequest("NuxSuggestFreeGiftsMessageComposer"))); } queuedServerMessage.AppendResponse(GetHabbo().GetAvatarEffectsInventoryComponent().GetPacket()); queuedServerMessage.SendResponse(); Yupi.GetGame().GetAchievementManager().TryProgressHabboClubAchievements(this); Yupi.GetGame().GetAchievementManager().TryProgressRegistrationAchievements(this); Yupi.GetGame().GetAchievementManager().TryProgressLoginAchievements(this); return(true); } catch (Exception ex) { ServerLogManager.LogCriticalException($"Bug during user login: {ex}"); } return(false); }
public void LogIn(string sso, bool loginWithUsernameAndPassword = false) { uint id = 0; //DUE TO R26 TESTING if (sso == "fcc08e21-8a14-41e4-22f4-1a258f9db47f") { using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.ExecuteQuery("UPDATE users SET auth_ticket = 'fcc08e21-8a14-41e4-22f4-1a258f9db47f' WHERE id = 3132 LIMIT 1"); } } else if (sso == "ESANPIKKUPIKAPANO") { using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.ExecuteQuery("UPDATE users SET auth_ticket = 'ESANPIKKUPIKAPANO' WHERE id = 3133 LIMIT 1"); } } try { if (string.IsNullOrEmpty(sso) || string.IsNullOrWhiteSpace(sso)) { this.SendNotif("Empty SSO ticket!"); } else { UserDataFactory userData = new UserDataFactory(this.connection.GetIP(), this.MachineID, sso, true, out this.SessionID); if (userData.IsUserLoaded) { id = (uint)userData.GetUserData()["id"]; string username = (string)userData.GetUserData()["username"]; Skylight.GetGame().GetGameClientManager().UpdateCachedUsername(id, username); //we loaded the user data.. why not update this too Skylight.GetGame().GetGameClientManager().UpdateCachedID(id, username); bool requireLogin = ServerConfiguration.MinRankRequireLogin == 0 ? false : (int)userData.GetUserData()["rank"] >= ServerConfiguration.MinRankRequireLogin; if ((!loginWithUsernameAndPassword && !requireLogin) || (loginWithUsernameAndPassword && requireLogin)) { Ban ban = Skylight.GetGame().GetBanManager().TryGetBan(id, this.GetIP(), this.MachineID); if (ban == null || Licence.CheckIfMatches(id, username, this.GetIP(), this.MachineID)) //don't load ANY shit before we are sure he can come on { Skylight.GetGame().GetGameClientManager().DisconnectDoubleSession(id); this.Habbo = Authenicator.LoadHabbo(userData, this); this.Habbo.LoadMore(); if (this.Habbo.IsTwoFactorAuthenticationEnabled()) { int failures = 0; using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { failures = dbClient.ReadInt32("SELECT COUNT(id) FROM user_2fa_failures WHERE timestamp >= UNIX_TIMESTAMP() - 60 * 15"); } if (failures < 3) { this.AddMessageHandlerToFrist(new TwoFactorAuthenticationHandler(failures)); if (this.Revision == Revision.RELEASE63_35255_34886_201108111108) { ServerMessage message = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message.Init(r63aOutgoing.ChangeNameWindow); this.SendMessage(message); } else { this.SendMessage(BasicUtilies.GetRevisionPacketManager(this.Revision).GetOutgoing(OutgoingPacketsEnum.AuthOk).Handle()); ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486, r63cOutgoing.VerifyMobilePhoneWindow); message_.AppendInt32(9); message_.AppendInt32(3); message_.AppendInt32(1); this.SendMessage(message_); } this.SendNotif("Looks like you have enable two factor authenication on your account! Please enter the code to log in!" + ((Skylight.GetConfig()["client.ping.enabled"] == "1") ? " You have one minute!" : "") + "\n\n!!CLOSE THIS!!", 2); } else { this.SendNotif("You have too many login fails inside 15 minutes! Please try again later!", 2); } } else { this.LetUserIn(); } } else { string banLenght = ""; if (ban.Permament) { banLenght = "PERMAMENT"; } else { TimeSpan lenght = new TimeSpan(0, 0, 0, (int)(ban.Expires - ban.AddedOn)); banLenght = lenght.Seconds + " seconds"; if (lenght.TotalMinutes >= 1) { banLenght += ", " + lenght.Minutes + " minutes"; } if (lenght.TotalHours >= 1) { banLenght += ", " + lenght.Hours + " hours"; } if (lenght.TotalDays >= 1) { banLenght += ", " + lenght.Days + " days"; } } this.SendNotif("You have been banned!\nReason: " + ban.Reason + "\nLength: " + banLenght + "\nExpires: " + (ban.Permament ? "NEVER" : TimeUtilies.UnixTimestampToDateTime(ban.Expires).ToString()) + "\nBanned by: " + Skylight.GetGame().GetGameClientManager().GetUsernameByID(ban.AddedByID), 2); //this.Stop("Banned!"); } } else { this.SendNotif("Sorry but, you cant use this login method!", 2); } } else { this.SendNotif("Invalid SSO ticket!", 2); } } } finally //fixes issue where valid sso ticket sets online to = '1' but dosent turn it back to = '0' after disconnection bcs users data isint loaded for few reasons example exeption or user is banned { if (id > 0) //only positive numbers are valid user ids { if (this.GetHabbo() == null) //only if habbo is null or this is already done by habbo class itself { using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient()) { dbClient.AddParamWithValue("userId", id); dbClient.ExecuteQuery("UPDATE users SET online = '0' WHERE id = @userId LIMIT 1"); } } } } }
public bool TryAuthenticate(string AuthTicket) { try { UserData userData = UserDataFactory.GetUserData(AuthTicket, out byte errorCode); if (errorCode == 1 || errorCode == 2) { Disconnect(); return(false); } #region Ban Checking //Let's have a quick search for a ban before we successfully authenticate.. ModerationBan BanRecord = null; if (!string.IsNullOrEmpty(MachineId)) { if (BiosEmuThiago.GetGame().GetModerationManager().IsBanned(MachineId, out BanRecord)) { if (BiosEmuThiago.GetGame().GetModerationManager().MachineBanCheck(MachineId)) { Disconnect(); return(false); } } } if (userData.user != null) { //Now let us check for a username ban record.. BanRecord = null; if (BiosEmuThiago.GetGame().GetModerationManager().IsBanned(userData.user.Username, out BanRecord)) { if (BiosEmuThiago.GetGame().GetModerationManager().UsernameBanCheck(userData.user.Username)) { Disconnect(); return(false); } } } #endregion BiosEmuThiago.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username); _habbo = userData.user; _habbo.ssoTicket = AuthTicket; if (_habbo != null) { userData.user.Init(this, userData); SendMessage(new AuthenticationOKComposer()); SendMessage(new AvatarEffectsComposer(_habbo.Effects().GetAllEffects)); SendMessage(new NavigatorSettingsComposer(_habbo.HomeRoom)); SendMessage(new FavouritesComposer(userData.user.FavoriteRooms)); SendMessage(new FigureSetIdsComposer(_habbo.GetClothing().GetClothingParts)); SendMessage(new UserRightsComposer(_habbo)); SendMessage(new AvailabilityStatusComposer()); SendMessage(new AchievementScoreComposer(_habbo.GetStats().AchievementPoints)); SendMessage(new BuildersClubMembershipComposer()); SendMessage(new CfhTopicsInitComposer(BiosEmuThiago.GetGame().GetModerationManager().UserActionPresets)); SendMessage(new BadgeDefinitionsComposer(BiosEmuThiago.GetGame().GetAchievementManager()._achievements)); SendMessage(new SoundSettingsComposer(_habbo.ClientVolume, _habbo.ChatPreference, _habbo.AllowMessengerInvites, _habbo.FocusPreference, FriendBarStateUtility.GetInt(_habbo.FriendbarState))); if (GetHabbo().GetMessenger() != null) { GetHabbo().GetMessenger().OnStatusChanged(true); } if (!string.IsNullOrEmpty(MachineId)) { if (_habbo.MachineId != MachineId) { using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `users` SET `machine_id` = @MachineId WHERE `id` = @id LIMIT 1"); dbClient.AddParameter("MachineId", MachineId); dbClient.AddParameter("id", _habbo.Id); dbClient.RunQuery(); } } _habbo.MachineId = MachineId; } if (BiosEmuThiago.GetGame().GetPermissionManager().TryGetGroup(_habbo.Rank, out PermissionGroup PermissionGroup)) { if (!String.IsNullOrEmpty(PermissionGroup.Badge)) { if (!_habbo.GetBadgeComponent().HasBadge(PermissionGroup.Badge)) { _habbo.GetBadgeComponent().GiveBadge(PermissionGroup.Badge, true, this); } } } if (!BiosEmuThiago.GetGame().GetCacheManager().ContainsUser(_habbo.Id)) { BiosEmuThiago.GetGame().GetCacheManager().GenerateUser(_habbo.Id); } _habbo.InitProcess(); if (userData.user.GetPermissions().HasRight("mod_tickets")) { SendMessage(new ModeratorInitComposer( BiosEmuThiago.GetGame().GetModerationManager().UserMessagePresets, BiosEmuThiago.GetGame().GetModerationManager().RoomMessagePresets, BiosEmuThiago.GetGame().GetModerationManager().GetTickets)); } if (BiosEmuThiago.GetGame().GetSettingsManager().TryGetValue("user.login.message.enabled") == "1") { SendMessage(new MOTDNotificationComposer(BiosEmuThiago.GetGame().GetLanguageManager().TryGetValue("user.login.message"))); } if (ExtraSettings.WELCOME_MESSAGE_ENABLED) { SendMessage(new MOTDNotificationComposer(ExtraSettings.WelcomeMessage.Replace("%username%", GetHabbo().Username))); } if (GetHabbo().Rank >= 3) { using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT * FROM `ranks` WHERE id = '" + GetHabbo().Rank + "'"); DataRow Table = dbClient.getRow(); if (GetHabbo().GetBadgeComponent().HasBadge(Convert.ToString(Table["badgeid"]))) { } else { GetHabbo().GetBadgeComponent().GiveBadge(Convert.ToString(Table["badgeid"]), true, GetHabbo().GetClient()); SendMessage(RoomNotificationComposer.SendBubble("badge/" + Table["badgeid"], "Você recebeu o emblema staff do seu rank!", "/inventory/open/badge")); } } } if (ExtraSettings.TARGETED_OFFERS_ENABLED) { if (BiosEmuThiago.GetGame().GetTargetedOffersManager().TargetedOffer != null) { BiosEmuThiago.GetGame().GetTargetedOffersManager().Initialize(BiosEmuThiago.GetDatabaseManager().GetQueryReactor()); TargetedOffers TargetedOffer = BiosEmuThiago.GetGame().GetTargetedOffersManager().TargetedOffer; if (TargetedOffer.Expire > BiosEmuThiago.GetIUnixTimestamp()) { if (TargetedOffer.Limit != GetHabbo()._TargetedBuy) { SendMessage(BiosEmuThiago.GetGame().GetTargetedOffersManager().TargetedOffer.Serialize()); } } else { using (var dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) dbClient.runFastQuery("UPDATE targeted_offers SET active = 'false'"); using (var dbClient2 = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) dbClient2.runFastQuery("UPDATE users SET targeted_buy = '0' WHERE targeted_buy > 0"); } } } // Fixe do Presentes do HC By Thiago Araujo //DateTime dateGregorians = new DateTime(); //dateGregorians = DateTime.Today; //int days = (dateGregorians.Day); //if (30 == days) //{ // SendMessage(new HCGiftsAlertComposer()); // SendMessage(new RoomNotificationComposer("sumando", "message", "Hoje é dia de presentes HC, pegue o seu antes que acabe!")); //} // Da a conquista de login por dia feito por Thiago Araujo string dFrank = null; using (var dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT Datahoje FROM users WHERE id = '" + userData.user.GetClient().GetHabbo().Id + "' LIMIT 1"); dFrank = dbClient.getString(); } int dFrankInt = Int32.Parse(dFrank); DateTime dateGregorian = new DateTime(); dateGregorian = DateTime.Today; int day = (dateGregorian.Day); if (dFrankInt != day) { using (var dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("UPDATE users SET Datahoje = '" + day + "' WHERE id = " + GetHabbo().Id + ";"); } BiosEmuThiago.GetGame().GetAchievementManager().ProgressAchievement(userData.user.GetClient(), "ACH_Login", 1); } if (ExtraSettings.STAFF_MENSG_ENTERTHIAGO) { using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT * FROM `ranks` WHERE id = '" + GetHabbo().Rank + "'"); DataRow Table = dbClient.getRow(); if (GetHabbo().Rank == 1) { // Thiago é muito lindo ser é doido } else { string figure = this.GetHabbo().Look; BiosEmuThiago.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("fig/" + figure, 3, "O " + Convert.ToString(Table["name"]) + " " + userData.user.GetClient().GetHabbo().Username + " entrou no hotel!", "")); } } if (GetHabbo().isMedal) { var nuxStatus = new ServerPacket(ServerPacketHeader.NuxUserStatus); nuxStatus.WriteInteger(2); SendMessage(nuxStatus); string thiagolindogostoso = this.GetHabbo().Look; BiosEmuThiago.GetGame().GetClientManager().StaffAlert(new RoomNotificationComposer("fig/" + thiagolindogostoso, 3, "Hey o usuário: " + GetHabbo().Username + " acaba de se registra no hotel.", "")); if (GetHabbo().isMedal) { string thiago = this.GetHabbo().Look; SendMessage(new RoomNotificationComposer("fig/" + thiago, 3, "Hey " + userData.user.GetClient().GetHabbo().Username + " Bem-vindo ao nosso hotel!", "")); } if (GetHabbo().isMedal == false) { string thiagolindo = this.GetHabbo().Look; SendMessage(new RoomNotificationComposer("fig/" + thiagolindo, 3, "Hey " + userData.user.GetClient().GetHabbo().Username + " Bem-vindo de volta ao nosso hotel!", "")); } } } if (GetHabbo().Rank > Convert.ToInt32(BiosEmuThiago.GetConfig().data["MineRankStaff"])) { using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("UPDATE users SET prefix_name = '' WHERE id = '" + GetHabbo().Id + "'"); dbClient.RunQuery("UPDATE users SET prefix_name_color = '' WHERE id = '" + GetHabbo().Id + "'"); } GetHabbo()._NamePrefixColor = ""; GetHabbo()._NamePrefix = ""; } if (GetHabbo().Rank > 0) { using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT * FROM `users` WHERE id = '" + GetHabbo().Id + "'"); DataRow Table = dbClient.getRow(); if (Convert.ToString(Table["LalaConf"]) == "0") { // Thiago é muito lindo ser é doido } else { BiosEmuThiago.GetGame().GetAchievementManager().ProgressAchievement(userData.user.GetClient(), "ACH_TraderPass", 1); BiosEmuThiago.GetGame().GetAchievementManager().ProgressAchievement(userData.user.GetClient(), "ACH_AvatarTags", 1); BiosEmuThiago.GetGame().GetAchievementManager().ProgressAchievement(userData.user.GetClient(), "ACH_EmailVerification", 1); } } } if (GetHabbo().isMedal) { if (ExtraSettings.WELCOME_NEW_MESSAGE_ENABLED) { ServerPacket notif = new ServerPacket(ServerPacketHeader.NuxAlertMessageComposer); notif.WriteString(ExtraSettings.WELCOME_MESSAGE_URL); SendMessage(notif); } using (var dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("UPDATE users SET isMedal = '0' WHERE id = " + GetHabbo().Id + ";"); } GetHabbo().isMedal = false; } BiosEmuThiago.GetGame().GetRewardManager().CheckRewards(this); BiosEmuThiago.GetGame().GetAchievementManager().TryProgressHabboClubAchievements(this); BiosEmuThiago.GetGame().GetAchievementManager().TryProgressRegistrationAchievements(this); BiosEmuThiago.GetGame().GetAchievementManager().TryProgressLoginAchievements(this); ICollection <MessengerBuddy> Friends = new List <MessengerBuddy>(); foreach (MessengerBuddy Buddy in GetHabbo().GetMessenger().GetFriends().ToList()) { if (Buddy == null) { continue; } GameClient Friend = BiosEmuThiago.GetGame().GetClientManager().GetClientByUserID(Buddy.Id); if (Friend == null) { continue; } string figure = GetHabbo().Look; Friend.SendMessage(new RoomNotificationComposer("fig/" + figure, 3, this.GetHabbo().Username + ", seu amigo acabou de entrar no hotel!", "")); } return(true); } } catch (Exception e) { ExceptionLogger.LogException(e); } return(false); }
public bool TryAuthenticate(string AuthTicket) { try { byte errorCode = 0; UserData userData = UserDataFactory.GetUserData(AuthTicket, out errorCode); if (errorCode == 1 || errorCode == 2) { Disconnect(); return(false); } #region Ban Checking ModerationBan BanRecord = null; if (!string.IsNullOrEmpty(MachineId)) { if (RocketEmulador.GetGame().GetModerationManager().IsBanned(MachineId, out BanRecord)) { if (RocketEmulador.GetGame().GetModerationManager().MachineBanCheck(MachineId)) { Disconnect(); return(false); } } } if (userData.user != null) { BanRecord = null; if (RocketEmulador.GetGame().GetModerationManager().IsBanned(userData.user.Username, out BanRecord)) { if (RocketEmulador.GetGame().GetModerationManager().UsernameBanCheck(userData.user.Username)) { Disconnect(); return(false); } } } #endregion RocketEmulador.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username); this._habbo = userData.user; bool flag8 = this._habbo != null; if (flag8) { userData.user.Init(this, userData); this.SendMessage(new AuthenticationOKComposer()); this.SendMessage(new AvatarEffectsComposer(this._habbo.Effects().GetAllEffects)); this.SendMessage(new NavigatorSettingsComposer(this._habbo.HomeRoom)); this.SendMessage(new FavouritesComposer(userData.user.FavoriteRooms)); this.SendMessage(new FigureSetIdsComposer(this._habbo.GetClothing().GetClothingAllParts)); this.SendMessage(new UserRightsComposer(this._habbo.Rank)); this.SendMessage(new AvailabilityStatusComposer()); this.SendMessage(new TalentTrackLevelComposer()); this.SendMessage(new TargetOfferMessageComposer()); this.SendMessage(new AchievementScoreComposer(this._habbo.GetStats().AchievementPoints)); ServerPacket serverPacket = new ServerPacket(879); serverPacket.WriteString("club_habbo"); serverPacket.WriteInteger(0); serverPacket.WriteInteger(0); serverPacket.WriteInteger(0); serverPacket.WriteInteger(2); serverPacket.WriteBoolean(false); serverPacket.WriteBoolean(false); serverPacket.WriteInteger(0); serverPacket.WriteInteger(0); serverPacket.WriteInteger(0); this.SendMessage(serverPacket); this.SendMessage(new BuildersClubMembershipComposer()); this.SendMessage(new CfhTopicsInitComposer()); this.SendMessage(new BadgeDefinitionsComposer(RocketEmulador.GetGame().GetAchievementManager()._achievements)); this.SendMessage(new SoundSettingsComposer(this._habbo.ClientVolume, this._habbo.ChatPreference, this._habbo.AllowMessengerInvites, this._habbo.FocusPreference, FriendBarStateUtility.GetInt(this._habbo.FriendbarState))); bool flag9 = this.GetHabbo().GetMessenger() != null; if (flag9) { this.GetHabbo().GetMessenger().OnStatusChanged(true); } bool flag10 = !string.IsNullOrEmpty(this.MachineId); if (flag10) { bool flag11 = this._habbo.MachineId != this.MachineId; if (flag11) { using (IQueryAdapter queryReactor = RocketEmulador.GetDatabaseManager().GetQueryReactor()) { queryReactor.SetQuery("UPDATE `users` SET `machine_id` = @MachineId WHERE `id` = @id LIMIT 1"); queryReactor.AddParameter("MachineId", this.MachineId); queryReactor.AddParameter("id", this._habbo.Id); queryReactor.RunQuery(); } } this._habbo.MachineId = this.MachineId; } PermissionGroup PermissionGroup = null; if (RocketEmulador.GetGame().GetPermissionManager().TryGetGroup(_habbo.Rank, out PermissionGroup)) { if (!String.IsNullOrEmpty(PermissionGroup.Badge)) { if (!_habbo.GetBadgeComponent().HasBadge(PermissionGroup.Badge)) { _habbo.GetBadgeComponent().GiveBadge(PermissionGroup.Badge, true, this); } } } SubscriptionData SubData = null; if (RocketEmulador.GetGame().GetSubscriptionManager().TryGetSubscriptionData(this._habbo.VIPRank, out SubData)) { if (!String.IsNullOrEmpty(SubData.Badge)) { if (!_habbo.GetBadgeComponent().HasBadge(SubData.Badge)) { _habbo.GetBadgeComponent().GiveBadge(SubData.Badge, true, this); } } } if (!RocketEmulador.GetGame().GetCacheManager().ContainsUser(_habbo.Id)) { RocketEmulador.GetGame().GetCacheManager().GenerateUser(_habbo.Id); } _habbo.InitProcess(); if (userData.user.GetPermissions().HasRight("mod_tickets")) { SendMessage(new ModeratorInitComposer( RocketEmulador.GetGame().GetModerationManager().UserMessagePresets, RocketEmulador.GetGame().GetModerationManager().RoomMessagePresets, RocketEmulador.GetGame().GetModerationManager().UserActionPresets, RocketEmulador.GetGame().GetModerationTool().GetTickets)); } { string hotelName = RocketEmulador.RocketData().data["hotelname"]; if (!string.IsNullOrWhiteSpace(RocketEmulador.GetDBConfig().DBData["welcome_message"])) { SendMessage(new MOTDNotificationComposer(RocketEmulador.GetDBConfig().DBData["welcome_message"])); } SendMessage(new RoomNotificationComposer("entrar", "message", "Bem-vindo" + " " + userData.user.GetClient().GetHabbo().Username + " " + "ao " + hotelName + "!")); if (GetHabbo().Rank == 10) { RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O PROGRAMADOR" + " " + userData.user.GetClient().GetHabbo().Username + " " + "entrou no " + hotelName + "!")); } if (GetHabbo().Rank == 9) { RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O CEO" + " " + userData.user.GetClient().GetHabbo().Username + " " + "entrou no " + hotelName + "!")); } if (GetHabbo().Rank == 8) { RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O GERENTE" + " " + userData.user.GetClient().GetHabbo().Username + " " + "entrou no " + hotelName + "!")); } if (GetHabbo().Rank == 7) { RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O ADM" + " " + userData.user.GetClient().GetHabbo().Username + " " + "entrou no " + hotelName + "!")); } if (GetHabbo().Rank == 6) { RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O MOD" + " " + userData.user.GetClient().GetHabbo().Username + " " + "entrou no " + hotelName + "!")); } if (GetHabbo().Rank == 5) { RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O PROMOTOR" + " " + userData.user.GetClient().GetHabbo().Username + " " + "entrou no " + hotelName + "!")); } if (GetHabbo().Rank == 4) { RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O EMB" + " " + userData.user.GetClient().GetHabbo().Username + " " + "entrou no " + hotelName + "!")); } if (GetHabbo().Rank == 3) { RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O VIP" + " " + userData.user.GetClient().GetHabbo().Username + " " + "entrou no " + hotelName + "!")); } if (GetHabbo().Rank == 2) { RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O LOCUTOR" + " " + userData.user.GetClient().GetHabbo().Username + " " + "entrou no " + hotelName + "!")); } Console.WriteLine("Um novo usuário se conectou seu nick é: " + userData.user.GetClient().GetHabbo().Username + " e seu ip: " + userData.user.GetClient().GetConnection().getIp(), "Rocket.Users", ConsoleColor.DarkGreen); } } } catch (Exception e) { Logging.LogCriticalException("Bug during user login: " + e); } return(false); }
/// <summary> /// Tries the login. /// </summary> /// <param name="authTicket">The authentication ticket.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> internal bool TryLogin(string authTicket) { try { string ip = GetConnection().getIp(); uint errorCode = 0; UserData userData = UserDataFactory.GetUserData(authTicket, out errorCode); if (errorCode == 1 || errorCode == 2) { Disconnect("error"); return(false); } #region Ban Checking //Let's have a quick search for a ban before we successfully authenticate.. ModerationBan BanRecord; if (!string.IsNullOrEmpty(MachineId)) { if (Plus.GetGame().GetBanManager().IsBanned(MachineId, out BanRecord)) { if (Plus.GetGame().GetBanManager().MachineBanCheck(MachineId)) { Disconnect("machine banned - login attempt"); return(false); } } } if (userData.User != null) { //Now let us check for a username ban record.. BanRecord = null; if (Plus.GetGame().GetBanManager().IsBanned(userData.User.UserName, out BanRecord)) { if (Plus.GetGame().GetBanManager().UsernameBanCheck(userData.User.UserName)) { Disconnect("banned - login attempt"); return(false); } } } #endregion Plus.GetGame().GetClientManager().RegisterClient(this, userData.UserId, userData.User.UserName); _habbo = userData.User; if (_habbo != null) { userData.User.LoadData(userData); using (Database.Manager.Database.Session_Details.Interfaces.IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT * FROM `rp_stats` WHERE `id` = '" + userData.UserId + "'"); DataRow Row = dbClient.GetRow(); RoleplayInstance RPData = CreateRoleplayInstance.GenerateInstance(Row); _roleplay = RPData; _roleplay.setRoleplayComponents(); } userData.User.Init(this, userData); var queuedServerMessage = new QueuedServerMessage(_connection); var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("UniqueMachineIDMessageComposer")); serverMessage.AppendString(MachineId); queuedServerMessage.AppendResponse(serverMessage); queuedServerMessage.AppendResponse( new ServerMessage(LibraryParser.OutgoingRequest("AuthenticationOKMessageComposer"))); if (_habbo != null) { var serverMessage2 = new ServerMessage(LibraryParser.OutgoingRequest("HomeRoomMessageComposer")); serverMessage2.AppendInteger(_habbo.HomeRoom); serverMessage2.AppendInteger(_habbo.HomeRoom); queuedServerMessage.AppendResponse(serverMessage2); } serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("MinimailCountMessageComposer")); serverMessage.AppendInteger(_habbo.MinimailUnreadMessages); queuedServerMessage.AppendResponse(serverMessage); serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("FavouriteRoomsMessageComposer")); serverMessage.AppendInteger(30); if (userData.User.FavoriteRooms == null || !userData.User.FavoriteRooms.Any()) { serverMessage.AppendInteger(0); } else { serverMessage.AppendInteger(userData.User.FavoriteRooms.Count); foreach (uint i in userData.User.FavoriteRooms) { serverMessage.AppendInteger(i); } } queuedServerMessage.AppendResponse(serverMessage); var rightsMessage = new ServerMessage(LibraryParser.OutgoingRequest("UserClubRightsMessageComposer")); rightsMessage.AppendInteger(userData.User.GetSubscriptionManager().HasSubscription ? 2 : 0); rightsMessage.AppendInteger(userData.User.Rank); rightsMessage.AppendInteger(0); queuedServerMessage.AppendResponse(rightsMessage); serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("EnableNotificationsMessageComposer")); serverMessage.AppendBool(true); //isOpen serverMessage.AppendBool(false); queuedServerMessage.AppendResponse(serverMessage); serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("EnableTradingMessageComposer")); serverMessage.AppendBool(true); queuedServerMessage.AppendResponse(serverMessage); userData.User.UpdateCreditsBalance(); serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ActivityPointsMessageComposer")); serverMessage.AppendInteger(2); serverMessage.AppendInteger(0); serverMessage.AppendInteger(userData.User.ActivityPoints); serverMessage.AppendInteger(5); serverMessage.AppendInteger(userData.User.BelCredits); queuedServerMessage.AppendResponse(serverMessage); if (userData.User.HasFuse("fuse_mod")) { queuedServerMessage.AppendResponse(Plus.GetGame().GetModerationTool().SerializeTool(this)); } queuedServerMessage.AppendResponse( Plus.GetGame().GetAchievementManager().AchievementDataCached); if (!GetHabbo().NuxPassed&& ExtraSettings.NEW_users_gifts_ENABLED) { queuedServerMessage.AppendResponse( new ServerMessage(LibraryParser.OutgoingRequest("NuxSuggestFreeGiftsMessageComposer"))); } queuedServerMessage.AppendResponse(GetHabbo().GetAvatarEffectsInventoryComponent().GetPacket()); queuedServerMessage.SendResponse(); Plus.GetGame().GetAchievementManager().TryProgressHabboClubAchievements(this); Plus.GetGame().GetAchievementManager().TryProgressRegistrationAchievements(this); Plus.GetGame().GetAchievementManager().TryProgressLoginAchievements(this); return(true); } } catch (Exception e) { Logging.LogCriticalException("Bug during user login: " + e); } return(false); }
internal bool tryLogin(string AuthTicket) { try { string ip = GetConnection().getIp(); byte errorCode = 0; UserData userData = UserDataFactory.GetUserData(AuthTicket, ip, out errorCode); if (errorCode == 1) { SendNotifWithScroll(LanguageLocale.GetValue("login.invalidsso")); return(false); } else if (errorCode == 2) { SendNotifWithScroll(LanguageLocale.GetValue("login.loggedin")); return(false); } if (Program.LicHandeler != null && ButterflyEnvironment.GetGame().GetClientManager().ClientCount > Program.LicHandeler.AmountOfSlots) { Program.LicHandeler.ReportFullServer(); SendBanMessage(LanguageLocale.GetValue("server.full")); return(false); } ButterflyEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username); this.Habbo = userData.user; userData.user.LoadData(userData); if (userData.user.Username == null) { SendBanMessage("You have no username."); return(false); } string banReason = ButterflyEnvironment.GetGame().GetBanManager().GetBanReason(userData.user.Username, ip); if (!string.IsNullOrEmpty(banReason)) { SendBanMessage(banReason); return(false); } userData.user.Init(this, userData); QueuedServerMessage response = new QueuedServerMessage(Connection); userData.user.SerializeQuests(ref response); List <string> Rights = ButterflyEnvironment.GetGame().GetRoleManager().GetRightsForHabbo(userData.user); ServerMessage appendingResponse = new ServerMessage(2); appendingResponse.Init(2); appendingResponse.AppendInt32(Rights.Count); foreach (string Right in Rights) { appendingResponse.AppendStringWithBreak(Right); } response.appendResponse(appendingResponse); if (userData.user.HasFuse("fuse_mod")) { response.appendResponse(ButterflyEnvironment.GetGame().GetModerationTool().SerializeTool()); ButterflyEnvironment.GetGame().GetModerationTool().SerializeOpenTickets(ref response, userData.userID); } response.appendResponse(userData.user.GetAvatarEffectsInventoryComponent().Serialize()); appendingResponse.Init(290); appendingResponse.AppendBoolean(true); appendingResponse.AppendBoolean(false); response.appendResponse(appendingResponse); appendingResponse.Init(3); response.appendResponse(appendingResponse); appendingResponse.Init(517); appendingResponse.AppendBoolean(true); response.appendResponse(appendingResponse); //if (PixelManager.NeedsUpdate(this)) // PixelManager.GivePixels(this); if (ButterflyEnvironment.GetGame().GetClientManager().pixelsOnLogin > 0) { PixelManager.GivePixels(this, ButterflyEnvironment.GetGame().GetClientManager().pixelsOnLogin); } if (ButterflyEnvironment.GetGame().GetClientManager().creditsOnLogin > 0) { userData.user.Credits += ButterflyEnvironment.GetGame().GetClientManager().creditsOnLogin; userData.user.UpdateCreditsBalance(); } if (userData.user.HomeRoom > 0) { appendingResponse.Init(455); appendingResponse.AppendUInt(userData.user.HomeRoom); response.appendResponse(appendingResponse); } appendingResponse.Init(458); appendingResponse.AppendInt32(30); appendingResponse.AppendInt32(userData.user.FavoriteRooms.Count); foreach (uint Id in userData.user.FavoriteRooms.ToArray()) { appendingResponse.AppendUInt(Id); } response.appendResponse(appendingResponse); if (userData.user.HasFuse("fuse_use_club_badge") && !userData.user.GetBadgeComponent().HasBadge("ACH_BasicClub1")) { userData.user.GetBadgeComponent().GiveBadge("ACH_BasicClub1", true); } else if (!userData.user.HasFuse("fuse_use_club_badge") && userData.user.GetBadgeComponent().HasBadge("ACH_BasicClub1")) { userData.user.GetBadgeComponent().RemoveBadge("ACH_BasicClub1"); } if (!userData.user.GetBadgeComponent().HasBadge("Z63")) { userData.user.GetBadgeComponent().GiveBadge("Z63", true); } appendingResponse.Init(2); appendingResponse.AppendInt32(0); if (userData.user.HasFuse("fuse_use_vip_outfits")) // VIP { appendingResponse.AppendInt32(2); } else if (userData.user.HasFuse("fuse_furni_chooser")) // HC { appendingResponse.AppendInt32(1); } else { appendingResponse.AppendInt32(0); } appendingResponse.AppendInt32(0); response.appendResponse(appendingResponse); appendingResponse.Init(2); appendingResponse.AppendInt32(Rights.Count); foreach (string Right in Rights) { appendingResponse.AppendStringWithBreak(Right); } response.appendResponse(appendingResponse); if (LanguageLocale.welcomeAlertEnabled) { ServerMessage alert = new ServerMessage(810); alert.AppendUInt(1); alert.AppendStringWithBreak(LanguageLocale.welcomeAlert); response.appendResponse(alert); } response.sendResponse(); Logging.WriteLine("[" + Habbo.Username + "] logged in"); return(true); } catch (UserDataNotFoundException e) { SendNotifWithScroll(LanguageLocale.GetValue("login.invalidsso") + "extra data: " + e.ToString()); } catch (Exception e) { //Logging.LogCriticalException("Invalid Dario bug duing user login: "******"Login error: " + e.ToString()); SendNotifWithScroll("Login error: " + e.ToString()); } return(false); }
internal static Habbo CreateHabbo(string username) { UserDataFactory userdata = new UserDataFactory(username, false); return(Authenticator.CreateHabbo(userdata.GetUserData(), "", null, userdata)); }
internal bool tryLogin(string AuthTicket) { int loginProgress = 0; try { string ip = GetConnection().getIp(); byte errorCode = 0; UserData userData = UserDataFactory.GetUserData(AuthTicket, ip, out errorCode); if (errorCode == 1) { SendNotifWithScroll(LanguageLocale.GetValue("login.invalidsso")); return(false); } else if (errorCode == 2) { SendNotifWithScroll(LanguageLocale.GetValue("login.loggedin")); return(false); } loginProgress++; FirewindEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username); this.Habbo = userData.user; userData.user.LoadData(userData); loginProgress++; if (userData.user.Username == null) { SendBanMessage("You have no username."); return(false); } string banReason = FirewindEnvironment.GetGame().GetBanManager().GetBanReason(userData.user.Username, ip); loginProgress++; if (!string.IsNullOrEmpty(banReason)) { SendBanMessage(banReason); return(false); } userData.user.Init(this, userData); QueuedServerMessage response = new QueuedServerMessage(Connection); ServerMessage UniqueId = new ServerMessage(Outgoing.UniqueID); UniqueId.AppendString(this.MachineId); response.appendResponse(UniqueId); ServerMessage authok = new ServerMessage(Outgoing.AuthenticationOK); response.appendResponse(authok); ServerMessage HomeRoom = new ServerMessage(Outgoing.HomeRoom); HomeRoom.AppendUInt(this.GetHabbo().HomeRoom); // first home HomeRoom.AppendUInt(this.GetHabbo().HomeRoom); // first home SendMessage(HomeRoom); loginProgress++; ServerMessage FavouriteRooms = new ServerMessage(Outgoing.FavouriteRooms); FavouriteRooms.AppendInt32(30); // max rooms FavouriteRooms.AppendInt32(userData.user.FavoriteRooms.Count); foreach (uint Id in userData.user.FavoriteRooms.ToArray()) { FavouriteRooms.AppendUInt(Id); } response.appendResponse(FavouriteRooms); loginProgress++; ServerMessage fuserights = new ServerMessage(Outgoing.Fuserights); if (GetHabbo().GetSubscriptionManager().HasSubscription("habbo_vip")) // VIP { fuserights.AppendInt32(2); } else if (GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club")) // HC { fuserights.AppendInt32(1); } else { fuserights.AppendInt32(0); } fuserights.AppendUInt(this.GetHabbo().Rank); response.appendResponse(fuserights); loginProgress++; ServerMessage bools1 = new ServerMessage(Outgoing.AvailabilityStatus); bools1.AppendBoolean(true); bools1.AppendBoolean(false); response.appendResponse(bools1); ServerMessage bools2 = new ServerMessage(Outgoing.InfoFeedEnable); bools2.AppendBoolean(false); response.appendResponse(bools2); loginProgress++; ServerMessage setRanking = new ServerMessage(Outgoing.SerializeCompetitionWinners); setRanking.AppendString("hlatCompetitions"); // competition type setRanking.AppendInt32(Ranking.getCompetitionForInfo("hlatCompetitions").Count); loginProgress++; int i = 0; foreach (Ranking r in Ranking.getCompetitionForInfo("hlatCompetitions")) { i++; setRanking.AppendUInt(r.UserId); Habbo data = FirewindEnvironment.getHabboForId(r.UserId); setRanking.AppendString((data != null) ? data.Username : "******"); setRanking.AppendString((data != null) ? data.Look : "sh-907-96.hd-3096-3.he-3082-91.lg-3018-81.ch-660-95.hr-9534-34"); setRanking.AppendInt32(i); // position setRanking.AppendInt32(r.Score); } response.appendResponse(setRanking); loginProgress++; if (userData.user.HasFuse("fuse_mod")) { this.SendMessage(FirewindEnvironment.GetGame().GetModerationTool().SerializeTool()); FirewindEnvironment.GetGame().GetModerationTool().SerializeOpenTickets(ref response, userData.userID); } if (LanguageLocale.welcomeAlertEnabled) { this.SendMOTD(LanguageLocale.welcomeAlert); } loginProgress++; using (IQueryAdapter db = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { db.setQuery("UPDATE users SET online = '1' WHERE id = @id"); db.addParameter("id", this.GetHabbo().Id); db.runQuery(); } loginProgress++; // Send the big chunk response.sendResponse(); // fire the event! FirewindEnvironment.GetGame().GetClientManager().ClientLoggedIn(this); return(true); } catch (UserDataNotFoundException e) { SendNotifWithScroll(LanguageLocale.GetValue("login.invalidsso") + "extra data: " + e.ToString()); } catch (Exception e) { Logging.LogCriticalException(String.Format("Invalid Dario bug duing user login (progress = {0}): ", loginProgress) + e.ToString()); SendNotifWithScroll("Login error: " + e.ToString()); } return(false); }
internal static Habbo CreateHabbo(string ssoTicket, GameClient Session, UserDataFactory userData, UserDataFactory otherData) { return(Authenticator.CreateHabbo(userData.GetUserData(), ssoTicket, Session, otherData)); }
public bool TryAuthenticate(string authTicket) { try { UserData userData = UserDataFactory.GetUserData(authTicket, out byte errorCode); if (errorCode == 1 || errorCode == 2) { Disconnect(); return(false); } #region Ban Checking //Let's have a quick search for a ban before we successfully authenticate.. if (!string.IsNullOrEmpty(MachineId)) { if (PlusEnvironment.GetGame().GetModerationManager().IsBanned(MachineId, out _)) { if (PlusEnvironment.GetGame().GetModerationManager().MachineBanCheck(MachineId)) { Disconnect(); return(false); } } } if (userData.user != null) { if (PlusEnvironment.GetGame().GetModerationManager().IsBanned(userData.user.Username, out _)) { if (PlusEnvironment.GetGame().GetModerationManager().UsernameBanCheck(userData.user.Username)) { Disconnect(); return(false); } } } #endregion if (userData.user == null) //Possible NPE { return(false); } PlusEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.UserId, userData.user.Username); _habbo = userData.user; if (_habbo != null) { userData.user.Init(this, userData); SendPacket(new AuthenticationOKComposer()); SendPacket(new AvatarEffectsComposer(_habbo.Effects().GetAllEffects)); SendPacket(new NavigatorSettingsComposer(_habbo.HomeRoom)); SendPacket(new FavouritesComposer(userData.user.FavoriteRooms)); SendPacket(new FigureSetIdsComposer(_habbo.GetClothing().GetClothingParts)); SendPacket(new UserRightsComposer(_habbo.Rank)); SendPacket(new AvailabilityStatusComposer()); SendPacket(new AchievementScoreComposer(_habbo.GetStats().AchievementPoints)); SendPacket(new BuildersClubMembershipComposer()); SendPacket(new CfhTopicsInitComposer(PlusEnvironment.GetGame().GetModerationManager().UserActionPresets)); SendPacket(new BadgeDefinitionsComposer(PlusEnvironment.GetGame().GetAchievementManager().Achievements)); SendPacket(new SoundSettingsComposer(_habbo.ClientVolume, _habbo.ChatPreference, _habbo.AllowMessengerInvites, _habbo.FocusPreference, FriendBarStateUtility.GetInt(_habbo.FriendbarState))); //SendMessage(new TalentTrackLevelComposer()); if (GetHabbo().GetMessenger() != null) { GetHabbo().GetMessenger().OnStatusChanged(true); } if (!string.IsNullOrEmpty(MachineId)) { if (_habbo.MachineId != MachineId) { using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `users` SET `machine_id` = @MachineId WHERE `id` = @id LIMIT 1"); dbClient.AddParameter("MachineId", MachineId); dbClient.AddParameter("id", _habbo.Id); dbClient.RunQuery(); } } _habbo.MachineId = MachineId; } if (PlusEnvironment.GetGame().GetPermissionManager().TryGetGroup(_habbo.Rank, out PermissionGroup group)) { if (!String.IsNullOrEmpty(group.Badge)) { if (!_habbo.GetBadgeComponent().HasBadge(group.Badge)) { _habbo.GetBadgeComponent().GiveBadge(group.Badge, true, this); } } } if (PlusEnvironment.GetGame().GetSubscriptionManager().TryGetSubscriptionData(_habbo.VIPRank, out SubscriptionData subData)) { if (!String.IsNullOrEmpty(subData.Badge)) { if (!_habbo.GetBadgeComponent().HasBadge(subData.Badge)) { _habbo.GetBadgeComponent().GiveBadge(subData.Badge, true, this); } } } if (!PlusEnvironment.GetGame().GetCacheManager().ContainsUser(_habbo.Id)) { PlusEnvironment.GetGame().GetCacheManager().GenerateUser(_habbo.Id); } _habbo.Look = PlusEnvironment.GetFigureManager().ProcessFigure(_habbo.Look, _habbo.Gender, _habbo.GetClothing().GetClothingParts, true); _habbo.InitProcess(); if (userData.user.GetPermissions().HasRight("mod_tickets")) { SendPacket(new ModeratorInitComposer( PlusEnvironment.GetGame().GetModerationManager().UserMessagePresets, PlusEnvironment.GetGame().GetModerationManager().RoomMessagePresets, PlusEnvironment.GetGame().GetModerationManager().GetTickets)); } if (PlusEnvironment.GetSettingsManager().TryGetValue("user.login.message.enabled") == "1") { SendPacket(new MotdNotificationComposer(PlusEnvironment.GetLanguageManager().TryGetValue("user.login.message"))); } PlusEnvironment.GetGame().GetRewardManager().CheckRewards(this); return(true); } } catch (Exception e) { ExceptionLogger.LogException(e); } return(false); }
internal bool tryLogin(string AuthTicket) { try { string ip = GetConnection().getIp(); byte errorCode = 0; UserData userData = UserDataFactory.GetUserData(AuthTicket, ip, out errorCode); if (errorCode == 1) { SendNotifWithScroll(LanguageLocale.GetValue("login.invalidsso")); return(false); } else if (errorCode == 2) { SendNotifWithScroll(LanguageLocale.GetValue("login.loggedin")); return(false); } PiciEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username); this.Habbo = userData.user; userData.user.LoadData(userData); if (userData.user.Username == null) { SendBanMessage("You have no username."); return(false); } string banReason = PiciEnvironment.GetGame().GetBanManager().GetBanReason(userData.user.Username, ip); if (!string.IsNullOrEmpty(banReason)) { SendBanMessage(banReason); return(false); } userData.user.Init(this, userData); QueuedServerMessage response = new QueuedServerMessage(Connection); userData.user.SerializeQuests(ref response); GetMessageHandler().GetResponse().Init(2); if (userData.user.HasRight("acc_anyroomowner")) { GetMessageHandler().GetResponse().AppendInt32(7); } else if (userData.user.HasRight("acc_anyroomrights")) { GetMessageHandler().GetResponse().AppendInt32(5); } else if (userData.user.HasRight("acc_supporttool")) { GetMessageHandler().GetResponse().AppendInt32(4); } else if (GetHabbo().GetSubscriptionManager().HasSubscription("habbo_vip")) { GetMessageHandler().GetResponse().AppendInt32(2); } else if (GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club")) { GetMessageHandler().GetResponse().AppendInt32(1); } else { GetMessageHandler().GetResponse().AppendInt32(0); } GetMessageHandler().SendResponse(); if (userData.user.HasRight("acc_supporttool")) { SendMessage(PiciEnvironment.GetGame().GetModerationTool().SerializeTool()); PiciEnvironment.GetGame().GetModerationTool().SerializeOpenTickets(this); } SendMessage(userData.user.GetAvatarEffectsInventoryComponent().Serialize()); GetMessageHandler().GetResponse().Init(290); GetMessageHandler().GetResponse().AppendBoolean(true); GetMessageHandler().GetResponse().AppendBoolean(false); GetMessageHandler().SendResponse(); GetMessageHandler().GetResponse().Init(3); GetMessageHandler().SendResponse(); GetMessageHandler().GetResponse().Init(517); GetMessageHandler().GetResponse().AppendBoolean(true); GetMessageHandler().SendResponse(); //if (PixelManager.NeedsUpdate(this)) // PixelManager.GivePixels(this); if (PiciEnvironment.GetGame().GetClientManager().pixelsOnLogin > 0) { PixelManager.GivePixels(this, PiciEnvironment.GetGame().GetClientManager().pixelsOnLogin); } if (PiciEnvironment.GetGame().GetClientManager().creditsOnLogin > 0) { userData.user.Credits += PiciEnvironment.GetGame().GetClientManager().creditsOnLogin; userData.user.UpdateCreditsBalance(); } if (userData.user.HomeRoom > 0) { GetMessageHandler().GetResponse().Init(455); GetMessageHandler().GetResponse().AppendUInt(userData.user.HomeRoom); GetMessageHandler().SendResponse(); } GetMessageHandler().GetResponse().Init(458); GetMessageHandler().GetResponse().AppendInt32(30); GetMessageHandler().GetResponse().AppendInt32(userData.user.FavoriteRooms.Count); foreach (uint Id in userData.user.FavoriteRooms.ToArray()) { GetMessageHandler().GetResponse().AppendUInt(Id); } GetMessageHandler().SendResponse(); if (!userData.user.GetBadgeComponent().HasBadge("ACH_BasicClub1")) { userData.user.GetBadgeComponent().GiveBadge("ACH_BasicClub1", true); } else if (userData.user.GetBadgeComponent().HasBadge("ACH_BasicClub1")) { userData.user.GetBadgeComponent().RemoveBadge("ACH_BasicClub1"); } if (!userData.user.GetBadgeComponent().HasBadge("Z63")) { userData.user.GetBadgeComponent().GiveBadge("Z63", true); } if (userData.user.Rank > 5 && !userData.user.GetBadgeComponent().HasBadge("ADM")) { userData.user.GetBadgeComponent().GiveBadge("ADM", true); } ServerMessage alert = new ServerMessage(810); alert.AppendUInt(1); alert.AppendStringWithBreak(LanguageLocale.welcomeAlert); SendMessage(alert); Logging.WriteLine("[" + Habbo.Username + "] logged in"); return(true); } catch (UserDataNotFoundException e) { SendNotifWithScroll(LanguageLocale.GetValue("login.invalidsso") + "extra data: " + e.ToString()); } catch (Exception e) { Logging.LogCriticalException("Invalid Dario bug duing user login: "******"Login error: " + e.ToString()); SendNotifWithScroll("Login error: " + e.ToString()); } return(false); }
public bool TryAuthenticate(string AuthTicket) { try { UserData userData = UserDataFactory.GetUserData(AuthTicket, out byte errorCode); if (errorCode == 1 || errorCode == 2) { Disconnect(); return(false); } #region Ban Checking //Let's have a quick search for a ban before we successfully authenticate.. ModerationBan BanRecord = null; if (!string.IsNullOrEmpty(MachineId)) { if (CloudServer.GetGame().GetModerationManager().IsBanned(MachineId, out BanRecord)) { if (CloudServer.GetGame().GetModerationManager().MachineBanCheck(MachineId)) { Disconnect(); return(false); } } } if (userData.user != null) { //Now let us check for a username ban record.. BanRecord = null; if (CloudServer.GetGame().GetModerationManager().IsBanned(userData.user.Username, out BanRecord)) { if (CloudServer.GetGame().GetModerationManager().UsernameBanCheck(userData.user.Username)) { Disconnect(); return(false); } } } #endregion CloudServer.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username); _habbo = userData.user; _habbo.ssoTicket = AuthTicket; if (_habbo != null) { userData.user.Init(this, userData); SendMessage(new AuthenticationOKComposer()); SendMessage(new AvatarEffectsComposer(_habbo.Effects().GetAllEffects)); SendMessage(new NavigatorSettingsComposer(_habbo.HomeRoom)); SendMessage(new FavouritesComposer(userData.user.FavoriteRooms)); SendMessage(new FigureSetIdsComposer(_habbo.GetClothing().GetClothingParts)); SendMessage(new UserRightsComposer(_habbo)); SendMessage(new AvailabilityStatusComposer()); SendMessage(new AchievementScoreComposer(_habbo.GetStats().AchievementPoints)); SendMessage(new BuildersClubMembershipComposer()); SendMessage(new CfhTopicsInitComposer(CloudServer.GetGame().GetModerationManager().UserActionPresets)); SendMessage(new BadgeDefinitionsComposer(CloudServer.GetGame().GetAchievementManager()._achievements)); SendMessage(new SoundSettingsComposer(_habbo.ClientVolume, _habbo.ChatPreference, _habbo.AllowMessengerInvites, _habbo.FocusPreference, FriendBarStateUtility.GetInt(_habbo.FriendbarState))); if (GetHabbo().GetMessenger() != null) { GetHabbo().GetMessenger().OnStatusChanged(true); } if (!string.IsNullOrEmpty(MachineId)) { if (_habbo.MachineId != MachineId) { using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `users` SET `machine_id` = @MachineId WHERE `id` = @id LIMIT 1"); dbClient.AddParameter("MachineId", MachineId); dbClient.AddParameter("id", _habbo.Id); dbClient.RunQuery(); } } _habbo.MachineId = MachineId; } if (CloudServer.GetGame().GetPermissionManager().TryGetGroup(_habbo.Rank, out PermissionGroup PermissionGroup)) { if (!String.IsNullOrEmpty(PermissionGroup.Badge)) { if (!_habbo.GetBadgeComponent().HasBadge(PermissionGroup.Badge)) { _habbo.GetBadgeComponent().GiveBadge(PermissionGroup.Badge, true, this); } } } if (!CloudServer.GetGame().GetCacheManager().ContainsUser(_habbo.Id)) { CloudServer.GetGame().GetCacheManager().GenerateUser(_habbo.Id); } _habbo.InitProcess(); if (userData.user.GetPermissions().HasRight("mod_tickets")) { SendMessage(new ModeratorInitComposer( CloudServer.GetGame().GetModerationManager().UserMessagePresets, CloudServer.GetGame().GetModerationManager().RoomMessagePresets, CloudServer.GetGame().GetModerationManager().GetTickets)); } if (CloudServer.GetGame().GetSettingsManager().TryGetValue("user.login.message.enabled") == "1") { SendMessage(new MOTDNotificationComposer(CloudServer.GetGame().GetLanguageManager().TryGetValue("user.login.message"))); } if (ExtraSettings.WELCOME_MESSAGE_ENABLED) { SendMessage(new MOTDNotificationComposer(ExtraSettings.WelcomeMessage.Replace("%username%", GetHabbo().Username))); } if (ExtraSettings.TARGETED_OFFERS_ENABLED) { if (CloudServer.GetGame().GetTargetedOffersManager().TargetedOffer != null) { CloudServer.GetGame().GetTargetedOffersManager().Initialize(CloudServer.GetDatabaseManager().GetQueryReactor()); TargetedOffers TargetedOffer = CloudServer.GetGame().GetTargetedOffersManager().TargetedOffer; if (TargetedOffer.Expire > CloudServer.GetIUnixTimestamp()) { if (TargetedOffer.Limit != GetHabbo()._TargetedBuy) { SendMessage(CloudServer.GetGame().GetTargetedOffersManager().TargetedOffer.Serialize()); } } else { using (var dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) dbClient.runFastQuery("UPDATE targeted_offers SET active = 'false'"); using (var dbClient2 = CloudServer.GetDatabaseManager().GetQueryReactor()) dbClient2.runFastQuery("UPDATE users SET targeted_buy = '0' WHERE targeted_buy > 0"); } } } //SendMessage(new HCGiftsAlertComposer()); /*var nuxStatuss = new ServerPacket(ServerPacketHeader.NuxSuggestFreeGiftsMessageComposer); * SendMessage(nuxStatuss);*/ CloudServer.GetGame().GetRewardManager().CheckRewards(this); CloudServer.GetGame().GetAchievementManager().TryProgressHabboClubAchievements(this); CloudServer.GetGame().GetAchievementManager().TryProgressRegistrationAchievements(this); CloudServer.GetGame().GetAchievementManager().TryProgressLoginAchievements(this); ICollection <MessengerBuddy> Friends = new List <MessengerBuddy>(); foreach (MessengerBuddy Buddy in GetHabbo().GetMessenger().GetFriends().ToList()) { if (Buddy == null) { continue; } GameClient Friend = CloudServer.GetGame().GetClientManager().GetClientByUserID(Buddy.Id); if (Friend == null) { continue; } string figure = GetHabbo().Look; } return(true); } } catch (Exception e) { ExceptionLogger.LogException(e); } return(false); }
internal bool tryLogin(string AuthTicket) { try { string ip = this.GetConnection().getIp(); byte b = 0; UserData userData = UserDataFactory.GetUserData(AuthTicket, ip, out b); bool result; if (b == 1) { result = false; return(result); } if (b == 2) { result = false; return(result); } CyberEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username); this.Habbo = userData.user; userData.user.LoadData(userData); string banReason = CyberEnvironment.GetGame().GetBanManager().GetBanReason(userData.user.Username, ip, this.MachineId); if (!string.IsNullOrEmpty(banReason) || userData.user.Username == null) { this.SendNotifWithScroll(banReason); using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor()) { queryreactor.setQuery("SELECT ip_last FROM users WHERE id=" + this.GetHabbo().Id + " LIMIT 1"); string @string = queryreactor.getString(); queryreactor.setQuery("SELECT COUNT(0) FROM bans_access WHERE user_id=" + this.Habbo.Id + " LIMIT 1"); int integer = queryreactor.getInteger(); if (integer > 0) { queryreactor.runFastQuery(string.Concat(new object[] { "UPDATE bans_access SET attempts = attempts + 1, ip='", @string, "' WHERE user_id=", this.GetHabbo().Id, " LIMIT 1" })); } else { queryreactor.runFastQuery(string.Concat(new object[] { "INSERT INTO bans_access (user_id, ip) VALUES (", this.GetHabbo().Id, ", '", @string, "')" })); } } result = false; return(result); } userData.user.Init(this, userData); QueuedServerMessage queuedServerMessage = new QueuedServerMessage(this.Connection); ServerMessage serverMessage = new ServerMessage(Outgoing.UniqueMachineIDMessageComposer); serverMessage.AppendString(this.MachineId); queuedServerMessage.appendResponse(serverMessage); queuedServerMessage.appendResponse(new ServerMessage(Outgoing.AuthenticationOKMessageComposer)); if (this.Habbo != null) { ServerMessage serverMessage2 = new ServerMessage(Outgoing.HomeRoomMessageComposer); serverMessage2.AppendUInt(this.Habbo.HomeRoom); serverMessage2.AppendUInt(this.Habbo.HomeRoom); queuedServerMessage.appendResponse(serverMessage2); } ServerMessage serverMessage3 = new ServerMessage(Outgoing.MinimailCountMessageComposer); serverMessage3.AppendInt32(this.Habbo.MinimailUnreadMessages); queuedServerMessage.appendResponse(serverMessage3); ServerMessage serverMessage4 = new ServerMessage(Outgoing.FavouriteRoomsMessageComposer); serverMessage4.AppendInt32(30); serverMessage4.AppendInt32(userData.user.FavoriteRooms.Count); object[] array = userData.user.FavoriteRooms.ToArray(); for (int i = 0; i < array.Length; i++) { uint i2 = (uint)array[i]; serverMessage4.AppendUInt(i2); } queuedServerMessage.appendResponse(serverMessage4); ServerMessage rightsMessage = new ServerMessage(Outgoing.UserClubRightsMessageComposer); rightsMessage.AppendInt32(userData.user.GetSubscriptionManager().HasSubscription ? 2 : 0); rightsMessage.AppendUInt(userData.user.Rank); rightsMessage.AppendInt32(0); queuedServerMessage.appendResponse(rightsMessage); ServerMessage serverMessage5 = new ServerMessage(Outgoing.EnableNotificationsMessageComposer); serverMessage5.AppendBoolean(true); serverMessage5.AppendBoolean(false); queuedServerMessage.appendResponse(serverMessage5); ServerMessage serverMessage6 = new ServerMessage(Outgoing.EnableTradingMessageComposer); serverMessage6.AppendBoolean(true); queuedServerMessage.appendResponse(serverMessage6); userData.user.UpdateCreditsBalance(); ServerMessage serverMessage7 = new ServerMessage(Outgoing.ActivityPointsMessageComposer); serverMessage7.AppendInt32(2); serverMessage7.AppendInt32(0); serverMessage7.AppendInt32(userData.user.ActivityPoints); serverMessage7.AppendInt32(5); serverMessage7.AppendInt32(userData.user.BelCredits); queuedServerMessage.appendResponse(serverMessage7); if (userData.user.HasFuse("fuse_mod")) { queuedServerMessage.appendResponse(CyberEnvironment.GetGame().GetModerationTool().SerializeTool()); } if (!string.IsNullOrWhiteSpace(CyberEnvironment.GetDBConfig().DBData["welcome_message"])) { this.SendBroadcastMessage(CyberEnvironment.GetDBConfig().DBData["welcome_message"]); } ServerMessage AchievementData = new ServerMessage(Outgoing.SendAchievementsRequirementsMessageComposer); AchievementData.AppendInt32(CyberEnvironment.GetGame().GetAchievementManager().Achievements.Count); foreach (Achievement Ach in CyberEnvironment.GetGame().GetAchievementManager().Achievements.Values) { AchievementData.AppendString(Ach.GroupName.Replace("ACH_", "")); AchievementData.AppendInt32(Ach.Levels.Count); for (int i = 1; i < Ach.Levels.Count + 1; i++) { AchievementData.AppendInt32(i); AchievementData.AppendInt32(Ach.Levels[i].Requirement); } } AchievementData.AppendInt32(0); queuedServerMessage.appendResponse(AchievementData); if (!GetHabbo().NUXPassed&& ExtraSettings.NEW_USER_GIFTS_ENABLED) { queuedServerMessage.appendResponse(new ServerMessage(Outgoing.NuxSuggestFreeGiftsMessageComposer)); } queuedServerMessage.appendResponse(this.GetHabbo().GetAvatarEffectsInventoryComponent().GetPacket()); queuedServerMessage.sendResponse(); result = true; return(result); } catch (Exception ex) { Logging.LogCriticalException("Bug during user login: " + ex.Message); } return(false); }