| @@ -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.7'); | |
| 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 |
| @@ -306,8 +333,12 @@ | ||
| 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 | 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 | + } | |
| 310 | 341 | |
| 311 | 342 | if(!empty($_COOKIE['lz_social_error']) && !empty($loginizer['social_settings']) && !loginizer_is_blacklisted()){ |
| 312 | 343 | add_filter('wp_login_errors', 'loginizer_social_login_error_handler', 10000, 2); |
| 313 | 344 | } |
| @@ -326,63 +357,16 @@ | ||
| 326 | 357 | |
| 327 | 358 | if(is_admin()){ |
| 328 | 359 | include_once LOGINIZER_DIR . '/main/admin.php'; |
| 329 | 360 | } |
| 330 | - | |
| 361 | + | |
| 331 | 362 | // ---------------- |
| 332 | 363 | // PRO INIT END |
| 333 | 364 | // ---------------- |
| 334 | 365 | |
| 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 | 366 | // Secuity checks for social login. |
| 383 | - if(!empty($_GET['lz_social_provider']) && loginizer_can_login()){ | |
| 384 | - include_once LOGINIZER_DIR . '/main/social-login.php'; | |
| 367 | + if(!empty($_GET['lz_social_provider']) && loginizer_can_login() && empty($_GET['lz_api'])){ | |
| 368 | + add_action('init', 'loginizer_social_login_load'); | |
| 385 | 369 | return; |
| 386 | 370 | } |
| 387 | 371 | } |
| 388 | 372 | |
| @@ -491,8 +475,11 @@ | ||
| 491 | 475 | } |
| 492 | 476 | |
| 493 | 477 | $lz_error['ip_blocked'] = $loginizer['msg']['lockout_err'].' '.$_time; |
| 494 | 478 | |
| 479 | + if(!empty($loginizer['ultimate-member-active']) && class_exists('UM')){ | |
| 480 | + \UM()->form()->add_error('blocked_msg', $lz_error['ip_blocked']); | |
| 481 | + } | |
| 495 | 482 | return false; |
| 496 | 483 | } |
| 497 | 484 | } |
| 498 | 485 | |
| @@ -507,26 +494,31 @@ | ||
| 507 | 494 | |
| 508 | 495 | if(empty($blacklist)){ |
| 509 | 496 | return false; |
| 510 | 497 | } |
| 511 | - | |
| 498 | + | |
| 499 | + $current_ip_inet = inet_ptoi($loginizer['current_ip']); | |
| 500 | + | |
| 512 | 501 | foreach($blacklist as $k => $v){ |
| 513 | - | |
| 502 | + | |
| 503 | + $start_inet = inet_ptoi($v['start']); | |
| 504 | + $end_inet = inet_ptoi($v['end']); | |
| 505 | + | |
| 514 | 506 | // 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'])){ | |
| 507 | + if($start_inet <= $current_ip_inet && $current_ip_inet <= $end_inet){ | |
| 516 | 508 | $result = 1; |
| 517 | 509 | break; |
| 518 | 510 | } |
| 519 | - | |
| 511 | + | |
| 520 | 512 | // Is it in a wider range ? |
| 521 | - if(inet_ptoi($v['start']) >= 0 && inet_ptoi($v['end']) < 0){ | |
| 513 | + if($start_inet >= 0 && $end_inet < 0){ | |
| 522 | 514 | |
| 523 | 515 | // Since the end of the RANGE (i.e. current IP range) is beyond the +ve value of inet_ptoi, |
| 524 | 516 | // if the current IP is <= than the start of the range, it is within the range |
| 525 | 517 | // OR |
| 526 | 518 | // 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'])){ | |
| 519 | + if($start_inet <= $current_ip_inet | |
| 520 | + || $current_ip_inet <= $end_inet){ | |
| 529 | 521 | $result = 1; |
| 530 | 522 | break; |
| 531 | 523 | } |
| 532 | 524 | |
| @@ -532,9 +524,9 @@ | ||
| 532 | 524 | |
| 533 | 525 | } |
| 534 | 526 | |
| 535 | 527 | } |
| 536 | - | |
| 528 | + | |
| 537 | 529 | // You are blacklisted |
| 538 | 530 | if(!empty($result)){ |
| 539 | 531 | $lz_error['ip_blacklisted'] = $loginizer['msg']['ip_blacklisted']; |
| 540 | 532 | return true; |
| @@ -543,52 +535,8 @@ | ||
| 543 | 535 | return false; |
| 544 | 536 | |
| 545 | 537 | } |
| 546 | 538 | |
| 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 | 539 | // When the login fails, then this is called |
| 592 | 540 | // We need to update the database |
| 593 | 541 | function loginizer_login_failed($username, $is_2fa = ''){ |
| 594 | 542 | |
| @@ -843,8 +791,15 @@ | ||
| 843 | 791 | wc_add_notice( loginizer_retries_left(), 'error' ); |
| 844 | 792 | } |
| 845 | 793 | } |
| 846 | 794 | |
| 795 | +function loginizer_ultimatemember_error_handler(){ | |
| 796 | + | |
| 797 | + if(class_exists('UM')){ | |
| 798 | + \UM()->form()->add_error('remaining_tries', loginizer_retries_left()); | |
| 799 | + } | |
| 800 | +} | |
| 801 | + | |
| 847 | 802 | // Handles social login URL |
| 848 | 803 | function loginizer_social_login_error_handler($errors = '', $redirect_to = ''){ |
| 849 | 804 | global $loginizer; |
| 850 | 805 | |
| @@ -944,8 +899,12 @@ | ||
| 944 | 899 | $loginizer['2fa_msg'][$lk] = $loginizer['2fa_d_msg'][$lk]; |
| 945 | 900 | } |
| 946 | 901 | } |
| 947 | 902 | |
| 903 | +} | |
| 904 | + | |
| 905 | +function loginizer_social_login_load(){ | |
| 906 | + include_once LOGINIZER_DIR . '/main/social-login.php'; | |
| 948 | 907 | } |
| 949 | 908 | |
| 950 | 909 | // Checks if softaculous is installed on the server. |
| 951 | 910 | function loginizer_check_softaculous(){ |