mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
Use ObjectMgr/AccountMgr functions instead explici DB quaries.
This commit is contained in:
parent
42b077df0c
commit
911dbe0b29
4 changed files with 34 additions and 37 deletions
|
|
@ -4842,25 +4842,18 @@ bool ChatHandler::HandleBanInfoCommand(const char* args)
|
|||
return false;
|
||||
}
|
||||
|
||||
loginDatabase.escape_string(nameOrIP);
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'", nameOrIP.c_str());
|
||||
if (!result)
|
||||
accountid = objmgr.GetPlayerAccountIdByPlayerName (nameOrIP);
|
||||
if (!accountid)
|
||||
{
|
||||
PSendSysMessage (LANG_BANINFO_NOCHARACTER);
|
||||
return true;
|
||||
}
|
||||
fields = result->Fetch();
|
||||
accountid = fields[0].GetUInt32();
|
||||
delete result;
|
||||
result = loginDatabase.PQuery("SELECT username FROM account WHERE id = '%u'", accountid);
|
||||
if (!result)
|
||||
|
||||
if (!accmgr.GetName (accountid,accountname))
|
||||
{
|
||||
PSendSysMessage (LANG_BANINFO_NOCHARACTER);
|
||||
return true;
|
||||
}
|
||||
fields = result->Fetch();
|
||||
accountname = fields[0].GetCppString();
|
||||
delete result;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1296,6 +1296,19 @@ uint32 ObjectMgr::GetPlayerAccountIdByGUID(const uint64 &guid) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
uint32 ObjectMgr::GetPlayerAccountIdByPlayerName(std::string name) const
|
||||
{
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'", name.c_str());
|
||||
if(result)
|
||||
{
|
||||
uint32 acc = (*result)[0].GetUInt32();
|
||||
delete result;
|
||||
return acc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadAuctions()
|
||||
{
|
||||
QueryResult *result = CharacterDatabase.Query("SELECT COUNT(*) FROM auctionhouse");
|
||||
|
|
|
|||
|
|
@ -391,6 +391,7 @@ class ObjectMgr
|
|||
bool GetPlayerNameByGUID(const uint64 &guid, std::string &name) const;
|
||||
uint32 GetPlayerTeamByGUID(const uint64 &guid) const;
|
||||
uint32 GetPlayerAccountIdByGUID(const uint64 &guid) const;
|
||||
uint32 GetPlayerAccountIdByPlayerName(std::string name) const;
|
||||
|
||||
uint32 GetNearestTaxiNode( float x, float y, float z, uint32 mapid );
|
||||
void GetTaxiPath( uint32 source, uint32 destination, uint32 &path, uint32 &cost);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
#include "SkillExtraItems.h"
|
||||
#include "SkillDiscovery.h"
|
||||
#include "World.h"
|
||||
#include "AccountMgr.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "Chat.h"
|
||||
|
|
@ -2279,33 +2280,22 @@ bool World::RemoveBanAccount(std::string type, std::string nameOrIP)
|
|||
uint32 account = 0;
|
||||
if (type == "account")
|
||||
{
|
||||
//NO SQL injection as name is escaped
|
||||
loginDatabase.escape_string(nameOrIP);
|
||||
QueryResult *resultAccounts = loginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'",nameOrIP.c_str());
|
||||
if(!resultAccounts)
|
||||
if (!AccountMgr::normilizeString (nameOrIP))
|
||||
return false;
|
||||
Field* fieldsAccount = resultAccounts->Fetch();
|
||||
account = fieldsAccount->GetUInt32();
|
||||
|
||||
delete resultAccounts;
|
||||
account = accmgr.GetId (nameOrIP);
|
||||
}
|
||||
else if (type == "character")
|
||||
{
|
||||
if (!normalizePlayerName (nameOrIP))
|
||||
return false;
|
||||
|
||||
//NO SQL injection as name is escaped
|
||||
loginDatabase.escape_string(nameOrIP);
|
||||
QueryResult *resultAccounts = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'",nameOrIP.c_str());
|
||||
if(!resultAccounts)
|
||||
return false;
|
||||
Field* fieldsAccount = resultAccounts->Fetch();
|
||||
account = fieldsAccount->GetUInt32();
|
||||
|
||||
delete resultAccounts;
|
||||
account = objmgr.GetPlayerAccountIdByPlayerName (nameOrIP);
|
||||
}
|
||||
|
||||
if (!account)
|
||||
return false;
|
||||
|
||||
//NO SQL injection as account is uint32
|
||||
loginDatabase.PExecute("UPDATE account_banned SET active = '0' WHERE id = '%u'",account);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue