diff --git a/engine/server/library/serverUtility/src/shared/AdminAccountManager.cpp b/engine/server/library/serverUtility/src/shared/AdminAccountManager.cpp index 6d30f4f5..9e1819d3 100755 --- a/engine/server/library/serverUtility/src/shared/AdminAccountManager.cpp +++ b/engine/server/library/serverUtility/src/shared/AdminAccountManager.cpp @@ -3,6 +3,8 @@ //----------------------------------------------------------------------- +#include "ConfigServerUtility.h" + #include "serverUtility/FirstServerUtility.h" #include "serverUtility/AdminAccountManager.h" @@ -10,6 +12,8 @@ #include "sharedUtility/DataTable.h" #include "sharedUtility/DataTableManager.h" +#include "../../../../../../external/3rd/library/webAPI/webAPI.h" + #include //----------------------------------------------------------------------- @@ -69,6 +73,14 @@ int AdminAccountManager::getAdminLevel(const std::string & account) int level = 0; DEBUG_FATAL(!ms_installed, ("AdminAccountManager not installed")); + if(ConfigServerUtility::isExternalAdminLevelsEnabled()){ + std::ostringstream postBuffer; + postBuffer << "user_name=" << account; + std::string response = webAPI::simplePost(ConfigServerUtility::getExternalAdminLevelsURL(), std::string(postBuffer.str()), ""); + level = std::stoi(response); + return level; + } + int columnNumber = ms_adminTable->findColumnNumber("AdminAccounts"); DEBUG_FATAL(columnNumber == -1, ("Error loading admin table...no account column")); int row = ms_adminTable->searchColumnString( columnNumber, account); @@ -113,8 +125,8 @@ bool AdminAccountManager::isInternalIp(const std::string & addr) size_t xpos = ipAddr.find ('x'); //if no X is found, do a straight compare - if ( (xpos == 0 || xpos == std::string::npos) - && ipAddr.compare(addr) == 0 + if ( (xpos == 0 || xpos == std::string::npos) + && ipAddr.compare(addr) == 0 ) { retval = true; @@ -125,7 +137,7 @@ bool AdminAccountManager::isInternalIp(const std::string & addr) else if (xpos - 1 > addr.size()) retval = false; - //compare substring + //compare substring else if (ipAddr.compare(0, xpos - 1, addr, 0, xpos - 1) == 0) { retval = true; diff --git a/engine/server/library/serverUtility/src/shared/ConfigServerUtility.cpp b/engine/server/library/serverUtility/src/shared/ConfigServerUtility.cpp index 83d3230c..a83a1d68 100755 --- a/engine/server/library/serverUtility/src/shared/ConfigServerUtility.cpp +++ b/engine/server/library/serverUtility/src/shared/ConfigServerUtility.cpp @@ -17,6 +17,8 @@ namespace ConfigServerUtilityNamespace int serverMaxChatLogLines; int playerMaxChatLogLines; bool chatLogManagerLoggingEnabled; + bool externalAdminLevelsEnabled; + const char * externalAdminLevelsURL; } using namespace ConfigServerUtilityNamespace; @@ -75,6 +77,20 @@ bool ConfigServerUtility::isChatLogManagerLoggingEnabled() //----------------------------------------------------------------------- +bool ConfigServerUtility::isExternalAdminLevelsEnabled() +{ + return externalAdminLevelsEnabled; +} + +//----------------------------------------------------------------------- + +const char * ConfigServerUtility::getExternalAdminLevelsURL() +{ + return externalAdminLevelsURL; +} + +//----------------------------------------------------------------------- + void ConfigServerUtility::install() { KEY_INT(spawnCookie, 0); @@ -82,6 +98,8 @@ void ConfigServerUtility::install() KEY_INT(serverMaxChatLogLines, 5000); KEY_INT(playerMaxChatLogLines, 200); KEY_BOOL(chatLogManagerLoggingEnabled, false); + KEY_BOOL(externalAdminLevelsEnabled, false); + KEY_STRING(externalAdminLevelsURL, "http://localhost/"); } //----------------------------------------------------------------------- @@ -91,4 +109,3 @@ void ConfigServerUtility::remove() } //----------------------------------------------------------------------- - diff --git a/engine/server/library/serverUtility/src/shared/ConfigServerUtility.h b/engine/server/library/serverUtility/src/shared/ConfigServerUtility.h index 33f0db04..d843c54e 100755 --- a/engine/server/library/serverUtility/src/shared/ConfigServerUtility.h +++ b/engine/server/library/serverUtility/src/shared/ConfigServerUtility.h @@ -17,6 +17,8 @@ public: static int getServerMaxChatLogLines(); static int getPlayerMaxChatLogLines(); static bool isChatLogManagerLoggingEnabled(); + static bool isExternalAdminLevelsEnabled(); + static const char * getExternalAdminLevelsURL(); static void install(); static void remove();