Skip to content

Commit f16f839

Browse files
committed
Remove guzzle and use file_put_contents
1 parent 0565fe3 commit f16f839

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
"illuminate/console": "~5.0",
1717
"illuminate/config": "~5.0",
1818
"monolog/monolog": "~1.11",
19-
"geoip2/geoip2": "~2.1",
20-
"guzzlehttp/guzzle": "^6.0"
19+
"geoip2/geoip2": "~2.1"
2120
},
2221
"require-dev": {
2322
"phpunit/phpunit": "~4.0",

src/Torann/GeoIP/GeoIPUpdater.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,15 @@ protected function updateMaxMindDatabase()
4747
$maxMindDatabaseUrl = $this->config->get('geoip.maxmind.update_url');
4848
$databasePath = $this->config->get('geoip.maxmind.database_path');
4949

50-
$client = new Client();
51-
$response = $client->get($maxMindDatabaseUrl);
52-
$file = $response->getBody();
50+
// Download zipped database to a system temp file
51+
$tmpFile = tempnam(sys_get_temp_dir(), 'maxmind');
52+
file_put_contents($tmpFile, fopen($maxMindDatabaseUrl, 'r'));
5353

54-
@file_put_contents($databasePath, gzdecode($file));
54+
// Unzip and save database
55+
file_put_contents($databasePath, gzopen($tmpFile, 'r'));
56+
57+
// Remove temp file
58+
@unlink($tmpFile);
5559

5660
return $databasePath;
5761
}

0 commit comments

Comments
 (0)