@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function onKernelController(FilterControllerEvent $event) |
58 | 58 | { |
59 | - $this->rateLimit = (int) $this->container->getParameter('app.rate_limit_count'); |
|
60 | - $this->rateDuration = (int) $this->container->getParameter('app.rate_limit_time'); |
|
59 | + $this->rateLimit = (int)$this->container->getParameter('app.rate_limit_count'); |
|
60 | + $this->rateDuration = (int)$this->container->getParameter('app.rate_limit_time'); |
|
61 | 61 | |
62 | 62 | // Zero values indicate the rate limiting feature should be disabled. |
63 | 63 | if ($this->rateLimit === 0 || $this->rateDuration === 0) { |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | $controller = $event->getController(); |
68 | - $loggedIn = (bool) $this->container->get('session')->get('logged_in_user'); |
|
68 | + $loggedIn = (bool)$this->container->get('session')->get('logged_in_user'); |
|
69 | 69 | |
70 | 70 | // No rate limits on index pages or if they are logged in. |
71 | 71 | if ($controller[1] === 'indexAction' || $loggedIn) { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $cacheItem = $cache->getItem($cacheKey); |
86 | 86 | |
87 | 87 | // If increment value already in cache, or start with 1. |
88 | - $count = $cacheItem->isHit() ? (int) $cacheItem->get() + 1 : 1; |
|
88 | + $count = $cacheItem->isHit() ? (int)$cacheItem->get()+1 : 1; |
|
89 | 89 | |
90 | 90 | // Check if limit has been exceeded, and if so, throw an error. |
91 | 91 | if ($count > $this->rateLimit) { |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | // Log the denied request |
138 | 138 | $logger = $this->container->get('monolog.logger.rate_limit'); |
139 | 139 | $logger->info( |
140 | - "<URI>: " . $request->getRequestUri() . |
|
141 | - ($logComment != '' ? "\t<Reason>: $logComment" : '') . |
|
142 | - "\t<User agent>: " . $request->headers->get('User-Agent') |
|
140 | + "<URI>: ".$request->getRequestUri(). |
|
141 | + ($logComment != '' ? "\t<Reason>: $logComment" : ''). |
|
142 | + "\t<User agent>: ".$request->headers->get('User-Agent') |
|
143 | 143 | ); |
144 | 144 | |
145 | - throw new AccessDeniedHttpException("Possible spider crawl detected. " . |
|
146 | - 'If you are human, you are making too many requests during a short period of time. ' . |
|
147 | - "Please wait $this->rateDuration minutes before reloading this tool. You can then " . |
|
145 | + throw new AccessDeniedHttpException("Possible spider crawl detected. ". |
|
146 | + 'If you are human, you are making too many requests during a short period of time. '. |
|
147 | + "Please wait $this->rateDuration minutes before reloading this tool. You can then ". |
|
148 | 148 | 'login to prevent this from happening again.'); |
149 | 149 | } |
150 | 150 | } |