public void BanUser(string mod, ModerationBanType type, string banValue, string reason, double expireTimestamp) { var banType = type == ModerationBanType.Ip ? "ip" : type == ModerationBanType.Machine ? "machine" : "user"; using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery( "REPLACE INTO `bans` (`bantype`, `value`, `reason`, `expire`, `added_by`,`added_date`) VALUES ('" + banType + "', '" + banValue + "', @reason, " + expireTimestamp + ", '" + mod + "', '" + PlusEnvironment.GetUnixTimestamp() + "');"); dbClient.AddParameter("reason", reason); dbClient.RunQuery(); } if (type == ModerationBanType.Machine || type == ModerationBanType.Username) { if (!_bans.ContainsKey(banValue)) { _bans.Add(banValue, new ModerationBan(type, banValue, reason, expireTimestamp)); } } }
/// <summary> /// Initializes a new instance of the <see cref="ModerationBan" /> struct. /// </summary> /// <param name="type">The type.</param> /// <param name="variable">The variable.</param> /// <param name="reasonMessage">The reason message.</param> /// <param name="expire">The expire.</param> internal ModerationBan(ModerationBanType type, string variable, string reasonMessage, double expire) { Type = type; Variable = variable; ReasonMessage = reasonMessage; Expire = expire; }
public ModerationBan(ModerationBanType banType, string banValue, string banReason, double banExpirationDate) { _banType = banType; _banValue = banValue; _banReason = banReason; _banExpirationDate = banExpirationDate; }
public void AddBan(string moderatorUsername, ModerationBanType banType, string banValue, string banReason, double expireTimestamp) { var type = (banType == ModerationBanType.ByIp ? "ip" : banType == ModerationBanType.ByMachine ? "machine" : "user"); using (var mysqlConnection = Sahara.GetServer().GetMySql().GetConnection()) { mysqlConnection.OpenConnection(); mysqlConnection.AddParameter("banType", type); mysqlConnection.AddParameter("banValue", banValue); mysqlConnection.AddParameter("reason", banReason); mysqlConnection.AddParameter("expireTimestamp", expireTimestamp); mysqlConnection.AddParameter("moderatorUsername", moderatorUsername); mysqlConnection.AddParameter("addedTimestamp", UnixTimestampGenerator.GetNow()); mysqlConnection.SetQuery("REPLACE INTO `bans` (`bantype`, `value`, `reason`, `expire`, `added_by`, `added_date`) VALUES (@banType, @banValue, @reason, @expireTimestamp, @moderatorUsername, @addedTimestamp)"); mysqlConnection.RunQuery(); mysqlConnection.CloseConnection(); } if (banType != ModerationBanType.ByMachine && banType != ModerationBanType.ByUsername) { return; } if (!_moderationBans.ContainsKey(banValue)) { _moderationBans.Add(banValue, new ModerationBan(banType, banValue, banReason, expireTimestamp)); } }
public void Initialise(DatabaseClient dbClient) { Console.BackgroundColor = ConsoleColor.Black; Logging.Write("Lädt bans.."); this.Bans.Clear(); DataTable dataTable = dbClient.ReadDataTable("SELECT bantype,value,reason,expire FROM bans WHERE expire > '" + HabboIM.GetUnixTimestamp() + "'"); if (dataTable != null) { foreach (DataRow dataRow in dataTable.Rows) { ModerationBanType Type = ModerationBanType.IP; if ((string)dataRow["bantype"] == "user") { Type = ModerationBanType.USERNAME; } if ((string)dataRow["bantype"] == "static_id") { Type = ModerationBanType.STATICID; } this.Bans.Add(new ModerationBan(Type, (string)dataRow["value"], (string)dataRow["reason"], (double)dataRow["expire"])); } Logging.WriteLine("Fertig!", ConsoleColor.Green); } }
public ModerationBan(ModerationBanType type, string value, string reason, double expire) { Type = type; Value = value; Reason = reason; Expire = expire; }
/// <summary> /// Initializes a new instance of the <see cref="ModerationBan" /> struct. /// </summary> /// <param name="type">The type.</param> /// <param name="variable">The variable.</param> /// <param name="reasonMessage">The reason message.</param> /// <param name="expire">The expire.</param> internal ModerationBan(ModerationBanType type, string variable, string reasonMessage, double expire) { Type = type; Variable = variable; ReasonMessage = reasonMessage; Expire = expire; }
public ModerationBan(ModerationBanType Type, string Value, string Reason, Double Expire) { this.Type = Type; this.Value = Value; this.Reason = Reason; this.Expire = Expire; }
internal ModerationBan(ModerationBanType Type, string Variable, string ReasonMessage, Double Expire) { this.Type = Type; this.Variable = Variable; this.ReasonMessage = ReasonMessage; this.Expire = Expire; }
internal ModerationBan(ModerationBanType Type, string Variable, string ReasonMessage, Double Expire) { this.Type = Type; this.Variable = Variable; this.ReasonMessage = ReasonMessage; this.Expire = Expire; }
public ModerationBan(ModerationBanType mType, string mVariable, string mReasonMessage, double mExpire) { this.Type = mType; this.Variable = mVariable; this.ReasonMessage = mReasonMessage; this.Expire = mExpire; }
/// <summary> /// The moderation ban constructor. /// </summary> /// <param name="Type"></param> /// <param name="Value"></param> /// <param name="Reason"></param> /// <param name="Expire"></param> public ModerationBan(ModerationBanType Type, string Value, string Reason, double Expire) { this.Type = Type; this.Value = Value; this.Reason = Reason; this.Expire = Expire; }
public ModerationBan(ModerationBanType mType, string mVariable, string mReasonMessage, double mExpire) { this.Type = mType; this.Variable = mVariable; this.ReasonMessage = mReasonMessage; this.Expire = mExpire; }
public ModerationBan(ModerationBanType type, string value, string reason, Double expire) { this.Type = type; this.Value = value; this.Reason = reason; this.Expire = expire; }
public void BanUser(GameClient client, string Mod, ModerationBanType Type, string BanValue, string Reason, double ExpireTimestamp) { string BanType = (Type == ModerationBanType.IP ? "ip" : Type == ModerationBanType.MACHINE ? "machine" : "user"); double BanExpire = Plus.GetUnixTimeStamp() + ExpireTimestamp; using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("INSERT INTO `users_bans` (`bantype`, `value`, `reason`, `expire`, `added_by`,`added_date`) VALUES ('" + BanType + "', '" + BanValue + "', @reason, " + BanExpire + ", '" + Mod + "', '" + DateTime.Now.ToLongDateString() + "');"); dbClient.AddParameter("reason", Reason); dbClient.RunQuery(); } if (Type == ModerationBanType.MACHINE || Type == ModerationBanType.USERNAME) { if (!this._bans.ContainsKey(BanValue)) { this._bans.Add(BanValue, new ModerationBan(Type, BanValue, Reason, BanExpire)); } } using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor()) { dbClient.RunFastQuery("UPDATE `users_info` SET `bans` = `bans` + '1' WHERE `user_id` = '" + client.GetHabbo().Id + "' LIMIT 1"); } client.Disconnect("banned"); }
public static string FromModerationBanType(ModerationBanType Type) { switch (Type) { default: case ModerationBanType.USERNAME: return "user"; case ModerationBanType.IP: return "ip"; case ModerationBanType.MACHINE: return "machine"; } }
public static string FromModerationBanType(ModerationBanType Type) { switch (Type) { default: case ModerationBanType.USERNAME: return("user"); case ModerationBanType.IP: return("ip"); case ModerationBanType.MACHINE: return("machine"); } }
public static string FromModerationBanType(ModerationBanType type) { switch (type) { default: case ModerationBanType.Username: return("user"); case ModerationBanType.Ip: return("ip"); case ModerationBanType.Machine: return("machine"); } }
public void BanUser(string Mod, ModerationBanType Type, string BanValue, string Reason, double ExpireTimestamp) { string BanType = (Type == ModerationBanType.IP ? "ip" : Type == ModerationBanType.MACHINE ? "machine" : "user"); using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("REPLACE INTO `bans` (`bantype`, `value`, `reason`, `expire`, `added_by`,`added_date`) VALUES ('" + BanType + "', '" + BanValue + "', @reason, " + ExpireTimestamp + ", '" + Mod + "', '" + PlusEnvironment.GetUnixTimestamp() + "');"); dbClient.AddParameter("reason", Reason); dbClient.RunQuery(); } if (Type == ModerationBanType.MACHINE || Type == ModerationBanType.USERNAME) { if (!this._bans.ContainsKey(BanValue)) this._bans.Add(BanValue, new ModerationBan(Type, BanValue, Reason, ExpireTimestamp)); } }
public void BanUser(string Mod, ModerationBanType Type, string BanValue, string Reason, double ExpireTimestamp) { string BanType = (Type == ModerationBanType.IP ? "ip" : Type == ModerationBanType.MACHINE ? "machine" : "user"); using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("REPLACE INTO `bans` (`bantype`, `value`, `reason`, `expire`, `added_by`,`added_date`) VALUES ('" + BanType + "', '" + BanValue + "', @reason, " + ExpireTimestamp + ", '" + Mod + "', '" + CloudServer.GetUnixTimestamp() + "');"); dbClient.AddParameter("reason", Reason); dbClient.RunQuery(); } if (Type == ModerationBanType.MACHINE || Type == ModerationBanType.USERNAME) { if (!this._bans.ContainsKey(BanValue)) this._bans.Add(BanValue, new ModerationBan(Type, BanValue, Reason, ExpireTimestamp)); } }
public void BanUser(string Mod, ModerationBanType Type, string BanValue, string Reason, double ExpireTimestamp) { var BanType = Type == ModerationBanType.IP ? "ip" : Type == ModerationBanType.Machine ? "machine" : "user"; using (var dbClient = Program.DatabaseManager.GetQueryReactor()) { dbClient.SetQuery("REPLACE INTO `bans` (`bantype`, `value`, `reason`, `expire`, `added_by`,`added_date`) VALUES ('" + BanType + "', '" + BanValue + "', @reason, " + ExpireTimestamp + ", '" + Mod + "', '" + UnixUtilities.GetNow() + "');"); dbClient.AddParameter("reason", Reason); dbClient.RunQuery(); } if (Type == ModerationBanType.Machine || Type == ModerationBanType.Username) { if (!_bans.ContainsKey(BanValue)) { _bans.Add(BanValue, new ModerationBan(Type, BanValue, Reason, ExpireTimestamp)); } } }
public void method_0(DatabaseClient class6_0) { Logging.smethod_0("Loading bans.."); this.list_0.Clear(); DataTable dataTable = class6_0.ReadDataTable("SELECT bantype,value,reason,expire FROM bans WHERE expire > '" + GoldTree.GetUnixTimestamp() + "'"); if (dataTable != null) { foreach (DataRow dataRow in dataTable.Rows) { ModerationBanType Type = ModerationBanType.IP; if ((string)dataRow["bantype"] == "user") { Type = ModerationBanType.USERNAME; } this.list_0.Add(new ModerationBan(Type, (string)dataRow["value"], (string)dataRow["reason"], (double)dataRow["expire"])); } Logging.WriteLine("completed!"); } }
public void LoadBans(DatabaseClient dbClient) { Logging.Write("Loading bans.."); this.Bans.Clear(); DataTable dataTable = dbClient.ReadDataTable("SELECT bantype,value,reason,expire FROM bans WHERE expire > '" + PhoenixEnvironment.GetUnixTimestamp() + "'"); if (dataTable != null) { foreach (DataRow dataRow in dataTable.Rows) { ModerationBanType iP = ModerationBanType.IP; if ((string)dataRow["bantype"] == "user") { iP = ModerationBanType.USERNAME; } this.Bans.Add(new ModerationBan(iP, (string)dataRow["value"], (string)dataRow["reason"], (double)dataRow["expire"])); } Logging.WriteLine("completed!"); } }
public void Initialise(DatabaseClient dbClient) { Logging.Write("Loading bans.."); this.Bans.Clear(); DataTable dataTable = dbClient.ReadDataTable("SELECT bantype,value,reason,expire FROM bans WHERE expire > '" + GoldTree.GetUnixTimestamp() + "'"); if (dataTable != null) { foreach (DataRow dataRow in dataTable.Rows) { ModerationBanType Type = ModerationBanType.IP; if ((string)dataRow["bantype"] == "user") { Type = ModerationBanType.USERNAME; } this.Bans.Add(new ModerationBan(Type, (string)dataRow["value"], (string)dataRow["reason"], (double)dataRow["expire"])); } Logging.WriteLine("completed!", ConsoleColor.Green); } }
public void BanUser(GameClient Session, string string_0, double length, string reason, bool banIp) { if (!Session.GetHabbo().IsJuniori) { ModerationBanType enum4_ = ModerationBanType.USERNAME; string text = Session.GetHabbo().Username; string object_ = "user"; double timestamp = GoldTree.GetUnixTimestamp() + length; if (banIp) { enum4_ = ModerationBanType.IP; if (!ServerConfiguration.IPLastBan) { text = Session.GetConnection().Address; } else { using (DatabaseClient dbClient = GoldTree.GetDatabase().GetClient()) { text = dbClient.ReadString("SELECT ip_last FROM users WHERE Id = " + Session.GetHabbo().Id + " LIMIT 1;"); } } object_ = "ip"; } this.Bans.Add(new ModerationBan(enum4_, text, reason, timestamp)); using (DatabaseClient dbClient = GoldTree.GetDatabase().GetClient()) { dbClient.AddParamWithValue("rawvar", object_); dbClient.AddParamWithValue("var", text); dbClient.AddParamWithValue("reason", reason); dbClient.AddParamWithValue("mod", string_0); dbClient.ExecuteQuery(string.Concat(new object[] { "INSERT INTO bans (bantype,value,reason,expire,added_by,added_date,appeal_state) VALUES (@rawvar,@var,@reason,'", timestamp, "',@mod,'", DateTime.Now.ToLongDateString(), "', '1')" })); } if (banIp) { DataTable dataTable = null; using (DatabaseClient dbClient = GoldTree.GetDatabase().GetClient()) { dbClient.AddParamWithValue("var", text); dataTable = dbClient.ReadDataTable("SELECT Id FROM users WHERE ip_last = @var"); } if (dataTable != null) { IEnumerator enumerator = dataTable.Rows.GetEnumerator(); try { while (enumerator.MoveNext()) { DataRow dataRow = (DataRow)enumerator.Current; using (DatabaseClient @class = GoldTree.GetDatabase().GetClient()) { @class.ExecuteQuery("UPDATE user_info SET bans = bans + 1 WHERE user_id = '" + (uint)dataRow["Id"] + "' LIMIT 1"); } } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } } } using (DatabaseClient dbClient = GoldTree.GetDatabase().GetClient()) { dbClient.ExecuteQuery("UPDATE user_info SET bans = bans + 1 WHERE user_id = '" + Session.GetHabbo().Id + "' LIMIT 1"); } Session.NotifyBan("You have been banned: " + reason); Session.method_12(); } }
internal void BanUser(GameClient Client, string Moderator, double LengthSeconds, string Reason, bool IpBan, bool Machine) { ModerationBanType type = ModerationBanType.USERNAME; string text = Client.GetHabbo().Username; string query = "user"; double num = (double)CyberEnvironment.GetUnixTimestamp() + LengthSeconds; if (IpBan) { type = ModerationBanType.IP; using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor()) { queryreactor.setQuery("SELECT ip_last FROM users WHERE username='******' LIMIT 1"); text = queryreactor.getString(); } query = "ip"; } if (Machine) { type = ModerationBanType.MACHINE; query = "machine"; text = Client.MachineId; } ModerationBan moderationBan = new ModerationBan(type, text, Reason, num); if (moderationBan.Type == ModerationBanType.IP) { if (this.bannedIPs.Contains(text)) { this.bannedIPs[text] = moderationBan; } else { this.bannedIPs.Add(text, moderationBan); } } else { if (moderationBan.Type == ModerationBanType.MACHINE) { if (this.bannedMachines.ContainsKey(text)) { this.bannedMachines[text] = moderationBan; } else { this.bannedMachines.Add(text, moderationBan); } } else { if (this.bannedUsernames.Contains(text)) { this.bannedUsernames[text] = moderationBan; } else { this.bannedUsernames.Add(text, moderationBan); } } } using (IQueryAdapter queryreactor2 = CyberEnvironment.GetDatabaseManager().getQueryReactor()) { queryreactor2.setQuery(string.Concat(new object[] { "INSERT INTO bans (bantype,value,reason,expire,added_by,added_date) VALUES (@rawvar,@var,@reason,'", num, "',@mod,'", DateTime.Now.ToLongDateString(), "')" })); queryreactor2.addParameter("rawvar", query); queryreactor2.addParameter("var", text); queryreactor2.addParameter("reason", Reason); queryreactor2.addParameter("mod", Moderator); queryreactor2.runQuery(); } if (IpBan) { DataTable dataTable = null; using (IQueryAdapter queryreactor3 = CyberEnvironment.GetDatabaseManager().getQueryReactor()) { queryreactor3.setQuery("SELECT id FROM users WHERE ip_last = @var"); queryreactor3.addParameter("var", text); dataTable = queryreactor3.getTable(); } if (dataTable != null) { using (IQueryAdapter queryreactor4 = CyberEnvironment.GetDatabaseManager().getQueryReactor()) { foreach (DataRow dataRow in dataTable.Rows) { queryreactor4.runFastQuery("UPDATE user_info SET bans = bans + 1 WHERE user_id = " + Convert.ToUInt32(dataRow["id"])); } } } this.BanUser(Client, Moderator, LengthSeconds, Reason, false, false); return; } using (IQueryAdapter queryreactor5 = CyberEnvironment.GetDatabaseManager().getQueryReactor()) { queryreactor5.runFastQuery("UPDATE user_info SET bans = bans + 1 WHERE user_id = " + Client.GetHabbo().Id); } Client.Disconnect(); }
public void method_2(GameClient Session, string string_0, double double_0, string string_1, bool bool_0) { if (!Session.GetHabbo().isJuniori) { ModerationBanType enum4_ = ModerationBanType.USERNAME; string text = Session.GetHabbo().Username; string object_ = "user"; double num = GoldTree.GetUnixTimestamp() + double_0; if (bool_0) { enum4_ = ModerationBanType.IP; if (!LicenseTools.bool_20) { text = Session.GetConnection().String_0; } else { using (DatabaseClient @class = GoldTree.GetDatabase().GetClient()) { text = @class.ReadString("SELECT ip_last FROM users WHERE Id = " + Session.GetHabbo().Id + " LIMIT 1;"); } } object_ = "ip"; } this.list_0.Add(new ModerationBan(enum4_, text, string_1, num)); using (DatabaseClient @class = GoldTree.GetDatabase().GetClient()) { @class.AddParamWithValue("rawvar", object_); @class.AddParamWithValue("var", text); @class.AddParamWithValue("reason", string_1); @class.AddParamWithValue("mod", string_0); @class.ExecuteQuery(string.Concat(new object[] { "INSERT INTO bans (bantype,value,reason,expire,added_by,added_date,appeal_state) VALUES (@rawvar,@var,@reason,'", num, "',@mod,'", DateTime.Now.ToLongDateString(), "', '1')" })); } if (bool_0) { DataTable dataTable = null; using (DatabaseClient @class = GoldTree.GetDatabase().GetClient()) { @class.AddParamWithValue("var", text); dataTable = @class.ReadDataTable("SELECT Id FROM users WHERE ip_last = @var"); } if (dataTable == null) { goto IL_268; } IEnumerator enumerator = dataTable.Rows.GetEnumerator(); try { while (enumerator.MoveNext()) { DataRow dataRow = (DataRow)enumerator.Current; using (DatabaseClient @class = GoldTree.GetDatabase().GetClient()) { @class.ExecuteQuery("UPDATE user_info SET bans = bans + 1 WHERE user_id = '" + (uint)dataRow["Id"] + "' LIMIT 1"); } } goto IL_268; } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } } using (DatabaseClient @class = GoldTree.GetDatabase().GetClient()) { @class.ExecuteQuery("UPDATE user_info SET bans = bans + 1 WHERE user_id = '" + Session.GetHabbo().Id + "' LIMIT 1"); } IL_268: Session.method_7("You have been banned: " + string_1); Session.method_12(); } }
/// <summary> /// Bans the user. /// </summary> /// <param name="client">The client.</param> /// <param name="moderator">The moderator.</param> /// <param name="lengthSeconds">The length seconds.</param> /// <param name="reason">The reason.</param> /// <param name="ipBan">if set to <c>true</c> [ip ban].</param> /// <param name="machine">if set to <c>true</c> [machine].</param> internal void BanUser(GameClient client, string moderator, double lengthSeconds, string reason, bool ipBan, bool machine) { ModerationBanType type = ModerationBanType.UserName; string text = client.GetHabbo().UserName; string typeStr = "user"; double num = Yupi.GetUnixTimeStamp() + lengthSeconds; if (ipBan) { type = ModerationBanType.Ip; using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor()) { queryReactor.SetQuery("SELECT ip_last FROM users WHERE username = @name LIMIT 1"); queryReactor.AddParameter("name", text); text = queryReactor.GetString(); } typeStr = "ip"; } if (machine) { type = ModerationBanType.Machine; typeStr = "machine"; text = client.MachineId; } ModerationBan moderationBan = new ModerationBan(type, text, reason, num); switch (moderationBan.Type) { case ModerationBanType.Ip: if (_bannedIPs.Contains(text)) _bannedIPs[text] = moderationBan; else _bannedIPs.Add(text, moderationBan); break; case ModerationBanType.Machine: if (_bannedMachines.ContainsKey(text)) _bannedMachines[text] = moderationBan; else _bannedMachines.Add(text, moderationBan); break; default: if (_bannedUsernames.Contains(text)) _bannedUsernames[text] = moderationBan; else _bannedUsernames.Add(text, moderationBan); break; } using (IQueryAdapter queryreactor2 = Yupi.GetDatabaseManager().GetQueryReactor()) { queryreactor2.SetQuery( "INSERT INTO users_bans (bantype,value,reason,expire,added_by,added_date) VALUES (@rawvar,@var,@reason,@num,@mod,@time)"); queryreactor2.AddParameter("rawvar", typeStr); queryreactor2.AddParameter("var", text); queryreactor2.AddParameter("reason", reason); queryreactor2.AddParameter("num", num); queryreactor2.AddParameter("mod", moderator); queryreactor2.AddParameter("time", DateTime.Now.ToLongDateString()); queryreactor2.RunQuery(); } if (ipBan) { DataTable dataTable; using (IQueryAdapter queryreactor3 = Yupi.GetDatabaseManager().GetQueryReactor()) { queryreactor3.SetQuery("SELECT id FROM users WHERE ip_last = @var"); queryreactor3.AddParameter("var", text); dataTable = queryreactor3.GetTable(); } if (dataTable != null) { using (IQueryAdapter queryreactor4 = Yupi.GetDatabaseManager().GetQueryReactor()) { foreach (DataRow dataRow in dataTable.Rows) queryreactor4.RunFastQuery( $"UPDATE users_info SET bans = bans + 1 WHERE user_id = {Convert.ToUInt32(dataRow["id"])}"); } } BanUser(client, moderator, lengthSeconds, reason, false, false); return; } using (IQueryAdapter queryreactor5 = Yupi.GetDatabaseManager().GetQueryReactor()) queryreactor5.RunFastQuery( $"UPDATE users_info SET bans = bans + 1 WHERE user_id = {client.GetHabbo().Id}"); client.Disconnect("banned"); }
public async void BanUser(int targetUserId, Session moderator, string reason, int duration, ModerationBanType type, int topic) { Player target = await Alias.Server.PlayerManager.ReadPlayerByIdAsync(targetUserId); if (target.Rank >= moderator.Player.Rank) { return; } //todo: insert ban if (target.Session != null) { target.Session.Disconnect(); } }
public void BanUser(GameClient Client, string Moderator, double LengthSeconds, string Reason, bool IpBan) { if (!Client.GetHabbo().isAaron) { ModerationBanType uSERNAME = ModerationBanType.USERNAME; string username = Client.GetHabbo().Username; string val = "user"; double Expire = PhoenixEnvironment.GetUnixTimestamp() + LengthSeconds; if (IpBan) { uSERNAME = ModerationBanType.IP; if (!GlobalClass.UseIP_Last) { username = Client.GetConnection().ipAddress; } else { using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient()) { username = adapter.ReadString("SELECT ip_last FROM users WHERE Id = " + Client.GetHabbo().Id + " LIMIT 1;"); } } val = "ip"; } this.Bans.Add(new ModerationBan(uSERNAME, username, Reason, Expire)); using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient()) { adapter.AddParamWithValue("rawvar", val); adapter.AddParamWithValue("var", username); adapter.AddParamWithValue("reason", Reason); adapter.AddParamWithValue("mod", Moderator); adapter.ExecuteQuery("INSERT INTO bans (bantype,value,reason,expire,added_by,added_date,appeal_state) VALUES (@rawvar,@var,@reason,'" + Expire + "',@mod,'" + DateTime.Now.ToLongDateString() + "', '1')"); } if (IpBan) { DataTable table = null; using (DatabaseClient client3 = PhoenixEnvironment.GetDatabase().GetClient()) { client3.AddParamWithValue("var", username); table = client3.ReadDataTable("SELECT id FROM users WHERE ip_last = @var"); } if (table != null) { foreach (DataRow row in table.Rows) { using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient()) { adapter.ExecuteQuery("UPDATE user_info SET bans = bans + 1 WHERE user_id = '" + ((uint)row["id"]) + "' LIMIT 1"); } } } } else { using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient()) { adapter.ExecuteQuery("UPDATE user_info SET bans = bans + 1 WHERE user_id = '" + Client.GetHabbo().Id + "' LIMIT 1"); } } Client.SendBanMessage("You have been banned: " + Reason); 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 = 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(); } }