- Timestamp:
- Jan 19, 2019, 6:12:21 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Web/API/ExecuteConsoleCommand.cs
r347 r351 4 4 namespace AllocsFixes.NetConnections.Servers.Web.API { 5 5 public class ExecuteConsoleCommand : WebAPI { 6 public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnectionuser,7 int permissionLevel) {8 if (string.IsNullOrEmpty ( req.QueryString ["command"])) {9 resp.StatusCode = (int) HttpStatusCode.BadRequest;10 Web.SetResponseTextContent ( resp, "No command given");6 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 7 int _permissionLevel) { 8 if (string.IsNullOrEmpty (_req.QueryString ["command"])) { 9 _resp.StatusCode = (int) HttpStatusCode.BadRequest; 10 Web.SetResponseTextContent (_resp, "No command given"); 11 11 return; 12 12 } 13 13 14 14 WebCommandResult.ResultType responseType = 15 req.QueryString ["raw"] != null15 _req.QueryString ["raw"] != null 16 16 ? WebCommandResult.ResultType.Raw 17 : ( req.QueryString ["simple"] != null17 : (_req.QueryString ["simple"] != null 18 18 ? WebCommandResult.ResultType.ResultOnly 19 19 : WebCommandResult.ResultType.Full); 20 20 21 string commandline = req.QueryString ["command"];21 string commandline = _req.QueryString ["command"]; 22 22 string commandPart = commandline.Split (' ') [0]; 23 23 string argumentsPart = commandline.Substring (Math.Min (commandline.Length, commandPart.Length + 1)); … … 26 26 27 27 if (command == null) { 28 resp.StatusCode = (int) HttpStatusCode.NotFound;29 Web.SetResponseTextContent ( resp, "Unknown command");28 _resp.StatusCode = (int) HttpStatusCode.NotFound; 29 Web.SetResponseTextContent (_resp, "Unknown command"); 30 30 return; 31 31 } … … 34 34 GameManager.Instance.adminTools.GetAdminToolsCommandPermission (command.GetCommands ()); 35 35 36 if ( permissionLevel > atcp.PermissionLevel) {37 resp.StatusCode = (int) HttpStatusCode.Forbidden;38 Web.SetResponseTextContent ( resp, "You are not allowed to execute this command");36 if (_permissionLevel > atcp.PermissionLevel) { 37 _resp.StatusCode = (int) HttpStatusCode.Forbidden; 38 Web.SetResponseTextContent (_resp, "You are not allowed to execute this command"); 39 39 return; 40 40 } 41 41 42 resp.SendChunked = true;43 WebCommandResult wcr = new WebCommandResult (commandPart, argumentsPart, responseType, resp);42 _resp.SendChunked = true; 43 WebCommandResult wcr = new WebCommandResult (commandPart, argumentsPart, responseType, _resp); 44 44 SdtdConsole.Instance.ExecuteAsync (commandline, wcr); 45 45 }
Note:
See TracChangeset
for help on using the changeset viewer.