@@ -301,7 +301,9 @@ |
||
301 | 301 | break; |
302 | 302 | } |
303 | 303 | |
304 | - if (WIP === true) error_log('DEBUG: Offset -> '.$post_offset.'/'.$post_totalSize.' | File -> '.$post_clearFilename.' | key -> '.$post_key); |
|
304 | + if (WIP === true) { |
|
305 | + error_log('DEBUG: Offset -> '.$post_offset.'/'.$post_totalSize.' | File -> '.$post_clearFilename.' | key -> '.$post_key); |
|
306 | + } |
|
305 | 307 | |
306 | 308 | include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php'; |
307 | 309 |
@@ -2401,7 +2401,9 @@ discard block |
||
2401 | 2401 | // Complete $userInfo |
2402 | 2402 | $userInfo['has_been_created'] = 1; |
2403 | 2403 | |
2404 | - if (WIP === true) error_log("--- USER CREATED ---"); |
|
2404 | + if (WIP === true) { |
|
2405 | + error_log("--- USER CREATED ---"); |
|
2406 | + } |
|
2405 | 2407 | |
2406 | 2408 | return [ |
2407 | 2409 | 'error' => false, |
@@ -2437,7 +2439,9 @@ discard block |
||
2437 | 2439 | } |
2438 | 2440 | |
2439 | 2441 | // Oauth2 user already exists and authenticated |
2440 | - if (WIP === true) error_log("--- USER AUTHENTICATED ---"); |
|
2442 | + if (WIP === true) { |
|
2443 | + error_log("--- USER AUTHENTICATED ---"); |
|
2444 | + } |
|
2441 | 2445 | $userInfo['has_been_created'] = 0; |
2442 | 2446 | |
2443 | 2447 | $passwordManager = new PasswordManager(); |
@@ -2667,8 +2671,9 @@ discard block |
||
2667 | 2671 | ); |
2668 | 2672 | |
2669 | 2673 | // No valid email address for user |
2670 | - if (!$userInfos || !filter_var($userInfos['email'], FILTER_VALIDATE_EMAIL)) |
|
2671 | - return; |
|
2674 | + if (!$userInfos || !filter_var($userInfos['email'], FILTER_VALIDATE_EMAIL)) { |
|
2675 | + return; |
|
2676 | + } |
|
2672 | 2677 | |
2673 | 2678 | $unlock_url = $SETTINGS['cpassman_url'].'/self-unlock.php?login='.$value.'&otp='.$unlock_code; |
2674 | 2679 |
@@ -83,7 +83,9 @@ discard block |
||
83 | 83 | |
84 | 84 | if (DB::count() > 0) { |
85 | 85 | // handle tasks inside this process |
86 | - if (WIP === true) error_log("Process in progress: ".$process_to_perform['increment_id']); |
|
86 | + if (WIP === true) { |
|
87 | + error_log("Process in progress: ".$process_to_perform['increment_id']); |
|
88 | + } |
|
87 | 89 | handleTask( |
88 | 90 | $process_to_perform['increment_id'], |
89 | 91 | json_decode($process_to_perform['arguments'], true), |
@@ -100,7 +102,9 @@ discard block |
||
100 | 102 | ); |
101 | 103 | |
102 | 104 | if (DB::count() > 0) { |
103 | - if (WIP === true) error_log("New process ta start: ".$process_to_perform['increment_id']); |
|
105 | + if (WIP === true) { |
|
106 | + error_log("New process ta start: ".$process_to_perform['increment_id']); |
|
107 | + } |
|
104 | 108 | // update DB - started_at |
105 | 109 | DB::update( |
106 | 110 | prefixTable('background_tasks'), |
@@ -153,8 +157,9 @@ discard block |
||
153 | 157 | ); |
154 | 158 | |
155 | 159 | // No more tasks, exit |
156 | - if ($process_to_perform !== 1) |
|
157 | - break; |
|
160 | + if ($process_to_perform !== 1) { |
|
161 | + break; |
|
162 | + } |
|
158 | 163 | |
159 | 164 | // Run next task |
160 | 165 | $process = new Symfony\Component\Process\Process([ |
@@ -331,7 +336,9 @@ discard block |
||
331 | 336 | if ($args['step'] === 'create_users_files_key') { |
332 | 337 | // Loop on all files for this item |
333 | 338 | // and encrypt them for each user |
334 | - if (WIP === true) provideLog('[DEBUG] '.print_r($args['files_keys'], true), $SETTINGS); |
|
339 | + if (WIP === true) { |
|
340 | + provideLog('[DEBUG] '.print_r($args['files_keys'], true), $SETTINGS); |
|
341 | + } |
|
335 | 342 | foreach($args['files_keys'] as $file) { |
336 | 343 | storeUsersShareKey( |
337 | 344 | prefixTable('sharekeys_items'), |
@@ -347,7 +354,9 @@ discard block |
||
347 | 354 | } elseif ($args['step'] === 'create_users_fields_key') { |
348 | 355 | // Loop on all encrypted fields for this item |
349 | 356 | // and encrypt them for each user |
350 | - if (WIP === true) provideLog('[DEBUG] '.print_r($args, true), $SETTINGS); |
|
357 | + if (WIP === true) { |
|
358 | + provideLog('[DEBUG] '.print_r($args, true), $SETTINGS); |
|
359 | + } |
|
351 | 360 | foreach($args['fields_keys'] as $field) { |
352 | 361 | storeUsersShareKey( |
353 | 362 | prefixTable('sharekeys_fields'), |
@@ -2366,7 +2366,9 @@ discard block |
||
2366 | 2366 | function encryptUserObjectKey(string $key, string $publicKey): string |
2367 | 2367 | { |
2368 | 2368 | // Empty password |
2369 | - if (empty($key)) return ''; |
|
2369 | + if (empty($key)) { |
|
2370 | + return ''; |
|
2371 | + } |
|
2370 | 2372 | |
2371 | 2373 | // Sanitize |
2372 | 2374 | $antiXss = new AntiXSS(); |
@@ -2515,7 +2517,9 @@ discard block |
||
2515 | 2517 | ]; |
2516 | 2518 | } |
2517 | 2519 | |
2518 | - if (WIP) error_log('DEBUG: File image url -> '.filter_var($safeFilePath, FILTER_SANITIZE_URL)); |
|
2520 | + if (WIP) { |
|
2521 | + error_log('DEBUG: File image url -> '.filter_var($safeFilePath, FILTER_SANITIZE_URL)); |
|
2522 | + } |
|
2519 | 2523 | |
2520 | 2524 | // Decrypt file content and return |
2521 | 2525 | return base64_encode($cipher->decrypt($ciphertext)); |
@@ -2650,7 +2654,9 @@ discard block |
||
2650 | 2654 | foreach ($users as $user) { |
2651 | 2655 | // Insert in DB the new object key for this item by user |
2652 | 2656 | if (count($objectKeyArray) === 0) { |
2653 | - if (WIP === true) error_log('TEAMPASS Debug - storeUsersShareKey case1 - ' . $object_name . ' - ' . $post_object_id . ' - ' . $user['id'] . ' - ' . $objectKey); |
|
2657 | + if (WIP === true) { |
|
2658 | + error_log('TEAMPASS Debug - storeUsersShareKey case1 - ' . $object_name . ' - ' . $post_object_id . ' - ' . $user['id'] . ' - ' . $objectKey); |
|
2659 | + } |
|
2654 | 2660 | DB::insert( |
2655 | 2661 | $object_name, |
2656 | 2662 | [ |
@@ -2664,7 +2670,9 @@ discard block |
||
2664 | 2670 | ); |
2665 | 2671 | } else { |
2666 | 2672 | foreach ($objectKeyArray as $object) { |
2667 | - if (WIP === true) error_log('TEAMPASS Debug - storeUsersShareKey case2 - ' . $object_name . ' - ' . $object['objectId'] . ' - ' . $user['id'] . ' - ' . $object['objectKey']); |
|
2673 | + if (WIP === true) { |
|
2674 | + error_log('TEAMPASS Debug - storeUsersShareKey case2 - ' . $object_name . ' - ' . $object['objectId'] . ' - ' . $user['id'] . ' - ' . $object['objectKey']); |
|
2675 | + } |
|
2668 | 2676 | DB::insert( |
2669 | 2677 | $object_name, |
2670 | 2678 | [ |
@@ -3990,7 +3998,9 @@ discard block |
||
3990 | 3998 | $taskName = [$taskName]; |
3991 | 3999 | } |
3992 | 4000 | foreach($taskName as $task) { |
3993 | - if (WIP === true) error_log('createTaskForItem - task: '.$task); |
|
4001 | + if (WIP === true) { |
|
4002 | + error_log('createTaskForItem - task: '.$task); |
|
4003 | + } |
|
3994 | 4004 | switch ($task) { |
3995 | 4005 | case 'item_password': |
3996 | 4006 | |
@@ -4421,19 +4431,22 @@ discard block |
||
4421 | 4431 | |
4422 | 4432 | // Organisation name (removed username@ and .tld) |
4423 | 4433 | $domain = explode('.', $emailParts[1]); |
4424 | - if (count($domain) > 1) |
|
4425 | - $forbiddenWords[] = $domain[0]; |
|
4434 | + if (count($domain) > 1) { |
|
4435 | + $forbiddenWords[] = $domain[0]; |
|
4436 | + } |
|
4426 | 4437 | } |
4427 | 4438 | } |
4428 | 4439 | |
4429 | 4440 | // Search forbidden words in password |
4430 | 4441 | foreach ($forbiddenWords as $word) { |
4431 | - if (empty($word)) |
|
4432 | - continue; |
|
4442 | + if (empty($word)) { |
|
4443 | + continue; |
|
4444 | + } |
|
4433 | 4445 | |
4434 | 4446 | // Stop if forbidden word found in password |
4435 | - if (stripos($password, $word) !== false) |
|
4436 | - return false; |
|
4447 | + if (stripos($password, $word) !== false) { |
|
4448 | + return false; |
|
4449 | + } |
|
4437 | 4450 | } |
4438 | 4451 | |
4439 | 4452 | // Get password complexity |
@@ -112,8 +112,9 @@ discard block |
||
112 | 112 | */ |
113 | 113 | private function isParentFolderAllowed($parent_id, $user_accessible_folders, $user_is_admin, $user_can_create_root_folder) |
114 | 114 | { |
115 | - if ($parent_id == 0 && $user_can_create_root_folder == true) |
|
116 | - return true; |
|
115 | + if ($parent_id == 0 && $user_can_create_root_folder == true) { |
|
116 | + return true; |
|
117 | + } |
|
117 | 118 | |
118 | 119 | if (in_array($parent_id, $user_accessible_folders) === false |
119 | 120 | && (int) $user_is_admin !== 1 |
@@ -438,8 +439,9 @@ discard block |
||
438 | 439 | )['count']; |
439 | 440 | |
440 | 441 | // Don't insert duplicates |
441 | - if ($count > 0) |
|
442 | - continue; |
|
442 | + if ($count > 0) { |
|
443 | + continue; |
|
444 | + } |
|
443 | 445 | |
444 | 446 | // Insert new background task |
445 | 447 | DB::insert( |
@@ -83,7 +83,9 @@ discard block |
||
83 | 83 | |
84 | 84 | if (DB::count() > 0) { |
85 | 85 | // handle tasks inside this process |
86 | - if (WIP === true) error_log("Process in progress: ".$process_to_perform['increment_id']); |
|
86 | + if (WIP === true) { |
|
87 | + error_log("Process in progress: ".$process_to_perform['increment_id']); |
|
88 | + } |
|
87 | 89 | handleTask( |
88 | 90 | $process_to_perform['increment_id'], |
89 | 91 | json_decode($process_to_perform['arguments'], true), |
@@ -100,7 +102,9 @@ discard block |
||
100 | 102 | ); |
101 | 103 | |
102 | 104 | if (DB::count() > 0) { |
103 | - if (WIP === true) error_log("New process ta start: ".$process_to_perform['increment_id']); |
|
105 | + if (WIP === true) { |
|
106 | + error_log("New process ta start: ".$process_to_perform['increment_id']); |
|
107 | + } |
|
104 | 108 | // update DB - started_at |
105 | 109 | DB::update( |
106 | 110 | prefixTable('background_tasks'), |
@@ -153,8 +157,9 @@ discard block |
||
153 | 157 | ); |
154 | 158 | |
155 | 159 | // No more tasks, exit |
156 | - if ($process_to_perform !== 1) |
|
157 | - break; |
|
160 | + if ($process_to_perform !== 1) { |
|
161 | + break; |
|
162 | + } |
|
158 | 163 | |
159 | 164 | // Run next task |
160 | 165 | $process = new Symfony\Component\Process\Process([ |
@@ -331,7 +336,9 @@ discard block |
||
331 | 336 | if ($args['step'] === 'create_users_files_key') { |
332 | 337 | // Loop on all files for this item |
333 | 338 | // and encrypt them for each user |
334 | - if (WIP === true) provideLog('[DEBUG] '.print_r($args['files_keys'], true), $SETTINGS); |
|
339 | + if (WIP === true) { |
|
340 | + provideLog('[DEBUG] '.print_r($args['files_keys'], true), $SETTINGS); |
|
341 | + } |
|
335 | 342 | foreach($args['files_keys'] as $file) { |
336 | 343 | storeUsersShareKey( |
337 | 344 | prefixTable('sharekeys_items'), |
@@ -347,7 +354,9 @@ discard block |
||
347 | 354 | } elseif ($args['step'] === 'create_users_fields_key') { |
348 | 355 | // Loop on all encrypted fields for this item |
349 | 356 | // and encrypt them for each user |
350 | - if (WIP === true) provideLog('[DEBUG] '.print_r($args, true), $SETTINGS); |
|
357 | + if (WIP === true) { |
|
358 | + provideLog('[DEBUG] '.print_r($args, true), $SETTINGS); |
|
359 | + } |
|
351 | 360 | foreach($args['fields_keys'] as $field) { |
352 | 361 | storeUsersShareKey( |
353 | 362 | prefixTable('sharekeys_fields'), |
@@ -77,8 +77,9 @@ |
||
77 | 77 | ); |
78 | 78 | |
79 | 79 | // No more pending user_build_cache_tree tasks |
80 | - if (DB::count() === 0) |
|
81 | - exit; |
|
80 | + if (DB::count() === 0) { |
|
81 | + exit; |
|
82 | + } |
|
82 | 83 | |
83 | 84 | // get email properties |
84 | 85 | $arguments = json_decode($record['arguments'], true); |
@@ -74,7 +74,9 @@ discard block |
||
74 | 74 | if ($args['step'] === 'create_users_files_key') { |
75 | 75 | // Loop on all files for this item |
76 | 76 | // and encrypt them for each user |
77 | - if (WIP === true) provideLog('[DEBUG] '.print_r($args['files_keys'], true), $SETTINGS); |
|
77 | + if (WIP === true) { |
|
78 | + provideLog('[DEBUG] '.print_r($args['files_keys'], true), $SETTINGS); |
|
79 | + } |
|
78 | 80 | foreach($args['files_keys'] as $file) { |
79 | 81 | storeUsersShareKey( |
80 | 82 | prefixTable('sharekeys_items'), |
@@ -91,7 +93,9 @@ discard block |
||
91 | 93 | } elseif ($args['step'] === 'create_users_fields_key') { |
92 | 94 | // Loop on all encrypted fields for this item |
93 | 95 | // and encrypt them for each user |
94 | - if (WIP === true) provideLog('[DEBUG] '.print_r($args, true), $SETTINGS); |
|
96 | + if (WIP === true) { |
|
97 | + provideLog('[DEBUG] '.print_r($args, true), $SETTINGS); |
|
98 | + } |
|
95 | 99 | foreach($args['fields_keys'] as $field) { |
96 | 100 | storeUsersShareKey( |
97 | 101 | prefixTable('sharekeys_fields'), |
@@ -1234,7 +1234,9 @@ discard block |
||
1234 | 1234 | ); |
1235 | 1235 | |
1236 | 1236 | // Create a task to create sharekeys for users |
1237 | - if (WIP=== true) error_log('createTaskForItem - new password for this item - '.$post_password ." -- ". $pw); |
|
1237 | + if (WIP=== true) { |
|
1238 | + error_log('createTaskForItem - new password for this item - '.$post_password ." -- ". $pw); |
|
1239 | + } |
|
1238 | 1240 | $tasksToBePerformed = ['item_password']; |
1239 | 1241 | $encryptionTaskIsRequested = true; |
1240 | 1242 | } else { |
@@ -1550,7 +1552,9 @@ discard block |
||
1550 | 1552 | |
1551 | 1553 | // create a task for all fields updated |
1552 | 1554 | if ($encryptionTaskIsRequested === true) { |
1553 | - if (WIP === true) error_log('createTaskForItem - '.print_r($tasksToBePerformed, true)); |
|
1555 | + if (WIP === true) { |
|
1556 | + error_log('createTaskForItem - '.print_r($tasksToBePerformed, true)); |
|
1557 | + } |
|
1554 | 1558 | createTaskForItem( |
1555 | 1559 | 'item_update_create_keys', |
1556 | 1560 | $tasksToBePerformed, |
@@ -2051,7 +2055,9 @@ discard block |
||
2051 | 2055 | $inputData['itemId'] |
2052 | 2056 | ); |
2053 | 2057 | foreach ($rows as $record) { |
2054 | - if ($record['raison'] === NULL) continue; |
|
2058 | + if ($record['raison'] === NULL) { |
|
2059 | + continue; |
|
2060 | + } |
|
2055 | 2061 | $reason = explode(':', $record['raison']); |
2056 | 2062 | if (count($reason) > 0) { |
2057 | 2063 | $sentence = date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['date']) . ' - ' |
@@ -4753,8 +4759,9 @@ discard block |
||
4753 | 4759 | $ids = $tree->getDescendants($folder['id'], true, false, true); |
4754 | 4760 | |
4755 | 4761 | // This folder is owned by user |
4756 | - if (in_array($inputData['folderId'], $ids)) |
|
4757 | - $accessLevel = 30; |
|
4762 | + if (in_array($inputData['folderId'], $ids)) { |
|
4763 | + $accessLevel = 30; |
|
4764 | + } |
|
4758 | 4765 | } |
4759 | 4766 | } |
4760 | 4767 |