@@ -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 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | # Check auth |
35 | 35 | |
36 | - if (($this instanceof Area\Auth) && Auth::isLogged()) Request::redirect(INSTALL_PATH . '/admin'); |
|
36 | + if (($this instanceof Area\Auth) && Auth::isLogged()) Request::redirect(INSTALL_PATH.'/admin'); |
|
37 | 37 | |
38 | 38 | # Handle request |
39 | 39 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | if (!Auth::isLogged() || ((false !== Request::get('logout')) && Auth::logout())) { |
56 | 56 | |
57 | - Request::redirect(INSTALL_PATH . '/admin/login'); |
|
57 | + Request::redirect(INSTALL_PATH.'/admin/login'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | # Handle request |
@@ -33,11 +33,15 @@ discard block |
||
33 | 33 | |
34 | 34 | # Check auth |
35 | 35 | |
36 | - if (($this instanceof Area\Auth) && Auth::isLogged()) Request::redirect(INSTALL_PATH . '/admin'); |
|
36 | + if (($this instanceof Area\Auth) && Auth::isLogged()) { |
|
37 | + Request::redirect(INSTALL_PATH . '/admin'); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | # Handle request |
39 | 41 | |
40 | - if (Template::isBlock($result = $this->handle())) return (new View\Form($this->_title))->display($result); |
|
42 | + if (Template::isBlock($result = $this->handle())) { |
|
43 | + return (new View\Form($this->_title))->display($result); |
|
44 | + } |
|
41 | 45 | |
42 | 46 | # ------------------------ |
43 | 47 | |
@@ -63,9 +67,13 @@ discard block |
||
63 | 67 | |
64 | 68 | $result = $this->handle(Request::isAjax() && ($request === 'display')); |
65 | 69 | |
66 | - if (Template::isBlock($result)) return (new View\Panel($this->_title))->$request($result); |
|
70 | + if (Template::isBlock($result)) { |
|
71 | + return (new View\Panel($this->_title))->$request($result); |
|
72 | + } |
|
67 | 73 | |
68 | - if (Ajax::isResponse($result)) return Ajax::output($result); |
|
74 | + if (Ajax::isResponse($result)) { |
|
75 | + return Ajax::output($result); |
|
76 | + } |
|
69 | 77 | |
70 | 78 | # ------------------------ |
71 | 79 | |
@@ -84,14 +92,20 @@ discard block |
||
84 | 92 | |
85 | 93 | $ips = preg_split('/ +/', CONFIG_ADMIN_IP, -1, PREG_SPLIT_NO_EMPTY); |
86 | 94 | |
87 | - if (!in_array(REQUEST_CLIENT_IP, $ips, true)) return Status::displayError404(); |
|
95 | + if (!in_array(REQUEST_CLIENT_IP, $ips, true)) { |
|
96 | + return Status::displayError404(); |
|
97 | + } |
|
88 | 98 | } |
89 | 99 | |
90 | 100 | # Handle request |
91 | 101 | |
92 | - if (($this instanceof Area\Auth) || ($this instanceof Area\Install)) return $this->handleFormArea(); |
|
102 | + if (($this instanceof Area\Auth) || ($this instanceof Area\Install)) { |
|
103 | + return $this->handleFormArea(); |
|
104 | + } |
|
93 | 105 | |
94 | - if ($this instanceof Area\Panel) return $this->handlePanelArea(); |
|
106 | + if ($this instanceof Area\Panel) { |
|
107 | + return $this->handlePanelArea(); |
|
108 | + } |
|
95 | 109 | |
96 | 110 | # ------------------------ |
97 | 111 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | # Check auth |
35 | 35 | |
36 | - if (Auth::isLogged()) Request::redirect(INSTALL_PATH . '/profile'); |
|
36 | + if (Auth::isLogged()) Request::redirect(INSTALL_PATH.'/profile'); |
|
37 | 37 | |
38 | 38 | # ------------------------ |
39 | 39 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | if (!Auth::isLogged() || ((false !== Request::get('logout')) && Auth::logout())) { |
52 | 52 | |
53 | - Request::redirect(INSTALL_PATH . '/profile/login'); |
|
53 | + Request::redirect(INSTALL_PATH.'/profile/login'); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | # ------------------------ |
@@ -33,7 +33,9 @@ discard block |
||
33 | 33 | |
34 | 34 | # Check auth |
35 | 35 | |
36 | - if (Auth::isLogged()) Request::redirect(INSTALL_PATH . '/profile'); |
|
36 | + if (Auth::isLogged()) { |
|
37 | + Request::redirect(INSTALL_PATH . '/profile'); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | # ------------------------ |
39 | 41 | |
@@ -68,9 +70,13 @@ discard block |
||
68 | 70 | |
69 | 71 | $result = $this->handle(Request::isAjax()); |
70 | 72 | |
71 | - if (Template::isBlock($result)) return (new View($this->_title, $this->_layout))->display($result); |
|
73 | + if (Template::isBlock($result)) { |
|
74 | + return (new View($this->_title, $this->_layout))->display($result); |
|
75 | + } |
|
72 | 76 | |
73 | - if (Ajax::isResponse($result)) return Ajax::output($result); |
|
77 | + if (Ajax::isResponse($result)) { |
|
78 | + return Ajax::output($result); |
|
79 | + } |
|
74 | 80 | |
75 | 81 | # ------------------------ |
76 | 82 | |
@@ -85,17 +91,27 @@ discard block |
||
85 | 91 | |
86 | 92 | # Check site status |
87 | 93 | |
88 | - if (Settings::get('site_status') === STATUS_MAINTENANCE) return Status::displayMaintenance(); |
|
94 | + if (Settings::get('site_status') === STATUS_MAINTENANCE) { |
|
95 | + return Status::displayMaintenance(); |
|
96 | + } |
|
89 | 97 | |
90 | - if (Settings::get('site_status') === STATUS_UPDATE) return Status::displayUpdate(); |
|
98 | + if (Settings::get('site_status') === STATUS_UPDATE) { |
|
99 | + return Status::displayUpdate(); |
|
100 | + } |
|
91 | 101 | |
92 | 102 | # Handle request |
93 | 103 | |
94 | - if ($this instanceof Area\Auth) return $this->handleAuthArea(); |
|
104 | + if ($this instanceof Area\Auth) { |
|
105 | + return $this->handleAuthArea(); |
|
106 | + } |
|
95 | 107 | |
96 | - if ($this instanceof Area\Authorized) return $this->handleAuthorizedArea(); |
|
108 | + if ($this instanceof Area\Authorized) { |
|
109 | + return $this->handleAuthorizedArea(); |
|
110 | + } |
|
97 | 111 | |
98 | - if ($this instanceof Area\Common) return $this->handleCommonArea(); |
|
112 | + if ($this instanceof Area\Common) { |
|
113 | + return $this->handleCommonArea(); |
|
114 | + } |
|
99 | 115 | |
100 | 116 | # ------------------------ |
101 | 117 |
@@ -19,7 +19,9 @@ discard block |
||
19 | 19 | |
20 | 20 | public static function start(string $name, int $lifetime) : bool { |
21 | 21 | |
22 | - if (session_id()) return true; |
|
22 | + if (session_id()) { |
|
23 | + return true; |
|
24 | + } |
|
23 | 25 | |
24 | 26 | ini_set('session.gc_maxlifetime', $lifetime); |
25 | 27 | |
@@ -47,7 +49,9 @@ discard block |
||
47 | 49 | |
48 | 50 | public static function set(string $name, $value) { |
49 | 51 | |
50 | - if (session_id()) $_SESSION[$name] = $value; |
|
52 | + if (session_id()) { |
|
53 | + $_SESSION[$name] = $value; |
|
54 | + } |
|
51 | 55 | } |
52 | 56 | |
53 | 57 | /** |
@@ -76,7 +80,9 @@ discard block |
||
76 | 80 | |
77 | 81 | public static function delete(string $name) { |
78 | 82 | |
79 | - if (isset($_SESSION[$name])) unset($_SESSION[$name]); |
|
83 | + if (isset($_SESSION[$name])) { |
|
84 | + unset($_SESSION[$name]); |
|
85 | + } |
|
80 | 86 | } |
81 | 87 | } |
82 | 88 | } |
@@ -73,25 +73,25 @@ discard block |
||
73 | 73 | |
74 | 74 | $pattern = [ |
75 | 75 | |
76 | - 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', |
|
77 | - 'Д' => 'D', 'Е' => 'E', 'Ж' => 'ZH', 'З' => 'Z', |
|
78 | - 'И' => 'I', 'Й' => 'J', 'К' => 'K', 'Л' => 'L', |
|
79 | - 'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', |
|
80 | - 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', |
|
81 | - 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', 'Ч' => 'CH', |
|
82 | - 'Ш' => 'SH', 'Щ' => 'SCH', 'Ъ' => '', 'Ь' => '', |
|
83 | - 'Ы' => 'Y', 'Э' => 'E', 'Ю' => 'JU', 'Я' => 'JA', |
|
84 | - 'І' => 'I', 'Ї' => 'JI', 'Ё' => 'JO', |
|
85 | - |
|
86 | - 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', |
|
87 | - 'д' => 'd', 'е' => 'e', 'ж' => 'zh', 'з' => 'z', |
|
88 | - 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l', |
|
89 | - 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', |
|
90 | - 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', |
|
91 | - 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', |
|
92 | - 'ш' => 'sh', 'щ' => 'sch', 'ъ' => '', 'ь' => '', |
|
93 | - 'ы' => 'y', 'э' => 'e', 'ю' => 'ju', 'я' => 'ja', |
|
94 | - 'і' => 'i', 'ї' => 'ji', 'ё' => 'jo' |
|
76 | + 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', |
|
77 | + 'Д' => 'D', 'Е' => 'E', 'Ж' => 'ZH', 'З' => 'Z', |
|
78 | + 'И' => 'I', 'Й' => 'J', 'К' => 'K', 'Л' => 'L', |
|
79 | + 'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', |
|
80 | + 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', |
|
81 | + 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', 'Ч' => 'CH', |
|
82 | + 'Ш' => 'SH', 'Щ' => 'SCH', 'Ъ' => '', 'Ь' => '', |
|
83 | + 'Ы' => 'Y', 'Э' => 'E', 'Ю' => 'JU', 'Я' => 'JA', |
|
84 | + 'І' => 'I', 'Ї' => 'JI', 'Ё' => 'JO', |
|
85 | + |
|
86 | + 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', |
|
87 | + 'д' => 'd', 'е' => 'e', 'ж' => 'zh', 'з' => 'z', |
|
88 | + 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l', |
|
89 | + 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', |
|
90 | + 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', |
|
91 | + 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', |
|
92 | + 'ш' => 'sh', 'щ' => 'sch', 'ъ' => '', 'ь' => '', |
|
93 | + 'ы' => 'y', 'э' => 'e', 'ю' => 'ju', 'я' => 'ja', |
|
94 | + 'і' => 'i', 'ї' => 'ji', 'ё' => 'jo' |
|
95 | 95 | ]; |
96 | 96 | |
97 | 97 | # ------------------------ |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | if (($maxlength < 1) || (self::length($string = trim($string)) <= $maxlength)) return $string; |
178 | 178 | |
179 | - $string = (rtrim(self::substr($string, 0, $maxlength)) . ($ellipsis ? '...' : '')); |
|
179 | + $string = (rtrim(self::substr($string, 0, $maxlength)).($ellipsis ? '...' : '')); |
|
180 | 180 | |
181 | 181 | # ------------------------ |
182 | 182 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | |
205 | 205 | public static function encode(string $salt, string $string) : string { |
206 | 206 | |
207 | - return sha1($salt . substr(sha1($string), 8, 32)); |
|
207 | + return sha1($salt.substr(sha1($string), 8, 32)); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | } |
@@ -22,14 +22,18 @@ discard block |
||
22 | 22 | |
23 | 23 | foreach (($string = explode("\n", $string)) as $key => $line) { |
24 | 24 | |
25 | - if ($multiline && $codestyle) $string[$key] = rtrim(preg_replace('/[\r\0\x0B]+/', '', $line)); |
|
26 | - |
|
27 | - else $string[$key] = trim(preg_replace(['/[ \t]+/', '/[\r\0\x0B]+/'], [' ', ''], $line)); |
|
25 | + if ($multiline && $codestyle) { |
|
26 | + $string[$key] = rtrim(preg_replace('/[\r\0\x0B]+/', '', $line)); |
|
27 | + } else { |
|
28 | + $string[$key] = trim(preg_replace(['/[ \t]+/', '/[\r\0\x0B]+/'], [' ', ''], $line)); |
|
29 | + } |
|
28 | 30 | } |
29 | 31 | |
30 | - if (!$multiline) $string = preg_replace('/ {2,}/', ' ', trim(implode(' ', $string), ' ')); |
|
31 | - |
|
32 | - else $string = preg_replace('/(\r\n){3,}/', "\r\n\r\n", trim(implode("\r\n", $string), "\r\n")); |
|
32 | + if (!$multiline) { |
|
33 | + $string = preg_replace('/ {2,}/', ' ', trim(implode(' ', $string), ' ')); |
|
34 | + } else { |
|
35 | + $string = preg_replace('/(\r\n){3,}/', "\r\n\r\n", trim(implode("\r\n", $string), "\r\n")); |
|
36 | + } |
|
33 | 37 | |
34 | 38 | # ------------------------ |
35 | 39 | |
@@ -174,7 +178,9 @@ discard block |
||
174 | 178 | |
175 | 179 | public static function cut(string $string, int $maxlength, bool $ellipsis = false) : string { |
176 | 180 | |
177 | - if (($maxlength < 1) || (self::length($string = trim($string)) <= $maxlength)) return $string; |
|
181 | + if (($maxlength < 1) || (self::length($string = trim($string)) <= $maxlength)) { |
|
182 | + return $string; |
|
183 | + } |
|
178 | 184 | |
179 | 185 | $string = (rtrim(self::substr($string, 0, $maxlength)) . ($ellipsis ? '...' : '')); |
180 | 186 | |
@@ -189,9 +195,13 @@ discard block |
||
189 | 195 | |
190 | 196 | public static function random(int $length, string $pool = STR_POOL_DEFAULT) : string { |
191 | 197 | |
192 | - if (($length < 1) || (0 === ($pool_length = self::length($pool)))) return ''; |
|
198 | + if (($length < 1) || (0 === ($pool_length = self::length($pool)))) { |
|
199 | + return ''; |
|
200 | + } |
|
193 | 201 | |
194 | - $string = ''; for ($i = 0; $i < $length; $i++) $string .= self::substr($pool, random_int(0, ($pool_length - 1)), 1); |
|
202 | + $string = ''; for ($i = 0; $i < $length; $i++) { |
|
203 | + $string .= self::substr($pool, random_int(0, ($pool_length - 1)), 1); |
|
204 | + } |
|
195 | 205 | |
196 | 206 | # ------------------------ |
197 | 207 |
@@ -23,15 +23,15 @@ |
||
23 | 23 | |
24 | 24 | $table = $this->getName($table); |
25 | 25 | |
26 | - if ($column !== '*') $column = (($distinct ? 'DISTINCT ' : '') . $this->getName($column)); |
|
26 | + if ($column !== '*') $column = (($distinct ? 'DISTINCT ' : '').$this->getName($column)); |
|
27 | 27 | |
28 | 28 | $condition = $this->getString($condition, '^name $operatable', ' AND '); |
29 | 29 | |
30 | 30 | # Build query |
31 | 31 | |
32 | - $this->query = ('SELECT COUNT(' . $column . ') as count ' . |
|
32 | + $this->query = ('SELECT COUNT('.$column.') as count '. |
|
33 | 33 | |
34 | - 'FROM ' . $table . ($condition ? (' WHERE (' . $condition . ')') : '')); |
|
34 | + 'FROM '.$table.($condition ? (' WHERE ('.$condition.')') : '')); |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | } |
@@ -23,7 +23,9 @@ |
||
23 | 23 | |
24 | 24 | $table = $this->getName($table); |
25 | 25 | |
26 | - if ($column !== '*') $column = (($distinct ? 'DISTINCT ' : '') . $this->getName($column)); |
|
26 | + if ($column !== '*') { |
|
27 | + $column = (($distinct ? 'DISTINCT ' : '') . $this->getName($column)); |
|
28 | + } |
|
27 | 29 | |
28 | 30 | $condition = $this->getString($condition, '^name $operatable', ' AND '); |
29 | 31 |
@@ -58,7 +58,9 @@ discard block |
||
58 | 58 | |
59 | 59 | public function getRow() { |
60 | 60 | |
61 | - if (!is_object($this->result)) return null; |
|
61 | + if (!is_object($this->result)) { |
|
62 | + return null; |
|
63 | + } |
|
62 | 64 | |
63 | 65 | return mysqli_fetch_assoc($this->result); |
64 | 66 | } |
@@ -69,9 +71,13 @@ discard block |
||
69 | 71 | |
70 | 72 | public function getRows() : array { |
71 | 73 | |
72 | - if (!is_object($this->result)) return []; |
|
74 | + if (!is_object($this->result)) { |
|
75 | + return []; |
|
76 | + } |
|
73 | 77 | |
74 | - $rows = []; while (null !== ($row = $this->getRow())) $rows[] = $row; |
|
78 | + $rows = []; while (null !== ($row = $this->getRow())) { |
|
79 | + $rows[] = $row; |
|
80 | + } |
|
75 | 81 | |
76 | 82 | # ------------------------ |
77 | 83 |