- Timestamp:
- 11/19/08 13:34:57 (17 years ago)
- Location:
- trunk/src/game
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/Level3.cpp
r85 r94 4825 4825 } 4826 4826 4827 loginDatabase.escape_string(nameOrIP); 4828 QueryResult *result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'", nameOrIP.c_str()); 4829 if (!result) 4827 accountid = objmgr.GetPlayerAccountIdByPlayerName (nameOrIP); 4828 if (!accountid) 4830 4829 { 4831 4830 PSendSysMessage(LANG_BANINFO_NOCHARACTER); 4832 4831 return true; 4833 4832 } 4834 fields = result->Fetch(); 4835 accountid = fields[0].GetUInt32(); 4836 delete result; 4837 result = loginDatabase.PQuery("SELECT username FROM account WHERE id = '%u'", accountid); 4838 if (!result) 4833 4834 if (!accmgr.GetName (accountid,accountname)) 4839 4835 { 4840 4836 PSendSysMessage(LANG_BANINFO_NOCHARACTER); 4841 4837 return true; 4842 4838 } 4843 fields = result->Fetch();4844 accountname = fields[0].GetCppString();4845 delete result;4846 4839 } 4847 4840 else -
trunk/src/game/ObjectMgr.cpp
r88 r94 1356 1356 { 1357 1357 QueryResult *result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE guid = '%u'", GUID_LOPART(guid)); 1358 if(result) 1359 { 1360 uint32 acc = (*result)[0].GetUInt32(); 1361 delete result; 1362 return acc; 1363 } 1364 1365 return 0; 1366 } 1367 1368 uint32 ObjectMgr::GetPlayerAccountIdByPlayerName(std::string name) const 1369 { 1370 QueryResult *result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'", name.c_str()); 1358 1371 if(result) 1359 1372 { -
trunk/src/game/ObjectMgr.h
r88 r94 414 414 uint32 GetPlayerTeamByGUID(const uint64 &guid) const; 415 415 uint32 GetPlayerAccountIdByGUID(const uint64 &guid) const; 416 uint32 GetPlayerAccountIdByPlayerName(std::string name) const; 416 417 417 418 uint32 GetNearestTaxiNode( float x, float y, float z, uint32 mapid ); -
trunk/src/game/World.cpp
r88 r94 37 37 #include "SkillDiscovery.h" 38 38 #include "World.h" 39 #include "AccountMgr.h" 39 40 #include "ObjectMgr.h" 40 41 #include "SpellMgr.h" … … 2338 2339 if(type == "account") 2339 2340 { 2340 //NO SQL injection as name is escaped 2341 loginDatabase.escape_string(nameOrIP); 2342 QueryResult *resultAccounts = loginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'",nameOrIP.c_str()); 2343 if(!resultAccounts) 2341 if (!AccountMgr::normilizeString (nameOrIP)) 2344 2342 return false; 2345 Field* fieldsAccount = resultAccounts->Fetch(); 2346 account = fieldsAccount->GetUInt32(); 2347 2348 delete resultAccounts; 2343 2344 account = accmgr.GetId (nameOrIP); 2349 2345 } 2350 2346 else if(type == "character") … … 2353 2349 return false; 2354 2350 2355 //NO SQL injection as name is escaped 2356 loginDatabase.escape_string(nameOrIP); 2357 QueryResult *resultAccounts = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'",nameOrIP.c_str()); 2358 if(!resultAccounts) 2359 return false; 2360 Field* fieldsAccount = resultAccounts->Fetch(); 2361 account = fieldsAccount->GetUInt32(); 2362 2363 delete resultAccounts; 2351 account = objmgr.GetPlayerAccountIdByPlayerName (nameOrIP); 2364 2352 } 2365 2353 if(!account) 2366 2354 return false; 2355 2367 2356 //NO SQL injection as account is uint32 2368 2357 loginDatabase.PExecute("UPDATE account_banned SET active = '0' WHERE id = '%u'",account);