@@ -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 | } |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | { |
| 49 | 49 | $headers = $this->getHeaders(); |
| 50 | 50 | |
| 51 | - if (! empty($this->deniedList)) { |
|
| 52 | - if (preg_match('/(' . implode('|', $this->deniedList). ')/i', implode(',', $headers))) { |
|
| 51 | + if (!empty($this->deniedList)) { |
|
| 52 | + if (preg_match('/(' . implode('|', $this->deniedList) . ')/i', implode(',', $headers))) { |
|
| 53 | 53 | return true; |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | foreach ($this->commonHeaderFileds as $fieldName) { |
| 60 | 60 | |
| 61 | 61 | // If strict mode is on, this value must be found. |
| 62 | - if (! isset($headers[$fieldName])) { |
|
| 62 | + if (!isset($headers[$fieldName])) { |
|
| 63 | 63 | return true; |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function setDeniedItem(string $string): void |
| 52 | 52 | { |
| 53 | - if (! in_array($string, $this->deniedList)) { |
|
| 53 | + if (!in_array($string, $this->deniedList)) { |
|
| 54 | 54 | array_push($this->deniedList, $string); |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -86,16 +86,16 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function removeItem(string $string): void |
| 88 | 88 | { |
| 89 | - if (! empty($this->allowedList)) { |
|
| 89 | + if (!empty($this->allowedList)) { |
|
| 90 | 90 | $key = array_search($string, $this->allowedList); |
| 91 | - if (false !== $key) { |
|
| 91 | + if (false !== $key) { |
|
| 92 | 92 | unset($this->allowedList[$key]); |
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - if (! empty($this->deniedList)) { |
|
| 96 | + if (!empty($this->deniedList)) { |
|
| 97 | 97 | $key = array_search($string, $this->deniedList); |
| 98 | - if (false !== $key) { |
|
| 98 | + if (false !== $key) { |
|
| 99 | 99 | unset($this->deniedList[$key]); |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | ], |
| 155 | 155 | ]; |
| 156 | 156 | |
| 157 | - if (! empty($_SERVER['HTTP_USER_AGENT'])) { |
|
| 157 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
| 158 | 158 | $this->userAgentString = $_SERVER['HTTP_USER_AGENT']; |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -164,11 +164,11 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | public function isAllowed(): bool |
| 166 | 166 | { |
| 167 | - if (! empty($this->trustedBotList)) { |
|
| 167 | + if (!empty($this->trustedBotList)) { |
|
| 168 | 168 | |
| 169 | 169 | $userAgent = array_unique(array_column($this->trustedBotList, 'userAgent')); |
| 170 | 170 | |
| 171 | - if (! preg_match('/(' . implode('|', $userAgent) . ')/i', $this->userAgentString)) { |
|
| 171 | + if (!preg_match('/(' . implode('|', $userAgent) . ')/i', $this->userAgentString)) { |
|
| 172 | 172 | // Okay, current request's user-agent string doesn't contain our truested bots' infroamtion. |
| 173 | 173 | // Ignore it. |
| 174 | 174 | return false; |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | if ($this->checkFakeRdns) { |
| 216 | 216 | |
| 217 | 217 | // We can identify that current access uses a fake RDNS record. |
| 218 | - if (! $rdnsCheck) { |
|
| 218 | + if (!$rdnsCheck) { |
|
| 219 | 219 | $this->isFake = true; |
| 220 | 220 | return false; |
| 221 | 221 | } |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | public function addList(array $list): void |
| 262 | 262 | { |
| 263 | - if (! empty($list[0]['userAgent']) && ! empty($list[0]['rdns']) && 2 === count($list[0])) { |
|
| 263 | + if (!empty($list[0]['userAgent']) && !empty($list[0]['rdns']) && 2 === count($list[0])) { |
|
| 264 | 264 | |
| 265 | 265 | // Append the new list to the end. |
| 266 | 266 | $this->trustedBotList = array_merge($this->trustedBotList, $list); |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | */ |
| 297 | 297 | public function removeItem(string $string): void |
| 298 | 298 | { |
| 299 | - if (! empty($this->trustedBotList)) { |
|
| 299 | + if (!empty($this->trustedBotList)) { |
|
| 300 | 300 | foreach ($this->trustedBotList as $index => $list) { |
| 301 | 301 | if ($list['userAgent'] === $string) { |
| 302 | 302 | unset($this->trustedBotList[$index]); |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | $ip = $ipData[0]; |
| 258 | 258 | $cidr = (int) $ipData[1] ?? 32; |
| 259 | 259 | |
| 260 | - $result[0] = long2ip((ip2long($ip)) & ((-1 << (32 - $cidr)))); |
|
| 260 | + $result[0] = long2ip((ip2long($ip)) & ((-1 << (32 - $cidr)))); |
|
| 261 | 261 | $result[1] = long2ip((ip2long($ip)) + pow(2, (32 - $cidr)) - 1); |
| 262 | 262 | |
| 263 | 263 | if ($isDecimal) { |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | $result[1] = ip2long($result[1]); |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - return $result; |
|
| 268 | + return $result; |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -45,7 +45,7 @@ |
||
| 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); |
@@ -43,41 +43,41 @@ |
||
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - /** |
|
| 46 | + /** |
|
| 47 | 47 | * Shieldon middleware invokable class. |
| 48 | 48 | * |
| 49 | - * @param Request $request |
|
| 50 | - * |
|
| 51 | - * @return mixed |
|
| 52 | - */ |
|
| 53 | - public function before(Request $request) |
|
| 54 | - { |
|
| 55 | - if ($request->isCLI()) { |
|
| 56 | - return; |
|
| 57 | - } |
|
| 49 | + * @param Request $request |
|
| 50 | + * |
|
| 51 | + * @return mixed |
|
| 52 | + */ |
|
| 53 | + public function before(Request $request) |
|
| 54 | + { |
|
| 55 | + if ($request->isCLI()) { |
|
| 56 | + return; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | $firewall = new Firewall($this->storage); |
| 60 | 60 | |
| 61 | 61 | // Pass CodeIgniter CSRF Token to Captcha form. |
| 62 | 62 | $firewall->getShieldon()->setCaptcha(new \Shieldon\Captcha\Csrf([ |
| 63 | - 'name' => csrf_token(), |
|
| 64 | - 'value' => csrf_hash(), |
|
| 63 | + 'name' => csrf_token(), |
|
| 64 | + 'value' => csrf_hash(), |
|
| 65 | 65 | ])); |
| 66 | 66 | |
| 67 | 67 | $firewall->restful(); |
| 68 | 68 | $firewall->run(); |
| 69 | - } |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * We don't have anything to do here. |
|
| 73 | - * |
|
| 74 | - * @param Response $request |
|
| 75 | - * @param Response $response |
|
| 76 | - * |
|
| 77 | - * @return mixed |
|
| 78 | - */ |
|
| 79 | - public function after(Request $request, Response $response) |
|
| 80 | - { |
|
| 71 | + /** |
|
| 72 | + * We don't have anything to do here. |
|
| 73 | + * |
|
| 74 | + * @param Response $request |
|
| 75 | + * @param Response $response |
|
| 76 | + * |
|
| 77 | + * @return mixed |
|
| 78 | + */ |
|
| 79 | + public function after(Request $request, Response $response) |
|
| 80 | + { |
|
| 81 | 81 | |
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | \ No newline at end of file |
@@ -83,7 +83,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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); |