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

Commit

Permalink
Admin only update of geoip db, and link in admin panel
Browse files Browse the repository at this point in the history
  • Loading branch information
MartyniP committed Oct 18, 2012
1 parent 79023ff commit 8ad6fd3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
6 changes: 5 additions & 1 deletion admin/site.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
elseif ($version < $current && $version !== $current) {
echo "<center><p style=\"color:blue;\">It seems you are running a prerelease version of Phurl. Expect Bugs!</p></center><hr/>";
}*/
if (!is_readable("../includes/geoip/geo-ipv6.dat") || !file_exists("../includes/geoip/geo-ipv6.dat")) {
echo "<center><p style=\"color:red;\">You have not downloaded the Maxmind GeoIP Database yet. You can do so <a href=\"includes/geoip/download.php\">here.</a></p></center><hr/>";
}
print_errors();
?>
<form method="post" action="admin/site.php">
Expand Down Expand Up @@ -145,7 +148,8 @@
<input type="hidden" name="form" value="user_sett">
</form>
<br />

<h4>Advanced</h4>
<a href="includes/geoip/download.php">Update Maxmind GeoIP Database.</a>

</div>
<?php
Expand Down
15 changes: 10 additions & 5 deletions includes/geoip/download.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<?php

include "../config.php";
include "../functions.php";
db_connect();
require_admin();

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

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

function gzfile_get_contents ($filename, $use_include_path=0){
Expand All @@ -22,12 +27,12 @@ function gzfile_get_contents ($filename, $use_include_path=0){
$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.");
$dbipv6 = file_get_contents($countryDbIPv6) or die("<br />\n\nError downloading IPv6 Database. Exiting\n");
file_put_contents("geo-ipv6.dat.gz", $dbipv6) or die("<br />\n\nError 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.");
$datipv6 = gzfile_get_contents("geo-ipv6.dat.gz", 0) or die("<br />\n\nError extracting IPv6 Database. Exiting\n");
file_put_contents("geo-ipv6.dat", $datipv6) or die("<br />\n\nError writing dat file.");
echo "Extracted IPv6 Database.\n<br />\n";


Expand Down

0 comments on commit 8ad6fd3

Please sign in to comment.