summaryrefslogtreecommitdiff
path: root/inc/functions.php
diff options
context:
space:
mode:
authorJano Slota <jano@alokal.eu>2014-07-05 02:11:31 +0200
committerczaks <marcin@6irc.net>2014-07-06 01:30:38 +0200
commit2488e77e86edc3bb2b24377b25e8439f35cc2343 (patch)
tree2db12d877d453e2a03392d0152960fbf1b965afc /inc/functions.php
parenta1d2d2388a24b7fa3dbf51a1dea5e9d2d3577cc8 (diff)
Second rework of the GeoIP code, now supporting cities!
Diffstat (limited to 'inc/functions.php')
-rw-r--r--inc/functions.php20
1 files changed, 14 insertions, 6 deletions
diff --git a/inc/functions.php b/inc/functions.php
index 4313e531..8fa79aff 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -246,15 +246,23 @@ function loadConfig() {
$config['anonymous'] = $config['anonymous'][array_rand($config['anonymous'])];
if ($config['country_flags'] || $config['country_anonymous']) {
- require_once 'inc/lib/geoip/geoip.inc';
- $gi=geoip_open('inc/lib/geoip/GeoIPv6.dat', GEOIP_STANDARD);
+ require_once 'inc/lib/geoip/geoipcity.inc';
+ require_once 'inc/lib/geoip/geoipregionvars.php';
+ $gi=geoip_open('inc/lib/geoip/GeoLiteCityv6.dat', GEOIP_STANDARD);
$ipaddy = $_SERVER['REMOTE_ADDR'];
if (IP::isIPv4($ipaddy))
$ipaddy = IP::to_ipv6($ipaddy, true);
- global $country_code, $country_name;
- $country_code = strtolower(geoip_country_code_by_addr_v6($gi, $ipaddy));
- $country_name = geoip_country_name_by_addr_v6($gi, $ipaddy);
- if (isset($config['country_anonymous'][$country_code])) {
+ $record = geoip_record_by_addr_v6($gi, $ipaddy);
+ global $country_code, $country_name, $city;
+ $country_code = strtolower($record->country_code);
+ $country_name = $record->country_name;
+ $city = $record->city;
+ if (isset($config['country_anonymous'][$country_code][$city]))
+ if (is_array($config['country_anonymous'][$country_code][$city]))
+ $config['anonymous'] = $config['country_anonymous'][$country_code][$city][array_rand($config['country_anonymous'][$country_code][$city])];
+ else
+ $config['anonymous'] = $config['country_anonymous'][$country_code][$city];
+ else if (isset($config['country_anonymous'][$country_code])) {
if (is_array($config['country_anonymous'][$country_code]))
$config['anonymous'] = $config['country_anonymous'][$country_code][array_rand($config['country_anonymous'][$country_code])];
else