public function checkBan() { // Max tries of 0 before ban means no ban check at all if ($this->tries == 0) { return false; } // TTL of zero for log entries means not ban check too if ($this->ttl_banlog_entry == 0) { return false; } // Without TTL for bans no bancheck needed if ($this->ttl_ban == 0) { return false; } // Further checks do need a set IP address if (empty($this->ip)) { $this->ip = $_SERVER['REMOTE_ADDR']; } // No ban if count current tries lies below set max treis if ($this->countBanLogEntries() < $this->tries) { return false; } // Do we have an active ban with TTL? if ($this->getBanActiveTimestamp() + $this->ttl_ban > time()) { if (isset($this->logger)) { $this->logger->notice('Access of a banned IP [' . $this->ip . ']'); } return true; } // Falling through here means to ban the current ip $banlog = new BanLogEntry($this->db); $banlog->setText('User got banned because of too many tries.'); $banlog->setCode(0); if (isset($this->logger)) { $banlog->setLogger($this->logger); } $banlog->add(); return true; }