aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Commands
diff options
context:
space:
mode:
authorGooyeth <566327+Gooyeth@users.noreply.github.com>2018-06-22 17:32:39 -0600
committerAokromes <Aokromes@users.noreply.github.com>2018-06-23 01:32:39 +0200
commit2fe4ab94c52ad2fa90189ecd9c053da49f06561e (patch)
treed505bd2176de8a659401c1b87694ca20c96bedb3 /src/server/scripts/Commands
parent0dcc318e377138dcbc116b5703d7dc1bffc0cc0f (diff)
Common: Replace ip2nation by ip2location. (#21957)
Replace ip2nation by ip2location. Download: https://lite.ip2location.com/database/ip-country
Diffstat (limited to 'src/server/scripts/Commands')
-rw-r--r--src/server/scripts/Commands/cs_account.cpp18
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp12
2 files changed, 9 insertions, 21 deletions
diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp
index bd0ae263d68..1aa32fff384 100644
--- a/src/server/scripts/Commands/cs_account.cpp
+++ b/src/server/scripts/Commands/cs_account.cpp
@@ -26,6 +26,7 @@ EndScriptData */
#include "Chat.h"
#include "DatabaseEnv.h"
#include "IpAddress.h"
+#include "IPLocation.h"
#include "Language.h"
#include "Log.h"
#include "Player.h"
@@ -290,25 +291,18 @@ public:
{
if (param == "on")
{
- PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_LOGON_COUNTRY);
- uint32 ip = Trinity::Net::address_to_uint(Trinity::Net::make_address_v4(handler->GetSession()->GetRemoteAddress()));
- EndianConvertReverse(ip);
- stmt->setUInt32(0, ip);
- PreparedQueryResult result = LoginDatabase.Query(stmt);
- if (result)
+ if (IpLocationRecord* location = sIPLocation->GetData(handler->GetSession()->GetRemoteAddress()))
{
- Field* fields = result->Fetch();
- std::string country = fields[0].GetString();
- stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_CONTRY);
- stmt->setString(0, country);
+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_CONTRY);
+ stmt->setString(0, location->country_code);
stmt->setUInt32(1, handler->GetSession()->GetAccountId());
LoginDatabase.Execute(stmt);
handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED);
}
else
{
- handler->PSendSysMessage("[IP2NATION] Table empty");
- TC_LOG_DEBUG("server.authserver", "[IP2NATION] Table empty");
+ handler->PSendSysMessage("IP2Location] No information");
+ TC_LOG_DEBUG("server.authserver", "IP2Location] No information");
}
}
else if (param == "off")
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index 36a7a00c2da..7a1c9e8738a 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -28,6 +28,7 @@
#include "GroupMgr.h"
#include "InstanceSaveMgr.h"
#include "IpAddress.h"
+#include "IPLocation.h"
#include "Item.h"
#include "Language.h"
#include "LFG.h"
@@ -1688,17 +1689,10 @@ public:
lastIp = fields[4].GetString();
lastLogin = fields[5].GetString();
- uint32 ip = Trinity::Net::address_to_uint(Trinity::Net::make_address_v4(lastIp));
- EndianConvertReverse(ip);
-
- // If ip2nation table is populated, it displays the country
- stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP2NATION_COUNTRY);
- stmt->setUInt32(0, ip);
- if (PreparedQueryResult result2 = LoginDatabase.Query(stmt))
+ if (IpLocationRecord* location = sIPLocation->GetData(lastIp))
{
- Field* fields2 = result2->Fetch();
lastIp.append(" (");
- lastIp.append(fields2[0].GetString());
+ lastIp.append(location->country_name);
lastIp.append(")");
}
}