From 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 21:24:15 +1000 Subject: Dump OpenSim 0.9.0.1 into it's own branch. --- OpenSim/Data/MySQL/MySQLUserAccountData.cs | 40 ++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'OpenSim/Data/MySQL/MySQLUserAccountData.cs') diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index e964295..59cfe70 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -46,17 +46,21 @@ namespace OpenSim.Data.MySQL { string[] words = query.Split(new char[] {' '}); + bool valid = false; + for (int i = 0 ; i < words.Length ; i++) { - if (words[i].Length < 3) - { - if (i != words.Length - 1) - Array.Copy(words, i + 1, words, i, words.Length - i - 1); - Array.Resize(ref words, words.Length - 1); - } + if (words[i].Length > 2) + valid = true; +// if (words[i].Length < 3) +// { +// if (i != words.Length - 1) +// Array.Copy(words, i + 1, words, i, words.Length - i - 1); +// Array.Resize(ref words, words.Length - 1); +// } } - if (words.Length == 0) + if ((!valid) || words.Length == 0) return new UserAccountData[0]; if (words.Length > 2) @@ -66,13 +70,13 @@ namespace OpenSim.Data.MySQL { if (words.Length == 1) { - cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search)", m_Realm); + cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search) and active=1", m_Realm); cmd.Parameters.AddWithValue("?search", "%" + words[0] + "%"); cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); } else { - cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst or LastName like ?searchLast)", m_Realm); + cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst and LastName like ?searchLast) and active=1", m_Realm); cmd.Parameters.AddWithValue("?searchFirst", "%" + words[0] + "%"); cmd.Parameters.AddWithValue("?searchLast", "%" + words[1] + "%"); cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); @@ -81,5 +85,21 @@ namespace OpenSim.Data.MySQL return DoQuery(cmd); } } + + public UserAccountData[] GetUsersWhere(UUID scopeID, string where) + { + using (MySqlCommand cmd = new MySqlCommand()) + { + if (scopeID != UUID.Zero) + { + where = "(ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (" + where + ")"; + cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); + } + + cmd.CommandText = String.Format("select * from {0} where " + where, m_Realm); + + return DoQuery(cmd); + } + } } -} \ No newline at end of file +} -- cgit v1.1