iQ Block Country - Version 1.1.51

Version Description

  • New: Added new GeoIP API server in Florida
  • New: Added new GeoIP API server in Asia
Download this release

Release Info

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

Code changes from version 1.1.50 to 1.1.51

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.1.50
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.
@@ -158,14 +158,13 @@ function iqblockcountry_upgrade()
158
  /* Check if update is necessary */
159
  $dbversion = get_option( 'blockcountry_version' );
160
  update_option('blockcountry_version',VERSION);
161
-
162
 
163
- if ($dbversion != "" && version_compare($dbversion, "1.1.44", '<=') )
 
 
 
 
164
  {
165
- if (get_option('blockcountry_geoapilocation') == "ASIA")
166
- {
167
- iqblockcountry_find_geoip_location();
168
- }
169
  $server_addr = array_key_exists( 'SERVER_ADDR', $_SERVER ) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'];
170
  if (get_option('blockcountry_frontendwhitelist') === FALSE || (get_option('blockcountry_frontendwhitelist') == "")) { update_option('blockcountry_frontendwhitelist',$server_addr); } iqblockcountry_install_db();
171
 
@@ -246,11 +245,12 @@ define("BANLISTRETRIEVEURL","https://eu.adminblock.webence.nl/iq-block-country-r
246
  define("GEOIPAPIURL","https://eu.geoip.webence.nl/geoipapi.php");
247
  define("GEOIPAPIURLUS","https://us.geoip.webence.nl/geoipapi.php");
248
  define("GEOIPAPIURLUS2","https://us2.geoip.webence.nl/geoipapi.php");
249
- define("GEOIPAPIURLASIA","https://us2.geoip.webence.nl/geoipapi.php");
 
250
  define("GEOIPAPICHECKURL","https://eu.geoip.webence.nl/geoipapi-keycheck.php");
251
  define("ADMINAPICHECKURL","https://tracking.webence.nl/adminapi-keycheck.php");
252
  define("IPLOOKUPURL",'https://geoip.webence.nl/iplookup/iplookup.php');
253
- define("VERSION","1.1.50");
254
  define("DBVERSION","122");
255
  define("PLUGINPATH",plugin_dir_path( __FILE__ ));
256
 
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.1.51
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.
158
  /* Check if update is necessary */
159
  $dbversion = get_option( 'blockcountry_version' );
160
  update_option('blockcountry_version',VERSION);
 
161
 
162
+ if ($dbversion != "" && version_compare($dbversion, "1.1.51", '<') )
163
+ {
164
+ iqblockcountry_find_geoip_location();
165
+ }
166
+ elseif ($dbversion != "" && version_compare($dbversion, "1.1.44", '<') )
167
  {
 
 
 
 
168
  $server_addr = array_key_exists( 'SERVER_ADDR', $_SERVER ) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'];
169
  if (get_option('blockcountry_frontendwhitelist') === FALSE || (get_option('blockcountry_frontendwhitelist') == "")) { update_option('blockcountry_frontendwhitelist',$server_addr); } iqblockcountry_install_db();
170
 
245
  define("GEOIPAPIURL","https://eu.geoip.webence.nl/geoipapi.php");
246
  define("GEOIPAPIURLUS","https://us.geoip.webence.nl/geoipapi.php");
247
  define("GEOIPAPIURLUS2","https://us2.geoip.webence.nl/geoipapi.php");
248
+ define("GEOIPAPIURLUS3","https://us3.geoip.webence.nl/geoipapi.php");
249
+ define("GEOIPAPIURLASIA","https://asia.geoip.webence.nl/geoipapi.php");
250
  define("GEOIPAPICHECKURL","https://eu.geoip.webence.nl/geoipapi-keycheck.php");
251
  define("ADMINAPICHECKURL","https://tracking.webence.nl/adminapi-keycheck.php");
252
  define("IPLOOKUPURL",'https://geoip.webence.nl/iplookup/iplookup.php');
253
+ define("VERSION","1.1.51");
254
  define("DBVERSION","122");
255
  define("PLUGINPATH",plugin_dir_path( __FILE__ ));
256
 
libs/blockcountry-checks.php CHANGED
@@ -62,6 +62,10 @@ function iqblockcountry_retrieve_geoipapi($ipaddress)
62
  {
63
  $url = GEOIPAPIURLUS2;
64
  }
 
 
 
 
65
  if (get_option('blockcountry_geoapilocation') == "ASIA")
66
  {
67
  $url = GEOIPAPIURLASIA;
62
  {
63
  $url = GEOIPAPIURLUS2;
64
  }
65
+ if (get_option('blockcountry_geoapilocation') == "US3")
66
+ {
67
+ $url = GEOIPAPIURLUS3;
68
+ }
69
  if (get_option('blockcountry_geoapilocation') == "ASIA")
70
  {
71
  $url = GEOIPAPIURLASIA;
libs/blockcountry-settings.php CHANGED
@@ -207,7 +207,6 @@ function iqblockcountry_set_defaults()
207
  if (get_option('blockcountry_frontendnrblocks') === FALSE) { update_option('blockcountry_frontendnrblocks', 0); }
208
  if (get_option('blockcountry_header') === FALSE) { update_option('blockcountry_header', 'on'); }
209
  if (get_option('blockcountry_nrstatistics') === FALSE) { update_option('blockcountry_nrstatistics',15); }
210
- // if (get_option('blockcountry_daysstatistics') === FALSE) { update_option('blockcountry_daysstatistics',30); }
211
  if ( NULL === get_option('blockcountry_daysstatistics', NULL ) ) { update_option('blockcountry_daysstatistics',30); }
212
  if (get_option('blockcountry_backendwhitelist') === FALSE || (get_option('blockcountry_backendwhitelist') == "")) { update_option('blockcountry_backendwhitelist',$ip_address); }
213
  if (get_option('blockcountry_frontendwhitelist') === FALSE || (get_option('blockcountry_frontendwhitelist') == "")) { update_option('blockcountry_frontendwhitelist',$server_addr); } iqblockcountry_install_db();
@@ -1485,6 +1484,8 @@ if (is_file ( IPV4DBFILE ) && (!get_option('blockcountry_geoapikey'))) {
1485
  <input type="radio" name="blockcountry_geoapilocation" value="EU" <?php checked('EU', get_option('blockcountry_geoapilocation'), true); ?>> Europe<br />
1486
  <input type="radio" name="blockcountry_geoapilocation" value="US" <?php checked('US', get_option('blockcountry_geoapilocation'), true); ?>> United States - East coast<br />
1487
  <input type="radio" name="blockcountry_geoapilocation" value="US2" <?php checked('US2', get_option('blockcountry_geoapilocation'), true); ?>> United States - West coast<br />
 
 
1488
  </td></tr>
1489
  <tr valign="top">
1490
  <th width="30%"><?php _e('Admin block API Key:', 'iq-block-country'); ?><br />
@@ -1774,6 +1775,26 @@ function iqblockcountry_find_geoip_location()
1774
  $resp = curl_exec($curl);
1775
  $infous2 = curl_getinfo($curl);
1776
  curl_close($curl);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1777
 
1778
  $curl = curl_init();
1779
  curl_setopt_array($curl, array(
@@ -1784,7 +1805,7 @@ function iqblockcountry_find_geoip_location()
1784
  $infoeu = curl_getinfo($curl);
1785
  curl_close($curl);
1786
 
1787
- $fastestsite = min($infoeu['total_time'],$infous['total_time'],$infous2['total_time']);
1788
 
1789
  if ($infous['total_time'] == $fastestsite)
1790
  {
@@ -1794,6 +1815,14 @@ function iqblockcountry_find_geoip_location()
1794
  {
1795
  update_option('blockcountry_geoapilocation','US2');
1796
  }
 
 
 
 
 
 
 
 
1797
  else
1798
  {
1799
  update_option('blockcountry_geoapilocation','EU');
207
  if (get_option('blockcountry_frontendnrblocks') === FALSE) { update_option('blockcountry_frontendnrblocks', 0); }
208
  if (get_option('blockcountry_header') === FALSE) { update_option('blockcountry_header', 'on'); }
209
  if (get_option('blockcountry_nrstatistics') === FALSE) { update_option('blockcountry_nrstatistics',15); }
 
210
  if ( NULL === get_option('blockcountry_daysstatistics', NULL ) ) { update_option('blockcountry_daysstatistics',30); }
211
  if (get_option('blockcountry_backendwhitelist') === FALSE || (get_option('blockcountry_backendwhitelist') == "")) { update_option('blockcountry_backendwhitelist',$ip_address); }
212
  if (get_option('blockcountry_frontendwhitelist') === FALSE || (get_option('blockcountry_frontendwhitelist') == "")) { update_option('blockcountry_frontendwhitelist',$server_addr); } iqblockcountry_install_db();
1484
  <input type="radio" name="blockcountry_geoapilocation" value="EU" <?php checked('EU', get_option('blockcountry_geoapilocation'), true); ?>> Europe<br />
1485
  <input type="radio" name="blockcountry_geoapilocation" value="US" <?php checked('US', get_option('blockcountry_geoapilocation'), true); ?>> United States - East coast<br />
1486
  <input type="radio" name="blockcountry_geoapilocation" value="US2" <?php checked('US2', get_option('blockcountry_geoapilocation'), true); ?>> United States - West coast<br />
1487
+ <input type="radio" name="blockcountry_geoapilocation" value="US3" <?php checked('US3', get_option('blockcountry_geoapilocation'), true); ?>> United States - Florida<br />
1488
+ <input type="radio" name="blockcountry_geoapilocation" value="ASIA" <?php checked('ASIA', get_option('blockcountry_geoapilocation'), true); ?>> Asia<br />
1489
  </td></tr>
1490
  <tr valign="top">
1491
  <th width="30%"><?php _e('Admin block API Key:', 'iq-block-country'); ?><br />
1775
  $resp = curl_exec($curl);
1776
  $infous2 = curl_getinfo($curl);
1777
  curl_close($curl);
1778
+
1779
+ $curl = curl_init();
1780
+ curl_setopt_array($curl, array(
1781
+ CURLOPT_RETURNTRANSFER => 1,
1782
+ CURLOPT_URL => 'https://us3.geoip.webence.nl/test',
1783
+ CURLOPT_USERAGENT => 'iQ Block Country location test'
1784
+ ));
1785
+ $resp = curl_exec($curl);
1786
+ $infous3 = curl_getinfo($curl);
1787
+ curl_close($curl);
1788
+
1789
+ $curl = curl_init();
1790
+ curl_setopt_array($curl, array(
1791
+ CURLOPT_RETURNTRANSFER => 1,
1792
+ CURLOPT_URL => 'https://asia.geoip.webence.nl/test',
1793
+ CURLOPT_USERAGENT => 'iQ Block Country location test'
1794
+ ));
1795
+ $resp = curl_exec($curl);
1796
+ $infoasia = curl_getinfo($curl);
1797
+ curl_close($curl);
1798
 
1799
  $curl = curl_init();
1800
  curl_setopt_array($curl, array(
1805
  $infoeu = curl_getinfo($curl);
1806
  curl_close($curl);
1807
 
1808
+ $fastestsite = min($infoeu['total_time'],$infous['total_time'],$infous2['total_time'],$infous3['total_time'],$infoasia['total_time']);
1809
 
1810
  if ($infous['total_time'] == $fastestsite)
1811
  {
1815
  {
1816
  update_option('blockcountry_geoapilocation','US2');
1817
  }
1818
+ elseif ($infous3['total_time'] == $fastestsite)
1819
+ {
1820
+ update_option('blockcountry_geoapilocation','US3');
1821
+ }
1822
+ elseif ($infoasia['total_time'] == $fastestsite)
1823
+ {
1824
+ update_option('blockcountry_geoapilocation','ASIA');
1825
+ }
1826
  else
1827
  {
1828
  update_option('blockcountry_geoapilocation','EU');
readme.txt CHANGED
@@ -4,9 +4,10 @@ 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: 4.9.6
7
- Stable tag: 1.1.50
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
 
10
 
11
  Allow or disallow visitors from certain countries accessing (parts of) your website
12
 
@@ -224,6 +225,11 @@ As the basic rule is to block all and every post you have to configure this in a
224
 
225
  == Changelog ==
226
 
 
 
 
 
 
227
  = 1.1.50 =
228
 
229
  * Bugfix: Fix for SQL error in rare conditions
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: 4.9.6
7
+ Stable tag: 1.1.51
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+ Requires PHP: 5.6
11
 
12
  Allow or disallow visitors from certain countries accessing (parts of) your website
13
 
225
 
226
  == Changelog ==
227
 
228
+ = 1.1.51 =
229
+
230
+ * New: Added new GeoIP API server in Florida
231
+ * New: Added new GeoIP API server in Asia
232
+
233
  = 1.1.50 =
234
 
235
  * Bugfix: Fix for SQL error in rare conditions