aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.RegionServer/CAPS
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/OpenSim.RegionServer/CAPS/AdminWebFront.cs228
1 files changed, 3 insertions, 225 deletions
diff --git a/OpenSim/OpenSim.RegionServer/CAPS/AdminWebFront.cs b/OpenSim/OpenSim.RegionServer/CAPS/AdminWebFront.cs
index 2299fa4..1f508ce 100644
--- a/OpenSim/OpenSim.RegionServer/CAPS/AdminWebFront.cs
+++ b/OpenSim/OpenSim.RegionServer/CAPS/AdminWebFront.cs
@@ -19,238 +19,16 @@ namespace OpenSim.CAPS
19 private string NewAccountForm; 19 private string NewAccountForm;
20 private string LoginForm; 20 private string LoginForm;
21 private string passWord = "Admin"; 21 private string passWord = "Admin";
22 private World m_world;
23 private LoginServer _userServer;
24 private InventoryCache _inventoryCache;
25 22
26 public AdminWebFront(string password, World world, InventoryCache inventoryCache, LoginServer userserver) 23
24 public AdminWebFront(string password)
27 { 25 {
28 _inventoryCache = inventoryCache;
29 _userServer = userserver;
30 m_world = world;
31 passWord = password; 26 passWord = password;
32 LoadAdminPage();
33 } 27 }
34 28
35 public void LoadMethods( BaseHttpServer server ) 29 public void LoadMethods( BaseHttpServer server )
36 { 30 {
37 server.AddRestHandler("GET", "/Admin", GetAdminPage); 31
38 server.AddRestHandler("GET", "/Admin/Welcome", GetWelcomePage);
39 server.AddRestHandler("GET", "/Admin/Accounts", GetAccountsPage );
40 server.AddRestHandler("GET", "/Admin/Clients", GetConnectedClientsPage);
41 server.AddRestHandler("GET", "/Admin/Entities", GetEntitiesPage);
42 server.AddRestHandler("GET", "/Admin/Scripts", GetScriptsPage);
43 server.AddRestHandler("GET", "/Admin/AddTestScript", AddTestScript );
44 server.AddRestHandler("GET", "/ClientInventory", GetClientsInventory);
45
46 server.AddRestHandler("POST", "/Admin/NewAccount", PostNewAccount );
47 server.AddRestHandler("POST", "/Admin/Login", PostLogin );
48 }
49
50 private string GetWelcomePage(string request, string path, string param)
51 {
52 string responseString;
53 responseString = "Welcome to the OpenSim Admin Page";
54 responseString += "<br><br><br> " + LoginForm;
55 return responseString;
56 }
57
58 private string PostLogin(string requestBody, string path, string param)
59 {
60 string responseString;
61// Console.WriteLine(requestBody);
62 if (requestBody == passWord)
63 {
64 responseString = "<p> Login Successful </p>";
65 }
66 else
67 {
68 responseString = "<p> Password Error </p>";
69 responseString += "<p> Please Login with the correct password </p>";
70 responseString += "<br><br> " + LoginForm;
71 }
72 return responseString;
73 }
74
75 private string PostNewAccount(string requestBody, string path, string param)
76 {
77 string responseString;
78 string firstName = "";
79 string secondName = "";
80 string userPasswd = "";
81 string[] comp;
82 string[] passw;
83 string[] line;
84 string delimStr = "&";
85 char[] delimiter = delimStr.ToCharArray();
86 string delimStr2 = "=";
87 char[] delimiter2 = delimStr2.ToCharArray();
88
89 //Console.WriteLine(requestBody);
90 comp = requestBody.Split(delimiter);
91 passw = comp[3].Split(delimiter2);
92 if (passw[1] == passWord) // check admin password is correct
93 {
94
95 line = comp[0].Split(delimiter2); //split firstname
96 if (line.Length > 1)
97 {
98 firstName = line[1];
99 }
100 line = comp[1].Split(delimiter2); //split secondname
101 if (line.Length > 1)
102 {
103 secondName = line[1];
104 }
105 line = comp[2].Split(delimiter2); //split user password
106 if (line.Length > 1)
107 {
108 userPasswd = line[1];
109 }
110 if (this._userServer != null)
111 {
112 this._userServer.CreateUserAccount(firstName, secondName, userPasswd);
113 }
114 responseString = "<p> New Account created </p>";
115 }
116 else
117 {
118 responseString = "<p> Admin password is incorrect, please login with the correct password</p>";
119 responseString += "<br><br>" + LoginForm;
120 }
121 return responseString;
122 } 32 }
123
124 private string GetConnectedClientsPage(string request, string path, string param)
125 {
126 string responseString;
127 responseString = " <p> Listing connected Clients </p>";
128 OpenSim.world.Avatar TempAv;
129 foreach (libsecondlife.LLUUID UUID in m_world.Entities.Keys)
130 {
131 if (m_world.Entities[UUID].ToString() == "OpenSim.world.Avatar")
132 {
133 TempAv = (OpenSim.world.Avatar)m_world.Entities[UUID];
134 responseString += "<p> Client: ";
135 responseString += TempAv.firstname + " , " + TempAv.lastname + " , <A HREF=\"javascript:loadXMLDoc('ClientInventory/" + UUID.ToString() + "')\">" + UUID + "</A> , " + TempAv.ControllingClient.SessionID + " , " + TempAv.ControllingClient.CircuitCode + " , " + TempAv.ControllingClient.userEP.ToString();
136 responseString += "</p>";
137 }
138 }
139 return responseString;
140 }
141
142 private string AddTestScript(string request, string path, string param)
143 {
144 int index = path.LastIndexOf('/');
145
146 string lluidStr = path.Substring(index+1);
147
148 LLUUID id;
149
150 if( LLUUID.TryParse( lluidStr, out id ) )
151 {
152 // This is just here for concept purposes... Remove!
153 m_world.AddScript( m_world.Entities[id], new FollowRandomAvatar());
154 return String.Format("Added new script to object [{0}]", id);
155 }
156 else
157 {
158 return String.Format("Couldn't parse [{0}]", lluidStr );
159 }
160 }
161
162 private string GetScriptsPage(string request, string path, string param)
163 {
164 return String.Empty;
165 }
166
167 private string GetEntitiesPage(string request, string path, string param)
168 {
169 string responseString;
170 responseString = " <p> Listing current entities</p><ul>";
171
172 foreach (Entity entity in m_world.Entities.Values)
173 {
174 string testScriptLink = "javascript:loadXMLDoc('Admin/AddTestScript/" + entity.uuid.ToString() + "');";
175 responseString += String.Format( "<li>[{0}] \"{1}\" @ {2} <a href=\"{3}\">add test script</a></li>", entity.uuid, entity.Name, entity.Pos, testScriptLink );
176 }
177 responseString += "</ul>";
178 return responseString;
179 }
180
181 private string GetClientsInventory(string request, string path, string param)
182 {
183 string[] line;
184 string delimStr = "/";
185 char[] delimiter = delimStr.ToCharArray();
186 string responseString;
187 responseString = " <p> Listing Inventory </p>";
188
189 line = path.Split(delimiter);
190 if (line.Length > 2)
191 {
192 if (line[1] == "ClientInventory")
193 {
194 AgentInventory inven = this._inventoryCache.GetAgentsInventory(new libsecondlife.LLUUID(line[2]));
195 responseString += " <p> Client: " + inven.AgentID.ToStringHyphenated() +" </p>";
196 if (inven != null)
197 {
198 foreach (InventoryItem item in inven.InventoryItems.Values)
199 {
200 responseString += "<p> InventoryItem: ";
201 responseString += item.Name +" , "+ item.ItemID +" , "+ item.Type +" , "+ item.FolderID +" , "+ item.AssetID +" , "+ item.Description ;
202 responseString += "</p>";
203 }
204 }
205 }
206 }
207 return responseString;
208 }
209
210 private string GetCachedAssets(string request, string path, string param)
211 {
212 return "";
213 }
214
215 private string GetAccountsPage(string request, string path, string param)
216 {
217 string responseString;
218 responseString = "<p> Account management </p>";
219 responseString += "<br> ";
220 responseString += "<p> Create New Account </p>";
221 responseString += NewAccountForm;
222 return responseString;
223 }
224
225 private string GetAdminPage(string request, string path, string param)
226 {
227 return AdminPage;
228 }
229
230 private void LoadAdminPage()
231 {
232 try
233 {
234 StreamReader SR;
235
236 SR = File.OpenText("testadmin.htm");
237 AdminPage = SR.ReadToEnd();
238 SR.Close();
239
240 SR = File.OpenText("newaccountform.htm");
241 NewAccountForm = SR.ReadToEnd();
242 SR.Close();
243
244 SR = File.OpenText("login.htm");
245 LoginForm = SR.ReadToEnd();
246 SR.Close();
247 }
248 catch (Exception e)
249 {
250 Console.WriteLine(e.ToString());
251 }
252
253 }
254
255 } 33 }
256} 34}