aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.RegionServer/CAPS
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/OpenSim.RegionServer/CAPS/AdminWebFront.cs281
1 files changed, 0 insertions, 281 deletions
diff --git a/OpenSim/OpenSim.RegionServer/CAPS/AdminWebFront.cs b/OpenSim/OpenSim.RegionServer/CAPS/AdminWebFront.cs
deleted file mode 100644
index ead902d..0000000
--- a/OpenSim/OpenSim.RegionServer/CAPS/AdminWebFront.cs
+++ /dev/null
@@ -1,281 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using System.IO;
32using OpenSim.RegionServer.Simulator;
33using OpenSim.UserServer;
34using OpenSim.Servers;
35using OpenSim.RegionServer.Assets;
36using OpenSim.Framework.Inventory;
37using libsecondlife;
38using OpenSim.RegionServer.Scripting;
39using Avatar=libsecondlife.Avatar;
40
41namespace OpenSim.RegionServer.CAPS
42{
43 public class AdminWebFront
44 {
45 private string AdminPage;
46 private string NewAccountForm;
47 private string LoginForm;
48 private string passWord = "Admin";
49 private World m_world;
50 private LoginServer _userServer;
51 private InventoryCache _inventoryCache;
52
53 public AdminWebFront(string password, World world, InventoryCache inventoryCache, LoginServer userserver)
54 {
55 _inventoryCache = inventoryCache;
56 _userServer = userserver;
57 m_world = world;
58 passWord = password;
59 LoadAdminPage();
60 }
61
62 public void LoadMethods( BaseHttpServer server )
63 {
64 server.AddRestHandler("GET", "/Admin", GetAdminPage);
65 server.AddRestHandler("GET", "/Admin/Welcome", GetWelcomePage);
66 server.AddRestHandler("GET", "/Admin/Accounts", GetAccountsPage );
67 server.AddRestHandler("GET", "/Admin/Clients", GetConnectedClientsPage);
68 server.AddRestHandler("GET", "/Admin/Entities", GetEntitiesPage);
69 server.AddRestHandler("GET", "/Admin/Scripts", GetScriptsPage);
70 server.AddRestHandler("GET", "/Admin/AddTestScript", AddTestScript );
71 server.AddRestHandler("GET", "/ClientInventory", GetClientsInventory);
72
73 server.AddRestHandler("POST", "/Admin/NewAccount", PostNewAccount );
74 server.AddRestHandler("POST", "/Admin/Login", PostLogin );
75 }
76
77 private string GetWelcomePage(string request, string path, string param)
78 {
79 string responseString;
80 responseString = "Welcome to the OpenSim Admin Page";
81 responseString += "<br><br><br> " + LoginForm;
82 return responseString;
83 }
84
85 private string PostLogin(string requestBody, string path, string param)
86 {
87 string responseString;
88 if (requestBody == passWord)
89 {
90 responseString = "<p> Login Successful </p>";
91 }
92 else
93 {
94 responseString = "<p> Password Error </p>";
95 responseString += "<p> Please Login with the correct password </p>";
96 responseString += "<br><br> " + LoginForm;
97 }
98 return responseString;
99 }
100
101 private string PostNewAccount(string requestBody, string path, string param)
102 {
103 string responseString;
104 string firstName = "";
105 string secondName = "";
106 string userPasswd = "";
107 string[] comp;
108 string[] passw;
109 string[] line;
110 string delimStr = "&";
111 char[] delimiter = delimStr.ToCharArray();
112 string delimStr2 = "=";
113 char[] delimiter2 = delimStr2.ToCharArray();
114
115 comp = requestBody.Split(delimiter);
116 passw = comp[3].Split(delimiter2);
117 if (passw[1] == passWord) // check admin password is correct
118 {
119
120 line = comp[0].Split(delimiter2); //split firstname
121 if (line.Length > 1)
122 {
123 firstName = line[1];
124 }
125 line = comp[1].Split(delimiter2); //split secondname
126 if (line.Length > 1)
127 {
128 secondName = line[1];
129 }
130 line = comp[2].Split(delimiter2); //split user password
131 if (line.Length > 1)
132 {
133 userPasswd = line[1];
134 }
135 if (this._userServer != null)
136 {
137 this._userServer.CreateUserAccount(firstName, secondName, userPasswd);
138 }
139 responseString = "<p> New Account created </p>";
140 }
141 else
142 {
143 responseString = "<p> Admin password is incorrect, please login with the correct password</p>";
144 responseString += "<br><br>" + LoginForm;
145 }
146 return responseString;
147 }
148
149 private string GetConnectedClientsPage(string request, string path, string param)
150 {
151 string responseString;
152 responseString = " <p> Listing connected Clients </p>";
153 OpenSim.RegionServer.Simulator.Avatar TempAv;
154 foreach (libsecondlife.LLUUID UUID in m_world.Entities.Keys)
155 {
156 if (m_world.Entities[UUID].ToString() == "OpenSim.RegionServer.Simulator.Avatar")
157 {
158 TempAv = (OpenSim.RegionServer.Simulator.Avatar)m_world.Entities[UUID];
159 responseString += "<p> Client: ";
160 responseString += TempAv.firstname + " , " + TempAv.lastname + " , <A HREF=\"javascript:loadXMLDoc('ClientInventory/" + UUID.ToString() + "')\">" + UUID + "</A> , " + TempAv.ControllingClient.SessionID + " , " + TempAv.ControllingClient.CircuitCode + " , " + TempAv.ControllingClient.userEP.ToString();
161 responseString += "</p>";
162 }
163 }
164 return responseString;
165 }
166
167 private string AddTestScript(string request, string path, string param)
168 {
169 int index = path.LastIndexOf('/');
170
171 string lluidStr = path.Substring(index+1);
172
173 LLUUID id;
174
175 if( LLUUID.TryParse( lluidStr, out id ) )
176 {
177 // This is just here for concept purposes... Remove!
178 m_world.AddScript( m_world.Entities[id], new FollowRandomAvatar());
179 return String.Format("Added new script to object [{0}]", id);
180 }
181 else
182 {
183 return String.Format("Couldn't parse [{0}]", lluidStr );
184 }
185 }
186
187 private string GetScriptsPage(string request, string path, string param)
188 {
189 return String.Empty;
190 }
191
192 private string GetEntitiesPage(string request, string path, string param)
193 {
194 string responseString;
195 responseString = " <p> Listing current entities</p><ul>";
196
197 foreach (Entity entity in m_world.Entities.Values)
198 {
199 string testScriptLink = "javascript:loadXMLDoc('Admin/AddTestScript/" + entity.uuid.ToString() + "');";
200 responseString += String.Format( "<li>[{0}] \"{1}\" @ {2} <a href=\"{3}\">add test script</a></li>", entity.uuid, entity.Name, entity.Pos, testScriptLink );
201 }
202 responseString += "</ul>";
203 return responseString;
204 }
205
206 private string GetClientsInventory(string request, string path, string param)
207 {
208 string[] line;
209 string delimStr = "/";
210 char[] delimiter = delimStr.ToCharArray();
211 string responseString;
212 responseString = " <p> Listing Inventory </p>";
213
214 line = path.Split(delimiter);
215 if (line.Length > 2)
216 {
217 if (line[1] == "ClientInventory")
218 {
219 AgentInventory inven = this._inventoryCache.GetAgentsInventory(new libsecondlife.LLUUID(line[2]));
220 responseString += " <p> Client: " + inven.AgentID.ToStringHyphenated() +" </p>";
221 if (inven != null)
222 {
223 foreach (InventoryItem item in inven.InventoryItems.Values)
224 {
225 responseString += "<p> InventoryItem: ";
226 responseString += item.Name +" , "+ item.ItemID +" , "+ item.Type +" , "+ item.FolderID +" , "+ item.AssetID +" , "+ item.Description ;
227 responseString += "</p>";
228 }
229 }
230 }
231 }
232 return responseString;
233 }
234
235 private string GetCachedAssets(string request, string path, string param)
236 {
237 return "";
238 }
239
240 private string GetAccountsPage(string request, string path, string param)
241 {
242 string responseString;
243 responseString = "<p> Account management </p>";
244 responseString += "<br> ";
245 responseString += "<p> Create New Account </p>";
246 responseString += NewAccountForm;
247 return responseString;
248 }
249
250 private string GetAdminPage(string request, string path, string param)
251 {
252 return AdminPage;
253 }
254
255 private void LoadAdminPage()
256 {
257 try
258 {
259 StreamReader SR;
260
261 SR = File.OpenText("testadmin.htm");
262 AdminPage = SR.ReadToEnd();
263 SR.Close();
264
265 SR = File.OpenText("newaccountform.htm");
266 NewAccountForm = SR.ReadToEnd();
267 SR.Close();
268
269 SR = File.OpenText("login.htm");
270 LoginForm = SR.ReadToEnd();
271 SR.Close();
272 }
273 catch (Exception e)
274 {
275 Console.WriteLine(e.ToString());
276 }
277
278 }
279
280 }
281}