Skip to content

Commit 1a20b2c

Browse files
committed
Upd. Firewall. Enhance IP data retrieval by adding subdivision and city information to the country report.
1 parent 81e7530 commit 1a20b2c

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

inc/spbc-tools.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ function spbc_report_country_part($ips_c, $ip = null)
1010
if (isset($ips_c[ $ip ]['country_code'])) {
1111
$country_code = strtolower($ips_c[ $ip ]['country_code']);
1212
$country_name = (isset($ips_c[ $ip ]['country_name']) ? $ips_c[ $ip ]['country_name'] : '-');
13+
$subdivision = (isset($ips_c[ $ip ]['subdivision']) ? ', ' . $ips_c[ $ip ]['subdivision'] : '');
14+
$city = (isset($ips_c[ $ip ]['city']) ? ', ' . $ips_c[ $ip ]['city'] : '');
1315

1416
$country_part = sprintf(
15-
'<img src="https://cleantalk.org/images/flags/%s.png" alt="%s" />&nbsp;%s',
17+
'<img src="https://cleantalk.org/images/flags/%s.png" alt="%s" />&nbsp;%s%s%s',
1618
$country_code,
1719
$country_code,
18-
$country_name
20+
$country_name,
21+
$subdivision,
22+
$city
1923
);
2024
} else {
2125
$country_part = '-';

security-malware-firewall.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,12 @@ function spbc_get_countries_by_ips($ips_data = '')
631631
if ( isset($v2['country_name']) ) {
632632
$ips_c[ $ip_dec ]['country_name'] = $v2['country_name'];
633633
}
634+
if ( isset($v2['subdivision']) && is_string($v2['subdivision']) && $v2['subdivision'] !== '' ) {
635+
$ips_c[ $ip_dec ]['subdivision'] = $v2['subdivision'];
636+
}
637+
if ( isset($v2['city']) && is_string($v2['city']) && $v2['city'] !== '' ) {
638+
$ips_c[ $ip_dec ]['city'] = $v2['city'];
639+
}
634640
}
635641
}
636642

0 commit comments

Comments
 (0)