mirror of
https://github.com/mangosfour/server.git
synced 2025-12-25 13:37:02 +00:00
[10102] Rename loginDatabase for consistence with other global db object names
Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
3122c0d10a
commit
f244e68c59
17 changed files with 122 additions and 122 deletions
|
|
@ -25,7 +25,7 @@
|
|||
#include "Util.h"
|
||||
#include "Auth/Sha1.h"
|
||||
|
||||
extern DatabaseType loginDatabase;
|
||||
extern DatabaseType LoginDatabase;
|
||||
|
||||
INSTANTIATE_SINGLETON_1(AccountMgr);
|
||||
|
||||
|
|
@ -48,16 +48,16 @@ AccountOpResult AccountMgr::CreateAccount(std::string username, std::string pass
|
|||
return AOR_NAME_ALREDY_EXIST; // username does already exist
|
||||
}
|
||||
|
||||
if(!loginDatabase.PExecute("INSERT INTO account(username,sha_pass_hash,joindate) VALUES('%s','%s',NOW())", username.c_str(), CalculateShaPassHash(username, password).c_str()))
|
||||
if(!LoginDatabase.PExecute("INSERT INTO account(username,sha_pass_hash,joindate) VALUES('%s','%s',NOW())", username.c_str(), CalculateShaPassHash(username, password).c_str()))
|
||||
return AOR_DB_INTERNAL_ERROR; // unexpected error
|
||||
loginDatabase.Execute("INSERT INTO realmcharacters (realmid, acctid, numchars) SELECT realmlist.id, account.id, 0 FROM realmlist,account LEFT JOIN realmcharacters ON acctid=account.id WHERE acctid IS NULL");
|
||||
LoginDatabase.Execute("INSERT INTO realmcharacters (realmid, acctid, numchars) SELECT realmlist.id, account.id, 0 FROM realmlist,account LEFT JOIN realmcharacters ON acctid=account.id WHERE acctid IS NULL");
|
||||
|
||||
return AOR_OK; // everything's fine
|
||||
}
|
||||
|
||||
AccountOpResult AccountMgr::DeleteAccount(uint32 accid)
|
||||
{
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d'", accid);
|
||||
QueryResult *result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d'", accid);
|
||||
if(!result)
|
||||
return AOR_NAME_NOT_EXIST; // account doesn't exist
|
||||
delete result;
|
||||
|
|
@ -83,13 +83,13 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accid)
|
|||
// table realm specific but common for all characters of account for realm
|
||||
CharacterDatabase.PExecute("DELETE FROM character_tutorial WHERE account = '%u'",accid);
|
||||
|
||||
loginDatabase.BeginTransaction();
|
||||
LoginDatabase.BeginTransaction();
|
||||
|
||||
bool res =
|
||||
loginDatabase.PExecute("DELETE FROM account WHERE id='%d'", accid) &&
|
||||
loginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid='%d'", accid);
|
||||
LoginDatabase.PExecute("DELETE FROM account WHERE id='%d'", accid) &&
|
||||
LoginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid='%d'", accid);
|
||||
|
||||
loginDatabase.CommitTransaction();
|
||||
LoginDatabase.CommitTransaction();
|
||||
|
||||
if(!res)
|
||||
return AOR_DB_INTERNAL_ERROR; // unexpected error;
|
||||
|
|
@ -99,7 +99,7 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accid)
|
|||
|
||||
AccountOpResult AccountMgr::ChangeUsername(uint32 accid, std::string new_uname, std::string new_passwd)
|
||||
{
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d'", accid);
|
||||
QueryResult *result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d'", accid);
|
||||
if(!result)
|
||||
return AOR_NAME_NOT_EXIST; // account doesn't exist
|
||||
delete result;
|
||||
|
|
@ -114,9 +114,9 @@ AccountOpResult AccountMgr::ChangeUsername(uint32 accid, std::string new_uname,
|
|||
normalizeString(new_passwd);
|
||||
|
||||
std::string safe_new_uname = new_uname;
|
||||
loginDatabase.escape_string(safe_new_uname);
|
||||
LoginDatabase.escape_string(safe_new_uname);
|
||||
|
||||
if(!loginDatabase.PExecute("UPDATE account SET v='0',s='0',username='%s',sha_pass_hash='%s' WHERE id='%d'", safe_new_uname.c_str(),
|
||||
if(!LoginDatabase.PExecute("UPDATE account SET v='0',s='0',username='%s',sha_pass_hash='%s' WHERE id='%d'", safe_new_uname.c_str(),
|
||||
CalculateShaPassHash(new_uname, new_passwd).c_str(), accid))
|
||||
return AOR_DB_INTERNAL_ERROR; // unexpected error
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ AccountOpResult AccountMgr::ChangePassword(uint32 accid, std::string new_passwd)
|
|||
normalizeString(new_passwd);
|
||||
|
||||
// also reset s and v to force update at next realmd login
|
||||
if(!loginDatabase.PExecute("UPDATE account SET v='0', s='0', sha_pass_hash='%s' WHERE id='%d'",
|
||||
if(!LoginDatabase.PExecute("UPDATE account SET v='0', s='0', sha_pass_hash='%s' WHERE id='%d'",
|
||||
CalculateShaPassHash(username, new_passwd).c_str(), accid))
|
||||
return AOR_DB_INTERNAL_ERROR; // unexpected error
|
||||
|
||||
|
|
@ -145,8 +145,8 @@ AccountOpResult AccountMgr::ChangePassword(uint32 accid, std::string new_passwd)
|
|||
|
||||
uint32 AccountMgr::GetId(std::string username)
|
||||
{
|
||||
loginDatabase.escape_string(username);
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'", username.c_str());
|
||||
LoginDatabase.escape_string(username);
|
||||
QueryResult *result = LoginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'", username.c_str());
|
||||
if(!result)
|
||||
return 0;
|
||||
else
|
||||
|
|
@ -159,7 +159,7 @@ uint32 AccountMgr::GetId(std::string username)
|
|||
|
||||
AccountTypes AccountMgr::GetSecurity(uint32 acc_id)
|
||||
{
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT gmlevel FROM account WHERE id = '%u'", acc_id);
|
||||
QueryResult *result = LoginDatabase.PQuery("SELECT gmlevel FROM account WHERE id = '%u'", acc_id);
|
||||
if(result)
|
||||
{
|
||||
AccountTypes sec = AccountTypes((*result)[0].GetInt32());
|
||||
|
|
@ -172,7 +172,7 @@ AccountTypes AccountMgr::GetSecurity(uint32 acc_id)
|
|||
|
||||
bool AccountMgr::GetName(uint32 acc_id, std::string &name)
|
||||
{
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT username FROM account WHERE id = '%u'", acc_id);
|
||||
QueryResult *result = LoginDatabase.PQuery("SELECT username FROM account WHERE id = '%u'", acc_id);
|
||||
if(result)
|
||||
{
|
||||
name = (*result)[0].GetCppString();
|
||||
|
|
@ -206,7 +206,7 @@ bool AccountMgr::CheckPassword(uint32 accid, std::string passwd)
|
|||
|
||||
normalizeString(passwd);
|
||||
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d' AND sha_pass_hash='%s'", accid, CalculateShaPassHash(username, passwd).c_str());
|
||||
QueryResult *result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE id='%d' AND sha_pass_hash='%s'", accid, CalculateShaPassHash(username, passwd).c_str());
|
||||
if (result)
|
||||
{
|
||||
delete result;
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
|
|||
return;
|
||||
}
|
||||
|
||||
QueryResult *resultacct = loginDatabase.PQuery("SELECT SUM(numchars) FROM realmcharacters WHERE acctid = '%d'", GetAccountId());
|
||||
QueryResult *resultacct = LoginDatabase.PQuery("SELECT SUM(numchars) FROM realmcharacters WHERE acctid = '%d'", GetAccountId());
|
||||
if (resultacct)
|
||||
{
|
||||
Field *fields=resultacct->Fetch();
|
||||
|
|
@ -471,8 +471,8 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
|
|||
pNewChar->SaveToDB();
|
||||
charcount += 1;
|
||||
|
||||
loginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid= '%d' AND realmid = '%d'", GetAccountId(), realmID);
|
||||
loginDatabase.PExecute("INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (%u, %u, %u)", charcount, GetAccountId(), realmID);
|
||||
LoginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid= '%d' AND realmid = '%d'", GetAccountId(), realmID);
|
||||
LoginDatabase.PExecute("INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (%u, %u, %u)", charcount, GetAccountId(), realmID);
|
||||
|
||||
data << (uint8)CHAR_CREATE_SUCCESS;
|
||||
SendPacket( &data );
|
||||
|
|
@ -717,7 +717,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
|
|||
pCurrChar->SendInitialPacketsAfterAddToMap();
|
||||
|
||||
CharacterDatabase.PExecute("UPDATE characters SET online = 1 WHERE guid = '%u'", pCurrChar->GetGUIDLow());
|
||||
loginDatabase.PExecute("UPDATE account SET active_realm_id = %d WHERE id = '%u'", realmID, GetAccountId());
|
||||
LoginDatabase.PExecute("UPDATE account SET active_realm_id = %d WHERE id = '%u'", realmID, GetAccountId());
|
||||
pCurrChar->SetInGameTime( getMSTime() );
|
||||
|
||||
// announce group about member online (must be after add to player list to receive announce to self)
|
||||
|
|
|
|||
|
|
@ -249,14 +249,14 @@ bool ChatHandler::HandleAccountLockCommand(const char* args)
|
|||
std::string argstr = (char*)args;
|
||||
if (argstr == "on")
|
||||
{
|
||||
loginDatabase.PExecute( "UPDATE account SET locked = '1' WHERE id = '%d'",GetAccountId());
|
||||
LoginDatabase.PExecute( "UPDATE account SET locked = '1' WHERE id = '%d'",GetAccountId());
|
||||
PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (argstr == "off")
|
||||
{
|
||||
loginDatabase.PExecute( "UPDATE account SET locked = '0' WHERE id = '%d'",GetAccountId());
|
||||
LoginDatabase.PExecute( "UPDATE account SET locked = '0' WHERE id = '%d'",GetAccountId());
|
||||
PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ bool ChatHandler::HandleMuteCommand(const char* args)
|
|||
if (target)
|
||||
target->GetSession()->m_muteTime = mutetime;
|
||||
|
||||
loginDatabase.PExecute("UPDATE account SET mutetime = " UI64FMTD " WHERE id = '%u'",uint64(mutetime), account_id );
|
||||
LoginDatabase.PExecute("UPDATE account SET mutetime = " UI64FMTD " WHERE id = '%u'",uint64(mutetime), account_id );
|
||||
|
||||
if(target)
|
||||
ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notspeaktime);
|
||||
|
|
@ -130,7 +130,7 @@ bool ChatHandler::HandleUnmuteCommand(const char* args)
|
|||
target->GetSession()->m_muteTime = 0;
|
||||
}
|
||||
|
||||
loginDatabase.PExecute("UPDATE account SET mutetime = '0' WHERE id = '%u'", account_id );
|
||||
LoginDatabase.PExecute("UPDATE account SET mutetime = '0' WHERE id = '%u'", account_id );
|
||||
|
||||
if(target)
|
||||
ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_ENABLED);
|
||||
|
|
@ -2161,7 +2161,7 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
|
|||
AccountTypes security = SEC_PLAYER;
|
||||
std::string last_login = GetMangosString(LANG_ERROR);
|
||||
|
||||
QueryResult* result = loginDatabase.PQuery("SELECT username,gmlevel,last_ip,last_login FROM account WHERE id = '%u'",accId);
|
||||
QueryResult* result = LoginDatabase.PQuery("SELECT username,gmlevel,last_ip,last_login FROM account WHERE id = '%u'",accId);
|
||||
if(result)
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
|
@ -4102,9 +4102,9 @@ bool ChatHandler::HandleLookupAccountEmailCommand(const char* args)
|
|||
char* limit_str = strtok (NULL, " ");
|
||||
uint32 limit = limit_str ? atoi (limit_str) : 100;
|
||||
|
||||
loginDatabase.escape_string (email);
|
||||
LoginDatabase.escape_string (email);
|
||||
// 0 1 2 3 4
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE email "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), email.c_str ());
|
||||
QueryResult *result = LoginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE email "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), email.c_str ());
|
||||
|
||||
return ShowAccountListHelper(result,&limit);
|
||||
}
|
||||
|
|
@ -4119,10 +4119,10 @@ bool ChatHandler::HandleLookupAccountIpCommand(const char* args)
|
|||
char* limit_str = strtok (NULL, " ");
|
||||
uint32 limit = limit_str ? atoi (limit_str) : 100;
|
||||
|
||||
loginDatabase.escape_string (ip);
|
||||
LoginDatabase.escape_string (ip);
|
||||
|
||||
// 0 1 2 3 4
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE last_ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), ip.c_str ());
|
||||
QueryResult *result = LoginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE last_ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), ip.c_str ());
|
||||
|
||||
return ShowAccountListHelper(result,&limit);
|
||||
}
|
||||
|
|
@ -4139,9 +4139,9 @@ bool ChatHandler::HandleLookupAccountNameCommand(const char* args)
|
|||
if (!AccountMgr::normalizeString (account))
|
||||
return false;
|
||||
|
||||
loginDatabase.escape_string (account);
|
||||
LoginDatabase.escape_string (account);
|
||||
// 0 1 2 3 4
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), account.c_str ());
|
||||
QueryResult *result = LoginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), account.c_str ());
|
||||
|
||||
return ShowAccountListHelper(result,&limit);
|
||||
}
|
||||
|
|
@ -4208,9 +4208,9 @@ bool ChatHandler::HandleLookupPlayerIpCommand(const char* args)
|
|||
char* limit_str = strtok (NULL, " ");
|
||||
uint32 limit = limit_str ? atoi (limit_str) : 100;
|
||||
|
||||
loginDatabase.escape_string (ip);
|
||||
LoginDatabase.escape_string (ip);
|
||||
|
||||
QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE last_ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), ip.c_str ());
|
||||
QueryResult* result = LoginDatabase.PQuery ("SELECT id,username FROM account WHERE last_ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), ip.c_str ());
|
||||
|
||||
return LookupPlayerSearchCommand (result,&limit);
|
||||
}
|
||||
|
|
@ -4227,9 +4227,9 @@ bool ChatHandler::HandleLookupPlayerAccountCommand(const char* args)
|
|||
if (!AccountMgr::normalizeString (account))
|
||||
return false;
|
||||
|
||||
loginDatabase.escape_string (account);
|
||||
LoginDatabase.escape_string (account);
|
||||
|
||||
QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), account.c_str ());
|
||||
QueryResult* result = LoginDatabase.PQuery ("SELECT id,username FROM account WHERE username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), account.c_str ());
|
||||
|
||||
return LookupPlayerSearchCommand (result,&limit);
|
||||
}
|
||||
|
|
@ -4244,9 +4244,9 @@ bool ChatHandler::HandleLookupPlayerEmailCommand(const char* args)
|
|||
char* limit_str = strtok (NULL, " ");
|
||||
uint32 limit = limit_str ? atoi (limit_str) : 100;
|
||||
|
||||
loginDatabase.escape_string (email);
|
||||
LoginDatabase.escape_string (email);
|
||||
|
||||
QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE email "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), email.c_str ());
|
||||
QueryResult* result = LoginDatabase.PQuery ("SELECT id,username FROM account WHERE email "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), email.c_str ());
|
||||
|
||||
return LookupPlayerSearchCommand (result,&limit);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -945,7 +945,7 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args)
|
|||
}
|
||||
|
||||
PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm);
|
||||
loginDatabase.PExecute("UPDATE account SET gmlevel = '%i' WHERE id = '%u'", gm, targetAccountId);
|
||||
LoginDatabase.PExecute("UPDATE account SET gmlevel = '%i' WHERE id = '%u'", gm, targetAccountId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -5135,7 +5135,7 @@ bool ChatHandler::HandleBanInfoCharacterCommand(const char* args)
|
|||
|
||||
bool ChatHandler::HandleBanInfoHelper(uint32 accountid, char const* accountname)
|
||||
{
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT FROM_UNIXTIME(bandate), unbandate-bandate, active, unbandate,banreason,bannedby FROM account_banned WHERE id = '%u' ORDER BY bandate ASC",accountid);
|
||||
QueryResult *result = LoginDatabase.PQuery("SELECT FROM_UNIXTIME(bandate), unbandate-bandate, active, unbandate,banreason,bannedby FROM account_banned WHERE id = '%u' ORDER BY bandate ASC",accountid);
|
||||
if(!result)
|
||||
{
|
||||
PSendSysMessage(LANG_BANINFO_NOACCOUNTBAN, accountname);
|
||||
|
|
@ -5175,8 +5175,8 @@ bool ChatHandler::HandleBanInfoIPCommand(const char* args)
|
|||
|
||||
std::string IP = cIP;
|
||||
|
||||
loginDatabase.escape_string(IP);
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason,bannedby,unbandate-bandate FROM ip_banned WHERE ip = '%s'",IP.c_str());
|
||||
LoginDatabase.escape_string(IP);
|
||||
QueryResult *result = LoginDatabase.PQuery("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason,bannedby,unbandate-bandate FROM ip_banned WHERE ip = '%s'",IP.c_str());
|
||||
if(!result)
|
||||
{
|
||||
PSendSysMessage(LANG_BANINFO_NOIP);
|
||||
|
|
@ -5194,14 +5194,14 @@ bool ChatHandler::HandleBanInfoIPCommand(const char* args)
|
|||
|
||||
bool ChatHandler::HandleBanListCharacterCommand(const char* args)
|
||||
{
|
||||
loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||
LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||
|
||||
char* cFilter = strtok ((char*)args, " ");
|
||||
if(!cFilter)
|
||||
return false;
|
||||
|
||||
std::string filter = cFilter;
|
||||
loginDatabase.escape_string(filter);
|
||||
LoginDatabase.escape_string(filter);
|
||||
QueryResult* result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"),filter.c_str());
|
||||
if (!result)
|
||||
{
|
||||
|
|
@ -5214,22 +5214,22 @@ bool ChatHandler::HandleBanListCharacterCommand(const char* args)
|
|||
|
||||
bool ChatHandler::HandleBanListAccountCommand(const char* args)
|
||||
{
|
||||
loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||
LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||
|
||||
char* cFilter = strtok((char*)args, " ");
|
||||
std::string filter = cFilter ? cFilter : "";
|
||||
loginDatabase.escape_string(filter);
|
||||
LoginDatabase.escape_string(filter);
|
||||
|
||||
QueryResult* result;
|
||||
|
||||
if(filter.empty())
|
||||
{
|
||||
result = loginDatabase.Query("SELECT account.id, username FROM account, account_banned"
|
||||
result = LoginDatabase.Query("SELECT account.id, username FROM account, account_banned"
|
||||
" WHERE account.id = account_banned.id AND active = 1 GROUP BY account.id");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = loginDatabase.PQuery("SELECT account.id, username FROM account, account_banned"
|
||||
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());
|
||||
}
|
||||
|
|
@ -5255,7 +5255,7 @@ bool ChatHandler::HandleBanListHelper(QueryResult* result)
|
|||
Field* fields = result->Fetch();
|
||||
uint32 accountid = fields[0].GetUInt32();
|
||||
|
||||
QueryResult* banresult = loginDatabase.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.id=account.id",accountid);
|
||||
QueryResult* banresult = LoginDatabase.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.id=account.id",accountid);
|
||||
if(banresult)
|
||||
{
|
||||
Field* fields2 = banresult->Fetch();
|
||||
|
|
@ -5286,7 +5286,7 @@ bool ChatHandler::HandleBanListHelper(QueryResult* result)
|
|||
sAccountMgr.GetName (account_id,account_name);
|
||||
|
||||
// No SQL injection. id is uint32.
|
||||
QueryResult *banInfo = loginDatabase.PQuery("SELECT bandate,unbandate,bannedby,banreason FROM account_banned WHERE id = %u ORDER BY unbandate", account_id);
|
||||
QueryResult *banInfo = LoginDatabase.PQuery("SELECT bandate,unbandate,bannedby,banreason FROM account_banned WHERE id = %u ORDER BY unbandate", account_id);
|
||||
if (banInfo)
|
||||
{
|
||||
Field *fields2 = banInfo->Fetch();
|
||||
|
|
@ -5323,23 +5323,23 @@ bool ChatHandler::HandleBanListHelper(QueryResult* result)
|
|||
|
||||
bool ChatHandler::HandleBanListIPCommand(const char* args)
|
||||
{
|
||||
loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||
LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||
|
||||
char* cFilter = strtok((char*)args, " ");
|
||||
std::string filter = cFilter ? cFilter : "";
|
||||
loginDatabase.escape_string(filter);
|
||||
LoginDatabase.escape_string(filter);
|
||||
|
||||
QueryResult* result;
|
||||
|
||||
if(filter.empty())
|
||||
{
|
||||
result = loginDatabase.Query ("SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned"
|
||||
result = LoginDatabase.Query ("SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned"
|
||||
" WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP())"
|
||||
" ORDER BY unbandate" );
|
||||
}
|
||||
else
|
||||
{
|
||||
result = loginDatabase.PQuery( "SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned"
|
||||
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() );
|
||||
}
|
||||
|
|
@ -6109,7 +6109,7 @@ bool ChatHandler::HandleInstanceSaveDataCommand(const char * /*args*/)
|
|||
bool ChatHandler::HandleGMListFullCommand(const char* /*args*/)
|
||||
{
|
||||
///- Get the accounts with GM Level >0
|
||||
QueryResult *result = loginDatabase.Query( "SELECT username,gmlevel FROM account WHERE gmlevel > 0" );
|
||||
QueryResult *result = LoginDatabase.Query( "SELECT username,gmlevel FROM account WHERE gmlevel > 0" );
|
||||
if(result)
|
||||
{
|
||||
SendSysMessage(LANG_GMLIST);
|
||||
|
|
@ -6243,7 +6243,7 @@ bool ChatHandler::HandleAccountSetAddonCommand(const char* args)
|
|||
return false;
|
||||
|
||||
// No SQL injection
|
||||
loginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'",lev,account_id);
|
||||
LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'",lev,account_id);
|
||||
PSendSysMessage(LANG_ACCOUNT_SETADDON,account_name.c_str(),account_id,lev);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1190,7 +1190,7 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data)
|
|||
|
||||
uint32 accid = plr->GetSession()->GetAccountId();
|
||||
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT username,email,last_ip FROM account WHERE id=%u", accid);
|
||||
QueryResult *result = LoginDatabase.PQuery("SELECT username,email,last_ip FROM account WHERE id=%u", accid);
|
||||
if(!result)
|
||||
{
|
||||
SendNotification(LANG_ACCOUNT_FOR_PLAYER_NOT_FOUND, charname.c_str());
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ World::AddSession_ (WorldSession* s)
|
|||
float popu = float(GetActiveSessionCount()); // updated number of users on the server
|
||||
popu /= pLimit;
|
||||
popu *= 2;
|
||||
loginDatabase.PExecute ("UPDATE realmlist SET population = '%f' WHERE id = '%d'", popu, realmID);
|
||||
LoginDatabase.PExecute ("UPDATE realmlist SET population = '%f' WHERE id = '%d'", popu, realmID);
|
||||
DETAIL_LOG("Server Population (%f).", popu);
|
||||
}
|
||||
}
|
||||
|
|
@ -902,7 +902,7 @@ void World::SetInitialWorldSettings()
|
|||
// not send custom type REALM_FFA_PVP to realm list
|
||||
uint32 server_type = IsFFAPvPRealm() ? REALM_TYPE_PVP : getConfig(CONFIG_UINT32_GAME_TYPE);
|
||||
uint32 realm_zone = getConfig(CONFIG_UINT32_REALM_ZONE);
|
||||
loginDatabase.PExecute("UPDATE realmlist SET icon = %u, timezone = %u WHERE id = '%d'", server_type, realm_zone, realmID);
|
||||
LoginDatabase.PExecute("UPDATE realmlist SET icon = %u, timezone = %u WHERE id = '%d'", server_type, realm_zone, realmID);
|
||||
|
||||
///- Remove the bones (they should not exist in DB though) and old corpses after a restart
|
||||
CharacterDatabase.PExecute("DELETE FROM corpse WHERE corpse_type = '0' OR time < (UNIX_TIMESTAMP()-'%u')", 3*DAY);
|
||||
|
|
@ -1236,7 +1236,7 @@ void World::SetInitialWorldSettings()
|
|||
sprintf( isoDate, "%04d-%02d-%02d %02d:%02d:%02d",
|
||||
local.tm_year+1900, local.tm_mon+1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec);
|
||||
|
||||
loginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime) VALUES('%u', " UI64FMTD ", '%s', 0)",
|
||||
LoginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime) VALUES('%u', " UI64FMTD ", '%s', 0)",
|
||||
realmID, uint64(m_startTime), isoDate);
|
||||
|
||||
m_timers[WUPDATE_OBJECTS].SetInterval(0);
|
||||
|
|
@ -1274,7 +1274,7 @@ void World::SetInitialWorldSettings()
|
|||
sMapMgr.LoadTransports();
|
||||
|
||||
sLog.outString("Deleting expired bans..." );
|
||||
loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||
LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||
|
||||
sLog.outString("Calculate next daily quest reset time..." );
|
||||
InitDailyQuestResetTime();
|
||||
|
|
@ -1418,7 +1418,7 @@ void World::Update(uint32 diff)
|
|||
uint32 maxClientsNum = GetMaxActiveSessionCount();
|
||||
|
||||
m_timers[WUPDATE_UPTIME].Reset();
|
||||
loginDatabase.PExecute("UPDATE uptime SET uptime = %u, maxplayers = %u WHERE realmid = %u AND starttime = " UI64FMTD, tmpDiff, maxClientsNum, realmID, uint64(m_startTime));
|
||||
LoginDatabase.PExecute("UPDATE uptime SET uptime = %u, maxplayers = %u WHERE realmid = %u AND starttime = " UI64FMTD, tmpDiff, maxClientsNum, realmID, uint64(m_startTime));
|
||||
}
|
||||
|
||||
/// <li> Handle all other objects
|
||||
|
|
@ -1628,10 +1628,10 @@ void World::KickAllLess(AccountTypes sec)
|
|||
/// Ban an account or ban an IP address, duration will be parsed using TimeStringToSecs if it is positive, otherwise permban
|
||||
BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author)
|
||||
{
|
||||
loginDatabase.escape_string(nameOrIP);
|
||||
loginDatabase.escape_string(reason);
|
||||
LoginDatabase.escape_string(nameOrIP);
|
||||
LoginDatabase.escape_string(reason);
|
||||
std::string safe_author=author;
|
||||
loginDatabase.escape_string(safe_author);
|
||||
LoginDatabase.escape_string(safe_author);
|
||||
|
||||
uint32 duration_secs = TimeStringToSecs(duration);
|
||||
QueryResult *resultAccounts = NULL; //used for kicking
|
||||
|
|
@ -1641,12 +1641,12 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, std::string dura
|
|||
{
|
||||
case BAN_IP:
|
||||
//No SQL injection as strings are escaped
|
||||
resultAccounts = loginDatabase.PQuery("SELECT id FROM account WHERE last_ip = '%s'",nameOrIP.c_str());
|
||||
loginDatabase.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+%u,'%s','%s')",nameOrIP.c_str(),duration_secs,safe_author.c_str(),reason.c_str());
|
||||
resultAccounts = LoginDatabase.PQuery("SELECT id FROM account WHERE last_ip = '%s'",nameOrIP.c_str());
|
||||
LoginDatabase.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+%u,'%s','%s')",nameOrIP.c_str(),duration_secs,safe_author.c_str(),reason.c_str());
|
||||
break;
|
||||
case BAN_ACCOUNT:
|
||||
//No SQL injection as string is escaped
|
||||
resultAccounts = loginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'",nameOrIP.c_str());
|
||||
resultAccounts = LoginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'",nameOrIP.c_str());
|
||||
break;
|
||||
case BAN_CHARACTER:
|
||||
//No SQL injection as string is escaped
|
||||
|
|
@ -1673,7 +1673,7 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, std::string dura
|
|||
if(mode!=BAN_IP)
|
||||
{
|
||||
//No SQL injection as strings are escaped
|
||||
loginDatabase.PExecute("INSERT INTO account_banned VALUES ('%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+%u, '%s', '%s', '1')",
|
||||
LoginDatabase.PExecute("INSERT INTO account_banned VALUES ('%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+%u, '%s', '%s', '1')",
|
||||
account,duration_secs,safe_author.c_str(),reason.c_str());
|
||||
}
|
||||
|
||||
|
|
@ -1692,8 +1692,8 @@ bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP)
|
|||
{
|
||||
if (mode == BAN_IP)
|
||||
{
|
||||
loginDatabase.escape_string(nameOrIP);
|
||||
loginDatabase.PExecute("DELETE FROM ip_banned WHERE ip = '%s'",nameOrIP.c_str());
|
||||
LoginDatabase.escape_string(nameOrIP);
|
||||
LoginDatabase.PExecute("DELETE FROM ip_banned WHERE ip = '%s'",nameOrIP.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1707,7 +1707,7 @@ bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP)
|
|||
return false;
|
||||
|
||||
//NO SQL injection as account is uint32
|
||||
loginDatabase.PExecute("UPDATE account_banned SET active = '0' WHERE id = '%u'",account);
|
||||
LoginDatabase.PExecute("UPDATE account_banned SET active = '0' WHERE id = '%u'",account);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1895,8 +1895,8 @@ void World::_UpdateRealmCharCount(QueryResult *resultCharCount, uint32 accountId
|
|||
Field *fields = resultCharCount->Fetch();
|
||||
uint32 charCount = fields[0].GetUInt32();
|
||||
delete resultCharCount;
|
||||
loginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid= '%d' AND realmid = '%d'", accountId, realmID);
|
||||
loginDatabase.PExecute("INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (%u, %u, %u)", charCount, accountId, realmID);
|
||||
LoginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid= '%d' AND realmid = '%d'", accountId, realmID);
|
||||
LoginDatabase.PExecute("INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (%u, %u, %u)", charCount, accountId, realmID);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2000,7 +2000,7 @@ void World::SetPlayerLimit( int32 limit, bool needUpdate )
|
|||
m_playerLimit = limit;
|
||||
|
||||
if (db_update_need)
|
||||
loginDatabase.PExecute("UPDATE realmlist SET allowedSecurityLevel = '%u' WHERE id = '%d'",uint8(GetPlayerSecurityLimit()),realmID);
|
||||
LoginDatabase.PExecute("UPDATE realmlist SET allowedSecurityLevel = '%u' WHERE id = '%d'",uint8(GetPlayerSecurityLimit()),realmID);
|
||||
}
|
||||
|
||||
void World::UpdateMaxSessionCounters()
|
||||
|
|
|
|||
|
|
@ -376,7 +376,7 @@ void WorldSession::LogoutPlayer(bool Save)
|
|||
///- Reset the online field in the account table
|
||||
// no point resetting online in character table here as Player::SaveToDB() will set it to 1 since player has not been removed from world at this stage
|
||||
// No SQL injection as AccountID is uint32
|
||||
loginDatabase.PExecute("UPDATE account SET active_realm_id = 0 WHERE id = '%u'", GetAccountId());
|
||||
LoginDatabase.PExecute("UPDATE account SET active_realm_id = 0 WHERE id = '%u'", GetAccountId());
|
||||
|
||||
///- If the player is in a guild, update the guild roster and broadcast a logout message to other guild members
|
||||
Guild *guild = sObjectMgr.GetGuildById(_player->GetGuildId());
|
||||
|
|
|
|||
|
|
@ -786,11 +786,11 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
|
|||
|
||||
// Get the account information from the realmd database
|
||||
std::string safe_account = account; // Duplicate, else will screw the SHA hash verification below
|
||||
loginDatabase.escape_string (safe_account);
|
||||
LoginDatabase.escape_string (safe_account);
|
||||
// No SQL injection, username escaped.
|
||||
|
||||
QueryResult *result =
|
||||
loginDatabase.PQuery ("SELECT "
|
||||
LoginDatabase.PQuery ("SELECT "
|
||||
"id, " //0
|
||||
"gmlevel, " //1
|
||||
"sessionkey, " //2
|
||||
|
|
@ -870,7 +870,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
|
|||
|
||||
// Re-check account ban (same check as in realmd)
|
||||
QueryResult *banresult =
|
||||
loginDatabase.PQuery ("SELECT 1 FROM account_banned WHERE id = %u AND active = 1 AND (unbandate > UNIX_TIMESTAMP() OR unbandate = bandate)"
|
||||
LoginDatabase.PQuery ("SELECT 1 FROM account_banned WHERE id = %u AND active = 1 AND (unbandate > UNIX_TIMESTAMP() OR unbandate = bandate)"
|
||||
"UNION "
|
||||
"SELECT 1 FROM ip_banned WHERE (unbandate = bandate OR unbandate > UNIX_TIMESTAMP()) AND ip = '%s'",
|
||||
id, GetRemoteAddress().c_str());
|
||||
|
|
@ -933,9 +933,9 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
|
|||
|
||||
// Update the last_ip in the database
|
||||
// No SQL injection, username escaped.
|
||||
loginDatabase.escape_string (address);
|
||||
LoginDatabase.escape_string (address);
|
||||
|
||||
loginDatabase.PExecute ("UPDATE account "
|
||||
LoginDatabase.PExecute ("UPDATE account "
|
||||
"SET last_ip = '%s' "
|
||||
"WHERE username = '%s'",
|
||||
address.c_str (),
|
||||
|
|
|
|||
|
|
@ -483,7 +483,7 @@ bool ChatHandler::HandleAccountOnlineListCommand(const char* args)
|
|||
|
||||
///- Get the list of accounts ID logged to the realm
|
||||
// 0 1 2 3 4
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE active_realm_id = %u", realmID);
|
||||
QueryResult *result = LoginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE active_realm_id = %u", realmID);
|
||||
|
||||
return ShowAccountListHelper(result,&limit);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ int m_ServiceStatus = -1;
|
|||
|
||||
DatabaseType WorldDatabase; ///< Accessor to the world database
|
||||
DatabaseType CharacterDatabase; ///< Accessor to the character database
|
||||
DatabaseType loginDatabase; ///< Accessor to the realm/login database
|
||||
DatabaseType LoginDatabase; ///< Accessor to the realm/login database
|
||||
|
||||
uint32 realmID; ///< Id of the realm
|
||||
|
||||
|
|
|
|||
|
|
@ -221,8 +221,8 @@ int Master::Run()
|
|||
// set realmbuilds depend on mangosd expected builds, and set server online
|
||||
{
|
||||
std::string builds = AcceptableClientBuildsListStr();
|
||||
loginDatabase.escape_string(builds);
|
||||
loginDatabase.PExecute("UPDATE realmlist SET realmflags = realmflags & ~(%u), population = 0, realmbuilds = '%s' WHERE id = '%d'", REALM_FLAG_OFFLINE, builds.c_str(), realmID);
|
||||
LoginDatabase.escape_string(builds);
|
||||
LoginDatabase.PExecute("UPDATE realmlist SET realmflags = realmflags & ~(%u), population = 0, realmbuilds = '%s' WHERE id = '%d'", REALM_FLAG_OFFLINE, builds.c_str(), realmID);
|
||||
}
|
||||
|
||||
ACE_Based::Thread* cliThread = NULL;
|
||||
|
|
@ -342,7 +342,7 @@ int Master::Run()
|
|||
}
|
||||
|
||||
///- Set server offline in realmlist
|
||||
loginDatabase.PExecute("UPDATE realmlist SET realmflags = realmflags | %u WHERE id = '%d'", REALM_FLAG_OFFLINE, realmID);
|
||||
LoginDatabase.PExecute("UPDATE realmlist SET realmflags = realmflags | %u WHERE id = '%d'", REALM_FLAG_OFFLINE, realmID);
|
||||
|
||||
///- Remove signal handling before leaving
|
||||
_UnhookSignals();
|
||||
|
|
@ -364,7 +364,7 @@ int Master::Run()
|
|||
///- Wait for DB delay threads to end
|
||||
CharacterDatabase.HaltDelayThread();
|
||||
WorldDatabase.HaltDelayThread();
|
||||
loginDatabase.HaltDelayThread();
|
||||
LoginDatabase.HaltDelayThread();
|
||||
|
||||
sLog.outString( "Halting process..." );
|
||||
|
||||
|
|
@ -495,7 +495,7 @@ bool Master::_StartDB()
|
|||
|
||||
///- Initialise the login database
|
||||
sLog.outString("Login Database: %s", dbstring.c_str() );
|
||||
if(!loginDatabase.Initialize(dbstring.c_str()))
|
||||
if(!LoginDatabase.Initialize(dbstring.c_str()))
|
||||
{
|
||||
sLog.outError("Cannot connect to login database %s",dbstring.c_str());
|
||||
|
||||
|
|
@ -505,12 +505,12 @@ bool Master::_StartDB()
|
|||
return false;
|
||||
}
|
||||
|
||||
if(!loginDatabase.CheckRequiredField("realmd_db_version",REVISION_DB_REALMD))
|
||||
if(!LoginDatabase.CheckRequiredField("realmd_db_version",REVISION_DB_REALMD))
|
||||
{
|
||||
///- Wait for already started DB delay threads to end
|
||||
WorldDatabase.HaltDelayThread();
|
||||
CharacterDatabase.HaltDelayThread();
|
||||
loginDatabase.HaltDelayThread();
|
||||
LoginDatabase.HaltDelayThread();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -523,7 +523,7 @@ bool Master::_StartDB()
|
|||
///- Wait for already started DB delay threads to end
|
||||
WorldDatabase.HaltDelayThread();
|
||||
CharacterDatabase.HaltDelayThread();
|
||||
loginDatabase.HaltDelayThread();
|
||||
LoginDatabase.HaltDelayThread();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -544,7 +544,7 @@ void Master::clearOnlineAccounts()
|
|||
{
|
||||
// Cleanup online status for characters hosted at current realm
|
||||
/// \todo Only accounts with characters logged on *this* realm should have online status reset. Move the online column from 'account' to 'realmcharacters'?
|
||||
loginDatabase.PExecute("UPDATE account SET active_realm_id = 0 WHERE active_realm_id = '%d'", realmID);
|
||||
LoginDatabase.PExecute("UPDATE account SET active_realm_id = 0 WHERE active_realm_id = '%d'", realmID);
|
||||
|
||||
CharacterDatabase.Execute("UPDATE characters SET online = 0 WHERE online<>0");
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
#include <ace/OS_NS_fcntl.h>
|
||||
#include <ace/OS_NS_sys_stat.h>
|
||||
|
||||
extern DatabaseType loginDatabase;
|
||||
extern DatabaseType LoginDatabase;
|
||||
|
||||
enum eStatus
|
||||
{
|
||||
|
|
@ -265,7 +265,7 @@ void AuthSocket::_SetVSFields(const std::string& rI)
|
|||
const char *v_hex, *s_hex;
|
||||
v_hex = v.AsHexStr();
|
||||
s_hex = s.AsHexStr();
|
||||
loginDatabase.PExecute("UPDATE account SET v = '%s', s = '%s' WHERE username = '%s'", v_hex, s_hex, _safelogin.c_str() );
|
||||
LoginDatabase.PExecute("UPDATE account SET v = '%s', s = '%s' WHERE username = '%s'", v_hex, s_hex, _safelogin.c_str() );
|
||||
OPENSSL_free((void*)v_hex);
|
||||
OPENSSL_free((void*)s_hex);
|
||||
}
|
||||
|
|
@ -358,7 +358,7 @@ bool AuthSocket::_HandleLogonChallenge()
|
|||
//Escape the user login to avoid further SQL injection
|
||||
//Memory will be freed on AuthSocket object destruction
|
||||
_safelogin = _login;
|
||||
loginDatabase.escape_string(_safelogin);
|
||||
LoginDatabase.escape_string(_safelogin);
|
||||
|
||||
pkt << (uint8) AUTH_LOGON_CHALLENGE;
|
||||
pkt << (uint8) 0x00;
|
||||
|
|
@ -366,8 +366,8 @@ bool AuthSocket::_HandleLogonChallenge()
|
|||
///- Verify that this IP is not in the ip_banned table
|
||||
// No SQL injection possible (paste the IP address as passed by the socket)
|
||||
std::string address = get_remote_address();
|
||||
loginDatabase.escape_string(address);
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT unbandate FROM ip_banned WHERE "
|
||||
LoginDatabase.escape_string(address);
|
||||
QueryResult *result = LoginDatabase.PQuery("SELECT unbandate FROM ip_banned WHERE "
|
||||
// permanent still banned
|
||||
"(unbandate = bandate OR unbandate > UNIX_TIMESTAMP()) AND ip = '%s'", address.c_str());
|
||||
if (result)
|
||||
|
|
@ -381,7 +381,7 @@ bool AuthSocket::_HandleLogonChallenge()
|
|||
///- Get the account details from the account table
|
||||
// No SQL injection (escaped user name)
|
||||
|
||||
result = loginDatabase.PQuery("SELECT sha_pass_hash,id,locked,last_ip,gmlevel,v,s FROM account WHERE username = '%s'",_safelogin.c_str ());
|
||||
result = LoginDatabase.PQuery("SELECT sha_pass_hash,id,locked,last_ip,gmlevel,v,s FROM account WHERE username = '%s'",_safelogin.c_str ());
|
||||
if( result )
|
||||
{
|
||||
///- If the IP is 'locked', check that the player comes indeed from the correct IP address
|
||||
|
|
@ -409,7 +409,7 @@ bool AuthSocket::_HandleLogonChallenge()
|
|||
if (!locked)
|
||||
{
|
||||
///- If the account is banned, reject the logon attempt
|
||||
QueryResult *banresult = loginDatabase.PQuery("SELECT bandate,unbandate FROM account_banned WHERE "
|
||||
QueryResult *banresult = LoginDatabase.PQuery("SELECT bandate,unbandate FROM account_banned WHERE "
|
||||
"id = %u AND active = 1 AND (unbandate > UNIX_TIMESTAMP() OR unbandate = bandate)", (*result)[1].GetUInt32());
|
||||
if(banresult)
|
||||
{
|
||||
|
|
@ -664,7 +664,7 @@ bool AuthSocket::_HandleLogonProof()
|
|||
///- Update the sessionkey, last_ip, last login time and reset number of failed logins in the account table for this account
|
||||
// No SQL injection (escaped user name) and IP address as received by socket
|
||||
const char* K_hex = K.AsHexStr();
|
||||
loginDatabase.PExecute("UPDATE account SET sessionkey = '%s', last_ip = '%s', last_login = NOW(), locale = '%u', failed_logins = 0 WHERE username = '%s'", K_hex, get_remote_address().c_str(), GetLocaleByName(_localizationName), _safelogin.c_str() );
|
||||
LoginDatabase.PExecute("UPDATE account SET sessionkey = '%s', last_ip = '%s', last_login = NOW(), locale = '%u', failed_logins = 0 WHERE username = '%s'", K_hex, get_remote_address().c_str(), GetLocaleByName(_localizationName), _safelogin.c_str() );
|
||||
OPENSSL_free((void*)K_hex);
|
||||
|
||||
///- Finish SRP6 and send the final result to the client
|
||||
|
|
@ -687,9 +687,9 @@ bool AuthSocket::_HandleLogonProof()
|
|||
if(MaxWrongPassCount > 0)
|
||||
{
|
||||
//Increment number of failed logins by one and if it reaches the limit temporarily ban that account or IP
|
||||
loginDatabase.PExecute("UPDATE account SET failed_logins = failed_logins + 1 WHERE username = '%s'",_safelogin.c_str());
|
||||
LoginDatabase.PExecute("UPDATE account SET failed_logins = failed_logins + 1 WHERE username = '%s'",_safelogin.c_str());
|
||||
|
||||
if(QueryResult *loginfail = loginDatabase.PQuery("SELECT id, failed_logins FROM account WHERE username = '%s'", _safelogin.c_str()))
|
||||
if(QueryResult *loginfail = LoginDatabase.PQuery("SELECT id, failed_logins FROM account WHERE username = '%s'", _safelogin.c_str()))
|
||||
{
|
||||
Field* fields = loginfail->Fetch();
|
||||
uint32 failed_logins = fields[1].GetUInt32();
|
||||
|
|
@ -702,7 +702,7 @@ bool AuthSocket::_HandleLogonProof()
|
|||
if(WrongPassBanType)
|
||||
{
|
||||
uint32 acc_id = fields[0].GetUInt32();
|
||||
loginDatabase.PExecute("INSERT INTO account_banned VALUES ('%u',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+'%u','MaNGOS realmd','Failed login autoban',1)",
|
||||
LoginDatabase.PExecute("INSERT INTO account_banned VALUES ('%u',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+'%u','MaNGOS realmd','Failed login autoban',1)",
|
||||
acc_id, WrongPassBanTime);
|
||||
BASIC_LOG("[AuthChallenge] account %s got banned for '%u' seconds because it failed to authenticate '%u' times",
|
||||
_login.c_str(), WrongPassBanTime, failed_logins);
|
||||
|
|
@ -710,8 +710,8 @@ bool AuthSocket::_HandleLogonProof()
|
|||
else
|
||||
{
|
||||
std::string current_ip = get_remote_address();
|
||||
loginDatabase.escape_string(current_ip);
|
||||
loginDatabase.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+'%u','MaNGOS realmd','Failed login autoban')",
|
||||
LoginDatabase.escape_string(current_ip);
|
||||
LoginDatabase.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+'%u','MaNGOS realmd','Failed login autoban')",
|
||||
current_ip.c_str(), WrongPassBanTime);
|
||||
BASIC_LOG("[AuthChallenge] IP %s got banned for '%u' seconds because account %s failed to authenticate '%u' times",
|
||||
current_ip.c_str(), WrongPassBanTime, _login.c_str(), failed_logins);
|
||||
|
|
@ -757,12 +757,12 @@ bool AuthSocket::_HandleReconnectChallenge()
|
|||
_login = (const char*)ch->I;
|
||||
|
||||
_safelogin = _login;
|
||||
loginDatabase.escape_string(_safelogin);
|
||||
LoginDatabase.escape_string(_safelogin);
|
||||
|
||||
EndianConvert(ch->build);
|
||||
_build = ch->build;
|
||||
|
||||
QueryResult *result = loginDatabase.PQuery ("SELECT sessionkey FROM account WHERE username = '%s'", _safelogin.c_str ());
|
||||
QueryResult *result = LoginDatabase.PQuery ("SELECT sessionkey FROM account WHERE username = '%s'", _safelogin.c_str ());
|
||||
|
||||
// Stop if the account is not found
|
||||
if (!result)
|
||||
|
|
@ -842,7 +842,7 @@ bool AuthSocket::_HandleRealmList()
|
|||
///- Get the user id (else close the connection)
|
||||
// No SQL injection (escaped user name)
|
||||
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT id,sha_pass_hash FROM account WHERE username = '%s'",_safelogin.c_str());
|
||||
QueryResult *result = LoginDatabase.PQuery("SELECT id,sha_pass_hash FROM account WHERE username = '%s'",_safelogin.c_str());
|
||||
if(!result)
|
||||
{
|
||||
sLog.outError("[ERROR] user %s tried to login and we cannot find him in the database.",_login.c_str());
|
||||
|
|
@ -886,7 +886,7 @@ void AuthSocket::LoadRealmlist(ByteBuffer &pkt, uint32 acctid)
|
|||
uint8 AmountOfCharacters;
|
||||
|
||||
// No SQL injection. id of realm is controlled by the database.
|
||||
QueryResult *result = loginDatabase.PQuery( "SELECT numchars FROM realmcharacters WHERE realmid = '%d' AND acctid='%u'", i->second.m_ID, acctid);
|
||||
QueryResult *result = LoginDatabase.PQuery( "SELECT numchars FROM realmcharacters WHERE realmid = '%d' AND acctid='%u'", i->second.m_ID, acctid);
|
||||
if( result )
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
|
|
@ -947,7 +947,7 @@ void AuthSocket::LoadRealmlist(ByteBuffer &pkt, uint32 acctid)
|
|||
uint8 AmountOfCharacters;
|
||||
|
||||
// No SQL injection. id of realm is controlled by the database.
|
||||
QueryResult *result = loginDatabase.PQuery( "SELECT numchars FROM realmcharacters WHERE realmid = '%d' AND acctid='%u'", i->second.m_ID, acctid);
|
||||
QueryResult *result = LoginDatabase.PQuery( "SELECT numchars FROM realmcharacters WHERE realmid = '%d' AND acctid='%u'", i->second.m_ID, acctid);
|
||||
if( result )
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ void HookSignals();
|
|||
|
||||
bool stopEvent = false; ///< Setting it to true stops the server
|
||||
|
||||
DatabaseType loginDatabase; ///< Accessor to the realm server database
|
||||
DatabaseType LoginDatabase; ///< Accessor to the realm server database
|
||||
|
||||
/// Print out the usage string for this program on the console.
|
||||
void usage(const char *prog)
|
||||
|
|
@ -221,8 +221,8 @@ extern int main(int argc, char **argv)
|
|||
|
||||
// cleanup query
|
||||
// set expired bans to inactive
|
||||
loginDatabase.Execute("UPDATE account_banned SET active = 0 WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||
loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||
LoginDatabase.Execute("UPDATE account_banned SET active = 0 WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||
LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||
|
||||
///- Launch the listening network socket
|
||||
ACE_Acceptor<AuthSocket, ACE_SOCK_Acceptor> acceptor;
|
||||
|
|
@ -302,7 +302,7 @@ extern int main(int argc, char **argv)
|
|||
{
|
||||
loopCounter = 0;
|
||||
DETAIL_LOG("Ping MySQL to keep connection alive");
|
||||
delete loginDatabase.Query("SELECT 1 FROM realmlist LIMIT 1");
|
||||
delete LoginDatabase.Query("SELECT 1 FROM realmlist LIMIT 1");
|
||||
}
|
||||
#ifdef WIN32
|
||||
if (m_ServiceStatus == 0) stopEvent = true;
|
||||
|
|
@ -311,7 +311,7 @@ extern int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
///- Wait for the delay thread to exit
|
||||
loginDatabase.HaltDelayThread();
|
||||
LoginDatabase.HaltDelayThread();
|
||||
|
||||
///- Remove signal handling before leaving
|
||||
UnhookSignals();
|
||||
|
|
@ -351,16 +351,16 @@ bool StartDB()
|
|||
}
|
||||
|
||||
sLog.outString("Database: %s", dbstring.c_str() );
|
||||
if(!loginDatabase.Initialize(dbstring.c_str()))
|
||||
if(!LoginDatabase.Initialize(dbstring.c_str()))
|
||||
{
|
||||
sLog.outError("Cannot connect to database");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!loginDatabase.CheckRequiredField("realmd_db_version",REVISION_DB_REALMD))
|
||||
if(!LoginDatabase.CheckRequiredField("realmd_db_version",REVISION_DB_REALMD))
|
||||
{
|
||||
///- Wait for already started DB delay threads to end
|
||||
loginDatabase.HaltDelayThread();
|
||||
LoginDatabase.HaltDelayThread();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
INSTANTIATE_SINGLETON_1( RealmList );
|
||||
|
||||
extern DatabaseType loginDatabase;
|
||||
extern DatabaseType LoginDatabase;
|
||||
|
||||
// will only support WoW 1.12.1/1.12.2 , WoW:TBC 2.4.3 and official release for WoW:WotLK and later, client builds 10505, 8606, 6005, 5875
|
||||
// if you need more from old build then add it in cases in realmd sources code
|
||||
|
|
@ -140,7 +140,7 @@ void RealmList::UpdateRealms(bool init)
|
|||
DETAIL_LOG("Updating Realm List...");
|
||||
|
||||
//// 0 1 2 3 4 5 6 7 8 9
|
||||
QueryResult *result = loginDatabase.Query( "SELECT id, name, address, port, icon, realmflags, timezone, allowedSecurityLevel, population, realmbuilds FROM realmlist WHERE (realmflags & 1) = 0 ORDER BY name" );
|
||||
QueryResult *result = LoginDatabase.Query( "SELECT id, name, address, port, icon, realmflags, timezone, allowedSecurityLevel, population, realmbuilds FROM realmlist WHERE (realmflags & 1) = 0 ORDER BY name" );
|
||||
|
||||
///- Circle through results and add them to the realm map
|
||||
if(result)
|
||||
|
|
|
|||
|
|
@ -48,6 +48,6 @@ typedef DatabaseMysql DatabaseType;
|
|||
|
||||
extern DatabaseType WorldDatabase;
|
||||
extern DatabaseType CharacterDatabase;
|
||||
extern DatabaseType loginDatabase;
|
||||
extern DatabaseType LoginDatabase;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "10101"
|
||||
#define REVISION_NR "10102"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue