private void GroupManager_OnLoggedInClient(GameClient client) { // This is called when an user sucessfully authed. Habbo user = client.GetHabbo(); if (user == null || user.Groups.Count == 0) return; client.GetConnection().connectionChanged += GroupManager_connectionChanged; foreach (int groupID in user.Groups) { if (GetGroup(groupID) == null) return; // Add one more count to reference counter if (!_groupReferences.ContainsKey(groupID)) _groupReferences.Add(groupID, 1); else _groupReferences[groupID]++; } }
// PENDING REWRITE internal void BanUser(GameClient Client, string Moderator, Double LengthSeconds, string Reason, Boolean IpBan) { ModerationBanType Type = ModerationBanType.USERNAME; string Var = Client.GetHabbo().Username; string RawVar = "user"; Double Expire = FirewindEnvironment.GetUnixTimestamp() + LengthSeconds; if (IpBan) { Type = ModerationBanType.IP; Var = Client.GetConnection().getIp(); RawVar = "ip"; } ModerationBan ban = new ModerationBan(Type, Var, Reason, Expire); if (ban.Type == ModerationBanType.IP) { if (bannedIPs.ContainsKey(Var)) bannedIPs[Var] = ban; else bannedIPs.Add(Var, ban); } else { if (bannedUsernames.ContainsKey(Var)) bannedUsernames[Var] = ban; else bannedUsernames.Add(Var, ban); } using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("INSERT INTO bans (bantype,value,reason,expire,added_by,added_date) VALUES (@rawvar,@var,@reason,'" + Expire + "',@mod,'" + DateTime.Now.ToLongDateString() + "')"); dbClient.addParameter("rawvar", RawVar); dbClient.addParameter("var", Var); dbClient.addParameter("reason", Reason); dbClient.addParameter("mod", Moderator); dbClient.runQuery(); } if (IpBan) { DataTable UsersAffected = null; using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("SELECT id FROM users WHERE ip_last = @var"); dbClient.addParameter("var", Var); UsersAffected = dbClient.getTable(); } if (UsersAffected != null) { using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { foreach (DataRow Row in UsersAffected.Rows) { dbClient.runFastQuery("UPDATE user_info SET bans = bans + 1 WHERE user_id = " + Convert.ToUInt32(Row["id"])); } } } BanUser(Client, Moderator, LengthSeconds, Reason, false); } else { using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("UPDATE user_info SET bans = bans + 1 WHERE user_id = " + Client.GetHabbo().Id); } Client.SendBanMessage(LanguageLocale.GetValue("moderation.banned") + " " + Reason); Client.Disconnect(); } }