aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/CAPS/AdminWebFront.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim.RegionServer/CAPS/AdminWebFront.cs')
-rw-r--r--OpenSim.RegionServer/CAPS/AdminWebFront.cs164
1 files changed, 164 insertions, 0 deletions
diff --git a/OpenSim.RegionServer/CAPS/AdminWebFront.cs b/OpenSim.RegionServer/CAPS/AdminWebFront.cs
new file mode 100644
index 0000000..ea32589
--- /dev/null
+++ b/OpenSim.RegionServer/CAPS/AdminWebFront.cs
@@ -0,0 +1,164 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.IO;
5
6namespace OpenSim.CAPS
7{
8 public class AdminWebFront : IRestHandler
9 {
10 private string AdminPage;
11 private string NewAccountForm;
12 private string LoginForm;
13 private string passWord = "Admin";
14
15 public AdminWebFront(string password)
16 {
17 passWord = password;
18 LoadAdminPage();
19 }
20
21 public string HandleREST(string requestBody, string requestURL, string requestMethod)
22 {
23 string responseString = "";
24 try
25 {
26 switch (requestURL)
27 {
28 case "/Admin":
29 if (requestMethod == "GET")
30 {
31 responseString = AdminPage;
32 }
33 break;
34 case "/Admin/Accounts":
35 if (requestMethod == "GET")
36 {
37 responseString = "<p> Account management </p>";
38 responseString += "<br> ";
39 responseString += "<p> Create New Account </p>";
40 responseString += NewAccountForm;
41 }
42 break;
43 case "/Admin/Clients":
44 if (requestMethod == "GET")
45 {
46 responseString = " <p> Listing connected Clients </p>";
47 OpenSim.world.Avatar TempAv;
48 foreach (libsecondlife.LLUUID UUID in OpenSimRoot.Instance.LocalWorld.Entities.Keys)
49 {
50 if (OpenSimRoot.Instance.LocalWorld.Entities[UUID].ToString() == "OpenSim.world.Avatar")
51 {
52 TempAv = (OpenSim.world.Avatar)OpenSimRoot.Instance.LocalWorld.Entities[UUID];
53 responseString += "<p>";
54 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());
55 responseString += "</p>";
56 }
57 }
58 }
59 break;
60 case "/Admin/NewAccount":
61 if (requestMethod == "POST")
62 {
63 string[] comp = new string[10];
64 string[] passw = new string[3];
65 string delimStr = "&";
66 char[] delimiter = delimStr.ToCharArray();
67 string delimStr2 = "=";
68 char[] delimiter2 = delimStr2.ToCharArray();
69
70 //Console.WriteLine(requestBody);
71 comp = requestBody.Split(delimiter);
72 passw = comp[3].Split(delimiter2);
73 if (passw[1] == passWord)
74 {
75 responseString = "<p> New Account created </p>";
76 }
77 else
78 {
79 responseString = "<p> Admin password is incorrect, please login with the correct password</p>";
80 responseString += "<br><br>" + LoginForm;
81 }
82 }
83 break;
84 case "/Admin/Login":
85 if (requestMethod == "POST")
86 {
87 // Console.WriteLine(requestBody);
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 }
99 break;
100 case "/Admin/Welcome":
101 if (requestMethod == "GET")
102 {
103 responseString = "Welcome to the OpenSim Admin Page";
104 responseString += "<br><br><br> " + LoginForm;
105
106 }
107 break;
108 }
109 }
110 catch (Exception e)
111 {
112 Console.WriteLine(e.ToString());
113 }
114 return responseString;
115 }
116
117 private void LoadAdminPage()
118 {
119 try
120 {
121 StreamReader SR;
122 string lines;
123 AdminPage = "";
124 NewAccountForm = "";
125 LoginForm = "";
126 SR = File.OpenText("testadmin.htm");
127
128 while (!SR.EndOfStream)
129 {
130 lines = SR.ReadLine();
131 AdminPage += lines + "\n";
132
133 }
134 SR.Close();
135
136 SR = File.OpenText("newaccountform.htm");
137
138 while (!SR.EndOfStream)
139 {
140 lines = SR.ReadLine();
141 NewAccountForm += lines + "\n";
142
143 }
144 SR.Close();
145
146 SR = File.OpenText("login.htm");
147
148 while (!SR.EndOfStream)
149 {
150 lines = SR.ReadLine();
151 LoginForm += lines + "\n";
152
153 }
154 SR.Close();
155 }
156 catch (Exception e)
157 {
158 Console.WriteLine(e.ToString());
159 }
160
161 }
162
163 }
164}