PluginProbe
Loginizer / 1.6.6
Loginizer v1.6.6
2.1.0 2.0.9 2.0.8 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 All 74 releases
← All changes | init.php +3241 -256 1.3.21.6.6 View file →
@@ -4,13 +4,14 @@
4 4 echo 'You are not allowed to access this page directly.';
5 5 exit;
6 6 }
7 7
8 -define('LOGINIZER_VERSION', '1.3.2');
9 -define('LOGINIZER_DIR', WP_PLUGIN_DIR.'/'.basename(dirname(LOGINIZER_FILE)));
8 +define('LOGINIZER_VERSION', '1.6.6');
9 +define('LOGINIZER_DIR', dirname(LOGINIZER_FILE));
10 10 define('LOGINIZER_URL', plugins_url('', LOGINIZER_FILE));
11 11 define('LOGINIZER_PRO_URL', 'https://loginizer.com/features#compare');
12 -define('LOGINIZER_DOCS', 'https://loginizer.com/wiki/');
12 +define('LOGINIZER_PRICING_URL', 'https://loginizer.com/pricing');
13 +define('LOGINIZER_DOCS', 'https://loginizer.com/docs/');
13 14
14 15 include_once(LOGINIZER_DIR.'/functions.php');
15 16
16 17 // Ok so we are now ready to go
@@ -30,10 +31,11 @@
30 31 `time` int(10) NOT NULL DEFAULT '0',
31 32 `count` int(10) NOT NULL DEFAULT '0',
32 33 `lockout` int(10) NOT NULL DEFAULT '0',
33 34 `ip` varchar(255) NOT NULL DEFAULT '',
35 + `url` varchar(255) NOT NULL DEFAULT '',
34 36 UNIQUE KEY `ip` (`ip`)
35 - ) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
37 + ) DEFAULT CHARSET=utf8;";
36 38
37 39 foreach($sql as $sk => $sv){
38 40 $wpdb->query($sv);
39 41 }
@@ -42,12 +44,19 @@
42 44 add_option('loginizer_options', array());
43 45 add_option('loginizer_last_reset', 0);
44 46 add_option('loginizer_whitelist', array());
45 47 add_option('loginizer_blacklist', array());
48 + add_option('loginizer_2fa_whitelist', array());
46 49
47 50 }
48 51
49 -// Checks if we are to update ?
52 +/**
53 + * Updates the database structure for Loginizer
54 + *
55 + * If the plugin files are updated but database structure is not updated
56 + * this function will update the database structure as per the plugin version
57 + * NOTE: This does not update plugin files it just updates the database structure
58 + */
50 59 function loginizer_update_check(){
51 60
52 61 global $wpdb;
53 62
@@ -107,9 +116,17 @@
107 116
108 117 // Update the existing failed logs to new table
109 118 if(is_array($lz_failed_logs)){
110 119 foreach($lz_failed_logs as $fk => $fv){
111 - $wpdb->query("INSERT INTO ".$wpdb->prefix."loginizer_logs SET `username` = '".$fv['username']."', `time` = '".$fv['time']."', `count` = '".$fv['count']."', `lockout` = '".$fv['lockout']."', `ip` = '".$fv['ip']."';");
120 + $insert_data = array('username' => $fv['username'],
121 + 'time' => $fv['time'],
122 + 'count' => $fv['count'],
123 + 'lockout' => $fv['lockout'],
124 + 'ip' => $fv['ip']);
125 +
126 + $format = array('%s','%d','%d','%d','%s');
127 +
128 + $wpdb->insert($wpdb->prefix.'loginizer_logs', $insert_data, $format);
112 129 }
113 130 }
114 131
115 132 // Update the existing options to new structure
@@ -158,11 +175,24 @@
158 175 }
159 176
160 177 }
161 178
179 + // Is it less than 1.3.9 ?
180 + if($version < 139){
181 +
182 + $wpdb->query("ALTER TABLE ".$wpdb->prefix."loginizer_logs ADD `url` VARCHAR(255) NOT NULL DEFAULT '' AFTER `ip`;");
183 +
184 + }
185 +
162 186 // Save the new Version
163 187 update_option('loginizer_version', LOGINIZER_VERSION);
164 188
189 + // In Sitepad Math Captcha is enabled by default
190 + if(defined('SITEPAD') && get_option('loginizer_captcha') === false){
191 + $option['captcha_no_google'] = 1;
192 + add_option('loginizer_captcha', $option);
193 + }
194 +
165 195 }
166 196
167 197 // Add the action to load the plugin
168 198 add_action('plugins_loaded', 'loginizer_load_plugin');
@@ -177,10 +207,18 @@
177 207
178 208 // Set the array
179 209 $loginizer = array();
180 210
211 + $loginizer['prefix'] = !defined('SITEPAD') ? 'Loginizer ' : 'SitePad ';
212 + $loginizer['app'] = !defined('SITEPAD') ? 'WordPress' : 'SitePad';
213 + $loginizer['login_basename'] = !defined('SITEPAD') ? 'wp-login.php' : 'login.php';
214 + $loginizer['wp-includes'] = !defined('SITEPAD') ? 'wp-includes' : 'site-inc';
215 +
181 216 // The IP Method to use
182 217 $loginizer['ip_method'] = get_option('loginizer_ip_method');
218 + if($loginizer['ip_method'] == 3){
219 + $loginizer['custom_ip_method'] = get_option('loginizer_custom_ip_method');
220 + }
183 221
184 222 // Load settings
185 223 $options = get_option('loginizer_options');
186 224 $loginizer['max_retries'] = empty($options['max_retries']) ? 3 : $options['max_retries'];
@@ -188,13 +226,51 @@
188 226 $loginizer['max_lockouts'] = empty($options['max_lockouts']) ? 5 : $options['max_lockouts'];
189 227 $loginizer['lockouts_extend'] = empty($options['lockouts_extend']) ? 86400 : $options['lockouts_extend']; // 24 hours
190 228 $loginizer['reset_retries'] = empty($options['reset_retries']) ? 86400 : $options['reset_retries']; // 24 hours
191 229 $loginizer['notify_email'] = empty($options['notify_email']) ? 0 : $options['notify_email'];
230 +
231 + // Default messages
232 + $loginizer['d_msg']['inv_userpass'] = __('Incorrect Username or Password', 'loginizer');
233 + $loginizer['d_msg']['ip_blacklisted'] = __('Your IP has been blacklisted', 'loginizer');
234 + $loginizer['d_msg']['attempts_left'] = __('attempt(s) left', 'loginizer');
235 + $loginizer['d_msg']['lockout_err'] = __('You have exceeded maximum login retries<br /> Please try after', 'loginizer');
236 + $loginizer['d_msg']['minutes_err'] = __('minute(s)', 'loginizer');
237 + $loginizer['d_msg']['hours_err'] = __('hour(s)', 'loginizer');
238 +
239 + // Message Strings
240 + $loginizer['msg'] = get_option('loginizer_msg');
241 +
242 + foreach($loginizer['d_msg'] as $lk => $lv){
243 + if(empty($loginizer['msg'][$lk])){
244 + $loginizer['msg'][$lk] = $loginizer['d_msg'][$lk];
245 + }
246 + }
247 +
248 + $loginizer['2fa_d_msg']['otp_app'] = __('Please enter the OTP as seen in your App', 'loginizer');
249 + $loginizer['2fa_d_msg']['otp_email'] = __('Please enter the OTP emailed to you', 'loginizer');
250 + $loginizer['2fa_d_msg']['otp_field'] = __('One Time Password', 'loginizer');
251 + $loginizer['2fa_d_msg']['otp_question'] = __('Please answer your security question', 'loginizer');
252 + $loginizer['2fa_d_msg']['otp_answer'] = __('Your Answer', 'loginizer');
253 +
254 + // Message Strings
255 + $loginizer['2fa_msg'] = get_option('loginizer_2fa_msg');
256 +
257 + foreach($loginizer['2fa_d_msg'] as $lk => $lv){
258 + if(empty($loginizer['2fa_msg'][$lk])){
259 + $loginizer['2fa_msg'][$lk] = $loginizer['2fa_d_msg'][$lk];
260 + }
261 + }
192 262
193 263 // Load the blacklist and whitelist
194 264 $loginizer['blacklist'] = get_option('loginizer_blacklist');
195 265 $loginizer['whitelist'] = get_option('loginizer_whitelist');
266 + $loginizer['2fa_whitelist'] = get_option('loginizer_2fa_whitelist');
196 267
268 + // It should not be false
269 + if(empty($loginizer['2fa_whitelist'])){
270 + $loginizer['2fa_whitelist'] = array();
271 + }
272 +
197 273 // When was the database cleared last time
198 274 $loginizer['last_reset'] = get_option('loginizer_last_reset');
199 275
200 276 //print_r($loginizer);
@@ -212,24 +288,152 @@
212 288 $loginizer['ins_time'] = $ins_time;
213 289
214 290 // Set the current IP
215 291 $loginizer['current_ip'] = lz_getip();
292 +
293 + // Is Brute Force Disabled ?
294 + $loginizer['disable_brute'] = get_option('loginizer_disable_brute');
216 295
217 - /* Filters and actions */
296 + // Filters and actions
297 + if(empty($loginizer['disable_brute'])){
218 298
219 - // Use this to verify before WP tries to login
220 - // Is always called and is the first function to be called
221 - //add_action('wp_authenticate', 'loginizer_wp_authenticate', 10, 2);// Not called by XML-RPC
222 - add_filter('authenticate', 'loginizer_wp_authenticate', 10001, 3);// This one is called by xmlrpc as well as GUI
299 + // Use this to verify before WP tries to login
300 + // Is always called and is the first function to be called
301 + //add_action('wp_authenticate', 'loginizer_wp_authenticate', 10, 2);// Not called by XML-RPC
302 + add_filter('authenticate', 'loginizer_wp_authenticate', 10001, 3);// This one is called by xmlrpc as well as GUI
303 +
304 + // Is called when a login attempt fails
305 + // Hence Update our records that the login failed
306 + add_action('wp_login_failed', 'loginizer_login_failed');
307 +
308 + // Is called before displaying the error message so that we dont show that the username is wrong or the password
309 + // Update Error message
310 + add_action('wp_login_errors', 'loginizer_error_handler', 10001, 2);
311 + add_action('woocommerce_login_failed', 'loginizer_woocommerce_error_handler', 10001);
223 312
224 - // Is called when a login attempt fails
225 - // Hence Update our records that the login failed
226 - add_action('wp_login_failed', 'loginizer_login_failed');
313 + }
227 314
228 - // Is called before displaying the error message so that we dont show that the username is wrong or the password
229 - // Update Error message
230 - add_action('wp_login_errors', 'loginizer_error_handler', 10001, 2);
315 + // ----------------
316 + // PRO INIT
317 + // ----------------
231 318
319 + // Email to Login
320 + $options = get_option('loginizer_epl');
321 + $loginizer['pl_d_sub'] = 'Login at $site_name';
322 + $loginizer['pl_d_msg'] = 'Hi,
323 +
324 +A login request was submitted for your account $email at :
325 +$site_name - $site_url
326 +
327 +Login at $site_name by visiting this url :
328 +$login_url
329 +
330 +If you have not requested for the Login URL, please ignore this email.
331 +
332 +Regards,
333 +$site_name';
334 + $loginizer['email_pass_less'] = empty($options['email_pass_less']) ? 0 : $options['email_pass_less'];
335 + $loginizer['passwordless_sub'] = empty($options['passwordless_sub']) ? $loginizer['pl_d_sub'] : $options['passwordless_sub'];
336 + $loginizer['passwordless_msg'] = empty($options['passwordless_msg']) ? $loginizer['pl_d_msg'] : $options['passwordless_msg'];
337 + $loginizer['passwordless_msg_is_custom'] = empty($options['passwordless_msg']) ? 0 : 1;
338 + $loginizer['passwordless_html'] = empty($options['passwordless_html']) ? 0 : $options['passwordless_html'];
339 +
340 + // 2FA OTP Email to Login
341 + $options = get_option('loginizer_2fa_email_template');
342 + $loginizer['2fa_email_d_sub'] = 'OTP : Login at $site_name';
343 + $loginizer['2fa_email_d_msg'] = 'Hi,
344 +
345 +A login request was submitted for your account $email at :
346 +$site_name - $site_url
347 +
348 +Please use the following One Time password (OTP) to login :
349 +$otp
350 +
351 +Note : The OTP expires after 10 minutes.
352 +
353 +If you haven\'t requested for the OTP, please ignore this email.
354 +
355 +Regards,
356 +$site_name';
357 +
358 + $loginizer['2fa_email_sub'] = empty($options['2fa_email_sub']) ? $loginizer['2fa_email_d_sub'] : $options['2fa_email_sub'];
359 + $loginizer['2fa_email_msg'] = empty($options['2fa_email_msg']) ? $loginizer['2fa_email_d_msg'] : $options['2fa_email_msg'];
360 +
361 + // For SitePad its always on
362 + if(defined('SITEPAD')){
363 + $loginizer['email_pass_less'] = 1;
364 + }
365 +
366 + // Captcha
367 + $options = get_option('loginizer_captcha');
368 + $loginizer['captcha_type'] = empty($options['captcha_type']) ? '' : $options['captcha_type'];
369 + $loginizer['captcha_key'] = empty($options['captcha_key']) ? '' : $options['captcha_key'];
370 + $loginizer['captcha_secret'] = empty($options['captcha_secret']) ? '' : $options['captcha_secret'];
371 + $loginizer['captcha_theme'] = empty($options['captcha_theme']) ? 'light' : $options['captcha_theme'];
372 + $loginizer['captcha_size'] = empty($options['captcha_size']) ? 'normal' : $options['captcha_size'];
373 + $loginizer['captcha_lang'] = empty($options['captcha_lang']) ? '' : $options['captcha_lang'];
374 + $loginizer['captcha_user_hide'] = !isset($options['captcha_user_hide']) ? 0 : $options['captcha_user_hide'];
375 + $loginizer['captcha_no_css_login'] = !isset($options['captcha_no_css_login']) ? 0 : $options['captcha_no_css_login'];
376 + $loginizer['captcha_no_js'] = 1;
377 + $loginizer['captcha_login'] = !isset($options['captcha_login']) ? 1 : $options['captcha_login'];
378 + $loginizer['captcha_lostpass'] = !isset($options['captcha_lostpass']) ? 1 : $options['captcha_lostpass'];
379 + $loginizer['captcha_resetpass'] = !isset($options['captcha_resetpass']) ? 1 : $options['captcha_resetpass'];
380 + $loginizer['captcha_register'] = !isset($options['captcha_register']) ? 1 : $options['captcha_register'];
381 + $loginizer['captcha_comment'] = !isset($options['captcha_comment']) ? 1 : $options['captcha_comment'];
382 + $loginizer['captcha_wc_checkout'] = !isset($options['captcha_wc_checkout']) ? 1 : $options['captcha_wc_checkout'];
383 +
384 + $loginizer['captcha_no_google'] = !isset($options['captcha_no_google']) ? 0 : $options['captcha_no_google'];
385 + $loginizer['captcha_text'] = empty($options['captcha_text']) ? __('Math Captcha', 'loginizer') : $options['captcha_text'];
386 + $loginizer['captcha_time'] = empty($options['captcha_time']) ? 300 : $options['captcha_time'];
387 + $loginizer['captcha_words'] = !isset($options['captcha_words']) ? 0 : $options['captcha_words'];
388 + $loginizer['captcha_add'] = !isset($options['captcha_add']) ? 1 : $options['captcha_add'];
389 + $loginizer['captcha_subtract'] = !isset($options['captcha_subtract']) ? 1 : $options['captcha_subtract'];
390 + $loginizer['captcha_multiply'] = !isset($options['captcha_multiply']) ? 0 : $options['captcha_multiply'];
391 + $loginizer['captcha_divide'] = !isset($options['captcha_divide']) ? 0 : $options['captcha_divide'];
392 +
393 + // 2fa/question
394 + $options = get_option('loginizer_2fa');
395 + $loginizer['2fa_app'] = !isset($options['2fa_app']) ? 0 : $options['2fa_app'];
396 + $loginizer['2fa_email'] = !isset($options['2fa_email']) ? 0 : $options['2fa_email'];
397 + $loginizer['2fa_email_force'] = !isset($options['2fa_email_force']) ? 0 : $options['2fa_email_force'];
398 + $loginizer['2fa_sms'] = !isset($options['2fa_sms']) ? 0 : $options['2fa_sms'];
399 + $loginizer['question'] = !isset($options['question']) ? 0 : $options['question'];
400 + $loginizer['2fa_default'] = empty($options['2fa_default']) ? 'question' : $options['2fa_default'];
401 + $loginizer['2fa_roles'] = empty($options['2fa_roles']) ? array() : $options['2fa_roles'];
402 +
403 + // Security Settings
404 + $options = get_option('loginizer_security');
405 + $loginizer['login_slug'] = empty($options['login_slug']) ? '' : $options['login_slug'];
406 + $loginizer['rename_login_secret'] = empty($options['rename_login_secret']) ? '' : $options['rename_login_secret'];
407 + $loginizer['xmlrpc_slug'] = empty($options['xmlrpc_slug']) ? '' : $options['xmlrpc_slug'];
408 + $loginizer['xmlrpc_disable'] = empty($options['xmlrpc_disable']) ? '' : $options['xmlrpc_disable'];// Disable XML-RPC
409 + $loginizer['pingbacks_disable'] = empty($options['pingbacks_disable']) ? '' : $options['pingbacks_disable'];// Disable Pingbacks
410 +
411 + // Admin Slug Settings
412 + $options = get_option('loginizer_wp_admin');
413 + $loginizer['admin_slug'] = empty($options['admin_slug']) ? '' : $options['admin_slug'];
414 + $loginizer['restrict_wp_admin'] = empty($options['restrict_wp_admin']) ? '' : $options['restrict_wp_admin'];
415 + $loginizer['wp_admin_msg'] = empty($options['wp_admin_msg']) ? '' : $options['wp_admin_msg'];
416 +
417 + // Checksum Settings
418 + $options = get_option('loginizer_checksums');
419 + $loginizer['disable_checksum'] = empty($options['disable_checksum']) ? '' : $options['disable_checksum'];
420 + $loginizer['checksum_time'] = empty($options['checksum_time']) ? '' : $options['checksum_time'];
421 + $loginizer['checksum_frequency'] = empty($options['checksum_frequency']) ? 7 : $options['checksum_frequency'];
422 + $loginizer['no_checksum_email'] = empty($options['no_checksum_email']) ? '' : $options['no_checksum_email'];
423 + $loginizer['checksums_last_run'] = get_option('loginizer_checksums_last_run');
424 +
425 + // Auto Blacklist Usernames
426 + $loginizer['username_blacklist'] = get_option('loginizer_username_blacklist');
427 +
428 + $loginizer['domains_blacklist'] = get_option('loginizer_domains_blacklist');
429 +
430 + $loginizer['wp_admin_d_msg'] = __('LZ : Not allowed via WP-ADMIN. Please access over the new Admin URL', 'loginizer');
431 +
432 + // ----------------
433 + // PRO INIT END
434 + // ----------------
435 +
232 436 // Is the premium features there ?
233 437 if(file_exists(LOGINIZER_DIR.'/premium.php')){
234 438
235 439 // Include the file
@@ -393,8 +597,12 @@
393 597
394 598 // Are you blacklisted ?
395 599 if(loginizer_is_blacklisted()){
396 600 $lz_cannot_login = 1;
601 +
602 + // This is used by WP Activity Log
603 + apply_filters( 'wp_login_blocked', $username );
604 +
397 605 return new WP_Error('ip_blacklisted', implode('', $lz_error), 'loginizer');
398 606 }
399 607
400 608 // Is the username blacklisted ?
@@ -400,8 +608,12 @@
400 608 // Is the username blacklisted ?
401 609 if(function_exists('loginizer_user_blacklisted')){
402 610 if(loginizer_user_blacklisted($username)){
403 611 $lz_cannot_login = 1;
612 +
613 + // This is used by WP Activity Log
614 + apply_filters( 'wp_login_blocked', $username );
615 +
404 616 return new WP_Error('user_blacklisted', implode('', $lz_error), 'loginizer');
405 617 }
406 618 }
407 619
@@ -409,8 +621,11 @@
409 621 return $user;
410 622 }
411 623
412 624 $lz_cannot_login = 1;
625 +
626 + // This is used by WP Activity Log
627 + apply_filters( 'wp_login_blocked', $username );
413 628
414 629 return new WP_Error('ip_blocked', implode('', $lz_error), 'loginizer');
415 630
416 631 }
@@ -419,9 +634,10 @@
419 634
420 635 global $wpdb, $loginizer, $lz_error;
421 636
422 637 // Get the logs
423 - $result = lz_selectquery("SELECT * FROM `".$wpdb->prefix."loginizer_logs` WHERE `ip` = '".$loginizer['current_ip']."';");
638 + $sel_query = $wpdb->prepare("SELECT * FROM `".$wpdb->prefix."loginizer_logs` WHERE `ip` = %s", $loginizer['current_ip']);
639 + $result = lz_selectquery($sel_query);
424 640
425 641 if(!empty($result['count']) && ($result['count'] % $loginizer['max_retries']) == 0){
426 642
427 643 // Has he reached max lockouts ?
@@ -432,20 +648,20 @@
432 648 // Is he in the lockout time ?
433 649 if($result['time'] >= (time() - $loginizer['lockout_time'])){
434 650 $banlift = ceil((($result['time'] + $loginizer['lockout_time']) - time()) / 60);
435 651
436 - //echo 'Current Time '.date('m/d/Y H:i:s', time()).'<br />';
437 - //echo 'Last attempt '.date('m/d/Y H:i:s', $result['time']).'<br />';
438 - //echo 'Unlock Time '.date('m/d/Y H:i:s', $result['time'] + $loginizer['lockout_time']).'<br />';
652 + //echo 'Current Time '.date('d/M/Y H:i:s P', time()).'<br />';
653 + //echo 'Last attempt '.date('d/M/Y H:i:s P', $result['time']).'<br />';
654 + //echo 'Unlock Time '.date('d/M/Y H:i:s P', $result['time'] + $loginizer['lockout_time']).'<br />';
439 655
440 - $_time = $banlift.' minute(s)';
656 + $_time = $banlift.' '.$loginizer['msg']['minutes_err'];
441 657
442 658 if($banlift > 60){
443 659 $banlift = ceil($banlift / 60);
444 - $_time = $banlift.' hour(s)';
660 + $_time = $banlift.' '.$loginizer['msg']['hours_err'];
445 661 }
446 662
447 - $lz_error['ip_blocked'] = 'You have exceeded maximum login retries<br /> Please try after '.$_time;
663 + $lz_error['ip_blocked'] = $loginizer['msg']['lockout_err'].' '.$_time;
448 664
449 665 return false;
450 666 }
451 667 }
@@ -461,22 +677,22 @@
461 677
462 678 foreach($blacklist as $k => $v){
463 679
464 680 // Is the IP in the blacklist ?
465 - if(ip2long($v['start']) <= ip2long($loginizer['current_ip']) && ip2long($loginizer['current_ip']) <= ip2long($v['end'])){
681 + if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip']) && inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
466 682 $result = 1;
467 683 break;
468 684 }
469 685
470 686 // Is it in a wider range ?
471 - if(ip2long($v['start']) >= 0 && ip2long($v['end']) < 0){
687 + if(inet_ptoi($v['start']) >= 0 && inet_ptoi($v['end']) < 0){
472 688
473 - // Since the end of the RANGE (i.e. current IP range) is beyond the +ve value of ip2long,
689 + // Since the end of the RANGE (i.e. current IP range) is beyond the +ve value of inet_ptoi,
474 690 // if the current IP is <= than the start of the range, it is within the range
475 691 // OR
476 692 // if the current IP is <= than the end of the range, it is within the range
477 - if(ip2long($v['start']) <= ip2long($loginizer['current_ip'])
478 - || ip2long($loginizer['current_ip']) <= ip2long($v['end'])){
693 + if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip'])
694 + || inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
479 695 $result = 1;
480 696 break;
481 697 }
482 698
@@ -485,9 +701,9 @@
485 701 }
486 702
487 703 // You are blacklisted
488 704 if(!empty($result)){
489 - $lz_error['ip_blacklisted'] = 'Your IP has been blacklisted';
705 + $lz_error['ip_blacklisted'] = $loginizer['msg']['ip_blacklisted'];
490 706 return true;
491 707 }
492 708
493 709 return false;
@@ -502,22 +718,22 @@
502 718
503 719 foreach($whitelist as $k => $v){
504 720
505 721 // Is the IP in the blacklist ?
506 - if(ip2long($v['start']) <= ip2long($loginizer['current_ip']) && ip2long($loginizer['current_ip']) <= ip2long($v['end'])){
722 + if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip']) && inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
507 723 $result = 1;
508 724 break;
509 725 }
510 726
511 727 // Is it in a wider range ?
512 - if(ip2long($v['start']) >= 0 && ip2long($v['end']) < 0){
728 + if(inet_ptoi($v['start']) >= 0 && inet_ptoi($v['end']) < 0){
513 729
514 - // Since the end of the RANGE (i.e. current IP range) is beyond the +ve value of ip2long,
730 + // Since the end of the RANGE (i.e. current IP range) is beyond the +ve value of inet_ptoi,
515 731 // if the current IP is <= than the start of the range, it is within the range
516 732 // OR
517 733 // if the current IP is <= than the end of the range, it is within the range
518 - if(ip2long($v['start']) <= ip2long($loginizer['current_ip'])
519 - || ip2long($loginizer['current_ip']) <= ip2long($v['end'])){
734 + if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip'])
735 + || inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
520 736 $result = 1;
521 737 break;
522 738 }
523 739
@@ -536,20 +752,47 @@
536 752
537 753
538 754 // When the login fails, then this is called
539 755 // We need to update the database
540 -function loginizer_login_failed($username){
756 +function loginizer_login_failed($username, $is_2fa = ''){
541 757
542 758 global $wpdb, $loginizer, $lz_cannot_login;
759 +
760 + // Some plugins are changing the value for username as null so we need to handle it before using it for the INSERT OR UPDATE query
761 + if(empty($username) || is_null($username)){
762 + $username = '';
763 + }
764 +
765 + $fail_type = 'Login';
766 +
767 + if(!empty($is_2fa)){
768 + $fail_type = '2FA';
769 + }
543 770
544 771 if(empty($lz_cannot_login) && empty($loginizer['ip_is_whitelisted']) && empty($loginizer['no_loginizer_logs'])){
545 772
546 - $result = lz_selectquery("SELECT * FROM `".$wpdb->prefix."loginizer_logs` WHERE `ip` = '".$loginizer['current_ip']."';");
773 + $url = @addslashes((!empty($_SERVER['HTTPS']) ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
774 + $url = esc_url($url);
547 775
776 + $sel_query = $wpdb->prepare("SELECT * FROM `".$wpdb->prefix."loginizer_logs` WHERE `ip` = %s", $loginizer['current_ip']);
777 + $result = lz_selectquery($sel_query);
778 +
548 779 if(!empty($result)){
549 780 $lockout = floor((($result['count']+1) / $loginizer['max_retries']));
550 - $sresult = $wpdb->query("UPDATE `".$wpdb->prefix."loginizer_logs` SET `username` = '".$username."', `time` = '".time()."', `count` = `count`+1, `lockout` = '".$lockout."' WHERE `ip` = '".$loginizer['current_ip']."';");
551 781
782 + $update_data = array('username' => $username,
783 + 'time' => time(),
784 + 'count' => $result['count']+1,
785 + 'lockout' => $lockout,
786 + 'url' => $url);
787 +
788 + $where_data = array('ip' => $loginizer['current_ip']);
789 +
790 + $format = array('%s','%d','%d','%d','%s');
791 + $where_format = array('%s');
792 +
793 + $wpdb->update($wpdb->prefix.'loginizer_logs', $update_data, $where_data, $format, $where_format);
794 +
552 795 // Do we need to email admin ?
553 796 if(!empty($loginizer['notify_email']) && $lockout >= $loginizer['notify_email']){
554 797
555 798 $sitename = lz_is_multisite() ? get_site_option('site_name') : get_option('blogname');
@@ -554,16 +797,17 @@
554 797
555 798 $sitename = lz_is_multisite() ? get_site_option('site_name') : get_option('blogname');
556 799 $mail = array();
557 800 $mail['to'] = lz_is_multisite() ? get_site_option('admin_email') : get_option('admin_email');
558 - $mail['subject'] = 'Failed Login Attempts from IP '.$loginizer['current_ip'].' ('.$sitename.')';
801 + $mail['subject'] = 'Failed '.$fail_type.' Attempts from IP '.$loginizer['current_ip'].' ('.$sitename.')';
559 802 $mail['message'] = 'Hi,
560 803
561 -'.($result['count']+1).' failed login attempts and '.$lockout.' lockout(s) from IP '.$loginizer['current_ip'].'
804 +'.($result['count']+1).' failed '.strtolower($fail_type).' attempts and '.$lockout.' lockout(s) from IP '.$loginizer['current_ip'].' on your site :
805 +'.home_url().'
562 806
563 -Last Login Attempt : '.date('d/m/Y H:i:s', time()).'
807 +Last '.$fail_type.' Attempt : '.date('d/M/Y H:i:s P', time()).'
564 808 Last User Attempt : '.$username.'
565 -IP has been blocked until : '.date('d/m/Y H:i:s', time() + $loginizer['lockout_time']).'
809 +IP has been blocked until : '.date('d/M/Y H:i:s P', time() + $loginizer['lockout_time']).'
566 810
567 811 Regards,
568 812 Loginizer';
569 813
@@ -569,9 +813,21 @@
569 813
570 814 @wp_mail($mail['to'], $mail['subject'], $mail['message']);
571 815 }
572 816 }else{
573 - $insert = $wpdb->query("INSERT INTO `".$wpdb->prefix."loginizer_logs` SET `username` = '".$username."', `time` = '".time()."', `count` = '1', `ip` = '".$loginizer['current_ip']."', `lockout` = '0';");
817 + $result = array();
818 + $result['count'] = 0;
819 +
820 + $insert_data = array('username' => $username,
821 + 'time' => time(),
822 + 'count' => 1,
823 + 'ip' => $loginizer['current_ip'],
824 + 'lockout' => 0,
825 + 'url' => $url);
826 +
827 + $format = array('%s','%d','%d','%s','%d','%s');
828 +
829 + $wpdb->insert($wpdb->prefix.'loginizer_logs', $insert_data, $format);
574 830 }
575 831
576 832 // We need to add one as this is a failed attempt as well
577 833 $result['count'] = $result['count'] + 1;
@@ -605,9 +861,9 @@
605 861 }
606 862
607 863 // Add the error
608 864 if(!empty($lz_user_pass) && !empty($show_error) && empty($lz_cannot_login)){
609 - $errors->add('invalid_userpass', '<b>ERROR:</b> Incorrect Username or Password');
865 + $errors->add('invalid_userpass', '<b>ERROR:</b> ' . $loginizer['msg']['inv_userpass']);
610 866 }
611 867
612 868 // Add the number of retires left as well
613 869 if(count($errors->get_error_codes()) > 0 && isset($loginizer['retries_left'])){
@@ -617,8 +873,21 @@
617 873 return $errors;
618 874
619 875 }
620 876
877 +
878 +
879 +// Handles the error of the password not being there
880 +function loginizer_woocommerce_error_handler(){
881 +
882 + global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
883 +
884 + if(function_exists('wc_add_notice')){
885 + wc_add_notice( loginizer_retries_left(), 'error' );
886 + }
887 +
888 +}
889 +
621 890 // Returns a string with the number of retries left
622 891 function loginizer_retries_left(){
623 892
624 893 global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
@@ -624,9 +893,9 @@
624 893 global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
625 894
626 895 // If we are to show the number of retries left
627 896 if(isset($loginizer['retries_left'])){
628 - return '<b>'.$loginizer['retries_left'].'</b> attempt(s) left';
897 + return '<b>'.$loginizer['retries_left'].'</b> '.$loginizer['msg']['attempts_left'];
629 898 }
630 899
631 900 }
632 901
@@ -633,11 +902,13 @@
633 902 function loginizer_reset_retries(){
634 903
635 904 global $wpdb, $loginizer;
636 905
637 - $deltime = time() - $loginizer['reset_retries'];
638 - $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs` WHERE `time` <= '".$deltime."';");
906 + $deltime = time() - $loginizer['reset_retries'];
639 907
908 + $del_query = $wpdb->prepare("DELETE FROM `".$wpdb->prefix."loginizer_logs` WHERE `time` <= %d", $deltime);
909 + $result = $wpdb->query($del_query);
910 +
640 911 update_option('loginizer_last_reset', time());
641 912
642 913 }
643 914
@@ -662,38 +933,58 @@
662 933 function loginizer_admin_menu() {
663 934
664 935 global $wp_version, $loginizer;
665 936
666 - // Add the menu page
667 - add_menu_page(__('Loginizer Dashboard'), __('Loginizer Security'), 'activate_plugins', 'loginizer', 'loginizer_page_dashboard');
937 + if(!defined('SITEPAD')){
668 938
669 - // Dashboard
670 - add_submenu_page('loginizer', __('Loginizer Dashboard'), __('Dashboard'), 'activate_plugins', 'loginizer', 'loginizer_page_dashboard');
939 + // Add the menu page
940 + add_menu_page(__('Loginizer Dashboard', 'loginizer'), __('Loginizer Security', 'loginizer'), 'activate_plugins', 'loginizer', 'loginizer_page_dashboard');
671 941
942 + // Dashboard
943 + add_submenu_page('loginizer', __('Loginizer Dashboard', 'loginizer'), __('Dashboard', 'loginizer'), 'activate_plugins', 'loginizer', 'loginizer_page_dashboard');
944 +
945 + }else{
946 +
947 + // Add the menu page
948 + add_menu_page(__('Security', 'loginizer'), __('Security', 'loginizer'), 'activate_plugins', 'loginizer', 'loginizer_page_security', 'dashicons-shield', 85);
949 +
950 + // Rename Login
951 + add_submenu_page('loginizer', __('Security Settings', 'loginizer'), __('Rename Login', 'loginizer'), 'activate_plugins', 'loginizer', 'loginizer_page_security');
952 +
953 + }
954 +
672 955 // Brute Force
673 - add_submenu_page('loginizer', __('Loginizer Brute Force Settings'), __('Brute Force'), 'activate_plugins', 'loginizer_brute_force', 'loginizer_page_brute_force');
956 + add_submenu_page('loginizer', __('Brute Force Settings', 'loginizer'), __('Brute Force', 'loginizer'), 'activate_plugins', 'loginizer_brute_force', 'loginizer_page_brute_force');
674 957
675 - if(defined('LOGINIZER_PREMIUM')){
958 + // PasswordLess
959 + add_submenu_page('loginizer', __($loginizer['prefix'].'PasswordLess Settings', 'loginizer'), __('PasswordLess', 'loginizer'), 'activate_plugins', 'loginizer_passwordless', 'loginizer_page_passwordless');
676 960
677 - // PasswordLess
678 - add_submenu_page('loginizer', __('Loginizer PasswordLess Settings'), __('PasswordLess'), 'activate_plugins', 'loginizer_passwordless', 'loginizer_page_passwordless');
679 -
961 + // Security Settings
962 + if(!defined('SITEPAD')){
963 +
680 964 // Two Factor Auth
681 - add_submenu_page('loginizer', __('Loginizer Two Factor Authentication'), __('Two Factor Auth'), 'activate_plugins', 'loginizer_2fa', 'loginizer_page_2fa');
682 -
683 - // reCaptcha
684 - add_submenu_page('loginizer', __('Loginizer reCAPTCHA Settings'), __('reCAPTCHA'), 'activate_plugins', 'loginizer_recaptcha', 'loginizer_page_recaptcha');
685 -
965 + add_submenu_page('loginizer', __($loginizer['prefix'].' Two Factor Authentication', 'loginizer'), __('Two Factor Auth', 'loginizer'), 'activate_plugins', 'loginizer_2fa', 'loginizer_page_2fa');
966 +
967 + }
968 +
969 + // reCaptcha
970 + add_submenu_page('loginizer', __($loginizer['prefix'].'reCAPTCHA Settings', 'loginizer'), __('reCAPTCHA', 'loginizer'), 'activate_plugins', 'loginizer_recaptcha', 'loginizer_page_recaptcha');
971 +
972 + // Security Settings
973 + if(!defined('SITEPAD')){
974 +
686 975 // Security Settings
687 - add_submenu_page('loginizer', __('Loginizer Security Settings'), __('Security Settings'), 'activate_plugins', 'loginizer_security', 'loginizer_page_security');
976 + add_submenu_page('loginizer', __($loginizer['prefix'].'Security Settings', 'loginizer'), __('Security Settings', 'loginizer'), 'activate_plugins', 'loginizer_security', 'loginizer_page_security');
688 977
689 - // Security Settings
690 - add_submenu_page('loginizer', __('Loginizer File Checksums'), __('File Checksums'), 'activate_plugins', 'loginizer_checksums', 'loginizer_page_checksums');
978 + // File Checksums
979 + add_submenu_page('loginizer', __('Loginizer File Checksums', 'loginizer'), __('File Checksums', 'loginizer'), 'activate_plugins', 'loginizer_checksums', 'loginizer_page_checksums');
691 980
692 - }elseif(!defined('LOGINIZER_PREMIUM') && !empty($loginizer['ins_time']) && $loginizer['ins_time'] < (time() - (30*24*3600))){
981 + }
982 +
983 + if(!defined('LOGINIZER_PREMIUM') && !empty($loginizer['ins_time']) && $loginizer['ins_time'] < (time() - (30*24*3600))){
693 984
694 985 // Go Pro link
695 - add_submenu_page('loginizer', __('Loginizer Go Pro'), __('Go Pro'), 'activate_plugins', LOGINIZER_PRO_URL);
986 + add_submenu_page('loginizer', __('Loginizer Go Pro', 'loginizer'), __('Go Pro', 'loginizer'), 'activate_plugins', LOGINIZER_PRO_URL);
696 987
697 988 }
698 989
699 990 }
@@ -699,19 +990,10 @@
699 990 }
700 991
701 992 // The Loginizer Admin Options Page
702 993 function loginizer_page_header($title = 'Loginizer'){
703 - /*wp_enqueue_script('common');
704 - wp_enqueue_script('wp-lists');
705 - wp_enqueue_script('postbox');
706 - wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
707 994
708 - echo '
709 -<script>
710 -jQuery(document).ready( function() {
711 - //add_postbox_toggles("loginizer");
712 -});
713 -</script>';*/
995 + global $loginizer;
714 996
715 997 ?>
716 998 <style>
717 999 .lz-right-ul{
@@ -730,12 +1012,19 @@
730 1012 <div id="top-sortables" class="meta-box-sortables ui-sortable">
731 1013
732 1014 <table cellpadding="2" cellspacing="1" width="100%" class="fixed" border="0">
733 1015 <tr>
734 - <td valign="top"><h3>'.$title.'</h3></td>
735 - <td align="right"><a target="_blank" class="button button-primary" href="https://wordpress.org/support/view/plugin-reviews/loginizer">Review Loginizer</a></td>
1016 + <td valign="top"><h3>'.$loginizer['prefix'].$title.'</h3></td>';
1017 +
1018 + if(!defined('SITEPAD')){
1019 +
1020 + echo '<td align="right"><a target="_blank" class="button button-primary" href="https://wordpress.org/support/view/plugin-reviews/loginizer">'.__('Review Loginizer', 'loginizer').'</a></td>
736 1021 <td align="right" width="40"><a target="_blank" href="https://twitter.com/loginizer"><img src="'.LOGINIZER_URL.'/twitter.png" /></a></td>
737 - <td align="right" width="40"><a target="_blank" href="https://www.facebook.com/Loginizer-815504798591884"><img src="'.LOGINIZER_URL.'/facebook.png" /></a></td>
1022 + <td align="right" width="40"><a target="_blank" href="https://www.facebook.com/Loginizer-815504798591884"><img src="'.LOGINIZER_URL.'/facebook.png" /></a></td>';
1023 +
1024 + }
1025 +
1026 + echo '
738 1027 </tr>
739 1028 </table>
740 1029 <hr />
741 1030
@@ -748,18 +1037,31 @@
748 1037
749 1038 // The Loginizer Theme footer
750 1039 function loginizer_page_footer(){
751 1040
1041 + if(!loginizer_is_premium()){
1042 + echo '<script>
1043 + jQuery("[loginizer-premium-only]").each(function(index) {
1044 + jQuery(this).find( "input, textarea, select" ).attr("disabled", true);
1045 + });
1046 + </script>';
1047 + }
1048 +
752 1049 echo '</td>
753 1050 <td width="200" valign="top" id="loginizer-right-bar">';
1051 +
1052 + if(!defined('SITEPAD')){
754 1053
755 - if(!defined('LOGINIZER_PREMIUM')){
1054 + if(!defined('LOGINIZER_PREMIUM')){
756 1055
757 - echo '
1056 + echo '
758 1057 <div class="postbox" style="min-width:0px !important;">
759 - <h2 class="hndle ui-sortable-handle">
760 - <span>Premium Version</span>
761 - </h2>
1058 + <div class="postbox-header">
1059 + <h2 class="hndle ui-sortable-handle">
1060 + <span>Premium Version</span>
1061 + </h2>
1062 + </div>
1063 +
762 1064 <div class="inside">
763 1065 <i>Upgrade to the premium version and get the following features </i>:<br>
764 1066 <ul class="lz-right-ul">
765 1067 <li>PasswordLess Login</li>
@@ -770,19 +1072,21 @@
770 1072 <li>Rename Login Page</li>
771 1073 <li>Disable XML-RPC</li>
772 1074 <li>And many more ...</li>
773 1075 </ul>
774 - <center><a class="button button-primary" href="https://loginizer.com/members/cart.php">Upgrade</a></center>
1076 + <center><a class="button button-primary" target="_blank" href="'.LOGINIZER_PRICING_URL.'">Upgrade</a></center>
775 1077 </div>
776 1078 </div>';
777 1079
778 - }else{
1080 + }else{
779 1081
780 - echo '
1082 + echo '
781 1083 <div class="postbox" style="min-width:0px !important;">
1084 + <div class="postbox-header">
782 1085 <h2 class="hndle ui-sortable-handle">
783 1086 <span>Recommendations</span>
784 1087 </h2>
1088 + </div>
785 1089 <div class="inside">
786 1090 <i>We recommed that you enable atleast one of the following security features</i>:<br>
787 1091 <ul class="lz-right-ul">
788 1092 <li>Rename Login Page</li>
@@ -793,17 +1097,69 @@
793 1097 <li>Change \'admin\' Username</li>
794 1098 </ul>
795 1099 </div>
796 1100 </div>';
1101 + }
1102 +
1103 + echo '
1104 + <div class="postbox" style="min-width:0px !important;">
1105 + <div class="postbox-header">
1106 + <h2 class="hndle ui-sortable-handle">
1107 + <span><a target="_blank" href="https://pagelayer.com/?from=loginizer-plugin"><img src="'.LOGINIZER_URL.'/images/pagelayer_product.png" width="100%" /></a></span>
1108 + </h2>
1109 + </div>
1110 + <div class="inside">
1111 + <i>Easily manage and make professional pages and content with our Pagelayer builder </i>:<br>
1112 + <ul class="lz-right-ul">
1113 + <li>30+ Free Widgets</li>
1114 + <li>60+ Premium Widgets</li>
1115 + <li>400+ Premium Sections</li>
1116 + <li>Theme Builder</li>
1117 + <li>WooCommerce Builder</li>
1118 + <li>Theme Creator and Exporter</li>
1119 + <li>Form Builder</li>
1120 + <li>Popup Builder</li>
1121 + <li>And many more ...</li>
1122 + </ul>
1123 + <center><a class="button button-primary" target="_blank" href="https://wordpress.org/plugins/pagelayer/">Visit Pagelayer</a></center>
1124 + </div>
1125 + </div>';
1126 +
1127 + echo '
1128 + <div class="postbox" style="min-width:0px !important;">
1129 + <div class="postbox-header">
1130 + <h2 class="hndle ui-sortable-handle">
1131 + <span><a target="_blank" href="https://wpcentral.co/?from=loginizer-plugin"><img src="'.LOGINIZER_URL.'/images/wpcentral_product.png" width="100%" /></a></span>
1132 + </h2>
1133 + </div>
1134 + <div class="inside">
1135 + <i>Manage all your WordPress sites from <b>1 dashboard</b> </i>:<br>
1136 + <ul class="lz-right-ul">
1137 + <li>1-click Admin Access</li>
1138 + <li>Update WordPress</li>
1139 + <li>Update Themes</li>
1140 + <li>Update Plugins</li>
1141 + <li>Backup your WordPress Site</li>
1142 + <li>Plugins & Theme Management</li>
1143 + <li>Post Management</li>
1144 + <li>And many more ...</li>
1145 + </ul>
1146 + <center><a class="button button-primary" target="_blank" href="https://wpcentral.co/?from=loginizer-plugin">Visit wpCentral</a></center>
1147 + </div>
1148 + </div>';
1149 +
797 1150 }
798 1151
799 1152 echo '</td>
800 1153 </tr>
801 - </table>
802 - <br />
1154 + </table>';
1155 +
1156 + if(!defined('SITEPAD')){
1157 +
1158 + echo '<br />
803 1159 <div style="width:45%;background:#FFF;padding:15px; margin:auto">
804 1160 <b>Let your friends know that you have secured your website :</b>
805 - <form method="get" action="http://twitter.com/intent/tweet" id="tweet" onsubmit="return dotweet(this);">
1161 + <form method="get" action="https://twitter.com/intent/tweet" id="tweet" onsubmit="return dotweet(this);">
806 1162 <textarea name="text" cols="45" row="3" style="resize:none;">I just secured my @WordPress site against #bruteforce using @loginizer</textarea>
807 1163 &nbsp; &nbsp; <input type="submit" value="Tweet!" class="button button-primary" onsubmit="return false;" id="twitter-btn" style="margin-top:20px;"/>
808 1164 </form>
809 1165
@@ -817,10 +1173,13 @@
817 1173 }
818 1174 </script>
819 1175
820 1176 <hr />
821 - <a href="http://loginizer.com" target="_blank">Loginizer</a> v'.LOGINIZER_VERSION.'. You can report any bugs <a href="http://wordpress.org/support/plugin/loginizer" target="_blank">here</a>.
822 -
1177 + <a href="http://loginizer.com" target="_blank">Loginizer</a> v'.LOGINIZER_VERSION.'. You can report any bugs <a href="http://wordpress.org/support/plugin/loginizer" target="_blank">here</a>.';
1178 +
1179 + }
1180 +
1181 + echo '
823 1182 </div>
824 1183 </div>
825 1184 </div>
826 1185 </div>';
@@ -830,53 +1189,40 @@
830 1189 // The Loginizer Admin Options Page
831 1190 function loginizer_page_dashboard(){
832 1191
833 1192 global $loginizer, $lz_error, $lz_env;
1193 +
1194 + if(!current_user_can('manage_options')){
1195 + wp_die('Sorry, but you do not have permissions to change settings.');
1196 + }
1197 +
1198 + // Dismiss the announcement
1199 + if(isset($_GET['dismiss_announcement'])){
1200 + update_option('loginizer_no_announcement', 1);
1201 + }
834 1202
835 - // Is there a license key ?
836 - if(isset($_POST['save_lz'])){
837 -
838 - $license = lz_optpost('lz_license');
839 -
840 - // Check if its a valid license
841 - if(empty($license)){
842 - $lz_error['lic_invalid'] = __('The license key was not submitted', 'loginizer');
843 - return loginizer_page_dashboard_T();
844 - }
845 -
846 - $resp = wp_remote_get(LOGINIZER_API.'license.php?license='.$license);
847 -
848 - if(is_array($resp)){
849 - $json = json_decode($resp['body'], true);
850 - //print_r($json);
851 - }
852 -
853 - // Save the License
854 - if(empty($json)){
855 -
856 - $lz_error['lic_invalid'] = __('The license key is invalid', 'loginizer');
857 - return loginizer_page_dashboard_T();
858 -
859 - }else{
860 -
861 - update_option('loginizer_license', $json);
862 -
863 - // Mark as saved
864 - $GLOBALS['lz_saved'] = true;
865 - }
866 -
1203 + /* Make sure post was from this page */
1204 + if(count($_POST) > 0){
1205 + check_admin_referer('loginizer-options');
867 1206 }
868 1207
1208 + do_action('loginizer_pre_page_dashboard');
869 1209
870 1210 // Is there a IP Method ?
871 1211 if(isset($_POST['save_lz_ip_method'])){
872 1212
873 1213 $ip_method = (int) lz_optpost('lz_ip_method');
1214 + $custom_ip_method = lz_optpost('lz_custom_ip_method');
874 1215
875 - if($ip_method >= 0 && $ip_method <= 2){
1216 + if($ip_method >= 0 && $ip_method <= 3){
876 1217 update_option('loginizer_ip_method', $ip_method);
877 1218 }
878 1219
1220 + // Custom Method name ?
1221 + if($ip_method == 3){
1222 + update_option('loginizer_custom_ip_method', $custom_ip_method);
1223 + }
1224 +
879 1225 }
880 1226
881 1227 loginizer_page_dashboard_T();
882 1228
@@ -886,9 +1232,9 @@
886 1232 function loginizer_page_dashboard_T(){
887 1233
888 1234 global $loginizer, $lz_error, $lz_env;
889 1235
890 - loginizer_page_header('Loginizer Dashboard');
1236 + loginizer_page_header('Dashboard');
891 1237 ?>
892 1238 <style>
893 1239 .welcome-panel{
894 1240 margin: 0px;
@@ -907,10 +1253,18 @@
907 1253 font-size:12px;
908 1254 }
909 1255 </style>
910 1256
911 - <?php
912 - echo '<script src="https://api.loginizer.com/'.(defined('LOGINIZER_PREMIUM') ? 'news_security.js' : 'news.js').'"></script><br>';
1257 + <?php
1258 +
1259 + loginizer_newsletter_subscribe();
1260 +
1261 + $hide_announcement = get_option('loginizer_no_announcement');
1262 + if(empty($hide_announcement)){
1263 + echo '<div id="message" class="welcome-panel">'. __('<a href="https://loginizer.com/blog/loginizer-has-been-acquired-by-softaculous/" target="_blank" style="text-decoration:none;">We are excited to announce that we have joined forces with Softaculous and have been acquired by them 😊. Read full announcement here.</a>', 'loginizer'). '<a class="welcome-panel-close" style="top:3px;right:2px;" href="'.menu_page_url('loginizer', false).'&dismiss_announcement=1" aria-label="Dismiss announcement"></a></div><br />';
1264 + }
1265 +
1266 + echo '<div class="welcome-panel">Thank you for choosing Loginizer! Many more features coming soon... &nbsp; Review Loginizer at WordPress &nbsp; &nbsp; <a href="https://wordpress.org/support/view/plugin-reviews/loginizer" class="button button-primary" target="_blank">Add Review</a></div><br />';
913 1267
914 1268 // Saved ?
915 1269 if(!empty($GLOBALS['lz_saved'])){
916 1270 echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
@@ -923,17 +1277,14 @@
923 1277
924 1278 ?>
925 1279
926 1280 <div class="postbox">
927 -
928 - <button class="handlediv button-link" aria-expanded="true" type="button">
929 - <span class="screen-reader-text">Toggle panel: Getting Started</span>
930 - <span class="toggle-indicator" aria-hidden="true"></span>
931 - </button>
932 1281
1282 + <div class="postbox-header">
933 1283 <h2 class="hndle ui-sortable-handle">
934 1284 <span><?php echo __('Getting Started', 'loginizer'); ?></span>
935 1285 </h2>
1286 + </div>
936 1287
937 1288 <div class="inside">
938 1289
939 1290 <form action="" method="post" enctype="multipart/form-data">
@@ -944,9 +1295,11 @@
944 1295 <i>Welcome to Loginizer Security. By default the <b>Brute Force Protection</b> is immediately enabled. You should start by going over the default settings and tweaking them as per your needs.</i>
945 1296 <?php
946 1297 if(defined('LOGINIZER_PREMIUM')){
947 1298 echo '<br><i>In the Premium version of Loginizer you have many more features. We recommend you enable features like <b>reCAPTCHA, Two Factor Auth or Email based PasswordLess</b> login. These features will improve your websites security.</i>';
948 - }
1299 + }else{
1300 + echo '<br><i><a href="'.LOGINIZER_PRICING_URL.'" target="_blank" style="text-decoration:none;color:red;">Upgrade to Pro</a> for more features like <b>reCAPTCHA, Two Factor Auth, Rename wp-admin and wp-login.php pages, Email based PasswordLess</b> login and more. These features will improve your website\'s security.</i>';
1301 + }
949 1302 ?>
950 1303 </td>
951 1304 </tr>
952 1305 </table>
@@ -956,17 +1309,13 @@
956 1309 </div>
957 1310
958 1311 <div class="postbox">
959 1312
960 - <button class="handlediv button-link" aria-expanded="true" type="button">
961 - <span class="screen-reader-text">Toggle panel: System Information</span>
962 - <span class="toggle-indicator" aria-hidden="true"></span>
963 - </button>
964 -
1313 + <div class="postbox-header">
965 1314 <h2 class="hndle ui-sortable-handle">
966 1315 <span><?php echo __('System Information', 'loginizer'); ?></span>
967 1316 </h2>
968 -
1317 + </div>
969 1318 <div class="inside">
970 1319
971 1320 <form action="" method="post" enctype="multipart/form-data">
972 1321 <?php wp_nonce_field('loginizer-options'); ?>
@@ -974,35 +1323,12 @@
974 1323 <?php
975 1324 echo '
976 1325 <tr>
977 1326 <th align="left" width="25%">'.__('Loginizer Version', 'loginizer').'</th>
978 - <td>'.LOGINIZER_VERSION.(defined('LOGINIZER_PREMIUM') ? ' (Security PRO Version)' : '').'</td>
1327 + <td>'.LOGINIZER_VERSION.(defined('LOGINIZER_PREMIUM') ? ' (<font color="green">Security PRO Version</font>)' : '').'</td>
979 1328 </tr>';
980 1329
981 - if(defined('LOGINIZER_PREMIUM')){
982 - echo '
983 - <tr>
984 - <th align="left" valign="top">'.__('Loginizer License', 'loginizer').'</th>
985 - <td align="left">
986 - '.(empty($loginizer['license']) ? '<span style="color:red">Unlicensed</span> &nbsp; &nbsp;' : '').'
987 - <input type="text" name="lz_license" value="'.(empty($loginizer['license']) ? '' : $loginizer['license']['license']).'" size="30" placeholder="e.g. WXCSE-SFJJX-XXXXX-AAAAA-BBBBB" style="width:300px;" /> &nbsp;
988 - <input name="save_lz" class="button button-primary" value="Update License" type="submit" />';
989 -
990 - if(!empty($loginizer['license'])){
991 -
992 - $expires = $loginizer['license']['expires'];
993 - $expires = substr($expires, 0, 4).'/'.substr($expires, 4, 2).'/'.substr($expires, 6);
994 -
995 - echo '<div style="margin-top:10px;">License Active : '.(empty($loginizer['license']['active']) ? '<span style="color:red">No</span>' : 'Yes').' &nbsp; &nbsp; &nbsp;
996 - License Expires : '.($loginizer['license']['expires'] <= date('Ymd') ? '<span style="color:red">'.$expires.'</span>' : $expires).'
997 - </div>';
998 - }
999 -
1000 -
1001 - echo
1002 - '</td>
1003 - </tr>';
1004 - }
1330 + do_action('loginizer_system_information');
1005 1331
1006 1332 echo '<tr>
1007 1333 <th align="left">'.__('URL', 'loginizer').'</th>
1008 1334 <td>'.get_site_url().'</td>
@@ -1012,9 +1338,9 @@
1012 1338 <td>'.ABSPATH.'</td>
1013 1339 </tr>
1014 1340 <tr>
1015 1341 <th align="left">'.__('Server\'s IP Address', 'loginizer').'</th>
1016 - <td>'.$_SERVER['SERVER_ADDR'].'</td>
1342 + <td>'.@$_SERVER['SERVER_ADDR'].'</td>
1017 1343 </tr>
1018 1344 <tr>
1019 1345 <th align="left">'.__('Your IP Address', 'loginizer').'</th>
1020 1346 <td>'.lz_getip().'
@@ -1019,13 +1345,15 @@
1019 1345 <th align="left">'.__('Your IP Address', 'loginizer').'</th>
1020 1346 <td>'.lz_getip().'
1021 1347 <div style="float:right">
1022 1348 Method :
1023 - <select name="lz_ip_method" style="font-size:11px; width:150px">
1349 + <select name="lz_ip_method" id="lz_ip_method" style="font-size:11px; width:150px" onchange="lz_ip_method_handle()">
1024 1350 <option value="0" '.lz_POSTselect('lz_ip_method', 0, (@$loginizer['ip_method'] == 0)).'>REMOTE_ADDR</option>
1025 1351 <option value="1" '.lz_POSTselect('lz_ip_method', 1, (@$loginizer['ip_method'] == 1)).'>HTTP_X_FORWARDED_FOR</option>
1026 1352 <option value="2" '.lz_POSTselect('lz_ip_method', 2, (@$loginizer['ip_method'] == 2)).'>HTTP_CLIENT_IP</option>
1353 + <option value="3" '.lz_POSTselect('lz_ip_method', 3, (@$loginizer['ip_method'] == 3)).'>CUSTOM</option>
1027 1354 </select>
1355 + <input name="lz_custom_ip_method" id="lz_custom_ip_method" type="text" value="'.lz_optpost('lz_custom_ip_method', @$loginizer['custom_ip_method']).'" style="font-size:11px; width:100px; display:none" />
1028 1356 <input name="save_lz_ip_method" class="button button-primary" value="Save" type="submit" />
1029 1357 </div>
1030 1358 </td>
1031 1359 </tr>
@@ -1048,19 +1376,31 @@
1048 1376 </form>
1049 1377
1050 1378 </div>
1051 1379 </div>
1380 +
1381 +<script type="text/javascript">
1382 +
1383 +function lz_ip_method_handle(){
1384 + var ele = jQuery('#lz_ip_method');
1385 + if(ele.val() == 3){
1386 + jQuery('#lz_custom_ip_method').show();
1387 + }else{
1388 + jQuery('#lz_custom_ip_method').hide();
1389 + }
1390 +};
1391 +
1392 +lz_ip_method_handle();
1393 +
1394 +</script>
1052 1395
1053 1396 <div id="" class="postbox">
1054 1397
1055 - <button class="handlediv button-link" aria-expanded="true" type="button">
1056 - <span class="screen-reader-text">Toggle panel: File Permissions</span>
1057 - <span class="toggle-indicator" aria-hidden="true"></span>
1058 - </button>
1059 -
1398 + <div class="postbox-header">
1060 1399 <h2 class="hndle ui-sortable-handle">
1061 1400 <span><?php echo __('File Permissions', 'loginizer'); ?></span>
1062 1401 </h2>
1402 + </div>
1063 1403
1064 1404 <div class="inside">
1065 1405
1066 1406 <form action="" method="post" enctype="multipart/form-data">
@@ -1076,16 +1416,16 @@
1076 1416 </tr>';
1077 1417
1078 1418 $wp_content = basename(dirname(dirname(dirname(__FILE__))));
1079 1419
1080 - $files_to_check = array('/' => '0755',
1081 - '/wp-admin' => '0755',
1082 - '/wp-includes' => '0755',
1083 - '/wp-config.php' => '0444',
1084 - '/'.$wp_content => '0755',
1085 - '/'.$wp_content.'/themes' => '0755',
1086 - '/'.$wp_content.'/plugins' => '0755',
1087 - '.htaccess' => '0444');
1420 + $files_to_check = array('/' => array('0755', '0750'),
1421 + '/wp-admin' => array('0755'),
1422 + '/wp-includes' => array('0755'),
1423 + '/wp-config.php' => array('0444'),
1424 + '/'.$wp_content => array('0755'),
1425 + '/'.$wp_content.'/themes' => array('0755'),
1426 + '/'.$wp_content.'/plugins' => array('0755'),
1427 + '.htaccess' => array('0444'));
1088 1428
1089 1429 $root = ABSPATH;
1090 1430
1091 1431 foreach($files_to_check as $k => $v){
@@ -1097,10 +1437,10 @@
1097 1437
1098 1438 echo '
1099 1439 <tr>
1100 1440 <td>'.$k.'</td>
1101 - <td>'.$suggested.'</td>
1102 - <td><span '.($suggested != $actual ? 'style="color: red;"' : '').'>'.$actual.'</span></td>
1441 + <td>'.current($suggested).'</td>
1442 + <td><span '.(!in_array($actual, $suggested) ? 'style="color: red;"' : '').'>'.$actual.'</span></td>
1103 1443 </tr>';
1104 1444
1105 1445 }
1106 1446
@@ -1131,14 +1471,43 @@
1131 1471 check_admin_referer('loginizer-options');
1132 1472 }
1133 1473
1134 1474 // BEGIN THEME
1135 - loginizer_page_header('Loginizer - Brute Force Settings');
1475 + loginizer_page_header('Brute Force Settings');
1136 1476
1137 1477 // Load the blacklist and whitelist
1138 1478 $loginizer['blacklist'] = get_option('loginizer_blacklist');
1139 1479 $loginizer['whitelist'] = get_option('loginizer_whitelist');
1140 1480
1481 + // Disable Brute Force
1482 + if(isset($_POST['disable_brute_lz'])){
1483 +
1484 + // Save the options
1485 + update_option('loginizer_disable_brute', 1);
1486 +
1487 + $loginizer['disable_brute'] = 1;
1488 +
1489 + echo '<div id="message" class="updated"><p>'
1490 + . __('The Brute Force Protection feature is now disabled', 'loginizer')
1491 + . '</p></div><br />';
1492 +
1493 + }
1494 +
1495 + // Enable brute force
1496 + if(isset($_POST['enable_brute_lz'])){
1497 +
1498 + // Save the options
1499 + update_option('loginizer_disable_brute', 0);
1500 +
1501 + $loginizer['disable_brute'] = 0;
1502 +
1503 + echo '<div id="message" class="updated"><p>'
1504 + . __('The Brute Force Protection feature is now enabled', 'loginizer')
1505 + . '</p></div><br />';
1506 +
1507 + }
1508 +
1509 + // The Brute Force Settings
1141 1510 if(isset($_POST['save_lz'])){
1142 1511
1143 1512 $max_retries = (int) lz_optpost('max_retries');
1144 1513 $lockout_time = (int) lz_optpost('lockout_time');
@@ -1181,9 +1550,9 @@
1181 1550
1182 1551 }
1183 1552
1184 1553 // Delete a Blackist IP range
1185 - if(isset($_GET['bdelid'])){
1554 + if(isset($_POST['bdelid'])){
1186 1555
1187 1556 $delid = (int) lz_optreq('bdelid');
1188 1557
1189 1558 // Unset and save
@@ -1196,10 +1565,22 @@
1196 1565 . '</p></div><br />';
1197 1566
1198 1567 }
1199 1568
1569 + // Delete all Blackist IP ranges
1570 + if(isset($_POST['del_all_blacklist'])){
1571 +
1572 + // Unset and save
1573 + update_option('loginizer_blacklist', array());
1574 +
1575 + echo '<div id="message" class="updated fade"><p>'
1576 + . __('The Blacklist IP range(s) have been cleared successfully', 'loginizer')
1577 + . '</p></div><br />';
1578 +
1579 + }
1580 +
1200 1581 // Delete a Whitelist IP range
1201 - if(isset($_GET['delid'])){
1582 + if(isset($_POST['delid'])){
1202 1583
1203 1584 $delid = (int) lz_optreq('delid');
1204 1585
1205 1586 // Unset and save
@@ -1212,14 +1593,25 @@
1212 1593 . '</p></div><br />';
1213 1594
1214 1595 }
1215 1596
1597 + // Delete all Blackist IP ranges
1598 + if(isset($_POST['del_all_whitelist'])){
1599 +
1600 + // Unset and save
1601 + update_option('loginizer_whitelist', array());
1602 +
1603 + echo '<div id="message" class="updated fade"><p>'
1604 + . __('The Whitelist IP range(s) have been cleared successfully', 'loginizer')
1605 + . '</p></div><br />';
1606 +
1607 + }
1608 +
1216 1609 // Reset All Logs
1217 1610 if(isset($_POST['lz_reset_all_ip'])){
1218 1611
1219 - $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs`
1220 - WHERE `time` > 0");
1221 -
1612 + $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs` WHERE `time` > 0");
1613 +
1222 1614 echo '<div id="message" class="updated fade"><p>'
1223 1615 . __('All the IP Logs have been cleared', 'loginizer')
1224 1616 . '</p></div><br />';
1225 1617 }
@@ -1230,22 +1622,23 @@
1230 1622 $ips = $_POST['lz_reset_ips'];
1231 1623
1232 1624 foreach($ips as $ip){
1233 1625 if(!lz_valid_ip($ip)){
1234 - $error[] = 'The IP - '.$ip.' is invalid !';
1626 + $error[] = 'The IP - '.esc_html($ip).' is invalid !';
1235 1627 }
1236 1628 }
1237 1629
1238 1630 if(count($ips) < 1){
1239 - $error[] = 'There are no IPs submitted';
1631 + $error[] = __('There are no IPs submitted', 'loginizer');
1240 1632 }
1241 1633
1242 1634 // Should we start deleting logs
1243 1635 if(empty($error)){
1244 1636
1245 - $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs`
1246 - WHERE `ip` IN ('".implode("', '", $ips)."')");
1247 -
1637 + foreach($ips as $ip){
1638 + $result = $wpdb->query($wpdb->prepare("DELETE FROM `".$wpdb->prefix."loginizer_logs` WHERE `ip` = %s", $ip));
1639 + }
1640 +
1248 1641 if(empty($error)){
1249 1642
1250 1643 echo '<div id="message" class="updated fade"><p>'
1251 1644 . __('The selected IP Logs have been reset', 'loginizer')
@@ -1266,9 +1659,9 @@
1266 1659 $start_ip = lz_optpost('start_ip');
1267 1660 $end_ip = lz_optpost('end_ip');
1268 1661
1269 1662 if(empty($start_ip)){
1270 - $error[] = 'Please enter the Start IP';
1663 + $error[] = __('Please enter the Start IP', 'loginizer');
1271 1664 }
1272 1665
1273 1666 // If no end IP we consider only 1 IP
1274 1667 if(empty($end_ip)){
@@ -1275,23 +1668,23 @@
1275 1668 $end_ip = $start_ip;
1276 1669 }
1277 1670
1278 1671 if(!lz_valid_ip($start_ip)){
1279 - $error[] = 'Please provide a valid start IP';
1672 + $error[] = __('Please provide a valid start IP', 'loginizer');
1280 1673 }
1281 1674
1282 1675 if(!lz_valid_ip($end_ip)){
1283 - $error[] = 'Please provide a valid end IP';
1676 + $error[] = __('Please provide a valid end IP', 'loginizer');
1284 1677 }
1285 1678
1286 1679 // Regular ranges will work
1287 - if(ip2long($start_ip) > ip2long($end_ip)){
1680 + if(inet_ptoi($start_ip) > inet_ptoi($end_ip)){
1288 1681
1289 1682 // BUT, if 0.0.0.1 - 255.255.255.255 is given, it will not work
1290 - if(ip2long($start_ip) >= 0 && ip2long($end_ip) < 0){
1683 + if(inet_ptoi($start_ip) >= 0 && inet_ptoi($end_ip) < 0){
1291 1684 // This is right
1292 1685 }else{
1293 - $error[] = 'The End IP cannot be smaller than the Start IP';
1686 + $error[] = __('The End IP cannot be smaller than the Start IP', 'loginizer');
1294 1687 }
1295 1688
1296 1689 }
1297 1690
@@ -1301,24 +1694,24 @@
1301 1694
1302 1695 foreach($blacklist as $k => $v){
1303 1696
1304 1697 // This is to check if there is any other range exists with the same Start or End IP
1305 - if(( ip2long($start_ip) <= ip2long($v['start']) && ip2long($v['start']) <= ip2long($end_ip) )
1306 - || ( ip2long($start_ip) <= ip2long($v['end']) && ip2long($v['end']) <= ip2long($end_ip) )
1698 + if(( inet_ptoi($start_ip) <= inet_ptoi($v['start']) && inet_ptoi($v['start']) <= inet_ptoi($end_ip) )
1699 + || ( inet_ptoi($start_ip) <= inet_ptoi($v['end']) && inet_ptoi($v['end']) <= inet_ptoi($end_ip) )
1307 1700 ){
1308 - $error[] = 'The Start IP or End IP submitted conflicts with an existing IP range !';
1701 + $error[] = __('The Start IP or End IP submitted conflicts with an existing IP range !', 'loginizer');
1309 1702 break;
1310 1703 }
1311 1704
1312 1705 // This is to check if there is any other range exists with the same Start IP
1313 - if(ip2long($v['start']) <= ip2long($start_ip) && ip2long($start_ip) <= ip2long($v['end'])){
1314 - $error[] = 'The Start IP is present in an existing range !';
1706 + if(inet_ptoi($v['start']) <= inet_ptoi($start_ip) && inet_ptoi($start_ip) <= inet_ptoi($v['end'])){
1707 + $error[] = __('The Start IP is present in an existing range !', 'loginizer');
1315 1708 break;
1316 1709 }
1317 1710
1318 1711 // This is to check if there is any other range exists with the same End IP
1319 - if(ip2long($v['start']) <= ip2long($end_ip) && ip2long($end_ip) <= ip2long($v['end'])){
1320 - $error[] = 'The End IP is present in an existing range!';
1712 + if(inet_ptoi($v['start']) <= inet_ptoi($end_ip) && inet_ptoi($end_ip) <= inet_ptoi($v['end'])){
1713 + $error[] = __('The End IP is present in an existing range!', 'loginizer');
1321 1714 break;
1322 1715 }
1323 1716
1324 1717 }
@@ -1353,9 +1746,9 @@
1353 1746 $start_ip = lz_optpost('start_ip_w');
1354 1747 $end_ip = lz_optpost('end_ip_w');
1355 1748
1356 1749 if(empty($start_ip)){
1357 - $error[] = 'Please enter the Start IP';
1750 + $error[] = __('Please enter the Start IP', 'loginizer');
1358 1751 }
1359 1752
1360 1753 // If no end IP we consider only 1 IP
1361 1754 if(empty($end_ip)){
@@ -1362,22 +1755,22 @@
1362 1755 $end_ip = $start_ip;
1363 1756 }
1364 1757
1365 1758 if(!lz_valid_ip($start_ip)){
1366 - $error[] = 'Please provide a valid start IP';
1759 + $error[] = __('Please provide a valid start IP', 'loginizer');
1367 1760 }
1368 1761
1369 1762 if(!lz_valid_ip($end_ip)){
1370 - $error[] = 'Please provide a valid end IP';
1763 + $error[] = __('Please provide a valid end IP', 'loginizer');
1371 1764 }
1372 1765
1373 - if(ip2long($start_ip) > ip2long($end_ip)){
1766 + if(inet_ptoi($start_ip) > inet_ptoi($end_ip)){
1374 1767
1375 1768 // BUT, if 0.0.0.1 - 255.255.255.255 is given, it will not work
1376 - if(ip2long($start_ip) >= 0 && ip2long($end_ip) < 0){
1769 + if(inet_ptoi($start_ip) >= 0 && inet_ptoi($end_ip) < 0){
1377 1770 // This is right
1378 1771 }else{
1379 - $error[] = 'The End IP cannot be smaller than the Start IP';
1772 + $error[] = __('The End IP cannot be smaller than the Start IP', 'loginizer');
1380 1773 }
1381 1774
1382 1775 }
1383 1776
@@ -1387,24 +1780,24 @@
1387 1780
1388 1781 foreach($whitelist as $k => $v){
1389 1782
1390 1783 // This is to check if there is any other range exists with the same Start or End IP
1391 - if(( ip2long($start_ip) <= ip2long($v['start']) && ip2long($v['start']) <= ip2long($end_ip) )
1392 - || ( ip2long($start_ip) <= ip2long($v['end']) && ip2long($v['end']) <= ip2long($end_ip) )
1784 + if(( inet_ptoi($start_ip) <= inet_ptoi($v['start']) && inet_ptoi($v['start']) <= inet_ptoi($end_ip) )
1785 + || ( inet_ptoi($start_ip) <= inet_ptoi($v['end']) && inet_ptoi($v['end']) <= inet_ptoi($end_ip) )
1393 1786 ){
1394 - $error[] = 'The Start IP or End IP submitted conflicts with an existing IP range !';
1787 + $error[] = __('The Start IP or End IP submitted conflicts with an existing IP range !', 'loginizer');
1395 1788 break;
1396 1789 }
1397 1790
1398 1791 // This is to check if there is any other range exists with the same Start IP
1399 - if(ip2long($v['start']) <= ip2long($start_ip) && ip2long($start_ip) <= ip2long($v['end'])){
1400 - $error[] = 'The Start IP is present in an existing range !';
1792 + if(inet_ptoi($v['start']) <= inet_ptoi($start_ip) && inet_ptoi($start_ip) <= inet_ptoi($v['end'])){
1793 + $error[] = __('The Start IP is present in an existing range !', 'loginizer');
1401 1794 break;
1402 1795 }
1403 1796
1404 1797 // This is to check if there is any other range exists with the same End IP
1405 - if(ip2long($v['start']) <= ip2long($end_ip) && ip2long($end_ip) <= ip2long($v['end'])){
1406 - $error[] = 'The End IP is present in an existing range!';
1798 + if(inet_ptoi($v['start']) <= inet_ptoi($end_ip) && inet_ptoi($end_ip) <= inet_ptoi($v['end'])){
1799 + $error[] = __('The End IP is present in an existing range!', 'loginizer');
1407 1800 break;
1408 1801 }
1409 1802
1410 1803 }
@@ -1431,9 +1824,28 @@
1431 1824 if(!empty($error)){
1432 1825 lz_report_error($error);echo '<br />';
1433 1826 }
1434 1827 }
1435 -
1828 +
1829 + // Save the messages
1830 + if(isset($_POST['save_err_msgs_lz'])){
1831 +
1832 + $msgs['inv_userpass'] = lz_optpost('msg_inv_userpass');
1833 + $msgs['ip_blacklisted'] = lz_optpost('msg_ip_blacklisted');
1834 + $msgs['attempts_left'] = lz_optpost('msg_attempts_left');
1835 + $msgs['lockout_err'] = lz_optpost('msg_lockout_err');
1836 + $msgs['minutes_err'] = lz_optpost('msg_minutes_err');
1837 + $msgs['hours_err'] = lz_optpost('msg_hours_err');
1838 +
1839 + // Update them
1840 + update_option('loginizer_msg', $msgs);
1841 +
1842 + echo '<div id="message" class="updated fade"><p>'
1843 + . __('Error messages were saved successfully', 'loginizer')
1844 + . '</p></div><br />';
1845 +
1846 + }
1847 +
1436 1848 // Count the Results
1437 1849 $tmp = lz_selectquery("SELECT COUNT(*) AS num FROM `".$wpdb->prefix."loginizer_logs`");
1438 1850 //print_r($tmp);
1439 1851
@@ -1457,20 +1869,19 @@
1457 1869 // Reload the settings
1458 1870 $loginizer['blacklist'] = get_option('loginizer_blacklist');
1459 1871 $loginizer['whitelist'] = get_option('loginizer_whitelist');
1460 1872
1873 + $saved_msgs = get_option('loginizer_msg');
1874 +
1461 1875 ?>
1462 1876
1463 1877 <div id="" class="postbox">
1464 1878
1465 - <button class="handlediv button-link" aria-expanded="true" type="button">
1466 - <span class="screen-reader-text">Toggle panel: Failed Login Attempts Logs</span>
1467 - <span class="toggle-indicator" aria-hidden="true"></span>
1468 - </button>
1469 -
1879 + <div class="postbox-header">
1470 1880 <h2 class="hndle ui-sortable-handle">
1471 1881 <?php echo __('<span>Failed Login Attempts Logs</span> &nbsp; (Past '.($loginizer['reset_retries']/60/60).' hours)','loginizer'); ?>
1472 1882 </h2>
1883 + </div>
1473 1884
1474 1885 <script>
1475 1886 function yesdsd(){
1476 1887 window.location = '<?php echo menu_page_url('loginizer_brute_force', false);?>&lzpage='+jQuery("#current-page-selector").val();
@@ -1502,11 +1913,13 @@
1502 1913 <table class="wp-list-table widefat fixed users" border="0">
1503 1914 <tr>
1504 1915 <th scope="row" valign="top" style="background:#EFEFEF;" width="20">#</th>
1505 1916 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('IP','loginizer'); ?></th>
1917 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Attempted Username','loginizer'); ?></th>
1506 1918 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Last Failed Attempt (DD/MM/YYYY)','loginizer'); ?></th>
1507 1919 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Failed Attempts Count','loginizer'); ?></th>
1508 - <th scope="row" valign="top" style="background:#EFEFEF;" width="150"><?php echo __('Lockouts Count','loginizer'); ?></th>
1920 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Lockouts Count','loginizer'); ?></th>
1921 + <th scope="row" valign="top" style="background:#EFEFEF;" width="150"><?php echo __('URL Attacked','loginizer'); ?></th>
1509 1922 </tr>
1510 1923 <?php
1511 1924
1512 1925 if(empty($result)){
@@ -1512,9 +1925,9 @@
1512 1925 if(empty($result)){
1513 1926 echo '
1514 1927 <tr>
1515 1928 <td colspan="4">
1516 - No Logs. You will see logs about failed login attempts here.
1929 + '.__('No Logs. You will see logs about failed login attempts here.', 'loginizer').'
1517 1930 </td>
1518 1931 </tr>';
1519 1932 }else{
1520 1933 foreach($result as $ik => $iv){
@@ -1521,22 +1934,28 @@
1521 1934 $status_button = (!empty($iv['status']) ? 'disable' : 'enable');
1522 1935 echo '
1523 1936 <tr>
1524 1937 <td>
1525 - <input type="checkbox" value="'.$iv['ip'].'" name="lz_reset_ips[]" />
1938 + <input type="checkbox" value="'.esc_attr($iv['ip']).'" name="lz_reset_ips[]" />
1526 1939 </td>
1527 1940 <td>
1528 - '.$iv['ip'].'
1941 + '.esc_html($iv['ip']).'
1529 1942 </td>
1530 1943 <td>
1531 - '.date('d/m/Y H:i:s', $iv['time']).'
1944 + '.esc_html($iv['username']).'
1532 1945 </td>
1533 1946 <td>
1534 - '.$iv['count'].'
1947 + '.date('d/M/Y H:i:s P', $iv['time']).'
1535 1948 </td>
1536 1949 <td>
1537 - '.$iv['lockout'].'
1950 + '.esc_html($iv['count']).'
1538 1951 </td>
1952 + <td>
1953 + '.esc_html($iv['lockout']).'
1954 + </td>
1955 + <td>
1956 + '.esc_html($iv['url']).'
1957 + </td>
1539 1958 </tr>';
1540 1959 }
1541 1960 }
1542 1961
@@ -1553,16 +1972,13 @@
1553 1972 <br />
1554 1973
1555 1974 <div id="" class="postbox">
1556 1975
1557 - <button class="handlediv button-link" aria-expanded="true" type="button">
1558 - <span class="screen-reader-text">Toggle panel: Brute Force Settings</span>
1559 - <span class="toggle-indicator" aria-hidden="true"></span>
1560 - </button>
1561 -
1976 + <div class="postbox-header">
1562 1977 <h2 class="hndle ui-sortable-handle">
1563 1978 <span><?php echo __('Brute Force Settings', 'loginizer'); ?></span>
1564 1979 </h2>
1980 + </div>
1565 1981
1566 1982 <div class="inside">
1567 1983
1568 1984 <form action="" method="post" enctype="multipart/form-data">
@@ -1606,8 +2022,21 @@
1606 2022 </td>
1607 2023 </tr>
1608 2024 </table><br />
1609 2025 <input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings','loginizer'); ?>" type="submit" />
2026 + <?php
2027 +
2028 + if(empty($loginizer['disable_brute'])){
2029 +
2030 + echo '<input name="disable_brute_lz" class="button action" value="'.__('Disable Brute Force Protection','loginizer').'" type="submit" style="float:right" />';
2031 +
2032 + }else{
2033 +
2034 + echo '<input name="enable_brute_lz" class="button button-primary action" value="'.__('Enable Brute Force Protection','loginizer').'" type="submit" style="float:right" />';
2035 +
2036 + }
2037 +
2038 + ?>
1610 2039 </form>
1611 2040
1612 2041 </div>
1613 2042 </div>
@@ -1612,18 +2041,76 @@
1612 2041 </div>
1613 2042 </div>
1614 2043 <br />
1615 2044
2045 +<?php
2046 +
2047 + wp_enqueue_script('jquery-paginate', LOGINIZER_URL.'/jquery-paginate.js', array('jquery'), '1.10.15');
2048 +
2049 +?>
2050 +
2051 +<style>
2052 +.page-navigation a {
2053 +margin: 5px 2px;
2054 +display: inline-block;
2055 +padding: 5px 8px;
2056 +color: #0073aa;
2057 +background: #e5e5e5 none repeat scroll 0 0;
2058 +border: 1px solid #ccc;
2059 +text-decoration: none;
2060 +transition-duration: 0.05s;
2061 +transition-property: border, background, color;
2062 +transition-timing-function: ease-in-out;
2063 +}
2064 +
2065 +.page-navigation a[data-selected] {
2066 +background-color: #00a0d2;
2067 +color: #fff;
2068 +}
2069 +</style>
2070 +
2071 +<script>
2072 +
2073 +jQuery(document).ready(function(){
2074 + jQuery('#lz_bl_table').paginate({ limit: 11, navigationWrapper: jQuery('#lz_bl_nav')});
2075 + jQuery('#lz_wl_table').paginate({ limit: 11, navigationWrapper: jQuery('#lz_wl_nav')});
2076 +});
2077 +
2078 +// Delete a Blacklist / Whitelist IP Range
2079 +function del_confirm(field, todo_id, msg){
2080 + var ret = confirm(msg);
2081 +
2082 + if(ret){
2083 + jQuery('#lz_bl_wl_todo').attr('name', field);
2084 + jQuery('#lz_bl_wl_todo').val(todo_id);
2085 + jQuery('#lz_bl_wl_form').submit();
2086 + }
2087 +
2088 + return false;
2089 +
2090 +}
2091 +
2092 +// Delete all Blacklist / Whitelist IP Ranges
2093 +function del_confirm_all(msg){
2094 + var ret = confirm(msg);
2095 +
2096 + if(ret){
2097 + return true;
2098 + }
2099 +
2100 + return false;
2101 +
2102 +}
2103 +
2104 +</script>
2105 +
1616 2106 <div id="" class="postbox">
1617 2107
1618 - <button class="handlediv button-link" aria-expanded="true" type="button">
1619 - <span class="screen-reader-text">Toggle panel: Blacklist IP</span>
1620 - <span class="toggle-indicator" aria-hidden="true"></span>
1621 - </button>
1622 -
2108 + <div class="postbox-header">
1623 2109 <h2 class="hndle ui-sortable-handle">
1624 2110 <span><?php echo __('Blacklist IP','loginizer'); ?></span>
1625 2111 </h2>
2112 + </div>
1626 2113
1627 2114 <div class="inside">
1628 2115
1629 2116 <?php echo __('Enter the IP you want to blacklist from login','loginizer'); ?>
@@ -1643,13 +2130,15 @@
1643 2130 <input type="text" size="25" value="<?php echo(lz_optpost('end_ip')); ?>" name="end_ip" id="end_ip"/> <?php echo __('End IP of the range. <br />If you want to blacklist single IP leave this field blank.','loginizer'); ?> <br />
1644 2131 </td>
1645 2132 </tr>
1646 2133 </table><br />
1647 - <input name="blacklist_iprange" class="button button-primary action" value="<?php echo __('Add Blacklist IP Range','loginizer'); ?>" type="submit" />
2134 + <input name="blacklist_iprange" class="button button-primary action" value="<?php echo __('Add Blacklist IP Range','loginizer'); ?>" type="submit" />
2135 + <input style="float:right" name="del_all_blacklist" onclick="return del_confirm_all('<?php echo __('Are you sure you want to delete all Blacklist IP Range(s) ?','loginizer'); ?>')" class="button action" value="<?php echo __('Delete All Blacklist IP Range(s)','loginizer'); ?>" type="submit" />
1648 2136 </form>
1649 2137 </div>
1650 2138
1651 - <table class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
2139 + <div id="lz_bl_nav" style="margin: 5px 10px; text-align:right"></div>
2140 + <table id="lz_bl_table" class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
1652 2141 <tr>
1653 2142 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
1654 2143 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
1655 2144 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
@@ -1659,9 +2148,9 @@
1659 2148 if(empty($loginizer['blacklist'])){
1660 2149 echo '
1661 2150 <tr>
1662 2151 <td colspan="4">
1663 - No Blacklist IPs. You will see blacklisted IP ranges here.
2152 + '.__('No Blacklist IPs. You will see blacklisted IP ranges here.', 'loginizer').'
1664 2153 </td>
1665 2154 </tr>';
1666 2155 }else{
1667 2156 foreach($loginizer['blacklist'] as $ik => $iv){
@@ -1676,9 +2165,9 @@
1676 2165 <td>
1677 2166 '.date('d/m/Y', $iv['time']).'
1678 2167 </td>
1679 2168 <td>
1680 - <a class="submitdelete" href="admin.php?page=loginizer_brute_force&bdelid='.$ik.'" onclick="return confirm(\'Are you sure you want to delete this IP range ?\')">Delete</a>
2169 + <a class="submitdelete" href="javascript:void(0)" onclick="return del_confirm(\'bdelid\', '.$ik.', \'Are you sure you want to delete this IP range ?\')">Delete</a>
1681 2170 </td>
1682 2171 </tr>';
1683 2172 }
1684 2173 }
@@ -1684,9 +2173,12 @@
1684 2173 }
1685 2174 ?>
1686 2175 </table>
1687 2176 <br />
1688 -
2177 + <form action="" method="post" id="lz_bl_wl_form">
2178 + <?php wp_nonce_field('loginizer-options'); ?>
2179 + <input type="hidden" value="" name="" id="lz_bl_wl_todo"/>
2180 + </form>
1689 2181 </div>
1690 2182
1691 2183 <br />
1692 2184
@@ -1691,16 +2183,13 @@
1691 2183 <br />
1692 2184
1693 2185 <div id="" class="postbox">
1694 2186
1695 - <button class="handlediv button-link" aria-expanded="true" type="button">
1696 - <span class="screen-reader-text">Toggle panel: Whitelist IP</span>
1697 - <span class="toggle-indicator" aria-hidden="true"></span>
1698 - </button>
1699 -
2187 + <div class="postbox-header">
1700 2188 <h2 class="hndle ui-sortable-handle">
1701 2189 <span><?php echo __('Whitelist IP', 'loginizer'); ?></span>
1702 2190 </h2>
2191 + </div>
1703 2192
1704 2193 <div class="inside">
1705 2194
1706 2195 <?php echo __('Enter the IP you want to whitelist for login','loginizer'); ?>
@@ -1719,13 +2208,15 @@
1719 2208 <input type="text" size="25" value="<?php echo(lz_optpost('end_ip_w')); ?>" name="end_ip_w" id="end_ip_w"/> <?php echo __('End IP of the range. <br />If you want to whitelist single IP leave this field blank.','loginizer'); ?> <br />
1720 2209 </td>
1721 2210 </tr>
1722 2211 </table><br />
1723 - <input name="whitelist_iprange" class="button button-primary action" value="<?php echo __('Add Whitelist IP Range','loginizer'); ?>" type="submit" />
2212 + <input name="whitelist_iprange" class="button button-primary action" value="<?php echo __('Add Whitelist IP Range','loginizer'); ?>" type="submit" />
2213 + <input style="float:right" name="del_all_whitelist" onclick="return del_confirm_all('<?php echo __('Are you sure you want to delete all Whitelist IP Range(s) ?','loginizer'); ?>')" class="button action" value="<?php echo __('Delete All Whitelist IP Range(s)','loginizer'); ?>" type="submit" />
1724 2214 </form>
1725 2215 </div>
1726 2216
1727 - <table class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
2217 + <div id="lz_wl_nav" style="margin: 5px 10px; text-align:right"></div>
2218 + <table id="lz_wl_table" class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
1728 2219 <tr>
1729 2220 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
1730 2221 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
1731 2222 <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
@@ -1735,9 +2226,9 @@
1735 2226 if(empty($loginizer['whitelist'])){
1736 2227 echo '
1737 2228 <tr>
1738 2229 <td colspan="4">
1739 - No Whitelist IPs. You will see whitelisted IP ranges here.
2230 + '.__('No Whitelist IPs. You will see whitelisted IP ranges here.', 'loginizer').'
1740 2231 </td>
1741 2232 </tr>';
1742 2233 }else{
1743 2234 foreach($loginizer['whitelist'] as $ik => $iv){
@@ -1752,9 +2243,9 @@
1752 2243 <td>
1753 2244 '.date('d/m/Y', $iv['time']).'
1754 2245 </td>
1755 2246 <td>
1756 - <a class="submitdelete" href="admin.php?page=loginizer_brute_force&delid='.$ik.'" onclick="return confirm(\'Are you sure you want to delete this IP range ?\')">Delete</a>
2247 + <a class="submitdelete" href="javascript:void(0)" onclick="return del_confirm(\'delid\', '.$ik.', \'Are you sure you want to delete this IP range ?\')">Delete</a>
1757 2248 </td>
1758 2249 </tr>';
1759 2250 }
1760 2251 }
@@ -1762,9 +2253,69 @@
1762 2253 </table>
1763 2254 <br />
1764 2255
1765 2256 </div>
2257 +
2258 + <div id="" class="postbox">
1766 2259
2260 + <div class="postbox-header">
2261 + <h2 class="hndle ui-sortable-handle">
2262 + <span><?php echo __('Error Messages', 'loginizer'); ?></span>
2263 + </h2>
2264 + </div>
2265 +
2266 + <div class="inside">
2267 +
2268 + <form action="" method="post" enctype="multipart/form-data">
2269 + <?php wp_nonce_field('loginizer-options'); ?>
2270 + <table class="form-table">
2271 + <tr>
2272 + <th scope="row" valign="top"><label for="msg_inv_userpass"><?php echo __('Failed Login Attempt','loginizer'); ?></label></th>
2273 + <td>
2274 + <input type="text" size="25" value="<?php echo esc_attr(@$saved_msgs['inv_userpass']); ?>" name="msg_inv_userpass" id="msg_inv_userpass" />
2275 + <?php echo __('Default: <em>&quot;' . $loginizer['d_msg']['inv_userpass']. '&quot;</em>', 'loginizer'); ?><br />
2276 + </td>
2277 + </tr>
2278 + <tr>
2279 + <th scope="row" valign="top"><label for="msg_ip_blacklisted"><?php echo __('Blacklisted IP','loginizer'); ?></label></th>
2280 + <td>
2281 + <input type="text" size="25" value="<?php echo esc_attr(@$saved_msgs['ip_blacklisted']); ?>" name="msg_ip_blacklisted" id="msg_ip_blacklisted" />
2282 + <?php echo __('Default: <em>&quot;' . $loginizer['d_msg']['ip_blacklisted']. '&quot;</em>', 'loginizer'); ?><br />
2283 + </td>
2284 + </tr>
2285 + <tr>
2286 + <th scope="row" valign="top"><label for="msg_attempts_left"><?php echo __('Attempts Left','loginizer'); ?></label></th>
2287 + <td>
2288 + <input type="text" size="25" value="<?php echo esc_attr(@$saved_msgs['attempts_left']); ?>" name="msg_attempts_left" id="msg_attempts_left" />
2289 + <?php echo __('Default: <em>&quot;' . $loginizer['d_msg']['attempts_left']. '&quot;</em>', 'loginizer'); ?><br />
2290 + </td>
2291 + </tr>
2292 + <tr>
2293 + <th scope="row" valign="top"><label for="msg_lockout_err"><?php echo __('Lockout Error','loginizer'); ?></label></th>
2294 + <td>
2295 + <input type="text" size="25" value="<?php echo esc_attr(@$saved_msgs['lockout_err']); ?>" name="msg_lockout_err" id="msg_lockout_err" />
2296 + <?php echo __('Default: <em>&quot;' . strip_tags($loginizer['d_msg']['lockout_err']). '&quot;</em>', 'loginizer'); ?><br />
2297 + </td>
2298 + </tr>
2299 + <tr>
2300 + <th scope="row" valign="top"><label for="msg_minutes_err"><?php echo __('Minutes','loginizer'); ?></label></th>
2301 + <td>
2302 + <input type="text" size="25" value="<?php echo esc_attr(@$saved_msgs['minutes_err']); ?>" name="msg_minutes_err" id="msg_minutes_err" />
2303 + <?php echo __('Default: <em>&quot;' . strip_tags($loginizer['d_msg']['minutes_err']). '&quot;</em>', 'loginizer'); ?><br />
2304 + </td>
2305 + </tr>
2306 + <tr>
2307 + <th scope="row" valign="top"><label for="msg_hours_err"><?php echo __('Hours','loginizer'); ?></label></th>
2308 + <td>
2309 + <input type="text" size="25" value="<?php echo esc_attr(@$saved_msgs['hours_err']); ?>" name="msg_hours_err" id="msg_hours_err" />
2310 + <?php echo __('Default: <em>&quot;' . strip_tags($loginizer['d_msg']['hours_err']). '&quot;</em>', 'loginizer'); ?><br />
2311 + </td>
2312 + </tr>
2313 + </table><br />
2314 + <input name="save_err_msgs_lz" class="button button-primary action" value="<?php echo __('Save Error Messages','loginizer'); ?>" type="submit" />
2315 + </form>
2316 + </div>
2317 + </div>
1767 2318 <?php
1768 2319
1769 2320 loginizer_page_footer();
1770 2321
@@ -1769,9 +2320,2438 @@
1769 2320 loginizer_page_footer();
1770 2321
1771 2322 }
1772 2323
2324 +//---------------------
2325 +// Admin Menu Pro Pages
2326 +//---------------------
1773 2327
2328 +// Loginizer - reCaptcha Page
2329 +function loginizer_page_recaptcha(){
2330 +
2331 + global $loginizer, $lz_error, $lz_env;
2332 +
2333 + if(!current_user_can('manage_options')){
2334 + wp_die('Sorry, but you do not have permissions to change settings.');
2335 + }
2336 +
2337 + if(!loginizer_is_premium() && count($_POST) > 0){
2338 + $lz_error['not_in_free'] = __('This feature is not available in the Free version. <a href="'.LOGINIZER_PRICING_URL.'" target="_blank" style="text-decoration:none; color:green;"><b>Upgrade to Pro</b></a>', 'loginizer');
2339 + return loginizer_page_recaptcha_T();
2340 + }
2341 +
2342 + /* Make sure post was from this page */
2343 + if(count($_POST) > 0){
2344 + check_admin_referer('loginizer-options');
2345 + }
2346 +
2347 + // Themes
2348 + $lz_env['theme']['light'] = 'Light';
2349 + $lz_env['theme']['dark'] = 'Dark';
2350 +
2351 + // Langs
2352 + $lz_env['lang'][''] = 'Auto Detect';
2353 + $lz_env['lang']['ar'] = 'Arabic';
2354 + $lz_env['lang']['bg'] = 'Bulgarian';
2355 + $lz_env['lang']['ca'] = 'Catalan';
2356 + $lz_env['lang']['zh-CN'] = 'Chinese (Simplified)';
2357 + $lz_env['lang']['zh-TW'] = 'Chinese (Traditional)';
2358 + $lz_env['lang']['hr'] = 'Croatian';
2359 + $lz_env['lang']['cs'] = 'Czech';
2360 + $lz_env['lang']['da'] = 'Danish';
2361 + $lz_env['lang']['nl'] = 'Dutch';
2362 + $lz_env['lang']['en-GB'] = 'English (UK)';
2363 + $lz_env['lang']['en'] = 'English (US)';
2364 + $lz_env['lang']['fil'] = 'Filipino';
2365 + $lz_env['lang']['fi'] = 'Finnish';
2366 + $lz_env['lang']['fr'] = 'French';
2367 + $lz_env['lang']['fr-CA'] = 'French (Canadian)';
2368 + $lz_env['lang']['de'] = 'German';
2369 + $lz_env['lang']['de-AT'] = 'German (Austria)';
2370 + $lz_env['lang']['de-CH'] = 'German (Switzerland)';
2371 + $lz_env['lang']['el'] = 'Greek';
2372 + $lz_env['lang']['iw'] = 'Hebrew';
2373 + $lz_env['lang']['hi'] = 'Hindi';
2374 + $lz_env['lang']['hu'] = 'Hungarain';
2375 + $lz_env['lang']['id'] = 'Indonesian';
2376 + $lz_env['lang']['it'] = 'Italian';
2377 + $lz_env['lang']['ja'] = 'Japanese';
2378 + $lz_env['lang']['ko'] = 'Korean';
2379 + $lz_env['lang']['lv'] = 'Latvian';
2380 + $lz_env['lang']['lt'] = 'Lithuanian';
2381 + $lz_env['lang']['no'] = 'Norwegian';
2382 + $lz_env['lang']['fa'] = 'Persian';
2383 + $lz_env['lang']['pl'] = 'Polish';
2384 + $lz_env['lang']['pt'] = 'Portuguese';
2385 + $lz_env['lang']['pt-BR'] = 'Portuguese (Brazil)';
2386 + $lz_env['lang']['pt-PT'] = 'Portuguese (Portugal)';
2387 + $lz_env['lang']['ro'] = 'Romanian';
2388 + $lz_env['lang']['ru'] = 'Russian';
2389 + $lz_env['lang']['sr'] = 'Serbian';
2390 + $lz_env['lang']['sk'] = 'Slovak';
2391 + $lz_env['lang']['sl'] = 'Slovenian';
2392 + $lz_env['lang']['es'] = 'Spanish';
2393 + $lz_env['lang']['es-419'] = 'Spanish (Latin America)';
2394 + $lz_env['lang']['sv'] = 'Swedish';
2395 + $lz_env['lang']['th'] = 'Thai';
2396 + $lz_env['lang']['tr'] = 'Turkish';
2397 + $lz_env['lang']['uk'] = 'Ukrainian';
2398 + $lz_env['lang']['vi'] = 'Vietnamese';
2399 +
2400 + // Sizes
2401 + $lz_env['size']['normal'] = 'Normal';
2402 + $lz_env['size']['compact'] = 'Compact';
2403 +
2404 + if(isset($_POST['save_lz'])){
2405 +
2406 + // Google Captcha
2407 + $option['captcha_type'] = lz_optpost('captcha_type');
2408 + $option['captcha_key'] = lz_optpost('captcha_key');
2409 + $option['captcha_secret'] = lz_optpost('captcha_secret');
2410 + $option['captcha_theme'] = lz_optpost('captcha_theme');
2411 + $option['captcha_size'] = lz_optpost('captcha_size');
2412 + $option['captcha_lang'] = lz_optpost('captcha_lang');
2413 +
2414 + // No Google Captcha
2415 + $option['captcha_text'] = lz_optpost('captcha_text');
2416 + $option['captcha_time'] = (int) lz_optpost('captcha_time');
2417 + $option['captcha_words'] = (int) lz_optpost('captcha_words');
2418 + $option['captcha_add'] = (int) lz_optpost('captcha_add');
2419 + $option['captcha_subtract'] = (int) lz_optpost('captcha_subtract');
2420 + $option['captcha_multiply'] = (int) lz_optpost('captcha_multiply');
2421 + $option['captcha_divide'] = (int) lz_optpost('captcha_divide');
2422 +
2423 + // Checkboxes
2424 + $option['captcha_user_hide'] = (int) lz_optpost('captcha_user_hide');
2425 + $option['captcha_no_css_login'] = (int) lz_optpost('captcha_no_css_login');
2426 + $option['captcha_login'] = (int) lz_optpost('captcha_login');
2427 + $option['captcha_lostpass'] = (int) lz_optpost('captcha_lostpass');
2428 + $option['captcha_resetpass'] = (int) lz_optpost('captcha_resetpass');
2429 + $option['captcha_register'] = (int) lz_optpost('captcha_register');
2430 + $option['captcha_comment'] = (int) lz_optpost('captcha_comment');
2431 + $option['captcha_wc_checkout'] = (int) lz_optpost('captcha_wc_checkout');
2432 +
2433 + // Are we to use Math Captcha ?
2434 + if(isset($_POST['captcha_no_google'])){
2435 +
2436 + $option['captcha_no_google'] = 1;
2437 +
2438 + // Make the checks
2439 + if(strlen($option['captcha_text']) < 1){
2440 + $lz_error['captcha_text'] = __('The Captcha key was not submitted', 'loginizer');
2441 + }
2442 +
2443 + }else{
2444 +
2445 + // Make the checks
2446 + if(strlen($option['captcha_key']) < 32 || strlen($option['captcha_key']) > 50){
2447 + $lz_error['captcha_key'] = __('The reCAPTCHA key is invalid', 'loginizer');
2448 + }
2449 +
2450 + // Is secret valid ?
2451 + if(strlen($option['captcha_secret']) < 32 || strlen($option['captcha_secret']) > 50){
2452 + $lz_error['captcha_secret'] = __('The reCAPTCHA secret is invalid', 'loginizer');
2453 + }
2454 +
2455 + // Is theme valid ?
2456 + if(empty($lz_env['theme'][$option['captcha_theme']])){
2457 + $lz_error['captcha_theme'] = __('The reCAPTCHA theme is invalid', 'loginizer');
2458 + }
2459 +
2460 + // Is size valid ?
2461 + if(empty($lz_env['size'][$option['captcha_size']])){
2462 + $lz_error['captcha_size'] = __('The reCAPTCHA size is invalid', 'loginizer');
2463 + }
2464 +
2465 + // Is lang valid ?
2466 + if(empty($lz_env['lang'][$option['captcha_lang']])){
2467 + $lz_error['captcha_lang'] = __('The reCAPTCHA language is invalid', 'loginizer');
2468 + }
2469 +
2470 + }
2471 +
2472 + // Is there an error ?
2473 + if(!empty($lz_error)){
2474 + return loginizer_page_recaptcha_T();
2475 + }
2476 +
2477 + // Save the options
2478 + update_option('loginizer_captcha', $option);
2479 +
2480 + // Mark as saved
2481 + $GLOBALS['lz_saved'] = true;
2482 +
2483 + }
2484 +
2485 + // Clear this
2486 + if(isset($_POST['clear_captcha_lz'])){
2487 +
2488 + // Save the options
2489 + update_option('loginizer_captcha', '');
2490 +
2491 + // Mark as saved
2492 + $GLOBALS['lz_cleared'] = true;
2493 +
2494 + }
2495 +
2496 + // Call the theme
2497 + loginizer_page_recaptcha_T();
2498 +
2499 +}
2500 +
2501 +// Loginizer - reCaptcha Page Theme
2502 +function loginizer_page_recaptcha_T(){
2503 +
2504 + global $loginizer, $lz_error, $lz_env;
2505 +
2506 + // Universal header
2507 + loginizer_page_header('reCAPTCHA Settings');
2508 +
2509 + loginizer_feature_available('reCAPTCHA');
2510 +
2511 + // Saved ?
2512 + if(!empty($GLOBALS['lz_saved'])){
2513 + echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
2514 + }
2515 +
2516 + // Cleared ?
2517 + if(!empty($GLOBALS['lz_cleared'])){
2518 + echo '<div id="message" class="updated"><p>'. __('reCAPTCHA has been disabled !', 'loginizer'). '</p></div><br />';
2519 + }
2520 +
2521 + // Any errors ?
2522 + if(!empty($lz_error)){
2523 + lz_report_error($lz_error);echo '<br />';
2524 + }
2525 +
2526 + ?>
2527 +
2528 +<style>
2529 +input[type="text"], textarea, select {
2530 + width: 70%;
2531 +}
2532 +</style>
2533 +
2534 + <div id="" class="postbox">
2535 +
2536 + <div class="postbox-header">
2537 + <h2 class="hndle ui-sortable-handle">
2538 + <span><?php echo __('reCAPTCHA Settings', 'loginizer'); ?></span>
2539 + </h2>
2540 + </div>
2541 +
2542 + <div class="inside">
2543 +
2544 + <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
2545 + <?php wp_nonce_field('loginizer-options'); ?>
2546 + <table class="form-table">
2547 + <tr class="lz_google_cap">
2548 + <td scope="row" valign="top" style="width:300px !important; padding-left:0px"><label><b><?php echo __('reCAPTCHA type', 'loginizer'); ?></b></label><br>
2549 + <?php echo __('Choose the type of reCAPTCHA', 'loginizer'); ?><br />
2550 + <?php echo __('<a href="https://g.co/recaptcha/sitetypes/" target="_blank">See Site Types for more details</a>', 'loginizer'); ?>
2551 + </td>
2552 + <td>
2553 + <input type="radio" value="v3" onchange="google_recaptcha_type(this)" <?php echo lz_POSTradio('captcha_type', 'v3', $loginizer['captcha_type']); ?> name="captcha_type" id="captcha_type_v3" /> <label for="captcha_type_v3"><?php echo __('reCAPTCHA v3', 'loginizer'); ?></label><br /><br />
2554 + <input type="radio" value="" onchange="google_recaptcha_type(this)" <?php echo lz_POSTradio('captcha_type', '', $loginizer['captcha_type']); ?> name="captcha_type" id="captcha_type_v2" /> <label for="captcha_type_v2"><?php echo __('reCAPTCHA v2 - Checkbox', 'loginizer'); ?></label><br /><br />
2555 + <input type="radio" value="v2_invisible" onchange="google_recaptcha_type(this)" <?php echo lz_POSTradio('captcha_type', 'v2_invisible', $loginizer['captcha_type']); ?> name="captcha_type" id="captcha_type_v2_invisible" /> <label for="captcha_type_v2_invisible"><?php echo __('reCAPTCHA v2 - Invisible', 'loginizer'); ?></label><br />
2556 + </td>
2557 + </tr>
2558 + <tr class="lz_google_cap">
2559 + <td scope="row" valign="top" style="width:300px !important; padding-left:0px"><label><b><?php echo __('Site Key', 'loginizer'); ?></b></label><br>
2560 + <?php echo __('Make sure you enter the correct keys as per the reCAPTCHA type selected above', 'loginizer'); ?>
2561 + </td>
2562 + <td>
2563 + <input type="text" size="50" value="<?php echo lz_optpost('captcha_key', $loginizer['captcha_key']); ?>" name="captcha_key" /><br />
2564 + <?php echo __('Get the Site Key and Secret Key from <a href="https://www.google.com/recaptcha/" target="_blank">Google</a>', 'loginizer'); ?>
2565 + </td>
2566 + </tr>
2567 + <tr class="lz_google_cap">
2568 + <th scope="row" valign="top"><label><?php echo __('Secret Key', 'loginizer'); ?></label></th>
2569 + <td>
2570 + <input type="text" size="50" value="<?php echo lz_optpost('captcha_secret', $loginizer['captcha_secret']); ?>" name="captcha_secret" />
2571 + </td>
2572 + </tr>
2573 + <tr class="lz_google_cap">
2574 + <th scope="row" valign="top"><label><?php echo __('Theme', 'loginizer'); ?></label></th>
2575 + <td>
2576 + <select name="captcha_theme">
2577 + <?php
2578 + foreach($lz_env['theme'] as $k => $v){
2579 + echo '<option '.lz_POSTselect('captcha_theme', $k, ($loginizer['captcha_theme'] == $k ? true : false)).' value="'.$k.'">'.$v.'</value>';
2580 + }
2581 + ?>
2582 + </select>
2583 + </td>
2584 + </tr>
2585 + <tr class="lz_google_cap">
2586 + <th scope="row" valign="top"><label><?php echo __('Language', 'loginizer'); ?></label></th>
2587 + <td>
2588 + <select name="captcha_lang">
2589 + <?php
2590 + foreach($lz_env['lang'] as $k => $v){
2591 + echo '<option '.lz_POSTselect('captcha_lang', $k, ($loginizer['captcha_lang'] == $k ? true : false)).' value="'.$k.'">'.$v.'</value>';
2592 + }
2593 + ?>
2594 + </select>
2595 + </td>
2596 + </tr>
2597 + <tr class="lz_google_cap lz_google_cap_size">
2598 + <th scope="row" valign="top"><label><?php echo __('Size', 'loginizer'); ?></label></th>
2599 + <td>
2600 + <select name="captcha_size">
2601 + <?php
2602 + foreach($lz_env['size'] as $k => $v){
2603 + echo '<option '.lz_POSTselect('captcha_size', $k, ($loginizer['captcha_size'] == $k ? true : false)).' value="'.$k.'">'.$v.'</value>';
2604 + }
2605 + ?>
2606 + </select>
2607 + </td>
2608 + </tr>
2609 + <tr>
2610 + <td scope="row" valign="top" style="padding-left:0px">
2611 + <label><b><?php echo __('Don\'t use Google reCAPTCHA', 'loginizer'); ?></b></label><br>
2612 + <?php echo __('If selected, '.$loginizer['prefix'].' will use a simple Math Captcha instead of Google reCAPTCHA', 'loginizer'); ?>
2613 + </td>
2614 + <td>
2615 + <input type="checkbox" onclick="no_google_recaptcha(this)" id="captcha_no_google" value="1" name="captcha_no_google" <?php echo lz_POSTchecked('captcha_no_google', (empty($loginizer['captcha_no_google']) ? false : true)); ?> />
2616 + </td>
2617 + </tr>
2618 + <tr class="lz_math_cap">
2619 + <td scope="row" valign="top" style="width:300px !important; padding-left:0px">
2620 + <label><b><?php echo __('Captcha Text', 'loginizer'); ?></b></label><br>
2621 + <?php echo __('The text to be shown for the Captcha Field', 'loginizer'); ?>
2622 + </td>
2623 + <td>
2624 + <input type="text" size="30" value="<?php echo lz_optpost('captcha_text', @$loginizer['captcha_text']); ?>" name="captcha_text" />
2625 + </td>
2626 + </tr>
2627 + <tr class="lz_math_cap">
2628 + <td scope="row" valign="top" style="padding-left:0px">
2629 + <label><b><?php echo __('Captcha Time', 'loginizer'); ?></b></label><br>
2630 + <?php echo __('Enter the number of seconds, a user has to enter captcha value.', 'loginizer'); ?>
2631 + </td>
2632 + <td>
2633 + <input type="text" size="30" value="<?php echo lz_optpost('captcha_time', @$loginizer['captcha_time']); ?>" name="captcha_time" />
2634 + </td>
2635 + </tr>
2636 + <tr class="lz_math_cap">
2637 + <td scope="row" valign="top" style="padding-left:0px">
2638 + <label><b><?php echo __('Display Captcha in Words', 'loginizer'); ?></b></label><br>
2639 + <?php echo __('If selected the Captcha will be displayed in words rather than numbers', 'loginizer'); ?>
2640 + </td>
2641 + <td>
2642 + <input type="checkbox" value="1" name="captcha_words" <?php echo lz_POSTchecked('captcha_words', (empty($loginizer['captcha_words']) ? false : true));?> />
2643 + </td>
2644 + </tr>
2645 + <tr class="lz_math_cap">
2646 + <td scope="row" valign="top" style="vertical-align: top !important; padding-left:0px">
2647 + <label><b><?php echo __('Mathematical operations', 'loginizer'); ?></b></label><br>
2648 + <?php echo __('The Mathematical operations to use for Captcha', 'loginizer'); ?>
2649 + </td>
2650 + <td valign="top">
2651 + <table class="wp-list-table fixed users" cellpadding="8" cellspacing="1">
2652 + <?php echo '
2653 + <tr>
2654 + <td>'.__('Addition (+)', 'loginizer').'</td>
2655 + <td><input type="checkbox" value="1" name="captcha_add" '.lz_POSTchecked('captcha_add', (empty($loginizer['captcha_add']) ? false : true)).' /></td>
2656 + </tr>
2657 + <tr>
2658 + <td>'.__('Subtraction (-)', 'loginizer').'</td>
2659 + <td><input type="checkbox" value="1" name="captcha_subtract" '.lz_POSTchecked('captcha_subtract', (empty($loginizer['captcha_subtract']) ? false : true)).' /></td>
2660 + </tr>
2661 + <tr>
2662 + <td>'.__('Multiplication (x)', 'loginizer').'</td>
2663 + <td><input type="checkbox" value="1" name="captcha_multiply" '.lz_POSTchecked('captcha_multiply', (empty($loginizer['captcha_multiply']) ? false : true)).' /></td>
2664 + </tr>
2665 + <tr>
2666 + <td>'.__('Division (รท)', 'loginizer').'</td>
2667 + <td><input type="checkbox" value="1" name="captcha_divide" '.lz_POSTchecked('captcha_divide', (empty($loginizer['captcha_divide']) ? false : true)).' /></td>
2668 + </tr>';
2669 + ?>
2670 + </table>
2671 + </td>
2672 + </tr>
2673 + <tr>
2674 + <th scope="row" valign="top"><label><?php echo __('Show Captcha On', 'loginizer'); ?></label></th>
2675 + <td valign="top">
2676 + <table class="wp-list-table fixed users" cellpadding="8" cellspacing="1">
2677 + <?php echo '
2678 + <tr>
2679 + <td>'.__('Login Form', 'loginizer').'</td>
2680 + <td><input type="checkbox" value="1" name="captcha_login" '.lz_POSTchecked('captcha_login', (empty($loginizer['captcha_login']) ? false : true)).' /></td>
2681 + </tr>
2682 + <tr>
2683 + <td>'.__('Lost Password Form', 'loginizer').'</td>
2684 + <td><input type="checkbox" value="1" name="captcha_lostpass" '.lz_POSTchecked('captcha_lostpass', (empty($loginizer['captcha_lostpass']) ? false : true)).' /></td>
2685 + </tr>
2686 + <tr>
2687 + <td>'.__('Reset Password Form', 'loginizer').'</td>
2688 + <td><input type="checkbox" value="1" name="captcha_resetpass" '.lz_POSTchecked('captcha_resetpass', (empty($loginizer['captcha_resetpass']) ? false : true)).' /></td>
2689 + </tr>
2690 + <tr>
2691 + <td>'.__('Registration Form', 'loginizer').'</td>
2692 + <td><input type="checkbox" value="1" name="captcha_register" '.lz_POSTchecked('captcha_register', (empty($loginizer['captcha_register']) ? false : true)).' /></td>
2693 + </tr>
2694 + <tr>
2695 + <td>'.__('Comment Form', 'loginizer').'</td>
2696 + <td><input type="checkbox" value="1" name="captcha_comment" '.lz_POSTchecked('captcha_comment', (empty($loginizer['captcha_comment']) ? false : true)).' /></td>
2697 + </tr>';
2698 +
2699 + if(!defined('SITEPAD')){
2700 +
2701 + echo '<tr>
2702 + <td>'.__('WooCommerce Checkout', 'loginizer').'</td>
2703 + <td><input type="checkbox" value="1" name="captcha_wc_checkout" '.lz_POSTchecked('captcha_wc_checkout', (empty($loginizer['captcha_wc_checkout']) ? false : true)).' /></td>
2704 + </tr>';
2705 +
2706 + }
2707 +
2708 + ?>
2709 + </table>
2710 + </td>
2711 + </tr>
2712 + <tr>
2713 + <th scope="row" valign="top"><label><?php echo __('Hide CAPTCHA for logged in Users', 'loginizer'); ?></label></th>
2714 + <td>
2715 + <input type="checkbox" value="1" name="captcha_user_hide" <?php echo lz_POSTchecked('captcha_user_hide', (empty($loginizer['captcha_user_hide']) ? false : true)); ?> />
2716 + </td>
2717 + </tr>
2718 + <tr class="lz_google_cap">
2719 + <th scope="row" valign="top"><label><?php echo __('Disable CSS inserted on Login Page', 'loginizer'); ?></label></th>
2720 + <td>
2721 + <input type="checkbox" value="1" name="captcha_no_css_login" <?php echo lz_POSTchecked('captcha_no_css_login', (empty($loginizer['captcha_no_css_login']) ? false : true)); ?> />
2722 + </td>
2723 + </tr>
2724 + </table><br />
2725 + <center><input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings','loginizer'); ?>" type="submit" />
2726 + <input style="float:right" name="clear_captcha_lz" class="button action" value="<?php echo __('Disable reCAPTCHA','loginizer'); ?>" type="submit" /></center>
2727 + </form>
2728 +
2729 + </div>
2730 + </div>
2731 + <br />
2732 +
2733 +<script type="text/javascript">
2734 +
2735 +function no_google_recaptcha(obj){
2736 +
2737 + if(obj.checked){
2738 + jQuery(".lz_google_cap").hide();
2739 + jQuery(".lz_math_cap").show();
2740 + }else{
2741 + jQuery(".lz_google_cap").show();
2742 + jQuery(".lz_math_cap").hide();
2743 + }
2744 +
2745 + var cur_captcha_type = jQuery("input:radio[name='captcha_type']:checked").val();
2746 +
2747 + if(cur_captcha_type == 'v3' || cur_captcha_type == 'v2_invisible'){
2748 + jQuery(".lz_google_cap_size").hide();
2749 + }else{
2750 + jQuery(".lz_google_cap_size").show();
2751 + }
2752 +
2753 +}
2754 +
2755 +no_google_recaptcha(jQuery("#captcha_no_google")[0]);
2756 +
2757 +function google_recaptcha_type(obj){
2758 + if(obj.value == 'v3' || obj.value == 'v2_invisible'){
2759 + jQuery(".lz_google_cap_size").hide();
2760 + }else{
2761 + jQuery(".lz_google_cap_size").show();
2762 + }
2763 +}
2764 +
2765 +
2766 +</script>
2767 +
2768 + <?php
2769 + loginizer_page_footer();
2770 +
2771 +}
2772 +
2773 +
2774 +// Loginizer - Two Factor Auth Page
2775 +function loginizer_page_2fa(){
2776 +
2777 + global $loginizer, $lz_error, $lz_env, $lz_roles, $lz_options, $saved_msgs;
2778 +
2779 + if(!current_user_can('manage_options')){
2780 + wp_die('Sorry, but you do not have permissions to change settings.');
2781 + }
2782 +
2783 + if(!loginizer_is_premium() && count($_POST) > 0){
2784 + $lz_error['not_in_free'] = __('This feature is not available in the Free version. <a href="'.LOGINIZER_PRICING_URL.'" target="_blank" style="text-decoration:none; color:green;"><b>Upgrade to Pro</b></a>', 'loginizer');
2785 + return loginizer_page_2fa_T();
2786 + }
2787 +
2788 + $lz_roles = get_editable_roles();
2789 +
2790 + /* Make sure post was from this page */
2791 + if(count($_POST) > 0){
2792 + check_admin_referer('loginizer-options');
2793 + }
2794 +
2795 + // Settings submitted
2796 + if(isset($_POST['save_lz'])){
2797 +
2798 + // In the future there can be more settings
2799 + $option['2fa_app'] = (int) lz_optpost('2fa_app');
2800 + $option['2fa_email'] = (int) lz_optpost('2fa_email');
2801 + $option['question'] = (int) lz_optpost('question');
2802 + $option['2fa_email_force'] = (int) lz_optpost('2fa_email_force');
2803 +
2804 + // Any roles to apply to ?
2805 + foreach($lz_roles as $k => $v){
2806 +
2807 + if(lz_optpost('2fa_roles_'.$k)){
2808 + $option['2fa_roles'][$k] = 1;
2809 + }
2810 +
2811 + }
2812 +
2813 + // If its all, then blank it
2814 + if(lz_optpost('2fa_roles_all') || empty($option['2fa_roles'])){
2815 + $option['2fa_roles'] = '';
2816 + }
2817 +
2818 + // Is there an error ?
2819 + if(!empty($lz_error)){
2820 + return loginizer_page_2fa_T();
2821 + }
2822 +
2823 + // Save the options
2824 + update_option('loginizer_2fa', $option);
2825 +
2826 + // Mark as saved
2827 + $GLOBALS['lz_saved'] = true;
2828 +
2829 + }
2830 +
2831 + // Reset a users 2FA
2832 + if(isset($_POST['reset_user_lz'])){
2833 +
2834 + $_username = lz_optpost('lz_user_2fa_disable');
2835 +
2836 + // Try to get the user
2837 + $user_search = get_user_by('login', $_username);
2838 +
2839 + // If not found then search by email
2840 + if(empty($user_search)){
2841 + $user_search = get_user_by('email', $_username);
2842 + }
2843 +
2844 + // If not found then give error
2845 + if(empty($user_search)){
2846 + $lz_error['2fa_user_not'] = __('There is no such user with the email or username you submitted', 'loginizer');
2847 + return loginizer_page_2fa_T();
2848 + }
2849 +
2850 + // Get the user prefences
2851 + $user_pref = get_user_meta($user_search->ID, 'loginizer_user_settings');
2852 +
2853 + // Blank it
2854 + $user_pref['pref'] = 'none';
2855 +
2856 + // Save it
2857 + update_user_meta($user_search->ID, 'loginizer_user_settings', $user_pref);
2858 +
2859 + // Mark as saved
2860 + $GLOBALS['lz_saved'] = __('The user\'s 2FA settings have been reset', 'loginizer');
2861 +
2862 + }
2863 +
2864 + if(isset($_POST['save_2fa_email_template_lz'])){
2865 +
2866 + // In the future there can be more settings
2867 + $option['2fa_email_sub'] = lz_optpost('lz_2fa_email_sub');
2868 + $option['2fa_email_msg'] = lz_optpost('lz_2fa_email_msg');
2869 +
2870 + // Is there an error ?
2871 + if(!empty($lz_error)){
2872 + return loginizer_page_2fa_T();
2873 + }
2874 +
2875 + // Save the options
2876 + update_option('loginizer_2fa_email_template', $option);
2877 +
2878 + // Mark as saved
2879 + $GLOBALS['lz_saved'] = true;
2880 +
2881 + }
2882 +
2883 + // Save the messages
2884 + if(isset($_POST['save_msgs_lz'])){
2885 +
2886 + $msgs['otp_app'] = lz_optpost('msg_otp_app');
2887 + $msgs['otp_email'] = lz_optpost('msg_otp_email');
2888 + $msgs['otp_field'] = lz_optpost('msg_otp_field');
2889 + $msgs['otp_question'] = lz_optpost('msg_otp_question');
2890 + $msgs['otp_answer'] = lz_optpost('msg_otp_answer');
2891 +
2892 + // Update them
2893 + update_option('loginizer_2fa_msg', $msgs);
2894 +
2895 + // Mark as saved
2896 + $GLOBALS['lz_saved'] = __('Messages were saved successfully', 'loginizer');
2897 +
2898 + }
2899 +
2900 + // Delete a Whitelist IP range
2901 + if(isset($_POST['delid'])){
2902 +
2903 + $delid = (int) lz_optreq('delid');
2904 +
2905 + // Unset and save
2906 + $whitelist = $loginizer['2fa_whitelist'];
2907 + unset($whitelist[$delid]);
2908 + update_option('loginizer_2fa_whitelist', $whitelist);
2909 +
2910 + // Mark as saved
2911 + $GLOBALS['lz_saved'] = __('The Whitelist IP range has been deleted successfully', 'loginizer');
2912 +
2913 + }
2914 +
2915 + // Delete all Blackist IP ranges
2916 + if(isset($_POST['del_all_whitelist'])){
2917 +
2918 + // Unset and save
2919 + update_option('loginizer_2fa_whitelist', array());
2920 +
2921 + // Mark as saved
2922 + $GLOBALS['lz_saved'] = __('The Whitelist IP range(s) have been cleared successfully', 'loginizer');
2923 +
2924 + }
2925 +
2926 + // Add IP range to 2FA whitelist
2927 + if(isset($_POST['2fa_whitelist_iprange'])){
2928 +
2929 + $start_ip = lz_optpost('start_ip_w_2fa');
2930 + $end_ip = lz_optpost('end_ip_w_2fa');
2931 +
2932 + if(empty($start_ip)){
2933 + $lz_error[] = __('Please enter the Start IP', 'loginizer');
2934 + return loginizer_page_2fa_T();
2935 + }
2936 +
2937 + // If no end IP we consider only 1 IP
2938 + if(empty($end_ip)){
2939 + $end_ip = $start_ip;
2940 + }
2941 +
2942 + if(!lz_valid_ip($start_ip)){
2943 + $lz_error[] = __('Please provide a valid start IP', 'loginizer');
2944 + }
2945 +
2946 + if(!lz_valid_ip($end_ip)){
2947 + $lz_error[] = __('Please provide a valid end IP', 'loginizer');
2948 + }
2949 +
2950 + if(inet_ptoi($start_ip) > inet_ptoi($end_ip)){
2951 +
2952 + // BUT, if 0.0.0.1 - 255.255.255.255 is given, it will not work
2953 + if(inet_ptoi($start_ip) >= 0 && inet_ptoi($end_ip) < 0){
2954 + // This is right
2955 + }else{
2956 + $lz_error[] = __('The End IP cannot be smaller than the Start IP', 'loginizer');
2957 + }
2958 +
2959 + }
2960 +
2961 + if(empty($lz_error)){
2962 +
2963 + $whitelist = $loginizer['2fa_whitelist'];
2964 +
2965 + foreach($whitelist as $k => $v){
2966 +
2967 + // This is to check if there is any other range exists with the same Start or End IP
2968 + if(( inet_ptoi($start_ip) <= inet_ptoi($v['start']) && inet_ptoi($v['start']) <= inet_ptoi($end_ip) )
2969 + || ( inet_ptoi($start_ip) <= inet_ptoi($v['end']) && inet_ptoi($v['end']) <= inet_ptoi($end_ip) )
2970 + ){
2971 + $lz_error[] = __('The Start IP or End IP submitted conflicts with an existing IP range !', 'loginizer');
2972 + break;
2973 + }
2974 +
2975 + // This is to check if there is any other range exists with the same Start IP
2976 + if(inet_ptoi($v['start']) <= inet_ptoi($start_ip) && inet_ptoi($start_ip) <= inet_ptoi($v['end'])){
2977 + $lz_error[] = __('The Start IP is present in an existing range !', 'loginizer');
2978 + break;
2979 + }
2980 +
2981 + // This is to check if there is any other range exists with the same End IP
2982 + if(inet_ptoi($v['start']) <= inet_ptoi($end_ip) && inet_ptoi($end_ip) <= inet_ptoi($v['end'])){
2983 + $lz_error[] = __('The End IP is present in an existing range!', 'loginizer');
2984 + break;
2985 + }
2986 +
2987 + }
2988 +
2989 + $newid = ( empty($whitelist) ? 0 : max(array_keys($whitelist)) ) + 1;
2990 +
2991 + if(empty($lz_error)){
2992 +
2993 + $whitelist[$newid] = array();
2994 + $whitelist[$newid]['start'] = $start_ip;
2995 + $whitelist[$newid]['end'] = $end_ip;
2996 + $whitelist[$newid]['time'] = time();
2997 +
2998 + update_option('loginizer_2fa_whitelist', $whitelist);
2999 +
3000 + // Mark as saved
3001 + $GLOBALS['lz_saved'] = __('Whitelist IP range for Two Factor Authentication added successfully', 'loginizer');
3002 +
3003 + }
3004 +
3005 + }
3006 + }
3007 +
3008 +
3009 + $lz_options = get_option('loginizer_2fa_email_template');
3010 + $saved_msgs = get_option('loginizer_2fa_msg');
3011 + $loginizer['2fa_whitelist'] = get_option('loginizer_2fa_whitelist');
3012 +
3013 + // Call theme
3014 + loginizer_page_2fa_T();
3015 +
3016 +}
3017 +
3018 +
3019 +// Loginizer - Two Factor Auth Page
3020 +function loginizer_page_2fa_T(){
3021 +
3022 + global $loginizer, $lz_error, $lz_env, $lz_roles, $lz_options, $saved_msgs;
3023 +
3024 + // Universal header
3025 + loginizer_page_header('Two Factor Authentication');
3026 +
3027 + loginizer_feature_available('Two-Factor Authentication');
3028 +
3029 + // Saved ?
3030 + if(!empty($GLOBALS['lz_saved'])){
3031 + echo '<div id="message" class="updated"><p>'. __(is_string($GLOBALS['lz_saved']) ? $GLOBALS['lz_saved'] : 'The settings were saved successfully', 'loginizer'). '</p></div><br />';
3032 + }
3033 +
3034 + // Any errors ?
3035 + if(!empty($lz_error)){
3036 + lz_report_error($lz_error);echo '<br />';
3037 + }
3038 +
3039 + ?>
3040 +
3041 +<style>
3042 +input[type="text"], textarea, select {
3043 + width: 70%;
3044 +}
3045 +
3046 +.form-table label{
3047 + font-weight:bold;
3048 +}
3049 +
3050 +.exp{
3051 + font-size:12px;
3052 +}
3053 +</style>
3054 +
3055 + <div id="" class="postbox">
3056 +
3057 + <div class="postbox-header">
3058 + <h2 class="hndle ui-sortable-handle">
3059 + <span><?php echo __('Two Factor Authentication Settings', 'loginizer'); ?></span>
3060 + </h2>
3061 + </div>
3062 +
3063 + <div class="inside">
3064 +
3065 + <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
3066 + <?php wp_nonce_field('loginizer-options'); ?>
3067 + <table class="form-table">
3068 + <tr>
3069 + <td scope="row" valign="top" colspan="2">
3070 + <i><?php echo __('Please choose from the following Two Factor Authentication methods. Each user can choose any one method from the ones enabled by you. You can enable all or anyone that you would like.', 'loginizer'); ?></i>
3071 + </td>
3072 + </tr>
3073 + <tr>
3074 + <td scope="row" valign="top" style="width:70% !important">
3075 + <label><?php echo __('OTP via App', 'loginizer'); ?></label><br>
3076 + <span class="exp"><?php echo __('After entering the correct login credentials, the user will be asked for the OTP. The OTP will be obtained from the users mobile app e.g. <b>Google Authenticator, Authy, etc.</b>', 'loginizer'); ?></span>
3077 + </td>
3078 + <td>
3079 + <input type="checkbox" value="1" name="2fa_app" <?php echo lz_POSTchecked('2fa_app', (empty($loginizer['2fa_app']) ? false : true), 'save_lz'); ?> />
3080 + </td>
3081 + </tr>
3082 + <tr>
3083 + <td scope="row" valign="top">
3084 + <label><?php echo __('OTP via Email', 'loginizer'); ?></label><br>
3085 + <span class="exp"><?php echo __('After entering the correct login credentials, the user will be asked for the OTP. The OTP will be emailed to the user.', 'loginizer'); ?></span>
3086 + </td>
3087 + <td>
3088 + <input type="checkbox" value="1" name="2fa_email" <?php echo lz_POSTchecked('2fa_email', (empty($loginizer['2fa_email']) ? false : true), 'save_lz'); ?> />
3089 + </td>
3090 + </tr>
3091 + <tr>
3092 + <td scope="row" valign="top">
3093 + <label><?php echo __('User Defined Question & Answer', 'loginizer'); ?></label><br>
3094 + <span class="exp"><?php echo __('In this method the user will be asked to set a secret personal question and answer. After entering the correct login credentials, the user will be asked to answer the question set by them, thus increasing the security', 'loginizer'); ?></span>
3095 + </td>
3096 + <td>
3097 + <input type="checkbox" value="1" name="question" <?php echo lz_POSTchecked('question', (empty($loginizer['question']) ? false : true), 'save_lz'); ?> />
3098 + </td>
3099 + </tr>
3100 + </table><br />
3101 +
3102 + <table class="form-table">
3103 + <tr>
3104 + <td scope="row" valign="top" style="width:70% !important">
3105 + <label><?php echo __('Force OTP via Email', 'loginizer'); ?></label><br>
3106 + <span class="exp"><?php echo __('If the user does not have any 2FA method selected, this will enforce the OTP via Email for the users.', 'loginizer'); ?></span>
3107 + </td>
3108 + <td>
3109 + <input type="checkbox" value="1" name="2fa_email_force" <?php echo lz_POSTchecked('2fa_email_force', (empty($loginizer['2fa_email_force']) ? false : true), 'save_lz'); ?> />
3110 + </td>
3111 + </tr>
3112 + <tr>
3113 + <td scope="row" valign="top" style="width:70% !important">
3114 + <label><?php echo __('Apply 2FA to Roles', 'loginizer'); ?></label><br>
3115 + <span class="exp"><?php echo __('Select the Roles to which 2FA should be applied.', 'loginizer'); ?></span>
3116 + </td>
3117 + <td>
3118 + <input type="checkbox" value="1" onchange="lz_roles_handle()" name="2fa_roles_all" id="2fa_roles_all" <?php echo lz_POSTchecked('2fa_roles_all', (empty($loginizer['2fa_roles']) ? true : false), 'save_lz'); ?> /> All<br />
3119 + <?php
3120 +
3121 + foreach($lz_roles as $k => $v){
3122 + echo '<span class="lz_roles"><input type="checkbox" value="1" name="2fa_roles_'.$k.'" '.lz_POSTchecked('2fa_roles_'.$k, (empty($loginizer['2fa_roles'][$k]) ? false : true), 'save_lz').' /> '.$v['name'].'<br /></span>';
3123 + }
3124 +
3125 + ?>
3126 + </td>
3127 + </tr>
3128 + </table><br />
3129 + <center><input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
3130 + </form>
3131 +
3132 + </div>
3133 + </div>
3134 +
3135 +<script type="text/javascript">
3136 +
3137 +function lz_roles_handle(){
3138 +
3139 + var obj = jQuery("#2fa_roles_all")[0];
3140 +
3141 + if(obj.checked){
3142 + jQuery(".lz_roles").hide();
3143 + }else{
3144 + jQuery(".lz_roles").show();
3145 + }
3146 +
3147 +}
3148 +
3149 +lz_roles_handle();
3150 +
3151 +</script>
3152 +
3153 + <div id="" class="postbox">
3154 +
3155 + <div class="postbox-header">
3156 + <h2 class="hndle ui-sortable-handle">
3157 + <span><?php echo __('OTP via Email Template', 'loginizer'); ?></span>
3158 + </h2>
3159 + </div>
3160 +
3161 + <div class="inside">
3162 +
3163 + <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
3164 + <?php wp_nonce_field('loginizer-options'); ?>
3165 + <table class="form-table">
3166 + <tr>
3167 + <td colspan="2" valign="top">
3168 + <?php echo __('Customize the email template to be used when sending the OTP to login via Email for 2FA.', 'loginizer'); ?><br>
3169 + <?php echo __('If you do not make changes below the default email template will be used !', 'loginizer'); ?>
3170 + </td>
3171 + </tr>
3172 + <tr>
3173 + <td scope="row" valign="top" style="width:350px !important">
3174 + <label><?php echo __('Email Subject', 'loginizer'); ?></label><br>
3175 + <span class="exp"><?php echo __('Set blank to reset to the default subject', 'loginizer'); ?></span>
3176 + <br />Default : <?php echo @$loginizer['2fa_email_d_sub']; ?>
3177 + </td>
3178 + <td valign="top">
3179 + <input type="text" size="40" value="<?php echo lz_optpost('lz_2fa_email_sub', @$lz_options['2fa_email_sub']); ?>" name="lz_2fa_email_sub" />
3180 + </td>
3181 + </tr>
3182 + <tr>
3183 + <td scope="row" valign="top">
3184 + <label><?php echo __('Email Body', 'loginizer'); ?></label><br>
3185 + <span class="exp"><?php echo __('Set blank to reset to the default message', 'loginizer'); ?></span>
3186 + <br />Default : <pre style="font-size:10px"><?php echo @$loginizer['2fa_email_d_msg']; ?></pre>
3187 + </td>
3188 + <td valign="top">
3189 + <textarea rows="10" name="lz_2fa_email_msg"><?php echo lz_optpost('lz_2fa_email_msg', @$lz_options['2fa_email_msg']); ?></textarea>
3190 + <br />
3191 + Variables :
3192 + <br />$otp - The OTP for login
3193 + <br />$site_name - The Site Name
3194 + <br />$site_url - The Site URL
3195 + <br />$email - Users Email
3196 + <br />$display_name - Users Display Name
3197 + <br />$user_login - Username
3198 + <br />$first_name - Users First Name
3199 + <br />$last_name - Users Last Name
3200 + </td>
3201 + </tr>
3202 + </table><br />
3203 + <center><input name="save_2fa_email_template_lz" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
3204 + </form>
3205 +
3206 + </div>
3207 + </div>
3208 +
3209 + <div id="" class="postbox">
3210 +
3211 + <div class="postbox-header">
3212 + <h2 class="hndle ui-sortable-handle">
3213 + <span><?php echo __('Custom Messages for OTP', 'loginizer'); ?></span>
3214 + </h2>
3215 + </div>
3216 +
3217 + <div class="inside">
3218 +
3219 + <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
3220 + <?php wp_nonce_field('loginizer-options'); ?>
3221 + <table class="form-table">
3222 + <tr>
3223 + <td colspan="2" valign="top">
3224 + <?php echo __('Customize the title for OTP field displayed to the user on the login form.', 'loginizer'); ?><br>
3225 + <?php echo __('If you do not make changes below the default messages will be used !', 'loginizer'); ?>
3226 + </td>
3227 + </tr>
3228 + <tr>
3229 + <td scope="row" valign="top" style="width:350px !important">
3230 + <label for="msg_otp_app"><?php echo __('OTP via APP','loginizer'); ?></label><br />
3231 + <?php echo __('Default: <em>&quot;' . $loginizer['2fa_d_msg']['otp_app']. '&quot;</em>', 'loginizer'); ?>
3232 + </td>
3233 + <td>
3234 + <input type="text" size="50" value="<?php echo esc_attr(@$saved_msgs['otp_app']); ?>" name="msg_otp_app" id="msg_otp_app" style="width:auto !important;" />
3235 + <br />
3236 + </td>
3237 + </tr>
3238 + <tr>
3239 + <td scope="row" valign="top" style="width:350px !important">
3240 + <label for="msg_otp_email"><?php echo __('OTP via Email','loginizer'); ?></label><br />
3241 + <?php echo __('Default: <em>&quot;' . $loginizer['2fa_d_msg']['otp_email']. '&quot;</em>', 'loginizer'); ?>
3242 + </td>
3243 + <td>
3244 + <input type="text" size="50" value="<?php echo esc_attr(@$saved_msgs['otp_email']); ?>" name="msg_otp_email" id="msg_otp_email" style="width:auto !important;" />
3245 + <br />
3246 + </td>
3247 + </tr>
3248 + <tr>
3249 + <td scope="row" valign="top" style="width:350px !important">
3250 + <label for="msg_otp_field"><?php echo __('Title for OTP field','loginizer'); ?></label><br />
3251 + <?php echo __('Default: <em>&quot;' . $loginizer['2fa_d_msg']['otp_field']. '&quot;</em>', 'loginizer'); ?>
3252 + </td>
3253 + <td>
3254 + <input type="text" size="50" value="<?php echo esc_attr(@$saved_msgs['otp_field']); ?>" name="msg_otp_field" id="msg_otp_field" style="width:auto !important;" />
3255 + <br />
3256 + </td>
3257 + </tr>
3258 + <tr>
3259 + <td scope="row" valign="top" style="width:350px !important">
3260 + <label for="msg_otp_question"><?php echo __('Title for Security Question','loginizer'); ?></label><br />
3261 + <?php echo __('Default: <em>&quot;' . $loginizer['2fa_d_msg']['otp_question']. '&quot;</em>', 'loginizer'); ?>
3262 + </td>
3263 + <td>
3264 + <input type="text" size="50" value="<?php echo esc_attr(@$saved_msgs['otp_question']); ?>" name="msg_otp_question" id="msg_otp_question" style="width:auto !important;" />
3265 + <br />
3266 + </td>
3267 + </tr>
3268 + <tr>
3269 + <td scope="row" valign="top" style="width:350px !important">
3270 + <label for="msg_otp_answer"><?php echo __('Title for Security Answer','loginizer'); ?></label><br />
3271 + <?php echo __('Default: <em>&quot;' . $loginizer['2fa_d_msg']['otp_answer']. '&quot;</em>', 'loginizer'); ?>
3272 + </td>
3273 + <td>
3274 + <input type="text" size="50" value="<?php echo esc_attr(@$saved_msgs['otp_answer']); ?>" name="msg_otp_answer" id="msg_otp_answer" style="width:auto !important;" />
3275 + <br />
3276 + </td>
3277 + </tr>
3278 + </table><br />
3279 + <center><input name="save_msgs_lz" class="button button-primary action" value="<?php echo __('Save Messages','loginizer'); ?>" type="submit" /></center>
3280 + </form>
3281 + </div>
3282 + </div>
3283 +
3284 + <!--Bypass a single user-->
3285 + <div id="" class="postbox">
3286 +
3287 + <div class="postbox-header">
3288 + <h2 class="hndle ui-sortable-handle">
3289 + <span><?php echo __('Disable Two Factor Authentication for a User', 'loginizer'); ?></span>
3290 + </h2>
3291 + </div>
3292 +
3293 + <div class="inside">
3294 +
3295 + <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
3296 + <?php wp_nonce_field('loginizer-options'); ?>
3297 + <table class="form-table">
3298 + <tr>
3299 + <td scope="row" valign="top" colspan="2">
3300 + <i><?php echo __('Here you can disable the Two Factor Authentication settings of a user. In the event a user has forgotten his secret answer or lost his Device App, he will not be able to login. You can reset such a users settings from here.', 'loginizer'); ?></i>
3301 + </td>
3302 + </tr>
3303 + <tr>
3304 + <td scope="row" valign="top">
3305 + <label><?php echo __('Username / Email', 'loginizer'); ?></label><br>
3306 + <span class="exp"><?php echo __('The username or email of the user whose 2FA you would like to disable', 'loginizer'); ?></span>
3307 + </td>
3308 + <td>
3309 + <input type="text" size="50" value="<?php echo lz_optpost('lz_user_2fa_disable', ''); ?>" name="lz_user_2fa_disable" />
3310 + </td>
3311 + </tr>
3312 + </table><br />
3313 +
3314 + <center><input name="reset_user_lz" class="button button-primary action" value="<?php echo __('Reset 2FA for User', 'loginizer'); ?>" type="submit" /></center>
3315 + </form>
3316 +
3317 + </div>
3318 + </div>
3319 +
3320 + <br />
3321 +
3322 +<?php
3323 +
3324 + wp_enqueue_script('jquery-paginate', LOGINIZER_URL.'/jquery-paginate.js', array('jquery'), '1.10.15');
3325 +
3326 +?>
3327 +
3328 +<style>
3329 +.page-navigation a {
3330 +margin: 5px 2px;
3331 +display: inline-block;
3332 +padding: 5px 8px;
3333 +color: #0073aa;
3334 +background: #e5e5e5 none repeat scroll 0 0;
3335 +border: 1px solid #ccc;
3336 +text-decoration: none;
3337 +transition-duration: 0.05s;
3338 +transition-property: border, background, color;
3339 +transition-timing-function: ease-in-out;
3340 +}
3341 +
3342 +.page-navigation a[data-selected] {
3343 +background-color: #00a0d2;
3344 +color: #fff;
3345 +}
3346 +</style>
3347 +
3348 +<script>
3349 +
3350 +jQuery(document).ready(function(){
3351 + jQuery('#lz_wl_2fa_table').paginate({ limit: 11, navigationWrapper: jQuery('#lz_wl_2fa_nav')});
3352 +});
3353 +
3354 +// Delete a 2FA Whitelist IP Range
3355 +function del_2fa_confirm(field, todo_id, msg){
3356 + var ret = confirm(msg);
3357 +
3358 + if(ret){
3359 + jQuery('#lz_wl_2fa_todo').attr('name', field);
3360 + jQuery('#lz_wl_2fa_todo').val(todo_id);
3361 + jQuery('#lz_wl_2fa_form').submit();
3362 + }
3363 +
3364 + return false;
3365 +
3366 +}
3367 +
3368 +// Delete all 2FA Whitelist IP Ranges
3369 +function del_2fa_confirm_all(msg){
3370 + var ret = confirm(msg);
3371 +
3372 + if(ret){
3373 + return true;
3374 + }
3375 +
3376 + return false;
3377 +
3378 +}
3379 +
3380 +</script>
3381 +
3382 + <div id="" class="postbox">
3383 +
3384 + <div class="postbox-header">
3385 + <h2 class="hndle ui-sortable-handle">
3386 + <span><?php echo __('Disable Two Factor Authentication for IP', 'loginizer'); ?></span>
3387 + </h2>
3388 + </div>
3389 +
3390 + <div class="inside">
3391 +
3392 + <?php echo __('Enter the IP you want to whitelist for two factor authentication', 'loginizer'); ?>
3393 + <form action="" method="post" loginizer-premium-only="1">
3394 + <?php wp_nonce_field('loginizer-options'); ?>
3395 + <table class="form-table">
3396 + <tr>
3397 + <th scope="row" valign="top"><label for="start_ip_w_2fa"><?php echo __('Start IP','loginizer'); ?></label></th>
3398 + <td>
3399 + <input type="text" size="25" style="width:auto;" value="<?php echo(lz_optpost('start_ip_w_2fa')); ?>" name="start_ip_w_2fa" id="start_ip_w_2fa"/> <?php echo __('Start IP of the range','loginizer'); ?> <br />
3400 + </td>
3401 + </tr>
3402 + <tr>
3403 + <th scope="row" valign="top"><label for="end_ip_w_2fa"><?php echo __('End IP (Optional)','loginizer'); ?></label></th>
3404 + <td>
3405 + <input type="text" size="25" style="width:auto;" value="<?php echo(lz_optpost('end_ip_w_2fa')); ?>" name="end_ip_w_2fa" id="end_ip_w_2fa"/> <?php echo __('End IP of the range. <br />If you want to whitelist single IP leave this field blank.','loginizer'); ?> <br />
3406 + </td>
3407 + </tr>
3408 + </table><br />
3409 + <input name="2fa_whitelist_iprange" class="button button-primary action" value="<?php echo __('Add Whitelist IP Range','loginizer'); ?>" type="submit" />
3410 + <input style="float:right" name="del_all_whitelist" onclick="return del_2fa_confirm_all('<?php echo __('Are you sure you want to delete all Whitelist IP Range(s) for 2FA ?','loginizer'); ?>')" class="button action" value="<?php echo __('Delete All Whitelist IP Range(s) for 2FA','loginizer'); ?>" type="submit" />
3411 + </form>
3412 + </div>
3413 +
3414 + <div id="lz_wl_2fa_nav" style="margin: 5px 10px; text-align:right"></div>
3415 + <table id="lz_wl_2fa_table" class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
3416 + <tr>
3417 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
3418 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
3419 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
3420 + <th scope="row" valign="top" style="background:#EFEFEF;" width="100"><?php echo __('Options','loginizer'); ?></th>
3421 + </tr>
3422 + <?php
3423 + if(empty($loginizer['2fa_whitelist'])){
3424 + echo '
3425 + <tr>
3426 + <td colspan="4">
3427 + '.__('No Whitelist IPs for Two Factor Authentication. You will see whitelisted IP ranges here.', 'loginizer').'
3428 + </td>
3429 + </tr>';
3430 + }else{
3431 + foreach($loginizer['2fa_whitelist'] as $ik => $iv){
3432 + echo '
3433 + <tr>
3434 + <td>
3435 + '.$iv['start'].'
3436 + </td>
3437 + <td>
3438 + '.$iv['end'].'
3439 + </td>
3440 + <td>
3441 + '.date('d/m/Y', $iv['time']).'
3442 + </td>
3443 + <td>
3444 + <a class="submitdelete" href="javascript:void(0)" onclick="return del_2fa_confirm(\'delid\', '.$ik.', \'Are you sure you want to delete this IP range for 2FA ?\')">Delete</a>
3445 + </td>
3446 + </tr>';
3447 + }
3448 + }
3449 + ?>
3450 + </table>
3451 + <br />
3452 + <form action="" method="post" id="lz_wl_2fa_form">
3453 + <?php wp_nonce_field('loginizer-options'); ?>
3454 + <input type="hidden" value="" name="" id="lz_wl_2fa_todo"/>
3455 + </form>
3456 + <br />
3457 +
3458 + </div>
3459 +
3460 + <?php
3461 + loginizer_page_footer();
3462 +
3463 +}
3464 +
3465 +// Loginizer - PasswordLess Page
3466 +function loginizer_page_passwordless(){
3467 +
3468 + global $loginizer, $lz_error, $lz_env;
3469 +
3470 + if(!current_user_can('manage_options')){
3471 + wp_die('Sorry, but you do not have permissions to change settings.');
3472 + }
3473 +
3474 + if(!loginizer_is_premium() && count($_POST) > 0){
3475 + $lz_error['not_in_free'] = __('This feature is not available in the Free version. <a href="'.LOGINIZER_PRICING_URL.'" target="_blank" style="text-decoration:none; color:green;"><b>Upgrade to Pro</b></a>', 'loginizer');
3476 + return loginizer_page_passwordless_T();
3477 + }
3478 +
3479 + /* Make sure post was from this page */
3480 + if(count($_POST) > 0){
3481 + check_admin_referer('loginizer-options');
3482 + }
3483 +
3484 + if(isset($_POST['save_lz'])){
3485 +
3486 + // In the future there can be more settings
3487 + $option['email_pass_less'] = (int) lz_optpost('email_pass_less');
3488 + $option['passwordless_sub'] = lz_optpost('lz_passwordless_sub');
3489 + $option['passwordless_msg'] = lz_optpost('lz_passwordless_msg');
3490 + $option['passwordless_html'] = (int) lz_optpost('lz_passwordless_html');
3491 +
3492 + // Is there an error ?
3493 + if(!empty($lz_error)){
3494 + return loginizer_page_passwordless_T();
3495 + }
3496 +
3497 + // Save the options
3498 + update_option('loginizer_epl', $option);
3499 +
3500 + // Mark as saved
3501 + $GLOBALS['lz_saved'] = true;
3502 +
3503 + }
3504 +
3505 + // Call theme
3506 + loginizer_page_passwordless_T();
3507 +}
3508 +
3509 +// Loginizer - PasswordLess Page Theme
3510 +function loginizer_page_passwordless_T(){
3511 +
3512 + global $loginizer, $lz_error, $lz_env;
3513 +
3514 + $lz_options = get_option('loginizer_epl');
3515 +
3516 + // Universal header
3517 + loginizer_page_header('PasswordLess Settings');
3518 +
3519 + loginizer_feature_available('PasswordLess Login');
3520 +
3521 + // Saved ?
3522 + if(!empty($GLOBALS['lz_saved'])){
3523 + echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
3524 + }
3525 +
3526 + // Any errors ?
3527 + if(!empty($lz_error)){
3528 + lz_report_error($lz_error);echo '<br />';
3529 + }
3530 +
3531 + ?>
3532 +
3533 +<style>
3534 +input[type="text"], textarea, select {
3535 + width: 90%;
3536 +}
3537 +
3538 +.form-table label{
3539 + font-weight:bold;
3540 +}
3541 +
3542 +.form-table td{
3543 + vertical-align:top;
3544 +}
3545 +
3546 +.exp{
3547 + font-size:12px;
3548 +}
3549 +</style>
3550 +
3551 + <div id="" class="postbox">
3552 +
3553 + <div class="postbox-header">
3554 + <h2 class="hndle ui-sortable-handle">
3555 + <span><?php echo __('PasswordLess Settings', 'loginizer'); ?></span>
3556 + </h2>
3557 + </div>
3558 +
3559 + <div class="inside">
3560 +
3561 + <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
3562 + <?php wp_nonce_field('loginizer-options'); ?>
3563 + <table class="form-table">
3564 + <tr>
3565 + <th scope="row" valign="top" style="width:350px !important"><label for="email_pass_less"><?php echo __('Enable PasswordLess Login', 'loginizer'); ?></label></th>
3566 + <td>
3567 + <input type="checkbox" value="1" name="email_pass_less" id="email_pass_less" <?php echo lz_POSTchecked('email_pass_less', (empty($loginizer['email_pass_less']) ? false : true)); echo (defined('SITEPAD') ? 'disabled="disabled"' : '') ?> />
3568 + </td>
3569 + </tr>
3570 + <tr>
3571 + <td colspan="2" valign="top">
3572 + <?php echo __('If enabled, the login screen will just ask for the username <b>OR</b> email address of the user. If such a user exists, an email with a <b>One Time Login </b> link will be sent to the email address of the user. The link will be valid for 10 minutes only.', 'loginizer'); ?><br><br>
3573 + <?php echo __('If a wrong username/email is given, the brute force checker will prevent any brute force attempt !', 'loginizer'); ?>
3574 + </td>
3575 + </tr>
3576 + <tr>
3577 + <td scope="row" valign="top">
3578 + <label for="lz_passwordless_sub"><?php echo __('Email Subject', 'loginizer'); ?></label><br>
3579 + <span class="exp"><?php echo __('Set blank to reset to the default subject', 'loginizer'); ?></span>
3580 + <br />Default : <?php echo @$loginizer['pl_d_sub']; ?>
3581 + </td>
3582 + <td valign="top">
3583 + <input type="text" size="40" value="<?php echo lz_optpost('lz_passwordless_sub', @$lz_options['passwordless_sub']); ?>" name="lz_passwordless_sub" id="lz_passwordless_sub" />
3584 + </td>
3585 + </tr>
3586 + <tr>
3587 + <td scope="row" valign="top">
3588 + <label for="lz_passwordless_msg"><?php echo __('Email Body', 'loginizer'); ?></label><br>
3589 + <span class="exp"><?php echo __('Set blank to reset to the default message', 'loginizer'); ?></span>
3590 + <br />Default : <pre style="font-size:10px"><?php echo @$loginizer['pl_d_msg']; ?></pre>
3591 + </td>
3592 + <td valign="top">
3593 + <textarea rows="10" name="lz_passwordless_msg" id="lz_passwordless_msg"><?php echo lz_optpost('lz_passwordless_msg', @$lz_options['passwordless_msg']); ?></textarea>
3594 + <br />
3595 + Variables :
3596 + <br />$email - Users Email
3597 + <br />$site_name - The Site Name
3598 + <br />$site_url - The Site URL
3599 + <br />$login_url - The Login URL
3600 + </td>
3601 + </tr>
3602 + <tr>
3603 + <th scope="row" valign="top" style="width:350px !important"><label for="lz_passwordless_html"><?php echo __('Send email as HTML', 'loginizer'); ?></label></th>
3604 + <td>
3605 + <input type="checkbox" value="1" name="lz_passwordless_html" id="lz_passwordless_html" <?php echo lz_POSTchecked('lz_passwordless_html', (empty($loginizer['passwordless_html']) ? false : true)); ?> />
3606 + </td>
3607 + </tr>
3608 + </table><br />
3609 + <center><input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
3610 + </form>
3611 +
3612 + </div>
3613 + </div>
3614 + <br />
3615 +
3616 + <?php
3617 + loginizer_page_footer();
3618 +
3619 +}
3620 +
3621 +// Loginizer - Security Settings Page
3622 +function loginizer_page_security(){
3623 +
3624 + global $loginizer, $lz_error, $lz_env, $wpdb;
3625 +
3626 + if(!current_user_can('manage_options')){
3627 + wp_die('Sorry, but you do not have permissions to change settings.');
3628 + }
3629 +
3630 + if(!loginizer_is_premium() && count($_POST) > 0){
3631 + $lz_error['not_in_free'] = __('This feature is not available in the Free version. <a href="'.LOGINIZER_PRICING_URL.'" target="_blank" style="text-decoration:none; color:green;"><b>Upgrade to Pro</b></a>', 'loginizer');
3632 + return loginizer_page_security_T();
3633 + }
3634 +
3635 + /* Make sure post was from this page */
3636 + if(count($_POST) > 0){
3637 + check_admin_referer('loginizer-options');
3638 + }
3639 +
3640 + if(isset($_POST['save_lz'])){
3641 +
3642 + $option['login_slug'] = lz_optpost('login_slug');
3643 + $option['rename_login_secret'] = (int) lz_optpost('rename_login_secret');
3644 + $option['xmlrpc_slug'] = lz_optpost('xmlrpc_slug');
3645 + $option['xmlrpc_disable'] = (int) lz_optpost('xmlrpc_disable');
3646 + $option['pingbacks_disable'] = (int) lz_optpost('pingbacks_disable');
3647 +
3648 + // Login Slug Valid ?
3649 + if(!empty($option['login_slug'])){
3650 + if(strlen($option['login_slug']) <= 4 || strlen($option['login_slug']) > 50){
3651 + $lz_error['login_slug'] = __('The Login slug length must be greater than <b>4</b> chars and upto <b>50</b> chars long', 'loginizer');
3652 + }
3653 + }
3654 +
3655 + // XML-RPC Slug Valid ?
3656 + if(!empty($option['xmlrpc_slug'])){
3657 + if(strlen($option['xmlrpc_slug']) <= 4 || strlen($option['xmlrpc_slug']) > 50){
3658 + $lz_error['xmlrpc_slug'] = __('The XML-RPC slug length must be greater than <b>4</b> chars and upto <b>50</b> chars long', 'loginizer');
3659 + }
3660 + }
3661 +
3662 + // Is there an error ?
3663 + if(!empty($lz_error)){
3664 + return loginizer_page_security_T();
3665 + }
3666 +
3667 + // Save the options
3668 + update_option('loginizer_security', $option);
3669 +
3670 + // Mark as saved
3671 + $GLOBALS['lz_saved'] = true;
3672 +
3673 + }
3674 +
3675 + // Reset the username
3676 + if(isset($_POST['save_lz_admin'])){
3677 +
3678 + // Get the new username
3679 + $current_username = lz_optpost('current_username');
3680 + $new_username = lz_optpost('new_username');
3681 +
3682 + if(empty($current_username)){
3683 + $lz_error['current_username_empty'] = __('Current username is required', 'loginizer');
3684 + return loginizer_page_security_T();
3685 + }
3686 +
3687 + if(empty($new_username)){
3688 + $lz_error['new_username_empty'] = __('New username is required', 'loginizer');
3689 + return loginizer_page_security_T();
3690 + }
3691 +
3692 + // Is the starting of the username having 'admin' ?
3693 + if(@strtolower(substr($new_username, 0, 5)) == 'admin'){
3694 + $lz_error['user_exists'] = __('The username begins with <b>admin</b>. Please change it !', 'loginizer');
3695 + return loginizer_page_security_T();
3696 + }
3697 +
3698 + // Lets check if there is such a user
3699 + $found = get_user_by('login', $new_username);
3700 +
3701 + // Found one !
3702 + if(!empty($found->ID)){
3703 + $lz_error['user_exists'] = __('The new username is already assigned to another user', 'loginizer');
3704 + return loginizer_page_security_T();
3705 + }
3706 +
3707 + $old_user = get_user_by('login', $current_username);
3708 +
3709 + if(empty($old_user->ID)){
3710 + $lz_error['current_username_invalid'] = __('No user found with the current username provided', 'loginizer');
3711 + return loginizer_page_security_T();
3712 + }
3713 +
3714 + if(empty($old_user->caps['administrator'])){
3715 + $lz_error['user_not_admin'] = __('The user is not an administrator. Only administrator user\'s username can be changed.', 'loginizer');
3716 + return loginizer_page_security_T();
3717 + }
3718 +
3719 + // Update the username
3720 + $update_data = array('user_login' => $new_username);
3721 + $where_data = array('ID' => $old_user->ID);
3722 +
3723 + $format = array('%s');
3724 + $where_format = array('%d');
3725 +
3726 + $wpdb->update($wpdb->prefix.'users', $update_data, $where_data, $format, $where_format);
3727 +
3728 + // Mark as saved
3729 + $GLOBALS['lz_saved'] = true;
3730 +
3731 + }
3732 +
3733 + // Change the wp-admin slug
3734 + if(isset($_POST['save_lz_wp_admin'])){
3735 +
3736 + // Get the new username
3737 + $option['admin_slug'] = lz_optpost('admin_slug');
3738 + $option['restrict_wp_admin'] = (int) lz_optpost('restrict_wp_admin');
3739 + $option['wp_admin_msg'] = @stripslashes($_POST['wp_admin_msg']);
3740 + $lz_wp_admin_docs = (int) lz_optpost('lz_wp_admin_docs');
3741 +
3742 + // Did you agree to this ?
3743 + if(!empty($option['admin_slug']) && empty($lz_wp_admin_docs)){
3744 + $lz_error['lz_wp_admin_docs'] = __('You have not confirmed that you have read the guide and configured .htaccess. Please read the guide, configure .htaccess and then save these settings and check this checkbox', 'loginizer');
3745 + return loginizer_page_security_T();
3746 + }
3747 +
3748 + // Length
3749 + if(!empty($option['admin_slug']) && (strlen($option['admin_slug']) <= 4 || strlen($option['admin_slug']) > 50)){
3750 + $lz_error['admin_slug'] = __('The new Admin slug length must be greater than <b>4</b> chars and upto <b>50</b> chars long', 'loginizer');
3751 + return loginizer_page_security_T();
3752 + }
3753 +
3754 + // Only regular characters
3755 + if(preg_match('/[^\w\d\-_]/is', $option['admin_slug'])){
3756 + $lz_error['admin_slug_chars'] = __('Special characters are not allowed', 'loginizer');
3757 + return loginizer_page_security_T();
3758 + }
3759 +
3760 + // Update the option
3761 + update_option('loginizer_wp_admin', $option);
3762 +
3763 + // Mark as saved
3764 + $GLOBALS['lz_saved'] = true;
3765 +
3766 + }
3767 +
3768 +
3769 + // Save blacklisted usernames
3770 + if(isset($_POST['save_lz_bl_users'])){
3771 +
3772 + $usernames = isset($_POST['lz_bl_users']) && is_array($_POST['lz_bl_users']) ? $_POST['lz_bl_users'] : array();
3773 +
3774 + // Process the usernames i.e. remove blanks
3775 + foreach($usernames as $k => $v){
3776 + $v = trim($v);
3777 +
3778 + // Unset blank values
3779 + if(empty($v)){
3780 + unset($usernames[$k]);
3781 + }
3782 +
3783 + // Disallow these special characters to avoid XSS or any other security vulnerability
3784 + if(preg_match('/[\<\>\"\']/', $v)){
3785 + unset($usernames[$k]);
3786 + }
3787 + }
3788 +
3789 + // Update the blacklist
3790 + update_option('loginizer_username_blacklist', array_values($usernames));
3791 +
3792 + // Mark as saved
3793 + $GLOBALS['lz_saved'] = true;
3794 +
3795 + }
3796 +
3797 +
3798 + // Save blacklisted domains
3799 + if(isset($_POST['save_lz_bl_domains'])){
3800 +
3801 + $domains = isset($_POST['lz_bl_domains']) && is_array($_POST['lz_bl_domains']) ? $_POST['lz_bl_domains'] : array();
3802 +
3803 + // Process the domains i.e. remove blanks
3804 + foreach($domains as $k => $v){
3805 + $v = trim($v);
3806 +
3807 + // Unset blank values
3808 + if(empty($v)){
3809 + unset($domains[$k]);
3810 + }
3811 +
3812 + // Disallow these special characters to avoid XSS or any other security vulnerability
3813 + if(preg_match('/[\<\>\"\']/', $v)){
3814 + unset($domains[$k]);
3815 + }
3816 + }
3817 +
3818 + // Update the blacklist
3819 + update_option('loginizer_domains_blacklist', array_values($domains));
3820 +
3821 + // Mark as saved
3822 + $GLOBALS['lz_saved'] = true;
3823 +
3824 + }
3825 +
3826 + // Call theme
3827 + loginizer_page_security_T();
3828 +
3829 +}
3830 +
3831 +// Loginizer - Security Settings Page Theme
3832 +function loginizer_page_security_T(){
3833 +
3834 + global $loginizer, $lz_error, $lz_env;
3835 +
3836 + // Universal header
3837 + loginizer_page_header('Security Settings');
3838 +
3839 + loginizer_feature_available('Security Settings');
3840 +
3841 + // Saved ?
3842 + if(!empty($GLOBALS['lz_saved'])){
3843 + echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
3844 + }
3845 +
3846 + // Any errors ?
3847 + if(!empty($lz_error)){
3848 + lz_report_error($lz_error);echo '<br />';
3849 + }
3850 +
3851 + $current_admin = get_user_by('id', 1);
3852 +
3853 + ?>
3854 +
3855 +<style>
3856 +input[type="text"], textarea, select {
3857 + width: 70%;
3858 +}
3859 +
3860 +.form-table label{
3861 + font-weight:bold;
3862 +}
3863 +
3864 +.exp{
3865 + font-size:12px;
3866 +}
3867 +</style>
3868 +
3869 +<form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
3870 +
3871 + <div id="" class="postbox">
3872 +
3873 + <div class="postbox-header">
3874 + <h2 class="hndle ui-sortable-handle">
3875 + <span><?php echo __('Rename Login Page', 'loginizer'); ?></span>
3876 + </h2>
3877 + </div>
3878 +
3879 + <div class="inside">
3880 +
3881 + <?php wp_nonce_field('loginizer-options'); ?>
3882 + <table class="form-table">
3883 + <tr>
3884 + <td scope="row" valign="top" colspan="2">
3885 + <i>You can rename your Login page from <b><?php echo $loginizer['login_basename']; ?></b> to anything of your choice e.g. mylogin. This would make it very difficult for automated attack bots to know where to login !</i>
3886 + </td>
3887 + </tr>
3888 + <tr>
3889 + <td scope="row" valign="top" style="width:40% !important">
3890 + <label><?php echo __('New Login Slug', 'loginizer'); ?></label><br>
3891 + <span class="exp"><?php echo __('Set blank to reset to the original login URL', 'loginizer'); ?></span>
3892 + </td>
3893 + <td>
3894 + <input type="text" size="50" value="<?php echo lz_POSTval('login_slug', $loginizer['login_slug']); ?>" name="login_slug" />
3895 + </td>
3896 + </tr>
3897 +
3898 +<?php
3899 +
3900 +if(!defined('SITEPAD')){
3901 +
3902 +?>
3903 + <tr>
3904 + <td scope="row" valign="top" style="width:200px !important">
3905 + <label><?php echo __('Access Secretly Only', 'loginizer'); ?></label><br>
3906 + <span class="exp"><?php echo __('If set, then all Login URL\'s will still point to '.$loginizer['login_basename'].' and users will have to access the New Login Slug by typing it in the browser.', 'loginizer'); ?></span>
3907 + </td>
3908 + <td>
3909 + <input type="checkbox" value="1" name="rename_login_secret" <?php echo lz_POSTchecked('rename_login_secret', (empty($loginizer['rename_login_secret']) ? false : true)); ?> />
3910 + </td>
3911 + </tr>
3912 +
3913 +<?php
3914 +
3915 +}
3916 +
3917 +?>
3918 + </table><br />
3919 + <center><input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
3920 +
3921 + </div>
3922 + </div>
3923 + <br />
3924 +
3925 + <?php
3926 +
3927 + if(!defined('SITEPAD')){
3928 +
3929 + ?>
3930 +
3931 + <div id="" class="postbox">
3932 +
3933 + <div class="postbox-header">
3934 + <h2 class="hndle ui-sortable-handle">
3935 + <span><?php echo __('XML-RPC Settings', 'loginizer'); ?></span>
3936 + </h2>
3937 + </div>
3938 +
3939 + <div class="inside">
3940 +
3941 + <?php wp_nonce_field('loginizer-options'); ?>
3942 + <table class="form-table">
3943 + <tr>
3944 + <td scope="row" valign="top" colspan="2">
3945 + <i><?php echo __('WordPress\'s XML-RPC feature allows external services to access and modify content on the site. Services like the Jetpack plugin, the WordPress mobile app, pingbacks, etc make use of the XML-RPC feature. If this site does not use a service that requires XML-RPC, please <b>disable</b> the XML-RPC feature as it prevents attackers from using the feature to attack the site. If your service can use a custom XML-RPC URL, you can also <b>rename</b> the XML-RPC page to a <b>custom slug</b>.', 'loginizer'); ?></i>
3946 + </td>
3947 + </tr>
3948 + <tr>
3949 + <td scope="row" valign="top" style="width:40% !important">
3950 + <label><?php echo __('Disable XML-RPC', 'loginizer'); ?></label>
3951 + </td>
3952 + <td>
3953 + <input type="checkbox" value="1" name="xmlrpc_disable" <?php echo lz_POSTchecked('xmlrpc_disable', (empty($loginizer['xmlrpc_disable']) ? false : true)); ?> />
3954 + </td>
3955 + </tr>
3956 + <tr>
3957 + <td scope="row" valign="top" style="width:40% !important">
3958 + <label><?php echo __('Disable Pingbacks', 'loginizer'); ?></label>
3959 + </td>
3960 + <td>
3961 + <input type="checkbox" value="1" name="pingbacks_disable" <?php echo lz_POSTchecked('pingbacks_disable', (empty($loginizer['pingbacks_disable']) ? false : true)); ?> />
3962 + </td>
3963 + </tr>
3964 + <tr>
3965 + <td scope="row" valign="top">
3966 + <label><?php echo __('New XML-RPC Slug', 'loginizer'); ?></label><br>
3967 + <span class="exp"><?php echo __('Set blank to reset to the original XML-RPC URL', 'loginizer'); ?></span>
3968 + </td>
3969 + <td>
3970 + <input type="text" size="50" value="<?php echo lz_optpost('xmlrpc_slug', $loginizer['xmlrpc_slug']); ?>" name="xmlrpc_slug" />
3971 + </td>
3972 + </tr>
3973 + </table><br />
3974 + <center><input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
3975 +
3976 + </div>
3977 + </div>
3978 + <br />
3979 +
3980 + <?php
3981 +
3982 + }
3983 +
3984 + ?>
3985 +
3986 +</form>
3987 +
3988 +<?php
3989 +
3990 +if(!defined('SITEPAD')){
3991 +
3992 +?>
3993 +
3994 +<script type="text/javascript">
3995 +
3996 +
3997 +function dirname(path) {
3998 + return path.replace(/\\/g, '/').replace(/\/[^/]*\/?$/, '');
3999 +}
4000 +
4001 +function lz_test_wp_admin(){
4002 +
4003 + var data = new Object();
4004 + data["action"] = "loginizer_wp_admin";
4005 + data["nonce"] = "<?php echo wp_create_nonce('loginizer_admin_ajax');?>";
4006 +
4007 + var new_ajaxurl = dirname(dirname(ajaxurl))+'/'+jQuery('#lz_admin_slug').val()+'/admin-ajax.php';
4008 +
4009 + // AJAX and on success function
4010 + jQuery.post(new_ajaxurl, data, function(response){
4011 +
4012 + if(response['result'] == 1){
4013 + alert("<?php echo __('Everything seems to be good. You can proceed to save the settings !', 'loginizer'); ?>");
4014 + }
4015 +
4016 + // Throw an error for failures
4017 + }).fail(function() {
4018 + alert("<?php echo __('There was an error connecting to WordPress with the new Admin Slug. Did you configure everything properly ?', 'loginizer'); ?>");
4019 + });
4020 + //jQuery.ajax('<input type="text" size="30" value="" name="lz_bl_users[]" class="lz_bl_users" />');
4021 + return false;
4022 +};
4023 +
4024 +</script>
4025 +
4026 +<form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
4027 + <div id="" class="postbox">
4028 +
4029 + <div class="postbox-header">
4030 + <h2 class="hndle ui-sortable-handle">
4031 + <span><?php echo __('Rename wp-admin access', 'loginizer'); ?></span>
4032 + </h2>
4033 + </div>
4034 +
4035 + <div class="inside">
4036 +
4037 + <?php wp_nonce_field('loginizer-options'); ?>
4038 + <table class="form-table">
4039 + <?php
4040 + if(preg_match('/(apache|litespeed|lsws)/is', $_SERVER["SERVER_SOFTWARE"])){
4041 + // Supported. Do nothing
4042 + }else{
4043 + echo '<tr>
4044 + <td scope="row" valign="top" colspan="2">
4045 + <div style="color:#a94442; background-color:#f2dede; border-color:#ebccd1; padding:15px; border:1px solid transparent; border-radius:4px;">'.__('Rename wp-admin access feature is supported only on Apache and Litespeed', 'loginizer').'</div>
4046 + </td>
4047 + </tr>';
4048 + }
4049 + ?>
4050 + <tr>
4051 + <td scope="row" valign="top" colspan="2">
4052 + <i>You can rename your WordPress Admin access URL <b>wp-admin</b> to anything of your choice e.g. my-admin. This will require you to change .htaccess, so please follow <a href="<?php echo LOGINIZER_DOCS;?>Renaming_the_WP-Admin_Area" target="_blank">our guide</a> on how to do so !</i>
4053 + </td>
4054 + </tr>
4055 + <tr>
4056 + <td scope="row" valign="top" style="width:40% !important">
4057 + <label><?php echo __('New wp-admin Slug', 'loginizer'); ?></label><br>
4058 + <span class="exp"><?php echo __('Set blank to reset to the original wp-admin URL', 'loginizer'); ?></span>
4059 + </td>
4060 + <td>
4061 + <input type="text" size="50" value="<?php echo lz_optpost('admin_slug', $loginizer['admin_slug']); ?>" name="admin_slug" id="lz_admin_slug" />
4062 + </td>
4063 + </tr>
4064 + <tr>
4065 + <td scope="row" valign="top" style="width:200px !important">
4066 + <label><?php echo __('Disable wp-admin access', 'loginizer'); ?></label><br>
4067 + <span class="exp"><?php echo __('If set, then only the new admin slug will work and access to the Old Admin Slug i.e. wp-admin will be disabled. If anyone accesses wp-admin, a warning will be shown.<br><label>NOTE: Please use this option cautiously !</label>', 'loginizer'); ?></span>
4068 + </td>
4069 + <td>
4070 + <input type="checkbox" id="lz_restrict_wp_admin" onchange="lz_wp_admin_msg_toggle()" value="1" name="restrict_wp_admin" <?php echo lz_POSTchecked('restrict_wp_admin', (empty($loginizer['restrict_wp_admin']) ? false : true)); ?> />
4071 + </td>
4072 + </tr>
4073 + <tr id="lz_wp_admin_msg_row" style="display:none">
4074 + <td scope="row" valign="top">
4075 + <label><?php echo __('WP-Admin Error Message', 'loginizer'); ?></label><br>
4076 + <span class="exp"><?php echo __('Error message to show if someone accesses wp-admin', 'loginizer'); ?></span> Default : <?php echo $loginizer['wp_admin_d_msg']; ?>
4077 + </td>
4078 + <td>
4079 + <input type="text" size="50" value="<?php echo lz_htmlizer(!empty($_POST['wp_admin_msg']) ? stripslashes($_POST['wp_admin_msg']) : @$loginizer['wp_admin_msg']); ?>" name="wp_admin_msg" id="lz_wp_admin_msg" />
4080 + </td>
4081 + </tr>
4082 + <tr>
4083 + <td scope="row" valign="top" style="width:200px !important">
4084 + <label><?php echo __('I have setup .htaccess', 'loginizer'); ?></label><br>
4085 + <span class="exp"><?php echo __('You need to confirm that you have configured .htaccess as per <a href="'.LOGINIZER_DOCS.'Renaming_the_WP-Admin_Area" target="_blank">our guide</a> so that we can safely enable this feature', 'loginizer'); ?></span>
4086 + </td>
4087 + <td>
4088 + <input type="checkbox" value="1" name="lz_wp_admin_docs" />
4089 + <input type="button" onclick="lz_test_wp_admin()" class="button" style="background: #5cb85c; color:white; border:#5cb85c" value="<?php echo __('Test New WP-Admin Slug', 'loginizer'); ?>" />
4090 + </td>
4091 + </tr>
4092 + </table><br />
4093 + <center><input name="save_lz_wp_admin" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /></center>
4094 +
4095 + </div>
4096 + </div>
4097 + <br />
4098 +</form>
4099 +
4100 +<script type="text/javascript">
4101 +
4102 +function lz_wp_admin_msg_toggle(){
4103 + var ele = jQuery('#lz_restrict_wp_admin')[0];
4104 + if(ele.checked){
4105 + jQuery('#lz_wp_admin_msg_row').show();
4106 + }else{
4107 + jQuery('#lz_wp_admin_msg_row').hide();
4108 + }
4109 +};
4110 +
4111 +lz_wp_admin_msg_toggle();
4112 +
4113 +</script>
4114 +
4115 +
4116 +<form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
4117 + <div id="" class="postbox">
4118 +
4119 + <div class="postbox-header">
4120 + <h2 class="hndle ui-sortable-handle">
4121 + <span><?php echo __('Change Admin Username', 'loginizer'); ?></span>
4122 + </h2>
4123 + </div>
4124 +
4125 + <div class="inside">
4126 +
4127 + <?php wp_nonce_field('loginizer-options'); ?>
4128 + <table class="form-table">
4129 + <tr>
4130 + <td scope="row" valign="top" colspan="2">
4131 + <i><?php echo __('You can change the Admin Username from here to anything of your choice e.g. iamtheboss. This would make it very difficult for automated attack bots to know what is the admin username !', 'loginizer'); ?></i>
4132 + </td>
4133 + </tr>
4134 + <tr>
4135 + <td scope="row" valign="top" style="width:40% !important">
4136 + <label for="current_username"><?php echo __('Current Username', 'loginizer'); ?></label><br>
4137 + <span class="exp"><?php echo __('The current username you want to change', 'loginizer'); ?></span>
4138 + </td>
4139 + <td>
4140 + <input type="text" size="50" value="<?php echo lz_optpost('current_username', (!empty($current_admin->user_login) ? $current_admin->user_login : '')); ?>" name="current_username" id="current_username" />
4141 + </td>
4142 + </tr>
4143 + <tr>
4144 + <td scope="row" valign="top" style="width:40% !important">
4145 + <label for="new_username"><?php echo __('New Username', 'loginizer'); ?></label><br>
4146 + <span class="exp"><?php echo __('The new username you want to set', 'loginizer'); ?></span>
4147 + </td>
4148 + <td>
4149 + <input type="text" size="50" value="<?php echo lz_optpost('new_username', ''); ?>" name="new_username" id="new_username" />
4150 + </td>
4151 + </tr>
4152 + </table><br />
4153 + <i><?php echo __('Note: Username can be changed only for administrator users.'); ?></i>
4154 + <center><input name="save_lz_admin" class="button button-primary action" value="<?php echo __('Set the Username', 'loginizer'); ?>" type="submit" /></center>
4155 +
4156 + </div>
4157 + </div>
4158 +</form>
4159 +
4160 +<script type="text/javascript">
4161 +function add_lz_bl_users(){
4162 + jQuery("#lz_bl_users").append('<input type="text" size="30" value="" name="lz_bl_users[]" class="lz_bl_users" />');
4163 + return false;
4164 +};
4165 +</script>
4166 +
4167 +<style>
4168 +.lz_bl_users, .lz_bl_domains{
4169 + margin-bottom:20px;
4170 +}
4171 +</style>
4172 +
4173 +<form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
4174 + <div id="" class="postbox">
4175 +
4176 + <div class="postbox-header">
4177 + <h2 class="hndle ui-sortable-handle">
4178 + <span><?php echo __('Username Auto Blacklist', 'loginizer'); ?></span>
4179 + </h2>
4180 + </div>
4181 +
4182 + <div class="inside">
4183 +
4184 + <?php wp_nonce_field('loginizer-options'); ?>
4185 + <table class="form-table">
4186 + <tr>
4187 + <td scope="row" valign="top" colspan="2">
4188 + <i><?php echo __('Attackers generally use common usernames like <b>admin, administrator, or variations of your domain name / business name</b>. You can specify such username here and Loginizer will auto-blacklist the IP Address(s) of clients who try to use such username(s).', 'loginizer'); ?></i>
4189 + </td>
4190 + </tr>
4191 + <tr>
4192 + <td scope="row" valign="top" style="width:40% !important; vertical-align:top !important;">
4193 + <label><?php echo __('Username(s)', 'loginizer'); ?></label><br>
4194 + <span class="exp"><?php echo __('You can use - <b>*</b> (Star)- as a wild card as well. Blank fields will be ignored', 'loginizer'); ?></span>
4195 + </td>
4196 + <td>
4197 + <div id="lz_bl_users">
4198 + <?php
4199 +
4200 + $usernames = isset($_POST['lz_bl_users']) && is_array($_POST['lz_bl_users']) ? $_POST['lz_bl_users'] : $loginizer['username_blacklist'];
4201 +
4202 + if(empty($usernames)){
4203 + $usernames[] = '';
4204 + }
4205 +
4206 + foreach($usernames as $_user){
4207 + echo '<input type="text" size="30" value="'.$_user.'" name="lz_bl_users[]" class="lz_bl_users" />';
4208 + }
4209 +
4210 + ?>
4211 + </div>
4212 + <br />
4213 + <input class="button" type="button" value="<?php echo __('Add New Username', 'loginizer'); ?>" onclick="return add_lz_bl_users();" style="float:right" />
4214 + </td>
4215 + </tr>
4216 + </table><br />
4217 + <center><input name="save_lz_bl_users" class="button button-primary action" value="<?php echo __('Save Username(s)', 'loginizer'); ?>" type="submit" /></center>
4218 +
4219 + </div>
4220 + </div>
4221 +</form>
4222 +
4223 +<script type="text/javascript">
4224 +function add_lz_bl_domains(){
4225 + jQuery("#lz_bl_domains").append('<input type="text" size="30" value="" name="lz_bl_domains[]" class="lz_bl_domains" />');
4226 + return false;
4227 +};
4228 +</script>
4229 +
4230 +
4231 +<form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
4232 + <div id="" class="postbox">
4233 +
4234 + <div class="postbox-header">
4235 + <h2 class="hndle ui-sortable-handle">
4236 + <span><?php echo __('New Registration Domain Blacklist', 'loginizer'); ?></span>
4237 + </h2>
4238 + </div>
4239 +
4240 + <div class="inside">
4241 +
4242 + <?php wp_nonce_field('loginizer-options'); ?>
4243 + <table class="form-table">
4244 + <tr>
4245 + <td scope="row" valign="top" colspan="2">
4246 + <i>If you would like to ban new registrations from a particular domain, you can use this utility to do so.</i>
4247 + </td>
4248 + </tr>
4249 + <tr>
4250 + <td scope="row" valign="top" style="width:40% !important; vertical-align:top !important;">
4251 + <label><?php echo __('Domain(s)', 'loginizer'); ?></label><br>
4252 + <span class="exp"><?php echo __('You can use - <b>*</b> (Star)- as a wild card as well. Blank fields will be ignored', 'loginizer'); ?></span>
4253 + </td>
4254 + <td>
4255 + <div id="lz_bl_domains">
4256 + <?php
4257 +
4258 + $domains = isset($_POST['lz_bl_domains']) && is_array($_POST['lz_bl_domains']) ? $_POST['lz_bl_domains'] : $loginizer['domains_blacklist'];
4259 +
4260 + if(empty($domains)){
4261 + $domains[] = '';
4262 + }
4263 +
4264 + foreach($domains as $_domain){
4265 + echo '<input type="text" size="30" value="'.$_domain.'" name="lz_bl_domains[]" class="lz_bl_domains" />';
4266 + }
4267 +
4268 + ?>
4269 + </div>
4270 + <br />
4271 + <input class="button" type="button" value="<?php echo __('Add New Domain', 'loginizer'); ?>" onclick="return add_lz_bl_domains();" style="float:right" />
4272 + </td>
4273 + </tr>
4274 + </table><br />
4275 + <center><input name="save_lz_bl_domains" class="button button-primary action" value="<?php echo __('Save Domains(s)', 'loginizer'); ?>" type="submit" /></center>
4276 +
4277 + </div>
4278 + </div>
4279 +</form>
4280 +
4281 +<?php
4282 +
4283 +}
4284 +
4285 + loginizer_page_footer();
4286 +
4287 +}
4288 +
4289 +// Loginizer - Checksum load data
4290 +function loginizer_page_checksums_L(&$files, &$_ignores){
4291 +
4292 + global $loginizer, $lz_error, $lz_env;
4293 +
4294 + // Load any mismatched files and ignores
4295 + $files = get_option('loginizer_checksums_diff');
4296 + $_ignores = get_option('loginizer_checksums_ignore');
4297 + $_ignores = is_array($_ignores) ? $_ignores : array(); // SHOULD ALWAYS BE PURE
4298 + $ignores = array();
4299 +
4300 + foreach($_ignores as $ik => $iv){
4301 + $ignores[$iv] = array();
4302 + if(!empty($files[$iv])){
4303 + $ignores[$iv] = $files[$iv];
4304 + }
4305 + }
4306 +
4307 + $lz_env['files'] = $files;
4308 + $lz_env['ignores'] = $ignores;
4309 +
4310 +}
4311 +
4312 +// Loginizer - PasswordLess Page
4313 +function loginizer_page_checksums(){
4314 +
4315 + global $loginizer, $lz_error, $lz_env;
4316 +
4317 + if(!current_user_can('manage_options')){
4318 + wp_die('Sorry, but you do not have permissions to change settings.');
4319 + }
4320 +
4321 + if(!loginizer_is_premium() && count($_POST) > 0){
4322 + $lz_error['not_in_free'] = __('This feature is not available in the Free version. <a href="'.LOGINIZER_PRICING_URL.'" target="_blank" style="text-decoration:none; color:green;"><b>Upgrade to Pro</b></a>', 'loginizer');
4323 + return loginizer_page_checksums_T();
4324 + }
4325 +
4326 + /* Make sure post was from this page */
4327 + if(count($_POST) > 0){
4328 + check_admin_referer('loginizer-options');
4329 + }
4330 +
4331 + // Are we to run it ?
4332 + if(isset($_REQUEST['lz_run_checksum'])){
4333 + loginizer_checksums();
4334 + }
4335 +
4336 + loginizer_page_checksums_L($files, $_ignores);
4337 +
4338 + $lz_env['csum_freq'][1] = __('Once a Day', 'loginizer');
4339 + $lz_env['csum_freq'][7] = __('Once a Week', 'loginizer');
4340 + $lz_env['csum_freq'][30] = __('Once a Month', 'loginizer');
4341 +
4342 + if(isset($_POST['save_lz'])){
4343 +
4344 + // In the future there can be more settings
4345 + $option['disable_checksum'] = (int) lz_optpost('disable_checksum');
4346 + $option['no_checksum_email'] = (int) lz_optpost('no_checksum_email');
4347 + $option['checksum_frequency'] = (int) lz_optpost('checksum_frequency');
4348 + $option['checksum_time'] = lz_optpost('checksum_time');
4349 +
4350 + // Is there an error ?
4351 + if(!empty($lz_error)){
4352 + return loginizer_page_checksums_T();
4353 + }
4354 +
4355 + // Save the options
4356 + update_option('loginizer_checksums', $option);
4357 +
4358 + // Mark as saved
4359 + $GLOBALS['lz_saved'] = true;
4360 +
4361 + }
4362 +
4363 + // Add or remove from ignore list
4364 + if(isset($_POST['save_lz_csum_ig'])){
4365 +
4366 + if(@is_array($_POST['checksum_del_ignore'])){
4367 +
4368 + foreach($_POST['checksum_del_ignore'] as $k => $v){
4369 + $key = array_search($v, $_ignores);
4370 + if($key !== false){
4371 + unset($_ignores[$key]);
4372 + }
4373 + }
4374 +
4375 + // Save it
4376 + update_option('loginizer_checksums_ignore', $_ignores);
4377 +
4378 + }
4379 +
4380 + if(@is_array($_POST['checksum_add_ignore'])){
4381 +
4382 + foreach($_POST['checksum_add_ignore'] as $k => $v){
4383 + if(!empty($files[$v])){
4384 + $_ignores[] = $v;
4385 + }
4386 + }
4387 +
4388 + // Save it
4389 + update_option('loginizer_checksums_ignore', $_ignores);
4390 +
4391 + }
4392 +
4393 + // Reload
4394 + loginizer_page_checksums_L($files, $_ignores);
4395 +
4396 + // Mark as saved
4397 + $GLOBALS['lz_saved'] = true;
4398 +
4399 + }
4400 +
4401 + // Call theme
4402 + loginizer_page_checksums_T();
4403 +}
4404 +
4405 +// Loginizer - PasswordLess Page Theme
4406 +function loginizer_page_checksums_T(){
4407 +
4408 + global $loginizer, $lz_error, $lz_env;
4409 +
4410 + // Universal header
4411 + loginizer_page_header('File Checksum Settings');
4412 +
4413 + loginizer_feature_available('File Checksum');
4414 +
4415 + wp_enqueue_script('jquery-clockpicker', LOGINIZER_URL.'/jquery-clockpicker.min.js', array('jquery'), '0.0.7');
4416 + wp_enqueue_style('jquery-clockpicker', LOGINIZER_URL.'/jquery-clockpicker.min.css', array(), '0.0.7');
4417 +
4418 + // Saved ?
4419 + if(!empty($GLOBALS['lz_saved'])){
4420 + echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
4421 + }
4422 +
4423 + // Did we just run the checksums
4424 + if(isset($_REQUEST['lz_run_checksum'])){
4425 + echo '<div id="message" class="updated"><p>'. __('The Checksum process was executed successfully', 'loginizer'). '</p></div><br />';
4426 + }
4427 +
4428 + // Any errors ?
4429 + if(!empty($lz_error)){
4430 + lz_report_error($lz_error);echo '<br />';
4431 + }
4432 +
4433 + ?>
4434 +
4435 +<style>
4436 +input[type="text"], textarea, select {
4437 + width: 70%;
4438 +}
4439 +
4440 +.form-table label{
4441 + font-weight:bold;
4442 +}
4443 +
4444 +.exp{
4445 + font-size:12px;
4446 +}
4447 +</style>
4448 +
4449 +<script>
4450 +function lz_apply_status(ele, the_class){
4451 +
4452 + var status = ele.checked;
4453 + jQuery(the_class).each(function(){
4454 + this.checked = status;
4455 + });
4456 +
4457 +}
4458 +</script>
4459 +
4460 + <div id="" class="postbox">
4461 + <div class="postbox-header">
4462 + <h2 class="hndle ui-sortable-handle">
4463 + <span><?php echo __('Checksum Settings', 'loginizer'); ?></span>
4464 + </h2>
4465 + </div>
4466 + <div class="inside">
4467 +
4468 + <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
4469 + <?php wp_nonce_field('loginizer-options'); ?>
4470 + <table class="form-table">
4471 + <tr>
4472 + <td scope="row" valign="top" style="width:400px !important">
4473 + <label><?php echo __('Disable Checksum of WP Core', 'loginizer'); ?></label><br>
4474 + <span class="exp"><?php echo __('If disabled, Loginizer will not check your sites core files against the WordPress checksum list.', 'loginizer'); ?></span>
4475 + </td>
4476 + <td valign="top">
4477 + <input type="checkbox" value="1" name="disable_checksum" <?php echo lz_POSTchecked('disable_checksum', (empty($loginizer['disable_checksum']) ? false : true)); ?> />
4478 + </td>
4479 + </tr>
4480 + <tr>
4481 + <td scope="row" valign="top" style="width:400px !important">
4482 + <label><?php echo __('Disable Email of Checksum Results', 'loginizer'); ?></label><br>
4483 + <span class="exp"><?php echo __('If checked, Loginizer will not email you the checksum results.', 'loginizer'); ?></span>
4484 + </td>
4485 + <td valign="top">
4486 + <input type="checkbox" value="1" name="no_checksum_email" <?php echo lz_POSTchecked('no_checksum_email', (empty($loginizer['no_checksum_email']) ? false : true)); ?> />
4487 + </td>
4488 + </tr>
4489 + <tr>
4490 + <td scope="row" valign="top" style="width:400px !important">
4491 + <label><?php echo __('Checksum Frequency', 'loginizer'); ?></label><br>
4492 + <span class="exp"><?php echo __('If Checksum is enabled, at what frequency should the checksums be performed.', 'loginizer'); ?></span>
4493 + </td>
4494 + <td valign="top">
4495 + <select name="checksum_frequency">
4496 + <?php
4497 + foreach($lz_env['csum_freq'] as $k => $v){
4498 + echo '<option '.lz_POSTselect('checksum_frequency', $k, ($loginizer['checksum_frequency'] == $k ? true : false)).' value="'.$k.'">'.$v.'</value>';
4499 + }
4500 + ?>
4501 + </select>
4502 + </td>
4503 + </tr>
4504 + <tr id="lz_checksum_time">
4505 + <td scope="row" valign="top" style="width:400px !important">
4506 + <label><?php echo __('Time of Day', 'loginizer'); ?></label><br>
4507 + <span class="exp"><?php echo __('If Checksum is enabled, what time of day should Loginizer do the check. Note : The check will be done on or after this time has elapsed as per the accesses being made.', 'loginizer'); ?></span>
4508 + </td>
4509 + <td valign="top">
4510 + <div class="input-group clockpicker" data-autoclose="true">
4511 + <input type="text" name="checksum_time" class="form-control" value="<?php echo (empty($loginizer['checksum_time']) ? '00:00' : $loginizer['checksum_time']);?>">
4512 + <span class="input-group-addon">
4513 + <span class="glyphicon glyphicon-time"></span>
4514 + </span>
4515 + </div>
4516 + <script type="text/javascript">
4517 + jQuery(document).ready(function(){
4518 + (function($) {
4519 + $('.clockpicker').clockpicker({donetext: 'Done'});
4520 + })(jQuery);
4521 + });
4522 + </script>
4523 + </td>
4524 + </tr>
4525 + <tr>
4526 + <td colspan="2">
4527 + <?php echo __('If disabled, Loginizer will not check your sites core files against the WordPress checksum list.', 'loginizer'); ?>
4528 + </td>
4529 + </tr>
4530 + </table><br />
4531 + <center><input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /><input name="lz_run_checksum" style="float:right; background: #5cb85c; color:white; border:#5cb85c" class="button button-secondary" value="<?php echo __('Do a Checksum Now', 'loginizer'); ?>" type="submit" /></center>
4532 + </form>
4533 +
4534 + </div>
4535 + </div>
4536 +
4537 + <div id="" class="postbox">
4538 +
4539 + <div class="postbox-header">
4540 + <h2 class="hndle ui-sortable-handle">
4541 + <span><?php echo __('Mismatching Files', 'loginizer'); ?></span>
4542 + </h2>
4543 + </div>
4544 +
4545 + <div class="inside">
4546 +
4547 + <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
4548 + <?php wp_nonce_field('loginizer-options'); ?>
4549 + <table class="wp-list-table fixed striped users" border="0" width="100%" cellpadding="10" align="center">
4550 + <?php
4551 +
4552 + $files = $lz_env['files'];
4553 +
4554 + // Avoid undefined notice for $files
4555 + if(!empty($files)){
4556 + foreach($files as $k => $v){
4557 + if(!empty($lz_env['ignores'][$k])){
4558 + unset($files[$k]);
4559 + }
4560 + }
4561 + }
4562 +
4563 + echo '
4564 + <tr>
4565 + <th style="background:#EFEFEF;">'.__('Relative Path', 'loginizer').'</th>
4566 + <th style="width:240px; background:#EFEFEF;">'.__('Found', 'loginizer').'</th>
4567 + <th style="width:240px; background:#EFEFEF;">'.__('Should be', 'loginizer').'</th>
4568 + <th style="width:10px; background:#EFEFEF;"><input type="checkbox" onchange="lz_apply_status(this, \'.csum_add_ig\');" /></th>
4569 + </tr>';
4570 +
4571 + if(is_array($files) && count($files) > 0){
4572 +
4573 + foreach($files as $k => $v){
4574 +
4575 + echo '
4576 + <tr>
4577 + <td>'.$k.'</td>
4578 + <td>'.$v['cur_md5'].'</td>
4579 + <td>'.$v['md5'].'</td>
4580 + <td><input type="checkbox" name="checksum_add_ignore[]" class="csum_add_ig" value="'.$k.'" /></td>
4581 + </tr>';
4582 +
4583 + }
4584 +
4585 + }else{
4586 +
4587 + echo '
4588 + <tr>
4589 + <td colspan="4" align="center">'.__('This is great ! No file with any wrong checksum has been found.').'</td>
4590 + </tr>';
4591 +
4592 + }
4593 +
4594 + ?>
4595 + </table><br />
4596 + <center><input name="save_lz_csum_ig" class="button button-primary action" value="<?php echo __('Add Selected to Ignore List', 'loginizer'); ?>" type="submit" /></center>
4597 + </form>
4598 + </div>
4599 +
4600 + </div>
4601 + <br />
4602 +
4603 + <div id="" class="postbox">
4604 +
4605 + <div class="postbox-header">
4606 + <h2 class="hndle ui-sortable-handle">
4607 + <span><?php echo __('Ignore List', 'loginizer'); ?></span>
4608 + </h2>
4609 + </div>
4610 +
4611 + <div class="inside">
4612 +
4613 + <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
4614 + <?php wp_nonce_field('loginizer-options'); ?>
4615 + <table class="wp-list-table fixed striped users" border="0" width="100%" cellpadding="10" align="center">
4616 + <?php
4617 +
4618 + $ignores = $lz_env['ignores'];
4619 +
4620 + echo '
4621 + <tr>
4622 + <th style="background:#EFEFEF;">'.__('Relative Path', 'loginizer').'</th>
4623 + <th style="width:240px; background:#EFEFEF;">'.__('Found', 'loginizer').'</th>
4624 + <th style="width:240px; background:#EFEFEF;">'.__('Should be', 'loginizer').'</th>
4625 + <th style="width:10px; background:#EFEFEF;"><input type="checkbox" onchange="lz_apply_status(this, \'.csum_del_ig\');" /></th>
4626 + </tr>';
4627 +
4628 + // Load any mismatched files
4629 + $files = $ignores;
4630 +
4631 + if(is_array($files) && count($files) > 0){
4632 +
4633 + foreach($files as $k => $v){
4634 +
4635 + echo '
4636 + <tr>
4637 + <td>'.$k.'</td>
4638 + <td>'.$v['cur_md5'].'</td>
4639 + <td>'.$v['md5'].'</td>
4640 + <td><input type="checkbox" name="checksum_del_ignore[]" class="csum_del_ig" value="'.$k.'" /></td>
4641 + </tr>';
4642 +
4643 + }
4644 +
4645 + }else{
4646 +
4647 + echo '
4648 + <tr>
4649 + <td colspan="4" align="center">'.__('No files have been added to the ignore list').'</td>
4650 + </tr>';
4651 +
4652 + }
4653 +
4654 + ?>
4655 + </table><br />
4656 + <center><input name="save_lz_csum_ig" class="button button-primary action" value="<?php echo __('Remove Selected from Ignore List', 'loginizer'); ?>" type="submit" /></center>
4657 + </form>
4658 + </div>
4659 +
4660 + </div>
4661 + <br />
4662 +
4663 + <?php
4664 + loginizer_page_footer();
4665 +
4666 +}
4667 +
4668 +function loginizer_dismiss_newsletter(){
4669 +
4670 + // Some AJAX security
4671 + check_ajax_referer('loginizer_admin_ajax', 'nonce');
4672 +
4673 + if(!current_user_can('manage_options')){
4674 + wp_die('Sorry, but you do not have permissions to change settings.');
4675 + }
4676 +
4677 + update_option('loginizer_dismiss_newsletter', time());
4678 + echo 1;
4679 + wp_die();
4680 +}
4681 +
4682 +add_action('wp_ajax_loginizer_dismiss_newsletter', 'loginizer_dismiss_newsletter');
4683 +
4684 +function loginizer_newsletter_subscribe(){
4685 +
4686 + $newsletter_dismiss = get_option('loginizer_dismiss_newsletter');
4687 +
4688 + if(!empty($newsletter_dismiss)){
4689 + return;
4690 + }
4691 +
4692 + $env['url'] = 'https://loginizer.com/';
4693 +
4694 + echo '
4695 + <style>
4696 + .newsletter_container{
4697 + color: #000000;
4698 + background: #FFFFFF;
4699 + text-align:center;
4700 + }
4701 + .subscribe_form_row{
4702 + color: #000000;
4703 + padding-bottom:0px !important;
4704 + }
4705 + .subscribe_heading{
4706 + font-size:22px;
4707 + }
4708 + </style>
4709 +
4710 + <div class="notice my-loginizer-dismiss-notice is-dismissible" style="background:#FFF;padding:15px; border: 1px solid #ccd0d4; width:80%;margin-left:0px;margin:auto;">
4711 + <div class="container">
4712 + <div class="col-md-6 col-md-offset-3 text-center newsletter_container">
4713 + <h2 style="font-weight:100; margin-bottom:20px; margin-top:5px;" class="subscribe_heading">Subscribe to our Newsletter</h2>
4714 + <form class="form-inline" action="" method="POST">
4715 + <div class="row subscribe_form_row">
4716 + <div class="col-md-12">
4717 + <input type="email" name="email" size="40" id="subscribe_email" class="" placeholder="email@example.com" value="">&nbsp;
4718 + <input type="button" name="subscribe" id="subscribe_button" class="button button-primary" value="Subscribe" onclick="loginizer_email_subscribe();" style="margin-top:0px;">
4719 + </div>
4720 + <div class="col-md-3">
4721 + </div>
4722 + </div>
4723 + </form>
4724 + <p><b>Note :</b> If a Loginizer account does not exist it will be created.</p>
4725 + </div>
4726 + </div>
4727 + </div><br />
4728 +
4729 + <script type="text/javascript">
4730 + function loginizer_dismiss_newsletter(){
4731 +
4732 + var data = new Object();
4733 + data["action"] = "loginizer_dismiss_newsletter";
4734 + data["nonce"] = "'.wp_create_nonce('loginizer_admin_ajax').'";
4735 +
4736 + var admin_url = "'.admin_url().'"+"admin-ajax.php";
4737 + jQuery.post(admin_url, data, function(response){
4738 +
4739 + });
4740 +
4741 + }
4742 +
4743 + function loginizer_email_subscribe(){
4744 + var subs_location = "'.$env['url'].'?email="+encodeURIComponent(jQuery("#subscribe_email").val());
4745 + window.open(subs_location, "_blank");
4746 + }
4747 + jQuery(document).on("click", ".my-loginizer-dismiss-notice .notice-dismiss", loginizer_dismiss_newsletter);
4748 + </script>';
4749 +
4750 + return true;
4751 +}
4752 +
4753 +
1774 4754 // Sorry to see you going
1775 4755 register_uninstall_hook(LOGINIZER_FILE, 'loginizer_deactivation');
1776 4756
1777 4757 function loginizer_deactivation(){
@@ -1789,7 +4769,12 @@
1789 4769 delete_option('loginizer_options');
1790 4770 delete_option('loginizer_last_reset');
1791 4771 delete_option('loginizer_whitelist');
1792 4772 delete_option('loginizer_blacklist');
4773 + delete_option('loginizer_msg');
4774 + delete_option('loginizer_2fa_msg');
4775 + delete_option('loginizer_2fa_email_template');
4776 + delete_option('loginizer_security');
4777 + delete_option('loginizer_wp_admin');
1793 4778
1794 4779 }
1795 4780