_get_region

The Google Font Fix get region function.

Description

_get_region( $gi, $ipnum ); 

Parameters (2)

0. $gi
The gi.
1. $ipnum
The ipnum.

Usage

  1. if ( !function_exists( '_get_region' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-font-fix/geo/geoip.inc.php'; 
  3.  
  4. // The gi. 
  5. $gi = null; 
  6.  
  7. // The ipnum. 
  8. $ipnum = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = _get_region($gi, $ipnum); 
  12.  

Defined (1)

The function is defined in the following location(s).

/geo/geoip.inc.php  
  1. function _get_region($gi, $ipnum) 
  2. if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) { 
  3. $seek_region = _geoip_seek_country($gi, $ipnum) - GEOIP_STATE_BEGIN_REV0
  4. if ($seek_region >= 1000) { 
  5. $country_code = "US"; 
  6. $region = chr(($seek_region - 1000) / 26 + 65) . chr(($seek_region - 1000) % 26 + 65); 
  7. } else { 
  8. $country_code = $gi->GEOIP_COUNTRY_CODES[$seek_region]; 
  9. $region = ""; 
  10. return array($country_code, $region); 
  11. } elseif ($gi->databaseType == GEOIP_REGION_EDITION_REV1) { 
  12. $seek_region = _geoip_seek_country($gi, $ipnum) - GEOIP_STATE_BEGIN_REV1
  13. if ($seek_region < US_OFFSET) { 
  14. $country_code = ""; 
  15. $region = ""; 
  16. } elseif ($seek_region < CANADA_OFFSET) { 
  17. $country_code = "US"; 
  18. $region = chr(($seek_region - US_OFFSET) / 26 + 65) . chr(($seek_region - US_OFFSET) % 26 + 65); 
  19. } elseif ($seek_region < WORLD_OFFSET) { 
  20. $country_code = "CA"; 
  21. $region = chr(($seek_region - CANADA_OFFSET) / 26 + 65) . chr(($seek_region - CANADA_OFFSET) % 26 + 65); 
  22. } else { 
  23. $country_code = $gi->GEOIP_COUNTRY_CODES[(int) (($seek_region - WORLD_OFFSET) / FIPS_RANGE)]; 
  24. $region = ""; 
  25. return array($country_code, $region); 
  26. return null;