@@ -2,7 +2,9 @@ discard block |
||
2 | 2 | |
3 | 3 | # Check PHP version |
4 | 4 | |
5 | -if (version_compare(PHP_VERSION, '7.0.0') < 0) exit('PHP version 7 or higher is required.'); |
|
5 | +if (version_compare(PHP_VERSION, '7.0.0') < 0) { |
|
6 | + exit('PHP version 7 or higher is required.'); |
|
7 | +} |
|
6 | 8 | |
7 | 9 | # Set error reporting |
8 | 10 | |
@@ -37,9 +39,11 @@ discard block |
||
37 | 39 | |
38 | 40 | # Require class file |
39 | 41 | |
40 | - if (@file_exists($file_name = ($path . '.php')) && @is_file($file_name)) require_once $file_name; |
|
41 | - |
|
42 | - else if (@file_exists($file_name = ($path . '/' . $last . '.php')) && @is_file($file_name)) require_once $file_name; |
|
42 | + if (@file_exists($file_name = ($path . '.php')) && @is_file($file_name)) { |
|
43 | + require_once $file_name; |
|
44 | + } else if (@file_exists($file_name = ($path . '/' . $last . '.php')) && @is_file($file_name)) { |
|
45 | + require_once $file_name; |
|
46 | + } |
|
43 | 47 | |
44 | 48 | # Check if class exists |
45 | 49 | |
@@ -50,5 +54,7 @@ discard block |
||
50 | 54 | |
51 | 55 | # Call autoload method |
52 | 56 | |
53 | - if (method_exists($class_name, '__autoload')) $class_name::__autoload(); |
|
54 | -}); |
|
57 | + if (method_exists($class_name, '__autoload')) { |
|
58 | + $class_name::__autoload(); |
|
59 | + } |
|
60 | + }); |
@@ -31,30 +31,46 @@ discard block |
||
31 | 31 | |
32 | 32 | # Validate name & email |
33 | 33 | |
34 | - if (false === ($name = Validate::userName($name))) return 'USER_ERROR_NAME_INVALID'; |
|
34 | + if (false === ($name = Validate::userName($name))) { |
|
35 | + return 'USER_ERROR_NAME_INVALID'; |
|
36 | + } |
|
35 | 37 | |
36 | - if (false === ($email = Validate::userEmail($email))) return 'USER_ERROR_EMAIL_INVALID'; |
|
38 | + if (false === ($email = Validate::userEmail($email))) { |
|
39 | + return 'USER_ERROR_EMAIL_INVALID'; |
|
40 | + } |
|
37 | 41 | |
38 | 42 | # Validate password |
39 | 43 | |
40 | 44 | if ((0 === $this->user->id) || ('' !== $password)) { |
41 | 45 | |
42 | - if (false === ($password = Validate::userPassword($password))) return 'USER_ERROR_PASSWORD_INVALID'; |
|
46 | + if (false === ($password = Validate::userPassword($password))) { |
|
47 | + return 'USER_ERROR_PASSWORD_INVALID'; |
|
48 | + } |
|
43 | 49 | |
44 | - if (0 !== strcmp($password, $password_retype)) return 'USER_ERROR_PASSWORD_MISMATCH'; |
|
50 | + if (0 !== strcmp($password, $password_retype)) { |
|
51 | + return 'USER_ERROR_PASSWORD_MISMATCH'; |
|
52 | + } |
|
45 | 53 | } |
46 | 54 | |
47 | 55 | # Check name exists |
48 | 56 | |
49 | - if (false === ($check_name = $this->user->check('name', $name))) return 'USER_ERROR_MODIFY'; |
|
57 | + if (false === ($check_name = $this->user->check('name', $name))) { |
|
58 | + return 'USER_ERROR_MODIFY'; |
|
59 | + } |
|
50 | 60 | |
51 | - if ($check_name === 1) return 'USER_ERROR_NAME_DUPLICATE'; |
|
61 | + if ($check_name === 1) { |
|
62 | + return 'USER_ERROR_NAME_DUPLICATE'; |
|
63 | + } |
|
52 | 64 | |
53 | 65 | # Check email exists |
54 | 66 | |
55 | - if (false === ($check_email = $this->user->check('email', $email))) return 'USER_ERROR_MODIFY'; |
|
67 | + if (false === ($check_email = $this->user->check('email', $email))) { |
|
68 | + return 'USER_ERROR_MODIFY'; |
|
69 | + } |
|
56 | 70 | |
57 | - if ($check_email === 1) return 'USER_ERROR_EMAIL_DUPLICATE'; |
|
71 | + if ($check_email === 1) { |
|
72 | + return 'USER_ERROR_EMAIL_DUPLICATE'; |
|
73 | + } |
|
58 | 74 | |
59 | 75 | # Modify user |
60 | 76 | |
@@ -84,7 +100,9 @@ discard block |
||
84 | 100 | |
85 | 101 | $modifier = ((0 === $this->user->id) ? 'create' : 'edit'); |
86 | 102 | |
87 | - if (!$this->user->$modifier($data)) return 'USER_ERROR_MODIFY'; |
|
103 | + if (!$this->user->$modifier($data)) { |
|
104 | + return 'USER_ERROR_MODIFY'; |
|
105 | + } |
|
88 | 106 | |
89 | 107 | # ------------------------ |
90 | 108 |
@@ -29,23 +29,31 @@ |
||
29 | 29 | |
30 | 30 | # Check for demo mode |
31 | 31 | |
32 | - if (Informer::isDemoMode()) return 'DEMO_MODE_RESTRICTION'; |
|
32 | + if (Informer::isDemoMode()) { |
|
33 | + return 'DEMO_MODE_RESTRICTION'; |
|
34 | + } |
|
33 | 35 | |
34 | 36 | # Validate name |
35 | 37 | |
36 | - if (false === ($name = Validate::fileName($name))) return 'FILEMANAGER_ERROR_NAME_INVALID'; |
|
38 | + if (false === ($name = Validate::fileName($name))) { |
|
39 | + return 'FILEMANAGER_ERROR_NAME_INVALID'; |
|
40 | + } |
|
37 | 41 | |
38 | 42 | # Check if item exists |
39 | 43 | |
40 | 44 | if ((0 !== strcasecmp($this->entity->name(), $name)) && |
41 | 45 | |
42 | - @file_exists($this->entity->parent()->pathFull() . $name)) return 'FILEMANAGER_ERROR_EXISTS'; |
|
46 | + @file_exists($this->entity->parent()->pathFull() . $name)) { |
|
47 | + return 'FILEMANAGER_ERROR_EXISTS'; |
|
48 | + } |
|
43 | 49 | |
44 | 50 | # Rename item |
45 | 51 | |
46 | - if (!$this->entity->rename($name)) return (($this->entity->type() === FILEMANAGER_TYPE_DIR) ? |
|
52 | + if (!$this->entity->rename($name)) { |
|
53 | + return (($this->entity->type() === FILEMANAGER_TYPE_DIR) ? |
|
47 | 54 | |
48 | 55 | 'FILEMANAGER_ERROR_DIR_RENAME' : 'FILEMANAGER_ERROR_FILE_RENAME'); |
56 | + } |
|
49 | 57 | |
50 | 58 | # ------------------------ |
51 | 59 |
@@ -29,23 +29,31 @@ |
||
29 | 29 | |
30 | 30 | # Check for demo mode |
31 | 31 | |
32 | - if (Informer::isDemoMode()) return 'DEMO_MODE_RESTRICTION'; |
|
32 | + if (Informer::isDemoMode()) { |
|
33 | + return 'DEMO_MODE_RESTRICTION'; |
|
34 | + } |
|
33 | 35 | |
34 | 36 | # Validate name |
35 | 37 | |
36 | - if (false === ($name = Validate::fileName($name))) return 'FILEMANAGER_ERROR_NAME_INVALID'; |
|
38 | + if (false === ($name = Validate::fileName($name))) { |
|
39 | + return 'FILEMANAGER_ERROR_NAME_INVALID'; |
|
40 | + } |
|
37 | 41 | |
38 | 42 | # Check if item exists |
39 | 43 | |
40 | - if (@file_exists($this->parent->pathFull() . $name)) return 'FILEMANAGER_ERROR_EXISTS'; |
|
44 | + if (@file_exists($this->parent->pathFull() . $name)) { |
|
45 | + return 'FILEMANAGER_ERROR_EXISTS'; |
|
46 | + } |
|
41 | 47 | |
42 | 48 | # Create item |
43 | 49 | |
44 | 50 | $entity = Filemanager::get($type, $this->parent); |
45 | 51 | |
46 | - if (!$entity->create($name)) return (($entity->type() === FILEMANAGER_TYPE_DIR) ? |
|
52 | + if (!$entity->create($name)) { |
|
53 | + return (($entity->type() === FILEMANAGER_TYPE_DIR) ? |
|
47 | 54 | |
48 | 55 | 'FILEMANAGER_ERROR_DIR_CREATE' : 'FILEMANAGER_ERROR_FILE_CREATE'); |
56 | + } |
|
49 | 57 | |
50 | 58 | # ------------------------ |
51 | 59 |
@@ -20,13 +20,19 @@ discard block |
||
20 | 20 | |
21 | 21 | # Validate values |
22 | 22 | |
23 | - if (false === ($email = Validate::userEmail($email))) return 'USER_ERROR_EMAIL_INVALID'; |
|
23 | + if (false === ($email = Validate::userEmail($email))) { |
|
24 | + return 'USER_ERROR_EMAIL_INVALID'; |
|
25 | + } |
|
24 | 26 | |
25 | 27 | # Check email exists |
26 | 28 | |
27 | - if (false === ($check_email = Auth::user()->check('email', $email))) return 'USER_ERROR_EDIT_PERSONAL'; |
|
29 | + if (false === ($check_email = Auth::user()->check('email', $email))) { |
|
30 | + return 'USER_ERROR_EDIT_PERSONAL'; |
|
31 | + } |
|
28 | 32 | |
29 | - if ($check_email === 1) return 'USER_ERROR_EMAIL_DUPLICATE'; |
|
33 | + if ($check_email === 1) { |
|
34 | + return 'USER_ERROR_EMAIL_DUPLICATE'; |
|
35 | + } |
|
30 | 36 | |
31 | 37 | # Update user |
32 | 38 | |
@@ -40,7 +46,9 @@ discard block |
||
40 | 46 | $data['country'] = $country; |
41 | 47 | $data['timezone'] = $timezone; |
42 | 48 | |
43 | - if (!Auth::user()->edit($data)) return 'USER_ERROR_EDIT_PERSONAL'; |
|
49 | + if (!Auth::user()->edit($data)) { |
|
50 | + return 'USER_ERROR_EDIT_PERSONAL'; |
|
51 | + } |
|
44 | 52 | |
45 | 53 | # ------------------------ |
46 | 54 |
@@ -20,17 +20,25 @@ discard block |
||
20 | 20 | |
21 | 21 | # Validate values |
22 | 22 | |
23 | - if (false === ($password = Validate::userPassword($password))) return 'USER_ERROR_PASSWORD_INVALID'; |
|
23 | + if (false === ($password = Validate::userPassword($password))) { |
|
24 | + return 'USER_ERROR_PASSWORD_INVALID'; |
|
25 | + } |
|
24 | 26 | |
25 | - if (false === ($password_new = Validate::userPassword($password_new))) return 'USER_ERROR_PASSWORD_NEW_INVALID'; |
|
27 | + if (false === ($password_new = 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 | # Check password |
30 | 36 | |
31 | 37 | $password = Str::encode(Auth::user()->auth_key, $password); |
32 | 38 | |
33 | - if (0 !== strcmp(Auth::user()->password, $password)) return 'USER_ERROR_PASSWORD_INCORRECT'; |
|
39 | + if (0 !== strcmp(Auth::user()->password, $password)) { |
|
40 | + return 'USER_ERROR_PASSWORD_INCORRECT'; |
|
41 | + } |
|
34 | 42 | |
35 | 43 | # Encode password |
36 | 44 | |
@@ -43,7 +51,9 @@ discard block |
||
43 | 51 | $data['auth_key'] = $auth_key; |
44 | 52 | $data['password'] = $password; |
45 | 53 | |
46 | - if (!Auth::user()->edit($data)) return 'USER_ERROR_EDIT_PASSWORD'; |
|
54 | + if (!Auth::user()->edit($data)) { |
|
55 | + return 'USER_ERROR_EDIT_PASSWORD'; |
|
56 | + } |
|
47 | 57 | |
48 | 58 | # ------------------------ |
49 | 59 |
@@ -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,15 +24,25 @@ discard block |
||
22 | 24 | |
23 | 25 | # Validate values |
24 | 26 | |
25 | - if (false === ($name = Validate::userName($name))) return 'USER_ERROR_NAME_INVALID'; |
|
27 | + if (false === ($name = Validate::userName($name))) { |
|
28 | + return 'USER_ERROR_NAME_INVALID'; |
|
29 | + } |
|
26 | 30 | |
27 | - if (false === ($password = Validate::userPassword($password))) return 'USER_ERROR_PASSWORD_INVALID'; |
|
31 | + if (false === ($password = Validate::userPassword($password))) { |
|
32 | + return 'USER_ERROR_PASSWORD_INVALID'; |
|
33 | + } |
|
28 | 34 | |
29 | - if (false === ($email = Validate::userEmail($email))) return 'USER_ERROR_EMAIL_INVALID'; |
|
35 | + if (false === ($email = Validate::userEmail($email))) { |
|
36 | + return 'USER_ERROR_EMAIL_INVALID'; |
|
37 | + } |
|
30 | 38 | |
31 | - if (0 !== strcmp($password, $password_retype)) return 'USER_ERROR_PASSWORD_MISMATCH'; |
|
39 | + if (0 !== strcmp($password, $password_retype)) { |
|
40 | + return 'USER_ERROR_PASSWORD_MISMATCH'; |
|
41 | + } |
|
32 | 42 | |
33 | - if (false === Security::checkCaptcha($captcha)) return 'USER_ERROR_CAPTCHA_INCORRECT'; |
|
43 | + if (false === Security::checkCaptcha($captcha)) { |
|
44 | + return 'USER_ERROR_CAPTCHA_INCORRECT'; |
|
45 | + } |
|
34 | 46 | |
35 | 47 | # Create user object |
36 | 48 | |
@@ -38,15 +50,23 @@ discard block |
||
38 | 50 | |
39 | 51 | # Check name exists |
40 | 52 | |
41 | - if (false === ($check_name = $user->check('name', $name))) return 'USER_ERROR_AUTH_REGISTER'; |
|
53 | + if (false === ($check_name = $user->check('name', $name))) { |
|
54 | + return 'USER_ERROR_AUTH_REGISTER'; |
|
55 | + } |
|
42 | 56 | |
43 | - if ($check_name === 1) return 'USER_ERROR_NAME_DUPLICATE'; |
|
57 | + if ($check_name === 1) { |
|
58 | + return 'USER_ERROR_NAME_DUPLICATE'; |
|
59 | + } |
|
44 | 60 | |
45 | 61 | # Check email exists |
46 | 62 | |
47 | - if (false === ($check_email = $user->check('email', $email))) return 'USER_ERROR_AUTH_REGISTER'; |
|
63 | + if (false === ($check_email = $user->check('email', $email))) { |
|
64 | + return 'USER_ERROR_AUTH_REGISTER'; |
|
65 | + } |
|
48 | 66 | |
49 | - if ($check_email === 1) return 'USER_ERROR_EMAIL_DUPLICATE'; |
|
67 | + if ($check_email === 1) { |
|
68 | + return 'USER_ERROR_EMAIL_DUPLICATE'; |
|
69 | + } |
|
50 | 70 | |
51 | 71 | # Encode password |
52 | 72 | |
@@ -69,7 +89,9 @@ discard block |
||
69 | 89 | $data['time_registered'] = REQUEST_TIME; |
70 | 90 | $data['time_logged'] = REQUEST_TIME; |
71 | 91 | |
72 | - if (!$user->create($data)) return 'USER_ERROR_AUTH_REGISTER'; |
|
92 | + if (!$user->create($data)) { |
|
93 | + return 'USER_ERROR_AUTH_REGISTER'; |
|
94 | + } |
|
73 | 95 | |
74 | 96 | # Send mail |
75 | 97 |
@@ -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 = Validate::userPassword($password_new))) return 'USER_ERROR_PASSWORD_NEW_INVALID'; |
|
27 | + if (false === ($password_new = 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 = Validate::userName($name))) return 'USER_ERROR_NAME_INVALID'; |
|
27 | + if (false === ($name = 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 |