本文整理汇总了C++中SqlStatement::DirectExecute方法的典型用法代码示例。如果您正苦于以下问题:C++ SqlStatement::DirectExecute方法的具体用法?C++ SqlStatement::DirectExecute怎么用?C++ SqlStatement::DirectExecute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlStatement
的用法示例。
在下文中一共展示了SqlStatement::DirectExecute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applySanction
void Antispam::applySanction(MessageBlock& messageBlock, uint32 detectType, uint32 repeats)
{
auto chatType = std::to_string(messageBlock.type);
switch (detectType)
{
case DETECT_STANDARD:
logSpam(messageBlock, "DETECT_STANDARD, chatType " + chatType);
break;
case DETECT_SEPARATED:
logSpam(messageBlock, "DETECT_SEPARATED, chatType " + chatType);
break;
case DETECT_FLOOD:
std::string reason = "DETECT_FLOOD, " + std::to_string(repeats) + " repeats, chatType " + chatType;
logSpam(messageBlock, reason);
break;
}
mute(messageBlock.fromAccount);
ChannelMgr::AnnounceBothFactionsChannel("ChatSpam", messageBlock.fromGuid, messageBlock.msg.c_str());
static SqlStatementID insDetect;
SqlStatement stmt = LoginDatabase.CreateStatement(insDetect, "INSERT INTO `antispam_detected` VALUES (?, 1, ?, ?) "
"ON DUPLICATE KEY UPDATE `detectScore` = `detectScore` + 1, `detectTime` = ?, `unmuteTime` = ?");
time_t currentTime = time(nullptr);
time_t unmuteTime = currentTime + m_mutetime;
stmt.addUInt32(messageBlock.fromAccount);
stmt.addUInt64(currentTime);
stmt.addUInt64(unmuteTime);
stmt.addUInt64(currentTime);
stmt.addUInt64(unmuteTime);
stmt.DirectExecute();
QueryResult *result = LoginDatabase.PQuery("SELECT `detectScore` FROM `antispam_detected` WHERE `id` = %u", messageBlock.fromAccount);
if (result)
{
auto fields = result->Fetch();
if (fields[0].GetUInt8() >= m_detectThreshold)
{
logSpam(messageBlock, "BAN SANCTION");
if (m_banEnabled)
{
sWorld.BanAccount(messageBlock.fromAccount, 0, "Spam detect. See details in logs", "Antispam");
LoginDatabase.PExecute("DELETE FROM `antispam_detected` WHERE `id` = %u", messageBlock.fromAccount);
}
}
delete result;
}
}
示例2: _HandleLogonProof
//.........这里部分代码省略.........
const char* K_hex = K.AsHexStr();
QueryResultAutoPtr result = AccountsDatabase.PQuery("SELECT account_id FROM account WHERE username = '%s'", _safelogin.c_str());
if (!result)
{
if (_build > 6005) // > 1.12.2
{
char data[4] = { CMD_AUTH_LOGON_PROOF, WOW_FAIL_UNKNOWN_ACCOUNT, 3, 0};
send(data, sizeof(data));
}
else
{
// 1.x not react incorrectly at 4-byte message use 3 as real error
char data[2] = { CMD_AUTH_LOGON_PROOF, WOW_FAIL_UNKNOWN_ACCOUNT};
send(data, sizeof(data));
}
return true;
}
uint32 accId = result->Fetch()->GetUInt32();
// direct to be sure that values will be set before character choose, this will slow down logging in a bit ;p
AccountsDatabase.DirectPExecute("UPDATE account_session SET session_key = '%s' WHERE account_id = '%u'", K_hex, accId);
static SqlStatementID updateAccount;
SqlStatement stmt = AccountsDatabase.CreateStatement(updateAccount, "UPDATE account SET last_ip = ?, last_local_ip = ?, last_login = NOW(), locale_id = ?, failed_logins = 0, client_os_version_id = ? WHERE account_id = ?");
std::string tmpIp = get_remote_address();
stmt.addString(tmpIp.c_str());
stmt.addString(localIp_.c_str());
stmt.addUInt8(uint8(GetLocaleByName(_localizationName)));
stmt.addUInt8(OS);
stmt.addUInt32(accId);
stmt.DirectExecute();
OPENSSL_free((void*)K_hex);
///- Finish SRP6 and send the final result to the client
sha.Initialize();
sha.UpdateBigNumbers(&A, &M, &K, NULL);
sha.Finalize();
SendProof(sha);
///- Set _authed to true!
_authed = true;
}
else
{
if (_build > 6005) // > 1.12.2
{
char data[4] = { CMD_AUTH_LOGON_PROOF, WOW_FAIL_UNKNOWN_ACCOUNT, 3, 0};
send(data, sizeof(data));
}
else
{
// 1.x not react incorrectly at 4-byte message use 3 as real error
char data[2] = { CMD_AUTH_LOGON_PROOF, WOW_FAIL_UNKNOWN_ACCOUNT};
send(data, sizeof(data));
}
sLog.outBasic("[AuthChallenge] account %s tried to login with wrong password!",_login.c_str ());
uint32 MaxWrongPassCount = sConfig.GetIntDefault("WrongPass.MaxCount", 0);
if (MaxWrongPassCount > 0)
{
static SqlStatementID updateAccountFailedLogins;