@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | */ |
77 | 77 | protected function doInitialize(bool $dbCheck = true): void |
78 | 78 | { |
79 | - if (! $this->isInitialized) { |
|
80 | - if (! empty($this->channel)) { |
|
79 | + if (!$this->isInitialized) { |
|
80 | + if (!empty($this->channel)) { |
|
81 | 81 | $this->setChannel($this->channel); |
82 | 82 | } |
83 | 83 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS); |
108 | 108 | $files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST); |
109 | 109 | |
110 | - foreach($files as $file) { |
|
110 | + foreach ($files as $file) { |
|
111 | 111 | if ($file->isFile()) { |
112 | 112 | |
113 | 113 | $content = json_decode(file_get_contents($file->getPath() . '/' . $file->getFilename()), true); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | { |
140 | 140 | $results = []; |
141 | 141 | |
142 | - if (! file_exists($this->getFilename($ip, $type))) { |
|
142 | + if (!file_exists($this->getFilename($ip, $type))) { |
|
143 | 143 | return $results; |
144 | 144 | } |
145 | 145 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $fileContent = file_get_contents($this->getFilename($ip, $type)); |
160 | 160 | $resultData = json_decode($fileContent, true); |
161 | 161 | |
162 | - if (! empty($resultData['log_data'])) { |
|
162 | + if (!empty($resultData['log_data'])) { |
|
163 | 163 | $results = $resultData['log_data']; |
164 | 164 | } |
165 | 165 | break; |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS); |
244 | 244 | $files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST); |
245 | 245 | |
246 | - foreach($files as $file) { |
|
246 | + foreach ($files as $file) { |
|
247 | 247 | if ($file->isDir()) { |
248 | 248 | // @codeCoverageIgnoreStart |
249 | 249 | rmdir($file->getRealPath()); |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | |
269 | 269 | // Check if are Shieldon directories removed or not. |
270 | 270 | $result = ( |
271 | - ! is_dir($this->getDirectory('filter_log')) && |
|
272 | - ! is_dir($this->getDirectory('rule')) && |
|
273 | - ! is_dir($this->getDirectory('session')) |
|
271 | + !is_dir($this->getDirectory('filter_log')) && |
|
272 | + !is_dir($this->getDirectory('rule')) && |
|
273 | + !is_dir($this->getDirectory('session')) |
|
274 | 274 | ); |
275 | 275 | |
276 | 276 | $this->createDirectory(); |
@@ -289,18 +289,18 @@ discard block |
||
289 | 289 | |
290 | 290 | $checkingFile = $this->directory . '/' . $this->channel . '_' . $this->checkPoint; |
291 | 291 | |
292 | - if (! file_exists($checkingFile)) { |
|
292 | + if (!file_exists($checkingFile)) { |
|
293 | 293 | $originalUmask = umask(0); |
294 | 294 | |
295 | - if (! is_dir($this->getDirectory('filter_log'))) { |
|
295 | + if (!is_dir($this->getDirectory('filter_log'))) { |
|
296 | 296 | $resultA = @mkdir($this->getDirectory('filter_log'), 0777, true); |
297 | 297 | } |
298 | 298 | |
299 | - if (! is_dir($this->getDirectory('rule'))) { |
|
299 | + if (!is_dir($this->getDirectory('rule'))) { |
|
300 | 300 | $resultB = @mkdir($this->getDirectory('rule'), 0777, true); |
301 | 301 | } |
302 | 302 | |
303 | - if (! is_dir($this->getDirectory('session'))) { |
|
303 | + if (!is_dir($this->getDirectory('session'))) { |
|
304 | 304 | $resultC = @mkdir($this->getDirectory('session'), 0777, true); |
305 | 305 | } |
306 | 306 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | */ |
325 | 325 | protected function checkDirectory(): bool |
326 | 326 | { |
327 | - if (! is_dir($this->directory) || ! is_writable($this->directory)) { |
|
327 | + if (!is_dir($this->directory) || !is_writable($this->directory)) { |
|
328 | 328 | throw new RuntimeException('The directory defined by File Driver must be writable. (' . $this->directory . ')'); |
329 | 329 | } |
330 | 330 | |
@@ -358,8 +358,8 @@ discard block |
||
358 | 358 | |
359 | 359 | switch ($type) { |
360 | 360 | case 'filter_log' : return $this->directory . '/' . $this->tableFilterLogs . '/' . $ip . '.' . $this->extension; |
361 | - case 'session' : return $this->directory . '/' . $this->tableSessions . '/' . $ip . '.' . $this->extension; |
|
362 | - case 'rule' : return $this->directory . '/' . $this->tableRuleList . '/' . $ip . '.' . $this->extension; |
|
361 | + case 'session' : return $this->directory . '/' . $this->tableSessions . '/' . $ip . '.' . $this->extension; |
|
362 | + case 'rule' : return $this->directory . '/' . $this->tableRuleList . '/' . $ip . '.' . $this->extension; |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | return ''; |
@@ -61,7 +61,7 @@ |
||
61 | 61 | { |
62 | 62 | $this->channel = $channel; |
63 | 63 | |
64 | - if (! empty($this->channel)) { |
|
64 | + if (!empty($this->channel)) { |
|
65 | 65 | $this->tableFilterLogs = $this->channel . '_shieldon_filter_logs'; |
66 | 66 | $this->tableRuleList = $this->channel . '_shieldon_rule_list'; |
67 | 67 | $this->tableSessions = $this->channel . '_shieldon_sessions'; |
@@ -146,7 +146,7 @@ |
||
146 | 146 | return $results; |
147 | 147 | } |
148 | 148 | |
149 | - /** |
|
149 | + /** |
|
150 | 150 | * {@inheritDoc} |
151 | 151 | */ |
152 | 152 | protected function doFetchAll(string $type = 'filter_log'): array |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | */ |
61 | 61 | protected function doInitialize(bool $dbCheck = true): void |
62 | 62 | { |
63 | - if (! $this->isInitialized) { |
|
64 | - if (! empty($this->channel)) { |
|
63 | + if (!$this->isInitialized) { |
|
64 | + if (!empty($this->channel)) { |
|
65 | 65 | $this->setChannel($this->channel); |
66 | 66 | } |
67 | 67 | |
68 | - if ($dbCheck && ! $this->checkTableExists()) { |
|
68 | + if ($dbCheck && !$this->checkTableExists()) { |
|
69 | 69 | $this->installSql(); |
70 | 70 | } |
71 | 71 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $resultData = $query->fetch($this->db::FETCH_ASSOC); |
94 | 94 | |
95 | 95 | // No data found. |
96 | - if (is_bool($resultData) && ! $resultData) { |
|
96 | + if (is_bool($resultData) && !$resultData) { |
|
97 | 97 | $resultData = []; |
98 | 98 | } |
99 | 99 | |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | $resultData = $query->fetch($this->db::FETCH_ASSOC); |
114 | 114 | |
115 | 115 | // No data found. |
116 | - if (is_bool($resultData) && ! $resultData) { |
|
116 | + if (is_bool($resultData) && !$resultData) { |
|
117 | 117 | $resultData = []; |
118 | 118 | } |
119 | 119 | |
120 | - if (! empty($resultData['log_data'])) { |
|
120 | + if (!empty($resultData['log_data'])) { |
|
121 | 121 | $results = json_decode($resultData['log_data'], true); |
122 | 122 | } |
123 | 123 | break; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $resultData = $query->fetch($this->db::FETCH_ASSOC); |
134 | 134 | |
135 | 135 | // No data found. |
136 | - if (is_bool($resultData) && ! $resultData) { |
|
136 | + if (is_bool($resultData) && !$resultData) { |
|
137 | 137 | $resultData = []; |
138 | 138 | } |
139 | 139 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | $query->execute(); |
229 | 229 | $result = $query->fetch(); |
230 | 230 | |
231 | - if (! empty($result[$field])) { |
|
231 | + if (!empty($result[$field])) { |
|
232 | 232 | return true; |
233 | 233 | } |
234 | 234 | |
@@ -277,9 +277,9 @@ discard block |
||
277 | 277 | protected function doDelete(string $ip, string $type = 'filter_log'): bool |
278 | 278 | { |
279 | 279 | switch ($type) { |
280 | - case 'rule' : return $this->remove($this->tableRuleList, ['log_ip' => $ip]); |
|
280 | + case 'rule' : return $this->remove($this->tableRuleList, ['log_ip' => $ip]); |
|
281 | 281 | case 'filter_log': return $this->remove($this->tableFilterLogs, ['log_ip' => $ip]); |
282 | - case 'session' : return $this->remove($this->tableSessions, ['id' => $ip]); |
|
282 | + case 'session' : return $this->remove($this->tableSessions, ['id' => $ip]); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | return false; |
@@ -305,14 +305,14 @@ discard block |
||
305 | 305 | private function update(string $table, array $data, array $where) |
306 | 306 | { |
307 | 307 | $placeholder = []; |
308 | - foreach($data as $k => $v) { |
|
308 | + foreach ($data as $k => $v) { |
|
309 | 309 | $placeholder[] = "$k = :$k"; |
310 | 310 | } |
311 | 311 | |
312 | 312 | $dataPlaceholder = implode(', ', $placeholder); |
313 | 313 | |
314 | 314 | $placeholder = []; |
315 | - foreach($where as $k => $v) { |
|
315 | + foreach ($where as $k => $v) { |
|
316 | 316 | $placeholder[] = "$k = :$k"; |
317 | 317 | } |
318 | 318 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | |
325 | 325 | $bind = array_merge($data, $where); |
326 | 326 | |
327 | - foreach($bind as $k => $v) { |
|
327 | + foreach ($bind as $k => $v) { |
|
328 | 328 | |
329 | 329 | // @codeCoverageIgnoreStart |
330 | 330 | |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | |
353 | 353 | // @codeCoverageIgnoreStart |
354 | 354 | |
355 | - } catch(Exception $e) { |
|
355 | + } catch (Exception $e) { |
|
356 | 356 | throw $e->getMessage(); |
357 | 357 | return false; |
358 | 358 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | { |
373 | 373 | $placeholderField = []; |
374 | 374 | $placeholderValue = []; |
375 | - foreach($data as $k => $v) { |
|
375 | + foreach ($data as $k => $v) { |
|
376 | 376 | $placeholderField[] = "`$k`"; |
377 | 377 | $placeholderValue[] = ":$k"; |
378 | 378 | } |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | $sql = 'INSERT INTO ' . $table . ' (' . $dataPlaceholderField . ') VALUES (' . $dataPlaceholderValue . ')'; |
385 | 385 | $query = $this->db->prepare($sql); |
386 | 386 | |
387 | - foreach($data as $k => $v) { |
|
387 | + foreach ($data as $k => $v) { |
|
388 | 388 | |
389 | 389 | // @codeCoverageIgnoreStart |
390 | 390 | |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | |
413 | 413 | // @codeCoverageIgnoreStart |
414 | 414 | |
415 | - } catch(Exception $e) { |
|
415 | + } catch (Exception $e) { |
|
416 | 416 | return false; |
417 | 417 | } |
418 | 418 | |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | { |
432 | 432 | |
433 | 433 | $placeholder = []; |
434 | - foreach($where as $k => $v) { |
|
434 | + foreach ($where as $k => $v) { |
|
435 | 435 | $placeholder[] = "`$k` = :$k"; |
436 | 436 | } |
437 | 437 | |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | $sql = 'DELETE FROM ' . $table . ' WHERE ' . $dataPlaceholder; |
443 | 443 | $query = $this->db->prepare($sql); |
444 | 444 | |
445 | - foreach($where as $k => $v) { |
|
445 | + foreach ($where as $k => $v) { |
|
446 | 446 | |
447 | 447 | // @codeCoverageIgnoreStart |
448 | 448 | |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | |
466 | 466 | // @codeCoverageIgnoreStart |
467 | 467 | |
468 | - } catch(Exception $e) { |
|
468 | + } catch (Exception $e) { |
|
469 | 469 | return false; |
470 | 470 | } |
471 | 471 |
@@ -27,11 +27,11 @@ |
||
27 | 27 | parent::__construct($pdo, $debug); |
28 | 28 | } |
29 | 29 | |
30 | - /** |
|
31 | - * Create SQL tables that Shieldon needs. |
|
32 | - * |
|
33 | - * @return bool |
|
34 | - */ |
|
30 | + /** |
|
31 | + * Create SQL tables that Shieldon needs. |
|
32 | + * |
|
33 | + * @return bool |
|
34 | + */ |
|
35 | 35 | protected function installSql(): bool |
36 | 36 | { |
37 | 37 | try { |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function setIp(string $ip = '', $queryRdns = false): void |
47 | 47 | { |
48 | - if (! empty($ip)) { |
|
48 | + if (!empty($ip)) { |
|
49 | 49 | $_SERVER['REMOTE_ADDR'] = $ip; |
50 | 50 | } |
51 | 51 | |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | |
56 | 56 | // Check if your IP is from localhost, perhaps your are in development environment? |
57 | 57 | if ( |
58 | - (substr($this->ip, 0 , 8) === '192.168.') || |
|
59 | - (substr($this->ip, 0 , 6) === '127.0.') |
|
58 | + (substr($this->ip, 0, 8) === '192.168.') || |
|
59 | + (substr($this->ip, 0, 6) === '127.0.') |
|
60 | 60 | ) { |
61 | 61 | $this->setRdns('localhost'); |
62 | 62 | } else { |
@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | - if (! is_array($this->properties['colors'])) { |
|
92 | + if (!is_array($this->properties['colors'])) { |
|
93 | 93 | $this->properties['colors'] = $defaults['colors']; |
94 | 94 | } |
95 | 95 | |
96 | 96 | foreach ($defaults['colors'] as $k => $v) { |
97 | - if (! is_array($this->properties['colors'][$k])) { |
|
97 | + if (!is_array($this->properties['colors'][$k])) { |
|
98 | 98 | $this->properties['colors'][$k] = $defaults['colors'][$k]; |
99 | 99 | } |
100 | 100 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | public function form(): string |
132 | 132 | { |
133 | 133 | // @codeCoverageIgnoreStart |
134 | - if (! extension_loaded('gd')) { |
|
134 | + if (!extension_loaded('gd')) { |
|
135 | 135 | return ''; |
136 | 136 | } |
137 | 137 | // @codeCoverageIgnoreEnd |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $html = ''; |
140 | 140 | $base64image = $this->createCaptcha(); |
141 | 141 | |
142 | - if (! empty($base64image)) { |
|
142 | + if (!empty($base64image)) { |
|
143 | 143 | $html = '<div style="padding: 0px; overflow: hidden; margin: 10px 0;">'; |
144 | 144 | $html .= '<div style=" |
145 | 145 | border: 1px #dddddd solid; |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | imagefilledrectangle($im, 0, 0, $this->properties['img_width'], $this->properties['img_height'], $colors['background']); |
209 | 209 | |
210 | 210 | // Create the spiral pattern. |
211 | - $theta = 1; |
|
211 | + $theta = 1; |
|
212 | 212 | $thetac = 7; |
213 | 213 | $radius = 16; |
214 | 214 | $circles = 20; |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | $y = 0; |
238 | 238 | |
239 | 239 | for ($i = 0; $i < $length; $i++) { |
240 | - $y = mt_rand(0 , $this->properties['img_height'] / 2); |
|
240 | + $y = mt_rand(0, $this->properties['img_height'] / 2); |
|
241 | 241 | imagestring($im, 5, $x, $y, $this->word[$i], $colors['text']); |
242 | 242 | $x += ($this->properties['font_spacing'] * 2); |
243 | 243 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | imagerectangle($im, 0, 0, $this->properties['img_width'] - 1, $this->properties['img_height'] - 1, $colors['border']); |
247 | 247 | |
248 | 248 | // Generate image in base64 string. |
249 | - ob_start (); |
|
249 | + ob_start(); |
|
250 | 250 | |
251 | 251 | if (function_exists('imagejpeg')) { |
252 | 252 | $this->imageType = 'jpeg'; |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | - // @codeCoverageIgnoreStart |
|
195 | + // @codeCoverageIgnoreStart |
|
196 | 196 | |
197 | 197 | /** |
198 | 198 | * Display pages. |
@@ -1308,7 +1308,7 @@ discard block |
||
1308 | 1308 | $iptablesQueueFile = $iptablesWatchingFolder . '/iptables_queue.log'; |
1309 | 1309 | |
1310 | 1310 | if ( |
1311 | - (isset($_POST['ip']) && (filter_var(explode('/', $_POST['ip'])[0], FILTER_VALIDATE_IP))) |
|
1311 | + (isset($_POST['ip']) && (filter_var(explode('/', $_POST['ip'])[0], FILTER_VALIDATE_IP))) |
|
1312 | 1312 | && (isset($_POST['port']) && (is_numeric($_POST['port']) || ($_POST['port'] === 'all') || ($_POST['port'] === 'custom'))) |
1313 | 1313 | && (isset($_POST['subnet']) && (is_numeric($_POST['subnet']) || ($_POST['subnet'] === 'null'))) |
1314 | 1314 | && (isset($_POST['protocol']) && (in_array($_POST['protocol'], ['tcp', 'udp', 'all']))) |
@@ -2252,7 +2252,7 @@ discard block |
||
2252 | 2252 | $channel = $_GET['channel'] ?? ''; |
2253 | 2253 | |
2254 | 2254 | if ( |
2255 | - ! empty($serverUrl) |
|
2255 | + ! empty($serverUrl) |
|
2256 | 2256 | && ! empty($userId) |
2257 | 2257 | && ! empty($accessToken) |
2258 | 2258 | && ! empty($channel) |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $this->filename = $instance->getFilename(); |
169 | 169 | } |
170 | 170 | |
171 | - if (! empty($this->shieldon->logger)) { |
|
171 | + if (!empty($this->shieldon->logger)) { |
|
172 | 172 | |
173 | 173 | // We need to know where the logs stored in. |
174 | 174 | $logDirectory = $this->shieldon->logger->getDirectory(); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | } |
187 | 187 | |
188 | 188 | // Flash message, use it when redirecting page. |
189 | - if (! empty($_SESSION['flash_messages'])) { |
|
189 | + if (!empty($_SESSION['flash_messages'])) { |
|
190 | 190 | $this->messages = $_SESSION['flash_messages']; |
191 | 191 | unset($_SESSION['flash_messages']); |
192 | 192 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | { |
206 | 206 | $this->locate = 'en'; |
207 | 207 | |
208 | - if (! empty($_SESSION['SHIELDON_PANEL_LANG'])) { |
|
208 | + if (!empty($_SESSION['SHIELDON_PANEL_LANG'])) { |
|
209 | 209 | $this->locate = $_SESSION['SHIELDON_PANEL_LANG']; |
210 | 210 | } |
211 | 211 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | unset($_POST); |
232 | 232 | } |
233 | 233 | |
234 | - switch($slug) { |
|
234 | + switch ($slug) { |
|
235 | 235 | |
236 | 236 | case 'overview': |
237 | 237 | $this->overview(); |
@@ -348,15 +348,15 @@ discard block |
||
348 | 348 | |
349 | 349 | } elseif (2 === count($csrfparams)) { |
350 | 350 | |
351 | - if (! empty($csrfparams[0]) && is_string($csrfparams[0])) { |
|
351 | + if (!empty($csrfparams[0]) && is_string($csrfparams[0])) { |
|
352 | 352 | $csrfKey = $csrfparams[0]; |
353 | 353 | } |
354 | 354 | |
355 | - if (! empty($csrfparams[1]) && is_string($csrfparams[1])) { |
|
355 | + if (!empty($csrfparams[1]) && is_string($csrfparams[1])) { |
|
356 | 356 | $csrfValue = $csrfparams[1]; |
357 | 357 | } |
358 | 358 | |
359 | - if (! empty($csrfKey)) { |
|
359 | + if (!empty($csrfKey)) { |
|
360 | 360 | $this->csrfField[] = [ |
361 | 361 | 'name' => $csrfKey, |
362 | 362 | 'value' => $csrfValue, |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | */ |
373 | 373 | public function _csrf(): void |
374 | 374 | { |
375 | - if (! empty($this->csrfField)) { |
|
375 | + if (!empty($this->csrfField)) { |
|
376 | 376 | foreach ($this->csrfField as $value) { |
377 | 377 | echo '<input type="hidden" name="' . $value['name'] . '" value="' . $value['value'] . '" id="csrf-field">'; |
378 | 378 | } |
@@ -389,11 +389,11 @@ discard block |
||
389 | 389 | */ |
390 | 390 | public function demo(string $user = '', string $pass = ''): void |
391 | 391 | { |
392 | - if (! empty($user)) { |
|
392 | + if (!empty($user)) { |
|
393 | 393 | $this->demoUser['user'] = $user; |
394 | 394 | } |
395 | 395 | |
396 | - if (! empty($pass)) { |
|
396 | + if (!empty($pass)) { |
|
397 | 397 | $this->demoUser['pass'] = $pass; |
398 | 398 | } |
399 | 399 | |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | |
436 | 436 | if ( |
437 | 437 | // Default password, unencrypted. |
438 | - $admin['user'] === $_POST['s_user'] && |
|
438 | + $admin['user'] === $_POST['s_user'] && |
|
439 | 439 | 'shieldon_pass' === $_POST['s_pass'] && |
440 | 440 | 'shieldon_pass' === $admin['pass'] |
441 | 441 | ) { |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | |
462 | 462 | // Check the response from Captcha modules. |
463 | 463 | foreach ($this->captcha as $captcha) { |
464 | - if (! $captcha->response()) { |
|
464 | + if (!$captcha->response()) { |
|
465 | 465 | $login = false; |
466 | 466 | $data['error'] = __('panel', 'login_message_invalid_captcha', 'Invalid Captcha code.'); |
467 | 467 | } |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | |
553 | 553 | $data['action_logger'] = false; |
554 | 554 | |
555 | - if (! empty($this->shieldon->logger)) { |
|
555 | + if (!empty($this->shieldon->logger)) { |
|
556 | 556 | $loggerInfo = $this->shieldon->logger->getCurrentLoggerInfo(); |
557 | 557 | $data['action_logger'] = true; |
558 | 558 | } |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | $data['logger_work_days'] = '0 day'; |
562 | 562 | $data['logger_total_size'] = '0 MB'; |
563 | 563 | |
564 | - if (! empty($loggerInfo)) { |
|
564 | + if (!empty($loggerInfo)) { |
|
565 | 565 | |
566 | 566 | $i = 0; |
567 | 567 | ksort($loggerInfo); |
@@ -609,11 +609,11 @@ discard block |
||
609 | 609 | */ |
610 | 610 | |
611 | 611 | $data['components'] = [ |
612 | - 'Ip' => (! empty($this->shieldon->component['Ip'])) ? true : false, |
|
613 | - 'TrustedBot' => (! empty($this->shieldon->component['TrustedBot'])) ? true : false, |
|
614 | - 'Header' => (! empty($this->shieldon->component['Header'])) ? true : false, |
|
615 | - 'Rdns' => (! empty($this->shieldon->component['Rdns'])) ? true : false, |
|
616 | - 'UserAgent' => (! empty($this->shieldon->component['UserAgent'])) ? true : false, |
|
612 | + 'Ip' => (!empty($this->shieldon->component['Ip'])) ? true : false, |
|
613 | + 'TrustedBot' => (!empty($this->shieldon->component['TrustedBot'])) ? true : false, |
|
614 | + 'Header' => (!empty($this->shieldon->component['Header'])) ? true : false, |
|
615 | + 'Rdns' => (!empty($this->shieldon->component['Rdns'])) ? true : false, |
|
616 | + 'UserAgent' => (!empty($this->shieldon->component['UserAgent'])) ? true : false, |
|
617 | 617 | ]; |
618 | 618 | |
619 | 619 | $reflection = new ReflectionObject($this->shieldon); |
@@ -706,11 +706,11 @@ discard block |
||
706 | 706 | protected function operationStatus(): void |
707 | 707 | { |
708 | 708 | $data['components'] = [ |
709 | - 'Ip' => (! empty($this->shieldon->component['Ip'])) ? true : false, |
|
710 | - 'TrustedBot' => (! empty($this->shieldon->component['TrustedBot'])) ? true : false, |
|
711 | - 'Header' => (! empty($this->shieldon->component['Header'])) ? true : false, |
|
712 | - 'Rdns' => (! empty($this->shieldon->component['Rdns'])) ? true : false, |
|
713 | - 'UserAgent' => (! empty($this->shieldon->component['UserAgent'])) ? true : false, |
|
709 | + 'Ip' => (!empty($this->shieldon->component['Ip'])) ? true : false, |
|
710 | + 'TrustedBot' => (!empty($this->shieldon->component['TrustedBot'])) ? true : false, |
|
711 | + 'Header' => (!empty($this->shieldon->component['Header'])) ? true : false, |
|
712 | + 'Rdns' => (!empty($this->shieldon->component['Rdns'])) ? true : false, |
|
713 | + 'UserAgent' => (!empty($this->shieldon->component['UserAgent'])) ? true : false, |
|
714 | 714 | ]; |
715 | 715 | |
716 | 716 | $reflection = new ReflectionObject($this->shieldon); |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | |
884 | 884 | $newIpList = []; |
885 | 885 | |
886 | - if (! empty($ipList)) { |
|
886 | + if (!empty($ipList)) { |
|
887 | 887 | foreach ($ipList as $i => $ipInfo) { |
888 | 888 | $key = $i + 1; |
889 | 889 | if ($order === $i) { |
@@ -1026,7 +1026,7 @@ discard block |
||
1026 | 1026 | $order = (int) $_POST['order']; |
1027 | 1027 | |
1028 | 1028 | // Check variable name. Should be mixed with a-zA-Z and underscore. |
1029 | - if (! ctype_alnum(str_replace('_', '', $variable))) { |
|
1029 | + if (!ctype_alnum(str_replace('_', '', $variable))) { |
|
1030 | 1030 | |
1031 | 1031 | // Ignore the `add` process. |
1032 | 1032 | $action = 'undefined'; |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | |
1099 | 1099 | $lastCachedTime = ''; |
1100 | 1100 | |
1101 | - if (! empty($this->parser)) { |
|
1101 | + if (!empty($this->parser)) { |
|
1102 | 1102 | |
1103 | 1103 | $logCacheHandler = new ActionLogParsedCache($this->parser->getDirectory()); |
1104 | 1104 | |
@@ -1106,13 +1106,13 @@ discard block |
||
1106 | 1106 | |
1107 | 1107 | // If we have cached data then we don't need to parse them again. |
1108 | 1108 | // This will save a lot of time in parsing logs. |
1109 | - if (! empty($ipDetailsCachedData)) { |
|
1109 | + if (!empty($ipDetailsCachedData)) { |
|
1110 | 1110 | |
1111 | 1111 | $data['ip_details'] = $ipDetailsCachedData['ip_details']; |
1112 | 1112 | $data['period_data'] = $ipDetailsCachedData['period_data']; |
1113 | 1113 | $lastCachedTime = date('Y-m-d H:i:s', $ipDetailsCachedData['time']); |
1114 | 1114 | |
1115 | - if ('today' === $type ) { |
|
1115 | + if ('today' === $type) { |
|
1116 | 1116 | $ipDetailsCachedData = $logCacheHandler->get('past_seven_hours'); |
1117 | 1117 | $data['past_seven_hours'] = $ipDetailsCachedData['period_data']; |
1118 | 1118 | } |
@@ -1126,7 +1126,7 @@ discard block |
||
1126 | 1126 | |
1127 | 1127 | $logCacheHandler->save($type, $data); |
1128 | 1128 | |
1129 | - if ('today' === $type ) { |
|
1129 | + if ('today' === $type) { |
|
1130 | 1130 | $this->parser->prepare('past_seven_hours'); |
1131 | 1131 | $data['past_seven_hours'] = $this->parser->getParsedPeriodData(); |
1132 | 1132 | |
@@ -1308,11 +1308,11 @@ discard block |
||
1308 | 1308 | $iptablesQueueFile = $iptablesWatchingFolder . '/iptables_queue.log'; |
1309 | 1309 | |
1310 | 1310 | if ( |
1311 | - (isset($_POST['ip']) && (filter_var(explode('/', $_POST['ip'])[0], FILTER_VALIDATE_IP))) |
|
1312 | - && (isset($_POST['port']) && (is_numeric($_POST['port']) || ($_POST['port'] === 'all') || ($_POST['port'] === 'custom'))) |
|
1313 | - && (isset($_POST['subnet']) && (is_numeric($_POST['subnet']) || ($_POST['subnet'] === 'null'))) |
|
1311 | + (isset($_POST['ip']) && (filter_var(explode('/', $_POST['ip'])[0], FILTER_VALIDATE_IP))) |
|
1312 | + && (isset($_POST['port']) && (is_numeric($_POST['port']) || ($_POST['port'] === 'all') || ($_POST['port'] === 'custom'))) |
|
1313 | + && (isset($_POST['subnet']) && (is_numeric($_POST['subnet']) || ($_POST['subnet'] === 'null'))) |
|
1314 | 1314 | && (isset($_POST['protocol']) && (in_array($_POST['protocol'], ['tcp', 'udp', 'all']))) |
1315 | - && (isset($_POST['action']) && (in_array($_POST['action'], ['allow', 'deny']))) |
|
1315 | + && (isset($_POST['action']) && (in_array($_POST['action'], ['allow', 'deny']))) |
|
1316 | 1316 | ) { |
1317 | 1317 | $ip = $_POST['ip']; |
1318 | 1318 | $port = $_POST['port']; |
@@ -1360,7 +1360,7 @@ discard block |
||
1360 | 1360 | // Add a command to the watching file. |
1361 | 1361 | file_put_contents($iptablesQueueFile, $applyCommand . "\n", FILE_APPEND | LOCK_EX); |
1362 | 1362 | |
1363 | - if (! $isRemoval) { |
|
1363 | + if (!$isRemoval) { |
|
1364 | 1364 | |
1365 | 1365 | // Becase we need system cronjob done, and then the web page will show the actual results. |
1366 | 1366 | sleep(10); |
@@ -1382,7 +1382,7 @@ discard block |
||
1382 | 1382 | $line = trim($file->fgets()); |
1383 | 1383 | $ipInfo = explode(',', $line); |
1384 | 1384 | |
1385 | - if (! empty($ipInfo[4])) { |
|
1385 | + if (!empty($ipInfo[4])) { |
|
1386 | 1386 | $ipCommand[] = $ipInfo; |
1387 | 1387 | } |
1388 | 1388 | } |
@@ -1463,7 +1463,7 @@ discard block |
||
1463 | 1463 | $line = trim($file->fgets()); |
1464 | 1464 | $ipInfo = explode(',', $line); |
1465 | 1465 | |
1466 | - if (! empty($ipInfo[4])) { |
|
1466 | + if (!empty($ipInfo[4])) { |
|
1467 | 1467 | $ipv6Command[] = $ipInfo; |
1468 | 1468 | } |
1469 | 1469 | } |
@@ -1514,12 +1514,12 @@ discard block |
||
1514 | 1514 | $configFilePath = $this->directory . '/' . $this->filename; |
1515 | 1515 | |
1516 | 1516 | foreach ($this->csrfField as $csrfInfo) { |
1517 | - if (! empty($csrfInfo['name'])) { |
|
1517 | + if (!empty($csrfInfo['name'])) { |
|
1518 | 1518 | unset($_POST[$csrfInfo['name']]); |
1519 | 1519 | } |
1520 | 1520 | } |
1521 | 1521 | |
1522 | - if (empty($_POST) || ! is_array($_POST) || 'managed' !== $this->mode) { |
|
1522 | + if (empty($_POST) || !is_array($_POST) || 'managed' !== $this->mode) { |
|
1523 | 1523 | return; |
1524 | 1524 | } |
1525 | 1525 | |
@@ -1553,7 +1553,7 @@ discard block |
||
1553 | 1553 | } else { |
1554 | 1554 | if (is_numeric($postData)) { |
1555 | 1555 | $this->setConfig(str_replace('__', '.', $postKey), (int) $postData); |
1556 | - } else { |
|
1556 | + } else { |
|
1557 | 1557 | $this->setConfig(str_replace('__', '.', $postKey), $postData); |
1558 | 1558 | } |
1559 | 1559 | } |
@@ -1583,7 +1583,7 @@ discard block |
||
1583 | 1583 | (string) $db['user'], |
1584 | 1584 | (string) $db['pass'] |
1585 | 1585 | ); |
1586 | - } catch(PDOException $e) { |
|
1586 | + } catch (PDOException $e) { |
|
1587 | 1587 | $isDataDriverFailed = true; |
1588 | 1588 | $this->responseMessage('error', |
1589 | 1589 | __( |
@@ -1617,8 +1617,8 @@ discard block |
||
1617 | 1617 | $sqliteFilePath = $sqliteDir . '/shieldon.sqlite3'; |
1618 | 1618 | $this->setConfig('drivers.sqlite.directory_path', $sqliteDir); |
1619 | 1619 | |
1620 | - if (! file_exists($sqliteFilePath)) { |
|
1621 | - if (! is_dir($sqliteDir)) { |
|
1620 | + if (!file_exists($sqliteFilePath)) { |
|
1621 | + if (!is_dir($sqliteDir)) { |
|
1622 | 1622 | $originalUmask = umask(0); |
1623 | 1623 | @mkdir($sqliteDir, 0777, true); |
1624 | 1624 | umask($originalUmask); |
@@ -1628,7 +1628,7 @@ discard block |
||
1628 | 1628 | if (class_exists('PDO')) { |
1629 | 1629 | try { |
1630 | 1630 | $pdo = new PDO('sqlite:' . $sqliteFilePath); |
1631 | - } catch(PDOException $e) { |
|
1631 | + } catch (PDOException $e) { |
|
1632 | 1632 | $isDataDriverFailed = true; |
1633 | 1633 | $this->responseMessage('error', $e->getMessage()); |
1634 | 1634 | } |
@@ -1643,7 +1643,7 @@ discard block |
||
1643 | 1643 | ); |
1644 | 1644 | } |
1645 | 1645 | |
1646 | - if (! is_writable($sqliteFilePath)) { |
|
1646 | + if (!is_writable($sqliteFilePath)) { |
|
1647 | 1647 | $isDataDriverFailed = true; |
1648 | 1648 | $this->responseMessage('error', |
1649 | 1649 | __( |
@@ -1663,9 +1663,9 @@ discard block |
||
1663 | 1663 | $redis = new Redis(); |
1664 | 1664 | $redis->connect( |
1665 | 1665 | (string) $this->getConfig('drivers.redis.host'), |
1666 | - (int) $this->getConfig('drivers.redis.port') |
|
1666 | + (int) $this->getConfig('drivers.redis.port') |
|
1667 | 1667 | ); |
1668 | - } catch(RedisException $e) { |
|
1668 | + } catch (RedisException $e) { |
|
1669 | 1669 | $isDataDriverFailed = true; |
1670 | 1670 | $this->responseMessage('error', $e->getMessage()); |
1671 | 1671 | } |
@@ -1694,13 +1694,13 @@ discard block |
||
1694 | 1694 | |
1695 | 1695 | $this->setConfig('drivers.file.directory_path', $fileDir); |
1696 | 1696 | |
1697 | - if (! is_dir($fileDir)) { |
|
1697 | + if (!is_dir($fileDir)) { |
|
1698 | 1698 | $originalUmask = umask(0); |
1699 | 1699 | @mkdir($fileDir, 0777, true); |
1700 | 1700 | umask($originalUmask); |
1701 | 1701 | } |
1702 | 1702 | |
1703 | - if (! is_writable($fileDir)) { |
|
1703 | + if (!is_writable($fileDir)) { |
|
1704 | 1704 | $isDataDriverFailed = true; |
1705 | 1705 | $this->responseMessage('error', |
1706 | 1706 | __( |
@@ -1724,13 +1724,13 @@ discard block |
||
1724 | 1724 | |
1725 | 1725 | $this->setConfig('loggers.action.config.directory_path', $actionLogDir); |
1726 | 1726 | |
1727 | - if (! is_dir($actionLogDir)) { |
|
1727 | + if (!is_dir($actionLogDir)) { |
|
1728 | 1728 | $originalUmask = umask(0); |
1729 | 1729 | @mkdir($actionLogDir, 0777, true); |
1730 | 1730 | umask($originalUmask); |
1731 | 1731 | } |
1732 | 1732 | |
1733 | - if (! is_writable($actionLogDir)) { |
|
1733 | + if (!is_writable($actionLogDir)) { |
|
1734 | 1734 | $isDataDriverFailed = true; |
1735 | 1735 | $this->responseMessage('error', |
1736 | 1736 | __( |
@@ -1753,7 +1753,7 @@ discard block |
||
1753 | 1753 | |
1754 | 1754 | $this->setConfig('iptables.config.watching_folder', $iptablesWatchingFolder); |
1755 | 1755 | |
1756 | - if (! is_dir($iptablesWatchingFolder)) { |
|
1756 | + if (!is_dir($iptablesWatchingFolder)) { |
|
1757 | 1757 | $originalUmask = umask(0); |
1758 | 1758 | @mkdir($iptablesWatchingFolder, 0777, true); |
1759 | 1759 | umask($originalUmask); |
@@ -1761,14 +1761,14 @@ discard block |
||
1761 | 1761 | // Create default log files. |
1762 | 1762 | if (is_writable($iptablesWatchingFolder)) { |
1763 | 1763 | fopen($iptablesWatchingFolder . '/iptables_queue.log', 'w+'); |
1764 | - fopen($iptablesWatchingFolder . '/ipv4_status.log', 'w+'); |
|
1765 | - fopen($iptablesWatchingFolder . '/ipv6_status.log', 'w+'); |
|
1766 | - fopen($iptablesWatchingFolder . '/ipv4_command.log', 'w+'); |
|
1767 | - fopen($iptablesWatchingFolder . '/ipv6_command.log', 'w+'); |
|
1764 | + fopen($iptablesWatchingFolder . '/ipv4_status.log', 'w+'); |
|
1765 | + fopen($iptablesWatchingFolder . '/ipv6_status.log', 'w+'); |
|
1766 | + fopen($iptablesWatchingFolder . '/ipv4_command.log', 'w+'); |
|
1767 | + fopen($iptablesWatchingFolder . '/ipv6_command.log', 'w+'); |
|
1768 | 1768 | } |
1769 | 1769 | } |
1770 | 1770 | |
1771 | - if (! is_writable($iptablesWatchingFolder)) { |
|
1771 | + if (!is_writable($iptablesWatchingFolder)) { |
|
1772 | 1772 | $isDataDriverFailed = true; |
1773 | 1773 | $this->responseMessage('error', |
1774 | 1774 | __( |
@@ -1781,7 +1781,7 @@ discard block |
||
1781 | 1781 | } |
1782 | 1782 | |
1783 | 1783 | // Only update settings while data driver is correctly connected. |
1784 | - if (! $isDataDriverFailed) { |
|
1784 | + if (!$isDataDriverFailed) { |
|
1785 | 1785 | file_put_contents($configFilePath, json_encode($this->configuration)); |
1786 | 1786 | |
1787 | 1787 | $this->responseMessage('success', |
@@ -1824,11 +1824,11 @@ discard block |
||
1824 | 1824 | die('Not allowed to view this page.'); |
1825 | 1825 | } |
1826 | 1826 | |
1827 | - if (! empty($_FILES['json_file']['tmp_name'])) { |
|
1827 | + if (!empty($_FILES['json_file']['tmp_name'])) { |
|
1828 | 1828 | $importedFileContent = file_get_contents($_FILES['json_file']['tmp_name']); |
1829 | 1829 | } |
1830 | 1830 | |
1831 | - if (! empty($importedFileContent)) { |
|
1831 | + if (!empty($importedFileContent)) { |
|
1832 | 1832 | $jsonData = json_decode($importedFileContent, true); |
1833 | 1833 | |
1834 | 1834 | if (json_last_error() !== JSON_ERROR_NONE) { |
@@ -1848,7 +1848,7 @@ discard block |
||
1848 | 1848 | $checkFileVaild = true; |
1849 | 1849 | |
1850 | 1850 | foreach (array_keys($this->configuration) as $key) { |
1851 | - if (! isset($jsonData[$key])) { |
|
1851 | + if (!isset($jsonData[$key])) { |
|
1852 | 1852 | $checkFileVaild = false; |
1853 | 1853 | } |
1854 | 1854 | } |
@@ -1934,11 +1934,11 @@ discard block |
||
1934 | 1934 | if (in_array($field, $hiddenForDemo)) { |
1935 | 1935 | echo __('panel', 'field_not_visible', 'Cannot view this field in demo mode.'); |
1936 | 1936 | } else { |
1937 | - echo (! empty($this->getConfig($field))) ? $this->getConfig($field) : $default; |
|
1937 | + echo (!empty($this->getConfig($field))) ? $this->getConfig($field) : $default; |
|
1938 | 1938 | } |
1939 | 1939 | |
1940 | 1940 | } else { |
1941 | - echo (! empty($this->getConfig($field))) ? $this->getConfig($field) : $default; |
|
1941 | + echo (!empty($this->getConfig($field))) ? $this->getConfig($field) : $default; |
|
1942 | 1942 | } |
1943 | 1943 | } elseif (is_array($this->getConfig($field))) { |
1944 | 1944 | |
@@ -2032,13 +2032,13 @@ discard block |
||
2032 | 2032 | */ |
2033 | 2033 | private function loadView(string $page, array $data = [], $echo = false) |
2034 | 2034 | { |
2035 | - if (! defined('SHIELDON_VIEW')) { |
|
2035 | + if (!defined('SHIELDON_VIEW')) { |
|
2036 | 2036 | define('SHIELDON_VIEW', true); |
2037 | 2037 | } |
2038 | 2038 | |
2039 | - $viewFilePath = __DIR__ . '/../../templates/' . $page . '.php'; |
|
2039 | + $viewFilePath = __DIR__ . '/../../templates/' . $page . '.php'; |
|
2040 | 2040 | |
2041 | - if (! empty($data)) { |
|
2041 | + if (!empty($data)) { |
|
2042 | 2042 | extract($data); |
2043 | 2043 | } |
2044 | 2044 | |
@@ -2069,7 +2069,7 @@ discard block |
||
2069 | 2069 | */ |
2070 | 2070 | private function _include(string $page, array $data = []): void |
2071 | 2071 | { |
2072 | - if (! defined('SHIELDON_VIEW')) { |
|
2072 | + if (!defined('SHIELDON_VIEW')) { |
|
2073 | 2073 | define('SHIELDON_VIEW', true); |
2074 | 2074 | } |
2075 | 2075 | |
@@ -2147,8 +2147,8 @@ discard block |
||
2147 | 2147 | $path = parse_url($httpProtocal . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], PHP_URL_PATH); |
2148 | 2148 | |
2149 | 2149 | $url = $httpProtocal . $_SERVER['HTTP_HOST'] . $path; |
2150 | - $soPage = (! empty($page)) ? '?so_page=' . $page : ''; |
|
2151 | - $soTab = (! empty($tab)) ? '&tab=' . $tab : ''; |
|
2150 | + $soPage = (!empty($page)) ? '?so_page=' . $page : ''; |
|
2151 | + $soTab = (!empty($tab)) ? '&tab=' . $tab : ''; |
|
2152 | 2152 | |
2153 | 2153 | return $url . $soPage . $soTab; |
2154 | 2154 | } |
@@ -2160,7 +2160,7 @@ discard block |
||
2160 | 2160 | */ |
2161 | 2161 | private function httpAuth(): void |
2162 | 2162 | { |
2163 | - if (! isset($_SESSION['SHIELDON_USER_LOGIN'])) { |
|
2163 | + if (!isset($_SESSION['SHIELDON_USER_LOGIN'])) { |
|
2164 | 2164 | $this->login(); |
2165 | 2165 | } |
2166 | 2166 | } |
@@ -2201,12 +2201,12 @@ discard block |
||
2201 | 2201 | $testMsgTitle = __('panel', 'test_msg_title', 'Testing Message from Host: ') . $_SERVER['SERVER_ADDR']; |
2202 | 2202 | $testMsgBody = __('panel', 'test_msg_body', 'Messenger module "{0}" has been tested and confirmed successfully.', [$moduleName]); |
2203 | 2203 | |
2204 | - switch($moduleName) { |
|
2204 | + switch ($moduleName) { |
|
2205 | 2205 | |
2206 | 2206 | case 'telegram': |
2207 | 2207 | $apiKey = $_GET['apiKey'] ?? ''; |
2208 | 2208 | $channel = $_GET['channel'] ?? ''; |
2209 | - if (! empty($apiKey) && ! empty($channel)) { |
|
2209 | + if (!empty($apiKey) && !empty($channel)) { |
|
2210 | 2210 | $messenger = new MessengerModule\Telegram($apiKey, $channel); |
2211 | 2211 | if ($messenger->send($testMsgBody)) { |
2212 | 2212 | $response['status'] = 'success'; |
@@ -2216,7 +2216,7 @@ discard block |
||
2216 | 2216 | |
2217 | 2217 | case 'line-notify': |
2218 | 2218 | $accessToken = $_GET['accessToken'] ?? ''; |
2219 | - if (! empty($accessToken)) { |
|
2219 | + if (!empty($accessToken)) { |
|
2220 | 2220 | $messenger = new MessengerModule\LineNotify($accessToken); |
2221 | 2221 | if ($messenger->send($testMsgBody)) { |
2222 | 2222 | $response['status'] = 'success'; |
@@ -2227,7 +2227,7 @@ discard block |
||
2227 | 2227 | case 'slack': |
2228 | 2228 | $botToken = $_GET['botToken'] ?? ''; |
2229 | 2229 | $channel = $_GET['channel'] ?? ''; |
2230 | - if (! empty($botToken) && ! empty($channel)) { |
|
2230 | + if (!empty($botToken) && !empty($channel)) { |
|
2231 | 2231 | $messenger = new MessengerModule\Slack($botToken, $channel); |
2232 | 2232 | if ($messenger->send($testMsgBody)) { |
2233 | 2233 | $response['status'] = 'success'; |
@@ -2237,7 +2237,7 @@ discard block |
||
2237 | 2237 | |
2238 | 2238 | case 'slack-webhook': |
2239 | 2239 | $webhookUrl = $_GET['webhookUrl'] ?? ''; |
2240 | - if (! empty($webhookUrl)) { |
|
2240 | + if (!empty($webhookUrl)) { |
|
2241 | 2241 | $messenger = new MessengerModule\SlackWebhook($webhookUrl); |
2242 | 2242 | if ($messenger->send($testMsgBody)) { |
2243 | 2243 | $response['status'] = 'success'; |
@@ -2252,10 +2252,10 @@ discard block |
||
2252 | 2252 | $channel = $_GET['channel'] ?? ''; |
2253 | 2253 | |
2254 | 2254 | if ( |
2255 | - ! empty($serverUrl) |
|
2256 | - && ! empty($userId) |
|
2257 | - && ! empty($accessToken) |
|
2258 | - && ! empty($channel) |
|
2255 | + !empty($serverUrl) |
|
2256 | + && !empty($userId) |
|
2257 | + && !empty($accessToken) |
|
2258 | + && !empty($channel) |
|
2259 | 2259 | ) { |
2260 | 2260 | $messenger = new MessengerModule\RocketChat($accessToken, $userId, $serverUrl, $channel); |
2261 | 2261 | if ($messenger->send($testMsgBody)) { |
@@ -2275,8 +2275,8 @@ discard block |
||
2275 | 2275 | $recipients = $_GET['recipients'] ?? ''; |
2276 | 2276 | |
2277 | 2277 | if ( |
2278 | - (! filter_var($host, FILTER_VALIDATE_IP) && ! filter_var($host, FILTER_VALIDATE_DOMAIN)) |
|
2279 | - || ! is_numeric($port) |
|
2278 | + (!filter_var($host, FILTER_VALIDATE_IP) && !filter_var($host, FILTER_VALIDATE_DOMAIN)) |
|
2279 | + || !is_numeric($port) |
|
2280 | 2280 | || empty($user) |
2281 | 2281 | || empty($pass) |
2282 | 2282 | ) { |
@@ -2289,14 +2289,14 @@ discard block |
||
2289 | 2289 | $host = $type . '://' . $host; |
2290 | 2290 | } |
2291 | 2291 | |
2292 | - if (! empty($sender) && $recipients) { |
|
2292 | + if (!empty($sender) && $recipients) { |
|
2293 | 2293 | $recipients = str_replace("\r", '|', $recipients); |
2294 | 2294 | $recipients = str_replace("\n", '|', $recipients); |
2295 | 2295 | $recipients = explode('|', $recipients); |
2296 | 2296 | |
2297 | 2297 | $messenger = new MessengerModule\Smtp($user, $pass, $host, (int) $port); |
2298 | 2298 | |
2299 | - foreach($recipients as $recipient) { |
|
2299 | + foreach ($recipients as $recipient) { |
|
2300 | 2300 | if (filter_var($recipient, FILTER_VALIDATE_EMAIL)) { |
2301 | 2301 | $messenger->addRecipient($recipient); |
2302 | 2302 | } |
@@ -2318,14 +2318,14 @@ discard block |
||
2318 | 2318 | $sender = $_GET['sender'] ?? ''; |
2319 | 2319 | $recipients = $_GET['recipients'] ?? ''; |
2320 | 2320 | |
2321 | - if (! empty($sender) && ! empty($recipients)) { |
|
2321 | + if (!empty($sender) && !empty($recipients)) { |
|
2322 | 2322 | $recipients = str_replace("\r", '|', $recipients); |
2323 | 2323 | $recipients = str_replace("\n", '|', $recipients); |
2324 | 2324 | $recipients = explode('|', $recipients); |
2325 | 2325 | |
2326 | 2326 | $messenger = new MessengerModule\Mail(); |
2327 | 2327 | |
2328 | - foreach($recipients as $recipient) { |
|
2328 | + foreach ($recipients as $recipient) { |
|
2329 | 2329 | |
2330 | 2330 | if (filter_var($recipient, FILTER_VALIDATE_EMAIL)) { |
2331 | 2331 | $messenger->addRecipient($recipient); |
@@ -2349,14 +2349,14 @@ discard block |
||
2349 | 2349 | $sender = $_GET['sender'] ?? ''; |
2350 | 2350 | $recipients = $_GET['recipients'] ?? ''; |
2351 | 2351 | |
2352 | - if (! empty($sender) && ! empty($recipients) && ! empty($apiKey)) { |
|
2352 | + if (!empty($sender) && !empty($recipients) && !empty($apiKey)) { |
|
2353 | 2353 | $recipients = str_replace("\r", '|', $recipients); |
2354 | 2354 | $recipients = str_replace("\n", '|', $recipients); |
2355 | 2355 | $recipients = explode('|', $recipients); |
2356 | 2356 | |
2357 | 2357 | $messenger = new MessengerModule\Sendgrid($apiKey); |
2358 | 2358 | |
2359 | - foreach($recipients as $recipient) { |
|
2359 | + foreach ($recipients as $recipient) { |
|
2360 | 2360 | if (filter_var($recipient, FILTER_VALIDATE_EMAIL)) { |
2361 | 2361 | $messenger->addRecipient($recipient); |
2362 | 2362 | } |
@@ -2380,14 +2380,14 @@ discard block |
||
2380 | 2380 | $sender = $_GET['sender'] ?? ''; |
2381 | 2381 | $recipients = $_GET['recipients'] ?? ''; |
2382 | 2382 | |
2383 | - if (! empty($sender) && ! empty($recipients) && ! empty($apiKey) && ! empty($domain)) { |
|
2383 | + if (!empty($sender) && !empty($recipients) && !empty($apiKey) && !empty($domain)) { |
|
2384 | 2384 | $recipients = str_replace("\r", '|', $recipients); |
2385 | 2385 | $recipients = str_replace("\n", '|', $recipients); |
2386 | 2386 | $recipients = explode('|', $recipients); |
2387 | 2387 | |
2388 | 2388 | $messenger = new MessengerModule\Mailgun($apiKey, $domain); |
2389 | 2389 | |
2390 | - foreach($recipients as $recipient) { |
|
2390 | + foreach ($recipients as $recipient) { |
|
2391 | 2391 | if (filter_var($recipient, FILTER_VALIDATE_EMAIL)) { |
2392 | 2392 | $messenger->addRecipient($recipient); |
2393 | 2393 | } |
@@ -322,8 +322,12 @@ discard block |
||
322 | 322 | break; |
323 | 323 | } |
324 | 324 | |
325 | - if (isset($_GET)) unset($_GET); |
|
326 | - if (isset($_POST)) unset($_POST); |
|
325 | + if (isset($_GET)) { |
|
326 | + unset($_GET); |
|
327 | + } |
|
328 | + if (isset($_POST)) { |
|
329 | + unset($_POST); |
|
330 | + } |
|
327 | 331 | } |
328 | 332 | |
329 | 333 | /** |
@@ -912,10 +916,18 @@ discard block |
||
912 | 916 | $this->setConfig('ip_manager', $ipList); |
913 | 917 | } |
914 | 918 | |
915 | - if (isset($_POST['url'])) unset($_POST['url']); |
|
916 | - if (isset($_POST['ip'])) unset($_POST['ip']); |
|
917 | - if (isset($_POST['action'])) unset($_POST['action']); |
|
918 | - if (isset($_POST['order'])) unset($_POST['order']); |
|
919 | + if (isset($_POST['url'])) { |
|
920 | + unset($_POST['url']); |
|
921 | + } |
|
922 | + if (isset($_POST['ip'])) { |
|
923 | + unset($_POST['ip']); |
|
924 | + } |
|
925 | + if (isset($_POST['action'])) { |
|
926 | + unset($_POST['action']); |
|
927 | + } |
|
928 | + if (isset($_POST['order'])) { |
|
929 | + unset($_POST['order']); |
|
930 | + } |
|
919 | 931 | |
920 | 932 | $this->saveConfig(); |
921 | 933 | } |
@@ -953,9 +965,15 @@ discard block |
||
953 | 965 | |
954 | 966 | $this->setConfig('excluded_urls', $excludedUrls); |
955 | 967 | |
956 | - if (isset($_POST['url'])) unset($_POST['url']); |
|
957 | - if (isset($_POST['action'])) unset($_POST['action']); |
|
958 | - if (isset($_POST['order'])) unset($_POST['order']); |
|
968 | + if (isset($_POST['url'])) { |
|
969 | + unset($_POST['url']); |
|
970 | + } |
|
971 | + if (isset($_POST['action'])) { |
|
972 | + unset($_POST['action']); |
|
973 | + } |
|
974 | + if (isset($_POST['order'])) { |
|
975 | + unset($_POST['order']); |
|
976 | + } |
|
959 | 977 | |
960 | 978 | $this->saveConfig(); |
961 | 979 | } |
@@ -996,11 +1014,21 @@ discard block |
||
996 | 1014 | |
997 | 1015 | $this->setConfig('www_authenticate', $authenticatedList); |
998 | 1016 | |
999 | - if (isset($_POST['url'])) unset($_POST['url']); |
|
1000 | - if (isset($_POST['user'])) unset($_POST['user']); |
|
1001 | - if (isset($_POST['pass'])) unset($_POST['pass']); |
|
1002 | - if (isset($_POST['action'])) unset($_POST['action']); |
|
1003 | - if (isset($_POST['order'])) unset($_POST['order']); |
|
1017 | + if (isset($_POST['url'])) { |
|
1018 | + unset($_POST['url']); |
|
1019 | + } |
|
1020 | + if (isset($_POST['user'])) { |
|
1021 | + unset($_POST['user']); |
|
1022 | + } |
|
1023 | + if (isset($_POST['pass'])) { |
|
1024 | + unset($_POST['pass']); |
|
1025 | + } |
|
1026 | + if (isset($_POST['action'])) { |
|
1027 | + unset($_POST['action']); |
|
1028 | + } |
|
1029 | + if (isset($_POST['order'])) { |
|
1030 | + unset($_POST['order']); |
|
1031 | + } |
|
1004 | 1032 | |
1005 | 1033 | $this->saveConfig(); |
1006 | 1034 | } |
@@ -1058,10 +1086,18 @@ discard block |
||
1058 | 1086 | |
1059 | 1087 | $this->setConfig('xss_protected_list', $xssProtectedList); |
1060 | 1088 | |
1061 | - if (isset($_POST['type'])) unset($_POST['type']); |
|
1062 | - if (isset($_POST['variable'])) unset($_POST['variable']); |
|
1063 | - if (isset($_POST['action'])) unset($_POST['action']); |
|
1064 | - if (isset($_POST['order'])) unset($_POST['order']); |
|
1089 | + if (isset($_POST['type'])) { |
|
1090 | + unset($_POST['type']); |
|
1091 | + } |
|
1092 | + if (isset($_POST['variable'])) { |
|
1093 | + unset($_POST['variable']); |
|
1094 | + } |
|
1095 | + if (isset($_POST['action'])) { |
|
1096 | + unset($_POST['action']); |
|
1097 | + } |
|
1098 | + if (isset($_POST['order'])) { |
|
1099 | + unset($_POST['order']); |
|
1100 | + } |
|
1065 | 1101 | |
1066 | 1102 | $this->saveConfig(); |
1067 | 1103 | } |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function isDenied(): bool |
47 | 47 | { |
48 | - if (! empty($this->deniedList)) { |
|
49 | - if (preg_match('/(' . implode('|', $this->deniedList). ')/i', $this->ipResolvedHostname)) { |
|
48 | + if (!empty($this->deniedList)) { |
|
49 | + if (preg_match('/(' . implode('|', $this->deniedList) . ')/i', $this->ipResolvedHostname)) { |
|
50 | 50 | return true; |
51 | 51 | } |
52 | 52 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | // Not a valid domain name. |
67 | - if (! filter_var($this->ipResolvedHostname, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) { |
|
67 | + if (!filter_var($this->ipResolvedHostname, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) { |
|
68 | 68 | return true; |
69 | 69 | } |
70 | 70 |
@@ -44,22 +44,22 @@ discard block |
||
44 | 44 | $this->deniedList = [ |
45 | 45 | |
46 | 46 | // Web information crawlers |
47 | - 'domain', // Block all domain name information crawlers. |
|
48 | - 'copyright', // Block all copyright information crawlers. |
|
47 | + 'domain', // Block all domain name information crawlers. |
|
48 | + 'copyright', // Block all copyright information crawlers. |
|
49 | 49 | |
50 | 50 | // SEO backlink crawlers |
51 | - 'Ahrefs', // http://ahrefs.com/robot/ |
|
52 | - 'roger', // rogerbot (SEOMOZ) |
|
53 | - 'moz.com', // Block all SEOMOZ crawlers |
|
54 | - 'MJ12bot', // Majestic crawlers |
|
55 | - 'findlinks', // http://wortschatz.uni-leipzig.de/findlinks |
|
56 | - 'Semrush', // http://www.semrush.com/bot.html |
|
51 | + 'Ahrefs', // http://ahrefs.com/robot/ |
|
52 | + 'roger', // rogerbot (SEOMOZ) |
|
53 | + 'moz.com', // Block all SEOMOZ crawlers |
|
54 | + 'MJ12bot', // Majestic crawlers |
|
55 | + 'findlinks', // http://wortschatz.uni-leipzig.de/findlinks |
|
56 | + 'Semrush', // http://www.semrush.com/bot.html |
|
57 | 57 | |
58 | 58 | // Others |
59 | - 'archive', // Wayback machine |
|
59 | + 'archive', // Wayback machine |
|
60 | 60 | ]; |
61 | 61 | |
62 | - if (! empty($_SERVER['HTTP_USER_AGENT'])) { |
|
62 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
63 | 63 | $this->userAgentString = $_SERVER['HTTP_USER_AGENT']; |
64 | 64 | } |
65 | 65 | } |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function isDenied(): bool |
71 | 71 | { |
72 | - if (! empty($this->deniedList)) { |
|
73 | - if (preg_match('/(' . implode('|', $this->deniedList). ')/i', $this->userAgentString)) { |
|
72 | + if (!empty($this->deniedList)) { |
|
73 | + if (preg_match('/(' . implode('|', $this->deniedList) . ')/i', $this->userAgentString)) { |
|
74 | 74 | return true; |
75 | 75 | } |
76 | 76 | } |