@@ -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 = Validate::userName($name))) return ['name', 'USER_ERROR_NAME_INVALID']; |
|
27 | + if (false === ($name = Validate::userName($name))) { |
|
28 | + return ['name', 'USER_ERROR_NAME_INVALID']; |
|
29 | + } |
|
26 | 30 | |
27 | - if (false === Security::checkCaptcha($captcha)) return ['captcha', 'USER_ERROR_CAPTCHA_INCORRECT']; |
|
31 | + if (false === Security::checkCaptcha($captcha)) { |
|
32 | + return ['captcha', '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 ['name', 'USER_ERROR_NAME_INCORRECT']; |
|
41 | + if (!$user->init($name, 'name')) { |
|
42 | + return ['name', 'USER_ERROR_NAME_INCORRECT']; |
|
43 | + } |
|
36 | 44 | |
37 | - if (Auth::admin() && ($user->rank < RANK_ADMINISTRATOR)) return ['name', 'USER_ERROR_NAME_INCORRECT']; |
|
45 | + if (Auth::admin() && ($user->rank < RANK_ADMINISTRATOR)) { |
|
46 | + return ['name', '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 |
@@ -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 = Validate::userName($name))) return ['name', 'USER_ERROR_NAME_INVALID']; |
|
27 | + if (false === ($name = Validate::userName($name))) { |
|
28 | + return ['name', 'USER_ERROR_NAME_INVALID']; |
|
29 | + } |
|
26 | 30 | |
27 | - if (false === ($password = Validate::userPassword($password))) return ['password', 'USER_ERROR_PASSWORD_INVALID']; |
|
31 | + if (false === ($password = Validate::userPassword($password))) { |
|
32 | + return ['password', 'USER_ERROR_PASSWORD_INVALID']; |
|
33 | + } |
|
28 | 34 | |
29 | 35 | # Create user object |
30 | 36 | |
@@ -32,19 +38,27 @@ discard block |
||
32 | 38 | |
33 | 39 | # Init user |
34 | 40 | |
35 | - if (!$user->init($name, 'name')) return ['name', 'USER_ERROR_NAME_INCORRECT']; |
|
41 | + if (!$user->init($name, 'name')) { |
|
42 | + return ['name', 'USER_ERROR_NAME_INCORRECT']; |
|
43 | + } |
|
36 | 44 | |
37 | - if (Auth::admin() && ($user->rank < RANK_ADMINISTRATOR)) return ['name', 'USER_ERROR_NAME_INCORRECT']; |
|
45 | + if (Auth::admin() && ($user->rank < RANK_ADMINISTRATOR)) { |
|
46 | + return ['name', 'USER_ERROR_NAME_INCORRECT']; |
|
47 | + } |
|
38 | 48 | |
39 | 49 | # Check password |
40 | 50 | |
41 | 51 | $password = Str::encode($user->auth_key, $password); |
42 | 52 | |
43 | - if (0 !== strcmp($user->password, $password)) return ['password', 'USER_ERROR_PASSWORD_INCORRECT']; |
|
53 | + if (0 !== strcmp($user->password, $password)) { |
|
54 | + return ['password', 'USER_ERROR_PASSWORD_INCORRECT']; |
|
55 | + } |
|
44 | 56 | |
45 | 57 | # Check access |
46 | 58 | |
47 | - if (!Auth::admin() && ($user->rank === RANK_GUEST)) return 'USER_ERROR_ACCESS'; |
|
59 | + if (!Auth::admin() && ($user->rank === RANK_GUEST)) { |
|
60 | + return 'USER_ERROR_ACCESS'; |
|
61 | + } |
|
48 | 62 | |
49 | 63 | # Create session |
50 | 64 | |
@@ -54,7 +68,9 @@ discard block |
||
54 | 68 | |
55 | 69 | $data = ['id' => $user->id, 'code' => $code, 'ip' => $ip, 'time' => $time]; |
56 | 70 | |
57 | - if (!$session->create($data)) return 'USER_ERROR_AUTH_LOGIN'; |
|
71 | + if (!$session->create($data)) { |
|
72 | + return 'USER_ERROR_AUTH_LOGIN'; |
|
73 | + } |
|
58 | 74 | |
59 | 75 | # Set session variable |
60 | 76 |
@@ -39,7 +39,7 @@ |
||
39 | 39 | |
40 | 40 | if ((0 !== strcasecmp($this->entity->name(), $name)) && |
41 | 41 | |
42 | - @file_exists($this->entity->parent()->pathFull() . $name)) return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
|
42 | + @file_exists($this->entity->parent()->pathFull().$name)) return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
|
43 | 43 | |
44 | 44 | # Rename item |
45 | 45 |
@@ -29,19 +29,25 @@ |
||
29 | 29 | |
30 | 30 | # Validate name |
31 | 31 | |
32 | - if (false === ($name = Validate::fileName($name))) return ['name', 'FILEMANAGER_ERROR_NAME_INVALID']; |
|
32 | + if (false === ($name = Validate::fileName($name))) { |
|
33 | + return ['name', 'FILEMANAGER_ERROR_NAME_INVALID']; |
|
34 | + } |
|
33 | 35 | |
34 | 36 | # Check if item exists |
35 | 37 | |
36 | 38 | if ((0 !== strcasecmp($this->entity->name(), $name)) && |
37 | 39 | |
38 | - @file_exists($this->entity->parent()->pathFull() . $name)) return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
|
40 | + @file_exists($this->entity->parent()->pathFull() . $name)) { |
|
41 | + return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
|
42 | + } |
|
39 | 43 | |
40 | 44 | # Rename item |
41 | 45 | |
42 | - if (!$this->entity->rename($name)) return (($this->entity->type() === FILEMANAGER_TYPE_DIR) ? |
|
46 | + if (!$this->entity->rename($name)) { |
|
47 | + return (($this->entity->type() === FILEMANAGER_TYPE_DIR) ? |
|
43 | 48 | |
44 | 49 | 'FILEMANAGER_ERROR_DIR_RENAME' : 'FILEMANAGER_ERROR_FILE_RENAME'); |
50 | + } |
|
45 | 51 | |
46 | 52 | # ------------------------ |
47 | 53 |
@@ -37,7 +37,7 @@ |
||
37 | 37 | |
38 | 38 | # Check if item exists |
39 | 39 | |
40 | - if (@file_exists($this->parent->pathFull() . $name)) return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
|
40 | + if (@file_exists($this->parent->pathFull().$name)) return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
|
41 | 41 | |
42 | 42 | # Create item |
43 | 43 |
@@ -29,19 +29,25 @@ |
||
29 | 29 | |
30 | 30 | # Validate name |
31 | 31 | |
32 | - if (false === ($name = Validate::fileName($name))) return ['name', 'FILEMANAGER_ERROR_NAME_INVALID']; |
|
32 | + if (false === ($name = Validate::fileName($name))) { |
|
33 | + return ['name', 'FILEMANAGER_ERROR_NAME_INVALID']; |
|
34 | + } |
|
33 | 35 | |
34 | 36 | # Check if item exists |
35 | 37 | |
36 | - if (@file_exists($this->parent->pathFull() . $name)) return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
|
38 | + if (@file_exists($this->parent->pathFull() . $name)) { |
|
39 | + return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
|
40 | + } |
|
37 | 41 | |
38 | 42 | # Create item |
39 | 43 | |
40 | 44 | $entity = Filemanager::get($type, $this->parent); |
41 | 45 | |
42 | - if (!$entity->create($name)) return (($entity->type() === FILEMANAGER_TYPE_DIR) ? |
|
46 | + if (!$entity->create($name)) { |
|
47 | + return (($entity->type() === FILEMANAGER_TYPE_DIR) ? |
|
43 | 48 | |
44 | 49 | 'FILEMANAGER_ERROR_DIR_CREATE' : 'FILEMANAGER_ERROR_FILE_CREATE'); |
50 | + } |
|
45 | 51 | |
46 | 52 | # ------------------------ |
47 | 53 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | $dirs = []; $files = []; |
17 | 17 | |
18 | - $prefix = (('' !== $this->parent->path()) ? ($this->parent->path() . '/') : ''); |
|
18 | + $prefix = (('' !== $this->parent->path()) ? ($this->parent->path().'/') : ''); |
|
19 | 19 | |
20 | 20 | # Read parent directory contents |
21 | 21 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | if (in_array($name, ['.', '..', '.empty'], true)) continue; |
27 | 27 | |
28 | - $path = ($prefix . $name); $path_full = ($this->parent->pathFull() . $name); |
|
28 | + $path = ($prefix.$name); $path_full = ($this->parent->pathFull().$name); |
|
29 | 29 | |
30 | 30 | $data = ['name' => $name, 'path' => $path, 'path_full' => $path_full]; |
31 | 31 | |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | |
113 | 113 | private function getPaginationBlock() { |
114 | 114 | |
115 | - $query = (('' !== $this->parent->path()) ? ('?parent=' . $this->parent->path()) : ''); |
|
115 | + $query = (('' !== $this->parent->path()) ? ('?parent='.$this->parent->path()) : ''); |
|
116 | 116 | |
117 | - $url = new Url(INSTALL_PATH . '/admin/content/filemanager' . $query); |
|
117 | + $url = new Url(INSTALL_PATH.'/admin/content/filemanager'.$query); |
|
118 | 118 | |
119 | 119 | # ------------------------ |
120 | 120 | |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | |
138 | 138 | # Set link |
139 | 139 | |
140 | - $query = (('' !== $this->parent->path()) ? ('?parent=' . $this->parent->path()) : ''); |
|
140 | + $query = (('' !== $this->parent->path()) ? ('?parent='.$this->parent->path()) : ''); |
|
141 | 141 | |
142 | - $contents->link = (INSTALL_PATH . '/admin/content/filemanager' . $query); |
|
142 | + $contents->link = (INSTALL_PATH.'/admin/content/filemanager'.$query); |
|
143 | 143 | |
144 | 144 | # Implement form |
145 | 145 | |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | |
181 | 181 | if ($upload || $this->form->handle(new Filemanager\Controller\Create($this->parent))) { |
182 | 182 | |
183 | - $query = (('' !== $this->parent->path()) ? ('?parent=' . $this->parent->path()) : ''); |
|
183 | + $query = (('' !== $this->parent->path()) ? ('?parent='.$this->parent->path()) : ''); |
|
184 | 184 | |
185 | - Request::redirect(INSTALL_PATH . '/admin/content/filemanager' . $query); |
|
185 | + Request::redirect(INSTALL_PATH.'/admin/content/filemanager'.$query); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | # Get index |
@@ -25,15 +25,19 @@ discard block |
||
25 | 25 | |
26 | 26 | while (false !== ($name = readdir($handler))) { |
27 | 27 | |
28 | - if (in_array($name, ['.', '..', '.empty'], true)) continue; |
|
28 | + if (in_array($name, ['.', '..', '.empty'], true)) { |
|
29 | + continue; |
|
30 | + } |
|
29 | 31 | |
30 | 32 | $path = ($prefix . $name); $path_full = ($this->parent->pathFull() . $name); |
31 | 33 | |
32 | 34 | $data = ['name' => $name, 'path' => $path, 'path_full' => $path_full]; |
33 | 35 | |
34 | - if (@is_dir($path_full)) $dirs[] = array_merge($data, ['type' => FILEMANAGER_TYPE_DIR]); |
|
35 | - |
|
36 | - else if (@is_file($path_full)) $files[] = array_merge($data, ['type' => FILEMANAGER_TYPE_FILE]); |
|
36 | + if (@is_dir($path_full)) { |
|
37 | + $dirs[] = array_merge($data, ['type' => FILEMANAGER_TYPE_DIR]); |
|
38 | + } else if (@is_file($path_full)) { |
|
39 | + $files[] = array_merge($data, ['type' => FILEMANAGER_TYPE_FILE]); |
|
40 | + } |
|
37 | 41 | } |
38 | 42 | |
39 | 43 | closedir($handler); |
@@ -135,9 +139,11 @@ discard block |
||
135 | 139 | |
136 | 140 | foreach ($this->items['list'] as $item) { |
137 | 141 | |
138 | - if ($item['type'] === FILEMANAGER_TYPE_DIR) $items->addItem($this->getDirItemBlock($item)); |
|
139 | - |
|
140 | - else if ($item['type'] === FILEMANAGER_TYPE_FILE) $items->addItem($this->getFileItemBlock($item)); |
|
142 | + if ($item['type'] === FILEMANAGER_TYPE_DIR) { |
|
143 | + $items->addItem($this->getDirItemBlock($item)); |
|
144 | + } else if ($item['type'] === FILEMANAGER_TYPE_FILE) { |
|
145 | + $items->addItem($this->getFileItemBlock($item)); |
|
146 | + } |
|
141 | 147 | } |
142 | 148 | |
143 | 149 | # Set pagination |
@@ -19,11 +19,15 @@ |
||
19 | 19 | |
20 | 20 | private function add(string $type, string $name, array $args) { |
21 | 21 | |
22 | - if (('' === $name) || isset($this->list[$name])) return; |
|
22 | + if (('' === $name) || isset($this->list[$name])) { |
|
23 | + return; |
|
24 | + } |
|
23 | 25 | |
24 | 26 | $this->list[$name] = new $this->types[$type](...$args); |
25 | 27 | |
26 | - if (($type !== 'textual') || $this->list[$name]->short) $this->secure[] = $name; |
|
28 | + if (($type !== 'textual') || $this->list[$name]->short) { |
|
29 | + $this->secure[] = $name; |
|
30 | + } |
|
27 | 31 | } |
28 | 32 | |
29 | 33 | # Constructor |
@@ -32,11 +32,11 @@ |
||
32 | 32 | |
33 | 33 | public function statement() { |
34 | 34 | |
35 | - return ("FOREIGN KEY (`" . $this->name . "`) REFERENCES `" . $this->table . "` (`" . $this->field . "`)") . |
|
35 | + return ("FOREIGN KEY (`".$this->name."`) REFERENCES `".$this->table."` (`".$this->field."`)"). |
|
36 | 36 | |
37 | - ((null !== $this->delete) ? (" ON DELETE " . $this->delete) : "") . |
|
37 | + ((null !== $this->delete) ? (" ON DELETE ".$this->delete) : ""). |
|
38 | 38 | |
39 | - ((null !== $this->update) ? (" ON UPDATE " . $this->update) : ""); |
|
39 | + ((null !== $this->update) ? (" ON UPDATE ".$this->update) : ""); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | } |
@@ -23,9 +23,13 @@ |
||
23 | 23 | |
24 | 24 | $this->name = $name; $this->table = $table; $this->field = $field; |
25 | 25 | |
26 | - if (null !== $delete) $this->delete = $this->getAction($delete); |
|
26 | + if (null !== $delete) { |
|
27 | + $this->delete = $this->getAction($delete); |
|
28 | + } |
|
27 | 29 | |
28 | - if (null !== $update) $this->update = $this->getAction($delete); |
|
30 | + if (null !== $update) { |
|
31 | + $this->update = $this->getAction($delete); |
|
32 | + } |
|
29 | 33 | } |
30 | 34 | |
31 | 35 | # Get statement |
@@ -32,7 +32,7 @@ |
||
32 | 32 | |
33 | 33 | return ((null !== $this->type) ? ($this->type . " ") : "") . |
34 | 34 | |
35 | - ("KEY `" . $this->name . "` (`" . $this->name . "`)"); |
|
35 | + ("KEY `" . $this->name . "` (`" . $this->name . "`)"); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | } |
@@ -30,9 +30,9 @@ |
||
30 | 30 | |
31 | 31 | public function statement() { |
32 | 32 | |
33 | - return ((null !== $this->type) ? ($this->type . " ") : "") . |
|
33 | + return ((null !== $this->type) ? ($this->type." ") : ""). |
|
34 | 34 | |
35 | - ("KEY `" . $this->name . "` (`" . $this->name . "`)"); |
|
35 | + ("KEY `".$this->name."` (`".$this->name."`)"); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | } |
@@ -23,7 +23,9 @@ |
||
23 | 23 | |
24 | 24 | $this->name = $name; |
25 | 25 | |
26 | - if (null !== $type) $this->type = $this->getType($type); |
|
26 | + if (null !== $type) { |
|
27 | + $this->type = $this->getType($type); |
|
28 | + } |
|
27 | 29 | } |
28 | 30 | |
29 | 31 | # Get statement |
@@ -19,7 +19,7 @@ |
||
19 | 19 | |
20 | 20 | public function statement() { |
21 | 21 | |
22 | - return ("`" . $this->name . "` int(10) UNSIGNED NOT NULL" . ($this->auto_increment ? " AUTO_INCREMENT" : "")); |
|
22 | + return ("`".$this->name."` int(10) UNSIGNED NOT NULL".($this->auto_increment ? " AUTO_INCREMENT" : "")); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | # Cast value |