From 42ba0712765b93f652a8671269e39ca647b8d05e Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 26 Mar 2007 16:51:50 +0000 Subject: Added a very very very basic Web front end for admin use - ready to be used in sandbox mode for adding new accounts. --- OpenSim.RegionServer/AgentAssetUpload.cs | 19 ++- OpenSim.RegionServer/Assets/InventoryCache.cs | 10 ++ OpenSim.RegionServer/CAPS/SimHttp.cs | 166 ++++++++++++++++++++++++-- OpenSim.RegionServer/SimClient.cs | 18 ++- 4 files changed, 201 insertions(+), 12 deletions(-) (limited to 'OpenSim.RegionServer') diff --git a/OpenSim.RegionServer/AgentAssetUpload.cs b/OpenSim.RegionServer/AgentAssetUpload.cs index 5d40c88..a482e80 100644 --- a/OpenSim.RegionServer/AgentAssetUpload.cs +++ b/OpenSim.RegionServer/AgentAssetUpload.cs @@ -79,7 +79,6 @@ namespace OpenSim } - /* for now we will only support uploading of textures else if (pack.AssetBlock.Type == 13 | pack.AssetBlock.Type == 5) { @@ -92,7 +91,7 @@ namespace OpenSim asset.Data = pack.AssetBlock.AssetData; - }*/ + } if (asset != null) { @@ -169,6 +168,22 @@ namespace OpenSim #endregion + public AssetBase AddUploadToAssetCache(LLUUID transactionID) + { + AssetBase asset = null; + if(this.transactions.ContainsKey(transactionID)) + { + AssetTransaction trans = this.transactions[transactionID]; + if (trans.UploadComplete) + { + OpenSimRoot.Instance.AssetCache.AddAsset(trans.Asset); + asset = trans.Asset; + } + } + + return asset; + } + public void CreateInventoryItem(CreateInventoryItemPacket packet) { if(this.transactions.ContainsKey(packet.InventoryBlock.TransactionID)) diff --git a/OpenSim.RegionServer/Assets/InventoryCache.cs b/OpenSim.RegionServer/Assets/InventoryCache.cs index f50047a..3a4aa36 100644 --- a/OpenSim.RegionServer/Assets/InventoryCache.cs +++ b/OpenSim.RegionServer/Assets/InventoryCache.cs @@ -57,6 +57,16 @@ namespace OpenSim.Assets this._agentsInventory.Add(agentInventory.AgentID, agentInventory); } + public AgentInventory GetAgentsInventory(LLUUID agentID) + { + if (this._agentsInventory.ContainsKey(agentID)) + { + return this._agentsInventory[agentID]; + } + + return null; + } + public void ClientLeaving(LLUUID clientID) { if (this._agentsInventory.ContainsKey(clientID)) diff --git a/OpenSim.RegionServer/CAPS/SimHttp.cs b/OpenSim.RegionServer/CAPS/SimHttp.cs index f5a8705..77c6bb8 100644 --- a/OpenSim.RegionServer/CAPS/SimHttp.cs +++ b/OpenSim.RegionServer/CAPS/SimHttp.cs @@ -48,12 +48,17 @@ namespace OpenSim.CAPS { public Thread HTTPD; public HttpListener Listener; + private string AdminPage; + private string NewAccountForm; + private string LoginForm; + private string passWord = "Admin"; public SimCAPSHTTPServer() { OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Starting up HTTP Server"); HTTPD = new Thread(new ThreadStart(StartHTTP)); HTTPD.Start(); + LoadAdminPage(); } public void StartHTTP() @@ -79,7 +84,7 @@ namespace OpenSim.CAPS } } - static string ParseXMLRPC(string requestBody) + private string ParseXMLRPC(string requestBody) { try { @@ -111,19 +116,101 @@ namespace OpenSim.CAPS return ""; } - static string ParseREST(string requestBody, string requestURL) + private string ParseREST(string requestBody, string requestURL, string requestMethod) { - return ""; + string responseString = ""; + switch (requestURL) + { + case "/Admin/Accounts": + if (requestMethod == "GET") + { + responseString = "
Account management
"; + responseString += "Create New Account
"; + responseString += NewAccountForm; + } + break; + case "/Admin/Clients": + if (requestMethod == "GET") + { + responseString = "Listing connected Clients
" ; + OpenSim.world.Avatar TempAv; + foreach (libsecondlife.LLUUID UUID in OpenSimRoot.Instance.LocalWorld.Entities.Keys) + { + if (OpenSimRoot.Instance.LocalWorld.Entities[UUID].ToString() == "OpenSim.world.Avatar") + { + TempAv = (OpenSim.world.Avatar)OpenSimRoot.Instance.LocalWorld.Entities[UUID]; + responseString += ""; + responseString += String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}", TempAv.firstname, TempAv.lastname, UUID, TempAv.ControllingClient.SessionID, TempAv.ControllingClient.CircuitCode, TempAv.ControllingClient.userEP.ToString()); + responseString += "
"; + } + } + } + break; + case "/Admin/NewAccount": + if (requestMethod == "POST") + { + string[] comp = new string[10]; + string[] passw = new string[3]; + string delimStr = "&"; + char[] delimiter = delimStr.ToCharArray(); + string delimStr2 = "="; + char[] delimiter2 = delimStr2.ToCharArray(); + + //Console.WriteLine(requestBody); + comp = requestBody.Split(delimiter); + passw = comp[3].Split(delimiter2); + if (passw[1] == passWord) + { + responseString = "New Account created
"; + } + else + { + responseString = "Admin password is incorrect, please login with the correct password
"; + responseString += "Login Successful
"; + } + else + { + responseString = "PassWord Error
"; + responseString += "Please Login with the correct password
"; + responseString += "