@@ -56,7 +56,7 @@ |
||
| 56 | 56 | |
| 57 | 57 | if ((!$this->user->init($$init_by, $init_by)) || (Auth::isAdmin() && ($this->user->rank < RANK_ADMINISTRATOR))) { |
| 58 | 58 | |
| 59 | - return ['name_email', ('USER_ERROR_' . strtoupper($init_by) .'_INCORRECT')]; |
|
| 59 | + return ['name_email', ('USER_ERROR_'.strtoupper($init_by).'_INCORRECT')]; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | # Check password |
@@ -46,9 +46,13 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | if ((false === ($name = Validate::userName($name_email))) && |
| 48 | 48 | |
| 49 | - (false === ($email = Validate::userEmail($name_email)))) return ['name_email', 'USER_ERROR_NAME_INVALID']; |
|
| 49 | + (false === ($email = Validate::userEmail($name_email)))) { |
|
| 50 | + return ['name_email', 'USER_ERROR_NAME_INVALID']; |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | - if (false === ($password = Validate::userPassword($password))) return ['password', 'USER_ERROR_PASSWORD_INVALID']; |
|
| 53 | + if (false === ($password = Validate::userPassword($password))) { |
|
| 54 | + return ['password', 'USER_ERROR_PASSWORD_INVALID']; |
|
| 55 | + } |
|
| 52 | 56 | |
| 53 | 57 | # Init user |
| 54 | 58 | |
@@ -63,11 +67,15 @@ discard block |
||
| 63 | 67 | |
| 64 | 68 | $password = Str::encode($this->user->auth_key, $password); |
| 65 | 69 | |
| 66 | - if (0 !== strcmp($this->user->password, $password)) return ['password', 'USER_ERROR_PASSWORD_INCORRECT']; |
|
| 70 | + if (0 !== strcmp($this->user->password, $password)) { |
|
| 71 | + return ['password', 'USER_ERROR_PASSWORD_INCORRECT']; |
|
| 72 | + } |
|
| 67 | 73 | |
| 68 | 74 | # Check access |
| 69 | 75 | |
| 70 | - if (!Auth::isAdmin() && ($this->user->rank === RANK_GUEST)) return 'USER_ERROR_ACCESS'; |
|
| 76 | + if (!Auth::isAdmin() && ($this->user->rank === RANK_GUEST)) { |
|
| 77 | + return 'USER_ERROR_ACCESS'; |
|
| 78 | + } |
|
| 71 | 79 | |
| 72 | 80 | # Create session |
| 73 | 81 | |
@@ -77,7 +85,9 @@ discard block |
||
| 77 | 85 | |
| 78 | 86 | $data = ['id' => $this->user->id, 'code' => $code, 'ip' => $ip, 'time' => $time]; |
| 79 | 87 | |
| 80 | - if (!$session->create($data)) return 'USER_ERROR_AUTH_LOGIN'; |
|
| 88 | + if (!$session->create($data)) { |
|
| 89 | + return 'USER_ERROR_AUTH_LOGIN'; |
|
| 90 | + } |
|
| 81 | 91 | |
| 82 | 92 | # Set session variable |
| 83 | 93 | |
@@ -44,27 +44,45 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | # Validate values |
| 46 | 46 | |
| 47 | - if (false === ($name = Validate::userName($name))) return ['name', 'USER_ERROR_NAME_INVALID']; |
|
| 47 | + if (false === ($name = Validate::userName($name))) { |
|
| 48 | + return ['name', 'USER_ERROR_NAME_INVALID']; |
|
| 49 | + } |
|
| 48 | 50 | |
| 49 | - if (false === ($password = Validate::userPassword($password))) return ['password', 'USER_ERROR_PASSWORD_INVALID']; |
|
| 51 | + if (false === ($password = Validate::userPassword($password))) { |
|
| 52 | + return ['password', 'USER_ERROR_PASSWORD_INVALID']; |
|
| 53 | + } |
|
| 50 | 54 | |
| 51 | - if (false === ($email = Validate::userEmail($email))) return ['email', 'USER_ERROR_EMAIL_INVALID']; |
|
| 55 | + if (false === ($email = Validate::userEmail($email))) { |
|
| 56 | + return ['email', 'USER_ERROR_EMAIL_INVALID']; |
|
| 57 | + } |
|
| 52 | 58 | |
| 53 | - if (0 !== strcmp($password, $password_retype)) return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH']; |
|
| 59 | + if (0 !== strcmp($password, $password_retype)) { |
|
| 60 | + return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH']; |
|
| 61 | + } |
|
| 54 | 62 | |
| 55 | - if (false === Security::checkCaptcha($captcha)) return ['captcha', 'USER_ERROR_CAPTCHA_INCORRECT']; |
|
| 63 | + if (false === Security::checkCaptcha($captcha)) { |
|
| 64 | + return ['captcha', 'USER_ERROR_CAPTCHA_INCORRECT']; |
|
| 65 | + } |
|
| 56 | 66 | |
| 57 | 67 | # Check name exists |
| 58 | 68 | |
| 59 | - if (false === ($check_name = $this->user->check($name, 'name'))) return 'USER_ERROR_AUTH_REGISTER'; |
|
| 69 | + if (false === ($check_name = $this->user->check($name, 'name'))) { |
|
| 70 | + return 'USER_ERROR_AUTH_REGISTER'; |
|
| 71 | + } |
|
| 60 | 72 | |
| 61 | - if ($check_name === 1) return ['name', 'USER_ERROR_NAME_DUPLICATE']; |
|
| 73 | + if ($check_name === 1) { |
|
| 74 | + return ['name', 'USER_ERROR_NAME_DUPLICATE']; |
|
| 75 | + } |
|
| 62 | 76 | |
| 63 | 77 | # Check email exists |
| 64 | 78 | |
| 65 | - if (false === ($check_email = $this->user->check($email, 'email'))) return 'USER_ERROR_AUTH_REGISTER'; |
|
| 79 | + if (false === ($check_email = $this->user->check($email, 'email'))) { |
|
| 80 | + return 'USER_ERROR_AUTH_REGISTER'; |
|
| 81 | + } |
|
| 66 | 82 | |
| 67 | - if ($check_email === 1) return ['email', 'USER_ERROR_EMAIL_DUPLICATE']; |
|
| 83 | + if ($check_email === 1) { |
|
| 84 | + return ['email', 'USER_ERROR_EMAIL_DUPLICATE']; |
|
| 85 | + } |
|
| 68 | 86 | |
| 69 | 87 | # Encode password |
| 70 | 88 | |
@@ -87,7 +105,9 @@ discard block |
||
| 87 | 105 | $data['time_registered'] = REQUEST_TIME; |
| 88 | 106 | $data['time_logged'] = REQUEST_TIME; |
| 89 | 107 | |
| 90 | - if (!$this->user->create($data)) return 'USER_ERROR_AUTH_REGISTER'; |
|
| 108 | + if (!$this->user->create($data)) { |
|
| 109 | + return 'USER_ERROR_AUTH_REGISTER'; |
|
| 110 | + } |
|
| 91 | 111 | |
| 92 | 112 | # Send mail |
| 93 | 113 | |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | protected function init() { |
| 14 | 14 | |
| 15 | - $this->config->addParam('active', '', function (bool $active) { |
|
| 15 | + $this->config->addParam('active', '', function(bool $active) { |
|
| 16 | 16 | |
| 17 | 17 | return ($active ? "ent.active = 1" : ''); |
| 18 | 18 | }); |
@@ -38,7 +38,9 @@ |
||
| 38 | 38 | |
| 39 | 39 | # Set remove button |
| 40 | 40 | |
| 41 | - if ($user->id === Auth::get('id')) $view->getBlock('remove')->class = 'disabled'; |
|
| 41 | + if ($user->id === Auth::get('id')) { |
|
| 42 | + $view->getBlock('remove')->class = 'disabled'; |
|
| 43 | + } |
|
| 42 | 44 | } |
| 43 | 45 | } |
| 44 | 46 | } |
@@ -14,19 +14,19 @@ |
||
| 14 | 14 | |
| 15 | 15 | # Add params |
| 16 | 16 | |
| 17 | - $this->params->textual ('code', true, 40, true, ''); |
|
| 18 | - $this->params->textual ('ip', true, 255, false, ''); |
|
| 19 | - $this->params->integer ('time', false, 10, true, 0); |
|
| 17 | + $this->params->textual('code', true, 40, true, ''); |
|
| 18 | + $this->params->textual('ip', true, 255, false, ''); |
|
| 19 | + $this->params->integer('time', false, 10, true, 0); |
|
| 20 | 20 | |
| 21 | 21 | # Add indexes |
| 22 | 22 | |
| 23 | - $this->indexes->add ('code', 'UNIQUE'); |
|
| 24 | - $this->indexes->add ('ip'); |
|
| 25 | - $this->indexes->add ('time'); |
|
| 23 | + $this->indexes->add('code', 'UNIQUE'); |
|
| 24 | + $this->indexes->add('ip'); |
|
| 25 | + $this->indexes->add('time'); |
|
| 26 | 26 | |
| 27 | 27 | # Add foreign keys |
| 28 | 28 | |
| 29 | - $this->foreigns->add ('id', TABLE_USERS, 'id', 'CASCADE', 'RESTRICT'); |
|
| 29 | + $this->foreigns->add('id', TABLE_USERS, 'id', 'CASCADE', 'RESTRICT'); |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | } |
@@ -12,19 +12,33 @@ |
||
| 12 | 12 | |
| 13 | 13 | $extension = strtolower(Explorer::getExtension($file_name, false)); |
| 14 | 14 | |
| 15 | - if (self::isImage($extension)) return 'image'; |
|
| 15 | + if (self::isImage($extension)) { |
|
| 16 | + return 'image'; |
|
| 17 | + } |
|
| 16 | 18 | |
| 17 | - if (self::isAudio($extension)) return 'audio'; |
|
| 19 | + if (self::isAudio($extension)) { |
|
| 20 | + return 'audio'; |
|
| 21 | + } |
|
| 18 | 22 | |
| 19 | - if (self::isVideo($extension)) return 'video'; |
|
| 23 | + if (self::isVideo($extension)) { |
|
| 24 | + return 'video'; |
|
| 25 | + } |
|
| 20 | 26 | |
| 21 | - if (in_array($extension, ['doc', 'docx'], true)) return 'word'; |
|
| 27 | + if (in_array($extension, ['doc', 'docx'], true)) { |
|
| 28 | + return 'word'; |
|
| 29 | + } |
|
| 22 | 30 | |
| 23 | - if (in_array($extension, ['xls', 'xlsx'], true)) return 'excel'; |
|
| 31 | + if (in_array($extension, ['xls', 'xlsx'], true)) { |
|
| 32 | + return 'excel'; |
|
| 33 | + } |
|
| 24 | 34 | |
| 25 | - if (in_array($extension, ['ppt', 'pptx'], true)) return 'powerpoint'; |
|
| 35 | + if (in_array($extension, ['ppt', 'pptx'], true)) { |
|
| 36 | + return 'powerpoint'; |
|
| 37 | + } |
|
| 26 | 38 | |
| 27 | - if ($extension === 'pdf') return 'pdf'; |
|
| 39 | + if ($extension === 'pdf') { |
|
| 40 | + return 'pdf'; |
|
| 41 | + } |
|
| 28 | 42 | |
| 29 | 43 | # ------------------------ |
| 30 | 44 | |
@@ -41,14 +41,18 @@ |
||
| 41 | 41 | |
| 42 | 42 | foreach (['full_name', 'city'] as $name) { |
| 43 | 43 | |
| 44 | - if ('' === ($text = Auth::get($name))) $contents->getBlock($name)->disable(); |
|
| 45 | - |
|
| 46 | - else $contents->getBlock($name)->text = $text; |
|
| 44 | + if ('' === ($text = Auth::get($name))) { |
|
| 45 | + $contents->getBlock($name)->disable(); |
|
| 46 | + } else { |
|
| 47 | + $contents->getBlock($name)->text = $text; |
|
| 48 | + } |
|
| 47 | 49 | } |
| 48 | 50 | |
| 49 | 51 | # Set country |
| 50 | 52 | |
| 51 | - if ('' === ($country = Auth::get('country'))) $contents->getBlock('country')->disable(); else { |
|
| 53 | + if ('' === ($country = Auth::get('country'))) { |
|
| 54 | + $contents->getBlock('country')->disable(); |
|
| 55 | + } else { |
|
| 52 | 56 | |
| 53 | 57 | $contents->getBlock('country')->code = $country; |
| 54 | 58 | |
@@ -33,13 +33,19 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | # Validate values |
| 35 | 35 | |
| 36 | - if (false === ($email = Validate::userEmail($email))) return ['email', 'USER_ERROR_EMAIL_INVALID']; |
|
| 36 | + if (false === ($email = Validate::userEmail($email))) { |
|
| 37 | + return ['email', 'USER_ERROR_EMAIL_INVALID']; |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | # Check email exists |
| 39 | 41 | |
| 40 | - if (false === ($check_email = Auth::getUser()->check($email, 'email'))) return 'USER_ERROR_EDIT_PERSONAL'; |
|
| 42 | + if (false === ($check_email = Auth::getUser()->check($email, 'email'))) { |
|
| 43 | + return 'USER_ERROR_EDIT_PERSONAL'; |
|
| 44 | + } |
|
| 41 | 45 | |
| 42 | - if ($check_email === 1) return ['email', 'USER_ERROR_EMAIL_DUPLICATE']; |
|
| 46 | + if ($check_email === 1) { |
|
| 47 | + return ['email', 'USER_ERROR_EMAIL_DUPLICATE']; |
|
| 48 | + } |
|
| 43 | 49 | |
| 44 | 50 | # Update user |
| 45 | 51 | |
@@ -53,7 +59,9 @@ discard block |
||
| 53 | 59 | $data['country'] = $country; |
| 54 | 60 | $data['timezone'] = $timezone; |
| 55 | 61 | |
| 56 | - if (!Auth::getUser()->edit($data)) return 'USER_ERROR_EDIT_PERSONAL'; |
|
| 62 | + if (!Auth::getUser()->edit($data)) { |
|
| 63 | + return 'USER_ERROR_EDIT_PERSONAL'; |
|
| 64 | + } |
|
| 57 | 65 | |
| 58 | 66 | # ------------------------ |
| 59 | 67 | |
@@ -33,23 +33,28 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | # Validate values |
| 35 | 35 | |
| 36 | - if (false === ($password = Validate::userPassword($password))) |
|
| 37 | - |
|
| 36 | + if (false === ($password = Validate::userPassword($password))) { |
|
| 37 | + |
|
| 38 | 38 | return ['password', 'USER_ERROR_PASSWORD_INVALID']; |
| 39 | + } |
|
| 39 | 40 | |
| 40 | - if (false === ($password_new = Validate::userPassword($password_new))) |
|
| 41 | - |
|
| 41 | + if (false === ($password_new = Validate::userPassword($password_new))) { |
|
| 42 | + |
|
| 42 | 43 | return ['password_new', 'USER_ERROR_PASSWORD_NEW_INVALID']; |
| 44 | + } |
|
| 43 | 45 | |
| 44 | - if (0 !== strcmp($password_new, $password_retype)) |
|
| 45 | - |
|
| 46 | + if (0 !== strcmp($password_new, $password_retype)) { |
|
| 47 | + |
|
| 46 | 48 | return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH']; |
| 49 | + } |
|
| 47 | 50 | |
| 48 | 51 | # Check password |
| 49 | 52 | |
| 50 | 53 | $password = Str::encode(Auth::get('auth_key'), $password); |
| 51 | 54 | |
| 52 | - if (0 !== strcmp(Auth::get('password'), $password)) return ['password', 'USER_ERROR_PASSWORD_INCORRECT']; |
|
| 55 | + if (0 !== strcmp(Auth::get('password'), $password)) { |
|
| 56 | + return ['password', 'USER_ERROR_PASSWORD_INCORRECT']; |
|
| 57 | + } |
|
| 53 | 58 | |
| 54 | 59 | # Encode password |
| 55 | 60 | |
@@ -62,7 +67,9 @@ discard block |
||
| 62 | 67 | $data['auth_key'] = $auth_key; |
| 63 | 68 | $data['password'] = $password; |
| 64 | 69 | |
| 65 | - if (!Auth::getUser()->edit($data)) return 'USER_ERROR_EDIT_PASSWORD'; |
|
| 70 | + if (!Auth::getUser()->edit($data)) { |
|
| 71 | + return 'USER_ERROR_EDIT_PASSWORD'; |
|
| 72 | + } |
|
| 66 | 73 | |
| 67 | 74 | # ------------------------ |
| 68 | 75 | |