PluginProbe
Loginizer / 2.0.9
Loginizer v2.0.9
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 +74 -106 2.0.02.0.9 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.0');
8 +define('LOGINIZER_VERSION', '2.0.9');
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');
@@ -187,8 +187,29 @@
187 187 $wpdb->query("ALTER TABLE ".$wpdb->prefix."loginizer_logs ADD `url` VARCHAR(255) NOT NULL DEFAULT '' AFTER `ip`;");
188 188
189 189 }
190 190
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 +
191 212 // Save the new Version
192 213 update_option('loginizer_version', LOGINIZER_VERSION);
193 214
194 215 // TODO:: REMOVE THIS AFTER MARCH 2025
@@ -268,8 +289,14 @@
268 289 }
269 290
270 291 // When was the database cleared last time
271 292 $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 + }
272 299
273 300 //print_r($loginizer);
274 301
275 302 // Clear retries
@@ -305,17 +332,22 @@
305 332 // Is called before displaying the error message so that we dont show that the username is wrong or the password
306 333 // Update Error message
307 334 add_action('wp_login_errors', 'loginizer_error_handler', 10001, 2);
308 335 add_action('woocommerce_login_failed', 'loginizer_woocommerce_error_handler', 10001);
309 - add_action('wp_login', 'loginizer_login_success', 10, 2);
336 + add_action('wp_login', 'loginizer_login_success', 11, 2);
337 + add_action('rsssl_two_factor_user_authenticated', 'loginizer_rsssl_2fa_success');
338 +
339 + if(!empty($loginizer['ultimate-member-active'])){
340 + add_action('wp_login_failed', 'loginizer_ultimatemember_error_handler', 10001);
341 + }
310 342
311 - if(!empty($_COOKIE['lz_social_error']) && !empty($loginizer['social_settings']) && !loginizer_is_blacklisted()){
343 + if(!empty($_COOKIE['lz_social_error']) && !empty($loginizer['social_settings'])){
312 344 add_filter('wp_login_errors', 'loginizer_social_login_error_handler', 10000, 2);
313 345 }
314 346 }
315 347
316 348 // Social Login Form Actions
317 - if(!empty($loginizer['social_settings']) && !loginizer_is_blacklisted()){
349 + if(!empty($loginizer['social_settings'])){
318 350 if(!empty($loginizer['social_settings']['login']['login_form'])){
319 351 add_action('login_form', 'loginizer_social_btn_login');
320 352 }
321 353 }
@@ -326,63 +358,16 @@
326 358
327 359 if(is_admin()){
328 360 include_once LOGINIZER_DIR . '/main/admin.php';
329 361 }
330 -
362 +
331 363 // ----------------
332 364 // PRO INIT END
333 365 // ----------------
334 366
335 - // Is the premium features there ?
336 - if(!defined('LOGINIZER_PREMIUM')){
337 -
338 - if(current_user_can('activate_plugins')){
339 - // The promo time
340 - $loginizer['promo_time'] = get_option('loginizer_promo_time');
341 - if(empty($loginizer['promo_time'])){
342 - $loginizer['promo_time'] = time();
343 - update_option('loginizer_promo_time', $loginizer['promo_time']);
344 - }
345 -
346 - // Are we to show the loginizer promo
347 - if(!empty($loginizer['promo_time']) && $loginizer['promo_time'] > 0 && $loginizer['promo_time'] < (time() - (30*24*3600))){
348 -
349 - add_action('admin_notices', 'loginizer_promo');
350 -
351 - }
352 -
353 - if(!empty($loginizer['csrf_promo']) && $loginizer['csrf_promo'] > 0 && $loginizer['csrf_promo'] < (time() - 86400)){
354 -
355 - add_action('admin_notices', 'loginizer_csrf_promo');
356 -
357 - }
358 -
359 - // Are we to disable the promo
360 - if(isset($_GET['loginizer_promo']) && (int)$_GET['loginizer_promo'] == 0){
361 - update_option('loginizer_promo_time', (0 - time()) );
362 - die('DONE');
363 - }
364 -
365 - $loginizer['backuply_promo'] = get_option('loginizer_backuply_promo_time');
366 -
367 - if(empty($loginizer['backuply_promo'])){
368 - $loginizer['backuply_promo'] = abs($loginizer['promo_time']);
369 - update_option('loginizer_backuply_promo_time', $loginizer['backuply_promo']);
370 - }
371 -
372 - // Setting CSRF Promo time
373 - $loginizer['csrf_promo'] = get_option('loginizer_csrf_promo_time');
374 -
375 - if(empty($loginizer['csrf_promo'])){
376 - $loginizer['csrf_promo'] = abs($loginizer['promo_time']);
377 - update_option('loginizer_csrf_promo_time', $loginizer['csrf_promo']);
378 - }
379 - }
380 - }
381 -
382 367 // Secuity checks for social login.
383 - if(!empty($_GET['lz_social_provider']) && loginizer_can_login()){
384 - include_once LOGINIZER_DIR . '/main/social-login.php';
368 + if(!empty($_GET['lz_social_provider']) && loginizer_can_login() && empty($_GET['lz_api'])){
369 + add_action('init', 'loginizer_social_login_load');
385 370 return;
386 371 }
387 372 }
388 373
@@ -491,8 +476,11 @@
491 476 }
492 477
493 478 $lz_error['ip_blocked'] = $loginizer['msg']['lockout_err'].' '.$_time;
494 479
480 + if(!empty($loginizer['ultimate-member-active']) && class_exists('UM')){
481 + \UM()->form()->add_error('blocked_msg', $lz_error['ip_blocked']);
482 + }
495 483 return false;
496 484 }
497 485 }
498 486
@@ -507,26 +495,31 @@
507 495
508 496 if(empty($blacklist)){
509 497 return false;
510 498 }
511 -
499 +
500 + $current_ip_inet = inet_ptoi($loginizer['current_ip']);
501 +
512 502 foreach($blacklist as $k => $v){
513 -
503 +
504 + $start_inet = inet_ptoi($v['start']);
505 + $end_inet = inet_ptoi($v['end']);
506 +
514 507 // Is the IP in the blacklist ?
515 - if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip']) && inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
508 + if($start_inet <= $current_ip_inet && $current_ip_inet <= $end_inet){
516 509 $result = 1;
517 510 break;
518 511 }
519 -
512 +
520 513 // Is it in a wider range ?
521 - if(inet_ptoi($v['start']) >= 0 && inet_ptoi($v['end']) < 0){
514 + if($start_inet >= 0 && $end_inet < 0){
522 515
523 516 // Since the end of the RANGE (i.e. current IP range) is beyond the +ve value of inet_ptoi,
524 517 // if the current IP is <= than the start of the range, it is within the range
525 518 // OR
526 519 // if the current IP is <= than the end of the range, it is within the range
527 - if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip'])
528 - || inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
520 + if($start_inet <= $current_ip_inet
521 + || $current_ip_inet <= $end_inet){
529 522 $result = 1;
530 523 break;
531 524 }
532 525
@@ -532,9 +525,9 @@
532 525
533 526 }
534 527
535 528 }
536 -
529 +
537 530 // You are blacklisted
538 531 if(!empty($result)){
539 532 $lz_error['ip_blacklisted'] = $loginizer['msg']['ip_blacklisted'];
540 533 return true;
@@ -543,52 +536,8 @@
543 536 return false;
544 537
545 538 }
546 539
547 -function loginizer_is_whitelisted(){
548 -
549 - global $wpdb, $loginizer, $lz_error;
550 -
551 - $whitelist = $loginizer['whitelist'];
552 -
553 - if(empty($whitelist)){
554 - return false;
555 - }
556 -
557 - foreach($whitelist as $k => $v){
558 -
559 - // Is the IP in the blacklist ?
560 - if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip']) && inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
561 - $result = 1;
562 - break;
563 - }
564 -
565 - // Is it in a wider range ?
566 - if(inet_ptoi($v['start']) >= 0 && inet_ptoi($v['end']) < 0){
567 -
568 - // Since the end of the RANGE (i.e. current IP range) is beyond the +ve value of inet_ptoi,
569 - // if the current IP is <= than the start of the range, it is within the range
570 - // OR
571 - // if the current IP is <= than the end of the range, it is within the range
572 - if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip'])
573 - || inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){
574 - $result = 1;
575 - break;
576 - }
577 -
578 - }
579 -
580 - }
581 -
582 - // You are whitelisted
583 - if(!empty($result)){
584 - return true;
585 - }
586 -
587 - return false;
588 -
589 -}
590 -
591 540 // When the login fails, then this is called
592 541 // We need to update the database
593 542 function loginizer_login_failed($username, $is_2fa = ''){
594 543
@@ -688,8 +637,12 @@
688 637
689 638 }
690 639 }
691 640
641 +function loginizer_rsssl_2fa_success($user){
642 + loginizer_login_success('', $user);
643 +}
644 +
692 645 function loginizer_login_success($user_login, $user) {
693 646 global $wp_version, $loginizer;
694 647
695 648 loginizer_update_attempt_stats(1);
@@ -843,11 +796,22 @@
843 796 wc_add_notice( loginizer_retries_left(), 'error' );
844 797 }
845 798 }
846 799
800 +function loginizer_ultimatemember_error_handler(){
801 +
802 + if(class_exists('UM')){
803 + \UM()->form()->add_error('remaining_tries', loginizer_retries_left());
804 + }
805 +}
806 +
847 807 // Handles social login URL
848 808 function loginizer_social_login_error_handler($errors = '', $redirect_to = ''){
849 809 global $loginizer;
810 +
811 + if(loginizer_is_blacklisted()){
812 + return $errors;
813 + }
850 814
851 815 loginizer_get_social_error();
852 816
853 817 if(empty($loginizer['social_errors'])){
@@ -944,8 +908,12 @@
944 908 $loginizer['2fa_msg'][$lk] = $loginizer['2fa_d_msg'][$lk];
945 909 }
946 910 }
947 911
912 +}
913 +
914 +function loginizer_social_login_load(){
915 + include_once LOGINIZER_DIR . '/main/social-login.php';
948 916 }
949 917
950 918 // Checks if softaculous is installed on the server.
951 919 function loginizer_check_softaculous(){