From 39c7fe5ec737c6cf259fd98d20723423419e847d Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 27 Mar 2007 09:35:03 +0000 Subject: Added REST-handler interface for the http server and changed the Admin Web front end to one. --- OpenSim.RegionServer/CAPS/AdminWebFront.cs | 164 +++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 OpenSim.RegionServer/CAPS/AdminWebFront.cs (limited to 'OpenSim.RegionServer/CAPS/AdminWebFront.cs') diff --git a/OpenSim.RegionServer/CAPS/AdminWebFront.cs b/OpenSim.RegionServer/CAPS/AdminWebFront.cs new file mode 100644 index 0000000..ea32589 --- /dev/null +++ b/OpenSim.RegionServer/CAPS/AdminWebFront.cs @@ -0,0 +1,164 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; + +namespace OpenSim.CAPS +{ + public class AdminWebFront : IRestHandler + { + private string AdminPage; + private string NewAccountForm; + private string LoginForm; + private string passWord = "Admin"; + + public AdminWebFront(string password) + { + passWord = password; + LoadAdminPage(); + } + + public string HandleREST(string requestBody, string requestURL, string requestMethod) + { + string responseString = ""; + try + { + switch (requestURL) + { + case "/Admin": + if (requestMethod == "GET") + { + responseString = AdminPage; + } + break; + 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 += "