Completed
Branch 1.x (bc5d7e)
by Terry
07:07 queued 05:06
created
src/Shieldon/Component/Ip.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
             $this->setIp($ip);
70 70
         }
71 71
 
72
-        if (! filter_var($this->ip, FILTER_VALIDATE_IP)) {
72
+        if (!filter_var($this->ip, FILTER_VALIDATE_IP)) {
73 73
             return [
74 74
                 'status' => 'deny',
75 75
                 'code' => self::REASON_INVALID_IP,
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
      */
367 367
     public function setAllowedItem(string $string): void
368 368
     {
369
-        if (! in_array($string, $this->allowedList)) {
369
+        if (!in_array($string, $this->allowedList)) {
370 370
             array_push($this->allowedList, $string);
371 371
         }
372 372
     }
Please login to merge, or discard this patch.
src/Shieldon/Integration/Bootstrapper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
 
46 46
             $firewall = new Firewall($storage);
47 47
 
48
-            if (! empty($requestURI) && 0 === strpos($_SERVER['REQUEST_URI'], $requestURI)) {
48
+            if (!empty($requestURI) && 0 === strpos($_SERVER['REQUEST_URI'], $requestURI)) {
49 49
 
50 50
                 // Get into the Firewall Panel.
51 51
                 $controlPanel = new FirewallPanel($firewall);
Please login to merge, or discard this patch.
src/Shieldon/Firewall.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             $this->directory = rtrim($source, '\\/');
84 84
             $configFilePath = $this->directory . '/' . $this->filename;
85 85
 
86
-            if (! file_exists($configFilePath)) {
86
+            if (!file_exists($configFilePath)) {
87 87
 
88 88
                 $jsonString = file_get_contents(__DIR__ . '/../../config.json');
89 89
 
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
                     $host = '127.0.0.1';
231 231
                     $port = 6379;
232 232
 
233
-                    if (! empty($redisSetting['host'])) {
233
+                    if (!empty($redisSetting['host'])) {
234 234
                         $host = $redisSetting['host'];
235 235
                     }
236 236
 
237
-                    if (! empty($redisSetting['port'])) {
237
+                    if (!empty($redisSetting['port'])) {
238 238
                         $port = $redisSetting['port'];
239 239
                     }
240 240
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
                     $redis = new Redis();
243 243
                     $redis->connect($host, $port);
244 244
 
245
-                    if (! empty($redisSetting['auth'])) {
245
+                    if (!empty($redisSetting['auth'])) {
246 246
 
247 247
                         // @codeCoverageIgnoreStart
248 248
                         $redis->auth($redisSetting['auth']);
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
                     $this->shieldon->setDriver(new RedisDriver($redis));
254 254
 
255 255
                 // @codeCoverageIgnoreStart
256
-                } catch(RedisException $e) {
256
+                } catch (RedisException $e) {
257 257
                     $this->status = false;
258 258
 
259 259
                     echo $e->getMessage();
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
                     $this->shieldon->setDriver(new SqliteDriver($pdoInstance));
297 297
     
298 298
                 // @codeCoverageIgnoreStart
299
-                } catch(PDOException $e) {
299
+                } catch (PDOException $e) {
300 300
                     $this->status = false;
301 301
 
302 302
                     echo $e->getMessage();
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
                     // Create a PDO instance.
316 316
                     $pdoInstance = new PDO(
317 317
                         'mysql:host=' 
318
-                            . $mysqlSetting['host']   . ';dbname=' 
318
+                            . $mysqlSetting['host'] . ';dbname=' 
319 319
                             . $mysqlSetting['dbname'] . ';charset=' 
320 320
                             . $mysqlSetting['charset']
321 321
                         , (string) $mysqlSetting['user']
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
                     $this->shieldon->setDriver(new MysqlDriver($pdoInstance));
327 327
 
328 328
                 // @codeCoverageIgnoreStart
329
-                } catch(PDOException $e) {
329
+                } catch (PDOException $e) {
330 330
                     echo $e->getMessage();
331 331
                 }
332 332
                 // @codeCoverageIgnoreEnd
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
         $loggerSetting = $this->getOption('action', 'loggers');
345 345
 
346 346
         if ($loggerSetting['enable']) {
347
-            if (! empty($loggerSetting['config']['directory_path'])) {
347
+            if (!empty($loggerSetting['config']['directory_path'])) {
348 348
                 $this->shieldon->setLogger(new ActionLogger($loggerSetting['config']['directory_path']));
349 349
             }
350 350
         }
@@ -574,8 +574,8 @@  discard block
 block discarded – undo
574 574
 
575 575
         $messageTitle = 'Firewall Notification';
576 576
 
577
-        if (! empty($telegramSetting['enable'])) {
578
-            if (! empty($telegramSetting['confirm_test'])) {
577
+        if (!empty($telegramSetting['enable'])) {
578
+            if (!empty($telegramSetting['confirm_test'])) {
579 579
                 $apiKey = $telegramSetting['config']['api_key'] ?? '';
580 580
                 $channel = $telegramSetting['config']['channel'] ?? '';
581 581
                 $this->shieldon->setMessenger(
@@ -584,8 +584,8 @@  discard block
 block discarded – undo
584 584
             }
585 585
         }
586 586
 
587
-        if (! empty($linenotodySetting['enable'])) {
588
-            if (! empty($linenotodySetting['confirm_test'])) {
587
+        if (!empty($linenotodySetting['enable'])) {
588
+            if (!empty($linenotodySetting['confirm_test'])) {
589 589
                 $accessToken = $linenotodySetting['config']['access_token'] ?? '';
590 590
                 $this->shieldon->setMessenger(
591 591
                     new MessengerModule\LineNotify($accessToken)
@@ -593,8 +593,8 @@  discard block
 block discarded – undo
593 593
             }
594 594
         }
595 595
 
596
-        if (! empty($sendgridSetting['enable'])) {
597
-            if (! empty($sendgridSetting['confirm_test'])) {
596
+        if (!empty($sendgridSetting['enable'])) {
597
+            if (!empty($sendgridSetting['confirm_test'])) {
598 598
                 $apiKey = $sendgridSetting['config']['api_key'] ?? '';
599 599
                 $sender = $sendgridSetting['config']['sender'] ?? '';
600 600
                 $recipients = $sendgridSetting['config']['recipients'] ?? [];
@@ -611,8 +611,8 @@  discard block
 block discarded – undo
611 611
             }
612 612
         }
613 613
 
614
-        if (! empty($phpMailSetting['enable'])) {
615
-            if (! empty($phpMailSetting['confirm_test'])) {
614
+        if (!empty($phpMailSetting['enable'])) {
615
+            if (!empty($phpMailSetting['confirm_test'])) {
616 616
                 $sender = $phpMailSetting['config']['sender'] ?? '';
617 617
                 $recipients = $phpMailSetting['config']['recipients'] ?? [];
618 618
 
@@ -628,8 +628,8 @@  discard block
 block discarded – undo
628 628
             }
629 629
         }
630 630
 
631
-        if (! empty($smtpSetting['enable'])) {
632
-            if (! empty($smtpSetting['confirm_test'])) {
631
+        if (!empty($smtpSetting['enable'])) {
632
+            if (!empty($smtpSetting['confirm_test'])) {
633 633
                 $sender = $smtpSetting['config']['sender'] ?? '';
634 634
                 $recipients = $smtpSetting['config']['recipients'] ?? [];
635 635
                 $host = $smtpSetting['config']['host'] ?? '';
@@ -649,8 +649,8 @@  discard block
 block discarded – undo
649 649
             }
650 650
         }
651 651
 
652
-        if (! empty($mailgunSetting['enable'])) {
653
-            if (! empty($mailgunSetting['confirm_test'])) {
652
+        if (!empty($mailgunSetting['enable'])) {
653
+            if (!empty($mailgunSetting['confirm_test'])) {
654 654
                 $apiKey = $mailgunSetting['config']['api_key'] ?? '';
655 655
                 $domain = $mailgunSetting['config']['domain_name'] ?? '';
656 656
                 $sender = $mailgunSetting['config']['sender'] ?? '';
@@ -668,8 +668,8 @@  discard block
 block discarded – undo
668 668
             }
669 669
         }
670 670
 
671
-        if (! empty($rocketchatSetting['enable'])) {
672
-            if (! empty($rocketchatSetting['confirm_test'])) {
671
+        if (!empty($rocketchatSetting['enable'])) {
672
+            if (!empty($rocketchatSetting['confirm_test'])) {
673 673
                 $serverUrl = $rocketchatSetting['config']['server_url'] ?? '';
674 674
                 $userId = $rocketchatSetting['config']['user_id'] ?? '';
675 675
                 $accessToken = $rocketchatSetting['config']['access_token'] ?? '';
@@ -683,8 +683,8 @@  discard block
 block discarded – undo
683 683
             }
684 684
         }
685 685
 
686
-        if (! empty($slackSetting['enable'])) {
687
-            if (! empty($slackSetting['confirm_test'])) {
686
+        if (!empty($slackSetting['enable'])) {
687
+            if (!empty($slackSetting['confirm_test'])) {
688 688
                 $botToken = $slackSetting['config']['bot_token'] ?? '';
689 689
                 $channel = $slackSetting['config']['channel'] ?? '';
690 690
 
@@ -694,8 +694,8 @@  discard block
 block discarded – undo
694 694
             }
695 695
         }
696 696
 
697
-        if (! empty($slackWebhookSetting['enable'])) {
698
-            if (! empty($slackWebhookSetting['confirm_test'])) {
697
+        if (!empty($slackWebhookSetting['enable'])) {
698
+            if (!empty($slackWebhookSetting['confirm_test'])) {
699 699
                 $webhookUrl = $slackWebhookSetting['config']['webhook_url'] ?? '';
700 700
 
701 701
                 $this->shieldon->setMessenger(
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
     protected function setIptablesWatchingFolder(): void
780 780
     {
781 781
         $iptablesSetting = $this->getOption('config', 'iptables');
782
-        $this->shieldon->setProperty('iptables_watching_folder',  $iptablesSetting['watching_folder']);
782
+        $this->shieldon->setProperty('iptables_watching_folder', $iptablesSetting['watching_folder']);
783 783
     }
784 784
 
785 785
     /**
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
 
817 817
             $lastResetTime = $cronjobSetting['config']['last_update'];
818 818
 
819
-            if (! empty($lastResetTime) ) {
819
+            if (!empty($lastResetTime)) {
820 820
                 $lastResetTime = strtotime($lastResetTime);
821 821
             } else {
822 822
                 // @codeCoverageIgnoreStart
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
     {
848 848
         $excludedUrls = $this->getOption('excluded_urls');
849 849
 
850
-        if (! empty($excludedUrls)) {
850
+        if (!empty($excludedUrls)) {
851 851
             $list = array_column($excludedUrls, 'url');
852 852
 
853 853
             $this->shieldon->setExcludedUrls($list);
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
 
868 868
         if ($xssProtectionOptions['post']) {
869 869
             $this->shieldon->setClosure('xss_post', function() use ($xssFilter) {
870
-                if (! empty($_POST)) {
870
+                if (!empty($_POST)) {
871 871
                     foreach (array_keys($_POST) as $k) {
872 872
                         $_POST[$k] = $xssFilter->clean($_POST[$k]);
873 873
                     }
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
 
878 878
         if ($xssProtectionOptions['get']) {
879 879
             $this->shieldon->setClosure('xss_get', function() use ($xssFilter) {
880
-                if (! empty($_GET)) {
880
+                if (!empty($_GET)) {
881 881
                     foreach (array_keys($_GET) as $k) {
882 882
                         $_GET[$k] = $xssFilter->clean($_GET[$k]);
883 883
                     }
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 
888 888
         if ($xssProtectionOptions['cookie']) {
889 889
             $this->shieldon->setClosure('xss_cookie', function() use ($xssFilter) {
890
-                if (! empty($_COOKIE)) {
890
+                if (!empty($_COOKIE)) {
891 891
                     foreach (array_keys($_COOKIE) as $k) {
892 892
                         $_COOKIE[$k] = $xssFilter->clean($_COOKIE[$k]);
893 893
                     }
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
 
898 898
         $xssProtectedList = $this->getOption('xss_protected_list');
899 899
 
900
-        if (! empty($xssProtectedList)) {
900
+        if (!empty($xssProtectedList)) {
901 901
         
902 902
             $this->shieldon->setClosure('xss_protection', function() use ($xssFilter, $xssProtectedList) {
903 903
 
@@ -908,21 +908,21 @@  discard block
 block discarded – undo
908 908
 
909 909
                         case 'get':
910 910
 
911
-                            if (! empty($_GET[$k])) {
911
+                            if (!empty($_GET[$k])) {
912 912
                                 $_GET[$k] = $xssFilter->clean($_GET[$k]);
913 913
                             }
914 914
                             break;
915 915
     
916 916
                         case 'post':
917 917
     
918
-                            if (! empty($_POST[$k])) {
918
+                            if (!empty($_POST[$k])) {
919 919
                                 $_POST[$k] = $xssFilter->clean($_POST[$k]);
920 920
                             }
921 921
                             break;
922 922
     
923 923
                         case 'cookie':
924 924
 
925
-                            if (! empty($_COOKIE[$k])) {
925
+                            if (!empty($_COOKIE[$k])) {
926 926
                                 $_COOKIE[$k] = $xssFilter->clean($_COOKIE[$k]);
927 927
                             }
928 928
                             break;
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
     {
944 944
         $authenticateList = $this->getOption('www_authenticate');
945 945
 
946
-        if (! empty($authenticateList)) {
946
+        if (!empty($authenticateList)) {
947 947
 
948 948
             $authHandler = new httpAuthentication();
949 949
 
@@ -964,10 +964,10 @@  discard block
 block discarded – undo
964 964
         $allowedList = [];
965 965
         $deniedList = [];
966 966
 
967
-        if (! empty($ipList)) {
967
+        if (!empty($ipList)) {
968 968
             foreach ($ipList as $ip) {
969 969
 
970
-                if (0 === strpos($this->shieldon->getCurrentUrl(), $ip['url']) ) {
970
+                if (0 === strpos($this->shieldon->getCurrentUrl(), $ip['url'])) {
971 971
     
972 972
                     if ('allow' === $ip['rule']) {
973 973
                         $allowedList[] = $ip['ip'];
@@ -980,11 +980,11 @@  discard block
 block discarded – undo
980 980
             }
981 981
         }
982 982
 
983
-        if (! empty($allowedList)) {
983
+        if (!empty($allowedList)) {
984 984
             $this->shieldon->component['Ip']->setAllowedList($allowedList);
985 985
         }
986 986
 
987
-        if (! empty($deniedList)) {
987
+        if (!empty($deniedList)) {
988 988
             $this->shieldon->component['Ip']->setDeniedList($deniedList);
989 989
         }
990 990
     }
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
     {
999 999
         $ui = $this->getOption('dialog_ui');
1000 1000
 
1001
-        if (! empty($ui)) {
1001
+        if (!empty($ui)) {
1002 1002
             $_SESSION['SHIELDON_UI_LANG'] = $ui['lang'];
1003 1003
             $this->shieldon->setDialogUI($this->getOption('dialog_ui'));
1004 1004
         }
@@ -1017,11 +1017,11 @@  discard block
 block discarded – undo
1017 1017
      */
1018 1018
     private function getOption(string $option, string $section = '')
1019 1019
     {
1020
-        if (! empty($this->configuration[$section][$option])) {
1020
+        if (!empty($this->configuration[$section][$option])) {
1021 1021
             return $this->configuration[$section][$option];
1022 1022
         }
1023 1023
 
1024
-        if (! empty($this->configuration[$option]) && $section === '') {
1024
+        if (!empty($this->configuration[$option]) && $section === '') {
1025 1025
             return $this->configuration[$option];
1026 1026
         }
1027 1027
 
@@ -1037,8 +1037,8 @@  discard block
 block discarded – undo
1037 1037
     {
1038 1038
         $configFilePath = $this->directory . '/' . $this->filename;
1039 1039
 
1040
-        if (! file_exists($configFilePath)) {
1041
-            if (! is_dir($this->directory)) {
1040
+        if (!file_exists($configFilePath)) {
1041
+            if (!is_dir($this->directory)) {
1042 1042
                 // @codeCoverageIgnoreStart
1043 1043
                 $originalUmask = umask(0);
1044 1044
                 @mkdir($this->directory, 0777, true);
Please login to merge, or discard this patch.
templates/panel/action_log_last_month.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 ?>
15 15
 
16 16
 <div class="so-dashboard">
17
-    <?php if (! empty($period_data)) : ?>
17
+    <?php if (!empty($period_data)) : ?>
18 18
     <div class="so-flex">
19 19
         <div class="so-board">
20 20
             <div class="board-field left">
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
                 </tr>
86 86
             </thead>
87 87
             <tbody>
88
-                <?php if (! empty($ip_details)) : ?>
89
-                <?php foreach($ip_details as $ip => $ipInfo) : ?>
88
+                <?php if (!empty($ip_details)) : ?>
89
+                <?php foreach ($ip_details as $ip => $ipInfo) : ?>
90 90
                 <tr>
91 91
                     <td>
92 92
                         <?php if ($this->mode === 'demo') : ?>
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         </table>
109 109
     </div>
110 110
     <div class="so-timezone">
111
-        <?php if (! empty($last_cached_time)) : ?>
111
+        <?php if (!empty($last_cached_time)) : ?>
112 112
             <?php _e('panel', 'log_label_cache_time', 'Report generated time'); ?>: <strong class="text-info"><?php echo $last_cached_time; ?></strong>
113 113
             &nbsp;&nbsp;&nbsp;&nbsp; 
114 114
         <?php endif; ?>
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
 <?php
120 120
 
121
-    if (! empty($period_data)) {
121
+    if (!empty($period_data)) {
122 122
         $data['period_data'] = $period_data;
123 123
         $this->_include('panel/js/chart', $data);
124 124
     }
Please login to merge, or discard this patch.
templates/panel/action_log_this_month.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 ?>
15 15
 
16 16
 <div class="so-dashboard">
17
-    <?php if (! empty($period_data)) : ?>
17
+    <?php if (!empty($period_data)) : ?>
18 18
     <div class="so-flex">
19 19
         <div class="so-board">
20 20
             <div class="board-field left">
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
                 </tr>
86 86
             </thead>
87 87
             <tbody>
88
-                <?php if (! empty($ip_details)) : ?>
89
-                <?php foreach($ip_details as $ip => $ipInfo) : ?>
88
+                <?php if (!empty($ip_details)) : ?>
89
+                <?php foreach ($ip_details as $ip => $ipInfo) : ?>
90 90
                 <tr>
91 91
                     <td>
92 92
                         <?php if ($this->mode === 'demo') : ?>
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         </table>
109 109
     </div>
110 110
     <div class="so-timezone">
111
-        <?php if (! empty($last_cached_time)) : ?>
111
+        <?php if (!empty($last_cached_time)) : ?>
112 112
             <?php _e('panel', 'log_label_cache_time', 'Report generated time'); ?>: <strong class="text-info"><?php echo $last_cached_time; ?></strong>
113 113
             &nbsp;&nbsp;&nbsp;&nbsp; 
114 114
         <?php endif; ?>
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
 <?php
120 120
 
121
-    if (! empty($period_data)) {
121
+    if (!empty($period_data)) {
122 122
         $data['period_data'] = $period_data;
123 123
         $this->_include('panel/js/chart', $data);
124 124
     }
Please login to merge, or discard this patch.
templates/panel/action_log_yesterday.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 ?>
15 15
 
16 16
 <div class="so-dashboard">
17
-    <?php if (! empty($period_data)) : ?>
17
+    <?php if (!empty($period_data)) : ?>
18 18
     <div class="so-flex">
19 19
         <div class="so-board">
20 20
             <div class="board-field left">
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
                 </tr>
86 86
             </thead>
87 87
             <tbody>
88
-                <?php if (! empty($ip_details)) : ?>
89
-                <?php foreach($ip_details as $ip => $ipInfo) : ?>
88
+                <?php if (!empty($ip_details)) : ?>
89
+                <?php foreach ($ip_details as $ip => $ipInfo) : ?>
90 90
                 <tr>
91 91
                     <td>
92 92
                         <?php if ($this->mode === 'demo') : ?>
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         </table>
109 109
     </div>
110 110
     <div class="so-timezone">
111
-        <?php if (! empty($last_cached_time)) : ?>
111
+        <?php if (!empty($last_cached_time)) : ?>
112 112
             <?php _e('panel', 'log_label_cache_time', 'Report generated time'); ?>: <strong class="text-info"><?php echo $last_cached_time; ?></strong>
113 113
             &nbsp;&nbsp;&nbsp;&nbsp; 
114 114
         <?php endif; ?>
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
 <?php
120 120
 
121
-    if (! empty($period_data)) {
121
+    if (!empty($period_data)) {
122 122
         $data['period_data'] = $period_data;
123 123
         $this->_include('panel/js/chart', $data);
124 124
     }
Please login to merge, or discard this patch.