diff options
author | onefang | 2019-08-08 04:11:54 +1000 |
---|---|---|
committer | onefang | 2019-08-08 04:11:54 +1000 |
commit | bab33ad24a4b960dc97eb0e179e99e52b12a1706 (patch) | |
tree | b1caa8abc1e4aa7b098ab910de0e9e5eaf915ef6 | |
parent | More account manager. (diff) | |
download | opensim-SC_OLD-bab33ad24a4b960dc97eb0e179e99e52b12a1706.zip opensim-SC_OLD-bab33ad24a4b960dc97eb0e179e99e52b12a1706.tar.gz opensim-SC_OLD-bab33ad24a4b960dc97eb0e179e99e52b12a1706.tar.bz2 opensim-SC_OLD-bab33ad24a4b960dc97eb0e179e99e52b12a1706.tar.xz |
Various clean ups.
-rw-r--r-- | OpenSim/Server/Handlers/Web/WebServerInConnector.cs | 113 | ||||
-rwxr-xr-x | scripts/start-sim | 6 |
2 files changed, 47 insertions, 72 deletions
diff --git a/OpenSim/Server/Handlers/Web/WebServerInConnector.cs b/OpenSim/Server/Handlers/Web/WebServerInConnector.cs index 1dedfa3..bcfb7ac 100644 --- a/OpenSim/Server/Handlers/Web/WebServerInConnector.cs +++ b/OpenSim/Server/Handlers/Web/WebServerInConnector.cs | |||
@@ -1,30 +1,3 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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 | |||
28 | using System; | 1 | using System; |
29 | using System.Collections; | 2 | using System.Collections; |
30 | using System.Collections.Generic; | 3 | using System.Collections.Generic; |
@@ -34,11 +7,11 @@ using System.Reflection; | |||
34 | using System.Security; | 7 | using System.Security; |
35 | using System.Text; | 8 | using System.Text; |
36 | using log4net; | 9 | using log4net; |
10 | using Nini.Config; | ||
37 | using OpenMetaverse; | 11 | using OpenMetaverse; |
38 | using OpenMetaverse.StructuredData; | 12 | using OpenMetaverse.StructuredData; |
39 | using Nini.Config; | ||
40 | using OpenSim.Framework; | ||
41 | using OpenSim.Data.MySQL; | 13 | using OpenSim.Data.MySQL; |
14 | using OpenSim.Framework; | ||
42 | using OpenSim.Framework.Servers.HttpServer; | 15 | using OpenSim.Framework.Servers.HttpServer; |
43 | using OpenSim.Server.Handlers.Base; | 16 | using OpenSim.Server.Handlers.Base; |
44 | 17 | ||
@@ -55,14 +28,12 @@ namespace OpenSim.Server.Handlers.Web | |||
55 | 28 | ||
56 | public WebServerInConnector(IConfigSource config, IHttpServer server, string configName) : base(config, server, configName) | 29 | public WebServerInConnector(IConfigSource config, IHttpServer server, string configName) : base(config, server, configName) |
57 | { | 30 | { |
58 | m_Config = config; | ||
59 | |||
60 | string dllName = String.Empty; | 31 | string dllName = String.Empty; |
61 | string connString = String.Empty; | 32 | string connString = String.Empty; |
62 | 33 | ||
63 | // | 34 | m_Config = config; |
35 | |||
64 | // Try reading the [DatabaseService] section, if it exists | 36 | // Try reading the [DatabaseService] section, if it exists |
65 | // | ||
66 | IConfig dbConfig = m_Config.Configs["DatabaseService"]; | 37 | IConfig dbConfig = m_Config.Configs["DatabaseService"]; |
67 | if (dbConfig != null) | 38 | if (dbConfig != null) |
68 | { | 39 | { |
@@ -71,7 +42,6 @@ namespace OpenSim.Server.Handlers.Web | |||
71 | if (connString == String.Empty) | 42 | if (connString == String.Empty) |
72 | connString = dbConfig.GetString("ConnectionString", String.Empty); | 43 | connString = dbConfig.GetString("ConnectionString", String.Empty); |
73 | } | 44 | } |
74 | |||
75 | if (dllName.Equals(String.Empty)) | 45 | if (dllName.Equals(String.Empty)) |
76 | throw new Exception("No StorageProvider configured"); | 46 | throw new Exception("No StorageProvider configured"); |
77 | 47 | ||
@@ -80,8 +50,6 @@ namespace OpenSim.Server.Handlers.Web | |||
80 | // m_Database = LoadPlugin<SQLGenericHandler>(dllName, new Object[] { connString }); | 50 | // m_Database = LoadPlugin<SQLGenericHandler>(dllName, new Object[] { connString }); |
81 | 51 | ||
82 | m_database = new MySQLRaw(connString); | 52 | m_database = new MySQLRaw(connString); |
83 | if (m_database == null) | ||
84 | throw new Exception("Could not find a storage interface in the given module " + dllName); | ||
85 | 53 | ||
86 | mime.Add(".gz", "application/gzip"); | 54 | mime.Add(".gz", "application/gzip"); |
87 | mime.Add(".js", "application/javascript"); | 55 | mime.Add(".js", "application/javascript"); |
@@ -111,24 +79,24 @@ namespace OpenSim.Server.Handlers.Web | |||
111 | 79 | ||
112 | IConfig cfg = m_Config.Configs["GridInfoService"]; | 80 | IConfig cfg = m_Config.Configs["GridInfoService"]; |
113 | string HomeURI = Util.GetConfigVarFromSections<string>(m_Config, "HomeURI", new string[] { "Startup", "Hypergrid" }, String.Empty); | 81 | string HomeURI = Util.GetConfigVarFromSections<string>(m_Config, "HomeURI", new string[] { "Startup", "Hypergrid" }, String.Empty); |
114 | ssi.Add("grid", cfg.GetString("gridname", "my grid")); | 82 | ssi.Add("grid", cfg.GetString("gridname", "my grid")); |
115 | ssi.Add("uri", cfg.GetString("login", HomeURI)); | 83 | ssi.Add("uri", cfg.GetString("login", HomeURI)); |
116 | ssi.Add("version", VersionInfo.Version); | 84 | ssi.Add("version", VersionInfo.Version); |
117 | server.AddHTTPHandler("/web/", WebRequestHandler); | 85 | server.AddHTTPHandler("/web/", WebRequestHandler); |
118 | } | 86 | } |
119 | 87 | ||
120 | private Hashtable WebRequestHandler(Hashtable request) | 88 | private Hashtable WebRequestHandler(Hashtable request) |
121 | { | 89 | { |
122 | long locIn = m_database.Count("Presence", "RegionID != '00000000-0000-0000-0000-000000000000'"); // Locals online but not HGing, and HGers in world. | 90 | long locIn = m_database.Count("Presence", "RegionID != '00000000-0000-0000-0000-000000000000'"); // Locals online but not HGing, and HGers in world. |
123 | long HGin = m_database.Count("Presence", "UserID NOT IN (SELECT PrincipalID FROM UserAccounts)"); // HGers in world. | 91 | long HGin = m_database.Count("Presence", "UserID NOT IN (SELECT PrincipalID FROM UserAccounts)"); // HGers in world. |
124 | long locOut = m_database.Count("hg_traveling_data", "GridExternalName != '" + ssi["uri"] + "'"); // Locals that are HGing. | 92 | long locOut = m_database.Count("hg_traveling_data", "GridExternalName != '" + ssi["uri"] + "'"); // Locals that are HGing. |
125 | Hashtable reply = new Hashtable(); | 93 | Hashtable reply = new Hashtable(); |
126 | ssi["members"] = m_database.Count("UserAccounts").ToString(); | 94 | ssi["members"] = m_database.Count("UserAccounts").ToString(); |
127 | ssi["sims"] = m_database.Count("regions").ToString(); | 95 | ssi["sims"] = m_database.Count("regions").ToString(); |
128 | ssi["inworld"] = (locIn - HGin).ToString(); | 96 | ssi["inworld"] = (locIn - HGin).ToString(); |
129 | ssi["outworld"] = locOut.ToString(); | 97 | ssi["outworld"] = locOut.ToString(); |
130 | ssi["hgers"] = HGin.ToString(); | 98 | ssi["hgers"] = HGin.ToString(); |
131 | ssi["month"] = m_database.Count("GridUser", "Login > UNIX_TIMESTAMP(FROM_UNIXTIME(UNIX_TIMESTAMP(now()) - 2419200))").ToString(); | 99 | ssi["month"] = m_database.Count("GridUser", "Login > UNIX_TIMESTAMP(FROM_UNIXTIME(UNIX_TIMESTAMP(now()) - 2419200))").ToString(); |
132 | 100 | ||
133 | string reqpath = (string) request["uri"]; | 101 | string reqpath = (string) request["uri"]; |
134 | string[] query = (string[]) request["querystringkeys"]; | 102 | string[] query = (string[]) request["querystringkeys"]; |
@@ -148,26 +116,26 @@ namespace OpenSim.Server.Handlers.Web | |||
148 | reply["int_response_code"] = 200; | 116 | reply["int_response_code"] = 200; |
149 | if ("GET" == method) | 117 | if ("GET" == method) |
150 | { | 118 | { |
151 | if (File.Exists(path)) | 119 | if (File.Exists(path)) |
152 | { | 120 | { |
153 | string m = (string) mime[Path.GetExtension(path).ToLower()]; | 121 | string m = (string) mime[Path.GetExtension(path).ToLower()]; |
154 | reply["content_type"] = m; | 122 | reply["content_type"] = m; |
155 | if ((null == m) || ("text/" != m.Substring(0, 5))) | 123 | if ((null == m) || ("text/" != m.Substring(0, 5))) |
156 | reply["bin_response_data"] = File.ReadAllBytes(path); | 124 | reply["bin_response_data"] = File.ReadAllBytes(path); |
157 | else | 125 | else |
158 | { | 126 | { |
159 | StreamReader csr = File.OpenText(path); | 127 | StreamReader csr = File.OpenText(path); |
160 | string content = csr.ReadToEnd(); | 128 | string content = csr.ReadToEnd(); |
161 | // Slow and wasteful, but I'm expecting only tiny web files, not accessed very often. | 129 | // Slow and wasteful, but I'm expecting only tiny web files, not accessed very often. |
162 | foreach (DictionaryEntry v in ssi) | 130 | foreach (DictionaryEntry v in ssi) |
163 | { | 131 | { |
164 | content = content.Replace("<!--#echo var=\"" + ((string) v.Key) + "\" -->", (string) v.Value); | 132 | content = content.Replace("<!--#echo var=\"" + ((string) v.Key) + "\" -->", (string) v.Value); |
165 | } | 133 | } |
166 | reply["str_response_string"] = content; | 134 | reply["str_response_string"] = content; |
167 | csr.Close(); | 135 | csr.Close(); |
168 | } | 136 | } |
169 | } | 137 | } |
170 | else | 138 | else |
171 | { | 139 | { |
172 | if ("account.html" == file) | 140 | if ("account.html" == file) |
173 | reply["str_response_string"] = loginPage(null, ""); | 141 | reply["str_response_string"] = loginPage(null, ""); |
@@ -303,7 +271,7 @@ namespace OpenSim.Server.Handlers.Web | |||
303 | { | 271 | { |
304 | return "<html>\n <head>\n <title>" + title + "</title>\n </head>\n <body>\n"; | 272 | return "<html>\n <head>\n <title>" + title + "</title>\n </head>\n <body>\n"; |
305 | } | 273 | } |
306 | // account.html?token=&UUID=.... | 274 | |
307 | private string table(List< Hashtable > rows, string[] fields, string caption, string URL, string id) | 275 | private string table(List< Hashtable > rows, string[] fields, string caption, string URL, string id) |
308 | { | 276 | { |
309 | string tbl = "<table border=\"1\"><caption>" + caption + "</caption>"; | 277 | string tbl = "<table border=\"1\"><caption>" + caption + "</caption>"; |
@@ -350,14 +318,17 @@ namespace OpenSim.Server.Handlers.Web | |||
350 | } | 318 | } |
351 | return tbl + "</table>"; | 319 | return tbl + "</table>"; |
352 | } | 320 | } |
321 | |||
353 | private string form(string action, string token, string form) | 322 | private string form(string action, string token, string form) |
354 | { | 323 | { |
355 | return " <form action=\"" + action + "\" method=\"POST\">\n" + hidden("token", token) + form + " </form>\n"; | 324 | return " <form action=\"" + action + "\" method=\"POST\">\n" + hidden("token", token) + form + " </form>\n"; |
356 | } | 325 | } |
326 | |||
357 | private string hidden(string name, string val) | 327 | private string hidden(string name, string val) |
358 | { | 328 | { |
359 | return " <input type=\"hidden\" name=\"" + name + "\" value=\"" + val + "\">\n"; | 329 | return " <input type=\"hidden\" name=\"" + name + "\" value=\"" + val + "\">\n"; |
360 | } | 330 | } |
331 | |||
361 | private string text(string type, string title, string name, string val, int max, bool required) | 332 | private string text(string type, string title, string name, string val, int max, bool required) |
362 | { | 333 | { |
363 | string extra = ""; | 334 | string extra = ""; |
@@ -369,10 +340,12 @@ namespace OpenSim.Server.Handlers.Web | |||
369 | val = "value=\"" + val + "\""; | 340 | val = "value=\"" + val + "\""; |
370 | return " <p>" + title + " : <input type=\"" + type + "\" name=\"" + name + "\"" + val + extra + "></p>\n"; | 341 | return " <p>" + title + " : <input type=\"" + type + "\" name=\"" + name + "\"" + val + extra + "></p>\n"; |
371 | } | 342 | } |
343 | |||
372 | private string select(string title, string name, string options) | 344 | private string select(string title, string name, string options) |
373 | { | 345 | { |
374 | return " <p>" + title + " : \n <select name=\"" + name + "\">\n" + options + " </select>\n </p>\n"; | 346 | return " <p>" + title + " : \n <select name=\"" + name + "\">\n" + options + " </select>\n </p>\n"; |
375 | } | 347 | } |
348 | |||
376 | private string option(string title, bool selected) | 349 | private string option(string title, bool selected) |
377 | { | 350 | { |
378 | string sel = ""; | 351 | string sel = ""; |
@@ -380,10 +353,12 @@ namespace OpenSim.Server.Handlers.Web | |||
380 | sel = " selected"; | 353 | sel = " selected"; |
381 | return " <option value=\"" + title + "\"" + sel + ">" + title + "</option>\n"; | 354 | return " <option value=\"" + title + "\"" + sel + ">" + title + "</option>\n"; |
382 | } | 355 | } |
356 | |||
383 | private string button(string title) | 357 | private string button(string title) |
384 | { | 358 | { |
385 | return " <button type=\"submit\" name=\"doit\" value=\"" + title + "\">" + title + "</button>\n"; | 359 | return " <button type=\"submit\" name=\"doit\" value=\"" + title + "\">" + title + "</button>\n"; |
386 | } | 360 | } |
361 | |||
387 | private string footer() | 362 | private string footer() |
388 | { | 363 | { |
389 | return " </body>\n</html>\n"; | 364 | return " </body>\n</html>\n"; |
diff --git a/scripts/start-sim b/scripts/start-sim index 78e627d..bf6a32e 100755 --- a/scripts/start-sim +++ b/scripts/start-sim | |||
@@ -55,10 +55,10 @@ if [ "x$1" = "x" ]; then | |||
55 | if [ "$tgt" = "scripts" ]; then | 55 | if [ "$tgt" = "scripts" ]; then |
56 | uptime | 56 | uptime |
57 | pushd ${PRGDIR}/../../config/ROBUST >/dev/null | 57 | pushd ${PRGDIR}/../../config/ROBUST >/dev/null |
58 | ./start-sim $quiet | 58 | ./start-sim -q |
59 | popd > /dev/null | ||
59 | echo "Sleeping for $((${delay} / 2)) seconds." | 60 | echo "Sleeping for $((${delay} / 2)) seconds." |
60 | sleep $((${delay} / 2)) | 61 | sleep $((${delay} / 2)) |
61 | popd > /dev/null | ||
62 | for i in $(seq -w 1 99) | 62 | for i in $(seq -w 1 99) |
63 | do | 63 | do |
64 | j=$(num2name ${i}) | 64 | j=$(num2name ${i}) |
@@ -68,12 +68,12 @@ if [ "x$1" = "x" ]; then | |||
68 | echo "Starting ${j}." | 68 | echo "Starting ${j}." |
69 | pushd ${PRGDIR}/../../config/${j} >/dev/null | 69 | pushd ${PRGDIR}/../../config/${j} >/dev/null |
70 | ./start-sim -w | 70 | ./start-sim -w |
71 | popd > /dev/null | ||
71 | uptime | 72 | uptime |
72 | # Sleep for a while, so that there is plenty of time to finish starting scripts and such, | 73 | # Sleep for a while, so that there is plenty of time to finish starting scripts and such, |
73 | # and we are not keeping the computer very busy if there are lots of sims. | 74 | # and we are not keeping the computer very busy if there are lots of sims. |
74 | echo "Sleeping for ${delay} seconds." | 75 | echo "Sleeping for ${delay} seconds." |
75 | sleep ${delay} | 76 | sleep ${delay} |
76 | popd > /dev/null | ||
77 | fi | 77 | fi |
78 | done | 78 | done |
79 | uptime | 79 | uptime |