Merge pull request #7367 from woothemes/wc-geo-ip

WC_Geo_IP class
This commit is contained in:
Claudio Sanches 2015-02-11 16:04:56 -02:00
commit 3593df34b3
3 changed files with 1750 additions and 1891 deletions

1738
includes/class-wc-geo-ip.php Normal file

File diff suppressed because it is too large Load Diff

View File

@ -6,10 +6,10 @@
*
* This product uses GeoLite2 data created by MaxMind, available from http://www.maxmind.com
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Classes
* @version 2.3.0
* @author WooThemes
* @category Admin
* @package WooCommerce/Classes
* @version 2.3.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@ -170,13 +170,15 @@ class WC_Geolocation {
* @return string
*/
private static function geolocate_via_db( $ip_address ) {
if ( ! class_exists( 'GeoIP' ) && ! class_exists( 'geoiprecord' ) ) {
include_once( 'libraries/geoip.php' );
if ( ! class_exists( 'WC_Geo_IP' ) ) {
include_once( 'class-wc-geo-ip.php' );
}
$database = self::get_local_database_path();
$gi = geoip_open( $database, GEOIP_STANDARD );
$country_code = geoip_country_code_by_addr( $gi, $ip_address );
geoip_close( $gi );
$database = self::get_local_database_path();
$gi = new WC_Geo_IP();
$gi->geoip_open( $database, 0 );
$country_code = $gi->geoip_country_code_by_addr( $ip_address );
$gi->geoip_close();
return sanitize_text_field( strtoupper( $country_code ) );
}

File diff suppressed because it is too large Load Diff