diff options
Diffstat (limited to 'OpenSim/Framework/Data.MySQL/MySQLUserData.cs')
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLUserData.cs | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs index 4b86d80..2d96f6e 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Data; | 30 | using System.Data; |
31 | using System.Text.RegularExpressions; | ||
31 | using libsecondlife; | 32 | using libsecondlife; |
32 | using OpenSim.Framework.Console; | 33 | using OpenSim.Framework.Console; |
33 | 34 | ||
@@ -61,7 +62,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
61 | database = | 62 | database = |
62 | new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, | 63 | new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, |
63 | settingPort); | 64 | settingPort); |
64 | 65 | ||
65 | TestTables(); | 66 | TestTables(); |
66 | } | 67 | } |
67 | 68 | ||
@@ -81,7 +82,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
81 | UpgradeAgentsTable(tableList["agents"]); | 82 | UpgradeAgentsTable(tableList["agents"]); |
82 | UpgradeUsersTable(tableList["users"]); | 83 | UpgradeUsersTable(tableList["users"]); |
83 | } | 84 | } |
84 | 85 | ||
85 | /// <summary> | 86 | /// <summary> |
86 | /// Create or upgrade the table if necessary | 87 | /// Create or upgrade the table if necessary |
87 | /// </summary> | 88 | /// </summary> |
@@ -95,8 +96,8 @@ namespace OpenSim.Framework.Data.MySQL | |||
95 | database.ExecuteResourceSql("CreateAgentsTable.sql"); | 96 | database.ExecuteResourceSql("CreateAgentsTable.sql"); |
96 | return; | 97 | return; |
97 | } | 98 | } |
98 | } | 99 | } |
99 | 100 | ||
100 | /// <summary> | 101 | /// <summary> |
101 | /// Create or upgrade the table if necessary | 102 | /// Create or upgrade the table if necessary |
102 | /// </summary> | 103 | /// </summary> |
@@ -110,8 +111,8 @@ namespace OpenSim.Framework.Data.MySQL | |||
110 | database.ExecuteResourceSql("CreateUsersTable.sql"); | 111 | database.ExecuteResourceSql("CreateUsersTable.sql"); |
111 | return; | 112 | return; |
112 | } | 113 | } |
113 | } | 114 | } |
114 | 115 | ||
115 | #endregion | 116 | #endregion |
116 | 117 | ||
117 | // see IUserData | 118 | // see IUserData |
@@ -144,11 +145,11 @@ namespace OpenSim.Framework.Data.MySQL | |||
144 | } | 145 | } |
145 | } | 146 | } |
146 | 147 | ||
147 | public List<OpenSim.Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) | 148 | public List<Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) |
148 | { | 149 | { |
149 | List<OpenSim.Framework.AvatarPickerAvatar> returnlist = new List<OpenSim.Framework.AvatarPickerAvatar>(); | 150 | List<Framework.AvatarPickerAvatar> returnlist = new List<Framework.AvatarPickerAvatar>(); |
150 | 151 | ||
151 | System.Text.RegularExpressions.Regex objAlphaNumericPattern = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9]"); | 152 | Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]"); |
152 | 153 | ||
153 | string[] querysplit; | 154 | string[] querysplit; |
154 | querysplit = query.Split(' '); | 155 | querysplit = query.Split(' '); |
@@ -161,21 +162,20 @@ namespace OpenSim.Framework.Data.MySQL | |||
161 | { | 162 | { |
162 | lock (database) | 163 | lock (database) |
163 | { | 164 | { |
164 | |||
165 | |||
166 | IDbCommand result = | 165 | IDbCommand result = |
167 | database.Query("SELECT UUID,username,lastname FROM users WHERE username like ?first AND lastname like ?second LIMIT 100", param); | 166 | database.Query( |
167 | "SELECT UUID,username,lastname FROM users WHERE username like ?first AND lastname like ?second LIMIT 100", | ||
168 | param); | ||
168 | IDataReader reader = result.ExecuteReader(); | 169 | IDataReader reader = result.ExecuteReader(); |
169 | 170 | ||
170 | 171 | ||
171 | while (reader.Read()) | 172 | while (reader.Read()) |
172 | { | 173 | { |
173 | OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar(); | 174 | Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); |
174 | user.AvatarID = new LLUUID((string)reader["UUID"]); | 175 | user.AvatarID = new LLUUID((string) reader["UUID"]); |
175 | user.firstName = (string)reader["username"]; | 176 | user.firstName = (string) reader["username"]; |
176 | user.lastName = (string)reader["lastname"]; | 177 | user.lastName = (string) reader["lastname"]; |
177 | returnlist.Add(user); | 178 | returnlist.Add(user); |
178 | |||
179 | } | 179 | } |
180 | reader.Close(); | 180 | reader.Close(); |
181 | result.Dispose(); | 181 | result.Dispose(); |
@@ -187,13 +187,9 @@ namespace OpenSim.Framework.Data.MySQL | |||
187 | MainLog.Instance.Error(e.ToString()); | 187 | MainLog.Instance.Error(e.ToString()); |
188 | return returnlist; | 188 | return returnlist; |
189 | } | 189 | } |
190 | |||
191 | |||
192 | |||
193 | } | 190 | } |
194 | else if (querysplit.Length == 1) | 191 | else if (querysplit.Length == 1) |
195 | { | 192 | { |
196 | |||
197 | try | 193 | try |
198 | { | 194 | { |
199 | lock (database) | 195 | lock (database) |
@@ -202,18 +198,19 @@ namespace OpenSim.Framework.Data.MySQL | |||
202 | param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], "") + "%"; | 198 | param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], "") + "%"; |
203 | 199 | ||
204 | IDbCommand result = | 200 | IDbCommand result = |
205 | database.Query("SELECT UUID,username,lastname FROM users WHERE username like ?first OR lastname like ?first LIMIT 100", param); | 201 | database.Query( |
202 | "SELECT UUID,username,lastname FROM users WHERE username like ?first OR lastname like ?first LIMIT 100", | ||
203 | param); | ||
206 | IDataReader reader = result.ExecuteReader(); | 204 | IDataReader reader = result.ExecuteReader(); |
207 | 205 | ||
208 | 206 | ||
209 | while (reader.Read()) | 207 | while (reader.Read()) |
210 | { | 208 | { |
211 | OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar(); | 209 | Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); |
212 | user.AvatarID = new LLUUID((string)reader["UUID"]); | 210 | user.AvatarID = new LLUUID((string) reader["UUID"]); |
213 | user.firstName = (string)reader["username"]; | 211 | user.firstName = (string) reader["username"]; |
214 | user.lastName = (string)reader["lastname"]; | 212 | user.lastName = (string) reader["lastname"]; |
215 | returnlist.Add(user); | 213 | returnlist.Add(user); |
216 | |||
217 | } | 214 | } |
218 | reader.Close(); | 215 | reader.Close(); |
219 | result.Dispose(); | 216 | result.Dispose(); |
@@ -402,4 +399,4 @@ namespace OpenSim.Framework.Data.MySQL | |||
402 | return "0.1"; | 399 | return "0.1"; |
403 | } | 400 | } |
404 | } | 401 | } |
405 | } | 402 | } \ No newline at end of file |