| @@ -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.8'); | |
| 8 | +define('LOGINIZER_VERSION', '2.0.2'); | |
| 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'); |
| @@ -332,10 +332,9 @@ | ||
| 332 | 332 | // Is called before displaying the error message so that we dont show that the username is wrong or the password |
| 333 | 333 | // Update Error message |
| 334 | 334 | add_action('wp_login_errors', 'loginizer_error_handler', 10001, 2); |
| 335 | 335 | add_action('woocommerce_login_failed', 'loginizer_woocommerce_error_handler', 10001); |
| 336 | - add_action('wp_login', 'loginizer_login_success', 11, 2); | |
| 337 | - add_action('rsssl_two_factor_user_authenticated', 'loginizer_rsssl_2fa_success'); | |
| 336 | + add_action('wp_login', 'loginizer_login_success', 10, 2); | |
| 338 | 337 | |
| 339 | 338 | if(!empty($loginizer['ultimate-member-active'])){ |
| 340 | 339 | add_action('wp_login_failed', 'loginizer_ultimatemember_error_handler', 10001); |
| 341 | 340 | } |
| @@ -495,31 +494,26 @@ | ||
| 495 | 494 | |
| 496 | 495 | if(empty($blacklist)){ |
| 497 | 496 | return false; |
| 498 | 497 | } |
| 499 | - | |
| 500 | - $current_ip_inet = inet_ptoi($loginizer['current_ip']); | |
| 501 | - | |
| 498 | + | |
| 502 | 499 | foreach($blacklist as $k => $v){ |
| 503 | - | |
| 504 | - $start_inet = inet_ptoi($v['start']); | |
| 505 | - $end_inet = inet_ptoi($v['end']); | |
| 506 | - | |
| 500 | + | |
| 507 | 501 | // Is the IP in the blacklist ? |
| 508 | - if($start_inet <= $current_ip_inet && $current_ip_inet <= $end_inet){ | |
| 502 | + if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip']) && inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){ | |
| 509 | 503 | $result = 1; |
| 510 | 504 | break; |
| 511 | 505 | } |
| 512 | - | |
| 506 | + | |
| 513 | 507 | // Is it in a wider range ? |
| 514 | - if($start_inet >= 0 && $end_inet < 0){ | |
| 508 | + if(inet_ptoi($v['start']) >= 0 && inet_ptoi($v['end']) < 0){ | |
| 515 | 509 | |
| 516 | 510 | // Since the end of the RANGE (i.e. current IP range) is beyond the +ve value of inet_ptoi, |
| 517 | 511 | // if the current IP is <= than the start of the range, it is within the range |
| 518 | 512 | // OR |
| 519 | 513 | // if the current IP is <= than the end of the range, it is within the range |
| 520 | - if($start_inet <= $current_ip_inet | |
| 521 | - || $current_ip_inet <= $end_inet){ | |
| 514 | + if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip']) | |
| 515 | + || inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){ | |
| 522 | 516 | $result = 1; |
| 523 | 517 | break; |
| 524 | 518 | } |
| 525 | 519 | |
| @@ -525,9 +519,9 @@ | ||
| 525 | 519 | |
| 526 | 520 | } |
| 527 | 521 | |
| 528 | 522 | } |
| 529 | - | |
| 523 | + | |
| 530 | 524 | // You are blacklisted |
| 531 | 525 | if(!empty($result)){ |
| 532 | 526 | $lz_error['ip_blacklisted'] = $loginizer['msg']['ip_blacklisted']; |
| 533 | 527 | return true; |
| @@ -536,8 +530,52 @@ | ||
| 536 | 530 | return false; |
| 537 | 531 | |
| 538 | 532 | } |
| 539 | 533 | |
| 534 | +function loginizer_is_whitelisted(){ | |
| 535 | + | |
| 536 | + global $wpdb, $loginizer, $lz_error; | |
| 537 | + | |
| 538 | + $whitelist = $loginizer['whitelist']; | |
| 539 | + | |
| 540 | + if(empty($whitelist)){ | |
| 541 | + return false; | |
| 542 | + } | |
| 543 | + | |
| 544 | + foreach($whitelist as $k => $v){ | |
| 545 | + | |
| 546 | + // Is the IP in the blacklist ? | |
| 547 | + if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip']) && inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){ | |
| 548 | + $result = 1; | |
| 549 | + break; | |
| 550 | + } | |
| 551 | + | |
| 552 | + // Is it in a wider range ? | |
| 553 | + if(inet_ptoi($v['start']) >= 0 && inet_ptoi($v['end']) < 0){ | |
| 554 | + | |
| 555 | + // Since the end of the RANGE (i.e. current IP range) is beyond the +ve value of inet_ptoi, | |
| 556 | + // if the current IP is <= than the start of the range, it is within the range | |
| 557 | + // OR | |
| 558 | + // if the current IP is <= than the end of the range, it is within the range | |
| 559 | + if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip']) | |
| 560 | + || inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){ | |
| 561 | + $result = 1; | |
| 562 | + break; | |
| 563 | + } | |
| 564 | + | |
| 565 | + } | |
| 566 | + | |
| 567 | + } | |
| 568 | + | |
| 569 | + // You are whitelisted | |
| 570 | + if(!empty($result)){ | |
| 571 | + return true; | |
| 572 | + } | |
| 573 | + | |
| 574 | + return false; | |
| 575 | + | |
| 576 | +} | |
| 577 | + | |
| 540 | 578 | // When the login fails, then this is called |
| 541 | 579 | // We need to update the database |
| 542 | 580 | function loginizer_login_failed($username, $is_2fa = ''){ |
| 543 | 581 | |
| @@ -635,12 +673,8 @@ | ||
| 635 | 673 | $loginizer['retries_left'] = ($loginizer['max_retries'] - ($result['count'] % $loginizer['max_retries'])); |
| 636 | 674 | $loginizer['retries_left'] = $loginizer['retries_left'] == $loginizer['max_retries'] ? 0 : $loginizer['retries_left']; |
| 637 | 675 | |
| 638 | 676 | } |
| 639 | -} | |
| 640 | - | |
| 641 | -function loginizer_rsssl_2fa_success($user){ | |
| 642 | - loginizer_login_success('', $user); | |
| 643 | 677 | } |
| 644 | 678 | |
| 645 | 679 | function loginizer_login_success($user_login, $user) { |
| 646 | 680 | global $wp_version, $loginizer; |