From afddecb2830f6afa73f869e120002d12803b3266 Mon Sep 17 00:00:00 2001 From: onefang Date: Wed, 7 Aug 2019 22:12:46 +1000 Subject: More account manager. Select with more parameters. Tables, with member accounts. Print the query values. --- OpenSim/Data/MySQL/MySQLRaw.cs | 8 ++- .../Server/Handlers/Web/WebServerInConnector.cs | 65 +++++++++++++++++++--- 2 files changed, 62 insertions(+), 11 deletions(-) diff --git a/OpenSim/Data/MySQL/MySQLRaw.cs b/OpenSim/Data/MySQL/MySQLRaw.cs index 4be6d90..e8f80aa 100644 --- a/OpenSim/Data/MySQL/MySQLRaw.cs +++ b/OpenSim/Data/MySQL/MySQLRaw.cs @@ -40,11 +40,15 @@ namespace OpenSim.Data.MySQL return result; } - public List< Hashtable > Select(string table, string wher) + public List< Hashtable > Select(string table, string select, string wher, string order) { - string query = "SELECT * FROM " + table; + if ("" == select) + select = "*"; + string query = "SELECT " + select + " FROM " + table; if ("" != wher) query = query + " WHERE " + wher; + if ("" != order) + query = query + " ORDER BY " + order; using (MySqlConnection dbcon = new MySqlConnection(m_connectString)) { diff --git a/OpenSim/Server/Handlers/Web/WebServerInConnector.cs b/OpenSim/Server/Handlers/Web/WebServerInConnector.cs index 568b7d6..1dedfa3 100644 --- a/OpenSim/Server/Handlers/Web/WebServerInConnector.cs +++ b/OpenSim/Server/Handlers/Web/WebServerInConnector.cs @@ -143,7 +143,7 @@ namespace OpenSim.Server.Handlers.Web foreach (DictionaryEntry h in headers) m_log.InfoFormat("[WEB SERVICE]: {0} method path {1} header {2} = {3}", method, reqpath, (string) h.Key, (string) h.Value); foreach (String q in query) - m_log.InfoFormat("[WEB SERVICE]: {0} method path {1} query {2}", method, reqpath, q); + m_log.InfoFormat("[WEB SERVICE]: {0} method path {1} query {2} value {3}", method, reqpath, q, (string) request[q]); reply["int_response_code"] = 200; if ("GET" == method) @@ -214,14 +214,12 @@ namespace OpenSim.Server.Handlers.Web } else if ("list" == fields["doit"].ToString()) { - List< Hashtable > rows = m_database.Select("GridUser", "Login > UNIX_TIMESTAMP(FROM_UNIXTIME(UNIX_TIMESTAMP(now()) - 2419200))"); - foreach (Hashtable row in rows) - { - string line = ""; - foreach (DictionaryEntry c in row) - line = line + " | " + (string) c.Value; - m_log.Info("[MariaDB RAW]: " + line); - } + List< Hashtable > rows = m_database.Select("UserAccounts", + "CONCAT(FirstName,' ',LastName) as Name,UserTitle as Title,UserLevel as Level,UserFlags as Flags,PrincipalID as UUID", + "", "Name"); + reply["str_response_string"] = "member accounts" + + table(rows, new string[5] {"Name", "Title", "Level", "Flags", "UUID"}, "member accounts", + "account.html?doit=edit&token=" + fields["token"].ToString(), "UUID") + "

" + button("my account") + "

"; } else { @@ -281,8 +279,10 @@ namespace OpenSim.Server.Handlers.Web + form("account.html", fields["token"].ToString(), hidden("firstName", fields["firstName"].ToString()) + hidden("lastName", fields["lastName"].ToString()) +// + hidden("UUID", fields["UUID"].ToString()) + text("email", "email", "email", fields["email"].ToString(), 0, false) + text("password", "password", "password", "", 14, false) +// + text("title", "text", "title", fields["title"].ToString(), 0, false) + select("type", "type", option("", false) + option("approved", true) @@ -303,6 +303,53 @@ namespace OpenSim.Server.Handlers.Web { return "\n \n " + title + "\n \n \n"; } + // account.html?token=&UUID=.... + private string table(List< Hashtable > rows, string[] fields, string caption, string URL, string id) + { + string tbl = ""; + bool head = true; + string address = ""; + string addrend = ""; + foreach (Hashtable row in rows) + { + if (0 == fields.Length) + { + int c = 0; + foreach (DictionaryEntry r in row) + c++; + fields = new string[c]; + c = 0; + foreach (DictionaryEntry r in row) + fields[c++] = (string) r.Key; + } + string line = ""; + address = ""; + if ("" != URL) + { + address = ""; + if (head) + { + foreach (string s in fields) + line = line + ""; + tbl = tbl + line + "\n"; + head = false; + } + line = ""; + foreach (string s in fields) + { + if (s == id) + line = line + ""; + else + line = line + ""; + } + tbl = tbl + line + "\n"; + } + return tbl + "
" + caption + "
" + s + "
" + address + row[s] + addrend + "" + row[s] + "
"; + } private string form(string action, string token, string form) { return "
\n" + hidden("token", token) + form + "
\n"; -- cgit v1.1