Skip to content
This repository has been archived by the owner on Feb 19, 2023. It is now read-only.

Commit

Permalink
SQL Update and browser side working GeoIP DB downloader working.
Browse files Browse the repository at this point in the history
  • Loading branch information
MartyniP committed Oct 18, 2012
1 parent 25e3026 commit 79023ff
Show file tree
Hide file tree
Showing 4 changed files with 795 additions and 5 deletions.
35 changes: 35 additions & 0 deletions includes/geoip/download.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

if (!is_writeable(".")) {
die("Error! The folder includes/geoip must be chmod 0777 (Writable by all)");
}

//ini_set('display_errors', '1');
//error_reporting(E_ALL);

function gzfile_get_contents ($filename, $use_include_path=0){
$file = @gzopen($filename, 'rb', $use_include_path) or die("failed gzopen");
if ($file) {
$data = '';
while (!gzeof($file)) {
$data .= gzread($file, 1024);
}
gzclose($file);
return $data;
}
}

$countryDbIPv6 = "http://geolite.maxmind.com/download/geoip/database/GeoIPv6.dat.gz";

echo "Downloading Maxmind GeoIP Lite Country database\n<br /><br />\n\n";
$dbipv6 = file_get_contents($countryDbIPv6) or die("Error downloading IPv6 Database. Exiting\n");
file_put_contents("geo-ipv6.dat.gz", $dbipv6) or die("Error writing gzfile.");
echo "Downloaded IPv6 Database.\n<br />\n";

$datipv6 = gzfile_get_contents("geo-ipv6.dat.gz", 0) or die("Error extracting IPv6 Database. Exiting\n");
file_put_contents("geo-ipv6.dat", $datipv6) or die("Error writing dat file.");
echo "Extracted IPv6 Database.\n<br />\n";



?>
Loading

0 comments on commit 79023ff

Please sign in to comment.