aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim.Framework/Util.cs2
-rw-r--r--OpenSim.RegionServer/AgentAssetUpload.cs19
-rw-r--r--OpenSim.RegionServer/Assets/InventoryCache.cs10
-rw-r--r--OpenSim.RegionServer/CAPS/SimHttp.cs166
-rw-r--r--OpenSim.RegionServer/SimClient.cs18
-rw-r--r--bin/login.htm5
-rw-r--r--bin/newaccountform.htm9
-rw-r--r--bin/testadmin.htm124
8 files changed, 340 insertions, 13 deletions
diff --git a/OpenSim.Framework/Util.cs b/OpenSim.Framework/Util.cs
index 440ce41..695cac9 100644
--- a/OpenSim.Framework/Util.cs
+++ b/OpenSim.Framework/Util.cs
@@ -9,7 +9,7 @@ namespace OpenSim.Framework.Utilities
9 public class Util 9 public class Util
10 { 10 {
11 private static Random randomClass = new Random(); 11 private static Random randomClass = new Random();
12 private static uint nextXferID = 10000; 12 private static uint nextXferID = 5000;
13 private static object XferLock = new object(); 13 private static object XferLock = new object();
14 14
15 public static ulong UIntsToLong(uint X, uint Y) 15 public static ulong UIntsToLong(uint X, uint Y)
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
79 79
80 80
81 } 81 }
82 /* for now we will only support uploading of textures
83 else if (pack.AssetBlock.Type == 13 | pack.AssetBlock.Type == 5) 82 else if (pack.AssetBlock.Type == 13 | pack.AssetBlock.Type == 5)
84 { 83 {
85 84
@@ -92,7 +91,7 @@ namespace OpenSim
92 asset.Data = pack.AssetBlock.AssetData; 91 asset.Data = pack.AssetBlock.AssetData;
93 92
94 93
95 }*/ 94 }
96 95
97 if (asset != null) 96 if (asset != null)
98 { 97 {
@@ -169,6 +168,22 @@ namespace OpenSim
169 168
170 #endregion 169 #endregion
171 170
171 public AssetBase AddUploadToAssetCache(LLUUID transactionID)
172 {
173 AssetBase asset = null;
174 if(this.transactions.ContainsKey(transactionID))
175 {
176 AssetTransaction trans = this.transactions[transactionID];
177 if (trans.UploadComplete)
178 {
179 OpenSimRoot.Instance.AssetCache.AddAsset(trans.Asset);
180 asset = trans.Asset;
181 }
182 }
183
184 return asset;
185 }
186
172 public void CreateInventoryItem(CreateInventoryItemPacket packet) 187 public void CreateInventoryItem(CreateInventoryItemPacket packet)
173 { 188 {
174 if(this.transactions.ContainsKey(packet.InventoryBlock.TransactionID)) 189 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
57 this._agentsInventory.Add(agentInventory.AgentID, agentInventory); 57 this._agentsInventory.Add(agentInventory.AgentID, agentInventory);
58 } 58 }
59 59
60 public AgentInventory GetAgentsInventory(LLUUID agentID)
61 {
62 if (this._agentsInventory.ContainsKey(agentID))
63 {
64 return this._agentsInventory[agentID];
65 }
66
67 return null;
68 }
69
60 public void ClientLeaving(LLUUID clientID) 70 public void ClientLeaving(LLUUID clientID)
61 { 71 {
62 if (this._agentsInventory.ContainsKey(clientID)) 72 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
48 { 48 {
49 public Thread HTTPD; 49 public Thread HTTPD;
50 public HttpListener Listener; 50 public HttpListener Listener;
51 private string AdminPage;
52 private string NewAccountForm;
53 private string LoginForm;
54 private string passWord = "Admin";
51 55
52 public SimCAPSHTTPServer() 56 public SimCAPSHTTPServer()
53 { 57 {
54 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Starting up HTTP Server"); 58 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Starting up HTTP Server");
55 HTTPD = new Thread(new ThreadStart(StartHTTP)); 59 HTTPD = new Thread(new ThreadStart(StartHTTP));
56 HTTPD.Start(); 60 HTTPD.Start();
61 LoadAdminPage();
57 } 62 }
58 63
59 public void StartHTTP() 64 public void StartHTTP()
@@ -79,7 +84,7 @@ namespace OpenSim.CAPS
79 } 84 }
80 } 85 }
81 86
82 static string ParseXMLRPC(string requestBody) 87 private string ParseXMLRPC(string requestBody)
83 { 88 {
84 try 89 try
85 { 90 {
@@ -111,19 +116,101 @@ namespace OpenSim.CAPS
111 return ""; 116 return "";
112 } 117 }
113 118
114 static string ParseREST(string requestBody, string requestURL) 119 private string ParseREST(string requestBody, string requestURL, string requestMethod)
115 { 120 {
116 return ""; 121 string responseString = "";
122 switch (requestURL)
123 {
124 case "/Admin/Accounts":
125 if (requestMethod == "GET")
126 {
127 responseString = "<p> Account management </p>";
128 responseString += "<br> ";
129 responseString += "<p> Create New Account </p>";
130 responseString += NewAccountForm;
131 }
132 break;
133 case "/Admin/Clients":
134 if (requestMethod == "GET")
135 {
136 responseString = " <p> Listing connected Clients </p>" ;
137 OpenSim.world.Avatar TempAv;
138 foreach (libsecondlife.LLUUID UUID in OpenSimRoot.Instance.LocalWorld.Entities.Keys)
139 {
140 if (OpenSimRoot.Instance.LocalWorld.Entities[UUID].ToString() == "OpenSim.world.Avatar")
141 {
142 TempAv = (OpenSim.world.Avatar)OpenSimRoot.Instance.LocalWorld.Entities[UUID];
143 responseString += "<p>";
144 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());
145 responseString += "</p>";
146 }
147 }
148 }
149 break;
150 case "/Admin/NewAccount":
151 if (requestMethod == "POST")
152 {
153 string[] comp = new string[10];
154 string[] passw = new string[3];
155 string delimStr = "&";
156 char[] delimiter = delimStr.ToCharArray();
157 string delimStr2 = "=";
158 char[] delimiter2 = delimStr2.ToCharArray();
159
160 //Console.WriteLine(requestBody);
161 comp = requestBody.Split(delimiter);
162 passw = comp[3].Split(delimiter2);
163 if (passw[1] == passWord)
164 {
165 responseString = "<p> New Account created </p>";
166 }
167 else
168 {
169 responseString = "<p> Admin password is incorrect, please login with the correct password</p>";
170 responseString += "<br><br>" + LoginForm;
171 }
172
173
174 }
175 break;
176 case "/Admin/Login":
177 if (requestMethod == "POST")
178 {
179 Console.WriteLine(requestBody);
180 if (requestBody == passWord)
181 {
182 responseString = "<p> Login Successful </p>";
183 }
184 else
185 {
186 responseString = "<p> PassWord Error </p>";
187 responseString += "<p> Please Login with the correct password </p>";
188 responseString += "<br><br> " + LoginForm;
189 }
190 }
191 break;
192 case "/Admin/Welcome":
193 if (requestMethod == "GET")
194 {
195 responseString = "Welcome to the OpenSim Admin Page";
196 responseString += "<br><br><br> " + LoginForm;
197
198 }
199 break;
200 }
201
202 return responseString;
117 } 203 }
118 204
119 static string ParseLLSDXML(string requestBody) 205 private string ParseLLSDXML(string requestBody)
120 { 206 {
121 // dummy function for now - IMPLEMENT ME! 207 // dummy function for now - IMPLEMENT ME!
122 return ""; 208 return "";
123 } 209 }
124 210
125 static void HandleRequest(Object stateinfo) 211 public void HandleRequest(Object stateinfo)
126 { 212 {
213 // Console.WriteLine("new http incoming");
127 HttpListenerContext context = (HttpListenerContext)stateinfo; 214 HttpListenerContext context = (HttpListenerContext)stateinfo;
128 215
129 HttpListenerRequest request = context.Request; 216 HttpListenerRequest request = context.Request;
@@ -140,6 +227,9 @@ namespace OpenSim.CAPS
140 body.Close(); 227 body.Close();
141 reader.Close(); 228 reader.Close();
142 229
230 //Console.WriteLine(request.HttpMethod + " " + request.RawUrl + " Http/" + request.ProtocolVersion.ToString() + " content type: " + request.ContentType);
231 //Console.WriteLine(requestBody);
232
143 string responseString = ""; 233 string responseString = "";
144 switch (request.ContentType) 234 switch (request.ContentType)
145 { 235 {
@@ -156,10 +246,26 @@ namespace OpenSim.CAPS
156 response.AddHeader("Content-type", "application/xml"); 246 response.AddHeader("Content-type", "application/xml");
157 break; 247 break;
158 248
249 case "application/x-www-form-urlencoded":
250 // a form data POST so send to the REST parser
251 responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod);
252 response.AddHeader("Content-type", "text/html");
253 break;
254
159 case null: 255 case null:
160 // must be REST or invalid crap, so pass to the REST parser 256 if ((request.HttpMethod == "GET") && (request.RawUrl == "/Admin"))
161 responseString = ParseREST(request.Url.OriginalString, requestBody); 257 {
258 responseString = AdminPage;
259 response.AddHeader("Content-type", "text/html");
260 }
261 else
262 {
263 // must be REST or invalid crap, so pass to the REST parser
264 responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod);
265 response.AddHeader("Content-type", "text/html");
266 }
162 break; 267 break;
268
163 } 269 }
164 270
165 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString); 271 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
@@ -169,6 +275,52 @@ namespace OpenSim.CAPS
169 output.Write(buffer, 0, buffer.Length); 275 output.Write(buffer, 0, buffer.Length);
170 output.Close(); 276 output.Close();
171 } 277 }
278
279 private void LoadAdminPage()
280 {
281 try
282 {
283 StreamReader SR;
284 string lines;
285 AdminPage = "";
286 NewAccountForm = "";
287 LoginForm = "";
288 SR = File.OpenText("testadmin.htm");
289
290 while (!SR.EndOfStream)
291 {
292 lines = SR.ReadLine();
293 AdminPage += lines + "\n";
294
295 }
296 SR.Close();
297
298 SR = File.OpenText("newaccountform.htm");
299
300 while (!SR.EndOfStream)
301 {
302 lines = SR.ReadLine();
303 NewAccountForm += lines + "\n";
304
305 }
306 SR.Close();
307
308 SR = File.OpenText("login.htm");
309
310 while (!SR.EndOfStream)
311 {
312 lines = SR.ReadLine();
313 LoginForm += lines + "\n";
314
315 }
316 SR.Close();
317 }
318 catch (Exception e)
319 {
320 Console.WriteLine(e.ToString());
321 }
322
323 }
172 } 324 }
173 325
174 326
diff --git a/OpenSim.RegionServer/SimClient.cs b/OpenSim.RegionServer/SimClient.cs
index dea385c..811e8b8 100644
--- a/OpenSim.RegionServer/SimClient.cs
+++ b/OpenSim.RegionServer/SimClient.cs
@@ -287,7 +287,7 @@ namespace OpenSim
287 //this.UploadAssets.HandleUploadPacket(request, LLUUID.Random()); 287 //this.UploadAssets.HandleUploadPacket(request, LLUUID.Random());
288 //} 288 //}
289 //else 289 //else
290 //{*/ 290 //{
291 this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID)); 291 this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID));
292 //} 292 //}
293 break; 293 break;
@@ -318,13 +318,25 @@ namespace OpenSim
318 OpenSimRoot.Instance.InventoryCache.FetchInventoryDescendents(this, Fetch); 318 OpenSimRoot.Instance.InventoryCache.FetchInventoryDescendents(this, Fetch);
319 break; 319 break;
320 case PacketType.UpdateInventoryItem: 320 case PacketType.UpdateInventoryItem:
321 /* UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack; 321 /*
322 UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack;
322 for (int i = 0; i < update.InventoryData.Length; i++) 323 for (int i = 0; i < update.InventoryData.Length; i++)
323 { 324 {
324 if (update.InventoryData[i].TransactionID != LLUUID.Zero) 325 if (update.InventoryData[i].TransactionID != LLUUID.Zero)
325 { 326 {
326 AssetBase asset = OpenSimRoot.Instance.AssetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID)); 327 AssetBase asset = OpenSimRoot.Instance.AssetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID));
327 OpenSimRoot.Instance.InventoryCache.UpdateInventoryItem(this, update.InventoryData[i].ItemID, asset); 328 if (asset != null)
329 {
330 OpenSimRoot.Instance.InventoryCache.UpdateInventoryItem(this, update.InventoryData[i].ItemID, asset);
331 }
332 else
333 {
334 asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID);
335 if (asset != null)
336 {
337 OpenSimRoot.Instance.InventoryCache.UpdateInventoryItem(this, update.InventoryData[i].ItemID, asset);
338 }
339 }
328 } 340 }
329 }*/ 341 }*/
330 break; 342 break;
diff --git a/bin/login.htm b/bin/login.htm
new file mode 100644
index 0000000..2becee9
--- /dev/null
+++ b/bin/login.htm
@@ -0,0 +1,5 @@
1<form action="javascript:setpass();" name="logon" id="logon">
2<p> Admin PassWord: <input type="password" id="Adminpss" size="17" maxlength="34"> </P>
3<input type="button" name="button" value="Login"
4 onclick="javascript:setpass(this.parentNode);">
5</form> \ No newline at end of file
diff --git a/bin/newaccountform.htm b/bin/newaccountform.htm
new file mode 100644
index 0000000..d21b983
--- /dev/null
+++ b/bin/newaccountform.htm
@@ -0,0 +1,9 @@
1<form action="javascript:get(document.getElementById('myform'));" name="myform" id="myform">
2<p> First Name: <input type="text" id="FirstName" size="17" maxlength="44"> </P>
3<p> Last Name:
4<input type="text" id="LastName" size="17" maxlength="44"> </p>
5<p> PassWord:
6<input type="password" id="PassWord" size="17" maxlength="44"> </p>
7<br>
8<input type="button" name="button" value="Create" onclick="javascript:get(this.parentNode);">
9</form> \ No newline at end of file
diff --git a/bin/testadmin.htm b/bin/testadmin.htm
new file mode 100644
index 0000000..4252ffd
--- /dev/null
+++ b/bin/testadmin.htm
@@ -0,0 +1,124 @@
1<html>
2<head>
3<script type="text/javascript">
4var http_request
5var adminpadd
6function loadXMLDoc(url)
7{
8http_request=null
9// code for Mozilla, etc.
10if (window.XMLHttpRequest)
11 {
12 http_request=new XMLHttpRequest()
13 }
14// code for IE
15else if (window.ActiveXObject)
16 {
17 http_request=new ActiveXObject("Microsoft.XMLHTTP")
18 }
19if (http_request!=null)
20 {
21 http_request.onreadystatechange=state_Change
22 http_request.open("GET",url,true)
23 http_request.send(null)
24 }
25else
26 {
27 alert("Your browser does not support XMLHTTP.")
28 }
29}
30
31function state_Change()
32{
33// if xmlhttp shows "loaded"
34if (http_request.readyState==4)
35 {
36 // if "OK"
37 if (http_request.status==200)
38 {
39 document.getElementById('T1').innerHTML=http_request.responseText
40 }
41 else
42 {
43 alert("Problem retrieving data:" + http_request.statusText)
44 }
45 }
46}
47
48
49 //var http_request = false;
50 function makePOSTRequest(url, parameters) {
51 http_request = false;
52 if (window.XMLHttpRequest) { // Mozilla, Safari,...
53 http_request = new XMLHttpRequest();
54 if (http_request.overrideMimeType) {
55 // set type accordingly to anticipated content type
56 //http_request.overrideMimeType('text/xml');
57 http_request.overrideMimeType('text/html');
58 }
59 } else if (window.ActiveXObject) { // IE
60 try {
61 http_request = new ActiveXObject("Msxml2.XMLHTTP");
62 } catch (e) {
63 try {
64 http_request = new ActiveXObject("Microsoft.XMLHTTP");
65 } catch (e) {}
66 }
67 }
68 if (!http_request) {
69 alert('Cannot create XMLHTTP instance');
70 return false;
71 }
72
73 http_request.onreadystatechange =state_Change
74 http_request.open('POST', url, true);
75 http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
76 http_request.setRequestHeader("Content-length", parameters.length);
77 http_request.setRequestHeader("Connection", "close");
78 http_request.send(parameters);
79 }
80
81 function alertContents() {
82 if (http_request.readyState == 4) {
83 if (http_request.status == 200) {
84 //alert(http_request.responseText);
85 result = http_request.responseText;
86 document.getElementById('T1').innerHTML = result;
87 } else {
88 alert('There was a problem with the request.');
89 }
90 }
91 }
92
93
94 function get(obj) {
95 var poststr = "FirstName=" + encodeURI( document.getElementById("FirstName").value ) +
96 "&LastName=" + encodeURI( document.getElementById("LastName").value )
97 + "&PassWord=" + encodeURI( document.getElementById("PassWord").value )
98 + "&AdminPass=" + adminpass;
99 makePOSTRequest('Admin/NewAccount', poststr);
100 }
101
102 function setpass(obj)
103 {
104 adminpass = encodeURI( document.getElementById("Adminpss").value );
105 makePOSTRequest('Admin/Login', adminpass);
106
107 }
108
109</script>
110</head>
111
112<body onload="loadXMLDoc('Admin/Welcome')">
113<div id="T1" style="border:1px solid black;height:500;width:600">
114<br>
115</div><br />
116<button onclick="loadXMLDoc('Admin/Clients')">Clients</button>
117<button onclick="loadXMLDoc('Admin/Accounts')">Accounts</button>
118
119</body>
120
121</html>
122
123
124