Common: Replace ip2nation by ip2location. (#21957)

Replace ip2nation by ip2location.

Download: https://lite.ip2location.com/database/ip-country
This commit is contained in:
Gooyeth
2018-06-22 17:32:39 -06:00
committed by Aokromes
parent 0dcc318e37
commit 2fe4ab94c5
14 changed files with 219 additions and 89 deletions

View File

@@ -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")

View File

@@ -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(")");
}
}