diff --git a/SharedLibrary/Commands/NativeCommands.cs b/SharedLibrary/Commands/NativeCommands.cs index 6e6985ae0..eaf64a118 100644 --- a/SharedLibrary/Commands/NativeCommands.cs +++ b/SharedLibrary/Commands/NativeCommands.cs @@ -396,7 +396,7 @@ namespace SharedLibrary.Commands public class CSetLevel : Command { public CSetLevel() : - base("setlevel", "set player to specified administration level", "sl", Player.Permission.Owner, true, new CommandArgument[] + base("setlevel", "set player to specified administration level", "sl", Player.Permission.Moderator, true, new CommandArgument[] { new CommandArgument() { @@ -415,7 +415,7 @@ namespace SharedLibrary.Commands { if (E.Target == E.Origin) { - await E.Origin.Tell("You cannot change your own level."); + await E.Origin.Tell("You cannot change your own level"); return; } @@ -424,12 +424,29 @@ namespace SharedLibrary.Commands if (newPerm == Player.Permission.Owner && E.Origin.Level != Player.Permission.Console) newPerm = Player.Permission.Banned; - if (newPerm == Player.Permission.Owner && !E.Owner.Manager.GetApplicationSettings().Configuration().EnableMultipleOwners) + if (newPerm == Player.Permission.Owner && + !E.Owner.Manager.GetApplicationSettings().Configuration().EnableMultipleOwners) { - await E.Origin.Tell("There can only be 1 owner. Modify your appsettings if multiple owners are required"); + await E.Origin.Tell("There can only be 1 owner. Modify your settings if multiple owners are required"); return; } + if (E.Origin.Level < Player.Permission.Owner && + !E.Owner.Manager.GetApplicationSettings().Configuration().EnableSteppedHierarchy) + { + await E.Origin.Tell($"This server does not allow you to promote ^5{E.Target.Name}"); + return; + } + + if (newPerm >= E.Origin.Level) + { + if (E.Origin.Level < Player.Permission.Owner) + { + await E.Origin.Tell($"You can only promote ^5{E.Target.Name} ^7to ^5{(E.Origin.Level - 1)} ^7or lower privilege"); + return; + } + } + if (newPerm > Player.Permission.Banned) { var ActiveClient = E.Owner.Manager.GetActiveClients() @@ -447,11 +464,11 @@ namespace SharedLibrary.Commands await E.Owner.Manager.GetClientService().Update(E.Target); } - await E.Origin.Tell($"{E.Target.Name} was successfully promoted!"); + await E.Origin.Tell($"{E.Target.Name} was successfully promoted"); } else - await E.Origin.Tell("Invalid group specified."); + await E.Origin.Tell("Invalid group specified"); } } @@ -989,7 +1006,9 @@ namespace SharedLibrary.Commands { if (!E.Owner.Throttled) { - // await E.Owner.ExecuteCommandAsync("quit"); +#if !DEBUG + await E.Owner.ExecuteCommandAsync("quit"); +#endif } } diff --git a/SharedLibrary/Configuration/ApplicationConfiguration.cs b/SharedLibrary/Configuration/ApplicationConfiguration.cs index f0e22503f..e7101af57 100644 --- a/SharedLibrary/Configuration/ApplicationConfiguration.cs +++ b/SharedLibrary/Configuration/ApplicationConfiguration.cs @@ -8,7 +8,7 @@ namespace SharedLibrary.Configuration public class ApplicationConfiguration : IBaseConfiguration { public bool EnableMultipleOwners { get; set; } - public bool EnableTrustedRank { get; set; } + public bool EnableSteppedHierarchy { get; set; } public bool EnableClientVPNs { get; set; } public bool EnableDiscordLink { get; set; } public string DiscordInviteCode { get; set; } @@ -24,13 +24,13 @@ namespace SharedLibrary.Configuration Console.Write("Enable multiple owners? [y/n]: "); EnableMultipleOwners = (Console.ReadLine().ToLower().FirstOrDefault() as char?) == 'y'; - Console.Write("Enable trusted rank? [y/n]: "); - EnableTrustedRank = (Console.ReadLine().ToLower().FirstOrDefault() as char?) == 'y'; + Console.Write("Enable stepped privilege hierarchy? [y/n]: "); + EnableSteppedHierarchy = (Console.ReadLine().ToLower().FirstOrDefault() as char?) == 'y'; Console.Write("Enable client VPNs [y/n]: "); EnableClientVPNs = (Console.ReadLine().ToLower().FirstOrDefault() as char?) == 'y'; - if (EnableClientVPNs) + if (!EnableClientVPNs) { Console.Write("Enter iphub.info api key: "); IPHubAPIKey = Console.ReadLine(); diff --git a/SharedLibrary/Database/DatabaseContext.cs b/SharedLibrary/Database/DatabaseContext.cs index c30c36f4d..e5a1835f2 100644 --- a/SharedLibrary/Database/DatabaseContext.cs +++ b/SharedLibrary/Database/DatabaseContext.cs @@ -56,7 +56,7 @@ namespace SharedLibrary.Database #if !DEBUG foreach (string dllPath in System.IO.Directory.GetFiles($"{Utilities.OperatingDirectory}Plugins")) #else - foreach (string dllPath in System.IO.Directory.GetFiles(@"C:\Projects\IW4M-Admin\WebfrontCore\bin\x86\Debug\Plugins").Where(f => f.Contains(".dll"))) + foreach (string dllPath in System.IO.Directory.GetFiles(/*C:\Projects\IW4M - Admin\WebfrontCore */ $@"{Environment.CurrentDirectory}\bin\x86\Debug\Plugins").Where(f => f.Contains(".dll"))) #endif { Assembly library; diff --git a/SharedLibrary/Server.cs b/SharedLibrary/Server.cs index 17f828d3e..581dca478 100644 --- a/SharedLibrary/Server.cs +++ b/SharedLibrary/Server.cs @@ -25,6 +25,7 @@ namespace SharedLibrary IW5, T4, T5, + T5M, } public Server(Interfaces.IManager mgr, ServerConfiguration config) diff --git a/SharedLibrary/Utilities.cs b/SharedLibrary/Utilities.cs index 655eab7fe..0fec39441 100644 --- a/SharedLibrary/Utilities.cs +++ b/SharedLibrary/Utilities.cs @@ -239,11 +239,6 @@ namespace SharedLibrary return new System.Net.IPAddress(BitConverter.GetBytes(ip)).ToString(); } - public static String DateTimeSQLite(DateTime datetime) - { - return datetime.ToString("yyyy-MM-dd H:mm:ss"); - } - public static String GetTimePassed(DateTime start) { return GetTimePassed(start, true); @@ -288,6 +283,8 @@ namespace SharedLibrary return Game.T4; if (gameName.Contains("COD_T5_S")) return Game.T5; + if (gameName.Contains("T5M")) + return Game.T5M; if (gameName.Contains("IW5")) return Game.IW5; @@ -391,5 +388,7 @@ namespace SharedLibrary } return cmdLine; } + + public static bool IsPrivileged(this Player p) => p.Level > Player.Permission.User; } } diff --git a/WebfrontCore/Application/Server.cs b/WebfrontCore/Application/Server.cs index ba0bdf248..a66d8af15 100644 --- a/WebfrontCore/Application/Server.cs +++ b/WebfrontCore/Application/Server.cs @@ -296,9 +296,11 @@ namespace IW4MAdmin else if (matchingPlayers.Count == 1) { E.Target = matchingPlayers.First(); - E.Data = Regex.Replace(E.Data, Regex.Escape($"\"{E.Target.Name}\""), "", RegexOptions.IgnoreCase).Trim(); - E.Data = Regex.Replace(E.Data, Regex.Escape($"{E.Target.Name}"), "", RegexOptions.IgnoreCase).Trim(); + string escapedName = Regex.Escape(E.Target.Name); + var reg = new Regex($"(\"{escapedName}\")|({escapedName})", RegexOptions.IgnoreCase); + E.Data = reg.Replace(E.Data, "", 1).Trim(); + if (E.Data.Length == 0 && C.RequiredArgumentCount > 1) { await E.Origin.Tell($"Not enough arguments supplied!"); @@ -321,8 +323,11 @@ namespace IW4MAdmin else if (matchingPlayers.Count == 1) { E.Target = matchingPlayers.First(); - E.Data = Regex.Replace(E.Data, Regex.Escape($"{E.Target.Name}"), "", RegexOptions.IgnoreCase).Trim(); - E.Data = Regex.Replace(E.Data, Regex.Escape($"{Args[0]}"), "", RegexOptions.IgnoreCase).Trim(); + + string escapedName = Regex.Escape(E.Target.Name); + string escapedArg = Regex.Escape(Args[0]); + var reg = new Regex($"({escapedName})|({escapedArg})", RegexOptions.IgnoreCase); + E.Data = reg.Replace(E.Data, "", 1).Trim(); if ((E.Data.Trim() == E.Target.Name.ToLower().Trim() || E.Data == String.Empty) && @@ -631,6 +636,8 @@ namespace IW4MAdmin #endif string mainPath = (GameName == Game.IW4 && onelog.Value >= 0) ? "userraw" : "main"; + // patch for T5M log path + mainPath = (GameName == Game.T5M) ? "rzodemo" : mainPath; string logPath = (game.Value == "" || onelog?.Value == 1) ? $"{basepath.Value.Replace('\\', Path.DirectorySeparatorChar)}{Path.DirectorySeparatorChar}{mainPath}{Path.DirectorySeparatorChar}{logfile.Value}" : @@ -672,8 +679,8 @@ namespace IW4MAdmin if (E.Origin.Level > Player.Permission.Moderator) await E.Origin.Tell($"There are ^5{Reports.Count} ^7recent reports"); - // give trusted rank - if (Manager.GetApplicationSettings().Configuration().EnableTrustedRank && + /*// give trusted rank + if (Manager.GetApplicationSettings().Configuration().EnableSteppedHierarchy && E.Origin.TotalConnectionTime / 60.0 >= 2880 && E.Origin.Level < Player.Permission.Trusted && E.Origin.Level != Player.Permission.Flagged) @@ -682,7 +689,7 @@ namespace IW4MAdmin await E.Origin.Tell("Congratulations, you are now a ^5trusted ^7player! Type ^5!help ^7to view new commands"); await E.Origin.Tell("You earned this by playing for ^53 ^7full days"); await Manager.GetClientService().Update(E.Origin); - } + }*/ } else if (E.Type == Event.GType.Disconnect)