aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRomain d'Alverny <rda@mageia.org>2011-04-05 13:31:46 +0000
committerRomain d'Alverny <rda@mageia.org>2011-04-05 13:31:46 +0000
commitf61ea1115c66d9e81eee861e569d06fd83f6982b (patch)
treeb8a3f4cf1668006daa0e773340b158695cda7c5e /lib
parentc1a10ccddf739c83b7510fc27195883c2c75fcfc (diff)
downloadwww-f61ea1115c66d9e81eee861e569d06fd83f6982b.tar
www-f61ea1115c66d9e81eee861e569d06fd83f6982b.tar.gz
www-f61ea1115c66d9e81eee861e569d06fd83f6982b.tar.bz2
www-f61ea1115c66d9e81eee861e569d06fd83f6982b.tar.xz
www-f61ea1115c66d9e81eee861e569d06fd83f6982b.zip
handle when php native geoip extension is available
Diffstat (limited to 'lib')
-rw-r--r--lib/Downloads.php26
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/Downloads.php b/lib/Downloads.php
index eca84284c..25cfa89c3 100644
--- a/lib/Downloads.php
+++ b/lib/Downloads.php
@@ -151,24 +151,24 @@ class Downloads
*/
function get_country($ip)
{
- error_log(sprintf('in get_country with %s.', $ip));
-
if ($ip == '127.0.0.1' || $ip == '::1')
return null;
- if (!function_exists('geoip_open')) {
+ if (function_exists('geoip_country_code_by_name'))
+ {
+ $loc = geoip_country_code_by_name($ip);
+ }
+ else
+ {
require_once '../../lib/maxmind/geoip/geoip.inc.php';
+ $gi = geoip_open(realpath('../../lib/maxmind/geoip/GeoIP.dat'),
+ GEOIP_STANDARD);
+ $loc = geoip_country_code_by_addr($gi, $ip);
+ geoip_close($gi);
}
- $gi = geoip_open(realpath('../../lib/maxmind/geoip/GeoIP.dat'),
- GEOIP_STANDARD);
- $loc = geoip_country_code_by_addr($gi, $ip);
- geoip_close($gi);
-
if (trim($loc) == '' || is_null($loc))
return null;
- error_log(sprintf('in get_country: %s', $loc));
-
return strtoupper($loc);
}
@@ -192,7 +192,7 @@ class Downloads
if (!$force && isset($_SESSION['dl-data']))
{
- error_log(sprintf('Got session data: %s', print_r($_SESSION['dl-data'], true)));
+ //error_log(sprintf('Got session data: %s', print_r($_SESSION['dl-data'], true)));
$system = $_SESSION['dl-data']['system'];
if (isset($_GET['mirror']))
{
@@ -209,7 +209,7 @@ class Downloads
}
else
{
- error_log('getting platform');
+ //error_log('getting platform');
$system = self::get_platform($_SERVER['HTTP_USER_AGENT']);
if (isset($_GET['mirror']))
{
@@ -219,7 +219,7 @@ class Downloads
}
else
{
- error_log('no mirror set yet');
+ //error_log('no mirror set yet');
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])
&& $str = $_SERVER['HTTP_X_FORWARDED_FOR'])
{