You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<?php use GeoIp2\Database\Reader;
register_hook('init', function () { global $config;
if (isset($config['checkIpLocation']) && !$config['checkIpLocation']) { return; }
if (!file_exists('data/GeoIP/GeoLite2-City.mmdb')) { $config['checkIpLocation'] = false; return; }
$reader = new Reader('data/GeoIP/GeoLite2-City.mmdb');
try { $record = $reader->city($_SERVER['REMOTE_ADDR']);
$config['defaultView']['lat'] = $record->location->latitude; $config['defaultView']['lon'] = $record->location->longitude; $config['defaultView']['zoom'] = 10; } catch (Exception $e) { // ignore error
trigger_error("Can't resolve IP address: " . $e->getMessage(), E_USER_WARNING); } });
|