Beispiel #1
0
require dirname(__FILE__) . '/../../core/bootstrap.php';
$VERBOSE = false;
// true: Include human readable IP addresses into the geoip database
echo "\nUpdating GeoIP database\n";
$dbFile = TMP_DIR . 'GeoIP/update.sqlite';
if (file_exists($dbFile)) {
    unlink($dbFile);
}
// Download
echo "  Downloading...";
mkdirs(TMP_DIR . 'GeoIP');
$zipFile = TMP_DIR . 'GeoIP/CountryCSV.zip';
if (file_exists($zipFile) == false || filemtime($zipFile) < time() - 3600) {
    // Is het gedownloade bestand ouder dan 1 uur?
    cURL::download('http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip', $zipFile);
    echo " done\n";
    flush();
} else {
    echo " skipped\n";
}
// Unzip
$csvFile = TMP_DIR . 'GeoIP/GeoIPCountryWhois.csv';
if (file_exists($csvFile)) {
    unlink($csvFile);
}
echo "  Extracting...";
$archive = new \ZipArchive();
if ($archive->open($zipFile) !== true) {
    throw new \Exception('Failed to open zipfile');
}