private void HandleTimeouts() { while (true) { try { while (timedOutConnections.Count > 0) { GameClient client = null; lock (timedOutConnections.SyncRoot) { if (timedOutConnections.Count > 0) { client = (GameClient)timedOutConnections.Dequeue(); } } if (client != null) { client.Disconnect(); } } } catch (Exception e) { Logging.LogThreadException(e.ToString(), "HandleTimeouts"); } Thread.Sleep(5000); } }
internal void LogClonesOut(uint UserID) { GameClient client = GetClientByUserID(UserID); if (client != null) { client.Disconnect(); } }
public void LogClonesOut(int UserID) { GameClient clientByUserId = this.GetClientByUserID(UserID); if (clientByUserId == null) { return; } clientByUserId.Disconnect(); }
public void BanUser(GameClient Client, string Moderator, double LengthSeconds, string Reason, bool IpBan, bool MachineBan) { if (string.IsNullOrEmpty(Reason)) { Reason = "Ne respect pas les régles"; } string Variable = Client.GetHabbo().Username.ToLower(); string str = "user"; double Expire = (double)ButterflyEnvironment.GetUnixTimestamp() + LengthSeconds; if (IpBan) { //Variable = Client.GetConnection().getIp(); Variable = Client.GetHabbo().IP; str = "ip"; } if (MachineBan) { Variable = Client.MachineId; str = "machine"; } using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor()) { queryreactor.SetQuery("INSERT INTO bans (bantype,value,reason,expire,added_by,added_date) VALUES (@rawvar, @var, @reason, '" + Expire + "', @mod, UNIX_TIMESTAMP())"); queryreactor.AddParameter("rawvar", str); queryreactor.AddParameter("var", Variable); queryreactor.AddParameter("reason", Reason); queryreactor.AddParameter("mod", Moderator); queryreactor.RunQuery(); } if (MachineBan) { this.BanUser(Client, Moderator, LengthSeconds, Reason, true, false); } else if (IpBan) { this.BanUser(Client, Moderator, LengthSeconds, Reason, false, false); } else { Client.Disconnect(); } }
// 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 = ButterflyEnvironment.GetUnixTimestamp() + LengthSeconds; if (IpBan) { Type = ModerationBanType.IP; using (IQueryAdapter adapter = ButterflyEnvironment.GetDatabaseManager().getQueryreactor()) { adapter.setQuery("SELECT ip_last FROM users WHERE username = '******' LIMIT 1"); Var = adapter.getString(); } 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 = ButterflyEnvironment.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 = ButterflyEnvironment.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 = ButterflyEnvironment.GetDatabaseManager().getQueryreactor()) { foreach (DataRow Row in UsersAffected.Rows) { dbClient.runFastQuery("UPDATE user_info SET bans = bans + 1 WHERE user_id = " + Convert.ToUInt32(Row["id"])); } } } Client.Disconnect(); } else { using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("UPDATE user_info SET bans = bans + 1 WHERE user_id = " + Client.GetHabbo().Id); } Client.Disconnect(); } }