diff options
Diffstat (limited to 'OpenSim/Framework/Data.MySQL')
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLManager.cs | 31 | ||||
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLUserData.cs | 46 |
2 files changed, 30 insertions, 47 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs index 46fd1bc..d422687 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLManager.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs | |||
@@ -138,13 +138,11 @@ namespace OpenSim.Framework.Data.MySQL | |||
138 | string dllName = module.Assembly.ManifestModule.Name; | 138 | string dllName = module.Assembly.ManifestModule.Name; |
139 | Version dllVersion = module.Assembly.GetName().Version; | 139 | Version dllVersion = module.Assembly.GetName().Version; |
140 | 140 | ||
141 | |||
142 | return | 141 | return |
143 | string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, | 142 | string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, |
144 | dllVersion.Revision); | 143 | dllVersion.Revision); |
145 | } | 144 | } |
146 | 145 | ||
147 | |||
148 | /// <summary> | 146 | /// <summary> |
149 | /// Extract a named string resource from the embedded resources | 147 | /// Extract a named string resource from the embedded resources |
150 | /// </summary> | 148 | /// </summary> |
@@ -156,7 +154,9 @@ namespace OpenSim.Framework.Data.MySQL | |||
156 | string[] names = assem.GetManifestResourceNames(); | 154 | string[] names = assem.GetManifestResourceNames(); |
157 | 155 | ||
158 | foreach (string s in names) | 156 | foreach (string s in names) |
157 | { | ||
159 | if (s.EndsWith(name)) | 158 | if (s.EndsWith(name)) |
159 | { | ||
160 | using (Stream resource = assem.GetManifestResourceStream(s)) | 160 | using (Stream resource = assem.GetManifestResourceStream(s)) |
161 | { | 161 | { |
162 | using (StreamReader resourceReader = new StreamReader(resource)) | 162 | using (StreamReader resourceReader = new StreamReader(resource)) |
@@ -165,6 +165,8 @@ namespace OpenSim.Framework.Data.MySQL | |||
165 | return resourceString; | 165 | return resourceString; |
166 | } | 166 | } |
167 | } | 167 | } |
168 | } | ||
169 | } | ||
168 | throw new Exception(string.Format("Resource '{0}' was not found", name)); | 170 | throw new Exception(string.Format("Resource '{0}' was not found", name)); |
169 | } | 171 | } |
170 | 172 | ||
@@ -214,8 +216,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
214 | } | 216 | } |
215 | } | 217 | } |
216 | 218 | ||
217 | 219 | // TODO: at some time this code should be cleaned up | |
218 | // at some time this code should be cleaned up | ||
219 | 220 | ||
220 | /// <summary> | 221 | /// <summary> |
221 | /// Runs a query with protection against SQL Injection by using parameterised input. | 222 | /// Runs a query with protection against SQL Injection by using parameterised input. |
@@ -249,7 +250,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
249 | { | 250 | { |
250 | } | 251 | } |
251 | 252 | ||
252 | // Try reopen it | 253 | // Try to reopen it |
253 | try | 254 | try |
254 | { | 255 | { |
255 | dbcon = new MySqlConnection(connectionString); | 256 | dbcon = new MySqlConnection(connectionString); |
@@ -368,7 +369,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
368 | retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString()); | 369 | retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString()); |
369 | retval.reservationName = (string) reader["resName"]; | 370 | retval.reservationName = (string) reader["resName"]; |
370 | retval.status = Convert.ToInt32(reader["status"].ToString()) == 1; | 371 | retval.status = Convert.ToInt32(reader["status"].ToString()) == 1; |
371 | LLUUID.TryParse((string) reader["userUUID"], out retval.userUUID); | 372 | LLUUID.TryParse((string) reader["userUUID"], out retval.userUUID); |
372 | } | 373 | } |
373 | else | 374 | else |
374 | { | 375 | { |
@@ -458,22 +459,22 @@ namespace OpenSim.Framework.Data.MySQL | |||
458 | else | 459 | else |
459 | retval.profileAboutText = (string) reader["profileAboutText"]; | 460 | retval.profileAboutText = (string) reader["profileAboutText"]; |
460 | 461 | ||
461 | if (reader.IsDBNull( reader.GetOrdinal( "profileFirstText" ) ) ) | 462 | if (reader.IsDBNull(reader.GetOrdinal("profileFirstText"))) |
462 | retval.profileFirstText = ""; | 463 | retval.profileFirstText = ""; |
463 | else | 464 | else |
464 | retval.profileFirstText = (string)reader["profileFirstText"]; | 465 | retval.profileFirstText = (string)reader["profileFirstText"]; |
465 | 466 | ||
466 | if (reader.IsDBNull( reader.GetOrdinal( "profileImage" ) ) ) | 467 | if (reader.IsDBNull(reader.GetOrdinal("profileImage"))) |
467 | retval.profileImage = LLUUID.Zero; | 468 | retval.profileImage = LLUUID.Zero; |
468 | else | 469 | else |
469 | LLUUID.TryParse((string)reader["profileImage"], out retval.profileImage); | 470 | LLUUID.TryParse((string)reader["profileImage"], out retval.profileImage); |
470 | 471 | ||
471 | if (reader.IsDBNull( reader.GetOrdinal( "profileFirstImage" ) ) ) | 472 | if (reader.IsDBNull(reader.GetOrdinal("profileFirstImage"))) |
472 | retval.profileFirstImage = LLUUID.Zero; | 473 | retval.profileFirstImage = LLUUID.Zero; |
473 | else | 474 | else |
474 | LLUUID.TryParse((string)reader["profileFirstImage"], out retval.profileFirstImage); | 475 | LLUUID.TryParse((string)reader["profileFirstImage"], out retval.profileFirstImage); |
475 | 476 | ||
476 | if( reader.IsDBNull( reader.GetOrdinal( "webLoginKey" ) ) ) | 477 | if(reader.IsDBNull(reader.GetOrdinal("webLoginKey"))) |
477 | { | 478 | { |
478 | retval.webLoginKey = LLUUID.Zero; | 479 | retval.webLoginKey = LLUUID.Zero; |
479 | } | 480 | } |
@@ -489,7 +490,6 @@ namespace OpenSim.Framework.Data.MySQL | |||
489 | return retval; | 490 | return retval; |
490 | } | 491 | } |
491 | 492 | ||
492 | |||
493 | /// <summary> | 493 | /// <summary> |
494 | /// Inserts a new row into the log database | 494 | /// Inserts a new row into the log database |
495 | /// </summary> | 495 | /// </summary> |
@@ -534,7 +534,6 @@ namespace OpenSim.Framework.Data.MySQL | |||
534 | return returnval; | 534 | return returnval; |
535 | } | 535 | } |
536 | 536 | ||
537 | |||
538 | /// <summary> | 537 | /// <summary> |
539 | /// Creates a new user and inserts it into the database | 538 | /// Creates a new user and inserts it into the database |
540 | /// </summary> | 539 | /// </summary> |
@@ -630,7 +629,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
630 | return returnval; | 629 | return returnval; |
631 | } | 630 | } |
632 | 631 | ||
633 | /// <summary> | 632 | /// <summary> |
634 | /// Creates a new user and inserts it into the database | 633 | /// Creates a new user and inserts it into the database |
635 | /// </summary> | 634 | /// </summary> |
636 | /// <param name="uuid">User ID</param> | 635 | /// <param name="uuid">User ID</param> |
@@ -823,6 +822,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
823 | 822 | ||
824 | return returnval; | 823 | return returnval; |
825 | } | 824 | } |
825 | |||
826 | /// <summary> | 826 | /// <summary> |
827 | /// Delete a region from the database | 827 | /// Delete a region from the database |
828 | /// </summary> | 828 | /// </summary> |
@@ -833,14 +833,13 @@ namespace OpenSim.Framework.Data.MySQL | |||
833 | { | 833 | { |
834 | bool returnval = false; | 834 | bool returnval = false; |
835 | 835 | ||
836 | string sql = | 836 | string sql = "DELETE FROM regions WHERE uuid = ?uuid;"; |
837 | "DELETE FROM regions WHERE uuid = ?uuid;"; | ||
838 | 837 | ||
839 | Dictionary<string, string> parameters = new Dictionary<string, string>(); | 838 | Dictionary<string, string> parameters = new Dictionary<string, string>(); |
840 | 839 | ||
841 | try | 840 | try |
842 | { | 841 | { |
843 | parameters["?uuid"] = uuid; | 842 | parameters["?uuid"] = uuid; |
844 | 843 | ||
845 | IDbCommand result = Query(sql, parameters); | 844 | IDbCommand result = Query(sql, parameters); |
846 | 845 | ||
diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs index 4c76461..1370b1b 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs | |||
@@ -108,7 +108,6 @@ namespace OpenSim.Framework.Data.MySQL | |||
108 | UpgradeAgentsTable(tableList[m_agentsTableName]); | 108 | UpgradeAgentsTable(tableList[m_agentsTableName]); |
109 | UpgradeUsersTable(tableList[m_usersTableName]); | 109 | UpgradeUsersTable(tableList[m_usersTableName]); |
110 | UpgradeFriendsTable(tableList[m_userFriendsTableName]); | 110 | UpgradeFriendsTable(tableList[m_userFriendsTableName]); |
111 | |||
112 | } | 111 | } |
113 | 112 | ||
114 | /// <summary> | 113 | /// <summary> |
@@ -227,7 +226,6 @@ namespace OpenSim.Framework.Data.MySQL | |||
227 | "(?friendID,?ownerID,?friendPerms,?datetimestamp)", | 226 | "(?friendID,?ownerID,?friendPerms,?datetimestamp)", |
228 | param); | 227 | param); |
229 | adder.ExecuteNonQuery(); | 228 | adder.ExecuteNonQuery(); |
230 | |||
231 | } | 229 | } |
232 | } | 230 | } |
233 | catch (Exception e) | 231 | catch (Exception e) |
@@ -244,23 +242,21 @@ namespace OpenSim.Framework.Data.MySQL | |||
244 | param["?ownerID"] = friendlistowner.UUID.ToString(); | 242 | param["?ownerID"] = friendlistowner.UUID.ToString(); |
245 | param["?friendID"] = friend.UUID.ToString(); | 243 | param["?friendID"] = friend.UUID.ToString(); |
246 | 244 | ||
247 | |||
248 | try | 245 | try |
249 | { | 246 | { |
250 | lock (database) | 247 | lock (database) |
251 | { | 248 | { |
252 | IDbCommand updater = | 249 | IDbCommand updater = |
253 | database.Query( | 250 | database.Query( |
254 | "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", | 251 | "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", |
255 | param); | 252 | param); |
256 | updater.ExecuteNonQuery(); | 253 | updater.ExecuteNonQuery(); |
257 | 254 | ||
258 | updater = | 255 | updater = |
259 | database.Query( | 256 | database.Query( |
260 | "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", | 257 | "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", |
261 | param); | 258 | param); |
262 | updater.ExecuteNonQuery(); | 259 | updater.ExecuteNonQuery(); |
263 | |||
264 | } | 260 | } |
265 | } | 261 | } |
266 | catch (Exception e) | 262 | catch (Exception e) |
@@ -270,13 +266,13 @@ namespace OpenSim.Framework.Data.MySQL | |||
270 | return; | 266 | return; |
271 | } | 267 | } |
272 | } | 268 | } |
269 | |||
273 | public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) | 270 | public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) |
274 | { | 271 | { |
275 | Dictionary<string, string> param = new Dictionary<string, string>(); | 272 | Dictionary<string, string> param = new Dictionary<string, string>(); |
276 | param["?ownerID"] = friendlistowner.UUID.ToString(); | 273 | param["?ownerID"] = friendlistowner.UUID.ToString(); |
277 | param["?friendID"] = friend.UUID.ToString(); | 274 | param["?friendID"] = friend.UUID.ToString(); |
278 | param["?friendPerms"] = perms.ToString(); | 275 | param["?friendPerms"] = perms.ToString(); |
279 | |||
280 | 276 | ||
281 | try | 277 | try |
282 | { | 278 | { |
@@ -284,12 +280,11 @@ namespace OpenSim.Framework.Data.MySQL | |||
284 | { | 280 | { |
285 | IDbCommand updater = | 281 | IDbCommand updater = |
286 | database.Query( | 282 | database.Query( |
287 | "update " + m_userFriendsTableName + | 283 | "update " + m_userFriendsTableName + |
288 | " SET friendPerms = ?friendPerms " + | 284 | " SET friendPerms = ?friendPerms " + |
289 | "where ownerID = ?ownerID and friendID = ?friendID", | 285 | "where ownerID = ?ownerID and friendID = ?friendID", |
290 | param); | 286 | param); |
291 | updater.ExecuteNonQuery(); | 287 | updater.ExecuteNonQuery(); |
292 | |||
293 | } | 288 | } |
294 | } | 289 | } |
295 | catch (Exception e) | 290 | catch (Exception e) |
@@ -300,7 +295,6 @@ namespace OpenSim.Framework.Data.MySQL | |||
300 | } | 295 | } |
301 | } | 296 | } |
302 | 297 | ||
303 | |||
304 | public List<FriendListItem> GetUserFriendList(LLUUID friendlistowner) | 298 | public List<FriendListItem> GetUserFriendList(LLUUID friendlistowner) |
305 | { | 299 | { |
306 | List<FriendListItem> Lfli = new List<FriendListItem>(); | 300 | List<FriendListItem> Lfli = new List<FriendListItem>(); |
@@ -315,12 +309,11 @@ namespace OpenSim.Framework.Data.MySQL | |||
315 | //Left Join userfriends to itself | 309 | //Left Join userfriends to itself |
316 | IDbCommand result = | 310 | IDbCommand result = |
317 | database.Query( | 311 | database.Query( |
318 | "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + | 312 | "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + |
319 | " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", | 313 | " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", |
320 | param); | 314 | param); |
321 | IDataReader reader = result.ExecuteReader(); | 315 | IDataReader reader = result.ExecuteReader(); |
322 | 316 | ||
323 | |||
324 | while (reader.Read()) | 317 | while (reader.Read()) |
325 | { | 318 | { |
326 | FriendListItem fli = new FriendListItem(); | 319 | FriendListItem fli = new FriendListItem(); |
@@ -354,7 +347,6 @@ namespace OpenSim.Framework.Data.MySQL | |||
354 | m_log.Info("[USER]: Stub UpdateUserCUrrentRegion called"); | 347 | m_log.Info("[USER]: Stub UpdateUserCUrrentRegion called"); |
355 | } | 348 | } |
356 | 349 | ||
357 | |||
358 | public List<Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) | 350 | public List<Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) |
359 | { | 351 | { |
360 | List<Framework.AvatarPickerAvatar> returnlist = new List<Framework.AvatarPickerAvatar>(); | 352 | List<Framework.AvatarPickerAvatar> returnlist = new List<Framework.AvatarPickerAvatar>(); |
@@ -378,7 +370,6 @@ namespace OpenSim.Framework.Data.MySQL | |||
378 | param); | 370 | param); |
379 | IDataReader reader = result.ExecuteReader(); | 371 | IDataReader reader = result.ExecuteReader(); |
380 | 372 | ||
381 | |||
382 | while (reader.Read()) | 373 | while (reader.Read()) |
383 | { | 374 | { |
384 | Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); | 375 | Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); |
@@ -413,7 +404,6 @@ namespace OpenSim.Framework.Data.MySQL | |||
413 | param); | 404 | param); |
414 | IDataReader reader = result.ExecuteReader(); | 405 | IDataReader reader = result.ExecuteReader(); |
415 | 406 | ||
416 | |||
417 | while (reader.Read()) | 407 | while (reader.Read()) |
418 | { | 408 | { |
419 | Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); | 409 | Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); |
@@ -489,7 +479,6 @@ namespace OpenSim.Framework.Data.MySQL | |||
489 | 479 | ||
490 | public void StoreWebLoginKey(LLUUID AgentID, LLUUID WebLoginKey) | 480 | public void StoreWebLoginKey(LLUUID AgentID, LLUUID WebLoginKey) |
491 | { | 481 | { |
492 | |||
493 | Dictionary<string, string> param = new Dictionary<string, string>(); | 482 | Dictionary<string, string> param = new Dictionary<string, string>(); |
494 | param["?UUID"] = AgentID.UUID.ToString(); | 483 | param["?UUID"] = AgentID.UUID.ToString(); |
495 | param["?webLoginKey"] = WebLoginKey.UUID.ToString(); | 484 | param["?webLoginKey"] = WebLoginKey.UUID.ToString(); |
@@ -500,11 +489,10 @@ namespace OpenSim.Framework.Data.MySQL | |||
500 | { | 489 | { |
501 | IDbCommand updater = | 490 | IDbCommand updater = |
502 | database.Query( | 491 | database.Query( |
503 | "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + | 492 | "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + |
504 | "where UUID = ?UUID", | 493 | "where UUID = ?UUID", |
505 | param); | 494 | param); |
506 | updater.ExecuteNonQuery(); | 495 | updater.ExecuteNonQuery(); |
507 | |||
508 | } | 496 | } |
509 | } | 497 | } |
510 | catch (Exception e) | 498 | catch (Exception e) |
@@ -513,10 +501,6 @@ namespace OpenSim.Framework.Data.MySQL | |||
513 | m_log.Error(e.ToString()); | 501 | m_log.Error(e.ToString()); |
514 | return; | 502 | return; |
515 | } | 503 | } |
516 | |||
517 | |||
518 | |||
519 | |||
520 | } | 504 | } |
521 | 505 | ||
522 | /// <summary> | 506 | /// <summary> |
@@ -605,11 +589,11 @@ namespace OpenSim.Framework.Data.MySQL | |||
605 | /// <param name="user">The profile data to use to update the DB</param> | 589 | /// <param name="user">The profile data to use to update the DB</param> |
606 | public bool UpdateUserProfile(UserProfileData user) | 590 | public bool UpdateUserProfile(UserProfileData user) |
607 | { | 591 | { |
608 | database.updateUserRow(user.UUID, user.username, user.surname, user.passwordHash, user.passwordSalt | 592 | database.updateUserRow(user.UUID, user.username, user.surname, user.passwordHash, user.passwordSalt, |
609 | , user.homeRegion, user.homeLocation.X, user.homeLocation.Y, user.homeLocation.Z, user.homeLookAt.X | 593 | user.homeRegion, user.homeLocation.X, user.homeLocation.Y, user.homeLocation.Z, user.homeLookAt.X, |
610 | , user.homeLookAt.Y, user.homeLookAt.Z, user.created, user.lastLogin, user.userInventoryURI | 594 | user.homeLookAt.Y, user.homeLookAt.Z, user.created, user.lastLogin, user.userInventoryURI, |
611 | , user.userAssetURI, user.profileCanDoMask, user.profileWantDoMask, user.profileAboutText | 595 | user.userAssetURI, user.profileCanDoMask, user.profileWantDoMask, user.profileAboutText, |
612 | , user.profileFirstText, user.profileImage, user.profileFirstImage, user.webLoginKey); | 596 | user.profileFirstText, user.profileImage, user.profileFirstImage, user.webLoginKey); |
613 | return true; | 597 | return true; |
614 | } | 598 | } |
615 | 599 | ||