@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $ret = []; |
| 35 | 35 | |
| 36 | 36 | foreach ($rows as $row) { |
| 37 | - $isVisible = in_array((int) $row['id'], $foldersId); |
|
| 37 | + $isVisible = in_array((int) $row['id'], $foldersId); |
|
| 38 | 38 | $childrens = $this->getFoldersChildren($row['id'], $foldersId); |
| 39 | 39 | |
| 40 | 40 | if ($isVisible || count($childrens) > 0) { |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | [ |
| 44 | 44 | 'id' => (int) $row['id'], |
| 45 | 45 | 'title' => $row['title'], |
| 46 | - 'isVisible' => $isVisible, |
|
| 46 | + 'isVisible' => $isVisible, |
|
| 47 | 47 | 'childrens' => $childrens |
| 48 | 48 | ] |
| 49 | 49 | ); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | if ( count($childrens) > 0) { |
| 65 | 65 | foreach ($childrens as $children) { |
| 66 | - $isVisible = in_array((int) $children['id'], $foldersId); |
|
| 66 | + $isVisible = in_array((int) $children['id'], $foldersId); |
|
| 67 | 67 | $childs = $this->getFoldersChildren($children['id'], $foldersId); |
| 68 | 68 | |
| 69 | 69 | if (in_array((int) $children['id'], $foldersId) || count($childs) > 0) { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | [ |
| 73 | 73 | 'id' => (int) $children['id'], |
| 74 | 74 | 'title' => $children['title'], |
| 75 | - 'isVisible' => $isVisible, |
|
| 75 | + 'isVisible' => $isVisible, |
|
| 76 | 76 | 'childrens' => $childs |
| 77 | 77 | ] |
| 78 | 78 | ); |
@@ -37,45 +37,45 @@ discard block |
||
| 37 | 37 | * @return boolean |
| 38 | 38 | */ |
| 39 | 39 | function is_jwt_valid($jwt) { |
| 40 | - try { |
|
| 41 | - $decoded = (array) JWT::decode($jwt, new Key(DB_PASSWD, 'HS256')); |
|
| 40 | + try { |
|
| 41 | + $decoded = (array) JWT::decode($jwt, new Key(DB_PASSWD, 'HS256')); |
|
| 42 | 42 | |
| 43 | - // Check if expiration is reached |
|
| 44 | - if ($decoded['exp'] - time() < 0) { |
|
| 45 | - return false; |
|
| 46 | - } |
|
| 43 | + // Check if expiration is reached |
|
| 44 | + if ($decoded['exp'] - time() < 0) { |
|
| 45 | + return false; |
|
| 46 | + } |
|
| 47 | 47 | /* |
| 48 | 48 | $decoded1 = JWT::decode($jwt, new Key(DB_PASSWD, 'HS256'), $headers = new stdClass()); |
| 49 | 49 | print_r($headers); |
| 50 | 50 | */ |
| 51 | 51 | |
| 52 | - return true; |
|
| 53 | - } catch (InvalidArgumentException $e) { |
|
| 54 | - // provided key/key-array is empty or malformed. |
|
| 55 | - return false; |
|
| 56 | - } catch (DomainException $e) { |
|
| 57 | - // provided algorithm is unsupported OR |
|
| 58 | - // provided key is invalid OR |
|
| 59 | - // unknown error thrown in openSSL or libsodium OR |
|
| 60 | - // libsodium is required but not available. |
|
| 61 | - return false; |
|
| 62 | - } catch (SignatureInvalidException $e) { |
|
| 63 | - // provided JWT signature verification failed. |
|
| 64 | - return false; |
|
| 65 | - } catch (BeforeValidException $e) { |
|
| 66 | - // provided JWT is trying to be used before "nbf" claim OR |
|
| 67 | - // provided JWT is trying to be used before "iat" claim. |
|
| 68 | - return false; |
|
| 69 | - } catch (ExpiredException $e) { |
|
| 70 | - // provided JWT is trying to be used after "exp" claim. |
|
| 71 | - return false; |
|
| 72 | - } catch (UnexpectedValueException $e) { |
|
| 73 | - // provided JWT is malformed OR |
|
| 74 | - // provided JWT is missing an algorithm / using an unsupported algorithm OR |
|
| 75 | - // provided JWT algorithm does not match provided key OR |
|
| 76 | - // provided key ID in key/key-array is empty or invalid. |
|
| 77 | - return false; |
|
| 78 | - } |
|
| 52 | + return true; |
|
| 53 | + } catch (InvalidArgumentException $e) { |
|
| 54 | + // provided key/key-array is empty or malformed. |
|
| 55 | + return false; |
|
| 56 | + } catch (DomainException $e) { |
|
| 57 | + // provided algorithm is unsupported OR |
|
| 58 | + // provided key is invalid OR |
|
| 59 | + // unknown error thrown in openSSL or libsodium OR |
|
| 60 | + // libsodium is required but not available. |
|
| 61 | + return false; |
|
| 62 | + } catch (SignatureInvalidException $e) { |
|
| 63 | + // provided JWT signature verification failed. |
|
| 64 | + return false; |
|
| 65 | + } catch (BeforeValidException $e) { |
|
| 66 | + // provided JWT is trying to be used before "nbf" claim OR |
|
| 67 | + // provided JWT is trying to be used before "iat" claim. |
|
| 68 | + return false; |
|
| 69 | + } catch (ExpiredException $e) { |
|
| 70 | + // provided JWT is trying to be used after "exp" claim. |
|
| 71 | + return false; |
|
| 72 | + } catch (UnexpectedValueException $e) { |
|
| 73 | + // provided JWT is malformed OR |
|
| 74 | + // provided JWT is missing an algorithm / using an unsupported algorithm OR |
|
| 75 | + // provided JWT algorithm does not match provided key OR |
|
| 76 | + // provided key ID in key/key-array is empty or invalid. |
|
| 77 | + return false; |
|
| 78 | + } |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | function base64url_encode($data) { |
@@ -83,24 +83,24 @@ discard block |
||
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | function get_authorization_header(){ |
| 86 | - $superGlobal = new SuperGlobal(); |
|
| 87 | - $headers = null; |
|
| 86 | + $superGlobal = new SuperGlobal(); |
|
| 87 | + $headers = null; |
|
| 88 | 88 | |
| 89 | - if (null !== $superGlobal->get('Authorization', 'SERVER')) { |
|
| 90 | - $headers = trim($superGlobal->get('Authorization', 'SERVER')); |
|
| 91 | - } else if (null !== $superGlobal->get('HTTP_AUTHORIZATION', 'SERVER')) { //Nginx or fast CGI |
|
| 92 | - $headers = trim($superGlobal->get('HTTP_AUTHORIZATION', 'SERVER')); |
|
| 93 | - } else if (function_exists('apache_request_headers') === true) { |
|
| 94 | - $requestHeaders = (array) apache_request_headers(); |
|
| 95 | - // Server-side fix for bug in old Android versions (a nice side-effect of this fix means we don't care about capitalization for Authorization) |
|
| 96 | - $requestHeaders = array_combine(array_map('ucwords', array_keys($requestHeaders)), array_values($requestHeaders)); |
|
| 97 | - //print_r($requestHeaders); |
|
| 98 | - if (isset($requestHeaders['Authorization']) === true) { |
|
| 99 | - $headers = trim($requestHeaders['Authorization']); |
|
| 100 | - } |
|
| 101 | - } |
|
| 89 | + if (null !== $superGlobal->get('Authorization', 'SERVER')) { |
|
| 90 | + $headers = trim($superGlobal->get('Authorization', 'SERVER')); |
|
| 91 | + } else if (null !== $superGlobal->get('HTTP_AUTHORIZATION', 'SERVER')) { //Nginx or fast CGI |
|
| 92 | + $headers = trim($superGlobal->get('HTTP_AUTHORIZATION', 'SERVER')); |
|
| 93 | + } else if (function_exists('apache_request_headers') === true) { |
|
| 94 | + $requestHeaders = (array) apache_request_headers(); |
|
| 95 | + // Server-side fix for bug in old Android versions (a nice side-effect of this fix means we don't care about capitalization for Authorization) |
|
| 96 | + $requestHeaders = array_combine(array_map('ucwords', array_keys($requestHeaders)), array_values($requestHeaders)); |
|
| 97 | + //print_r($requestHeaders); |
|
| 98 | + if (isset($requestHeaders['Authorization']) === true) { |
|
| 99 | + $headers = trim($requestHeaders['Authorization']); |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - return $headers; |
|
| 103 | + return $headers; |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | function get_bearer_token() { |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | function get_bearer_data($jwt) { |
| 119 | 119 | // split the jwt |
| 120 | - $tokenParts = explode('.', $jwt); |
|
| 121 | - $payload = base64_decode($tokenParts[1]); |
|
| 120 | + $tokenParts = explode('.', $jwt); |
|
| 121 | + $payload = base64_decode($tokenParts[1]); |
|
| 122 | 122 | |
| 123 | 123 | // HEADER: Get the access token from the header |
| 124 | 124 | if (empty($payload) === false) { |
@@ -133,7 +133,7 @@ |
||
| 133 | 133 | { |
| 134 | 134 | include API_ROOT_PATH . '/../includes/config/tp.config.php'; |
| 135 | 135 | |
| 136 | - $payload = [ |
|
| 136 | + $payload = [ |
|
| 137 | 137 | 'username' => $login, |
| 138 | 138 | 'id' => $id, |
| 139 | 139 | 'exp' => (time() + $SETTINGS['api_token_duration'] + 600), |
@@ -2,28 +2,28 @@ |
||
| 2 | 2 | |
| 3 | 3 | declare(strict_types=1); |
| 4 | 4 | |
| 5 | - /** |
|
| 6 | - * Teampass - a collaborative passwords manager. |
|
| 7 | - * --- |
|
| 8 | - * This library is distributed in the hope that it will be useful, |
|
| 9 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 10 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
| 11 | - * --- |
|
| 12 | - * |
|
| 13 | - * @project Teampass |
|
| 14 | - * |
|
| 15 | - * @file search.js.php |
|
| 16 | - * --- |
|
| 17 | - * |
|
| 18 | - * @author Nils Laumaillé ([email protected]) |
|
| 19 | - * |
|
| 20 | - * @copyright 2009-2023 Teampass.net |
|
| 21 | - * |
|
| 22 | - * @license https://spdx.org/licenses/GPL-3.0-only.html#licenseText GPL-3.0 |
|
| 23 | - * --- |
|
| 24 | - * |
|
| 25 | - * @see https://www.teampass.net |
|
| 26 | - */ |
|
| 5 | + /** |
|
| 6 | + * Teampass - a collaborative passwords manager. |
|
| 7 | + * --- |
|
| 8 | + * This library is distributed in the hope that it will be useful, |
|
| 9 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 10 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
| 11 | + * --- |
|
| 12 | + * |
|
| 13 | + * @project Teampass |
|
| 14 | + * |
|
| 15 | + * @file search.js.php |
|
| 16 | + * --- |
|
| 17 | + * |
|
| 18 | + * @author Nils Laumaillé ([email protected]) |
|
| 19 | + * |
|
| 20 | + * @copyright 2009-2023 Teampass.net |
|
| 21 | + * |
|
| 22 | + * @license https://spdx.org/licenses/GPL-3.0-only.html#licenseText GPL-3.0 |
|
| 23 | + * --- |
|
| 24 | + * |
|
| 25 | + * @see https://www.teampass.net |
|
| 26 | + */ |
|
| 27 | 27 | |
| 28 | 28 | use TeampassClasses\PerformChecks\PerformChecks; |
| 29 | 29 | use TeampassClasses\SessionManager\SessionManager; |
@@ -2225,7 +2225,7 @@ discard block |
||
| 2225 | 2225 | * <tt>exec("find ".$path." -type d -exec chmod 755 {} \;");</tt> |
| 2226 | 2226 | * |
| 2227 | 2227 | * @author Jeppe Toustrup (tenzer at tenzer dot dk) |
| 2228 | - * |
|
| 2228 | + * |
|
| 2229 | 2229 | * @param string $path An either relative or absolute path to a file or directory which should be processed. |
| 2230 | 2230 | * @param int $filePerm The permissions any found files should get. |
| 2231 | 2231 | * @param int $dirPerm The permissions any found folder should get. |
@@ -3848,7 +3848,6 @@ discard block |
||
| 3848 | 3848 | * @param integer $processId |
| 3849 | 3849 | * @param integer $nbItemsToTreat |
| 3850 | 3850 | * @return void |
| 3851 | - |
|
| 3852 | 3851 | */ |
| 3853 | 3852 | function createUserTasks($processId, $nbItemsToTreat): void |
| 3854 | 3853 | { |