Version Description
- Change: A lot of internal code changes to make it more in line of WordPress Best Practices
Download this release
Release Info
Developer | iqpascal |
Plugin | iQ Block Country |
Version | 1.2.14 |
Comparing to | |
See all releases |
Code changes from version 1.2.13 to 1.2.14
- iq-block-country.php +182 -253
- libs/blockcountry-checks.php +395 -440
- libs/blockcountry-geoip.php +7 -3
- libs/blockcountry-logging.php +58 -56
- libs/blockcountry-search-engines.php +10 -12
- libs/blockcountry-settings.php +1255 -1336
- libs/blockcountry-tracking.php +51 -56
- libs/blockcountry-validation.php +184 -200
- readme.txt +5 -2
iq-block-country.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: iQ Block Country
|
4 |
-
Plugin URI: https://
|
5 |
-
Version: 1.2.
|
6 |
Author: Pascal
|
7 |
-
Author URI: https://
|
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.
|
9 |
License: GPL2
|
10 |
Text Domain: iq-block-country
|
@@ -29,270 +29,202 @@ Domain Path: /lang
|
|
29 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
30 |
*/
|
31 |
|
32 |
-
|
33 |
-
*
|
34 |
* This software is dedicated to my one true love.
|
35 |
* Luvya :)
|
36 |
-
|
37 |
-
*/
|
38 |
|
39 |
-
|
40 |
* Try to make this plugin the first plugin that is loaded.
|
41 |
* Because we output header info we don't want other plugins to send output first.
|
42 |
-
|
43 |
function iqblockcountry_this_plugin_first()
|
44 |
{
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
}
|
55 |
|
56 |
|
57 |
-
|
58 |
* Attempt on output buffering to protect against headers already send mistakes
|
59 |
-
|
60 |
-
function iqblockcountry_buffer()
|
61 |
-
|
|
|
62 |
}
|
63 |
|
64 |
-
|
65 |
* Attempt on output buffering to protect against headers already send mistakes
|
66 |
-
|
67 |
-
function iqblockcountry_buffer_flush()
|
68 |
-
|
|
|
|
|
69 |
}
|
70 |
|
71 |
|
72 |
-
|
73 |
* Localization
|
74 |
-
|
75 |
function iqblockcountry_localization()
|
76 |
{
|
77 |
-
load_plugin_textdomain(
|
78 |
}
|
79 |
|
80 |
/*
|
81 |
* Retrieves the IP address from the HTTP Headers
|
82 |
*/
|
83 |
-
function iqblockcountry_get_ipaddress()
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
|
|
|
|
91 |
|
92 |
-
if (
|
93 |
-
|
94 |
}
|
95 |
-
elseif (
|
96 |
-
|
97 |
}
|
98 |
-
elseif (
|
99 |
-
|
100 |
}
|
101 |
-
elseif (
|
102 |
-
|
103 |
}
|
104 |
-
elseif (
|
105 |
-
|
106 |
}
|
107 |
-
elseif (
|
108 |
-
|
109 |
}
|
110 |
-
elseif (
|
111 |
-
|
112 |
}
|
113 |
-
elseif (
|
114 |
-
|
115 |
}
|
116 |
-
elseif (
|
117 |
-
|
118 |
}
|
119 |
|
120 |
-
$
|
121 |
-
if (isset($
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
if (iqblockcountry_is_valid_ipv4($_SERVER[$ipoverride]) || iqblockcountry_is_valid_ipv6($_SERVER[$ipoverride]))
|
126 |
-
{
|
127 |
-
$ip_address = $_SERVER[$ipoverride];
|
128 |
}
|
129 |
}
|
130 |
}
|
131 |
|
132 |
// Get first ip if ip_address contains multiple addresses
|
133 |
-
$
|
134 |
|
135 |
-
if (iqblockcountry_is_valid_ipv4(trim($
|
136 |
-
|
137 |
-
$ip_address = trim($ips[0]);
|
138 |
}
|
139 |
-
if ($
|
140 |
-
|
141 |
-
|
142 |
-
$ip_address = $_SERVER['REMOTE_ADDR'];
|
143 |
}
|
144 |
else
|
145 |
{
|
146 |
-
$
|
147 |
}
|
148 |
|
149 |
}
|
150 |
-
return $
|
151 |
}
|
152 |
|
153 |
|
154 |
function iqblockcountry_upgrade()
|
155 |
{
|
156 |
/* Check if update is necessary */
|
157 |
-
$
|
158 |
-
update_option('blockcountry_version',
|
159 |
|
160 |
-
if ($
|
161 |
-
{
|
162 |
iqblockcountry_find_geoip_location();
|
163 |
-
$
|
164 |
-
if
|
165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
else
|
167 |
{
|
168 |
-
$
|
169 |
-
$
|
170 |
-
if ($
|
171 |
-
|
172 |
-
|
173 |
-
update_option('blockcountry_backendwhitelist',$tmpbackendallowlist);
|
174 |
}
|
175 |
}
|
176 |
|
177 |
}
|
178 |
-
elseif ($dbversion != "" && version_compare($dbversion, "1.2.5", '<') )
|
179 |
-
{
|
180 |
-
update_option('blockcountry_blockfeed' , 'on');
|
181 |
-
}
|
182 |
-
elseif ($dbversion != "" && version_compare($dbversion, "1.2.3", '<') )
|
183 |
-
{
|
184 |
-
update_option('blockcountry_ipoverride' , 'NONE');
|
185 |
-
}
|
186 |
-
elseif ($dbversion != "" && version_compare($dbversion, "1.1.44", '<') )
|
187 |
-
{
|
188 |
-
$server_addr = array_key_exists( 'SERVER_ADDR', $_SERVER ) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'];
|
189 |
-
if (get_option('blockcountry_frontendwhitelist') === FALSE || (get_option('blockcountry_frontendwhitelist') == "")) { update_option('blockcountry_frontendwhitelist',$server_addr); } iqblockcountry_install_db();
|
190 |
-
|
191 |
-
}
|
192 |
-
elseif ($dbversion != "" && version_compare($dbversion, "1.1.41", '<') )
|
193 |
-
{
|
194 |
-
update_option('blockcountry_daysstatistics',30);
|
195 |
-
}
|
196 |
-
elseif ($dbversion != "" && version_compare($dbversion, "1.1.31", '<') )
|
197 |
-
{
|
198 |
-
if (!get_option('blockcountry_blocktag'))
|
199 |
-
{
|
200 |
-
update_option('blockcountry_blocktag','on');
|
201 |
-
}
|
202 |
-
}
|
203 |
-
elseif ($dbversion != "" && version_compare($dbversion, "1.1.19", '<') )
|
204 |
-
{
|
205 |
-
update_option('blockcountry_blocksearch','on');
|
206 |
-
}
|
207 |
-
if ($dbversion != "" && version_compare($dbversion, "1.1.17", '<') )
|
208 |
-
{
|
209 |
-
delete_option('blockcountry_automaticupdate');
|
210 |
-
delete_option('blockcountry_lastupdate');
|
211 |
-
}
|
212 |
-
elseif ($dbversion != "" && version_compare($dbversion, "1.1.11", '<') )
|
213 |
-
{
|
214 |
-
update_option('blockcountry_nrstatistics', 15);
|
215 |
-
}
|
216 |
-
elseif ($dbversion != "" && version_compare($dbversion, "1.0.10", '<') )
|
217 |
-
{
|
218 |
-
$frontendbanlist = get_option('blockcountry_banlist');
|
219 |
-
update_option('blockcountry_backendbanlist',$frontendbanlist);
|
220 |
-
update_option('blockcountry_backendnrblocks', 0);
|
221 |
-
update_option('blockcountry_frontendnrblocks', 0);
|
222 |
-
update_option('blockcountry_header', 'on');
|
223 |
-
}
|
224 |
-
elseif ($dbversion != "" && version_compare($dbversion, "1.0.10", '=') )
|
225 |
-
{
|
226 |
-
iqblockcountry_install_db();
|
227 |
-
update_option('blockcountry_backendnrblocks', 0);
|
228 |
-
update_option('blockcountry_frontendnrblocks', 0);
|
229 |
-
update_option('blockcountry_header', 'on');
|
230 |
-
}
|
231 |
-
elseif ($dbversion == "")
|
232 |
-
{
|
233 |
-
iqblockcountry_install_db();
|
234 |
-
add_option( "blockcountry_dbversion", DBVERSION );
|
235 |
-
update_option('blockcountry_blockfrontend' , 'on');
|
236 |
-
update_option('blockcountry_version',VERSION);
|
237 |
-
update_option('blockcountry_backendnrblocks', 0);
|
238 |
-
update_option('blockcountry_frontendnrblocks', 0);
|
239 |
-
update_option('blockcountry_header', 'on');
|
240 |
-
$frontendbanlist = get_option('blockcountry_banlist');
|
241 |
-
update_option('blockcountry_backendbanlist',$frontendbanlist);
|
242 |
-
}
|
243 |
-
|
244 |
iqblockcountry_update_db_check();
|
245 |
|
246 |
}
|
247 |
|
248 |
|
249 |
-
|
250 |
* Main plugin works.
|
251 |
-
|
252 |
-
$
|
253 |
define("CHOSENJS", plugins_url('/js/chosen.jquery.js', __FILE__));
|
254 |
define("CHOSENCSS", plugins_url('/chosen.css', __FILE__));
|
255 |
-
define("CHOSENCUSTOM",plugins_url('/js/chosen.custom.js', __FILE__));
|
256 |
-
define("
|
257 |
-
define("
|
258 |
-
define("
|
259 |
-
define("
|
260 |
-
define("
|
261 |
-
define("
|
262 |
-
define("
|
263 |
-
define("
|
264 |
-
define("
|
265 |
-
define("
|
266 |
-
define("
|
267 |
-
define("
|
268 |
-
define("
|
269 |
-
define("
|
270 |
-
define("
|
271 |
-
define("
|
272 |
-
define("
|
273 |
-
define("
|
274 |
-
define("IPLOOKUPURL",'https://geoip.webence.nl/iplookup/iplookup.php');
|
275 |
-
define("VERSION","1.2.10");
|
276 |
-
define("DBVERSION","122");
|
277 |
-
define("PLUGINPATH",plugin_dir_path( __FILE__ ));
|
278 |
|
279 |
|
280 |
|
281 |
/*
|
282 |
* Include libraries
|
283 |
*/
|
284 |
-
require_once
|
285 |
-
require_once
|
286 |
-
require_once
|
287 |
-
require_once
|
288 |
-
require_once
|
289 |
-
require_once
|
290 |
-
require_once
|
291 |
-
require_once('vendor/autoload.php'
|
292 |
-
|
293 |
-
global $
|
294 |
-
$
|
295 |
-
$
|
296 |
|
297 |
$blockcountry_is_login_page = iqblockcountry_is_login_page();
|
298 |
$blockcountry_is_xmlrpc = iqblockcountry_is_xmlrpc();
|
@@ -305,94 +237,91 @@ register_uninstall_hook(__file__, 'iqblockcountry_uninstall');
|
|
305 |
iqblockcountry_upgrade();
|
306 |
|
307 |
/* Clean logging database */
|
308 |
-
|
309 |
iqblockcountry_get_blockallowlist();
|
310 |
|
311 |
-
if (isset($_POST['
|
312 |
-
{
|
313 |
|
314 |
-
$
|
315 |
-
if ($
|
316 |
if(!function_exists('is_user_logged_in')) {
|
317 |
-
include
|
318 |
}
|
319 |
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
331 |
}
|
332 |
-
$iqtempvalue = preg_replace("/[^A-Za-z0-9]/", "", get_bloginfo());
|
333 |
-
$filename = $iqtempvalue . "-iqblockcountry-logging-export.csv";
|
334 |
-
header("Content-type: text/csv");
|
335 |
-
header("Content-Disposition: attachment; filename=$filename");
|
336 |
-
header("Pragma: no-cache");
|
337 |
-
header("Expires: 0");
|
338 |
-
echo $output;
|
339 |
-
exit();
|
340 |
-
}
|
341 |
}
|
342 |
}
|
343 |
|
344 |
-
$
|
345 |
-
$
|
346 |
-
iqblockcountry_debug_logging($
|
347 |
|
348 |
|
349 |
-
function
|
350 |
-
|
351 |
-
|
|
|
352 |
// Scripts
|
353 |
-
wp_enqueue_script(
|
354 |
-
wp_enqueue_script(
|
|
|
355 |
}
|
356 |
}
|
357 |
|
358 |
-
add_action(
|
359 |
|
360 |
|
361 |
/*
|
362 |
* Check first if users want to block the backend.
|
363 |
*/
|
364 |
-
if (($blockcountry_is_login_page || is_admin() || $blockcountry_is_xmlrpc) && get_option('blockcountry_blockbackend') == 'on')
|
365 |
-
|
366 |
-
add_action ( 'init', 'iqblockcountry_checkCountryBackEnd', 1 );
|
367 |
-
}
|
368 |
-
elseif ((!$blockcountry_is_login_page && !is_admin() && !$blockcountry_is_xmlrpc) && get_option('blockcountry_blockfrontend') == 'on')
|
369 |
-
{
|
370 |
-
add_action ( 'wp', 'iqblockcountry_checkCountryFrontEnd', 1 );
|
371 |
}
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
$
|
376 |
-
|
|
|
377 |
|
378 |
}
|
379 |
|
380 |
-
add_action
|
381 |
-
add_action
|
382 |
-
add_filter
|
383 |
-
add_filter
|
384 |
-
add_filter
|
385 |
-
add_filter
|
386 |
-
|
387 |
-
add_filter
|
388 |
-
add_filter
|
389 |
-
add_action
|
390 |
-
add_action
|
391 |
-
if (get_option('blockcountry_buffer') == "on")
|
392 |
-
|
393 |
-
add_action
|
394 |
-
add_action ( 'shutdown', 'iqblockcountry_buffer_flush');
|
395 |
}
|
396 |
|
397 |
|
398 |
-
?>
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: iQ Block Country
|
4 |
+
Plugin URI: https://webence.nl/plugins/iq-block-country-the-wordpress-plugin-that-blocks-countries-for-you/
|
5 |
+
Version: 1.2.14
|
6 |
Author: Pascal
|
7 |
+
Author URI: https://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.
|
9 |
License: GPL2
|
10 |
Text Domain: iq-block-country
|
29 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
30 |
*/
|
31 |
|
32 |
+
/**
|
|
|
33 |
* This software is dedicated to my one true love.
|
34 |
* Luvya :)
|
35 |
+
**/
|
|
|
36 |
|
37 |
+
/**
|
38 |
* Try to make this plugin the first plugin that is loaded.
|
39 |
* Because we output header info we don't want other plugins to send output first.
|
40 |
+
**/
|
41 |
function iqblockcountry_this_plugin_first()
|
42 |
{
|
43 |
+
$iqbc_wp_path_to_this_file = preg_replace('/(.*)plugins\/(.*)$/', WP_PLUGIN_DIR."/$2", __FILE__);
|
44 |
+
$iqbc_this_plugin = plugin_basename(trim($iqbc_wp_path_to_this_file));
|
45 |
+
$iqbc_active_plugins = get_option('active_plugins');
|
46 |
+
$iqbc_this_plugin_key = array_search($iqbc_this_plugin, $iqbc_active_plugins);
|
47 |
+
if ($iqbc_this_plugin_key) { // if it's 0 it's the first plugin already, no need to continue
|
48 |
+
array_splice($iqbc_active_plugins, $iqbc_this_plugin_key, 1);
|
49 |
+
array_unshift($iqbc_active_plugins, $iqbc_this_plugin);
|
50 |
+
update_option('active_plugins', $iqbc_active_plugins);
|
51 |
+
}
|
52 |
}
|
53 |
|
54 |
|
55 |
+
/**
|
56 |
* Attempt on output buffering to protect against headers already send mistakes
|
57 |
+
**/
|
58 |
+
function iqblockcountry_buffer()
|
59 |
+
{
|
60 |
+
ob_start();
|
61 |
}
|
62 |
|
63 |
+
/**
|
64 |
* Attempt on output buffering to protect against headers already send mistakes
|
65 |
+
**/
|
66 |
+
function iqblockcountry_buffer_flush()
|
67 |
+
{
|
68 |
+
if (ob_get_contents()) { ob_end_flush();
|
69 |
+
}
|
70 |
}
|
71 |
|
72 |
|
73 |
+
/**
|
74 |
* Localization
|
75 |
+
**/
|
76 |
function iqblockcountry_localization()
|
77 |
{
|
78 |
+
load_plugin_textdomain('iq-block-country', false, dirname(plugin_basename(__FILE__)) . '/lang');
|
79 |
}
|
80 |
|
81 |
/*
|
82 |
* Retrieves the IP address from the HTTP Headers
|
83 |
*/
|
84 |
+
function iqblockcountry_get_ipaddress()
|
85 |
+
{
|
86 |
+
global $iqbc_ip_address;
|
87 |
+
|
88 |
+
$iqbc_server_address = "";
|
89 |
+
if(isset($_SERVER['SERVER_ADDR']) && (filter_var($_SERVER['SERVER_ADDR'],FILTER_VALIDATE_IP))) {
|
90 |
+
$iqbc_server_address = $_SERVER['SERVER_ADDR'];
|
91 |
+
} elseif(array_key_exists('LOCAL_ADDR', $_SERVER) && (filter_var($_SERVER['LOCAL_ADDR'],FILTER_VALIDATE_IP))) {
|
92 |
+
$iqbc_server_address = $_SERVER['LOCAL_ADDR'];
|
93 |
+
}
|
94 |
|
95 |
+
if (isset($_SERVER['HTTP_CF_CONNECTING_IP']) && filter_var($_SERVER['HTTP_CF_CONNECTING_IP'],FILTER_VALIDATE_IP) ) {
|
96 |
+
$iqbc_ip_address = $_SERVER['HTTP_CF_CONNECTING_IP'];
|
97 |
}
|
98 |
+
elseif (isset($_SERVER['HTTP_X_REAL_IP']) && filter_var($_SERVER['HTTP_X_REAL_IP'],FILTER_VALIDATE_IP) ) {
|
99 |
+
$iqbc_ip_address = $_SERVER['HTTP_X_REAL_IP'];
|
100 |
}
|
101 |
+
elseif (isset($_SERVER['HTTP_X_SUCURI_CLIENTIP']) && filter_var($_SERVER['HTTP_X_SUCURI_CLIENTIP'],FILTER_VALIDATE_IP) ) {
|
102 |
+
$iqbc_ip_address = $_SERVER['HTTP_X_SUCURI_CLIENTIP'];
|
103 |
}
|
104 |
+
elseif (isset($_SERVER['HTTP_INCAP_CLIENT_IP']) && filter_var($_SERVER['HTTP_INCAP_CLIENT_IP'],FILTER_VALIDATE_IP) ) {
|
105 |
+
$iqbc_ip_address = $_SERVER['HTTP_INCAP_CLIENT_IP'];
|
106 |
}
|
107 |
+
elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && filter_var($_SERVER['HTTP_X_FORWARDED_FOR'],FILTER_VALIDATE_IP)) {
|
108 |
+
$iqbc_ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
109 |
}
|
110 |
+
elseif (isset($_SERVER['HTTP_X_FORWARDED']) && filter_var($_SERVER['HTTP_X_FORWARDED'],FILTER_VALIDATE_IP)) {
|
111 |
+
$iqbc_ip_address = $_SERVER['HTTP_X_FORWARDED'];
|
112 |
}
|
113 |
+
elseif (isset($_SERVER['HTTP_CLIENT_IP']) && filter_var($_SERVER['HTTP_CLIENT_IP'],FILTER_VALIDATE_IP) ) {
|
114 |
+
$iqbc_ip_address = $_SERVER['HTTP_CLIENT_IP'];
|
115 |
}
|
116 |
+
elseif (isset($_SERVER['HTTP_FORWARDED']) && filter_var($_SERVER['HTTP_FORWARDED'],FILTER_VALIDATE_IP)) {
|
117 |
+
$iqbc_ip_address = $_SERVER['HTTP_FORWARDED'];
|
118 |
}
|
119 |
+
elseif (isset($_SERVER['REMOTE_ADDR']) && filter_var($_SERVER['REMOTE_ADDR'],FILTER_VALIDATE_IP) ) {
|
120 |
+
$iqbc_ip_address = $_SERVER['REMOTE_ADDR'];
|
121 |
}
|
122 |
|
123 |
+
$iqbc_ipoverride = get_option('blockcountry_ipoverride');
|
124 |
+
if (isset($iqbc_ipoverride) && (!empty($iqbc_ipoverride) && ($iqbc_ipoverride != "NONE") )) {
|
125 |
+
if (isset($_SERVER[$iqbc_ipoverride]) && !empty($_SERVER[$iqbc_ipoverride])) {
|
126 |
+
if (iqblockcountry_is_valid_ipv4($_SERVER[$iqbc_ipoverride]) || iqblockcountry_is_valid_ipv6($_SERVER[$iqbc_ipoverride])) {
|
127 |
+
$iqbc_ip_address = $_SERVER[$iqbc_ipoverride];
|
|
|
|
|
|
|
128 |
}
|
129 |
}
|
130 |
}
|
131 |
|
132 |
// Get first ip if ip_address contains multiple addresses
|
133 |
+
$iqbc_ips = explode(',', $iqbc_ip_address);
|
134 |
|
135 |
+
if (iqblockcountry_is_valid_ipv4(trim($iqbc_ips[0])) || iqblockcountry_is_valid_ipv6(trim($iqbc_ips[0]))) {
|
136 |
+
$iqbc_ip_address = trim($iqbc_ips[0]);
|
|
|
137 |
}
|
138 |
+
if ($iqbc_ip_address == $iqbc_server_address) {
|
139 |
+
if (isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR']) && filter_var($_SERVER['REMOTE_ADDR'],FILTER_VALIDATE_IP) ) {
|
140 |
+
$iqbc_ip_address = $_SERVER['REMOTE_ADDR'];
|
|
|
141 |
}
|
142 |
else
|
143 |
{
|
144 |
+
$iqbc_ip_address = "0.0.0.0";
|
145 |
}
|
146 |
|
147 |
}
|
148 |
+
return $iqbc_ip_address;
|
149 |
}
|
150 |
|
151 |
|
152 |
function iqblockcountry_upgrade()
|
153 |
{
|
154 |
/* Check if update is necessary */
|
155 |
+
$iqbc_dbversion = get_option('blockcountry_version');
|
156 |
+
update_option('blockcountry_version', IQDBVERSION);
|
157 |
|
158 |
+
if ($iqbc_dbversion != "" && version_compare($iqbc_dbversion, "1.2.10", '<') ) {
|
|
|
159 |
iqblockcountry_find_geoip_location();
|
160 |
+
$iqbc_server_addr = "";
|
161 |
+
if(isset($_SERVER['SERVER_ADDR']) && (filter_var($_SERVER['SERVER_ADDR'],FILTER_VALIDATE_IP))) {
|
162 |
+
$iqbc_server_addr = $_SERVER['SERVER_ADDR'];
|
163 |
+
} elseif(array_key_exists('LOCAL_ADDR', $_SERVER) && (filter_var($_SERVER['LOCAL_ADDR'],FILTER_VALIDATE_IP))) {
|
164 |
+
$iqbc_server_addr = $_SERVER['LOCAL_ADDR'];
|
165 |
+
}
|
166 |
+
|
167 |
+
if (get_option('blockcountry_backendwhitelist') === false || (get_option('blockcountry_backendwhitelist') == "")) { update_option('blockcountry_backendwhitelist', $iqbc_server_addr . ";");
|
168 |
+
}
|
169 |
else
|
170 |
{
|
171 |
+
$iqbc_tmpbackendallowlist = get_option('blockcountry_backendwhitelist');
|
172 |
+
$iqbc_ippos = strpos($iqbc_tmpbackendallowlist, $iqbc_server_addr);
|
173 |
+
if ($iqbc_ippos === false) {
|
174 |
+
$iqbc_tmpbackendallowlist .= $iqbc_server_addr . ";";
|
175 |
+
update_option('blockcountry_backendwhitelist', $iqbc_tmpbackendallowlist);
|
|
|
176 |
}
|
177 |
}
|
178 |
|
179 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
iqblockcountry_update_db_check();
|
181 |
|
182 |
}
|
183 |
|
184 |
|
185 |
+
/**
|
186 |
* Main plugin works.
|
187 |
+
**/
|
188 |
+
$iqbc_upload_dir = wp_upload_dir();
|
189 |
define("CHOSENJS", plugins_url('/js/chosen.jquery.js', __FILE__));
|
190 |
define("CHOSENCSS", plugins_url('/chosen.css', __FILE__));
|
191 |
+
define("CHOSENCUSTOM", plugins_url('/js/chosen.custom.js', __FILE__));
|
192 |
+
define("IQBCMAXMINDURL", "https://dev.maxmind.com/geoip/geoip2/geolite2/");
|
193 |
+
define("IQBCGEOIP2DBFILE", $iqbc_upload_dir['basedir'] . "/GeoLite2-Country.mmdb");
|
194 |
+
define("IQBCTRACKINGURL", "https://tracking.webence.nl/iq-block-country-tracking.php");
|
195 |
+
define("IQBCBANLISTRETRIEVEURL", "https://eu.adminblock.webence.nl/iq-block-country-retrieve.php");
|
196 |
+
define("GEOIPAPIURL", "https://eu.geoip.webence.nl/geoipapi.php");
|
197 |
+
define("GEOIPAPIURLEU2", "https://eu2.geoip.webence.nl/geoipapi.php");
|
198 |
+
define("GEOIPAPIURLEU3", "https://eu3.geoip.webence.nl/geoipapi.php");
|
199 |
+
define("GEOIPAPIURLEU4", "https://eu4.geoip.webence.nl/geoipapi.php");
|
200 |
+
define("GEOIPAPIURLUS", "https://us.geoip.webence.nl/geoipapi.php");
|
201 |
+
define("GEOIPAPIURLUS2", "https://us2.geoip.webence.nl/geoipapi.php");
|
202 |
+
define("GEOIPAPIURLUS3", "https://us3.geoip.webence.nl/geoipapi.php");
|
203 |
+
define("GEOIPAPIURLASIA", "https://asia.geoip.webence.nl/geoipapi.php");
|
204 |
+
define("GEOIPAPICHECKURL", "https://eu.geoip.webence.nl/geoipapi-keycheck.php");
|
205 |
+
define("GEOIPAPICHECKUSAGEURL", "https://eu.geoip.webence.nl/geoipapi-usage.php");
|
206 |
+
define("ADMINAPICHECKURL", "https://tracking.webence.nl/adminapi-keycheck.php");
|
207 |
+
define("IQDBVERSION", "1.2.15");
|
208 |
+
define("IQDBDBVERSION", "122");
|
209 |
+
define("IQBCPLUGINPATH", plugin_dir_path(__FILE__));
|
|
|
|
|
|
|
|
|
210 |
|
211 |
|
212 |
|
213 |
/*
|
214 |
* Include libraries
|
215 |
*/
|
216 |
+
require_once 'libs/blockcountry-geoip.php';
|
217 |
+
require_once 'libs/blockcountry-checks.php';
|
218 |
+
require_once 'libs/blockcountry-settings.php';
|
219 |
+
require_once 'libs/blockcountry-validation.php';
|
220 |
+
require_once 'libs/blockcountry-logging.php';
|
221 |
+
require_once 'libs/blockcountry-tracking.php';
|
222 |
+
require_once 'libs/blockcountry-search-engines.php';
|
223 |
+
require_once dirname(__FILE__) . '/vendor/autoload.php';
|
224 |
+
|
225 |
+
global $iqbc_apiblocklist;
|
226 |
+
$iqbc_apiblocklist = false;
|
227 |
+
$iqbc_backendblocklistcheck = false;
|
228 |
|
229 |
$blockcountry_is_login_page = iqblockcountry_is_login_page();
|
230 |
$blockcountry_is_xmlrpc = iqblockcountry_is_xmlrpc();
|
237 |
iqblockcountry_upgrade();
|
238 |
|
239 |
/* Clean logging database */
|
240 |
+
iqblockcountry_clean_db();
|
241 |
iqblockcountry_get_blockallowlist();
|
242 |
|
243 |
+
if (isset($_POST['iqbc_action'])) {
|
|
|
244 |
|
245 |
+
$iqbc_iqaction = filter_var($_POST['iqbc_action'], FILTER_SANITIZE_STRING);
|
246 |
+
if ($iqbc_iqaction == 'iqbc_csvoutput') {
|
247 |
if(!function_exists('is_user_logged_in')) {
|
248 |
+
include ABSPATH . "wp-includes/pluggable.php";
|
249 |
}
|
250 |
|
251 |
+
if (is_user_logged_in() && is_admin() && check_admin_referer('iqbc_iqblockcountrycsv')) {
|
252 |
+
global $wpdb;
|
253 |
+
$iqbc_output = "";
|
254 |
+
$iqbc_table_name = $wpdb->prefix . "iqblock_logging";
|
255 |
+
$iqbc_format = get_option('date_format') . ' ' . get_option('time_format');
|
256 |
+
$iqbc_sql = "DELETE FROM " . $iqbc_table_name . " WHERE `datetime` < DATE_SUB(NOW(), INTERVAL 14 DAY);";
|
257 |
+
|
258 |
+
foreach ($wpdb->get_results("SELECT * FROM $iqbc_table_name ORDER BY datetime ASC") as $iqbc_row)
|
259 |
+
{
|
260 |
+
$iqbc_datetime = strtotime($iqbc_row->datetime);
|
261 |
+
$iqbc_mysqldate = date($iqbc_format, $iqbc_datetime);
|
262 |
+
$iqbc_output .= '"' . $iqbc_mysqldate . '"' . ';"' . $iqbc_row->ipaddress . '";"' . $iqbc_row->url . '"'. "\n";
|
263 |
+
}
|
264 |
+
$iqbc_iqtempvalue = preg_replace("/[^A-Za-z0-9]/", "", get_bloginfo());
|
265 |
+
$iqbc_filename = $iqbc_iqtempvalue . "-iqblockcountry-logging-export.csv";
|
266 |
+
header("Content-type: text/csv");
|
267 |
+
header("Content-Disposition: attachment; filename=$iqbc_filename");
|
268 |
+
header("Pragma: no-cache");
|
269 |
+
header("Expires: 0");
|
270 |
+
echo $iqbc_output;
|
271 |
+
exit();
|
272 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
}
|
274 |
}
|
275 |
|
276 |
+
$iqbc_ip_address = iqblockcountry_get_ipaddress();
|
277 |
+
$iqbc_country = iqblockcountry_check_ipaddress($iqbc_ip_address);
|
278 |
+
iqblockcountry_debug_logging($iqbc_ip_address, $iqbc_country, '');
|
279 |
|
280 |
|
281 |
+
function iqbc_add_my_scripts()
|
282 |
+
{
|
283 |
+
$iqbc_iqscreen = get_current_screen();
|
284 |
+
if ($iqbc_iqscreen->id == 'settings_page_iq-block-country/libs/blockcountry-settings' ) {
|
285 |
// Scripts
|
286 |
+
wp_enqueue_script('chosen', CHOSENJS, array( 'jquery' ), false, true);
|
287 |
+
wp_enqueue_script('custom', CHOSENCUSTOM, array( 'jquery', 'chosen' ), false, true);
|
288 |
+
wp_enqueue_style( 'chosenstylecss', CHOSENCSS );
|
289 |
}
|
290 |
}
|
291 |
|
292 |
+
add_action('admin_enqueue_scripts', 'iqbc_add_my_scripts');
|
293 |
|
294 |
|
295 |
/*
|
296 |
* Check first if users want to block the backend.
|
297 |
*/
|
298 |
+
if (($blockcountry_is_login_page || is_admin() || $blockcountry_is_xmlrpc) && get_option('blockcountry_blockbackend') == 'on') {
|
299 |
+
add_action('init', 'iqblockcountry_checkCountryBackEnd', 1);
|
|
|
|
|
|
|
|
|
|
|
300 |
}
|
301 |
+
elseif ((!$blockcountry_is_login_page && !is_admin() && !$blockcountry_is_xmlrpc) && get_option('blockcountry_blockfrontend') == 'on') {
|
302 |
+
add_action('wp', 'iqblockcountry_checkCountryFrontEnd', 1);
|
303 |
+
} else {
|
304 |
+
$iqbc_ip_address = iqblockcountry_get_ipaddress();
|
305 |
+
$iqbc_country = iqblockcountry_check_ipaddress($iqbc_ip_address);
|
306 |
+
iqblockcountry_debug_logging($iqbc_ip_address, $iqbc_country, 'NH');
|
307 |
|
308 |
}
|
309 |
|
310 |
+
add_action('admin_init', 'iqblockcountry_localization');
|
311 |
+
add_action('admin_menu', 'iqblockcountry_create_menu');
|
312 |
+
add_filter('update_option_blockcountry_tracking', 'iqblockcountry_schedule_tracking', 10, 2);
|
313 |
+
add_filter('add_option_blockcountry_tracking', 'iqblockcountry_schedule_tracking', 10, 2);
|
314 |
+
add_filter('update_option_blockcountry_apikey', 'iqblockcountry_schedule_retrieving', 10, 2);
|
315 |
+
add_filter('add_option_blockcountry_apikey', 'iqblockcountry_schedule_retrieving', 10, 2);
|
316 |
+
|
317 |
+
add_filter('update_option_blockcountry_debuglogging', 'iqblockcountry_blockcountry_debuglogging', 10, 2);
|
318 |
+
add_filter('add_option_blockcountry_debuglogging', 'iqblockcountry_blockcountry_debuglogging', 10, 2);
|
319 |
+
add_action('blockcountry_tracking', 'iqblockcountry_tracking');
|
320 |
+
add_action('blockcountry_retrievebanlist', 'iqblockcountry_tracking_retrieve_xml');
|
321 |
+
if (get_option('blockcountry_buffer') == "on") {
|
322 |
+
add_action('init', 'iqblockcountry_buffer', 1);
|
323 |
+
add_action('shutdown', 'iqblockcountry_buffer_flush');
|
|
|
324 |
}
|
325 |
|
326 |
|
327 |
+
?>
|
libs/blockcountry-checks.php
CHANGED
@@ -1,378 +1,328 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
function iqblockcountry_check_ipaddress($
|
5 |
{
|
6 |
-
if (!class_exists('GeoIP'))
|
7 |
-
|
8 |
-
include_once("geoip.inc");
|
9 |
}
|
10 |
|
11 |
-
if (get_option('blockcountry_geoapikey'))
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
}
|
26 |
-
catch(Exception $e) {
|
27 |
-
$country = "FALSE";
|
28 |
-
}
|
29 |
}
|
30 |
}
|
31 |
|
32 |
}
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
$ipv4 = FALSE;
|
37 |
-
$ipv6 = FALSE;
|
38 |
-
if (iqblockcountry_is_valid_ipv4($ip_address)) { $ipv4 = TRUE; }
|
39 |
-
if (iqblockcountry_is_valid_ipv6($ip_address)) { $ipv6 = TRUE; }
|
40 |
-
|
41 |
-
if ($ipv4)
|
42 |
-
{
|
43 |
-
$gi = geoip_open ( IPV4DBFILE, GEOIP_STANDARD );
|
44 |
-
$country = geoip_country_code_by_addr ( $gi, $ip_address );
|
45 |
-
geoip_close ( $gi );
|
46 |
-
}
|
47 |
-
elseif ($ipv6)
|
48 |
-
{
|
49 |
-
if (is_file ( IPV6DBFILE )) {
|
50 |
-
$gi = geoip_open(IPV6DBFILE,GEOIP_STANDARD);
|
51 |
-
$country = geoip_country_code_by_addr_v6 ( $gi, $ip_address );
|
52 |
-
geoip_close($gi);
|
53 |
-
}
|
54 |
-
else {
|
55 |
-
$country = 'ipv6';
|
56 |
-
}
|
57 |
-
}
|
58 |
-
else { $country = "Unknown"; }
|
59 |
-
}
|
60 |
-
else { $country = "Unknown"; }
|
61 |
|
62 |
-
if (empty($
|
63 |
-
|
64 |
-
$country = "Unknown";
|
65 |
}
|
66 |
|
67 |
-
return $
|
68 |
}
|
69 |
|
70 |
/*
|
71 |
* iQ Block Retrieve XML file for API blocking
|
72 |
*/
|
73 |
-
function iqblockcountry_retrieve_geoipapi($
|
74 |
{
|
75 |
-
|
76 |
-
{
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
{
|
101 |
-
$url = GEOIPAPIURLEU4;
|
102 |
-
}
|
103 |
-
if (get_option('blockcountry_geoapilocation') == "ASIA")
|
104 |
-
{
|
105 |
-
$url = GEOIPAPIURLASIA;
|
106 |
-
}
|
107 |
|
108 |
-
|
109 |
-
$
|
110 |
array(
|
111 |
'body' => array(
|
112 |
'api-key' => get_option('blockcountry_geoapikey'),
|
113 |
-
'ipaddress' => $
|
114 |
|
115 |
)
|
116 |
)
|
117 |
);
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
{
|
127 |
-
if (strpos($xml->error, 'License expired on ') !== false) {
|
128 |
-
update_option('blockcountry_geoapikey','');
|
129 |
-
return "Expired";
|
130 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
}
|
132 |
-
else { return "Unknown"; }
|
133 |
}
|
134 |
-
|
135 |
-
|
136 |
}
|
137 |
-
else return "Unknown";
|
138 |
-
}
|
139 |
-
else
|
140 |
-
{ return "Invalid"; }
|
141 |
}
|
142 |
|
143 |
|
144 |
|
145 |
-
|
146 |
* Check country against bad countries, allow list and block list
|
147 |
-
|
148 |
-
function iqblockcountry_check($
|
149 |
{
|
150 |
/* Set default blocked status and get all options */
|
151 |
-
$
|
152 |
-
$
|
153 |
-
//$
|
154 |
-
$
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
$blockedpages = array_diff($all_pages, $pagesbanlist);
|
163 |
-
} else {
|
164 |
-
$blockedpages = $pagesbanlist;
|
165 |
}
|
|
|
|
|
|
|
|
|
166 |
|
167 |
-
$
|
168 |
-
$
|
169 |
-
$
|
170 |
-
$
|
171 |
-
$
|
172 |
-
$
|
173 |
|
174 |
-
global $
|
175 |
-
global $
|
176 |
|
177 |
-
$
|
178 |
-
$
|
179 |
|
180 |
/* Block if user is in a bad country from frontend or backend. Unblock may happen later */
|
181 |
-
if (is_array
|
182 |
-
$
|
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 allow list / block list. */
|
191 |
-
if (!($blockcountry_is_login_page) && !(is_admin()) && !($blockcountry_is_xmlrpc))
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
{
|
199 |
-
$blocked = FALSE;
|
200 |
-
}
|
201 |
}
|
202 |
|
203 |
|
204 |
-
if ($blockcountry_is_login_page || is_admin() || $blockcountry_is_xmlrpc)
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
$
|
209 |
-
global $apiblocklist;
|
210 |
-
$apiblocklist = TRUE;
|
211 |
}
|
212 |
-
if (iqblockcountry_validate_ip_in_list($
|
213 |
-
$
|
214 |
-
|
215 |
-
if (iqblockcountry_validate_ip_in_list($
|
216 |
-
$
|
217 |
-
|
218 |
-
if (iqblockcountry_is_adminajax() && get_option('blockcountry_adminajax'))
|
219 |
-
|
220 |
-
$blocked = FALSE;
|
221 |
}
|
222 |
}
|
223 |
|
224 |
-
if ($
|
225 |
-
|
226 |
-
$
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
if (iqblockcountry_validate_ip_in_list($ip_address,$feallowlistiprange4,$feallowlistiprange6,$feallowlistip)) {
|
231 |
-
$blocked = FALSE;
|
232 |
}
|
233 |
}
|
234 |
else
|
235 |
{
|
236 |
-
$
|
237 |
}
|
238 |
}
|
239 |
|
240 |
-
if (is_page() && $
|
241 |
-
|
242 |
-
$
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
if (iqblockcountry_validate_ip_in_list($ip_address,$feallowlistiprange4,$feallowlistiprange6,$feallowlistip)) {
|
247 |
-
$blocked = FALSE;
|
248 |
}
|
249 |
}
|
250 |
else
|
251 |
{
|
252 |
-
$
|
253 |
}
|
254 |
}
|
255 |
-
if (is_single() && $
|
256 |
-
|
257 |
-
$
|
258 |
-
|
259 |
-
$
|
260 |
-
$
|
261 |
-
foreach ($
|
262 |
{
|
263 |
-
if (in_array($
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
if (iqblockcountry_validate_ip_in_list($ip_address,$feallowlistiprange4,$feallowlistiprange6,$feallowlistip)) {
|
269 |
-
$flagged = FALSE;
|
270 |
}
|
271 |
}
|
272 |
}
|
273 |
}
|
274 |
-
if ($
|
|
|
|
|
275 |
}
|
276 |
|
277 |
-
if (is_single() && $
|
278 |
-
|
279 |
-
$
|
280 |
-
$
|
281 |
-
|
282 |
-
$
|
283 |
-
if (empty($
|
284 |
-
|
285 |
-
|
|
|
286 |
{
|
287 |
-
if (in_array($
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
$flagged = TRUE;
|
292 |
-
if (iqblockcountry_validate_ip_in_list($ip_address,$feallowlistiprange4,$feallowlistiprange6,$feallowlistip)) {
|
293 |
|
294 |
-
$
|
295 |
}
|
296 |
}
|
297 |
}
|
298 |
}
|
299 |
-
if ($
|
|
|
|
|
300 |
}
|
301 |
|
302 |
|
303 |
-
if (is_category() && $
|
304 |
-
|
305 |
-
$
|
306 |
-
$
|
307 |
-
|
308 |
-
{
|
309 |
-
$flagged = TRUE;
|
310 |
}
|
311 |
-
if (iqblockcountry_validate_ip_in_list($
|
312 |
|
313 |
-
$
|
|
|
|
|
|
|
314 |
}
|
315 |
-
if ($flagged) { $blocked = TRUE; } else { $blocked = FALSE; }
|
316 |
}
|
317 |
|
318 |
|
319 |
-
if (is_tag() && $
|
320 |
-
|
321 |
-
$
|
322 |
-
|
323 |
-
{
|
324 |
-
$flagged = TRUE;
|
325 |
}
|
326 |
-
if (iqblockcountry_validate_ip_in_list($
|
327 |
|
328 |
-
$
|
|
|
|
|
|
|
329 |
}
|
330 |
-
if ($flagged) { $blocked = TRUE; } else { $blocked = FALSE; }
|
331 |
}
|
332 |
-
elseif (is_tag() && $
|
333 |
-
|
334 |
-
$blocked = FALSE;
|
335 |
}
|
336 |
|
337 |
-
if (is_feed() && $
|
338 |
-
|
339 |
-
$
|
340 |
-
|
341 |
-
{
|
342 |
-
$flagged = TRUE;
|
343 |
}
|
344 |
-
if (iqblockcountry_validate_ip_in_list($
|
345 |
|
346 |
-
$
|
|
|
|
|
|
|
347 |
}
|
348 |
-
if ($flagged) { $blocked = TRUE; } else { $blocked = FALSE; }
|
349 |
}
|
350 |
-
elseif (is_feed() && $
|
351 |
-
|
352 |
-
$blocked = FALSE;
|
353 |
}
|
354 |
|
355 |
-
if (is_home() && (get_option('blockcountry_blockhome')) ==
|
356 |
-
|
357 |
-
$blocked = FALSE;
|
358 |
}
|
359 |
-
if (is_page($
|
360 |
-
|
361 |
-
$blocked = FALSE;
|
362 |
}
|
363 |
|
364 |
-
$
|
365 |
-
if (!$blockcountry_is_login_page && isset
|
366 |
-
|
367 |
-
$blocked = FALSE;
|
368 |
}
|
369 |
|
370 |
-
if (is_search() && (get_option('blockcountry_blocksearch')) ==
|
371 |
-
|
372 |
-
$blocked = FALSE;
|
373 |
}
|
374 |
|
375 |
-
return $
|
376 |
}
|
377 |
|
378 |
/*
|
@@ -380,105 +330,99 @@ function iqblockcountry_check($country,$badcountries,$ip_address)
|
|
380 |
* Does the real check of visitor IP against MaxMind database or the GeoAPI
|
381 |
*
|
382 |
*/
|
383 |
-
function iqblockcountry_CheckCountryBackEnd()
|
384 |
-
|
385 |
-
$
|
|
|
386 |
global $blockcountry_is_login_page,$blockcountry_is_xmlrpc;
|
387 |
-
if (($blockcountry_is_login_page || is_admin() || $blockcountry_is_xmlrpc) && get_option('blockcountry_blockbackend') == 'on')
|
388 |
-
|
389 |
-
$
|
390 |
-
|
391 |
-
if (get_option(
|
392 |
-
$
|
393 |
-
$
|
394 |
} else {
|
395 |
-
$
|
396 |
}
|
397 |
}
|
398 |
|
399 |
-
$
|
400 |
-
if (
|
401 |
|
402 |
/* Check ip address against banlist, allow list and block list */
|
403 |
-
if (iqblockcountry_check($
|
404 |
-
|
405 |
-
|
406 |
-
{
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
413 |
{
|
414 |
-
|
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');
|
423 |
-
}
|
424 |
-
else
|
425 |
-
{
|
426 |
-
iqblockcountry_logging($ip_address, $country, "A");
|
427 |
-
iqblockcountry_debug_logging($ip_address,$country,'AB');
|
428 |
-
}
|
429 |
}
|
430 |
}
|
431 |
-
|
|
|
432 |
{
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
}
|
442 |
}
|
|
|
443 |
|
444 |
|
445 |
-
|
446 |
-
$
|
447 |
-
$
|
448 |
-
$
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
header("Expires: Sat, 26 Jul 2012 05:00:00 GMT");
|
456 |
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
header("Location: $redirecturl");
|
467 |
-
}
|
468 |
// Display block message
|
469 |
-
print "$
|
470 |
|
471 |
|
472 |
-
|
473 |
-
|
474 |
else
|
475 |
{
|
476 |
-
iqblockcountry_debug_logging($
|
477 |
}
|
478 |
}
|
479 |
else
|
480 |
{
|
481 |
-
iqblockcountry_debug_logging($
|
482 |
}
|
483 |
}
|
484 |
|
@@ -487,177 +431,188 @@ function iqblockcountry_CheckCountryBackEnd() {
|
|
487 |
* Does the real check of visitor IP against MaxMind database or the GeoAPI FrontEnd
|
488 |
*
|
489 |
*/
|
490 |
-
function iqblockcountry_CheckCountryFrontEnd()
|
491 |
-
|
492 |
-
$
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
|
|
|
|
501 |
|
502 |
-
$
|
503 |
-
if (
|
504 |
|
505 |
/* Check ip address against banlist, allow list and block list */
|
506 |
-
if (iqblockcountry_check($
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
$
|
511 |
-
update_option('blockcountry_frontendnrblocks', $
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
}
|
517 |
|
518 |
|
519 |
-
|
520 |
-
$
|
521 |
-
$
|
522 |
-
$
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
header("Expires: Sat, 26 Jul 2012 05:00:00 GMT");
|
530 |
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
header("Location: $redirecturl");
|
541 |
-
}
|
542 |
// Display block message
|
543 |
-
print "$
|
544 |
-
|
545 |
|
546 |
-
|
547 |
-
|
548 |
else
|
549 |
{
|
550 |
-
iqblockcountry_debug_logging($
|
551 |
}
|
552 |
}
|
553 |
else
|
554 |
{
|
555 |
-
iqblockcountry_debug_logging($
|
556 |
}
|
557 |
}
|
558 |
|
559 |
|
560 |
/**
|
561 |
* Check if xmlrpc.php is hit.
|
|
|
562 |
* @return bool
|
563 |
*/
|
564 |
-
function iqblockcountry_is_xmlrpc()
|
|
|
565 |
return defined('XMLRPC_REQUEST') && XMLRPC_REQUEST;
|
566 |
}
|
567 |
|
568 |
/*
|
569 |
* Check for active caching plugins
|
570 |
*/
|
571 |
-
function iqblockcountry_is_caching_active()
|
572 |
-
|
|
|
573 |
|
574 |
|
575 |
-
include_once
|
576 |
-
if (
|
577 |
-
$
|
578 |
}
|
579 |
-
if (
|
580 |
-
$
|
581 |
}
|
582 |
|
583 |
-
if (get_option('blockcountry_blockfrontend') ==
|
584 |
-
|
585 |
-
$found = FALSE;
|
586 |
}
|
587 |
|
588 |
-
return $
|
589 |
}
|
590 |
|
591 |
/*
|
592 |
* Check if page is the login page
|
593 |
*/
|
594 |
-
function iqblockcountry_is_login_page()
|
595 |
-
|
596 |
-
|
|
|
597 |
|
598 |
-
include_once
|
599 |
-
if (
|
600 |
-
$
|
601 |
-
if (!empty($
|
602 |
-
|
|
|
603 |
}
|
604 |
|
605 |
-
if (
|
606 |
-
$
|
607 |
-
if (!empty($
|
608 |
-
|
|
|
609 |
}
|
610 |
|
611 |
-
if (
|
612 |
-
$
|
613 |
-
if (!empty($
|
614 |
-
|
|
|
615 |
}
|
616 |
|
617 |
-
if (
|
618 |
-
$
|
619 |
-
if (!empty($
|
620 |
-
|
|
|
621 |
}
|
622 |
|
623 |
-
if (
|
624 |
-
$
|
625 |
-
if (!empty($
|
626 |
-
|
|
|
627 |
}
|
628 |
|
629 |
|
630 |
|
631 |
-
$
|
632 |
-
if ($
|
633 |
-
|
|
|
|
|
634 |
|
635 |
-
return $
|
636 |
}
|
637 |
|
638 |
|
639 |
/*
|
640 |
* Check if page is within wp-admin page
|
641 |
*/
|
642 |
-
function iqblockcountry_is_admin()
|
643 |
-
|
|
|
644 |
|
645 |
|
646 |
-
$
|
647 |
-
if ($
|
|
|
648 |
|
649 |
-
return $
|
650 |
}
|
651 |
|
652 |
/*
|
653 |
* Check if page is within admin-ajax url.
|
654 |
*/
|
655 |
-
function iqblockcountry_is_adminajax()
|
656 |
-
|
|
|
657 |
|
658 |
|
659 |
-
$
|
660 |
-
if ($
|
|
|
661 |
|
662 |
-
return $
|
663 |
}
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
function iqblockcountry_check_ipaddress($iqbc_ip_address)
|
5 |
{
|
6 |
+
if (!class_exists('GeoIP')) {
|
7 |
+
include_once "geoip.inc";
|
|
|
8 |
}
|
9 |
|
10 |
+
if (get_option('blockcountry_geoapikey')) {
|
11 |
+
$iqbc_country = iqblockcountry_retrieve_geoipapi($iqbc_ip_address);
|
12 |
+
}
|
13 |
+
elseif ((is_file(IQBCGEOIP2DBFILE))) {
|
14 |
+
if (iqblockcountry_is_valid_ipv4($iqbc_ip_address) || iqblockcountry_is_valid_ipv6($iqbc_ip_address)) {
|
15 |
+
if (class_exists('GeoIp2\\Database\\Reader')) {
|
16 |
+
try {
|
17 |
+
$iqbc_blockreader = new GeoIp2\Database\Reader(IQBCGEOIP2DBFILE);
|
18 |
+
$iqbc_blockrecord = $iqbc_blockreader->country($iqbc_ip_address);
|
19 |
+
$iqbc_country = filter_var($iqbc_blockrecord->country->isoCode, FILTER_SANITIZE_STRING);
|
20 |
+
}
|
21 |
+
catch(Exception $iqbc_e) {
|
22 |
+
$iqbc_country = "FALSE";
|
23 |
+
}
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
}
|
26 |
|
27 |
}
|
28 |
+
else { $iqbc_country = "Unknown";
|
29 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
+
if (empty($iqbc_country) || $iqbc_country == null ) {
|
32 |
+
$iqbc_country = "Unknown";
|
|
|
33 |
}
|
34 |
|
35 |
+
return $iqbc_country;
|
36 |
}
|
37 |
|
38 |
/*
|
39 |
* iQ Block Retrieve XML file for API blocking
|
40 |
*/
|
41 |
+
function iqblockcountry_retrieve_geoipapi($iqbc_ipaddress)
|
42 |
{
|
43 |
+
if (iqblockcountry_is_valid_ipv4($iqbc_ipaddress) || iqblockcountry_is_valid_ipv6($iqbc_ipaddress)) {
|
|
|
44 |
|
45 |
+
$iqbc_url = GEOIPAPIURL;
|
46 |
+
if (get_option('blockcountry_geoapilocation') == "US") {
|
47 |
+
$iqbc_url = GEOIPAPIURLUS;
|
48 |
+
}
|
49 |
+
if (get_option('blockcountry_geoapilocation') == "US2") {
|
50 |
+
$iqbc_url = GEOIPAPIURLUS2;
|
51 |
+
}
|
52 |
+
if (get_option('blockcountry_geoapilocation') == "US3") {
|
53 |
+
$iqbc_url = GEOIPAPIURLUS3;
|
54 |
+
}
|
55 |
+
if (get_option('blockcountry_geoapilocation') == "EU2") {
|
56 |
+
$iqbc_url = GEOIPAPIURLEU2;
|
57 |
+
}
|
58 |
+
if (get_option('blockcountry_geoapilocation') == "EU3") {
|
59 |
+
$iqbc_url = GEOIPAPIURLEU3;
|
60 |
+
}
|
61 |
+
if (get_option('blockcountry_geoapilocation') == "EU4") {
|
62 |
+
$iqbc_url = GEOIPAPIURLEU4;
|
63 |
+
}
|
64 |
+
if (get_option('blockcountry_geoapilocation') == "ASIA") {
|
65 |
+
$iqbc_url = GEOIPAPIURLASIA;
|
66 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
+
$iqbc_result = wp_remote_post(
|
69 |
+
$iqbc_url,
|
70 |
array(
|
71 |
'body' => array(
|
72 |
'api-key' => get_option('blockcountry_geoapikey'),
|
73 |
+
'ipaddress' => $iqbc_ipaddress
|
74 |
|
75 |
)
|
76 |
)
|
77 |
);
|
78 |
+
if (is_wp_error($iqbc_result) ) {
|
79 |
+
return "Unknown";
|
80 |
+
}
|
81 |
+
elseif (200 == $iqbc_result['response']['code'] ) {
|
82 |
+
$iqbc_body = $iqbc_result['body'];
|
83 |
+
$iqbc_xml = new SimpleXmlElement($iqbc_body);
|
84 |
+
// FIX: Check against countries
|
85 |
+
if (isset($iqbc_xml->country)) { return (string) $iqbc_xml->country;
|
|
|
|
|
|
|
|
|
86 |
}
|
87 |
+
elseif (isset($iqbc_xml->error)) {
|
88 |
+
if (strpos($iqbc_xml->error, 'License expired on ') !== false) {
|
89 |
+
update_option('blockcountry_geoapikey', '');
|
90 |
+
return "Expired";
|
91 |
+
}
|
92 |
+
}
|
93 |
+
else { return "Unknown";
|
94 |
+
}
|
95 |
+
}
|
96 |
+
elseif (403 == $iqbc_result['response']['code'] ) {
|
97 |
+
update_option('blockcountry_geoapikey', '');
|
98 |
+
}
|
99 |
+
else { return "Unknown";
|
100 |
}
|
|
|
101 |
}
|
102 |
+
else
|
103 |
+
{ return "Invalid";
|
104 |
}
|
|
|
|
|
|
|
|
|
105 |
}
|
106 |
|
107 |
|
108 |
|
109 |
+
/**
|
110 |
* Check country against bad countries, allow list and block list
|
111 |
+
**/
|
112 |
+
function iqblockcountry_check($iqbc_country,$iqbc_badcountries,$iqbc_ip_address)
|
113 |
{
|
114 |
/* Set default blocked status and get all options */
|
115 |
+
$iqbc_blocked = false;
|
116 |
+
$iqbc_blockedpage = get_option('blockcountry_blockpages');
|
117 |
+
//$iqbc_blockedpages = get_option('blockcountry_pages');
|
118 |
+
$iqbc_pagesbanlist = get_option('blockcountry_pages');
|
119 |
+
if (!is_array($iqbc_pagesbanlist)) { $iqbc_pagesbanlist = array();
|
120 |
+
}
|
121 |
+
if (get_option('blockcountry_blockpages_inverse') == 'on') {
|
122 |
+
$iqbc_pages = get_pages();
|
123 |
+
$iqbc_all_pages = array();
|
124 |
+
foreach ( $iqbc_pages as $iqbc_page ) {
|
125 |
+
$iqbc_all_pages[$iqbc_page->ID] = $iqbc_page->ID;
|
|
|
|
|
|
|
126 |
}
|
127 |
+
$iqbc_blockedpages = array_diff($iqbc_all_pages, $iqbc_pagesbanlist);
|
128 |
+
} else {
|
129 |
+
$iqbc_blockedpages = $iqbc_pagesbanlist;
|
130 |
+
}
|
131 |
|
132 |
+
$iqbc_blockedcategory = get_option('blockcountry_blockcategories');
|
133 |
+
$iqbc_blocktags = get_option('blockcountry_blocktags');
|
134 |
+
$iqbc_blockedposttypes = get_option('blockcountry_blockposttypes');
|
135 |
+
$iqbc_blockedtag = get_option('blockcountry_blocktag');
|
136 |
+
$iqbc_blockedfeed = get_option('blockcountry_blockfeed');
|
137 |
+
$iqbc_postid = get_the_ID();
|
138 |
|
139 |
+
global $iqbc_feblocklistip,$iqbc_feblocklistiprange4,$iqbc_feblocklistiprange6,$iqbc_feallowlistip,$iqbc_feallowlistiprange4,$iqbc_feallowlistiprange6;
|
140 |
+
global $iqbc_beblocklistip,$iqbc_beblocklistiprange4,$iqbc_beblocklistiprange6,$iqbc_beallowlistip,$iqbc_beallowlistiprange4,$iqbc_beallowlistiprange6;
|
141 |
|
142 |
+
$iqbc_backendbanlistip = unserialize(get_option('blockcountry_backendbanlistip'));
|
143 |
+
$iqbc_blockredirect = get_option('blockcountry_redirect');
|
144 |
|
145 |
/* Block if user is in a bad country from frontend or backend. Unblock may happen later */
|
146 |
+
if (is_array($iqbc_badcountries) && in_array($iqbc_country, $iqbc_badcountries)) {
|
147 |
+
$iqbc_blocked = true;
|
148 |
+
global $iqbc_backendblocklistcheck;
|
149 |
+
$iqbc_backendblocklistcheck = true;
|
150 |
}
|
151 |
|
152 |
global $blockcountry_is_login_page,$blockcountry_is_xmlrpc;
|
153 |
|
154 |
|
155 |
/* Check if requested url is not login page. Else check against frontend allow list / block list. */
|
156 |
+
if (!($blockcountry_is_login_page) && !(is_admin()) && !($blockcountry_is_xmlrpc)) {
|
157 |
+
if (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_feblocklistiprange4, $iqbc_feblocklistiprange6, $iqbc_feblocklistip)) {
|
158 |
+
$iqbc_blocked = true;
|
159 |
+
}
|
160 |
+
if (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_feallowlistiprange4, $iqbc_feallowlistiprange6, $iqbc_feallowlistip)) {
|
161 |
+
$iqbc_blocked = false;
|
162 |
+
}
|
|
|
|
|
|
|
163 |
}
|
164 |
|
165 |
|
166 |
+
if ($blockcountry_is_login_page || is_admin() || $blockcountry_is_xmlrpc) {
|
167 |
+
if (is_array($iqbc_backendbanlistip) && in_array($iqbc_ip_address, $iqbc_backendbanlistip)) {
|
168 |
+
$iqbc_blocked = true;
|
169 |
+
global $iqbc_apiblocklist;
|
170 |
+
$iqbc_apiblocklist = true;
|
|
|
|
|
171 |
}
|
172 |
+
if (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_beblocklistiprange4, $iqbc_beblocklistiprange6, $iqbc_beblocklistip)) {
|
173 |
+
$iqbc_blocked = true;
|
174 |
+
}
|
175 |
+
if (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_beallowlistiprange4, $iqbc_beallowlistiprange6, $iqbc_beallowlistip)) {
|
176 |
+
$iqbc_blocked = false;
|
177 |
+
}
|
178 |
+
if (iqblockcountry_is_adminajax() && get_option('blockcountry_adminajax')) {
|
179 |
+
$iqbc_blocked = false;
|
|
|
180 |
}
|
181 |
}
|
182 |
|
183 |
+
if ($iqbc_blockedposttypes == "on") {
|
184 |
+
$iqbc_blockedposttypes = get_option('blockcountry_posttypes');
|
185 |
+
if (is_array($iqbc_blockedposttypes) && in_array(get_post_type($iqbc_postid), $iqbc_blockedposttypes) && ((is_array($iqbc_badcountries) && in_array($iqbc_country, $iqbc_badcountries) || (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_feblocklistiprange4, $iqbc_feblocklistiprange6, $iqbc_feblocklistip))))) {
|
186 |
+
$iqbc_blocked = true;
|
187 |
+
if (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_feallowlistiprange4, $iqbc_feallowlistiprange6, $iqbc_feallowlistip)) {
|
188 |
+
$iqbc_blocked = false;
|
|
|
|
|
189 |
}
|
190 |
}
|
191 |
else
|
192 |
{
|
193 |
+
$iqbc_blocked = false;
|
194 |
}
|
195 |
}
|
196 |
|
197 |
+
if (is_page() && $iqbc_blockedpage == "on") {
|
198 |
+
$iqbc_post = get_post();
|
199 |
+
if (is_page($iqbc_blockedpages) && !empty($iqbc_blockedpages) && ((is_array($iqbc_badcountries) && in_array($iqbc_country, $iqbc_badcountries) || (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_feblocklistiprange4, $iqbc_feblocklistiprange6, $iqbc_feblocklistip))))) {
|
200 |
+
$iqbc_blocked = true;
|
201 |
+
if (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_feallowlistiprange4, $iqbc_feallowlistiprange6, $iqbc_feallowlistip)) {
|
202 |
+
$iqbc_blocked = false;
|
|
|
|
|
203 |
}
|
204 |
}
|
205 |
else
|
206 |
{
|
207 |
+
$iqbc_blocked = false;
|
208 |
}
|
209 |
}
|
210 |
+
if (is_single() && $iqbc_blockedcategory == "on") {
|
211 |
+
$iqbc_blockedcategories = get_option('blockcountry_categories');
|
212 |
+
if (!is_array($iqbc_blockedcategories)) { $iqbc_blockedcategories = array();
|
213 |
+
}
|
214 |
+
$iqbc_post_categories = wp_get_post_categories($iqbc_postid);
|
215 |
+
$iqbc_flagged = false;
|
216 |
+
foreach ($iqbc_post_categories as $iqbc_key => $iqbc_value)
|
217 |
{
|
218 |
+
if (in_array($iqbc_value, $iqbc_blockedcategories)) {
|
219 |
+
if (is_single() && ((is_array($iqbc_badcountries) && in_array($iqbc_country, $iqbc_badcountries) || (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_feblocklistiprange4, $iqbc_feblocklistiprange6, $iqbc_feblocklistip))))) {
|
220 |
+
$iqbc_flagged = true;
|
221 |
+
if (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_feallowlistiprange4, $iqbc_feallowlistiprange6, $iqbc_feallowlistip)) {
|
222 |
+
$iqbc_flagged = false;
|
|
|
|
|
223 |
}
|
224 |
}
|
225 |
}
|
226 |
}
|
227 |
+
if ($iqbc_flagged) { $iqbc_blocked = true;
|
228 |
+
} else { $iqbc_blocked = false;
|
229 |
+
}
|
230 |
}
|
231 |
|
232 |
+
if (is_single() && $iqbc_blocktags == "on") {
|
233 |
+
$iqbc_previousblock = $iqbc_blocked;
|
234 |
+
$iqbc_blockedtags = get_option('blockcountry_tags');
|
235 |
+
if (!is_array($iqbc_blockedtags)) { $iqbc_blockedtags = array();
|
236 |
+
}
|
237 |
+
$iqbc_post_tags = get_the_tags($iqbc_postid);
|
238 |
+
if (empty($iqbc_post_tags)) { $iqbc_post_tags = array();
|
239 |
+
}
|
240 |
+
$iqbc_flagged = false;
|
241 |
+
foreach ($iqbc_post_tags as $iqbc_tag)
|
242 |
{
|
243 |
+
if (in_array($iqbc_tag->term_id, $iqbc_blockedtags)) {
|
244 |
+
if (is_single() && ((is_array($iqbc_badcountries) && in_array($iqbc_country, $iqbc_badcountries) || (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_feblocklistiprange4, $iqbc_feblocklistiprange6, $iqbc_feblocklistip))))) {
|
245 |
+
$iqbc_flagged = true;
|
246 |
+
if (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_feallowlistiprange4, $iqbc_feallowlistiprange6, $iqbc_feallowlistip)) {
|
|
|
|
|
247 |
|
248 |
+
$iqbc_flagged = false;
|
249 |
}
|
250 |
}
|
251 |
}
|
252 |
}
|
253 |
+
if ($iqbc_flagged || $iqbc_previousblock == true) { $iqbc_blocked = true;
|
254 |
+
} else { $iqbc_blocked = false;
|
255 |
+
}
|
256 |
}
|
257 |
|
258 |
|
259 |
+
if (is_category() && $iqbc_blockedcategory == "on") {
|
260 |
+
$iqbc_flagged = false;
|
261 |
+
$iqbc_blockedcategories = get_option('blockcountry_categories');
|
262 |
+
if (is_category($iqbc_blockedcategories) && ((is_array($iqbc_badcountries) && in_array($iqbc_country, $iqbc_badcountries) || (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_feblocklistiprange4, $iqbc_feblocklistiprange6, $iqbc_feblocklistip))))) {
|
263 |
+
$iqbc_flagged = true;
|
|
|
|
|
264 |
}
|
265 |
+
if (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_feallowlistiprange4, $iqbc_feallowlistiprange6, $iqbc_feallowlistip)) {
|
266 |
|
267 |
+
$iqbc_flagged = false;
|
268 |
+
}
|
269 |
+
if ($iqbc_flagged) { $iqbc_blocked = true;
|
270 |
+
} else { $iqbc_blocked = false;
|
271 |
}
|
|
|
272 |
}
|
273 |
|
274 |
|
275 |
+
if (is_tag() && $iqbc_blockedtag == "on") {
|
276 |
+
$iqbc_flagged = false;
|
277 |
+
if ((is_array($iqbc_badcountries) && in_array($iqbc_country, $iqbc_badcountries) || (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_feblocklistiprange4, $iqbc_feblocklistiprange6, $iqbc_feblocklistip)))) {
|
278 |
+
$iqbc_flagged = true;
|
|
|
|
|
279 |
}
|
280 |
+
if (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_feallowlistiprange4, $iqbc_feallowlistiprange6, $iqbc_feallowlistip)) {
|
281 |
|
282 |
+
$iqbc_flagged = false;
|
283 |
+
}
|
284 |
+
if ($iqbc_flagged) { $iqbc_blocked = true;
|
285 |
+
} else { $iqbc_blocked = false;
|
286 |
}
|
|
|
287 |
}
|
288 |
+
elseif (is_tag() && $iqbc_blockedtag == false) {
|
289 |
+
$iqbc_blocked = false;
|
|
|
290 |
}
|
291 |
|
292 |
+
if (is_feed() && $iqbc_blockedfeed == "on") {
|
293 |
+
$iqbc_flagged = false;
|
294 |
+
if ((is_array($iqbc_badcountries) && in_array($iqbc_country, $iqbc_badcountries) || (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_feblocklistiprange4, $iqbc_feblocklistiprange6, $iqbc_feblocklistip)))) {
|
295 |
+
$iqbc_flagged = true;
|
|
|
|
|
296 |
}
|
297 |
+
if (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_feallowlistiprange4, $iqbc_feallowlistiprange6, $iqbc_feallowlistip)) {
|
298 |
|
299 |
+
$iqbc_flagged = false;
|
300 |
+
}
|
301 |
+
if ($iqbc_flagged) { $iqbc_blocked = true;
|
302 |
+
} else { $iqbc_blocked = false;
|
303 |
}
|
|
|
304 |
}
|
305 |
+
elseif (is_feed() && $iqbc_blockedfeed == false) {
|
306 |
+
$iqbc_blocked = false;
|
|
|
307 |
}
|
308 |
|
309 |
+
if (is_home() && (get_option('blockcountry_blockhome')) == false && $iqbc_blockedcategory == "on") {
|
310 |
+
$iqbc_blocked = false;
|
|
|
311 |
}
|
312 |
+
if (is_page($iqbc_blockredirect) && ($iqbc_blockredirect != 0) && !(empty($iqbc_blockredirect))) {
|
313 |
+
$iqbc_blocked = false;
|
|
|
314 |
}
|
315 |
|
316 |
+
$iqbc_allowse = get_option('blockcountry_allowse');
|
317 |
+
if (!$blockcountry_is_login_page && isset($_SERVER['HTTP_USER_AGENT']) && iqblockcountry_check_searchengine($_SERVER['HTTP_USER_AGENT'], $iqbc_allowse)) {
|
318 |
+
$iqbc_blocked = false;
|
|
|
319 |
}
|
320 |
|
321 |
+
if (is_search() && (get_option('blockcountry_blocksearch')) == false) {
|
322 |
+
$iqbc_blocked = false;
|
|
|
323 |
}
|
324 |
|
325 |
+
return $iqbc_blocked;
|
326 |
}
|
327 |
|
328 |
/*
|
330 |
* Does the real check of visitor IP against MaxMind database or the GeoAPI
|
331 |
*
|
332 |
*/
|
333 |
+
function iqblockcountry_CheckCountryBackEnd()
|
334 |
+
{
|
335 |
+
$iqbc_ip_address = iqblockcountry_get_ipaddress();
|
336 |
+
$iqbc_country = iqblockcountry_check_ipaddress($iqbc_ip_address);
|
337 |
global $blockcountry_is_login_page,$blockcountry_is_xmlrpc;
|
338 |
+
if (($blockcountry_is_login_page || is_admin() || $blockcountry_is_xmlrpc) && get_option('blockcountry_blockbackend') == 'on') {
|
339 |
+
$iqbc_banlist = get_option('blockcountry_backendbanlist');
|
340 |
+
if (!is_array($iqbc_banlist)) { $iqbc_banlist = array();
|
341 |
+
}
|
342 |
+
if (get_option('blockcountry_backendbanlist_inverse') == 'on') {
|
343 |
+
$iqbc_all_countries = array_keys(iqblockcountry_get_isocountries());
|
344 |
+
$iqbc_badcountries = array_diff($iqbc_all_countries, $iqbc_banlist);
|
345 |
} else {
|
346 |
+
$iqbc_badcountries = $iqbc_banlist;
|
347 |
}
|
348 |
}
|
349 |
|
350 |
+
$iqbc_blocklogin = get_option('blockcountry_blocklogin');
|
351 |
+
if (((is_user_logged_in()) && ($iqbc_blocklogin != "on")) || (!(is_user_logged_in())) ) {
|
352 |
|
353 |
/* Check ip address against banlist, allow list and block list */
|
354 |
+
if (iqblockcountry_check($iqbc_country, $iqbc_badcountries, $iqbc_ip_address)) {
|
355 |
+
if (($blockcountry_is_login_page || is_admin() || $blockcountry_is_xmlrpc) && get_option('blockcountry_blockbackend') == 'on') {
|
356 |
+
$iqbc_blocked = get_option('blockcountry_backendnrblocks');
|
357 |
+
if (empty($iqbc_blocked)) { $iqbc_blocked = 0;
|
358 |
+
}
|
359 |
+
$iqbc_blocked++;
|
360 |
+
update_option('blockcountry_backendnrblocks', $iqbc_blocked);
|
361 |
+
global $iqbc_apiblocklist,$iqbc_backendblocklistcheck,$iqbc_debughandled;
|
362 |
+
if (!get_option('blockcountry_logging')) {
|
363 |
+
if (!$iqbc_apiblocklist) {
|
364 |
+
iqblockcountry_logging($iqbc_ip_address, $iqbc_country, "B");
|
365 |
+
iqblockcountry_debug_logging($iqbc_ip_address, $iqbc_country, 'BB');
|
366 |
+
}
|
367 |
+
elseif ($iqbc_backendblocklistcheck && $iqbc_apiblocklist) {
|
368 |
+
iqblockcountry_logging($iqbc_ip_address, $iqbc_country, "T");
|
369 |
+
iqblockcountry_debug_logging($iqbc_ip_address, $iqbc_country, 'TB');
|
370 |
+
}
|
371 |
+
else
|
372 |
{
|
373 |
+
iqblockcountry_logging($iqbc_ip_address, $iqbc_country, "A");
|
374 |
+
iqblockcountry_debug_logging($iqbc_ip_address, $iqbc_country, 'AB');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
375 |
}
|
376 |
}
|
377 |
+
}
|
378 |
+
else
|
379 |
{
|
380 |
+
$iqbc_blocked = get_option('blockcountry_frontendnrblocks');
|
381 |
+
if (empty($iqbc_blocked)) { $iqbc_blocked = 0;
|
382 |
+
}
|
383 |
+
$iqbc_blocked++;
|
384 |
+
update_option('blockcountry_frontendnrblocks', $iqbc_blocked);
|
385 |
+
if (!get_option('blockcountry_logging')) {
|
386 |
+
iqblockcountry_logging($iqbc_ip_address, $iqbc_country, "F");
|
387 |
+
iqblockcountry_debug_logging($iqbc_ip_address, $iqbc_country, 'FB');
|
|
|
388 |
}
|
389 |
+
}
|
390 |
|
391 |
|
392 |
+
$iqbc_blockmessage = get_option('blockcountry_blockmessage');
|
393 |
+
$iqbc_blockredirect = get_option('blockcountry_redirect');
|
394 |
+
$iqbc_blockredirect_url = get_option('blockcountry_redirect_url');
|
395 |
+
$iqbc_header = get_option('blockcountry_header');
|
396 |
+
if (!empty($iqbc_header) && ($iqbc_header)) {
|
397 |
+
// Prevent as much as possible that this error message is cached:
|
398 |
+
header("Cache-Control: no-store, no-cache, must-revalidate");
|
399 |
+
header("Cache-Control: post-check=0, pre-check=0", false);
|
400 |
+
header("Pragma: no-cache");
|
401 |
+
header("Expires: Sat, 26 Jul 2021 05:00:00 GMT");
|
|
|
402 |
|
403 |
+
header('HTTP/1.1 403 Forbidden');
|
404 |
+
}
|
405 |
+
if (!empty($iqbc_blockredirect_url)) {
|
406 |
+
header("Location: $iqbc_blockredirect_url");
|
407 |
+
}
|
408 |
+
elseif (!empty($iqbc_blockredirect) && $iqbc_blockredirect != 0) {
|
409 |
+
$iqbc_redirecturl = get_permalink($iqbc_blockredirect);
|
410 |
+
header("Location: $iqbc_redirecturl");
|
411 |
+
}
|
|
|
|
|
412 |
// Display block message
|
413 |
+
print "$iqbc_blockmessage";
|
414 |
|
415 |
|
416 |
+
exit();
|
417 |
+
}
|
418 |
else
|
419 |
{
|
420 |
+
iqblockcountry_debug_logging($iqbc_ip_address, $iqbc_country, 'NB');
|
421 |
}
|
422 |
}
|
423 |
else
|
424 |
{
|
425 |
+
iqblockcountry_debug_logging($iqbc_ip_address, $iqbc_country, 'NB');
|
426 |
}
|
427 |
}
|
428 |
|
431 |
* Does the real check of visitor IP against MaxMind database or the GeoAPI FrontEnd
|
432 |
*
|
433 |
*/
|
434 |
+
function iqblockcountry_CheckCountryFrontEnd()
|
435 |
+
{
|
436 |
+
$iqbc_ip_address = iqblockcountry_get_ipaddress();
|
437 |
+
$iqbc_country = iqblockcountry_check_ipaddress($iqbc_ip_address);
|
438 |
+
$iqbc_banlist = get_option('blockcountry_banlist');
|
439 |
+
if (!is_array($iqbc_banlist)) { $iqbc_banlist = array();
|
440 |
+
}
|
441 |
+
if (get_option('blockcountry_banlist_inverse') == 'on') {
|
442 |
+
$iqbc_all_countries = array_keys(iqblockcountry_get_isocountries());
|
443 |
+
$iqbc_badcountries = array_diff($iqbc_all_countries, $iqbc_banlist);
|
444 |
+
} else {
|
445 |
+
$iqbc_badcountries = $iqbc_banlist;
|
446 |
+
}
|
447 |
|
448 |
+
$iqbc_blocklogin = get_option('blockcountry_blocklogin');
|
449 |
+
if (((is_user_logged_in()) && ($iqbc_blocklogin != "on")) || (!(is_user_logged_in())) ) {
|
450 |
|
451 |
/* Check ip address against banlist, allow list and block list */
|
452 |
+
if (iqblockcountry_check($iqbc_country, $iqbc_badcountries, $iqbc_ip_address)) {
|
453 |
+
$iqbc_blocked = get_option('blockcountry_frontendnrblocks');
|
454 |
+
if (empty($iqbc_blocked)) { $iqbc_blocked = 0;
|
455 |
+
}
|
456 |
+
$iqbc_blocked++;
|
457 |
+
update_option('blockcountry_frontendnrblocks', $iqbc_blocked);
|
458 |
+
if (!get_option('blockcountry_logging')) {
|
459 |
+
iqblockcountry_logging($iqbc_ip_address, $iqbc_country, "F");
|
460 |
+
iqblockcountry_debug_logging($iqbc_ip_address, $iqbc_country, 'FB');
|
461 |
+
}
|
|
|
462 |
|
463 |
|
464 |
+
$iqbc_blockmessage = get_option('blockcountry_blockmessage');
|
465 |
+
$iqbc_blockredirect = get_option('blockcountry_redirect');
|
466 |
+
$iqbc_blockredirect_url = get_option('blockcountry_redirect_url');
|
467 |
+
$iqbc_header = get_option('blockcountry_header');
|
468 |
+
if (!empty($iqbc_header) && ($iqbc_header)) {
|
469 |
+
// Prevent as much as possible that this error message is cached:
|
470 |
+
header("Cache-Control: no-store, no-cache, must-revalidate");
|
471 |
+
header("Cache-Control: post-check=0, pre-check=0", false);
|
472 |
+
header("Pragma: no-cache");
|
473 |
+
header("Expires: Sat, 26 Jul 2012 05:00:00 GMT");
|
|
|
474 |
|
475 |
+
header('HTTP/1.1 403 Forbidden');
|
476 |
+
}
|
477 |
+
if (!empty($iqbc_blockredirect_url)) {
|
478 |
+
header("Location: $iqbc_blockredirect_url");
|
479 |
+
}
|
480 |
+
elseif (!empty($iqbc_blockredirect) && $iqbc_blockredirect != 0) {
|
481 |
+
$iqbc_redirecturl = get_permalink($iqbc_blockredirect);
|
482 |
+
header("Location: $iqbc_redirecturl");
|
483 |
+
}
|
|
|
|
|
484 |
// Display block message
|
485 |
+
print "$iqbc_blockmessage";
|
|
|
486 |
|
487 |
+
exit();
|
488 |
+
}
|
489 |
else
|
490 |
{
|
491 |
+
iqblockcountry_debug_logging($iqbc_ip_address, $iqbc_country, 'NB');
|
492 |
}
|
493 |
}
|
494 |
else
|
495 |
{
|
496 |
+
iqblockcountry_debug_logging($iqbc_ip_address, $iqbc_country, 'NB');
|
497 |
}
|
498 |
}
|
499 |
|
500 |
|
501 |
/**
|
502 |
* Check if xmlrpc.php is hit.
|
503 |
+
*
|
504 |
* @return bool
|
505 |
*/
|
506 |
+
function iqblockcountry_is_xmlrpc()
|
507 |
+
{
|
508 |
return defined('XMLRPC_REQUEST') && XMLRPC_REQUEST;
|
509 |
}
|
510 |
|
511 |
/*
|
512 |
* Check for active caching plugins
|
513 |
*/
|
514 |
+
function iqblockcountry_is_caching_active()
|
515 |
+
{
|
516 |
+
$iqbc_found = false;
|
517 |
|
518 |
|
519 |
+
include_once ABSPATH . 'wp-admin/includes/plugin.php';
|
520 |
+
if (is_plugin_active('w3-total-cache/w3-total-cache.php') ) {
|
521 |
+
$iqbc_found = true;
|
522 |
}
|
523 |
+
if (is_plugin_active('hyper-cache/plugin.php') ) {
|
524 |
+
$iqbc_found = true;
|
525 |
}
|
526 |
|
527 |
+
if (get_option('blockcountry_blockfrontend') == false) {
|
528 |
+
$iqbc_found = false;
|
|
|
529 |
}
|
530 |
|
531 |
+
return $iqbc_found;
|
532 |
}
|
533 |
|
534 |
/*
|
535 |
* Check if page is the login page
|
536 |
*/
|
537 |
+
function iqblockcountry_is_login_page()
|
538 |
+
{
|
539 |
+
$iqbc_found = false;
|
540 |
+
$iqbc_pos2 = false;
|
541 |
|
542 |
+
include_once ABSPATH . 'wp-admin/includes/plugin.php';
|
543 |
+
if (is_plugin_active('all-in-one-wp-security-and-firewall/wp-security.php') ) {
|
544 |
+
$iqbc_aio = get_option('aio_wp_security_configs');
|
545 |
+
if (!empty($iqbc_aio) && !(empty($iqbc_aio['aiowps_login_page_slug']))) {
|
546 |
+
$iqbc_pos2 = strpos($_SERVER['REQUEST_URI'], $iqbc_aio['aiowps_login_page_slug']);
|
547 |
+
}
|
548 |
}
|
549 |
|
550 |
+
if (is_plugin_active('lockdown-wp-admin/lockdown-wp-admin.php') ) {
|
551 |
+
$iqbc_ld = get_option('ld_login_base');
|
552 |
+
if (!empty($iqbc_ld)) {
|
553 |
+
$iqbc_pos2 = strpos($_SERVER['REQUEST_URI'], $iqbc_ld);
|
554 |
+
}
|
555 |
}
|
556 |
|
557 |
+
if (is_plugin_active('wp-simple-firewall/icwp-wpsf.php') ) {
|
558 |
+
$iqbc_wpsf = get_option('icwp_wpsf_loginprotect_options');
|
559 |
+
if (!empty($iqbc_wpsf['rename_wplogin_path'])) {
|
560 |
+
$iqbc_pos2 = strpos($_SERVER['REQUEST_URI'], $iqbc_wpsf['rename_wplogin_path']);
|
561 |
+
}
|
562 |
}
|
563 |
|
564 |
+
if (is_plugin_active('rename-wp-login/rename-wp-login.php') ) {
|
565 |
+
$iqbc_rwpl = get_option('rwl_page');
|
566 |
+
if (!empty($iqbc_rwpl)) {
|
567 |
+
$iqbc_pos2 = strpos($_SERVER['REQUEST_URI'], $iqbc_rwpl);
|
568 |
+
}
|
569 |
}
|
570 |
|
571 |
+
if (is_plugin_active('wps-hide-login/wps-hide-login.php') ) {
|
572 |
+
$iqbc_whlpage = get_option('whl_page');
|
573 |
+
if (!empty($iqbc_whlpage)) {
|
574 |
+
$iqbc_pos2 = strpos($_SERVER['REQUEST_URI'], $iqbc_whlpage);
|
575 |
+
}
|
576 |
}
|
577 |
|
578 |
|
579 |
|
580 |
+
$iqbc_pos = strpos($_SERVER['REQUEST_URI'], 'wp-login');
|
581 |
+
if ($iqbc_pos !== false) { $iqbc_found = true;
|
582 |
+
}
|
583 |
+
elseif ($iqbc_pos2 !== false) { $iqbc_found = true;
|
584 |
+
}
|
585 |
|
586 |
+
return $iqbc_found;
|
587 |
}
|
588 |
|
589 |
|
590 |
/*
|
591 |
* Check if page is within wp-admin page
|
592 |
*/
|
593 |
+
function iqblockcountry_is_admin()
|
594 |
+
{
|
595 |
+
$iqbc_found = false;
|
596 |
|
597 |
|
598 |
+
$iqbc_pos = strpos($_SERVER['REQUEST_URI'], '/wp-admin/');
|
599 |
+
if ($iqbc_pos !== false) { $iqbc_found = true;
|
600 |
+
}
|
601 |
|
602 |
+
return $iqbc_found;
|
603 |
}
|
604 |
|
605 |
/*
|
606 |
* Check if page is within admin-ajax url.
|
607 |
*/
|
608 |
+
function iqblockcountry_is_adminajax()
|
609 |
+
{
|
610 |
+
$iqbc_found = false;
|
611 |
|
612 |
|
613 |
+
$iqbc_pos = strpos($_SERVER['REQUEST_URI'], '/wp-admin/admin-ajax.php');
|
614 |
+
if ($iqbc_pos !== false) { $iqbc_found = true;
|
615 |
+
}
|
616 |
|
617 |
+
return $iqbc_found;
|
618 |
}
|
libs/blockcountry-geoip.php
CHANGED
@@ -1,9 +1,13 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
3 |
function iqblockcountry_get_isocountries()
|
4 |
{
|
5 |
|
6 |
-
$
|
7 |
'A1' => "Anonymous Proxy",
|
8 |
'A2' => "Satellite Provider",
|
9 |
'AF' => 'Afghanistan',
|
@@ -256,9 +260,9 @@ $iqcountrylist = array(
|
|
256 |
'YE' => 'Yemen',
|
257 |
'ZM' => 'Zambia',
|
258 |
'ZW' => 'Zimbabwe',
|
259 |
-
);
|
260 |
|
261 |
-
return $
|
262 |
}
|
263 |
|
264 |
?>
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
*
|
6 |
+
*/
|
7 |
function iqblockcountry_get_isocountries()
|
8 |
{
|
9 |
|
10 |
+
$iqbc_countrylist = array(
|
11 |
'A1' => "Anonymous Proxy",
|
12 |
'A2' => "Satellite Provider",
|
13 |
'AF' => 'Afghanistan',
|
260 |
'YE' => 'Yemen',
|
261 |
'ZM' => 'Zambia',
|
262 |
'ZW' => 'Zimbabwe',
|
263 |
+
);
|
264 |
|
265 |
+
return $iqbc_countrylist;
|
266 |
}
|
267 |
|
268 |
?>
|
libs/blockcountry-logging.php
CHANGED
@@ -1,11 +1,12 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
function iqblockcountry_install_db()
|
4 |
-
|
|
|
5 |
|
6 |
-
|
7 |
|
8 |
-
|
9 |
id bigint(20) NOT NULL AUTO_INCREMENT,
|
10 |
datetime datetime NOT NULL,
|
11 |
ipaddress tinytext NOT NULL,
|
@@ -16,51 +17,55 @@ function iqblockcountry_install_db() {
|
|
16 |
KEY `datetime` (`datetime`)
|
17 |
);";
|
18 |
|
19 |
-
|
20 |
-
|
21 |
}
|
22 |
|
23 |
|
24 |
-
function iqblockcountry_uninstall_db()
|
25 |
-
|
|
|
26 |
|
27 |
-
|
28 |
|
29 |
-
|
30 |
|
31 |
-
|
32 |
|
33 |
-
|
34 |
}
|
35 |
|
36 |
function iqblockcountry_clean_db()
|
37 |
{
|
38 |
-
|
39 |
|
40 |
-
|
41 |
-
|
|
|
42 |
|
43 |
-
|
44 |
-
|
45 |
|
46 |
-
|
47 |
|
48 |
}
|
49 |
|
50 |
|
51 |
-
function iqblockcountry_update_db_check()
|
52 |
-
|
|
|
53 |
iqblockcountry_install_db();
|
54 |
-
update_option(
|
55 |
}
|
56 |
}
|
57 |
|
58 |
-
function iqblockcountry_install_loggingdb()
|
59 |
-
|
|
|
60 |
|
61 |
-
|
62 |
|
63 |
-
|
64 |
id bigint(20) NOT NULL AUTO_INCREMENT,
|
65 |
datetime datetime NOT NULL,
|
66 |
ipaddress tinytext NOT NULL,
|
@@ -71,71 +76,68 @@ function iqblockcountry_install_loggingdb() {
|
|
71 |
PRIMARY KEY id (id)
|
72 |
);";
|
73 |
|
74 |
-
|
75 |
-
|
76 |
}
|
77 |
|
78 |
-
function iqblockcountry_uninstall_loggingdb()
|
79 |
-
|
|
|
80 |
|
81 |
-
|
82 |
|
83 |
-
|
84 |
|
85 |
-
|
86 |
|
87 |
-
|
88 |
}
|
89 |
|
90 |
function iqblockcountry_clean_loggingdb()
|
91 |
{
|
92 |
-
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
// $
|
97 |
-
|
98 |
}
|
99 |
|
100 |
/*
|
101 |
* Schedule debug logging if this option was set in the admin panel
|
102 |
*/
|
103 |
-
function iqblockcountry_blockcountry_debuglogging($
|
104 |
{
|
105 |
-
if ($
|
106 |
-
|
107 |
-
if ($new_value == '')
|
108 |
-
{
|
109 |
iqblockcountry_uninstall_loggingdb();
|
110 |
}
|
111 |
-
elseif (!empty($
|
112 |
-
{
|
113 |
iqblockcountry_install_loggingdb();
|
114 |
}
|
115 |
}
|
116 |
}
|
117 |
|
118 |
|
119 |
-
function iqblockcountry_logging($
|
120 |
{
|
121 |
global $wpdb;
|
122 |
|
123 |
-
$
|
124 |
|
125 |
-
$
|
126 |
-
$wpdb->insert($
|
127 |
}
|
128 |
|
129 |
-
function iqblockcountry_debug_logging($
|
130 |
{
|
131 |
-
if (get_option('blockcountry_debuglogging'))
|
132 |
-
{
|
133 |
global $wpdb;
|
134 |
|
135 |
-
$
|
136 |
-
$
|
137 |
|
138 |
-
$
|
139 |
-
$wpdb->insert($
|
140 |
}
|
141 |
}
|
1 |
<?php
|
2 |
|
3 |
+
function iqblockcountry_install_db()
|
4 |
+
{
|
5 |
+
global $wpdb;
|
6 |
|
7 |
+
$iqbc_table_name = $wpdb->prefix . "iqblock_logging";
|
8 |
|
9 |
+
$iqbc_sql = "CREATE TABLE $iqbc_table_name (
|
10 |
id bigint(20) NOT NULL AUTO_INCREMENT,
|
11 |
datetime datetime NOT NULL,
|
12 |
ipaddress tinytext NOT NULL,
|
17 |
KEY `datetime` (`datetime`)
|
18 |
);";
|
19 |
|
20 |
+
include_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
21 |
+
dbDelta($iqbc_sql);
|
22 |
}
|
23 |
|
24 |
|
25 |
+
function iqblockcountry_uninstall_db()
|
26 |
+
{
|
27 |
+
global $wpdb;
|
28 |
|
29 |
+
$iqbc_table_name = $wpdb->prefix . "iqblock_logging";
|
30 |
|
31 |
+
$iqbc_sql = "DROP TABLE IF EXISTS `$iqbc_table_name`;";
|
32 |
|
33 |
+
$wpdb->query($iqbc_sql);
|
34 |
|
35 |
+
delete_option("blockcountry_dbversion");
|
36 |
}
|
37 |
|
38 |
function iqblockcountry_clean_db()
|
39 |
{
|
40 |
+
global $wpdb;
|
41 |
|
42 |
+
$iqbc_nrdays = get_option('blockcountry_daysstatistics');
|
43 |
+
if (empty($iqbc_nrdays)) { $iqbc_nrdays = 30;
|
44 |
+
}
|
45 |
|
46 |
+
$iqbc_table_name = $wpdb->prefix . "iqblock_logging";
|
47 |
+
$iqbc_sql = $wpdb->prepare("DELETE FROM " . $iqbc_table_name . " WHERE `datetime` < DATE_SUB(NOW(), INTERVAL %d DAY);",$iqbc_nrdays);
|
48 |
|
49 |
+
$wpdb->query($iqbc_sql);
|
50 |
|
51 |
}
|
52 |
|
53 |
|
54 |
+
function iqblockcountry_update_db_check()
|
55 |
+
{
|
56 |
+
if (get_site_option('blockcountry_dbversion') != DBVERSION) {
|
57 |
iqblockcountry_install_db();
|
58 |
+
update_option("blockcountry_dbversion", DBVERSION);
|
59 |
}
|
60 |
}
|
61 |
|
62 |
+
function iqblockcountry_install_loggingdb()
|
63 |
+
{
|
64 |
+
global $wpdb;
|
65 |
|
66 |
+
$iqbc_table_name = $wpdb->prefix . "iqblock_debug_logging";
|
67 |
|
68 |
+
$iqbc_sql = "CREATE TABLE $iqbc_table_name (
|
69 |
id bigint(20) NOT NULL AUTO_INCREMENT,
|
70 |
datetime datetime NOT NULL,
|
71 |
ipaddress tinytext NOT NULL,
|
76 |
PRIMARY KEY id (id)
|
77 |
);";
|
78 |
|
79 |
+
include_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
80 |
+
dbDelta($iqbc_sql);
|
81 |
}
|
82 |
|
83 |
+
function iqblockcountry_uninstall_loggingdb()
|
84 |
+
{
|
85 |
+
global $wpdb;
|
86 |
|
87 |
+
$iqbc_table_name = $wpdb->prefix . "iqblock_debug_logging";
|
88 |
|
89 |
+
$iqbc_sql = "DROP TABLE IF EXISTS `$iqbc_table_name`;";
|
90 |
|
91 |
+
$wpdb->query($iqbc_sql);
|
92 |
|
93 |
+
delete_option("blockcountry_dbversion2");
|
94 |
}
|
95 |
|
96 |
function iqblockcountry_clean_loggingdb()
|
97 |
{
|
98 |
+
global $wpdb;
|
99 |
|
100 |
+
$iqbc_table_name = $wpdb->prefix . "iqblock_debug_logging";
|
101 |
+
$iqbc_sql = "DELETE FROM " . $iqbc_table_name . " WHERE `datetime` < DATE_SUB(NOW(), INTERVAL 14 DAY);";
|
102 |
+
// $iqbc_sql = "DELETE FROM " . $iqbc_table_name . " WHERE DATE_SUB(CURDATE(),INTERVAL 14 DAY) >= datetime;";
|
103 |
+
$wpdb->query($iqbc_sql);
|
104 |
}
|
105 |
|
106 |
/*
|
107 |
* Schedule debug logging if this option was set in the admin panel
|
108 |
*/
|
109 |
+
function iqblockcountry_blockcountry_debuglogging($iqbc_old_value, $iqbc_new_value)
|
110 |
{
|
111 |
+
if ($iqbc_old_value !== $iqbc_new_value) {
|
112 |
+
if ($iqbc_new_value == '') {
|
|
|
|
|
113 |
iqblockcountry_uninstall_loggingdb();
|
114 |
}
|
115 |
+
elseif (!empty($iqbc_new_value)) {
|
|
|
116 |
iqblockcountry_install_loggingdb();
|
117 |
}
|
118 |
}
|
119 |
}
|
120 |
|
121 |
|
122 |
+
function iqblockcountry_logging($iqbc_ipaddress,$iqbc_country,$iqbc_banned)
|
123 |
{
|
124 |
global $wpdb;
|
125 |
|
126 |
+
$iqbc_urlRequested = (isset($_SERVER["REQUEST_URI"]) ? htmlspecialchars($_SERVER["REQUEST_URI"]) : '/' );
|
127 |
|
128 |
+
$iqbc_table_name = $wpdb->prefix . "iqblock_logging";
|
129 |
+
$wpdb->insert($iqbc_table_name, array ('datetime' => current_time('mysql'), 'ipaddress' => $iqbc_ipaddress, 'country' => $iqbc_country, 'banned' => $iqbc_banned,'url' => $iqbc_urlRequested));
|
130 |
}
|
131 |
|
132 |
+
function iqblockcountry_debug_logging($iqbc_ipaddress,$iqbc_country,$iqbc_banned)
|
133 |
{
|
134 |
+
if (get_option('blockcountry_debuglogging')) {
|
|
|
135 |
global $wpdb;
|
136 |
|
137 |
+
$iqbc_urlRequested = (isset($_SERVER["REQUEST_URI"]) ? htmlspecialchars($_SERVER["REQUEST_URI"]) : '/' );
|
138 |
+
$iqbc_type = htmlspecialchars($_SERVER['REQUEST_METHOD']);
|
139 |
|
140 |
+
$iqbc_table_name = $wpdb->prefix . "iqblock_debug_logging";
|
141 |
+
$wpdb->insert($iqbc_table_name, array ('datetime' => current_time('mysql'), 'ipaddress' => $iqbc_ipaddress, 'type' => $iqbc_type, 'country' => $iqbc_country, 'banned' => $iqbc_banned,'url' => $iqbc_urlRequested));
|
142 |
}
|
143 |
}
|
libs/blockcountry-search-engines.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
global $
|
4 |
-
$
|
5 |
"Alexa" => "ia_archiver",
|
6 |
"AppleBot" => "Applebot",
|
7 |
"Ask" => "ask jeeves",
|
@@ -42,20 +42,18 @@ $searchengines = array(
|
|
42 |
"Yandex" => "yandexbot"
|
43 |
);
|
44 |
|
45 |
-
function iqblockcountry_check_searchengine($
|
46 |
{
|
47 |
-
global $
|
48 |
-
$
|
49 |
-
foreach ( $
|
50 |
-
if (is_array($
|
51 |
-
|
52 |
-
|
53 |
-
{
|
54 |
-
$issearchengine = TRUE;
|
55 |
}
|
56 |
}
|
57 |
}
|
58 |
-
return $
|
59 |
}
|
60 |
|
61 |
?>
|
1 |
<?php
|
2 |
|
3 |
+
global $iqbc_searchengines;
|
4 |
+
$iqbc_searchengines = array(
|
5 |
"Alexa" => "ia_archiver",
|
6 |
"AppleBot" => "Applebot",
|
7 |
"Ask" => "ask jeeves",
|
42 |
"Yandex" => "yandexbot"
|
43 |
);
|
44 |
|
45 |
+
function iqblockcountry_check_searchengine($iqbc_user_agent,$iqbc_allowse)
|
46 |
{
|
47 |
+
global $iqbc_searchengines;
|
48 |
+
$iqbc_issearchengine = false;
|
49 |
+
foreach ( $iqbc_searchengines AS $iqbc_se => $iqbc_seua ) {
|
50 |
+
if (is_array($iqbc_allowse) && in_array($iqbc_se, $iqbc_allowse)) {
|
51 |
+
if(stripos($iqbc_user_agent, $iqbc_seua) !== false) {
|
52 |
+
$iqbc_issearchengine = true;
|
|
|
|
|
53 |
}
|
54 |
}
|
55 |
}
|
56 |
+
return $iqbc_issearchengine;
|
57 |
}
|
58 |
|
59 |
?>
|
libs/blockcountry-settings.php
CHANGED
@@ -1,106 +1,38 @@
|
|
1 |
<?php
|
2 |
|
3 |
/* Check if the Geo Database exists or if GeoIP API key is entered otherwise display notification */
|
4 |
-
if (!is_file
|
5 |
-
add_action(
|
6 |
-
}
|
7 |
-
|
8 |
-
/* Check if the Geo Database exists or if GeoIP API key is entered otherwise display notification */
|
9 |
-
if ((is_file(IPV4DBFILE) && !is_file ( GEOIP2DBFILE )) && (!get_option('blockcountry_geoapikey'))) {
|
10 |
-
add_action( 'admin_notices', 'iq_missing_dbgeoip2_notice' );
|
11 |
}
|
12 |
|
13 |
/* check if caching plugins are active, if so display notice */
|
14 |
-
|
15 |
-
|
16 |
-
{
|
17 |
-
add_action( 'admin_notices', 'iq_cachingisactive_notice' );
|
18 |
-
}
|
19 |
-
|
20 |
-
|
21 |
-
/*
|
22 |
-
* Unzip the MaxMind IPv4 database if somebody uploaded it in GZIP format
|
23 |
-
*/
|
24 |
-
if (is_file(IPV4DBFILE . ".gz"))
|
25 |
-
{
|
26 |
-
$zd = gzopen ( IPV4DBFILE . ".gz", "r" );
|
27 |
-
$buffer = gzread ( $zd, 2000000 );
|
28 |
-
gzclose ( $zd );
|
29 |
-
if (is_file ( IPV4DBFILE . ".gz" )) { unlink ( IPV4DBFILE . ".gz" ); }
|
30 |
-
|
31 |
-
/* Write this file to the GeoIP database file */
|
32 |
-
if (is_file ( IPV4DBFILE )) { unlink ( IPV4DBFILE ); }
|
33 |
-
$fp = fopen ( IPV4DBFILE, "w" );
|
34 |
-
fwrite ( $fp, "$buffer" );
|
35 |
-
fclose ( $fp );
|
36 |
-
}
|
37 |
-
|
38 |
-
/*
|
39 |
-
* Unzip the MaxMind IPv6 database if somebody uploaded it in GZIP format
|
40 |
-
*/
|
41 |
-
if (is_file(IPV6DBFILE . ".gz"))
|
42 |
-
{
|
43 |
-
$zd = gzopen ( IPV6DBFILE . ".gz", "r" );
|
44 |
-
$buffer = gzread ( $zd, 2000000 );
|
45 |
-
gzclose ( $zd );
|
46 |
-
if (is_file ( IPV6DBFILE . ".gz" )) { unlink ( IPV6DBFILE . ".gz" ); }
|
47 |
-
|
48 |
-
/* Write this file to the GeoIP database file */
|
49 |
-
if (is_file ( IPV6DBFILE )) { unlink ( IPV6DBFILE ); }
|
50 |
-
$fp = fopen ( IPV6DBFILE, "w" );
|
51 |
-
fwrite ( $fp, "$buffer" );
|
52 |
-
fclose ( $fp );
|
53 |
}
|
54 |
|
55 |
-
|
56 |
-
/*
|
57 |
* Display missing database notification.
|
58 |
-
|
59 |
function iq_missing_db_notice()
|
60 |
{
|
61 |
-
|
62 |
-
{
|
63 |
?>
|
64 |
<div class="notice notice-error">
|
65 |
<h3>iQ Block Country</h3>
|
66 |
-
<p><?php
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
<b><?php
|
72 |
|
73 |
-
|
74 |
|
75 |
</div>
|
76 |
-
|
77 |
-
|
78 |
}
|
79 |
|
80 |
-
/*
|
81 |
-
* Display missing GeoIP2 database notification.
|
82 |
-
*/
|
83 |
-
function iq_missing_dbgeoip2_notice()
|
84 |
-
{
|
85 |
-
if (is_file(IPV4DBFILE) && !(is_file(GEOIP2DBFILE)))
|
86 |
-
{
|
87 |
-
?>
|
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> "; ?>
|
95 |
-
<?php _e("unzip the file and afterwards upload the GeoLite2-Country.mmdb file to the following location: " , 'iq-block-country'); ?>
|
96 |
-
<b><?php echo GEOIP2DBFILE; ?></b></p>
|
97 |
-
|
98 |
-
<p><?php _e('For more detailed instructions take a look at the documentation..', 'iq-block-country'); ?></p>
|
99 |
-
|
100 |
-
</div>
|
101 |
-
<?php
|
102 |
-
}
|
103 |
-
}
|
104 |
|
105 |
|
106 |
/*
|
@@ -111,11 +43,11 @@ function iq_cachingisactive_notice()
|
|
111 |
?>
|
112 |
<div class="notice notice-warning is-dismissible">
|
113 |
<h3>iQ Block Country</h3>
|
114 |
-
<p><?php
|
115 |
-
<p><?php
|
116 |
-
<p><?php
|
117 |
</div>
|
118 |
-
|
119 |
}
|
120 |
|
121 |
|
@@ -128,17 +60,17 @@ function iq_old_db_notice()
|
|
128 |
?>
|
129 |
<div class="notice notice-warning">
|
130 |
<h3>iQ Block Country</h3>
|
131 |
-
<p><?php
|
132 |
-
|
133 |
-
<?php
|
134 |
-
<?php
|
135 |
-
<?php
|
136 |
-
<b><?php
|
137 |
|
138 |
-
|
139 |
|
140 |
</div>
|
141 |
-
|
142 |
}
|
143 |
|
144 |
|
@@ -147,10 +79,10 @@ function iq_old_db_notice()
|
|
147 |
*/
|
148 |
function iqblockcountry_create_menu()
|
149 |
{
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
}
|
155 |
|
156 |
/*
|
@@ -158,49 +90,49 @@ function iqblockcountry_create_menu()
|
|
158 |
*/
|
159 |
function iqblockcountry_register_mysettings()
|
160 |
{
|
161 |
-
|
162 |
-
|
163 |
-
register_setting
|
164 |
-
register_setting
|
165 |
-
register_setting
|
166 |
-
register_setting
|
167 |
-
register_setting
|
168 |
-
register_setting
|
169 |
-
register_setting
|
170 |
-
register_setting
|
171 |
-
register_setting
|
172 |
-
register_setting
|
173 |
-
register_setting
|
174 |
-
register_setting
|
175 |
-
register_setting
|
176 |
-
register_setting
|
177 |
-
register_setting
|
178 |
-
register_setting
|
179 |
-
|
180 |
-
|
181 |
-
register_setting
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
register_setting
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
register_setting
|
194 |
-
register_setting
|
195 |
-
register_setting
|
196 |
-
register_setting
|
197 |
-
register_setting
|
198 |
-
register_setting
|
199 |
-
register_setting
|
200 |
-
register_setting
|
201 |
-
register_setting
|
202 |
-
register_setting
|
203 |
-
register_setting
|
204 |
}
|
205 |
|
206 |
/**
|
@@ -208,8 +140,9 @@ function iqblockcountry_register_mysettings()
|
|
208 |
*
|
209 |
* @return array of options.
|
210 |
*/
|
211 |
-
function iqblockcountry_get_options_arr()
|
212 |
-
|
|
|
213 |
'blockcountry_backendblacklist','blockcountry_backendwhitelist','blockcountry_frontendblacklist','blockcountry_frontendwhitelist',
|
214 |
'blockcountry_blockmessage','blockcountry_blocklogin','blockcountry_blockfrontend','blockcountry_blockbackend','blockcountry_header',
|
215 |
'blockcountry_blockpages','blockcountry_blockpages_inverse','blockcountry_pages','blockcountry_blockcategories','blockcountry_categories','blockcountry_tracking',
|
@@ -217,7 +150,7 @@ function iqblockcountry_get_options_arr() {
|
|
217 |
'blockcountry_geoapilocation','blockcountry_apikey','blockcountry_redirect','blockcountry_redirect_url','blockcountry_allowse',
|
218 |
'blockcountry_debuglogging','blockcountry_buffer','blockcountry_accessibility','blockcountry_ipoverride','blockcountry_logging','blockcountry_blockposttypes',
|
219 |
'blockcountry_posttypes','blockcountry_blocksearch','blockcountry_adminajax','blockcountry_blocktag','blockcountry_blockfeed','blockcountry_blocktags','blockcountry_tags');
|
220 |
-
return apply_filters(
|
221 |
}
|
222 |
|
223 |
|
@@ -226,33 +159,48 @@ function iqblockcountry_get_options_arr() {
|
|
226 |
*/
|
227 |
function iqblockcountry_set_defaults()
|
228 |
{
|
229 |
-
update_option('blockcountry_version',VERSION);
|
230 |
-
$
|
231 |
-
$
|
232 |
-
$usercountry = iqblockcountry_check_ipaddress($
|
233 |
-
$
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
if (get_option('blockcountry_backendnrblocks') === FALSE) { update_option('blockcountry_backendnrblocks', 0); }
|
239 |
-
if (get_option('blockcountry_frontendnrblocks') === FALSE) { update_option('blockcountry_frontendnrblocks', 0); }
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
iqblockcountry_install_db();
|
253 |
-
|
254 |
-
|
255 |
-
|
|
|
|
|
|
|
256 |
iqblockcountry_find_geoip_location();
|
257 |
}
|
258 |
|
@@ -261,20 +209,20 @@ function iqblockcountry_uninstall() //deletes all the database entries that the
|
|
261 |
{
|
262 |
iqblockcountry_uninstall_db();
|
263 |
iqblockcountry_uninstall_loggingdb();
|
264 |
-
|
265 |
-
delete_option('blockcountry_banlist_inverse'
|
266 |
-
|
267 |
delete_option('blockcountry_backendbanlist_inverse');
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
delete_option('blockcountry_version');
|
279 |
delete_option('blockcountry_header');
|
280 |
delete_option('blockcountry_blockpages');
|
@@ -312,832 +260,800 @@ function iqblockcountry_uninstall() //deletes all the database entries that the
|
|
312 |
|
313 |
|
314 |
|
315 |
-
function iqblockcountry_settings_tools()
|
|
|
316 |
?>
|
317 |
-
<h3><?php
|
318 |
|
319 |
-
|
320 |
-
<input type="hidden" name="action" value="
|
321 |
-
<input name="
|
322 |
-
<?php
|
323 |
-
<?php
|
324 |
-
global $
|
325 |
-
global $
|
326 |
-
|
327 |
-
|
328 |
-
if ( isset($_POST['action']) && $_POST[ 'action' ] == 'ipcheck') {
|
329 |
-
if (!isset($_POST['ipcheck_nonce'])) die("Failed security check.");
|
330 |
-
if (!wp_verify_nonce($_POST['ipcheck_nonce'],'ipcheck_nonce')) die("Is this a CSRF attempts?");
|
331 |
-
if (isset($_POST['ipaddress']) && !empty($_POST['ipaddress']))
|
332 |
-
{
|
333 |
-
if (iqblockcountry_is_valid_ipv4($_POST['ipaddress']) || iqblockcountry_is_valid_ipv6($_POST['ipaddress']))
|
334 |
-
{
|
335 |
-
if (filter_var($_POST['ipaddress'], FILTER_VALIDATE_IP))
|
336 |
-
{ $ip_address = $_POST['ipaddress']; }
|
337 |
-
$country = iqblockcountry_check_ipaddress($ip_address);
|
338 |
-
$countrylist = iqblockcountry_get_isocountries();
|
339 |
-
if ($country == "Unknown" || $country == "ipv6" || $country == "" || $country == "FALSE")
|
340 |
-
{
|
341 |
-
echo "<p>" . __('No country for', 'iq-block-country') . ' ' . $ip_address . ' ' . __('could be found. Or', 'iq-block-country') . ' ' . $ip_address . ' ' . __('is not a valid IPv4 or IPv6 IP address', 'iq-block-country');
|
342 |
-
echo "</p>";
|
343 |
-
}
|
344 |
-
else {
|
345 |
-
$displaycountry = $countrylist[$country];
|
346 |
-
echo "<p>" . __('IP Adress', 'iq-block-country') . ' ' . $ip_address . ' ' . __('belongs to', 'iq-block-country') . ' ' . $displaycountry . ".</p>";
|
347 |
-
$haystack = get_option('blockcountry_banlist');
|
348 |
-
if (!is_array($haystack)) { $haystack = array(); }
|
349 |
-
$inverse = get_option( 'blockcountry_banlist_inverse');
|
350 |
-
if ($inverse == "on") {
|
351 |
-
if (is_array($haystack) && !in_array ($country, $haystack )) {
|
352 |
-
_e('This country is not permitted to visit the frontend of this website.', 'iq-block-country');
|
353 |
-
echo "<br />";
|
354 |
-
}
|
355 |
-
} else {
|
356 |
-
if (is_array($haystack) && in_array ( $country, $haystack )) {
|
357 |
-
_e('This country is not permitted to visit the frontend of this website.', 'iq-block-country');
|
358 |
-
echo "<br />";
|
359 |
-
}
|
360 |
-
}
|
361 |
-
$inverse = get_option( 'blockcountry_backendbanlist_inverse');
|
362 |
-
$haystack = get_option('blockcountry_backendbanlist');
|
363 |
-
if (!is_array($haystack)) { $haystack = array(); }
|
364 |
-
if ($inverse == "on") {
|
365 |
-
if (is_array($haystack) && !in_array ( $country, $haystack )) {
|
366 |
-
_e('This country is not permitted to visit the backend of this website.', 'iq-block-country');
|
367 |
-
echo "<br />";
|
368 |
-
}
|
369 |
-
}
|
370 |
-
else
|
371 |
-
{
|
372 |
-
if (is_array($haystack) && in_array ( $country, $haystack )) {
|
373 |
-
_e('This country is not permitted to visit the backend of this website.', 'iq-block-country');
|
374 |
-
echo "<br />";
|
375 |
-
}
|
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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
404 |
}
|
405 |
-
}
|
406 |
-
|
407 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
408 |
wp_nonce_field('iqblockcountry');
|
409 |
|
410 |
-
|
411 |
</form>
|
412 |
|
413 |
<hr />
|
414 |
|
415 |
-
<h3><?php
|
416 |
<?php
|
417 |
|
418 |
-
$
|
419 |
-
if (!get_option('blockcountry_geoapikey'))
|
420 |
-
|
421 |
-
if (!is_file ( GEOIP2DBFILE ))
|
422 |
-
{
|
423 |
-
/* Check if the Geo Database exists */
|
424 |
-
if (is_file ( IPV4DBFILE )) {
|
425 |
-
|
426 |
-
_e("IPv4 database exists. File date: ", 'iq-block-country');
|
427 |
-
$iqfiledate = filemtime(IPV4DBFILE);
|
428 |
-
echo date ($format,$iqfiledate);
|
429 |
-
echo " ";
|
430 |
-
$iq3months = time() - 3 * 31 * 86400;
|
431 |
-
if ($iqfiledate < $iq3months)
|
432 |
-
{
|
433 |
-
_e("Database is older than 3 months... Please update...", 'iq-block-country');
|
434 |
-
}
|
435 |
-
}
|
436 |
-
else
|
437 |
-
{
|
438 |
-
_e("IPv4 database does not exist.", 'iq-block-country');
|
439 |
-
}
|
440 |
-
echo "<br />";
|
441 |
-
|
442 |
-
if (is_file ( IPV6DBFILE )) {
|
443 |
|
444 |
-
|
445 |
-
$
|
446 |
-
echo date
|
447 |
echo " ";
|
448 |
-
$
|
449 |
-
if ($
|
450 |
-
|
451 |
-
_e("Database is older than 3 months... Please update...", 'iq-block-country');
|
452 |
}
|
453 |
}
|
454 |
else
|
455 |
{
|
456 |
-
|
457 |
-
}
|
458 |
echo "<br />";
|
459 |
}
|
460 |
-
if (
|
461 |
-
|
462 |
-
|
463 |
-
$
|
464 |
-
echo date ($format,$iqfiledate);
|
465 |
-
echo " ";
|
466 |
-
$iq3months = time() - 3 * 31 * 86400;
|
467 |
-
if ($iqfiledate < $iq3months)
|
468 |
-
{
|
469 |
-
_e("Database is older than 3 months... Please update...", 'iq-block-country');
|
470 |
-
}
|
471 |
-
}
|
472 |
-
else
|
473 |
-
{
|
474 |
-
_e("GeoIP2 database does not exist.", 'iq-block-country');
|
475 |
-
}
|
476 |
-
echo "<br />";
|
477 |
-
}
|
478 |
-
if (get_option('blockcountry_geoapikey'))
|
479 |
-
{
|
480 |
-
$licensedate = strtotime(iqblockcountry_get_licensedate_geoapikey(get_option('blockcountry_geoapikey')));
|
481 |
-
_e("Your GeoIP API key is valid till: ", 'iq-block-country');
|
482 |
-
echo date($format,$licensedate);
|
483 |
echo "<br />";
|
484 |
-
$
|
485 |
-
|
486 |
-
|
487 |
}
|
488 |
?>
|
489 |
<br />
|
490 |
<br />
|
491 |
|
492 |
-
<h3><?php
|
493 |
|
494 |
<div class="wrap">
|
495 |
<div id="icon-tools" class="icon32"><br /></div>
|
496 |
-
<p><?php
|
497 |
|
498 |
-
<?php $
|
499 |
-
<p><?php
|
500 |
-
<?php $
|
501 |
-
<p><?php
|
502 |
|
503 |
<form method='post'>
|
504 |
<p class="submit">
|
505 |
<?php wp_nonce_field('iqblockresetcounter'); ?>
|
506 |
-
<input type='submit' name='
|
507 |
</p>
|
508 |
</form>
|
509 |
</div>
|
510 |
<?php
|
511 |
-
if ((isset($_POST['
|
512 |
-
update_option('blockcountry_backendnrblocks',0);
|
513 |
-
update_option('blockcountry_frontendnrblocks',0);
|
514 |
-
|
515 |
}
|
516 |
?>
|
517 |
-
<h3><?php
|
518 |
<?php
|
519 |
|
520 |
-
$
|
521 |
-
$
|
522 |
|
523 |
echo '<table class="widefat">';
|
524 |
-
echo '<thead><tr><th>' .
|
525 |
|
526 |
-
|
527 |
-
if (
|
528 |
-
|
529 |
-
|
530 |
-
echo '<td>' . $
|
531 |
-
echo '<td>' . $
|
532 |
-
echo '<td>' . $
|
533 |
echo "</tr></tbody>";
|
534 |
}
|
535 |
}
|
536 |
echo '</table>';
|
537 |
-
echo $
|
538 |
global $wpdb;
|
539 |
|
540 |
-
$
|
541 |
|
542 |
-
if (
|
543 |
-
$
|
544 |
}
|
545 |
|
546 |
-
$
|
547 |
-
$
|
548 |
|
549 |
-
$
|
550 |
-
$
|
551 |
|
552 |
|
553 |
?>
|
554 |
-
<h3><?php
|
555 |
|
556 |
<table class="widefat">
|
557 |
-
<tbody><tr><td><?php
|
558 |
-
<tbody><tr><td><?php
|
559 |
</table>
|
560 |
|
561 |
|
562 |
-
<h3><?php
|
563 |
<table class="widefat">
|
564 |
-
<tbody><tr><td><?php
|
565 |
-
<tbody><tr><td><?php
|
566 |
-
<tbody><tr><td><?php
|
567 |
-
<?php $
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
<tbody><tr><td><?php
|
578 |
</table>
|
579 |
|
580 |
|
581 |
-
<h3><?php
|
582 |
|
583 |
<table class="widefat">
|
584 |
|
585 |
-
|
586 |
-
<tbody><tr><td><?php
|
587 |
-
|
588 |
-
|
589 |
-
<tbody><tr><td><?php _e( 'Operating System', 'iq-block-country' ); ?>: <strong><?php echo PHP_OS; ?></strong></td></tr></tbody>
|
590 |
-
<tbody><tr><td><?php _e( 'Browser Compression Supported', 'iq-block-country' ); ?>:
|
591 |
-
<strong><?php echo filter_var( $_SERVER['HTTP_ACCEPT_ENCODING'], FILTER_SANITIZE_STRING ); ?></strong></td></tr></tbody>
|
592 |
<?php
|
593 |
|
594 |
-
if (
|
595 |
|
596 |
-
$
|
597 |
|
598 |
-
|
599 |
|
600 |
-
|
601 |
-
|
602 |
|
603 |
-
|
604 |
}
|
605 |
|
606 |
-
$
|
607 |
|
608 |
-
if (
|
609 |
-
$
|
610 |
}
|
611 |
|
612 |
?>
|
613 |
-
<tbody><tr><td><?php
|
614 |
-
<strong><?php echo $
|
615 |
</table>
|
616 |
|
617 |
|
618 |
-
<h3><?php
|
619 |
|
620 |
<table class="widefat">
|
621 |
|
622 |
|
623 |
-
<tbody><tr><td><?php
|
624 |
-
<tbody><tr><td><?php
|
625 |
|
626 |
<?php
|
627 |
-
if (
|
628 |
-
$
|
629 |
} else {
|
630 |
-
$
|
631 |
}
|
632 |
?>
|
633 |
-
<tbody><tr><td><?php
|
634 |
<?php
|
635 |
-
if (
|
636 |
-
$
|
637 |
} else {
|
638 |
-
$
|
639 |
}
|
640 |
?>
|
641 |
-
<tbody><tr><td><?php
|
642 |
<?php
|
643 |
-
if (
|
644 |
-
$
|
645 |
} else {
|
646 |
-
$
|
647 |
}
|
648 |
?>
|
649 |
-
<tbody><tr><td><?php
|
650 |
<?php
|
651 |
-
if (
|
652 |
-
$
|
653 |
} else {
|
654 |
-
$
|
655 |
}
|
656 |
?>
|
657 |
-
<tbody><tr><td><?php
|
658 |
<?php
|
659 |
-
if (
|
660 |
-
$
|
661 |
} else {
|
662 |
-
$
|
663 |
}
|
664 |
?>
|
665 |
-
<tbody><tr><td><?php
|
666 |
<?php
|
667 |
-
if (
|
668 |
-
$
|
669 |
} else {
|
670 |
-
$
|
671 |
}
|
672 |
?>
|
673 |
-
<tbody><tr><td><?php
|
674 |
<?php
|
675 |
-
if (
|
676 |
-
$
|
677 |
} else {
|
678 |
-
$
|
679 |
}
|
680 |
?>
|
681 |
-
<tbody><tr><td><?php
|
682 |
-
<strong><?php echo $
|
683 |
<?php
|
684 |
-
if (
|
685 |
-
$
|
686 |
} else {
|
687 |
-
$
|
688 |
}
|
689 |
?>
|
690 |
-
<tbody><tr><td><?php
|
691 |
<?php
|
692 |
-
if (
|
693 |
-
$
|
694 |
} else {
|
695 |
-
$
|
696 |
}
|
697 |
?>
|
698 |
-
<tbody><tr><td><?php
|
699 |
-
<strong><?php echo $
|
700 |
<?php
|
701 |
-
if (
|
702 |
-
$
|
703 |
} else {
|
704 |
-
$
|
705 |
}
|
706 |
?>
|
707 |
-
<tbody><tr><td><?php
|
708 |
<?php
|
709 |
-
if (
|
710 |
-
$
|
711 |
} else {
|
712 |
-
$
|
713 |
}
|
714 |
?>
|
715 |
-
<tbody><tr><td><?php
|
716 |
<?php
|
717 |
-
if (
|
718 |
-
$
|
719 |
} else {
|
720 |
-
$
|
721 |
}
|
722 |
?>
|
723 |
-
<tbody><tr><td><?php
|
724 |
-
<?php $
|
725 |
-
<tbody><tr><td><?php
|
726 |
|
727 |
|
728 |
</table>
|
729 |
|
730 |
|
731 |
|
732 |
-
<h3><?php
|
733 |
|
734 |
<table class="widefat">
|
735 |
<?php
|
736 |
-
if (
|
737 |
-
$
|
738 |
} else {
|
739 |
-
$
|
740 |
}
|
741 |
?>
|
742 |
-
<tbody><tr><td><?php
|
743 |
<?php
|
744 |
-
if (
|
745 |
-
$
|
746 |
} else {
|
747 |
-
$
|
748 |
}
|
749 |
?>
|
750 |
-
<tbody><tr><td><?php
|
751 |
-
<strong> <?php echo $
|
752 |
-
<tbody><tr><td><?php
|
753 |
</table>
|
754 |
|
755 |
<br />
|
756 |
<br />
|
757 |
-
<h3><?php
|
758 |
|
759 |
<?php
|
760 |
echo "<br />HTTP_CF_CONNECTING_IP: ";
|
761 |
-
if (
|
762 |
-
|
|
|
|
|
763 |
}
|
764 |
-
else { _e('Not set', 'iq-block-country'); }
|
765 |
echo "<br />HTTP_X_SUCURI_CLIENTIP: ";
|
766 |
-
if (
|
767 |
-
|
|
|
|
|
768 |
}
|
769 |
-
else { _e('Not set', 'iq-block-country'); }
|
770 |
echo "<br />HTTP_INCAP_CLIENT_IP: ";
|
771 |
-
if (
|
772 |
-
|
|
|
|
|
773 |
}
|
774 |
-
else { _e('Not set', 'iq-block-country'); }
|
775 |
echo "<br />HTTP_X_FORWARDED_FOR: ";
|
776 |
-
if (
|
777 |
-
|
778 |
}
|
779 |
-
else {
|
|
|
780 |
echo "<br />HTTP_X_FORWARDED: ";
|
781 |
-
if (
|
782 |
-
|
|
|
|
|
783 |
}
|
784 |
-
else { _e('Not set', 'iq-block-country'); }
|
785 |
echo "<br />HTTP_CLIENT_IP: ";
|
786 |
-
if (
|
787 |
-
|
|
|
|
|
788 |
}
|
789 |
-
else { _e('Not set', 'iq-block-country'); }
|
790 |
echo "<br />HTTP_X_REAL_IP: ";
|
791 |
-
if (
|
792 |
-
|
793 |
}
|
794 |
-
else {
|
|
|
795 |
echo "<br />HTTP_FORWARDED: ";
|
796 |
-
if (
|
797 |
-
|
|
|
|
|
798 |
}
|
799 |
-
else { _e('Not set', 'iq-block-country'); }
|
800 |
echo "<br />REMOTE_ADDR: ";
|
801 |
-
if (
|
802 |
-
|
|
|
|
|
803 |
}
|
804 |
-
else { _e('Not set', 'iq-block-country'); }
|
805 |
|
806 |
?>
|
807 |
|
808 |
-
<?php
|
809 |
}
|
810 |
|
811 |
/*
|
812 |
* Function: Import/Export settings
|
813 |
*/
|
814 |
-
function iqblockcountry_settings_importexport()
|
815 |
-
|
816 |
-
|
|
|
817 |
?>
|
818 |
<div class="wrap">
|
819 |
<div id="icon-tools" class="icon32"><br /></div>
|
820 |
-
<h2><?php
|
821 |
-
<p><?php
|
822 |
-
<p><?php
|
823 |
<form method='post'>
|
824 |
<p class="submit">
|
825 |
<?php wp_nonce_field('iqblockexport'); ?>
|
826 |
-
<input type='submit' name='
|
827 |
</p>
|
828 |
</form>
|
829 |
</div>
|
830 |
|
831 |
<div class="wrap">
|
832 |
<div id="icon-tools" class="icon32"><br /></div>
|
833 |
-
<h2><?php
|
834 |
-
<p><?php
|
835 |
-
<p><?php
|
836 |
<form method='post' enctype='multipart/form-data'>
|
837 |
<p class="submit">
|
838 |
<?php wp_nonce_field('iqblockimport'); ?>
|
839 |
-
<input type='file' name='
|
840 |
-
<input type='submit' name='
|
841 |
</p>
|
842 |
</form>
|
843 |
</div>
|
844 |
<?php
|
845 |
}
|
846 |
-
elseif (isset($_POST['
|
847 |
|
848 |
-
$
|
849 |
-
$
|
850 |
-
$
|
851 |
-
$
|
852 |
-
$json_name = $blogname."-".$date . "-" . $resultrand; // Filename will be generated with random string.
|
853 |
|
854 |
-
$
|
855 |
-
foreach ( $
|
856 |
-
$
|
857 |
-
$need_options[$
|
858 |
}
|
859 |
|
860 |
-
$
|
861 |
|
862 |
-
if (
|
863 |
-
wp_die(
|
|
|
864 |
|
865 |
-
if (
|
866 |
-
wp_die(
|
|
|
867 |
|
868 |
-
fclose(
|
869 |
|
870 |
-
chdir(
|
871 |
-
$
|
872 |
-
$
|
873 |
-
$
|
874 |
-
$
|
875 |
-
foreach ($
|
876 |
-
|
877 |
}
|
878 |
-
$
|
879 |
-
unlink($
|
880 |
|
881 |
-
$
|
882 |
-
$
|
883 |
|
884 |
-
if (
|
885 |
-
$
|
886 |
-
document.location = \'' . $
|
887 |
</script>';
|
888 |
} else {
|
889 |
-
$
|
890 |
}
|
891 |
-
echo $
|
892 |
}
|
893 |
-
elseif (isset($_POST['
|
894 |
-
$
|
895 |
-
if (isset($_FILES['
|
896 |
-
if (($_FILES['
|
897 |
-
wp_die(
|
898 |
}
|
899 |
else
|
900 |
{
|
901 |
-
$
|
902 |
-
$
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
update_option($key, $value);
|
916 |
-
}
|
917 |
}
|
918 |
-
unlink($dir['path'] . '/iqblockcountry.ini');
|
919 |
-
|
920 |
-
echo "<div class='notice notice-success'><p>" . __("All options are restored successfully.", 'iq-block-country') . "</p></div>";
|
921 |
}
|
922 |
-
|
923 |
-
|
924 |
-
|
|
|
|
|
|
|
|
|
925 |
}
|
926 |
}
|
927 |
else {
|
928 |
-
wp_die(
|
929 |
}
|
930 |
}
|
931 |
-
else { wp_die(
|
|
|
932 |
|
933 |
}
|
934 |
|
935 |
/*
|
936 |
* Function: Page settings
|
937 |
*/
|
938 |
-
function iqblockcountry_settings_pages()
|
|
|
939 |
?>
|
940 |
-
<h3><?php
|
941 |
<form method="post" action="options.php">
|
942 |
-
<?php
|
943 |
-
settings_fields
|
944 |
-
?>
|
945 |
-
<table class="form-table" cellspacing="2" cellpadding="5" width="100%">
|
946 |
<tr valign="top">
|
947 |
-
<th width="30%"><?php
|
948 |
-
<?php
|
949 |
<td width="70%">
|
950 |
-
|
951 |
</td></tr>
|
952 |
|
953 |
|
954 |
<tr valign="top">
|
955 |
-
<th width="30%"><?php
|
956 |
-
<?php
|
957 |
<td width="70%">
|
958 |
-
<input type="radio" name="blockcountry_blockpages_inverse" value="off" <?php checked('off', get_option('blockcountry_blockpages_inverse'), true); ?> <?php checked(
|
959 |
<input type="radio" name="blockcountry_blockpages_inverse" value="on" <?php checked('on', get_option('blockcountry_blockpages_inverse'), true); ?> />
|
960 |
</td></tr>
|
961 |
|
962 |
<tr valign="top">
|
963 |
-
<th width="30%"><?php
|
964 |
<td width="70%">
|
965 |
|
966 |
-
|
967 |
<?php
|
968 |
-
$
|
969 |
-
$
|
970 |
-
$
|
971 |
-
foreach ( $
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
</td></tr>
|
983 |
<tr><td></td><td>
|
984 |
-
|
985 |
-
|
986 |
-
</td></tr>
|
987 |
-
</table>
|
988 |
</form>
|
989 |
|
990 |
-
|
991 |
}
|
992 |
|
993 |
/*
|
994 |
* Function: Categories settings
|
995 |
*/
|
996 |
-
function iqblockcountry_settings_categories()
|
|
|
997 |
?>
|
998 |
-
<h3><?php
|
999 |
<form method="post" action="options.php">
|
1000 |
-
<?php
|
1001 |
-
settings_fields
|
1002 |
-
?>
|
1003 |
-
<table class="form-table" cellspacing="2" cellpadding="5" width="100%">
|
1004 |
<tr valign="top">
|
1005 |
-
<th width="30%"><?php
|
1006 |
-
<?php
|
1007 |
<td width="70%">
|
1008 |
-
|
1009 |
</td></tr>
|
1010 |
<tr valign="top">
|
1011 |
-
<th width="30%"><?php
|
1012 |
-
<?php
|
1013 |
<td width="70%">
|
1014 |
-
|
1015 |
</td></tr>
|
1016 |
<tr valign="top">
|
1017 |
-
<th width="30%"><?php
|
1018 |
<td width="70%">
|
1019 |
|
1020 |
-
|
1021 |
<?php
|
1022 |
-
$
|
1023 |
-
$
|
1024 |
-
$
|
1025 |
-
foreach ( $
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
</td></tr>
|
1037 |
<tr><td></td><td>
|
1038 |
-
|
1039 |
-
|
1040 |
-
</td></tr>
|
1041 |
-
</table>
|
1042 |
</form>
|
1043 |
|
1044 |
-
|
1045 |
}
|
1046 |
|
1047 |
/*
|
1048 |
* Function: Categories settings
|
1049 |
*/
|
1050 |
-
function iqblockcountry_settings_tags()
|
|
|
1051 |
?>
|
1052 |
-
<h3><?php
|
1053 |
<form method="post" action="options.php">
|
1054 |
-
<?php
|
1055 |
-
settings_fields
|
1056 |
-
?>
|
1057 |
-
<table class="form-table" cellspacing="2" cellpadding="5" width="100%">
|
1058 |
<tr valign="top">
|
1059 |
-
<th width="30%"><?php
|
1060 |
-
<?php
|
1061 |
<td width="70%">
|
1062 |
-
|
1063 |
</td></tr>
|
1064 |
<tr valign="top">
|
1065 |
-
<th width="30%"><?php
|
1066 |
<td width="70%">
|
1067 |
|
1068 |
-
|
1069 |
<?php
|
1070 |
-
$
|
1071 |
-
$
|
1072 |
-
$
|
1073 |
-
foreach ( $
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
</td></tr>
|
1085 |
<tr><td></td><td>
|
1086 |
-
|
1087 |
-
|
1088 |
-
</td></tr>
|
1089 |
-
</table>
|
1090 |
</form>
|
1091 |
|
1092 |
-
|
1093 |
}
|
1094 |
|
1095 |
|
1096 |
/*
|
1097 |
* Function: Custom post type settings
|
1098 |
*/
|
1099 |
-
function iqblockcountry_settings_posttypes()
|
|
|
1100 |
?>
|
1101 |
-
<h3><?php
|
1102 |
<form method="post" action="options.php">
|
1103 |
-
<?php
|
1104 |
-
settings_fields
|
1105 |
-
?>
|
1106 |
-
<table class="form-table" cellspacing="2" cellpadding="5" width="100%">
|
1107 |
<tr valign="top">
|
1108 |
-
<th width="30%"><?php
|
1109 |
<td width="70%">
|
1110 |
-
|
1111 |
</td></tr>
|
1112 |
<tr valign="top">
|
1113 |
-
<th width="30%"><?php
|
1114 |
<td width="70%">
|
1115 |
|
1116 |
-
|
1117 |
<?php
|
1118 |
-
$
|
1119 |
-
$
|
1120 |
-
$
|
1121 |
-
foreach ( $
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
</td></tr>
|
1133 |
<tr><td></td><td>
|
1134 |
-
|
1135 |
-
|
1136 |
-
</td></tr>
|
1137 |
-
</table>
|
1138 |
</form>
|
1139 |
|
1140 |
-
|
1141 |
}
|
1142 |
|
1143 |
|
@@ -1145,46 +1061,47 @@ function iqblockcountry_settings_posttypes() {
|
|
1145 |
/*
|
1146 |
* Function: Services settings
|
1147 |
*/
|
1148 |
-
function iqblockcountry_settings_services()
|
|
|
1149 |
?>
|
1150 |
-
<h3><?php
|
1151 |
<form method="post" action="options.php">
|
1152 |
-
<?php
|
1153 |
-
settings_fields
|
1154 |
-
?>
|
1155 |
-
<table class="form-table" cellspacing="2" cellpadding="5" width="100%">
|
1156 |
<tr valign="top">
|
1157 |
-
<th width="30%"><?php
|
1158 |
-
<?php
|
1159 |
-
<?php
|
1160 |
</th>
|
1161 |
<td width="70%">
|
1162 |
|
1163 |
-
|
1164 |
<?php
|
1165 |
-
global $
|
1166 |
-
$
|
1167 |
-
$
|
1168 |
-
|
1169 |
-
if (is_array($
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
</td></tr>
|
1180 |
<tr><td></td><td>
|
1181 |
-
|
1182 |
-
|
1183 |
-
</td></tr>
|
1184 |
-
</table>
|
1185 |
</form>
|
1186 |
|
1187 |
-
|
1188 |
}
|
1189 |
|
1190 |
|
@@ -1193,112 +1110,109 @@ function iqblockcountry_settings_services() {
|
|
1193 |
*/
|
1194 |
function iqblockcountry_settings_frontend()
|
1195 |
{
|
1196 |
-
?>
|
1197 |
-
<h3><?php
|
1198 |
|
1199 |
<form method="post" action="options.php">
|
1200 |
<?php
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
$
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
else { $displaycountry = $countrylist[$country]; }
|
1215 |
|
1216 |
-
|
1217 |
|
1218 |
-
<link rel="stylesheet" href=<?php echo "\"" . CHOSENCSS . "\""?> type="text/css" />
|
1219 |
|
1220 |
|
1221 |
-
<table class="form-table" cellspacing="2" cellpadding="5" width="100%">
|
1222 |
|
1223 |
<tr valign="top">
|
1224 |
-
<th width="30%"><?php
|
1225 |
<td width="70%">
|
1226 |
-
|
1227 |
</td></tr>
|
1228 |
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
|
1235 |
<tr valign="top">
|
1236 |
-
<th width="30%"><?php
|
1237 |
<td width="70%">
|
1238 |
-
|
1239 |
</td></tr>
|
1240 |
|
1241 |
<tr valign="top">
|
1242 |
-
<th width="30%"><?php
|
1243 |
-
<?php
|
1244 |
<td width="70%">
|
1245 |
-
<input type="radio" name="blockcountry_banlist_inverse" value="off" <?php checked('off', get_option('blockcountry_banlist_inverse'), true); ?> <?php checked(
|
1246 |
<input type="radio" name="blockcountry_banlist_inverse" value="on" <?php checked('on', get_option('blockcountry_banlist_inverse'), true); ?> />
|
1247 |
</td></tr>
|
1248 |
|
1249 |
<tr valign="top">
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
|
1254 |
<?php
|
1255 |
-
$
|
1256 |
-
$
|
1257 |
|
1258 |
-
if (get_option('blockcountry_accessibility'))
|
1259 |
-
{
|
1260 |
echo "<ul>";
|
1261 |
-
foreach ( $
|
1262 |
-
|
1263 |
-
$
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
echo "<li><input type=\"checkbox\" " . $
|
1268 |
}
|
1269 |
echo "</ul>";
|
1270 |
}
|
1271 |
else
|
1272 |
{
|
1273 |
-
|
1274 |
|
1275 |
|
1276 |
<select data-placeholder="Choose a country..." class="chosen" name="blockcountry_banlist[]" multiple="true" style="width:600px;">
|
1277 |
<optgroup label="(de)select all countries">
|
1278 |
<?php
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
print "
|
1285 |
-
|
1286 |
echo "</optgroup>";
|
1287 |
echo " </select>";
|
1288 |
}
|
1289 |
|
1290 |
-
|
1291 |
</td></tr>
|
1292 |
<tr valign="top">
|
1293 |
-
<th width="30%"><?php
|
1294 |
-
<?php
|
1295 |
<td width="70%">
|
1296 |
<input type="checkbox" name="blockcountry_blocktag" <?php checked('on', get_option('blockcountry_blocktag'), true); ?> />
|
1297 |
</td></tr>
|
1298 |
|
1299 |
<tr valign="top">
|
1300 |
-
<th width="30%"><?php
|
1301 |
-
<?php
|
1302 |
<td width="70%">
|
1303 |
<input type="checkbox" name="blockcountry_blockfeed" <?php checked('on', get_option('blockcountry_blockfeed'), true); ?> />
|
1304 |
</td></tr>
|
@@ -1306,33 +1220,33 @@ function iqblockcountry_settings_frontend()
|
|
1306 |
|
1307 |
|
1308 |
<tr valign="top">
|
1309 |
-
<th width="30%"><?php
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
<textarea cols="70" rows="5" name="blockcountry_frontendwhitelist"><?php echo
|
1315 |
-
|
1316 |
<tr valign="top">
|
1317 |
-
<th width="30%"><?php
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
<textarea cols="70" rows="5" name="blockcountry_frontendblacklist"><?php echo
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
</form>
|
1330 |
-
<?php
|
1331 |
-
|
1332 |
-
|
1333 |
{
|
1334 |
-
|
1335 |
-
|
1336 |
|
1337 |
}
|
1338 |
|
@@ -1342,127 +1256,122 @@ function iqblockcountry_settings_frontend()
|
|
1342 |
*/
|
1343 |
function iqblockcountry_settings_backend()
|
1344 |
{
|
1345 |
-
?>
|
1346 |
-
<h3><?php
|
1347 |
|
1348 |
<form method="post" action="options.php">
|
1349 |
<?php
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
$
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
else { $displaycountry = $countrylist[$country]; }
|
1365 |
|
1366 |
|
1367 |
-
|
1368 |
-
|
1369 |
-
<link rel="stylesheet" href=<?php echo "\"" . CHOSENCSS . "\""?> type="text/css" />
|
1370 |
-
|
1371 |
|
1372 |
-
<table class="form-table" cellspacing="2" cellpadding="5" width="100%">
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
</td></tr>
|
1378 |
|
1379 |
<tr>
|
1380 |
<th width="30%"></th>
|
1381 |
<th width="70%">
|
1382 |
-
<?php
|
1383 |
-
<?php
|
1384 |
-
<?php echo "<strong>" .
|
1385 |
</th>
|
1386 |
</tr>
|
1387 |
-
|
1388 |
<tr valign="top">
|
1389 |
-
<th width="30%"><?php
|
1390 |
-
<?php
|
1391 |
<td width="70%">
|
1392 |
-
<input type="radio" name="blockcountry_backendbanlist_inverse" value="off" <?php checked('off', get_option('blockcountry_backendbanlist_inverse'), true); ?> <?php checked(
|
1393 |
<input type="radio" name="blockcountry_backendbanlist_inverse" value="on" <?php checked('on', get_option('blockcountry_backendbanlist_inverse'), true); ?> />
|
1394 |
</td></tr>
|
1395 |
|
1396 |
<tr valign="top">
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
|
1401 |
<?php
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
?> <select class="chosen" data-placeholder="Choose a country..." name="blockcountry_backendbanlist[]" multiple="true" style="width:600px;">
|
1421 |
<optgroup label="(de)select all countries">
|
1422 |
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
print "
|
1430 |
}
|
1431 |
echo "</optgroup>";
|
1432 |
echo " </select>";
|
1433 |
-
|
1434 |
-
|
1435 |
|
1436 |
</td></tr>
|
1437 |
|
1438 |
<tr valign="top">
|
1439 |
-
<th width="30%"><?php
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
<textarea cols="70" rows="5" name="blockcountry_backendwhitelist"><?php echo
|
1445 |
-
|
1446 |
<tr valign="top">
|
1447 |
-
<th width="30%"><?php
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
<textarea cols="70" rows="5" name="blockcountry_backendblacklist"><?php echo
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
</form>
|
1460 |
-
<?php
|
1461 |
-
|
1462 |
-
|
1463 |
{
|
1464 |
-
|
1465 |
-
|
1466 |
|
1467 |
}
|
1468 |
|
@@ -1474,246 +1383,243 @@ function iqblockcountry_settings_backend()
|
|
1474 |
function iqblockcountry_settings_home()
|
1475 |
{
|
1476 |
|
1477 |
-
/* Check if the Geo Database exists or if GeoIP API key is entered otherwise display notification */
|
1478 |
-
if (is_file
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
}
|
1485 |
-
}
|
1486 |
|
1487 |
|
1488 |
-
?>
|
1489 |
-
<h3><?php
|
1490 |
|
1491 |
-
<?php $
|
1492 |
-
<p><?php echo number_format($
|
1493 |
-
<?php $
|
1494 |
-
<p><?php echo number_format($
|
1495 |
|
1496 |
<form method="post" action="options.php">
|
1497 |
<?php
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
?>
|
1507 |
-
|
1508 |
-
<link rel="stylesheet" href=<?php echo "\"" . CHOSENCSS . "\""?> type="text/css" />
|
1509 |
|
1510 |
<hr>
|
1511 |
-
<h3><?php
|
1512 |
<em>
|
1513 |
-
<?php
|
1514 |
</em>
|
1515 |
-
<table class="form-table" cellspacing="2" cellpadding="5" width="100%">
|
1516 |
|
1517 |
<tr valign="top">
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
|
|
1526 |
|
1527 |
|
1528 |
<tr valign="top">
|
1529 |
-
|
1530 |
-
<em><?php
|
1531 |
</th>
|
1532 |
-
|
1533 |
<select class="chosen" name="blockcountry_redirect" style="width:400px;">
|
1534 |
<?php
|
1535 |
-
|
1536 |
-
echo "<option value=\"0\">".
|
1537 |
-
$
|
1538 |
-
|
1539 |
-
|
1540 |
-
if ($
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
</select>
|
1548 |
</td></tr>
|
1549 |
|
1550 |
<tr valign="top">
|
1551 |
-
<th width="30%"><?php
|
1552 |
-
<em><?php
|
1553 |
</th>
|
1554 |
<td width="70%">
|
1555 |
-
<input type="text" style="width:100%" name="blockcountry_redirect_url" value="<?php echo get_option
|
1556 |
</td></tr>
|
1557 |
</table>
|
1558 |
<hr>
|
1559 |
-
<h3><?php
|
1560 |
|
1561 |
-
<table class="form-table" cellspacing="2" cellpadding="5" width="100%">
|
1562 |
<tr valign="top">
|
1563 |
-
|
1564 |
-
<em><?php
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
|
1569 |
<tr valign="top">
|
1570 |
-
|
1571 |
-
<em><?php
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
|
1576 |
-
|
1577 |
-
|
1578 |
-
<em><?php
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
<em><?php
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
|
1590 |
|
1591 |
|
1592 |
|
1593 |
<tr valign="top">
|
1594 |
-
|
1595 |
-
<em><?php
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
<select name="blockcountry_nrstatistics">
|
1600 |
-
<option <?php selected(
|
1601 |
-
<option <?php selected(
|
1602 |
-
<option <?php selected(
|
1603 |
-
<option <?php selected(
|
1604 |
-
<option <?php selected(
|
1605 |
-
<option <?php selected(
|
1606 |
</select>
|
1607 |
-
|
1608 |
|
1609 |
<tr valign="top">
|
1610 |
-
|
1611 |
-
<em><?php
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
<select name="blockcountry_daysstatistics">
|
1616 |
-
<option <?php selected(
|
1617 |
-
<option <?php selected(
|
1618 |
-
<option <?php selected(
|
1619 |
-
<option <?php selected(
|
1620 |
-
<option <?php selected(
|
1621 |
-
<option <?php selected(
|
1622 |
</select>
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
<em><?php
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
|
1632 |
-
|
1633 |
-
|
1634 |
-
<em><?php
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
|
1639 |
<tr valign="top">
|
1640 |
-
|
1641 |
-
<em><?php
|
1642 |
</th>
|
1643 |
<td width="70%">
|
1644 |
-
<input type="text" size="25" name="blockcountry_geoapikey" value="<?php echo get_option
|
1645 |
</td></tr>
|
1646 |
|
1647 |
|
1648 |
<tr valign="top">
|
1649 |
-
|
1650 |
-
<em><?php
|
1651 |
</th>
|
1652 |
-
|
1653 |
|
1654 |
<input type="radio" name="blockcountry_geoapilocation" value="EU" <?php checked('EU', get_option('blockcountry_geoapilocation'), true); ?>> Europe (Netherlands)<br />
|
1655 |
-
<input type="radio" name="blockcountry_geoapilocation" value="EU3" <?php checked('EU3', get_option('blockcountry_geoapilocation'), true); ?>> Europe (
|
1656 |
<input type="radio" name="blockcountry_geoapilocation" value="US" <?php checked('US', get_option('blockcountry_geoapilocation'), true); ?>> United States - New York<br />
|
1657 |
<input type="radio" name="blockcountry_geoapilocation" value="US2" <?php checked('US2', get_option('blockcountry_geoapilocation'), true); ?>> United States - San Francisco<br />
|
1658 |
<input type="radio" name="blockcountry_geoapilocation" value="US3" <?php checked('US3', get_option('blockcountry_geoapilocation'), true); ?>> United States - Miami<br />
|
1659 |
|
1660 |
-
|
1661 |
<tr valign="top">
|
1662 |
-
|
1663 |
-
<em><?php
|
1664 |
</th>
|
1665 |
-
|
1666 |
-
<input type="text" size="25" name="blockcountry_apikey" value="<?php echo get_option
|
1667 |
-
|
1668 |
|
1669 |
|
1670 |
-
|
1671 |
-
|
1672 |
-
<em><?php
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
|
1677 |
<tr valign="top">
|
1678 |
-
|
1679 |
-
<em><?php
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
<select name="blockcountry_ipoverride">
|
1684 |
-
<option <?php selected(
|
1685 |
-
<option <?php selected(
|
1686 |
-
<option <?php selected(
|
1687 |
-
<option <?php selected(
|
1688 |
-
<option <?php selected(
|
1689 |
-
<option <?php selected(
|
1690 |
-
<option <?php selected(
|
1691 |
-
<option <?php selected(
|
1692 |
-
<option <?php selected(
|
1693 |
-
<option <?php selected(
|
1694 |
</select>
|
1695 |
-
|
1696 |
|
1697 |
<tr valign="top">
|
1698 |
-
|
1699 |
-
<em><?php
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
|
1704 |
|
1705 |
<tr><td></td><td>
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
</form>
|
1711 |
-
<?php
|
1712 |
-
|
1713 |
-
|
1714 |
{
|
1715 |
-
|
1716 |
-
|
1717 |
}
|
1718 |
|
1719 |
/*
|
@@ -1722,118 +1628,126 @@ if (is_file ( GEOIP2DBFILE ) && (!get_option('blockcountry_geoapikey'))) {
|
|
1722 |
function iqblockcountry_settings_logging()
|
1723 |
{
|
1724 |
?>
|
1725 |
-
<h3><?php
|
1726 |
-
|
1727 |
-
|
1728 |
-
{
|
1729 |
|
1730 |
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
|
|
1756 |
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
|
|
|
|
|
|
|
|
1772 |
|
1773 |
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
|
|
1786 |
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
|
1802 |
-
|
1803 |
|
1804 |
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
|
|
1818 |
|
1819 |
-
|
1820 |
<form name="cleardatabase" action="#" method="post">
|
1821 |
-
<input type="hidden" name="
|
1822 |
-
<input name="
|
1823 |
|
1824 |
-
<?php
|
1825 |
-
echo '<div class="submit"><input type="submit" name="test" value="' .
|
1826 |
wp_nonce_field('iqblockcountry');
|
1827 |
|
1828 |
-
if (
|
1829 |
-
if (!isset($_POST['
|
1830 |
-
|
|
|
|
|
1831 |
global $wpdb;
|
1832 |
-
$
|
1833 |
-
$
|
1834 |
-
$wpdb->query($
|
1835 |
-
$
|
1836 |
-
$wpdb->query($
|
1837 |
echo "Cleared database";
|
1838 |
|
1839 |
}
|
@@ -1841,49 +1755,51 @@ function iqblockcountry_settings_logging()
|
|
1841 |
?>
|
1842 |
</form>
|
1843 |
|
1844 |
-
|
1845 |
-
<input type="hidden" name="
|
1846 |
-
<input name="
|
1847 |
<?php
|
1848 |
-
echo '<div class="submit"><input type="submit" name="submit" value="' .
|
1849 |
-
wp_nonce_field('
|
1850 |
echo '</form>';
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
}
|
1859 |
|
1860 |
|
1861 |
/*
|
1862 |
* Create the settings page.
|
1863 |
*/
|
1864 |
-
function iqblockcountry_settings_page()
|
|
|
1865 |
|
1866 |
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
{
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
|
1876 |
<h2 class="nav-tab-wrapper">
|
1877 |
-
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=home" class="nav-tab <?php echo $
|
1878 |
-
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=frontend" class="nav-tab <?php echo $
|
1879 |
-
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=backend" class="nav-tab <?php echo $
|
1880 |
-
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=pages" class="nav-tab <?php echo $
|
1881 |
-
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=categories" class="nav-tab <?php echo $
|
1882 |
-
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=tags" class="nav-tab <?php echo $
|
1883 |
-
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=
|
1884 |
-
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=
|
1885 |
-
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=
|
1886 |
-
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=
|
|
|
1887 |
</h2>
|
1888 |
|
1889 |
|
@@ -1892,44 +1808,34 @@ function iqblockcountry_settings_page() {
|
|
1892 |
|
1893 |
<hr />
|
1894 |
<?php
|
1895 |
-
if ($
|
1896 |
-
{
|
1897 |
iqblockcountry_settings_frontend();
|
1898 |
}
|
1899 |
-
elseif ($
|
1900 |
-
{
|
1901 |
iqblockcountry_settings_backend();
|
1902 |
}
|
1903 |
-
elseif ($
|
1904 |
-
{
|
1905 |
iqblockcountry_settings_tools();
|
1906 |
}
|
1907 |
-
elseif ($
|
1908 |
-
{
|
1909 |
iqblockcountry_settings_logging();
|
1910 |
}
|
1911 |
-
elseif ($
|
1912 |
-
{
|
1913 |
iqblockcountry_settings_pages();
|
1914 |
}
|
1915 |
-
elseif ($
|
1916 |
-
{
|
1917 |
iqblockcountry_settings_categories();
|
1918 |
}
|
1919 |
-
elseif ($
|
1920 |
-
{
|
1921 |
iqblockcountry_settings_tags();
|
1922 |
}
|
1923 |
-
elseif ($
|
1924 |
-
{
|
1925 |
iqblockcountry_settings_posttypes();
|
1926 |
}
|
1927 |
-
elseif ($
|
1928 |
-
{
|
1929 |
iqblockcountry_settings_services();
|
1930 |
}
|
1931 |
-
elseif ($
|
1932 |
-
{
|
1933 |
iqblockcountry_settings_importexport();
|
1934 |
}
|
1935 |
else
|
@@ -1947,7 +1853,7 @@ function iqblockcountry_settings_page() {
|
|
1947 |
See <a href="https://webence.nl/plugins/donate/">Plugin donation page</a></p>
|
1948 |
|
1949 |
<?php
|
1950 |
-
|
1951 |
}
|
1952 |
|
1953 |
|
@@ -1956,94 +1862,99 @@ function iqblockcountry_settings_page() {
|
|
1956 |
*/
|
1957 |
function iqblockcountry_find_geoip_location()
|
1958 |
{
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
// )
|
1997 |
-
// $
|
1998 |
-
//
|
1999 |
-
//
|
|
|
|
|
|
|
|
|
|
|
2000 |
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
|
|
|
|
|
|
|
|
2018 |
|
2019 |
|
2020 |
-
|
2021 |
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
//
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
else
|
2043 |
-
{
|
2044 |
-
update_option('blockcountry_geoapilocation','EU');
|
2045 |
}
|
2046 |
-
}
|
2047 |
}
|
2048 |
|
2049 |
/*
|
@@ -2051,67 +1962,75 @@ function iqblockcountry_find_geoip_location()
|
|
2051 |
*/
|
2052 |
function iqblockcountry_get_blockallowlist()
|
2053 |
{
|
2054 |
-
$
|
2055 |
-
$
|
2056 |
-
$
|
2057 |
-
$
|
2058 |
|
2059 |
|
2060 |
-
$
|
2061 |
-
$
|
2062 |
-
$
|
2063 |
-
$
|
2064 |
-
$
|
2065 |
-
$
|
2066 |
-
global $
|
2067 |
|
2068 |
-
$
|
2069 |
-
$
|
2070 |
-
$
|
2071 |
-
$
|
2072 |
-
$
|
2073 |
-
$
|
2074 |
-
global $
|
2075 |
|
2076 |
|
2077 |
-
if (preg_match('/;/'
|
2078 |
-
|
2079 |
-
$
|
2080 |
-
foreach ($frontendblocklistip AS $ip)
|
2081 |
{
|
2082 |
-
if (iqblockcountry_is_valid_ipv4($
|
2083 |
-
|
2084 |
-
elseif (
|
|
|
|
|
|
|
2085 |
}
|
2086 |
}
|
2087 |
-
if (preg_match('/;/'
|
2088 |
-
|
2089 |
-
$
|
2090 |
-
foreach ($frontendallowlistip AS $ip)
|
2091 |
{
|
2092 |
-
if (iqblockcountry_is_valid_ipv4($
|
2093 |
-
|
2094 |
-
elseif (
|
|
|
|
|
|
|
2095 |
}
|
2096 |
}
|
2097 |
-
if (preg_match('/;/'
|
2098 |
-
|
2099 |
-
$
|
2100 |
-
foreach ($backendblocklistip AS $ip)
|
2101 |
{
|
2102 |
-
if (iqblockcountry_is_valid_ipv4($
|
2103 |
-
|
2104 |
-
elseif (
|
|
|
|
|
|
|
2105 |
}
|
2106 |
}
|
2107 |
-
if (preg_match('/;/'
|
2108 |
-
|
2109 |
-
$
|
2110 |
-
foreach ($backendallowlistip AS $ip)
|
2111 |
{
|
2112 |
-
if (iqblockcountry_is_valid_ipv4($
|
2113 |
-
|
2114 |
-
elseif (
|
|
|
|
|
|
|
2115 |
}
|
2116 |
}
|
2117 |
|
1 |
<?php
|
2 |
|
3 |
/* Check if the Geo Database exists or if GeoIP API key is entered otherwise display notification */
|
4 |
+
if (!is_file(IQBCGEOIP2DBFILE) && (!get_option('blockcountry_geoapikey'))) {
|
5 |
+
add_action('admin_notices', 'iq_missing_db_notice');
|
|
|
|
|
|
|
|
|
|
|
6 |
}
|
7 |
|
8 |
/* check if caching plugins are active, if so display notice */
|
9 |
+
if (iqblockcountry_is_caching_active()) {
|
10 |
+
add_action('admin_notices', 'iq_cachingisactive_notice');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
}
|
12 |
|
13 |
+
/**
|
|
|
14 |
* Display missing database notification.
|
15 |
+
**/
|
16 |
function iq_missing_db_notice()
|
17 |
{
|
18 |
+
if (!is_file(IQBCGEOIP2DBFILE) ) {
|
|
|
19 |
?>
|
20 |
<div class="notice notice-error">
|
21 |
<h3>iQ Block Country</h3>
|
22 |
+
<p><?php esc_html_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>
|
23 |
+
<p><?php esc_html_e("Please download the database (GeoLite2-Country.tar.gz) from: ", 'iq-block-country'); ?>
|
24 |
+
<?php esc_html_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'); ?>
|
25 |
+
<?php esc_html_e("<a href=\"" . IQBCMAXMINDURL . "\" target=\"_blank\">" . IQBCMAXMINDURL . "</a> "); ?>
|
26 |
+
<?php esc_html_e("unzip the file and afterwards upload the GeoLite2-Country.mmdb file to the following location: ", 'iq-block-country'); ?>
|
27 |
+
<b><?php esc_html_e(IQBCGEOIP2DBFILE); ?></b></p>
|
28 |
|
29 |
+
<p><?php esc_html_e('For more detailed instructions take a look at the documentation..', 'iq-block-country'); ?></p>
|
30 |
|
31 |
</div>
|
32 |
+
<?php
|
33 |
+
}
|
34 |
}
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
|
38 |
/*
|
43 |
?>
|
44 |
<div class="notice notice-warning is-dismissible">
|
45 |
<h3>iQ Block Country</h3>
|
46 |
+
<p><?php esc_html_e('A caching plugin appears to be active on your WordPress installation.', 'iq-block-country'); ?></p>
|
47 |
+
<p><?php esc_html_e('Caching plugins do not always cooperate nicely together with the iQ Block Country plugin which may lead to non blocked visitors getting a cached banned message or page.', 'iq-block-country'); ?></p>
|
48 |
+
<p><?php esc_html_e('For more information visit the following page:', 'iq-block-country'); ?> <a target="_blank"href="https://www.webence.nl/questions/iq-block-country-and-caching-plugins/">https://www.webence.nl/questions/iq-block-country-and-caching-plugins/</a></p>
|
49 |
</div>
|
50 |
+
<?php
|
51 |
}
|
52 |
|
53 |
|
60 |
?>
|
61 |
<div class="notice notice-warning">
|
62 |
<h3>iQ Block Country</h3>
|
63 |
+
<p><?php esc_html_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>
|
64 |
+
<p><?php esc_html_e("Please download the database (GeoLite2-Country.tar.gz) from MaxMind. ", 'iq-block-country'); ?>
|
65 |
+
<?php esc_html_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'); ?>
|
66 |
+
<?php esc_html_e("<a href=\"" . IQBCMAXMINDURL . "\" target=\"_blank\">" . IQBCMAXMINDURL . "</a> "); ?>
|
67 |
+
<?php esc_html_e("unzip the file and afterwards upload it to the following location: ", 'iq-block-country'); ?>
|
68 |
+
<b><?php esc_html_e(IQBCGEOIP2DBFILE); ?></b></p>
|
69 |
|
70 |
+
<p><?php esc_html_e('For more detailed instructions take a look at the documentation..', 'iq-block-country'); ?></p>
|
71 |
|
72 |
</div>
|
73 |
+
<?php
|
74 |
}
|
75 |
|
76 |
|
79 |
*/
|
80 |
function iqblockcountry_create_menu()
|
81 |
{
|
82 |
+
//create new menu option in the settings department
|
83 |
+
add_submenu_page('options-general.php', 'iQ Block Country', 'iQ Block Country', 'administrator', __FILE__, 'iqblockcountry_settings_page');
|
84 |
+
//call register settings function
|
85 |
+
add_action('admin_init', 'iqblockcountry_register_mysettings');
|
86 |
}
|
87 |
|
88 |
/*
|
90 |
*/
|
91 |
function iqblockcountry_register_mysettings()
|
92 |
{
|
93 |
+
//register our settings
|
94 |
+
register_setting('iqblockcountry-settings-group', 'blockcountry_blockmessage');
|
95 |
+
register_setting('iqblockcountry-settings-group', 'blockcountry_redirect');
|
96 |
+
register_setting('iqblockcountry-settings-group', 'blockcountry_redirect_url', 'iqblockcountry_is_valid_url');
|
97 |
+
register_setting('iqblockcountry-settings-group', 'blockcountry_header');
|
98 |
+
register_setting('iqblockcountry-settings-group', 'blockcountry_buffer');
|
99 |
+
register_setting('iqblockcountry-settings-group', 'blockcountry_tracking');
|
100 |
+
register_setting('iqblockcountry-settings-group', 'blockcountry_nrstatistics');
|
101 |
+
register_setting('iqblockcountry-settings-group', 'blockcountry_daysstatistics');
|
102 |
+
register_setting('iqblockcountry-settings-group', 'blockcountry_lookupstatistics');
|
103 |
+
register_setting('iqblockcountry-settings-group', 'blockcountry_geoapikey', 'iqblockcountry_check_geoapikey');
|
104 |
+
register_setting('iqblockcountry-settings-group', 'blockcountry_geoapilocation');
|
105 |
+
register_setting('iqblockcountry-settings-group', 'blockcountry_apikey', 'iqblockcountry_check_adminapikey');
|
106 |
+
register_setting('iqblockcountry-settings-group', 'blockcountry_debuglogging');
|
107 |
+
register_setting('iqblockcountry-settings-group', 'blockcountry_accessibility');
|
108 |
+
register_setting('iqblockcountry-settings-group', 'blockcountry_ipoverride');
|
109 |
+
register_setting('iqblockcountry-settings-group', 'blockcountry_logging');
|
110 |
+
register_setting('iqblockcountry-settings-group', 'blockcountry_adminajax');
|
111 |
+
register_setting('iqblockcountry-settings-group-backend', 'blockcountry_blockbackend');
|
112 |
+
register_setting('iqblockcountry-settings-group-backend', 'blockcountry_backendbanlist');
|
113 |
+
register_setting('iqblockcountry-settings-group-backend', 'blockcountry_backendbanlist_inverse');
|
114 |
+
register_setting('iqblockcountry-settings-group-backend', 'blockcountry_backendblacklist', 'iqblockcountry_validate_ip');
|
115 |
+
register_setting('iqblockcountry-settings-group-backend', 'blockcountry_backendwhitelist', 'iqblockcountry_validate_ip');
|
116 |
+
register_setting('iqblockcountry-settings-group-frontend', 'blockcountry_banlist');
|
117 |
+
register_setting('iqblockcountry-settings-group-frontend', 'blockcountry_banlist_inverse');
|
118 |
+
register_setting('iqblockcountry-settings-group-frontend', 'blockcountry_frontendblacklist', 'iqblockcountry_validate_ip');
|
119 |
+
register_setting('iqblockcountry-settings-group-frontend', 'blockcountry_frontendwhitelist', 'iqblockcountry_validate_ip');
|
120 |
+
register_setting('iqblockcountry-settings-group-frontend', 'blockcountry_blocklogin');
|
121 |
+
register_setting('iqblockcountry-settings-group-frontend', 'blockcountry_blocksearch');
|
122 |
+
register_setting('iqblockcountry-settings-group-frontend', 'blockcountry_blockfrontend');
|
123 |
+
register_setting('iqblockcountry-settings-group-frontend', 'blockcountry_blocktag');
|
124 |
+
register_setting('iqblockcountry-settings-group-frontend', 'blockcountry_blockfeed');
|
125 |
+
register_setting('iqblockcountry-settings-group-pages', 'blockcountry_blockpages');
|
126 |
+
register_setting('iqblockcountry-settings-group-pages', 'blockcountry_blockpages_inverse');
|
127 |
+
register_setting('iqblockcountry-settings-group-pages', 'blockcountry_pages');
|
128 |
+
register_setting('iqblockcountry-settings-group-posttypes', 'blockcountry_blockposttypes');
|
129 |
+
register_setting('iqblockcountry-settings-group-posttypes', 'blockcountry_posttypes');
|
130 |
+
register_setting('iqblockcountry-settings-group-cat', 'blockcountry_blockcategories');
|
131 |
+
register_setting('iqblockcountry-settings-group-cat', 'blockcountry_categories');
|
132 |
+
register_setting('iqblockcountry-settings-group-cat', 'blockcountry_blockhome');
|
133 |
+
register_setting('iqblockcountry-settings-group-tags', 'blockcountry_blocktags');
|
134 |
+
register_setting('iqblockcountry-settings-group-tags', 'blockcountry_tags');
|
135 |
+
register_setting('iqblockcountry-settings-group-se', 'blockcountry_allowse');
|
136 |
}
|
137 |
|
138 |
/**
|
140 |
*
|
141 |
* @return array of options.
|
142 |
*/
|
143 |
+
function iqblockcountry_get_options_arr()
|
144 |
+
{
|
145 |
+
$iqbc_optarr = array( 'blockcountry_banlist','blockcountry_banlist_inverse', 'blockcountry_backendbanlist','blockcountry_backendbanlist_inverse',
|
146 |
'blockcountry_backendblacklist','blockcountry_backendwhitelist','blockcountry_frontendblacklist','blockcountry_frontendwhitelist',
|
147 |
'blockcountry_blockmessage','blockcountry_blocklogin','blockcountry_blockfrontend','blockcountry_blockbackend','blockcountry_header',
|
148 |
'blockcountry_blockpages','blockcountry_blockpages_inverse','blockcountry_pages','blockcountry_blockcategories','blockcountry_categories','blockcountry_tracking',
|
150 |
'blockcountry_geoapilocation','blockcountry_apikey','blockcountry_redirect','blockcountry_redirect_url','blockcountry_allowse',
|
151 |
'blockcountry_debuglogging','blockcountry_buffer','blockcountry_accessibility','blockcountry_ipoverride','blockcountry_logging','blockcountry_blockposttypes',
|
152 |
'blockcountry_posttypes','blockcountry_blocksearch','blockcountry_adminajax','blockcountry_blocktag','blockcountry_blockfeed','blockcountry_blocktags','blockcountry_tags');
|
153 |
+
return apply_filters('iqblockcountry_options', $iqbc_optarr);
|
154 |
}
|
155 |
|
156 |
|
159 |
*/
|
160 |
function iqblockcountry_set_defaults()
|
161 |
{
|
162 |
+
update_option('blockcountry_version', VERSION);
|
163 |
+
$iqbc_countrylist = iqblockcountry_get_isocountries();
|
164 |
+
$iqbc_ip_address = iqblockcountry_get_ipaddress();
|
165 |
+
$usercountry = iqblockcountry_check_ipaddress($iqbc_ip_address);
|
166 |
+
$iqbc_server_addr = "";
|
167 |
+
if(isset($_SERVER['SERVER_ADDR']) && (filter_var($_SERVER['SERVER_ADDR'],FILTER_VALIDATE_IP))) {
|
168 |
+
$iqbc_server_addr = $_SERVER['SERVER_ADDR'];
|
169 |
+
} elseif(array_key_exists('LOCAL_ADDR', $_SERVER) && (filter_var($_SERVER['LOCAL_ADDR'],FILTER_VALIDATE_IP))) {
|
170 |
+
$iqbc_server_addr = $_SERVER['LOCAL_ADDR'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
}
|
172 |
+
|
173 |
+
if (get_option('blockcountry_blockfrontend') === false) { update_option('blockcountry_blockfrontend', 'on');
|
174 |
+
}
|
175 |
+
if (get_option('blockcountry_blockfeed') === false) { update_option('blockcountry_blockfeed', 'on');
|
176 |
+
}
|
177 |
+
if (get_option('blockcountry_backendnrblocks') === false) { update_option('blockcountry_backendnrblocks', 0);
|
178 |
+
}
|
179 |
+
if (get_option('blockcountry_frontendnrblocks') === false) { update_option('blockcountry_frontendnrblocks', 0);
|
180 |
+
}
|
181 |
+
if (get_option('blockcountry_header') === false) { update_option('blockcountry_header', 'on');
|
182 |
+
}
|
183 |
+
if (get_option('blockcountry_nrstatistics') === false) { update_option('blockcountry_nrstatistics', 15);
|
184 |
+
}
|
185 |
+
if (null === get_option('blockcountry_daysstatistics', null) ) { update_option('blockcountry_daysstatistics', 30);
|
186 |
+
}
|
187 |
+
if (get_option('blockcountry_backendwhitelist') === false || (get_option('blockcountry_backendwhitelist') == "")) { update_option('blockcountry_backendwhitelist', $iqbc_ip_address . ";");
|
188 |
+
}
|
189 |
+
$iqbc_tmpbackendallowlist = get_option('blockcountry_backendwhitelist');
|
190 |
+
$iqbc_ippos = strpos($iqbc_tmpbackendallowlist, $iqbc_server_addr);
|
191 |
+
if ($iqbc_ippos === false) {
|
192 |
+
$iqbc_tmpbackendallowlist .= $iqbc_server_addr . ";";
|
193 |
+
update_option('blockcountry_backendwhitelist', $iqbc_tmpbackendallowlist);
|
194 |
+
}
|
195 |
+
if (get_option('blockcountry_frontendwhitelist') === false || (get_option('blockcountry_frontendwhitelist') == "")) { update_option('blockcountry_frontendwhitelist', $iqbc_server_addr . ";");
|
196 |
+
}
|
197 |
iqblockcountry_install_db();
|
198 |
+
if (get_option('blockcountry_banlist_inverse') === false) { update_option('blockcountry_banlist_inverse', 'off');
|
199 |
+
}
|
200 |
+
if (get_option('blockcountry_backendbanlist_inverse') === false) { update_option('blockcountry_backendbanlist_inverse', 'off');
|
201 |
+
}
|
202 |
+
if (get_option('blockcountry_ipoverride') === false) { update_option('blockcountry_ipoverride', 'NONE');
|
203 |
+
}
|
204 |
iqblockcountry_find_geoip_location();
|
205 |
}
|
206 |
|
209 |
{
|
210 |
iqblockcountry_uninstall_db();
|
211 |
iqblockcountry_uninstall_loggingdb();
|
212 |
+
delete_option('blockcountry_banlist');
|
213 |
+
delete_option('blockcountry_banlist_inverse');
|
214 |
+
delete_option('blockcountry_backendbanlist');
|
215 |
delete_option('blockcountry_backendbanlist_inverse');
|
216 |
+
delete_option('blockcountry_backendblacklist');
|
217 |
+
delete_option('blockcountry_backendwhitelist');
|
218 |
+
delete_option('blockcountry_frontendblacklist');
|
219 |
+
delete_option('blockcountry_frontendwhitelist');
|
220 |
+
delete_option('blockcountry_blockmessage');
|
221 |
+
delete_option('blockcountry_backendnrblocks');
|
222 |
+
delete_option('blockcountry_frontendnrblocks');
|
223 |
+
delete_option('blockcountry_blocklogin');
|
224 |
+
delete_option('blockcountry_blockfrontend');
|
225 |
+
delete_option('blockcountry_blockbackend');
|
226 |
delete_option('blockcountry_version');
|
227 |
delete_option('blockcountry_header');
|
228 |
delete_option('blockcountry_blockpages');
|
260 |
|
261 |
|
262 |
|
263 |
+
function iqblockcountry_settings_tools()
|
264 |
+
{
|
265 |
?>
|
266 |
+
<h3><?php esc_html_e('Check which country belongs to an IP Address according to the current database.', 'iq-block-country'); ?></h3>
|
267 |
|
268 |
+
<form name="ipcheck" action="#ipcheck" method="post">
|
269 |
+
<input type="hidden" name="action" value="iqbc_ipcheck" />
|
270 |
+
<input name="iqbc_ipcheck_nonce" type="hidden" value="<?php echo wp_create_nonce('iqbc_ipcheck_nonce'); ?>" />
|
271 |
+
<?php esc_html_e('IP Address to check:', 'iq-block-country'); ?> <input type="text" name="iqbc_ipaddress" lenth="50" />
|
272 |
+
<?php
|
273 |
+
global $iqbc_feblocklistip,$iqbc_feblocklistiprange4,$iqbc_feblocklistiprange6,$iqbc_feallowlistip,$iqbc_feallowlistiprange4,$iqbc_feallowlistiprange6;
|
274 |
+
global $iqbc_beblocklistip,$iqbc_beblocklistiprange4,$iqbc_beblocklistiprange6,$iqbc_beallowlistip,$iqbc_beallowlistiprange4,$iqbc_beallowlistiprange6;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
|
277 |
+
if (isset($_POST['iqbc_action']) && $_POST[ 'iqbc_action' ] == 'iqbc_ipcheck') {
|
278 |
+
if (!isset($_POST['iqbc_ipcheck_nonce'])) { die("Failed security check.");
|
279 |
+
}
|
280 |
+
if (!wp_verify_nonce($_POST['iqbc_ipcheck_nonce'], 'iqbc_ipcheck_nonce')) { die("Is this a CSRF attempts?");
|
281 |
+
}
|
282 |
+
if (isset($_POST['iqbc_ipaddress']) && !empty($_POST['iqbc_ipaddress'])) {
|
283 |
+
if (iqblockcountry_is_valid_ipv4($_POST['iqbc_ipaddress']) || iqblockcountry_is_valid_ipv6($_POST['iqbc_ipaddress'])) {
|
284 |
+
if (filter_var($_POST['iqbc_ipaddress'], FILTER_VALIDATE_IP)) { $iqbc_ip_address = $_POST['iqbc_ipaddress'];
|
285 |
+
}
|
286 |
+
$iqbc_country = iqblockcountry_check_ipaddress($iqbc_ip_address);
|
287 |
+
$iqbc_countrylist = iqblockcountry_get_isocountries();
|
288 |
+
if ($iqbc_country == "Unknown" || $iqbc_country == "ipv6" || $iqbc_country == "" || $iqbc_country == "FALSE") {
|
289 |
+
echo "<p>" . esc_html('No country for', 'iq-block-country') . ' ' . esc_html($iqbc_ip_address) . ' ' . esc_html('could be found. Or', 'iq-block-country') . ' ' . esc_html($iqbc_ip_address) . ' ' . esc_html('is not a valid IPv4 or IPv6 IP address', 'iq-block-country');
|
290 |
+
echo "</p>";
|
291 |
+
}
|
292 |
+
else {
|
293 |
+
$iqbc_displaycountry = $iqbc_countrylist[$iqbc_country];
|
294 |
+
echo "<p>" . esc_html('IP Adress', 'iq-block-country') . ' ' . esc_html($iqbc_ip_address) . ' ' . esc_html('belongs to', 'iq-block-country') . ' ' . esc_html($iqbc_displaycountry) . ".</p>";
|
295 |
+
$iqbc_haystack = get_option('blockcountry_banlist');
|
296 |
+
if (!is_array($iqbc_haystack)) { $iqbc_haystack = array();
|
297 |
+
}
|
298 |
+
$iqbc_inverse = get_option('blockcountry_banlist_inverse');
|
299 |
+
if ($iqbc_inverse == "on") {
|
300 |
+
if (is_array($iqbc_haystack) && !in_array($iqbc_country, $iqbc_haystack)) {
|
301 |
+
esc_html_e('This country is not permitted to visit the frontend of this website.', 'iq-block-country');
|
302 |
+
echo "<br />";
|
303 |
+
}
|
304 |
+
} else {
|
305 |
+
if (is_array($iqbc_haystack) && in_array($iqbc_country, $iqbc_haystack)) {
|
306 |
+
esc_html_e('This country is not permitted to visit the frontend of this website.', 'iq-block-country');
|
307 |
+
echo "<br />";
|
308 |
+
}
|
309 |
+
}
|
310 |
+
$iqbc_inverse = get_option('blockcountry_backendbanlist_inverse');
|
311 |
+
$iqbc_haystack = get_option('blockcountry_backendbanlist');
|
312 |
+
if (!is_array($iqbc_haystack)) { $iqbc_haystack = array();
|
313 |
+
}
|
314 |
+
if ($iqbc_inverse == "on") {
|
315 |
+
if (is_array($iqbc_haystack) && !in_array($iqbc_country, $iqbc_haystack)) {
|
316 |
+
esc_html_e('This country is not permitted to visit the backend of this website.', 'iq-block-country');
|
317 |
+
echo "<br />";
|
318 |
+
}
|
319 |
+
}
|
320 |
+
else
|
321 |
+
{
|
322 |
+
if (is_array($iqbc_haystack) && in_array($iqbc_country, $iqbc_haystack)) {
|
323 |
+
esc_html_e('This country is not permitted to visit the backend of this website.', 'iq-block-country');
|
324 |
+
echo "<br />";
|
325 |
}
|
326 |
+
}
|
327 |
+
$iqbc_backendbanlistip = unserialize(get_option('blockcountry_backendbanlistip'));
|
328 |
+
if (is_array($iqbc_backendbanlistip) && in_array($iqbc_ip_address, $iqbc_backendbanlistip)) {
|
329 |
+
esc_html_e('This IP address is present in the block list.', 'iq-block-country');
|
330 |
+
}
|
331 |
+
|
332 |
+
}
|
333 |
+
if (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_feblocklistiprange4, $iqbc_feblocklistiprange6, $iqbc_feblocklistip)) {
|
334 |
+
esc_html_e('This IP address is present in the frontend block list.', 'iq-block-country');
|
335 |
+
echo "<br />";
|
336 |
+
}
|
337 |
+
if (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_feallowlistiprange4, $iqbc_feallowlistiprange6, $iqbc_feallowlistip)) {
|
338 |
+
esc_html_e('This IP address is present in the frontend allow list.', 'iq-block-country');
|
339 |
+
echo "<br />";
|
340 |
+
}
|
341 |
+
if (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_beblocklistiprange4, $iqbc_beblocklistiprange6, $iqbc_beblocklistip)) {
|
342 |
+
esc_html_e('This IP address is present in the backend block list.', 'iq-block-country');
|
343 |
+
echo "<br />";
|
344 |
+
}
|
345 |
+
if (iqblockcountry_validate_ip_in_list($iqbc_ip_address, $iqbc_beallowlistiprange4, $iqbc_beallowlistiprange6, $iqbc_beblocklistip)) {
|
346 |
+
esc_html_e('This IP address is present in the backend allow list.', 'iq-block-country');
|
347 |
+
echo "<br />";
|
348 |
+
}
|
349 |
+
|
350 |
+
}
|
351 |
+
}
|
352 |
+
}
|
353 |
+
echo '<div class="submit"><input type="submit" name="test" value="' . esc_html('Check IP address', 'iq-block-country') . '" /></div>';
|
354 |
wp_nonce_field('iqblockcountry');
|
355 |
|
356 |
+
?>
|
357 |
</form>
|
358 |
|
359 |
<hr />
|
360 |
|
361 |
+
<h3><?php esc_html_e('Database information', 'iq-block-country'); ?></h3>
|
362 |
<?php
|
363 |
|
364 |
+
$iqbc_format = get_option('date_format') . ' ' . get_option('time_format');
|
365 |
+
if (!get_option('blockcountry_geoapikey')) {
|
366 |
+
if (is_file(IQBCGEOIP2DBFILE)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
|
368 |
+
esc_html_e("GeoIP2 database exists. File date: ", 'iq-block-country');
|
369 |
+
$iqbc_filedate = filemtime(IQBCGEOIP2DBFILE);
|
370 |
+
echo esc_html(date($iqbc_format, $iqbc_filedate));
|
371 |
echo " ";
|
372 |
+
$iqbc_3months = time() - 3 * 31 * 86400;
|
373 |
+
if ($iqbc_filedate < $iqbc_3months) {
|
374 |
+
esc_html_e("Database is older than 3 months... Please update...", 'iq-block-country');
|
|
|
375 |
}
|
376 |
}
|
377 |
else
|
378 |
{
|
379 |
+
esc_html_e("GeoIP2 database does not exist.", 'iq-block-country');
|
380 |
+
}
|
381 |
echo "<br />";
|
382 |
}
|
383 |
+
if (get_option('blockcountry_geoapikey')) {
|
384 |
+
$iqbc_licensedate = strtotime(iqblockcountry_get_licensedate_geoapikey(get_option('blockcountry_geoapikey')));
|
385 |
+
esc_html_e("Your GeoIP API key is valid till: ", 'iq-block-country');
|
386 |
+
esc_html_e(date($iqbc_format, $iqbc_licensedate));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
387 |
echo "<br />";
|
388 |
+
$iqbc_usagerequests = iqblockcountry_get_usage_geoapikey(get_option('blockcountry_geoapikey'));
|
389 |
+
esc_html_e("Your GeoIP API usage this month: ", 'iq-block-country');
|
390 |
+
esc_html_e($iqbc_usagerequests);
|
391 |
}
|
392 |
?>
|
393 |
<br />
|
394 |
<br />
|
395 |
|
396 |
+
<h3><?php esc_html_e('Reset Counters', 'iq-block-country'); ?></h3>
|
397 |
|
398 |
<div class="wrap">
|
399 |
<div id="icon-tools" class="icon32"><br /></div>
|
400 |
+
<p><?php esc_html_e('When you click on the Reset Counter button the counters of total Frontend & Backend blocks will be set to 0.', 'iq-block-country'); ?></p>
|
401 |
|
402 |
+
<?php $iqbc_blocked = get_option('blockcountry_backendnrblocks'); ?>
|
403 |
+
<p><?php esc_html_e(number_format($iqbc_blocked)); ?> <?php esc_html_e('visitors blocked from the backend.', 'iq-block-country'); ?></p>
|
404 |
+
<?php $iqbc_blocked = get_option('blockcountry_frontendnrblocks'); ?>
|
405 |
+
<p><?php esc_html_e(number_format($iqbc_blocked)); ?> <?php esc_html_e('visitors blocked from the frontend.', 'iq-block-country'); ?></p>
|
406 |
|
407 |
<form method='post'>
|
408 |
<p class="submit">
|
409 |
<?php wp_nonce_field('iqblockresetcounter'); ?>
|
410 |
+
<input type='submit' name='iqbc_resetcounter' value='<?php esc_html_e('Reset Counter', 'iq-block-country'); ?>'/>
|
411 |
</p>
|
412 |
</form>
|
413 |
</div>
|
414 |
<?php
|
415 |
+
if ((isset($_POST['iqbc_resetcounter'])) && (check_admin_referer('iqblockresetcounter'))) {
|
416 |
+
update_option('blockcountry_backendnrblocks', 0);
|
417 |
+
update_option('blockcountry_frontendnrblocks', 0);
|
418 |
+
esc_html_e("Counters reset", 'iq-block-country');
|
419 |
}
|
420 |
?>
|
421 |
+
<h3><?php esc_html_e('Active plugins', 'iq-block-country'); ?></h3>
|
422 |
<?php
|
423 |
|
424 |
+
$iqbc_plugins = get_plugins();
|
425 |
+
$iqbc_plugins_string = '';
|
426 |
|
427 |
echo '<table class="widefat">';
|
428 |
+
echo '<thead><tr><th>' . esc_html('Plugin name', 'iq-block-country') . '</th><th>' . esc_html('Version', 'iq-block-country') . '</th><th>' . esc_html('URL', 'iq-block-country') . '</th></tr></thead>';
|
429 |
|
430 |
+
foreach( array_keys($iqbc_plugins) as $iqbc_key ) {
|
431 |
+
if (is_plugin_active($iqbc_key) ) {
|
432 |
+
$iqbc_plugin =& $iqbc_plugins[$iqbc_key];
|
433 |
+
echo "<tbody><tr>";
|
434 |
+
echo '<td>' . esc_html($iqbc_plugin['Name']) . '</td>';
|
435 |
+
echo '<td>' . esc_html($iqbc_plugin['Version']) . '</td>';
|
436 |
+
echo '<td>' . esc_url($iqbc_plugin['PluginURI']) . '</td>';
|
437 |
echo "</tr></tbody>";
|
438 |
}
|
439 |
}
|
440 |
echo '</table>';
|
441 |
+
//echo $iqbc_plugins_string;
|
442 |
global $wpdb;
|
443 |
|
444 |
+
$iqbc_disabled_functions = @ini_get('disable_functions');
|
445 |
|
446 |
+
if ($iqbc_disabled_functions == '' || $iqbc_disabled_functions === false ) {
|
447 |
+
$iqbc_disabled_functions = '<i>(' . esc_html('none', 'iq-block-country') . ')</i>';
|
448 |
}
|
449 |
|
450 |
+
$iqbc_disabled_functions = str_replace(', ', ',', $iqbc_disabled_functions); // Normalize spaces or lack of spaces between disabled functions.
|
451 |
+
$iqbc_disabled_functions_array = explode(',', $iqbc_disabled_functions);
|
452 |
|
453 |
+
$iqbc_php_uid = esc_html('unavailable', 'iq-block-country');
|
454 |
+
$iqbc_php_user = esc_html('unavailable', 'iq-block-country');
|
455 |
|
456 |
|
457 |
?>
|
458 |
+
<h3><?php esc_html_e('File System Information', 'iq-block-country'); ?></h3>
|
459 |
|
460 |
<table class="widefat">
|
461 |
+
<tbody><tr><td><?php esc_html_e('Website url', 'iq-block-country'); ?>: <strong><?php echo esc_url(get_site_url()); ?></strong></td></tr></tbody>
|
462 |
+
<tbody><tr><td><?php esc_html_e('Document Root Path', 'iq-block-country'); ?>: <strong><?php echo esc_html(filter_var($_SERVER['DOCUMENT_ROOT'], FILTER_SANITIZE_STRING)); ?></strong></td></tr></tbody>
|
463 |
</table>
|
464 |
|
465 |
|
466 |
+
<h3><?php esc_html_e('Database Information', 'iq-block-country'); ?></h3>
|
467 |
<table class="widefat">
|
468 |
+
<tbody><tr><td><?php esc_html_e('MySQL Database Version', 'iq-block-country'); ?>: <?php $iqbc_sqlversion = $wpdb->get_var("SELECT VERSION() AS version"); ?><strong><?php echo esc_html($iqbc_sqlversion); ?></strong></td></tr></tbody>
|
469 |
+
<tbody><tr><td><?php esc_html_e('MySQL Client Version', 'iq-block-country'); ?>: <strong><?php echo esc_html($wpdb->db_version()); ?></strong></td></tr></tbody>
|
470 |
+
<tbody><tr><td><?php esc_html_e('Database Host', 'iq-block-country'); ?>: <strong><?php echo esc_html(DB_HOST); ?></strong></td></tr></tbody>
|
471 |
+
<?php $iqbc_mysqlinfo = $wpdb->get_results("SHOW VARIABLES LIKE 'sql_mode'");
|
472 |
+
if (is_array($iqbc_mysqlinfo) ) {
|
473 |
+
$iqbc_sql_mode = $iqbc_mysqlinfo[0]->Value;
|
474 |
+
}
|
475 |
+
if (empty($iqbc_sql_mode) ) {
|
476 |
+
$iqbc_sql_mode = esc_html('Not Set', 'iq-block-country');
|
477 |
+
} else {
|
478 |
+
$iqbc_sql_mode = esc_html('Off', 'iq-block-country');
|
479 |
+
}
|
480 |
+
?>
|
481 |
+
<tbody><tr><td><?php esc_html_e('SQL Mode', 'iq-block-country'); ?>: <strong><?php echo esc_html($iqbc_sql_mode); ?></strong></td></tr></tbody>
|
482 |
</table>
|
483 |
|
484 |
|
485 |
+
<h3><?php esc_html_e('Server Information', 'iq-block-country'); ?></h3>
|
486 |
|
487 |
<table class="widefat">
|
488 |
|
489 |
+
<tbody><tr><td><?php esc_html_e('Server Type', 'iq-block-country'); ?>: <strong><?php echo esc_html(filter_var(filter_var($_SERVER['SERVER_SOFTWARE'], FILTER_SANITIZE_STRING))); ?></strong></td></tr></tbody>
|
490 |
+
<tbody><tr><td><?php esc_html_e('Operating System', 'iq-block-country'); ?>: <strong><?php echo esc_html(PHP_OS); ?></strong></td></tr></tbody>
|
491 |
+
<tbody><tr><td><?php esc_html_e('Browser Compression Supported', 'iq-block-country'); ?>:
|
492 |
+
<strong><?php echo esc_html(filter_var($_SERVER['HTTP_ACCEPT_ENCODING'], FILTER_SANITIZE_STRING)); ?></strong></td></tr></tbody>
|
|
|
|
|
|
|
493 |
<?php
|
494 |
|
495 |
+
if (is_callable('posix_geteuid') && ( false === in_array('posix_geteuid', $iqbc_disabled_functions_array) ) ) {
|
496 |
|
497 |
+
$iqbc_php_uid = @posix_geteuid();
|
498 |
|
499 |
+
if (is_callable('posix_getpwuid') && ( false === in_array('posix_getpwuid', $iqbc_disabled_functions_array) ) ) {
|
500 |
|
501 |
+
$iqbc_php_user = @posix_getpwuid($iqbc_php_uid);
|
502 |
+
$iqbc_php_user = $iqbc_php_user['name'];
|
503 |
|
504 |
+
}
|
505 |
}
|
506 |
|
507 |
+
$iqbc_php_gid = esc_html('undefined', 'iq-block-country');
|
508 |
|
509 |
+
if (is_callable('posix_getegid') && ( false === in_array('posix_getegid', $iqbc_disabled_functions_array) ) ) {
|
510 |
+
$iqbc_php_gid = @posix_getegid();
|
511 |
}
|
512 |
|
513 |
?>
|
514 |
+
<tbody><tr><td><?php esc_html_e('PHP Process User (UID:GID)', 'iq-block-country'); ?>:
|
515 |
+
<strong><?php echo esc_html($iqbc_php_user) . ' (' . esc_html($iqbc_php_uid) . ':' . esc_html($iqbc_php_gid) . ')'; ?></strong></td></tr></tbody>
|
516 |
</table>
|
517 |
|
518 |
|
519 |
+
<h3><?php esc_html_e('PHP Information', 'iq-block-country'); ?></h3>
|
520 |
|
521 |
<table class="widefat">
|
522 |
|
523 |
|
524 |
+
<tbody><tr><td><?php esc_html_e('PHP Version', 'iq-block-country'); ?>: <strong><?php echo esc_html(PHP_VERSION); ?></strong></td></tr></tbody>
|
525 |
+
<tbody><tr><td><?php esc_html_e('PHP Memory Usage', 'iq-block-country'); ?>: <strong><?php echo esc_html(round(memory_get_usage() / 1024 / 1024, 2)) . esc_html(' MB', 'iq-block-country'); ?></strong></td></tr></tbody>
|
526 |
|
527 |
<?php
|
528 |
+
if (ini_get('memory_limit') ) {
|
529 |
+
$iqbc_memory_limit = filter_var(ini_get('memory_limit'), FILTER_SANITIZE_STRING);
|
530 |
} else {
|
531 |
+
$iqbc_memory_limit = esc_html('N/A', 'iq-block-country');
|
532 |
}
|
533 |
?>
|
534 |
+
<tbody><tr><td><?php esc_html_e('PHP Memory Limit', 'iq-block-country'); ?>: <strong><?php echo esc_html($iqbc_memory_limit); ?></strong></td></tr></tbody>
|
535 |
<?php
|
536 |
+
if (ini_get('upload_max_filesize') ) {
|
537 |
+
$iqbc_upload_max = filter_var(ini_get('upload_max_filesize'), FILTER_SANITIZE_STRING);
|
538 |
} else {
|
539 |
+
$iqbc_upload_max = esc_html('N/A', 'iq-block-country');
|
540 |
}
|
541 |
?>
|
542 |
+
<tbody><tr><td><?php esc_html_e('PHP Max Upload Size', 'iq-block-country'); ?>: <strong><?php echo esc_html($iqbc_upload_max); ?></strong></td></tr></tbody>
|
543 |
<?php
|
544 |
+
if (ini_get('post_max_size') ) {
|
545 |
+
$iqbc_post_max = filter_var(ini_get('post_max_size'), FILTER_SANITIZE_STRING);
|
546 |
} else {
|
547 |
+
$iqbc_post_max = esc_html('N/A', 'iq-block-country');
|
548 |
}
|
549 |
?>
|
550 |
+
<tbody><tr><td><?php esc_html_e('PHP Max Post Size', 'iq-block-country'); ?>: <strong><?php echo esc_html($iqbc_post_max); ?></strong></td></tr></tbody>
|
551 |
<?php
|
552 |
+
if (ini_get('allow_url_fopen') ) {
|
553 |
+
$iqbc_allow_url_fopen = esc_html('On', 'iq-block-country');
|
554 |
} else {
|
555 |
+
$iqbc_allow_url_fopen = esc_html('Off', 'iq-block-country');
|
556 |
}
|
557 |
?>
|
558 |
+
<tbody><tr><td><?php esc_html_e('PHP Allow URL fopen', 'iq-block-country'); ?>: <strong><?php echo esc_html($iqbc_allow_url_fopen); ?></strong></td></tr></tbody>
|
559 |
<?php
|
560 |
+
if (ini_get('allow_url_include') ) {
|
561 |
+
$iqbc_allow_url_include = esc_html('On', 'iq-block-country');
|
562 |
} else {
|
563 |
+
$iqbc_allow_url_include = esc_html('Off', 'iq-block-country');
|
564 |
}
|
565 |
?>
|
566 |
+
<tbody><tr><td><?php esc_html_e('PHP Allow URL Include'); ?>: <strong><?php echo esc_html($iqbc_allow_url_include); ?></strong></td></tr></tbody>
|
567 |
<?php
|
568 |
+
if (ini_get('display_errors') ) {
|
569 |
+
$iqbc_display_errors = esc_html('On', 'iq-block-country');
|
570 |
} else {
|
571 |
+
$iqbc_display_errors = esc_html('Off', 'iq-block-country');
|
572 |
}
|
573 |
?>
|
574 |
+
<tbody><tr><td><?php esc_html_e('PHP Display Errors', 'iq-block-country'); ?>: <strong><?php echo esc_html($iqbc_display_errors); ?></strong></td></tr></tbody>
|
575 |
<?php
|
576 |
+
if (ini_get('display_startup_errors') ) {
|
577 |
+
$iqbc_display_startup_errors = esc_html('On', 'iq-block-country');
|
578 |
} else {
|
579 |
+
$iqbc_display_startup_errors = esc_html('Off', 'iq-block-country');
|
580 |
}
|
581 |
?>
|
582 |
+
<tbody><tr><td><?php esc_html_e('PHP Display Startup Errors', 'iq-block-country'); ?>:
|
583 |
+
<strong><?php echo esc_html($iqbc_display_startup_errors); ?></strong></td></tr></tbody>
|
584 |
<?php
|
585 |
+
if (ini_get('expose_php') ) {
|
586 |
+
$iqbc_expose_php = esc_html('On', 'iq-block-country');
|
587 |
} else {
|
588 |
+
$iqbc_expose_php = esc_html('Off', 'iq-block-country');
|
589 |
}
|
590 |
?>
|
591 |
+
<tbody><tr><td><?php esc_html_e('PHP Expose PHP', 'iq-block-country'); ?>: <strong><?php echo esc_html($iqbc_expose_php); ?></strong></td></tr></tbody>
|
592 |
<?php
|
593 |
+
if (ini_get('max_execution_time') ) {
|
594 |
+
$iqbc_max_execute = filter_var(ini_get('max_execution_time'));
|
595 |
} else {
|
596 |
+
$iqbc_max_execute = esc_html('N/A', 'iq-block-country');
|
597 |
}
|
598 |
?>
|
599 |
+
<tbody><tr><td><?php esc_html_e('PHP Max Script Execution Time'); ?>:
|
600 |
+
<strong><?php echo esc_html($iqbc_max_execute); ?> <?php esc_html_e('Seconds'); ?></strong></td></tr></tbody>
|
601 |
<?php
|
602 |
+
if (ini_get('open_basedir') ) {
|
603 |
+
$iqbc_open_basedir = esc_html('On', 'iq-block-country');
|
604 |
} else {
|
605 |
+
$iqbc_open_basedir = esc_html('Off', 'iq-block-country');
|
606 |
}
|
607 |
?>
|
608 |
+
<tbody><tr><td><?php esc_html_e('PHP open_basedir', 'iq-block-country'); ?>: <strong><?php echo esc_html($iqbc_open_basedir); ?></strong></td></tr></tbody>
|
609 |
<?php
|
610 |
+
if (is_callable('xml_parser_create') ) {
|
611 |
+
$iqbc_xml = esc_html('Yes', 'iq-block-country');
|
612 |
} else {
|
613 |
+
$iqbc_xml = esc_html('No', 'iq-block-country');
|
614 |
}
|
615 |
?>
|
616 |
+
<tbody><tr><td><?php esc_html_e('PHP XML Support', 'iq-block-country'); ?>: <strong><?php echo esc_html($iqbc_xml); ?></strong></td></tr></tbody>
|
617 |
<?php
|
618 |
+
if (is_callable('iptcparse') ) {
|
619 |
+
$iqbc_iptc = esc_html('Yes', 'iq-block-country');
|
620 |
} else {
|
621 |
+
$iqbc_iptc = esc_html('No', 'iq-block-country');
|
622 |
}
|
623 |
?>
|
624 |
+
<tbody><tr><td><?php esc_html_e('PHP IPTC Support', 'iq-block-country'); ?>: <strong><?php echo esc_html($iqbc_iptc); ?></strong></td></tr></tbody>
|
625 |
+
<?php $iqbc_disabled_functions = str_replace(',', ', ', $iqbc_disabled_functions); // Normalize spaces or lack of spaces between disabled functions. ?>
|
626 |
+
<tbody><tr><td><?php esc_html_e('Disabled PHP Functions', 'iq-block-country'); ?>: <strong><?php echo esc_html($iqbc_disabled_functions); ?></strong></td></tr></tbody>
|
627 |
|
628 |
|
629 |
</table>
|
630 |
|
631 |
|
632 |
|
633 |
+
<h3><?php esc_html_e('Wordpress info', 'iq-block-country'); ?></h3>
|
634 |
|
635 |
<table class="widefat">
|
636 |
<?php
|
637 |
+
if (is_multisite() ) {
|
638 |
+
$iqbc_multSite = esc_html('is enabled', 'iq-block-country');
|
639 |
} else {
|
640 |
+
$iqbc_multSite = esc_html('is disabled', 'iq-block-country');
|
641 |
}
|
642 |
?>
|
643 |
+
<tbody><tr><td><?php esc_html_e(' Multisite', 'iq-block-country'); ?> <strong><?php echo esc_html($iqbc_multSite); ?></strong></td></tr></tbody>
|
644 |
<?php
|
645 |
+
if (get_option('permalink_structure') != '' ) {
|
646 |
+
$iqbc_permalink_structure = esc_html('are enabled', 'iq-block-country');
|
647 |
} else {
|
648 |
+
$iqbc_permalink_structure = esc_html('are disabled', 'iq-block-country');
|
649 |
}
|
650 |
?>
|
651 |
+
<tbody><tr><td><?php esc_html_e('Permalinks', 'iq-block-country'); ?>
|
652 |
+
<strong> <?php echo esc_html($iqbc_permalink_structure); ?></strong></td></tr></tbody>
|
653 |
+
<tbody><tr><td><?php esc_html_e('Document Root Path', 'iq-block-country'); ?>: <strong><?php echo esc_html(WP_CONTENT_DIR) ?></strong></td></tr></tbody>
|
654 |
</table>
|
655 |
|
656 |
<br />
|
657 |
<br />
|
658 |
+
<h3><?php esc_html_e('IP Address information', 'iq-block-country'); ?></h3>
|
659 |
|
660 |
<?php
|
661 |
echo "<br />HTTP_CF_CONNECTING_IP: ";
|
662 |
+
if (isset($_SERVER['HTTP_CF_CONNECTING_IP']) && !empty($_SERVER['HTTP_CF_CONNECTING_IP']) ) {
|
663 |
+
echo esc_html($_SERVER['HTTP_CF_CONNECTING_IP']);
|
664 |
+
}
|
665 |
+
else { esc_html_e('Not set', 'iq-block-country');
|
666 |
}
|
|
|
667 |
echo "<br />HTTP_X_SUCURI_CLIENTIP: ";
|
668 |
+
if (isset($_SERVER['HTTP_X_SUCURI_CLIENTIP']) && !empty($_SERVER['HTTP_X_SUCURI_CLIENTIP']) ) {
|
669 |
+
echo esc_html($_SERVER['HTTP_X_SUCURI_CLIENTIP']);
|
670 |
+
}
|
671 |
+
else { esc_html_e('Not set', 'iq-block-country');
|
672 |
}
|
|
|
673 |
echo "<br />HTTP_INCAP_CLIENT_IP: ";
|
674 |
+
if (isset($_SERVER['HTTP_INCAP_CLIENT_IP']) && !empty($_SERVER['HTTP_INCAP_CLIENT_IP']) ) {
|
675 |
+
echo esc_html($_SERVER['HTTP_INCAP_CLIENT_IP']);
|
676 |
+
}
|
677 |
+
else { esc_html_e('Not set', 'iq-block-country');
|
678 |
}
|
|
|
679 |
echo "<br />HTTP_X_FORWARDED_FOR: ";
|
680 |
+
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ) {
|
681 |
+
echo esc_html($_SERVER['HTTP_X_FORWARDED_FOR']);
|
682 |
}
|
683 |
+
else { esc_html_e('Not set', 'iq-block-country');
|
684 |
+
}
|
685 |
echo "<br />HTTP_X_FORWARDED: ";
|
686 |
+
if (isset($_SERVER['HTTP_X_FORWARDED']) && !empty($_SERVER['HTTP_X_FORWARDED']) ) {
|
687 |
+
echo esc_html($_SERVER['HTTP_X_FORWARDED']);
|
688 |
+
}
|
689 |
+
else { esc_html_e('Not set', 'iq-block-country');
|
690 |
}
|
|
|
691 |
echo "<br />HTTP_CLIENT_IP: ";
|
692 |
+
if (isset($_SERVER['HTTP_CLIENT_IP']) && !empty($_SERVER['HTTP_CLIENT_IP']) ) {
|
693 |
+
echo esc_html($_SERVER['HTTP_CLIENT_IP']);
|
694 |
+
}
|
695 |
+
else { esc_html_e('Not set', 'iq-block-country');
|
696 |
}
|
|
|
697 |
echo "<br />HTTP_X_REAL_IP: ";
|
698 |
+
if (isset($_SERVER['HTTP_X_REAL_IP']) && !empty($_SERVER['HTTP_X_REAL_IP']) ) {
|
699 |
+
echo esc_html($_SERVER['HTTP_X_REAL_IP']);
|
700 |
}
|
701 |
+
else { esc_html_e('Not set', 'iq-block-country');
|
702 |
+
}
|
703 |
echo "<br />HTTP_FORWARDED: ";
|
704 |
+
if (isset($_SERVER['HTTP_FORWARDED']) && !empty($_SERVER['HTTP_FORWARDED']) ) {
|
705 |
+
echo esc_html($_SERVER['HTTP_FORWARDED']);
|
706 |
+
}
|
707 |
+
else { esc_html_e('Not set', 'iq-block-country');
|
708 |
}
|
|
|
709 |
echo "<br />REMOTE_ADDR: ";
|
710 |
+
if (isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR']) ) {
|
711 |
+
echo esc_html($_SERVER['REMOTE_ADDR']);
|
712 |
+
}
|
713 |
+
else { esc_html_e('Not set', 'iq-block-country');
|
714 |
}
|
|
|
715 |
|
716 |
?>
|
717 |
|
718 |
+
<?php
|
719 |
}
|
720 |
|
721 |
/*
|
722 |
* Function: Import/Export settings
|
723 |
*/
|
724 |
+
function iqblockcountry_settings_importexport()
|
725 |
+
{
|
726 |
+
$iqbc_dir = wp_upload_dir();
|
727 |
+
if (!isset($_POST['iqbc_export']) && !isset($_POST['iqbc_import'])) {
|
728 |
?>
|
729 |
<div class="wrap">
|
730 |
<div id="icon-tools" class="icon32"><br /></div>
|
731 |
+
<h2><?php esc_html_e('Export', 'iq-block-country'); ?></h2>
|
732 |
+
<p><?php esc_html_e('When you click on Backup all settings button a backup of the iQ Block Country configuration will be created.', 'iq-block-country'); ?></p>
|
733 |
+
<p><?php esc_html_e('After exporting, you can either use the backup file to restore your settings on this site again or copy the settings to another WordPress site.', 'iq-block-country'); ?></p>
|
734 |
<form method='post'>
|
735 |
<p class="submit">
|
736 |
<?php wp_nonce_field('iqblockexport'); ?>
|
737 |
+
<input type='submit' name='iqbc_export' value='<?php esc_html_e('Backup all settings', 'iq-block-country'); ?>'/>
|
738 |
</p>
|
739 |
</form>
|
740 |
</div>
|
741 |
|
742 |
<div class="wrap">
|
743 |
<div id="icon-tools" class="icon32"><br /></div>
|
744 |
+
<h2><?php esc_html_e('Import', 'iq-block-country'); ?></h2>
|
745 |
+
<p><?php esc_html_e('Click the browse button and choose a zip file that you exported before.', 'iq-block-country'); ?></p>
|
746 |
+
<p><?php esc_html_e('Press Restore settings button, and let WordPress do the magic for you.', 'iq-block-country'); ?></p>
|
747 |
<form method='post' enctype='multipart/form-data'>
|
748 |
<p class="submit">
|
749 |
<?php wp_nonce_field('iqblockimport'); ?>
|
750 |
+
<input type='file' name='iqbc_import' />
|
751 |
+
<input type='submit' name='iqbc_import' value='<?php esc_html_e('Restore settings', 'iq-block-country'); ?>'/>
|
752 |
</p>
|
753 |
</form>
|
754 |
</div>
|
755 |
<?php
|
756 |
}
|
757 |
+
elseif (isset($_POST['iqbc_export'])) {
|
758 |
|
759 |
+
$iqbc_date = date("d-m-Y");
|
760 |
+
$iqbc_randstr=rand();
|
761 |
+
$iqbc_resultrand = sha1($iqbc_randstr);
|
762 |
+
$iqbc_json_name = "iqblockcountry-".$iqbc_date . "-" . $iqbc_resultrand; // Filename will be generated with random string.
|
|
|
763 |
|
764 |
+
$iqbc_optarr = iqblockcountry_get_options_arr();
|
765 |
+
foreach ( $iqbc_optarr as $iqbc_options ) {
|
766 |
+
$iqbc_value = get_option($iqbc_options);
|
767 |
+
$need_options[$iqbc_options] = $iqbc_value;
|
768 |
}
|
769 |
|
770 |
+
$iqbc_json_file = json_encode($need_options); // Encode data into json data
|
771 |
|
772 |
+
if (!$iqbc_handle = fopen($iqbc_dir['path'] . '/' . 'iqblockcountry.ini', 'w') ) {
|
773 |
+
wp_die( esc_html("Something went wrong exporting this file", 'iq-block-country'));
|
774 |
+
}
|
775 |
|
776 |
+
if (!fwrite($iqbc_handle, $iqbc_json_file) ) {
|
777 |
+
wp_die( esc_html("Something went wrong exporting this file", 'iq-block-country'));
|
778 |
+
}
|
779 |
|
780 |
+
fclose($iqbc_handle);
|
781 |
|
782 |
+
chdir($iqbc_dir['path']);
|
783 |
+
$iqbc_zipfiles = array('iqblockcountry.ini');
|
784 |
+
$iqbc_zipfilename = $iqbc_dir['path'] . '/' . $iqbc_json_name . '-iqblockcountry.zip';
|
785 |
+
$iqbc_zip = new ZipArchive;
|
786 |
+
$iqbc_zip->open($iqbc_zipfilename, ZipArchive::CREATE);
|
787 |
+
foreach ($iqbc_zipfiles as $iqbc_file) {
|
788 |
+
$iqbc_zip->addFile($iqbc_file);
|
789 |
}
|
790 |
+
$iqbc_zip->close();
|
791 |
+
unlink($iqbc_dir['path'] . '/iqblockcountry.ini');
|
792 |
|
793 |
+
$iqbc_url = $iqbc_dir['url'] . '/' . $iqbc_json_name . '-iqblockcountry.zip';
|
794 |
+
$iqbc_content = "<div class='notice notice-success'><p>" . esc_html("Exporting settings...", 'iq-block-country') . "</p></div>";
|
795 |
|
796 |
+
if ($iqbc_url ) {
|
797 |
+
$iqbc_content .= '<script type="text/javascript">
|
798 |
+
document.location = \'' . $iqbc_url . '\';
|
799 |
</script>';
|
800 |
} else {
|
801 |
+
$iqbc_content .= 'Error: ' . $iqbc_url;
|
802 |
}
|
803 |
+
echo $iqbc_content;
|
804 |
}
|
805 |
+
elseif (isset($_POST['iqbc_import'])) {
|
806 |
+
$iqbc_optarr = iqblockcountry_get_options_arr();
|
807 |
+
if (isset($_FILES['iqbc_import']) && check_admin_referer('iqblockimport')) {
|
808 |
+
if (($_FILES['iqbc_import']['error'] > 0) && ($_FILES['type'] == "application/x-zip-compressed")) {
|
809 |
+
wp_die( esc_html("Something went wrong importing this file", 'iq-block-country'));
|
810 |
}
|
811 |
else
|
812 |
{
|
813 |
+
$iqbc_zip = new ZipArchive;
|
814 |
+
$iqbc_res = $iqbc_zip->open($_FILES['iqbc_import']['tmp_name']);
|
815 |
+
if ($iqbc_res === true) {
|
816 |
+
$iqbc_zip->extractTo($iqbc_dir['path'], 'iqblockcountry.ini');
|
817 |
+
$iqbc_zip->close();
|
818 |
+
} else {
|
819 |
+
wp_die( esc_html("Something went wrong importing this file", 'iq-block-country'));
|
820 |
+
}
|
821 |
+
if (file_exists($iqbc_dir['path'] . '/iqblockcountry.ini')) {
|
822 |
+
$encode_options = file_get_contents($iqbc_dir['path'] . '/iqblockcountry.ini');
|
823 |
+
$iqbc_options = json_decode($encode_options, true);
|
824 |
+
foreach ($iqbc_options as $iqbc_key => $iqbc_value) {
|
825 |
+
if (in_array($iqbc_key, $iqbc_optarr)) {
|
826 |
+
update_option($iqbc_key, $iqbc_value);
|
|
|
|
|
827 |
}
|
|
|
|
|
|
|
828 |
}
|
829 |
+
unlink($iqbc_dir['path'] . '/iqblockcountry.ini');
|
830 |
+
|
831 |
+
echo "<div class='notice notice-success'><p>" . esc_html("All options are restored successfully.", 'iq-block-country') . "</p></div>";
|
832 |
+
}
|
833 |
+
else {
|
834 |
+
wp_die( esc_html("ZIP File did not contain any settings", 'iq-block-country'));
|
835 |
+
}
|
836 |
}
|
837 |
}
|
838 |
else {
|
839 |
+
wp_die( esc_html("Something went wrong importing this file", 'iq-block-country'));
|
840 |
}
|
841 |
}
|
842 |
+
else { wp_die( esc_html("No correct import or export option given.", 'iq-block-country'));
|
843 |
+
}
|
844 |
|
845 |
}
|
846 |
|
847 |
/*
|
848 |
* Function: Page settings
|
849 |
*/
|
850 |
+
function iqblockcountry_settings_pages()
|
851 |
+
{
|
852 |
?>
|
853 |
+
<h3><?php esc_html_e('Select which pages are blocked.', 'iq-block-country'); ?></h3>
|
854 |
<form method="post" action="options.php">
|
855 |
+
<?php
|
856 |
+
settings_fields('iqblockcountry-settings-group-pages');
|
857 |
+
?>
|
858 |
+
<table class="form-table" cellspacing="2" cellpadding="5" width="100%">
|
859 |
<tr valign="top">
|
860 |
+
<th width="30%"><?php esc_html_e('Do you want to block individual pages:', 'iq-block-country'); ?><br />
|
861 |
+
<?php esc_html_e('If you do not select this option all pages will be blocked.', 'iq-block-country'); ?></th>
|
862 |
<td width="70%">
|
863 |
+
<input type="checkbox" name="blockcountry_blockpages" value="on" <?php checked('on', get_option('blockcountry_blockpages'), true); ?> />
|
864 |
</td></tr>
|
865 |
|
866 |
|
867 |
<tr valign="top">
|
868 |
+
<th width="30%"><?php esc_html_e('Block pages selected below:', 'iq-block-country'); ?><br />
|
869 |
+
<?php esc_html_e('Block all pages except those selected below', 'iq-block-country'); ?></th>
|
870 |
<td width="70%">
|
871 |
+
<input type="radio" name="blockcountry_blockpages_inverse" value="off" <?php checked('off', get_option('blockcountry_blockpages_inverse'), true); ?> <?php checked(false, get_option('blockcountry_blockpages_inverse'), true); ?> /><br />
|
872 |
<input type="radio" name="blockcountry_blockpages_inverse" value="on" <?php checked('on', get_option('blockcountry_blockpages_inverse'), true); ?> />
|
873 |
</td></tr>
|
874 |
|
875 |
<tr valign="top">
|
876 |
+
<th width="30%"><?php esc_html_e('Select pages you want to block:', 'iq-block-country'); ?></th>
|
877 |
<td width="70%">
|
878 |
|
879 |
+
<ul>
|
880 |
<?php
|
881 |
+
$iqbc_selectedpages = get_option('blockcountry_pages');
|
882 |
+
$iqbc_pages = get_pages();
|
883 |
+
$iqbc_selected = "";
|
884 |
+
foreach ( $iqbc_pages as $iqbc_page ) {
|
885 |
+
if (is_array($iqbc_selectedpages)) {
|
886 |
+
if (in_array($iqbc_page->ID, $iqbc_selectedpages) ) {
|
887 |
+
$iqbc_selected = " checked=\"checked\"";
|
888 |
+
} else {
|
889 |
+
$iqbc_selected = "";
|
890 |
+
}
|
891 |
+
}
|
892 |
+
echo "<li><input type=\"checkbox\" " . $iqbc_selected . " name=\"blockcountry_pages[]\" value=\"" . $iqbc_page->ID . "\" id=\"" . $iqbc_page->post_title . "\" /> <label for=\"" . $iqbc_page->post_title . "\">" . $iqbc_page->post_title . "</label></li>";
|
893 |
+
}
|
894 |
+
?>
|
895 |
</td></tr>
|
896 |
<tr><td></td><td>
|
897 |
+
<p class="submit"><input type="submit" class="button-primary"
|
898 |
+
value="<?php esc_html_e('Save Changes', 'iq-block-country')?>" /></p>
|
899 |
+
</td></tr>
|
900 |
+
</table>
|
901 |
</form>
|
902 |
|
903 |
+
<?php
|
904 |
}
|
905 |
|
906 |
/*
|
907 |
* Function: Categories settings
|
908 |
*/
|
909 |
+
function iqblockcountry_settings_categories()
|
910 |
+
{
|
911 |
?>
|
912 |
+
<h3><?php esc_html_e('Select which categories are blocked.', 'iq-block-country'); ?></h3>
|
913 |
<form method="post" action="options.php">
|
914 |
+
<?php
|
915 |
+
settings_fields('iqblockcountry-settings-group-cat');
|
916 |
+
?>
|
917 |
+
<table class="form-table" cellspacing="2" cellpadding="5" width="100%">
|
918 |
<tr valign="top">
|
919 |
+
<th width="30%"><?php esc_html_e('Do you want to block individual categories:', 'iq-block-country'); ?><br />
|
920 |
+
<?php esc_html_e('If you do not select this option all blog articles will be blocked.', 'iq-block-country'); ?></th>
|
921 |
<td width="70%">
|
922 |
+
<input type="checkbox" name="blockcountry_blockcategories" value="on" <?php checked('on', get_option('blockcountry_blockcategories'), true); ?> />
|
923 |
</td></tr>
|
924 |
<tr valign="top">
|
925 |
+
<th width="30%"><?php esc_html_e('Do you want to block the homepage:', 'iq-block-country'); ?><br />
|
926 |
+
<?php esc_html_e('If you do not select this option visitors will not be blocked from your homepage regardless of the categories you select.', 'iq-block-country'); ?></th>
|
927 |
<td width="70%">
|
928 |
+
<input type="checkbox" name="blockcountry_blockhome" value="on" <?php checked('on', get_option('blockcountry_blockhome'), true); ?> />
|
929 |
</td></tr>
|
930 |
<tr valign="top">
|
931 |
+
<th width="30%"><?php esc_html_e('Select categories you want to block:', 'iq-block-country'); ?></th>
|
932 |
<td width="70%">
|
933 |
|
934 |
+
<ul>
|
935 |
<?php
|
936 |
+
$iqbc_selectedcategories = get_option('blockcountry_categories');
|
937 |
+
$iqbc_categories = get_categories(array("hide_empty"=>0));
|
938 |
+
$iqbc_selected = "";
|
939 |
+
foreach ( $iqbc_categories as $iqbc_category ) {
|
940 |
+
if (is_array($iqbc_selectedcategories)) {
|
941 |
+
if (in_array($iqbc_category->term_id, $iqbc_selectedcategories) ) {
|
942 |
+
$iqbc_selected = " checked=\"checked\"";
|
943 |
+
} else {
|
944 |
+
$iqbc_selected = "";
|
945 |
+
}
|
946 |
+
}
|
947 |
+
echo "<li><input type=\"checkbox\" " . $iqbc_selected . " name=\"blockcountry_categories[]\" value=\"" . $iqbc_category->term_id . "\" id=\"" . $iqbc_category->name . "\" /> <label for=\"" . $iqbc_category->name . "\">" . $iqbc_category->name . "</label></li>";
|
948 |
+
}
|
949 |
+
?>
|
950 |
</td></tr>
|
951 |
<tr><td></td><td>
|
952 |
+
<p class="submit"><input type="submit" class="button-primary"
|
953 |
+
value="<?php esc_html_e('Save Changes', 'iq-block-country')?>" /></p>
|
954 |
+
</td></tr>
|
955 |
+
</table>
|
956 |
</form>
|
957 |
|
958 |
+
<?php
|
959 |
}
|
960 |
|
961 |
/*
|
962 |
* Function: Categories settings
|
963 |
*/
|
964 |
+
function iqblockcountry_settings_tags()
|
965 |
+
{
|
966 |
?>
|
967 |
+
<h3><?php esc_html_e('Select which tags are blocked.', 'iq-block-country'); ?></h3>
|
968 |
<form method="post" action="options.php">
|
969 |
+
<?php
|
970 |
+
settings_fields('iqblockcountry-settings-group-tags');
|
971 |
+
?>
|
972 |
+
<table class="form-table" cellspacing="2" cellpadding="5" width="100%">
|
973 |
<tr valign="top">
|
974 |
+
<th width="30%"><?php esc_html_e('Do you want to block individual tags:', 'iq-block-country'); ?><br />
|
975 |
+
<?php esc_html_e('If you do not select this option all blog articles will be blocked.', 'iq-block-country'); ?></th>
|
976 |
<td width="70%">
|
977 |
+
<input type="checkbox" name="blockcountry_blocktags" value="on" <?php checked('on', get_option('blockcountry_blocktags'), true); ?> />
|
978 |
</td></tr>
|
979 |
<tr valign="top">
|
980 |
+
<th width="30%"><?php esc_html_e('Select tags you want to block:', 'iq-block-country'); ?></th>
|
981 |
<td width="70%">
|
982 |
|
983 |
+
<ul>
|
984 |
<?php
|
985 |
+
$iqbc_selectedtags = get_option('blockcountry_tags');
|
986 |
+
$iqbc_tags = get_tags(array("hide_empty"=>0));
|
987 |
+
$iqbc_selected = "";
|
988 |
+
foreach ( $iqbc_tags as $iqbc_tag ) {
|
989 |
+
if (is_array($iqbc_selectedtags)) {
|
990 |
+
if (in_array($iqbc_tag->term_id, $iqbc_selectedtags) ) {
|
991 |
+
$iqbc_selected = " checked=\"checked\"";
|
992 |
+
} else {
|
993 |
+
$iqbc_selected = "";
|
994 |
+
}
|
995 |
+
}
|
996 |
+
echo "<li><input type=\"checkbox\" " . $iqbc_selected . " name=\"blockcountry_tags[]\" value=\"" . $iqbc_tag->term_id . "\" id=\"" . $iqbc_tag->name . "\" /> <label for=\"" . $iqbc_tag->name . "\">" . $iqbc_tag->name . "</label></li>";
|
997 |
+
}
|
998 |
+
?>
|
999 |
</td></tr>
|
1000 |
<tr><td></td><td>
|
1001 |
+
<p class="submit"><input type="submit" class="button-primary"
|
1002 |
+
value="<?php esc_html_e('Save Changes', 'iq-block-country')?>" /></p>
|
1003 |
+
</td></tr>
|
1004 |
+
</table>
|
1005 |
</form>
|
1006 |
|
1007 |
+
<?php
|
1008 |
}
|
1009 |
|
1010 |
|
1011 |
/*
|
1012 |
* Function: Custom post type settings
|
1013 |
*/
|
1014 |
+
function iqblockcountry_settings_posttypes()
|
1015 |
+
{
|
1016 |
?>
|
1017 |
+
<h3><?php esc_html_e('Select which post types are blocked.', 'iq-block-country'); ?></h3>
|
1018 |
<form method="post" action="options.php">
|
1019 |
+
<?php
|
1020 |
+
settings_fields('iqblockcountry-settings-group-posttypes');
|
1021 |
+
?>
|
1022 |
+
<table class="form-table" cellspacing="2" cellpadding="5" width="100%">
|
1023 |
<tr valign="top">
|
1024 |
+
<th width="30%"><?php esc_html_e('Do you want to block individual post types:', 'iq-block-country'); ?><br />
|
1025 |
<td width="70%">
|
1026 |
+
<input type="checkbox" name="blockcountry_blockposttypes" value="on" <?php checked('on', get_option('blockcountry_blockposttypes'), true); ?> />
|
1027 |
</td></tr>
|
1028 |
<tr valign="top">
|
1029 |
+
<th width="30%"><?php esc_html_e('Select post types you want to block:', 'iq-block-country'); ?></th>
|
1030 |
<td width="70%">
|
1031 |
|
1032 |
+
<ul>
|
1033 |
<?php
|
1034 |
+
$iqbc_post_types = get_post_types('', 'names');
|
1035 |
+
$iqbc_selectedposttypes = get_option('blockcountry_posttypes');
|
1036 |
+
$iqbc_selected = "";
|
1037 |
+
foreach ( $iqbc_post_types as $iqbc_post_type ) {
|
1038 |
+
if (is_array($iqbc_selectedposttypes)) {
|
1039 |
+
if (in_array($iqbc_post_type, $iqbc_selectedposttypes) ) {
|
1040 |
+
$iqbc_selected = " checked=\"checked\"";
|
1041 |
+
} else {
|
1042 |
+
$iqbc_selected = "";
|
1043 |
+
}
|
1044 |
+
}
|
1045 |
+
echo "<li><input type=\"checkbox\" " . $iqbc_selected . " name=\"blockcountry_posttypes[]\" value=\"" . $iqbc_post_type . "\" id=\"" . $iqbc_post_type . "\" /> <label for=\"" . $iqbc_post_type . "\">" . $iqbc_post_type . "</label></li>";
|
1046 |
+
}
|
1047 |
+
?>
|
1048 |
</td></tr>
|
1049 |
<tr><td></td><td>
|
1050 |
+
<p class="submit"><input type="submit" class="button-primary"
|
1051 |
+
value="<?php esc_html_e('Save Changes', 'iq-block-country')?>" /></p>
|
1052 |
+
</td></tr>
|
1053 |
+
</table>
|
1054 |
</form>
|
1055 |
|
1056 |
+
<?php
|
1057 |
}
|
1058 |
|
1059 |
|
1061 |
/*
|
1062 |
* Function: Services settings
|
1063 |
*/
|
1064 |
+
function iqblockcountry_settings_services()
|
1065 |
+
{
|
1066 |
?>
|
1067 |
+
<h3><?php esc_html_e('Select which services are allowed.', 'iq-block-country'); ?></h3>
|
1068 |
<form method="post" action="options.php">
|
1069 |
+
<?php
|
1070 |
+
settings_fields('iqblockcountry-settings-group-se');
|
1071 |
+
?>
|
1072 |
+
<table class="form-table" cellspacing="2" cellpadding="5" width="100%">
|
1073 |
<tr valign="top">
|
1074 |
+
<th width="30%"><?php esc_html_e('Select which services you want to allow:', 'iq-block-country'); ?><br />
|
1075 |
+
<?php esc_html_e('This will allow a service like for instance a search engine to your site despite if you blocked the country.', 'iq-block-country'); ?><br />
|
1076 |
+
<?php esc_html_e('Please note the "Search Engine Visibility" should not be selected in ', 'iq-block-country'); ?><a href="/wp-admin/options-reading.php"><?php esc_html_e('reading settings.', 'iq-block-country'); ?></a>
|
1077 |
</th>
|
1078 |
<td width="70%">
|
1079 |
|
1080 |
+
<ul>
|
1081 |
<?php
|
1082 |
+
global $iqbc_searchengines;
|
1083 |
+
$iqbc_selectedse = get_option('blockcountry_allowse');
|
1084 |
+
$iqbc_selected = "";
|
1085 |
+
foreach ( $iqbc_searchengines AS $iqbc_se => $iqbc_seua ) {
|
1086 |
+
if (is_array($iqbc_selectedse)) {
|
1087 |
+
if (in_array($iqbc_se, $iqbc_selectedse) ) {
|
1088 |
+
$iqbc_selected = " checked=\"checked\"";
|
1089 |
+
} else {
|
1090 |
+
$iqbc_selected = "";
|
1091 |
+
}
|
1092 |
+
}
|
1093 |
+
echo "<li><input type=\"checkbox\" " . $iqbc_selected . " name=\"blockcountry_allowse[]\" value=\"" . $iqbc_se . "\" id=\"" . $iqbc_se . "\" /> <label for=\"" . $iqbc_se . "\">" . $iqbc_se . "</label></li>";
|
1094 |
+
}
|
1095 |
+
?>
|
1096 |
</td></tr>
|
1097 |
<tr><td></td><td>
|
1098 |
+
<p class="submit"><input type="submit" class="button-primary"
|
1099 |
+
value="<?php esc_html_e('Save Changes', 'iq-block-country')?>" /></p>
|
1100 |
+
</td></tr>
|
1101 |
+
</table>
|
1102 |
</form>
|
1103 |
|
1104 |
+
<?php
|
1105 |
}
|
1106 |
|
1107 |
|
1110 |
*/
|
1111 |
function iqblockcountry_settings_frontend()
|
1112 |
{
|
1113 |
+
?>
|
1114 |
+
<h3><?php esc_html_e('Frontend options', 'iq-block-country'); ?></h3>
|
1115 |
|
1116 |
<form method="post" action="options.php">
|
1117 |
<?php
|
1118 |
+
settings_fields('iqblockcountry-settings-group-frontend');
|
1119 |
+
if (!class_exists('GeoIP')) {
|
1120 |
+
include_once "geoip.inc";
|
1121 |
+
}
|
1122 |
+
if (class_exists('GeoIP')) {
|
1123 |
+
$iqbc_countrylist = iqblockcountry_get_isocountries();
|
1124 |
+
|
1125 |
+
$iqbc_ip_address = iqblockcountry_get_ipaddress();
|
1126 |
+
$iqbc_country = iqblockcountry_check_ipaddress($iqbc_ip_address);
|
1127 |
+
if ($iqbc_country == "Unknown" || $iqbc_country == "ipv6" || $iqbc_country == "" || $iqbc_country == "FALSE") { $iqbc_displaycountry = "Unknown";
|
1128 |
+
}
|
1129 |
+
else { $iqbc_displaycountry = $iqbc_countrylist[$iqbc_country];
|
1130 |
+
}
|
|
|
1131 |
|
1132 |
+
?>
|
1133 |
|
|
|
1134 |
|
1135 |
|
1136 |
+
<table class="form-table" cellspacing="2" cellpadding="5" width="100%">
|
1137 |
|
1138 |
<tr valign="top">
|
1139 |
+
<th width="30%"><?php esc_html_e('Block visitors from visiting the frontend of your website:', 'iq-block-country'); ?></th>
|
1140 |
<td width="70%">
|
1141 |
+
<input type="checkbox" name="blockcountry_blockfrontend" <?php checked('on', get_option('blockcountry_blockfrontend'), true); ?> />
|
1142 |
</td></tr>
|
1143 |
|
1144 |
+
<tr valign="top">
|
1145 |
+
<th width="30%"><?php esc_html_e('Do not block visitors that are logged in from visiting frontend website:', 'iq-block-country'); ?></th>
|
1146 |
+
<td width="70%">
|
1147 |
+
<input type="checkbox" name="blockcountry_blocklogin" <?php checked('on', get_option('blockcountry_blocklogin'), true); ?> />
|
1148 |
+
</td></tr>
|
1149 |
|
1150 |
<tr valign="top">
|
1151 |
+
<th width="30%"><?php esc_html_e('Block visitors from using the search function of your website:', 'iq-block-country'); ?></th>
|
1152 |
<td width="70%">
|
1153 |
+
<input type="checkbox" name="blockcountry_blocksearch" <?php checked('on', get_option('blockcountry_blocksearch'), true); ?> />
|
1154 |
</td></tr>
|
1155 |
|
1156 |
<tr valign="top">
|
1157 |
+
<th width="30%"><?php esc_html_e('Block countries selected below:', 'iq-block-country'); ?><br />
|
1158 |
+
<?php esc_html_e('Block all countries except those selected below', 'iq-block-country'); ?></th>
|
1159 |
<td width="70%">
|
1160 |
+
<input type="radio" name="blockcountry_banlist_inverse" value="off" <?php checked('off', get_option('blockcountry_banlist_inverse'), true); ?> <?php checked(false, get_option('blockcountry_banlist_inverse'), true); ?> /><br />
|
1161 |
<input type="radio" name="blockcountry_banlist_inverse" value="on" <?php checked('on', get_option('blockcountry_banlist_inverse'), true); ?> />
|
1162 |
</td></tr>
|
1163 |
|
1164 |
<tr valign="top">
|
1165 |
+
<th scope="row" width="30%"><?php esc_html_e('Select the countries:', 'iq-block-country'); ?><br />
|
1166 |
+
<?php esc_html_e('Use the CTRL key to select multiple countries', 'iq-block-country'); ?></th>
|
1167 |
+
<td width="70%">
|
1168 |
|
1169 |
<?php
|
1170 |
+
$iqbc_selected = "";
|
1171 |
+
$iqbc_haystack = get_option('blockcountry_banlist');
|
1172 |
|
1173 |
+
if (get_option('blockcountry_accessibility')) {
|
|
|
1174 |
echo "<ul>";
|
1175 |
+
foreach ( $iqbc_countrylist as $iqbc_key => $iqbc_value ) {
|
1176 |
+
if (is_array($iqbc_haystack) && in_array($iqbc_key, $iqbc_haystack)) {
|
1177 |
+
$iqbc_selected = " checked=\"checked\"";
|
1178 |
+
} else {
|
1179 |
+
$iqbc_selected = "";
|
1180 |
+
}
|
1181 |
+
echo "<li><input type=\"checkbox\" " . $iqbc_selected . " name=\"blockcountry_banlist[]\" value=\"" . esc_html($iqbc_key) . "\" \"/> <label for=\"" . esc_html($iqbc_value) . "\">" . esc_html($iqbc_value) . "</label></li>";
|
1182 |
}
|
1183 |
echo "</ul>";
|
1184 |
}
|
1185 |
else
|
1186 |
{
|
1187 |
+
?>
|
1188 |
|
1189 |
|
1190 |
<select data-placeholder="Choose a country..." class="chosen" name="blockcountry_banlist[]" multiple="true" style="width:600px;">
|
1191 |
<optgroup label="(de)select all countries">
|
1192 |
<?php
|
1193 |
+
foreach ( $iqbc_countrylist as $iqbc_key => $iqbc_value ) {
|
1194 |
+
print "<option value=\"". esc_html($iqbc_key) ."\"";
|
1195 |
+
if (is_array($iqbc_haystack) && in_array($iqbc_key, $iqbc_haystack)) {
|
1196 |
+
print " selected=\"selected\" ";
|
1197 |
+
}
|
1198 |
+
print ">". esc_html($iqbc_value) ."</option>\n";
|
1199 |
+
}
|
1200 |
echo "</optgroup>";
|
1201 |
echo " </select>";
|
1202 |
}
|
1203 |
|
1204 |
+
?>
|
1205 |
</td></tr>
|
1206 |
<tr valign="top">
|
1207 |
+
<th width="30%"><?php esc_html_e('Block tag pages:', 'iq-block-country'); ?><br />
|
1208 |
+
<?php esc_html_e('If you select this option tag pages will be blocked.', 'iq-block-country')?></th>
|
1209 |
<td width="70%">
|
1210 |
<input type="checkbox" name="blockcountry_blocktag" <?php checked('on', get_option('blockcountry_blocktag'), true); ?> />
|
1211 |
</td></tr>
|
1212 |
|
1213 |
<tr valign="top">
|
1214 |
+
<th width="30%"><?php esc_html_e('Block feed:', 'iq-block-country'); ?><br />
|
1215 |
+
<?php esc_html_e('If you select this option feed pages will be blocked.', 'iq-block-country')?></th>
|
1216 |
<td width="70%">
|
1217 |
<input type="checkbox" name="blockcountry_blockfeed" <?php checked('on', get_option('blockcountry_blockfeed'), true); ?> />
|
1218 |
</td></tr>
|
1220 |
|
1221 |
|
1222 |
<tr valign="top">
|
1223 |
+
<th width="30%"><?php esc_html_e('Frontend allow list IPv4 and/or IPv6 addresses:', 'iq-block-country'); ?><br /><?php esc_html_e('Use a semicolon (;) to separate IP addresses', 'iq-block-country'); ?><br /><?php esc_html_e('This field accepts single IP addresses as well as ranges in CIDR format.', 'iq-block-country'); ?></th>
|
1224 |
+
<td width="70%">
|
1225 |
+
<?php
|
1226 |
+
$iqbc_frontendallowlist = get_option('blockcountry_frontendwhitelist');
|
1227 |
+
?>
|
1228 |
+
<textarea cols="70" rows="5" name="blockcountry_frontendwhitelist"><?php echo esc_html($iqbc_frontendallowlist); ?></textarea>
|
1229 |
+
</td></tr>
|
1230 |
<tr valign="top">
|
1231 |
+
<th width="30%"><?php esc_html_e('Frontend block list IPv4 and/or IPv6 addresses:', 'iq-block-country'); ?><br /><?php esc_html_e('Use a semicolon (;) to separate IP addresses', 'iq-block-country'); ?><br /><?php esc_html_e('This field accepts single IP addresses as well as ranges in CIDR format.', 'iq-block-country'); ?></th>
|
1232 |
+
<td width="70%">
|
1233 |
+
<?php
|
1234 |
+
$iqbc_frontendblocklist = get_option('blockcountry_frontendblacklist');
|
1235 |
+
?>
|
1236 |
+
<textarea cols="70" rows="5" name="blockcountry_frontendblacklist"><?php echo esc_html($iqbc_frontendblocklist); ?></textarea>
|
1237 |
+
</td></tr>
|
1238 |
+
<tr><td></td><td>
|
1239 |
+
<p class="submit"><input type="submit" class="button-primary"
|
1240 |
+
value="<?php esc_html_e('Save Changes', 'iq-block-country')?>" /></p>
|
1241 |
+
</td></tr>
|
1242 |
+
</table>
|
1243 |
</form>
|
1244 |
+
<?php
|
1245 |
+
}
|
1246 |
+
else
|
1247 |
{
|
1248 |
+
print "<p>You are missing the GeoIP class. Perhaps geoip.inc is missing?</p>";
|
1249 |
+
}
|
1250 |
|
1251 |
}
|
1252 |
|
1256 |
*/
|
1257 |
function iqblockcountry_settings_backend()
|
1258 |
{
|
1259 |
+
?>
|
1260 |
+
<h3><?php esc_html_e('Backend Options', 'iq-block-country'); ?></h3>
|
1261 |
|
1262 |
<form method="post" action="options.php">
|
1263 |
<?php
|
1264 |
+
settings_fields('iqblockcountry-settings-group-backend');
|
1265 |
+
if (!class_exists('GeoIP')) {
|
1266 |
+
include_once "geoip.inc";
|
1267 |
+
}
|
1268 |
+
if (class_exists('GeoIP')) {
|
1269 |
+
|
1270 |
+
$iqbc_countrylist = iqblockcountry_get_isocountries();
|
1271 |
+
|
1272 |
+
$iqbc_ip_address = iqblockcountry_get_ipaddress();
|
1273 |
+
$iqbc_country = iqblockcountry_check_ipaddress($iqbc_ip_address);
|
1274 |
+
if ($iqbc_country == "Unknown" || $iqbc_country == "ipv6" || $iqbc_country == "" || $iqbc_country == "FALSE") { $iqbc_displaycountry = "Unknown";
|
1275 |
+
}
|
1276 |
+
else { $iqbc_displaycountry = $iqbc_countrylist[$iqbc_country];
|
1277 |
+
}
|
|
|
1278 |
|
1279 |
|
1280 |
+
?>
|
|
|
|
|
|
|
1281 |
|
1282 |
+
<table class="form-table" cellspacing="2" cellpadding="5" width="100%">
|
1283 |
+
<tr valign="top">
|
1284 |
+
<th width="30%"><?php esc_html_e('Block visitors from visiting the backend (administrator) of your website:', 'iq-block-country'); ?></th>
|
1285 |
+
<td width="70%">
|
1286 |
+
<input type="checkbox" name="blockcountry_blockbackend" <?php checked('on', get_option('blockcountry_blockbackend'), true); ?> />
|
1287 |
</td></tr>
|
1288 |
|
1289 |
<tr>
|
1290 |
<th width="30%"></th>
|
1291 |
<th width="70%">
|
1292 |
+
<?php esc_html_e('Your IP address is', 'iq-block-country'); ?> <i><?php echo $iqbc_ip_address ?></i>. <?php esc_html_e('The country that is listed for this IP address is', 'iq-block-country'); ?> <em><?php echo $iqbc_displaycountry ?></em>.<br />
|
1293 |
+
<?php esc_html_e('Do NOT set the \'Block visitors from visiting the backend (administrator) of your website\' and also select', 'iq-block-country'); ?> <?php echo $iqbc_displaycountry ?> <?php esc_html_e('below.', 'iq-block-country'); ?><br />
|
1294 |
+
<?php echo "<strong>" . esc_html_e('You will NOT be able to login the next time if you DO block your own country from visiting the backend.', 'iq-block-country') . "</strong>"; ?>
|
1295 |
</th>
|
1296 |
</tr>
|
1297 |
+
</td></tr>
|
1298 |
<tr valign="top">
|
1299 |
+
<th width="30%"><?php esc_html_e('Block countries selected below:', 'iq-block-country'); ?><br />
|
1300 |
+
<?php esc_html_e('Block all countries except those selected below', 'iq-block-country'); ?></th>
|
1301 |
<td width="70%">
|
1302 |
+
<input type="radio" name="blockcountry_backendbanlist_inverse" value="off" <?php checked('off', get_option('blockcountry_backendbanlist_inverse'), true); ?> <?php checked(false, get_option('blockcountry_backendbanlist_inverse'), true); ?> /><br />
|
1303 |
<input type="radio" name="blockcountry_backendbanlist_inverse" value="on" <?php checked('on', get_option('blockcountry_backendbanlist_inverse'), true); ?> />
|
1304 |
</td></tr>
|
1305 |
|
1306 |
<tr valign="top">
|
1307 |
+
<th scope="row" width="30%"><?php esc_html_e('Select the countries:', 'iq-block-country'); ?><br />
|
1308 |
+
<?php esc_html_e('Use the CTRL key to select multiple countries', 'iq-block-country'); ?></th>
|
1309 |
+
<td width="70%">
|
1310 |
|
1311 |
<?php
|
1312 |
+
$iqbc_selected = "";
|
1313 |
+
$iqbc_haystack = get_option('blockcountry_backendbanlist');
|
1314 |
+
|
1315 |
+
if (get_option('blockcountry_accessibility')) {
|
1316 |
+
echo "<ul>";
|
1317 |
+
foreach ( $iqbc_countrylist as $iqbc_key => $iqbc_value ) {
|
1318 |
+
if (is_array($iqbc_haystack) && in_array($iqbc_key, $iqbc_haystack)) {
|
1319 |
+
$iqbc_selected = " checked=\"checked\"";
|
1320 |
+
} else {
|
1321 |
+
$iqbc_selected = "";
|
1322 |
+
}
|
1323 |
+
echo "<li><input type=\"checkbox\" " . $iqbc_selected . " name=\"blockcountry_backendbanlist[]\" value=\"" . esc_html($iqbc_key) . "\" \"/> <label for=\"" . esc_html($iqbc_value) . "\">" . esc_html($iqbc_value) . "</label></li>";
|
1324 |
+
}
|
1325 |
+
echo "</ul>";
|
1326 |
+
}
|
1327 |
+
else
|
1328 |
+
{
|
1329 |
+
?> <select class="chosen" data-placeholder="Choose a country..." name="blockcountry_backendbanlist[]" multiple="true" style="width:600px;">
|
|
|
1330 |
<optgroup label="(de)select all countries">
|
1331 |
|
1332 |
+
<?php
|
1333 |
+
foreach ( $iqbc_countrylist as $iqbc_key => $iqbc_value ) {
|
1334 |
+
print "<option value=\"". esc_html($iqbc_key) . "\"";
|
1335 |
+
if (is_array($iqbc_haystack) && in_array($iqbc_key, $iqbc_haystack)) {
|
1336 |
+
print " selected=\"selected\" ";
|
1337 |
+
}
|
1338 |
+
print ">". esc_html($iqbc_value) . "</option>\n";
|
1339 |
}
|
1340 |
echo "</optgroup>";
|
1341 |
echo " </select>";
|
1342 |
+
}
|
1343 |
+
?>
|
1344 |
|
1345 |
</td></tr>
|
1346 |
|
1347 |
<tr valign="top">
|
1348 |
+
<th width="30%"><?php esc_html_e('Backend allow list IPv4 and/or IPv6 addresses:', 'iq-block-country'); ?><br /><?php esc_html_e('Use a semicolon (;) to separate IP addresses', 'iq-block-country'); ?><br /><?php esc_html_e('This field accepts single IP addresses as well as ranges in CIDR format.', 'iq-block-country'); ?></th>
|
1349 |
+
<td width="70%">
|
1350 |
+
<?php
|
1351 |
+
$iqbc_backendallowlist = get_option('blockcountry_backendwhitelist');
|
1352 |
+
?>
|
1353 |
+
<textarea cols="70" rows="5" name="blockcountry_backendwhitelist"><?php echo esc_html($iqbc_backendallowlist); ?></textarea>
|
1354 |
+
</td></tr>
|
1355 |
<tr valign="top">
|
1356 |
+
<th width="30%"><?php esc_html_e('Backend block list IPv4 and/or IPv6 addresses:', 'iq-block-country'); ?><br /><?php esc_html_e('Use a semicolon (;) to separate IP addresses', 'iq-block-country'); ?><br /><?php esc_html_e('This field accepts single IP addresses as well as ranges in CIDR format.', 'iq-block-country'); ?></th>
|
1357 |
+
<td width="70%">
|
1358 |
+
<?php
|
1359 |
+
$iqbc_backendblocklist = get_option('blockcountry_backendblacklist');
|
1360 |
+
?>
|
1361 |
+
<textarea cols="70" rows="5" name="blockcountry_backendblacklist"><?php echo esc_html($iqbc_backendblocklist); ?></textarea>
|
1362 |
+
</td></tr>
|
1363 |
+
<tr><td></td><td>
|
1364 |
+
<p class="submit"><input type="submit" class="button-primary"
|
1365 |
+
value="<?php esc_html_e('Save Changes', 'iq-block-country')?>" /></p>
|
1366 |
+
</td></tr>
|
1367 |
+
</table>
|
1368 |
</form>
|
1369 |
+
<?php
|
1370 |
+
}
|
1371 |
+
else
|
1372 |
{
|
1373 |
+
print "<p>You are missing the GeoIP class. Perhaps geoip.inc is missing?</p>";
|
1374 |
+
}
|
1375 |
|
1376 |
}
|
1377 |
|
1383 |
function iqblockcountry_settings_home()
|
1384 |
{
|
1385 |
|
1386 |
+
/* Check if the Geo Database exists or if GeoIP API key is entered otherwise display notification */
|
1387 |
+
if (is_file(IQBCGEOIP2DBFILE) && (!get_option('blockcountry_geoapikey'))) {
|
1388 |
+
$iqbc_filedate = filemtime(IQBCGEOIP2DBFILE);
|
1389 |
+
$iqbc_3months = time() - 3 * 31 * 86400;
|
1390 |
+
if ($iqbc_filedate < $iqbc_3months) {
|
1391 |
+
iq_old_db_notice();
|
1392 |
+
}
|
1393 |
+
}
|
|
|
1394 |
|
1395 |
|
1396 |
+
?>
|
1397 |
+
<h3><?php esc_html_e('Overall statistics since start', 'iq-block-country'); ?></h3>
|
1398 |
|
1399 |
+
<?php $iqbc_blocked = get_option('blockcountry_backendnrblocks'); ?>
|
1400 |
+
<p><?php echo esc_html(number_format($iqbc_blocked)); ?> <?php esc_html_e('visitors blocked from the backend.', 'iq-block-country'); ?></p>
|
1401 |
+
<?php $iqbc_blocked = get_option('blockcountry_frontendnrblocks'); ?>
|
1402 |
+
<p><?php echo esc_html(number_format($iqbc_blocked)); ?> <?php esc_html_e('visitors blocked from the frontend.', 'iq-block-country'); ?></p>
|
1403 |
|
1404 |
<form method="post" action="options.php">
|
1405 |
<?php
|
1406 |
+
settings_fields('iqblockcountry-settings-group');
|
1407 |
+
if (!class_exists('GeoIP')) {
|
1408 |
+
include_once "geoip.inc";
|
1409 |
+
}
|
1410 |
+
if (class_exists('GeoIP')) {
|
1411 |
+
$iqbc_countrylist = iqblockcountry_get_isocountries();
|
1412 |
+
?>
|
1413 |
+
|
|
|
|
|
|
|
1414 |
|
1415 |
<hr>
|
1416 |
+
<h3><?php esc_html_e('Block type', 'iq-block-country'); ?></h3>
|
1417 |
<em>
|
1418 |
+
<?php esc_html_e('You should choose one of the 3 block options below. This wil either show a block message, redirect to an internal page or redirect to an external page.', 'iq-block-country'); ?>
|
1419 |
</em>
|
1420 |
+
<table class="form-table" cellspacing="2" cellpadding="5" width="100%">
|
1421 |
|
1422 |
<tr valign="top">
|
1423 |
+
<th width="30%"><?php esc_html_e('Message to display when people are blocked:', 'iq-block-country'); ?></th>
|
1424 |
+
<td width="70%">
|
1425 |
+
<?php
|
1426 |
+
$iqbc_blockmessage = get_option('blockcountry_blockmessage');
|
1427 |
+
if (empty($iqbc_blockmessage)) { $iqbc_blockmessage = "Forbidden - Visitors from your country are not permitted to browse this site.";
|
1428 |
+
}
|
1429 |
+
?>
|
1430 |
+
<textarea cols="100" rows="3" name="blockcountry_blockmessage"><?php echo esc_html($iqbc_blockmessage); ?></textarea>
|
1431 |
+
</td></tr>
|
1432 |
|
1433 |
|
1434 |
<tr valign="top">
|
1435 |
+
<th width="30%"><?php esc_html_e('Page to redirect to:', 'iq-block-country'); ?><br />
|
1436 |
+
<em><?php esc_html_e('If you select a page here blocked visitors will be redirected to this page instead of displaying above block message.', 'iq-block-country'); ?></em></th>
|
1437 |
</th>
|
1438 |
+
<td width="70%">
|
1439 |
<select class="chosen" name="blockcountry_redirect" style="width:400px;">
|
1440 |
<?php
|
1441 |
+
$iqbc_haystack = get_option('blockcountry_redirect');
|
1442 |
+
echo "<option value=\"0\">". esc_html("Choose a page...", 'iq-block-country') . "</option>";
|
1443 |
+
$iqbc_pages = get_pages();
|
1444 |
+
foreach ( $iqbc_pages as $iqbc_page ) {
|
1445 |
+
print "<option value=\"$iqbc_page->ID\"";
|
1446 |
+
if ($iqbc_page->ID == $iqbc_haystack) {
|
1447 |
+
|
1448 |
+
print " selected=\"selected\" ";
|
1449 |
+
}
|
1450 |
+
print ">" . esc_html($iqbc_page->post_title) . "</option>\n";
|
1451 |
+
}
|
1452 |
+
?>
|
1453 |
</select>
|
1454 |
</td></tr>
|
1455 |
|
1456 |
<tr valign="top">
|
1457 |
+
<th width="30%"><?php esc_html_e('URL to redirect to:', 'iq-block-country'); ?><br />
|
1458 |
+
<em><?php esc_html_e('If you enter a URL here blocked visitors will be redirected to this URL instead of displaying above block message or redirected to a local page.', 'iq-block-country'); ?></em>
|
1459 |
</th>
|
1460 |
<td width="70%">
|
1461 |
+
<input type="text" style="width:100%" name="blockcountry_redirect_url" value="<?php echo get_option('blockcountry_redirect_url');?>">
|
1462 |
</td></tr>
|
1463 |
</table>
|
1464 |
<hr>
|
1465 |
+
<h3><?php esc_html_e('General settings', 'iq-block-country'); ?></h3>
|
1466 |
|
1467 |
+
<table class="form-table" cellspacing="2" cellpadding="5" width="100%">
|
1468 |
<tr valign="top">
|
1469 |
+
<th width="30%"><?php esc_html_e('Send headers when user is blocked:', 'iq-block-country'); ?><br />
|
1470 |
+
<em><?php esc_html_e('Under normal circumstances you should keep this selected! Only if you have "Cannot modify header information - headers already sent" errors or if you know what you are doing uncheck this.', 'iq-block-country'); ?></em></th>
|
1471 |
+
<td width="70%">
|
1472 |
+
<input type="checkbox" name="blockcountry_header" <?php checked('on', get_option('blockcountry_header'), true); ?> />
|
1473 |
+
</td></tr>
|
1474 |
|
1475 |
<tr valign="top">
|
1476 |
+
<th width="30%"><?php esc_html_e('Buffer output?:', 'iq-block-country'); ?><br />
|
1477 |
+
<em><?php esc_html_e('You can use this option to buffer all output. This can be helpful in case you have "headers already sent" issues.', 'iq-block-country'); ?></em></th>
|
1478 |
+
<td width="70%">
|
1479 |
+
<input type="checkbox" name="blockcountry_buffer" <?php checked('on', get_option('blockcountry_buffer'), true); ?> />
|
1480 |
+
</td></tr>
|
1481 |
|
1482 |
+
<tr valign="top">
|
1483 |
+
<th width="30%"><?php esc_html_e('Do not log IP addresses:', 'iq-block-country'); ?><br />
|
1484 |
+
<em><?php esc_html_e('Check this box if the laws in your country do not permit you to log IP addresses or if you do not want to log the ip addresses.', 'iq-block-country'); ?></em></th>
|
1485 |
+
<td width="70%">
|
1486 |
+
<input type="checkbox" name="blockcountry_logging" <?php checked('on', get_option('blockcountry_logging'), true); ?> />
|
1487 |
+
</td></tr>
|
1488 |
+
|
1489 |
+
<tr valign="top">
|
1490 |
+
<th width="30%"><?php esc_html_e('Do not block admin-ajax.php:', 'iq-block-country'); ?><br />
|
1491 |
+
<em><?php esc_html_e('Check this box if you use a plugin that uses admin-ajax.php.', 'iq-block-country'); ?></em></th>
|
1492 |
+
<td width="70%">
|
1493 |
+
<input type="checkbox" name="blockcountry_adminajax" <?php checked('on', get_option('blockcountry_adminajax'), true); ?> />
|
1494 |
+
</td></tr>
|
1495 |
|
1496 |
|
1497 |
|
1498 |
|
1499 |
<tr valign="top">
|
1500 |
+
<th width="30%"><?php esc_html_e('Number of rows on logging tab:', 'iq-block-country'); ?><br />
|
1501 |
+
<em><?php esc_html_e('How many rows do you want to display on each column on the logging tab.', 'iq-block-country'); ?></em></th>
|
1502 |
+
<td width="70%">
|
1503 |
+
<?php
|
1504 |
+
$iqbc_nrrows = get_option('blockcountry_nrstatistics'); ?>
|
1505 |
<select name="blockcountry_nrstatistics">
|
1506 |
+
<option <?php selected($iqbc_nrrows, 10); ?> value="10">10</option>
|
1507 |
+
<option <?php selected($iqbc_nrrows, 15); ?> value="15">15</option>
|
1508 |
+
<option <?php selected($iqbc_nrrows, 20); ?> value="20">20</option>
|
1509 |
+
<option <?php selected($iqbc_nrrows, 25); ?> value="25">25</option>
|
1510 |
+
<option <?php selected($iqbc_nrrows, 30); ?> value="30">30</option>
|
1511 |
+
<option <?php selected($iqbc_nrrows, 45); ?> value="45">45</option>
|
1512 |
</select>
|
1513 |
+
</td></tr>
|
1514 |
|
1515 |
<tr valign="top">
|
1516 |
+
<th width="30%"><?php esc_html_e('Number of days to keep logging:', 'iq-block-country'); ?><br />
|
1517 |
+
<em><?php esc_html_e('How many days do you want to keep the logging used for the logging tab.', 'iq-block-country'); ?></em></th>
|
1518 |
+
<td width="70%">
|
1519 |
+
<?php
|
1520 |
+
$iqbc_nrdays = get_option('blockcountry_daysstatistics'); ?>
|
1521 |
<select name="blockcountry_daysstatistics">
|
1522 |
+
<option <?php selected($iqbc_nrdays, 7); ?> value="7">7</option>
|
1523 |
+
<option <?php selected($iqbc_nrdays, 14); ?> value="14">14</option>
|
1524 |
+
<option <?php selected($iqbc_nrdays, 21); ?> value="21">21</option>
|
1525 |
+
<option <?php selected($iqbc_nrdays, 30); ?> value="30">30</option>
|
1526 |
+
<option <?php selected($iqbc_nrdays, 60); ?> value="60">60</option>
|
1527 |
+
<option <?php selected($iqbc_nrdays, 90); ?> value="90">90</option>
|
1528 |
</select>
|
1529 |
+
</td></tr>
|
1530 |
+
|
1531 |
+
<tr valign="top">
|
1532 |
+
<th width="30%"><?php esc_html_e('Do not lookup hosts on the logging tab:', 'iq-block-country'); ?><br />
|
1533 |
+
<em><?php esc_html_e('On some hosting environments looking up hosts may slow down the logging tab.', 'iq-block-country'); ?></em></th>
|
1534 |
+
<td width="70%">
|
1535 |
+
<input type="checkbox" name="blockcountry_lookupstatistics" <?php checked('on', get_option('blockcountry_lookupstatistics'), true); ?> />
|
1536 |
+
</td></tr>
|
1537 |
|
1538 |
+
<tr valign="top">
|
1539 |
+
<th width="30%"><?php esc_html_e('Allow tracking:', 'iq-block-country'); ?><br />
|
1540 |
+
<em><?php esc_html_e('This sends only the IP address and the number of attempts this ip address tried to login to your backend and was blocked doing so to a central server. No other data is being send. This helps us to get a better picture of rogue countries.', 'iq-block-country'); ?></em></th>
|
1541 |
+
<td width="70%">
|
1542 |
+
<input type="checkbox" name="blockcountry_tracking" <?php checked('on', get_option('blockcountry_tracking'), true); ?> />
|
1543 |
+
</td></tr>
|
1544 |
|
1545 |
<tr valign="top">
|
1546 |
+
<th width="30%"><?php esc_html_e('GeoIP API Key:', 'iq-block-country'); ?><br />
|
1547 |
+
<em><?php esc_html_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>
|
1548 |
</th>
|
1549 |
<td width="70%">
|
1550 |
+
<input type="text" size="25" name="blockcountry_geoapikey" value="<?php echo get_option('blockcountry_geoapikey');?>">
|
1551 |
</td></tr>
|
1552 |
|
1553 |
|
1554 |
<tr valign="top">
|
1555 |
+
<th width="30%"><?php esc_html_e('GeoIP API Key Server Location:', 'iq-block-country'); ?><br />
|
1556 |
+
<em><?php esc_html_e('Choose a location closest to your own location.', 'iq-block-country'); ?>
|
1557 |
</th>
|
1558 |
+
<td width="70%">
|
1559 |
|
1560 |
<input type="radio" name="blockcountry_geoapilocation" value="EU" <?php checked('EU', get_option('blockcountry_geoapilocation'), true); ?>> Europe (Netherlands)<br />
|
1561 |
+
<input type="radio" name="blockcountry_geoapilocation" value="EU3" <?php checked('EU3', get_option('blockcountry_geoapilocation'), true); ?>> Europe (Netherlands)<br />
|
1562 |
<input type="radio" name="blockcountry_geoapilocation" value="US" <?php checked('US', get_option('blockcountry_geoapilocation'), true); ?>> United States - New York<br />
|
1563 |
<input type="radio" name="blockcountry_geoapilocation" value="US2" <?php checked('US2', get_option('blockcountry_geoapilocation'), true); ?>> United States - San Francisco<br />
|
1564 |
<input type="radio" name="blockcountry_geoapilocation" value="US3" <?php checked('US3', get_option('blockcountry_geoapilocation'), true); ?>> United States - Miami<br />
|
1565 |
|
1566 |
+
</td></tr>
|
1567 |
<tr valign="top">
|
1568 |
+
<th width="30%"><?php esc_html_e('Admin block API Key:', 'iq-block-country'); ?><br />
|
1569 |
+
<em><?php esc_html_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>
|
1570 |
</th>
|
1571 |
+
<td width="70%">
|
1572 |
+
<input type="text" size="25" name="blockcountry_apikey" value="<?php echo get_option('blockcountry_apikey');?>">
|
1573 |
+
</td></tr>
|
1574 |
|
1575 |
|
1576 |
+
<tr valign="top">
|
1577 |
+
<th width="30%"><?php esc_html_e('Accessibility options:', 'iq-block-country'); ?><br />
|
1578 |
+
<em><?php esc_html_e('Set this option if you cannot use the default country selection box.', 'iq-block-country'); ?></em></th>
|
1579 |
+
<td width="70%">
|
1580 |
+
<input type="checkbox" name="blockcountry_accessibility" <?php checked('on', get_option('blockcountry_accessibility'), true); ?> />
|
1581 |
+
</td></tr>
|
1582 |
|
1583 |
<tr valign="top">
|
1584 |
+
<th width="30%"><?php esc_html_e('Override IP information:', 'iq-block-country'); ?><br />
|
1585 |
+
<em><?php esc_html_e('This option allows you to override how iQ Block Country gets the real IP of your visitors.', 'iq-block-country'); ?></em></th>
|
1586 |
+
<td width="70%">
|
1587 |
+
<?php
|
1588 |
+
$iqbc_ipoverride = get_option('blockcountry_ipoverride'); ?>
|
1589 |
<select name="blockcountry_ipoverride">
|
1590 |
+
<option <?php selected($iqbc_ipoverride, "NONE"); ?> value="NONE">No override</option>
|
1591 |
+
<option <?php selected($iqbc_ipoverride, "REMOTE_ADDR"); ?> value="REMOTE_ADDR">REMOTE_ADDR</option>
|
1592 |
+
<option <?php selected($iqbc_ipoverride, "HTTP_FORWARDED"); ?> value="HTTP_FORWARDED">HTTP_FORWARDED</option>
|
1593 |
+
<option <?php selected($iqbc_ipoverride, "HTTP_X_REAL_IP"); ?> value="HTTP_X_REAL_IP">HTTP_X_REAL_IP</option>
|
1594 |
+
<option <?php selected($iqbc_ipoverride, "HTTP_CLIENT_IP"); ?> value="HTTP_CLIENT_IP">HTTP_CLIENT_IP</option>
|
1595 |
+
<option <?php selected($iqbc_ipoverride, "HTTP_X_FORWARDED"); ?> value="HTTP_X_FORWARDED">HTTP_X_FORWARDED</option>
|
1596 |
+
<option <?php selected($iqbc_ipoverride, "HTTP_X_FORWARDED_FOR"); ?> value="HTTP_X_FORWARDED_FOR">HTTP_X_FORWARDED_FOR</option>
|
1597 |
+
<option <?php selected($iqbc_ipoverride, "HTTP_INCAP_CLIENT_IP"); ?> value="HTTP_INCAP_CLIENT_IP">HTTP_X_FORWARDED</option>
|
1598 |
+
<option <?php selected($iqbc_ipoverride, "HTTP_X_SUCURI_CLIENTIP"); ?> value="HTTP_X_SUCURI_CLIENTIP">HTTP_X_SUCURI_CLIENTIP</option>
|
1599 |
+
<option <?php selected($iqbc_ipoverride, "HTTP_CF_CONNECTING_IP"); ?> value="HTTP_CF_CONNECTING_IP">HTTP_CF_CONNECTING_IP</option>
|
1600 |
</select>
|
1601 |
+
</td></tr>
|
1602 |
|
1603 |
<tr valign="top">
|
1604 |
+
<th width="30%"><?php esc_html_e('Log all visits:', 'iq-block-country'); ?><br />
|
1605 |
+
<em><?php esc_html_e('This logs all visits despite if they are blocked or not. This is only for debugging purposes.', 'iq-block-country'); ?></em></th>
|
1606 |
+
<td width="70%">
|
1607 |
+
<input type="checkbox" name="blockcountry_debuglogging" <?php checked('on', get_option('blockcountry_debuglogging'), true); ?> />
|
1608 |
+
</td></tr>
|
1609 |
|
1610 |
|
1611 |
<tr><td></td><td>
|
1612 |
+
<p class="submit"><input type="submit" class="button-primary"
|
1613 |
+
value="<?php esc_html_e('Save Changes', 'iq-block-country')?>" /></p>
|
1614 |
+
</td></tr>
|
1615 |
+
</table>
|
1616 |
</form>
|
1617 |
+
<?php
|
1618 |
+
}
|
1619 |
+
else
|
1620 |
{
|
1621 |
+
print "<p>You are missing the GeoIP class. Perhaps geoip.inc is missing?</p>";
|
1622 |
+
}
|
1623 |
}
|
1624 |
|
1625 |
/*
|
1628 |
function iqblockcountry_settings_logging()
|
1629 |
{
|
1630 |
?>
|
1631 |
+
<h3><?php esc_html_e('Last blocked visits', 'iq-block-country'); ?></h3>
|
1632 |
+
<?php
|
1633 |
+
if (!get_option('blockcountry_logging')) {
|
|
|
1634 |
|
1635 |
|
1636 |
+
global $wpdb;
|
1637 |
+
|
1638 |
+
$iqbc_table_name = $wpdb->prefix . "iqblock_logging";
|
1639 |
+
$iqbc_format = get_option('date_format') . ' ' . get_option('time_format');
|
1640 |
+
$iqbc_nrrows = get_option('blockcountry_nrstatistics');
|
1641 |
+
$iqbc_lookupstats = get_option('blockcountry_lookupstatistics');
|
1642 |
+
if ($iqbc_nrrows == "") { $iqbc_nrrows = 15;
|
1643 |
+
};
|
1644 |
+
$iqbc_countrylist = iqblockcountry_get_isocountries();
|
1645 |
+
echo '<table class="widefat">';
|
1646 |
+
echo '<thead><tr><th>' . esc_html('Date / Time', 'iq-block-country') . '</th><th>' . esc_html('IP Address', 'iq-block-country') . '</th><th>' . esc_html('Hostname', 'iq-block-country') . '</th><th>' . esc_html('URL', 'iq-block-country') . '</th><th>' . esc_html('Country', 'iq-block-country') . '</th><th>' . esc_html('Frontend/Backend', 'iq-block-country') . '</th></tr></thead>';
|
1647 |
+
$iqbcsql = $wpdb->prepare("SELECT * FROM $iqbc_table_name ORDER BY datetime DESC LIMIT %d",$iqbc_nrrows);
|
1648 |
+
foreach ($wpdb->get_results("$iqbcsql") as $iqbc_row)
|
1649 |
+
{
|
1650 |
+
$iqbc_countryimage = "icons/" . strtolower($iqbc_row->country) . ".png";
|
1651 |
+
$iqbc_countryurl = '<img src="' . plugins_url($iqbc_countryimage, dirname(__FILE__)) . '" > ';
|
1652 |
+
echo "<tbody><tr><td>";
|
1653 |
+
$iqbc_datetime = strtotime($iqbc_row->datetime);
|
1654 |
+
$iqbc_mysqldate = date($iqbc_format, $iqbc_datetime);
|
1655 |
+
if ($iqbc_lookupstats) {
|
1656 |
+
if (extension_loaded('mbstring')) {
|
1657 |
+
echo $iqbc_mysqldate . '</td><td>' . esc_html($iqbc_row->ipaddress) . '</td><td>' . esc_html($iqbc_row->ipaddress) . 'S</td><td>' . esc_url(mb_strimwidth($iqbc_row->url, 0, 75, '...')) . '</td><td>' . $iqbc_countryurl . esc_html($iqbc_countrylist[$iqbc_row->country]) . '<td>';
|
1658 |
+
}
|
1659 |
+
else
|
1660 |
+
{
|
1661 |
+
echo $iqbc_mysqldate . '</td><td>' . esc_html($iqbc_row->ipaddress) . '</td><td>' . esc_html($iqbc_row->ipaddress) . 'S</td><td>' . esc_url($iqbc_row->url) . '</td><td>' . $iqbc_countryurl . esc_html($iqbc_countrylist[$iqbc_row->country]) . '<td>';
|
1662 |
|
1663 |
+
}
|
1664 |
+
}
|
1665 |
+
else
|
1666 |
+
{
|
1667 |
+
if (extension_loaded('mbstring')) {
|
1668 |
+
echo $iqbc_mysqldate . '</td><td>' . esc_html($iqbc_row->ipaddress) . '</td><td>' . esc_html($iqbc_row->ipaddress) . '</td><td>' . esc_url(mb_strimwidth($iqbc_row->url, 0, 75, '...')) . '</td><td>' . $iqbc_countryurl . $iqbc_countrylist[$iqbc_row->country] . '<td>';
|
1669 |
+
}
|
1670 |
+
else {
|
1671 |
+
echo $iqbc_mysqldate . '</td><td>' . esc_html($iqbc_row->ipaddress) . '</td><td>' . esc_html(gethostbyaddr($iqbc_row->ipaddress)) . '</td><td>' . esc_url($iqbc_row->url) . '</td><td>' . $iqbc_countryurl . $iqbc_countrylist[$iqbc_row->country] . '<td>';
|
1672 |
+
}
|
1673 |
+
}
|
1674 |
+
if ($iqbc_row->banned == "F") { esc_html_e('Frontend', 'iq-block-country');
|
1675 |
+
} elseif ($iqbc_row->banned == "A") { esc_html_e('Backend banlist', 'iq-block-country');
|
1676 |
+
} elseif ($iqbc_row->banned == "T") { esc_html_e('Backend & Backend banlist', 'iq-block-country');
|
1677 |
+
} else { esc_html_e('Backend', 'iq-block-country');
|
1678 |
+
}
|
1679 |
+
echo "</td></tr></tbody>";
|
1680 |
+
}
|
1681 |
+
echo '</table>';
|
1682 |
|
1683 |
|
1684 |
+
echo '<hr>';
|
1685 |
+
echo '<h3>' . esc_html('Top countries that are blocked', 'iq-block-country') . '</h3>';
|
1686 |
+
echo '<table class="widefat">';
|
1687 |
+
echo '<thead><tr><th>' . esc_html('Country', 'iq-block-country') . '</th><th>' . esc_html('# of blocked attempts', 'iq-block-country') . '</th></tr></thead>';
|
1688 |
+
|
1689 |
+
$iqbcsql = $wpdb->prepare("SELECT count(country) AS count,country FROM $iqbc_table_name GROUP BY country ORDER BY count(country) DESC LIMIT %d",$iqbc_nrrows);
|
1690 |
+
foreach ($wpdb->get_results("$iqbcsql") as $iqbc_row)
|
1691 |
+
{
|
1692 |
+
$iqbc_countryimage = "icons/" . strtolower($iqbc_row->country) . ".png";
|
1693 |
+
$iqbc_countryurl = '<img src="' . plugins_url($iqbc_countryimage, dirname(__FILE__)) . '" > ';
|
1694 |
+
echo "<tbody><tr><td>" . $iqbc_countryurl . esc_html($iqbc_countrylist[$iqbc_row->country]) . "</td><td>" . esc_html($iqbc_row->count) . "</td></tr></tbody>";
|
1695 |
+
}
|
1696 |
+
echo '</table>';
|
1697 |
|
1698 |
+
echo '<hr>';
|
1699 |
+
echo '<h3>' . esc_html('Top hosts that are blocked', 'iq-block-country') . '</h3>';
|
1700 |
+
echo '<table class="widefat">';
|
1701 |
+
echo '<thead><tr><th>' . esc_html('IP Address', 'iq-block-country') . '</th><th>' . esc_html('Hostname', 'iq-block-country') . '</th><th>' . esc_html('# of blocked attempts', 'iq-block-country') . '</th></tr></thead>';
|
1702 |
+
|
1703 |
+
$iqbcsql = $wpdb->prepare("SELECT count(ipaddress) AS count,ipaddress FROM $iqbc_table_name GROUP BY ipaddress ORDER BY count(ipaddress) DESC LIMIT %d",$iqbc_nrrows);
|
1704 |
+
foreach ($wpdb->get_results("$iqbcsql") as $iqbc_row)
|
1705 |
+
{
|
1706 |
+
if ($iqbc_lookupstats) {
|
1707 |
+
echo "<tbody><tr><td>" . esc_html($iqbc_row->ipaddress) . "</td><td>" . esc_html($iqbc_row->ipaddress) . "</td><td>" . esc_html($iqbc_row->count) . "</td></tr></tbody>";
|
1708 |
+
}
|
1709 |
+
else
|
1710 |
+
{
|
1711 |
+
echo "<tbody><tr><td>" . esc_html($iqbc_row->ipaddress) . "</td><td>" . esc_html(gethostbyaddr($iqbc_row->ipaddress)) . "</td><td>" . esc_html($iqbc_row->count) . "</td></tr></tbody>";
|
1712 |
|
1713 |
+
}
|
1714 |
|
1715 |
|
1716 |
+
}
|
1717 |
+
echo '</table>';
|
1718 |
+
|
1719 |
+
echo '<hr>';
|
1720 |
+
echo '<h3>' . esc_html('Top URLs that are blocked', 'iq-block-country') . '</h3>';
|
1721 |
+
echo '<table class="widefat">';
|
1722 |
+
echo '<thead><tr><th>' . esc_html('URL', 'iq-block-country') . '</th><th>' . esc_html('# of blocked attempts', 'iq-block-country') . '</th></tr></thead>';
|
1723 |
+
|
1724 |
+
$iqbcsql = $wpdb->prepare("SELECT count(url) AS count,url FROM $iqbc_table_name GROUP BY url ORDER BY count(url) DESC LIMIT %d",$iqbc_nrrows);
|
1725 |
+
foreach ($wpdb->get_results($iqbcsql) as $iqbc_row)
|
1726 |
+
{
|
1727 |
+
echo "<tbody><tr><td>" . esc_url($iqbc_row->url) . "</td><td>" . esc_html($iqbc_row->count) . "</td></tr></tbody>";
|
1728 |
+
}
|
1729 |
+
echo '</table>';
|
1730 |
|
1731 |
+
?>
|
1732 |
<form name="cleardatabase" action="#" method="post">
|
1733 |
+
<input type="hidden" name="iqbc_action" value="iqbc_cleardatabase" />
|
1734 |
+
<input name="iqbc_cleardatabase_nonce" type="hidden" value="<?php echo wp_create_nonce('iqbc_cleardatabase_nonce'); ?>" />
|
1735 |
|
1736 |
+
<?php
|
1737 |
+
echo '<div class="submit"><input type="submit" name="test" value="' . esc_html('Clear database', 'iq-block-country') . '" /></div>';
|
1738 |
wp_nonce_field('iqblockcountry');
|
1739 |
|
1740 |
+
if (isset($_POST['iqbc_action']) && $_POST[ 'iqbc_action' ] == 'iqbc_cleardatabase') {
|
1741 |
+
if (!isset($_POST['iqbc_cleardatabase_nonce'])) { die("Failed security check.");
|
1742 |
+
}
|
1743 |
+
if (!wp_verify_nonce($_POST['iqbc_cleardatabase_nonce'], 'iqbc_cleardatabase_nonce')) { die("Is this a CSRF attempt?");
|
1744 |
+
}
|
1745 |
global $wpdb;
|
1746 |
+
$iqbc_table_name = $wpdb->prefix . "iqblock_logging";
|
1747 |
+
$iqbc_sql = "TRUNCATE " . $iqbc_table_name . ";";
|
1748 |
+
$wpdb->query($iqbc_sql);
|
1749 |
+
$iqbc_sql = "ALTER TABLE ". $iqbc_table_name . " AUTO_INCREMENT = 1;";
|
1750 |
+
$wpdb->query($iqbc_sql);
|
1751 |
echo "Cleared database";
|
1752 |
|
1753 |
}
|
1755 |
?>
|
1756 |
</form>
|
1757 |
|
1758 |
+
<form name="csvoutput" action="#" method="post">
|
1759 |
+
<input type="hidden" name="iqbc_action" value="iqbc_csvoutput" />
|
1760 |
+
<input name="iqbc_csv_nonce" type="hidden" value="<?php echo wp_create_nonce('iqbc_csv_nonce'); ?>" />
|
1761 |
<?php
|
1762 |
+
echo '<div class="submit"><input type="submit" name="submit" value="' . esc_html('Download as CSV file', 'iq-block-country') . '" /></div>';
|
1763 |
+
wp_nonce_field('iqbc_iqblockcountrycsv');
|
1764 |
echo '</form>';
|
1765 |
+
}
|
1766 |
+
else
|
1767 |
+
{
|
1768 |
+
echo "<hr><h3>";
|
1769 |
+
esc_html_e('You are not logging any information. Please uncheck the option \'Do not log IP addresses\' if this is not what you want.', 'iq-block-country');
|
1770 |
+
echo "<hr></h3>";
|
1771 |
+
}
|
1772 |
}
|
1773 |
|
1774 |
|
1775 |
/*
|
1776 |
* Create the settings page.
|
1777 |
*/
|
1778 |
+
function iqblockcountry_settings_page()
|
1779 |
+
{
|
1780 |
|
1781 |
|
1782 |
+
if(isset($_GET[ 'tab' ]) ) {
|
1783 |
+
$iqbc_active_tab = filter_var($_GET[ 'tab' ], FILTER_SANITIZE_STRING);
|
1784 |
+
}
|
1785 |
+
else
|
1786 |
{
|
1787 |
+
$iqbc_active_tab = 'home';
|
1788 |
+
}
|
1789 |
+
?>
|
1790 |
|
1791 |
<h2 class="nav-tab-wrapper">
|
1792 |
+
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=home" class="nav-tab <?php echo $iqbc_active_tab == 'home' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Home', 'iq-block-country'); ?></a>
|
1793 |
+
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=frontend" class="nav-tab <?php echo $iqbc_active_tab == 'frontend' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Frontend', 'iq-block-country'); ?></a>
|
1794 |
+
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=backend" class="nav-tab <?php echo $iqbc_active_tab == 'backend' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Backend', 'iq-block-country'); ?></a>
|
1795 |
+
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=pages" class="nav-tab <?php echo $iqbc_active_tab == 'pages' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Pages', 'iq-block-country'); ?></a>
|
1796 |
+
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=categories" class="nav-tab <?php echo $iqbc_active_tab == 'categories' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Categories', 'iq-block-country'); ?></a>
|
1797 |
+
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=tags" class="nav-tab <?php echo $iqbc_active_tab == 'tags' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Tags', 'iq-block-country'); ?></a>
|
1798 |
+
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=posttypes" class="nav-tab <?php echo $iqbc_active_tab == 'posttypes' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Post types', 'iq-block-country'); ?></a>
|
1799 |
+
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=services" class="nav-tab <?php echo $iqbc_active_tab == 'services' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Services', 'iq-block-country'); ?></a>
|
1800 |
+
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=tools" class="nav-tab <?php echo $iqbc_active_tab == 'tools' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Tools', 'iq-block-country'); ?></a>
|
1801 |
+
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=logging" class="nav-tab <?php echo $iqbc_active_tab == 'logging' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Logging', 'iq-block-country'); ?></a>
|
1802 |
+
<a href="?page=iq-block-country/libs/blockcountry-settings.php&tab=export" class="nav-tab <?php echo $iqbc_active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Import/Export', 'iq-block-country'); ?></a>
|
1803 |
</h2>
|
1804 |
|
1805 |
|
1808 |
|
1809 |
<hr />
|
1810 |
<?php
|
1811 |
+
if ($iqbc_active_tab == "frontend") {
|
|
|
1812 |
iqblockcountry_settings_frontend();
|
1813 |
}
|
1814 |
+
elseif ($iqbc_active_tab == "backend") {
|
|
|
1815 |
iqblockcountry_settings_backend();
|
1816 |
}
|
1817 |
+
elseif ($iqbc_active_tab == "tools") {
|
|
|
1818 |
iqblockcountry_settings_tools();
|
1819 |
}
|
1820 |
+
elseif ($iqbc_active_tab == "logging") {
|
|
|
1821 |
iqblockcountry_settings_logging();
|
1822 |
}
|
1823 |
+
elseif ($iqbc_active_tab == "pages") {
|
|
|
1824 |
iqblockcountry_settings_pages();
|
1825 |
}
|
1826 |
+
elseif ($iqbc_active_tab == "categories") {
|
|
|
1827 |
iqblockcountry_settings_categories();
|
1828 |
}
|
1829 |
+
elseif ($iqbc_active_tab == "tags") {
|
|
|
1830 |
iqblockcountry_settings_tags();
|
1831 |
}
|
1832 |
+
elseif ($iqbc_active_tab == "posttypes") {
|
|
|
1833 |
iqblockcountry_settings_posttypes();
|
1834 |
}
|
1835 |
+
elseif ($iqbc_active_tab == "services") {
|
|
|
1836 |
iqblockcountry_settings_services();
|
1837 |
}
|
1838 |
+
elseif ($iqbc_active_tab == "export") {
|
|
|
1839 |
iqblockcountry_settings_importexport();
|
1840 |
}
|
1841 |
else
|
1853 |
See <a href="https://webence.nl/plugins/donate/">Plugin donation page</a></p>
|
1854 |
|
1855 |
<?php
|
1856 |
+
|
1857 |
}
|
1858 |
|
1859 |
|
1862 |
*/
|
1863 |
function iqblockcountry_find_geoip_location()
|
1864 |
{
|
1865 |
+
if (function_exists('curl_init')) {
|
1866 |
+
$iqbc_curl = curl_init();
|
1867 |
+
curl_setopt_array(
|
1868 |
+
$iqbc_curl, array(
|
1869 |
+
CURLOPT_RETURNTRANSFER => 1,
|
1870 |
+
CURLOPT_URL => 'https://us.geoip.webence.nl/test',
|
1871 |
+
CURLOPT_USERAGENT => 'iQ Block Country US location test/' . get_bloginfo('wpurl')
|
1872 |
+
)
|
1873 |
+
);
|
1874 |
+
$iqbc_resp = curl_exec($iqbc_curl);
|
1875 |
+
$iqbc_infous = curl_getinfo($iqbc_curl);
|
1876 |
+
curl_close($iqbc_curl);
|
1877 |
+
|
1878 |
+
$iqbc_curl = curl_init();
|
1879 |
+
curl_setopt_array(
|
1880 |
+
$iqbc_curl, array(
|
1881 |
+
CURLOPT_RETURNTRANSFER => 1,
|
1882 |
+
CURLOPT_URL => 'https://us2.geoip.webence.nl/test',
|
1883 |
+
CURLOPT_USERAGENT => 'iQ Block Country US2 location test/' . get_bloginfo('wpurl')
|
1884 |
+
)
|
1885 |
+
);
|
1886 |
+
$iqbc_resp = curl_exec($iqbc_curl);
|
1887 |
+
$iqbc_infous2 = curl_getinfo($iqbc_curl);
|
1888 |
+
curl_close($iqbc_curl);
|
1889 |
+
|
1890 |
+
$iqbc_curl = curl_init();
|
1891 |
+
curl_setopt_array(
|
1892 |
+
$iqbc_curl, array(
|
1893 |
+
CURLOPT_RETURNTRANSFER => 1,
|
1894 |
+
CURLOPT_URL => 'https://us3.geoip.webence.nl/test',
|
1895 |
+
CURLOPT_USERAGENT => 'iQ Block Country US3 location test/' . get_bloginfo('wpurl')
|
1896 |
+
)
|
1897 |
+
);
|
1898 |
+
$iqbc_resp = curl_exec($iqbc_curl);
|
1899 |
+
$iqbc_infous3 = curl_getinfo($iqbc_curl);
|
1900 |
+
curl_close($iqbc_curl);
|
1901 |
+
|
1902 |
+
// $iqbc_curl = curl_init();
|
1903 |
+
// curl_setopt_array($iqbc_curl, array(
|
1904 |
+
// CURLOPT_RETURNTRANSFER => 1,
|
1905 |
+
// CURLOPT_URL => 'https://asia.geoip.webence.nl/test',
|
1906 |
+
// CURLOPT_USERAGENT => 'iQ Block Country Asia location test/' . get_bloginfo('wpurl')
|
1907 |
+
// ));
|
1908 |
+
// $iqbc_resp = curl_exec($iqbc_curl);
|
1909 |
+
// $infoasia = curl_getinfo($iqbc_curl);
|
1910 |
+
// curl_close($iqbc_curl);
|
1911 |
|
1912 |
+
$iqbc_curl = curl_init();
|
1913 |
+
curl_setopt_array(
|
1914 |
+
$iqbc_curl, array(
|
1915 |
+
CURLOPT_URL => 'https://eu.geoip.webence.nl/test',
|
1916 |
+
CURLOPT_USERAGENT => 'iQ Block Country EU location test/' . get_bloginfo('wpurl')
|
1917 |
+
)
|
1918 |
+
);
|
1919 |
+
$iqbc_resp = curl_exec($iqbc_curl);
|
1920 |
+
$iqbc_infoeu = curl_getinfo($iqbc_curl);
|
1921 |
+
curl_close($iqbc_curl);
|
1922 |
+
|
1923 |
+
$iqbc_curl = curl_init();
|
1924 |
+
curl_setopt_array(
|
1925 |
+
$iqbc_curl, array(
|
1926 |
+
CURLOPT_URL => 'https://eu3.geoip.webence.nl/test',
|
1927 |
+
CURLOPT_USERAGENT => 'iQ Block Country EU3 location test/' . get_bloginfo('wpurl')
|
1928 |
+
)
|
1929 |
+
);
|
1930 |
+
$iqbc_resp = curl_exec($iqbc_curl);
|
1931 |
+
$iqbc_infoeu3 = curl_getinfo($iqbc_curl);
|
1932 |
+
curl_close($iqbc_curl);
|
1933 |
|
1934 |
|
1935 |
+
$iqbc_fastestsite = min($iqbc_infoeu['total_time'], $iqbc_infoeu3['total_time'], $iqbc_infous['total_time'], $iqbc_infous2['total_time'], $iqbc_infous3['total_time']);
|
1936 |
|
1937 |
+
if ($iqbc_infous['total_time'] == $iqbc_fastestsite) {
|
1938 |
+
update_option('blockcountry_geoapilocation', 'US');
|
1939 |
+
}
|
1940 |
+
elseif ($iqbc_infous2['total_time'] == $iqbc_fastestsite) {
|
1941 |
+
update_option('blockcountry_geoapilocation', 'US2');
|
1942 |
+
}
|
1943 |
+
elseif ($iqbc_infous3['total_time'] == $iqbc_fastestsite) {
|
1944 |
+
update_option('blockcountry_geoapilocation', 'US3');
|
1945 |
+
}
|
1946 |
+
// elseif ($infoasia['total_time'] == $iqbc_fastestsite)
|
1947 |
+
// {
|
1948 |
+
// update_option('blockcountry_geoapilocation','ASIA');
|
1949 |
+
// }
|
1950 |
+
elseif ($iqbc_infoeu3['total_time'] == $iqbc_fastestsite) {
|
1951 |
+
update_option('blockcountry_geoapilocation', 'EU3');
|
1952 |
+
}
|
1953 |
+
else
|
1954 |
+
{
|
1955 |
+
update_option('blockcountry_geoapilocation', 'EU');
|
1956 |
+
}
|
|
|
|
|
|
|
1957 |
}
|
|
|
1958 |
}
|
1959 |
|
1960 |
/*
|
1962 |
*/
|
1963 |
function iqblockcountry_get_blockallowlist()
|
1964 |
{
|
1965 |
+
$iqbc_frontendblocklistip = array(); $iqbc_frontendblocklist = get_option('blockcountry_frontendblacklist');
|
1966 |
+
$iqbc_frontendallowlistip = array(); $iqbc_frontendallowlist = get_option('blockcountry_frontendwhitelist');
|
1967 |
+
$iqbc_backendblocklistip = array(); $iqbc_backendblocklist = get_option('blockcountry_backendblacklist');
|
1968 |
+
$iqbc_backendallowlistip = array(); $iqbc_backendallowlist = get_option('blockcountry_backendwhitelist');
|
1969 |
|
1970 |
|
1971 |
+
$iqbc_feblocklistip = array();
|
1972 |
+
$iqbc_feblocklistiprange4 = array();
|
1973 |
+
$iqbc_feblocklistiprange6 = array();
|
1974 |
+
$iqbc_feallowlistip = array();
|
1975 |
+
$iqbc_feallowlistiprange4 = array();
|
1976 |
+
$iqbc_feallowlistiprange6 = array();
|
1977 |
+
global $iqbc_feblocklistip,$iqbc_feblocklistiprange4,$iqbc_feblocklistiprange6,$iqbc_feallowlistip,$iqbc_feallowlistiprange4,$iqbc_feallowlistiprange6;
|
1978 |
|
1979 |
+
$iqbc_beblocklistip = array();
|
1980 |
+
$iqbc_beblocklistiprange4 = array();
|
1981 |
+
$iqbc_beblocklistiprange6 = array();
|
1982 |
+
$iqbc_beallowlistip = array();
|
1983 |
+
$iqbc_beallowlistiprange4 = array();
|
1984 |
+
$iqbc_beallowlistiprange6 = array();
|
1985 |
+
global $iqbc_beblocklistip,$iqbc_beblocklistiprange4,$iqbc_beblocklistiprange6,$iqbc_beallowlistip,$iqbc_beallowlistiprange4,$iqbc_beallowlistiprange6;
|
1986 |
|
1987 |
|
1988 |
+
if (preg_match('/;/', $iqbc_frontendblocklist)) {
|
1989 |
+
$iqbc_frontendblocklistip = explode(";", $iqbc_frontendblocklist);
|
1990 |
+
foreach ($iqbc_frontendblocklistip AS $iqbc_ip)
|
|
|
1991 |
{
|
1992 |
+
if (iqblockcountry_is_valid_ipv4($iqbc_ip) || iqblockcountry_is_valid_ipv6($iqbc_ip)) { $iqbc_feblocklistip[] = $iqbc_ip;
|
1993 |
+
}
|
1994 |
+
elseif (iqblockcountry_is_valid_ipv4_cidr($iqbc_ip)) { $iqbc_feblocklistiprange4[] = $iqbc_ip;
|
1995 |
+
}
|
1996 |
+
elseif (iqblockcountry_is_valid_ipv6_cidr($iqbc_ip)) { $iqbc_feblocklistiprange6[] = $iqbc_ip;
|
1997 |
+
}
|
1998 |
}
|
1999 |
}
|
2000 |
+
if (preg_match('/;/', $iqbc_frontendallowlist)) {
|
2001 |
+
$iqbc_frontendallowlistip = explode(";", $iqbc_frontendallowlist);
|
2002 |
+
foreach ($iqbc_frontendallowlistip AS $iqbc_ip)
|
|
|
2003 |
{
|
2004 |
+
if (iqblockcountry_is_valid_ipv4($iqbc_ip) || iqblockcountry_is_valid_ipv6($iqbc_ip)) { $iqbc_feallowlistip[] = $iqbc_ip;
|
2005 |
+
}
|
2006 |
+
elseif (iqblockcountry_is_valid_ipv4_cidr($iqbc_ip)) { $iqbc_feallowlistiprange4[] = $iqbc_ip;
|
2007 |
+
}
|
2008 |
+
elseif (iqblockcountry_is_valid_ipv6_cidr($iqbc_ip)) { $iqbc_feallowlistiprange6[] = $iqbc_ip;
|
2009 |
+
}
|
2010 |
}
|
2011 |
}
|
2012 |
+
if (preg_match('/;/', $iqbc_backendblocklist)) {
|
2013 |
+
$iqbc_backendblocklistip = explode(";", $iqbc_backendblocklist);
|
2014 |
+
foreach ($iqbc_backendblocklistip AS $iqbc_ip)
|
|
|
2015 |
{
|
2016 |
+
if (iqblockcountry_is_valid_ipv4($iqbc_ip) || iqblockcountry_is_valid_ipv6($iqbc_ip)) { $iqbc_beblocklistip[] = $iqbc_ip;
|
2017 |
+
}
|
2018 |
+
elseif (iqblockcountry_is_valid_ipv4_cidr($iqbc_ip)) { $iqbc_beblocklistiprange4[] = $iqbc_ip;
|
2019 |
+
}
|
2020 |
+
elseif (iqblockcountry_is_valid_ipv6_cidr($iqbc_ip)) { $iqbc_beblocklistiprange6[] = $iqbc_ip;
|
2021 |
+
}
|
2022 |
}
|
2023 |
}
|
2024 |
+
if (preg_match('/;/', $iqbc_backendallowlist)) {
|
2025 |
+
$iqbc_backendallowlistip = explode(";", $iqbc_backendallowlist);
|
2026 |
+
foreach ($iqbc_backendallowlistip AS $iqbc_ip)
|
|
|
2027 |
{
|
2028 |
+
if (iqblockcountry_is_valid_ipv4($iqbc_ip) || iqblockcountry_is_valid_ipv6($iqbc_ip)) { $iqbc_beallowlistip[] = $iqbc_ip;
|
2029 |
+
}
|
2030 |
+
elseif (iqblockcountry_is_valid_ipv4_cidr($iqbc_ip)) { $iqbc_beallowlistiprange4[] = $iqbc_ip;
|
2031 |
+
}
|
2032 |
+
elseif (iqblockcountry_is_valid_ipv6_cidr($iqbc_ip)) { $iqbc_beallowlistiprange6[] = $iqbc_ip;
|
2033 |
+
}
|
2034 |
}
|
2035 |
}
|
2036 |
|
libs/blockcountry-tracking.php
CHANGED
@@ -3,18 +3,15 @@
|
|
3 |
/*
|
4 |
* Schedule tracking if this option was set in the admin panel
|
5 |
*/
|
6 |
-
function iqblockcountry_schedule_tracking($
|
7 |
{
|
8 |
-
$
|
9 |
-
if ($
|
10 |
-
|
11 |
-
|
12 |
-
{
|
13 |
-
wp_clear_scheduled_hook( 'blockcountry_tracking' );
|
14 |
}
|
15 |
-
elseif ($
|
16 |
-
|
17 |
-
wp_schedule_event( time(), 'hourly', 'blockcountry_tracking' );
|
18 |
}
|
19 |
}
|
20 |
}
|
@@ -25,38 +22,36 @@ function iqblockcountry_schedule_tracking($old_value, $new_value)
|
|
25 |
*/
|
26 |
function iqblockcountry_tracking()
|
27 |
{
|
28 |
-
if (get_option("blockcountry_tracking") == "on")
|
29 |
-
|
30 |
-
$lasttracked = get_option("blockcountry_lasttrack");
|
31 |
global $wpdb;
|
32 |
|
33 |
-
$
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
{
|
38 |
-
$query = "SELECT id,ipaddress,count(ipaddress) as countip FROM $table_name WHERE banned=\"B\" and id > $lasttracked GROUP BY ipaddress ORDER BY id";
|
39 |
}
|
40 |
else
|
41 |
{
|
42 |
-
$
|
43 |
}
|
44 |
-
foreach ($wpdb->get_results(
|
45 |
{
|
46 |
-
$
|
47 |
-
array_push($
|
48 |
-
$
|
49 |
}
|
50 |
|
51 |
-
if (!empty($
|
52 |
-
|
53 |
-
|
54 |
array(
|
55 |
-
'body' => $
|
56 |
)
|
57 |
-
|
58 |
|
59 |
-
|
|
|
60 |
}
|
61 |
}
|
62 |
}
|
@@ -68,32 +63,35 @@ function iqblockcountry_tracking()
|
|
68 |
*/
|
69 |
function iqblockcountry_tracking_retrieve_xml()
|
70 |
{
|
71 |
-
$
|
72 |
|
73 |
-
$
|
74 |
-
|
75 |
-
|
76 |
'body' => array(
|
77 |
'api-key' => get_option('blockcountry_apikey')
|
78 |
|
79 |
)
|
80 |
)
|
81 |
-
|
82 |
|
83 |
-
if (
|
84 |
-
return
|
85 |
}
|
86 |
-
elseif (
|
87 |
-
|
88 |
-
$
|
89 |
-
$
|
90 |
-
$
|
91 |
-
foreach ($
|
92 |
{
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
95 |
}
|
96 |
-
update_option('blockcountry_backendbanlistip', serialize($
|
97 |
}
|
98 |
|
99 |
|
@@ -102,18 +100,15 @@ function iqblockcountry_tracking_retrieve_xml()
|
|
102 |
/*
|
103 |
* Schedule retrieving banlist.
|
104 |
*/
|
105 |
-
function iqblockcountry_schedule_retrieving($
|
106 |
{
|
107 |
-
$
|
108 |
-
if ($
|
109 |
-
|
110 |
-
|
111 |
-
{
|
112 |
-
wp_clear_scheduled_hook( 'blockcountry_retrievebanlist' );
|
113 |
}
|
114 |
-
elseif (!empty($
|
115 |
-
|
116 |
-
wp_schedule_event( time(), 'twicedaily', 'blockcountry_retrievebanlist' );
|
117 |
}
|
118 |
}
|
119 |
}
|
3 |
/*
|
4 |
* Schedule tracking if this option was set in the admin panel
|
5 |
*/
|
6 |
+
function iqblockcountry_schedule_tracking($iqbc_old_value, $iqbc_new_value)
|
7 |
{
|
8 |
+
$iqbc_current_schedule = wp_next_scheduled('blockcountry_tracking');
|
9 |
+
if ($iqbc_old_value !== $iqbc_new_value) {
|
10 |
+
if ($iqbc_new_value == '') {
|
11 |
+
wp_clear_scheduled_hook('blockcountry_tracking');
|
|
|
|
|
12 |
}
|
13 |
+
elseif ($iqbc_new_value == 'on' && $iqbc_current_schedule == false) {
|
14 |
+
wp_schedule_event(time(), 'hourly', 'blockcountry_tracking');
|
|
|
15 |
}
|
16 |
}
|
17 |
}
|
22 |
*/
|
23 |
function iqblockcountry_tracking()
|
24 |
{
|
25 |
+
if (get_option("blockcountry_tracking") == "on") {
|
26 |
+
$iqbc_lasttracked = get_option("blockcountry_lasttrack");
|
|
|
27 |
global $wpdb;
|
28 |
|
29 |
+
$iqbc_table_name = $wpdb->prefix . "iqblock_logging";
|
30 |
+
$iqbc_content = array();
|
31 |
+
if (!empty($iqbc_lasttracked)) {
|
32 |
+
$iqbc_query = $wpdb->prepare("SELECT id,ipaddress,count(ipaddress) as countip FROM $iqbc_table_name WHERE banned=\"B\" and id > %d GROUP BY ipaddress ORDER BY id",$iqbc_lasttracked);
|
|
|
|
|
33 |
}
|
34 |
else
|
35 |
{
|
36 |
+
$iqbc_query = "SELECT id,ipaddress,count(ipaddress) as countip FROM $iqbc_table_name WHERE banned=\"B\" GROUP BY ipaddress ORDER BY id";
|
37 |
}
|
38 |
+
foreach ($wpdb->get_results($iqbc_query) as $iqbc_row)
|
39 |
{
|
40 |
+
$iqbc_newcontent = array('ipaddress' => $iqbc_row->ipaddress,'count' => $iqbc_row->countip);
|
41 |
+
array_push($iqbc_content, $iqbc_newcontent);
|
42 |
+
$iqbc_id = $iqbc_row->id;
|
43 |
}
|
44 |
|
45 |
+
if (!empty($iqbc_content)) {
|
46 |
+
$iqbc_response = wp_remote_post(
|
47 |
+
IQBCTRACKINGURL,
|
48 |
array(
|
49 |
+
'body' => $iqbc_content
|
50 |
)
|
51 |
+
);
|
52 |
|
53 |
+
if (isset($iqbc_id)) { update_option('blockcountry_lasttrack', $iqbc_id);
|
54 |
+
}
|
55 |
}
|
56 |
}
|
57 |
}
|
63 |
*/
|
64 |
function iqblockcountry_tracking_retrieve_xml()
|
65 |
{
|
66 |
+
$iqbc_url = IQBCBANLISTRETRIEVEURL;
|
67 |
|
68 |
+
$iqbc_result = wp_remote_post(
|
69 |
+
$iqbc_url,
|
70 |
+
array(
|
71 |
'body' => array(
|
72 |
'api-key' => get_option('blockcountry_apikey')
|
73 |
|
74 |
)
|
75 |
)
|
76 |
+
);
|
77 |
|
78 |
+
if (is_wp_error($iqbc_result) ) {
|
79 |
+
return false;
|
80 |
}
|
81 |
+
elseif (200 == $iqbc_result['response']['code'] ) {
|
82 |
+
$iqbc_body = $iqbc_result['body'];
|
83 |
+
$iqbc_xml = new SimpleXmlElement($iqbc_body);
|
84 |
+
$iqbc_banlist = array();
|
85 |
+
$iqbc_i=0;
|
86 |
+
foreach ($iqbc_xml->banlist->ipaddress AS $iqbc_ip)
|
87 |
{
|
88 |
+
if (filter_var($iqbc_ip,FILTER_VALIDATE_IP))
|
89 |
+
{
|
90 |
+
array_push($iqbc_banlist, sprintf('%s', $iqbc_ip));
|
91 |
+
$iqbc_i++;
|
92 |
+
}
|
93 |
}
|
94 |
+
update_option('blockcountry_backendbanlistip', serialize($iqbc_banlist));
|
95 |
}
|
96 |
|
97 |
|
100 |
/*
|
101 |
* Schedule retrieving banlist.
|
102 |
*/
|
103 |
+
function iqblockcountry_schedule_retrieving($iqbc_old_value, $iqbc_new_value)
|
104 |
{
|
105 |
+
$iqbc_current_schedule = wp_next_scheduled('blockcountry_retrievebanlist');
|
106 |
+
if ($iqbc_old_value !== $iqbc_new_value) {
|
107 |
+
if ($iqbc_new_value == '') {
|
108 |
+
wp_clear_scheduled_hook('blockcountry_retrievebanlist');
|
|
|
|
|
109 |
}
|
110 |
+
elseif (!empty($iqbc_new_value) && $iqbc_current_schedule == false) {
|
111 |
+
wp_schedule_event(time(), 'twicedaily', 'blockcountry_retrievebanlist');
|
|
|
112 |
}
|
113 |
}
|
114 |
}
|
libs/blockcountry-validation.php
CHANGED
@@ -3,9 +3,9 @@
|
|
3 |
/*
|
4 |
* Check of an IP address is a valid IPv4 address
|
5 |
*/
|
6 |
-
function iqblockcountry_is_valid_ipv4($
|
7 |
{
|
8 |
-
if(filter_var($
|
9 |
return false;
|
10 |
}
|
11 |
|
@@ -15,19 +15,18 @@ function iqblockcountry_is_valid_ipv4($ipv4)
|
|
15 |
/*
|
16 |
* Check of an IP address is a valid IPv6 address
|
17 |
*/
|
18 |
-
function iqblockcountry_is_valid_ipv6($
|
19 |
{
|
20 |
-
if(filter_var($
|
21 |
-
|
22 |
}
|
23 |
|
24 |
return true;
|
25 |
}
|
26 |
|
27 |
-
function iqblockcountry_is_valid_ipv4_cidr($
|
28 |
{
|
29 |
-
if (preg_match('/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$/'
|
30 |
-
{
|
31 |
return true;
|
32 |
}
|
33 |
else
|
@@ -36,10 +35,9 @@ function iqblockcountry_is_valid_ipv4_cidr($ip)
|
|
36 |
}
|
37 |
}
|
38 |
|
39 |
-
function iqblockcountry_is_valid_ipv6_cidr($
|
40 |
{
|
41 |
-
if (preg_match('/^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*(\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?$/'
|
42 |
-
{
|
43 |
return true;
|
44 |
}
|
45 |
else
|
@@ -52,15 +50,15 @@ function iqblockcountry_is_valid_ipv6_cidr($ip)
|
|
52 |
/*
|
53 |
* Check of given url is a valid url
|
54 |
*/
|
55 |
-
function iqblockcountry_is_valid_url($
|
56 |
{
|
57 |
-
if(filter_var($
|
58 |
-
|
|
|
|
|
|
|
|
|
59 |
}
|
60 |
-
else
|
61 |
-
{
|
62 |
-
return $input;
|
63 |
-
}
|
64 |
|
65 |
}
|
66 |
|
@@ -68,78 +66,73 @@ else
|
|
68 |
/*
|
69 |
* Sanitize callback. Check if supplied IP address list is valid IPv4 or IPv6
|
70 |
*/
|
71 |
-
function iqblockcountry_validate_ip($
|
72 |
{
|
73 |
-
$
|
74 |
-
if (preg_match('/;/'
|
75 |
-
|
76 |
-
$
|
77 |
-
|
78 |
-
|
79 |
-
{
|
80 |
-
$validips .= $value . ";";
|
81 |
}
|
82 |
|
83 |
}
|
84 |
}
|
85 |
else
|
86 |
{
|
87 |
-
if (iqblockcountry_is_valid_ipv4($
|
88 |
-
|
89 |
-
$validips = $input . ";";
|
90 |
}
|
91 |
}
|
92 |
-
return $
|
93 |
|
94 |
}
|
95 |
|
96 |
/*
|
97 |
* Check if GeoIP API key is correct.
|
98 |
*/
|
99 |
-
function iqblockcountry_check_geoapikey($
|
100 |
{
|
101 |
|
102 |
// Check first if API key is empty....
|
103 |
-
if (!empty($
|
104 |
-
{
|
105 |
|
106 |
-
$
|
107 |
|
108 |
-
$
|
109 |
-
$
|
110 |
array(
|
111 |
'body' => array(
|
112 |
-
'api-key' => $
|
113 |
)
|
114 |
)
|
115 |
);
|
116 |
-
$
|
117 |
-
$
|
118 |
-
if (
|
119 |
-
|
120 |
}
|
121 |
|
122 |
-
elseif (
|
123 |
-
$
|
124 |
-
$
|
125 |
-
if ($
|
126 |
-
|
127 |
-
$
|
128 |
-
$
|
129 |
-
$input = FALSE;
|
130 |
}
|
131 |
else
|
132 |
{
|
133 |
-
$
|
134 |
-
$
|
135 |
}
|
136 |
}
|
137 |
else
|
138 |
{
|
139 |
-
$
|
140 |
}
|
141 |
-
add_settings_error('iqblockcountry_geoipapi_error',esc_attr(
|
142 |
-
return $
|
143 |
}
|
144 |
return "";
|
145 |
}
|
@@ -147,49 +140,47 @@ function iqblockcountry_check_geoapikey($input)
|
|
147 |
/*
|
148 |
* Check if GeoIP API key is correct.
|
149 |
*/
|
150 |
-
function iqblockcountry_check_adminapikey($
|
151 |
{
|
152 |
|
153 |
// Check first if API key is empty....
|
154 |
-
if (!empty($
|
155 |
-
{
|
156 |
|
157 |
-
$
|
158 |
|
159 |
-
$
|
160 |
-
$
|
161 |
array(
|
162 |
'body' => array(
|
163 |
-
'api-key' => $
|
164 |
)
|
165 |
)
|
166 |
);
|
167 |
-
$
|
168 |
-
$
|
169 |
-
if (
|
170 |
-
|
171 |
}
|
172 |
-
elseif (
|
173 |
-
$
|
174 |
-
$
|
175 |
-
if ($
|
176 |
-
|
177 |
-
$
|
178 |
-
$
|
179 |
-
$input = FALSE;
|
180 |
}
|
181 |
else
|
182 |
{
|
183 |
-
$
|
184 |
-
$
|
185 |
}
|
186 |
}
|
187 |
else
|
188 |
{
|
189 |
-
$
|
190 |
}
|
191 |
-
add_settings_error('iqblockcountry_adminapi_error',esc_attr(
|
192 |
-
return $
|
193 |
}
|
194 |
return "";
|
195 |
}
|
@@ -198,32 +189,30 @@ function iqblockcountry_check_adminapikey($input)
|
|
198 |
/*
|
199 |
* Check if GeoIP API key is correct.
|
200 |
*/
|
201 |
-
function iqblockcountry_get_licensedate_geoapikey($
|
202 |
{
|
203 |
|
204 |
// Check first if API key is empty....
|
205 |
-
if (!empty($
|
206 |
-
{
|
207 |
|
208 |
-
$
|
209 |
|
210 |
-
$
|
211 |
-
$
|
212 |
array(
|
213 |
'body' => array(
|
214 |
-
'api-key' => $
|
215 |
)
|
216 |
)
|
217 |
);
|
218 |
-
if (
|
219 |
return "";
|
220 |
}
|
221 |
-
elseif (
|
222 |
-
$
|
223 |
-
$
|
224 |
-
if ($
|
225 |
-
|
226 |
-
return $xml->LicenseDate;
|
227 |
}
|
228 |
}
|
229 |
else
|
@@ -237,32 +226,30 @@ function iqblockcountry_get_licensedate_geoapikey($apikey)
|
|
237 |
/*
|
238 |
* Check usage of GeoIP API
|
239 |
*/
|
240 |
-
function iqblockcountry_get_usage_geoapikey($
|
241 |
{
|
242 |
|
243 |
// Check first if API key is empty....
|
244 |
-
if (!empty($
|
245 |
-
{
|
246 |
|
247 |
-
$
|
248 |
|
249 |
-
$
|
250 |
-
$
|
251 |
array(
|
252 |
'body' => array(
|
253 |
-
'api-key' => $
|
254 |
)
|
255 |
)
|
256 |
);
|
257 |
-
if (
|
258 |
return "";
|
259 |
}
|
260 |
-
elseif (
|
261 |
-
$
|
262 |
-
$
|
263 |
-
if ($
|
264 |
-
|
265 |
-
return $xml->requests;
|
266 |
}
|
267 |
}
|
268 |
else
|
@@ -276,155 +263,152 @@ function iqblockcountry_get_usage_geoapikey($apikey)
|
|
276 |
|
277 |
/**
|
278 |
* Check if a given ip is in a network
|
279 |
-
*
|
280 |
-
* @param string $
|
|
|
281 |
* @return boolean true if the ip is in this range / false if not.
|
282 |
*/
|
283 |
-
function iqblockcountry_ip_in_ipv4_range( $
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
|
|
294 |
}
|
295 |
|
296 |
-
function iqblockcountry_ip2long6($
|
297 |
-
|
298 |
-
|
|
|
299 |
}
|
300 |
|
301 |
-
$
|
302 |
-
$
|
303 |
-
foreach ($
|
304 |
-
$
|
305 |
}
|
306 |
|
307 |
-
return base_convert($
|
308 |
}
|
309 |
// Get the ipv6 full format and return it as a decimal value.
|
310 |
-
function iqblockcountry_get_ipv6_full($
|
311 |
{
|
312 |
-
$
|
313 |
-
$
|
314 |
-
$
|
315 |
// Extract out the main IP pieces
|
316 |
-
$
|
317 |
-
$
|
318 |
-
$
|
319 |
// Pad out the shorthand entries.
|
320 |
-
$
|
321 |
-
foreach($
|
322 |
-
$
|
323 |
}
|
324 |
// Check to see if the last IP block (part after ::) is set
|
325 |
-
$
|
326 |
-
$
|
327 |
-
if (trim($
|
328 |
-
$
|
329 |
|
330 |
// Build the full form of the IPV6 address considering the last IP block set
|
331 |
-
for ($
|
332 |
-
$
|
333 |
}
|
334 |
-
$
|
335 |
}
|
336 |
else {
|
337 |
// Build the full form of the IPV6 address
|
338 |
-
for ($
|
339 |
-
$
|
340 |
}
|
341 |
}
|
342 |
|
343 |
// Rebuild the final long form IPV6 address
|
344 |
-
$
|
345 |
-
return iqblockcountry_ip2long6($
|
346 |
}
|
347 |
// Determine whether the IPV6 address is within range.
|
348 |
-
// $
|
349 |
-
// $
|
350 |
-
// Returns true if the IPV6 address, $
|
351 |
-
function iqblockcountry_ipv6_in_range($
|
352 |
{
|
353 |
-
$
|
354 |
-
$
|
355 |
-
$
|
356 |
// Extract out the main IP pieces
|
357 |
-
$
|
358 |
-
$
|
359 |
-
$
|
360 |
// Pad out the shorthand entries.
|
361 |
-
$
|
362 |
-
foreach($
|
363 |
-
$
|
364 |
}
|
365 |
// Create the first and last pieces that will denote the IPV6 range.
|
366 |
-
$
|
367 |
-
$
|
368 |
// Check to see if the last IP block (part after ::) is set
|
369 |
-
$
|
370 |
-
$
|
371 |
-
if (trim($
|
372 |
-
$
|
373 |
|
374 |
// Build the full form of the IPV6 address considering the last IP block set
|
375 |
-
for ($
|
376 |
-
$
|
377 |
-
$
|
378 |
}
|
379 |
-
$
|
380 |
}
|
381 |
else {
|
382 |
// Build the full form of the IPV6 address
|
383 |
-
for ($
|
384 |
-
$
|
385 |
-
$
|
386 |
}
|
387 |
}
|
388 |
// Rebuild the final long form IPV6 address
|
389 |
-
$
|
390 |
-
$
|
391 |
-
$
|
392 |
-
return $
|
393 |
}
|
394 |
|
395 |
|
396 |
-
function iqblockcountry_validate_ip_in_list($
|
397 |
{
|
398 |
|
399 |
-
$
|
400 |
-
if (iqblockcountry_is_valid_ipv4($
|
401 |
-
|
402 |
-
foreach ($ipv4list AS $iprange)
|
403 |
{
|
404 |
-
if (iqblockcountry_ip_in_ipv4_range($
|
405 |
-
|
406 |
-
$match = TRUE;
|
407 |
}
|
408 |
}
|
409 |
}
|
410 |
-
elseif (iqblockcountry_is_valid_ipv6($
|
411 |
-
|
412 |
-
foreach ($ipv6list AS $iprange)
|
413 |
{
|
414 |
-
$
|
415 |
-
if (iqblockcountry_ipv6_in_range($
|
416 |
-
|
417 |
-
$match = TRUE;
|
418 |
}
|
419 |
}
|
420 |
|
421 |
}
|
422 |
-
if ((iqblockcountry_is_valid_ipv4($
|
423 |
-
|
424 |
-
|
425 |
-
{
|
426 |
-
$match = TRUE;
|
427 |
}
|
428 |
}
|
429 |
-
return $
|
430 |
}
|
3 |
/*
|
4 |
* Check of an IP address is a valid IPv4 address
|
5 |
*/
|
6 |
+
function iqblockcountry_is_valid_ipv4($iqbc_ipv4)
|
7 |
{
|
8 |
+
if(filter_var($iqbc_ipv4, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false) {
|
9 |
return false;
|
10 |
}
|
11 |
|
15 |
/*
|
16 |
* Check of an IP address is a valid IPv6 address
|
17 |
*/
|
18 |
+
function iqblockcountry_is_valid_ipv6($iqbc_ipv6)
|
19 |
{
|
20 |
+
if(filter_var($iqbc_ipv6, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) {
|
21 |
+
return false;
|
22 |
}
|
23 |
|
24 |
return true;
|
25 |
}
|
26 |
|
27 |
+
function iqblockcountry_is_valid_ipv4_cidr($iqbc_ip)
|
28 |
{
|
29 |
+
if (preg_match('/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$/', $iqbc_ip)) {
|
|
|
30 |
return true;
|
31 |
}
|
32 |
else
|
35 |
}
|
36 |
}
|
37 |
|
38 |
+
function iqblockcountry_is_valid_ipv6_cidr($iqbc_ip)
|
39 |
{
|
40 |
+
if (preg_match('/^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*(\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?$/', $iqbc_ip)) {
|
|
|
41 |
return true;
|
42 |
}
|
43 |
else
|
50 |
/*
|
51 |
* Check of given url is a valid url
|
52 |
*/
|
53 |
+
function iqblockcountry_is_valid_url($iqbc_input)
|
54 |
{
|
55 |
+
if(filter_var($iqbc_input, FILTER_VALIDATE_URL) === false) {
|
56 |
+
return "";
|
57 |
+
}
|
58 |
+
else
|
59 |
+
{
|
60 |
+
return $iqbc_input;
|
61 |
}
|
|
|
|
|
|
|
|
|
62 |
|
63 |
}
|
64 |
|
66 |
/*
|
67 |
* Sanitize callback. Check if supplied IP address list is valid IPv4 or IPv6
|
68 |
*/
|
69 |
+
function iqblockcountry_validate_ip($iqbc_input)
|
70 |
{
|
71 |
+
$iqbc_validips = "";
|
72 |
+
if (preg_match('/;/', $iqbc_input)) {
|
73 |
+
$iqbc_arr = explode(";", $iqbc_input);
|
74 |
+
foreach ($iqbc_arr as $iqbc_value) {
|
75 |
+
if (iqblockcountry_is_valid_ipv4($iqbc_value) || iqblockcountry_is_valid_ipv6($iqbc_value) || iqblockcountry_is_valid_ipv4_cidr($iqbc_value) || iqblockcountry_is_valid_ipv6_cidr($iqbc_value)) {
|
76 |
+
$iqbc_validips .= $iqbc_value . ";";
|
|
|
|
|
77 |
}
|
78 |
|
79 |
}
|
80 |
}
|
81 |
else
|
82 |
{
|
83 |
+
if (iqblockcountry_is_valid_ipv4($iqbc_input) || iqblockcountry_is_valid_ipv6($iqbc_input) || iqblockcountry_is_valid_ipv4_cidr($iqbc_input) || iqblockcountry_is_valid_ipv6_cidr($iqbc_input)) {
|
84 |
+
$iqbc_validips = $iqbc_input . ";";
|
|
|
85 |
}
|
86 |
}
|
87 |
+
return $iqbc_validips;
|
88 |
|
89 |
}
|
90 |
|
91 |
/*
|
92 |
* Check if GeoIP API key is correct.
|
93 |
*/
|
94 |
+
function iqblockcountry_check_geoapikey($iqbc_input)
|
95 |
{
|
96 |
|
97 |
// Check first if API key is empty....
|
98 |
+
if (!empty($iqbc_input)) {
|
|
|
99 |
|
100 |
+
$iqbc_url = GEOIPAPICHECKURL;
|
101 |
|
102 |
+
$iqbc_result = wp_remote_post(
|
103 |
+
$iqbc_url,
|
104 |
array(
|
105 |
'body' => array(
|
106 |
+
'api-key' => $iqbc_input
|
107 |
)
|
108 |
)
|
109 |
);
|
110 |
+
$iqbc_message = "";
|
111 |
+
$iqbc_type = "updated";
|
112 |
+
if (is_wp_error($iqbc_result) ) {
|
113 |
+
return false;
|
114 |
}
|
115 |
|
116 |
+
elseif (200 == $iqbc_result['response']['code'] ) {
|
117 |
+
$iqbc_body = $iqbc_result['body'];
|
118 |
+
$iqbc_xml = new SimpleXmlElement($iqbc_body);
|
119 |
+
if ($iqbc_xml->check != "Ok") {
|
120 |
+
$iqbc_message = esc_html('The GeoIP API key is incorrect. Please update the key.', 'iq-block-country');
|
121 |
+
$iqbc_type = "error";
|
122 |
+
$iqbc_input = false;
|
|
|
123 |
}
|
124 |
else
|
125 |
{
|
126 |
+
$iqbc_message = esc_html('Setting saved.', 'iq-block-country');
|
127 |
+
$iqbc_type = "updated";
|
128 |
}
|
129 |
}
|
130 |
else
|
131 |
{
|
132 |
+
$iqbc_input = false;
|
133 |
}
|
134 |
+
add_settings_error('iqblockcountry_geoipapi_error', esc_attr('settings_updated'), $iqbc_message, $iqbc_type);
|
135 |
+
return $iqbc_input;
|
136 |
}
|
137 |
return "";
|
138 |
}
|
140 |
/*
|
141 |
* Check if GeoIP API key is correct.
|
142 |
*/
|
143 |
+
function iqblockcountry_check_adminapikey($iqbc_input)
|
144 |
{
|
145 |
|
146 |
// Check first if API key is empty....
|
147 |
+
if (!empty($iqbc_input)) {
|
|
|
148 |
|
149 |
+
$iqbc_url = ADMINAPICHECKURL;
|
150 |
|
151 |
+
$iqbc_result = wp_remote_post(
|
152 |
+
$iqbc_url,
|
153 |
array(
|
154 |
'body' => array(
|
155 |
+
'api-key' => $iqbc_input
|
156 |
)
|
157 |
)
|
158 |
);
|
159 |
+
$iqbc_message = "";
|
160 |
+
$iqbc_type = "updated";
|
161 |
+
if (is_wp_error($iqbc_result) ) {
|
162 |
+
return false;
|
163 |
}
|
164 |
+
elseif (200 == $iqbc_result['response']['code'] ) {
|
165 |
+
$iqbc_body = $iqbc_result['body'];
|
166 |
+
$iqbc_xml = new SimpleXmlElement($iqbc_body);
|
167 |
+
if ($iqbc_xml->check != "Ok") {
|
168 |
+
$iqbc_message = esc_html('The Admin Block API key is incorrect. Please update the key.', 'iq-block-country');
|
169 |
+
$iqbc_type = "error";
|
170 |
+
$iqbc_input = false;
|
|
|
171 |
}
|
172 |
else
|
173 |
{
|
174 |
+
$iqbc_message = esc_html('Setting saved.', 'iq-block-country');
|
175 |
+
$iqbc_type = "updated";
|
176 |
}
|
177 |
}
|
178 |
else
|
179 |
{
|
180 |
+
$iqbc_input = false;
|
181 |
}
|
182 |
+
add_settings_error('iqblockcountry_adminapi_error', esc_attr('settings_updated'), $iqbc_message, $iqbc_type);
|
183 |
+
return $iqbc_input;
|
184 |
}
|
185 |
return "";
|
186 |
}
|
189 |
/*
|
190 |
* Check if GeoIP API key is correct.
|
191 |
*/
|
192 |
+
function iqblockcountry_get_licensedate_geoapikey($iqbc_apikey)
|
193 |
{
|
194 |
|
195 |
// Check first if API key is empty....
|
196 |
+
if (!empty($iqbc_apikey)) {
|
|
|
197 |
|
198 |
+
$iqbc_url = GEOIPAPICHECKURL;
|
199 |
|
200 |
+
$iqbc_result = wp_remote_post(
|
201 |
+
$iqbc_url,
|
202 |
array(
|
203 |
'body' => array(
|
204 |
+
'api-key' => $iqbc_apikey
|
205 |
)
|
206 |
)
|
207 |
);
|
208 |
+
if (is_wp_error($iqbc_result) ) {
|
209 |
return "";
|
210 |
}
|
211 |
+
elseif (200 == $iqbc_result['response']['code'] ) {
|
212 |
+
$iqbc_body = $iqbc_result['body'];
|
213 |
+
$iqbc_xml = new SimpleXmlElement($iqbc_body);
|
214 |
+
if ($iqbc_xml->check == "Ok") {
|
215 |
+
return $iqbc_xml->LicenseDate;
|
|
|
216 |
}
|
217 |
}
|
218 |
else
|
226 |
/*
|
227 |
* Check usage of GeoIP API
|
228 |
*/
|
229 |
+
function iqblockcountry_get_usage_geoapikey($iqbc_apikey)
|
230 |
{
|
231 |
|
232 |
// Check first if API key is empty....
|
233 |
+
if (!empty($iqbc_apikey)) {
|
|
|
234 |
|
235 |
+
$iqbc_url = GEOIPAPICHECKUSAGEURL;
|
236 |
|
237 |
+
$iqbc_result = wp_remote_post(
|
238 |
+
$iqbc_url,
|
239 |
array(
|
240 |
'body' => array(
|
241 |
+
'api-key' => $iqbc_apikey
|
242 |
)
|
243 |
)
|
244 |
);
|
245 |
+
if (is_wp_error($iqbc_result) ) {
|
246 |
return "";
|
247 |
}
|
248 |
+
elseif (200 == $iqbc_result['response']['code'] ) {
|
249 |
+
$iqbc_body = $iqbc_result['body'];
|
250 |
+
$iqbc_xml = new SimpleXmlElement($iqbc_body);
|
251 |
+
if ($iqbc_xml->check == "Ok") {
|
252 |
+
return $iqbc_xml->requests;
|
|
|
253 |
}
|
254 |
}
|
255 |
else
|
263 |
|
264 |
/**
|
265 |
* Check if a given ip is in a network
|
266 |
+
*
|
267 |
+
* @param string $iqbc_ip IP to check in IPV4 format eg. 127.0.0.1
|
268 |
+
* @param string $range IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed
|
269 |
* @return boolean true if the ip is in this range / false if not.
|
270 |
*/
|
271 |
+
function iqblockcountry_ip_in_ipv4_range( $iqbc_ip, $iqbc_range )
|
272 |
+
{
|
273 |
+
if (strpos($iqbc_range, '/') == false ) {
|
274 |
+
$iqbc_range .= '/32';
|
275 |
+
}
|
276 |
+
// $iqbc_range is in IP/CIDR format eg 127.0.0.1/24
|
277 |
+
list( $iqbc_range, $iqbc_netmask ) = explode('/', $iqbc_range, 2);
|
278 |
+
$iqbc_range_decimal = ip2long($iqbc_range);
|
279 |
+
$iqbc_ip_decimal = ip2long($iqbc_ip);
|
280 |
+
$iqbc_wildcard_decimal = pow(2, ( 32 - $iqbc_netmask )) - 1;
|
281 |
+
$iqbc_netmask_decimal = ~ $iqbc_wildcard_decimal;
|
282 |
+
return ( ( $iqbc_ip_decimal & $netmask_decimal ) == ( $iqbc_range_decimal & $iqbc_netmask_decimal ) );
|
283 |
}
|
284 |
|
285 |
+
function iqblockcountry_ip2long6($iqbc_ip)
|
286 |
+
{
|
287 |
+
if (substr_count($iqbc_ip, '::')) {
|
288 |
+
$iqbc_ip = str_replace('::', str_repeat(':0000', 8 - substr_count($iqbc_ip, ':')) . ':', $iqbc_ip);
|
289 |
}
|
290 |
|
291 |
+
$iqbc_ip = explode(':', $iqbc_ip);
|
292 |
+
$iqbc_r_ip = '';
|
293 |
+
foreach ($iqbc_ip as $iqbc_v) {
|
294 |
+
$iqbc_r_ip .= str_pad(base_convert($iqbc_v, 16, 2), 16, 0, STR_PAD_LEFT);
|
295 |
}
|
296 |
|
297 |
+
return base_convert($iqbc_r_ip, 2, 10);
|
298 |
}
|
299 |
// Get the ipv6 full format and return it as a decimal value.
|
300 |
+
function iqblockcountry_get_ipv6_full($iqbc_ip)
|
301 |
{
|
302 |
+
$iqbc_pieces = explode("/", $iqbc_ip, 2);
|
303 |
+
$iqbc_left_piece = $iqbc_pieces[0];
|
304 |
+
$iqbc_right_piece = $iqbc_pieces[1];
|
305 |
// Extract out the main IP pieces
|
306 |
+
$iqbc_ip_pieces = explode("::", $iqbc_left_piece, 2);
|
307 |
+
$iqbc_main_ip_piece = $iqbc_ip_pieces[0];
|
308 |
+
$iqbc_last_ip_piece = $iqbc_ip_pieces[1];
|
309 |
// Pad out the shorthand entries.
|
310 |
+
$iqbc_main_ip_pieces = explode(":", $iqbc_main_ip_piece);
|
311 |
+
foreach($iqbc_main_ip_pieces as $iqbc_key=>$iqbc_val) {
|
312 |
+
$iqbc_main_ip_pieces[$iqbc_key] = str_pad($iqbc_main_ip_pieces[$iqbc_key], 4, "0", STR_PAD_LEFT);
|
313 |
}
|
314 |
// Check to see if the last IP block (part after ::) is set
|
315 |
+
$iqbc_last_piece = "";
|
316 |
+
$iqbc_size = count($iqbc_main_ip_pieces);
|
317 |
+
if (trim($iqbc_last_ip_piece) != "") {
|
318 |
+
$iqbc_last_piece = str_pad($iqbc_last_ip_piece, 4, "0", STR_PAD_LEFT);
|
319 |
|
320 |
// Build the full form of the IPV6 address considering the last IP block set
|
321 |
+
for ($iqbc_i = $iqbc_size; $iqbc_i < 7; $iqbc_i++) {
|
322 |
+
$iqbc_main_ip_pieces[$iqbc_i] = "0000";
|
323 |
}
|
324 |
+
$iqbc_main_ip_pieces[7] = $iqbc_last_piece;
|
325 |
}
|
326 |
else {
|
327 |
// Build the full form of the IPV6 address
|
328 |
+
for ($iqbc_i = $iqbc_size; $iqbc_i < 8; $iqbc_i++) {
|
329 |
+
$iqbc_main_ip_pieces[$iqbc_i] = "0000";
|
330 |
}
|
331 |
}
|
332 |
|
333 |
// Rebuild the final long form IPV6 address
|
334 |
+
$iqbc_final_ip = implode(":", $iqbc_main_ip_pieces);
|
335 |
+
return iqblockcountry_ip2long6($iqbc_final_ip);
|
336 |
}
|
337 |
// Determine whether the IPV6 address is within range.
|
338 |
+
// $iqbc_ip is the IPV6 address in decimal format to check if its within the IP range created by the cloudflare IPV6 address, $range_ip.
|
339 |
+
// $iqbc_ip and $range_ip are converted to full IPV6 format.
|
340 |
+
// Returns true if the IPV6 address, $iqbc_ip, is within the range from $range_ip. False otherwise.
|
341 |
+
function iqblockcountry_ipv6_in_range($iqbc_ip, $range_ip)
|
342 |
{
|
343 |
+
$iqbc_pieces = explode("/", $range_ip, 2);
|
344 |
+
$iqbc_left_piece = $iqbc_pieces[0];
|
345 |
+
$iqbc_right_piece = $iqbc_pieces[1];
|
346 |
// Extract out the main IP pieces
|
347 |
+
$iqbc_ip_pieces = explode("::", $iqbc_left_piece, 2);
|
348 |
+
$iqbc_main_ip_piece = $iqbc_ip_pieces[0];
|
349 |
+
$iqbc_last_ip_piece = $iqbc_ip_pieces[1];
|
350 |
// Pad out the shorthand entries.
|
351 |
+
$iqbc_main_ip_pieces = explode(":", $iqbc_main_ip_piece);
|
352 |
+
foreach($iqbc_main_ip_pieces as $iqbc_key=>$iqbc_val) {
|
353 |
+
$iqbc_main_ip_pieces[$iqbc_key] = str_pad($iqbc_main_ip_pieces[$iqbc_key], 4, "0", STR_PAD_LEFT);
|
354 |
}
|
355 |
// Create the first and last pieces that will denote the IPV6 range.
|
356 |
+
$iqbc_first = $iqbc_main_ip_pieces;
|
357 |
+
$iqbc_last = $iqbc_main_ip_pieces;
|
358 |
// Check to see if the last IP block (part after ::) is set
|
359 |
+
$iqbc_last_piece = "";
|
360 |
+
$iqbc_size = count($iqbc_main_ip_pieces);
|
361 |
+
if (trim($iqbc_last_ip_piece) != "") {
|
362 |
+
$iqbc_last_piece = str_pad($iqbc_last_ip_piece, 4, "0", STR_PAD_LEFT);
|
363 |
|
364 |
// Build the full form of the IPV6 address considering the last IP block set
|
365 |
+
for ($iqbc_i = $iqbc_size; $iqbc_i < 7; $iqbc_i++) {
|
366 |
+
$iqbc_first[$iqbc_i] = "0000";
|
367 |
+
$iqbc_last[$iqbc_i] = "ffff";
|
368 |
}
|
369 |
+
$iqbc_main_ip_pieces[7] = $iqbc_last_piece;
|
370 |
}
|
371 |
else {
|
372 |
// Build the full form of the IPV6 address
|
373 |
+
for ($iqbc_i = $iqbc_size; $iqbc_i < 8; $iqbc_i++) {
|
374 |
+
$iqbc_first[$iqbc_i] = "0000";
|
375 |
+
$iqbc_last[$iqbc_i] = "ffff";
|
376 |
}
|
377 |
}
|
378 |
// Rebuild the final long form IPV6 address
|
379 |
+
$iqbc_first = iqblockcountry_ip2long6(implode(":", $iqbc_first));
|
380 |
+
$iqbc_last = iqblockcountry_ip2long6(implode(":", $iqbc_last));
|
381 |
+
$iqbc_in_range = ($iqbc_ip >= $iqbc_first && $iqbc_ip <= $iqbc_last);
|
382 |
+
return $iqbc_in_range;
|
383 |
}
|
384 |
|
385 |
|
386 |
+
function iqblockcountry_validate_ip_in_list($iqbc_ipaddress,$iqbc_ipv4list,$iqbc_ipv6list,$iqbc_iplist)
|
387 |
{
|
388 |
|
389 |
+
$iqbc_match = false;
|
390 |
+
if (iqblockcountry_is_valid_ipv4($iqbc_ipaddress) && is_array($iqbc_ipv4list)) {
|
391 |
+
foreach ($iqbc_ipv4list AS $iqbc_iprange)
|
|
|
392 |
{
|
393 |
+
if (iqblockcountry_ip_in_ipv4_range($iqbc_ipaddress, $iqbc_iprange)) {
|
394 |
+
$iqbc_match = true;
|
|
|
395 |
}
|
396 |
}
|
397 |
}
|
398 |
+
elseif (iqblockcountry_is_valid_ipv6($iqbc_ipaddress) && is_array($iqbc_ipv6list)) {
|
399 |
+
foreach ($iqbc_ipv6list AS $iqbc_iprange)
|
|
|
400 |
{
|
401 |
+
$iqbc_ipaddress6 = iqblockcountry_get_ipv6_full($iqbc_ipaddress);
|
402 |
+
if (iqblockcountry_ipv6_in_range($iqbc_ipaddress6, $iqbc_iprange)) {
|
403 |
+
$iqbc_match = true;
|
|
|
404 |
}
|
405 |
}
|
406 |
|
407 |
}
|
408 |
+
if ((iqblockcountry_is_valid_ipv4($iqbc_ipaddress) || iqblockcountry_is_valid_ipv6($iqbc_ipaddress)) && is_array($iqbc_iplist)) {
|
409 |
+
if (in_array($iqbc_ipaddress, $iqbc_iplist)) {
|
410 |
+
$iqbc_match = true;
|
|
|
|
|
411 |
}
|
412 |
}
|
413 |
+
return $iqbc_match;
|
414 |
}
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ 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:
|
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: 7.0
|
@@ -241,6 +241,9 @@ be used.
|
|
241 |
|
242 |
== Changelog ==
|
243 |
|
|
|
|
|
|
|
244 |
= 1.2.13 =
|
245 |
|
246 |
* Change: Altered import/export function to make it more secure
|
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: 6.0
|
7 |
+
Stable tag: 1.2.14
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
Requires PHP: 7.0
|
241 |
|
242 |
== Changelog ==
|
243 |
|
244 |
+
= 1.2.14 =
|
245 |
+
* Change: A lot of internal code changes to make it more in line of WordPress Best Practices
|
246 |
+
|
247 |
= 1.2.13 =
|
248 |
|
249 |
* Change: Altered import/export function to make it more secure
|