@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | private function getCutoff($expire) { |
83 | 83 | $d1 = new \DateTime(); |
84 | 84 | $d2 = clone $d1; |
85 | - $d2->sub(new \DateInterval('PT' . $expire . 'S')); |
|
85 | + $d2->sub(new \DateInterval('PT'.$expire.'S')); |
|
86 | 86 | return $d2->diff($d1); |
87 | 87 | } |
88 | 88 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $ip, |
99 | 99 | array $metadata = []) { |
100 | 100 | // No need to log if the bruteforce protection is disabled |
101 | - if($this->config->getSystemValue('auth.bruteforce.protection.enabled', true) === false) { |
|
101 | + if ($this->config->getSystemValue('auth.bruteforce.protection.enabled', true) === false) { |
|
102 | 102 | return; |
103 | 103 | } |
104 | 104 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $values = [ |
107 | 107 | 'action' => $action, |
108 | 108 | 'occurred' => $this->timeFactory->getTime(), |
109 | - 'ip' => (string)$ipAddress, |
|
109 | + 'ip' => (string) $ipAddress, |
|
110 | 110 | 'subnet' => $ipAddress->getSubnet(), |
111 | 111 | 'metadata' => json_encode($metadata), |
112 | 112 | ]; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $qb = $this->db->getQueryBuilder(); |
126 | 126 | $qb->insert('bruteforce_attempts'); |
127 | - foreach($values as $column => $value) { |
|
127 | + foreach ($values as $column => $value) { |
|
128 | 128 | $qb->setValue($column, $qb->createNamedParameter($value)); |
129 | 129 | } |
130 | 130 | $qb->execute(); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @return bool |
138 | 138 | */ |
139 | 139 | private function isIPWhitelisted($ip) { |
140 | - if($this->config->getSystemValue('auth.bruteforce.protection.enabled', true) === false) { |
|
140 | + if ($this->config->getSystemValue('auth.bruteforce.protection.enabled', true) === false) { |
|
141 | 141 | return true; |
142 | 142 | } |
143 | 143 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | |
163 | 163 | $cx = explode('/', $cidr); |
164 | 164 | $addr = $cx[0]; |
165 | - $mask = (int)$cx[1]; |
|
165 | + $mask = (int) $cx[1]; |
|
166 | 166 | |
167 | 167 | // Do not compare ipv4 to ipv6 |
168 | 168 | if (($type === 4 && !filter_var($addr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) || |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | $addr = inet_pton($addr); |
174 | 174 | |
175 | 175 | $valid = true; |
176 | - for($i = 0; $i < $mask; $i++) { |
|
177 | - $part = ord($addr[(int)($i/8)]); |
|
178 | - $orig = ord($ip[(int)($i/8)]); |
|
176 | + for ($i = 0; $i < $mask; $i++) { |
|
177 | + $part = ord($addr[(int) ($i / 8)]); |
|
178 | + $orig = ord($ip[(int) ($i / 8)]); |
|
179 | 179 | |
180 | 180 | $bitmask = 1 << (7 - ($i % 8)); |
181 | 181 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function getDelay($ip, $action = '') { |
208 | 208 | $ipAddress = new IpAddress($ip); |
209 | - if ($this->isIPWhitelisted((string)$ipAddress)) { |
|
209 | + if ($this->isIPWhitelisted((string) $ipAddress)) { |
|
210 | 210 | return 0; |
211 | 211 | } |
212 | 212 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | |
233 | 233 | $maxDelay = 25; |
234 | 234 | $firstDelay = 0.1; |
235 | - if ($attempts > (8 * PHP_INT_SIZE - 1)) { |
|
235 | + if ($attempts > (8 * PHP_INT_SIZE - 1)) { |
|
236 | 236 | // Don't ever overflow. Just assume the maxDelay time:s |
237 | 237 | $firstDelay = $maxDelay; |
238 | 238 | } else { |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | */ |
254 | 254 | public function resetDelay($ip, $action, $metadata) { |
255 | 255 | $ipAddress = new IpAddress($ip); |
256 | - if ($this->isIPWhitelisted((string)$ipAddress)) { |
|
256 | + if ($this->isIPWhitelisted((string) $ipAddress)) { |
|
257 | 257 | return; |
258 | 258 | } |
259 | 259 |