diff options
author | lbsa71 | 2009-02-17 14:12:57 +0000 |
---|---|---|
committer | lbsa71 | 2009-02-17 14:12:57 +0000 |
commit | 93465df5e3cdab1774216fbf3f741af03aa609f7 (patch) | |
tree | bb52b80891584a591b6d9cfbf96eb11404fd96d4 /OpenSim/Data/MySQL/MySQLEstateData.cs | |
parent | Re-add the objectID field to the anim pack, that was deemed unneccessary (diff) | |
download | opensim-SC_OLD-93465df5e3cdab1774216fbf3f741af03aa609f7.zip opensim-SC_OLD-93465df5e3cdab1774216fbf3f741af03aa609f7.tar.gz opensim-SC_OLD-93465df5e3cdab1774216fbf3f741af03aa609f7.tar.bz2 opensim-SC_OLD-93465df5e3cdab1774216fbf3f741af03aa609f7.tar.xz |
* Moved the nifty MySQLEstateData connectionstring password-stripper out into the Util project
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLEstateData.cs')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLEstateData.cs | 46 |
1 files changed, 15 insertions, 31 deletions
diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 5acbb9d..8e8c88f 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs | |||
@@ -58,31 +58,15 @@ namespace OpenSim.Data.MySQL | |||
58 | { | 58 | { |
59 | m_connectionString = connectionString; | 59 | m_connectionString = connectionString; |
60 | 60 | ||
61 | int passPosition = 0; | ||
62 | int passEndPosition = 0; | ||
63 | string displayConnectionString = null; | ||
64 | |||
65 | try | 61 | try |
66 | { // hide the password in the connection string | 62 | { |
67 | passPosition = m_connectionString.IndexOf("password", StringComparison.OrdinalIgnoreCase); | 63 | m_log.Info("[REGION DB]: MySql - connecting: " + Util.GetDisplayConnectionString(m_connectionString)); |
68 | passPosition = m_connectionString.IndexOf("=", passPosition); | ||
69 | if (passPosition < m_connectionString.Length) | ||
70 | passPosition += 1; | ||
71 | passEndPosition = m_connectionString.IndexOf(";", passPosition); | ||
72 | |||
73 | displayConnectionString = m_connectionString.Substring(0, passPosition); | ||
74 | displayConnectionString += "***"; | ||
75 | displayConnectionString += m_connectionString.Substring(passEndPosition, m_connectionString.Length - passEndPosition); | ||
76 | } | 64 | } |
77 | catch (Exception e) | 65 | catch (Exception e) |
78 | { | 66 | { |
79 | m_log.Debug("Exception: password not found in connection string\n" + e.ToString()); | 67 | m_log.Debug("Exception: password not found in connection string\n" + e.ToString()); |
80 | } | 68 | } |
81 | 69 | ||
82 | m_log.Info("[REGION DB]: MySql - connecting: " + displayConnectionString); | ||
83 | |||
84 | //m_log.Info("[ESTATE DB]: MySql - connecting: "+m_connectionString); | ||
85 | |||
86 | m_connection = new MySqlConnection(m_connectionString); | 70 | m_connection = new MySqlConnection(m_connectionString); |
87 | m_connection.Open(); | 71 | m_connection.Open(); |
88 | 72 | ||
@@ -159,7 +143,7 @@ namespace OpenSim.Data.MySQL | |||
159 | EstateSettings es = new EstateSettings(); | 143 | EstateSettings es = new EstateSettings(); |
160 | es.OnSave += StoreEstateSettings; | 144 | es.OnSave += StoreEstateSettings; |
161 | 145 | ||
162 | string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID"; | 146 | string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + " from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID"; |
163 | 147 | ||
164 | CheckConnection(); | 148 | CheckConnection(); |
165 | 149 | ||
@@ -206,7 +190,7 @@ namespace OpenSim.Data.MySQL | |||
206 | 190 | ||
207 | names.Remove("EstateID"); | 191 | names.Remove("EstateID"); |
208 | 192 | ||
209 | sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( ?"+String.Join(", ?", names.ToArray())+")"; | 193 | sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; |
210 | 194 | ||
211 | cmd.CommandText = sql; | 195 | cmd.CommandText = sql; |
212 | cmd.Parameters.Clear(); | 196 | cmd.Parameters.Clear(); |
@@ -216,13 +200,13 @@ namespace OpenSim.Data.MySQL | |||
216 | if (m_FieldMap[name].GetValue(es) is bool) | 200 | if (m_FieldMap[name].GetValue(es) is bool) |
217 | { | 201 | { |
218 | if ((bool)m_FieldMap[name].GetValue(es)) | 202 | if ((bool)m_FieldMap[name].GetValue(es)) |
219 | cmd.Parameters.AddWithValue("?"+name, "1"); | 203 | cmd.Parameters.AddWithValue("?" + name, "1"); |
220 | else | 204 | else |
221 | cmd.Parameters.AddWithValue("?"+name, "0"); | 205 | cmd.Parameters.AddWithValue("?" + name, "0"); |
222 | } | 206 | } |
223 | else | 207 | else |
224 | { | 208 | { |
225 | cmd.Parameters.AddWithValue("?"+name, m_FieldMap[name].GetValue(es).ToString()); | 209 | cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); |
226 | } | 210 | } |
227 | } | 211 | } |
228 | 212 | ||
@@ -255,7 +239,7 @@ namespace OpenSim.Data.MySQL | |||
255 | // Munge and transfer the ban list | 239 | // Munge and transfer the ban list |
256 | // | 240 | // |
257 | cmd.Parameters.Clear(); | 241 | cmd.Parameters.Clear(); |
258 | cmd.CommandText = "insert into estateban select "+es.EstateID.ToString()+", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; | 242 | cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; |
259 | cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); | 243 | cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); |
260 | 244 | ||
261 | try | 245 | try |
@@ -279,7 +263,7 @@ namespace OpenSim.Data.MySQL | |||
279 | 263 | ||
280 | public void StoreEstateSettings(EstateSettings es) | 264 | public void StoreEstateSettings(EstateSettings es) |
281 | { | 265 | { |
282 | string sql = "replace into estate_settings ("+String.Join(",", FieldList)+") values ( ?"+String.Join(", ?", FieldList)+")"; | 266 | string sql = "replace into estate_settings (" + String.Join(",", FieldList) + ") values ( ?" + String.Join(", ?", FieldList) + ")"; |
283 | 267 | ||
284 | CheckConnection(); | 268 | CheckConnection(); |
285 | 269 | ||
@@ -292,13 +276,13 @@ namespace OpenSim.Data.MySQL | |||
292 | if (m_FieldMap[name].GetValue(es) is bool) | 276 | if (m_FieldMap[name].GetValue(es) is bool) |
293 | { | 277 | { |
294 | if ((bool)m_FieldMap[name].GetValue(es)) | 278 | if ((bool)m_FieldMap[name].GetValue(es)) |
295 | cmd.Parameters.AddWithValue("?"+name, "1"); | 279 | cmd.Parameters.AddWithValue("?" + name, "1"); |
296 | else | 280 | else |
297 | cmd.Parameters.AddWithValue("?"+name, "0"); | 281 | cmd.Parameters.AddWithValue("?" + name, "0"); |
298 | } | 282 | } |
299 | else | 283 | else |
300 | { | 284 | { |
301 | cmd.Parameters.AddWithValue("?"+name, m_FieldMap[name].GetValue(es).ToString()); | 285 | cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); |
302 | } | 286 | } |
303 | } | 287 | } |
304 | 288 | ||
@@ -369,14 +353,14 @@ namespace OpenSim.Data.MySQL | |||
369 | 353 | ||
370 | MySqlCommand cmd = m_connection.CreateCommand(); | 354 | MySqlCommand cmd = m_connection.CreateCommand(); |
371 | 355 | ||
372 | cmd.CommandText = "delete from "+table+" where EstateID = ?EstateID"; | 356 | cmd.CommandText = "delete from " + table + " where EstateID = ?EstateID"; |
373 | cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); | 357 | cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); |
374 | 358 | ||
375 | cmd.ExecuteNonQuery(); | 359 | cmd.ExecuteNonQuery(); |
376 | 360 | ||
377 | cmd.Parameters.Clear(); | 361 | cmd.Parameters.Clear(); |
378 | 362 | ||
379 | cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( ?EstateID, ?uuid )"; | 363 | cmd.CommandText = "insert into " + table + " (EstateID, uuid) values ( ?EstateID, ?uuid )"; |
380 | 364 | ||
381 | foreach (UUID uuid in data) | 365 | foreach (UUID uuid in data) |
382 | { | 366 | { |
@@ -396,7 +380,7 @@ namespace OpenSim.Data.MySQL | |||
396 | 380 | ||
397 | MySqlCommand cmd = m_connection.CreateCommand(); | 381 | MySqlCommand cmd = m_connection.CreateCommand(); |
398 | 382 | ||
399 | cmd.CommandText = "select uuid from "+table+" where EstateID = ?EstateID"; | 383 | cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID"; |
400 | cmd.Parameters.AddWithValue("?EstateID", EstateID); | 384 | cmd.Parameters.AddWithValue("?EstateID", EstateID); |
401 | 385 | ||
402 | IDataReader r = cmd.ExecuteReader(); | 386 | IDataReader r = cmd.ExecuteReader(); |