aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Commands
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2013-04-22 15:54:46 +0200
committerShauren <shauren.trinity@gmail.com>2013-04-22 15:54:46 +0200
commitbd69c9ad491d3420b7a0812d45b2bc30d68dca10 (patch)
treec7f501831b7002e2ff755a4461efe5fc664f4884 /src/server/scripts/Commands
parent00a3023314402a039963bf9023dfc0e04a2bac06 (diff)
parent7542049eba46205572b9c9498d6891df31d0ca5b (diff)
Merge branch 'pr/n9655_Bezo'
Diffstat (limited to 'src/server/scripts/Commands')
-rw-r--r--src/server/scripts/Commands/cs_account.cpp60
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp2
2 files changed, 59 insertions, 3 deletions
diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp
index 3953beab3da..cf2816c985e 100644
--- a/src/server/scripts/Commands/cs_account.cpp
+++ b/src/server/scripts/Commands/cs_account.cpp
@@ -42,13 +42,19 @@ public:
{ "password", SEC_CONSOLE, true, &HandleAccountSetPasswordCommand, "", NULL },
{ NULL, SEC_PLAYER, false, NULL, "", NULL }
};
+ static ChatCommand accountLockCommandTable[] =
+ {
+ { "country", SEC_PLAYER, true, &HandleAccountLockCountryCommand, "", NULL },
+ { "ip", SEC_PLAYER, true, &HandleAccountLockIpCommand, "", NULL },
+ { NULL, SEC_PLAYER, false, NULL, "", NULL },
+ };
static ChatCommand accountCommandTable[] =
{
{ "addon", SEC_MODERATOR, false, &HandleAccountAddonCommand, "", NULL },
{ "create", SEC_CONSOLE, true, &HandleAccountCreateCommand, "", NULL },
{ "delete", SEC_CONSOLE, true, &HandleAccountDeleteCommand, "", NULL },
{ "onlinelist", SEC_CONSOLE, true, &HandleAccountOnlineListCommand, "", NULL },
- { "lock", SEC_PLAYER, false, &HandleAccountLockCommand, "", NULL },
+ { "lock", SEC_PLAYER, false, NULL, "", accountLockCommandTable },
{ "set", SEC_ADMINISTRATOR, true, NULL, "", accountSetCommandTable },
{ "password", SEC_PLAYER, false, &HandleAccountPasswordCommand, "", NULL },
{ "", SEC_PLAYER, false, &HandleAccountCommand, "", NULL },
@@ -245,7 +251,57 @@ public:
return true;
}
- static bool HandleAccountLockCommand(ChatHandler* handler, char const* args)
+ static bool HandleAccountLockCountryCommand(ChatHandler* handler, char const* args)
+ {
+ if (!*args)
+ {
+ handler->SendSysMessage(LANG_USE_BOL);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+ std::string param = (char*)args;
+
+ if (!param.empty())
+ {
+ if (param == "on")
+ {
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_LOGON_COUNTRY);
+ uint32 ip = inet_addr(handler->GetSession()->GetRemoteAddress().c_str());
+ EndianConvertReverse(ip);
+ stmt->setUInt32(0, ip);
+ PreparedQueryResult result = LoginDatabase.Query(stmt);
+ if (result)
+ {
+ Field* fields = result->Fetch();
+ std::string country = fields[0].GetString();
+ stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_CONTRY);
+ stmt->setString(0, country);
+ stmt->setUInt32(1, handler->GetSession()->GetAccountId());
+ LoginDatabase.Execute(stmt);
+ handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED);
+ }
+ else
+ {
+ handler->PSendSysMessage("[IP2NATION] Table empty");
+ sLog->outDebug(LOG_FILTER_AUTHSERVER, "[IP2NATION] Table empty");
+ }
+ }
+ else if (param == "off")
+ {
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_CONTRY);
+ stmt->setString(0, "00");
+ stmt->setUInt32(1, handler->GetSession()->GetAccountId());
+ LoginDatabase.Execute(stmt);
+ handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED);
+ }
+ return true;
+ }
+ handler->SendSysMessage(LANG_USE_BOL);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ static bool HandleAccountLockIpCommand(ChatHandler* handler, char const* args)
{
if (!*args)
{
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index c6d80cea3a5..bb7d6ea9594 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -1587,7 +1587,7 @@ public:
EndianConvertReverse(ip);
#endif
- PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_IP2NATION_COUNTRY);
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP2NATION_COUNTRY);
stmt->setUInt32(0, ip);