Visman 5 vuotta sitten
vanhempi
commit
8131e14e56
100 muutettua tiedostoa jossa 1423 lisäystä ja 520 poistoa
  1. 2 2
      app/Controllers/Install.php
  2. 6 2
      app/Controllers/Primary.php
  3. 24 8
      app/Controllers/Routing.php
  4. 19 7
      app/Core/Cache/FileCache.php
  5. 8 2
      app/Core/Container.php
  6. 41 29
      app/Core/DB.php
  7. 31 22
      app/Core/DB/mysql.php
  8. 8 5
      app/Core/DBStatement.php
  9. 14 4
      app/Core/ErrorHandler.php
  10. 12 3
      app/Core/File.php
  11. 5 2
      app/Core/Files.php
  12. 22 10
      app/Core/Func.php
  13. 13 4
      app/Core/Image.php
  14. 36 26
      app/Core/Lang.php
  15. 53 21
      app/Core/Mail.php
  16. 27 17
      app/Core/Parser.php
  17. 41 14
      app/Core/Router.php
  18. 4 1
      app/Core/Secury.php
  19. 73 18
      app/Core/Validator.php
  20. 1 1
      app/Core/View.php
  21. 4 1
      app/Models/BanList/Check.php
  22. 4 1
      app/Models/BanList/Filter.php
  23. 7 2
      app/Models/BanList/Insert.php
  24. 9 2
      app/Models/BanList/IsBanned.php
  25. 4 1
      app/Models/BanList/Load.php
  26. 1 1
      app/Models/BanList/Model.php
  27. 7 2
      app/Models/BanList/Update.php
  28. 3 3
      app/Models/Censorship/Model.php
  29. 3 3
      app/Models/Censorship/Refresh.php
  30. 2 1
      app/Models/Censorship/Save.php
  31. 6 3
      app/Models/Cookie/Model.php
  32. 16 5
      app/Models/DataModel.php
  33. 5 2
      app/Models/Forum/LoadTree.php
  34. 4 1
      app/Models/Forum/Manager.php
  35. 19 7
      app/Models/Forum/Model.php
  36. 4 1
      app/Models/Forum/Refresh.php
  37. 5 2
      app/Models/Forum/Save.php
  38. 8 2
      app/Models/Group/Perm.php
  39. 1 1
      app/Models/Group/Save.php
  40. 1 1
      app/Models/Online/Info.php
  41. 13 10
      app/Models/Online/Model.php
  42. 47 16
      app/Models/Page.php
  43. 5 1
      app/Models/Pages/Admin.php
  44. 38 9
      app/Models/Pages/Admin/Bans.php
  45. 4 1
      app/Models/Pages/Admin/Categories.php
  46. 13 3
      app/Models/Pages/Admin/Forums.php
  47. 47 11
      app/Models/Pages/Admin/Groups.php
  48. 17 4
      app/Models/Pages/Admin/Maintenance.php
  49. 4 1
      app/Models/Pages/Admin/Options.php
  50. 22 10
      app/Models/Pages/Admin/Statistics.php
  51. 2 1
      app/Models/Pages/Admin/Users.php
  52. 18 6
      app/Models/Pages/Admin/Users/Action.php
  53. 17 4
      app/Models/Pages/Admin/Users/Result.php
  54. 7 4
      app/Models/Pages/Auth.php
  55. 9 3
      app/Models/Pages/Delete.php
  56. 33 9
      app/Models/Pages/Edit.php
  57. 4 1
      app/Models/Pages/Forum.php
  58. 13 3
      app/Models/Pages/Install.php
  59. 61 15
      app/Models/Pages/Moderate.php
  60. 41 11
      app/Models/Pages/Post.php
  61. 17 7
      app/Models/Pages/PostFormTrait.php
  62. 19 7
      app/Models/Pages/PostValidatorTrait.php
  63. 18 5
      app/Models/Pages/Profile.php
  64. 4 1
      app/Models/Pages/Profile/Config.php
  65. 15 5
      app/Models/Pages/Profile/Edit.php
  66. 10 3
      app/Models/Pages/Profile/Email.php
  67. 8 2
      app/Models/Pages/Profile/Mod.php
  68. 4 1
      app/Models/Pages/Profile/Pass.php
  69. 24 6
      app/Models/Pages/Profile/View.php
  70. 1 1
      app/Models/Pages/Redirect.php
  71. 10 3
      app/Models/Pages/Register.php
  72. 4 1
      app/Models/Pages/Report.php
  73. 1 1
      app/Models/Pages/Rules.php
  74. 32 8
      app/Models/Pages/Search.php
  75. 13 4
      app/Models/Pages/Topic.php
  76. 8 2
      app/Models/Pages/Userlist.php
  77. 4 1
      app/Models/Post/Delete.php
  78. 17 9
      app/Models/Post/Load.php
  79. 5 1
      app/Models/Post/Manager.php
  80. 37 12
      app/Models/Post/Model.php
  81. 1 1
      app/Models/Post/Save.php
  82. 1 1
      app/Models/Post/UserInfoFromIP.php
  83. 12 3
      app/Models/Post/View.php
  84. 2 2
      app/Models/Report/Load.php
  85. 8 2
      app/Models/Report/Model.php
  86. 1 1
      app/Models/Report/Save.php
  87. 2 1
      app/Models/Rules/Profile.php
  88. 8 2
      app/Models/Rules/Users.php
  89. 4 1
      app/Models/Search/Delete.php
  90. 33 7
      app/Models/Search/Execute.php
  91. 10 3
      app/Models/Search/Prepare.php
  92. 5 2
      app/Models/Stopwords/Model.php
  93. 4 1
      app/Models/Topic/Load.php
  94. 43 11
      app/Models/Topic/Model.php
  95. 1 1
      app/Models/Topic/Save.php
  96. 12 3
      app/Models/Topic/View.php
  97. 8 2
      app/Models/User/ChangeGroup.php
  98. 43 30
      app/Models/User/Current.php
  99. 2 2
      app/Models/User/Delete.php
  100. 4 1
      app/Models/User/Filter.php

+ 2 - 2
app/Controllers/Install.php

@@ -31,7 +31,7 @@ class Install
     public function routing(): Page
     public function routing(): Page
     {
     {
         $uri = $_SERVER['REQUEST_URI'];
         $uri = $_SERVER['REQUEST_URI'];
-        if (($pos = \strpos($uri, '?')) !== false) {
+        if (false !== ($pos = \strpos($uri, '?'))) {
             $uri = \substr($uri, 0, $pos);
             $uri = \substr($uri, 0, $pos);
         }
         }
         $uri = \rawurldecode($uri);
         $uri = \rawurldecode($uri);
@@ -45,7 +45,7 @@ class Install
         $method = $_SERVER['REQUEST_METHOD'];
         $method = $_SERVER['REQUEST_METHOD'];
 
 
         $route = $r->route($method, $uri);
         $route = $r->route($method, $uri);
-        $page = null;
+        $page  = null;
         switch ($route[0]) {
         switch ($route[0]) {
             case $r::OK:
             case $r::OK:
                 // ... 200 OK
                 // ... 200 OK

+ 6 - 2
app/Controllers/Primary.php

@@ -33,7 +33,8 @@ class Primary
     public function check(): ?Page
     public function check(): ?Page
     {
     {
         if ($this->c->config->o_maintenance && ! $this->c->MAINTENANCE_OFF) {
         if ($this->c->config->o_maintenance && ! $this->c->MAINTENANCE_OFF) {
-            if (! isset($this->c->admins->list[$this->c->Cookie->uId])
+            if (
+                ! isset($this->c->admins->list[$this->c->Cookie->uId])
                 || ! isset($this->c->admins->list[$this->c->user->id])
                 || ! isset($this->c->admins->list[$this->c->user->id])
             ) {
             ) {
                 if (! $this->c->isInit('user')) {
                 if (! $this->c->isInit('user')) {
@@ -48,7 +49,10 @@ class Primary
             exit;
             exit;
         }
         }
 
 
-        if (! $this->c->user->isAdmin && $this->c->bans->check($this->c->user)) {
+        if (
+            ! $this->c->user->isAdmin
+            && $this->c->bans->check($this->c->user)
+        ) {
             return $this->c->Ban->ban($this->c->user);
             return $this->c->Ban->ban($this->c->user);
         }
         }
 
 

+ 24 - 8
app/Controllers/Routing.php

@@ -34,9 +34,9 @@ class Routing
      */
      */
     public function routing(): Page
     public function routing(): Page
     {
     {
-        $user = $this->c->user;
+        $user   = $this->c->user;
         $config = $this->c->config;
         $config = $this->c->config;
-        $r = $this->c->Router;
+        $r      = $this->c->Router;
 
 
         // регистрация/вход/выход
         // регистрация/вход/выход
         if ($user->isGuest) {
         if ($user->isGuest) {
@@ -68,7 +68,13 @@ class Routing
             $r->add(self::GET, '/index.php',  'Redirect:toIndex');
             $r->add(self::GET, '/index.php',  'Redirect:toIndex');
             $r->add(self::GET, '/index.html', 'Redirect:toIndex');
             $r->add(self::GET, '/index.html', 'Redirect:toIndex');
             // правила
             // правила
-            if ('1' == $config->o_rules && (! $user->isGuest || '1' == $config->o_regs_allow)) {
+            if (
+                '1' == $config->o_rules
+                && (
+                    ! $user->isGuest
+                    || '1' == $config->o_regs_allow
+                )
+            ) {
                 $r->add(self::GET, '/rules', 'Rules:view', 'Rules');
                 $r->add(self::GET, '/rules', 'Rules:view', 'Rules');
             }
             }
             // поиск
             // поиск
@@ -125,7 +131,10 @@ class Routing
             $r->add(self::DUO, '/post/{id:[1-9]\d*}/edit',   'Edit:edit',      'EditPost'  );
             $r->add(self::DUO, '/post/{id:[1-9]\d*}/edit',   'Edit:edit',      'EditPost'  );
             $r->add(self::DUO, '/post/{id:[1-9]\d*}/delete', 'Delete:delete',  'DeletePost');
             $r->add(self::DUO, '/post/{id:[1-9]\d*}/delete', 'Delete:delete',  'DeletePost');
             // сигналы (репорты)
             // сигналы (репорты)
-            if (! $user->isAdmin && ! $user->isGuest) { // ????
+            if (
+                ! $user->isAdmin
+                && ! $user->isGuest
+            ) { // ????
                 $r->add(self::DUO, '/post/{id:[1-9]\d*}/report', 'Report:report', 'ReportPost');
                 $r->add(self::DUO, '/post/{id:[1-9]\d*}/report', 'Report:report', 'ReportPost');
             }
             }
 
 
@@ -158,7 +167,11 @@ class Routing
                 $r->add(self::GET, '/admin/bans/delete/{id:[1-9]\d*}/{token}[/{uid:[2-9]|[1-9]\d+}]', 'AdminBans:delete', 'AdminBansDelete');
                 $r->add(self::GET, '/admin/bans/delete/{id:[1-9]\d*}/{token}[/{uid:[2-9]|[1-9]\d+}]', 'AdminBans:delete', 'AdminBansDelete');
             }
             }
 
 
-            if ($user->isAdmin || $config->o_report_method == '0' || $config->o_report_method == '2') {
+            if (
+                $user->isAdmin
+                || '0' == $config->o_report_method
+                || '2' == $config->o_report_method
+            ) {
                 $r->add(self::GET, '/admin/reports',                           'AdminReports:view', 'AdminReports');
                 $r->add(self::GET, '/admin/reports',                           'AdminReports:view', 'AdminReports');
                 $r->add(self::GET, '/admin/reports/zap/{id:[1-9]\d*}/{token}', 'AdminReports:zap',  'AdminReportsZap');
                 $r->add(self::GET, '/admin/reports/zap/{id:[1-9]\d*}/{token}', 'AdminReports:zap',  'AdminReportsZap');
             }
             }
@@ -190,14 +203,14 @@ class Routing
         }
         }
 
 
         $uri = $_SERVER['REQUEST_URI'];
         $uri = $_SERVER['REQUEST_URI'];
-        if (($pos = \strpos($uri, '?')) !== false) {
+        if (false !== ($pos = \strpos($uri, '?'))) {
             $uri = \substr($uri, 0, $pos);
             $uri = \substr($uri, 0, $pos);
         }
         }
         $uri    = \rawurldecode($uri);
         $uri    = \rawurldecode($uri);
         $method = $_SERVER['REQUEST_METHOD'];
         $method = $_SERVER['REQUEST_METHOD'];
 
 
         $route = $r->route($method, $uri);
         $route = $r->route($method, $uri);
-        $page = null;
+        $page  = null;
         switch ($route[0]) {
         switch ($route[0]) {
             case $r::OK:
             case $r::OK:
                 // ... 200 OK
                 // ... 200 OK
@@ -206,7 +219,10 @@ class Routing
                 break;
                 break;
             case $r::NOT_FOUND:
             case $r::NOT_FOUND:
                 // ... 404 Not Found
                 // ... 404 Not Found
-                if ($user->g_read_board != '1' && $user->isGuest) {
+                if (
+                    '1' != $user->g_read_board
+                    && $user->isGuest
+                ) {
                     $page = $this->c->Redirect->page('Login');
                     $page = $this->c->Redirect->page('Login');
                 } else {
                 } else {
                     $page = $this->c->Message->message('Bad request');
                     $page = $this->c->Message->message('Bad request');

+ 19 - 7
app/Core/Cache/FileCache.php

@@ -26,7 +26,10 @@ class FileCache implements ProviderCacheInterface
      */
      */
     public function __construct($dir)
     public function __construct($dir)
     {
     {
-        if (empty($dir) || ! \is_string($dir)) {
+        if (
+            empty($dir)
+            || ! \is_string($dir)
+        ) {
             throw new InvalidArgumentException('Cache directory must be set to a string');
             throw new InvalidArgumentException('Cache directory must be set to a string');
         } elseif (! \is_dir($dir)) {
         } elseif (! \is_dir($dir)) {
             throw new RuntimeException("`$dir`: Not a directory");
             throw new RuntimeException("`$dir`: Not a directory");
@@ -50,7 +53,13 @@ class FileCache implements ProviderCacheInterface
         if (\is_file($file)) {
         if (\is_file($file)) {
             require $file;
             require $file;
 
 
-            if (isset($expire, $data) && ($expire < 1 || $expire > \time())) {
+            if (
+                isset($expire, $data)
+                && (
+                    $expire < 1
+                    || $expire > \time()
+                )
+            ) {
                 return $data;
                 return $data;
             }
             }
         }
         }
@@ -70,8 +79,8 @@ class FileCache implements ProviderCacheInterface
      */
      */
     public function set(string $key, $value, int $ttl = null): bool
     public function set(string $key, $value, int $ttl = null): bool
     {
     {
-        $file = $this->file($key);
-        $expire = null === $ttl || $ttl < 1 ? 0 : \time() + $ttl;
+        $file    = $this->file($key);
+        $expire  = null === $ttl || $ttl < 1 ? 0 : \time() + $ttl;
         $content = "<?php\n\n" . '$expire = ' . $expire . ";\n\n" . '$data = ' . \var_export($value, true) . ";\n";
         $content = "<?php\n\n" . '$expire = ' . $expire . ";\n\n" . '$data = ' . \var_export($value, true) . ";\n";
         if (false === \file_put_contents($file, $content, \LOCK_EX)) {
         if (false === \file_put_contents($file, $content, \LOCK_EX)) {
             throw new RuntimeException("The key '$key' can not be saved");
             throw new RuntimeException("The key '$key' can not be saved");
@@ -112,9 +121,9 @@ class FileCache implements ProviderCacheInterface
      */
      */
     public function clear(): bool
     public function clear(): bool
     {
     {
-        $dir = new RecursiveDirectoryIterator($this->cacheDir, RecursiveDirectoryIterator::SKIP_DOTS);
+        $dir      = new RecursiveDirectoryIterator($this->cacheDir, RecursiveDirectoryIterator::SKIP_DOTS);
         $iterator = new RecursiveIteratorIterator($dir);
         $iterator = new RecursiveIteratorIterator($dir);
-        $files = new RegexIterator($iterator, '%\.php$%i', RegexIterator::MATCH);
+        $files    = new RegexIterator($iterator, '%\.php$%i', RegexIterator::MATCH);
 
 
         $result = true;
         $result = true;
         foreach ($files as $file) {
         foreach ($files as $file) {
@@ -146,7 +155,10 @@ class FileCache implements ProviderCacheInterface
      */
      */
     protected function file(string $key): string
     protected function file(string $key): string
     {
     {
-        if (\is_string($key) && \preg_match('%^[a-z0-9_-]+$%Di', $key)) {
+        if (
+            \is_string($key)
+            && \preg_match('%^[a-z0-9_-]+$%Di', $key)
+        ) {
             return $this->cacheDir . '/cache_' . $key . '.php';
             return $this->cacheDir . '/cache_' . $key . '.php';
         }
         }
         throw new InvalidArgumentException("Key '$key' contains invalid characters.");
         throw new InvalidArgumentException("Key '$key' contains invalid characters.");

+ 8 - 2
app/Core/Container.php

@@ -94,7 +94,10 @@ class Container
             $args[] = \is_numeric($k) ? $v : $this->resolve($v);
             $args[] = \is_numeric($k) ? $v : $this->resolve($v);
         }
         }
         // Special case: reference to factory method
         // Special case: reference to factory method
-        if ('@' === $class[0]  && false !== \strpos($class, ':')) {
+        if (
+            '@' === $class[0]
+            && false !== \strpos($class, ':')
+        ) {
             list($name, $method) = \explode(':', \substr($class, 1), 2);
             list($name, $method) = \explode(':', \substr($class, 1), 2);
             $factory = $this->__get($name);
             $factory = $this->__get($name);
             $service = $factory->$method(...$args);
             $service = $factory->$method(...$args);
@@ -195,7 +198,10 @@ class Container
                         $value
                         $value
                     );
                     );
                 }
                 }
-            } elseif (isset($value[0]) && '@' === $value[0]) {
+            } elseif (
+                isset($value[0])
+                && '@' === $value[0]
+            ) {
                 return $this->__get(\substr($value, 1));
                 return $this->__get(\substr($value, 1));
             }
             }
         } elseif (\is_array($value)) {
         } elseif (\is_array($value)) {

+ 41 - 29
app/Core/DB.php

@@ -105,12 +105,15 @@ class DB extends PDO
      *
      *
      * @return bool
      * @return bool
      */
      */
-    protected function isOptions(array $arr): bool
+    protected function isOptions(array $options): bool
     {
     {
         $verify = [self::ATTR_CURSOR => [self::CURSOR_FWDONLY, self::CURSOR_SCROLL]];
         $verify = [self::ATTR_CURSOR => [self::CURSOR_FWDONLY, self::CURSOR_SCROLL]];
 
 
-        foreach ($arr as $key => $value) {
-           if (! isset($verify[$key]) || ! \in_array($value, $verify[$key])) {
+        foreach ($options as $key => $value) {
+           if (
+               ! isset($verify[$key])
+               || ! \in_array($value, $verify[$key])
+            ) {
                return false;
                return false;
            }
            }
         }
         }
@@ -129,18 +132,18 @@ class DB extends PDO
      */
      */
     protected function parse(string &$query, array $params): array
     protected function parse(string &$query, array $params): array
     {
     {
-        $idxIn = 0;
+        $idxIn  = 0;
         $idxOut = 1;
         $idxOut = 1;
-        $map = [];
-        $query = \preg_replace_callback(
+        $map    = [];
+        $query  = \preg_replace_callback(
             '%(?=[?:])(?<![\w?:])(?:::(\w+)|\?(?![?:])(?:(\w+)(?::(\w+))?)?|:(\w+))%',
             '%(?=[?:])(?<![\w?:])(?:::(\w+)|\?(?![?:])(?:(\w+)(?::(\w+))?)?|:(\w+))%',
             function($matches) use ($params, &$idxIn, &$idxOut, &$map) {
             function($matches) use ($params, &$idxIn, &$idxOut, &$map) {
                 if (! empty($matches[1])) {
                 if (! empty($matches[1])) {
                     return $this->dbPrefix . $matches[1];
                     return $this->dbPrefix . $matches[1];
                 }
                 }
 
 
-                $type = empty($matches[2]) ? 's' : $matches[2];
-                $key = $matches[4] ?? ($matches[3] ?? $idxIn++);
+                $type  = empty($matches[2]) ? 's' : $matches[2];
+                $key   = $matches[4] ?? ($matches[3] ?? $idxIn++);
                 $value = $this->getValue($key, $params);
                 $value = $this->getValue($key, $params);
 
 
                 switch ($type) {
                 switch ($type) {
@@ -157,7 +160,7 @@ class DB extends PDO
                         break;
                         break;
                     default:
                     default:
                         $value = [1];
                         $value = [1];
-                        $type = 's';
+                        $type  = 's';
                         break;
                         break;
                 }
                 }
 
 
@@ -171,8 +174,8 @@ class DB extends PDO
 
 
                 $res = [];
                 $res = [];
                 foreach ($value as $val) {
                 foreach ($value as $val) {
-                    $name = ':' . $idxOut++;
-                    $res[] = $name;
+                    $name        = ':' . $idxOut++;
+                    $res[]       = $name;
                     $map[$key][] = $name;
                     $map[$key][] = $name;
                 }
                 }
                 return \implode(',', $res);
                 return \implode(',', $res);
@@ -196,12 +199,15 @@ class DB extends PDO
     {
     {
         if (
         if (
             \is_string($key)
             \is_string($key)
-            && (isset($params[':' . $key]) || \array_key_exists(':' . $key, $params))
+            && \array_key_exists(':' . $key, $params)
         ) {
         ) {
             return $params[':' . $key];
             return $params[':' . $key];
         } elseif (
         } elseif (
-            (\is_string($key) || \is_int($key))
-            && (isset($params[$key]) || \array_key_exists($key, $params))
+            (
+                \is_string($key)
+                || \is_int($key)
+            )
+            && \array_key_exists($key, $params)
         ) {
         ) {
             return $params[$key];
             return $params[$key];
         }
         }
@@ -242,7 +248,7 @@ class DB extends PDO
             ++$this->qCount;
             ++$this->qCount;
         }
         }
         $this->queries[] = [$query, $time + $this->delta];
         $this->queries[] = [$query, $time + $this->delta];
-        $this->delta = 0;
+        $this->delta     = 0;
     }
     }
 
 
     /**
     /**
@@ -264,8 +270,8 @@ class DB extends PDO
             return $result;
             return $result;
         }
         }
 
 
-        $start = \microtime(true);
-        $stmt  = parent::prepare($query);
+        $start       = \microtime(true);
+        $stmt        = parent::prepare($query);
         $this->delta = \microtime(true) - $start;
         $this->delta = \microtime(true) - $start;
 
 
         $stmt->setMap($map);
         $stmt->setMap($map);
@@ -288,21 +294,24 @@ class DB extends PDO
      */
      */
     public function prepare($query, $arg1 = null, $arg2 = null): PDOStatement
     public function prepare($query, $arg1 = null, $arg2 = null): PDOStatement
     {
     {
-        if (empty($arg1) === empty($arg2) || ! empty($arg2)) {
-            $params = $arg1;
+        if (
+            empty($arg1) === empty($arg2)
+            || ! empty($arg2)
+        ) {
+            $params  = $arg1;
             $options = $arg2;
             $options = $arg2;
         } elseif ($this->isOptions($arg1)) {
         } elseif ($this->isOptions($arg1)) {
-            $params = [];
+            $params  = [];
             $options = $arg1;
             $options = $arg1;
         } else {
         } else {
-            $params = $arg1;
+            $params  = $arg1;
             $options = [];
             $options = [];
         }
         }
 
 
         $map = $this->parse($query, $params);
         $map = $this->parse($query, $params);
 
 
-        $start = \microtime(true);
-        $stmt  = parent::prepare($query, $options);
+        $start       = \microtime(true);
+        $stmt        = parent::prepare($query, $options);
         $this->delta = \microtime(true) - $start;
         $this->delta = \microtime(true) - $start;
 
 
         $stmt->setMap($map);
         $stmt->setMap($map);
@@ -322,7 +331,10 @@ class DB extends PDO
      */
      */
     public function query(string $query, ...$args)
     public function query(string $query, ...$args)
     {
     {
-        if (isset($args[0]) && \is_array($args[0])) {
+        if (
+            isset($args[0])
+            && \is_array($args[0])
+        ) {
             $params = \array_shift($args);
             $params = \array_shift($args);
         } else {
         } else {
             $params = [];
             $params = [];
@@ -337,8 +349,8 @@ class DB extends PDO
             return $result;
             return $result;
         }
         }
 
 
-        $start = \microtime(true);
-        $stmt  = parent::prepare($query);
+        $start       = \microtime(true);
+        $stmt        = parent::prepare($query);
         $this->delta = \microtime(true) - $start;
         $this->delta = \microtime(true) - $start;
 
 
         $stmt->setMap($map);
         $stmt->setMap($map);
@@ -359,7 +371,7 @@ class DB extends PDO
      */
      */
     public function beginTransaction(): bool
     public function beginTransaction(): bool
     {
     {
-        $start = \microtime(true);
+        $start  = \microtime(true);
         $result = parent::beginTransaction();
         $result = parent::beginTransaction();
         $this->saveQuery('beginTransaction()', \microtime(true) - $start, false);
         $this->saveQuery('beginTransaction()', \microtime(true) - $start, false);
         return $result;
         return $result;
@@ -370,7 +382,7 @@ class DB extends PDO
      */
      */
     public function commit(): bool
     public function commit(): bool
     {
     {
-        $start = \microtime(true);
+        $start  = \microtime(true);
         $result = parent::commit();
         $result = parent::commit();
         $this->saveQuery('commit()', \microtime(true) - $start, false);
         $this->saveQuery('commit()', \microtime(true) - $start, false);
         return $result;
         return $result;
@@ -381,7 +393,7 @@ class DB extends PDO
      */
      */
     public function rollback(): bool
     public function rollback(): bool
     {
     {
-        $start = \microtime(true);
+        $start  = \microtime(true);
         $result = parent::rollback();
         $result = parent::rollback();
         $this->saveQuery('rollback()', \microtime(true) - $start, false);
         $this->saveQuery('rollback()', \microtime(true) - $start, false);
         return $result;
         return $result;

+ 31 - 22
app/Core/DB/mysql.php

@@ -55,7 +55,7 @@ class Mysql
      */
      */
     public function __construct(DB $db, $prefix)
     public function __construct(DB $db, $prefix)
     {
     {
-        $this->db = $db;
+        $this->db       = $db;
         $this->dbPrefix = $prefix;
         $this->dbPrefix = $prefix;
     }
     }
 
 
@@ -81,7 +81,10 @@ class Mysql
      */
      */
     protected function testStr(string $str): void
     protected function testStr(string $str): void
     {
     {
-        if (! \is_string($str) || \preg_match('%[^a-zA-Z0-9_]%', $str)) {
+        if (
+            ! \is_string($str)
+            || \preg_match('%[^a-zA-Z0-9_]%', $str)
+        ) {
             throw new PDOException("Name '{$str}' have bad characters.");
             throw new PDOException("Name '{$str}' have bad characters.");
         }
         }
     }
     }
@@ -154,7 +157,7 @@ class Mysql
     {
     {
         $table = ($noPrefix ? '' : $this->dbPrefix) . $table;
         $table = ($noPrefix ? '' : $this->dbPrefix) . $table;
         try {
         try {
-            $stmt = $this->db->query('SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?s:table', [':table' => $table]);
+            $stmt   = $this->db->query('SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?s:table', [':table' => $table]);
             $result = $stmt->fetch();
             $result = $stmt->fetch();
             $stmt->closeCursor();
             $stmt->closeCursor();
         } catch (PDOException $e) {
         } catch (PDOException $e) {
@@ -176,7 +179,7 @@ class Mysql
     {
     {
         $table = ($noPrefix ? '' : $this->dbPrefix) . $table;
         $table = ($noPrefix ? '' : $this->dbPrefix) . $table;
         try {
         try {
-            $stmt = $this->db->query('SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?s:table AND COLUMN_NAME = ?s:field', [':table' => $table, ':field' => $field]);
+            $stmt   = $this->db->query('SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?s:table AND COLUMN_NAME = ?s:field', [':table' => $table, ':field' => $field]);
             $result = $stmt->fetch();
             $result = $stmt->fetch();
             $stmt->closeCursor();
             $stmt->closeCursor();
         } catch (PDOException $e) {
         } catch (PDOException $e) {
@@ -197,9 +200,9 @@ class Mysql
     public function indexExists(string $table, string $index, bool $noPrefix = false): bool
     public function indexExists(string $table, string $index, bool $noPrefix = false): bool
     {
     {
         $table = ($noPrefix ? '' : $this->dbPrefix) . $table;
         $table = ($noPrefix ? '' : $this->dbPrefix) . $table;
-        $index = $index == 'PRIMARY' ? $index : $table . '_' . $index;
+        $index = 'PRIMARY' == $index ? $index : $table . '_' . $index;
         try {
         try {
-            $stmt = $this->db->query('SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?s:table AND INDEX_NAME = ?s:index', [':table' => $table, ':index' => $index]);
+            $stmt   = $this->db->query('SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?s:table AND INDEX_NAME = ?s:index', [':table' => $table, ':index' => $index]);
             $result = $stmt->fetch();
             $result = $stmt->fetch();
             $stmt->closeCursor();
             $stmt->closeCursor();
         } catch (PDOException $e) {
         } catch (PDOException $e) {
@@ -229,7 +232,10 @@ class Mysql
             // сравнение
             // сравнение
             if (\preg_match('%^(?:CHAR|VARCHAR|TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|ENUM|SET)%i', $data[0])) {
             if (\preg_match('%^(?:CHAR|VARCHAR|TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|ENUM|SET)%i', $data[0])) {
                 $query .= ' CHARACTER SET utf8mb4 COLLATE utf8mb4_';
                 $query .= ' CHARACTER SET utf8mb4 COLLATE utf8mb4_';
-                if (isset($data[3]) && \is_string($data[3])) {
+                if (
+                    isset($data[3])
+                    && \is_string($data[3])
+                ) {
                     $this->testStr($data[3]);
                     $this->testStr($data[3]);
                     $query .= $data[3];
                     $query .= $data[3];
                 } else {
                 } else {
@@ -287,7 +293,7 @@ class Mysql
         }
         }
         $this->testStr($engine);
         $this->testStr($engine);
         $query = \rtrim($query, ', ') . ") ENGINE={$engine} CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";
         $query = \rtrim($query, ', ') . ") ENGINE={$engine} CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";
-        return $this->db->exec($query) !== false;
+        return false !== $this->db->exec($query);
     }
     }
 
 
     /**
     /**
@@ -302,7 +308,7 @@ class Mysql
     {
     {
         $table = ($noPrefix ? '' : $this->dbPrefix) . $table;
         $table = ($noPrefix ? '' : $this->dbPrefix) . $table;
         $this->testStr($table);
         $this->testStr($table);
-        return $this->db->exec("DROP TABLE IF EXISTS `{$table}`") !== false;
+        return false !== $this->db->exec("DROP TABLE IF EXISTS `{$table}`");
     }
     }
 
 
     /**
     /**
@@ -316,14 +322,17 @@ class Mysql
      */
      */
     public function renameTable(string $old, string $new, bool $noPrefix = false): bool
     public function renameTable(string $old, string $new, bool $noPrefix = false): bool
     {
     {
-        if ($this->tableExists($new, $noPrefix) && ! $this->tableExists($old, $noPrefix)) {
+        if (
+            $this->tableExists($new, $noPrefix)
+            && ! $this->tableExists($old, $noPrefix)
+        ) {
             return true;
             return true;
         }
         }
         $old = ($noPrefix ? '' : $this->dbPrefix) . $old;
         $old = ($noPrefix ? '' : $this->dbPrefix) . $old;
         $this->testStr($old);
         $this->testStr($old);
         $new = ($noPrefix ? '' : $this->dbPrefix) . $new;
         $new = ($noPrefix ? '' : $this->dbPrefix) . $new;
         $this->testStr($new);
         $this->testStr($new);
-        return $this->db->exec("ALTER TABLE `{$old}` RENAME TO `{$new}`") !== false;
+        return false !== $this->db->exec("ALTER TABLE `{$old}` RENAME TO `{$new}`");
     }
     }
 
 
     /**
     /**
@@ -358,7 +367,7 @@ class Mysql
             $this->testStr($after);
             $this->testStr($after);
             $query .= " AFTER `{$after}`";
             $query .= " AFTER `{$after}`";
         }
         }
-        return $this->db->exec($query) !== false;
+        return false !== $this->db->exec($query);
     }
     }
 
 
     /**
     /**
@@ -390,7 +399,7 @@ class Mysql
             $this->testStr($after);
             $this->testStr($after);
             $query .= " AFTER `{$after}`";
             $query .= " AFTER `{$after}`";
         }
         }
-        return $this->db->exec($query) !== false;
+        return false !== $this->db->exec($query);
     }
     }
 
 
     /**
     /**
@@ -410,7 +419,7 @@ class Mysql
         $table = ($noPrefix ? '' : $this->dbPrefix) . $table;
         $table = ($noPrefix ? '' : $this->dbPrefix) . $table;
         $this->testStr($table);
         $this->testStr($table);
         $this->testStr($field);
         $this->testStr($field);
-        return $this->db->exec("ALTER TABLE `{$table}` DROP COLUMN `{$field}`") !== false;
+        return false !== $this->db->exec("ALTER TABLE `{$table}` DROP COLUMN `{$field}`");
     }
     }
 
 
     /**
     /**
@@ -432,7 +441,7 @@ class Mysql
         $table = ($noPrefix ? '' : $this->dbPrefix) . $table;
         $table = ($noPrefix ? '' : $this->dbPrefix) . $table;
         $this->testStr($table);
         $this->testStr($table);
         $query = "ALTER TABLE `{$table}` ADD ";
         $query = "ALTER TABLE `{$table}` ADD ";
-        if ($index == 'PRIMARY') {
+        if ('PRIMARY' == $index) {
             $query .= 'PRIMARY KEY';
             $query .= 'PRIMARY KEY';
         } else {
         } else {
             $index = $table . '_' . $index;
             $index = $table . '_' . $index;
@@ -444,7 +453,7 @@ class Mysql
             }
             }
         }
         }
         $query .= ' (' . $this->replIdxs($fields) . ')';
         $query .= ' (' . $this->replIdxs($fields) . ')';
-        return $this->db->exec($query) !== false;
+        return false !== $this->db->exec($query);
     }
     }
 
 
     /**
     /**
@@ -464,14 +473,14 @@ class Mysql
         $table = ($noPrefix ? '' : $this->dbPrefix) . $table;
         $table = ($noPrefix ? '' : $this->dbPrefix) . $table;
         $this->testStr($table);
         $this->testStr($table);
         $query = "ALTER TABLE `{$table}` ";
         $query = "ALTER TABLE `{$table}` ";
-        if ($index == 'PRIMARY') {
+        if ('PRIMARY' == $index) {
             $query .= "DROP PRIMARY KEY";
             $query .= "DROP PRIMARY KEY";
         } else {
         } else {
             $index = $table . '_' . $index;
             $index = $table . '_' . $index;
             $this->testStr($index);
             $this->testStr($index);
             $query .= "DROP INDEX `{$index}`";
             $query .= "DROP INDEX `{$index}`";
         }
         }
-        return $this->db->exec($query) !== false;
+        return false !== $this->db->exec($query);
     }
     }
 
 
     /**
     /**
@@ -486,7 +495,7 @@ class Mysql
     {
     {
         $table = ($noPrefix ? '' : $this->dbPrefix) . $table;
         $table = ($noPrefix ? '' : $this->dbPrefix) . $table;
         $this->testStr($table);
         $this->testStr($table);
-        return $this->db->exec("TRUNCATE TABLE `{$table}`") !== false;
+        return false !== $this->db->exec("TRUNCATE TABLE `{$table}`");
     }
     }
 
 
     /**
     /**
@@ -497,10 +506,10 @@ class Mysql
     public function statistics(): array
     public function statistics(): array
     {
     {
         $this->testStr($this->dbPrefix);
         $this->testStr($this->dbPrefix);
-        $prefix = str_replace('_', '\\_', $this->dbPrefix);
-        $stmt = $this->db->query("SHOW TABLE STATUS LIKE '{$prefix}%'");
+        $prefix  = str_replace('_', '\\_', $this->dbPrefix);
+        $stmt    = $this->db->query("SHOW TABLE STATUS LIKE '{$prefix}%'");
         $records = $size = 0;
         $records = $size = 0;
-        $engine = [];
+        $engine  = [];
         while ($row = $stmt->fetch()) {
         while ($row = $stmt->fetch()) {
             $records += $row['Rows'];
             $records += $row['Rows'];
             $size += $row['Data_length'] + $row['Index_length'];
             $size += $row['Data_length'] + $row['Index_length'];

+ 8 - 5
app/Core/DBStatement.php

@@ -64,11 +64,11 @@ class DBStatement extends PDOStatement
     public function bindValueList(array $params): void
     public function bindValueList(array $params): void
     {
     {
         foreach ($this->map as $key => $data) {
         foreach ($this->map as $key => $data) {
-            $type = \array_shift($data);
-            $bType = $this->types[$type];
+            $type   = \array_shift($data);
+            $bType  = $this->types[$type];
             $bValue = $this->db->getValue($key, $params);
             $bValue = $this->db->getValue($key, $params);
 
 
-            if ($type[0] === 'a') {
+            if ('a' === $type[0]) {
                 if (! \is_array($bValue)) {
                 if (! \is_array($bValue)) {
                     throw new PDOException("Expected array: key='{$key}'");
                     throw new PDOException("Expected array: key='{$key}'");
                 }
                 }
@@ -92,10 +92,13 @@ class DBStatement extends PDOStatement
      */
      */
     public function execute($params = null): bool
     public function execute($params = null): bool
     {
     {
-        if (\is_array($params) && ! empty($params)) {
+        if (
+            \is_array($params)
+            && ! empty($params)
+        ) {
             $this->bindValueList($params);
             $this->bindValueList($params);
         }
         }
-        $start = \microtime(true);
+        $start  = \microtime(true);
         $result = parent::execute();
         $result = parent::execute();
         $this->db->saveQuery($this->queryString, \microtime(true) - $start);
         $this->db->saveQuery($this->queryString, \microtime(true) - $start);
         return $result;
         return $result;

+ 14 - 4
app/Core/ErrorHandler.php

@@ -150,7 +150,10 @@ class ErrorHandler
             }
             }
         }
         }
 
 
-        if (isset($this->error['type']) && ! $this->logged) {
+        if (
+            isset($this->error['type'])
+            && ! $this->logged
+        ) {
             $this->log($this->error);
             $this->log($this->error);
         }
         }
 
 
@@ -205,11 +208,15 @@ EOT;
         if (1 == \ini_get('display_errors')) {
         if (1 == \ini_get('display_errors')) {
             echo '<p>' . $this->e($this->message($error)) . '</p>';
             echo '<p>' . $this->e($this->message($error)) . '</p>';
 
 
-            if (isset($error['trace']) && \is_array($error['trace'])) {
+            if (
+                isset($error['trace'])
+                && \is_array($error['trace'])
+            ) {
                 echo '<div><p>Trace:</p><ol>';
                 echo '<div><p>Trace:</p><ol>';
 
 
                 foreach ($error['trace'] as $cur) {
                 foreach ($error['trace'] as $cur) {
-                    if (isset($cur['file'], $cur['line'], $error['file'], $error['line'])
+                    if (
+                        isset($cur['file'], $cur['line'], $error['file'], $error['line'])
                         && $error['line'] === $cur['line']
                         && $error['line'] === $cur['line']
                         && $error['file'] === $cur['file']
                         && $error['file'] === $cur['file']
                     ) {
                     ) {
@@ -223,7 +230,10 @@ EOT;
                     }
                     }
                     $line .= ($cur['function'] ?? 'unknown') . '(';
                     $line .= ($cur['function'] ?? 'unknown') . '(';
 
 
-                    if (! empty($cur['args']) && \is_array($cur['args'])) {
+                    if (
+                        ! empty($cur['args'])
+                        && \is_array($cur['args'])
+                    ) {
                         $comma = '';
                         $comma = '';
 
 
                         foreach($cur['args'] as $arg) {
                         foreach($cur['args'] as $arg) {

+ 12 - 3
app/Core/File.php

@@ -152,7 +152,10 @@ class File
 
 
         if ('*' === $matches[3]) {
         if ('*' === $matches[3]) {
             $matches[3] = $this->ext;
             $matches[3] = $this->ext;
-        } elseif ('(' === $matches[3][0] && ')' === $matches[3][\strlen($matches[3]) - 1]) {
+        } elseif (
+            '(' === $matches[3][0]
+            && ')' === $matches[3][\strlen($matches[3]) - 1]
+        ) {
             $matches[3] = \explode('|', \substr($matches[3], 1, -1));
             $matches[3] = \explode('|', \substr($matches[3], 1, -1));
 
 
             if (1 === \count($matches[3])) {
             if (1 === \count($matches[3])) {
@@ -254,7 +257,10 @@ class File
     {
     {
         $info = $this->pathinfo($path);
         $info = $this->pathinfo($path);
 
 
-        if (null === $info || ! $this->dirProc($info['dirname'])) {
+        if (
+            null === $info
+            || ! $this->dirProc($info['dirname'])
+        ) {
             return false;
             return false;
         }
         }
 
 
@@ -265,7 +271,10 @@ class File
                 ++$i;
                 ++$i;
                 $info['filename'] = $old . '_' . $i;
                 $info['filename'] = $old . '_' . $i;
             }
             }
-        } elseif (! $this->rewrite && \file_exists($info['dirname'] . $info['filename'] . '.' . $info['extension'])) {
+        } elseif (
+            ! $this->rewrite
+            && \file_exists($info['dirname'] . $info['filename'] . '.' . $info['extension'])
+        ) {
             $this->error = 'Such file already exists';
             $this->error = 'Such file already exists';
             return false;
             return false;
         }
         }

+ 5 - 2
app/Core/Files.php

@@ -141,7 +141,7 @@ class Files
         }
         }
 
 
         if (\is_string($to)) {
         if (\is_string($to)) {
-            $to = \trim($to);
+            $to   = \trim($to);
             $unit = \strtoupper($to[0]);
             $unit = \strtoupper($to[0]);
             $expo = \strpos($this->units, $unit);
             $expo = \strpos($this->units, $unit);
 
 
@@ -213,7 +213,10 @@ class Files
             $result = [];
             $result = [];
             foreach ($file['tmp_name'] as $key => $value) {
             foreach ($file['tmp_name'] as $key => $value) {
                 // изображение не было отправлено
                 // изображение не было отправлено
-                if ('' === $file['name'][$key] && empty($file['size'][$key])) {
+                if (
+                    '' === $file['name'][$key]
+                    && empty($file['size'][$key])
+                ) {
                     continue;
                     continue;
                 }
                 }
 
 

+ 22 - 10
app/Core/Func.php

@@ -96,10 +96,14 @@ class Func
     public function getFoldersWithFile(string $dir, string $file): array
     public function getFoldersWithFile(string $dir, string $file): array
     {
     {
         $result = [];
         $result = [];
-        if (\is_dir($dir) && ($dh = \opendir($dir)) !== false) {
-            while (($entry = \readdir($dh)) !== false) {
-                if (isset($entry[0])
-                    && $entry[0] !== '.'
+        if (
+            \is_dir($dir)
+            && false !== ($dh = \opendir($dir))
+        ) {
+            while (false !== ($entry = \readdir($dh))) {
+                if (
+                    isset($entry[0])
+                    && '.' !== $entry[0]
                     && \is_dir("{$dir}/{$entry}")
                     && \is_dir("{$dir}/{$entry}")
                     && \is_file("{$dir}/{$entry}/{$file}")
                     && \is_file("{$dir}/{$entry}/{$file}")
                 ) {
                 ) {
@@ -131,13 +135,13 @@ class Func
         } else {
         } else {
             if ($cur > 0) {
             if ($cur > 0) {
                 $pages[] = [\ForkBB\__($info, $cur, $all), 'info', null];
                 $pages[] = [\ForkBB\__($info, $cur, $all), 'info', null];
-                $cur = \min(\max(1, $cur), $all);
+                $cur     = \min(\max(1, $cur), $all);
                 if ($cur > 1) {
                 if ($cur > 1) {
                     $pages[] = [$this->c->Router->link($marker, ['page' => $cur - 1] + $args), 'prev', null];
                     $pages[] = [$this->c->Router->link($marker, ['page' => $cur - 1] + $args), 'prev', null];
                 }
                 }
-                $tpl = [1 => 1];
+                $tpl   = [1 => 1];
                 $start = $cur < 6 ? 2 : $cur - 2;
                 $start = $cur < 6 ? 2 : $cur - 2;
-                $end = $all - $cur < 5 ? $all : $cur + 3;
+                $end   = $all - $cur < 5 ? $all : $cur + 3;
                 for ($i = $start; $i < $end; ++$i) {
                 for ($i = $start; $i < $end; ++$i) {
                     $tpl[$i] = $i;
                     $tpl[$i] = $i;
                 }
                 }
@@ -159,7 +163,10 @@ class Func
                 }
                 }
                 $k = $i;
                 $k = $i;
             }
             }
-            if ($cur > 0 && $cur < $all) {
+            if (
+                $cur > 0
+                && $cur < $all
+            ) {
                 $pages[] = [$this->c->Router->link($marker, ['page' => $cur + 1] + $args), 'next', null];
                 $pages[] = [$this->c->Router->link($marker, ['page' => $cur + 1] + $args), 'next', null];
             }
             }
         }
         }
@@ -179,9 +186,14 @@ class Func
 
 
         foreach (\explode(',', $str) as $step) {
         foreach (\explode(',', $str) as $step) {
             $dsr = \explode(';', $step, 2);
             $dsr = \explode(';', $step, 2);
-            if (isset($dsr[1])) {
+            if (
+                isset($dsr[1])) {
                 $q = \trim(\ltrim(\ltrim($dsr[1], 'q '), '='));
                 $q = \trim(\ltrim(\ltrim($dsr[1], 'q '), '='));
-                if (! \is_numeric($q) || $q < 0 || $q > 1) {
+                if (
+                    ! \is_numeric($q)
+                    || $q < 0
+                    || $q > 1
+                ) {
                     continue;
                     continue;
                 }
                 }
                 $q = (float) $q;
                 $q = (float) $q;

+ 13 - 4
app/Core/Image.php

@@ -39,7 +39,10 @@ class Image extends File
     {
     {
         parent::__construct($path, $options);
         parent::__construct($path, $options);
 
 
-        if (! \extension_loaded('gd') || ! \function_exists('\\imagecreatetruecolor')) {
+        if (
+            ! \extension_loaded('gd')
+            || ! \function_exists('\\imagecreatetruecolor')
+        ) {
             throw new FileException('GD library not connected');
             throw new FileException('GD library not connected');
         }
         }
 
 
@@ -85,10 +88,16 @@ class Image extends File
         }
         }
         \imagecolortransparent($image, $color);
         \imagecolortransparent($image, $color);
         $palette = \imagecolorstotal($this->image);
         $palette = \imagecolorstotal($this->image);
-        if ($palette > 0 && ! \imagetruecolortopalette($image, true, $palette)) {
+        if (
+            $palette > 0
+            && ! \imagetruecolortopalette($image, true, $palette)
+        ) {
             throw new FileException('Failed to convert image to palette');
             throw new FileException('Failed to convert image to palette');
         }
         }
-        if (false === \imagealphablending($image, false) || false === \imagesavealpha($image, true)) {
+        if (
+            false === \imagealphablending($image, false)
+            || false === \imagesavealpha($image, true)
+        ) {
             throw new FileException('Failed to adjust image');
             throw new FileException('Failed to adjust image');
         }
         }
         if (false === \imagecopyresampled($image, $this->image, 0, 0, 0, 0, $width, $height, $oldW, $oldH)) {
         if (false === \imagecopyresampled($image, $this->image, 0, 0, 0, 0, $width, $height, $oldW, $oldH)) {
@@ -141,7 +150,7 @@ class Image extends File
                 break;
                 break;
             case 'png':
             case 'png':
                 $quality = \floor((100 - $this->quality) / 11);
                 $quality = \floor((100 - $this->quality) / 11);
-                $result = @\imagepng($this->image, $path, $quality);
+                $result  = @\imagepng($this->image, $path, $quality);
                 break;
                 break;
             case 'gif':
             case 'gif':
                 $result = @\imagegif($this->image, $path);
                 $result = @\imagegif($this->image, $path);

+ 36 - 26
app/Core/Lang.php

@@ -45,7 +45,10 @@ class Lang
      */
      */
     public function get(string $message, string $lang = null)
     public function get(string $message, string $lang = null)
     {
     {
-        if ($lang && isset($this->tr[$lang][$message])) {
+        if (
+            $lang
+            && isset($this->tr[$lang][$message])
+        ) {
             return $this->tr[$lang][$message];
             return $this->tr[$lang][$message];
         }
         }
 
 
@@ -77,7 +80,7 @@ class Lang
         $lang = $lang ?: $this->c->user->language;
         $lang = $lang ?: $this->c->user->language;
         $path = $path ?: $this->c->DIR_LANG;
         $path = $path ?: $this->c->DIR_LANG;
         do {
         do {
-            $flag = true;
+            $flag     = true;
             $fullPath = $path . '/'. $lang . '/' . $name . '.po';
             $fullPath = $path . '/'. $lang . '/' . $name . '.po';
             if (\is_file($fullPath)) {
             if (\is_file($fullPath)) {
                 $file = \file_get_contents($fullPath);
                 $file = \file_get_contents($fullPath);
@@ -87,7 +90,7 @@ class Lang
                     $this->tr[$lang] = $this->arrayFromStr($file);
                     $this->tr[$lang] = $this->arrayFromStr($file);
                 }
                 }
                 $flag = false;
                 $flag = false;
-            } elseif ($lang === 'en') {
+            } elseif ('en' === $lang) {
                 $flag = false;
                 $flag = false;
             }
             }
             $lang = 'en';
             $lang = 'en';
@@ -107,14 +110,14 @@ class Lang
      */
      */
     protected function arrayFromStr(string $str): array
     protected function arrayFromStr(string $str): array
     {
     {
-        $lines = \explode("\n", $str);
-        $count = \count($lines);
-        $result = [];
-        $cur = [];
-        $curComm = null;
-        $curVal = '';
+        $lines    = \explode("\n", $str);
+        $count    = \count($lines);
+        $result   = [];
+        $cur      = [];
+        $curComm  = null;
+        $curVal   = '';
         $nplurals = 2;
         $nplurals = 2;
-        $plural = '($n != 1);';
+        $plural   = '($n != 1);';
 
 
         for ($i = 0; $i < $count; ++$i) {
         for ($i = 0; $i < $count; ++$i) {
             $line = \trim($lines[$i]);
             $line = \trim($lines[$i]);
@@ -143,7 +146,10 @@ class Lang
                 // перевод
                 // перевод
                 } else {
                 } else {
                     // множественный
                     // множественный
-                    if (isset($cur['msgid_plural'][0]) || isset($cur[1][0])) {
+                    if (
+                        isset($cur['msgid_plural'][0])
+                        || isset($cur[1][0])
+                    ) {
                         if (! isset($cur[1][0])) {
                         if (! isset($cur[1][0])) {
                             $cur[1] = $cur['msgid_plural'];
                             $cur[1] = $cur['msgid_plural'];
                         }
                         }
@@ -162,7 +168,7 @@ class Lang
                         }
                         }
 
 
                         if (isset($curVal)) {
                         if (isset($curVal)) {
-                            $curVal['plural'] = $plural;
+                            $curVal['plural']      = $plural;
                             $result[$cur['msgid']] = $curVal;
                             $result[$cur['msgid']] = $curVal;
                         }
                         }
 
 
@@ -173,16 +179,16 @@ class Lang
                 }
                 }
 
 
                 $curComm = null;
                 $curComm = null;
-                $curVal = '';
-                $cur = [];
+                $curVal  = '';
+                $cur     = [];
                 continue;
                 continue;
 
 
             // комментарий
             // комментарий
-            } elseif ($line[0] == '#') {
+            } elseif ('#' == $line[0]) {
                 continue;
                 continue;
 
 
             // многострочное содержимое
             // многострочное содержимое
-            } elseif ($line[0] == '"') {
+            } elseif ('"' == $line[0]) {
                 if (isset($curComm)) {
                 if (isset($curComm)) {
                     $curVal .= $this->originalLine($line);
                     $curVal .= $this->originalLine($line);
                 }
                 }
@@ -194,47 +200,47 @@ class Lang
             }
             }
 
 
             // выделение команды
             // выделение команды
-            $v = \explode(' ', $line, 2);
+            $v       = \explode(' ', $line, 2);
             $command = $v[0];
             $command = $v[0];
-            $v = isset($v[1]) ? $this->originalLine(\trim($v[1])) : '';
+            $v       = isset($v[1]) ? $this->originalLine(\trim($v[1])) : '';
 
 
             switch ($command) {
             switch ($command) {
                 case 'msgctxt':
                 case 'msgctxt':
                 case 'msgid':
                 case 'msgid':
                 case 'msgid_plural':
                 case 'msgid_plural':
                     $curComm = $command;
                     $curComm = $command;
-                    $curVal = $v;
+                    $curVal  = $v;
                     break;
                     break;
 
 
                 case 'msgstr':
                 case 'msgstr':
                 case 'msgstr[0]':
                 case 'msgstr[0]':
                     $curComm = 0;
                     $curComm = 0;
-                    $curVal = $v;
+                    $curVal  = $v;
                     break;
                     break;
 
 
                 case 'msgstr[1]':
                 case 'msgstr[1]':
                     $curComm = 1;
                     $curComm = 1;
-                    $curVal = $v;
+                    $curVal  = $v;
                     break;
                     break;
 
 
                 case 'msgstr[2]':
                 case 'msgstr[2]':
                     $curComm = 2;
                     $curComm = 2;
-                    $curVal = $v;
+                    $curVal  = $v;
                     break;
                     break;
 
 
                 case 'msgstr[3]':
                 case 'msgstr[3]':
                     $curComm = 3;
                     $curComm = 3;
-                    $curVal = $v;
+                    $curVal  = $v;
                     break;
                     break;
 
 
                 case 'msgstr[4]':
                 case 'msgstr[4]':
                     $curComm = 4;
                     $curComm = 4;
-                    $curVal = $v;
+                    $curVal  = $v;
                     break;
                     break;
 
 
                 case 'msgstr[5]':
                 case 'msgstr[5]':
                     $curComm = 5;
                     $curComm = 5;
-                    $curVal = $v;
+                    $curVal  = $v;
                     break;
                     break;
 
 
                 default:
                 default:
@@ -255,7 +261,11 @@ class Lang
      */
      */
     protected function originalLine(string $line): string
     protected function originalLine(string $line): string
     {
     {
-        if (isset($line[1]) && $line[0] == '"' && $line[\strlen($line) - 1] == '"') {
+        if (
+            isset($line[1])
+            && '"' == $line[0]
+            && '"' == $line[\strlen($line) - 1]
+        ) {
             $line = \substr($line, 1, -1);
             $line = \substr($line, 1, -1);
         }
         }
         return \str_replace(
         return \str_replace(

+ 53 - 21
app/Core/Mail.php

@@ -63,9 +63,16 @@ class Mail
      */
      */
     public function __construct($host, $user, $pass, $ssl, $eol)
     public function __construct($host, $user, $pass, $ssl, $eol)
     {
     {
-        if (\is_string($host) && \strlen(\trim($host)) > 0 ) {
+        if (
+            \is_string($host)
+            && \strlen(\trim($host)) > 0
+        ) {
             list($host, $port) = \explode(':', $host);
             list($host, $port) = \explode(':', $host);
-            if (empty($port) || $port < 1 || $port > 65535) {
+            if (
+                empty($port)
+                || $port < 1
+                || $port > 65535
+            ) {
                 $port = 25;
                 $port = 25;
             }
             }
             $this->smtp = [
             $this->smtp = [
@@ -91,7 +98,8 @@ class Mail
      */
      */
     public function valid($email, bool $strict = false, bool $idna = false)
     public function valid($email, bool $strict = false, bool $idna = false)
     {
     {
-        if (! \is_string($email)
+        if (
+            ! \is_string($email)
             || \mb_strlen($email, 'UTF-8') > 80 //???? for DB
             || \mb_strlen($email, 'UTF-8') > 80 //???? for DB
             || ! \preg_match('%^(?!\.)((?:(?:^|\.)(?>"(?!\s)(?:\x5C[^\x00-\x1F]|[^\x00-\x1F\x5C"])++(?<!\s)"|[a-zA-Z0-9!#$\%&\'*+/=?^_`{|}~-]+))+)@([^\x00-\x1F\s@]++)$%Du', $email, $matches)
             || ! \preg_match('%^(?!\.)((?:(?:^|\.)(?>"(?!\s)(?:\x5C[^\x00-\x1F]|[^\x00-\x1F\x5C"])++(?<!\s)"|[a-zA-Z0-9!#$\%&\'*+/=?^_`{|}~-]+))+)@([^\x00-\x1F\s@]++)$%Du', $email, $matches)
             || \mb_strlen($matches[1], 'UTF-8') > 64
             || \mb_strlen($matches[1], 'UTF-8') > 64
@@ -101,7 +109,10 @@ class Mail
         $local  = $matches[1];
         $local  = $matches[1];
         $domain = $matches[2];
         $domain = $matches[2];
 
 
-        if ('[' === $domain[0] && ']' === \substr($domain, -1)) {
+        if (
+            '[' === $domain[0]
+            && ']' === \substr($domain, -1)
+        ) {
             if (1 === \strpos($domain, 'IPv6:')) {
             if (1 === \strpos($domain, 'IPv6:')) {
                 $prefix = 'IPv6:';
                 $prefix = 'IPv6:';
                 $ip     = \substr($domain, 6, -1);
                 $ip     = \substr($domain, 6, -1);
@@ -120,11 +131,17 @@ class Mail
             $ip          = null;
             $ip          = null;
             $domainASCII = $domain = \mb_strtolower($domain, 'UTF-8');
             $domainASCII = $domain = \mb_strtolower($domain, 'UTF-8');
 
 
-            if (\preg_match('%[\x80-\xFF]%', $domain) && \function_exists('\\idn_to_ascii')) {
+            if (
+                \preg_match('%[\x80-\xFF]%', $domain)
+                && \function_exists('\\idn_to_ascii')
+            ) {
                 $domainASCII = \idn_to_ascii($domain, 0, \INTL_IDNA_VARIANT_UTS46);
                 $domainASCII = \idn_to_ascii($domain, 0, \INTL_IDNA_VARIANT_UTS46);
             }
             }
 
 
-            if ('localhost' == $domain || ! \preg_match('%^(?:(?:xn\-\-)?[a-z0-9]+(?:\-[a-z0-9]+)*(?:$|\.(?!$)))+$%', $domainASCII)) {
+            if (
+                'localhost' == $domain
+                || ! \preg_match('%^(?:(?:xn\-\-)?[a-z0-9]+(?:\-[a-z0-9]+)*(?:$|\.(?!$)))+$%', $domainASCII)
+            ) {
                 return false;
                 return false;
             }
             }
         }
         }
@@ -249,7 +266,10 @@ class Mail
      */
      */
     protected function formatAddress($email, string $name = null): string
     protected function formatAddress($email, string $name = null): string
     {
     {
-        if (! \is_string($name) || \strlen(\trim($name)) == 0) {
+        if (
+            ! \is_string($name)
+            || 0 == \strlen(\trim($name))
+        ) {
             return $email;
             return $email;
         } else {
         } else {
             $name = $this->encodeText($this->filterName($name));
             $name = $this->encodeText($this->filterName($name));
@@ -373,16 +393,16 @@ class Mail
         if (! isset($this->headers['Subject'])) {
         if (! isset($this->headers['Subject'])) {
             throw new MailException('The subject of the email is empty.');
             throw new MailException('The subject of the email is empty.');
         }
         }
-        if (trim($this->message) == '') {
+        if ('' == \trim($this->message)) {
             throw new MailException('The body of the email is empty.');
             throw new MailException('The body of the email is empty.');
         }
         }
 
 
         $this->headers = \array_replace($this->headers, [
         $this->headers = \array_replace($this->headers, [
-            'Date' => \gmdate('r'),
-            'MIME-Version' => '1.0',
+            'Date'                      => \gmdate('r'),
+            'MIME-Version'              => '1.0',
             'Content-transfer-encoding' => '8bit',
             'Content-transfer-encoding' => '8bit',
-            'Content-type' => 'text/plain; charset=utf-8',
-            'X-Mailer' => 'ForkBB Mailer',
+            'Content-type'              => 'text/plain; charset=utf-8',
+            'X-Mailer'                  => 'ForkBB Mailer',
         ]);
         ]);
 
 
         if (\is_array($this->smtp)) {
         if (\is_array($this->smtp)) {
@@ -399,7 +419,7 @@ class Mail
      */
      */
     protected function mail(): bool
     protected function mail(): bool
     {
     {
-        $to = \implode(', ', $this->to);
+        $to      = \implode(', ', $this->to);
         $subject = $this->headers['Subject'];
         $subject = $this->headers['Subject'];
         $headers = $this->headers;
         $headers = $this->headers;
         unset($headers['Subject']);
         unset($headers['Subject']);
@@ -434,7 +454,7 @@ class Mail
     {
     {
         // подлючение
         // подлючение
         if (! \is_resource($this->connect)) {
         if (! \is_resource($this->connect)) {
-            if (($connect = @\fsockopen($this->smtp['host'], $this->smtp['port'], $errno, $errstr, 5)) === false) {
+            if (false === ($connect = @\fsockopen($this->smtp['host'], $this->smtp['port'], $errno, $errstr, 5))) {
                 throw new SmtpException('Couldn\'t connect to smtp host "' . $this->smtp['host'] . ':' . $this->smtp['port'] . '" (' . $errno . ') (' . $errstr . ').');
                 throw new SmtpException('Couldn\'t connect to smtp host "' . $this->smtp['host'] . ':' . $this->smtp['port'] . '" (' . $errno . ') (' . $errstr . ').');
             }
             }
             \stream_set_timeout($connect, 5);
             \stream_set_timeout($connect, 5);
@@ -467,9 +487,12 @@ class Mail
                 $this->smtpData('EHLO ' . $this->hostname(), '250');
                 $this->smtpData('EHLO ' . $this->hostname(), '250');
                 return;
                 return;
             case 0:
             case 0:
-                if ($this->smtp['user'] != '' && $this->smtp['pass'] != '') {
+                if (
+                    '' != $this->smtp['user']
+                    && '' != $this->smtp['pass']
+                ) {
                    $code = $this->smtpData('EHLO ' . $this->hostname(), ['250', '500', '501', '502', '550']);
                    $code = $this->smtpData('EHLO ' . $this->hostname(), ['250', '500', '501', '502', '550']);
-                   if ($code === '250') {
+                   if ('250' === $code) {
                        $this->smtpData('AUTH LOGIN', '334');
                        $this->smtpData('AUTH LOGIN', '334');
                        $this->smtpData(\base64_encode($this->smtp['user']), '334');
                        $this->smtpData(\base64_encode($this->smtp['user']), '334');
                        $this->smtpData(\base64_encode($this->smtp['pass']), '235');
                        $this->smtpData(\base64_encode($this->smtp['pass']), '235');
@@ -498,22 +521,28 @@ class Mail
     protected function smtpData(string $data, $code): string
     protected function smtpData(string $data, $code): string
     {
     {
         if (\is_resource($this->connect)) {
         if (\is_resource($this->connect)) {
-            if (@\fwrite($this->connect, $data . $this->EOL) === false) {
+            if (false === @\fwrite($this->connect, $data . $this->EOL)) {
                 throw new SmtpException('Couldn\'t send data to mail server.');
                 throw new SmtpException('Couldn\'t send data to mail server.');
             }
             }
         }
         }
         $response = '';
         $response = '';
         while (\is_resource($this->connect) && ! \feof($this->connect)) {
         while (\is_resource($this->connect) && ! \feof($this->connect)) {
-            if (($get = @\fgets($this->connect, 512)) === false) {
+            if (false === ($get = @\fgets($this->connect, 512))) {
                 throw new SmtpException('Couldn\'t get mail server response codes.');
                 throw new SmtpException('Couldn\'t get mail server response codes.');
             }
             }
             $response .= $get;
             $response .= $get;
-            if (isset($get[3]) && $get[3] === ' ') {
+            if (
+                isset($get[3])
+                && ' ' === $get[3]
+            ) {
                 $return = \substr($get, 0, 3);
                 $return = \substr($get, 0, 3);
                 break;
                 break;
             }
             }
         }
         }
-        if ($code !== null && ! \in_array($return, (array) $code)) {
+        if (
+            null !== $code
+            && ! \in_array($return, (array) $code)
+        ) {
             throw new SmtpException('Unable to send email. Response of mail server: "' . $get . '"');
             throw new SmtpException('Unable to send email. Response of mail server: "' . $get . '"');
         }
         }
         return $return;
         return $return;
@@ -529,7 +558,10 @@ class Mail
     protected function getEmailFrom(string $str): string
     protected function getEmailFrom(string $str): string
     {
     {
         $match = \explode('" <', $str);
         $match = \explode('" <', $str);
-        if (\count($match) == 2 && \substr($match[1], -1) == '>') {
+        if (
+            2 == \count($match)
+            && '>' == \substr($match[1], -1)
+        ) {
             return \rtrim($match[1], '>');
             return \rtrim($match[1], '>');
         } else {
         } else {
             return $str;
             return $str;

+ 27 - 17
app/Core/Parser.php

@@ -31,13 +31,20 @@ class Parser extends Parserus
      */
      */
     protected function init(): void
     protected function init(): void
     {
     {
-        if ($this->c->config->p_message_bbcode == '1' || $this->c->config->p_sig_bbcode == '1') {
+        if (
+            '1' == $this->c->config->p_message_bbcode
+            || '1' == $this->c->config->p_sig_bbcode
+        ) {
             $bbcodes = include $this->c->DIR_CONFIG . '/defaultBBCode.php';
             $bbcodes = include $this->c->DIR_CONFIG . '/defaultBBCode.php';
             $this->setBBCodes($bbcodes);
             $this->setBBCodes($bbcodes);
         }
         }
 
 
-        if ($this->c->user->show_smilies == '1'
-            && ($this->c->config->o_smilies_sig == '1' || $this->c->config->o_smilies == '1')
+        if (
+            '1' == $this->c->user->show_smilies
+            && (
+                '1' == $this->c->config->o_smilies_sig
+                || '1' == $this->c->config->o_smilies
+            )
         ) {
         ) {
             $smilies = $this->c->smilies->list; //????
             $smilies = $this->c->smilies->list; //????
 
 
@@ -52,8 +59,8 @@ class Parser extends Parserus
         }
         }
 
 
         $this->setAttr('baseUrl', $this->c->BASE_URL);
         $this->setAttr('baseUrl', $this->c->BASE_URL);
-        $this->setAttr('showImg', $this->c->user->show_img != '0');
-        $this->setAttr('showImgSign', $this->c->user->show_img_sig != '0');
+        $this->setAttr('showImg', '0' != $this->c->user->show_img);
+        $this->setAttr('showImgSign', '0' != $this->c->user->show_img_sig);
     }
     }
 
 
     /**
     /**
@@ -65,7 +72,7 @@ class Parser extends Parserus
      */
      */
     public function addBBCode(array $bb): self
     public function addBBCode(array $bb): self
     {
     {
-        if ($bb['tag'] == 'quote') {
+        if ('quote' == $bb['tag']) {
             $bb['self nesting'] = (int) $this->c->config->o_quote_depth;
             $bb['self nesting'] = (int) $this->c->config->o_quote_depth;
         }
         }
         return parent::addBBCode($bb);
         return parent::addBBCode($bb);
@@ -84,11 +91,11 @@ class Parser extends Parserus
     public function prepare(string $text, bool $isSignature = false): string
     public function prepare(string $text, bool $isSignature = false): string
     {
     {
         if ($isSignature) {
         if ($isSignature) {
-            $whiteList = $this->c->config->p_sig_bbcode == '1' ? $this->c->BBCODE_INFO['forSign'] : [];
-            $blackList = $this->c->config->p_sig_img_tag == '1' ? [] : ['img'];
+            $whiteList = '1' == $this->c->config->p_sig_bbcode ? $this->c->BBCODE_INFO['forSign'] : [];
+            $blackList = '1' == $this->c->config->p_sig_img_tag ? [] : ['img'];
         } else {
         } else {
-            $whiteList = $this->c->config->p_message_bbcode == '1' ? null : [];
-            $blackList = $this->c->config->p_message_img_tag == '1' ? [] : ['img'];
+            $whiteList = '1' == $this->c->config->p_message_bbcode ? null : [];
+            $blackList = '1' == $this->c->config->p_message_img_tag ? [] : ['img'];
         }
         }
 
 
         $this->setAttr('isSign', $isSignature)
         $this->setAttr('isSign', $isSignature)
@@ -97,7 +104,7 @@ class Parser extends Parserus
              ->parse($text, ['strict' => true])
              ->parse($text, ['strict' => true])
              ->stripEmptyTags(" \n\t\r\v", true);
              ->stripEmptyTags(" \n\t\r\v", true);
 
 
-        if ($this->c->config->o_make_links == '1') {
+        if ('1' == $this->c->config->o_make_links) {
             $this->detectUrls();
             $this->detectUrls();
         }
         }
 
 
@@ -116,8 +123,8 @@ class Parser extends Parserus
     {
     {
         // при null предполагается брать данные после prepare()
         // при null предполагается брать данные после prepare()
         if (null !== $text) {
         if (null !== $text) {
-            $whiteList = $this->c->config->p_message_bbcode == '1' ? null : [];
-            $blackList = $this->c->config->p_message_img_tag == '1' ? [] : ['img'];
+            $whiteList = '1' == $this->c->config->p_message_bbcode ? null : [];
+            $blackList = '1' == $this->c->config->p_message_img_tag ? [] : ['img'];
 
 
             $this->setAttr('isSign', false)
             $this->setAttr('isSign', false)
                  ->setWhiteList($whiteList)
                  ->setWhiteList($whiteList)
@@ -125,7 +132,10 @@ class Parser extends Parserus
                  ->parse($text);
                  ->parse($text);
         }
         }
 
 
-        if (! $hideSmilies && $this->c->config->o_smilies == '1') {
+        if (
+            ! $hideSmilies
+            && '1' == $this->c->config->o_smilies
+        ) {
             $this->detectSmilies();
             $this->detectSmilies();
         }
         }
 
 
@@ -143,8 +153,8 @@ class Parser extends Parserus
     {
     {
         // при null предполагается брать данные после prepare()
         // при null предполагается брать данные после prepare()
         if (null !== $text) {
         if (null !== $text) {
-            $whiteList = $this->c->config->p_sig_bbcode == '1' ? $this->c->BBCODE_INFO['forSign'] : [];
-            $blackList = $this->c->config->p_sig_img_tag == '1' ? [] : ['img'];
+            $whiteList = '1' == $this->c->config->p_sig_bbcode ? $this->c->BBCODE_INFO['forSign'] : [];
+            $blackList = '1' == $this->c->config->p_sig_img_tag ? [] : ['img'];
 
 
             $this->setAttr('isSign', true)
             $this->setAttr('isSign', true)
                  ->setWhiteList($whiteList)
                  ->setWhiteList($whiteList)
@@ -152,7 +162,7 @@ class Parser extends Parserus
                  ->parse($text);
                  ->parse($text);
         }
         }
 
 
-        if ($this->c->config->o_smilies_sig == '1') {
+        if ('1' == $this->c->config->o_smilies_sig) {
             $this->detectSmilies();
             $this->detectSmilies();
         }
         }
 
 

+ 41 - 14
app/Core/Router.php

@@ -93,10 +93,11 @@ class Router
      */
      */
     public function validate($url, string $defMarker, array $defArgs = []): string
     public function validate($url, string $defMarker, array $defArgs = []): string
     {
     {
-        if (\is_string($url)
+        if (
+            \is_string($url)
             && \parse_url($url, PHP_URL_HOST) === $this->host
             && \parse_url($url, PHP_URL_HOST) === $this->host
             && ($route = $this->route('GET', \rawurldecode(\parse_url($url, \PHP_URL_PATH))))
             && ($route = $this->route('GET', \rawurldecode(\parse_url($url, \PHP_URL_PATH))))
-            && $route[0] === self::OK
+            && self::OK === $route[0]
         ) {
         ) {
             if (isset($route[3])) {
             if (isset($route[3])) {
                 return $this->link($route[3], $route[2]);
                 return $this->link($route[3], $route[2]);
@@ -139,7 +140,10 @@ class Router
             // значение есть
             // значение есть
             if (isset($args[$name])) {
             if (isset($args[$name])) {
                 // кроме page = 1
                 // кроме page = 1
-                if ($name !== 'page' || $args[$name] !== 1) {
+                if (
+                    'page' !== $name
+                    || 1 !== $args[$name]
+                ) {
                     $data['{' . $name . '}'] = \rawurlencode(\str_replace($this->subSearch, $this->subRepl, $args[$name]));
                     $data['{' . $name . '}'] = \rawurlencode(\str_replace($this->subSearch, $this->subRepl, $args[$name]));
                     continue;
                     continue;
                 }
                 }
@@ -169,9 +173,15 @@ class Router
      */
      */
     public function route(string $method, string $uri): array
     public function route(string $method, string $uri): array
     {
     {
-        $head = $method == 'HEAD';
-
-        if (empty($this->methods[$method]) && (! $head || empty($this->methods['GET']))) {
+        $head = 'HEAD' == $method;
+
+        if (
+            empty($this->methods[$method])
+            && (
+                ! $head
+                || empty($this->methods['GET'])
+            )
+        ) {
             return [self::NOT_IMPLEMENTED];
             return [self::NOT_IMPLEMENTED];
         }
         }
 
 
@@ -189,7 +199,10 @@ class Router
             if (isset($this->statical[$uri][$method])) {
             if (isset($this->statical[$uri][$method])) {
                 list($handler, $marker) = $this->statical[$uri][$method];
                 list($handler, $marker) = $this->statical[$uri][$method];
                 return [self::OK, $handler, [], $marker];
                 return [self::OK, $handler, [], $marker];
-            } elseif ($head && isset($this->statical[$uri]['GET'])) {
+            } elseif (
+                $head
+                && isset($this->statical[$uri]['GET'])
+            ) {
                 list($handler, $marker) = $this->statical[$uri]['GET'];
                 list($handler, $marker) = $this->statical[$uri]['GET'];
                 return [self::OK, $handler, [], $marker];
                 return [self::OK, $handler, [], $marker];
             } else {
             } else {
@@ -197,7 +210,7 @@ class Router
             }
             }
         }
         }
 
 
-        $pos = \strpos($uri, '/', 1);
+        $pos  = \strpos($uri, '/', 1);
         $base = false === $pos ? $uri : \substr($uri, 0, $pos);
         $base = false === $pos ? $uri : \substr($uri, 0, $pos);
 
 
         if (isset($this->dynamic[$base])) {
         if (isset($this->dynamic[$base])) {
@@ -208,7 +221,10 @@ class Router
 
 
                 if (isset($data[$method])) {
                 if (isset($data[$method])) {
                     list($handler, $keys, $marker) = $data[$method];
                     list($handler, $keys, $marker) = $data[$method];
-                } elseif ($head && isset($data['GET'])) {
+                } elseif (
+                    $head
+                    && isset($data['GET'])
+                ) {
                     list($handler, $keys, $marker) = $data['GET'];
                     list($handler, $keys, $marker) = $data['GET'];
                 } else {
                 } else {
                     $allowed += \array_keys($data);
                     $allowed += \array_keys($data);
@@ -301,11 +317,15 @@ class Router
 
 
         $s = 1;
         $s = 1;
         $base = $parts[0];
         $base = $parts[0];
-        if ($parts[0] === '/') {
-            $s = 2;
+        if ('/' === $parts[0]) {
+            $s     = 2;
             $base .= $parts[1];
             $base .= $parts[1];
         }
         }
-        if (isset($parts[$s]) && $parts[$s] !== '/' && $parts[$s] !== '[') {
+        if (
+            isset($parts[$s])
+            && '/' !== $parts[$s]
+            && '[' !== $parts[$s]
+        ) {
             $base = '/';
             $base = '/';
         }
         }
 
 
@@ -329,7 +349,11 @@ class Router
                         if (! isset($data[1])) {
                         if (! isset($data[1])) {
                             $data[1] = '[^/\x00-\x1f]+';
                             $data[1] = '[^/\x00-\x1f]+';
                         }
                         }
-                        if ($data[0] === '' || $data[1] === '' || \is_numeric($data[0][0])) {
+                        if (
+                            '' === $data[0]
+                            || '' === $data[1]
+                            || \is_numeric($data[0][0])
+                        ) {
                             return null;
                             return null;
                         }
                         }
                         $pattern .= '(?P<' . $data[0] . '>' . $data[1] . ')';
                         $pattern .= '(?P<' . $data[0] . '>' . $data[1] . ')';
@@ -381,7 +405,10 @@ class Router
                 }
                 }
             }
             }
         }
         }
-        if ($var || $s) {
+        if (
+            $var
+            || $s
+        ) {
             return null;
             return null;
         }
         }
         $pattern .= '$%D';
         $pattern .= '$%D';

+ 4 - 1
app/Core/Secury.php

@@ -24,7 +24,10 @@ class Secury
      */
      */
     public function __construct(array $hmac)
     public function __construct(array $hmac)
     {
     {
-        if (empty($hmac['salt']) || empty($hmac['algo'])) {
+        if (
+            empty($hmac['salt'])
+            || empty($hmac['algo'])
+        ) {
             throw new InvalidArgumentException('Algorithm and salt can not be empty');
             throw new InvalidArgumentException('Algorithm and salt can not be empty');
         }
         }
         if (! \in_array($hmac['algo'], \hash_hmac_algos())) {
         if (! \in_array($hmac['algo'], \hash_hmac_algos())) {

+ 73 - 18
app/Core/Validator.php

@@ -187,7 +187,10 @@ class Validator
                  $rules[$vs[0]] = $vs[1] ?? '';
                  $rules[$vs[0]] = $vs[1] ?? '';
             }
             }
             if (isset($suffix)) {
             if (isset($suffix)) {
-                if (isset($this->rules[$field]['array']) && ! \is_array($this->rules[$field]['array'])) {
+                if (
+                    isset($this->rules[$field]['array'])
+                    && ! \is_array($this->rules[$field]['array'])
+                ) {
                     $this->rules[$field]['array'] = [];
                     $this->rules[$field]['array'] = [];
                 }
                 }
                 $this->rules[$field]['array'][$suffix] = $rules;
                 $this->rules[$field]['array'][$suffix] = $rules;
@@ -294,15 +297,25 @@ class Validator
         }
         }
 
 
         $value = null;
         $value = null;
-        if (! isset($this->raw[$field]) && isset($this->rules[$field]['required'])) {
+        if (
+            ! isset($this->raw[$field])
+            && isset($this->rules[$field]['required'])
+        ) {
             $rules = ['required' => ''];
             $rules = ['required' => ''];
         } else {
         } else {
             $rules = $this->rules[$field];
             $rules = $this->rules[$field];
             if (isset($this->raw[$field])) {
             if (isset($this->raw[$field])) {
                 $value = $this->c->Secury->replInvalidChars($this->raw[$field]);
                 $value = $this->c->Secury->replInvalidChars($this->raw[$field]);
                 // пустое поле в соответствии с правилом 'required' должно быть равно null
                 // пустое поле в соответствии с правилом 'required' должно быть равно null
-                if ((\is_string($value) && 0 === \strlen(\preg_replace('%^\s+|\s+$%u', '', $value)))
-                    || (\is_array($value) && empty($value))
+                if (
+                    (
+                        \is_string($value)
+                        && 0 === \strlen(\preg_replace('%^\s+|\s+$%u', '', $value))
+                    )
+                    || (
+                        \is_array($value)
+                        && empty($value)
+                    )
                 ) {
                 ) {
                     $value = null;
                     $value = null;
                 }
                 }
@@ -564,7 +577,10 @@ class Validator
     {
     {
         if (null === $value) {
         if (null === $value) {
             return null;
             return null;
-        } elseif (\is_numeric($value) && \is_int(0 + $value)) {
+        } elseif (
+            \is_numeric($value)
+            && \is_int(0 + $value)
+        ) {
             return (int) $value;
             return (int) $value;
         } else {
         } else {
             $this->addError('The :alias must be integer');
             $this->addError('The :alias must be integer');
@@ -574,7 +590,10 @@ class Validator
 
 
     protected function vArray(Validator $v, $value, $attr)
     protected function vArray(Validator $v, $value, $attr)
     {
     {
-        if (null !== $value && ! \is_array($value)) {
+        if (
+            null !== $value
+            && ! \is_array($value)
+        ) {
             $this->addError('The :alias must be array');
             $this->addError('The :alias must be array');
             return null;
             return null;
         } elseif (! $attr) {
         } elseif (! $attr) {
@@ -627,8 +646,15 @@ class Validator
     {
     {
         if (\is_string($value)) {
         if (\is_string($value)) {
             $isBytes = \strpos($attr, 'bytes');
             $isBytes = \strpos($attr, 'bytes');
-            if (($isBytes && \strlen($value) < (int) $attr)
-                || (! $isBytes && \mb_strlen($value, 'UTF-8') < $attr)
+            if (
+                (
+                    $isBytes
+                    && \strlen($value) < (int) $attr
+                )
+                || (
+                    ! $isBytes
+                    && \mb_strlen($value, 'UTF-8') < $attr
+                )
             ) {
             ) {
                 $this->addError('The :alias minimum is :attr characters');
                 $this->addError('The :alias minimum is :attr characters');
             }
             }
@@ -651,8 +677,15 @@ class Validator
     {
     {
         if (\is_string($value)) {
         if (\is_string($value)) {
             $isBytes = \strpos($attr, 'bytes');
             $isBytes = \strpos($attr, 'bytes');
-            if (($isBytes && \strlen($value) > (int) $attr)
-                || (! $isBytes && \mb_strlen($value, 'UTF-8') > $attr)
+            if (
+                (
+                    $isBytes
+                    && \strlen($value) > (int) $attr
+                )
+                || (
+                    ! $isBytes
+                    && \mb_strlen($value, 'UTF-8') > $attr
+                )
             ) {
             ) {
                 $this->addError('The :alias maximum is :attr characters');
                 $this->addError('The :alias maximum is :attr characters');
             }
             }
@@ -689,7 +722,10 @@ class Validator
         if (! \is_array($args)) {
         if (! \is_array($args)) {
             $args = [];
             $args = [];
         }
         }
-        if (! \is_string($value) || ! $this->c->Csrf->verify($value, $attr, $args)) {
+        if (
+            ! \is_string($value)
+            || ! $this->c->Csrf->verify($value, $attr, $args)
+        ) {
             $this->addError('Bad token', 'e');
             $this->addError('Bad token', 'e');
             return null;
             return null;
         } else {
         } else {
@@ -712,7 +748,10 @@ class Validator
 
 
     protected function vSame(Validator $v, $value, $attr)
     protected function vSame(Validator $v, $value, $attr)
     {
     {
-        if (! $this->getStatus($attr) || $value === $this->__get($attr)) {
+        if (
+            ! $this->getStatus($attr)
+            || $value === $this->__get($attr)
+        ) {
             return $value;
             return $value;
         } else {
         } else {
             $this->addError('The :alias must be same with original');
             $this->addError('The :alias must be same with original');
@@ -722,8 +761,12 @@ class Validator
 
 
     protected function vRegex(Validator $v, $value, $attr)
     protected function vRegex(Validator $v, $value, $attr)
     {
     {
-        if (null !== $value
-            && (! \is_string($value) || ! \preg_match($attr, $value))
+        if (
+            null !== $value
+            && (
+                ! \is_string($value)
+                || ! \preg_match($attr, $value)
+            )
         ) {
         ) {
             $this->addError('The :alias is not valid format');
             $this->addError('The :alias is not valid format');
             return null;
             return null;
@@ -739,7 +782,10 @@ class Validator
 
 
     protected function vIn(Validator $v, $value, $attr)
     protected function vIn(Validator $v, $value, $attr)
     {
     {
-        if (null !== $value && ! \in_array($value, \explode(',', $attr))) {
+        if (
+            null !== $value
+            && ! \in_array($value, \explode(',', $attr))
+        ) {
             $this->addError('The :alias contains an invalid value');
             $this->addError('The :alias contains an invalid value');
         }
         }
         return $value;
         return $value;
@@ -747,7 +793,10 @@ class Validator
 
 
     protected function vNotIn(Validator $v, $value, $attr)
     protected function vNotIn(Validator $v, $value, $attr)
     {
     {
-        if (null !== $value && \in_array($value, \explode(',', $attr))) {
+        if (
+            null !== $value
+            && \in_array($value, \explode(',', $attr))
+        ) {
             $this->addError('The :alias contains an invalid value');
             $this->addError('The :alias contains an invalid value');
         }
         }
         return $value;
         return $value;
@@ -791,7 +840,10 @@ class Validator
                     return null;
                     return null;
                 }
                 }
             }
             }
-        } elseif (null !== $value && null === $this->c->Files->isImage($value)) {
+        } elseif (
+            null !== $value
+            && null === $this->c->Files->isImage($value)
+        ) {
             $this->addError('The :alias not contains image');
             $this->addError('The :alias not contains image');
             return null;
             return null;
         }
         }
@@ -802,7 +854,10 @@ class Validator
     {
     {
         if (null === $value) {
         if (null === $value) {
             return null;
             return null;
-        } elseif (! \is_string($value) || false === \strtotime($value . ' UTC')) {
+        } elseif (
+            ! \is_string($value)
+            || false === \strtotime($value . ' UTC')
+        ) {
             $v->addError('The :alias does not contain a date');
             $v->addError('The :alias does not contain a date');
             return \is_string($value) ? $value : null;
             return \is_string($value) ? $value : null;
         }
         }

+ 1 - 1
app/Core/View.php

@@ -61,7 +61,7 @@ use function \ForkBB\{__, cens, num, dt, utc, size};
 ?>
 ?>
 EOD;
 EOD;
 
 
-        if (\strpos($value, '<!-- inline -->') === false) {
+        if (false === \strpos($value, '<!-- inline -->')) {
             return $perfix . $value;
             return $perfix . $value;
         }
         }
         return $perfix . \preg_replace_callback(
         return $perfix . \preg_replace_callback(

+ 4 - 1
app/Models/BanList/Check.php

@@ -28,7 +28,10 @@ class Check extends Method
             $now = \time();
             $now = \time();
 
 
             foreach ($this->model->banList as $id => $row) {
             foreach ($this->model->banList as $id => $row) {
-                if (null !== $row['expire'] && $row['expire'] < $now) {
+                if (
+                    null !== $row['expire']
+                    && $row['expire'] < $now
+                ) {
                     $ids[] = $id;
                     $ids[] = $id;
                 }
                 }
             }
             }

+ 4 - 1
app/Models/BanList/Filter.php

@@ -28,7 +28,10 @@ class Filter extends Method
             if (! isset($fields[$field])) {
             if (! isset($fields[$field])) {
                 throw new InvalidArgumentException("The '{$field}' field is not found");
                 throw new InvalidArgumentException("The '{$field}' field is not found");
             }
             }
-            if ('ASC' !== $dir && 'DESC' !== $dir) {
+            if (
+                'ASC' !== $dir
+                && 'DESC' !== $dir
+            ) {
                 throw new InvalidArgumentException('The sort direction is not defined');
                 throw new InvalidArgumentException('The sort direction is not defined');
             }
             }
             $orderBy[] = "b.{$field} {$dir}";
             $orderBy[] = "b.{$field} {$dir}";

+ 7 - 2
app/Models/BanList/Insert.php

@@ -17,7 +17,8 @@ class Insert extends Method
      */
      */
     public function insert(array $ban): BanList
     public function insert(array $ban): BanList
     {
     {
-        if (isset($ban['id'])
+        if (
+            isset($ban['id'])
             || ! isset($ban['username'])
             || ! isset($ban['username'])
             || ! isset($ban['ip'])
             || ! isset($ban['ip'])
             || ! isset($ban['email'])
             || ! isset($ban['email'])
@@ -27,7 +28,11 @@ class Insert extends Method
             throw new InvalidArgumentException('Expected an array with a ban description');
             throw new InvalidArgumentException('Expected an array with a ban description');
         }
         }
 
 
-        if ('' == $ban['username'] && '' == $ban['ip'] && '' == $ban['email']) {
+        if (
+            '' == $ban['username']
+            && '' == $ban['ip']
+            && '' == $ban['email']
+        ) {
             throw new InvalidArgumentException('Empty ban');
             throw new InvalidArgumentException('Empty ban');
         }
         }
 
 

+ 9 - 2
app/Models/BanList/IsBanned.php

@@ -18,11 +18,18 @@ class IsBanned extends Method
     {
     {
         $name  = $this->model->trimToNull($user->username, true);
         $name  = $this->model->trimToNull($user->username, true);
         // бан имени пользователя
         // бан имени пользователя
-        if (null !== $name && isset($this->model->userList[$name])) {
+        if (
+            null !== $name
+            && isset($this->model->userList[$name])
+        ) {
             return $this->model->userList[$name];
             return $this->model->userList[$name];
         }
         }
         // бан email
         // бан email
-        if ($user->isGuest && ! empty($this->model->emailList) && $user->email && $user->email_normal) { // ????
+        if (
+            $user->isGuest
+            && ! empty($this->model->emailList)
+            && $user->email && $user->email_normal
+        ) { // ????
             $email = $this->model->trimToNull($user->email_normal);
             $email = $this->model->trimToNull($user->email_normal);
             $stage = 0;
             $stage = 0;
 
 

+ 4 - 1
app/Models/BanList/Load.php

@@ -61,7 +61,10 @@ class Load extends Method
             $message = $this->model->trimToNull($row['message']);
             $message = $this->model->trimToNull($row['message']);
             $expire  = empty($row['expire']) ? null : $row['expire'];
             $expire  = empty($row['expire']) ? null : $row['expire'];
 
 
-            if (null === $message && null === $expire) {
+            if (
+                null === $message
+                && null === $expire
+            ) {
                 continue;
                 continue;
             }
             }
 
 

+ 1 - 1
app/Models/BanList/Model.php

@@ -42,7 +42,7 @@ class Model extends ParentModel
     public function trimToNull($val, bool $toLower = false): ?string
     public function trimToNull($val, bool $toLower = false): ?string
     {
     {
         $val = \trim($val);
         $val = \trim($val);
-        if ($val == '') {
+        if ('' == $val) {
             return null;
             return null;
         } elseif ($toLower) {
         } elseif ($toLower) {
             return \mb_strtolower($val, 'UTF-8');
             return \mb_strtolower($val, 'UTF-8');

+ 7 - 2
app/Models/BanList/Update.php

@@ -17,7 +17,8 @@ class Update extends Method
      */
      */
     public function update(array $ban): BanList
     public function update(array $ban): BanList
     {
     {
-        if (empty($ban['id'])
+        if (
+            empty($ban['id'])
             || ! isset($ban['username'])
             || ! isset($ban['username'])
             || ! isset($ban['ip'])
             || ! isset($ban['ip'])
             || ! isset($ban['email'])
             || ! isset($ban['email'])
@@ -27,7 +28,11 @@ class Update extends Method
             throw new InvalidArgumentException('Expected an array with a ban description');
             throw new InvalidArgumentException('Expected an array with a ban description');
         }
         }
 
 
-        if ('' == $ban['username'] && '' == $ban['ip'] && '' == $ban['email']) {
+        if (
+            '' == $ban['username']
+            && '' == $ban['ip']
+            && '' == $ban['email']
+        ) {
             throw new InvalidArgumentException('Empty ban');
             throw new InvalidArgumentException('Empty ban');
         }
         }
 
 

+ 3 - 3
app/Models/Censorship/Model.php

@@ -15,9 +15,9 @@ class Model extends ParentModel
     {
     {
         if ('1' == $this->c->config->o_censoring) {
         if ('1' == $this->c->config->o_censoring) {
             if ($this->c->Cache->has('censorship')) {
             if ($this->c->Cache->has('censorship')) {
-                $list = $this->c->Cache->get('censorship');
-                $this->searchList   = $list['searchList'];
-                $this->replaceList  = $list['replaceList'];
+                $list              = $this->c->Cache->get('censorship');
+                $this->searchList  = $list['searchList'];
+                $this->replaceList = $list['replaceList'];
             } else {
             } else {
                 $this->refresh();
                 $this->refresh();
             }
             }

+ 3 - 3
app/Models/Censorship/Refresh.php

@@ -15,15 +15,15 @@ class Refresh extends Method
      */
      */
     public function refresh(): Censorship
     public function refresh(): Censorship
     {
     {
-        $stmt = $this->c->DB->query('SELECT ce.id, ce.search_for, ce.replace_with FROM ::censoring AS ce');
+        $stmt    = $this->c->DB->query('SELECT ce.id, ce.search_for, ce.replace_with FROM ::censoring AS ce');
         $search  = [];
         $search  = [];
         $replace = [];
         $replace = [];
         while ($row = $stmt->fetch()) {
         while ($row = $stmt->fetch()) {
             $search[$row['id']]  = '%(?<![\p{L}\p{N}])(' . \str_replace('\*', '[\p{L}\p{N}]*?', \preg_quote($row['search_for'], '%')).')(?![\p{L}\p{N}])%iu';
             $search[$row['id']]  = '%(?<![\p{L}\p{N}])(' . \str_replace('\*', '[\p{L}\p{N}]*?', \preg_quote($row['search_for'], '%')).')(?![\p{L}\p{N}])%iu';
             $replace[$row['id']] = $row['replace_with'];
             $replace[$row['id']] = $row['replace_with'];
         }
         }
-        $this->model->searchList   = $search;
-        $this->model->replaceList  = $replace;
+        $this->model->searchList  = $search;
+        $this->model->replaceList = $replace;
         $this->c->Cache->set('censorship', [
         $this->c->Cache->set('censorship', [
             'searchList'  => $search,
             'searchList'  => $search,
             'replaceList' => $replace,
             'replaceList' => $replace,

+ 2 - 1
app/Models/Censorship/Save.php

@@ -28,7 +28,8 @@ class Save extends Method
                     $forDel[] = $id;
                     $forDel[] = $id;
                 }
                 }
             } elseif (isset($words[$id])) {
             } elseif (isset($words[$id])) {
-                if ($list[$id]['search_for'] !== $words[$id]['search_for']
+                if (
+                    $list[$id]['search_for'] !== $words[$id]['search_for']
                     || $list[$id]['replace_with'] !== $words[$id]['replace_with']
                     || $list[$id]['replace_with'] !== $words[$id]['replace_with']
                 ) {
                 ) {
                     $vars = [
                     $vars = [

+ 6 - 3
app/Models/Cookie/Model.php

@@ -109,13 +109,15 @@ class Model extends ParentModel
     {
     {
         $ckUser = $this->get(self::NAME);
         $ckUser = $this->get(self::NAME);
 
 
-        if (null === $ckUser
+        if (
+            null === $ckUser
             || ! \preg_match('%^(\-)?(\d{1,10})_(\d{10})_([a-f\d]{32,})_([a-f\d]{32,})$%Di', $ckUser, $ms)
             || ! \preg_match('%^(\-)?(\d{1,10})_(\d{10})_([a-f\d]{32,})_([a-f\d]{32,})$%Di', $ckUser, $ms)
         ) {
         ) {
             return;
             return;
         }
         }
 
 
-        if (2 > $ms[2]
+        if (
+            2 > $ms[2]
             || \time() > $ms[3]
             || \time() > $ms[3]
             || ! \hash_equals(
             || ! \hash_equals(
                     $this->c->Secury->hmac($ms[1] . $ms[2] . $ms[3] . $ms[4], $this->key1),
                     $this->c->Secury->hmac($ms[1] . $ms[2] . $ms[3] . $ms[4], $this->key1),
@@ -161,7 +163,8 @@ class Model extends ParentModel
             return $this->deleteUser();
             return $this->deleteUser();
         }
         }
 
 
-        if ($remember
+        if (
+            $remember
             || (null === $remember
             || (null === $remember
                 && $this->uId === (int) $user->id
                 && $this->uId === (int) $user->id
                 && $this->uRemember
                 && $this->uRemember

+ 16 - 5
app/Models/DataModel.php

@@ -97,7 +97,7 @@ class DataModel extends Model
     public function __set(string $name, $value): void
     public function __set(string $name, $value): void
     {
     {
         // без отслеживания
         // без отслеживания
-        if (\strpos($name, '__') === 0) {
+        if (0 === \strpos($name, '__')) {
             $track = null;
             $track = null;
             $name  = \substr($name, 2);
             $name  = \substr($name, 2);
         // с отслеживанием
         // с отслеживанием
@@ -107,7 +107,11 @@ class DataModel extends Model
                 $track = true;
                 $track = true;
                 $old   = $this->zAttrs[$name];
                 $old   = $this->zAttrs[$name];
                 // fix
                 // fix
-                if (\is_int($value) && \is_numeric($old) && \is_int(0 + $old)) {
+                if (
+                    \is_int($value)
+                    && \is_numeric($old)
+                    && \is_int(0 + $old)
+                ) {
                     $old = (int) $old;
                     $old = (int) $old;
                 }
                 }
             }
             }
@@ -123,8 +127,15 @@ class DataModel extends Model
             return;
             return;
         }
         }
 
 
-        if ((! $track && \array_key_exists($name, $this->zAttrs))
-            || ($track && $old !== $this->zAttrs[$name])
+        if (
+            (
+                ! $track
+                && \array_key_exists($name, $this->zAttrs)
+            )
+            || (
+                $track
+                && $old !== $this->zAttrs[$name]
+            )
         ) {
         ) {
             $this->zModFlags[$name] = true;
             $this->zModFlags[$name] = true;
         }
         }
@@ -140,7 +151,7 @@ class DataModel extends Model
     public function __get(string $name)
     public function __get(string $name)
     {
     {
         // без вычисления
         // без вычисления
-        if (\strpos($name, '__') === 0) {
+        if (0 === \strpos($name, '__')) {
             return $this->getAttr(\substr($name, 2));
             return $this->getAttr(\substr($name, 2));
         // с вычислениями
         // с вычислениями
         } else {
         } else {

+ 5 - 2
app/Models/Forum/LoadTree.php

@@ -61,7 +61,7 @@ class LoadTree extends Action
                            f.last_post, f.last_post_id, f.last_poster, f.last_topic
                            f.last_post, f.last_post_id, f.last_poster, f.last_topic
                     FROM ::forums AS f
                     FROM ::forums AS f
                     WHERE id IN (?ai:forums)';
                     WHERE id IN (?ai:forums)';
-        } elseif ($this->c->config->o_forum_subscriptions == '1') {
+        } elseif ('1' == $this->c->config->o_forum_subscriptions) {
             $sql = 'SELECT f.id, f.forum_desc, f.num_topics, f.sort_by, f.num_posts,
             $sql = 'SELECT f.id, f.forum_desc, f.num_topics, f.sort_by, f.num_posts,
                            f.last_post, f.last_post_id, f.last_poster, f.last_topic,
                            f.last_post, f.last_post_id, f.last_poster, f.last_topic,
                            mof.mf_mark_all_read, s.user_id AS is_subscribed
                            mof.mf_mark_all_read, s.user_id AS is_subscribed
@@ -91,7 +91,10 @@ class LoadTree extends Action
      */
      */
     protected function checkForNew(array $list): void
     protected function checkForNew(array $list): void
     {
     {
-        if (empty($list) || $this->c->user->isGuest) {
+        if (
+            empty($list)
+            || $this->c->user->isGuest
+        ) {
             return;
             return;
         }
         }
 
 

+ 4 - 1
app/Models/Forum/Manager.php

@@ -48,7 +48,10 @@ class Manager extends ManagerModel
             $list = $this->refresh($group);
             $list = $this->refresh($group);
         } else {
         } else {
             $result = $this->c->Cache->get('forums_' . $gid);
             $result = $this->c->Cache->get('forums_' . $gid);
-            if (empty($result['time']) || $result['time'] < $mark) {
+            if (
+                empty($result['time'])
+                || $result['time'] < $mark
+            ) {
                 $list = $this->refresh($group);
                 $list = $this->refresh($group);
             } else {
             } else {
                 $list = $result['list'];
                 $list = $result['list'];

+ 19 - 7
app/Models/Forum/Model.php

@@ -20,7 +20,10 @@ class Model extends DataModel
      */
      */
     protected function getparent(): ?Forum
     protected function getparent(): ?Forum
     {
     {
-        if (null === $this->parent_forum_id && $this->id !== 0) {
+        if (
+            null === $this->parent_forum_id
+            && 0 !== $this->id
+        ) {
             throw new RuntimeException('Parent is not defined');
             throw new RuntimeException('Parent is not defined');
         }
         }
 
 
@@ -35,8 +38,8 @@ class Model extends DataModel
     protected function getcanCreateTopic(): bool
     protected function getcanCreateTopic(): bool
     {
     {
         $user = $this->c->user;
         $user = $this->c->user;
-        return $this->post_topics == 1
-            || (null === $this->post_topics && $user->g_post_topics == 1)
+        return 1 == $this->post_topics
+            || (null === $this->post_topics && 1 == $user->g_post_topics)
             || $user->isAdmin
             || $user->isAdmin
             || $user->isModerator($this);
             || $user->isModerator($this);
     }
     }
@@ -162,11 +165,14 @@ class Model extends DataModel
     protected function getmoderators(): array
     protected function getmoderators(): array
     {
     {
         $attr = $this->getAttr('moderators');
         $attr = $this->getAttr('moderators');
-        if (empty($attr) || ! \is_array($attr)) {
+        if (
+            empty($attr)
+            || ! \is_array($attr)
+        ) {
             return [];
             return [];
         }
         }
 
 
-        if ($this->c->user->g_view_users == '1') {
+        if ('1' == $this->c->user->g_view_users) {
             foreach($attr as $id => &$cur) {
             foreach($attr as $id => &$cur) {
                 $cur = [
                 $cur = [
                     $this->c->Router->link('User', [
                     $this->c->Router->link('User', [
@@ -192,7 +198,10 @@ class Model extends DataModel
     public function modAdd(User ...$users): void
     public function modAdd(User ...$users): void
     {
     {
         $attr = $this->getAttr('moderators');
         $attr = $this->getAttr('moderators');
-        if (empty($attr) || ! \is_array($attr)) {
+        if (
+            empty($attr)
+            || ! \is_array($attr)
+        ) {
             $attr = [];
             $attr = [];
         }
         }
 
 
@@ -216,7 +225,10 @@ class Model extends DataModel
     public function modDelete(User ...$users): void
     public function modDelete(User ...$users): void
     {
     {
         $attr = $this->getAttr('moderators');
         $attr = $this->getAttr('moderators');
-        if (empty($attr) || ! \is_array($attr)) {
+        if (
+            empty($attr)
+            || ! \is_array($attr)
+        ) {
             return;
             return;
         }
         }
 
 

+ 4 - 1
app/Models/Forum/Refresh.php

@@ -87,7 +87,10 @@ class Refresh extends Action
         $sub = [];
         $sub = [];
         $all = [];
         $all = [];
         foreach ($list as $id => $f) {
         foreach ($list as $id => $f) {
-            if ($parent === $id || $parent !== $f['parent_forum_id']) {
+            if (
+                $parent === $id
+                || $parent !== $f['parent_forum_id']
+            ) {
                 continue;
                 continue;
             }
             }
             $sub[] = $id;
             $sub[] = $id;

+ 5 - 2
app/Models/Forum/Save.php

@@ -34,7 +34,7 @@ class Save extends Action
                 continue;
                 continue;
             }
             }
             $vars[] = $values[$name];
             $vars[] = $values[$name];
-            $set[] = $name . '=?' . $fileds[$name];
+            $set[]  = $name . '=?' . $fileds[$name];
         }
         }
         if (empty($set)) {
         if (empty($set)) {
             return $forum;
             return $forum;
@@ -44,7 +44,10 @@ class Save extends Action
         $this->c->DB->exec('UPDATE ::forums SET ' . \implode(', ', $set) . ' WHERE id=?i', $vars);
         $this->c->DB->exec('UPDATE ::forums SET ' . \implode(', ', $set) . ' WHERE id=?i', $vars);
 
 
         // модификация категории у потомков при ее изменении
         // модификация категории у потомков при ее изменении
-        if (\in_array('cat_id', $modified) && $forum->descendants) {
+        if (
+            \in_array('cat_id', $modified)
+            && $forum->descendants
+        ) {
             foreach ($forum->descendants as $f) {
             foreach ($forum->descendants as $f) {
                 $f->__cat_id = $values['cat_id'];
                 $f->__cat_id = $values['cat_id'];
             }
             }

+ 8 - 2
app/Models/Group/Perm.php

@@ -91,7 +91,10 @@ class Perm extends Action
                 }
                 }
             }
             }
 
 
-            if ($modDef || $modPerm) {
+            if (
+                $modDef
+                || $modPerm
+            ) {
                 $vars = [
                 $vars = [
                     ':gid' => $id,
                     ':gid' => $id,
                     ':fid' => $forum->id,
                     ':fid' => $forum->id,
@@ -167,7 +170,10 @@ class Perm extends Action
      */
      */
     public function copy(Group $from, Group $to): void
     public function copy(Group $from, Group $to): void
     {
     {
-        if ($from->g_id < 1 || $to->g_id < 1) {
+        if (
+            $from->g_id < 1
+            || $to->g_id < 1
+        ) {
             throw new RuntimeException('The group does not have ID');
             throw new RuntimeException('The group does not have ID');
         }
         }
 
 

+ 1 - 1
app/Models/Group/Save.php

@@ -34,7 +34,7 @@ class Save extends Action
                 continue;
                 continue;
             }
             }
             $vars[] = $values[$name];
             $vars[] = $values[$name];
-            $set[] = $name . '=?' . $fileds[$name];
+            $set[]  = $name . '=?' . $fileds[$name];
         }
         }
         if (empty($set)) {
         if (empty($set)) {
             return $group;
             return $group;

+ 1 - 1
app/Models/Online/Info.php

@@ -22,7 +22,7 @@ class Info extends Method
         $this->model->maxTime = $this->c->config->st_max_users_time;
         $this->model->maxTime = $this->c->config->st_max_users_time;
 
 
         $info = [];
         $info = [];
-        if ($this->c->user->g_view_users == '1') {
+        if ('1' == $this->c->user->g_view_users) {
             foreach ($this->model->users as $id => $name) {
             foreach ($this->model->users as $id => $name) {
                 $info[] = [
                 $info[] = [
                     $this->c->Router->link('User', [
                     $this->c->Router->link('User', [

+ 13 - 10
app/Models/Online/Model.php

@@ -41,18 +41,18 @@ class Model extends ParentModel
         if (null === $position) {
         if (null === $position) {
             return $this;
             return $this;
         }
         }
-        $detail = $page->onlineDetail && $this->c->config->o_users_online == '1';
+        $detail = $page->onlineDetail && '1' == $this->c->config->o_users_online;
         $filter = $page->onlineFilter;
         $filter = $page->onlineFilter;
 
 
         $this->updateUser($position);
         $this->updateUser($position);
 
 
-        $all     = 0;
-        $now     = \time();
-        $tOnline = $now - $this->c->config->o_timeout_online;
-        $tVisit  = $now - $this->c->config->o_timeout_visit;
-        $users   = [];
-        $guests  = [];
-        $bots    = [];
+        $all       = 0;
+        $now       = \time();
+        $tOnline   = $now - $this->c->config->o_timeout_online;
+        $tVisit    = $now - $this->c->config->o_timeout_visit;
+        $users     = [];
+        $guests    = [];
+        $bots      = [];
         $needClean = false;
         $needClean = false;
 
 
         if ($detail) {
         if ($detail) {
@@ -86,7 +86,10 @@ class Model extends ParentModel
             }
             }
 
 
             // включен фильтр и проверка не пройдена
             // включен фильтр и проверка не пройдена
-            if ($filter && $cur['o_position'] !== $position) {
+            if (
+                $filter
+                && $cur['o_position'] !== $position
+            ) {
                 continue;
                 continue;
             }
             }
 
 
@@ -94,7 +97,7 @@ class Model extends ParentModel
             if ($cur['user_id'] > 1) {
             if ($cur['user_id'] > 1) {
                 $users[$cur['user_id']] = $cur['ident'];
                 $users[$cur['user_id']] = $cur['ident'];
             // гость
             // гость
-            } elseif ($cur['o_name'] == '') {
+            } elseif ('' == $cur['o_name']) {
                 $guests[] = $cur['ident'];
                 $guests[] = $cur['ident'];
             // бот
             // бот
             } else {
             } else {

+ 47 - 16
app/Models/Page.php

@@ -34,7 +34,7 @@ abstract class Page extends Model
         $this->fTitle       = $container->config->o_board_title;
         $this->fTitle       = $container->config->o_board_title;
         $this->fDescription = $container->config->o_board_desc;
         $this->fDescription = $container->config->o_board_desc;
         $this->fRootLink    = $container->Router->link('Index');
         $this->fRootLink    = $container->Router->link('Index');
-        if ($container->config->o_announcement == '1') {
+        if ('1' == $container->config->o_announcement) {
             $this->fAnnounce = $container->config->o_announcement_message;
             $this->fAnnounce = $container->config->o_announcement_message;
         }
         }
         $this->user         = $this->c->user; // передача текущего юзера в шаблон
         $this->user         = $this->c->user; // передача текущего юзера в шаблон
@@ -62,17 +62,28 @@ abstract class Page extends Model
             'index' => [$r->link('Index'), 'Index']
             'index' => [$r->link('Index'), 'Index']
         ];
         ];
 
 
-        if ($this->user->g_read_board == '1' && $this->user->viewUsers) {
+        if (
+            '1' == $this->user->g_read_board
+            && $this->user->viewUsers
+        ) {
             $nav['userlist'] = [$r->link('Userlist'), 'User list'];
             $nav['userlist'] = [$r->link('Userlist'), 'User list'];
         }
         }
 
 
-        if ($this->c->config->o_rules == '1'
-            && (! $this->user->isGuest || $this->user->g_read_board == '1' || $this->c->config->o_regs_allow == '1')
+        if (
+            '1' == $this->c->config->o_rules
+            && (
+                ! $this->user->isGuest
+                || '1' == $this->user->g_read_board
+                || '1' == $this->c->config->o_regs_allow
+            )
         ) {
         ) {
             $nav['rules'] = [$r->link('Rules'), 'Rules'];
             $nav['rules'] = [$r->link('Rules'), 'Rules'];
         }
         }
 
 
-        if ($this->user->g_read_board == '1' && $this->user->g_search == '1') {
+        if (
+            '1' == $this->user->g_read_board
+            && '1' == $this->user->g_search
+        ) {
             $sub = [];
             $sub = [];
             $sub['latest'] = [
             $sub['latest'] = [
                 $r->link('SearchAction', ['action' => 'latest_active_topics']),
                 $r->link('SearchAction', ['action' => 'latest_active_topics']),
@@ -97,11 +108,17 @@ abstract class Page extends Model
 
 
         if ($this->user->isGuest) {
         if ($this->user->isGuest) {
             $nav['register'] = [$r->link('Register'), 'Register'];
             $nav['register'] = [$r->link('Register'), 'Register'];
-            $nav['login'] = [$r->link('Login'), 'Login'];
+            $nav['login']    = [$r->link('Login'), 'Login'];
         } else {
         } else {
             $nav['profile'] = [$this->user->link, 'Profile'];
             $nav['profile'] = [$this->user->link, 'Profile'];
             // New PMS
             // New PMS
-            if ($this->c->config->o_pms_enabled == '1' && ($this->user->isAdmin || $this->user->messages_new > 0)) { //????
+            if (
+                '1' == $this->c->config->o_pms_enabled
+                && (
+                    $this->user->isAdmin
+                    || $this->user->messages_new > 0
+                )
+            ) { //????
                 $nav['pmsnew'] = ['pmsnew.php', 'PM']; //'<li id="nav"'.((PUN_ACTIVE_PAGE == 'pms_new' || $user['messages_new'] > 0) ? ' class="isactive"' : '').'><a href="pmsnew.php">'.\ForkBB\__('PM').(($user['messages_new'] > 0) ? ' (<span'.((empty($this->c->config->o_pms_flasher) || PUN_ACTIVE_PAGE == 'pms_new') ? '' : ' class="remflasher"' ).'>'.$user['messages_new'].'</span>)' : '').'</a></li>';
                 $nav['pmsnew'] = ['pmsnew.php', 'PM']; //'<li id="nav"'.((PUN_ACTIVE_PAGE == 'pms_new' || $user['messages_new'] > 0) ? ' class="isactive"' : '').'><a href="pmsnew.php">'.\ForkBB\__('PM').(($user['messages_new'] > 0) ? ' (<span'.((empty($this->c->config->o_pms_flasher) || PUN_ACTIVE_PAGE == 'pms_new') ? '' : ' class="remflasher"' ).'>'.$user['messages_new'].'</span>)' : '').'</a></li>';
             }
             }
             // New PMS
             // New PMS
@@ -110,12 +127,13 @@ abstract class Page extends Model
                 $nav['admin'] = [$r->link('Admin'), 'Admin'];
                 $nav['admin'] = [$r->link('Admin'), 'Admin'];
             }
             }
 
 
-            $nav['logout'] = [$r->link('Logout', [
-                'token' => $this->c->Csrf->create('Logout'),
-            ]), 'Logout'];
+            $nav['logout'] = [$r->link('Logout', ['token' => $this->c->Csrf->create('Logout')]), 'Logout'];
         }
         }
 
 
-        if ($this->user->g_read_board == '1' && $this->c->config->o_additional_navlinks != '') {
+        if (
+            '1' == $this->user->g_read_board
+            && '' != $this->c->config->o_additional_navlinks
+        ) {
             // position|name|link[|id]\n
             // position|name|link[|id]\n
             if (\preg_match_all('%^(\d+)\|([^\|\n\r]+)\|([^\|\n\r]+)(?:\|([^\|\n\r]+))?%m', $this->c->config->o_additional_navlinks . "\n", $matches)) {
             if (\preg_match_all('%^(\d+)\|([^\|\n\r]+)\|([^\|\n\r]+)(?:\|([^\|\n\r]+))?%m', $this->c->config->o_additional_navlinks . "\n", $matches)) {
                $k = \count($matches[0]);
                $k = \count($matches[0]);
@@ -143,11 +161,17 @@ abstract class Page extends Model
      */
      */
     protected function maintenance(): void
     protected function maintenance(): void
     {
     {
-        if ($this->c->config->o_maintenance == '1' && $this->user->isAdmin) {
+        if (
+            '1' == $this->c->config->o_maintenance
+            && $this->user->isAdmin
+        ) {
             $this->fIswev = ['w', \ForkBB\__('Maintenance mode enabled', $this->c->Router->link('AdminMaintenance'))];
             $this->fIswev = ['w', \ForkBB\__('Maintenance mode enabled', $this->c->Router->link('AdminMaintenance'))];
         }
         }
 
 
-        if ($this->user->isAdmMod && $this->user->last_report_id < $this->c->reports->lastId()) {
+        if (
+            $this->user->isAdmMod
+            && $this->user->last_report_id < $this->c->reports->lastId()
+        ) {
             $this->fIswev = ['i', \ForkBB\__('New reports', $this->c->Router->link('AdminReports'))];
             $this->fIswev = ['i', \ForkBB\__('New reports', $this->c->Router->link('AdminReports'))];
         }
         }
     }
     }
@@ -233,7 +257,7 @@ abstract class Page extends Model
         } else {
         } else {
             $key .= ':';
             $key .= ':';
         }
         }
-        $attr = $this->getAttr('httpHeaders', []);
+        $attr   = $this->getAttr('httpHeaders', []);
         $attr[] = ["{$key} {$value}", $replace];
         $attr[] = ["{$key} {$value}", $replace];
         $this->setAttr('httpHeaders', $attr);
         $this->setAttr('httpHeaders', $attr);
         return $this;
         return $this;
@@ -304,7 +328,11 @@ abstract class Page extends Model
     {
     {
         $attr = $this->getAttr('fIswev', []);
         $attr = $this->getAttr('fIswev', []);
 
 
-        if (isset($value[0], $value[1]) && \is_string($value[0]) && \is_string($value[1])) {
+        if (
+            isset($value[0], $value[1])
+            && \is_string($value[0])
+            && \is_string($value[1])
+        ) {
             $attr[$value[0]][] = $value[1];
             $attr[$value[0]][] = $value[1];
         } else {
         } else {
             $attr = \array_merge_recursive($attr, $value); // ???? добавить проверку?
             $attr = \array_merge_recursive($attr, $value); // ???? добавить проверку?
@@ -355,7 +383,10 @@ abstract class Page extends Model
                     $crumb        = $crumb->parent;
                     $crumb        = $crumb->parent;
                 } while ($crumb instanceof Model && null !== $crumb->parent);
                 } while ($crumb instanceof Model && null !== $crumb->parent);
             // ссылка (передана массивом)
             // ссылка (передана массивом)
-            } elseif (\is_array($crumb) && isset($crumb[0], $crumb[1])) {
+            } elseif (
+                \is_array($crumb)
+                && isset($crumb[0], $crumb[1])
+            ) {
                 $result[]     = [$crumb[0], $crumb[1], $active];
                 $result[]     = [$crumb[0], $crumb[1], $active];
                 $this->titles = $crumb[1];
                 $this->titles = $crumb[1];
             // строка
             // строка

+ 5 - 1
app/Models/Pages/Admin.php

@@ -56,7 +56,11 @@ class Admin extends Page
         if ($this->c->userRules->banUsers) {
         if ($this->c->userRules->banUsers) {
             $nav['bans'] = [$r->link('AdminBans'), \ForkBB\__('Bans')];
             $nav['bans'] = [$r->link('AdminBans'), \ForkBB\__('Bans')];
         }
         }
-        if ($this->user->isAdmin || $this->c->config->o_report_method == '0' || $this->c->config->o_report_method == '2') {
+        if (
+            $this->user->isAdmin
+            || '0' == $this->c->config->o_report_method
+            || '2' == $this->c->config->o_report_method
+        ) {
             $nav['reports'] = [$r->link('AdminReports'), \ForkBB\__('Reports')];
             $nav['reports'] = [$r->link('AdminReports'), \ForkBB\__('Reports')];
         }
         }
 
 

+ 38 - 9
app/Models/Pages/Admin/Bans.php

@@ -55,7 +55,8 @@ class Bans extends Admin
             return false;
             return false;
         }
         }
 
 
-        if (! \hash_equals($data[1], $this->c->Secury->hash($data[0]))
+        if (
+            ! \hash_equals($data[1], $this->c->Secury->hash($data[0]))
             || ! \is_array($data = \json_decode(\base64_decode($data[0], true), true))
             || ! \is_array($data = \json_decode(\base64_decode($data[0], true), true))
         ) {
         ) {
             return false;
             return false;
@@ -343,7 +344,11 @@ class Bans extends Admin
         $filters = [];
         $filters = [];
 
 
         foreach ($data as $field => $value) {
         foreach ($data as $field => $value) {
-            if ('' == $value || 'order_by' === $field || 'direction' === $field) {
+            if (
+                '' == $value
+                || 'order_by' === $field
+                || 'direction' === $field
+            ) {
                 continue;
                 continue;
             }
             }
 
 
@@ -564,7 +569,10 @@ class Bans extends Admin
             $this->banCount = \count($ids);
             $this->banCount = \count($ids);
             $tmp = $this->c->users->loadByIds($ids);
             $tmp = $this->c->users->loadByIds($ids);
 
 
-            if (\is_array($tmp) && \count($tmp) === $this->banCount) {
+            if (
+                \is_array($tmp)
+                && \count($tmp) === $this->banCount
+            ) {
                 $userList = $tmp; // ???? проверка массива на User'ов?
                 $userList = $tmp; // ???? проверка массива на User'ов?
             } else {
             } else {
                 return $this->c->Message->message('No user ID message');
                 return $this->c->Message->message('No user ID message');
@@ -695,7 +703,11 @@ class Bans extends Admin
 
 
                 $redirect = $this->c->Redirect;
                 $redirect = $this->c->Redirect;
 
 
-                if ($isNew && ! empty($args['uid']) && 1 === $this->banCount) {
+                if (
+                    $isNew
+                    && ! empty($args['uid'])
+                    && 1 === $this->banCount
+                ) {
                     $user = \reset($userList);
                     $user = \reset($userList);
                     $redirect->url($user->link);
                     $redirect->url($user->link);
                 } else {
                 } else {
@@ -713,7 +725,10 @@ class Bans extends Admin
             $user = \reset($userList);
             $user = \reset($userList);
             $data['username'] = $user->username;
             $data['username'] = $user->username;
 
 
-            if ($isNew && 'POST' !== $method) {
+            if (
+                $isNew
+                && 'POST' !== $method
+            ) {
                 $data['email'] = (string) $user->email;
                 $data['email'] = (string) $user->email;
 
 
                 $ip  = (string) $user->registration_ip;
                 $ip  = (string) $user->registration_ip;
@@ -746,7 +761,10 @@ class Bans extends Admin
      */
      */
     public function vUserBan(Validator $v, $username)
     public function vUserBan(Validator $v, $username)
     {
     {
-        if (empty($v->getErrors()) && '' != \trim($username)) {
+        if (
+            empty($v->getErrors())
+            && '' != \trim($username)
+        ) {
             $user = $this->c->users->loadByName($username, true);
             $user = $this->c->users->loadByName($username, true);
 
 
             if (! $user instanceof User) { // ???? может ли вернутся несколько юзеров?
             if (! $user instanceof User) { // ???? может ли вернутся несколько юзеров?
@@ -818,9 +836,15 @@ class Bans extends Admin
         if ('' != \trim($email)) {
         if ('' != \trim($email)) {
             $error = true;
             $error = true;
 
 
-            if (false !== \strpos($email, '@') && false !== $this->c->Mail->valid($email)) {
+            if (
+                false !== \strpos($email, '@')
+                && false !== $this->c->Mail->valid($email)
+            ) {
                 $error = false;
                 $error = false;
-            } elseif ('.' === $email[0] && false !== $this->c->Mail->valid('test@sub' . $email)) {
+            } elseif (
+                '.' === $email[0]
+                && false !== $this->c->Mail->valid('test@sub' . $email)
+            ) {
                 $error = false;
                 $error = false;
             } elseif (false !== $this->c->Mail->valid('test@' . $email)) {
             } elseif (false !== $this->c->Mail->valid('test@' . $email)) {
                 $error = false;
                 $error = false;
@@ -863,7 +887,12 @@ class Bans extends Admin
      */
      */
     public function vSubmitBan(Validator $v, $value)
     public function vSubmitBan(Validator $v, $value)
     {
     {
-        if ($this->banCount < 1 && '' == $v->username && '' == $v->ip && '' == $v->email) {
+        if (
+            $this->banCount < 1
+            && '' == $v->username
+            && '' == $v->ip
+            && '' == $v->email
+        ) {
             $v->addError('Must enter message');
             $v->addError('Must enter message');
         }
         }
 
 

+ 4 - 1
app/Models/Pages/Admin/Categories.php

@@ -158,7 +158,10 @@ class Categories extends Admin
                     'token' => $args,
                     'token' => $args,
                 ]);
                 ]);
 
 
-            if (! $v->validation($_POST) || $v->confirm !== 1) {
+            if (
+                ! $v->validation($_POST)
+                || 1 !== $v->confirm
+            ) {
                 return $this->c->Redirect->page('AdminCategories')->message('No confirm redirect');
                 return $this->c->Redirect->page('AdminCategories')->message('No confirm redirect');
             }
             }
 
 

+ 13 - 3
app/Models/Pages/Admin/Forums.php

@@ -34,7 +34,11 @@ class Forums extends Admin
 
 
                 $indent = \str_repeat(\ForkBB\__('Forum indent'), $f->depth);
                 $indent = \str_repeat(\ForkBB\__('Forum indent'), $f->depth);
 
 
-                if ($f->id === $forum->id || isset($forum->descendants[$f->id]) || $f->redirect_url) {
+                if (
+                    $f->id === $forum->id
+                    || isset($forum->descendants[$f->id])
+                    || $f->redirect_url
+                ) {
                     $options[] = [$f->id, $indent . \ForkBB\__('Forum prefix') . $f->forum_name, true];
                     $options[] = [$f->id, $indent . \ForkBB\__('Forum prefix') . $f->forum_name, true];
                 } else {
                 } else {
                     $options[] = [$f->id, $indent . \ForkBB\__('Forum prefix') . $f->forum_name];
                     $options[] = [$f->id, $indent . \ForkBB\__('Forum prefix') . $f->forum_name];
@@ -218,7 +222,10 @@ class Forums extends Admin
     public function delete(array $args, string $method): Page
     public function delete(array $args, string $method): Page
     {
     {
         $forum = $this->c->forums->get((int) $args['id']);
         $forum = $this->c->forums->get((int) $args['id']);
-        if (! $forum instanceof Forum || $forum->subforums) {
+        if (
+            ! $forum instanceof Forum
+            || $forum->subforums
+        ) {
             return $this->c->Message->message('Bad request');
             return $this->c->Message->message('Bad request');
         }
         }
 
 
@@ -235,7 +242,10 @@ class Forums extends Admin
                     'token' => $args,
                     'token' => $args,
                 ]);
                 ]);
 
 
-            if (! $v->validation($_POST) || $v->confirm !== 1) {
+            if (
+                ! $v->validation($_POST)
+                || 1 !== $v->confirm
+            ) {
                 return $this->c->Redirect->page('AdminForums')->message('No confirm redirect');
                 return $this->c->Redirect->page('AdminForums')->message('No confirm redirect');
             }
             }
 
 

+ 47 - 11
app/Models/Pages/Admin/Groups.php

@@ -32,7 +32,10 @@ class Groups extends Admin
             if (! \in_array($group->g_id, $notForNew)) {
             if (! \in_array($group->g_id, $notForNew)) {
                 $groupsNew[$key] = $group->g_title;
                 $groupsNew[$key] = $group->g_title;
             }
             }
-            if (! \in_array($group->g_id, $notForDefault) && $group->g_moderator == 0) {
+            if (
+                ! \in_array($group->g_id, $notForDefault)
+                && 0 == $group->g_moderator
+            ) {
                 $groupsDefault[$key] = $group->g_title;
                 $groupsDefault[$key] = $group->g_title;
             }
             }
         }
         }
@@ -167,7 +170,10 @@ class Groups extends Admin
     public function edit(array $args, string $method): Page
     public function edit(array $args, string $method): Page
     {
     {
         // начало создания новой группы
         // начало создания новой группы
-        if (empty($args['id']) && empty($args['base'])) {
+        if (
+            empty($args['id'])
+            && empty($args['base'])
+        ) {
             $v = $this->c->Validator->reset()
             $v = $this->c->Validator->reset()
                 ->addRules([
                 ->addRules([
                     'token'     => 'token:AdminGroupsNew',
                     'token'     => 'token:AdminGroupsNew',
@@ -217,7 +223,10 @@ class Groups extends Admin
             $this->classForm = 'creategroup';
             $this->classForm = 'creategroup';
         }
         }
 
 
-        if ('POST' === $method && $next) {
+        if (
+            'POST' === $method
+            && $next
+        ) {
             $reserve = [];
             $reserve = [];
             foreach ($this->groupsList as $key => $cur) {
             foreach ($this->groupsList as $key => $cur) {
                 if ($group->g_id !== $key) {
                 if ($group->g_id !== $key) {
@@ -261,7 +270,11 @@ class Groups extends Admin
                     'g_report_flood'         => 'integer|min:0|max:999999',
                     'g_report_flood'         => 'integer|min:0|max:999999',
                 ]);
                 ]);
 
 
-                if (! $group->groupGuest && ! $group->groupMember && $group->g_id != $this->c->config->o_default_user_group) {
+                if (
+                    ! $group->groupGuest
+                    && ! $group->groupMember
+                    && $group->g_id != $this->c->config->o_default_user_group
+                ) {
                     $v->addRules([
                     $v->addRules([
                         'g_moderator'            => 'integer|in:0,1',
                         'g_moderator'            => 'integer|in:0,1',
                         'g_mod_edit_users'       => 'integer|in:0,1',
                         'g_mod_edit_users'       => 'integer|in:0,1',
@@ -298,14 +311,21 @@ class Groups extends Admin
      */
      */
     public function save(Group $group, Group $baseGroup, array $data): Page
     public function save(Group $group, Group $baseGroup, array $data): Page
     {
     {
-        if (! $group->groupAdmin && isset($data['g_moderator']) && 0 === $data['g_moderator']) {
+        if (
+            ! $group->groupAdmin
+            && isset($data['g_moderator'])
+            && 0 === $data['g_moderator']
+        ) {
             $data['g_mod_edit_users']       = 0;
             $data['g_mod_edit_users']       = 0;
             $data['g_mod_rename_users']     = 0;
             $data['g_mod_rename_users']     = 0;
             $data['g_mod_change_passwords'] = 0;
             $data['g_mod_change_passwords'] = 0;
             $data['g_mod_promote_users']    = 0;
             $data['g_mod_promote_users']    = 0;
             $data['g_mod_ban_users']        = 0;
             $data['g_mod_ban_users']        = 0;
         }
         }
-        if (isset($data['g_promote_next_group']) && $data['g_promote_next_group'] * $data['g_promote_min_posts'] == 0) {
+        if (
+            isset($data['g_promote_next_group'])
+            && 0 == $data['g_promote_next_group'] * $data['g_promote_min_posts']
+        ) {
             $data['g_promote_next_group'] = 0;
             $data['g_promote_next_group'] = 0;
             $data['g_promote_min_posts']  = 0;
             $data['g_promote_min_posts']  = 0;
         }
         }
@@ -398,7 +418,10 @@ class Groups extends Admin
             $options = [0 => \ForkBB\__('Disable promotion')];
             $options = [0 => \ForkBB\__('Disable promotion')];
 
 
             foreach ($this->groupsNew as $key => $title) {
             foreach ($this->groupsNew as $key => $title) {
-                if ($key === $group->g_id || $key === $this->c->GROUP_GUEST) {
+                if (
+                    $key === $group->g_id
+                    || $key === $this->c->GROUP_GUEST
+                ) {
                     continue;
                     continue;
                 }
                 }
                 $options[$key] = $title;
                 $options[$key] = $title;
@@ -423,7 +446,11 @@ class Groups extends Admin
 
 
         $yn = [1 => \ForkBB\__('Yes'), 0 => \ForkBB\__('No')];
         $yn = [1 => \ForkBB\__('Yes'), 0 => \ForkBB\__('No')];
 
 
-        if (! $group->groupGuest && ! $group->groupMember && $group->g_id != $this->c->config->o_default_user_group) {
+        if (
+            ! $group->groupGuest
+            && ! $group->groupMember
+            && $group->g_id != $this->c->config->o_default_user_group
+        ) {
             $fieldset['g_moderator'] = [
             $fieldset['g_moderator'] = [
                 'type'    => 'radio',
                 'type'    => 'radio',
                 'value'   => $group->g_moderator,
                 'value'   => $group->g_moderator,
@@ -634,7 +661,10 @@ class Groups extends Admin
     {
     {
         $group = $this->c->groups->get((int) $args['id']);
         $group = $this->c->groups->get((int) $args['id']);
 
 
-        if (null === $group || ! $group->canDelete) {
+        if (
+            null === $group
+            || ! $group->canDelete
+        ) {
             return $this->c->Message->message('Bad request');
             return $this->c->Message->message('Bad request');
         }
         }
 
 
@@ -643,7 +673,10 @@ class Groups extends Admin
         if ($count) {
         if ($count) {
             $move = 'required|integer|in:';
             $move = 'required|integer|in:';
             foreach ($this->groupsList as $key => $cur) {
             foreach ($this->groupsList as $key => $cur) {
-                if ($key === $this->c->GROUP_GUEST || $key === $group->g_id) {
+                if (
+                    $key === $this->c->GROUP_GUEST
+                    || $key === $group->g_id
+                ) {
                     continue;
                     continue;
                 }
                 }
                 $groups[$key] = $cur[0];
                 $groups[$key] = $cur[0];
@@ -665,7 +698,10 @@ class Groups extends Admin
                     'token' => $args,
                     'token' => $args,
                 ]);
                 ]);
 
 
-            if (! $v->validation($_POST) || $v->confirm !== 1) {
+            if (
+                ! $v->validation($_POST)
+                || 1 !== $v->confirm
+            ) {
                 return $this->c->Redirect->page('AdminGroups')->message('No confirm redirect');
                 return $this->c->Redirect->page('AdminGroups')->message('No confirm redirect');
             }
             }
 
 

+ 17 - 4
app/Models/Pages/Admin/Maintenance.php

@@ -180,7 +180,10 @@ class Maintenance extends Admin
      */
      */
     public function vCheckMessage(Validator $v, $value)
     public function vCheckMessage(Validator $v, $value)
     {
     {
-        if (1 === $v->o_maintenance && 0 === strlen($value)) {
+        if (
+            1 === $v->o_maintenance
+            && 0 === \strlen($value)
+        ) {
             $value = \ForkBB\__('Default maintenance message');
             $value = \ForkBB\__('Default maintenance message');
         }
         }
         return $value;
         return $value;
@@ -211,8 +214,15 @@ class Maintenance extends Admin
             ])->addMessages([
             ])->addMessages([
             ]);
             ]);
 
 
-        if (('POST' === $method && ! $v->validation($_POST))
-            || ('POST' !== $method && ! $v->validation($args))
+        if (
+            (
+                'POST' === $method
+                && ! $v->validation($_POST)
+            )
+            || (
+                'POST' !== $method
+                && ! $v->validation($args)
+            )
         ) {
         ) {
             $this->fIswev = $v->getErrors();
             $this->fIswev = $v->getErrors();
             return $this->view([], 'GET');
             return $this->view([], 'GET');
@@ -220,7 +230,10 @@ class Maintenance extends Admin
 
 
         @\set_time_limit(0);
         @\set_time_limit(0);
 
 
-        if ('POST' === $method && $v->clear) {
+        if (
+            'POST' === $method
+            && $v->clear
+        ) {
             $this->c->search->truncateIndex();
             $this->c->search->truncateIndex();
         }
         }
 
 

+ 4 - 1
app/Models/Pages/Admin/Options.php

@@ -167,7 +167,10 @@ class Options extends Admin
      */
      */
     public function vCheckEmpty(Validator $v, $value, $attr)
     public function vCheckEmpty(Validator $v, $value, $attr)
     {
     {
-        if (0 !== $value && 0 === \strlen($v->$attr)) {
+        if (
+            0 !== $value
+            && 0 === \strlen($v->$attr)
+        ) {
             $value = 0;
             $value = 0;
         }
         }
         return $value;
         return $value;

+ 22 - 10
app/Models/Pages/Admin/Statistics.php

@@ -15,7 +15,7 @@ class Statistics extends Admin
     public function info(): Page
     public function info(): Page
     {
     {
         // Is phpinfo() a disabled function?
         // Is phpinfo() a disabled function?
-        if (\strpos(\strtolower((string) \ini_get('disable_functions')), 'phpinfo') !== false) {
+        if (false !== \strpos(\strtolower((string) \ini_get('disable_functions')), 'phpinfo')) {
             $this->c->Message->message('PHPinfo disabled message', true, 200);
             $this->c->Message->message('PHPinfo disabled message', true, 200);
         }
         }
 
 
@@ -46,11 +46,11 @@ class Statistics extends Admin
             $phpinfo = '- - -';
             $phpinfo = '- - -';
         }
         }
 
 
-        $this->nameTpl   = 'admin/phpinfo';
+        $this->nameTpl    = 'admin/phpinfo';
         $this->mainSuffix = '-one-column';
         $this->mainSuffix = '-one-column';
-        $this->aCrumbs[] = [$this->c->Router->link('AdminInfo'), 'phpinfo()'];
-        $this->aCrumbs[] = [$this->c->Router->link('AdminStatistics'), \ForkBB\__('Server statistics')];
-        $this->phpinfo   = $phpinfo;
+        $this->aCrumbs[]  = [$this->c->Router->link('AdminInfo'), 'phpinfo()'];
+        $this->aCrumbs[]  = [$this->c->Router->link('AdminStatistics'), \ForkBB\__('Server statistics')];
+        $this->phpinfo    = $phpinfo;
 
 
         return $this;
         return $this;
     }
     }
@@ -69,9 +69,12 @@ class Statistics extends Admin
         $this->linkInfo  = $this->c->Router->link('AdminInfo');
         $this->linkInfo  = $this->c->Router->link('AdminInfo');
 
 
         // Get the server load averages (if possible)
         // Get the server load averages (if possible)
-        if (@\file_exists('/proc/loadavg') && \is_readable('/proc/loadavg')) {
+        if (
+            @\file_exists('/proc/loadavg')
+            && \is_readable('/proc/loadavg')
+        ) {
             // We use @ just in case
             // We use @ just in case
-            $fh = @\fopen('/proc/loadavg', 'r');
+            $fh  = @\fopen('/proc/loadavg', 'r');
             $ave = @\fread($fh, 64);
             $ave = @\fread($fh, 64);
             @\fclose($fh);
             @\fclose($fh);
 
 
@@ -84,7 +87,10 @@ class Statistics extends Admin
 
 
             $ave = @\explode(' ', $ave);
             $ave = @\explode(' ', $ave);
             $this->serverLoad = isset($ave[2]) ? $ave[0].' '.$ave[1].' '.$ave[2] : \ForkBB\__('Not available');
             $this->serverLoad = isset($ave[2]) ? $ave[0].' '.$ave[1].' '.$ave[2] : \ForkBB\__('Not available');
-        } elseif (! \in_array(\PHP_OS, ['WINNT', 'WIN32']) && \preg_match('%averages?: ([\d\.]+),?\s+([\d\.]+),?\s+([\d\.]+)%i', @\exec('uptime'), $ave)) {
+        } elseif (
+            ! \in_array(\PHP_OS, ['WINNT', 'WIN32'])
+            && \preg_match('%averages?: ([\d\.]+),?\s+([\d\.]+),?\s+([\d\.]+)%i', @\exec('uptime'), $ave)
+        ) {
             $this->serverLoad = $ave[1].' '.$ave[2].' '.$ave[3];
             $this->serverLoad = $ave[1].' '.$ave[2].' '.$ave[3];
         } else {
         } else {
             $this->serverLoad = \ForkBB\__('Not available');
             $this->serverLoad = \ForkBB\__('Not available');
@@ -101,13 +107,19 @@ class Statistics extends Admin
         $this->tOther    = $stat;
         $this->tOther    = $stat;
 
 
         // Check for the existence of various PHP opcode caches/optimizers
         // Check for the existence of various PHP opcode caches/optimizers
-        if (\ini_get('opcache.enable') && \function_exists('\\opcache_invalidate')) {
+        if (
+            \ini_get('opcache.enable')
+            && \function_exists('\\opcache_invalidate')
+        ) {
             $this->accelerator = 'Zend OPcache';
             $this->accelerator = 'Zend OPcache';
             $this->linkAcc     = 'https://secure.php.net/opcache/';
             $this->linkAcc     = 'https://secure.php.net/opcache/';
         } elseif (\ini_get('wincache.fcenabled')) {
         } elseif (\ini_get('wincache.fcenabled')) {
             $this->accelerator = 'Windows Cache for PHP';
             $this->accelerator = 'Windows Cache for PHP';
             $this->linkAcc     = 'https://secure.php.net/wincache/';
             $this->linkAcc     = 'https://secure.php.net/wincache/';
-        } elseif (\ini_get('apc.enabled') && \function_exists('\\apc_delete_file')) {
+        } elseif (
+            \ini_get('apc.enabled')
+            && \function_exists('\\apc_delete_file')
+        ) {
             $this->accelerator = 'Alternative PHP Cache (APC)'; //???? частичная эмуляция APCu
             $this->accelerator = 'Alternative PHP Cache (APC)'; //???? частичная эмуляция APCu
             $this->linkAcc     = 'https://secure.php.net/apc/';
             $this->linkAcc     = 'https://secure.php.net/apc/';
         } elseif (\ini_get('xcache.cacher')) {
         } elseif (\ini_get('xcache.cacher')) {

+ 2 - 1
app/Models/Pages/Admin/Users.php

@@ -65,7 +65,8 @@ abstract class Users extends Admin
             return false === $ip ? false : ['ip' => $ip];
             return false === $ip ? false : ['ip' => $ip];
         }
         }
 
 
-        if (! \hash_equals($data[1], $this->c->Secury->hash($data[0]))
+        if (
+            ! \hash_equals($data[1], $this->c->Secury->hash($data[0]))
             || ! \is_array($data = \json_decode(\base64_decode($data[0], true), true))
             || ! \is_array($data = \json_decode(\base64_decode($data[0], true), true))
         ) {
         ) {
             return false;
             return false;

+ 18 - 6
app/Models/Pages/Admin/Users/Action.php

@@ -62,9 +62,15 @@ class Action extends Users
                 }
                 }
                 break;
                 break;
             case self::ACTION_CHG:
             case self::ACTION_CHG:
-                if ($profile && ! $this->c->userRules->canChangeGroup($this->c->users->load((int) $args['ids']), true)) {
+                if (
+                    $profile
+                    && ! $this->c->userRules->canChangeGroup($this->c->users->load((int) $args['ids']), true)
+                ) {
                     $error = true;
                     $error = true;
-                } elseif (! $profile && ! $this->c->userRules->changeGroup) {
+                } elseif (
+                    ! $profile
+                    && ! $this->c->userRules->changeGroup
+                ) {
                     $error = true;
                     $error = true;
                 }
                 }
                 break;
                 break;
@@ -120,7 +126,10 @@ class Action extends Users
                     'token' => $args,
                     'token' => $args,
                 ]);
                 ]);
 
 
-            if (! $v->validation($_POST) || $v->confirm !== 1) {
+            if (
+                ! $v->validation($_POST)
+                || 1 !== $v->confirm
+            ) {
                 return $this->c->Redirect->page('AdminUsers')->message('No confirm redirect');
                 return $this->c->Redirect->page('AdminUsers')->message('No confirm redirect');
             }
             }
 
 
@@ -246,7 +255,10 @@ class Action extends Users
             $user = $this->c->users->load((int) $args['ids']);
             $user = $this->c->users->load((int) $args['ids']);
             $link = $this->c->Router->link('EditUserProfile', ['id' => $user->id]);
             $link = $this->c->Router->link('EditUserProfile', ['id' => $user->id]);
 
 
-            if ($user->isAdmin || $user->id === $this->user->id) {
+            if (
+                $user->isAdmin
+                || $user->id === $this->user->id
+            ) {
                 $rulePass = 'required|string:trim|check_password';
                 $rulePass = 'required|string:trim|check_password';
             }
             }
         } else {
         } else {
@@ -271,7 +283,7 @@ class Action extends Users
             $redirect = $this->c->Redirect;
             $redirect = $this->c->Redirect;
 
 
             if ($v->validation($_POST)) {
             if ($v->validation($_POST)) {
-                if ($v->confirm !== 1) {
+                if (1 !== $v->confirm) {
                     return $redirect->url($link)->message('No confirm redirect');
                     return $redirect->url($link)->message('No confirm redirect');
                 }
                 }
 
 
@@ -299,7 +311,7 @@ class Action extends Users
         $this->classForm  = 'change-group';
         $this->classForm  = 'change-group';
         $this->titleForm  = \ForkBB\__('Change user group');
         $this->titleForm  = \ForkBB\__('Change user group');
         $this->aCrumbs[]  = [$this->c->Router->link('AdminUsersAction', $args), \ForkBB\__('Change user group')];
         $this->aCrumbs[]  = [$this->c->Router->link('AdminUsersAction', $args), \ForkBB\__('Change user group')];
-        $this->form       = $this->formChange($args, $profile, $link, $rulePass !== 'absent');
+        $this->form       = $this->formChange($args, $profile, $link, 'absent' !== $rulePass);
 
 
         return $this;
         return $this;
     }
     }

+ 17 - 4
app/Models/Pages/Admin/Users/Result.php

@@ -74,11 +74,20 @@ class Result extends Users
             ]);
             ]);
 
 
             if ($v->validation($_POST)) {
             if ($v->validation($_POST)) {
-                if (! empty($v->ban) && $this->c->userRules->banUsers) {
+                if (
+                    ! empty($v->ban)
+                    && $this->c->userRules->banUsers
+                ) {
                     $action = self::ACTION_BAN;
                     $action = self::ACTION_BAN;
-                } elseif (! empty($v->delete) && $this->c->userRules->deleteUsers) {
+                } elseif (
+                    ! empty($v->delete)
+                    && $this->c->userRules->deleteUsers
+                ) {
                     $action = self::ACTION_DEL;
                     $action = self::ACTION_DEL;
-                } elseif (! empty($v->change_group) && $this->c->userRules->changeGroup) {
+                } elseif (
+                    ! empty($v->change_group)
+                    && $this->c->userRules->changeGroup
+                ) {
                     $action = self::ACTION_CHG;
                     $action = self::ACTION_CHG;
                 } else {
                 } else {
                     $this->fIswev = ['v', \ForkBB\__('Action not available')];
                     $this->fIswev = ['v', \ForkBB\__('Action not available')];
@@ -174,7 +183,11 @@ class Result extends Users
         }
         }
 
 
         foreach ($data as $field => $value) {
         foreach ($data as $field => $value) {
-            if ('order_by' === $field || 'direction' === $field || 'user_group' === $field) {
+            if (
+                'order_by' === $field
+                || 'direction' === $field
+                || 'user_group' === $field
+            ) {
                 continue;
                 continue;
             }
             }
 
 

+ 7 - 4
app/Models/Pages/Auth.php

@@ -72,7 +72,7 @@ class Auth extends Page
         $this->onlinePos  = 'login';
         $this->onlinePos  = 'login';
         $this->robots     = 'noindex';
         $this->robots     = 'noindex';
         $this->titles     = \ForkBB\__('Login');
         $this->titles     = \ForkBB\__('Login');
-        $this->regLink    = $this->c->config->o_regs_allow == '1' ? $this->c->Router->link('Register') : null;
+        $this->regLink    = '1' == $this->c->config->o_regs_allow ? $this->c->Router->link('Register') : null;
 
 
         $username         = $v ? $v->username : ($args['_username'] ?? '');
         $username         = $v ? $v->username : ($args['_username'] ?? '');
         $save             = $v ? $v->save : 1;
         $save             = $v ? $v->save : 1;
@@ -147,7 +147,8 @@ class Auth extends Page
     public function vLoginProcess(Validator $v, $password)
     public function vLoginProcess(Validator $v, $password)
     {
     {
         if (! empty($v->getErrors())) {
         if (! empty($v->getErrors())) {
-        } elseif (! ($user = $this->c->users->loadByName($v->username)) instanceof User
+        } elseif (
+            ! ($user = $this->c->users->loadByName($v->username)) instanceof User
             || $user->isGuest
             || $user->isGuest
         ) {
         ) {
             $v->addError('Wrong user/pass');
             $v->addError('Wrong user/pass');
@@ -159,7 +160,8 @@ class Auth extends Page
                 $v->addError('Wrong user/pass');
                 $v->addError('Wrong user/pass');
             } else {
             } else {
                 // перезаписываем ip админа и модератора - Visman
                 // перезаписываем ip админа и модератора - Visman
-                if ($user->isAdmMod
+                if (
+                    $user->isAdmMod
                     && $this->c->config->o_check_ip
                     && $this->c->config->o_check_ip
                     && $user->registration_ip != $this->user->ip
                     && $user->registration_ip != $this->user->ip
                 ) {
                 ) {
@@ -310,7 +312,8 @@ class Auth extends Page
      */
      */
     public function changePass(array $args, string $method): Page
     public function changePass(array $args, string $method): Page
     {
     {
-        if (! \hash_equals($args['hash'], $this->c->Secury->hash($args['id'] . $args['key']))
+        if (
+            ! \hash_equals($args['hash'], $this->c->Secury->hash($args['id'] . $args['key']))
             || ! ($user = $this->c->users->load((int) $args['id'])) instanceof User
             || ! ($user = $this->c->users->load((int) $args['id'])) instanceof User
             || $user->isGuest
             || $user->isGuest
             || empty($user->activate_string)
             || empty($user->activate_string)

+ 9 - 3
app/Models/Pages/Delete.php

@@ -19,7 +19,10 @@ class Delete extends Page
     {
     {
         $post = $this->c->posts->load((int) $args['id']);
         $post = $this->c->posts->load((int) $args['id']);
 
 
-        if (empty($post) || ! $post->canDelete) {
+        if (
+            empty($post)
+            || ! $post->canDelete
+        ) {
             return $this->c->Message->message('Bad request');
             return $this->c->Message->message('Bad request');
         }
         }
 
 
@@ -28,7 +31,7 @@ class Delete extends Page
 
 
         $this->c->Lang->load('delete');
         $this->c->Lang->load('delete');
 
 
-        if ($method === 'POST') {
+        if ('POST' === $method) {
             $v = $this->c->Validator->reset()
             $v = $this->c->Validator->reset()
                 ->addRules([
                 ->addRules([
                     'token'   => 'token:DeletePost',
                     'token'   => 'token:DeletePost',
@@ -39,7 +42,10 @@ class Delete extends Page
                     'token' => $args,
                     'token' => $args,
                 ]);
                 ]);
 
 
-            if (! $v->validation($_POST) || $v->confirm !== 1) {
+            if (
+                ! $v->validation($_POST)
+                || 1 !== $v->confirm
+            ) {
                 return $this->c->Redirect->page('ViewPost', $args)->message('No confirm redirect');
                 return $this->c->Redirect->page('ViewPost', $args)->message('No confirm redirect');
             }
             }
 
 

+ 33 - 9
app/Models/Pages/Edit.php

@@ -23,7 +23,10 @@ class Edit extends Page
     {
     {
         $post = $this->c->posts->load((int) $args['id']);
         $post = $this->c->posts->load((int) $args['id']);
 
 
-        if (empty($post) || ! $post->canEdit) {
+        if (
+            empty($post)
+            || ! $post->canEdit
+        ) {
             return $this->c->Message->message('Bad request');
             return $this->c->Message->message('Bad request');
         }
         }
 
 
@@ -32,17 +35,23 @@ class Edit extends Page
 
 
         $this->c->Lang->load('post');
         $this->c->Lang->load('post');
 
 
-        if ($method === 'POST') {
+        if ('POST' === $method) {
             $v = $this->messageValidator($post, 'EditPost', $args, true, $editSubject);
             $v = $this->messageValidator($post, 'EditPost', $args, true, $editSubject);
 
 
-            if ($v->validation($_POST) && null === $v->preview) {
+            if (
+                $v->validation($_POST)
+                && null === $v->preview
+            ) {
                 return $this->endEdit($post, $v);
                 return $this->endEdit($post, $v);
             }
             }
 
 
             $this->fIswev  = $v->getErrors();
             $this->fIswev  = $v->getErrors();
             $args['_vars'] = $v->getData(); //????
             $args['_vars'] = $v->getData(); //????
 
 
-            if (null !== $v->preview && ! $v->getErrors()) {
+            if (
+                null !== $v->preview
+                && ! $v->getErrors()
+            ) {
                 $this->previewHtml = $this->c->Parser->parseMessage(null, (bool) $v->hide_smilies);
                 $this->previewHtml = $this->c->Parser->parseMessage(null, (bool) $v->hide_smilies);
             }
             }
         } else {
         } else {
@@ -97,11 +106,17 @@ class Edit extends Page
             }
             }
         }
         }
         // показ смайлов
         // показ смайлов
-        if ($this->c->config->o_smilies == '1' && (bool) $post->hide_smilies !== (bool) $v->hide_smilies ) {
+        if (
+            '1' == $this->c->config->o_smilies
+            && (bool) $post->hide_smilies !== (bool) $v->hide_smilies
+        ) {
             $post->hide_smilies  = $v->hide_smilies ? 1 : 0;
             $post->hide_smilies  = $v->hide_smilies ? 1 : 0;
         }
         }
         // редактирование без ограничений
         // редактирование без ограничений
-        if ($executive && (bool) $post->edit_post !== (bool) $v->edit_post) {
+        if (
+            $executive
+            && (bool) $post->edit_post !== (bool) $v->edit_post
+        ) {
             $post->edit_post     = $v->edit_post ? 1 : 0;
             $post->edit_post     = $v->edit_post ? 1 : 0;
         }
         }
 
 
@@ -114,11 +129,17 @@ class Edit extends Page
                 $calcForum       = true;
                 $calcForum       = true;
             }
             }
             // выделение темы
             // выделение темы
-            if ($executive && (bool) $topic->sticky !== (bool) $v->stick_topic) {
+            if (
+                $executive
+                && (bool) $topic->sticky !== (bool) $v->stick_topic
+            ) {
                 $topic->sticky   = $v->stick_topic ? 1 : 0;
                 $topic->sticky   = $v->stick_topic ? 1 : 0;
             }
             }
             // закрепление первого сообшения
             // закрепление первого сообшения
-            if ($executive && (bool) $topic->stick_fp !== (bool) $v->stick_fp) {
+            if (
+                $executive
+                && (bool) $topic->stick_fp !== (bool) $v->stick_fp
+            ) {
                 $topic->stick_fp = $v->stick_fp ? 1 : 0;
                 $topic->stick_fp = $v->stick_fp ? 1 : 0;
             }
             }
         }
         }
@@ -139,7 +160,10 @@ class Edit extends Page
         $this->c->forums->update($topic->parent);
         $this->c->forums->update($topic->parent);
 
 
         // антифлуд
         // антифлуд
-        if ($calcPost || $calcForum) {
+        if (
+            $calcPost
+            || $calcForum
+        ) {
             $this->user->last_post = $now; //????
             $this->user->last_post = $now; //????
             $this->c->users->update($this->user);
             $this->c->users->update($this->user);
         }
         }

+ 4 - 1
app/Models/Pages/Forum.php

@@ -44,7 +44,10 @@ class Forum extends Page
 
 
         if (empty($this->topics)) {
         if (empty($this->topics)) {
             $this->fIswev = ['i', \ForkBB\__('Empty forum')];
             $this->fIswev = ['i', \ForkBB\__('Empty forum')];
-        } elseif ($this->user->isAdmin || $this->user->isModerator($forum)) {
+        } elseif (
+            $this->user->isAdmin
+            || $this->user->isModerator($forum)
+        ) {
             $this->c->Lang->load('misc');
             $this->c->Lang->load('misc');
 
 
             $this->enableMod = true;
             $this->enableMod = true;

+ 13 - 3
app/Models/Pages/Install.php

@@ -127,7 +127,11 @@ class Install extends Page
         }
         }
 
 
         $fIswev = $this->getAttr('fIswev'); // ????
         $fIswev = $this->getAttr('fIswev'); // ????
-        if ('POST' === $method && ! $changeLang && empty($fIswev['e'])) { //????
+        if (
+            'POST' === $method
+            && ! $changeLang
+            && empty($fIswev['e'])
+        ) { //????
             $v = $this->c->Validator->reset()
             $v = $this->c->Validator->reset()
                 ->addValidators([
                 ->addValidators([
                     'check_prefix' => [$this, 'vCheckPrefix'],
                     'check_prefix' => [$this, 'vCheckPrefix'],
@@ -405,7 +409,10 @@ class Install extends Page
         if (isset($prefix[0])) {
         if (isset($prefix[0])) {
             if (! \preg_match('%^[a-z][a-z\d_]*$%i', $prefix)) {
             if (! \preg_match('%^[a-z][a-z\d_]*$%i', $prefix)) {
                 $v->addError('Table prefix error');
                 $v->addError('Table prefix error');
-            } elseif ('sqlite' === $v->dbtype && 'sqlite_' === \strtolower($prefix)) {
+            } elseif (
+                'sqlite' === $v->dbtype
+                && 'sqlite_' === \strtolower($prefix)
+            ) {
                 $v->addError('Prefix reserved');
                 $v->addError('Prefix reserved');
             }
             }
         }
         }
@@ -475,7 +482,10 @@ class Install extends Page
         }
         }
 
 
         // база MySQL, кодировка базы отличается от UTF-8 (4 байта)
         // база MySQL, кодировка базы отличается от UTF-8 (4 байта)
-        if (isset($stat['character_set_database']) && 'utf8mb4' !== $stat['character_set_database']) {
+        if (
+            isset($stat['character_set_database'])
+            && 'utf8mb4' !== $stat['character_set_database']
+        ) {
             $v->addError('Bad database charset');
             $v->addError('Bad database charset');
         }
         }
 
 

+ 61 - 15
app/Models/Pages/Moderate.php

@@ -67,7 +67,13 @@ class Moderate extends Page
 
 
                 $indent = \str_repeat(\ForkBB\__('Forum indent'), $f->depth);
                 $indent = \str_repeat(\ForkBB\__('Forum indent'), $f->depth);
 
 
-                if ($f->redirect_url || ($noUseCurForum && $f->id === $curForum)) {
+                if (
+                    $f->redirect_url
+                    || (
+                        $noUseCurForum
+                        && $f->id === $curForum
+                    )
+                ) {
                     $options[] = [$f->id, $indent . \ForkBB\__('Forum prefix') . $f->forum_name, true];
                     $options[] = [$f->id, $indent . \ForkBB\__('Forum prefix') . $f->forum_name, true];
                 } else {
                 } else {
                     $options[] = [$f->id, $indent . \ForkBB\__('Forum prefix') . $f->forum_name];
                     $options[] = [$f->id, $indent . \ForkBB\__('Forum prefix') . $f->forum_name];
@@ -99,10 +105,14 @@ class Moderate extends Page
                 }
                 }
             }
             }
             // нажата не одна кнопка или недоступная кнопка
             // нажата не одна кнопка или недоступная кнопка
-            if (1 !== $sum || ! ($type & $this->actions[$action])) {
+            if (
+                1 !== $sum
+                || ! ($type & $this->actions[$action])
+            ) {
                 $v->addError('Action not available');
                 $v->addError('Action not available');
             // не выбрано ни одного сообщения для действий прямо этого требующих
             // не выбрано ни одного сообщения для действий прямо этого требующих
-            } elseif ($v->topic
+            } elseif (
+                $v->topic
                 && 1 === \count($v->ids)
                 && 1 === \count($v->ids)
                 && ! ((self::TOTOPIC + self::IFTOTPC) & $this->actions[$action])
                 && ! ((self::TOTOPIC + self::IFTOTPC) & $this->actions[$action])
             ) {
             ) {
@@ -110,17 +120,30 @@ class Moderate extends Page
             }
             }
 
 
             // объединение тем
             // объединение тем
-            if ('merge' === $action && \count($v->ids) < 2) {
+            if (
+                'merge' === $action
+                && \count($v->ids) < 2
+            ) {
                 $v->addError('Not enough topics selected');
                 $v->addError('Not enough topics selected');
             // перенос тем или разделение постов
             // перенос тем или разделение постов
-            } elseif ('move' === $action || 'split' === $action) {
+            } elseif (
+                'move' === $action
+                || 'split' === $action
+            ) {
                 $this->calcList($v->forum, 'move' === $action);
                 $this->calcList($v->forum, 'move' === $action);
 
 
                 if (empty($this->listOfIndexes)) {
                 if (empty($this->listOfIndexes)) {
                     $v->addError('Nowhere to move');
                     $v->addError('Nowhere to move');
-                } elseif (1 === $v->confirm && ! \in_array($v->destination, $this->listOfIndexes)) {
+                } elseif (
+                    1 === $v->confirm
+                    && ! \in_array($v->destination, $this->listOfIndexes)
+                ) {
                     $v->addError('Invalid destination');
                     $v->addError('Invalid destination');
-                } elseif ('split' === $action && 1 === $v->confirm && '' == $v->subject) {
+                } elseif (
+                    'split' === $action
+                    && 1 === $v->confirm
+                    && '' == $v->subject
+                ) {
                     $v->addError('No subject');
                     $v->addError('No subject');
                 }
                 }
             }
             }
@@ -178,7 +201,10 @@ class Moderate extends Page
         $this->curForum = $this->c->forums->loadTree($v->forum);
         $this->curForum = $this->c->forums->loadTree($v->forum);
         if (! $this->curForum instanceof Forum) {
         if (! $this->curForum instanceof Forum) {
             return $this->c->Message->message('Bad request');
             return $this->c->Message->message('Bad request');
-        } elseif (! $this->user->isAdmin && ! $this->user->isModerator($this->curForum)) {
+        } elseif (
+            ! $this->user->isAdmin
+            && ! $this->user->isModerator($this->curForum)
+        ) {
             return $this->c->Message->message('No permission', true, 403);
             return $this->c->Message->message('No permission', true, 403);
         }
         }
 
 
@@ -186,7 +212,10 @@ class Moderate extends Page
 
 
         if ($v->topic) {
         if ($v->topic) {
             $this->curTopic = $this->c->topics->load($v->topic);
             $this->curTopic = $this->c->topics->load($v->topic);
-            if (! $this->curTopic instanceof Topic || $this->curTopic->parent !== $this->curForum) {
+            if (
+                ! $this->curTopic instanceof Topic
+                || $this->curTopic->parent !== $this->curForum
+            ) {
                 return $this->c->Message->message('Bad request');
                 return $this->c->Message->message('Bad request');
             }
             }
 
 
@@ -197,14 +226,20 @@ class Moderate extends Page
             if (self::TOTOPIC & $curType) {
             if (self::TOTOPIC & $curType) {
                 $objects = [$this->curTopic];
                 $objects = [$this->curTopic];
             } elseif (self::IFTOTPC & $curType) {
             } elseif (self::IFTOTPC & $curType) {
-                if (1 === \count($ids) && \reset($ids) === $firstId) {
+                if (
+                    1 === \count($ids)
+                    && \reset($ids) === $firstId
+                ) {
                     $objects = [$this->curTopic];
                     $objects = [$this->curTopic];
                 }
                 }
             }
             }
             if (null === $objects) {
             if (null === $objects) {
                 $objects = $this->c->posts->loadByIds(\array_diff($ids, [$firstId]), false);
                 $objects = $this->c->posts->loadByIds(\array_diff($ids, [$firstId]), false);
                 foreach ($objects as $post) {
                 foreach ($objects as $post) {
-                    if (! $post instanceof Post || $post->parent !== $this->curTopic) {
+                    if (
+                        ! $post instanceof Post
+                        || $post->parent !== $this->curTopic
+                    ) {
                         return $this->c->Message->message('Bad request');
                         return $this->c->Message->message('Bad request');
                     }
                     }
                 }
                 }
@@ -219,7 +254,10 @@ class Moderate extends Page
         } else {
         } else {
             $objects = $this->c->topics->loadByIds($v->ids, false);
             $objects = $this->c->topics->loadByIds($v->ids, false);
             foreach ($objects as $topic) {
             foreach ($objects as $topic) {
-                if (! $topic instanceof Topic || $topic->parent !== $this->curForum) {
+                if (
+                    ! $topic instanceof Topic
+                    || $topic->parent !== $this->curForum
+                ) {
                     return $this->c->Message->message('Bad request');
                     return $this->c->Message->message('Bad request');
                 }
                 }
             }
             }
@@ -289,8 +327,15 @@ class Moderate extends Page
     {
     {
         if (! $this->user->isAdmin) { //???? разобраться с правами на удаление
         if (! $this->user->isAdmin) { //???? разобраться с правами на удаление
             foreach ($objects as $object) {
             foreach ($objects as $object) {
-                if (($object instanceof Topic && isset($this->c->admins->list[$object->poster_id]))
-                    || ($object instanceof Post && ! $object->canDelete)
+                if (
+                    (
+                        $object instanceof Topic
+                        && isset($this->c->admins->list[$object->poster_id])
+                    )
+                    || (
+                        $object instanceof Post
+                        && ! $object->canDelete
+                    )
                 ) {
                 ) {
                     return $this->c->Message->message('No permission', true, 403); //???? причина
                     return $this->c->Message->message('No permission', true, 403); //???? причина
                 }
                 }
@@ -354,7 +399,8 @@ class Moderate extends Page
             if ($topic->moved_to) {
             if ($topic->moved_to) {
                 return $this->c->Message->message('Topic links cannot be merged');
                 return $this->c->Message->message('Topic links cannot be merged');
             }
             }
-            if (! $this->firstTopic instanceof Topic
+            if (
+                ! $this->firstTopic instanceof Topic
                 || $topic->first_post_id < $this->firstTopic->first_post_id
                 || $topic->first_post_id < $this->firstTopic->first_post_id
             ) {
             ) {
                 $this->firstTopic = $topic;
                 $this->firstTopic = $topic;

+ 41 - 11
app/Models/Pages/Post.php

@@ -24,7 +24,11 @@ class Post extends Page
     {
     {
         $forum = $this->c->forums->get((int) $args['id']);
         $forum = $this->c->forums->get((int) $args['id']);
 
 
-        if (empty($forum) || $forum->redirect_url || ! $forum->canCreateTopic) {
+        if (
+            empty($forum)
+            || $forum->redirect_url
+            || ! $forum->canCreateTopic
+        ) {
             return $this->c->Message->message('Bad request');
             return $this->c->Message->message('Bad request');
         }
         }
 
 
@@ -33,14 +37,20 @@ class Post extends Page
         if ('POST' === $method) {
         if ('POST' === $method) {
             $v = $this->messageValidator($forum, 'NewTopic', $args, false, true);
             $v = $this->messageValidator($forum, 'NewTopic', $args, false, true);
 
 
-            if ($v->validation($_POST) && null === $v->preview) {
+            if (
+                $v->validation($_POST)
+                && null === $v->preview
+            ) {
                 return $this->endPost($forum, $v);
                 return $this->endPost($forum, $v);
             }
             }
 
 
             $this->fIswev  = $v->getErrors();
             $this->fIswev  = $v->getErrors();
             $args['_vars'] = $v->getData(); //????
             $args['_vars'] = $v->getData(); //????
 
 
-            if (null !== $v->preview && ! $v->getErrors()) {
+            if (
+                null !== $v->preview
+                && ! $v->getErrors()
+            ) {
                 $this->previewHtml = $this->c->Parser->parseMessage(null, (bool) $v->hide_smilies);
                 $this->previewHtml = $this->c->Parser->parseMessage(null, (bool) $v->hide_smilies);
             }
             }
         }
         }
@@ -68,7 +78,11 @@ class Post extends Page
     {
     {
         $topic = $this->c->topics->load((int) $args['id']);
         $topic = $this->c->topics->load((int) $args['id']);
 
 
-        if (empty($topic) || $topic->moved_to || ! $topic->canReply) {
+        if (
+            empty($topic)
+            || $topic->moved_to
+            || ! $topic->canReply
+        ) {
             return $this->c->Message->message('Bad request');
             return $this->c->Message->message('Bad request');
         }
         }
 
 
@@ -77,14 +91,20 @@ class Post extends Page
         if ('POST' === $method) {
         if ('POST' === $method) {
             $v = $this->messageValidator($topic, 'NewReply', $args);
             $v = $this->messageValidator($topic, 'NewReply', $args);
 
 
-            if ($v->validation($_POST) && null === $v->preview) {
+            if (
+                $v->validation($_POST)
+                && null === $v->preview
+            ) {
                 return $this->endPost($topic, $v);
                 return $this->endPost($topic, $v);
             }
             }
 
 
             $this->fIswev  = $v->getErrors();
             $this->fIswev  = $v->getErrors();
             $args['_vars'] = $v->getData(); //????
             $args['_vars'] = $v->getData(); //????
 
 
-            if (null !== $v->preview && ! $v->getErrors()) {
+            if (
+                null !== $v->preview
+                && ! $v->getErrors()
+            ) {
                 $this->previewHtml = $this->c->Parser->parseMessage(null, (bool) $v->hide_smilies);
                 $this->previewHtml = $this->c->Parser->parseMessage(null, (bool) $v->hide_smilies);
             }
             }
         } elseif (isset($args['quote'])) {
         } elseif (isset($args['quote'])) {
@@ -134,13 +154,17 @@ class Post extends Page
             $forum       = $model->parent;
             $forum       = $model->parent;
             $topic       = $model;
             $topic       = $model;
 
 
-            if (! $this->user->isGuest && $topic->last_poster_id === $this->user->id) {
+            if (
+                ! $this->user->isGuest
+                && $topic->last_poster_id === $this->user->id
+            ) {
                 if ($executive) {
                 if ($executive) {
                     if ($v->merge_post) {
                     if ($v->merge_post) {
                         $merge = true;
                         $merge = true;
                     }
                     }
                 } else {
                 } else {
-                    if ($this->c->config->o_merge_timeout > 0 // ???? стоит завязать на время редактирование сообщений?
+                    if (
+                        $this->c->config->o_merge_timeout > 0 // ???? стоит завязать на время редактирование сообщений?
                         && $now - $topic->last_post < $this->c->config->o_merge_timeout
                         && $now - $topic->last_post < $this->c->config->o_merge_timeout
                     ) {
                     ) {
                         $merge = true;
                         $merge = true;
@@ -216,11 +240,17 @@ class Post extends Page
         $this->c->forums->update($forum->calcStat());
         $this->c->forums->update($forum->calcStat());
 
 
         // обновление данных текущего пользователя
         // обновление данных текущего пользователя
-        if (! $merge && ! $this->user->isGuest) {
-            if ($forum->no_sum_mess != '1') {
+        if (
+            ! $merge
+            && ! $this->user->isGuest
+        ) {
+            if ('1' != $forum->no_sum_mess) {
                 $this->user->num_posts = $this->user->num_posts + 1;
                 $this->user->num_posts = $this->user->num_posts + 1;
 
 
-                if (0 != $this->user->g_promote_next_group && $this->user->num_posts >= $this->user->g_promote_min_posts) {
+                if (
+                    0 != $this->user->g_promote_next_group
+                    && $this->user->num_posts >= $this->user->g_promote_min_posts
+                ) {
                     $this->user->group_id = $this->user->g_promote_next_group;
                     $this->user->group_id = $this->user->g_promote_next_group;
                 }
                 }
             }
             }

+ 17 - 7
app/Models/Pages/PostFormTrait.php

@@ -89,10 +89,10 @@ trait PostFormTrait
             'required' => true,
             'required' => true,
             'value'    => $vars['message'] ?? null,
             'value'    => $vars['message'] ?? null,
             'bb'       => [
             'bb'       => [
-                ['link', \ForkBB\__('BBCode'), \ForkBB\__($this->c->config->p_message_bbcode == '1' ? 'on' : 'off')],
-                ['link', \ForkBB\__('url tag'), \ForkBB\__($this->c->config->p_message_bbcode == '1' && $this->user->g_post_links == '1' ? 'on' : 'off')],
-                ['link', \ForkBB\__('img tag'), \ForkBB\__($this->c->config->p_message_bbcode == '1' && $this->c->config->p_message_img_tag == '1' ? 'on' : 'off')],
-                ['link', \ForkBB\__('Smilies'), \ForkBB\__($this->c->config->o_smilies == '1' ? 'on' : 'off')],
+                ['link', \ForkBB\__('BBCode'), \ForkBB\__('1' == $this->c->config->p_message_bbcode ? 'on' : 'off')],
+                ['link', \ForkBB\__('url tag'), \ForkBB\__('1' == $this->c->config->p_message_bbcode && '1' == $this->user->g_post_links ? 'on' : 'off')],
+                ['link', \ForkBB\__('img tag'), \ForkBB\__('1' == $this->c->config->p_message_bbcode && '1' == $this->c->config->p_message_img_tag ? 'on' : 'off')],
+                ['link', \ForkBB\__('Smilies'), \ForkBB\__('1' == $this->c->config->o_smilies ? 'on' : 'off')],
             ],
             ],
             'autofocus' => $autofocus,
             'autofocus' => $autofocus,
         ];
         ];
@@ -102,7 +102,10 @@ trait PostFormTrait
         $autofocus = null;
         $autofocus = null;
 
 
         $fieldset = [];
         $fieldset = [];
-        if ($this->user->isAdmin || $this->user->isModerator($model)) {
+        if (
+            $this->user->isAdmin
+            || $this->user->isModerator($model)
+        ) {
             if ($editSubject) {
             if ($editSubject) {
                 $fieldset['stick_topic'] = [
                 $fieldset['stick_topic'] = [
                     'type'    => 'checkbox',
                     'type'    => 'checkbox',
@@ -124,7 +127,11 @@ trait PostFormTrait
                     'checked' => isset($vars['merge_post']) ? (bool) $vars['merge_post'] : true,
                     'checked' => isset($vars['merge_post']) ? (bool) $vars['merge_post'] : true,
                 ];
                 ];
             }
             }
-            if ($editPost && ! $model->user->isGuest && ! $model->user->isAdmin) {
+            if (
+                $editPost
+                && ! $model->user->isGuest
+                && ! $model->user->isAdmin
+            ) {
                 $fieldset['edit_post'] = [
                 $fieldset['edit_post'] = [
                     'type'    => 'checkbox',
                     'type'    => 'checkbox',
                     'label'   => \ForkBB\__('EditPost edit'),
                     'label'   => \ForkBB\__('EditPost edit'),
@@ -133,7 +140,10 @@ trait PostFormTrait
                 ];
                 ];
             }
             }
         }
         }
-        if (! $quickReply && $this->c->config->o_smilies == '1') {
+        if (
+            ! $quickReply
+            && '1' == $this->c->config->o_smilies
+        ) {
             $fieldset['hide_smilies'] = [
             $fieldset['hide_smilies'] = [
                 'type'    => 'checkbox',
                 'type'    => 'checkbox',
                 'label'   => \ForkBB\__('Hide smilies'),
                 'label'   => \ForkBB\__('Hide smilies'),

+ 19 - 7
app/Models/Pages/PostValidatorTrait.php

@@ -18,10 +18,11 @@ trait PostValidatorTrait
     public function vCheckSubject(Validator $v, $subject, $attr, $executive)
     public function vCheckSubject(Validator $v, $subject, $attr, $executive)
     {
     {
         // после цензуры заголовок темы путой
         // после цензуры заголовок темы путой
-        if (\ForkBB\cens($subject) == '') {
+        if ('' == \ForkBB\cens($subject)) {
             $v->addError('No subject after censoring');
             $v->addError('No subject after censoring');
         // заголовок темы только заглавными буквами
         // заголовок темы только заглавными буквами
-        } elseif (! $executive
+        } elseif (
+            ! $executive
             && '0' == $this->c->config->p_subject_all_caps
             && '0' == $this->c->config->p_subject_all_caps
             && \preg_match('%\p{Lu}%u', $subject)
             && \preg_match('%\p{Lu}%u', $subject)
             && ! \preg_match('%\p{Ll}%u', $subject)
             && ! \preg_match('%\p{Ll}%u', $subject)
@@ -42,10 +43,11 @@ trait PostValidatorTrait
     public function vCheckMessage(Validator $v, $message, $attr, $executive)
     public function vCheckMessage(Validator $v, $message, $attr, $executive)
     {
     {
         // после цензуры текст сообщения пустой
         // после цензуры текст сообщения пустой
-        if (\ForkBB\cens($message) == '') {
+        if ('' == \ForkBB\cens($message)) {
             $v->addError('No message after censoring');
             $v->addError('No message after censoring');
         // текст сообщения только заглавными буквами
         // текст сообщения только заглавными буквами
-        } elseif (! $executive
+        } elseif (
+            ! $executive
             && '0' == $this->c->config->p_message_all_caps
             && '0' == $this->c->config->p_message_all_caps
             && \preg_match('%\p{Lu}%u', $message)
             && \preg_match('%\p{Lu}%u', $message)
             && ! \preg_match('%\p{Ll}%u', $message)
             && ! \preg_match('%\p{Ll}%u', $message)
@@ -107,7 +109,10 @@ trait PostValidatorTrait
             $ruleUsername = 'absent';
             $ruleUsername = 'absent';
         }
         }
 
 
-        if ($this->user->isAdmin || $this->user->isModerator($model)) {
+        if (
+            $this->user->isAdmin
+            || $this->user->isModerator($model)
+        ) {
             if ($editSubject) {
             if ($editSubject) {
                 $ruleStickTopic = 'checkbox';
                 $ruleStickTopic = 'checkbox';
                 $ruleStickFP    = 'checkbox';
                 $ruleStickFP    = 'checkbox';
@@ -115,12 +120,19 @@ trait PostValidatorTrait
                 $ruleStickTopic = 'absent';
                 $ruleStickTopic = 'absent';
                 $ruleStickFP    = 'absent';
                 $ruleStickFP    = 'absent';
             }
             }
-            if (! $editSubject && ! $editPost) {
+            if (
+                ! $editSubject
+                && ! $editPost
+            ) {
                 $ruleMergePost  = 'checkbox';
                 $ruleMergePost  = 'checkbox';
             } else {
             } else {
                 $ruleMergePost  = 'absent';
                 $ruleMergePost  = 'absent';
             }
             }
-            if ($editPost && ! $model->user->isGuest && ! $model->user->isAdmin) {
+            if (
+                $editPost
+                && ! $model->user->isGuest
+                && ! $model->user->isAdmin
+            ) {
                 $ruleEditPost   = 'checkbox';
                 $ruleEditPost   = 'checkbox';
             } else {
             } else {
                 $ruleEditPost   = 'absent';
                 $ruleEditPost   = 'absent';

+ 18 - 5
app/Models/Pages/Profile.php

@@ -19,9 +19,13 @@ abstract class Profile extends Page
     {
     {
         $this->curUser = $this->c->users->load((int) $id);
         $this->curUser = $this->c->users->load((int) $id);
 
 
-        if (! $this->curUser instanceof User
+        if (
+            ! $this->curUser instanceof User
             || $this->curUser->isGuest
             || $this->curUser->isGuest
-            || ($this->curUser->isUnverified && ! $this->user->isAdmMod)
+            || (
+                $this->curUser->isUnverified
+                && ! $this->user->isAdmMod
+            )
         ) {
         ) {
             return false;
             return false;
         }
         }
@@ -81,7 +85,10 @@ abstract class Profile extends Page
     protected function btns(string $type): array
     protected function btns(string $type): array
     {
     {
         $btns = [];
         $btns = [];
-        if ($this->user->isAdmin && ! $this->rules->editProfile) {
+        if (
+            $this->user->isAdmin
+            && ! $this->rules->editProfile
+        ) {
             $btns['change-user-group'] = [
             $btns['change-user-group'] = [
                 $this->linkChangeGroup(),
                 $this->linkChangeGroup(),
                 \ForkBB\__('Change user group'),
                 \ForkBB\__('Change user group'),
@@ -117,7 +124,10 @@ abstract class Profile extends Page
                 \ForkBB\__('Delete user'),
                 \ForkBB\__('Delete user'),
             ];
             ];
         }
         }
-        if ('edit' != $type && $this->rules->editProfile) {
+        if (
+            'edit' != $type
+            && $this->rules->editProfile
+        ) {
             $btns['edit-profile'] = [
             $btns['edit-profile'] = [
                 $this->c->Router->link('EditUserProfile',  ['id' => $this->curUser->id]),
                 $this->c->Router->link('EditUserProfile',  ['id' => $this->curUser->id]),
                 \ForkBB\__('Edit '),
                 \ForkBB\__('Edit '),
@@ -129,7 +139,10 @@ abstract class Profile extends Page
                 \ForkBB\__('View '),
                 \ForkBB\__('View '),
             ];
             ];
         }
         }
-        if ('config' != $type && $this->rules->editConfig) {
+        if (
+            'config' != $type
+            && $this->rules->editConfig
+        ) {
             $btns['edit-settings'] = [
             $btns['edit-settings'] = [
                 $this->c->Router->link('EditUserBoardConfig', ['id' => $this->curUser->id]),
                 $this->c->Router->link('EditUserBoardConfig', ['id' => $this->curUser->id]),
                 \ForkBB\__('Configure '),
                 \ForkBB\__('Configure '),

+ 4 - 1
app/Models/Pages/Profile/Config.php

@@ -18,7 +18,10 @@ class Config extends Profile
      */
      */
     public function config(array $args, string $method): Page
     public function config(array $args, string $method): Page
     {
     {
-        if (false === $this->initProfile($args['id']) || ! $this->rules->editConfig) {
+        if (
+            false === $this->initProfile($args['id'])
+            || ! $this->rules->editConfig
+        ) {
             return $this->c->Message->message('Bad request');
             return $this->c->Message->message('Bad request');
         }
         }
 
 

+ 15 - 5
app/Models/Pages/Profile/Edit.php

@@ -21,7 +21,10 @@ class Edit extends Profile
      */
      */
     public function edit(array $args, string $method): Page
     public function edit(array $args, string $method): Page
     {
     {
-        if (false === $this->initProfile($args['id']) || ! $this->rules->editProfile) {
+        if (
+            false === $this->initProfile($args['id'])
+            || ! $this->rules->editProfile
+        ) {
             return $this->c->Message->message('Bad request');
             return $this->c->Message->message('Bad request');
         }
         }
 
 
@@ -105,7 +108,10 @@ class Edit extends Profile
             unset($data['token'], $data['upload_avatar'], $data['delete_avatar']);
             unset($data['token'], $data['upload_avatar'], $data['delete_avatar']);
 
 
             if ($valid) {
             if ($valid) {
-                if ($v->delete_avatar || $v->upload_avatar instanceof Image) {
+                if (
+                    $v->delete_avatar
+                    || $v->upload_avatar instanceof Image
+                ) {
                     $this->curUser->deleteAvatar();
                     $this->curUser->deleteAvatar();
                 }
                 }
 
 
@@ -148,13 +154,14 @@ class Edit extends Profile
     {
     {
         if ('' != $signature) {
         if ('' != $signature) {
             // после цензуры текст сообщения пустой
             // после цензуры текст сообщения пустой
-            if (\ForkBB\cens($signature) == '') {
+            if ('' == \ForkBB\cens($signature)) {
                 $v->addError('No signature after censoring');
                 $v->addError('No signature after censoring');
             // количество строк
             // количество строк
             } elseif (\substr_count($signature, "\n") >= $this->c->config->p_sig_lines) {
             } elseif (\substr_count($signature, "\n") >= $this->c->config->p_sig_lines) {
                 $v->addError('Signature has too many lines');
                 $v->addError('Signature has too many lines');
             // текст сообщения только заглавными буквами
             // текст сообщения только заглавными буквами
-            } elseif (! $this->c->user->isAdmin
+            } elseif (
+                ! $this->c->user->isAdmin
                 && '0' == $this->c->config->p_sig_all_caps
                 && '0' == $this->c->config->p_sig_all_caps
                 && \preg_match('%\p{Lu}%u', $signature)
                 && \preg_match('%\p{Lu}%u', $signature)
                 && ! \preg_match('%\p{Ll}%u', $signature)
                 && ! \preg_match('%\p{Ll}%u', $signature)
@@ -391,7 +398,10 @@ class Edit extends Profile
                 'caption'   => \ForkBB\__('Website'),
                 'caption'   => \ForkBB\__('Website'),
                 'value'     => $this->curUser->url,
                 'value'     => $this->curUser->url,
             ];
             ];
-        } elseif ($this->rules->viewWebsite && $this->curUser->url) {
+        } elseif (
+            $this->rules->viewWebsite
+            && $this->curUser->url
+        ) {
             $fields['url'] = [
             $fields['url'] = [
                 'id'      => 'website',
                 'id'      => 'website',
                 'class'   => 'pline',
                 'class'   => 'pline',

+ 10 - 3
app/Models/Pages/Profile/Email.php

@@ -20,7 +20,8 @@ class Email extends Profile
      */
      */
     public function setEmail(array $args, string $method): Page
     public function setEmail(array $args, string $method): Page
     {
     {
-        if ($this->user->id !== (int) $args['id']
+        if (
+            $this->user->id !== (int) $args['id']
             || ! \hash_equals($args['hash'], $this->c->Secury->hash($args['id'] . $args['email'] . $args['key']))
             || ! \hash_equals($args['hash'], $this->c->Secury->hash($args['id'] . $args['email'] . $args['key']))
             || empty($this->user->activate_string)
             || empty($this->user->activate_string)
             || ! \hash_equals($this->user->activate_string, $args['key'])
             || ! \hash_equals($this->user->activate_string, $args['key'])
@@ -49,7 +50,10 @@ class Email extends Profile
      */
      */
     public function email(array $args, string $method): Page
     public function email(array $args, string $method): Page
     {
     {
-        if (false === $this->initProfile($args['id']) || ! $this->rules->editEmail) {
+        if (
+            false === $this->initProfile($args['id'])
+            || ! $this->rules->editEmail
+        ) {
             return $this->c->Message->message('Bad request');
             return $this->c->Message->message('Bad request');
         }
         }
 
 
@@ -75,7 +79,10 @@ class Email extends Profile
                     return $this->c->Redirect->page('EditUserProfile', ['id' => $this->curUser->id])->message('Email is old redirect');
                     return $this->c->Redirect->page('EditUserProfile', ['id' => $this->curUser->id])->message('Email is old redirect');
                 }
                 }
 
 
-                if ($this->user->isAdmin || '1' != $this->c->config->o_regs_verify) {
+                if (
+                    $this->user->isAdmin
+                    || '1' != $this->c->config->o_regs_verify
+                ) {
                     $this->curUser->email           = $v->new_email;
                     $this->curUser->email           = $v->new_email;
                     $this->curUser->email_confirmed = 0;
                     $this->curUser->email_confirmed = 0;
 
 

+ 8 - 2
app/Models/Pages/Profile/Mod.php

@@ -22,7 +22,10 @@ class Mod extends Profile
      */
      */
     public function moderation(array $args, string $method): Page
     public function moderation(array $args, string $method): Page
     {
     {
-        if (false === $this->initProfile($args['id']) || ! $this->rules->confModer) {
+        if (
+            false === $this->initProfile($args['id'])
+            || ! $this->rules->confModer
+        ) {
             return $this->c->Message->message('Bad request');
             return $this->c->Message->message('Bad request');
         }
         }
 
 
@@ -40,7 +43,10 @@ class Mod extends Profile
 
 
             if ($v->validation($_POST)) {
             if ($v->validation($_POST)) {
                 foreach ($this->c->forums->get(0)->descendants as $forum) {
                 foreach ($this->c->forums->get(0)->descendants as $forum) {
-                    if (isset($v->moderator[$forum->id]) && $v->moderator[$forum->id] === $forum->id) {
+                    if (
+                        isset($v->moderator[$forum->id])
+                        && $v->moderator[$forum->id] === $forum->id
+                    ) {
                         $forum->modAdd($this->curUser);
                         $forum->modAdd($this->curUser);
                     } else {
                     } else {
                         $forum->modDelete($this->curUser);
                         $forum->modDelete($this->curUser);

+ 4 - 1
app/Models/Pages/Profile/Pass.php

@@ -21,7 +21,10 @@ class Pass extends Profile
      */
      */
     public function pass(array $args, string $method): Page
     public function pass(array $args, string $method): Page
     {
     {
-        if (false === $this->initProfile($args['id']) || ! $this->rules->editPass) {
+        if (
+            false === $this->initProfile($args['id'])
+            || ! $this->rules->editPass
+        ) {
             return $this->c->Message->message('Bad request');
             return $this->c->Message->message('Bad request');
         }
         }
 
 

+ 24 - 6
app/Models/Pages/Profile/View.php

@@ -65,7 +65,10 @@ class View extends Profile
         $fields[] = [
         $fields[] = [
             'type' => 'endwrap',
             'type' => 'endwrap',
         ];
         ];
-        if ($this->rules->useAvatar && $this->curUser->avatar) {
+        if (
+            $this->rules->useAvatar
+            && $this->curUser->avatar
+        ) {
             $fields['avatar'] = [
             $fields['avatar'] = [
                 'type'    => 'yield',
                 'type'    => 'yield',
                 'caption' => \ForkBB\__('Avatar'),
                 'caption' => \ForkBB\__('Avatar'),
@@ -79,7 +82,10 @@ class View extends Profile
         ];
         ];
 
 
         // примечание администрации
         // примечание администрации
-        if ($this->user->isAdmMod && '' != $this->curUser->admin_note) {
+        if (
+            $this->user->isAdmMod
+            && '' != $this->curUser->admin_note
+        ) {
             $form['sets']['note'] = [
             $form['sets']['note'] = [
                 'class'  => 'data',
                 'class'  => 'data',
                 'legend' => \ForkBB\__('Admin note'),
                 'legend' => \ForkBB\__('Admin note'),
@@ -109,7 +115,10 @@ class View extends Profile
             1 => \ForkBB\__('Male'),
             1 => \ForkBB\__('Male'),
             2 => \ForkBB\__('Female'),
             2 => \ForkBB\__('Female'),
         ];
         ];
-        if ($this->curUser->gender && isset($genders[$this->curUser->gender])) {
+        if (
+            $this->curUser->gender
+            && isset($genders[$this->curUser->gender])
+        ) {
             $fields['gender'] = [
             $fields['gender'] = [
                 'class'   => 'pline',
                 'class'   => 'pline',
                 'type'    => 'str',
                 'type'    => 'str',
@@ -163,7 +172,10 @@ class View extends Profile
                 ];
                 ];
             }
             }
         }
         }
-        if ($this->rules->viewWebsite && $this->curUser->url) {
+        if (
+            $this->rules->viewWebsite
+            && $this->curUser->url
+        ) {
             $fields['url'] = [
             $fields['url'] = [
                 'id'      => 'website',
                 'id'      => 'website',
                 'class'   => 'pline',
                 'class'   => 'pline',
@@ -222,7 +234,10 @@ class View extends Profile
             'value'   => \ForkBB\dt($this->curUser->last_post, true),
             'value'   => \ForkBB\dt($this->curUser->last_post, true),
             'caption' => \ForkBB\__('Last post info'),
             'caption' => \ForkBB\__('Last post info'),
         ];
         ];
-        if ($this->curUser->num_posts || $this->curUser->num_topics) {
+        if (
+            $this->curUser->num_posts
+            || $this->curUser->num_topics
+        ) {
             if ('1' == $this->user->g_search) {
             if ('1' == $this->user->g_search) {
                 $fields['posts'] = [
                 $fields['posts'] = [
                     'class'   => 'pline',
                     'class'   => 'pline',
@@ -255,7 +270,10 @@ class View extends Profile
                 ];
                 ];
             }
             }
         }
         }
-        if ($this->rules->viewIP && false !== \filter_var($this->curUser->registration_ip, \FILTER_VALIDATE_IP)) {
+        if (
+            $this->rules->viewIP
+            && false !== \filter_var($this->curUser->registration_ip, \FILTER_VALIDATE_IP)
+        ) {
             $fields['ip'] = [
             $fields['ip'] = [
                 'class'   => 'pline',
                 'class'   => 'pline',
                 'type'    => 'link',
                 'type'    => 'link',

+ 1 - 1
app/Models/Pages/Redirect.php

@@ -53,7 +53,7 @@ class Redirect extends Page
     public function message(string $message): Page
     public function message(string $message): Page
     {
     {
         // переадресация без вывода сообщения
         // переадресация без вывода сообщения
-        if ($this->c->config->o_redirect_delay == '0') {
+        if ('0' == $this->c->config->o_redirect_delay) {
             return $this;
             return $this;
         }
         }
 
 

+ 10 - 3
app/Models/Pages/Register.php

@@ -39,7 +39,10 @@ class Register extends Page
             ]);
             ]);
 
 
         // завершение регистрации
         // завершение регистрации
-        if ($v->validation($_POST) && 1 === $v->on) {
+        if (
+            $v->validation($_POST)
+            && 1 === $v->on
+        ) {
             return $this->regEnd($v);
             return $this->regEnd($v);
         }
         }
 
 
@@ -159,7 +162,10 @@ class Register extends Page
         $newUserId = $this->c->users->insert($user);
         $newUserId = $this->c->users->insert($user);
 
 
         // уведомление о регистрации
         // уведомление о регистрации
-        if ('1' == $this->c->config->o_regs_report && '' != $this->c->config->o_mailing_list) {
+        if (
+            '1' == $this->c->config->o_regs_report
+            && '' != $this->c->config->o_mailing_list
+        ) {
             $tplData = [
             $tplData = [
                 'fTitle' => $this->c->config->o_board_title,
                 'fTitle' => $this->c->config->o_board_title,
                 'fRootLink' => $this->c->Router->link('Index'),
                 'fRootLink' => $this->c->Router->link('Index'),
@@ -235,7 +241,8 @@ class Register extends Page
      */
      */
     public function activate(array $args): Page
     public function activate(array $args): Page
     {
     {
-        if (! \hash_equals($args['hash'], $this->c->Secury->hash($args['id'] . $args['key']))
+        if (
+            ! \hash_equals($args['hash'], $this->c->Secury->hash($args['id'] . $args['key']))
             || ! ($user = $this->c->users->load((int) $args['id'])) instanceof User
             || ! ($user = $this->c->users->load((int) $args['id'])) instanceof User
             || $user->isGuest
             || $user->isGuest
             || empty($user->activate_string)
             || empty($user->activate_string)

+ 4 - 1
app/Models/Pages/Report.php

@@ -50,7 +50,10 @@ class Report extends Page
             ])->addMessages([
             ])->addMessages([
             ]);
             ]);
 
 
-            if ($v->validation($_POST) && 0 === $floodSize) {
+            if (
+                $v->validation($_POST)
+                && 0 === $floodSize
+            ) {
                 $report = $this->c->reports->create();
                 $report = $this->c->reports->create();
 
 
                 $report->author = $this->user;
                 $report->author = $this->user;

+ 1 - 1
app/Models/Pages/Rules.php

@@ -39,7 +39,7 @@ class Rules extends Page
         $this->robots     = 'noindex';
         $this->robots     = 'noindex';
         $this->title      = \ForkBB\__('Forum rules');
         $this->title      = \ForkBB\__('Forum rules');
         $this->crumbs     = $this->crumbs(\ForkBB\__('Forum rules'), [$this->c->Router->link('Register'), \ForkBB\__('Register')]);
         $this->crumbs     = $this->crumbs(\ForkBB\__('Forum rules'), [$this->c->Router->link('Register'), \ForkBB\__('Register')]);
-        $this->rules      = $this->c->config->o_rules == '1' ? $this->c->config->o_rules_message : \ForkBB\__('If no rules');
+        $this->rules      = '1' == $this->c->config->o_rules ? $this->c->config->o_rules_message : \ForkBB\__('If no rules');
         $this->form       = $this->formAgree();
         $this->form       = $this->formAgree();
 
 
         return $this;
         return $this;

+ 32 - 8
app/Models/Pages/Search.php

@@ -70,7 +70,10 @@ class Search extends Page
         $marker = $advanced ? 'SearchAdvanced' : 'Search';
         $marker = $advanced ? 'SearchAdvanced' : 'Search';
 
 
         $v = null;
         $v = null;
-        if ('POST' === $method || isset($args['keywords'])) {
+        if (
+            'POST' === $method
+            || isset($args['keywords'])
+        ) {
             $v = $this->c->Validator->reset()
             $v = $this->c->Validator->reset()
                 ->addValidators([
                 ->addValidators([
                     'check_query'  => [$this, 'vCheckQuery'],
                     'check_query'  => [$this, 'vCheckQuery'],
@@ -116,9 +119,15 @@ class Search extends Page
                 'keywords'     => 'required|string:trim|max:100|check_query:' . $method,
                 'keywords'     => 'required|string:trim|max:100|check_query:' . $method,
             ]);
             ]);
 
 
-            if ('POST' === $method && $v->validation($_POST)) {
+            if (
+                'POST' === $method
+                && $v->validation($_POST)
+            ) {
                 return $this->c->Redirect->page($marker, $v->getData());
                 return $this->c->Redirect->page($marker, $v->getData());
-            } elseif ('GET' === $method && $v->validation($args)) {
+            } elseif (
+                'GET' === $method
+                && $v->validation($args)
+            ) {
                 return $this->action(\array_merge($args, $v->getData(), ['action' => 'search']), $method, $advanced);
                 return $this->action(\array_merge($args, $v->getData(), ['action' => 'search']), $method, $advanced);
             }
             }
 
 
@@ -325,7 +334,10 @@ class Search extends Page
         if (empty($v->getErrors())) {
         if (empty($v->getErrors())) {
             $flood = $this->user->last_search && \time() - $this->user->last_search < $this->user->g_search_flood;
             $flood = $this->user->last_search && \time() - $this->user->last_search < $this->user->g_search_flood;
 
 
-            if ('POST' !== $method || ! $flood) {
+            if (
+                'POST' !== $method
+                || ! $flood
+            ) {
                 $search = $this->c->search;
                 $search = $this->c->search;
 
 
                 if (! $search->prepare($query)) {
                 if (! $search->prepare($query)) {
@@ -339,7 +351,10 @@ class Search extends Page
                             $v->addError('No hits', 'i');
                             $v->addError('No hits', 'i');
                         }
                         }
 
 
-                        if ($search->queryNoCache && $this->user->g_search_flood) {
+                        if (
+                            $search->queryNoCache
+                            && $this->user->g_search_flood
+                        ) {
                             $this->user->last_search = \time();
                             $this->user->last_search = \time();
                             $this->c->users->update($this->user); //?????
                             $this->c->users->update($this->user); //?????
                         }
                         }
@@ -366,7 +381,10 @@ class Search extends Page
     public function vCheckForums(Validator $v, $forums)
     public function vCheckForums(Validator $v, $forums)
     {
     {
         if ('*' !== $forums) {
         if ('*' !== $forums) {
-            if (\is_string($forums) && \preg_match('%^\d+(?:\.\d+)*$%D', $forums)) {
+            if (
+                \is_string($forums)
+                && \preg_match('%^\d+(?:\.\d+)*$%D', $forums)
+            ) {
                 $forums = \explode('.', $forums);
                 $forums = \explode('.', $forums);
             } elseif (null === $forums) {
             } elseif (null === $forums) {
                 $forums = '*';
                 $forums = '*';
@@ -399,7 +417,10 @@ class Search extends Page
     {
     {
         $name = \preg_replace('%\*+%', '*', $name);
         $name = \preg_replace('%\*+%', '*', $name);
 
 
-        if ('*' !== $name && ! \preg_match('%[\p{L}\p{N}]%', $name)) {
+        if (
+            '*' !== $name
+            && ! \preg_match('%[\p{L}\p{N}]%', $name)
+        ) {
             $v->addError('The :alias is not valid format');
             $v->addError('The :alias is not valid format');
         }
         }
 
 
@@ -483,7 +504,10 @@ class Search extends Page
                     break;
                     break;
                 }
                 }
                 $user              = $this->c->users->load($uid);
                 $user              = $this->c->users->load($uid);
-                if (! $user instanceof User || $user->isGuest) {
+                if (
+                    ! $user instanceof User
+                    || $user->isGuest
+                ) {
                     break;
                     break;
                 }
                 }
                 if ($asTopicsList) {
                 if ($asTopicsList) {

+ 13 - 4
app/Models/Pages/Topic.php

@@ -105,14 +105,17 @@ class Topic extends Page
      */
      */
     protected function view(string $type, array $args): Page
     protected function view(string $type, array $args): Page
     {
     {
-        if ($type === 'post') {
+        if ('post' === $type) {
             $post  = $this->c->posts->load((int) $args['id']);
             $post  = $this->c->posts->load((int) $args['id']);
             $topic = null === $post ? null : $post->parent;
             $topic = null === $post ? null : $post->parent;
         } else {
         } else {
             $topic = $this->c->topics->load((int) $args['id']);
             $topic = $this->c->topics->load((int) $args['id']);
         }
         }
 
 
-        if (! $topic instanceof TopicModel || ! $topic->last_post_id) {
+        if (
+            ! $topic instanceof TopicModel
+            || ! $topic->last_post_id
+        ) {
             return $this->c->Message->message('Bad request');
             return $this->c->Message->message('Bad request');
         }
         }
 
 
@@ -151,11 +154,17 @@ class Topic extends Page
         $this->online       = $this->c->Online->calc($this)->info();
         $this->online       = $this->c->Online->calc($this)->info();
         $this->stats        = null;
         $this->stats        = null;
 
 
-        if ($topic->canReply && $this->c->config->o_quickpost == '1') {
+        if (
+            $topic->canReply
+            && '1' == $this->c->config->o_quickpost
+        ) {
             $this->form     = $this->messageForm(['id' => $topic->id], $topic, 'NewReply', false, false, true);
             $this->form     = $this->messageForm(['id' => $topic->id], $topic, 'NewReply', false, false, true);
         }
         }
 
 
-        if ($this->user->isAdmin || $this->user->isModerator($topic)) {
+        if (
+            $this->user->isAdmin
+            || $this->user->isModerator($topic)
+        ) {
             $this->c->Lang->load('misc');
             $this->c->Lang->load('misc');
 
 
             $this->enableMod = true;
             $this->enableMod = true;

+ 8 - 2
app/Models/Pages/Userlist.php

@@ -57,7 +57,10 @@ class Userlist extends Page
                    + (int) (null === $v->group)
                    + (int) (null === $v->group)
                    + (int) (null === $v->name);
                    + (int) (null === $v->name);
 
 
-            if (0 === $count || 4 === $count) {
+            if (
+                0 === $count
+                || 4 === $count
+            ) {
                 $error = false;
                 $error = false;
             }
             }
         }
         }
@@ -114,7 +117,10 @@ class Userlist extends Page
                     $vars['dir'] = $dir;
                     $vars['dir'] = $dir;
                     $links[$i * 2 + $j] = $this->c->Router->link('Userlist', $vars);
                     $links[$i * 2 + $j] = $this->c->Router->link('Userlist', $vars);
 
 
-                    if ($v->sort === $sort && $v->dir === $dir) {
+                    if (
+                        $v->sort === $sort
+                        && $v->dir === $dir
+                    ) {
                         $this->activeLink = $i * 2 + $j;
                         $this->activeLink = $i * 2 + $j;
                     }
                     }
                 }
                 }

+ 4 - 1
app/Models/Post/Delete.php

@@ -64,7 +64,10 @@ class Delete extends Action
                 $topics[$arg->id] = $arg;
                 $topics[$arg->id] = $arg;
                 $isTopic          = 1;
                 $isTopic          = 1;
             } elseif ($arg instanceof Post) {
             } elseif ($arg instanceof Post) {
-                if (! $arg->parent instanceof Topic || ! $arg->parent->parent instanceof Forum) {
+                if (
+                    ! $arg->parent instanceof Topic
+                    || ! $arg->parent->parent instanceof Forum
+                ) {
                     throw new RuntimeException('Parents unavailable');
                     throw new RuntimeException('Parents unavailable');
                 }
                 }
                 $posts[$arg->id]         = $arg->id;
                 $posts[$arg->id]         = $arg->id;

+ 17 - 9
app/Models/Post/Load.php

@@ -39,7 +39,10 @@ class Load extends Action
         if ($id < 1) {
         if ($id < 1) {
             throw new InvalidArgumentException('Expected a positive post id');
             throw new InvalidArgumentException('Expected a positive post id');
         }
         }
-        if (null !== $tid && $tid < 1) {
+        if (
+            null !== $tid
+            && $tid < 1
+        ) {
             throw new InvalidArgumentException('Expected a positive topic id');
             throw new InvalidArgumentException('Expected a positive topic id');
         }
         }
 
 
@@ -47,11 +50,7 @@ class Load extends Action
             ':pid' => $id,
             ':pid' => $id,
             ':tid' => $tid,
             ':tid' => $tid,
         ];
         ];
-        $sql  = $this->getSql(
-            null !== $tid ?
-            'p.id=?i:pid AND p.topic_id=?i:tid' :
-            'p.id=?i:pid'
-        );
+        $sql = $this->getSql(null !== $tid ? 'p.id=?i:pid AND p.topic_id=?i:tid' : 'p.id=?i:pid');
         $data = $this->c->DB->query($sql, $vars)->fetch();
         $data = $this->c->DB->query($sql, $vars)->fetch();
 
 
         if (empty($data)) {
         if (empty($data)) {
@@ -64,7 +63,10 @@ class Load extends Action
         if (! $topic instanceof Topic) {
         if (! $topic instanceof Topic) {
             return null;
             return null;
         }
         }
-        if (null !== $tid && $topic->id !== $tid) {
+        if (
+            null !== $tid
+            && $topic->id !== $tid
+        ) {
             return null;
             return null;
         }
         }
 
 
@@ -80,7 +82,10 @@ class Load extends Action
     public function loadByIds(array $ids, bool $withTopics): array
     public function loadByIds(array $ids, bool $withTopics): array
     {
     {
         foreach ($ids as $id) {
         foreach ($ids as $id) {
-            if (! \is_int($id) || $id < 1) {
+            if (
+                ! \is_int($id)
+                || $id < 1
+            ) {
                 throw new InvalidArgumentException('Expected a positive topic id');
                 throw new InvalidArgumentException('Expected a positive topic id');
             }
             }
         }
         }
@@ -109,7 +114,10 @@ class Load extends Action
             unset($post);
             unset($post);
         } else {
         } else {
             foreach ($topicIds as $id) {
             foreach ($topicIds as $id) {
-                if (! $this->c->topics->isset($id) || ! $this->c->topics->get($id) instanceof Topic) {
+                if (
+                    ! $this->c->topics->isset($id)
+                    || ! $this->c->topics->get($id) instanceof Topic
+                ) {
                     throw new RuntimeException("Topic number {$id} not loaded");
                     throw new RuntimeException("Topic number {$id} not loaded");
                 }
                 }
             }
             }

+ 5 - 1
app/Models/Post/Manager.php

@@ -33,7 +33,11 @@ class Manager extends ManagerModel
         if ($this->isset($id)) {
         if ($this->isset($id)) {
             $post = $this->get($id);
             $post = $this->get($id);
 
 
-            if ($post instanceof Post && null !== $tid && $post->topic_id !== $tid) {
+            if (
+                $post instanceof Post
+                && null !== $tid
+                && $post->topic_id !== $tid
+            ) {
                 return null;
                 return null;
             }
             }
         } else {
         } else {

+ 37 - 12
app/Models/Post/Model.php

@@ -25,7 +25,11 @@ class Model extends DataModel
 
 
         $topic = $this->c->topics->load($this->topic_id);
         $topic = $this->c->topics->load($this->topic_id);
 
 
-        if (! $topic instanceof Topic || $topic->moved_to || ! $topic->parent instanceof Forum) {
+        if (
+            ! $topic instanceof Topic
+            || $topic->moved_to
+            || ! $topic->parent instanceof Forum
+        ) {
             return null;
             return null;
         } else {
         } else {
             return $topic;
             return $topic;
@@ -81,18 +85,32 @@ class Model extends DataModel
     {
     {
         if ($this->c->user->isGuest) {
         if ($this->c->user->isGuest) {
             return false;
             return false;
-        } elseif ($this->c->user->isAdmin || ($this->c->user->isModerator($this) && ! $this->user->isAdmin)) {
+        } elseif (
+            $this->c->user->isAdmin
+            || (
+                $this->c->user->isModerator($this)
+                && ! $this->user->isAdmin
+            )
+        ) {
             return true;
             return true;
-        } elseif ($this->parent->closed == '1') {
+        } elseif ('1' == $this->parent->closed) {
             return false;
             return false;
         }
         }
 
 
         return $this->user->id === $this->c->user->id
         return $this->user->id === $this->c->user->id
-            && (($this->id == $this->parent->first_post_id && $this->c->user->g_delete_topics == '1')
-                || ($this->id != $this->parent->first_post_id && $this->c->user->g_delete_posts == '1')
+            && (
+                (
+                    $this->id == $this->parent->first_post_id
+                    && '1' == $this->c->user->g_delete_topics
+                )
+                || (
+                    $this->id != $this->parent->first_post_id
+                    && '1' == $this->c->user->g_delete_posts
+                )
             )
             )
-            && ($this->c->user->g_deledit_interval == '0'
-                || $this->edit_post == '1'
+            && (
+                '0' == $this->c->user->g_deledit_interval
+                || '1' == $this->edit_post
                 || \time() - $this->posted < $this->c->user->g_deledit_interval
                 || \time() - $this->posted < $this->c->user->g_deledit_interval
             );
             );
     }
     }
@@ -106,16 +124,23 @@ class Model extends DataModel
     {
     {
         if ($this->c->user->isGuest) {
         if ($this->c->user->isGuest) {
             return false;
             return false;
-        } elseif ($this->c->user->isAdmin || ($this->c->user->isModerator($this) && ! $this->user->isAdmin)) {
+        } elseif (
+            $this->c->user->isAdmin
+            || (
+                $this->c->user->isModerator($this)
+                && ! $this->user->isAdmin
+            )
+        ) {
             return true;
             return true;
-        } elseif ($this->parent->closed == '1') {
+        } elseif ('1' == $this->parent->closed) {
             return false;
             return false;
         }
         }
 
 
         return $this->user->id === $this->c->user->id
         return $this->user->id === $this->c->user->id
-            && $this->c->user->g_edit_posts == '1'
-            && ($this->c->user->g_deledit_interval == '0'
-                || $this->edit_post == '1'
+            && '1' == $this->c->user->g_edit_posts
+            && (
+                '0' == $this->c->user->g_deledit_interval
+                || '1' == $this->edit_post
                 || \time() - $this->posted < $this->c->user->g_deledit_interval
                 || \time() - $this->posted < $this->c->user->g_deledit_interval
             );
             );
     }
     }

+ 1 - 1
app/Models/Post/Save.php

@@ -34,7 +34,7 @@ class Save extends Action
                 continue;
                 continue;
             }
             }
             $vars[] = $values[$name];
             $vars[] = $values[$name];
-            $set[] = $name . '=?' . $fileds[$name];
+            $set[]  = $name . '=?' . $fileds[$name];
         }
         }
         if (empty($set)) {
         if (empty($set)) {
             return $post;
             return $post;

+ 1 - 1
app/Models/Post/UserInfoFromIP.php

@@ -30,7 +30,7 @@ class UserInfoFromIP extends Action
         $ids    = [];
         $ids    = [];
 
 
         while ($row = $stmt->fetch()) {
         while ($row = $stmt->fetch()) {
-            if ($row['poster_id'] === 1) {
+            if (1 === $row['poster_id']) {
                 $result[] = $row['poster'];
                 $result[] = $row['poster'];
             } elseif (empty($ids[$row['poster_id']])) {
             } elseif (empty($ids[$row['poster_id']])) {
                 $result[]               = $row['poster_id'];
                 $result[]               = $row['poster_id'];

+ 12 - 3
app/Models/Post/View.php

@@ -25,11 +25,17 @@ class View extends Action
      */
      */
     public function view($arg, bool $review = false): array
     public function view($arg, bool $review = false): array
     {
     {
-        if (! $arg instanceof Topic && ! $arg instanceof Search) {
+        if (
+            ! $arg instanceof Topic
+            && ! $arg instanceof Search
+        ) {
             throw new InvalidArgumentException('Expected Topic or Search');
             throw new InvalidArgumentException('Expected Topic or Search');
         }
         }
 
 
-        if (empty($arg->idsList) || ! \is_array($arg->idsList)) {
+        if (
+            empty($arg->idsList)
+            || ! \is_array($arg->idsList)
+        ) {
             throw new RuntimeException('Model does not contain of posts list for display');
             throw new RuntimeException('Model does not contain of posts list for display');
         }
         }
 
 
@@ -74,7 +80,10 @@ class View extends Action
                 } elseif ($post->posted > $timeMax) {
                 } elseif ($post->posted > $timeMax) {
                     $timeMax = $post->posted;
                     $timeMax = $post->posted;
                 }
                 }
-                if ($post->id === $arg->first_post_id && $offset > 0) {
+                if (
+                    $post->id === $arg->first_post_id
+                    && $offset > 0
+                ) {
                     if (empty($post->id)) {
                     if (empty($post->id)) {
                         continue;
                         continue;
                     }
                     }

+ 2 - 2
app/Models/Report/Load.php

@@ -35,7 +35,7 @@ class Load extends Action
             return null;
             return null;
         }
         }
 
 
-        $report  = $this->manager->create($data);
+        $report = $this->manager->create($data);
 
 
         return $report;
         return $report;
     }
     }
@@ -50,7 +50,7 @@ class Load extends Action
     public function loadList(bool $noZapped): array
     public function loadList(bool $noZapped): array
     {
     {
         $result = [];
         $result = [];
-        $vars = [];
+        $vars   = [];
 
 
         if ($noZapped) {
         if ($noZapped) {
             $sql = 'SELECT r.*
             $sql = 'SELECT r.*

+ 8 - 2
app/Models/Report/Model.php

@@ -40,7 +40,10 @@ class Model extends DataModel
 
 
         $user = $this->c->users->load($this->reported_by);
         $user = $this->c->users->load($this->reported_by);
 
 
-        if (! $user instanceof User || $user->isGuest) {
+        if (
+            ! $user instanceof User
+            || $user->isGuest
+        ) {
             $user = $this->c->users->create();
             $user = $this->c->users->create();
 
 
             $user->__id       = $this->reported_by;
             $user->__id       = $this->reported_by;
@@ -84,7 +87,10 @@ class Model extends DataModel
 
 
         $user = $this->c->users->load($this->zapped_by);
         $user = $this->c->users->load($this->zapped_by);
 
 
-        if (! $user instanceof User || $user->isGuest) {
+        if (
+            ! $user instanceof User
+            || $user->isGuest
+        ) {
             $user = $this->c->users->create();
             $user = $this->c->users->create();
 
 
             $user->__id       = $this->zapped_by;
             $user->__id       = $this->zapped_by;

+ 1 - 1
app/Models/Report/Save.php

@@ -34,7 +34,7 @@ class Save extends Action
                 continue;
                 continue;
             }
             }
             $vars[] = $values[$name];
             $vars[] = $values[$name];
-            $set[] = $name . '=?' . $fileds[$name];
+            $set[]  = $name . '=?' . $fileds[$name];
         }
         }
         if (empty($set)) {
         if (empty($set)) {
             return $report;
             return $report;

+ 2 - 1
app/Models/Rules/Profile.php

@@ -59,7 +59,8 @@ class Profile extends Rules
     protected function getviewEmail(): bool // ?????
     protected function getviewEmail(): bool // ?????
     {
     {
         return ! $this->my
         return ! $this->my
-            && (($this->user->isAdmMod && 1 === $this->curUser->email_setting)
+            && (
+                ($this->user->isAdmMod && 1 === $this->curUser->email_setting)
                 || (! $this->user->isGuest && ! $this->user->isAdmMod && '1' == $this->user->g_send_email)
                 || (! $this->user->isGuest && ! $this->user->isAdmMod && '1' == $this->user->g_send_email)
             );
             );
     }
     }

+ 8 - 2
app/Models/Rules/Users.php

@@ -69,9 +69,15 @@ class Users extends Rules
             $this->profileRules = $this->c->ProfileRules;
             $this->profileRules = $this->c->ProfileRules;
         }
         }
 
 
-        if ($profile && $this->user->isAdmin) {
+        if (
+            $profile
+            && $this->user->isAdmin
+        ) {
             return true;
             return true;
-        } elseif (! $profile && $user->isAdmin) {
+        } elseif (
+            ! $profile
+            && $user->isAdmin
+        ) {
             return false;
             return false;
         }
         }
 
 

+ 4 - 1
app/Models/Search/Delete.php

@@ -59,7 +59,10 @@ class Delete extends Method
                 $topics[$arg->id] = $arg;
                 $topics[$arg->id] = $arg;
                 $isTopic          = 1;
                 $isTopic          = 1;
             } elseif ($arg instanceof Post) {
             } elseif ($arg instanceof Post) {
-                if (! $arg->parent instanceof Topic || ! $arg->parent->parent instanceof Forum) {
+                if (
+                    ! $arg->parent instanceof Topic
+                    || ! $arg->parent->parent instanceof Forum
+                ) {
                     throw new RuntimeException('Parents unavailable');
                     throw new RuntimeException('Parents unavailable');
                 }
                 }
                 $posts[$arg->id] = $arg;
                 $posts[$arg->id] = $arg;

+ 33 - 7
app/Models/Search/Execute.php

@@ -34,7 +34,10 @@ class Execute extends Method
      */
      */
     public function execute(Validator $v, array $forumIdxs, bool $flood): bool
     public function execute(Validator $v, array $forumIdxs, bool $flood): bool
     {
     {
-        if (! \is_array($this->model->queryWords) || ! \is_string($this->model->queryText)) {
+        if (
+            ! \is_array($this->model->queryWords)
+            || ! \is_string($this->model->queryText)
+        ) {
             throw new RuntimeException('No query data');
             throw new RuntimeException('No query data');
         }
         }
 
 
@@ -62,7 +65,10 @@ class Execute extends Method
                 LIMIT 1';
                 LIMIT 1';
         $row = $this->c->DB->query($sql, $vars)->fetch();
         $row = $this->c->DB->query($sql, $vars)->fetch();
 
 
-        if (! empty($row['search_time']) && \time() - $row['search_time'] < 60 * 5) { //????
+        if (
+            ! empty($row['search_time'])
+            && \time() - $row['search_time'] < 60 * 5
+        ) { //????
             $result                    = \explode("\n", $row['search_data']);
             $result                    = \explode("\n", $row['search_data']);
             $this->model->queryIds     = '' == $result[0] ? [] : \array_map('\\intval', \explode(',', $result[0]));
             $this->model->queryIds     = '' == $result[0] ? [] : \array_map('\\intval', \explode(',', $result[0]));
             $this->model->queryNoCache = false;
             $this->model->queryNoCache = false;
@@ -115,21 +121,38 @@ class Execute extends Method
 
 
         foreach ($words as $word) {
         foreach ($words as $word) {
             // служебное слово
             // служебное слово
-            if ('AND' === $word || 'OR' === $word || 'NOT' === $word) {
+            if (
+                'AND' === $word
+                || 'OR' === $word
+                || 'NOT' === $word
+            ) {
                 $type = $word;
                 $type = $word;
                 continue;
                 continue;
             }
             }
 
 
             // если до сих пор ни чего не найдено и тип операции не ИЛИ, то выполнять не надо
             // если до сих пор ни чего не найдено и тип операции не ИЛИ, то выполнять не надо
-            if ($count && empty($ids) && 'OR' !== $type) {
+            if (
+                $count
+                && empty($ids)
+                && 'OR' !== $type
+            ) {
                 continue;
                 continue;
             }
             }
 
 
-            if (\is_array($word) && (! isset($word['type']) || 'CJK' !== $word['type'])) {
+            if (
+                \is_array($word)
+                && (
+                    ! isset($word['type'])
+                    || 'CJK' !== $word['type']
+                )
+            ) {
                 $ids = $this->exec($word, $vars);
                 $ids = $this->exec($word, $vars);
             } else {
             } else {
                 $CJK = false;
                 $CJK = false;
-                if (isset($word['type']) && 'CJK' === $word['type']) {
+                if (
+                    isset($word['type'])
+                    && 'CJK' === $word['type']
+                ) {
                     $CJK  = true;
                     $CJK  = true;
                     $word = '*' . \trim($word['word'], '*') . '*';
                     $word = '*' . \trim($word['word'], '*') . '*';
                 }
                 }
@@ -195,7 +218,10 @@ class Execute extends Method
         $useTCJK  = false;
         $useTCJK  = false;
         $usePCJK  = false;
         $usePCJK  = false;
 
 
-        if ('*' !== $v->forums || ! $this->c->user->isAdmin) {
+        if (
+            '*' !== $v->forums
+            || ! $this->c->user->isAdmin
+        ) {
             $useTIdx                 = true;
             $useTIdx                 = true;
             $whereIdx[]              = 't.forum_id IN (?ai:forums)';
             $whereIdx[]              = 't.forum_id IN (?ai:forums)';
             $whereCJK[]              = 't.forum_id IN (?ai:forums)';
             $whereCJK[]              = 't.forum_id IN (?ai:forums)';

+ 10 - 3
app/Models/Search/Prepare.php

@@ -44,7 +44,8 @@ class Prepare extends Method
                 // не стоп-слово и минимальная длина удовлетворяет условию
                 // не стоп-слово и минимальная длина удовлетворяет условию
                 if (null !== $this->model->word($subQuery)) {
                 if (null !== $this->model->word($subQuery)) {
                     // подстрока является словом и нет символов CJK языков
                     // подстрока является словом и нет символов CJK языков
-                    if (false === \strpos($subQuery, ' ')
+                    if (
+                        false === \strpos($subQuery, ' ')
                         && ! $this->model->isCJKWord($subQuery)
                         && ! $this->model->isCJKWord($subQuery)
                         && $this->model->cleanText($subQuery) === $subQuery
                         && $this->model->cleanText($subQuery) === $subQuery
                     ) {
                     ) {
@@ -142,7 +143,10 @@ class Prepare extends Method
                             if (! $keyword) {
                             if (! $keyword) {
                                 $words[] = 'AND';
                                 $words[] = 'AND';
                             }
                             }
-                            if (1 === $countT || 'AND' === \end($words)) {
+                            if (
+                                1 === $countT
+                                || 'AND' === \end($words)
+                            ) {
                                 $words  = \array_merge($words, $temp);
                                 $words  = \array_merge($words, $temp);
                                 $count += $countT;
                                 $count += $countT;
                             } else {
                             } else {
@@ -184,7 +188,10 @@ class Prepare extends Method
         $space  = '';
         $space  = '';
         $result = '';
         $result = '';
         foreach ($words as $word) {
         foreach ($words as $word) {
-            if (isset($word['type']) && 'CJK' === $word['type']) {
+            if (
+                isset($word['type'])
+                && 'CJK' === $word['type']
+            ) {
                 $word = '"' . $word['word'] . '"';
                 $word = '"' . $word['word'] . '"';
             } elseif (\is_array($word)) {
             } elseif (\is_array($word)) {
                 $word = '(' . $this->queryText($word) . ')';
                 $word = '(' . $this->queryText($word) . ')';

+ 5 - 2
app/Models/Stopwords/Model.php

@@ -14,7 +14,10 @@ class Model extends ParentModel
     public function init(): self
     public function init(): self
     {
     {
         $data = $this->c->Cache->get('stopwords');
         $data = $this->c->Cache->get('stopwords');
-        if (isset($data['id'], $data['stopwords']) && $data['id'] === $this->generateId()) {
+        if (
+            isset($data['id'], $data['stopwords'])
+            && $data['id'] === $this->generateId()
+        ) {
             $this->list = $data['stopwords'];
             $this->list = $data['stopwords'];
         } else {
         } else {
             $this->load();
             $this->load();
@@ -34,7 +37,7 @@ class Model extends ParentModel
         }
         }
 
 
         $files = \glob($this->c->DIR_LANG . '/*/stopwords.txt');
         $files = \glob($this->c->DIR_LANG . '/*/stopwords.txt');
-        if ($files === false) {
+        if (false === $files) {
             return 'cache_id_error';
             return 'cache_id_error';
         }
         }
 
 

+ 4 - 1
app/Models/Topic/Load.php

@@ -82,7 +82,10 @@ class Load extends Action
     public function loadByIds(array $ids, bool $full): array
     public function loadByIds(array $ids, bool $full): array
     {
     {
         foreach ($ids as $id) {
         foreach ($ids as $id) {
-            if (! \is_int($id) || $id < 1) {
+            if (
+                ! \is_int($id)
+                || $id < 1
+            ) {
                 throw new InvalidArgumentException('Expected a positive topic id');
                 throw new InvalidArgumentException('Expected a positive topic id');
             }
             }
         }
         }

+ 43 - 11
app/Models/Topic/Model.php

@@ -24,7 +24,10 @@ class Model extends DataModel
 
 
         $forum = $this->c->forums->get($this->forum_id);
         $forum = $this->c->forums->get($this->forum_id);
 
 
-        if (! $forum instanceof Forum || $forum->redirect_url) {
+        if (
+            ! $forum instanceof Forum
+            || $forum->redirect_url
+        ) {
             return null;
             return null;
         } else {
         } else {
             return $forum;
             return $forum;
@@ -40,10 +43,17 @@ class Model extends DataModel
     {
     {
         if ($this->c->user->isAdmin) {
         if ($this->c->user->isAdmin) {
             return true;
             return true;
-        } elseif ($this->closed || $this->c->user->isBot) {
+        } elseif (
+            $this->closed
+            || $this->c->user->isBot
+        ) {
             return false;
             return false;
-        } elseif ($this->parent->post_replies == '1'
-            || (null === $this->parent->post_replies && $this->c->user->g_post_replies == '1')
+        } elseif (
+            '1' == $this->parent->post_replies
+            || (
+                null === $this->parent->post_replies
+                && '1' == $this->c->user->g_post_replies
+            )
             || $this->c->user->isModerator($this)
             || $this->c->user->isModerator($this)
         ) {
         ) {
             return true;
             return true;
@@ -111,7 +121,10 @@ class Model extends DataModel
      */
      */
     protected function gethasNew()
     protected function gethasNew()
     {
     {
-        if ($this->c->user->isGuest || $this->moved_to) {
+        if (
+            $this->c->user->isGuest
+            || $this->moved_to
+        ) {
             return false;
             return false;
         }
         }
 
 
@@ -132,7 +145,10 @@ class Model extends DataModel
      */
      */
     protected function gethasUnread()
     protected function gethasUnread()
     {
     {
-        if ($this->c->user->isGuest || $this->moved_to) {
+        if (
+            $this->c->user->isGuest
+            || $this->moved_to
+        ) {
             return false;
             return false;
         }
         }
 
 
@@ -214,7 +230,10 @@ class Model extends DataModel
     {
     {
         $page = (int) $this->page;
         $page = (int) $this->page;
 
 
-        if ($page < 1 && $this->numPages === 1) {
+        if (
+            $page < 1
+            && 1 === $this->numPages
+        ) {
             // 1 страницу в списке тем раздела не отображаем
             // 1 страницу в списке тем раздела не отображаем
             return [];
             return [];
         } else { //????
         } else { //????
@@ -257,7 +276,14 @@ class Model extends DataModel
                 LIMIT ?i:offset, ?i:rows';
                 LIMIT ?i:offset, ?i:rows';
         $list = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
         $list = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
 
 
-        if (! empty($list) && ($this->stick_fp || $this->poll_type) && ! \in_array($this->first_post_id, $list)) {
+        if (
+            ! empty($list)
+            && (
+                $this->stick_fp
+                || $this->poll_type
+            )
+            && ! \in_array($this->first_post_id, $list)
+        ) {
             \array_unshift($list, $this->first_post_id);
             \array_unshift($list, $this->first_post_id);
         }
         }
 
 
@@ -321,7 +347,7 @@ class Model extends DataModel
      */
      */
     protected function getshowViews(): bool
     protected function getshowViews(): bool
     {
     {
-        return $this->c->config->o_topic_views == '1';
+        return '1' == $this->c->config->o_topic_views;
     }
     }
 
 
     /**
     /**
@@ -358,14 +384,20 @@ class Model extends DataModel
             $flag = true;
             $flag = true;
             $vars[':visit'] = $this->last_post;
             $vars[':visit'] = $this->last_post;
         }
         }
-        if (false !== $this->hasUnread && $this->timeMax > $this->hasUnread) {
+        if (
+            false !== $this->hasUnread
+            && $this->timeMax > $this->hasUnread
+        ) {
             $flag = true;
             $flag = true;
             $vars[':read'] = $this->timeMax;
             $vars[':read'] = $this->timeMax;
             $vars[':visit'] = $this->last_post;
             $vars[':visit'] = $this->last_post;
         }
         }
 
 
         if ($flag) {
         if ($flag) {
-            if (empty($this->mt_last_read) && empty($this->mt_last_visit)) {
+            if (
+                empty($this->mt_last_read)
+                && empty($this->mt_last_visit)
+            ) {
                 $sql = 'INSERT INTO ::mark_of_topic (uid, tid, mt_last_visit, mt_last_read)
                 $sql = 'INSERT INTO ::mark_of_topic (uid, tid, mt_last_visit, mt_last_read)
                         SELECT ?i:uid, ?i:tid, ?i:visit, ?i:read
                         SELECT ?i:uid, ?i:tid, ?i:visit, ?i:read
                         FROM ::groups
                         FROM ::groups

+ 1 - 1
app/Models/Topic/Save.php

@@ -34,7 +34,7 @@ class Save extends Action
                 continue;
                 continue;
             }
             }
             $vars[] = $values[$name];
             $vars[] = $values[$name];
-            $set[] = $name . '=?' . $fileds[$name];
+            $set[]  = $name . '=?' . $fileds[$name];
         }
         }
         if (empty($set)) {
         if (empty($set)) {
             return $topic;
             return $topic;

+ 12 - 3
app/Models/Topic/View.php

@@ -32,13 +32,19 @@ class View extends Action
             throw new InvalidArgumentException('Expected Forum or Search');
             throw new InvalidArgumentException('Expected Forum or Search');
         }
         }
 
 
-        if (empty($arg->idsList) || ! \is_array($arg->idsList)) {
+        if (
+            empty($arg->idsList)
+            || ! \is_array($arg->idsList)
+        ) {
             throw new RuntimeException('Model does not contain of topics list for display');
             throw new RuntimeException('Model does not contain of topics list for display');
         }
         }
 
 
         $result = $this->c->topics->loadByIds($arg->idsList, $full);
         $result = $this->c->topics->loadByIds($arg->idsList, $full);
 
 
-        if (! $this->c->user->isGuest && '1' == $this->c->config->o_show_dot) {
+        if (
+            ! $this->c->user->isGuest
+            && '1' == $this->c->config->o_show_dot
+        ) {
             $vars = [
             $vars = [
                 ':uid' => $this->c->user->id,
                 ':uid' => $this->c->user->id,
                 ':ids' => $arg->idsList,
                 ':ids' => $arg->idsList,
@@ -50,7 +56,10 @@ class View extends Action
             $dots = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
             $dots = $this->c->DB->query($sql, $vars)->fetchAll(PDO::FETCH_COLUMN);
 
 
             foreach ($dots as $id) {
             foreach ($dots as $id) {
-                if (isset($result[$id]) && $result[$id] instanceof Topic) {
+                if (
+                    isset($result[$id])
+                    && $result[$id] instanceof Topic
+                ) {
                     $result[$id]->__dot = true;
                     $result[$id]->__dot = true;
                 }
                 }
             }
             }

+ 8 - 2
app/Models/User/ChangeGroup.php

@@ -22,7 +22,10 @@ class ChangeGroup extends Action
     public function changeGroup(int $newGroupId, User ...$users): void
     public function changeGroup(int $newGroupId, User ...$users): void
     {
     {
         $newGroup = $this->c->groups->get($newGroupId);
         $newGroup = $this->c->groups->get($newGroupId);
-        if (null === $newGroup || $newGroup->groupGuest) {
+        if (
+            null === $newGroup
+            || $newGroup->groupGuest
+        ) {
             throw new InvalidArgumentException('Expected group number');
             throw new InvalidArgumentException('Expected group number');
         }
         }
 
 
@@ -38,7 +41,10 @@ class ChangeGroup extends Action
                 throw new RuntimeException('Guest can not change group');
                 throw new RuntimeException('Guest can not change group');
             }
             }
 
 
-            if (1 != $newGroup->g_moderator && $user->isAdmMod) {
+            if (
+                1 != $newGroup->g_moderator
+                && $user->isAdmMod
+            ) {
                 $moderators[$user->id] = $user;
                 $moderators[$user->id] = $user;
             }
             }
             if ($user->isAdmin) {
             if ($user->isAdmin) {

+ 43 - 30
app/Models/User/Current.php

@@ -17,12 +17,13 @@ class Current extends Action
     public function current(): User
     public function current(): User
     {
     {
         $cookie = $this->c->Cookie;
         $cookie = $this->c->Cookie;
-        $user = $this->load((int) $cookie->uId);
+        $user   = $this->load((int) $cookie->uId);
 
 
         if (! $user->isGuest) {
         if (! $user->isGuest) {
             if (! $cookie->verifyUser($user)) {
             if (! $cookie->verifyUser($user)) {
                 $user = $this->load(1);
                 $user = $this->load(1);
-            } elseif ($this->c->config->o_check_ip == '1'
+            } elseif (
+                '1' == $this->c->config->o_check_ip
                 && $user->isAdmMod
                 && $user->isAdmMod
                 && $user->registration_ip !== $user->ip
                 && $user->registration_ip !== $user->ip
             ) {
             ) {
@@ -60,7 +61,10 @@ class Current extends Action
 #                $user->__disp_posts = $this->c->config->o_disp_posts_default;
 #                $user->__disp_posts = $this->c->config->o_disp_posts_default;
 #            }
 #            }
             // Special case: We've timed out, but no other user has browsed the forums since we timed out
             // Special case: We've timed out, but no other user has browsed the forums since we timed out
-            if ($user->isLogged && $user->logged < \time() - $this->c->config->o_timeout_visit) {
+            if (
+                $user->isLogged
+                && $user->logged < \time() - $this->c->config->o_timeout_visit
+            ) {
                 $this->manager->updateLastVisit($user); //????
                 $this->manager->updateLastVisit($user); //????
             }
             }
 
 
@@ -82,7 +86,7 @@ class Current extends Action
     protected function load(int $id): User
     protected function load(int $id): User
     {
     {
         $data = null;
         $data = null;
-        $ip = $this->getIp();
+        $ip   = $this->getIp();
         if ($id > 1) {
         if ($id > 1) {
             $data = $this->c->DB->query('SELECT u.*, g.*, o.logged FROM ::users AS u INNER JOIN ::groups AS g ON u.group_id=g.g_id LEFT JOIN ::online AS o ON o.user_id=u.id WHERE u.id=?i:id', [':id' => $id])->fetch();
             $data = $this->c->DB->query('SELECT u.*, g.*, o.logged FROM ::users AS u INNER JOIN ::groups AS g ON u.group_id=g.g_id LEFT JOIN ::online AS o ON o.user_id=u.id WHERE u.id=?i:id', [':id' => $id])->fetch();
         }
         }
@@ -93,8 +97,8 @@ class Current extends Action
             }
             }
         }
         }
 
 
-        $user = $this->manager->create($data);
-        $user->__ip = $ip;
+        $user              = $this->manager->create($data);
+        $user->__ip        = $ip;
         $user->__userAgent = $this->getUserAgent();
         $user->__userAgent = $this->getUserAgent();
         return $user;
         return $user;
     }
     }
@@ -129,29 +133,34 @@ class Current extends Action
     protected function isBot()
     protected function isBot()
     {
     {
         $agent = $this->getUserAgent();
         $agent = $this->getUserAgent();
-        if ($agent == '') {
+        if ('' == $agent) {
             return false;
             return false;
         }
         }
         $agentL = \strtolower($agent);
         $agentL = \strtolower($agent);
 
 
-        if (\strpos($agentL, 'bot') !== false
-            || \strpos($agentL, 'spider') !== false
-            || \strpos($agentL, 'crawler') !== false
-            || \strpos($agentL, 'http') !== false
+        if (
+            false !== \strpos($agentL, 'bot')
+            || false !== \strpos($agentL, 'spider')
+            || false !== \strpos($agentL, 'crawler')
+            || false !== \strpos($agentL, 'http')
         ) {
         ) {
             return $this->nameBot($agent, $agentL);
             return $this->nameBot($agent, $agentL);
         }
         }
 
 
-        if (\strpos($agent, 'Mozilla/') !== false
-            && (\strpos($agent, 'Gecko') !== false
-                || (\strpos($agent, '(compatible; MSIE ') !== false
-                    && \strpos($agent, 'Windows') !== false
+        if (
+            false !== \strpos($agent, 'Mozilla/')
+            && (
+                false !== \strpos($agent, 'Gecko')
+                || (
+                    false !== \strpos($agent, '(compatible; MSIE ')
+                    && false !== \strpos($agent, 'Windows')
                 )
                 )
             )
             )
         ) {
         ) {
             return false;
             return false;
-        } elseif (\strpos($agent, 'Opera/') !== false
-            && \strpos($agent, 'Presto/') !== false
+        } elseif (
+            false !== \strpos($agent, 'Opera/')
+            && false !== \strpos($agent, 'Presto/')
         ) {
         ) {
             return false;
             return false;
         }
         }
@@ -168,21 +177,22 @@ class Current extends Action
      */
      */
     protected function nameBot(string $agent, string $agentL): string
     protected function nameBot(string $agent, string $agentL): string
     {
     {
-        if (\strpos($agentL, 'mozilla') !== false) {
+        if (false !== \strpos($agentL, 'mozilla')) {
             $agent = \preg_replace('%Mozilla.*?compatible%i', ' ', $agent);
             $agent = \preg_replace('%Mozilla.*?compatible%i', ' ', $agent);
         }
         }
-        if (\strpos($agentL, 'http') !== false || \strpos($agentL, 'www.') !== false) {
+        if (false !== \strpos($agentL, 'http') || false !== \strpos($agentL, 'www.')) {
             $agent = \preg_replace('%(?:https?://|www\.)[^\)]*(\)[^/]+$)?%i', ' ', $agent);
             $agent = \preg_replace('%(?:https?://|www\.)[^\)]*(\)[^/]+$)?%i', ' ', $agent);
         }
         }
-        if (\strpos($agent, '@') !== false) {
+        if (false !== \strpos($agent, '@')) {
             $agent = \preg_replace('%\b[a-z0-9_\.-]+@[^\)]+%i', ' ', $agent);
             $agent = \preg_replace('%\b[a-z0-9_\.-]+@[^\)]+%i', ' ', $agent);
         }
         }
 
 
         $agentL = \strtolower($agent);
         $agentL = \strtolower($agent);
-        if (\strpos($agentL, 'bot') !== false
-            || \strpos($agentL, 'spider') !== false
-            || \strpos($agentL, 'crawler') !== false
-            || \strpos($agentL, 'engine') !== false
+        if (
+            false !== \strpos($agentL, 'bot')
+            || false !== \strpos($agentL, 'spider')
+            || false !== \strpos($agentL, 'crawler')
+            || false !== \strpos($agentL, 'engine')
         ) {
         ) {
             $f = true;
             $f = true;
             $p = '%(?<=[^a-z\d\.-])(?:robot|bot|spider|crawler)\b.*%i';
             $p = '%(?<=[^a-z\d\.-])(?:robot|bot|spider|crawler)\b.*%i';
@@ -191,8 +201,10 @@ class Current extends Action
             $p = '%^$%';
             $p = '%^$%';
         }
         }
 
 
-        if ($f && \preg_match('%\b(([a-z\d\.! _-]+)?(?:robot|(?<!ro)bot|spider|crawler|engine)(?(2)[a-z\d\.! _-]*|[a-z\d\.! _-]+))%i', $agent, $matches))
-        {
+        if (
+            $f
+            && \preg_match('%\b(([a-z\d\.! _-]+)?(?:robot|(?<!ro)bot|spider|crawler|engine)(?(2)[a-z\d\.! _-]*|[a-z\d\.! _-]+))%i', $agent, $matches)
+        ) {
             $agent = $matches[1];
             $agent = $matches[1];
 
 
             $pat = [
             $pat = [
@@ -237,9 +249,10 @@ class Current extends Action
             return 'Unknown';
             return 'Unknown';
         }
         }
 
 
-        $a = \explode(' ', $agent);
+        $a     = \explode(' ', $agent);
         $agent = $a[0];
         $agent = $a[0];
-        if (\strlen($agent) < 20
+        if (
+            \strlen($agent) < 20
             && ! empty($a[1])
             && ! empty($a[1])
             && \strlen($agent . ' ' . $a[1]) < 26
             && \strlen($agent . ' ' . $a[1]) < 26
         ) {
         ) {
@@ -260,11 +273,11 @@ class Current extends Action
     {
     {
         if (! empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         if (! empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
             $langs = $this->c->Func->getLangs();
             $langs = $this->c->Func->getLangs();
-            $main = [];
+            $main  = [];
             foreach ($this->c->Func->langParse($_SERVER['HTTP_ACCEPT_LANGUAGE']) as $entry) {
             foreach ($this->c->Func->langParse($_SERVER['HTTP_ACCEPT_LANGUAGE']) as $entry) {
                 $arr = \explode('-', $entry, 2);
                 $arr = \explode('-', $entry, 2);
                 if (isset($arr[1])) {
                 if (isset($arr[1])) {
-                    $entry = $arr[0] . '_' . \strtoupper($arr[1]);
+                    $entry  = $arr[0] . '_' . \strtoupper($arr[1]);
                     $main[] = $arr[0];
                     $main[] = $arr[0];
                 }
                 }
                 if (isset($langs[$entry])) {
                 if (isset($langs[$entry])) {

+ 2 - 2
app/Models/User/Delete.php

@@ -25,8 +25,8 @@ class Delete extends Action
             throw new InvalidArgumentException('No arguments, expected User(s)');
             throw new InvalidArgumentException('No arguments, expected User(s)');
         }
         }
 
 
-        $ids = [];
-        $moderators = [];
+        $ids          = [];
+        $moderators   = [];
         $adminPresent = false;
         $adminPresent = false;
         foreach ($users as $user) {
         foreach ($users as $user) {
             if (! $user instanceof User) {
             if (! $user instanceof User) {

+ 4 - 1
app/Models/User/Filter.php

@@ -28,7 +28,10 @@ class Filter extends Action
             if (! isset($fields[$field])) {
             if (! isset($fields[$field])) {
                 throw new InvalidArgumentException("The '{$field}' field is not found");
                 throw new InvalidArgumentException("The '{$field}' field is not found");
             }
             }
-            if ('ASC' !== $dir && 'DESC' !== $dir) {
+            if (
+                'ASC' !== $dir
+                && 'DESC' !== $dir
+            ) {
                 throw new InvalidArgumentException('The sort direction is not defined');
                 throw new InvalidArgumentException('The sort direction is not defined');
             }
             }
             $orderBy[] = "u.{$field} {$dir}";
             $orderBy[] = "u.{$field} {$dir}";

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä