Version 4.2.0
This commit is contained in:
1 parent
0dc2aee5ed
commit
96997ddd8e
2074 files changed
+125454
-55780
No files matched your search
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief GeoLocation
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 19 Apr 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS;
|
||||
@@ -473,7 +472,7 @@ class _GeoLocation
|
||||
* @throws \BadFunctionCallException Service is not available
|
||||
* @throws \IPS\Http\Request\Exception Error communicating with external service
|
||||
* @throws \RuntimeException Error within the external service
|
||||
* @throws \OutOfRangeException IP address is not in database
|
||||
* @throws \OutOfRangeException IP address has no data
|
||||
*/
|
||||
public static function getByIp( $ip )
|
||||
{
|
||||
@@ -496,7 +495,8 @@ class _GeoLocation
|
||||
$data = \IPS\Db::i()->select( 'data', 'core_geoip_cache', array( 'ip_address=?', $ip ) )->first();
|
||||
if ( !$data )
|
||||
{
|
||||
throw new \UnderflowException;
|
||||
/* @note This was changed from an \UnderflowException to be consistent with the \OutOfRangeException thrown later on, otherwise the system will keep trying even when it should not. cleanup task will remove out of date entries and it can try again then. */
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -594,12 +594,12 @@ class _GeoLocation
|
||||
|
||||
if( $component['types'][0] == 'administrative_area_level_1' )
|
||||
{
|
||||
$obj->region = $component['short_name'];
|
||||
$obj->region = $component['long_name'];
|
||||
}
|
||||
|
||||
if( $component['types'][0] == 'locality' )
|
||||
{
|
||||
$obj->city = $component['short_name'];
|
||||
$obj->city = $component['long_name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -645,8 +645,48 @@ class _GeoLocation
|
||||
return;
|
||||
}
|
||||
|
||||
$_address = NULL;
|
||||
|
||||
$this->lat = $data['results'][0]['geometry']['location']['lat'];
|
||||
$this->long = $data['results'][0]['geometry']['location']['lng'];
|
||||
|
||||
/* Reset address components in case there were typos */
|
||||
foreach( $data['results'][0]['address_components'] as $component )
|
||||
{
|
||||
if( $component['types'][0] == 'street_number' )
|
||||
{
|
||||
$_address = $component['long_name'];
|
||||
}
|
||||
elseif( $component['types'][0] == 'route' )
|
||||
{
|
||||
$_address .= " " . $component['long_name'];
|
||||
}
|
||||
|
||||
if( $component['types'][0] == 'postal_code' )
|
||||
{
|
||||
$this->postalCode = $component['long_name'];
|
||||
}
|
||||
|
||||
if( $component['types'][0] == 'country' )
|
||||
{
|
||||
$this->country = $component['short_name'];
|
||||
}
|
||||
|
||||
if( $component['types'][0] == 'administrative_area_level_1' )
|
||||
{
|
||||
$this->region = $component['long_name'];
|
||||
}
|
||||
|
||||
if( $component['types'][0] == 'locality' )
|
||||
{
|
||||
$this->city = $component['long_name'];
|
||||
}
|
||||
}
|
||||
|
||||
if( $_address )
|
||||
{
|
||||
$this->addressLines = array( $_address );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user