iQ Block Country - Version 1.2.8

Version Description

  • Bugfix: Checking the IP address on the tools tab gave wrong information about countries being blocked if the "block countries below" function was used. This had no effect on the actual denying of visitors.
  • New: Added GeoIP API usage (not realtime) of the current month to the tools tab as beta function.
Download this release

Release Info

Developer iqpascal
Plugin Icon 128x128 iQ Block Country
Version 1.2.8
Comparing to
See all releases

Code changes from version 1.2.7 to 1.2.8

iq-block-country.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: iQ Block Country
4
  Plugin URI: https://www.webence.nl/plugins/iq-block-country-the-wordpress-plugin-that-blocks-countries-for-you/
5
- Version: 1.2.7
6
  Author: Pascal
7
  Author URI: https://www.webence.nl/
8
  Description: Block visitors from visiting your website and backend website based on which country their IP address is from. The Maxmind GeoIP lite database is used for looking up from which country an ip address is from.
@@ -250,6 +250,7 @@ define("GEOIPAPIURLUS2","https://us2.geoip.webence.nl/geoipapi.php");
250
  define("GEOIPAPIURLUS3","https://us3.geoip.webence.nl/geoipapi.php");
251
  define("GEOIPAPIURLASIA","https://asia.geoip.webence.nl/geoipapi.php");
252
  define("GEOIPAPICHECKURL","https://eu.geoip.webence.nl/geoipapi-keycheck.php");
 
253
  define("ADMINAPICHECKURL","https://tracking.webence.nl/adminapi-keycheck.php");
254
  define("IPLOOKUPURL",'https://geoip.webence.nl/iplookup/iplookup.php');
255
  define("VERSION","1.2.7");
2
  /*
3
  Plugin Name: iQ Block Country
4
  Plugin URI: https://www.webence.nl/plugins/iq-block-country-the-wordpress-plugin-that-blocks-countries-for-you/
5
+ Version: 1.2.8
6
  Author: Pascal
7
  Author URI: https://www.webence.nl/
8
  Description: Block visitors from visiting your website and backend website based on which country their IP address is from. The Maxmind GeoIP lite database is used for looking up from which country an ip address is from.
250
  define("GEOIPAPIURLUS3","https://us3.geoip.webence.nl/geoipapi.php");
251
  define("GEOIPAPIURLASIA","https://asia.geoip.webence.nl/geoipapi.php");
252
  define("GEOIPAPICHECKURL","https://eu.geoip.webence.nl/geoipapi-keycheck.php");
253
+ define("GEOIPAPICHECKUSAGEURL","https://eu.geoip.webence.nl/geoipapi-usage.php");
254
  define("ADMINAPICHECKURL","https://tracking.webence.nl/adminapi-keycheck.php");
255
  define("IPLOOKUPURL",'https://geoip.webence.nl/iplookup/iplookup.php');
256
  define("VERSION","1.2.7");
libs/blockcountry-settings.php CHANGED
@@ -241,7 +241,8 @@ function iqblockcountry_set_defaults()
241
  if (get_option('blockcountry_nrstatistics') === FALSE) { update_option('blockcountry_nrstatistics',15); }
242
  if ( NULL === get_option('blockcountry_daysstatistics', NULL ) ) { update_option('blockcountry_daysstatistics',30); }
243
  if (get_option('blockcountry_backendwhitelist') === FALSE || (get_option('blockcountry_backendwhitelist') == "")) { update_option('blockcountry_backendwhitelist',$ip_address); }
244
- if (get_option('blockcountry_frontendwhitelist') === FALSE || (get_option('blockcountry_frontendwhitelist') == "")) { update_option('blockcountry_frontendwhitelist',$server_addr); } iqblockcountry_install_db();
 
245
  if (get_option('blockcountry_banlist_inverse') === FALSE) { update_option('blockcountry_banlist_inverse' , 'off'); }
246
  if (get_option('blockcountry_backendbanlist_inverse') === FALSE) { update_option('blockcountry_backendbanlist_inverse' , 'off'); }
247
  if (get_option('blockcountry_ipoverride') === FALSE) { update_option('blockcountry_ipoverride' , 'NONE'); }
@@ -322,9 +323,9 @@ function iqblockcountry_settings_tools() {
322
  if (!wp_verify_nonce($_POST['ipcheck_nonce'],'ipcheck_nonce')) die("Is this a CSRF attempts?");
323
  if (isset($_POST['ipaddress']) && !empty($_POST['ipaddress']))
324
  {
325
- $ip_address = $_POST['ipaddress'];
326
- if (iqblockcountry_is_valid_ipv4($ip_address) || iqblockcountry_is_valid_ipv6($ip_address))
327
  {
 
328
  $country = iqblockcountry_check_ipaddress($ip_address);
329
  $countrylist = iqblockcountry_get_isocountries();
330
  if ($country == "Unknown" || $country == "ipv6" || $country == "" || $country == "FALSE")
@@ -338,7 +339,7 @@ function iqblockcountry_settings_tools() {
338
  $haystack = get_option('blockcountry_banlist');
339
  if (!is_array($haystack)) { $haystack = array(); }
340
  $inverse = get_option( 'blockcountry_banlist_inverse');
341
- if ($inverse) {
342
  if (is_array($haystack) && !in_array ($country, $haystack )) {
343
  _e('This country is not permitted to visit the frontend of this website.', 'iq-block-country');
344
  echo "<br />";
@@ -352,7 +353,7 @@ function iqblockcountry_settings_tools() {
352
  $inverse = get_option( 'blockcountry_backendbanlist_inverse');
353
  $haystack = get_option('blockcountry_backendbanlist');
354
  if (!is_array($haystack)) { $haystack = array(); }
355
- if ($inverse) {
356
  if (is_array($haystack) && !in_array ( $country, $haystack )) {
357
  _e('This country is not permitted to visit the backend of this website.', 'iq-block-country');
358
  echo "<br />";
@@ -472,6 +473,9 @@ function iqblockcountry_settings_tools() {
472
  _e("Your GeoIP API key is valid till: ", 'iq-block-country');
473
  echo date($format,$licensedate);
474
  echo "<br />";
 
 
 
475
  }
476
  ?>
477
  <br />
241
  if (get_option('blockcountry_nrstatistics') === FALSE) { update_option('blockcountry_nrstatistics',15); }
242
  if ( NULL === get_option('blockcountry_daysstatistics', NULL ) ) { update_option('blockcountry_daysstatistics',30); }
243
  if (get_option('blockcountry_backendwhitelist') === FALSE || (get_option('blockcountry_backendwhitelist') == "")) { update_option('blockcountry_backendwhitelist',$ip_address); }
244
+ if (get_option('blockcountry_frontendwhitelist') === FALSE || (get_option('blockcountry_frontendwhitelist') == "")) { update_option('blockcountry_frontendwhitelist',$server_addr); }
245
+ iqblockcountry_install_db();
246
  if (get_option('blockcountry_banlist_inverse') === FALSE) { update_option('blockcountry_banlist_inverse' , 'off'); }
247
  if (get_option('blockcountry_backendbanlist_inverse') === FALSE) { update_option('blockcountry_backendbanlist_inverse' , 'off'); }
248
  if (get_option('blockcountry_ipoverride') === FALSE) { update_option('blockcountry_ipoverride' , 'NONE'); }
323
  if (!wp_verify_nonce($_POST['ipcheck_nonce'],'ipcheck_nonce')) die("Is this a CSRF attempts?");
324
  if (isset($_POST['ipaddress']) && !empty($_POST['ipaddress']))
325
  {
326
+ if (iqblockcountry_is_valid_ipv4($_POST['ipaddress']) || iqblockcountry_is_valid_ipv6($_POST['ipaddress']))
 
327
  {
328
+ $ip_address = $_POST['ipaddress'];
329
  $country = iqblockcountry_check_ipaddress($ip_address);
330
  $countrylist = iqblockcountry_get_isocountries();
331
  if ($country == "Unknown" || $country == "ipv6" || $country == "" || $country == "FALSE")
339
  $haystack = get_option('blockcountry_banlist');
340
  if (!is_array($haystack)) { $haystack = array(); }
341
  $inverse = get_option( 'blockcountry_banlist_inverse');
342
+ if ($inverse == "on") {
343
  if (is_array($haystack) && !in_array ($country, $haystack )) {
344
  _e('This country is not permitted to visit the frontend of this website.', 'iq-block-country');
345
  echo "<br />";
353
  $inverse = get_option( 'blockcountry_backendbanlist_inverse');
354
  $haystack = get_option('blockcountry_backendbanlist');
355
  if (!is_array($haystack)) { $haystack = array(); }
356
+ if ($inverse == "on") {
357
  if (is_array($haystack) && !in_array ( $country, $haystack )) {
358
  _e('This country is not permitted to visit the backend of this website.', 'iq-block-country');
359
  echo "<br />";
473
  _e("Your GeoIP API key is valid till: ", 'iq-block-country');
474
  echo date($format,$licensedate);
475
  echo "<br />";
476
+ $usagerequests = iqblockcountry_get_usage_geoapikey(get_option('blockcountry_geoapikey'));
477
+ _e("Your GeoIP API usage this month: ", 'iq-block-country');
478
+ echo $usagerequests;
479
  }
480
  ?>
481
  <br />
libs/blockcountry-validation.php CHANGED
@@ -234,6 +234,46 @@ function iqblockcountry_get_licensedate_geoapikey($apikey)
234
  return "";
235
  }
236
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
  /**
238
  * Check if a given ip is in a network
239
  * @param string $ip IP to check in IPV4 format eg. 127.0.0.1
234
  return "";
235
  }
236
 
237
+ /*
238
+ * Check usage of GeoIP API
239
+ */
240
+ function iqblockcountry_get_usage_geoapikey($apikey)
241
+ {
242
+
243
+ // Check first if API key is empty....
244
+ if (!empty($apikey))
245
+ {
246
+
247
+ $url = GEOIPAPICHECKUSAGEURL;
248
+
249
+ $result = wp_remote_post(
250
+ $url,
251
+ array(
252
+ 'body' => array(
253
+ 'api-key' => $apikey
254
+ )
255
+ )
256
+ );
257
+ if ( is_wp_error( $result ) ) {
258
+ return "";
259
+ }
260
+ elseif ( 200 == $result['response']['code'] ) {
261
+ $body = $result['body'];
262
+ $xml = new SimpleXmlElement($body);
263
+ if ($xml->check == "Ok")
264
+ {
265
+ return $xml->requests;
266
+ }
267
+ }
268
+ else
269
+ {
270
+ return "";
271
+ }
272
+ }
273
+ return "";
274
+ }
275
+
276
+
277
  /**
278
  * Check if a given ip is in a network
279
  * @param string $ip IP to check in IPV4 format eg. 127.0.0.1
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.webence.nl/plugins/donate
4
  Tags: spam, block, country, comments, ban, geo, geo blocking, geo ip, block country, block countries, ban countries, ban country, blacklist, whitelist, security
5
  Requires at least: 3.5.2
6
  Tested up to: 5.4.1
7
- Stable tag: 1.2.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  Requires PHP: 5.6
@@ -37,8 +37,6 @@ The Wordpress license does not allow this plugin to download the MaxMind Geo dat
37
 
38
  Do you need help with this plugin? Please email support@webence.nl.
39
 
40
- [](http://coderisk.com/wp/plugin/iq-block-country/RIPS-gqj4iaDvG_)
41
-
42
  = GDPR Information =
43
 
44
  This plugin stores data about your visitors in your local WordPress database. The number of days this data is stores can be configured on the settings page. You can also disable logging any data.
@@ -239,6 +237,11 @@ be used.
239
 
240
  == Changelog ==
241
 
 
 
 
 
 
242
  = 1.2.7 =
243
 
244
  * Change: Typo in San Francisco (Thanks to Shizart)
@@ -484,4 +487,4 @@ be used.
484
 
485
  = 1.1.19 =
486
 
487
- This plugin no longer downloads the MaxMind database. You have to download manually or use the GeoIP API.
4
  Tags: spam, block, country, comments, ban, geo, geo blocking, geo ip, block country, block countries, ban countries, ban country, blacklist, whitelist, security
5
  Requires at least: 3.5.2
6
  Tested up to: 5.4.1
7
+ Stable tag: 1.2.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  Requires PHP: 5.6
37
 
38
  Do you need help with this plugin? Please email support@webence.nl.
39
 
 
 
40
  = GDPR Information =
41
 
42
  This plugin stores data about your visitors in your local WordPress database. The number of days this data is stores can be configured on the settings page. You can also disable logging any data.
237
 
238
  == Changelog ==
239
 
240
+ = 1.2.8 =
241
+
242
+ * Bugfix: Checking the IP address on the tools tab gave wrong information about countries being blocked if the "block countries below" function was used. This had no effect on the actual denying of visitors.
243
+ * New: Added GeoIP API usage (not realtime) of the current month to the tools tab as beta function.
244
+
245
  = 1.2.7 =
246
 
247
  * Change: Typo in San Francisco (Thanks to Shizart)
487
 
488
  = 1.1.19 =
489
 
490
+ This plugin no longer downloads the MaxMind database. You have to download manually or use the GeoIP API.