aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Server')
-rwxr-xr-xsrc/server/game/Server/WorldSocket.cpp47
1 files changed, 24 insertions, 23 deletions
diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp
index 2c6098fb23f..40b4a0bad4f 100755
--- a/src/server/game/Server/WorldSocket.cpp
+++ b/src/server/game/Server/WorldSocket.cpp
@@ -812,13 +812,11 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
clientSeed);
// Get the account information from the realmd database
- std::string safe_account = account; // Duplicate, else will screw the SHA hash verification below
- LoginDatabase.EscapeString (safe_account);
- // No SQL injection, username escaped.
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_INFO_BY_NAME);
- // 0 1 2 3 4 5 6 7 8 9 10
- QueryResult result = LoginDatabase.PQuery ("SELECT id, sessionkey, last_ip, locked, v, s, expansion, mutetime, locale, recruiter, os FROM account "
- "WHERE username = '%s'", safe_account.c_str());
+ stmt->setString(0, account);
+
+ PreparedQueryResult result = LoginDatabase.Query(stmt);
// Stop if the account is not found
if (!result)
@@ -899,29 +897,28 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
std::string os = fields[10].GetString();
// Checks gmlevel per Realm
- result =
- LoginDatabase.PQuery ("SELECT "
- "RealmID, " //0
- "gmlevel " //1
- "FROM account_access "
- "WHERE id = '%d'"
- " AND (RealmID = '%d'"
- " OR RealmID = '-1')",
- id, realmID);
+ stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_GMLEVEL_BY_REALMID);
+
+ stmt->setUInt32(0, id);
+ stmt->setInt32(1, int32(realmID));
+
+ result = LoginDatabase.Query(stmt);
+
if (!result)
security = 0;
else
{
fields = result->Fetch();
- security = fields[1].GetInt32();
+ security = fields[0].GetInt32();
}
// Re-check account ban (same check as in realmd)
- QueryResult banresult =
- LoginDatabase.PQuery ("SELECT 1 FROM account_banned WHERE id = %u AND active = 1 "
- "UNION "
- "SELECT 1 FROM ip_banned WHERE ip = '%s'",
- id, GetRemoteAddress().c_str());
+ stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BANS);
+
+ stmt->setUInt32(0, id);
+ stmt->setString(1, GetRemoteAddress());
+
+ PreparedQueryResult banresult = LoginDatabase.Query(stmt);
if (banresult) // if account banned
{
@@ -976,7 +973,11 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
address.c_str());
// Check if this user is by any chance a recruiter
- result = LoginDatabase.PQuery ("SELECT 1 FROM account WHERE recruiter = %u", id);
+ stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_RECRUITER);
+
+ stmt->setUInt32(0, id);
+
+ result = LoginDatabase.Query(stmt);
bool isRecruiter = false;
if (result)
@@ -984,7 +985,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
// Update the last_ip in the database
- PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LAST_IP);
+ stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LAST_IP);
stmt->setString(0, address);
stmt->setString(1, account);