- Timestamp:
- Sep 4, 2018, 1:00:48 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Web/API/ExecuteConsoleCommand.cs
r306 r325 1 using AllocsFixes.JSON;2 using AllocsFixes.PersistentData;3 1 using System; 4 using System.Collections.Generic;5 2 using System.Net; 6 3 7 namespace AllocsFixes.NetConnections.Servers.Web.API 8 { 9 public class ExecuteConsoleCommand : WebAPI 10 { 11 public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel) { 4 namespace AllocsFixes.NetConnections.Servers.Web.API { 5 public class ExecuteConsoleCommand : WebAPI { 6 public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, 7 int permissionLevel) { 12 8 if (string.IsNullOrEmpty (req.QueryString ["command"])) { 13 resp.StatusCode = (int) HttpStatusCode.BadRequest;9 resp.StatusCode = (int) HttpStatusCode.BadRequest; 14 10 Web.SetResponseTextContent (resp, "No command given"); 15 11 return; … … 17 13 18 14 WebCommandResult.ResultType responseType = 19 req.QueryString ["raw"] != null ? WebCommandResult.ResultType.Raw : 20 (req.QueryString ["simple"] != null ? WebCommandResult.ResultType.ResultOnly : 21 WebCommandResult.ResultType.Full); 15 req.QueryString ["raw"] != null 16 ? WebCommandResult.ResultType.Raw 17 : (req.QueryString ["simple"] != null 18 ? WebCommandResult.ResultType.ResultOnly 19 : WebCommandResult.ResultType.Full); 22 20 23 21 string commandline = req.QueryString ["command"]; … … 28 26 29 27 if (command == null) { 30 resp.StatusCode = (int) HttpStatusCode.NotImplemented;28 resp.StatusCode = (int) HttpStatusCode.NotImplemented; 31 29 Web.SetResponseTextContent (resp, "Unknown command"); 32 30 return; 33 31 } 34 32 35 AdminToolsCommandPermissions atcp = GameManager.Instance.adminTools.GetAdminToolsCommandPermission (command.GetCommands ()); 33 AdminToolsCommandPermissions atcp = 34 GameManager.Instance.adminTools.GetAdminToolsCommandPermission (command.GetCommands ()); 36 35 37 36 if (permissionLevel > atcp.PermissionLevel) { 38 resp.StatusCode = (int) HttpStatusCode.Forbidden;37 resp.StatusCode = (int) HttpStatusCode.Forbidden; 39 38 Web.SetResponseTextContent (resp, "You are not allowed to execute this command"); 40 39 return; … … 51 50 } 52 51 } 53
Note:
See TracChangeset
for help on using the changeset viewer.