Completed
Branch 1.x (bc5d7e)
by Terry
07:07 queued 05:06
created
src/Shieldon/Mock/Messenger.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,8 +33,8 @@
 block discarded – undo
33 33
      */
34 34
     public function send(string $message): bool
35 35
     {
36
-        if (! empty($message)) {
37
-            echo "\n" . $this->provider() . "\n";;
36
+        if (!empty($message)) {
37
+            echo "\n" . $this->provider() . "\n"; ;
38 38
             echo "\n--- BEGIN - Mock of sending message ---\n\n";
39 39
             echo $message;
40 40
             echo "\n--- END - Mock of sending message ---\n";
Please login to merge, or discard this patch.
src/Shieldon/helpers.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     // If we don't get the string from the localization file, use placeholder instead.
75 75
     $resultString = $placeholder;
76 76
 
77
-    if (! empty($i18n[$filename][$langcode])) {
77
+    if (!empty($i18n[$filename][$langcode])) {
78 78
         $resultString = $i18n[$filename][$langcode];
79 79
     }
80 80
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
         $masked = implode('.', $tmp);
128 128
 
129 129
     } else {
130
-        $masked =  str_repeat('*', strlen($str) - 6) . substr(str, -6);
130
+        $masked = str_repeat('*', strlen($str) - 6) . substr(str, -6);
131 131
     }
132 132
 
133 133
     return $masked;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
     $cpuLoads = @sys_getloadavg();
155 155
     $cpuCores = trim(@shell_exec("grep -P '^processor' /proc/cpuinfo|wc -l"));
156 156
 
157
-    if (! empty($cpuCores) && ! empty($cpuLoads)) {
157
+    if (!empty($cpuCores) && !empty($cpuLoads)) {
158 158
         $return = round($cpuLoads[1] / ($cpuCores + 1) * 100, 0) . '%';
159 159
     }
160 160
     return $return;
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 
180 180
     $freeResult = explode("\n", trim(@shell_exec('free')));
181 181
 
182
-    if (! empty($freeResult)) {
182
+    if (!empty($freeResult)) {
183 183
         $parsed = preg_split("/[\s]+/", $freeResult[1]);
184 184
         $return = round($parsed[2] / $parsed[1] * 100, 0) . '%';
185 185
     }
Please login to merge, or discard this patch.
src/Shieldon/Log/ActionLogParsedCache.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@
 block discarded – undo
119 119
                 $keepCache = false;
120 120
             }
121 121
 
122
-            if (! $keepCache) {
122
+            if (!$keepCache) {
123 123
                 $data = [];
124 124
             }
125 125
             // @codeCoverageIgnoreEnd
Please login to merge, or discard this patch.
src/Shieldon/Log/ActionLogger.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -94,14 +94,14 @@  discard block
 block discarded – undo
94 94
      */
95 95
     public function add(array $record): void
96 96
     {
97
-        if (! empty($record['session_id'])) {
97
+        if (!empty($record['session_id'])) {
98 98
             $record['session_id'] = substr($record['session_id'], 0, 4);
99 99
         }
100 100
 
101
-        $data[0] = $record['ip']          ?? 'null';
102
-        $data[1] = $record['session_id']  ?? 'null';
101
+        $data[0] = $record['ip'] ?? 'null';
102
+        $data[1] = $record['session_id'] ?? 'null';
103 103
         $data[2] = $record['action_code'] ?? 'null';
104
-        $data[3] = $record['timesamp']    ?? 'null';
104
+        $data[3] = $record['timesamp'] ?? 'null';
105 105
 
106 106
         file_put_contents($this->filePath, implode(',', $data) . "\n", FILE_APPEND | LOCK_EX);
107 107
     }
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
 
132 132
                 $logFile = fopen($this->filePath, 'r');
133 133
 
134
-                while (! feof($logFile)) {
134
+                while (!feof($logFile)) {
135 135
                     $line = fgets($logFile);
136 136
 
137
-                    if (! empty($line)) {
137
+                    if (!empty($line)) {
138 138
                         $data = explode(',', trim($line));
139 139
                     }
140 140
         
141
-                    if (! empty($data[0])) {
141
+                    if (!empty($data[0])) {
142 142
                         $results[] = [
143 143
                             'ip'          => $data[0],
144 144
                             'session_id'  => $data[1],
@@ -173,14 +173,14 @@  discard block
 block discarded – undo
173 173
 
174 174
                     $logFile = fopen($thisDayLogFile, 'r');
175 175
 
176
-                    while (! feof($logFile)) {
176
+                    while (!feof($logFile)) {
177 177
                         $line = fgets($logFile);
178 178
 
179
-                        if (! empty($line)) {
179
+                        if (!empty($line)) {
180 180
                             $data = explode(',', trim($line));
181 181
                         }
182 182
 
183
-                        if (! empty($data[0])) {
183
+                        if (!empty($data[0])) {
184 184
                             $results[] = [
185 185
                                 'ip'          => $data[0],
186 186
                                 'session_id'  => $data[1],
@@ -207,14 +207,14 @@  discard block
 block discarded – undo
207 207
     {
208 208
         $result = true;
209 209
 
210
-        if (! is_dir($this->directory)) {
210
+        if (!is_dir($this->directory)) {
211 211
             $originalUmask = umask(0);
212 212
             $result = @mkdir($this->directory, 0777, true);
213 213
             umask($originalUmask);
214 214
         }
215 215
 
216 216
         // @codeCoverageIgnoreStart
217
-        if (! is_writable($this->directory)) {
217
+        if (!is_writable($this->directory)) {
218 218
             throw new RuntimeException('The directory usded by ActionLogger must be writable. (' . $this->directory . ')');
219 219
         }
220 220
         // @codeCoverageIgnoreEnd
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
             $it = new RecursiveDirectoryIterator($this->directory, RecursiveDirectoryIterator::SKIP_DOTS);
246 246
             $files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
247 247
 
248
-            foreach($files as $file) {
248
+            foreach ($files as $file) {
249 249
                 if ($file->isDir()) {
250 250
                     // @codeCoverageIgnoreStart
251 251
                     rmdir($file->getRealPath());
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
             $it = new RecursiveDirectoryIterator($this->directory, RecursiveDirectoryIterator::SKIP_DOTS);
276 276
             $files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
277 277
 
278
-            foreach($files as $file) {
278
+            foreach ($files as $file) {
279 279
                 if ($file->isFile()) {
280 280
                     $key = $file->getBasename('.log');
281 281
                     $size = $file->getSize();
Please login to merge, or discard this patch.
src/Shieldon/Log/ActionLogParser.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      */
88 88
     public function __construct(string $directory = '') 
89 89
     {
90
-        if (! isset($this->logger)) {
90
+        if (!isset($this->logger)) {
91 91
             $this->logger = new Logger($directory);
92 92
         }
93 93
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
             default:
207 207
 
208 208
                 // We also accept querying N days data from logs. For example: `past_365_days`.
209
-                if (preg_match('/past_([0-9]+)_days/', $this->type, $matches) ) {
209
+                if (preg_match('/past_([0-9]+)_days/', $this->type, $matches)) {
210 210
 
211 211
                     $dayCount = $matches[1];
212 212
                     $startDate = date('Ymd', strtotime('-' . $dayCount . ' days'));
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
         // Fetch data from log files.
232 232
         $logs = $this->logger->get($startDate, $endDate);
233 233
 
234
-        foreach($logs as $log) {
234
+        foreach ($logs as $log) {
235 235
 
236 236
             $logTimesamp = (int) $log['timesamp'];
237 237
             $logIp = $log['ip'];
@@ -252,12 +252,12 @@  discard block
 block discarded – undo
252 252
 
253 253
                     // Initialize all the counters.
254 254
                     foreach ($this->fields as $field) {
255
-                        if (! isset($this->periodDetail[$t][$k][$field])) {
255
+                        if (!isset($this->periodDetail[$t][$k][$field])) {
256 256
                             $this->periodDetail[$t][$k][$field] = 0;
257 257
                         }
258 258
 
259 259
                         if ($logTimesamp >= $detailTimesampBegin && $logTimesamp < $detailTimesampEnd) {
260
-                            if (! isset($this->ipDetail[$t][$logIp][$field])) {
260
+                            if (!isset($this->ipDetail[$t][$logIp][$field])) {
261 261
                                 $this->ipDetail[$t][$logIp][$field] = 0;
262 262
                             }
263 263
                         }
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
      */
298 298
     public function getPeriodData()
299 299
     {
300
-        if (! empty($this->periodDetail[$this->type])) {
300
+        if (!empty($this->periodDetail[$this->type])) {
301 301
             return $this->periodDetail[$this->type];
302 302
         }
303 303
         return [];
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
      */
311 311
     public function getIpData()
312 312
     {
313
-        if (! empty($this->ipDetail[$this->type])) {
313
+        if (!empty($this->ipDetail[$this->type])) {
314 314
             return $this->ipDetail[$this->type];
315 315
         }
316 316
         return [];
@@ -329,25 +329,25 @@  discard block
 block discarded – undo
329 329
             return [];
330 330
         }
331 331
 
332
-        $results['captcha_chart_string']  = '';     // string
333
-        $results['pageview_chart_string'] = '';     // string
334
-        $results['captcha_success_count'] = 0;      // integer
335
-        $results['captcha_failure_count'] = 0;      // integer
336
-        $results['captcha_count'] = 0;              // integer
337
-        $results['pageview_count'] = 0;             // integer
338
-        $results['captcha_percentageage'] = 0;      // integer
332
+        $results['captcha_chart_string']  = ''; // string
333
+        $results['pageview_chart_string'] = ''; // string
334
+        $results['captcha_success_count'] = 0; // integer
335
+        $results['captcha_failure_count'] = 0; // integer
336
+        $results['captcha_count'] = 0; // integer
337
+        $results['pageview_count'] = 0; // integer
338
+        $results['captcha_percentageage'] = 0; // integer
339 339
         $results['captcha_failure_percentage'] = 0; // integer
340 340
         $results['captcha_success_percentage'] = 0; // integer
341 341
 
342
-        $results['action_ban_count'] = 0;           // integer
343
-        $results['action_temp_ban_count'] = 0;      // integer
344
-        $results['action_unban_count'] = 0;         // integer
345
-        $results['blacklist_count'] = 0;            // integer
346
-        $results['session_limit_count'] = 0;        // integer
342
+        $results['action_ban_count'] = 0; // integer
343
+        $results['action_temp_ban_count'] = 0; // integer
344
+        $results['action_unban_count'] = 0; // integer
345
+        $results['blacklist_count'] = 0; // integer
346
+        $results['session_limit_count'] = 0; // integer
347 347
 
348 348
         $ipdData = $this->getIpData();
349 349
 
350
-        if (! empty($ipdData)) {
350
+        if (!empty($ipdData)) {
351 351
 
352 352
             foreach ($ipdData as $ipKey => $ipInfo) {
353 353
 
@@ -384,24 +384,24 @@  discard block
 block discarded – undo
384 384
     {
385 385
         $periodData = $this->getPeriodData();
386 386
 
387
-        $results['captcha_chart_string']  = '';     // string
388
-        $results['pageview_chart_string'] = '';     // string
389
-        $results['label_chart_string'] = '';        // string
390
-        $results['captcha_success_count'] = 0;      // integer
391
-        $results['captcha_failure_count'] = 0;      // integer
392
-        $results['captcha_count'] = 0;              // integer
393
-        $results['pageview_count'] = 0;             // integer
394
-        $results['captcha_percentageage'] = 0;      // integer
387
+        $results['captcha_chart_string']  = ''; // string
388
+        $results['pageview_chart_string'] = ''; // string
389
+        $results['label_chart_string'] = ''; // string
390
+        $results['captcha_success_count'] = 0; // integer
391
+        $results['captcha_failure_count'] = 0; // integer
392
+        $results['captcha_count'] = 0; // integer
393
+        $results['pageview_count'] = 0; // integer
394
+        $results['captcha_percentageage'] = 0; // integer
395 395
         $results['captcha_failure_percentage'] = 0; // integer
396 396
         $results['captcha_success_percentage'] = 0; // integer
397 397
 
398
-        $results['action_ban_count'] = 0;           // integer
399
-        $results['action_temp_ban_count'] = 0;      // integer
400
-        $results['action_unban_count'] = 0;         // integer
401
-        $results['blacklist_count'] = 0;            // integer
402
-        $results['session_limit_count'] = 0;        // integer
398
+        $results['action_ban_count'] = 0; // integer
399
+        $results['action_temp_ban_count'] = 0; // integer
400
+        $results['action_unban_count'] = 0; // integer
401
+        $results['blacklist_count'] = 0; // integer
402
+        $results['session_limit_count'] = 0; // integer
403 403
 
404
-        if (! empty($periodData)) {
404
+        if (!empty($periodData)) {
405 405
 
406 406
             $chartCaptcha = [];
407 407
             $chartPageview = [];
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
             }
430 430
 
431 431
             $results['captcha_chart_string'] = implode(',', $chartCaptcha);
432
-            $results['pageview_chart_string']= implode(',', $chartPageview);
432
+            $results['pageview_chart_string'] = implode(',', $chartPageview);
433 433
             $results['captcha_success_chart_string'] = implode(',', $chartCaptchaSuccess);
434 434
             $results['captcha_failure_chart_string'] = implode(',', $chartCaptchaFailure);
435 435
             $results['label_chart_string'] = "'" . implode("','", $labels) . "'";
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
         $ip = $log['ip'];
460 460
         $sessionId = $log['session_id'];
461 461
 
462
-        $this->ipDetail[$t][$ip]['session_id'][$sessionId ] = 1;
462
+        $this->ipDetail[$t][$ip]['session_id'][$sessionId] = 1;
463 463
 
464 464
         if ($logActionCode === self::LOG_TEMPORARILY_BAN) {
465 465
             $this->periodDetail[$t][$k]['action_temp_ban_count']++;
Please login to merge, or discard this patch.
src/Shieldon/Security/httpAuthentication.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public function set(array $protectedUrlList = []): void
76 76
     {
77
-        if (! empty($protectedUrlList)) {
77
+        if (!empty($protectedUrlList)) {
78 78
             $this->protectedUrlList = $protectedUrlList;
79 79
         }
80 80
     }
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
             if (0 === strpos($this->currentUrl, $urlInfo['url'])) {
96 96
 
97 97
                 // Prompt a window to ask for username and password.
98
-                if (! isset($_SERVER['PHP_AUTH_USER']) || ! isset($_SERVER['PHP_AUTH_PW'])) {
98
+                if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) {
99 99
                     header('WWW-Authenticate: Basic realm="' . $this->realm . '"');
100 100
                     header('HTTP/1.0 401 Unauthorized');
101 101
                     die('Permission required.');
Please login to merge, or discard this patch.
src/Shieldon/Security/Xss.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -90,13 +90,13 @@  discard block
 block discarded – undo
90 90
 
91 91
         $this->deniedRegexList = [
92 92
             'javascript\s*:',
93
-            '\bon\w+=\S+(?=.*>)',       // Inline JavaScript.
93
+            '\bon\w+=\S+(?=.*>)', // Inline JavaScript.
94 94
             '(document|(document\.)?window)\.(location|on\w*)',
95 95
             'expression\s*(\(|&\#40;)', // CSS and IE
96
-            'vbscript\s*:',             // IE, surprise!
97
-            'wscript\s*:',              // IE
98
-            'jscript\s*:',              // IE
99
-            'vbs\s*:',                  // IE
96
+            'vbscript\s*:', // IE, surprise!
97
+            'wscript\s*:', // IE
98
+            'jscript\s*:', // IE
99
+            'vbs\s*:', // IE
100 100
             'Redirect\s+30\d:',
101 101
             "([\"'])?data\s*:[^\\1]*?base64[^\\1]*?,[^\\1]*?\\1?",
102 102
         ];
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
          */
224 224
         $words = [
225 225
             'javascript', 'expression', 'vbscript', 'jscript', 'wscript',
226
-            'vbs',        'script',     'base64',   'applet',  'alert', 
227
-            'document',   'write',      'cookie',   'window',  'confirm',
228
-            'prompt',     'eval',
226
+            'vbs', 'script', 'base64', 'applet', 'alert', 
227
+            'document', 'write', 'cookie', 'window', 'confirm',
228
+            'prompt', 'eval',
229 229
         ];
230 230
 
231 231
         foreach ($words as $word) {
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
                 );
281 281
             }
282 282
 
283
-        } while($original !== $str);
283
+        } while ($original !== $str);
284 284
 
285 285
         unset($original);
286 286
 
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
         $originExif = @exif_read_data($imageAbsPath);
394 394
         $filteredExif = [];
395 395
 
396
-        if (! empty($originExif)) {
396
+        if (!empty($originExif)) {
397 397
             $filteredExif = $this->clean($originExif, true);
398 398
         }
399 399
 
@@ -620,21 +620,21 @@  discard block
 block discarded – undo
620 620
             "'", '"', '&', '$', '#',
621 621
             '{', '}', '[', ']', '=',
622 622
             ';', '?', '%20', '%22',
623
-            '%3c',		// <
624
-            '%253c',	// <
625
-            '%3e',		// >
626
-            '%0e',		// >
627
-            '%28',		// (
628
-            '%29',		// )
629
-            '%2528',	// (
630
-            '%26',		// &
631
-            '%24',		// $
632
-            '%3f',		// ?
633
-            '%3b',		// ;
623
+            '%3c', // <
624
+            '%253c', // <
625
+            '%3e', // >
626
+            '%0e', // >
627
+            '%28', // (
628
+            '%29', // )
629
+            '%2528', // (
630
+            '%26', // &
631
+            '%24', // $
632
+            '%3f', // ?
633
+            '%3b', // ;
634 634
             '%3d'		// =
635 635
         ];
636 636
 
637
-        if (! $relativePath) {
637
+        if (!$relativePath) {
638 638
             $bad[] = './';
639 639
             $bad[] = '/';
640 640
         }
@@ -676,19 +676,19 @@  discard block
 block discarded – undo
676 676
     protected function sanitizeNaughtyHtml(array $matches): string
677 677
     {
678 678
         static $naughtyTags = [
679
-            'alert',    'prompt', 'confirm',    'applet',  'audio',
680
-            'basefont', 'base',   'behavior',   'bgsound', 'blink', 
681
-            'body',     'embed',  'expression', 'form',    'frameset', 
682
-            'frame',    'head',   'html',       'ilayer',  'iframe', 
683
-            'input',    'button', 'select',     'isindex', 'layer', 
684
-            'link',     'meta',   'keygen',     'object',  'plaintext',
685
-            'style',    'script', 'textarea',   'title',   'math',
686
-            'video',    'svg',    'xml',        'xss',
679
+            'alert', 'prompt', 'confirm', 'applet', 'audio',
680
+            'basefont', 'base', 'behavior', 'bgsound', 'blink', 
681
+            'body', 'embed', 'expression', 'form', 'frameset', 
682
+            'frame', 'head', 'html', 'ilayer', 'iframe', 
683
+            'input', 'button', 'select', 'isindex', 'layer', 
684
+            'link', 'meta', 'keygen', 'object', 'plaintext',
685
+            'style', 'script', 'textarea', 'title', 'math',
686
+            'video', 'svg', 'xml', 'xss',
687 687
         ];
688 688
 
689 689
         static $evilAttributes = [
690
-            'on\w+', 'style',      'xmlns',     'seekSegmentTime', 
691
-            'form',  'xlink:href', 'FSCommand', 'formaction',
690
+            'on\w+', 'style', 'xmlns', 'seekSegmentTime', 
691
+            'form', 'xlink:href', 'FSCommand', 'formaction',
692 692
         ];
693 693
 
694 694
         // First, escape unclosed tags
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
                 // of numerous XSS issues we've had.
722 722
                 $matches['attributes'] = preg_replace('#^[^a-z]+#i', '', $matches['attributes']);
723 723
 
724
-                if (! preg_match($attributesPattern, $matches['attributes'], $attribute, PREG_OFFSET_CAPTURE)) {
724
+                if (!preg_match($attributesPattern, $matches['attributes'], $attribute, PREG_OFFSET_CAPTURE)) {
725 725
                     // No (valid) attribute found? Discard everything else inside the tag
726 726
                     break;
727 727
                 }
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 
746 746
             $attributes = empty($attributes)
747 747
                 ? ''
748
-                : ' '.implode(' ', $attributes);
748
+                : ' ' . implode(' ', $attributes);
749 749
             return '<' . $matches['slash'] . $matches['tagName'] . $attributes . '>';
750 750
         }
751 751
 
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 
901 901
 		$version = (string) $version;
902 902
 
903
-		if (! isset($_isPHP[$version])) {
903
+		if (!isset($_isPHP[$version])) {
904 904
 			$_isPHP[$version] = version_compare(PHP_VERSION, $version, '>=');
905 905
 		}
906 906
 
Please login to merge, or discard this patch.
src/Shieldon/Security/Csrf.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      *
30 30
      * @var string
31 31
      */
32
-    protected $hash	= '';
32
+    protected $hash = '';
33 33
 
34 34
     /**
35 35
      * Token name.
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         // Let's start checking process.
80 80
 
81 81
         // Do the tokens exist in both the _POST and _SESSION?
82
-        if (! isset($_POST[$this->name], $_SESSION[$this->name])) {
82
+        if (!isset($_POST[$this->name], $_SESSION[$this->name])) {
83 83
             return false;
84 84
         }
85 85
 
Please login to merge, or discard this patch.
src/Shieldon/Driver/RedisDriver.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     {
53 53
         $this->channel = $channel;
54 54
 
55
-        if (! empty($this->channel)) {
55
+        if (!empty($this->channel)) {
56 56
             $this->tableFilterLogs = $this->channel . ':shieldon_filter_logs';
57 57
             $this->tableRuleList = $this->channel . ':shieldon_rule_list';
58 58
             $this->tableSessions = $this->channel . ':shieldon_sessions';
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
      */
70 70
     protected function doInitialize(bool $dbCheck = true): void
71 71
     {
72
-        if (! $this->isInitialized) {
73
-            if (! empty($this->channel)) {
72
+        if (!$this->isInitialized) {
73
+            if (!empty($this->channel)) {
74 74
                 $this->setChannel($this->channel);
75 75
             }
76 76
         }
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
                 $keys = $this->redis->keys($this->getNamespace($type) . ':*');
95 95
 
96
-                foreach($keys as $key) {
96
+                foreach ($keys as $key) {
97 97
                     $content = $this->redis->get($key);
98 98
                     $content = json_decode($content, true);
99 99
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     {
121 121
         $results = [];
122 122
 
123
-        if (! $this->checkExist($ip, $type)) {
123
+        if (!$this->checkExist($ip, $type)) {
124 124
             return $results;
125 125
         }
126 126
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
                 $content = $this->redis->get($this->getKeyName($ip, $type));
140 140
                 $resultData = json_decode($content, true);
141 141
 
142
-                if (! empty($resultData['log_data'])) {
142
+                if (!empty($resultData['log_data'])) {
143 143
                     $results = $resultData['log_data']; 
144 144
                 }
145 145
         }
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
         foreach (['rule', 'filter_log', 'session'] as $type) {
221 221
             $keys = $this->redis->keys($this->getNamespace($type) . ':*');
222 222
 
223
-            if (! empty($keys)) {
224
-                foreach($keys as $key) {
223
+            if (!empty($keys)) {
224
+                foreach ($keys as $key) {
225 225
                     $this->redis->del($key);
226 226
                 }
227 227
             }
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
     private function getKeyName(string $ip, string $type = 'filter_log'): string
241 241
     {
242 242
         switch ($type) {
243
-            case 'filter_log'    : return $this->tableFilterLogs     . ':' . $ip;
243
+            case 'filter_log'    : return $this->tableFilterLogs . ':' . $ip;
244 244
             case 'session': return $this->tableSessions . ':' . $ip;
245 245
             case 'rule'   : return $this->tableRuleList . ':' . $ip;
246 246
         }
Please login to merge, or discard this patch.