*Cleaned up database queries - by XTZGZoReX
--HG-- branch : trunk
This commit is contained in:
@@ -194,7 +194,7 @@ bool ChatHandler::HandleAccountOnlineListCommand(const char* args)
|
||||
///- Get the username, last IP and GM level of each account
|
||||
// No SQL injection. account is uint32.
|
||||
// 0 1 2 3
|
||||
QueryResult *resultLogin = loginDatabase.PQuery("SELECT username, last_ip, gmlevel, expansion FROM account WHERE id = '%u'",account);
|
||||
QueryResult *resultLogin = LoginDatabase.PQuery("SELECT username, last_ip, gmlevel, expansion FROM account WHERE id = '%u'",account);
|
||||
|
||||
if(resultLogin)
|
||||
{
|
||||
|
||||
@@ -54,7 +54,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
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
loopCounter = 0;
|
||||
sLog.outDetail ("Ping MySQL to keep connection alive");
|
||||
delete WorldDatabase.Query ("SELECT 1 FROM command LIMIT 1");
|
||||
delete loginDatabase.Query ("SELECT 1 FROM realmlist LIMIT 1");
|
||||
delete LoginDatabase.Query ("SELECT 1 FROM realmlist LIMIT 1");
|
||||
delete CharacterDatabase.Query ("SELECT 1 FROM bugreport LIMIT 1");
|
||||
}
|
||||
}
|
||||
@@ -239,7 +239,7 @@ int Master::Run()
|
||||
t.setPriority ((ZThread::Priority )2);
|
||||
|
||||
// set server online
|
||||
loginDatabase.PExecute("UPDATE realmlist SET color = 0, population = 0 WHERE id = '%d'",realmID);
|
||||
LoginDatabase.PExecute("UPDATE realmlist SET color = 0, population = 0 WHERE id = '%d'",realmID);
|
||||
|
||||
#ifdef WIN32
|
||||
if (sConfig.GetBoolDefault("Console.Enable", true) && (m_ServiceStatus == -1)/* need disable console in service mode*/)
|
||||
@@ -330,7 +330,7 @@ int Master::Run()
|
||||
sWorldSocketMgr->Wait ();
|
||||
|
||||
// set server offline
|
||||
loginDatabase.PExecute("UPDATE realmlist SET color = 2 WHERE id = '%d'",realmID);
|
||||
LoginDatabase.PExecute("UPDATE realmlist SET color = 2 WHERE id = '%d'",realmID);
|
||||
|
||||
///- Remove signal handling before leaving
|
||||
_UnhookSignals();
|
||||
@@ -346,7 +346,7 @@ int Master::Run()
|
||||
///- Wait for delay threads to end
|
||||
CharacterDatabase.HaltDelayThread();
|
||||
WorldDatabase.HaltDelayThread();
|
||||
loginDatabase.HaltDelayThread();
|
||||
LoginDatabase.HaltDelayThread();
|
||||
|
||||
sLog.outString( "Halting process..." );
|
||||
|
||||
@@ -440,7 +440,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());
|
||||
return false;
|
||||
@@ -469,7 +469,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(
|
||||
LoginDatabase.PExecute(
|
||||
"UPDATE account SET online = 0 WHERE online > 0 "
|
||||
"AND id IN (SELECT acctid FROM realmcharacters WHERE realmid = '%d')",realmID);
|
||||
|
||||
|
||||
@@ -152,9 +152,9 @@ void RASocket::OnRead()
|
||||
AccountMgr::normilizeString(login);
|
||||
|
||||
///- Escape the Login to allow quotes in names
|
||||
loginDatabase.escape_string(login);
|
||||
LoginDatabase.escape_string(login);
|
||||
|
||||
QueryResult* result = loginDatabase.PQuery("SELECT gmlevel FROM account WHERE username = '%s'",login.c_str());
|
||||
QueryResult* result = LoginDatabase.PQuery("SELECT gmlevel FROM account WHERE username = '%s'",login.c_str());
|
||||
|
||||
///- If the user is not found, deny access
|
||||
if(!result)
|
||||
@@ -193,10 +193,10 @@ void RASocket::OnRead()
|
||||
|
||||
AccountMgr::normilizeString(login);
|
||||
AccountMgr::normilizeString(pw);
|
||||
loginDatabase.escape_string(login);
|
||||
loginDatabase.escape_string(pw);
|
||||
LoginDatabase.escape_string(login);
|
||||
LoginDatabase.escape_string(pw);
|
||||
|
||||
QueryResult *check = loginDatabase.PQuery(
|
||||
QueryResult *check = LoginDatabase.PQuery(
|
||||
"SELECT 1 FROM account WHERE username = '%s' AND sha_pass_hash=SHA1(CONCAT(username,':','%s'))",
|
||||
login.c_str(), pw.c_str());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user