Version Description
- Change: Changed whitelist/blacklist to allow list / block list.
- Change: Removed Paris as GeoIP location
- Change: Added website server address to allow list of the backend to ensure certain WordPress functions keep working if you block the country your website is hosted from the backend.
Download this release
Release Info
Developer | iqpascal |
Plugin | iQ Block Country |
Version | 1.2.10 |
Comparing to | |
See all releases |
Code changes from version 1.2.9 to 1.2.10
- iq-block-country.php +21 -7
- libs/blockcountry-checks.php +31 -31
- libs/blockcountry-settings.php +82 -89
- readme.txt +4 -19
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.
|
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.
|
@@ -151,9 +151,23 @@ function iqblockcountry_upgrade()
|
|
151 |
$dbversion = get_option( 'blockcountry_version' );
|
152 |
update_option('blockcountry_version',VERSION);
|
153 |
|
154 |
-
if ($dbversion != "" && version_compare($dbversion, "1.2.
|
155 |
{
|
156 |
iqblockcountry_find_geoip_location();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
}
|
158 |
elseif ($dbversion != "" && version_compare($dbversion, "1.2.5", '<') )
|
159 |
{
|
@@ -252,7 +266,7 @@ define("GEOIPAPICHECKURL","https://eu.geoip.webence.nl/geoipapi-keycheck.php");
|
|
252 |
define("GEOIPAPICHECKUSAGEURL","https://eu.geoip.webence.nl/geoipapi-usage.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.
|
256 |
define("DBVERSION","122");
|
257 |
define("PLUGINPATH",plugin_dir_path( __FILE__ ));
|
258 |
|
@@ -270,9 +284,9 @@ require_once('libs/blockcountry-tracking.php');
|
|
270 |
require_once('libs/blockcountry-search-engines.php');
|
271 |
require_once('vendor/autoload.php');
|
272 |
|
273 |
-
global $
|
274 |
-
$
|
275 |
-
$
|
276 |
|
277 |
$blockcountry_is_login_page = iqblockcountry_is_login_page();
|
278 |
$blockcountry_is_xmlrpc = iqblockcountry_is_xmlrpc();
|
@@ -286,7 +300,7 @@ register_uninstall_hook(__file__, 'iqblockcountry_uninstall');
|
|
286 |
|
287 |
/* Clean logging database */
|
288 |
iqblockcountry_clean_db();
|
289 |
-
|
290 |
|
291 |
if (isset($_POST['action']))
|
292 |
{
|
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.10
|
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.
|
151 |
$dbversion = get_option( 'blockcountry_version' );
|
152 |
update_option('blockcountry_version',VERSION);
|
153 |
|
154 |
+
if ($dbversion != "" && version_compare($dbversion, "1.2.10", '<') )
|
155 |
{
|
156 |
iqblockcountry_find_geoip_location();
|
157 |
+
$server_addr = array_key_exists( 'SERVER_ADDR', $_SERVER ) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'];
|
158 |
+
if (get_option('blockcountry_backendwhitelist') === FALSE || (get_option('blockcountry_backendwhitelist') == ""))
|
159 |
+
{ update_option('blockcountry_backendwhitelist',$server_addr . ";"); }
|
160 |
+
else
|
161 |
+
{
|
162 |
+
$tmpbackendallowlist = get_option('blockcountry_backendwhitelist');
|
163 |
+
$ippos = strpos($tmpbackendallowlist,$server_addr);
|
164 |
+
if ($ippos === false)
|
165 |
+
{
|
166 |
+
$tmpbackendallowlist .= $server_addr . ";";
|
167 |
+
update_option('blockcountry_backendwhitelist',$tmpbackendallowlist);
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
}
|
172 |
elseif ($dbversion != "" && version_compare($dbversion, "1.2.5", '<') )
|
173 |
{
|
266 |
define("GEOIPAPICHECKUSAGEURL","https://eu.geoip.webence.nl/geoipapi-usage.php");
|
267 |
define("ADMINAPICHECKURL","https://tracking.webence.nl/adminapi-keycheck.php");
|
268 |
define("IPLOOKUPURL",'https://geoip.webence.nl/iplookup/iplookup.php');
|
269 |
+
define("VERSION","1.2.10");
|
270 |
define("DBVERSION","122");
|
271 |
define("PLUGINPATH",plugin_dir_path( __FILE__ ));
|
272 |
|
284 |
require_once('libs/blockcountry-search-engines.php');
|
285 |
require_once('vendor/autoload.php');
|
286 |
|
287 |
+
global $apiblocklist;
|
288 |
+
$apiblocklist = FALSE;
|
289 |
+
$backendblocklistcheck = FALSE;
|
290 |
|
291 |
$blockcountry_is_login_page = iqblockcountry_is_login_page();
|
292 |
$blockcountry_is_xmlrpc = iqblockcountry_is_xmlrpc();
|
300 |
|
301 |
/* Clean logging database */
|
302 |
iqblockcountry_clean_db();
|
303 |
+
iqblockcountry_get_blockallowlist();
|
304 |
|
305 |
if (isset($_POST['action']))
|
306 |
{
|
libs/blockcountry-checks.php
CHANGED
@@ -143,7 +143,7 @@ function iqblockcountry_retrieve_geoipapi($ipaddress)
|
|
143 |
|
144 |
|
145 |
/*
|
146 |
-
* Check country against bad countries,
|
147 |
*/
|
148 |
function iqblockcountry_check($country,$badcountries,$ip_address)
|
149 |
{
|
@@ -171,8 +171,8 @@ function iqblockcountry_check($country,$badcountries,$ip_address)
|
|
171 |
$blockedfeed = get_option('blockcountry_blockfeed');
|
172 |
$postid = get_the_ID();
|
173 |
|
174 |
-
global $
|
175 |
-
global $
|
176 |
|
177 |
$backendbanlistip = unserialize(get_option('blockcountry_backendbanlistip'));
|
178 |
$blockredirect = get_option ( 'blockcountry_redirect');
|
@@ -180,21 +180,21 @@ function iqblockcountry_check($country,$badcountries,$ip_address)
|
|
180 |
/* Block if user is in a bad country from frontend or backend. Unblock may happen later */
|
181 |
if (is_array ( $badcountries ) && in_array ( $country, $badcountries )) {
|
182 |
$blocked = TRUE;
|
183 |
-
global $
|
184 |
-
$
|
185 |
}
|
186 |
|
187 |
global $blockcountry_is_login_page,$blockcountry_is_xmlrpc;
|
188 |
|
189 |
|
190 |
-
/* Check if requested url is not login page. Else check against frontend
|
191 |
if (!($blockcountry_is_login_page) && !(is_admin()) && !($blockcountry_is_xmlrpc))
|
192 |
{
|
193 |
-
if (iqblockcountry_validate_ip_in_list($ip_address,$
|
194 |
{
|
195 |
$blocked = TRUE;
|
196 |
}
|
197 |
-
if (iqblockcountry_validate_ip_in_list($ip_address,$
|
198 |
{
|
199 |
$blocked = FALSE;
|
200 |
}
|
@@ -206,13 +206,13 @@ function iqblockcountry_check($country,$badcountries,$ip_address)
|
|
206 |
if (is_array($backendbanlistip) && in_array($ip_address,$backendbanlistip))
|
207 |
{
|
208 |
$blocked = TRUE;
|
209 |
-
global $
|
210 |
-
$
|
211 |
}
|
212 |
-
if (iqblockcountry_validate_ip_in_list($ip_address,$
|
213 |
$blocked = TRUE;
|
214 |
}
|
215 |
-
if (iqblockcountry_validate_ip_in_list($ip_address,$
|
216 |
$blocked = FALSE;
|
217 |
}
|
218 |
if (iqblockcountry_is_adminajax() && get_option('blockcountry_adminajax'))
|
@@ -224,10 +224,10 @@ function iqblockcountry_check($country,$badcountries,$ip_address)
|
|
224 |
if ($blockedposttypes == "on")
|
225 |
{
|
226 |
$blockedposttypes = get_option('blockcountry_posttypes');
|
227 |
-
if (is_array($blockedposttypes) && in_array(get_post_type( $postid ), $blockedposttypes) && ((is_array ( $badcountries ) && in_array ( $country, $badcountries ) || (iqblockcountry_validate_ip_in_list($ip_address,$
|
228 |
{
|
229 |
$blocked = TRUE;
|
230 |
-
if (iqblockcountry_validate_ip_in_list($ip_address,$
|
231 |
$blocked = FALSE;
|
232 |
}
|
233 |
}
|
@@ -240,10 +240,10 @@ function iqblockcountry_check($country,$badcountries,$ip_address)
|
|
240 |
if (is_page() && $blockedpage == "on")
|
241 |
{
|
242 |
$post = get_post();
|
243 |
-
if (is_page($blockedpages) && !empty($blockedpages) && ((is_array ( $badcountries ) && in_array ( $country, $badcountries ) || (iqblockcountry_validate_ip_in_list($ip_address,$
|
244 |
{
|
245 |
$blocked = TRUE;
|
246 |
-
if (iqblockcountry_validate_ip_in_list($ip_address,$
|
247 |
$blocked = FALSE;
|
248 |
}
|
249 |
}
|
@@ -262,10 +262,10 @@ function iqblockcountry_check($country,$badcountries,$ip_address)
|
|
262 |
{
|
263 |
if (in_array($value,$blockedcategories))
|
264 |
{
|
265 |
-
if (is_single() && ((is_array ( $badcountries ) && in_array ( $country, $badcountries ) || (iqblockcountry_validate_ip_in_list($ip_address,$
|
266 |
{
|
267 |
$flagged = TRUE;
|
268 |
-
if (iqblockcountry_validate_ip_in_list($ip_address,$
|
269 |
$flagged = FALSE;
|
270 |
}
|
271 |
}
|
@@ -286,10 +286,10 @@ function iqblockcountry_check($country,$badcountries,$ip_address)
|
|
286 |
{
|
287 |
if (in_array($tag->term_id,$blockedtags))
|
288 |
{
|
289 |
-
if (is_single() && ((is_array ( $badcountries ) && in_array ( $country, $badcountries ) || (iqblockcountry_validate_ip_in_list($ip_address,$
|
290 |
{
|
291 |
$flagged = TRUE;
|
292 |
-
if (iqblockcountry_validate_ip_in_list($ip_address,$
|
293 |
|
294 |
$flagged = FALSE;
|
295 |
}
|
@@ -304,11 +304,11 @@ function iqblockcountry_check($country,$badcountries,$ip_address)
|
|
304 |
{
|
305 |
$flagged = FALSE;
|
306 |
$blockedcategories = get_option('blockcountry_categories');
|
307 |
-
if (is_category($blockedcategories) && ((is_array ( $badcountries ) && in_array ( $country, $badcountries ) || (iqblockcountry_validate_ip_in_list($ip_address,$
|
308 |
{
|
309 |
$flagged = TRUE;
|
310 |
}
|
311 |
-
if (iqblockcountry_validate_ip_in_list($ip_address,$
|
312 |
|
313 |
$flagged = FALSE;
|
314 |
}
|
@@ -319,11 +319,11 @@ function iqblockcountry_check($country,$badcountries,$ip_address)
|
|
319 |
if (is_tag() && $blockedtag == "on")
|
320 |
{
|
321 |
$flagged = FALSE;
|
322 |
-
if ((is_array ( $badcountries ) && in_array ( $country, $badcountries ) || (iqblockcountry_validate_ip_in_list($ip_address,$
|
323 |
{
|
324 |
$flagged = TRUE;
|
325 |
}
|
326 |
-
if (iqblockcountry_validate_ip_in_list($ip_address,$
|
327 |
|
328 |
$flagged = FALSE;
|
329 |
}
|
@@ -337,11 +337,11 @@ function iqblockcountry_check($country,$badcountries,$ip_address)
|
|
337 |
if (is_feed() && $blockedfeed == "on")
|
338 |
{
|
339 |
$flagged = FALSE;
|
340 |
-
if ((is_array ( $badcountries ) && in_array ( $country, $badcountries ) || (iqblockcountry_validate_ip_in_list($ip_address,$
|
341 |
{
|
342 |
$flagged = TRUE;
|
343 |
}
|
344 |
-
if (iqblockcountry_validate_ip_in_list($ip_address,$
|
345 |
|
346 |
$flagged = FALSE;
|
347 |
}
|
@@ -399,7 +399,7 @@ function iqblockcountry_CheckCountryBackEnd() {
|
|
399 |
$blocklogin = get_option ( 'blockcountry_blocklogin' );
|
400 |
if ( ((is_user_logged_in()) && ($blocklogin != "on")) || (!(is_user_logged_in())) ) {
|
401 |
|
402 |
-
/* Check ip address against banlist,
|
403 |
if (iqblockcountry_check($country,$badcountries,$ip_address))
|
404 |
{
|
405 |
if (($blockcountry_is_login_page || is_admin() || $blockcountry_is_xmlrpc) && get_option('blockcountry_blockbackend') == 'on')
|
@@ -408,15 +408,15 @@ function iqblockcountry_CheckCountryBackEnd() {
|
|
408 |
if (empty($blocked)) { $blocked = 0; }
|
409 |
$blocked++;
|
410 |
update_option('blockcountry_backendnrblocks', $blocked);
|
411 |
-
global $
|
412 |
if (!get_option('blockcountry_logging'))
|
413 |
{
|
414 |
-
if (!$
|
415 |
{
|
416 |
iqblockcountry_logging($ip_address, $country, "B");
|
417 |
iqblockcountry_debug_logging($ip_address,$country,'BB');
|
418 |
}
|
419 |
-
elseif ($
|
420 |
{
|
421 |
iqblockcountry_logging($ip_address, $country, "T");
|
422 |
iqblockcountry_debug_logging($ip_address,$country,'TB');
|
@@ -502,7 +502,7 @@ function iqblockcountry_CheckCountryFrontEnd() {
|
|
502 |
$blocklogin = get_option ( 'blockcountry_blocklogin' );
|
503 |
if ( ((is_user_logged_in()) && ($blocklogin != "on")) || (!(is_user_logged_in())) ) {
|
504 |
|
505 |
-
/* Check ip address against banlist,
|
506 |
if (iqblockcountry_check($country,$badcountries,$ip_address))
|
507 |
{
|
508 |
$blocked = get_option('blockcountry_frontendnrblocks');
|
143 |
|
144 |
|
145 |
/*
|
146 |
+
* Check country against bad countries, allow list and block list
|
147 |
*/
|
148 |
function iqblockcountry_check($country,$badcountries,$ip_address)
|
149 |
{
|
171 |
$blockedfeed = get_option('blockcountry_blockfeed');
|
172 |
$postid = get_the_ID();
|
173 |
|
174 |
+
global $feblocklistip,$feblocklistiprange4,$feblocklistiprange6,$feallowlistip,$feallowlistiprange4,$feallowlistiprange6;
|
175 |
+
global $beblocklistip,$beblocklistiprange4,$beblocklistiprange6,$beallowlistip,$beallowlistiprange4,$beallowlistiprange6;
|
176 |
|
177 |
$backendbanlistip = unserialize(get_option('blockcountry_backendbanlistip'));
|
178 |
$blockredirect = get_option ( 'blockcountry_redirect');
|
180 |
/* Block if user is in a bad country from frontend or backend. Unblock may happen later */
|
181 |
if (is_array ( $badcountries ) && in_array ( $country, $badcountries )) {
|
182 |
$blocked = TRUE;
|
183 |
+
global $backendblocklistcheck;
|
184 |
+
$backendblocklistcheck = TRUE;
|
185 |
}
|
186 |
|
187 |
global $blockcountry_is_login_page,$blockcountry_is_xmlrpc;
|
188 |
|
189 |
|
190 |
+
/* Check if requested url is not login page. Else check against frontend allow list / block list. */
|
191 |
if (!($blockcountry_is_login_page) && !(is_admin()) && !($blockcountry_is_xmlrpc))
|
192 |
{
|
193 |
+
if (iqblockcountry_validate_ip_in_list($ip_address,$feblocklistiprange4,$feblocklistiprange6,$feblocklistip))
|
194 |
{
|
195 |
$blocked = TRUE;
|
196 |
}
|
197 |
+
if (iqblockcountry_validate_ip_in_list($ip_address,$feallowlistiprange4,$feallowlistiprange6,$feallowlistip))
|
198 |
{
|
199 |
$blocked = FALSE;
|
200 |
}
|
206 |
if (is_array($backendbanlistip) && in_array($ip_address,$backendbanlistip))
|
207 |
{
|
208 |
$blocked = TRUE;
|
209 |
+
global $apiblocklist;
|
210 |
+
$apiblocklist = TRUE;
|
211 |
}
|
212 |
+
if (iqblockcountry_validate_ip_in_list($ip_address,$beblocklistiprange4,$beblocklistiprange6,$beblocklistip)) {
|
213 |
$blocked = TRUE;
|
214 |
}
|
215 |
+
if (iqblockcountry_validate_ip_in_list($ip_address,$beallowlistiprange4,$beallowlistiprange6,$beallowlistip)) {
|
216 |
$blocked = FALSE;
|
217 |
}
|
218 |
if (iqblockcountry_is_adminajax() && get_option('blockcountry_adminajax'))
|
224 |
if ($blockedposttypes == "on")
|
225 |
{
|
226 |
$blockedposttypes = get_option('blockcountry_posttypes');
|
227 |
+
if (is_array($blockedposttypes) && in_array(get_post_type( $postid ), $blockedposttypes) && ((is_array ( $badcountries ) && in_array ( $country, $badcountries ) || (iqblockcountry_validate_ip_in_list($ip_address,$feblocklistiprange4,$feblocklistiprange6,$feblocklistip)))))
|
228 |
{
|
229 |
$blocked = TRUE;
|
230 |
+
if (iqblockcountry_validate_ip_in_list($ip_address,$feallowlistiprange4,$feallowlistiprange6,$feallowlistip)) {
|
231 |
$blocked = FALSE;
|
232 |
}
|
233 |
}
|
240 |
if (is_page() && $blockedpage == "on")
|
241 |
{
|
242 |
$post = get_post();
|
243 |
+
if (is_page($blockedpages) && !empty($blockedpages) && ((is_array ( $badcountries ) && in_array ( $country, $badcountries ) || (iqblockcountry_validate_ip_in_list($ip_address,$feblocklistiprange4,$feblocklistiprange6,$feblocklistip)))))
|
244 |
{
|
245 |
$blocked = TRUE;
|
246 |
+
if (iqblockcountry_validate_ip_in_list($ip_address,$feallowlistiprange4,$feallowlistiprange6,$feallowlistip)) {
|
247 |
$blocked = FALSE;
|
248 |
}
|
249 |
}
|
262 |
{
|
263 |
if (in_array($value,$blockedcategories))
|
264 |
{
|
265 |
+
if (is_single() && ((is_array ( $badcountries ) && in_array ( $country, $badcountries ) || (iqblockcountry_validate_ip_in_list($ip_address,$feblocklistiprange4,$feblocklistiprange6,$feblocklistip)))))
|
266 |
{
|
267 |
$flagged = TRUE;
|
268 |
+
if (iqblockcountry_validate_ip_in_list($ip_address,$feallowlistiprange4,$feallowlistiprange6,$feallowlistip)) {
|
269 |
$flagged = FALSE;
|
270 |
}
|
271 |
}
|
286 |
{
|
287 |
if (in_array($tag->term_id,$blockedtags))
|
288 |
{
|
289 |
+
if (is_single() && ((is_array ( $badcountries ) && in_array ( $country, $badcountries ) || (iqblockcountry_validate_ip_in_list($ip_address,$feblocklistiprange4,$feblocklistiprange6,$feblocklistip)))))
|
290 |
{
|
291 |
$flagged = TRUE;
|
292 |
+
if (iqblockcountry_validate_ip_in_list($ip_address,$feallowlistiprange4,$feallowlistiprange6,$feallowlistip)) {
|
293 |
|
294 |
$flagged = FALSE;
|
295 |
}
|
304 |
{
|
305 |
$flagged = FALSE;
|
306 |
$blockedcategories = get_option('blockcountry_categories');
|
307 |
+
if (is_category($blockedcategories) && ((is_array ( $badcountries ) && in_array ( $country, $badcountries ) || (iqblockcountry_validate_ip_in_list($ip_address,$feblocklistiprange4,$feblocklistiprange6,$feblocklistip)))))
|
308 |
{
|
309 |
$flagged = TRUE;
|
310 |
}
|
311 |
+
if (iqblockcountry_validate_ip_in_list($ip_address,$feallowlistiprange4,$feallowlistiprange6,$feallowlistip)) {
|
312 |
|
313 |
$flagged = FALSE;
|
314 |
}
|
319 |
if (is_tag() && $blockedtag == "on")
|
320 |
{
|
321 |
$flagged = FALSE;
|
322 |
+
if ((is_array ( $badcountries ) && in_array ( $country, $badcountries ) || (iqblockcountry_validate_ip_in_list($ip_address,$feblocklistiprange4,$feblocklistiprange6,$feblocklistip))))
|
323 |
{
|
324 |
$flagged = TRUE;
|
325 |
}
|
326 |
+
if (iqblockcountry_validate_ip_in_list($ip_address,$feallowlistiprange4,$feallowlistiprange6,$feallowlistip)) {
|
327 |
|
328 |
$flagged = FALSE;
|
329 |
}
|
337 |
if (is_feed() && $blockedfeed == "on")
|
338 |
{
|
339 |
$flagged = FALSE;
|
340 |
+
if ((is_array ( $badcountries ) && in_array ( $country, $badcountries ) || (iqblockcountry_validate_ip_in_list($ip_address,$feblocklistiprange4,$feblocklistiprange6,$feblocklistip))))
|
341 |
{
|
342 |
$flagged = TRUE;
|
343 |
}
|
344 |
+
if (iqblockcountry_validate_ip_in_list($ip_address,$feallowlistiprange4,$feallowlistiprange6,$feallowlistip)) {
|
345 |
|
346 |
$flagged = FALSE;
|
347 |
}
|
399 |
$blocklogin = get_option ( 'blockcountry_blocklogin' );
|
400 |
if ( ((is_user_logged_in()) && ($blocklogin != "on")) || (!(is_user_logged_in())) ) {
|
401 |
|
402 |
+
/* Check ip address against banlist, allow list and block list */
|
403 |
if (iqblockcountry_check($country,$badcountries,$ip_address))
|
404 |
{
|
405 |
if (($blockcountry_is_login_page || is_admin() || $blockcountry_is_xmlrpc) && get_option('blockcountry_blockbackend') == 'on')
|
408 |
if (empty($blocked)) { $blocked = 0; }
|
409 |
$blocked++;
|
410 |
update_option('blockcountry_backendnrblocks', $blocked);
|
411 |
+
global $apiblocklist,$backendblocklistcheck,$debughandled;
|
412 |
if (!get_option('blockcountry_logging'))
|
413 |
{
|
414 |
+
if (!$apiblocklist)
|
415 |
{
|
416 |
iqblockcountry_logging($ip_address, $country, "B");
|
417 |
iqblockcountry_debug_logging($ip_address,$country,'BB');
|
418 |
}
|
419 |
+
elseif ($backendblocklistcheck && $apiblocklist)
|
420 |
{
|
421 |
iqblockcountry_logging($ip_address, $country, "T");
|
422 |
iqblockcountry_debug_logging($ip_address,$country,'TB');
|
502 |
$blocklogin = get_option ( 'blockcountry_blocklogin' );
|
503 |
if ( ((is_user_logged_in()) && ($blocklogin != "on")) || (!(is_user_logged_in())) ) {
|
504 |
|
505 |
+
/* Check ip address against banlist, allow list and block list */
|
506 |
if (iqblockcountry_check($country,$badcountries,$ip_address))
|
507 |
{
|
508 |
$blocked = get_option('blockcountry_frontendnrblocks');
|
libs/blockcountry-settings.php
CHANGED
@@ -63,7 +63,7 @@ function iq_missing_db_notice()
|
|
63 |
?>
|
64 |
<div class="notice notice-error">
|
65 |
<h3>iQ Block Country</h3>
|
66 |
-
<p><?php _e('The MaxMind GeoIP2 database does not exist. Please download this file manually or if you wish to use the GeoIP API get an API key from: ', 'iq-block-country'); ?> <a href="https://
|
67 |
<p><?php _e("Please download the database (GeoLite2-Country.tar.gz) from: " , 'iq-block-country'); ?>
|
68 |
<?php _e("If you do not have an account at Maxmind yet for the Geolite2 database sign up for a free account at:", 'iq-block-country'); ?>
|
69 |
<?php echo "<a href=\"" . MAXMINDURL . "\" target=\"_blank\">" . MAXMINDURL . "</a> "; ?>
|
@@ -88,7 +88,7 @@ function iq_missing_dbgeoip2_notice()
|
|
88 |
<div class="notice notice-error">
|
89 |
<h3>iQ Block Country</h3>
|
90 |
<p><?php _e('Please upgrade your old GeoIP database. This database is no longer maintained by MaxMind and everyone should upgrade to the GeoIP2 database.<br />', 'iq-block-country');
|
91 |
-
_e( 'The MaxMind GeoIP2 database does not exist yet . Please download this file manually or if you wish to use the GeoIP API get an API key from: ', 'iq-block-country'); ?> <a href="https://
|
92 |
<p><?php _e("Please download the database (GeoLite2-Country.tar.gz) from: " , 'iq-block-country'); ?>
|
93 |
<?php _e("If you do not have an account at Maxmind yet for the Geolite2 database sign up for a free account at:", 'iq-block-country'); ?>
|
94 |
<?php echo "<a href=\"" . MAXMINDURL . "\" target=\"_blank\">" . MAXMINDURL . "</a> "; ?>
|
@@ -128,7 +128,7 @@ function iq_old_db_notice()
|
|
128 |
?>
|
129 |
<div class="notice notice-warning">
|
130 |
<h3>iQ Block Country</h3>
|
131 |
-
<p><?php _e('The MaxMind GeoIP database is older than 3 months. Please update this file manually or if you wish to use the GeoIP API get an API key from: ', 'iq-block-country'); ?><a href="https://
|
132 |
<p><?php _e("Please download the database (GeoLite2-Country.tar.gz) from MaxMind. " , 'iq-block-country'); ?>
|
133 |
<?php _e("If you do not have an account at Maxmind yet for the Geolite2 database sign up for a free account at:", 'iq-block-country'); ?>
|
134 |
<?php echo "<a href=\"" . MAXMINDURL . "\" target=\"_blank\">" . MAXMINDURL . "</a> "; ?>
|
@@ -240,8 +240,15 @@ function iqblockcountry_set_defaults()
|
|
240 |
if (get_option('blockcountry_header') === FALSE) { update_option('blockcountry_header', 'on'); }
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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'); }
|
@@ -314,8 +321,8 @@ function iqblockcountry_settings_tools() {
|
|
314 |
<input name="ipcheck_nonce" type="hidden" value="<?php echo wp_create_nonce('ipcheck_nonce'); ?>" />
|
315 |
<?php _e('IP Address to check:', 'iq-block-country'); ?> <input type="text" name="ipaddress" lenth="50" />
|
316 |
<?php
|
317 |
-
global $
|
318 |
-
global $
|
319 |
|
320 |
|
321 |
if ( isset($_POST['action']) && $_POST[ 'action' ] == 'ipcheck') {
|
@@ -369,28 +376,28 @@ function iqblockcountry_settings_tools() {
|
|
369 |
}
|
370 |
$backendbanlistip = unserialize(get_option('blockcountry_backendbanlistip'));
|
371 |
if (is_array($backendbanlistip) && in_array($ip_address,$backendbanlistip)) {
|
372 |
-
_e('This IP address is present in the
|
373 |
}
|
374 |
|
375 |
}
|
376 |
-
if (iqblockcountry_validate_ip_in_list($ip_address,$
|
377 |
{
|
378 |
-
_e('This IP address is present in the frontend
|
379 |
echo "<br />";
|
380 |
}
|
381 |
-
if (iqblockcountry_validate_ip_in_list($ip_address,$
|
382 |
{
|
383 |
-
_e('This IP address is present in the frontend
|
384 |
echo "<br />";
|
385 |
}
|
386 |
-
if (iqblockcountry_validate_ip_in_list($ip_address,$
|
387 |
{
|
388 |
-
_e('This IP address is present in the backend
|
389 |
echo "<br />";
|
390 |
}
|
391 |
-
if (iqblockcountry_validate_ip_in_list($ip_address,$
|
392 |
{
|
393 |
-
_e('This IP address is present in the backend
|
394 |
echo "<br />";
|
395 |
}
|
396 |
|
@@ -1262,20 +1269,20 @@ function iqblockcountry_settings_frontend()
|
|
1262 |
|
1263 |
|
1264 |
<tr valign="top">
|
1265 |
-
<th width="30%"><?php _e('Frontend
|
1266 |
<td width="70%">
|
1267 |
<?php
|
1268 |
-
$
|
1269 |
?>
|
1270 |
-
<textarea cols="70" rows="5" name="blockcountry_frontendwhitelist"><?php echo htmlspecialchars($
|
1271 |
</td></tr>
|
1272 |
<tr valign="top">
|
1273 |
-
<th width="30%"><?php _e('Frontend
|
1274 |
<td width="70%">
|
1275 |
<?php
|
1276 |
-
$
|
1277 |
?>
|
1278 |
-
<textarea cols="70" rows="5" name="blockcountry_frontendblacklist"><?php echo htmlspecialchars($
|
1279 |
</td></tr>
|
1280 |
<tr><td></td><td>
|
1281 |
<p class="submit"><input type="submit" class="button-primary"
|
@@ -1392,20 +1399,20 @@ function iqblockcountry_settings_backend()
|
|
1392 |
</td></tr>
|
1393 |
|
1394 |
<tr valign="top">
|
1395 |
-
<th width="30%"><?php _e('Backend
|
1396 |
<td width="70%">
|
1397 |
<?php
|
1398 |
-
$
|
1399 |
?>
|
1400 |
-
<textarea cols="70" rows="5" name="blockcountry_backendwhitelist"><?php echo htmlspecialchars($
|
1401 |
</td></tr>
|
1402 |
<tr valign="top">
|
1403 |
-
<th width="30%"><?php _e('Backend
|
1404 |
<td width="70%">
|
1405 |
<?php
|
1406 |
-
$
|
1407 |
?>
|
1408 |
-
<textarea cols="70" rows="5" name="blockcountry_backendblacklist"><?php echo htmlspecialchars($
|
1409 |
</td></tr>
|
1410 |
<tr><td></td><td>
|
1411 |
<p class="submit"><input type="submit" class="button-primary"
|
@@ -1594,7 +1601,7 @@ if (is_file ( GEOIP2DBFILE ) && (!get_option('blockcountry_geoapikey'))) {
|
|
1594 |
|
1595 |
<tr valign="top">
|
1596 |
<th width="30%"><?php _e('GeoIP API Key:', 'iq-block-country'); ?><br />
|
1597 |
-
<em><?php _e('If for some reason you cannot or do not want to download the MaxMind GeoIP databases you will need an API key for the GeoIP api.<br />You can get an API key from: ', 'iq-block-country'); ?> <a href="https://
|
1598 |
</th>
|
1599 |
<td width="70%">
|
1600 |
<input type="text" size="25" name="blockcountry_geoapikey" value="<?php echo get_option ( 'blockcountry_geoapikey' );?>">
|
@@ -1609,7 +1616,6 @@ if (is_file ( GEOIP2DBFILE ) && (!get_option('blockcountry_geoapikey'))) {
|
|
1609 |
|
1610 |
<input type="radio" name="blockcountry_geoapilocation" value="EU" <?php checked('EU', get_option('blockcountry_geoapilocation'), true); ?>> Europe (Netherlands)<br />
|
1611 |
<input type="radio" name="blockcountry_geoapilocation" value="EU3" <?php checked('EU3', get_option('blockcountry_geoapilocation'), true); ?>> Europe (Germany)<br />
|
1612 |
-
<input type="radio" name="blockcountry_geoapilocation" value="EU4" <?php checked('EU4', get_option('blockcountry_geoapilocation'), true); ?>> Europe (France)<br />
|
1613 |
<input type="radio" name="blockcountry_geoapilocation" value="US" <?php checked('US', get_option('blockcountry_geoapilocation'), true); ?>> United States - New York<br />
|
1614 |
<input type="radio" name="blockcountry_geoapilocation" value="US2" <?php checked('US2', get_option('blockcountry_geoapilocation'), true); ?>> United States - San Francisco<br />
|
1615 |
<input type="radio" name="blockcountry_geoapilocation" value="US3" <?php checked('US3', get_option('blockcountry_geoapilocation'), true); ?>> United States - Miami<br />
|
@@ -1617,7 +1623,7 @@ if (is_file ( GEOIP2DBFILE ) && (!get_option('blockcountry_geoapikey'))) {
|
|
1617 |
</td></tr>
|
1618 |
<tr valign="top">
|
1619 |
<th width="30%"><?php _e('Admin block API Key:', 'iq-block-country'); ?><br />
|
1620 |
-
<em><?php _e('For additional security you can protect your backend from known IP addresses who have made hack attempts at other WordPress sites.<br />You can get more information and an API key from: ', 'iq-block-country'); ?> <a href="https://
|
1621 |
</th>
|
1622 |
<td width="70%">
|
1623 |
<input type="text" size="25" name="blockcountry_apikey" value="<?php echo get_option ( 'blockcountry_apikey' );?>">
|
@@ -1964,15 +1970,6 @@ function iqblockcountry_find_geoip_location()
|
|
1964 |
$infoeu = curl_getinfo($curl);
|
1965 |
curl_close($curl);
|
1966 |
|
1967 |
-
$curl = curl_init();
|
1968 |
-
curl_setopt_array($curl, array(
|
1969 |
-
CURLOPT_URL => 'https://eu4.geoip.webence.nl/test',
|
1970 |
-
CURLOPT_USERAGENT => 'iQ Block Country EU4 location test/' . get_bloginfo('wpurl')
|
1971 |
-
));
|
1972 |
-
$resp = curl_exec($curl);
|
1973 |
-
$infoeu4 = curl_getinfo($curl);
|
1974 |
-
curl_close($curl);
|
1975 |
-
|
1976 |
$curl = curl_init();
|
1977 |
curl_setopt_array($curl, array(
|
1978 |
CURLOPT_URL => 'https://eu3.geoip.webence.nl/test',
|
@@ -1983,7 +1980,7 @@ function iqblockcountry_find_geoip_location()
|
|
1983 |
curl_close($curl);
|
1984 |
|
1985 |
|
1986 |
-
$fastestsite = min($infoeu['total_time'],$
|
1987 |
|
1988 |
if ($infous['total_time'] == $fastestsite)
|
1989 |
{
|
@@ -2001,10 +1998,6 @@ function iqblockcountry_find_geoip_location()
|
|
2001 |
// {
|
2002 |
// update_option('blockcountry_geoapilocation','ASIA');
|
2003 |
// }
|
2004 |
-
elseif ($infoeu4['total_time'] == $fastestsite)
|
2005 |
-
{
|
2006 |
-
update_option('blockcountry_geoapilocation','EU4');
|
2007 |
-
}
|
2008 |
elseif ($infoeu3['total_time'] == $fastestsite)
|
2009 |
{
|
2010 |
update_option('blockcountry_geoapilocation','EU3');
|
@@ -2017,71 +2010,71 @@ function iqblockcountry_find_geoip_location()
|
|
2017 |
}
|
2018 |
|
2019 |
/*
|
2020 |
-
* Get different lists of
|
2021 |
*/
|
2022 |
-
function
|
2023 |
{
|
2024 |
-
$
|
2025 |
-
$
|
2026 |
-
$
|
2027 |
-
$
|
2028 |
|
2029 |
|
2030 |
-
$
|
2031 |
-
$
|
2032 |
-
$
|
2033 |
-
$
|
2034 |
-
$
|
2035 |
-
$
|
2036 |
-
global $
|
2037 |
|
2038 |
-
$
|
2039 |
-
$
|
2040 |
-
$
|
2041 |
-
$
|
2042 |
-
$
|
2043 |
-
$
|
2044 |
-
global $
|
2045 |
|
2046 |
|
2047 |
-
if (preg_match('/;/',$
|
2048 |
{
|
2049 |
-
$
|
2050 |
-
foreach ($
|
2051 |
{
|
2052 |
-
if (iqblockcountry_is_valid_ipv4($ip) || iqblockcountry_is_valid_ipv6($ip)) { $
|
2053 |
-
elseif (iqblockcountry_is_valid_ipv4_cidr($ip)) { $
|
2054 |
-
elseif (iqblockcountry_is_valid_ipv6_cidr($ip)) { $
|
2055 |
}
|
2056 |
}
|
2057 |
-
if (preg_match('/;/',$
|
2058 |
{
|
2059 |
-
$
|
2060 |
-
foreach ($
|
2061 |
{
|
2062 |
-
if (iqblockcountry_is_valid_ipv4($ip) || iqblockcountry_is_valid_ipv6($ip)) { $
|
2063 |
-
elseif (iqblockcountry_is_valid_ipv4_cidr($ip)) { $
|
2064 |
-
elseif (iqblockcountry_is_valid_ipv6_cidr($ip)) { $
|
2065 |
}
|
2066 |
}
|
2067 |
-
if (preg_match('/;/',$
|
2068 |
{
|
2069 |
-
$
|
2070 |
-
foreach ($
|
2071 |
{
|
2072 |
-
if (iqblockcountry_is_valid_ipv4($ip) || iqblockcountry_is_valid_ipv6($ip)) { $
|
2073 |
-
elseif (iqblockcountry_is_valid_ipv4_cidr($ip)) { $
|
2074 |
-
elseif (iqblockcountry_is_valid_ipv6_cidr($ip)) { $
|
2075 |
}
|
2076 |
}
|
2077 |
-
if (preg_match('/;/',$
|
2078 |
{
|
2079 |
-
$
|
2080 |
-
foreach ($
|
2081 |
{
|
2082 |
-
if (iqblockcountry_is_valid_ipv4($ip) || iqblockcountry_is_valid_ipv6($ip)) { $
|
2083 |
-
elseif (iqblockcountry_is_valid_ipv4_cidr($ip)) { $
|
2084 |
-
elseif (iqblockcountry_is_valid_ipv6_cidr($ip)) { $
|
2085 |
}
|
2086 |
}
|
2087 |
|
63 |
?>
|
64 |
<div class="notice notice-error">
|
65 |
<h3>iQ Block Country</h3>
|
66 |
+
<p><?php _e('The MaxMind GeoIP2 database does not exist. Please download this file manually or if you wish to use the GeoIP API get an API key from: ', 'iq-block-country'); ?> <a href="https://webence.nl/geoip-api/" target="_blank">https://webence.nl/geoip-api/</a></p>
|
67 |
<p><?php _e("Please download the database (GeoLite2-Country.tar.gz) from: " , 'iq-block-country'); ?>
|
68 |
<?php _e("If you do not have an account at Maxmind yet for the Geolite2 database sign up for a free account at:", 'iq-block-country'); ?>
|
69 |
<?php echo "<a href=\"" . MAXMINDURL . "\" target=\"_blank\">" . MAXMINDURL . "</a> "; ?>
|
88 |
<div class="notice notice-error">
|
89 |
<h3>iQ Block Country</h3>
|
90 |
<p><?php _e('Please upgrade your old GeoIP database. This database is no longer maintained by MaxMind and everyone should upgrade to the GeoIP2 database.<br />', 'iq-block-country');
|
91 |
+
_e( 'The MaxMind GeoIP2 database does not exist yet . Please download this file manually or if you wish to use the GeoIP API get an API key from: ', 'iq-block-country'); ?> <a href="https://webence.nl/geoip-api/" target="_blank">https://webence.nl/geoip-api/</a></p>
|
92 |
<p><?php _e("Please download the database (GeoLite2-Country.tar.gz) from: " , 'iq-block-country'); ?>
|
93 |
<?php _e("If you do not have an account at Maxmind yet for the Geolite2 database sign up for a free account at:", 'iq-block-country'); ?>
|
94 |
<?php echo "<a href=\"" . MAXMINDURL . "\" target=\"_blank\">" . MAXMINDURL . "</a> "; ?>
|
128 |
?>
|
129 |
<div class="notice notice-warning">
|
130 |
<h3>iQ Block Country</h3>
|
131 |
+
<p><?php _e('The MaxMind GeoIP database is older than 3 months. Please update this file manually or if you wish to use the GeoIP API get an API key from: ', 'iq-block-country'); ?><a href="https://webence.nl/geoip-api/" target="_blank">https://webence.nl/geoip-api/</a></p>
|
132 |
<p><?php _e("Please download the database (GeoLite2-Country.tar.gz) from MaxMind. " , 'iq-block-country'); ?>
|
133 |
<?php _e("If you do not have an account at Maxmind yet for the Geolite2 database sign up for a free account at:", 'iq-block-country'); ?>
|
134 |
<?php echo "<a href=\"" . MAXMINDURL . "\" target=\"_blank\">" . MAXMINDURL . "</a> "; ?>
|
240 |
if (get_option('blockcountry_header') === FALSE) { update_option('blockcountry_header', 'on'); }
|
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 |
+
$tmpbackendallowlist = get_option('blockcountry_backendwhitelist');
|
245 |
+
$ippos = strpos($tmpbackendallowlist,$server_addr);
|
246 |
+
if ($ippos === false)
|
247 |
+
{
|
248 |
+
$tmpbackendallowlist .= $server_addr . ";";
|
249 |
+
update_option('blockcountry_backendwhitelist',$tmpbackendallowlist);
|
250 |
+
}
|
251 |
+
if (get_option('blockcountry_frontendwhitelist') === FALSE || (get_option('blockcountry_frontendwhitelist') == "")) { update_option('blockcountry_frontendwhitelist',$server_addr . ";"); }
|
252 |
iqblockcountry_install_db();
|
253 |
if (get_option('blockcountry_banlist_inverse') === FALSE) { update_option('blockcountry_banlist_inverse' , 'off'); }
|
254 |
if (get_option('blockcountry_backendbanlist_inverse') === FALSE) { update_option('blockcountry_backendbanlist_inverse' , 'off'); }
|
321 |
<input name="ipcheck_nonce" type="hidden" value="<?php echo wp_create_nonce('ipcheck_nonce'); ?>" />
|
322 |
<?php _e('IP Address to check:', 'iq-block-country'); ?> <input type="text" name="ipaddress" lenth="50" />
|
323 |
<?php
|
324 |
+
global $feblocklistip,$feblocklistiprange4,$feblocklistiprange6,$feallowlistip,$feallowlistiprange4,$feallowlistiprange6;
|
325 |
+
global $beblocklistip,$beblocklistiprange4,$beblocklistiprange6,$beallowlistip,$beallowlistiprange4,$beallowlistiprange6;
|
326 |
|
327 |
|
328 |
if ( isset($_POST['action']) && $_POST[ 'action' ] == 'ipcheck') {
|
376 |
}
|
377 |
$backendbanlistip = unserialize(get_option('blockcountry_backendbanlistip'));
|
378 |
if (is_array($backendbanlistip) && in_array($ip_address,$backendbanlistip)) {
|
379 |
+
_e('This IP address is present in the block list.', 'iq-block-country');
|
380 |
}
|
381 |
|
382 |
}
|
383 |
+
if (iqblockcountry_validate_ip_in_list($ip_address,$feblocklistiprange4,$feblocklistiprange6,$feblocklistip))
|
384 |
{
|
385 |
+
_e('This IP address is present in the frontend block list.', 'iq-block-country');
|
386 |
echo "<br />";
|
387 |
}
|
388 |
+
if (iqblockcountry_validate_ip_in_list($ip_address,$feallowlistiprange4,$feallowlistiprange6,$feallowlistip))
|
389 |
{
|
390 |
+
_e('This IP address is present in the frontend allow list.', 'iq-block-country');
|
391 |
echo "<br />";
|
392 |
}
|
393 |
+
if (iqblockcountry_validate_ip_in_list($ip_address,$beblocklistiprange4,$beblocklistiprange6,$beblocklistip))
|
394 |
{
|
395 |
+
_e('This IP address is present in the backend block list.', 'iq-block-country');
|
396 |
echo "<br />";
|
397 |
}
|
398 |
+
if (iqblockcountry_validate_ip_in_list($ip_address,$beallowlistiprange4,$beallowlistiprange6,$beblocklistip))
|
399 |
{
|
400 |
+
_e('This IP address is present in the backend allow list.', 'iq-block-country');
|
401 |
echo "<br />";
|
402 |
}
|
403 |
|
1269 |
|
1270 |
|
1271 |
<tr valign="top">
|
1272 |
+
<th width="30%"><?php _e('Frontend allow list IPv4 and/or IPv6 addresses:', 'iq-block-country'); ?><br /><?php _e('Use a semicolon (;) to separate IP addresses', 'iq-block-country'); ?><br /><?php _e('This field accepts single IP addresses as well as ranges in CIDR format.', 'iq-block-country'); ?></th>
|
1273 |
<td width="70%">
|
1274 |
<?php
|
1275 |
+
$frontendallowlist = get_option ( 'blockcountry_frontendwhitelist' );
|
1276 |
?>
|
1277 |
+
<textarea cols="70" rows="5" name="blockcountry_frontendwhitelist"><?php echo htmlspecialchars($frontendallowlist); ?></textarea>
|
1278 |
</td></tr>
|
1279 |
<tr valign="top">
|
1280 |
+
<th width="30%"><?php _e('Frontend block list IPv4 and/or IPv6 addresses:', 'iq-block-country'); ?><br /><?php _e('Use a semicolon (;) to separate IP addresses', 'iq-block-country'); ?><br /><?php _e('This field accepts single IP addresses as well as ranges in CIDR format.', 'iq-block-country'); ?></th>
|
1281 |
<td width="70%">
|
1282 |
<?php
|
1283 |
+
$frontendblocklist = get_option ( 'blockcountry_frontendblacklist' );
|
1284 |
?>
|
1285 |
+
<textarea cols="70" rows="5" name="blockcountry_frontendblacklist"><?php echo htmlspecialchars($frontendblocklist); ?></textarea>
|
1286 |
</td></tr>
|
1287 |
<tr><td></td><td>
|
1288 |
<p class="submit"><input type="submit" class="button-primary"
|
1399 |
</td></tr>
|
1400 |
|
1401 |
<tr valign="top">
|
1402 |
+
<th width="30%"><?php _e('Backend allow list IPv4 and/or IPv6 addresses:', 'iq-block-country'); ?><br /><?php _e('Use a semicolon (;) to separate IP addresses', 'iq-block-country'); ?><br /><?php _e('This field accepts single IP addresses as well as ranges in CIDR format.', 'iq-block-country'); ?></th>
|
1403 |
<td width="70%">
|
1404 |
<?php
|
1405 |
+
$backendallowlist = get_option ( 'blockcountry_backendwhitelist' );
|
1406 |
?>
|
1407 |
+
<textarea cols="70" rows="5" name="blockcountry_backendwhitelist"><?php echo htmlspecialchars($backendallowlist); ?></textarea>
|
1408 |
</td></tr>
|
1409 |
<tr valign="top">
|
1410 |
+
<th width="30%"><?php _e('Backend block list IPv4 and/or IPv6 addresses:', 'iq-block-country'); ?><br /><?php _e('Use a semicolon (;) to separate IP addresses', 'iq-block-country'); ?><br /><?php _e('This field accepts single IP addresses as well as ranges in CIDR format.', 'iq-block-country'); ?></th>
|
1411 |
<td width="70%">
|
1412 |
<?php
|
1413 |
+
$backendblocklist = get_option ( 'blockcountry_backendblacklist' );
|
1414 |
?>
|
1415 |
+
<textarea cols="70" rows="5" name="blockcountry_backendblacklist"><?php echo htmlspecialchars($backendblocklist); ?></textarea>
|
1416 |
</td></tr>
|
1417 |
<tr><td></td><td>
|
1418 |
<p class="submit"><input type="submit" class="button-primary"
|
1601 |
|
1602 |
<tr valign="top">
|
1603 |
<th width="30%"><?php _e('GeoIP API Key:', 'iq-block-country'); ?><br />
|
1604 |
+
<em><?php _e('If for some reason you cannot or do not want to download the MaxMind GeoIP databases you will need an API key for the GeoIP api.<br />You can get an API key from: ', 'iq-block-country'); ?> <a href="https://webence.nl/geoip-api/" target="_blank">https://webence.nl/geoip-api/</a></em></th>
|
1605 |
</th>
|
1606 |
<td width="70%">
|
1607 |
<input type="text" size="25" name="blockcountry_geoapikey" value="<?php echo get_option ( 'blockcountry_geoapikey' );?>">
|
1616 |
|
1617 |
<input type="radio" name="blockcountry_geoapilocation" value="EU" <?php checked('EU', get_option('blockcountry_geoapilocation'), true); ?>> Europe (Netherlands)<br />
|
1618 |
<input type="radio" name="blockcountry_geoapilocation" value="EU3" <?php checked('EU3', get_option('blockcountry_geoapilocation'), true); ?>> Europe (Germany)<br />
|
|
|
1619 |
<input type="radio" name="blockcountry_geoapilocation" value="US" <?php checked('US', get_option('blockcountry_geoapilocation'), true); ?>> United States - New York<br />
|
1620 |
<input type="radio" name="blockcountry_geoapilocation" value="US2" <?php checked('US2', get_option('blockcountry_geoapilocation'), true); ?>> United States - San Francisco<br />
|
1621 |
<input type="radio" name="blockcountry_geoapilocation" value="US3" <?php checked('US3', get_option('blockcountry_geoapilocation'), true); ?>> United States - Miami<br />
|
1623 |
</td></tr>
|
1624 |
<tr valign="top">
|
1625 |
<th width="30%"><?php _e('Admin block API Key:', 'iq-block-country'); ?><br />
|
1626 |
+
<em><?php _e('For additional security you can protect your backend from known IP addresses who have made hack attempts at other WordPress sites.<br />You can get more information and an API key from: ', 'iq-block-country'); ?> <a href="https://webence.nl/admin-block-api/" target="_blank">https://webence.nl/admin-block-api/</a></em></th>
|
1627 |
</th>
|
1628 |
<td width="70%">
|
1629 |
<input type="text" size="25" name="blockcountry_apikey" value="<?php echo get_option ( 'blockcountry_apikey' );?>">
|
1970 |
$infoeu = curl_getinfo($curl);
|
1971 |
curl_close($curl);
|
1972 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1973 |
$curl = curl_init();
|
1974 |
curl_setopt_array($curl, array(
|
1975 |
CURLOPT_URL => 'https://eu3.geoip.webence.nl/test',
|
1980 |
curl_close($curl);
|
1981 |
|
1982 |
|
1983 |
+
$fastestsite = min($infoeu['total_time'],$infoeu3['total_time'],$infous['total_time'],$infous2['total_time'],$infous3['total_time']);
|
1984 |
|
1985 |
if ($infous['total_time'] == $fastestsite)
|
1986 |
{
|
1998 |
// {
|
1999 |
// update_option('blockcountry_geoapilocation','ASIA');
|
2000 |
// }
|
|
|
|
|
|
|
|
|
2001 |
elseif ($infoeu3['total_time'] == $fastestsite)
|
2002 |
{
|
2003 |
update_option('blockcountry_geoapilocation','EU3');
|
2010 |
}
|
2011 |
|
2012 |
/*
|
2013 |
+
* Get different lists of block and allow list
|
2014 |
*/
|
2015 |
+
function iqblockcountry_get_blockallowlist()
|
2016 |
{
|
2017 |
+
$frontendblocklistip = array(); $frontendblocklist = get_option ( 'blockcountry_frontendblacklist' );
|
2018 |
+
$frontendallowlistip = array(); $frontendallowlist = get_option ( 'blockcountry_frontendwhitelist' );
|
2019 |
+
$backendblocklistip = array(); $backendblocklist = get_option ( 'blockcountry_backendblacklist' );
|
2020 |
+
$backendallowlistip = array(); $backendallowlist = get_option ( 'blockcountry_backendwhitelist' );
|
2021 |
|
2022 |
|
2023 |
+
$feblocklistip = array();
|
2024 |
+
$feblocklistiprange4 = array();
|
2025 |
+
$feblocklistiprange6 = array();
|
2026 |
+
$feallowlistip = array();
|
2027 |
+
$feallowlistiprange4 = array();
|
2028 |
+
$feallowlistiprange6 = array();
|
2029 |
+
global $feblocklistip,$feblocklistiprange4,$feblocklistiprange6,$feallowlistip,$feallowlistiprange4,$feallowlistiprange6;
|
2030 |
|
2031 |
+
$beblocklistip = array();
|
2032 |
+
$beblocklistiprange4 = array();
|
2033 |
+
$beblocklistiprange6 = array();
|
2034 |
+
$beallowlistip = array();
|
2035 |
+
$beallowlistiprange4 = array();
|
2036 |
+
$beallowlistiprange6 = array();
|
2037 |
+
global $beblocklistip,$beblocklistiprange4,$beblocklistiprange6,$beallowlistip,$beallowlistiprange4,$beallowlistiprange6;
|
2038 |
|
2039 |
|
2040 |
+
if (preg_match('/;/',$frontendblocklist))
|
2041 |
{
|
2042 |
+
$frontendblocklistip = explode(";", $frontendblocklist);
|
2043 |
+
foreach ($frontendblocklistip AS $ip)
|
2044 |
{
|
2045 |
+
if (iqblockcountry_is_valid_ipv4($ip) || iqblockcountry_is_valid_ipv6($ip)) { $feblocklistip[] = $ip; }
|
2046 |
+
elseif (iqblockcountry_is_valid_ipv4_cidr($ip)) { $feblocklistiprange4[] = $ip; }
|
2047 |
+
elseif (iqblockcountry_is_valid_ipv6_cidr($ip)) { $feblocklistiprange6[] = $ip; }
|
2048 |
}
|
2049 |
}
|
2050 |
+
if (preg_match('/;/',$frontendallowlist))
|
2051 |
{
|
2052 |
+
$frontendallowlistip = explode(";", $frontendallowlist);
|
2053 |
+
foreach ($frontendallowlistip AS $ip)
|
2054 |
{
|
2055 |
+
if (iqblockcountry_is_valid_ipv4($ip) || iqblockcountry_is_valid_ipv6($ip)) { $feallowlistip[] = $ip; }
|
2056 |
+
elseif (iqblockcountry_is_valid_ipv4_cidr($ip)) { $feallowlistiprange4[] = $ip; }
|
2057 |
+
elseif (iqblockcountry_is_valid_ipv6_cidr($ip)) { $feallowlistiprange6[] = $ip; }
|
2058 |
}
|
2059 |
}
|
2060 |
+
if (preg_match('/;/',$backendblocklist))
|
2061 |
{
|
2062 |
+
$backendblocklistip = explode(";", $backendblocklist);
|
2063 |
+
foreach ($backendblocklistip AS $ip)
|
2064 |
{
|
2065 |
+
if (iqblockcountry_is_valid_ipv4($ip) || iqblockcountry_is_valid_ipv6($ip)) { $beblocklistip[] = $ip; }
|
2066 |
+
elseif (iqblockcountry_is_valid_ipv4_cidr($ip)) { $beblocklistiprange4[] = $ip; }
|
2067 |
+
elseif (iqblockcountry_is_valid_ipv6_cidr($ip)) { $beblocklistiprange6[] = $ip; }
|
2068 |
}
|
2069 |
}
|
2070 |
+
if (preg_match('/;/',$backendallowlist))
|
2071 |
{
|
2072 |
+
$backendallowlistip = explode(";", $backendallowlist);
|
2073 |
+
foreach ($backendallowlistip AS $ip)
|
2074 |
{
|
2075 |
+
if (iqblockcountry_is_valid_ipv4($ip) || iqblockcountry_is_valid_ipv6($ip)) { $beallowlistip[] = $ip; }
|
2076 |
+
elseif (iqblockcountry_is_valid_ipv4_cidr($ip)) { $beallowlistiprange4[] = $ip; }
|
2077 |
+
elseif (iqblockcountry_is_valid_ipv6_cidr($ip)) { $beallowlistiprange6[] = $ip; }
|
2078 |
}
|
2079 |
}
|
2080 |
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== iQ Block Country ===
|
2 |
Contributors: iqpascal
|
3 |
-
Donate link: https://webence.nl/plugins/donate
|
4 |
Tags: spam, block, country, comments, ban, geo, geo blocking, geo ip, block country, block countries, ban countries, ban country, allow list, block list, security
|
5 |
Requires at least: 3.5.2
|
6 |
-
Tested up to: 5.
|
7 |
-
Stable tag: 1.2.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
Requires PHP: 5.6
|
@@ -35,11 +35,6 @@ If you cannot or do not want to download the GeoIP database from Maxmind you can
|
|
35 |
If you want to use the GeoLite database from Maxmind you will have to download the GeoIP database from MaxMind directly and upload it to your site.
|
36 |
The Wordpress license does not allow this plugin to download the MaxMind Geo database for you.
|
37 |
|
38 |
-
Please be aware that although this plugin can help you greatly with reducing the number of 'bad' visitors on your website it is not fool proof and those who really want to visit your site may find a away.
|
39 |
-
This is not a security issue but a simple fact of today. Nobody can guarantee you 100% security as it is a constant battle between the good guys and the bad guys.
|
40 |
-
|
41 |
-
If you are sure your webhosting or yourself does not use any form of caching or proxying we recommend setting the "Override IP information" on the Home tab to REMOTE_ADDR
|
42 |
-
|
43 |
Do you need help with this plugin? Please email support@webence.nl.
|
44 |
|
45 |
= GDPR Information =
|
@@ -97,6 +92,7 @@ This however does not mean this plugin does not work, it just means somebody tri
|
|
97 |
|
98 |
If you are worried this plugin does not work you could try to block your own country or your own ip address and afterwards visit your frontend website and see if it actually works. Also if you have access to the logfiles of the webserver that hosts your website you can see that these visitors are actually denied with a HTTP error 403.
|
99 |
|
|
|
100 |
= This plugin does not work, I blocked a country and still see visitors! =
|
101 |
|
102 |
Well, this plugin does in fact work but is limited to the data MaxMind provides. Also in your statistics software or logfiles you probably will see log entries from countries that you have blocked. See the "How come I still see visitors..." FAQ for that.
|
@@ -241,17 +237,6 @@ be used.
|
|
241 |
|
242 |
== Changelog ==
|
243 |
|
244 |
-
= 1.2.12 =
|
245 |
-
|
246 |
-
* Change: Added/Changed some services.
|
247 |
-
* Bugfix: Security issue fixed which could only be abused by people with administrator rights.
|
248 |
-
|
249 |
-
= 1.2.11 =
|
250 |
-
|
251 |
-
* Change: Minor UI fix
|
252 |
-
* Change: Added some more checking if the visitors IP is an actual IPv4 or IPv6 address
|
253 |
-
* Change: Updated README
|
254 |
-
|
255 |
= 1.2.10 =
|
256 |
|
257 |
* Change: Changed whitelist/blacklist to allow list / block list.
|
1 |
=== iQ Block Country ===
|
2 |
Contributors: iqpascal
|
3 |
+
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, allow list, block list, security
|
5 |
Requires at least: 3.5.2
|
6 |
+
Tested up to: 5.5.1
|
7 |
+
Stable tag: 1.2.10
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
Requires PHP: 5.6
|
35 |
If you want to use the GeoLite database from Maxmind you will have to download the GeoIP database from MaxMind directly and upload it to your site.
|
36 |
The Wordpress license does not allow this plugin to download the MaxMind Geo database for you.
|
37 |
|
|
|
|
|
|
|
|
|
|
|
38 |
Do you need help with this plugin? Please email support@webence.nl.
|
39 |
|
40 |
= GDPR Information =
|
92 |
|
93 |
If you are worried this plugin does not work you could try to block your own country or your own ip address and afterwards visit your frontend website and see if it actually works. Also if you have access to the logfiles of the webserver that hosts your website you can see that these visitors are actually denied with a HTTP error 403.
|
94 |
|
95 |
+
|
96 |
= This plugin does not work, I blocked a country and still see visitors! =
|
97 |
|
98 |
Well, this plugin does in fact work but is limited to the data MaxMind provides. Also in your statistics software or logfiles you probably will see log entries from countries that you have blocked. See the "How come I still see visitors..." FAQ for that.
|
237 |
|
238 |
== Changelog ==
|
239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
= 1.2.10 =
|
241 |
|
242 |
* Change: Changed whitelist/blacklist to allow list / block list.
|