@@ -29,10 +29,10 @@ |
||
29 | 29 | */ |
30 | 30 | public static function get(array $setting): MessengerInterface |
31 | 31 | { |
32 | - $serverUrl = $setting['config']['server_url'] ?? ''; |
|
33 | - $userId = $setting['config']['user_id'] ?? ''; |
|
32 | + $serverUrl = $setting['config']['server_url'] ?? ''; |
|
33 | + $userId = $setting['config']['user_id'] ?? ''; |
|
34 | 34 | $accessToken = $setting['config']['access_token'] ?? ''; |
35 | - $channel = $setting['config']['channel'] ?? ''; |
|
35 | + $channel = $setting['config']['channel'] ?? ''; |
|
36 | 36 | |
37 | 37 | return new RocketChat($accessToken, $userId, $serverUrl, $channel); |
38 | 38 | } |
@@ -236,11 +236,11 @@ |
||
236 | 236 | private function overviewTemplateVarsOfComponents(array $data = []): array |
237 | 237 | { |
238 | 238 | $data['components'] = [ |
239 | - 'Ip' => (!empty($this->kernel->component['Ip'])) ? true : false, |
|
239 | + 'Ip' => (!empty($this->kernel->component['Ip'])) ? true : false, |
|
240 | 240 | 'TrustedBot' => (!empty($this->kernel->component['TrustedBot'])) ? true : false, |
241 | - 'Header' => (!empty($this->kernel->component['Header'])) ? true : false, |
|
242 | - 'Rdns' => (!empty($this->kernel->component['Rdns'])) ? true : false, |
|
243 | - 'UserAgent' => (!empty($this->kernel->component['UserAgent'])) ? true : false, |
|
241 | + 'Header' => (!empty($this->kernel->component['Header'])) ? true : false, |
|
242 | + 'Rdns' => (!empty($this->kernel->component['Rdns'])) ? true : false, |
|
243 | + 'UserAgent' => (!empty($this->kernel->component['UserAgent'])) ? true : false, |
|
244 | 244 | ]; |
245 | 245 | |
246 | 246 | return $data; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $data['period_data'] = $ipDetailsCachedData['period_data']; |
128 | 128 | $lastCachedTime = date('Y-m-d H:i:s', $ipDetailsCachedData['time']); |
129 | 129 | |
130 | - if ('today' === $type ) { |
|
130 | + if ('today' === $type) { |
|
131 | 131 | $ipDetailsCachedData = $logCacheHandler->get('past_seven_hours'); |
132 | 132 | $data['past_seven_hours'] = $ipDetailsCachedData['period_data']; |
133 | 133 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | $logCacheHandler->save($type, $data); |
143 | 143 | |
144 | - if ('today' === $type ) { |
|
144 | + if ('today' === $type) { |
|
145 | 145 | $this->parser->prepare('past_seven_hours'); |
146 | 146 | $data['past_seven_hours'] = $this->parser->getParsedPeriodData(); |
147 | 147 | |
@@ -172,11 +172,11 @@ discard block |
||
172 | 172 | private function operationTemplateVarsOfComponents(array $data = []): array |
173 | 173 | { |
174 | 174 | $data['components'] = [ |
175 | - 'Ip' => (!empty($this->kernel->component['Ip'])) ? true : false, |
|
175 | + 'Ip' => (!empty($this->kernel->component['Ip'])) ? true : false, |
|
176 | 176 | 'TrustedBot' => (!empty($this->kernel->component['TrustedBot'])) ? true : false, |
177 | - 'Header' => (!empty($this->kernel->component['Header'])) ? true : false, |
|
178 | - 'Rdns' => (!empty($this->kernel->component['Rdns'])) ? true : false, |
|
179 | - 'UserAgent' => (!empty($this->kernel->component['UserAgent'])) ? true : false, |
|
177 | + 'Header' => (!empty($this->kernel->component['Header'])) ? true : false, |
|
178 | + 'Rdns' => (!empty($this->kernel->component['Rdns'])) ? true : false, |
|
179 | + 'UserAgent' => (!empty($this->kernel->component['UserAgent'])) ? true : false, |
|
180 | 180 | ]; |
181 | 181 | |
182 | 182 | return $data; |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | if ( |
98 | 98 | isset($_SERVER['HTTP_HOST']) && |
99 | 99 | strpos($_SERVER['HTTP_HOST'], 'project.lo') !== false |
100 | -) { |
|
100 | +) { |
|
101 | 101 | // `shieldon-doc.lo` is the virtual domain that Terry is using to design CSS for Firewall Panel UI. |
102 | 102 | $staticSrc = 'http://shieldon-doc.lo/static'; |
103 | 103 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | </div> |
331 | 331 | </div> |
332 | 332 | </div> |
333 | - <?php if (! empty($this->messages)) : ?> |
|
333 | + <?php if (!empty($this->messages)) : ?> |
|
334 | 334 | <div id="message-modal" class="modal fade" tabindex="-1" role="dialog"> |
335 | 335 | <div class="modal-dialog modal-dialog-centered modal-lightbox" role="document"> |
336 | 336 | <div class="modal-content"> |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | define('SHIELDON_VIEW', true); |
175 | 175 | } |
176 | 176 | |
177 | - $viewFilePath = __DIR__ . '/../../../templates/' . $page . '.php'; |
|
177 | + $viewFilePath = __DIR__ . '/../../../templates/' . $page . '.php'; |
|
178 | 178 | |
179 | 179 | if (!empty($data)) { |
180 | 180 | extract($data); |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | } else { |
526 | 526 | if (is_numeric($postData)) { |
527 | 527 | $this->setConfig(str_replace('__', '.', $postKey), (int) $postData); |
528 | - } else { |
|
528 | + } else { |
|
529 | 529 | $this->setConfig(str_replace('__', '.', $postKey), $postData); |
530 | 530 | } |
531 | 531 | } |
@@ -613,10 +613,10 @@ discard block |
||
613 | 613 | // Create default log files. |
614 | 614 | if (is_writable($iptablesWatchingFolder)) { |
615 | 615 | fopen($iptablesWatchingFolder . '/iptables_queue.log', 'w+'); |
616 | - fopen($iptablesWatchingFolder . '/ipv4_status.log', 'w+'); |
|
617 | - fopen($iptablesWatchingFolder . '/ipv6_status.log', 'w+'); |
|
618 | - fopen($iptablesWatchingFolder . '/ipv4_command.log', 'w+'); |
|
619 | - fopen($iptablesWatchingFolder . '/ipv6_command.log', 'w+'); |
|
616 | + fopen($iptablesWatchingFolder . '/ipv4_status.log', 'w+'); |
|
617 | + fopen($iptablesWatchingFolder . '/ipv6_status.log', 'w+'); |
|
618 | + fopen($iptablesWatchingFolder . '/ipv4_command.log', 'w+'); |
|
619 | + fopen($iptablesWatchingFolder . '/ipv6_command.log', 'w+'); |
|
620 | 620 | } |
621 | 621 | } |
622 | 622 | |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | (string) $db['user'], |
695 | 695 | (string) $db['pass'] |
696 | 696 | ); |
697 | - } catch(PDOException $e) { |
|
697 | + } catch (PDOException $e) { |
|
698 | 698 | $result = false; |
699 | 699 | $this->pushMessage('error', |
700 | 700 | __( |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | if (class_exists('PDO')) { |
748 | 748 | try { |
749 | 749 | new PDO('sqlite:' . $sqliteFilePath); |
750 | - } catch(PDOException $e) { |
|
750 | + } catch (PDOException $e) { |
|
751 | 751 | $this->pushMessage('error', $e->getMessage()); |
752 | 752 | $result = false; |
753 | 753 | } |
@@ -789,10 +789,10 @@ discard block |
||
789 | 789 | $redis = new Redis(); |
790 | 790 | $redis->connect( |
791 | 791 | (string) $this->getConfig('drivers.redis.host'), |
792 | - (int) $this->getConfig('drivers.redis.port') |
|
792 | + (int) $this->getConfig('drivers.redis.port') |
|
793 | 793 | ); |
794 | 794 | unset($redis); |
795 | - } catch(RedisException $e) { |
|
795 | + } catch (RedisException $e) { |
|
796 | 796 | $this->pushMessage('error', $e->getMessage()); |
797 | 797 | $result = false; |
798 | 798 | } |
@@ -356,8 +356,8 @@ |
||
356 | 356 | $path = []; |
357 | 357 | |
358 | 358 | $path['filter'] = $this->directory . '/' . $this->tableFilterLogs . '/' . $ip . '.' . $this->extension; |
359 | - $path['session'] = $this->directory . '/' . $this->tableSessions . '/' . $ip . '.' . $this->extension; |
|
360 | - $path['rule'] = $this->directory . '/' . $this->tableRuleList . '/' . $ip . '.' . $this->extension; |
|
359 | + $path['session'] = $this->directory . '/' . $this->tableSessions . '/' . $ip . '.' . $this->extension; |
|
360 | + $path['rule'] = $this->directory . '/' . $this->tableRuleList . '/' . $ip . '.' . $this->extension; |
|
361 | 361 | |
362 | 362 | return $path[$type] ?? ''; |
363 | 363 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | // @codeCoverageIgnoreStart |
304 | 304 | |
305 | - } catch(Exception $e) { |
|
305 | + } catch (Exception $e) { |
|
306 | 306 | return false; |
307 | 307 | } |
308 | 308 | |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | |
362 | 362 | // @codeCoverageIgnoreStart |
363 | 363 | |
364 | - } catch(Exception $e) { |
|
364 | + } catch (Exception $e) { |
|
365 | 365 | return false; |
366 | 366 | } |
367 | 367 | |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | |
415 | 415 | // @codeCoverageIgnoreStart |
416 | 416 | |
417 | - } catch(Exception $e) { |
|
417 | + } catch (Exception $e) { |
|
418 | 418 | return false; |
419 | 419 | } |
420 | 420 |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | default: |
209 | 209 | |
210 | 210 | // We also accept querying N days data from logs. For example: `past_365_days`. |
211 | - if (preg_match('/past_([0-9]+)_days/', $this->type, $matches) ) { |
|
211 | + if (preg_match('/past_([0-9]+)_days/', $this->type, $matches)) { |
|
212 | 212 | |
213 | 213 | $dayCount = $matches[1]; |
214 | 214 | $startDate = date('Ymd', strtotime('-' . $dayCount . ' days')); |
@@ -331,21 +331,21 @@ discard block |
||
331 | 331 | return []; |
332 | 332 | } |
333 | 333 | |
334 | - $results['captcha_chart_string'] = ''; // string |
|
335 | - $results['pageview_chart_string'] = ''; // string |
|
336 | - $results['captcha_success_count'] = 0; // integer |
|
337 | - $results['captcha_failure_count'] = 0; // integer |
|
338 | - $results['captcha_count'] = 0; // integer |
|
339 | - $results['pageview_count'] = 0; // integer |
|
340 | - $results['captcha_percentageage'] = 0; // integer |
|
334 | + $results['captcha_chart_string'] = ''; // string |
|
335 | + $results['pageview_chart_string'] = ''; // string |
|
336 | + $results['captcha_success_count'] = 0; // integer |
|
337 | + $results['captcha_failure_count'] = 0; // integer |
|
338 | + $results['captcha_count'] = 0; // integer |
|
339 | + $results['pageview_count'] = 0; // integer |
|
340 | + $results['captcha_percentageage'] = 0; // integer |
|
341 | 341 | $results['captcha_failure_percentage'] = 0; // integer |
342 | 342 | $results['captcha_success_percentage'] = 0; // integer |
343 | 343 | |
344 | - $results['action_ban_count'] = 0; // integer |
|
345 | - $results['action_temp_ban_count'] = 0; // integer |
|
346 | - $results['action_unban_count'] = 0; // integer |
|
347 | - $results['blacklist_count'] = 0; // integer |
|
348 | - $results['session_limit_count'] = 0; // integer |
|
344 | + $results['action_ban_count'] = 0; // integer |
|
345 | + $results['action_temp_ban_count'] = 0; // integer |
|
346 | + $results['action_unban_count'] = 0; // integer |
|
347 | + $results['blacklist_count'] = 0; // integer |
|
348 | + $results['session_limit_count'] = 0; // integer |
|
349 | 349 | |
350 | 350 | $ipdData = $this->getIpData(); |
351 | 351 | |
@@ -386,22 +386,22 @@ discard block |
||
386 | 386 | { |
387 | 387 | $periodData = $this->getPeriodData(); |
388 | 388 | |
389 | - $results['captcha_chart_string'] = ''; // string |
|
390 | - $results['pageview_chart_string'] = ''; // string |
|
391 | - $results['label_chart_string'] = ''; // string |
|
392 | - $results['captcha_success_count'] = 0; // integer |
|
393 | - $results['captcha_failure_count'] = 0; // integer |
|
394 | - $results['captcha_count'] = 0; // integer |
|
395 | - $results['pageview_count'] = 0; // integer |
|
396 | - $results['captcha_percentageage'] = 0; // integer |
|
389 | + $results['captcha_chart_string'] = ''; // string |
|
390 | + $results['pageview_chart_string'] = ''; // string |
|
391 | + $results['label_chart_string'] = ''; // string |
|
392 | + $results['captcha_success_count'] = 0; // integer |
|
393 | + $results['captcha_failure_count'] = 0; // integer |
|
394 | + $results['captcha_count'] = 0; // integer |
|
395 | + $results['pageview_count'] = 0; // integer |
|
396 | + $results['captcha_percentageage'] = 0; // integer |
|
397 | 397 | $results['captcha_failure_percentage'] = 0; // integer |
398 | 398 | $results['captcha_success_percentage'] = 0; // integer |
399 | 399 | |
400 | - $results['action_ban_count'] = 0; // integer |
|
401 | - $results['action_temp_ban_count'] = 0; // integer |
|
402 | - $results['action_unban_count'] = 0; // integer |
|
403 | - $results['blacklist_count'] = 0; // integer |
|
404 | - $results['session_limit_count'] = 0; // integer |
|
400 | + $results['action_ban_count'] = 0; // integer |
|
401 | + $results['action_temp_ban_count'] = 0; // integer |
|
402 | + $results['action_unban_count'] = 0; // integer |
|
403 | + $results['blacklist_count'] = 0; // integer |
|
404 | + $results['session_limit_count'] = 0; // integer |
|
405 | 405 | |
406 | 406 | if (!empty($periodData)) { |
407 | 407 | |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | } |
432 | 432 | |
433 | 433 | $results['captcha_chart_string'] = implode(',', $chartCaptcha); |
434 | - $results['pageview_chart_string']= implode(',', $chartPageview); |
|
434 | + $results['pageview_chart_string'] = implode(',', $chartPageview); |
|
435 | 435 | $results['captcha_success_chart_string'] = implode(',', $chartCaptchaSuccess); |
436 | 436 | $results['captcha_failure_chart_string'] = implode(',', $chartCaptchaFailure); |
437 | 437 | $results['label_chart_string'] = "'" . implode("','", $labels) . "'"; |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | $ip = $log['ip']; |
462 | 462 | $sessionId = $log['session_id']; |
463 | 463 | |
464 | - $this->ipDetail[$t][$ip]['session_id'][$sessionId ] = 1; |
|
464 | + $this->ipDetail[$t][$ip]['session_id'][$sessionId] = 1; |
|
465 | 465 | |
466 | 466 | if ($logActionCode === self::LOG_TEMPORARILY_BAN) { |
467 | 467 | $this->periodDetail[$t][$k]['action_temp_ban_count']++; |
@@ -100,10 +100,10 @@ |
||
100 | 100 | $record['session_id'] = substr($record['session_id'], 0, 4); |
101 | 101 | } |
102 | 102 | |
103 | - $data[0] = $record['ip'] ?? 'null'; |
|
104 | - $data[1] = $record['session_id'] ?? 'null'; |
|
103 | + $data[0] = $record['ip'] ?? 'null'; |
|
104 | + $data[1] = $record['session_id'] ?? 'null'; |
|
105 | 105 | $data[2] = $record['action_code'] ?? 'null'; |
106 | - $data[3] = $record['timesamp'] ?? 'null'; |
|
106 | + $data[3] = $record['timesamp'] ?? 'null'; |
|
107 | 107 | |
108 | 108 | file_put_contents($this->filePath, implode(',', $data) . "\n", FILE_APPEND | LOCK_EX); |
109 | 109 | } |