/** * {@inheritdoc} */ public function checkVisitor(Visitor $visitor) { if ($this->blacklist->match($visitor->getIP())) { return CheckInterface::RESULT_BLOCK; } $uastring = $visitor->getUserAgent()->getUserAgentString(); if ($this->untrustedUserAgents->match($uastring)) { return CheckInterface::RESULT_BLOCK; } return CheckInterface::RESULT_OKAY; }
/** * {@inheritdoc} */ protected function setup() { $list = new StringList(); $list->beginsWith($this->getSpambotNamesBeginning()); $list->contains($this->getSpambotNamesAnywhere()); $list->matches($this->getSpambotNamesRegex()); $this->addCheck(new BlacklistCheck(null, $list)); $this->addCheck(new UrlCheck()); $this->addCheck(new AbsurditiesCheck($this->settings)); $this->addCheck(new UserAgentCheck()); // More intensive screening applies to POST requests $this->addCheck(new PostRequestCheck($this->settings)); }
/** * Checks if the visitor is whitelisted. * * @param \FlameCore\Gatekeeper\Visitor $visitor The visitor * @return bool */ protected function isWhitelisted(Visitor $visitor) { if ($this->whitelist->match($visitor->getIP())) { return true; } $uastring = $visitor->getUserAgent()->getUserAgentString(); if ($this->trustedUserAgents->match($uastring)) { return true; } return false; }