protected function downloadFile($dbType, $url)
    {
        $url = trim($url);

        $ext = GeoIP2AutoUpdater::getGeoIPUrlExtension($url);

        // NOTE: using the first item in $dbNames[$dbType] makes sure GeoLiteCity will be renamed to GeoIPCity
        $zippedFilename = LocationProviderGeoIp2::$dbNames[$dbType][0] . '.' . $ext;

        $zippedOutputPath = LocationProviderGeoIp2::getPathForGeoIpDatabase($zippedFilename);

        $url = self::removeDateFromUrl($url);

        // download zipped file to misc dir
        try {
            $success = Http::sendHttpRequest($url, $timeout = 3600, $userAgent = null, $zippedOutputPath);
        } catch (Exception $ex) {
            throw new Exception("GeoIP2AutoUpdater: failed to download '$url' to "
                . "'$zippedOutputPath': " . $ex->getMessage());
        }

        if ($success !== true) {
            throw new Exception("GeoIP2AutoUpdater: failed to download '$url' to "
                . "'$zippedOutputPath'! (Unknown error)");
        }

        Log::info("GeoIP2AutoUpdater: successfully downloaded '%s'", $url);

        try {
            self::unzipDownloadedFile($zippedOutputPath, $dbType, $unlink = true);
        } catch (Exception $ex) {
            throw new Exception("GeoIP2AutoUpdater: failed to unzip '$zippedOutputPath' after "
                . "downloading " . "'$url': " . $ex->getMessage());
        }

        Log::info("GeoIP2AutoUpdater: successfully updated GeoIP 2 database '%s'", $url);
    }
protected function downloadFile($dbType, $url)
    {
        $url = trim($url);

        $ext = GeoIP2AutoUpdater::getGeoIPUrlExtension($url);

        // NOTE: using the first item in $dbNames[$dbType] makes sure GeoLiteCity will be renamed to GeoIPCity
        $zippedFilename = LocationProviderGeoIp2::$dbNames[$dbType][0] . '.' . $ext;

        $zippedOutputPath = LocationProviderGeoIp2::getPathForGeoIpDatabase($zippedFilename);

        $url = self::removeDateFromUrl($url);

        // download zipped file to misc dir
        try {
            $success = Http::sendHttpRequest($url, $timeout = 3600, $userAgent = null, $zippedOutputPath);
        } catch (Exception $ex) {
            throw new Exception("GeoIP2AutoUpdater: failed to download '$url' to "
                . "'$zippedOutputPath': " . $ex->getMessage());
        }

        if ($success !== true) {
            throw new Exception("GeoIP2AutoUpdater: failed to download '$url' to "
                . "'$zippedOutputPath'! (Unknown error)");
        }

        Log::info("GeoIP2AutoUpdater: successfully downloaded '%s'", $url);

        try {
            self::unzipDownloadedFile($zippedOutputPath, $dbType, $unlink = true);
        } catch (Exception $ex) {
            throw new Exception("GeoIP2AutoUpdater: failed to unzip '$zippedOutputPath' after "
                . "downloading " . "'$url': " . $ex->getMessage());
        }

        Log::info("GeoIP2AutoUpdater: successfully updated GeoIP 2 database '%s'", $url);
    }
protected function downloadFile ( $ dbType , $ url ) { $ url = trim ( $ url ) ; $ ext = GeoIP2AutoUpdater :: getGeoIPUrlExtension ( $ url ) ; // NOTE: using the first item in $dbNames[$dbType] makes sure GeoLiteCity will be renamed to GeoIPCity $ zippedFilename = LocationProviderGeoIp2 :: $ dbNames [ $ dbType ] [ 0 ] . '.' . $ ext ; $ zippedOutputPath = LocationProviderGeoIp2 :: getPathForGeoIpDatabase ( $ zippedFilename ) ; $ url = self :: removeDateFromUrl ( $ url ) ; // download zipped file to misc dir try { $ success = Http :: sendHttpRequest ( $ url , $ timeout = 3600 , $ userAgent = null , $ zippedOutputPath ) ; } catch ( Exception $ ex ) { throw new Exception ( "GeoIP2AutoUpdater: failed to download '$url' to " . "'$zippedOutputPath': " . $ ex -> getMessage ( ) ) ; } if ( $ success !== true ) { throw new Exception ( "GeoIP2AutoUpdater: failed to download '$url' to " . "'$zippedOutputPath'! (Unknown error)" ) ; } Log :: info ( "GeoIP2AutoUpdater: successfully downloaded '%s'" , $ url ) ; try { self :: unzipDownloadedFile ( $ zippedOutputPath , $ dbType , $ unlink = true ) ; } catch ( Exception $ ex ) { throw new Exception ( "GeoIP2AutoUpdater: failed to unzip '$zippedOutputPath' after " . "downloading " . "'$url': " . $ ex -> getMessage ( ) ) ; } Log :: info ( "GeoIP2AutoUpdater: successfully updated GeoIP 2 database '%s'" , $ url ) ; }
Downloads a GeoIP 2 database archive, extracts the .mmdb file and overwrites the existing
old database.

If something happens that causes the download to fail, no exception is thrown, but
an error is logged.

@param string $dbType
@param string $url URL to the database to download. The type of database is determined
from this URL.
@throws Exception
Downloads a GeoIP 2 database archive extracts the . mmdb file and overwrites the existing old database .