| @@ -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.2'); | |
| 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'); |
| @@ -494,26 +494,31 @@ | ||
| 494 | 494 | |
| 495 | 495 | if(empty($blacklist)){ |
| 496 | 496 | return false; |
| 497 | 497 | } |
| 498 | - | |
| 498 | + | |
| 499 | + $current_ip_inet = inet_ptoi($loginizer['current_ip']); | |
| 500 | + | |
| 499 | 501 | foreach($blacklist as $k => $v){ |
| 500 | - | |
| 502 | + | |
| 503 | + $start_inet = inet_ptoi($v['start']); | |
| 504 | + $end_inet = inet_ptoi($v['end']); | |
| 505 | + | |
| 501 | 506 | // Is the IP in the blacklist ? |
| 502 | - 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){ | |
| 503 | 508 | $result = 1; |
| 504 | 509 | break; |
| 505 | 510 | } |
| 506 | - | |
| 511 | + | |
| 507 | 512 | // Is it in a wider range ? |
| 508 | - if(inet_ptoi($v['start']) >= 0 && inet_ptoi($v['end']) < 0){ | |
| 513 | + if($start_inet >= 0 && $end_inet < 0){ | |
| 509 | 514 | |
| 510 | 515 | // Since the end of the RANGE (i.e. current IP range) is beyond the +ve value of inet_ptoi, |
| 511 | 516 | // if the current IP is <= than the start of the range, it is within the range |
| 512 | 517 | // OR |
| 513 | 518 | // if the current IP is <= than the end of the range, it is within the range |
| 514 | - if(inet_ptoi($v['start']) <= inet_ptoi($loginizer['current_ip']) | |
| 515 | - || inet_ptoi($loginizer['current_ip']) <= inet_ptoi($v['end'])){ | |
| 519 | + if($start_inet <= $current_ip_inet | |
| 520 | + || $current_ip_inet <= $end_inet){ | |
| 516 | 521 | $result = 1; |
| 517 | 522 | break; |
| 518 | 523 | } |
| 519 | 524 | |
| @@ -519,56 +524,12 @@ | ||
| 519 | 524 | |
| 520 | 525 | } |
| 521 | 526 | |
| 522 | 527 | } |
| 523 | - | |
| 528 | + | |
| 524 | 529 | // You are blacklisted |
| 525 | 530 | if(!empty($result)){ |
| 526 | 531 | $lz_error['ip_blacklisted'] = $loginizer['msg']['ip_blacklisted']; |
| 527 | - return true; | |
| 528 | - } | |
| 529 | - | |
| 530 | - return false; | |
| 531 | - | |
| 532 | -} | |
| 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 | 532 | return true; |
| 572 | 533 | } |
| 573 | 534 | |
| 574 | 535 | return false; |