diff --git a/src/ninja/ninja_init.cpp b/src/ninja/ninja_init.cpp index 63b7664f..344e91f4 100644 --- a/src/ninja/ninja_init.cpp +++ b/src/ninja/ninja_init.cpp @@ -133,44 +133,9 @@ int NinjaInitialize(const char *pszGdalData, const char *pszWindNinjaData) std::cout << "Logging message to console." << std::endl; - -std::string firstLocalIP; -struct ifaddrs *ifAddrStruct = NULL; -struct ifaddrs *ifa = NULL; -void *tmpAddrPtr = NULL; -getifaddrs(&ifAddrStruct); - -for (ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next) { - if (!ifa->ifa_addr) { - continue; - } - - if (ifa->ifa_addr->sa_family == AF_INET) { // Check it is IPv4 - tmpAddrPtr = &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr; - char addressBuffer[INET_ADDRSTRLEN]; - inet_ntop(AF_INET, tmpAddrPtr, addressBuffer, INET_ADDRSTRLEN); - if (strcmp(addressBuffer, "127.0.0.1") != 0) { - firstLocalIP = addressBuffer; - break; - } - } else if (ifa->ifa_addr->sa_family == AF_INET6) { // Check it is IPv6 - tmpAddrPtr = &((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr; - char addressBuffer[INET6_ADDRSTRLEN]; - inet_ntop(AF_INET6, tmpAddrPtr, addressBuffer, INET6_ADDRSTRLEN); - if (strcmp(addressBuffer, "::1") != 0) { - firstLocalIP = addressBuffer; - break; - } - } -} - -if (ifAddrStruct != NULL) - freeifaddrs(ifAddrStruct); - -std::string address = firstLocalIP; time_t now = time(0); @@ -180,24 +145,39 @@ char* dt = asctime(gmtm); std::string cpp_string(dt); -std::string url = "http://ninjastorm.firelab.org/windninja/stats/?IP="; +std::string url = "https://ninjastorm.firelab.org/sqlitetest/?time="; + cpp_string.erase(std::remove_if(cpp_string.begin(), cpp_string.end(), ::isspace), + cpp_string.end()); + + +std::string full = url + cpp_string; -std::string full = url + address + "&time=" + cpp_string; const char *charStr = full.data(); -if (!firstLocalIP.empty()) { CPLHTTPResult *poResult; std::cout << charStr << std::endl; + CPLSetConfigOption("GDAL_HTTP_UNSAFESSL", "YES"); - poResult = CPLHTTPFetch(charStr, NULL); - CPLHTTPDestroyResult(poResult); -} + poResult = CPLHTTPFetch(charStr, NULL); + if (poResult) { + CPLHTTPDestroyResult(poResult); + } else { + std::cerr << "Fetch data." << std::endl; + } + + + CPLSetConfigOption( "GDAL_HTTP_UNSAFESSL", "YES"); + + + + + if(!CPLCheckForFile(CPLStrdup(CPLFormFilename(CPLStrdup(pszGdalData), "gdalicon.png", NULL)), NULL)) { CPLDebug("WINDNINJA", "Invalid path for GDAL_DATA: %s", pszGdalData); @@ -235,37 +215,6 @@ int NinjaInitialize() int rc = 0; -time_t now = time(0); - -// convert now to tm struct for UTC -tm *gmtm = gmtime(&now); -char* dt = asctime(gmtm); -std::string cpp_string(dt); - - -std::string url = "https://ninjastorm.firelab.org/sqlitetest/?time="; - cpp_string.erase(std::remove_if(cpp_string.begin(), cpp_string.end(), ::isspace), - cpp_string.end()); - - -std::string full = url + cpp_string; - - -const char *charStr = full.data(); - - CPLHTTPResult *poResult; - std::cout << charStr << std::endl; - CPLSetConfigOption("GDAL_HTTP_UNSAFESSL", "YES"); - - poResult = CPLHTTPFetch(charStr, NULL); - - if (poResult) { - CPLHTTPDestroyResult(poResult); - } else { - std::cerr << "Fetch data." << std::endl; - } - - /* ** Setting the CURL_CA_BUNDLE variable through GDAL doesn't seem to work, ** but could be investigated in the future. CURL_CA_BUNDLE can only be set in GDAL