diff options
Diffstat (limited to 'OpenSim/Framework/Data.MySQL/MySQLUserData.cs')
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLUserData.cs | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs index 3ae1fba..3138911 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs | |||
@@ -110,31 +110,35 @@ namespace OpenSim.Framework.Data.MySQL | |||
110 | public List<OpenSim.Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) | 110 | public List<OpenSim.Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) |
111 | { | 111 | { |
112 | List<OpenSim.Framework.AvatarPickerAvatar> returnlist = new List<OpenSim.Framework.AvatarPickerAvatar>(); | 112 | List<OpenSim.Framework.AvatarPickerAvatar> returnlist = new List<OpenSim.Framework.AvatarPickerAvatar>(); |
113 | |||
114 | System.Text.RegularExpressions.Regex objAlphaNumericPattern = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9]"); | ||
115 | |||
113 | string[] querysplit; | 116 | string[] querysplit; |
114 | querysplit = query.Split(' '); | 117 | querysplit = query.Split(' '); |
115 | if (querysplit.Length == 2) | 118 | if (querysplit.Length == 2) |
116 | { | 119 | { |
120 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
121 | param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], "") + "%"; | ||
122 | param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], "") + "%"; | ||
117 | try | 123 | try |
118 | { | 124 | { |
119 | lock (database) | 125 | lock (database) |
120 | { | 126 | { |
121 | Dictionary<string, string> param = new Dictionary<string, string>(); | 127 | |
122 | param["?first"] = querysplit[0]; | ||
123 | param["?second"] = querysplit[1]; | ||
124 | 128 | ||
125 | IDbCommand result = | 129 | IDbCommand result = |
126 | database.Query("SELECT UUID,username,surname FROM users WHERE username = ?first AND lastname = ?second", param); | 130 | database.Query("SELECT UUID,username,lastname FROM users WHERE username like ?first AND lastname like ?second LIMIT 100", param); |
127 | IDataReader reader = result.ExecuteReader(); | 131 | IDataReader reader = result.ExecuteReader(); |
128 | 132 | ||
129 | 133 | ||
130 | while (reader.Read()) | 134 | while (reader.Read()) |
131 | { | 135 | { |
132 | OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar(); | 136 | OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar(); |
133 | user.AvatarID = new LLUUID((string)reader["UUID"]); | 137 | user.AvatarID = new LLUUID((string)reader["UUID"]); |
134 | user.firstName = (string)reader["username"]; | 138 | user.firstName = (string)reader["username"]; |
135 | user.lastName = (string)reader["surname"]; | 139 | user.lastName = (string)reader["lastname"]; |
136 | returnlist.Add(user); | 140 | returnlist.Add(user); |
137 | 141 | ||
138 | } | 142 | } |
139 | reader.Close(); | 143 | reader.Close(); |
140 | result.Dispose(); | 144 | result.Dispose(); |
@@ -148,7 +152,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
148 | } | 152 | } |
149 | 153 | ||
150 | 154 | ||
151 | 155 | ||
152 | } | 156 | } |
153 | else if (querysplit.Length == 1) | 157 | else if (querysplit.Length == 1) |
154 | { | 158 | { |
@@ -158,11 +162,10 @@ namespace OpenSim.Framework.Data.MySQL | |||
158 | lock (database) | 162 | lock (database) |
159 | { | 163 | { |
160 | Dictionary<string, string> param = new Dictionary<string, string>(); | 164 | Dictionary<string, string> param = new Dictionary<string, string>(); |
161 | param["?first"] = querysplit[0]; | 165 | param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], "") + "%"; |
162 | param["?second"] = querysplit[1]; | ||
163 | 166 | ||
164 | IDbCommand result = | 167 | IDbCommand result = |
165 | database.Query("SELECT UUID,username,surname FROM users WHERE username = ?first OR lastname = ?second", param); | 168 | database.Query("SELECT UUID,username,lastname FROM users WHERE username like ?first OR lastname like ?first LIMIT 100", param); |
166 | IDataReader reader = result.ExecuteReader(); | 169 | IDataReader reader = result.ExecuteReader(); |
167 | 170 | ||
168 | 171 | ||
@@ -171,7 +174,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
171 | OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar(); | 174 | OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar(); |
172 | user.AvatarID = new LLUUID((string)reader["UUID"]); | 175 | user.AvatarID = new LLUUID((string)reader["UUID"]); |
173 | user.firstName = (string)reader["username"]; | 176 | user.firstName = (string)reader["username"]; |
174 | user.lastName = (string)reader["surname"]; | 177 | user.lastName = (string)reader["lastname"]; |
175 | returnlist.Add(user); | 178 | returnlist.Add(user); |
176 | 179 | ||
177 | } | 180 | } |