@@ -10,7 +10,9 @@ discard block |
||
10 | 10 | |
11 | 11 | public function __invoke(array $post) { |
12 | 12 | |
13 | - if (!Auth::check()) return false; |
|
13 | + if (!Auth::check()) { |
|
14 | + return false; |
|
15 | + } |
|
14 | 16 | |
15 | 17 | # Declare variables |
16 | 18 | |
@@ -22,9 +24,13 @@ discard block |
||
22 | 24 | |
23 | 25 | # Validate values |
24 | 26 | |
25 | - if (false === ($password_new = Auth\Validate::userPassword($password_new))) return 'USER_ERROR_PASSWORD_NEW_INVALID'; |
|
27 | + if (false === ($password_new = Auth\Validate::userPassword($password_new))) { |
|
28 | + return 'USER_ERROR_PASSWORD_NEW_INVALID'; |
|
29 | + } |
|
26 | 30 | |
27 | - if (0 !== strcmp($password_new, $password_retype)) return 'USER_ERROR_PASSWORD_MISMATCH'; |
|
31 | + if (0 !== strcmp($password_new, $password_retype)) { |
|
32 | + return 'USER_ERROR_PASSWORD_MISMATCH'; |
|
33 | + } |
|
28 | 34 | |
29 | 35 | # Encode password |
30 | 36 | |
@@ -34,7 +40,9 @@ discard block |
||
34 | 40 | |
35 | 41 | $data = ['auth_key' => $auth_key, 'password' => $password]; |
36 | 42 | |
37 | - if (!Auth::user()->edit($data)) return 'USER_ERROR_AUTH_RECOVER'; |
|
43 | + if (!Auth::user()->edit($data)) { |
|
44 | + return 'USER_ERROR_AUTH_RECOVER'; |
|
45 | + } |
|
38 | 46 | |
39 | 47 | # Remove secret |
40 | 48 |
@@ -10,7 +10,9 @@ discard block |
||
10 | 10 | |
11 | 11 | public function __invoke(array $post) { |
12 | 12 | |
13 | - if (Auth::check()) return true; |
|
13 | + if (Auth::check()) { |
|
14 | + return true; |
|
15 | + } |
|
14 | 16 | |
15 | 17 | # Declare variables |
16 | 18 | |
@@ -22,9 +24,13 @@ discard block |
||
22 | 24 | |
23 | 25 | # Validate values |
24 | 26 | |
25 | - if (false === ($name = Auth\Validate::userName($name))) return 'USER_ERROR_NAME_INVALID'; |
|
27 | + if (false === ($name = Auth\Validate::userName($name))) { |
|
28 | + return 'USER_ERROR_NAME_INVALID'; |
|
29 | + } |
|
26 | 30 | |
27 | - if (false === Security::checkCaptcha($captcha)) return 'USER_ERROR_CAPTCHA_INCORRECT'; |
|
31 | + if (false === Security::checkCaptcha($captcha)) { |
|
32 | + return 'USER_ERROR_CAPTCHA_INCORRECT'; |
|
33 | + } |
|
28 | 34 | |
29 | 35 | # Create user object |
30 | 36 | |
@@ -32,13 +38,19 @@ discard block |
||
32 | 38 | |
33 | 39 | # Init user |
34 | 40 | |
35 | - if (!$user->init($name, 'name')) return 'USER_ERROR_NAME_INCORRECT'; |
|
41 | + if (!$user->init($name, 'name')) { |
|
42 | + return 'USER_ERROR_NAME_INCORRECT'; |
|
43 | + } |
|
36 | 44 | |
37 | - if (Auth::admin() && ($user->rank < RANK_ADMINISTRATOR)) return 'USER_ERROR_NAME_INCORRECT'; |
|
45 | + if (Auth::admin() && ($user->rank < RANK_ADMINISTRATOR)) { |
|
46 | + return 'USER_ERROR_NAME_INCORRECT'; |
|
47 | + } |
|
38 | 48 | |
39 | 49 | # Check access |
40 | 50 | |
41 | - if (!Auth::admin() && ($user->rank === RANK_GUEST)) return 'USER_ERROR_ACCESS'; |
|
51 | + if (!Auth::admin() && ($user->rank === RANK_GUEST)) { |
|
52 | + return 'USER_ERROR_ACCESS'; |
|
53 | + } |
|
42 | 54 | |
43 | 55 | # Create session |
44 | 56 | |
@@ -48,7 +60,9 @@ discard block |
||
48 | 60 | |
49 | 61 | $data = ['id' => $user->id, 'code' => $code, 'ip' => $ip, 'time' => $time]; |
50 | 62 | |
51 | - if (!$secret->create($data)) return 'USER_ERROR_AUTH_RESET'; |
|
63 | + if (!$secret->create($data)) { |
|
64 | + return 'USER_ERROR_AUTH_RESET'; |
|
65 | + } |
|
52 | 66 | |
53 | 67 | # Send mail |
54 | 68 |
@@ -14,9 +14,11 @@ |
||
14 | 14 | |
15 | 15 | # Init user by secret code |
16 | 16 | |
17 | - if (false !== ($code = Auth::secret())) $this->code = $code; |
|
18 | - |
|
19 | - else Request::redirect(INSTALL_PATH . (Auth::admin() ? '/admin' : '/profile') . '/reset'); |
|
17 | + if (false !== ($code = Auth::secret())) { |
|
18 | + $this->code = $code; |
|
19 | + } else { |
|
20 | + Request::redirect(INSTALL_PATH . (Auth::admin() ? '/admin' : '/profile') . '/reset'); |
|
21 | + } |
|
20 | 22 | |
21 | 23 | # Create form |
22 | 24 |
@@ -12,9 +12,13 @@ discard block |
||
12 | 12 | |
13 | 13 | private static function getAuth(string $code, string $type, int $lifetime) { |
14 | 14 | |
15 | - if (!($auth = Entitizer::get($type))->init($code, 'code')) return false; |
|
15 | + if (!($auth = Entitizer::get($type))->init($code, 'code')) { |
|
16 | + return false; |
|
17 | + } |
|
16 | 18 | |
17 | - if (($auth->ip !== REQUEST_CLIENT_IP) || ($auth->time < (REQUEST_TIME - $lifetime))) return false; |
|
19 | + if (($auth->ip !== REQUEST_CLIENT_IP) || ($auth->time < (REQUEST_TIME - $lifetime))) { |
|
20 | + return false; |
|
21 | + } |
|
18 | 22 | |
19 | 23 | # ------------------------ |
20 | 24 | |
@@ -25,9 +29,13 @@ discard block |
||
25 | 29 | |
26 | 30 | private static function getUser(int $id) { |
27 | 31 | |
28 | - if (0 === ($user = Entitizer::get(ENTITY_TYPE_USER, $id))->id) return false; |
|
32 | + if (0 === ($user = Entitizer::get(ENTITY_TYPE_USER, $id))->id) { |
|
33 | + return false; |
|
34 | + } |
|
29 | 35 | |
30 | - if ($user->rank < (self::$admin ? RANK_ADMINISTRATOR : RANK_USER)) return false; |
|
36 | + if ($user->rank < (self::$admin ? RANK_ADMINISTRATOR : RANK_USER)) { |
|
37 | + return false; |
|
38 | + } |
|
31 | 39 | |
32 | 40 | # ------------------------ |
33 | 41 | |
@@ -42,17 +50,23 @@ discard block |
||
42 | 50 | |
43 | 51 | # Check session code |
44 | 52 | |
45 | - if (false === ($code = Auth\Validate::code(Session::get('code')))) return false; |
|
53 | + if (false === ($code = Auth\Validate::code(Session::get('code')))) { |
|
54 | + return false; |
|
55 | + } |
|
46 | 56 | |
47 | 57 | # Get auth |
48 | 58 | |
49 | 59 | $type = ENTITY_TYPE_USER_SESSION; $lifetime = CONFIG_USER_SESSION_LIFETIME; |
50 | 60 | |
51 | - if (false === ($session = self::getAuth($code, $type, $lifetime))) return false; |
|
61 | + if (false === ($session = self::getAuth($code, $type, $lifetime))) { |
|
62 | + return false; |
|
63 | + } |
|
52 | 64 | |
53 | 65 | # Get user |
54 | 66 | |
55 | - if (false === ($user = self::getUser($session->id))) return false; |
|
67 | + if (false === ($user = self::getUser($session->id))) { |
|
68 | + return false; |
|
69 | + } |
|
56 | 70 | |
57 | 71 | # Update session |
58 | 72 | |
@@ -71,21 +85,29 @@ discard block |
||
71 | 85 | |
72 | 86 | public static function secret() { |
73 | 87 | |
74 | - if ((null === self::$user) || (0 !== self::$user->id)) return false; |
|
88 | + if ((null === self::$user) || (0 !== self::$user->id)) { |
|
89 | + return false; |
|
90 | + } |
|
75 | 91 | |
76 | 92 | # Check secret code |
77 | 93 | |
78 | - if (false === ($code = Auth\Validate::code(Request::get('code')))) return false; |
|
94 | + if (false === ($code = Auth\Validate::code(Request::get('code')))) { |
|
95 | + return false; |
|
96 | + } |
|
79 | 97 | |
80 | 98 | # Get auth |
81 | 99 | |
82 | 100 | $type = ENTITY_TYPE_USER_SECRET; $lifetime = CONFIG_USER_SECRET_LIFETIME; |
83 | 101 | |
84 | - if (false === ($secret = self::getAuth($code, $type, $lifetime))) return false; |
|
102 | + if (false === ($secret = self::getAuth($code, $type, $lifetime))) { |
|
103 | + return false; |
|
104 | + } |
|
85 | 105 | |
86 | 106 | # Get user |
87 | 107 | |
88 | - if (false === ($user = self::getUser($secret->id))) return false; |
|
108 | + if (false === ($user = self::getUser($secret->id))) { |
|
109 | + return false; |
|
110 | + } |
|
89 | 111 | |
90 | 112 | # ------------------------ |
91 | 113 | |
@@ -96,7 +118,9 @@ discard block |
||
96 | 118 | |
97 | 119 | public static function logout() { |
98 | 120 | |
99 | - if ((null === self::$user) || (0 === self::$user->id)) return false; |
|
121 | + if ((null === self::$user) || (0 === self::$user->id)) { |
|
122 | + return false; |
|
123 | + } |
|
100 | 124 | |
101 | 125 | # Remove session |
102 | 126 |
@@ -10,7 +10,9 @@ |
||
10 | 10 | |
11 | 11 | private static function validate(string $string, string $regex, int $min, int $max) { |
12 | 12 | |
13 | - if (!preg_match($regex, $string)) return false; |
|
13 | + if (!preg_match($regex, $string)) { |
|
14 | + return false; |
|
15 | + } |
|
14 | 16 | |
15 | 17 | return ((Str::between($string, $min, $max)) ? $string : false); |
16 | 18 | } |
@@ -20,7 +20,9 @@ |
||
20 | 20 | |
21 | 21 | # Implement form |
22 | 22 | |
23 | - if (null !== $this->form) $this->form->implement($contents); |
|
23 | + if (null !== $this->form) { |
|
24 | + $this->form->implement($contents); |
|
25 | + } |
|
24 | 26 | |
25 | 27 | # ------------------------ |
26 | 28 |
@@ -23,15 +23,19 @@ discard block |
||
23 | 23 | |
24 | 24 | while (false !== ($name = readdir($handler))) { |
25 | 25 | |
26 | - if (in_array($name, ['.', '..', '.empty'], true)) continue; |
|
26 | + if (in_array($name, ['.', '..', '.empty'], true)) { |
|
27 | + continue; |
|
28 | + } |
|
27 | 29 | |
28 | 30 | $path = ($prefix . $name); $path_full = ($this->parent->pathFull() . $name); |
29 | 31 | |
30 | 32 | $data = ['name' => $name, 'path' => $path, 'path_full' => $path_full]; |
31 | 33 | |
32 | - if (@is_dir($path_full)) $dirs[] = array_merge($data, ['type' => FILEMANAGER_TYPE_DIR]); |
|
33 | - |
|
34 | - else if (@is_file($path_full)) $files[] = array_merge($data, ['type' => FILEMANAGER_TYPE_FILE]); |
|
34 | + if (@is_dir($path_full)) { |
|
35 | + $dirs[] = array_merge($data, ['type' => FILEMANAGER_TYPE_DIR]); |
|
36 | + } else if (@is_file($path_full)) { |
|
37 | + $files[] = array_merge($data, ['type' => FILEMANAGER_TYPE_FILE]); |
|
38 | + } |
|
35 | 39 | } |
36 | 40 | |
37 | 41 | closedir($handler); |
@@ -98,9 +102,11 @@ discard block |
||
98 | 102 | |
99 | 103 | foreach ($this->items['list'] as $item) { |
100 | 104 | |
101 | - if ($item['type'] === FILEMANAGER_TYPE_DIR) $items->add($this->getDirItemBlock($item)); |
|
102 | - |
|
103 | - else if ($item['type'] === FILEMANAGER_TYPE_FILE) $items->add($this->getFileItemBlock($item)); |
|
105 | + if ($item['type'] === FILEMANAGER_TYPE_DIR) { |
|
106 | + $items->add($this->getDirItemBlock($item)); |
|
107 | + } else if ($item['type'] === FILEMANAGER_TYPE_FILE) { |
|
108 | + $items->add($this->getFileItemBlock($item)); |
|
109 | + } |
|
104 | 110 | } |
105 | 111 | |
106 | 112 | # ------------------------ |
@@ -149,7 +155,9 @@ discard block |
||
149 | 155 | |
150 | 156 | $items = $this->getItemsBlock(); |
151 | 157 | |
152 | - if ($items->count() > 0) $contents->items = $items; |
|
158 | + if ($items->count() > 0) { |
|
159 | + $contents->items = $items; |
|
160 | + } |
|
153 | 161 | |
154 | 162 | # Set pagination |
155 | 163 |
@@ -2,8 +2,15 @@ |
||
2 | 2 | |
3 | 3 | namespace Modules\Filemanager\Handler { |
4 | 4 | |
5 | - use Modules\Filemanager, Utils\Messages, Utils\Pagination, Utils\Uploader, Utils\View; |
|
6 | - use Ajax, Arr, Explorer, Language, Number, Request, Template, Url; |
|
5 | + use Modules\Filemanager; |
|
6 | + use Utils\Pagination; |
|
7 | + use Utils\Uploader; |
|
8 | + use Utils\View; |
|
9 | + use Arr; |
|
10 | + use Number; |
|
11 | + use Request; |
|
12 | + use Template; |
|
13 | + use Url; |
|
7 | 14 | |
8 | 15 | class Listview { |
9 | 16 |
@@ -16,7 +16,9 @@ discard block |
||
16 | 16 | |
17 | 17 | $path = implode('/', $scheme); $path_full = (DIR_UPLOADS . (('' !== $path) ? ($path . '/') : '')); |
18 | 18 | |
19 | - if (!Explorer::isDir($path_full)) return; |
|
19 | + if (!Explorer::isDir($path_full)) { |
|
20 | + return; |
|
21 | + } |
|
20 | 22 | |
21 | 23 | $this->scheme = $scheme; $this->path = $path; $this->path_full = $path_full; |
22 | 24 | } |
@@ -27,9 +29,12 @@ discard block |
||
27 | 29 | |
28 | 30 | $scheme = []; $breadcrumbs = []; |
29 | 31 | |
30 | - if ([] !== $this->scheme) foreach ($this->scheme as $name) { |
|
32 | + if ([] !== $this->scheme) { |
|
33 | + foreach ($this->scheme as $name) { |
|
31 | 34 | |
32 | - $scheme[] = $name; $breadcrumbs[] = ['path' => implode('/', $scheme), 'name' => $name]; |
|
35 | + $scheme[] = $name; |
|
36 | + } |
|
37 | + $breadcrumbs[] = ['path' => implode('/', $scheme), 'name' => $name]; |
|
33 | 38 | } |
34 | 39 | |
35 | 40 | # ------------------------ |
@@ -12,7 +12,9 @@ discard block |
||
12 | 12 | |
13 | 13 | private function getPrototype(string $name) { |
14 | 14 | |
15 | - if (preg_match('/[\/\\\\]/', $name)) return false; |
|
15 | + if (preg_match('/[\/\\\\]/', $name)) { |
|
16 | + return false; |
|
17 | + } |
|
16 | 18 | |
17 | 19 | $path = (($this->parent->path() ? ($this->parent->path() . '/') : '') . $name); |
18 | 20 | |
@@ -34,11 +36,17 @@ discard block |
||
34 | 36 | |
35 | 37 | public function init(string $name) { |
36 | 38 | |
37 | - if (false === ($prototype = $this->getPrototype($name))) return false; |
|
39 | + if (false === ($prototype = $this->getPrototype($name))) { |
|
40 | + return false; |
|
41 | + } |
|
38 | 42 | |
39 | - if (!Explorer::{static::$checker}($prototype['path_full'])) return false; |
|
43 | + if (!Explorer::{static::$checker}($prototype['path_full'])) { |
|
44 | + return false; |
|
45 | + } |
|
40 | 46 | |
41 | - foreach ($prototype as $var => $value) $this->$var = $value; |
|
47 | + foreach ($prototype as $var => $value) { |
|
48 | + $this->$var = $value; |
|
49 | + } |
|
42 | 50 | |
43 | 51 | # ------------------------ |
44 | 52 | |
@@ -49,11 +57,17 @@ discard block |
||
49 | 57 | |
50 | 58 | public function create(string $name) { |
51 | 59 | |
52 | - if (('' !== $this->name) || (false === ($prototype = $this->getPrototype($name)))) return false; |
|
60 | + if (('' !== $this->name) || (false === ($prototype = $this->getPrototype($name)))) { |
|
61 | + return false; |
|
62 | + } |
|
53 | 63 | |
54 | - if (!Explorer::{static::$creator}($prototype['path_full'])) return false; |
|
64 | + if (!Explorer::{static::$creator}($prototype['path_full'])) { |
|
65 | + return false; |
|
66 | + } |
|
55 | 67 | |
56 | - foreach ($prototype as $var => $value) $this->$var = $value; |
|
68 | + foreach ($prototype as $var => $value) { |
|
69 | + $this->$var = $value; |
|
70 | + } |
|
57 | 71 | |
58 | 72 | # ------------------------ |
59 | 73 | |
@@ -64,11 +78,17 @@ discard block |
||
64 | 78 | |
65 | 79 | public function rename(string $name) { |
66 | 80 | |
67 | - if (('' === $this->name) || (false === ($prototype = $this->getPrototype($name)))) return false; |
|
81 | + if (('' === $this->name) || (false === ($prototype = $this->getPrototype($name)))) { |
|
82 | + return false; |
|
83 | + } |
|
68 | 84 | |
69 | - if (!@rename($this->path_full, $prototype['path_full'])) return false; |
|
85 | + if (!@rename($this->path_full, $prototype['path_full'])) { |
|
86 | + return false; |
|
87 | + } |
|
70 | 88 | |
71 | - foreach ($prototype as $var => $value) $this->$var = $value; |
|
89 | + foreach ($prototype as $var => $value) { |
|
90 | + $this->$var = $value; |
|
91 | + } |
|
72 | 92 | |
73 | 93 | # ------------------------ |
74 | 94 | |
@@ -79,9 +99,13 @@ discard block |
||
79 | 99 | |
80 | 100 | public function remove() { |
81 | 101 | |
82 | - if ('' === $this->name) return false; |
|
102 | + if ('' === $this->name) { |
|
103 | + return false; |
|
104 | + } |
|
83 | 105 | |
84 | - if (!Explorer::{static::$remover}($this->path_full, true)) return false; |
|
106 | + if (!Explorer::{static::$remover}($this->path_full, true)) { |
|
107 | + return false; |
|
108 | + } |
|
85 | 109 | |
86 | 110 | $this->name = ''; $this->path = ''; $this->path_full = ''; |
87 | 111 |