Example #1
0
 /**
  * Filter out LogEntries with the same host as the banned hosts from the event.
  *
  * @param LogEntriesEvent $event
  */
 public function onBanHost(LogEntriesEvent $event)
 {
     foreach ($event->getLogEntries() as $banned) {
         $this->logEntriesWithGetParameter = array_filter($this->logEntriesWithGetParameter, function (LogEntry $logEntry) use($banned) {
             return $logEntry->getHost() !== $banned->getHost();
         });
     }
 }
Example #2
0
 /**
  * Incoming log entries from the filter chain
  *
  * @param LogEntriesEvent $event
  */
 public function onProcess(LogEntriesEvent $event)
 {
     $endpointPattern = $this->getEndpointPattern();
     $event->setLogEntries(array_filter($event->getLogEntries(), function (LogEntry $logEntry) use($endpointPattern) {
         $matches = [];
         preg_match($endpointPattern, $logEntry->getRequest(), $matches);
         return count($matches) > 0;
     }));
 }
Example #3
0
 /**
  * Incoming log entries where we should block the host
  *
  * @param LogEntriesEvent $event
  */
 public function onBanHost(LogEntriesEvent $event)
 {
     foreach ($event->getLogEntries() as $banned) {
         $this->blockedLogEntries[] = $banned;
         $this->withheldLogEntries = array_filter($this->withheldLogEntries, function (LogEntry $logEntry) use($banned) {
             return $logEntry->getHost() !== $banned->getHost();
         });
     }
 }