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 +4088 -340 2.0.31.6.6 View file →
@@ -4,9 +4,9 @@
4 4 echo 'You are not allowed to access this page directly.';
5 5 exit;
6 6 }
7 7
8 -define('LOGINIZER_VERSION', '2.0.3');
8 +define('LOGINIZER_VERSION', '1.6.6');
9 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 12 define('LOGINIZER_PRICING_URL', 'https://loginizer.com/pricing');
@@ -24,9 +24,9 @@
24 24
25 25 $sql = array();
26 26
27 27 $sql[] = "DROP TABLE IF EXISTS `".$wpdb->prefix."loginizer_logs`";
28 -
28 +
29 29 $sql[] = "CREATE TABLE `".$wpdb->prefix."loginizer_logs` (
30 30 `username` varchar(255) NOT NULL DEFAULT '',
31 31 `time` int(10) NOT NULL DEFAULT '0',
32 32 `count` int(10) NOT NULL DEFAULT '0',
@@ -45,14 +45,9 @@
45 45 add_option('loginizer_last_reset', 0);
46 46 add_option('loginizer_whitelist', array());
47 47 add_option('loginizer_blacklist', array());
48 48 add_option('loginizer_2fa_whitelist', array());
49 -
50 - // TODO:: REMOVE THIS AFTER MARCH 2025
51 - $softwp_upgrade = get_option('loginizer_softwp_upgrade', 0);
52 - if(!defined('SITEPAD') && empty($softwp_upgrade)){
53 - loginizer_check_softaculous();
54 - }
49 +
55 50 }
56 51
57 52 /**
58 53 * Updates the database structure for Loginizer
@@ -89,9 +84,9 @@
89 84 // Trick the following if conditions to not run
90 85 $version = (int) str_replace('.', '', LOGINIZER_VERSION);
91 86
92 87 }
93 -
88 +
94 89 // Is it less than 1.0.1 ?
95 90 if($version < 101){
96 91
97 92 // TODO : GET the existing settings
@@ -187,38 +182,11 @@
187 182 $wpdb->query("ALTER TABLE ".$wpdb->prefix."loginizer_logs ADD `url` VARCHAR(255) NOT NULL DEFAULT '' AFTER `ip`;");
188 183
189 184 }
190 185
191 - // Setting alignment to left in social login ?
192 - if($version < 201){
193 - $social_settings = get_option('loginizer_social_settings', []);
194 -
195 - if(!empty($social_settings)){
196 - if(!empty($social_settings['login']) && (!empty($social_settings['login']['login_form']) || !empty($social_settings['login']['registration_form']))){
197 - $social_settings['login']['button_alignment'] = 'left';
198 - }
199 -
200 - if(!empty($social_settings['woocommerce']) && (!empty($social_settings['woocommmerce']['login_form']) || !empty($social_settings['woocommerce']['registration_form']))){
201 - $social_settings['woocommerce']['button_alignment'] = 'left';
202 - }
203 -
204 - if(!empty($social_settings['comment']) && !empty($social_settings['comment']['enable_buttons'])){
205 - $social_settings['comment']['button_alignment'] = 'left';
206 - }
207 -
208 - update_option('loginizer_social_settings', $social_settings);
209 - }
210 - }
211 -
212 186 // Save the new Version
213 187 update_option('loginizer_version', LOGINIZER_VERSION);
214 188
215 - // TODO:: REMOVE THIS AFTER MARCH 2025
216 - $softwp_upgrade = get_option('loginizer_softwp_upgrade', 0);
217 - if(!defined('SITEPAD') && empty($softwp_upgrade)){
218 - loginizer_check_softaculous();
219 - }
220 -
221 189 // In Sitepad Math Captcha is enabled by default
222 190 if(defined('SITEPAD') && get_option('loginizer_captcha') === false){
223 191 $option['captcha_no_google'] = 1;
224 192 add_option('loginizer_captcha', $option);
@@ -235,13 +203,11 @@
235 203 global $loginizer;
236 204
237 205 // Check if the installed version is outdated
238 206 loginizer_update_check();
239 -
207 +
240 208 // Set the array
241 - if(empty($loginizer)){
242 - $loginizer = array();
243 - }
209 + $loginizer = array();
244 210
245 211 $loginizer['prefix'] = !defined('SITEPAD') ? 'Loginizer ' : 'SitePad ';
246 212 $loginizer['app'] = !defined('SITEPAD') ? 'WordPress' : 'SitePad';
247 213 $loginizer['login_basename'] = !defined('SITEPAD') ? 'wp-login.php' : 'login.php';
@@ -260,28 +226,44 @@
260 226 $loginizer['max_lockouts'] = empty($options['max_lockouts']) ? 5 : $options['max_lockouts'];
261 227 $loginizer['lockouts_extend'] = empty($options['lockouts_extend']) ? 86400 : $options['lockouts_extend']; // 24 hours
262 228 $loginizer['reset_retries'] = empty($options['reset_retries']) ? 86400 : $options['reset_retries']; // 24 hours
263 229 $loginizer['notify_email'] = empty($options['notify_email']) ? 0 : $options['notify_email'];
264 - $loginizer['notify_email_address'] = lz_is_multisite() ? get_site_option('admin_email') : get_option('admin_email');
265 - $loginizer['trusted_ips'] = empty($options['trusted_ips']) ? false : true;
266 - $loginizer['blocked_screen'] = empty($options['blocked_screen']) ? false : true;
267 - $loginizer['social_settings'] = get_option('loginizer_social_settings', []);
268 230
269 - if(!empty($options['notify_email_address'])){
270 - $loginizer['notify_email_address'] = $options['notify_email_address'];
271 - $loginizer['custom_notify_email'] = 1;
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 + }
272 246 }
273 247
274 - // Login Success Email Notification.
275 - $loginizer['login_mail'] = get_option('loginizer_login_mail', []);
276 - add_action('init', 'loginizer_load_translation_vars', 0);
277 -
278 - $loginizer['login_mail_subject'] = empty($loginizer['login_mail']['subject']) ? '' : $loginizer['login_mail']['subject'];
279 - $loginizer['login_mail_body'] = empty($loginizer['login_mail']['body']) ? '' : $loginizer['login_mail']['body'];
280 -
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 + }
262 +
281 263 // Load the blacklist and whitelist
282 - $loginizer['blacklist'] = get_option('loginizer_blacklist', []);
283 - $loginizer['whitelist'] = get_option('loginizer_whitelist', []);
264 + $loginizer['blacklist'] = get_option('loginizer_blacklist');
265 + $loginizer['whitelist'] = get_option('loginizer_whitelist');
284 266 $loginizer['2fa_whitelist'] = get_option('loginizer_2fa_whitelist');
285 267
286 268 // It should not be false
287 269 if(empty($loginizer['2fa_whitelist'])){
@@ -289,14 +271,8 @@
289 271 }
290 272
291 273 // When was the database cleared last time
292 274 $loginizer['last_reset'] = get_option('loginizer_last_reset');
293 -
294 - if(!isset($loginizer['ultimate-member-active'])){
295 - $um_is_active = in_array('ultimate-member/ultimate-member.php', apply_filters('active_plugins', get_option('active_plugins', [])));
296 -
297 - $loginizer['ultimate-member-active'] = !empty($um_is_active) ? true : false;
298 - }
299 275
300 276 //print_r($loginizer);
301 277
302 278 // Clear retries
@@ -332,45 +308,279 @@
332 308 // Is called before displaying the error message so that we dont show that the username is wrong or the password
333 309 // Update Error message
334 310 add_action('wp_login_errors', 'loginizer_error_handler', 10001, 2);
335 311 add_action('woocommerce_login_failed', 'loginizer_woocommerce_error_handler', 10001);
336 - add_action('wp_login', 'loginizer_login_success', 10, 2);
337 -
338 - if(!empty($loginizer['ultimate-member-active'])){
339 - add_action('wp_login_failed', 'loginizer_ultimatemember_error_handler', 10001);
340 - }
312 +
313 + }
314 +
315 + // ----------------
316 + // PRO INIT
317 + // ----------------
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,
341 323
342 - if(!empty($_COOKIE['lz_social_error']) && !empty($loginizer['social_settings']) && !loginizer_is_blacklisted()){
343 - add_filter('wp_login_errors', 'loginizer_social_login_error_handler', 10000, 2);
344 - }
345 - }
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'];
346 339
347 - // Social Login Form Actions
348 - if(!empty($loginizer['social_settings']) && !loginizer_is_blacklisted()){
349 - if(!empty($loginizer['social_settings']['login']['login_form'])){
350 - add_action('login_form', 'loginizer_social_btn_login');
351 - }
352 - }
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,
353 344
354 - if((function_exists('wp_doing_ajax') && wp_doing_ajax()) || (defined( 'DOING_AJAX' ) && DOING_AJAX)){
355 - include_once LOGINIZER_DIR . '/main/ajax.php';
356 - }
345 +A login request was submitted for your account $email at :
346 +$site_name - $site_url
357 347
358 - if(is_admin()){
359 - include_once LOGINIZER_DIR . '/main/admin.php';
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;
360 364 }
361 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 +
362 432 // ----------------
363 433 // PRO INIT END
364 434 // ----------------
365 435
366 - // Secuity checks for social login.
367 - if(!empty($_GET['lz_social_provider']) && loginizer_can_login() && empty($_GET['lz_api'])){
368 - add_action('init', 'loginizer_social_login_load');
369 - return;
436 + // Is the premium features there ?
437 + if(file_exists(LOGINIZER_DIR.'/premium.php')){
438 +
439 + // Include the file
440 + include_once(LOGINIZER_DIR.'/premium.php');
441 +
442 + loginizer_security_init();
443 +
444 + // Its the free version
445 + }else{
446 +
447 + // The promo time
448 + $loginizer['promo_time'] = get_option('loginizer_promo_time');
449 + if(empty($loginizer['promo_time'])){
450 + $loginizer['promo_time'] = time();
451 + update_option('loginizer_promo_time', $loginizer['promo_time']);
452 + }
453 +
454 + // Are we to show the loginizer promo
455 + if(!empty($loginizer['promo_time']) && $loginizer['promo_time'] > 0 && $loginizer['promo_time'] < (time() - (30*24*3600))){
456 +
457 + add_action('admin_notices', 'loginizer_promo');
458 +
459 + }
460 +
461 + // Are we to disable the promo
462 + if(isset($_GET['loginizer_promo']) && (int)$_GET['loginizer_promo'] == 0){
463 + update_option('loginizer_promo_time', (0 - time()) );
464 + die('DONE');
465 + }
466 +
370 467 }
468 +
371 469 }
372 470
471 +// Show the promo
472 +function loginizer_promo(){
473 +
474 + echo '
475 +<style>
476 +.lz_button {
477 +background-color: #4CAF50; /* Green */
478 +border: none;
479 +color: white;
480 +padding: 8px 16px;
481 +text-align: center;
482 +text-decoration: none;
483 +display: inline-block;
484 +font-size: 16px;
485 +margin: 4px 2px;
486 +-webkit-transition-duration: 0.4s; /* Safari */
487 +transition-duration: 0.4s;
488 +cursor: pointer;
489 +}
490 +
491 +.lz_button:focus{
492 +border: none;
493 +color: white;
494 +}
495 +
496 +.lz_button1 {
497 +color: white;
498 +background-color: #4CAF50;
499 +border:3px solid #4CAF50;
500 +}
501 +
502 +.lz_button1:hover {
503 +box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19);
504 +color: white;
505 +border:3px solid #4CAF50;
506 +}
507 +
508 +.lz_button2 {
509 +color: white;
510 +background-color: #0085ba;
511 +}
512 +
513 +.lz_button2:hover {
514 +box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19);
515 +color: white;
516 +}
517 +
518 +.lz_button3 {
519 +color: white;
520 +background-color: #365899;
521 +}
522 +
523 +.lz_button3:hover {
524 +box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19);
525 +color: white;
526 +}
527 +
528 +.lz_button4 {
529 +color: white;
530 +background-color: rgb(66, 184, 221);
531 +}
532 +
533 +.lz_button4:hover {
534 +box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19);
535 +color: white;
536 +}
537 +
538 +.loginizer_promo-close{
539 +float:right;
540 +text-decoration:none;
541 +margin: 5px 10px 0px 0px;
542 +}
543 +
544 +.loginizer_promo-close:hover{
545 +color: red;
546 +}
547 +</style>
548 +
549 +<script>
550 +jQuery(document).ready( function() {
551 + (function($) {
552 + $("#loginizer_promo .loginizer_promo-close").click(function(){
553 + var data;
554 +
555 + // Hide it
556 + $("#loginizer_promo").hide();
557 +
558 + // Save this preference
559 + $.post("'.admin_url('?loginizer_promo=0').'", data, function(response) {
560 + //alert(response);
561 + });
562 + });
563 + })(jQuery);
564 +});
565 +</script>
566 +
567 +<div class="notice notice-success" id="loginizer_promo" style="min-height:120px">
568 + <a class="loginizer_promo-close" href="javascript:" aria-label="Dismiss this Notice">
569 + <span class="dashicons dashicons-dismiss"></span> Dismiss
570 + </a>
571 + <img src="'.LOGINIZER_URL.'/loginizer-200.png" style="float:left; margin:10px 20px 10px 10px" width="100" />
572 + <p style="font-size:16px">We are glad you like Loginizer and have been using it since the past few days. It is time to take the next step </p>
573 + <p>
574 + <a class="lz_button lz_button1" target="_blank" href="https://loginizer.com/features">Upgrade to Pro</a>
575 + <a class="lz_button lz_button2" target="_blank" href="https://wordpress.org/support/view/plugin-reviews/loginizer">Rate it 5★\'s</a>
576 + <a class="lz_button lz_button3" target="_blank" href="https://www.facebook.com/Loginizer-815504798591884/">Like Us on Facebook</a>
577 + <a class="lz_button lz_button4" target="_blank" href="https://twitter.com/home?status='.rawurlencode('I use @loginizer to secure my #WordPress site - https://loginizer.com').'">Tweet about Loginizer</a>
578 + </p>
579 +</div>';
580 +
581 +}
582 +
373 583 // Should return NULL if everything is fine
374 584 function loginizer_wp_authenticate($user, $username, $password){
375 585
376 586 global $loginizer, $lz_error, $lz_cannot_login, $lz_user_pass;
@@ -382,22 +592,8 @@
382 592 // Are you whitelisted ?
383 593 if(loginizer_is_whitelisted()){
384 594 $loginizer['ip_is_whitelisted'] = 1;
385 595 return $user;
386 -
387 - } else if (!empty($loginizer['trusted_ips'])){
388 - $lz_cannot_login = 1;
389 -
390 - // This is used by WP Activity Log
391 - apply_filters( 'wp_login_blocked', $username );
392 -
393 - // Shows a blocked screen
394 - if(!empty($loginizer['blocked_screen'])){
395 - $lz_error['trusted_ip'] = __('You are restricted from logging in as your IP is not whitelisted.', 'loginizer');
396 - loginizer_blocked_page($lz_error);
397 - }
398 -
399 - return new WP_Error('ip_blacklisted', __('You are restricted from logging in as your IP is not whitelisted.', 'loginizer'));
400 596 }
401 597
402 598 // Are you blacklisted ?
403 599 if(loginizer_is_blacklisted()){
@@ -405,13 +601,8 @@
405 601
406 602 // This is used by WP Activity Log
407 603 apply_filters( 'wp_login_blocked', $username );
408 604
409 - // Shows a blocked screen
410 - if(!empty($loginizer['blocked_screen'])){
411 - loginizer_blocked_page($lz_error);
412 - }
413 -
414 605 return new WP_Error('ip_blacklisted', implode('', $lz_error), 'loginizer');
415 606 }
416 607
417 608 // Is the username blacklisted ?
@@ -420,9 +611,9 @@
420 611 $lz_cannot_login = 1;
421 612
422 613 // This is used by WP Activity Log
423 614 apply_filters( 'wp_login_blocked', $username );
424 -
615 +
425 616 return new WP_Error('user_blacklisted', implode('', $lz_error), 'loginizer');
426 617 }
427 618 }
428 619
@@ -430,19 +621,14 @@
430 621 return $user;
431 622 }
432 623
433 624 $lz_cannot_login = 1;
434 -
625 +
435 626 // This is used by WP Activity Log
436 627 apply_filters( 'wp_login_blocked', $username );
437 628
438 - // Shows a blocked screen
439 - if(!empty($loginizer['blocked_screen'])){
440 - loginizer_blocked_page($lz_error);
441 - }
629 + return new WP_Error('ip_blocked', implode('', $lz_error), 'loginizer');
442 630
443 - return new WP_Error('ip_blocked', implode('', $lz_error), 'loginizer');
444 -
445 631 }
446 632
447 633 function loginizer_can_login(){
448 634
@@ -452,9 +638,9 @@
452 638 $sel_query = $wpdb->prepare("SELECT * FROM `".$wpdb->prefix."loginizer_logs` WHERE `ip` = %s", $loginizer['current_ip']);
453 639 $result = lz_selectquery($sel_query);
454 640
455 641 if(!empty($result['count']) && ($result['count'] % $loginizer['max_retries']) == 0){
456 -
642 +
457 643 // Has he reached max lockouts ?
458 644 if($result['lockout'] >= $loginizer['max_lockouts']){
459 645 $loginizer['lockout_time'] = $loginizer['lockouts_extend'];
460 646 }
@@ -475,11 +661,8 @@
475 661 }
476 662
477 663 $lz_error['ip_blocked'] = $loginizer['msg']['lockout_err'].' '.$_time;
478 664
479 - if(!empty($loginizer['ultimate-member-active']) && class_exists('UM')){
480 - \UM()->form()->add_error('blocked_msg', $lz_error['ip_blocked']);
481 - }
482 665 return false;
483 666 }
484 667 }
485 668
@@ -489,14 +672,10 @@
489 672 function loginizer_is_blacklisted(){
490 673
491 674 global $wpdb, $loginizer, $lz_error;
492 675
493 - $blacklist = isset($loginizer['blacklist']) ? $loginizer['blacklist'] : [];
494 -
495 - if(empty($blacklist)){
496 - return false;
497 - }
498 -
676 + $blacklist = $loginizer['blacklist'];
677 +
499 678 foreach($blacklist as $k => $v){
500 679
501 680 // Is the IP in the blacklist ?
502 681 if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip']) && inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
@@ -536,12 +715,8 @@
536 715 global $wpdb, $loginizer, $lz_error;
537 716
538 717 $whitelist = $loginizer['whitelist'];
539 718
540 - if(empty($whitelist)){
541 - return false;
542 - }
543 -
544 719 foreach($whitelist as $k => $v){
545 720
546 721 // Is the IP in the blacklist ?
547 722 if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip']) && inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
@@ -574,8 +749,9 @@
574 749 return false;
575 750
576 751 }
577 752
753 +
578 754 // When the login fails, then this is called
579 755 // We need to update the database
580 756 function loginizer_login_failed($username, $is_2fa = ''){
581 757
@@ -593,16 +769,9 @@
593 769 }
594 770
595 771 if(empty($lz_cannot_login) && empty($loginizer['ip_is_whitelisted']) && empty($loginizer['no_loginizer_logs'])){
596 772
597 - // The params which comes when social login returns an error, have some characters, which WordPress could not save.
598 - $server_uri = $_SERVER['REQUEST_URI'];
599 - if(!empty($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], 'lz_social_provider') !== FALSE){
600 - $request_uri = explode('=', $_SERVER['REQUEST_URI']);
601 - $server_uri = $request_uri[0];
602 - }
603 -
604 - $url = @addslashes((!empty($_SERVER['HTTPS']) ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$server_uri);
773 + $url = @addslashes((!empty($_SERVER['HTTPS']) ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
605 774 $url = esc_url($url);
606 775
607 776 $sel_query = $wpdb->prepare("SELECT * FROM `".$wpdb->prefix."loginizer_logs` WHERE `ip` = %s", $loginizer['current_ip']);
608 777 $result = lz_selectquery($sel_query);
@@ -625,18 +794,11 @@
625 794
626 795 // Do we need to email admin ?
627 796 if(!empty($loginizer['notify_email']) && $lockout >= $loginizer['notify_email']){
628 797
629 - $lockout_time = $loginizer['lockout_time'];
630 -
631 - if($lockout >= $loginizer['max_lockouts']){
632 - // extended lockout is in hours so we have to convert to minute
633 - $lockout_time = $loginizer['lockouts_extend'];
634 - }
635 -
636 798 $sitename = lz_is_multisite() ? get_site_option('site_name') : get_option('blogname');
637 799 $mail = array();
638 - $mail['to'] = $loginizer['notify_email_address'];
800 + $mail['to'] = lz_is_multisite() ? get_site_option('admin_email') : get_option('admin_email');
639 801 $mail['subject'] = 'Failed '.$fail_type.' Attempts from IP '.$loginizer['current_ip'].' ('.$sitename.')';
640 802 $mail['message'] = 'Hi,
641 803
642 804 '.($result['count']+1).' failed '.strtolower($fail_type).' attempts and '.$lockout.' lockout(s) from IP '.$loginizer['current_ip'].' on your site :
@@ -643,9 +805,9 @@
643 805 '.home_url().'
644 806
645 807 Last '.$fail_type.' Attempt : '.date('d/M/Y H:i:s P', time()).'
646 808 Last User Attempt : '.$username.'
647 -IP has been blocked until : '.date('d/M/Y H:i:s P', time() + $lockout_time).'
809 +IP has been blocked until : '.date('d/M/Y H:i:s P', time() + $loginizer['lockout_time']).'
648 810
649 811 Regards,
650 812 Loginizer';
651 813
@@ -668,9 +830,8 @@
668 830 }
669 831
670 832 // We need to add one as this is a failed attempt as well
671 833 $result['count'] = $result['count'] + 1;
672 - loginizer_update_attempt_stats(0);
673 834 $loginizer['retries_left'] = ($loginizer['max_retries'] - ($result['count'] % $loginizer['max_retries']));
674 835 $loginizer['retries_left'] = $loginizer['retries_left'] == $loginizer['max_retries'] ? 0 : $loginizer['retries_left'];
675 836
676 837 }
@@ -675,324 +836,3921 @@
675 836
676 837 }
677 838 }
678 839
679 -function loginizer_login_success($user_login, $user) {
840 +// Handles the error of the password not being there
841 +function loginizer_error_handler($errors, $redirect_to){
842 +
843 + global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
844 +
845 + //echo 'loginizer_error_handler :';print_r($errors->errors);echo '<br>';
846 +
847 + // Remove the empty password error
848 + if(is_wp_error($errors)){
849 +
850 + $codes = $errors->get_error_codes();
851 +
852 + foreach($codes as $k => $v){
853 + if($v == 'invalid_username' || $v == 'incorrect_password'){
854 + $show_error = 1;
855 + }
856 + }
857 +
858 + $errors->remove('invalid_username');
859 + $errors->remove('incorrect_password');
860 +
861 + }
862 +
863 + // Add the error
864 + if(!empty($lz_user_pass) && !empty($show_error) && empty($lz_cannot_login)){
865 + $errors->add('invalid_userpass', '<b>ERROR:</b> ' . $loginizer['msg']['inv_userpass']);
866 + }
867 +
868 + // Add the number of retires left as well
869 + if(count($errors->get_error_codes()) > 0 && isset($loginizer['retries_left'])){
870 + $errors->add('retries_left', loginizer_retries_left());
871 + }
872 +
873 + return $errors;
874 +
875 +}
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 +
890 +// Returns a string with the number of retries left
891 +function loginizer_retries_left(){
892 +
893 + global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
894 +
895 + // If we are to show the number of retries left
896 + if(isset($loginizer['retries_left'])){
897 + return '<b>'.$loginizer['retries_left'].'</b> '.$loginizer['msg']['attempts_left'];
898 + }
899 +
900 +}
901 +
902 +function loginizer_reset_retries(){
903 +
904 + global $wpdb, $loginizer;
905 +
906 + $deltime = time() - $loginizer['reset_retries'];
907 +
908 + $del_query = $wpdb->prepare("DELETE FROM `".$wpdb->prefix."loginizer_logs` WHERE `time` <= %d", $deltime);
909 + $result = $wpdb->query($del_query);
910 +
911 + update_option('loginizer_last_reset', time());
912 +
913 +}
914 +
915 +add_filter("plugin_action_links_$plugin_loginizer", 'loginizer_plugin_action_links');
916 +
917 +// Add settings link on plugin page
918 +function loginizer_plugin_action_links($links) {
919 +
920 + if(!defined('LOGINIZER_PREMIUM')){
921 + $links[] = '<a href="'.LOGINIZER_PRO_URL.'" style="color:#3db634;" target="_blank">'._x('Upgrade', 'Plugin action link label.', 'loginizer').'</a>';
922 + }
923 +
924 + $settings_link = '<a href="admin.php?page=loginizer">Settings</a>';
925 + array_unshift($links, $settings_link);
926 +
927 + return $links;
928 +}
929 +
930 +add_action('admin_menu', 'loginizer_admin_menu');
931 +
932 +// Shows the admin menu of Loginizer
933 +function loginizer_admin_menu() {
934 +
680 935 global $wp_version, $loginizer;
936 +
937 + if(!defined('SITEPAD')){
938 +
939 + // Add the menu page
940 + add_menu_page(__('Loginizer Dashboard', 'loginizer'), __('Loginizer Security', 'loginizer'), 'activate_plugins', 'loginizer', 'loginizer_page_dashboard');
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 +
955 + // Brute Force
956 + add_submenu_page('loginizer', __('Brute Force Settings', 'loginizer'), __('Brute Force', 'loginizer'), 'activate_plugins', 'loginizer_brute_force', 'loginizer_page_brute_force');
957 +
958 + // PasswordLess
959 + add_submenu_page('loginizer', __($loginizer['prefix'].'PasswordLess Settings', 'loginizer'), __('PasswordLess', 'loginizer'), 'activate_plugins', 'loginizer_passwordless', 'loginizer_page_passwordless');
960 +
961 + // Security Settings
962 + if(!defined('SITEPAD')){
963 +
964 + // Two Factor Auth
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 +
975 + // Security Settings
976 + add_submenu_page('loginizer', __($loginizer['prefix'].'Security Settings', 'loginizer'), __('Security Settings', 'loginizer'), 'activate_plugins', 'loginizer_security', 'loginizer_page_security');
977 +
978 + // File Checksums
979 + add_submenu_page('loginizer', __('Loginizer File Checksums', 'loginizer'), __('File Checksums', 'loginizer'), 'activate_plugins', 'loginizer_checksums', 'loginizer_page_checksums');
980 +
981 + }
982 +
983 + if(!defined('LOGINIZER_PREMIUM') && !empty($loginizer['ins_time']) && $loginizer['ins_time'] < (time() - (30*24*3600))){
984 +
985 + // Go Pro link
986 + add_submenu_page('loginizer', __('Loginizer Go Pro', 'loginizer'), __('Go Pro', 'loginizer'), 'activate_plugins', LOGINIZER_PRO_URL);
987 +
988 + }
989 +
990 +}
681 991
682 - loginizer_update_attempt_stats(1);
992 +// The Loginizer Admin Options Page
993 +function loginizer_page_header($title = 'Loginizer'){
683 994
684 - if(empty($loginizer['login_mail'])){
685 - return;
995 + global $loginizer;
996 +
997 +?>
998 +<style>
999 +.lz-right-ul{
1000 + padding-left: 10px !important;
1001 +}
1002 +
1003 +.lz-right-ul li{
1004 + list-style: circle !important;
1005 +}
1006 +</style>
1007 +<?php
1008 +
1009 + echo '<div style="margin: 10px 20px 0 2px;">
1010 +<div class="metabox-holder columns-2">
1011 +<div class="postbox-container">
1012 +<div id="top-sortables" class="meta-box-sortables ui-sortable">
1013 +
1014 + <table cellpadding="2" cellspacing="1" width="100%" class="fixed" border="0">
1015 + <tr>
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>
1021 + <td align="right" width="40"><a target="_blank" href="https://twitter.com/loginizer"><img src="'.LOGINIZER_URL.'/twitter.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 +
686 1024 }
1025 +
1026 + echo '
1027 + </tr>
1028 + </table>
1029 + <hr />
1030 +
1031 + <!--Main Table-->
1032 + <table cellpadding="8" cellspacing="1" width="100%" class="fixed">
1033 + <tr>
1034 + <td valign="top">';
687 1035
688 - if(empty($loginizer['login_mail']['enable'])){
689 - return;
1036 +}
1037 +
1038 +// The Loginizer Theme footer
1039 +function loginizer_page_footer(){
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>';
690 1047 }
1048 +
1049 + echo '</td>
1050 + <td width="200" valign="top" id="loginizer-right-bar">';
1051 +
1052 + if(!defined('SITEPAD')){
1053 +
1054 + if(!defined('LOGINIZER_PREMIUM')){
1055 +
1056 + echo '
1057 + <div class="postbox" style="min-width:0px !important;">
1058 + <div class="postbox-header">
1059 + <h2 class="hndle ui-sortable-handle">
1060 + <span>Premium Version</span>
1061 + </h2>
1062 + </div>
1063 +
1064 + <div class="inside">
1065 + <i>Upgrade to the premium version and get the following features </i>:<br>
1066 + <ul class="lz-right-ul">
1067 + <li>PasswordLess Login</li>
1068 + <li>Two Factor Auth - Email</li>
1069 + <li>Two Factor Auth - App</li>
1070 + <li>Login Challenge Question</li>
1071 + <li>reCAPTCHA</li>
1072 + <li>Rename Login Page</li>
1073 + <li>Disable XML-RPC</li>
1074 + <li>And many more ...</li>
1075 + </ul>
1076 + <center><a class="button button-primary" target="_blank" href="'.LOGINIZER_PRICING_URL.'">Upgrade</a></center>
1077 + </div>
1078 + </div>';
1079 +
1080 + }else{
1081 +
1082 + echo '
1083 + <div class="postbox" style="min-width:0px !important;">
1084 + <div class="postbox-header">
1085 + <h2 class="hndle ui-sortable-handle">
1086 + <span>Recommendations</span>
1087 + </h2>
1088 + </div>
1089 + <div class="inside">
1090 + <i>We recommed that you enable atleast one of the following security features</i>:<br>
1091 + <ul class="lz-right-ul">
1092 + <li>Rename Login Page</li>
1093 + <li>Login Challenge Question</li>
1094 + <li>reCAPTCHA</li>
1095 + <li>Two Factor Auth - Email</li>
1096 + <li>Two Factor Auth - App</li>
1097 + <li>Change \'admin\' Username</li>
1098 + </ul>
1099 + </div>
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 +
1150 + }
1151 +
1152 + echo '</td>
1153 + </tr>
1154 + </table>';
1155 +
1156 + if(!defined('SITEPAD')){
1157 +
1158 + echo '<br />
1159 + <div style="width:45%;background:#FFF;padding:15px; margin:auto">
1160 + <b>Let your friends know that you have secured your website :</b>
1161 + <form method="get" action="https://twitter.com/intent/tweet" id="tweet" onsubmit="return dotweet(this);">
1162 + <textarea name="text" cols="45" row="3" style="resize:none;">I just secured my @WordPress site against #bruteforce using @loginizer</textarea>
1163 + &nbsp; &nbsp; <input type="submit" value="Tweet!" class="button button-primary" onsubmit="return false;" id="twitter-btn" style="margin-top:20px;"/>
1164 + </form>
1165 +
1166 + </div>
1167 + <br />
1168 +
1169 + <script>
1170 + function dotweet(ele){
1171 + window.open(jQuery("#"+ele.id).attr("action")+"?"+jQuery("#"+ele.id).serialize(), "_blank", "scrollbars=no, menubar=no, height=400, width=500, resizable=yes, toolbar=no, status=no");
1172 + return false;
1173 + }
1174 + </script>
1175 +
1176 + <hr />
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 '
1182 +</div>
1183 +</div>
1184 +</div>
1185 +</div>';
691 1186
692 - if(!empty($loginizer['login_mail']['disable_whitelist'])){
693 - // Check its whitelist ip
694 - if(loginizer_is_whitelisted()){
695 - return;
1187 +}
1188 +
1189 +// The Loginizer Admin Options Page
1190 +function loginizer_page_dashboard(){
1191 +
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 + }
1202 +
1203 + /* Make sure post was from this page */
1204 + if(count($_POST) > 0){
1205 + check_admin_referer('loginizer-options');
1206 + }
1207 +
1208 + do_action('loginizer_pre_page_dashboard');
1209 +
1210 + // Is there a IP Method ?
1211 + if(isset($_POST['save_lz_ip_method'])){
1212 +
1213 + $ip_method = (int) lz_optpost('lz_ip_method');
1214 + $custom_ip_method = lz_optpost('lz_custom_ip_method');
1215 +
1216 + if($ip_method >= 0 && $ip_method <= 3){
1217 + update_option('loginizer_ip_method', $ip_method);
696 1218 }
1219 +
1220 + // Custom Method name ?
1221 + if($ip_method == 3){
1222 + update_option('loginizer_custom_ip_method', $custom_ip_method);
1223 + }
1224 +
697 1225 }
1226 +
1227 + loginizer_page_dashboard_T();
1228 +
1229 +}
698 1230
699 - if(empty($user_login) && empty($user)){
700 - error_log('Loginizer: No user information to send email');
701 - return;
1231 +// The Loginizer Admin Options Page - THEME
1232 +function loginizer_page_dashboard_T(){
1233 +
1234 + global $loginizer, $lz_error, $lz_env;
1235 +
1236 + loginizer_page_header('Dashboard');
1237 +?>
1238 +<style>
1239 +.welcome-panel{
1240 + margin: 0px;
1241 + padding: 10px;
1242 +}
1243 +
1244 +input[type="text"], textarea, select {
1245 + width: 70%;
1246 +}
1247 +
1248 +.form-table label{
1249 + font-weight:bold;
1250 +}
1251 +
1252 +.exp{
1253 + font-size:12px;
1254 +}
1255 +</style>
1256 +
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 />';
702 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 />';
703 1267
704 - if(empty($user)){
705 - $user = get_user_by('login', $user_login);
1268 + // Saved ?
1269 + if(!empty($GLOBALS['lz_saved'])){
1270 + echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
706 1271 }
1272 +
1273 + // Any errors ?
1274 + if(!empty($lz_error)){
1275 + lz_report_error($lz_error);echo '<br />';
1276 + }
1277 +
1278 + ?>
1279 +
1280 + <div class="postbox">
1281 +
1282 + <div class="postbox-header">
1283 + <h2 class="hndle ui-sortable-handle">
1284 + <span><?php echo __('Getting Started', 'loginizer'); ?></span>
1285 + </h2>
1286 + </div>
1287 +
1288 + <div class="inside">
1289 +
1290 + <form action="" method="post" enctype="multipart/form-data">
1291 + <?php wp_nonce_field('loginizer-options'); ?>
1292 + <table class="form-table">
1293 + <tr>
1294 + <td scope="row" valign="top" colspan="2" style="line-height:150%">
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>
1296 + <?php
1297 + if(defined('LOGINIZER_PREMIUM')){
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>';
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 + }
1302 + ?>
1303 + </td>
1304 + </tr>
1305 + </table>
1306 + </form>
1307 +
1308 + </div>
1309 + </div>
1310 +
1311 + <div class="postbox">
1312 +
1313 + <div class="postbox-header">
1314 + <h2 class="hndle ui-sortable-handle">
1315 + <span><?php echo __('System Information', 'loginizer'); ?></span>
1316 + </h2>
1317 + </div>
1318 + <div class="inside">
1319 +
1320 + <form action="" method="post" enctype="multipart/form-data">
1321 + <?php wp_nonce_field('loginizer-options'); ?>
1322 + <table class="wp-list-table fixed striped users" cellspacing="1" border="0" width="95%" cellpadding="10" align="center">
1323 + <?php
1324 + echo '
1325 + <tr>
1326 + <th align="left" width="25%">'.__('Loginizer Version', 'loginizer').'</th>
1327 + <td>'.LOGINIZER_VERSION.(defined('LOGINIZER_PREMIUM') ? ' (<font color="green">Security PRO Version</font>)' : '').'</td>
1328 + </tr>';
1329 +
1330 + do_action('loginizer_system_information');
1331 +
1332 + echo '<tr>
1333 + <th align="left">'.__('URL', 'loginizer').'</th>
1334 + <td>'.get_site_url().'</td>
1335 + </tr>
1336 + <tr>
1337 + <th align="left">'.__('Path', 'loginizer').'</th>
1338 + <td>'.ABSPATH.'</td>
1339 + </tr>
1340 + <tr>
1341 + <th align="left">'.__('Server\'s IP Address', 'loginizer').'</th>
1342 + <td>'.@$_SERVER['SERVER_ADDR'].'</td>
1343 + </tr>
1344 + <tr>
1345 + <th align="left">'.__('Your IP Address', 'loginizer').'</th>
1346 + <td>'.lz_getip().'
1347 + <div style="float:right">
1348 + Method :
1349 + <select name="lz_ip_method" id="lz_ip_method" style="font-size:11px; width:150px" onchange="lz_ip_method_handle()">
1350 + <option value="0" '.lz_POSTselect('lz_ip_method', 0, (@$loginizer['ip_method'] == 0)).'>REMOTE_ADDR</option>
1351 + <option value="1" '.lz_POSTselect('lz_ip_method', 1, (@$loginizer['ip_method'] == 1)).'>HTTP_X_FORWARDED_FOR</option>
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>
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" />
1356 + <input name="save_lz_ip_method" class="button button-primary" value="Save" type="submit" />
1357 + </div>
1358 + </td>
1359 + </tr>
1360 + <tr>
1361 + <th align="left">'.__('wp-config.php is writable', 'loginizer').'</th>
1362 + <td>'.(is_writable(ABSPATH.'/wp-config.php') ? '<span style="color:red">Yes</span>' : '<span style="color:green">No</span>').'</td>
1363 + </tr>';
1364 +
1365 + if(file_exists(ABSPATH.'/.htaccess')){
1366 + echo '
1367 + <tr>
1368 + <th align="left">'.__('.htaccess is writable', 'loginizer').'</th>
1369 + <td>'.(is_writable(ABSPATH.'/.htaccess') ? '<span style="color:red">Yes</span>' : '<span style="color:green">No</span>').'</td>
1370 + </tr>';
1371 +
1372 + }
1373 +
1374 + ?>
1375 + </table>
1376 + </form>
1377 +
1378 + </div>
1379 + </div>
707 1380
708 - if(empty($user)){
709 - error_log('Loginizer: Unable to get the user');
710 - return;
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();
711 1389 }
1390 +};
712 1391
713 - if(empty($loginizer['login_mail']['roles']) || !is_array($loginizer['login_mail']['roles'])){
714 - return;
1392 +lz_ip_method_handle();
1393 +
1394 +</script>
1395 +
1396 + <div id="" class="postbox">
1397 +
1398 + <div class="postbox-header">
1399 + <h2 class="hndle ui-sortable-handle">
1400 + <span><?php echo __('File Permissions', 'loginizer'); ?></span>
1401 + </h2>
1402 + </div>
1403 +
1404 + <div class="inside">
1405 +
1406 + <form action="" method="post" enctype="multipart/form-data">
1407 + <?php wp_nonce_field('loginizer-options'); ?>
1408 + <table class="wp-list-table fixed striped users" border="0" width="95%" cellpadding="10" align="center">
1409 + <?php
1410 +
1411 + echo '
1412 + <tr>
1413 + <th style="background:#EFEFEF;">'.__('Relative Path', 'loginizer').'</th>
1414 + <th style="width:10%; background:#EFEFEF;">'.__('Suggested', 'loginizer').'</th>
1415 + <th style="width:10%; background:#EFEFEF;">'.__('Actual', 'loginizer').'</th>
1416 + </tr>';
1417 +
1418 + $wp_content = basename(dirname(dirname(dirname(__FILE__))));
1419 +
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'));
1428 +
1429 + $root = ABSPATH;
1430 +
1431 + foreach($files_to_check as $k => $v){
1432 +
1433 + $path = $root.'/'.$k;
1434 + $stat = @stat($path);
1435 + $suggested = $v;
1436 + $actual = substr(sprintf('%o', $stat['mode']), -4);
1437 +
1438 + echo '
1439 + <tr>
1440 + <td>'.$k.'</td>
1441 + <td>'.current($suggested).'</td>
1442 + <td><span '.(!in_array($actual, $suggested) ? 'style="color: red;"' : '').'>'.$actual.'</span></td>
1443 + </tr>';
1444 +
1445 + }
1446 +
1447 + ?>
1448 + </table>
1449 + </form>
1450 +
1451 + </div>
1452 + </div>
1453 +
1454 +<?php
1455 +
1456 + loginizer_page_footer();
1457 +
1458 +}
1459 +
1460 +// The Loginizer Admin Options Page
1461 +function loginizer_page_brute_force(){
1462 +
1463 + global $wpdb, $wp_roles, $loginizer;
1464 +
1465 + if(!current_user_can('manage_options')){
1466 + wp_die('Sorry, but you do not have permissions to change settings.');
715 1467 }
716 1468
717 - // Check if the user role is enabled for email notification.
718 - if(!array_intersect($user->roles, $loginizer['login_mail']['roles'])){
719 - return;
1469 + /* Make sure post was from this page */
1470 + if(count($_POST) > 0){
1471 + check_admin_referer('loginizer-options');
720 1472 }
1473 +
1474 + // BEGIN THEME
1475 + loginizer_page_header('Brute Force Settings');
1476 +
1477 + // Load the blacklist and whitelist
1478 + $loginizer['blacklist'] = get_option('loginizer_blacklist');
1479 + $loginizer['whitelist'] = get_option('loginizer_whitelist');
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
1510 + if(isset($_POST['save_lz'])){
1511 +
1512 + $max_retries = (int) lz_optpost('max_retries');
1513 + $lockout_time = (int) lz_optpost('lockout_time');
1514 + $max_lockouts = (int) lz_optpost('max_lockouts');
1515 + $lockouts_extend = (int) lz_optpost('lockouts_extend');
1516 + $reset_retries = (int) lz_optpost('reset_retries');
1517 + $notify_email = (int) lz_optpost('notify_email');
1518 +
1519 + $lockout_time = $lockout_time * 60;
1520 + $lockouts_extend = $lockouts_extend * 60 * 60;
1521 + $reset_retries = $reset_retries * 60 * 60;
1522 +
1523 + if(empty($error)){
1524 +
1525 + $option['max_retries'] = $max_retries;
1526 + $option['lockout_time'] = $lockout_time;
1527 + $option['max_lockouts'] = $max_lockouts;
1528 + $option['lockouts_extend'] = $lockouts_extend;
1529 + $option['reset_retries'] = $reset_retries;
1530 + $option['notify_email'] = $notify_email;
1531 +
1532 + // Save the options
1533 + update_option('loginizer_options', $option);
1534 +
1535 + $saved = true;
1536 +
1537 + }else{
1538 + lz_report_error($error);
1539 + }
1540 +
1541 + if(!empty($notice)){
1542 + lz_report_notice($notice);
1543 + }
1544 +
1545 + if(!empty($saved)){
1546 + echo '<div id="message" class="updated"><p>'
1547 + . __('The settings were saved successfully', 'loginizer')
1548 + . '</p></div><br />';
1549 + }
1550 +
1551 + }
1552 +
1553 + // Delete a Blackist IP range
1554 + if(isset($_POST['bdelid'])){
1555 +
1556 + $delid = (int) lz_optreq('bdelid');
1557 +
1558 + // Unset and save
1559 + $blacklist = $loginizer['blacklist'];
1560 + unset($blacklist[$delid]);
1561 + update_option('loginizer_blacklist', $blacklist);
1562 +
1563 + echo '<div id="message" class="updated fade"><p>'
1564 + . __('The Blacklist IP range has been deleted successfully', 'loginizer')
1565 + . '</p></div><br />';
1566 +
1567 + }
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 +
1581 + // Delete a Whitelist IP range
1582 + if(isset($_POST['delid'])){
1583 +
1584 + $delid = (int) lz_optreq('delid');
1585 +
1586 + // Unset and save
1587 + $whitelist = $loginizer['whitelist'];
1588 + unset($whitelist[$delid]);
1589 + update_option('loginizer_whitelist', $whitelist);
1590 +
1591 + echo '<div id="message" class="updated fade"><p>'
1592 + . __('The Whitelist IP range has been deleted successfully', 'loginizer')
1593 + . '</p></div><br />';
1594 +
1595 + }
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 +
1609 + // Reset All Logs
1610 + if(isset($_POST['lz_reset_all_ip'])){
1611 +
1612 + $result = $wpdb->query("DELETE FROM `".$wpdb->prefix."loginizer_logs` WHERE `time` > 0");
1613 +
1614 + echo '<div id="message" class="updated fade"><p>'
1615 + . __('All the IP Logs have been cleared', 'loginizer')
1616 + . '</p></div><br />';
1617 + }
1618 +
1619 + // Reset Logs
1620 + if(isset($_POST['lz_reset_ips']) && is_array($_POST['lz_reset_ips'])){
721 1621
722 - // current_datetime & wp_timezone_string were introduced in WordPress 5.3
723 - if(!empty($wp_version) && version_compare($wp_version, '5.3', '>') && function_exists('current_datetime')){
724 - $time_zone = wp_timezone_string();
1622 + $ips = $_POST['lz_reset_ips'];
1623 +
1624 + foreach($ips as $ip){
1625 + if(!lz_valid_ip($ip)){
1626 + $error[] = 'The IP - '.esc_html($ip).' is invalid !';
1627 + }
1628 + }
1629 +
1630 + if(count($ips) < 1){
1631 + $error[] = __('There are no IPs submitted', 'loginizer');
1632 + }
1633 +
1634 + // Should we start deleting logs
1635 + if(empty($error)){
1636 +
1637 + foreach($ips as $ip){
1638 + $result = $wpdb->query($wpdb->prepare("DELETE FROM `".$wpdb->prefix."loginizer_logs` WHERE `ip` = %s", $ip));
1639 + }
1640 +
1641 + if(empty($error)){
1642 +
1643 + echo '<div id="message" class="updated fade"><p>'
1644 + . __('The selected IP Logs have been reset', 'loginizer')
1645 + . '</p></div><br />';
1646 +
1647 + }
1648 +
1649 + }
1650 +
1651 + if(!empty($error)){
1652 + lz_report_error($error);echo '<br />';
1653 + }
1654 +
1655 + }
1656 +
1657 + if(isset($_POST['blacklist_iprange'])){
725 1658
726 - if(!empty($time_zone) && isset($time_zone[1]) && is_numeric($time_zone[1])){
727 - $time_zone = 'UTC'.$time_zone;
1659 + $start_ip = lz_optpost('start_ip');
1660 + $end_ip = lz_optpost('end_ip');
1661 +
1662 + if(empty($start_ip)){
1663 + $error[] = __('Please enter the Start IP', 'loginizer');
728 1664 }
1665 +
1666 + // If no end IP we consider only 1 IP
1667 + if(empty($end_ip)){
1668 + $end_ip = $start_ip;
1669 + }
1670 +
1671 + if(!lz_valid_ip($start_ip)){
1672 + $error[] = __('Please provide a valid start IP', 'loginizer');
1673 + }
1674 +
1675 + if(!lz_valid_ip($end_ip)){
1676 + $error[] = __('Please provide a valid end IP', 'loginizer');
1677 + }
1678 +
1679 + // Regular ranges will work
1680 + if(inet_ptoi($start_ip) > inet_ptoi($end_ip)){
1681 +
1682 + // BUT, if 0.0.0.1 - 255.255.255.255 is given, it will not work
1683 + if(inet_ptoi($start_ip) >= 0 && inet_ptoi($end_ip) < 0){
1684 + // This is right
1685 + }else{
1686 + $error[] = __('The End IP cannot be smaller than the Start IP', 'loginizer');
1687 + }
1688 +
1689 + }
1690 +
1691 + if(empty($error)){
1692 +
1693 + $blacklist = $loginizer['blacklist'];
1694 +
1695 + foreach($blacklist as $k => $v){
1696 +
1697 + // This is to check if there is any other range exists with the same Start or 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) )
1700 + ){
1701 + $error[] = __('The Start IP or End IP submitted conflicts with an existing IP range !', 'loginizer');
1702 + break;
1703 + }
1704 +
1705 + // This is to check if there is any other range exists with the same Start IP
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');
1708 + break;
1709 + }
1710 +
1711 + // This is to check if there is any other range exists with the same End IP
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');
1714 + break;
1715 + }
1716 +
1717 + }
1718 +
1719 + $newid = ( empty($blacklist) ? 0 : max(array_keys($blacklist)) ) + 1;
1720 +
1721 + if(empty($error)){
1722 +
1723 + $blacklist[$newid] = array();
1724 + $blacklist[$newid]['start'] = $start_ip;
1725 + $blacklist[$newid]['end'] = $end_ip;
1726 + $blacklist[$newid]['time'] = time();
1727 +
1728 + update_option('loginizer_blacklist', $blacklist);
1729 +
1730 + echo '<div id="message" class="updated fade"><p>'
1731 + . __('Blacklist IP range added successfully', 'loginizer')
1732 + . '</p></div><br />';
1733 +
1734 + }
1735 +
1736 + }
1737 +
1738 + if(!empty($error)){
1739 + lz_report_error($error);echo '<br />';
1740 + }
1741 +
1742 + }
1743 +
1744 + if(isset($_POST['whitelist_iprange'])){
729 1745
730 - // Setting up data variables.
731 - $date = current_datetime()->format('Y-m-d H:i:s') .' '. $time_zone;
732 - } else {
733 - $date = date("Y-m-d H:i:s", time()) . ' ' . date_default_timezone_get();
1746 + $start_ip = lz_optpost('start_ip_w');
1747 + $end_ip = lz_optpost('end_ip_w');
1748 +
1749 + if(empty($start_ip)){
1750 + $error[] = __('Please enter the Start IP', 'loginizer');
1751 + }
1752 +
1753 + // If no end IP we consider only 1 IP
1754 + if(empty($end_ip)){
1755 + $end_ip = $start_ip;
1756 + }
1757 +
1758 + if(!lz_valid_ip($start_ip)){
1759 + $error[] = __('Please provide a valid start IP', 'loginizer');
1760 + }
1761 +
1762 + if(!lz_valid_ip($end_ip)){
1763 + $error[] = __('Please provide a valid end IP', 'loginizer');
1764 + }
1765 +
1766 + if(inet_ptoi($start_ip) > inet_ptoi($end_ip)){
1767 +
1768 + // BUT, if 0.0.0.1 - 255.255.255.255 is given, it will not work
1769 + if(inet_ptoi($start_ip) >= 0 && inet_ptoi($end_ip) < 0){
1770 + // This is right
1771 + }else{
1772 + $error[] = __('The End IP cannot be smaller than the Start IP', 'loginizer');
1773 + }
1774 +
1775 + }
1776 +
1777 + if(empty($error)){
1778 +
1779 + $whitelist = $loginizer['whitelist'];
1780 +
1781 + foreach($whitelist as $k => $v){
1782 +
1783 + // This is to check if there is any other range exists with the same Start or 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) )
1786 + ){
1787 + $error[] = __('The Start IP or End IP submitted conflicts with an existing IP range !', 'loginizer');
1788 + break;
1789 + }
1790 +
1791 + // This is to check if there is any other range exists with the same Start IP
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');
1794 + break;
1795 + }
1796 +
1797 + // This is to check if there is any other range exists with the same End IP
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');
1800 + break;
1801 + }
1802 +
1803 + }
1804 +
1805 + $newid = ( empty($whitelist) ? 0 : max(array_keys($whitelist)) ) + 1;
1806 +
1807 + if(empty($error)){
1808 +
1809 + $whitelist[$newid] = array();
1810 + $whitelist[$newid]['start'] = $start_ip;
1811 + $whitelist[$newid]['end'] = $end_ip;
1812 + $whitelist[$newid]['time'] = time();
1813 +
1814 + update_option('loginizer_whitelist', $whitelist);
1815 +
1816 + echo '<div id="message" class="updated fade"><p>'
1817 + . __('Whitelist IP range added successfully', 'loginizer')
1818 + . '</p></div><br />';
1819 +
1820 + }
1821 +
1822 + }
1823 +
1824 + if(!empty($error)){
1825 + lz_report_error($error);echo '<br />';
1826 + }
734 1827 }
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 + }
735 1847
736 - $sitename = lz_is_multisite() ? get_site_option('site_name') : get_option('blogname');
737 - $email = $user->data->user_email;
1848 + // Count the Results
1849 + $tmp = lz_selectquery("SELECT COUNT(*) AS num FROM `".$wpdb->prefix."loginizer_logs`");
1850 + //print_r($tmp);
1851 +
1852 + // Which Page is it
1853 + $lz_env['res_len'] = 10;
1854 + $lz_env['cur_page'] = lz_get_page('lzpage', $lz_env['res_len']);
1855 + $lz_env['num_res'] = $tmp['num'];
1856 + $lz_env['max_page'] = ceil($lz_env['num_res'] / $lz_env['res_len']);
1857 +
1858 + // Get the logs
1859 + $result = lz_selectquery("SELECT * FROM `".$wpdb->prefix."loginizer_logs`
1860 + ORDER BY `time` DESC
1861 + LIMIT ".$lz_env['cur_page'].", ".$lz_env['res_len']."", 1);
1862 + //print_r($result);
1863 +
1864 + $lz_env['cur_page'] = ($lz_env['cur_page'] / $lz_env['res_len']) + 1;
1865 + $lz_env['cur_page'] = $lz_env['cur_page'] < 1 ? 1 : $lz_env['cur_page'];
1866 + $lz_env['next_page'] = ($lz_env['cur_page'] + 1) > $lz_env['max_page'] ? $lz_env['max_page'] : ($lz_env['cur_page'] + 1);
1867 + $lz_env['prev_page'] = ($lz_env['cur_page'] - 1) < 1 ? 1 : ($lz_env['cur_page'] - 1);
1868 +
1869 + // Reload the settings
1870 + $loginizer['blacklist'] = get_option('loginizer_blacklist');
1871 + $loginizer['whitelist'] = get_option('loginizer_whitelist');
1872 +
1873 + $saved_msgs = get_option('loginizer_msg');
1874 +
1875 + ?>
738 1876
739 - $vars = array(
740 - 'date' => $date,
741 - 'ip' => esc_html($loginizer['current_ip']),
742 - 'sitename' => $sitename,
743 - 'user_login' => $user_login
744 - );
1877 + <div id="" class="postbox">
1878 +
1879 + <div class="postbox-header">
1880 + <h2 class="hndle ui-sortable-handle">
1881 + <?php echo __('<span>Failed Login Attempts Logs</span> &nbsp; (Past '.($loginizer['reset_retries']/60/60).' hours)','loginizer'); ?>
1882 + </h2>
1883 + </div>
1884 +
1885 + <script>
1886 + function yesdsd(){
1887 + window.location = '<?php echo menu_page_url('loginizer_brute_force', false);?>&lzpage='+jQuery("#current-page-selector").val();
1888 + return false;
1889 + }
1890 + </script>
1891 +
1892 + <form method="get" onsubmit="return yesdsd();">
1893 + <div class="tablenav">
1894 + <p class="tablenav-pages" style="margin: 5px 10px" align="right">
1895 + <span class="displaying-num"><?php echo $lz_env['num_res'];?> items</span>
1896 + <span class="pagination-links">
1897 + <a class="first-page" href="<?php echo menu_page_url('loginizer_brute_force', false).'&lzpage=1';?>"><span class="screen-reader-text">First page</span><span aria-hidden="true">«</span></a>
1898 + <a class="prev-page" href="<?php echo menu_page_url('loginizer_brute_force', false).'&lzpage='.$lz_env['prev_page'];?>"><span class="screen-reader-text">Previous page</span><span aria-hidden="true">‹</span></a>
1899 + <span class="paging-input">
1900 + <label for="current-page-selector" class="screen-reader-text">Current Page</label>
1901 + <input class="current-page" id="current-page-selector" name="lzpage" value="<?php echo $lz_env['cur_page'];?>" size="3" aria-describedby="table-paging" type="text"><span class="tablenav-paging-text"> of <span class="total-pages"><?php echo $lz_env['max_page'];?></span></span>
1902 + </span>
1903 + <a class="next-page" href="<?php echo menu_page_url('loginizer_brute_force', false).'&lzpage='.$lz_env['next_page'];?>"><span class="screen-reader-text">Next page</span><span aria-hidden="true">›</span></a>
1904 + <a class="last-page" href="<?php echo menu_page_url('loginizer_brute_force', false).'&lzpage='.$lz_env['max_page'];?>"><span class="screen-reader-text">Last page</span><span aria-hidden="true">»</span></a>
1905 + </span>
1906 + </p>
1907 + </div>
1908 + </form>
1909 +
1910 + <form action="" method="post" enctype="multipart/form-data">
1911 + <?php wp_nonce_field('loginizer-options'); ?>
1912 + <div class="inside">
1913 + <table class="wp-list-table widefat fixed users" border="0">
1914 + <tr>
1915 + <th scope="row" valign="top" style="background:#EFEFEF;" width="20">#</th>
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>
1918 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Last Failed Attempt (DD/MM/YYYY)','loginizer'); ?></th>
1919 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Failed Attempts 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>
1922 + </tr>
1923 + <?php
1924 +
1925 + if(empty($result)){
1926 + echo '
1927 + <tr>
1928 + <td colspan="4">
1929 + '.__('No Logs. You will see logs about failed login attempts here.', 'loginizer').'
1930 + </td>
1931 + </tr>';
1932 + }else{
1933 + foreach($result as $ik => $iv){
1934 + $status_button = (!empty($iv['status']) ? 'disable' : 'enable');
1935 + echo '
1936 + <tr>
1937 + <td>
1938 + <input type="checkbox" value="'.esc_attr($iv['ip']).'" name="lz_reset_ips[]" />
1939 + </td>
1940 + <td>
1941 + '.esc_html($iv['ip']).'
1942 + </td>
1943 + <td>
1944 + '.esc_html($iv['username']).'
1945 + </td>
1946 + <td>
1947 + '.date('d/M/Y H:i:s P', $iv['time']).'
1948 + </td>
1949 + <td>
1950 + '.esc_html($iv['count']).'
1951 + </td>
1952 + <td>
1953 + '.esc_html($iv['lockout']).'
1954 + </td>
1955 + <td>
1956 + '.esc_html($iv['url']).'
1957 + </td>
1958 + </tr>';
1959 + }
1960 + }
1961 +
1962 + ?>
1963 + </table>
1964 +
1965 + <br>
1966 + <input name="lz_reset_ip" class="button button-primary action" value="<?php echo __('Remove From Logs', 'loginizer'); ?>" type="submit" />
1967 + &nbsp; &nbsp;
1968 + <input name="lz_reset_all_ip" class="button button-primary action" value="<?php echo __('Clear All Logs', 'loginizer'); ?>" type="submit" />
1969 + </div>
1970 + </div>
1971 + </form>
1972 + <br />
1973 +
1974 + <div id="" class="postbox">
1975 +
1976 + <div class="postbox-header">
1977 + <h2 class="hndle ui-sortable-handle">
1978 + <span><?php echo __('Brute Force Settings', 'loginizer'); ?></span>
1979 + </h2>
1980 + </div>
1981 +
1982 + <div class="inside">
1983 +
1984 + <form action="" method="post" enctype="multipart/form-data">
1985 + <?php wp_nonce_field('loginizer-options'); ?>
1986 + <table class="form-table">
1987 + <tr>
1988 + <th scope="row" valign="top"><label for="max_retries"><?php echo __('Max Retries','loginizer'); ?></label></th>
1989 + <td>
1990 + <input type="text" size="3" value="<?php echo lz_optpost('max_retries', $loginizer['max_retries']); ?>" name="max_retries" id="max_retries" /> <?php echo __('Maximum failed attempts allowed before lockout','loginizer'); ?> <br />
1991 + </td>
1992 + </tr>
1993 + <tr>
1994 + <th scope="row" valign="top"><label for="lockout_time"><?php echo __('Lockout Time','loginizer'); ?></label></th>
1995 + <td>
1996 + <input type="text" size="3" value="<?php echo (!empty($lockout_time) ? $lockout_time : $loginizer['lockout_time']) / 60; ?>" name="lockout_time" id="lockout_time" /> <?php echo __('minutes','loginizer'); ?> <br />
1997 + </td>
1998 + </tr>
1999 + <tr>
2000 + <th scope="row" valign="top"><label for="max_lockouts"><?php echo __('Max Lockouts','loginizer'); ?></label></th>
2001 + <td>
2002 + <input type="text" size="3" value="<?php echo lz_optpost('max_lockouts', $loginizer['max_lockouts']); ?>" name="max_lockouts" id="max_lockouts" /> <?php echo __('','loginizer'); ?> <br />
2003 + </td>
2004 + </tr>
2005 + <tr>
2006 + <th scope="row" valign="top"><label for="lockouts_extend"><?php echo __('Extend Lockout','loginizer'); ?></label></th>
2007 + <td>
2008 + <input type="text" size="3" value="<?php echo (!empty($lockouts_extend) ? $lockouts_extend : $loginizer['lockouts_extend']) / 60 / 60; ?>" name="lockouts_extend" id="lockouts_extend" /> <?php echo __('hours. Extend Lockout time after Max Lockouts','loginizer'); ?> <br />
2009 + </td>
2010 + </tr>
2011 + <tr>
2012 + <th scope="row" valign="top"><label for="reset_retries"><?php echo __('Reset Retries','loginizer'); ?></label></th>
2013 + <td>
2014 + <input type="text" size="3" value="<?php echo (!empty($reset_retries) ? $reset_retries : $loginizer['reset_retries']) / 60 / 60; ?>" name="reset_retries" id="reset_retries" /> <?php echo __('hours','loginizer'); ?> <br />
2015 + </td>
2016 + </tr>
2017 + <tr>
2018 + <th scope="row" valign="top"><label for="notify_email"><?php echo __('Email Notification','loginizer'); ?></label></th>
2019 + <td>
2020 + <?php echo __('after ','loginizer'); ?>
2021 + <input type="text" size="3" value="<?php echo (!empty($notify_email) ? $notify_email : $loginizer['notify_email']); ?>" name="notify_email" id="notify_email" /> <?php echo __('lockouts <br />0 to disable email notifications','loginizer'); ?>
2022 + </td>
2023 + </tr>
2024 + </table><br />
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 + ?>
2039 + </form>
2040 +
2041 + </div>
2042 + </div>
2043 + <br />
2044 +
2045 +<?php
2046 +
2047 + wp_enqueue_script('jquery-paginate', LOGINIZER_URL.'/jquery-paginate.js', array('jquery'), '1.10.15');
2048 +
2049 +?>
745 2050
746 - $message = lz_lang_vars_name($loginizer['login_mail_body'], $vars);
747 - $subject = lz_lang_vars_name($loginizer['login_mail_subject'], $vars);
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);
748 2081
749 - $headers = [];
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 + }
750 2087
751 - // Do we need to send the email as HTML ?
752 - if(!empty($loginizer['login_mail']['html_mail'])){
753 - $headers[] = 'Content-Type: text/html; charset=UTF-8';
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 +
2106 + <div id="" class="postbox">
2107 +
2108 + <div class="postbox-header">
2109 + <h2 class="hndle ui-sortable-handle">
2110 + <span><?php echo __('Blacklist IP','loginizer'); ?></span>
2111 + </h2>
2112 + </div>
754 2113
755 - if(!empty($loginizer['login_mail']['body'])){
756 - $message = html_entity_decode($message);
2114 + <div class="inside">
2115 +
2116 + <?php echo __('Enter the IP you want to blacklist from login','loginizer'); ?>
2117 +
2118 + <form action="" method="post">
2119 + <?php wp_nonce_field('loginizer-options'); ?>
2120 + <table class="form-table">
2121 + <tr>
2122 + <th scope="row" valign="top"><label for="start_ip"><?php echo __('Start IP','loginizer'); ?></label></th>
2123 + <td>
2124 + <input type="text" size="25" value="<?php echo(lz_optpost('start_ip')); ?>" name="start_ip" id="start_ip"/> <?php echo __('Start IP of the range','loginizer'); ?> <br />
2125 + </td>
2126 + </tr>
2127 + <tr>
2128 + <th scope="row" valign="top"><label for="end_ip"><?php echo __('End IP (Optional)','loginizer'); ?></label></th>
2129 + <td>
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 />
2131 + </td>
2132 + </tr>
2133 + </table><br />
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" />
2136 + </form>
2137 + </div>
2138 +
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">
2141 + <tr>
2142 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
2143 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
2144 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
2145 + <th scope="row" valign="top" style="background:#EFEFEF;" width="100"><?php echo __('Options','loginizer'); ?></th>
2146 + </tr>
2147 + <?php
2148 + if(empty($loginizer['blacklist'])){
2149 + echo '
2150 + <tr>
2151 + <td colspan="4">
2152 + '.__('No Blacklist IPs. You will see blacklisted IP ranges here.', 'loginizer').'
2153 + </td>
2154 + </tr>';
2155 + }else{
2156 + foreach($loginizer['blacklist'] as $ik => $iv){
2157 + echo '
2158 + <tr>
2159 + <td>
2160 + '.$iv['start'].'
2161 + </td>
2162 + <td>
2163 + '.$iv['end'].'
2164 + </td>
2165 + <td>
2166 + '.date('d/m/Y', $iv['time']).'
2167 + </td>
2168 + <td>
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>
2170 + </td>
2171 + </tr>';
2172 + }
2173 + }
2174 + ?>
2175 + </table>
2176 + <br />
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>
2181 + </div>
2182 +
2183 + <br />
2184 +
2185 + <div id="" class="postbox">
2186 +
2187 + <div class="postbox-header">
2188 + <h2 class="hndle ui-sortable-handle">
2189 + <span><?php echo __('Whitelist IP', 'loginizer'); ?></span>
2190 + </h2>
2191 + </div>
2192 +
2193 + <div class="inside">
2194 +
2195 + <?php echo __('Enter the IP you want to whitelist for login','loginizer'); ?>
2196 + <form action="" method="post">
2197 + <?php wp_nonce_field('loginizer-options'); ?>
2198 + <table class="form-table">
2199 + <tr>
2200 + <th scope="row" valign="top"><label for="start_ip_w"><?php echo __('Start IP','loginizer'); ?></label></th>
2201 + <td>
2202 + <input type="text" size="25" value="<?php echo(lz_optpost('start_ip_w')); ?>" name="start_ip_w" id="start_ip_w"/> <?php echo __('Start IP of the range','loginizer'); ?> <br />
2203 + </td>
2204 + </tr>
2205 + <tr>
2206 + <th scope="row" valign="top"><label for="end_ip_w"><?php echo __('End IP (Optional)','loginizer'); ?></label></th>
2207 + <td>
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 />
2209 + </td>
2210 + </tr>
2211 + </table><br />
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" />
2214 + </form>
2215 + </div>
2216 +
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">
2219 + <tr>
2220 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Start IP','loginizer'); ?></th>
2221 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('End IP','loginizer'); ?></th>
2222 + <th scope="row" valign="top" style="background:#EFEFEF;"><?php echo __('Date (DD/MM/YYYY)','loginizer'); ?></th>
2223 + <th scope="row" valign="top" style="background:#EFEFEF;" width="100"><?php echo __('Options','loginizer'); ?></th>
2224 + </tr>
2225 + <?php
2226 + if(empty($loginizer['whitelist'])){
2227 + echo '
2228 + <tr>
2229 + <td colspan="4">
2230 + '.__('No Whitelist IPs. You will see whitelisted IP ranges here.', 'loginizer').'
2231 + </td>
2232 + </tr>';
2233 + }else{
2234 + foreach($loginizer['whitelist'] as $ik => $iv){
2235 + echo '
2236 + <tr>
2237 + <td>
2238 + '.$iv['start'].'
2239 + </td>
2240 + <td>
2241 + '.$iv['end'].'
2242 + </td>
2243 + <td>
2244 + '.date('d/m/Y', $iv['time']).'
2245 + </td>
2246 + <td>
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>
2248 + </td>
2249 + </tr>';
2250 + }
2251 + }
2252 + ?>
2253 + </table>
2254 + <br />
2255 +
2256 + </div>
2257 +
2258 + <div id="" class="postbox">
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>
2318 +<?php
2319 +
2320 +loginizer_page_footer();
2321 +
2322 +}
2323 +
2324 +//---------------------
2325 +// Admin Menu Pro Pages
2326 +//---------------------
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 +
757 2443 }else{
758 - $message = preg_replace("/\<br\s*\/\>/i", "<br/>", $message);
759 - $message = preg_replace('/(?<!<br\/>)\n/i', "<br/>\n", $message);
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 +
760 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 +
761 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 +}
762 2500
763 - // Sending notification
764 - if(empty(wp_mail($email, $subject, $message, $headers))){
765 - error_log(__('There was a problem sending your email.', 'loginizer'));
766 - return;
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 />';
767 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%;
768 2531 }
2532 +</style>
769 2533
770 -function loginizer_update_attempt_stats($type){
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 />
771 2732
772 - $stats = get_option('loginizer_login_attempt_stats', []);
773 - $time = strtotime(date('Y-m-d H:00:00'));
2733 +<script type="text/javascript">
2734 +
2735 +function no_google_recaptcha(obj){
774 2736
775 - if(empty($stats[$time][$type])){
776 - $stats[$time][$type] = 0;
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();
777 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 +}
778 2754
779 - $stats[$time][$type] += 1;
2755 +no_google_recaptcha(jQuery("#captcha_no_google")[0]);
780 2756
781 - update_option('loginizer_login_attempt_stats', $stats, false);
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 + }
782 2763 }
783 2764
784 -// Handles the error of the password not being there
785 -function loginizer_error_handler($errors, $redirect_to){
2765 +
2766 +</script>
786 2767
787 - global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
2768 + <?php
2769 + loginizer_page_footer();
2770 +
2771 +}
788 2772
789 - //echo 'loginizer_error_handler :';print_r($errors->errors);echo '<br>';
790 - if(is_null($errors) || empty($errors)){
791 - return true;
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.');
792 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 + }
793 2787
794 - // Remove the empty password error
795 - if(is_wp_error($errors)){
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'])){
796 2797
797 - $codes = $errors->get_error_codes();
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');
798 2803
799 - foreach($codes as $k => $v){
800 - if($v == 'invalid_username' || $v == 'incorrect_password'){
801 - $show_error = 1;
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;
802 2809 }
2810 +
803 2811 }
804 2812
805 - $errors->remove('invalid_username');
806 - $errors->remove('incorrect_password');
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 + }
807 2830
808 - // Add the error
809 - if(!empty($lz_user_pass) && !empty($show_error) && empty($lz_cannot_login)){
810 - $errors->add('invalid_userpass', '<b>ERROR:</b> ' . $loginizer['msg']['inv_userpass']);
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);
811 2842 }
812 2843
813 - // Add the number of retires left as well
814 - if(count($errors->get_error_codes()) > 0 && isset($loginizer['retries_left'])){
815 - $errors->add('retries_left', loginizer_retries_left());
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();
816 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'])){
817 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 + }
818 3006 }
819 3007
820 - return $errors;
821 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 +
822 3016 }
823 3017
824 -// Handles the error of the password not being there
825 -function loginizer_woocommerce_error_handler(){
826 3018
827 - global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
3019 +// Loginizer - Two Factor Auth Page
3020 +function loginizer_page_2fa_T(){
828 3021
829 - if(function_exists('wc_add_notice')){
830 - wc_add_notice( loginizer_retries_left(), 'error' );
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 />';
831 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%;
832 3044 }
833 3045
834 -function loginizer_ultimatemember_error_handler(){
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">
835 3056
836 - if(class_exists('UM')){
837 - \UM()->form()->add_error('remaining_tries', loginizer_retries_left());
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();
838 3145 }
3146 +
839 3147 }
840 3148
841 -// Handles social login URL
842 -function loginizer_social_login_error_handler($errors = '', $redirect_to = ''){
843 - global $loginizer;
3149 +lz_roles_handle();
844 3150
845 - loginizer_get_social_error();
3151 +</script>
846 3152
847 - if(empty($loginizer['social_errors'])){
848 - return $errors;
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();
849 3362 }
3363 +
3364 + return false;
3365 +
3366 +}
850 3367
851 - if(is_null($errors) || empty($errors) || !is_wp_error($errors)){
852 - $errors = new WP_Error();
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;
853 3374 }
3375 +
3376 + return false;
3377 +
3378 +}
854 3379
855 - foreach($loginizer['social_errors'] as $key => $text){
856 - $errors->add($key, $text);
857 - }
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>
858 3459
859 - return $errors;
3460 + <?php
3461 + loginizer_page_footer();
3462 +
860 3463 }
861 3464
862 -// Returns a string with the number of retries left
863 -function loginizer_retries_left(){
3465 +// Loginizer - PasswordLess Page
3466 +function loginizer_page_passwordless(){
864 3467
865 - global $wpdb, $loginizer, $lz_user_pass, $lz_cannot_login;
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 + }
866 3473
867 - // If we are to show the number of retries left
868 - if(isset($loginizer['retries_left'])){
869 - $retries_left = apply_filters('loginizer_retries_left_num', $loginizer['retries_left']);
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'])){
870 3485
871 - return '<b>'.esc_html($retries_left).'</b> '.$loginizer['msg']['attempts_left'];
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 +
872 3503 }
873 3504
3505 + // Call theme
3506 + loginizer_page_passwordless_T();
874 3507 }
875 3508
876 -function loginizer_reset_retries(){
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 + }
877 3530
878 - global $wpdb, $loginizer;
3531 + ?>
879 3532
880 - $deltime = time() - $loginizer['reset_retries'];
3533 +<style>
3534 +input[type="text"], textarea, select {
3535 + width: 90%;
3536 +}
881 3537
882 - $del_query = $wpdb->prepare("DELETE FROM `".$wpdb->prefix."loginizer_logs` WHERE `time` <= %d", $deltime);
883 - $result = $wpdb->query($del_query);
3538 +.form-table label{
3539 + font-weight:bold;
3540 +}
884 3541
885 - update_option('loginizer_last_reset', time());
3542 +.form-table td{
3543 + vertical-align:top;
3544 +}
886 3545
3546 +.exp{
3547 + font-size:12px;
887 3548 }
3549 +</style>
888 3550
889 -function loginizer_load_translation_vars(){
890 - global $loginizer;
3551 + <div id="" class="postbox">
891 3552
892 - $loginizer['login_mail_default_sub'] = __('Login Successful at $sitename', 'loginizer');
893 - $loginizer['login_mail_default_msg'] = __('Hello $user_login,
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 />
894 3615
895 -Your account was recently logged in from the IP : $ip
896 -Time : $date
897 -If it was not you who logged in then please report this to us immediately.
3616 + <?php
3617 + loginizer_page_footer();
3618 +
3619 +}
898 3620
899 -Regards,
900 -$sitename','loginizer');
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 + }
901 3634
902 - if(empty($loginizer['login_mail_subject'])){
903 - $loginizer['login_mail_subject'] = $loginizer['login_mail_default_sub'];
3635 + /* Make sure post was from this page */
3636 + if(count($_POST) > 0){
3637 + check_admin_referer('loginizer-options');
904 3638 }
905 3639
906 - if(empty($loginizer['login_mail_body'])){
907 - $loginizer['login_mail_body'] = $loginizer['login_mail_default_msg'];
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 +
908 3673 }
909 3674
910 - // Default messages
911 - $loginizer['d_msg']['inv_userpass'] = __('Incorrect Username or Password', 'loginizer');
912 - $loginizer['d_msg']['ip_blacklisted'] = __('Your IP has been blacklisted', 'loginizer');
913 - $loginizer['d_msg']['attempts_left'] = __('attempt(s) left', 'loginizer');
914 - $loginizer['d_msg']['lockout_err'] = __('You have exceeded maximum login retries<br /> Please try after', 'loginizer');
915 - $loginizer['d_msg']['minutes_err'] = __('minute(s)', 'loginizer');
916 - $loginizer['d_msg']['hours_err'] = __('hour(s)', 'loginizer');
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 + }
917 3706
918 - // Message Strings
919 - $loginizer['msg'] = get_option('loginizer_msg', []);
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 + }
920 3732
921 - foreach($loginizer['d_msg'] as $lk => $lv){
922 - if(empty($loginizer['msg'][$lk])){
923 - $loginizer['msg'][$lk] = $loginizer['d_msg'][$lk];
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();
924 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 +
925 3766 }
926 3767
927 - $loginizer['2fa_d_msg']['otp_app'] = __('Please enter the OTP as seen in your App', 'loginizer');
928 - $loginizer['2fa_d_msg']['otp_email'] = __('Please enter the OTP emailed to you', 'loginizer');
929 - $loginizer['2fa_d_msg']['otp_field'] = __('One Time Password', 'loginizer');
930 - $loginizer['2fa_d_msg']['otp_question'] = __('Please answer your security question', 'loginizer');
931 - $loginizer['2fa_d_msg']['otp_answer'] = __('Your Answer', 'loginizer');
932 3768
933 - // Message Strings
934 - $loginizer['2fa_msg'] = get_option('loginizer_2fa_msg', []);
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 + }
935 3796
936 - foreach($loginizer['2fa_d_msg'] as $lk => $lv){
937 - if(empty($loginizer['2fa_msg'][$lk])){
938 - $loginizer['2fa_msg'][$lk] = $loginizer['2fa_d_msg'][$lk];
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 + }
939 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 +
940 3824 }
941 3825
3826 + // Call theme
3827 + loginizer_page_security_T();
3828 +
942 3829 }
943 3830
944 -function loginizer_social_login_load(){
945 - include_once LOGINIZER_DIR . '/main/social-login.php';
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%;
946 3858 }
947 3859
948 -// Checks if softaculous is installed on the server.
949 -function loginizer_check_softaculous(){
3860 +.form-table label{
3861 + font-weight:bold;
3862 +}
950 3863
951 - // Checking if we have Softaculous installed?
952 - if(!preg_match('/^\/home(?:\d+)?\/.*\//U', ABSPATH, $matches)){
953 - return false;
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 +
954 3982 }
955 3983
956 - if(empty($matches) || empty($matches[0])){
957 - return false;
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();
958 4108 }
4109 +};
959 4110
960 - $softaculous_path = $matches[0] . '.softaculous/installations.php';
961 - if(!file_exists($softaculous_path)){
962 - return false;
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 + }
963 4305 }
964 4306
965 - // Checking if users has changed the branding of Softaculous.
966 - $universal_file = '';
967 - // Plesk, ISPManager, ISPConfig, InterWorx, H-Sphere, CentOS Web Panel, Softaculous Remote and Softaculous Enterprise
968 - if(file_exists('/usr/local/softaculous/enduser/universal.php')){
969 - $universal_file = '/usr/local/softaculous/enduser/universal.php';
970 - }else if(file_exists('/usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/universal.php')){
971 - $universal_file = '/usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/universal.php';
972 - }else if(file_exists('/usr/local/directadmin/plugins/softaculous/enduser/universal.php')){
973 - $universal_file = '/usr/local/directadmin/plugins/softaculous/enduser/universal.php';
974 - }else if(file_exists('/usr/local/vesta/softaculous/enduser/universal.php')){
975 - $universal_file = '/usr/local/vesta/softaculous/enduser/universal.php';
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.');
976 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 + }
977 4325
978 - if(empty($universal_file)){
979 - return false;
4326 + /* Make sure post was from this page */
4327 + if(count($_POST) > 0){
4328 + check_admin_referer('loginizer-options');
980 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 +}
981 4404
982 - $universal = file_get_contents($universal_file);
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 + }
983 4432
984 - if(empty($universal)){
985 - return false;
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.');
986 4675 }
4676 +
4677 + update_option('loginizer_dismiss_newsletter', time());
4678 + echo 1;
4679 + wp_die();
4680 +}
987 4681
988 - // Checking if Softaculous is being whitelabeled
989 - if(preg_match('/\$globals\[["\']sn["\']\]\s.?=\s.?["\']Softaculous["\']/', $universal)){
990 - update_option('loginizer_softwp_upgrade', time());
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;
991 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 +}
992 4752
993 - return false;
994 -}
995 4753
996 4754 // Sorry to see you going
997 4755 register_uninstall_hook(LOGINIZER_FILE, 'loginizer_deactivation');
998 4756
@@ -1016,17 +4774,7 @@
1016 4774 delete_option('loginizer_2fa_msg');
1017 4775 delete_option('loginizer_2fa_email_template');
1018 4776 delete_option('loginizer_security');
1019 4777 delete_option('loginizer_wp_admin');
1020 - delete_option('loginizer_csrf_promo_time');
1021 - delete_option('loginizer_backuply_promo_time');
1022 - delete_option('loginizer_promo_time');
1023 - delete_option('loginizer_ins_time');
1024 - delete_option('loginizer_2fa_whitelist');
1025 - delete_option('loginizer_checksums_last_run');
1026 - delete_option('loginizer_checksums_diff');
1027 - delete_option('loginizer_ip_method');
1028 - delete_option('loginizer_2fa_custom_redirect');
1029 - delete_option('external_updates-loginizer-security');
1030 - delete_option('loginizer_login_attempt_stats');
1031 4778
1032 -}
4779 +}
4780 +