Skip to content

Commit fa5d675

Browse files
author
Benjamin Pick
committed
FIX: In the datasource hostip.info, the region code (i.e. CA) is now correctly moved to the property (previously, it was part of the property )
1 parent cce4fde commit fa5d675

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

data-sources/hostinfo.php

+14
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ public function city($ip) {
3636
$r['country']['iso_code'] = strtoupper($data['country_code']);
3737

3838
if ($data['city']) {
39+
// In USA, region code is part of the city parameter
40+
$cityParts = explode(',', $data['city']);
41+
$data['city'] = trim($cityParts[0]);
42+
if (!empty($cityParts[1])) {
43+
$region = trim($cityParts[1]);
44+
if (!empty($region)) {
45+
$r['subdivisions'][0] = array(
46+
'iso_code' => $region,
47+
'names' => array('en' => $region),
48+
);
49+
}
50+
}
51+
3952
$r['city']['names'] = [ 'en' => $data['city'] ];
4053
}
4154

@@ -80,6 +93,7 @@ private function api_call($ip) {
8093
if ($key == 'country_code' && $value == 'XX')
8194
$value = '';
8295
}
96+
8397
$hasInfo = $data['country_name'] || $data['country_code'] || $data['city'];
8498
}
8599

data-sources/ipstack.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function city($ip) {
8484
if (!empty($data['country_code']))
8585
$r['country']['iso_code'] = strtoupper($data['country_code']);
8686

87-
if (!empty($data['region_code'])) {
87+
if (!empty($data['region_code'])) {
8888
$r['subdivisions'][0] = array(
8989
'iso_code' => $data['region_code'],
9090
'names' => $this->locales($locale, $data['region_name']),

geoip-detect.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Description: Provides geographic information detected by an IP adress.
66
Author: Yellow Tree (Benjamin Pick)
77
Author URI: http://www.yellowtree.de
8-
Version: 5.4.1
8+
Version: 5.5.0-beta1
99
License: GPLv3 or later
1010
License URI: http://www.gnu.org/licenses/gpl-3.0.html
1111
Text Domain: geoip-detect
@@ -16,7 +16,7 @@
1616
Requires PHP: 7.2.5
1717
*/
1818

19-
define('GEOIP_DETECT_VERSION', '5.4.1');
19+
define('GEOIP_DETECT_VERSION', '5.5.0');
2020

2121
/*
2222
Copyright 2013-2023 Yellow Tree, Siegen, Germany

readme.txt

+3
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ If you use Maxmind "Automatic download" then you need to upgrade to this plugin
174174

175175
== Changelog ==
176176

177+
= 5.5.0 =
178+
* FIX [!]: In the datasource "hostip.info", the region code (i.e. CA) is now correctly moved to the property `mostSpecificSubdivision` (previously, it was part of the property `city`)
179+
177180
= 5.4.1 =
178181
* NEW: JS now emit events 'geoip-detect-shortcodes-done' and 'geoip-detect-body-classes-done', see https://github.com/yellowtree/geoip-detect/wiki/API:-AJAX#events
179182
* FIX: Remove Fatal Error in check_requirements ("Undefined constand GEOIP_DETECT_DEBUG")

0 commit comments

Comments
 (0)