aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authoronefang2019-08-05 01:41:34 +1000
committeronefang2019-08-05 01:41:34 +1000
commit5fae30eb8863f3f39e6853584fd49197c52e8835 (patch)
treed4b8d58cde836103b17dec6539c59d4524caf3c9
parentWarning-- (diff)
downloadopensim-SC-5fae30eb8863f3f39e6853584fd49197c52e8835.zip
opensim-SC-5fae30eb8863f3f39e6853584fd49197c52e8835.tar.gz
opensim-SC-5fae30eb8863f3f39e6853584fd49197c52e8835.tar.bz2
opensim-SC-5fae30eb8863f3f39e6853584fd49197c52e8835.tar.xz
More basic web server.
Diffstat (limited to '')
-rw-r--r--OpenSim/Server/Handlers/Web/WebServerInConnector.cs53
-rw-r--r--example/web/loginpage.html17
2 files changed, 53 insertions, 17 deletions
diff --git a/OpenSim/Server/Handlers/Web/WebServerInConnector.cs b/OpenSim/Server/Handlers/Web/WebServerInConnector.cs
index 94c636f..e7fb2fc 100644
--- a/OpenSim/Server/Handlers/Web/WebServerInConnector.cs
+++ b/OpenSim/Server/Handlers/Web/WebServerInConnector.cs
@@ -45,27 +45,60 @@ namespace OpenSim.Server.Handlers.Web
45{ 45{
46 public class WebServerInConnector : ServiceConnector 46 public class WebServerInConnector : ServiceConnector
47 { 47 {
48 // This is all slow and clunky, it's not a real web server, just something to use if you don't want a real one.
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 private IConfigSource m_Config; 50 private IConfigSource m_Config;
50 private Hashtable mime = new Hashtable(); 51 private Hashtable mime = new Hashtable();
52 private Hashtable ssi = new Hashtable();
51 53
52 public WebServerInConnector(IConfigSource config, IHttpServer server, string configName) : base(config, server, configName) 54 public WebServerInConnector(IConfigSource config, IHttpServer server, string configName) : base(config, server, configName)
53 { 55 {
54 m_Config = config; 56 m_Config = config;
57 mime.Add(".gz", "application/gzip");
58 mime.Add(".js", "application/javascript");
59 mime.Add(".json", "application/json");
60 mime.Add(".pdf", "application/pdf");
61 mime.Add(".rtf", "application/rtf");
62 mime.Add(".zip", "application/zip");
63 mime.Add(".xz", "application/x-xz");
64 mime.Add(".gif", "image/gif");
65 mime.Add(".png", "image/png");
66 mime.Add(".jp2", "image/jp2");
67 mime.Add(".jpg2", "image/jp2");
68 mime.Add(".jpe", "image/jpeg");
69 mime.Add(".jpg", "image/jpeg");
70 mime.Add(".jpeg", "image/jpeg");
71 mime.Add(".svg", "image/svg+xml");
72 mime.Add(".svgz", "image/svg+xml");
73 mime.Add(".tif", "image/tiff");
74 mime.Add(".tiff", "image/tiff");
75 mime.Add(".css", "text/css");
55 mime.Add(".html", "text/html"); 76 mime.Add(".html", "text/html");
56 mime.Add(".htm", "text/html"); 77 mime.Add(".htm", "text/html");
57 mime.Add(".shtml", "text/html"); 78 mime.Add(".shtml", "text/html");
79// mime.Add(".md", "text/markdown");
80// mime.Add(".markdown","text/markdown");
58 mime.Add(".txt", "text/plain"); 81 mime.Add(".txt", "text/plain");
59 mime.Add(".css", "text/css"); 82
60 mime.Add(".js", "application/javascript"); 83 IConfig cfg = m_Config.Configs["GridInfoService"];
61 mime.Add(".png", "image/png"); 84 string HomeURI = Util.GetConfigVarFromSections<string>(m_Config, "HomeURI", new string[] { "Startup", "Hypergrid" }, String.Empty);
62 mime.Add(".jpeg", "image/jpeg"); 85 ssi.Add("grid", cfg.GetString("gridname", "my grid"));
86 ssi.Add("uri", cfg.GetString("login", HomeURI));
87 ssi.Add("version", VersionInfo.Version);
63 server.AddHTTPHandler("/web/", WebRequestHandler); 88 server.AddHTTPHandler("/web/", WebRequestHandler);
64 } 89 }
65 90
66 private Hashtable WebRequestHandler(Hashtable request) 91 private Hashtable WebRequestHandler(Hashtable request)
67 { 92 {
68 Hashtable reply = new Hashtable(); 93 Hashtable reply = new Hashtable();
94 // Looks like we have to jump through hoops to do simple database queries. B-(
95 ssi["members"] = "?"; // SELECT COUNT(PrincipalID) FROM UserAccounts
96 ssi["inworld"] = "?"; // SELECT COUNT(UserID) FROM presence_culled; Includes locals and HGers in world, but not locals HGing.
97 // SELECT COUNT(UserID) FROM users_online; Includes local online only.
98 ssi["outworld"] = "?"; // SELECT COUNT(UserID) FROM hg_traveling_data WHERE GridExternalName != ssi["uri"]; Includes locals that are HGing.
99// ssi["hgers"] = "?"; // This is complex.
100 ssi["sims"] = "?"; // SELECT COUNT(uuid) FROM regions
101// ssi["month"] = "?"; // SELECT COUNT(UserID) FROM Presence WHERE LastSeen < one month ago 2017-11-28 09:01:51; Includes external HGers, and locals on now.
69 102
70 string reqpath = (string) request["uri"]; 103 string reqpath = (string) request["uri"];
71 string[] query = (string[]) request["querystringkeys"]; 104 string[] query = (string[]) request["querystringkeys"];
@@ -78,16 +111,22 @@ namespace OpenSim.Server.Handlers.Web
78 reply["int_response_code"] = 200; 111 reply["int_response_code"] = 200;
79 if (File.Exists(file)) 112 if (File.Exists(file))
80 { 113 {
81 string m = (string) mime[Path.GetExtension(file)]; 114 string m = (string) mime[Path.GetExtension(file).ToLower()];
82 reply["content_type"] = m; 115 reply["content_type"] = m;
83 if (("image/jpeg" == m) || ("image/png" == m)) 116 if ((null == m) || ("text/" != m.Substring(0, 5)))
84 { 117 {
85 reply["bin_response_data"] = File.ReadAllBytes(file); 118 reply["bin_response_data"] = File.ReadAllBytes(file);
86 } 119 }
87 else 120 else
88 { 121 {
89 StreamReader csr = File.OpenText(file); 122 StreamReader csr = File.OpenText(file);
90 reply["str_response_string"] = csr.ReadToEnd(); 123 string content = csr.ReadToEnd();
124 // Slow and wasteful, but I'm expecting only tiny web files, not accessed very often.
125 foreach (DictionaryEntry v in ssi)
126 {
127 content = content.Replace("<!--#echo var=\"" + ((string) v.Key) + "\" -->", (string) v.Value);
128 }
129 reply["str_response_string"] = content;
91 csr.Close(); 130 csr.Close();
92 } 131 }
93 } 132 }
diff --git a/example/web/loginpage.html b/example/web/loginpage.html
index aa58e6b..9246263 100644
--- a/example/web/loginpage.html
+++ b/example/web/loginpage.html
@@ -1,24 +1,21 @@
1<html> 1<html>
2<title>This grid</title> 2<title><!--#echo var="grid" --> splash page</title>
3<head> 3<head>
4</head> 4</head>
5<body bgcolor="black" text="white" alink="red" link="blue" vlink="purple" background="SledjHamr.png"> 5<body bgcolor="black" text="white" alink="red" link="blue" vlink="purple" background="SledjHamr.png">
6<p>&nbsp;</p> 6<p>&nbsp;</p>
7<p>&nbsp;</p> 7<p>&nbsp;</p>
8<h1>Add your fancy splash page for your grid here.</h1> 8<h1>Add your fancy splash page for <!--#echo var="grid" --> here. &nbsp; &nbsp; Login URI - <!--#echo var="uri" --></h1>
9<p>&nbsp;</p> 9<p>&nbsp;</p>
10<p>&nbsp;</p> 10<p>&nbsp;</p>
11<p>There may be some new members. &nbsp; Welcome new members.</p> 11<p>There are likely some (<!--#echo var="members" -->) members of this grid.</p>
12<p>&nbsp;</p> 12<p>&nbsp;</p>
13<p>There are likely some members of this grid.</p> 13<p>There are maybe some (<!--#echo var="inworld" -->) people in world now (including hypergridders).</p>
14<p>&nbsp;</p> 14<p>&nbsp;</p>
15<p>There maybe some people online now.</p> 15<p>There are maybe some (<!--#echo var="outworld" -->) locals hypergridding now.</p>
16<p>&nbsp;</p> 16<p>&nbsp;</p>
17<p>There maybe some visitors from the hypergrid.</p> 17<p>There is probably at least one (<!--#echo var="sims" -->) region, maybe more.</p>
18<p>&nbsp;</p>
19<p>There is probably at least one region, maybe more.</p>
20<p>&nbsp;</p>
21<p>Some people might have been on in the last month.</p>
22<p>&nbsp;</p> 18<p>&nbsp;</p>
19<p> This grid is running <!--#echo var="version" --></p>
23</body> 20</body>
24</html> 21</html>