/**
* @return array or boolean false
*/
public function findLocationByIp()
{
$ip = $this->findIp();
if (empty($ip)) {
return false;
}
if (Validation::ip($ip)) {
App::import('Vendor', 'geoip', ['file' => 'geoip' . DS . 'geoip.php']);
$gi = Net_GeoIP::getInstance(APP . 'vendors' . DS . 'geoip' . DS . 'GeoLiteCity.dat');
$record = $gi->lookupLocation($ip);
$gi->close();
} else {
$this->log('Invalid IP \'' . h($ip) . '\'', LOG_WARNING);
}
return !empty($record) ? $this->findLocationByCoordinates($record->latitude, $record->longitude, 1) : false;
}