Esempio n. 1
0
 private function validateIP($ip)
 {
     $val = new ipValidator();
     if (!$val->validate($ip)) {
         return false;
     }
     return true;
 }
Esempio n. 2
0
 private function mightBeIP($inValue)
 {
     $validator = new ipValidator();
     $parsed = parse_url($inValue);
     return $validator->validate($parsed['host']);
 }
Esempio n. 3
0
 public function isLockedOut($ipAddress)
 {
     $val = new ipValidator();
     //Lock the client out if the clients IP isn't valid
     if (!$val->validate($ipAddress)) {
         return true;
     }
     $lockout = $this->getLockout($ipAddress);
     if ($lockout === false) {
         return false;
     }
     if ($lockout->getNumberOfAttemptsLeft() > 0) {
         return false;
     }
     $lockoutPeriod = $this->getLockoutPeriod();
     $totalLockoutLength = $lockout->getNumberOfFailedAttempts() * $lockoutPeriod;
     $lastUpdate = clone $lockout->lastUpdated();
     $lockedOutUntil = $lastUpdate->add(DateInterval::createFromDateString($totalLockoutLength . ' minutes'));
     $currentTime = new DateTime();
     if ($currentTime >= $lockedOutUntil) {
         $lockout->reEnable($this->getNumberOfAttemptsBeforeLockout());
         $this->setLockout($lockout);
         return false;
     }
     return true;
 }