Core/DBLayer: Convert PQuery() queries to prepared statements
This commit is contained in:
@@ -444,7 +444,10 @@ ChatCommand* ChatHandler::getCommandTable()
|
||||
added += appendCommandTable(commandTableCache + added, *it);
|
||||
}
|
||||
|
||||
QueryResult result = WorldDatabase.Query("SELECT name, security, help FROM command");
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_COMMANDS);
|
||||
|
||||
PreparedQueryResult result = WorldDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
|
||||
@@ -350,8 +350,8 @@ class ChatHandler
|
||||
bool HandleSaveAllCommand(const char* args);
|
||||
|
||||
// Utility methods for commands
|
||||
bool LookupPlayerSearchCommand(QueryResult result, int32 limit);
|
||||
bool HandleBanListHelper(QueryResult result);
|
||||
bool LookupPlayerSearchCommand(PreparedQueryResult result, int32 limit);
|
||||
bool HandleBanListHelper(PreparedQueryResult result);
|
||||
bool HandleBanHelper(BanMode mode, char const* args);
|
||||
bool HandleBanInfoHelper(uint32 accountid, char const* accountname);
|
||||
bool HandleUnBanHelper(BanMode mode, char const* args);
|
||||
|
||||
@@ -266,18 +266,18 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
|
||||
else if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name))
|
||||
return false;
|
||||
|
||||
uint32 accId = 0;
|
||||
uint32 money = 0;
|
||||
uint32 accId = 0;
|
||||
uint32 money = 0;
|
||||
uint32 total_player_time = 0;
|
||||
uint8 level = 0;
|
||||
uint32 latency = 0;
|
||||
uint8 level = 0;
|
||||
uint32 latency = 0;
|
||||
uint8 race;
|
||||
uint8 Class;
|
||||
int64 muteTime = 0;
|
||||
int64 banTime = -1;
|
||||
int64 muteTime = 0;
|
||||
int64 banTime = -1;
|
||||
uint32 mapId;
|
||||
uint32 areaId;
|
||||
uint32 phase = 0;
|
||||
uint32 phase = 0;
|
||||
|
||||
// get additional information from Player object
|
||||
if (target)
|
||||
@@ -286,17 +286,17 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
|
||||
if (HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
accId = target->GetSession()->GetAccountId();
|
||||
money = target->GetMoney();
|
||||
accId = target->GetSession()->GetAccountId();
|
||||
money = target->GetMoney();
|
||||
total_player_time = target->GetTotalPlayedTime();
|
||||
level = target->getLevel();
|
||||
latency = target->GetSession()->GetLatency();
|
||||
race = target->getRace();
|
||||
Class = target->getClass();
|
||||
muteTime = target->GetSession()->m_muteTime;
|
||||
mapId = target->GetMapId();
|
||||
areaId = target->GetAreaId();
|
||||
phase = target->GetPhaseMask();
|
||||
level = target->getLevel();
|
||||
latency = target->GetSession()->GetLatency();
|
||||
race = target->getRace();
|
||||
Class = target->getClass();
|
||||
muteTime = target->GetSession()->m_muteTime;
|
||||
mapId = target->GetMapId();
|
||||
areaId = target->GetAreaId();
|
||||
phase = target->GetPhaseMask();
|
||||
}
|
||||
// get additional information from DB
|
||||
else
|
||||
@@ -305,41 +305,42 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
|
||||
if (HasLowerSecurity(NULL, target_guid))
|
||||
return false;
|
||||
|
||||
// 0 1 2 3 4 5 6 7
|
||||
QueryResult result = CharacterDatabase.PQuery("SELECT totaltime, level, money, account, race, class, map, zone FROM characters "
|
||||
"WHERE guid = '%u'", GUID_LOPART(target_guid));
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PINFO);
|
||||
stmt->setUInt32(0, GUID_LOPART(target_guid));
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
Field* fields = result->Fetch();
|
||||
Field* fields = result->Fetch();
|
||||
total_player_time = fields[0].GetUInt32();
|
||||
level = fields[1].GetUInt32();
|
||||
money = fields[2].GetUInt32();
|
||||
accId = fields[3].GetUInt32();
|
||||
race = fields[4].GetUInt8();
|
||||
Class = fields[5].GetUInt8();
|
||||
mapId = fields[6].GetUInt16();
|
||||
areaId = fields[7].GetUInt16();
|
||||
level = fields[1].GetUInt32();
|
||||
money = fields[2].GetUInt32();
|
||||
accId = fields[3].GetUInt32();
|
||||
race = fields[4].GetUInt8();
|
||||
Class = fields[5].GetUInt8();
|
||||
mapId = fields[6].GetUInt16();
|
||||
areaId = fields[7].GetUInt16();
|
||||
}
|
||||
|
||||
std::string username = GetTrinityString(LANG_ERROR);
|
||||
std::string email = GetTrinityString(LANG_ERROR);
|
||||
std::string last_ip = GetTrinityString(LANG_ERROR);
|
||||
uint32 security = 0;
|
||||
std::string username = GetTrinityString(LANG_ERROR);
|
||||
std::string email = GetTrinityString(LANG_ERROR);
|
||||
std::string last_ip = GetTrinityString(LANG_ERROR);
|
||||
uint32 security = 0;
|
||||
std::string last_login = GetTrinityString(LANG_ERROR);
|
||||
|
||||
QueryResult result = LoginDatabase.PQuery("SELECT a.username, aa.gmlevel, a.email, a.last_ip, a.last_login, a.mutetime "
|
||||
"FROM account a "
|
||||
"LEFT JOIN account_access aa "
|
||||
"ON (a.id = aa.id AND (aa.RealmID = -1 OR aa.RealmID = %u)) "
|
||||
"WHERE a.id = '%u'", realmID, accId);
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO);
|
||||
stmt->setInt32(0, int32(realmID));
|
||||
stmt->setUInt32(1, accId);
|
||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
username = fields[0].GetString();
|
||||
security = fields[1].GetUInt32();
|
||||
email = fields[2].GetString();
|
||||
muteTime = fields[5].GetUInt64();
|
||||
username = fields[0].GetString();
|
||||
security = fields[1].GetUInt32();
|
||||
email = fields[2].GetString();
|
||||
muteTime = fields[5].GetUInt64();
|
||||
|
||||
if (email.empty())
|
||||
email = "-";
|
||||
@@ -354,8 +355,13 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
|
||||
EndianConvertReverse(ip);
|
||||
#endif
|
||||
|
||||
if (QueryResult result2 = WorldDatabase.PQuery("SELECT c.country FROM ip2nationCountries c, ip2nation i WHERE "
|
||||
"i.ip < %u AND c.code = i.country ORDER BY i.ip DESC LIMIT 0,1", ip))
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_IP2NATION_COUNTRY);
|
||||
|
||||
stmt->setUInt32(0, ip);
|
||||
|
||||
PreparedQueryResult result2 = WorldDatabase.Query(stmt);
|
||||
|
||||
if (result2)
|
||||
{
|
||||
Field* fields2 = result2->Fetch();
|
||||
last_ip.append(" (");
|
||||
@@ -376,21 +382,23 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
|
||||
|
||||
std::string bannedby = "unknown";
|
||||
std::string banreason = "";
|
||||
if (QueryResult result2 = LoginDatabase.PQuery("SELECT unbandate, bandate = unbandate, bannedby, banreason FROM account_banned "
|
||||
"WHERE id = '%u' AND active ORDER BY bandate ASC LIMIT 1", accId))
|
||||
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO_BANS);
|
||||
stmt->setUInt32(0, accId);
|
||||
PreparedQueryResult result2 = LoginDatabase.Query(stmt);
|
||||
if (!result2)
|
||||
{
|
||||
Field* fields = result2->Fetch();
|
||||
banTime = fields[1].GetBool() ? 0 : fields[0].GetUInt64();
|
||||
bannedby = fields[2].GetString();
|
||||
banreason = fields[3].GetString();
|
||||
stmt = LoginDatabase.GetPreparedStatement(CHAR_SEL_PINFO_BANS);
|
||||
stmt->setUInt32(0, GUID_LOPART(target_guid));
|
||||
result2 = LoginDatabase.Query(stmt);
|
||||
}
|
||||
else if (QueryResult result3 = CharacterDatabase.PQuery("SELECT unbandate, bandate = unbandate, bannedby, banreason FROM character_banned "
|
||||
"WHERE guid = '%u' AND active ORDER BY bandate ASC LIMIT 1", GUID_LOPART(target_guid)))
|
||||
|
||||
if (result2)
|
||||
{
|
||||
Field* fields = result3->Fetch();
|
||||
banTime = fields[1].GetBool() ? 0 : fields[0].GetUInt64();
|
||||
bannedby = fields[2].GetString();
|
||||
banreason = fields[3].GetString();
|
||||
Field* fields = result->Fetch();
|
||||
banTime = fields[1].GetBool() ? 0 : fields[0].GetUInt64();
|
||||
bannedby = fields[2].GetString();
|
||||
banreason = fields[3].GetString();
|
||||
}
|
||||
|
||||
if (muteTime > 0)
|
||||
@@ -741,9 +749,9 @@ bool ChatHandler::HandleLookupPlayerIpCommand(const char* args)
|
||||
limit = limit_str ? atoi (limit_str) : -1;
|
||||
}
|
||||
|
||||
LoginDatabase.EscapeString(ip);
|
||||
|
||||
QueryResult result = LoginDatabase.PQuery("SELECT id, username FROM account WHERE last_ip = '%s'", ip.c_str());
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BY_IP);
|
||||
stmt->setString(0, ip);
|
||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||
|
||||
return LookupPlayerSearchCommand(result, limit);
|
||||
}
|
||||
@@ -760,9 +768,9 @@ bool ChatHandler::HandleLookupPlayerAccountCommand(const char* args)
|
||||
if (!AccountMgr::normalizeString (account))
|
||||
return false;
|
||||
|
||||
LoginDatabase.EscapeString (account);
|
||||
|
||||
QueryResult result = LoginDatabase.PQuery ("SELECT id, username FROM account WHERE username = '%s'", account.c_str ());
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_LIST_BY_NAME);
|
||||
stmt->setString(0, account);
|
||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||
|
||||
return LookupPlayerSearchCommand (result, limit);
|
||||
}
|
||||
@@ -776,14 +784,14 @@ bool ChatHandler::HandleLookupPlayerEmailCommand(const char* args)
|
||||
char* limit_str = strtok (NULL, " ");
|
||||
int32 limit = limit_str ? atoi (limit_str) : -1;
|
||||
|
||||
LoginDatabase.EscapeString (email);
|
||||
|
||||
QueryResult result = LoginDatabase.PQuery ("SELECT id, username FROM account WHERE email = '%s'", email.c_str ());
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_LIST_BY_EMAIL);
|
||||
stmt->setString(0, email);
|
||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||
|
||||
return LookupPlayerSearchCommand(result, limit);
|
||||
}
|
||||
|
||||
bool ChatHandler::LookupPlayerSearchCommand(QueryResult result, int32 limit)
|
||||
bool ChatHandler::LookupPlayerSearchCommand(PreparedQueryResult result, int32 limit)
|
||||
{
|
||||
if (!result)
|
||||
{
|
||||
@@ -807,8 +815,11 @@ bool ChatHandler::LookupPlayerSearchCommand(QueryResult result, int32 limit)
|
||||
uint32 acc_id = fields[0].GetUInt32();
|
||||
std::string acc_name = fields[1].GetString();
|
||||
|
||||
QueryResult chars = CharacterDatabase.PQuery("SELECT guid, name FROM characters WHERE account = '%u'", acc_id);
|
||||
if (chars)
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_GUID_NAME_BY_ACC);
|
||||
stmt->setUInt32(0, acc_id);
|
||||
PreparedQueryResult result2 = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (result2)
|
||||
{
|
||||
PSendSysMessage(LANG_LOOKUP_PLAYER_ACCOUNT, acc_name.c_str(), acc_id);
|
||||
|
||||
@@ -817,14 +828,14 @@ bool ChatHandler::LookupPlayerSearchCommand(QueryResult result, int32 limit)
|
||||
|
||||
do
|
||||
{
|
||||
Field* charfields = chars->Fetch();
|
||||
Field* charfields = result2->Fetch();
|
||||
guid = charfields[0].GetUInt64();
|
||||
name = charfields[1].GetString();
|
||||
|
||||
PSendSysMessage(LANG_LOOKUP_PLAYER_CHARACTER, name.c_str(), guid);
|
||||
++i;
|
||||
|
||||
} while (chars->NextRow() && (limit == -1 || i < limit));
|
||||
} while (result2->NextRow() && (limit == -1 || i < limit));
|
||||
}
|
||||
} while (result->NextRow());
|
||||
|
||||
|
||||
@@ -225,7 +225,11 @@ bool ChatHandler::HandleAddItemCommand(const char *args)
|
||||
{
|
||||
std::string itemName = citemName+1;
|
||||
WorldDatabase.EscapeString(itemName);
|
||||
QueryResult result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE name = '%s'", itemName.c_str());
|
||||
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_ITEM_TEMPLATE_BY_NAME);
|
||||
stmt->setString(0, itemName);
|
||||
PreparedQueryResult result = WorldDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_COULDNOTFIND, citemName+1);
|
||||
@@ -413,22 +417,22 @@ bool ChatHandler::HandleListItemCommand(const char *args)
|
||||
return false;
|
||||
uint32 count = uint32(_count);
|
||||
|
||||
QueryResult result;
|
||||
PreparedQueryResult result;
|
||||
|
||||
// inventory case
|
||||
uint32 inv_count = 0;
|
||||
result = CharacterDatabase.PQuery("SELECT COUNT(itemEntry) FROM character_inventory ci INNER JOIN item_instance ii ON ii.guid = ci.item WHERE itemEntry = '%u'", item_id);
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_COUNT_ITEM);
|
||||
stmt->setUInt32(0, item_id);
|
||||
result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
inv_count = (*result)[0].GetUInt32();
|
||||
|
||||
result=CharacterDatabase.PQuery(
|
||||
// 0 1 2 3 4 5
|
||||
"SELECT ci.item, cb.slot AS bag, ci.slot, ci.guid, c.account, c.name FROM characters c "
|
||||
"INNER JOIN character_inventory ci ON ci.guid = c.guid "
|
||||
"INNER JOIN item_instance ii ON ii.guid = ci.item "
|
||||
"LEFT JOIN character_inventory cb ON cb.item = ci.bag "
|
||||
"WHERE ii.itemEntry = '%u' LIMIT %u ",
|
||||
item_id, count);
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY);
|
||||
stmt->setUInt32(0, item_id);
|
||||
stmt->setUInt32(1, count);
|
||||
result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
{
|
||||
@@ -466,24 +470,23 @@ bool ChatHandler::HandleListItemCommand(const char *args)
|
||||
|
||||
// mail case
|
||||
uint32 mail_count = 0;
|
||||
result = CharacterDatabase.PQuery("SELECT COUNT(itemEntry) FROM mail_items mi INNER JOIN item_instance ii ON ii.guid = mi.item_guid WHERE itemEntry = '%u'", item_id);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_COUNT_ITEM);
|
||||
stmt->setUInt32(0, item_id);
|
||||
result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
mail_count = (*result)[0].GetUInt32();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
result = CharacterDatabase.PQuery(
|
||||
// 0 1 2 3 4 5 6
|
||||
"SELECT mi.item_guid, m.sender, m.receiver, cs.account, cs.name, cr.account, cr.name FROM mail m "
|
||||
"INNER JOIN mail_items mi ON mi.mail_id = m.id "
|
||||
"INNER JOIN item_instance ii ON ii.guid = mi.item_guid "
|
||||
"INNER JOIN characters cs ON cs.guid = m.sender "
|
||||
"INNER JOIN characters cr ON cr.guid = m.receiver "
|
||||
"WHERE ii.itemEntry = '%u' LIMIT %u",
|
||||
item_id, count);
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_ITEMS_BY_ENTRY);
|
||||
stmt->setUInt32(0, item_id);
|
||||
stmt->setUInt32(1, count);
|
||||
result = CharacterDatabase.Query(stmt);
|
||||
}
|
||||
else
|
||||
result = QueryResult(NULL);
|
||||
result = PreparedQueryResult(NULL);
|
||||
|
||||
if (result)
|
||||
{
|
||||
@@ -514,21 +517,23 @@ bool ChatHandler::HandleListItemCommand(const char *args)
|
||||
|
||||
// auction case
|
||||
uint32 auc_count = 0;
|
||||
result=CharacterDatabase.PQuery("SELECT COUNT(itemEntry) FROM auctionhouse ah INNER JOIN item_instance ii ON ii.guid = ah.itemguid WHERE itemEntry = '%u'", item_id);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTIONHOUSE_COUNT_ITEM);
|
||||
stmt->setUInt32(0, item_id);
|
||||
result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
auc_count = (*result)[0].GetUInt32();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
result = CharacterDatabase.PQuery(
|
||||
// 0 1 2 3
|
||||
"SELECT ah.itemguid, ah.itemowner, c.account, c.name FROM auctionhouse ah "
|
||||
"INNER JOIN characters c ON c.guid = ah.itemowner "
|
||||
"INNER JOIN item_instance ii ON ii.guid = ah.itemguid "
|
||||
"WHERE ii.itemEntry = '%u' LIMIT %u", item_id, count);
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTIONHOUSE_ITEM_BY_ENTRY);
|
||||
stmt->setUInt32(0, item_id);
|
||||
stmt->setUInt32(1, count);
|
||||
result = CharacterDatabase.Query(stmt);
|
||||
}
|
||||
else
|
||||
result = QueryResult(NULL);
|
||||
result = PreparedQueryResult(NULL);
|
||||
|
||||
if (result)
|
||||
{
|
||||
@@ -549,17 +554,18 @@ bool ChatHandler::HandleListItemCommand(const char *args)
|
||||
|
||||
// guild bank case
|
||||
uint32 guild_count = 0;
|
||||
result = CharacterDatabase.PQuery("SELECT COUNT(itemEntry) FROM guild_bank_item gbi INNER JOIN item_instance ii ON ii.guid = gbi.item_guid WHERE itemEntry = '%u'", item_id);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_BANK_COUNT_ITEM);
|
||||
stmt->setUInt32(0, item_id);
|
||||
result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
guild_count = (*result)[0].GetUInt32();
|
||||
|
||||
result = CharacterDatabase.PQuery(
|
||||
// 0 1 2
|
||||
"SELECT gi.item_guid, gi.guildid, g.name FROM guild_bank_item gi "
|
||||
"INNER JOIN guild g ON g.guildid = gi.guildid "
|
||||
"INNER JOIN item_instance ii ON ii.guid = gi.item_guid "
|
||||
"WHERE ii.itemEntry = '%u' LIMIT %u ",
|
||||
item_id, count);
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_BANK_ITEM_BY_ENTRY);
|
||||
stmt->setUInt32(0, item_id);
|
||||
stmt->setUInt32(1, count);
|
||||
result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
{
|
||||
@@ -3220,7 +3226,7 @@ bool ChatHandler::HandleBanListCharacterCommand(const char *args)
|
||||
|
||||
std::string filter(cFilter);
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUID_BY_NAME_FILTER);
|
||||
stmt->setString(0, filter.c_str());
|
||||
stmt->setString(0, filter);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
if (!result)
|
||||
{
|
||||
@@ -3302,20 +3308,22 @@ bool ChatHandler::HandleBanListAccountCommand(const char *args)
|
||||
|
||||
char* cFilter = strtok((char*)args, " ");
|
||||
std::string filter = cFilter ? cFilter : "";
|
||||
LoginDatabase.EscapeString(filter);
|
||||
|
||||
QueryResult result;
|
||||
PreparedQueryResult result;
|
||||
|
||||
if (filter.empty())
|
||||
{
|
||||
result = LoginDatabase.Query("SELECT account.id, username FROM account, account_banned"
|
||||
" WHERE account.id = account_banned.id AND active = 1 GROUP BY account.id");
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED_ALL);
|
||||
|
||||
result = LoginDatabase.Query(stmt);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = LoginDatabase.PQuery("SELECT account.id, username FROM account, account_banned"
|
||||
" WHERE account.id = account_banned.id AND active = 1 AND username "_LIKE_" "_CONCAT3_("'%%'", "'%s'", "'%%'")" GROUP BY account.id",
|
||||
filter.c_str());
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED_BY_USERNAME);
|
||||
|
||||
stmt->setString(0, filter);
|
||||
|
||||
result = LoginDatabase.Query(stmt);
|
||||
}
|
||||
|
||||
if (!result)
|
||||
@@ -3327,7 +3335,7 @@ bool ChatHandler::HandleBanListAccountCommand(const char *args)
|
||||
return HandleBanListHelper(result);
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleBanListHelper(QueryResult result)
|
||||
bool ChatHandler::HandleBanListHelper(PreparedQueryResult result)
|
||||
{
|
||||
PSendSysMessage(LANG_BANLIST_MATCHINGACCOUNT);
|
||||
|
||||
@@ -3410,19 +3418,21 @@ bool ChatHandler::HandleBanListIPCommand(const char *args)
|
||||
std::string filter = cFilter ? cFilter : "";
|
||||
LoginDatabase.EscapeString(filter);
|
||||
|
||||
QueryResult result;
|
||||
PreparedQueryResult result;
|
||||
|
||||
if (filter.empty())
|
||||
{
|
||||
result = LoginDatabase.Query ("SELECT ip, bandate, unbandate, bannedby, banreason FROM ip_banned"
|
||||
" WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP())"
|
||||
" ORDER BY unbandate");
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_BANNED_ALL);
|
||||
|
||||
result = LoginDatabase.Query(stmt);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = LoginDatabase.PQuery("SELECT ip, bandate, unbandate, bannedby, banreason FROM ip_banned"
|
||||
" WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP()) AND ip "_LIKE_" "_CONCAT3_("'%%'", "'%s'", "'%%'")
|
||||
" ORDER BY unbandate", filter.c_str());
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_BANNED_BY_IP);
|
||||
|
||||
stmt->setString(0, filter);
|
||||
|
||||
result = LoginDatabase.Query(stmt);
|
||||
}
|
||||
|
||||
if (!result)
|
||||
@@ -4619,8 +4629,11 @@ bool ChatHandler::HandleUnFreezeCommand(const char *args)
|
||||
{
|
||||
if (TargetName)
|
||||
{
|
||||
//check for offline players
|
||||
QueryResult result = CharacterDatabase.PQuery("SELECT characters.guid FROM characters WHERE characters.name = '%s'", name.c_str());
|
||||
// Check for offline players
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_GUID_BY_NAME);
|
||||
stmt->setString(0, name);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
SendSysMessage(LANG_COMMAND_FREEZE_WRONG);
|
||||
@@ -4630,7 +4643,10 @@ bool ChatHandler::HandleUnFreezeCommand(const char *args)
|
||||
Field* fields=result->Fetch();
|
||||
uint64 pguid = fields[0].GetUInt64();
|
||||
|
||||
CharacterDatabase.PQuery("DELETE FROM character_aura WHERE character_aura.spell = 9454 AND character_aura.guid = '%u'", pguid);
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_AURA_FROZEN);
|
||||
stmt->setUInt32(0, pguid);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
PSendSysMessage(LANG_COMMAND_UNFREEZE, name.c_str());
|
||||
return true;
|
||||
}
|
||||
@@ -4646,8 +4662,11 @@ bool ChatHandler::HandleUnFreezeCommand(const char *args)
|
||||
|
||||
bool ChatHandler::HandleListFreezeCommand(const char * /*args*/)
|
||||
{
|
||||
//Get names from DB
|
||||
QueryResult result = CharacterDatabase.Query("SELECT characters.name FROM characters LEFT JOIN character_aura ON (characters.guid = character_aura.guid) WHERE character_aura.spell = 9454");
|
||||
// Get names from DB
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_AURA_FROZEN);
|
||||
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
SendSysMessage(LANG_COMMAND_NO_FROZEN_PLAYERS);
|
||||
|
||||
Reference in New Issue
Block a user