@@ -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 | ); |
@@ -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 | { |
@@ -239,7 +239,7 @@ |
||
239 | 239 | $configManager = new ConfigManager(); |
240 | 240 | $SETTINGS = $configManager->getAllSettings(); |
241 | 241 | |
242 | - $payload = [ |
|
242 | + $payload = [ |
|
243 | 243 | 'username' => $login, |
244 | 244 | 'id' => $id, |
245 | 245 | 'exp' => (time() + $SETTINGS['api_token_duration'] + 600), |
@@ -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) { |
@@ -84,24 +84,24 @@ discard block |
||
84 | 84 | |
85 | 85 | function get_authorization_header() |
86 | 86 | { |
87 | - $request = symfonyRequest::createFromGlobals(); |
|
88 | - $authorizationHeader = $request->headers->get('Authorization'); |
|
89 | - $headers = null; |
|
87 | + $request = symfonyRequest::createFromGlobals(); |
|
88 | + $authorizationHeader = $request->headers->get('Authorization'); |
|
89 | + $headers = null; |
|
90 | 90 | |
91 | - // Check if the authorization header is not empty |
|
92 | - if (!empty($authorizationHeader)) { |
|
93 | - $headers = trim($authorizationHeader); |
|
94 | - } else if (function_exists('apache_request_headers') === true) { |
|
95 | - $requestHeaders = (array) apache_request_headers(); |
|
96 | - // 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) |
|
97 | - $requestHeaders = array_combine(array_map('ucwords', array_keys($requestHeaders)), array_values($requestHeaders)); |
|
98 | - //print_r($requestHeaders); |
|
99 | - if (isset($requestHeaders['Authorization']) === true) { |
|
100 | - $headers = trim($requestHeaders['Authorization']); |
|
101 | - } |
|
102 | - } |
|
91 | + // Check if the authorization header is not empty |
|
92 | + if (!empty($authorizationHeader)) { |
|
93 | + $headers = trim($authorizationHeader); |
|
94 | + } else if (function_exists('apache_request_headers') === true) { |
|
95 | + $requestHeaders = (array) apache_request_headers(); |
|
96 | + // 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) |
|
97 | + $requestHeaders = array_combine(array_map('ucwords', array_keys($requestHeaders)), array_values($requestHeaders)); |
|
98 | + //print_r($requestHeaders); |
|
99 | + if (isset($requestHeaders['Authorization']) === true) { |
|
100 | + $headers = trim($requestHeaders['Authorization']); |
|
101 | + } |
|
102 | + } |
|
103 | 103 | |
104 | - return $headers; |
|
104 | + return $headers; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | function get_bearer_token() { |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | |
119 | 119 | function get_bearer_data($jwt) { |
120 | 120 | // split the jwt |
121 | - $tokenParts = explode('.', $jwt); |
|
122 | - $payload = base64_decode($tokenParts[1]); |
|
121 | + $tokenParts = explode('.', $jwt); |
|
122 | + $payload = base64_decode($tokenParts[1]); |
|
123 | 123 | |
124 | 124 | // HEADER: Get the access token from the header |
125 | 125 | if (empty($payload) === false) { |
@@ -830,7 +830,7 @@ |
||
830 | 830 | 'encode' |
831 | 831 | ); |
832 | 832 | |
833 | - /* |
|
833 | + /* |
|
834 | 834 | * Generate BUG report |
835 | 835 | */ |
836 | 836 | case 'generate_bug_report'://action_system |
@@ -2663,7 +2663,7 @@ |
||
2663 | 2663 | 'SELECT email, name |
2664 | 2664 | FROM '.prefixTable('users').' |
2665 | 2665 | WHERE login = %s', |
2666 | - $value |
|
2666 | + $value |
|
2667 | 2667 | ); |
2668 | 2668 | |
2669 | 2669 | // No valid email address for user |
@@ -342,8 +342,8 @@ |
||
342 | 342 | ); |
343 | 343 | |
344 | 344 | if (DB::count() > 0 && ( |
345 | - (isset($SETTINGS['duplicate_item']) && (int) $SETTINGS['duplicate_item'] === 0) |
|
346 | - && (int) $itemInfos['personal_folder'] === 0) |
|
345 | + (isset($SETTINGS['duplicate_item']) && (int) $SETTINGS['duplicate_item'] === 0) |
|
346 | + && (int) $itemInfos['personal_folder'] === 0) |
|
347 | 347 | ) { |
348 | 348 | throw new Exception('Similar item already exists. Duplicates are not allowed.'); |
349 | 349 | } |
@@ -91,215 +91,215 @@ |
||
91 | 91 | switch ($post_type) { |
92 | 92 | //########################################################## |
93 | 93 | //CASE for creating a DB backup |
94 | -case 'perform_fix_pf_items-step1': |
|
95 | - // Check KEY |
|
96 | - if (!hash_equals((string) $session->get('key'), (string) $post_key)) { |
|
97 | - echo prepareExchangedData( |
|
98 | - array( |
|
99 | - 'error' => true, |
|
100 | - 'message' => $lang->get('key_is_not_correct'), |
|
101 | - ), |
|
102 | - 'encode' |
|
103 | - ); |
|
104 | - break; |
|
105 | - } |
|
106 | - // Is admin? |
|
107 | - if ((int) $session->get('user-admin') !== 1) { |
|
108 | - echo prepareExchangedData( |
|
109 | - array( |
|
110 | - 'error' => true, |
|
111 | - 'message' => $lang->get('error_not_allowed_to'), |
|
112 | - ), |
|
113 | - 'encode' |
|
114 | - ); |
|
115 | - break; |
|
116 | - } |
|
94 | + case 'perform_fix_pf_items-step1': |
|
95 | + // Check KEY |
|
96 | + if (!hash_equals((string) $session->get('key'), (string) $post_key)) { |
|
97 | + echo prepareExchangedData( |
|
98 | + array( |
|
99 | + 'error' => true, |
|
100 | + 'message' => $lang->get('key_is_not_correct'), |
|
101 | + ), |
|
102 | + 'encode' |
|
103 | + ); |
|
104 | + break; |
|
105 | + } |
|
106 | + // Is admin? |
|
107 | + if ((int) $session->get('user-admin') !== 1) { |
|
108 | + echo prepareExchangedData( |
|
109 | + array( |
|
110 | + 'error' => true, |
|
111 | + 'message' => $lang->get('error_not_allowed_to'), |
|
112 | + ), |
|
113 | + 'encode' |
|
114 | + ); |
|
115 | + break; |
|
116 | + } |
|
117 | 117 | |
118 | - // decrypt and retrieve data in JSON format |
|
119 | - $dataReceived = prepareExchangedData( |
|
120 | - $post_data, |
|
121 | - 'decode' |
|
122 | - ); |
|
118 | + // decrypt and retrieve data in JSON format |
|
119 | + $dataReceived = prepareExchangedData( |
|
120 | + $post_data, |
|
121 | + 'decode' |
|
122 | + ); |
|
123 | 123 | |
124 | - $userId = filter_var($dataReceived['userId'], FILTER_SANITIZE_NUMBER_INT); |
|
124 | + $userId = filter_var($dataReceived['userId'], FILTER_SANITIZE_NUMBER_INT); |
|
125 | 125 | |
126 | - // Get user info |
|
127 | - $userInfo = DB::queryFirstRow( |
|
128 | - 'SELECT private_key, public_key, psk, encrypted_psk |
|
126 | + // Get user info |
|
127 | + $userInfo = DB::queryFirstRow( |
|
128 | + 'SELECT private_key, public_key, psk, encrypted_psk |
|
129 | 129 | FROM teampass_users |
130 | 130 | WHERE id = %i', |
131 | - $userId |
|
132 | - ); |
|
131 | + $userId |
|
132 | + ); |
|
133 | 133 | |
134 | - // Get user's private folders |
|
135 | - $userPFRoot = DB::queryFirstRow( |
|
136 | - 'SELECT id |
|
134 | + // Get user's private folders |
|
135 | + $userPFRoot = DB::queryFirstRow( |
|
136 | + 'SELECT id |
|
137 | 137 | FROM teampass_nested_tree |
138 | 138 | WHERE title = %i', |
139 | - $userId |
|
140 | - ); |
|
141 | - if (DB::count() === 0) { |
|
142 | - echo prepareExchangedData( |
|
143 | - array( |
|
144 | - 'error' => true, |
|
145 | - 'message' => 'User has no personal folders', |
|
146 | - ), |
|
147 | - 'encode' |
|
148 | - ); |
|
149 | - break; |
|
150 | - } |
|
151 | - $personalFolders = []; |
|
152 | - $tree = new NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title'); |
|
153 | - $tree->rebuild(); |
|
154 | - $folders = $tree->getDescendants($userPFRoot['id'], true); |
|
155 | - foreach ($folders as $folder) { |
|
156 | - array_push($personalFolders, $folder->id); |
|
157 | - } |
|
158 | - |
|
159 | - //Show done |
|
160 | - echo prepareExchangedData( |
|
161 | - array( |
|
162 | - 'error' => false, |
|
163 | - 'message' => 'Personal Folders found: ', |
|
164 | - 'personalFolders' => json_encode($personalFolders), |
|
165 | - ), |
|
166 | - 'encode' |
|
167 | - ); |
|
168 | - break; |
|
169 | - |
|
170 | -case 'perform_fix_pf_items-step2': |
|
171 | - // Check KEY |
|
172 | - if (!hash_equals((string) $session->get('key'), (string) $post_key)) { |
|
173 | - echo prepareExchangedData( |
|
174 | - array( |
|
175 | - 'error' => true, |
|
176 | - 'message' => $lang->get('key_is_not_correct'), |
|
177 | - ), |
|
178 | - 'encode' |
|
139 | + $userId |
|
179 | 140 | ); |
180 | - break; |
|
181 | - } |
|
182 | - // Is admin? |
|
183 | - if ((int) $session->get('user-admin') !== 1) { |
|
141 | + if (DB::count() === 0) { |
|
142 | + echo prepareExchangedData( |
|
143 | + array( |
|
144 | + 'error' => true, |
|
145 | + 'message' => 'User has no personal folders', |
|
146 | + ), |
|
147 | + 'encode' |
|
148 | + ); |
|
149 | + break; |
|
150 | + } |
|
151 | + $personalFolders = []; |
|
152 | + $tree = new NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title'); |
|
153 | + $tree->rebuild(); |
|
154 | + $folders = $tree->getDescendants($userPFRoot['id'], true); |
|
155 | + foreach ($folders as $folder) { |
|
156 | + array_push($personalFolders, $folder->id); |
|
157 | + } |
|
158 | + |
|
159 | + //Show done |
|
184 | 160 | echo prepareExchangedData( |
185 | 161 | array( |
186 | - 'error' => true, |
|
187 | - 'message' => $lang->get('error_not_allowed_to'), |
|
162 | + 'error' => false, |
|
163 | + 'message' => 'Personal Folders found: ', |
|
164 | + 'personalFolders' => json_encode($personalFolders), |
|
188 | 165 | ), |
189 | 166 | 'encode' |
190 | 167 | ); |
191 | 168 | break; |
192 | - } |
|
193 | 169 | |
194 | - // decrypt and retrieve data in JSON format |
|
195 | - $dataReceived = prepareExchangedData( |
|
196 | - $post_data, |
|
197 | - 'decode' |
|
198 | - ); |
|
170 | + case 'perform_fix_pf_items-step2': |
|
171 | + // Check KEY |
|
172 | + if (!hash_equals((string) $session->get('key'), (string) $post_key)) { |
|
173 | + echo prepareExchangedData( |
|
174 | + array( |
|
175 | + 'error' => true, |
|
176 | + 'message' => $lang->get('key_is_not_correct'), |
|
177 | + ), |
|
178 | + 'encode' |
|
179 | + ); |
|
180 | + break; |
|
181 | + } |
|
182 | + // Is admin? |
|
183 | + if ((int) $session->get('user-admin') !== 1) { |
|
184 | + echo prepareExchangedData( |
|
185 | + array( |
|
186 | + 'error' => true, |
|
187 | + 'message' => $lang->get('error_not_allowed_to'), |
|
188 | + ), |
|
189 | + 'encode' |
|
190 | + ); |
|
191 | + break; |
|
192 | + } |
|
199 | 193 | |
200 | - $userId = filter_var($dataReceived['userId'], FILTER_SANITIZE_NUMBER_INT); |
|
201 | - $personalFolders = filter_var($dataReceived['personalFolders'], FILTER_SANITIZE_FULL_SPECIAL_CHARS); |
|
194 | + // decrypt and retrieve data in JSON format |
|
195 | + $dataReceived = prepareExchangedData( |
|
196 | + $post_data, |
|
197 | + 'decode' |
|
198 | + ); |
|
199 | + |
|
200 | + $userId = filter_var($dataReceived['userId'], FILTER_SANITIZE_NUMBER_INT); |
|
201 | + $personalFolders = filter_var($dataReceived['personalFolders'], FILTER_SANITIZE_FULL_SPECIAL_CHARS); |
|
202 | 202 | |
203 | - // Delete all private items with sharekeys |
|
204 | - $pfiSharekeys = DB::queryFirstColumn( |
|
205 | - 'select s.increment_id |
|
203 | + // Delete all private items with sharekeys |
|
204 | + $pfiSharekeys = DB::queryFirstColumn( |
|
205 | + 'select s.increment_id |
|
206 | 206 | from teampass_sharekeys_items as s |
207 | 207 | INNER JOIN teampass_items AS i ON (i.id = s.object_id) |
208 | 208 | WHERE s.user_id = %i AND i.perso = 1 AND i.id_tree IN %ls', |
209 | - $userId, |
|
210 | - $personalFolders |
|
211 | - ); |
|
212 | - $pfiSharekeysCount = DB::count(); |
|
213 | - if ($pfiSharekeysCount > 0) { |
|
214 | - DB::delete( |
|
215 | - "teampass_sharekeys_items", |
|
216 | - "increment_id IN %ls", |
|
217 | - $pfiSharekeys |
|
209 | + $userId, |
|
210 | + $personalFolders |
|
218 | 211 | ); |
219 | - } |
|
212 | + $pfiSharekeysCount = DB::count(); |
|
213 | + if ($pfiSharekeysCount > 0) { |
|
214 | + DB::delete( |
|
215 | + "teampass_sharekeys_items", |
|
216 | + "increment_id IN %ls", |
|
217 | + $pfiSharekeys |
|
218 | + ); |
|
219 | + } |
|
220 | 220 | |
221 | 221 | |
222 | - //Show done |
|
223 | - echo prepareExchangedData( |
|
224 | - array( |
|
225 | - 'error' => false, |
|
226 | - 'message' => '<br>Number of Sharekeys for private items DELETED: ', |
|
227 | - 'nbDeleted' => $pfiSharekeysCount, |
|
228 | - 'personalFolders' => json_encode($personalFolders), |
|
229 | - ), |
|
230 | - 'encode' |
|
231 | - ); |
|
232 | - break; |
|
233 | - |
|
234 | -case 'perform_fix_pf_items-step3': |
|
235 | - // Check KEY |
|
236 | - if (!hash_equals((string) $session->get('key'), (string) $post_key)) { |
|
237 | - echo prepareExchangedData( |
|
238 | - array( |
|
239 | - 'error' => true, |
|
240 | - 'message' => $lang->get('key_is_not_correct'), |
|
241 | - ), |
|
242 | - 'encode' |
|
243 | - ); |
|
244 | - break; |
|
245 | - } |
|
246 | - // Is admin? |
|
247 | - if ((int) $session->get('user-admin') !== 1) { |
|
222 | + //Show done |
|
248 | 223 | echo prepareExchangedData( |
249 | 224 | array( |
250 | - 'error' => true, |
|
251 | - 'message' => $lang->get('error_not_allowed_to'), |
|
225 | + 'error' => false, |
|
226 | + 'message' => '<br>Number of Sharekeys for private items DELETED: ', |
|
227 | + 'nbDeleted' => $pfiSharekeysCount, |
|
228 | + 'personalFolders' => json_encode($personalFolders), |
|
252 | 229 | ), |
253 | 230 | 'encode' |
254 | 231 | ); |
255 | 232 | break; |
256 | - } |
|
257 | 233 | |
258 | - // decrypt and retrieve data in JSON format |
|
259 | - $dataReceived = prepareExchangedData( |
|
260 | - $post_data, |
|
261 | - 'decode' |
|
262 | - ); |
|
234 | + case 'perform_fix_pf_items-step3': |
|
235 | + // Check KEY |
|
236 | + if (!hash_equals((string) $session->get('key'), (string) $post_key)) { |
|
237 | + echo prepareExchangedData( |
|
238 | + array( |
|
239 | + 'error' => true, |
|
240 | + 'message' => $lang->get('key_is_not_correct'), |
|
241 | + ), |
|
242 | + 'encode' |
|
243 | + ); |
|
244 | + break; |
|
245 | + } |
|
246 | + // Is admin? |
|
247 | + if ((int) $session->get('user-admin') !== 1) { |
|
248 | + echo prepareExchangedData( |
|
249 | + array( |
|
250 | + 'error' => true, |
|
251 | + 'message' => $lang->get('error_not_allowed_to'), |
|
252 | + ), |
|
253 | + 'encode' |
|
254 | + ); |
|
255 | + break; |
|
256 | + } |
|
257 | + |
|
258 | + // decrypt and retrieve data in JSON format |
|
259 | + $dataReceived = prepareExchangedData( |
|
260 | + $post_data, |
|
261 | + 'decode' |
|
262 | + ); |
|
263 | 263 | |
264 | - $userId = filter_var($dataReceived['userId'], FILTER_SANITIZE_NUMBER_INT); |
|
265 | - $personalFolders = filter_var($dataReceived['personalFolders'], FILTER_SANITIZE_FULL_SPECIAL_CHARS); |
|
264 | + $userId = filter_var($dataReceived['userId'], FILTER_SANITIZE_NUMBER_INT); |
|
265 | + $personalFolders = filter_var($dataReceived['personalFolders'], FILTER_SANITIZE_FULL_SPECIAL_CHARS); |
|
266 | 266 | |
267 | - // Update from items_old to items all the private itemsitems that have been converted to teampass_aes |
|
268 | - // Get all key back |
|
269 | - $items = DB::query( |
|
270 | - "SELECT id |
|
267 | + // Update from items_old to items all the private itemsitems that have been converted to teampass_aes |
|
268 | + // Get all key back |
|
269 | + $items = DB::query( |
|
270 | + "SELECT id |
|
271 | 271 | FROM teampass_items |
272 | 272 | WHERE id_tree IN %ls AND encryption_type = %s", |
273 | - $personalFolders, |
|
274 | - "teampass_aes" |
|
275 | - ); |
|
276 | - //DB::debugMode(false); |
|
277 | - $nbItems = DB::count(); |
|
278 | - foreach ($items as $item) { |
|
279 | - $defusePwd = DB::queryFirstField("SELECT pw FROM teampass_items_old WHERE id = %i", $item['id']); |
|
280 | - DB::update( |
|
281 | - "teampass_items", |
|
282 | - ['pw' => $defusePwd, "encryption_type" => "defuse"], |
|
283 | - "id = %i", |
|
284 | - $item['id'] |
|
273 | + $personalFolders, |
|
274 | + "teampass_aes" |
|
285 | 275 | ); |
286 | - } |
|
276 | + //DB::debugMode(false); |
|
277 | + $nbItems = DB::count(); |
|
278 | + foreach ($items as $item) { |
|
279 | + $defusePwd = DB::queryFirstField("SELECT pw FROM teampass_items_old WHERE id = %i", $item['id']); |
|
280 | + DB::update( |
|
281 | + "teampass_items", |
|
282 | + ['pw' => $defusePwd, "encryption_type" => "defuse"], |
|
283 | + "id = %i", |
|
284 | + $item['id'] |
|
285 | + ); |
|
286 | + } |
|
287 | 287 | |
288 | 288 | |
289 | - //Show done |
|
290 | - echo prepareExchangedData( |
|
291 | - array( |
|
292 | - 'error' => false, |
|
293 | - 'message' => '<br>Number of items reseted to Defuse: ', |
|
294 | - 'nbItems' => $nbItems, |
|
295 | - 'personalFolders' => json_encode($personalFolders), |
|
296 | - ), |
|
297 | - 'encode' |
|
298 | - ); |
|
299 | - break; |
|
300 | - |
|
301 | - /* TOOL #2 - Fixing items master keys */ |
|
302 | - /* |
|
289 | + //Show done |
|
290 | + echo prepareExchangedData( |
|
291 | + array( |
|
292 | + 'error' => false, |
|
293 | + 'message' => '<br>Number of items reseted to Defuse: ', |
|
294 | + 'nbItems' => $nbItems, |
|
295 | + 'personalFolders' => json_encode($personalFolders), |
|
296 | + ), |
|
297 | + 'encode' |
|
298 | + ); |
|
299 | + break; |
|
300 | + |
|
301 | + /* TOOL #2 - Fixing items master keys */ |
|
302 | + /* |
|
303 | 303 | * STEP 1 - Check if we have the correct pwd for TP_USER |
304 | 304 | */ |
305 | 305 | case 'perform_fix_items_master_keys-step1': |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * Certain components of this file may be under different licenses. For |
23 | 23 | * details, see the `licenses` directory or individual file headers. |
24 | 24 | * --- |
25 | - * @file search.js.php |
|
25 | + * @file search.js.php |
|
26 | 26 | * @author Nils Laumaillé ([email protected]) |
27 | 27 | * @copyright 2009-2025 Teampass.net |
28 | 28 | * @license GPL-3.0 |