Passed
Push — master ( b5e43b...b727b7 )
by Nils
06:02
created
scripts/background_tasks___worker.php 1 patch
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -64,7 +64,9 @@  discard block
 block discarded – undo
64 64
      */
65 65
     public function execute() {
66 66
         try {
67
-            if (LOG_TASKS=== true) $this->logger->log('Processing task: ' . print_r($this->taskData, true), 'DEBUG');
67
+            if (LOG_TASKS=== true) {
68
+                $this->logger->log('Processing task: ' . print_r($this->taskData, true), 'DEBUG');
69
+            }
68 70
             // Dispatch selon le type de processus
69 71
             switch ($this->processType) {
70 72
                 case 'item_copy':
@@ -136,7 +138,9 @@  discard block
 block discarded – undo
136 138
             $arguments = '';
137 139
         }
138 140
 
139
-        if (LOG_TASKS=== true) $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG');
141
+        if (LOG_TASKS=== true) {
142
+            $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG');
143
+        }
140 144
 
141 145
         // Add 'arguments' only if not empty
142 146
         if (!empty($arguments)) {
@@ -150,7 +154,9 @@  discard block
 block discarded – undo
150 154
             'increment_id = %i',
151 155
             $this->taskId
152 156
         );
153
-        if (LOG_TASKS=== true) $this->logger->log('Finishing task: ' . $this->taskId, 'DEBUG');
157
+        if (LOG_TASKS=== true) {
158
+            $this->logger->log('Finishing task: ' . $this->taskId, 'DEBUG');
159
+        }
154 160
     }
155 161
 
156 162
     /**
@@ -185,7 +191,9 @@  discard block
 block discarded – undo
185 191
      * @return void
186 192
      */
187 193
     private function processSubTasks($arguments) {
188
-        if (LOG_TASKS=== true) $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG');
194
+        if (LOG_TASKS=== true) {
195
+            $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG');
196
+        }
189 197
         // Get all subtasks related to this task
190 198
         $subtasks = DB::query(
191 199
             'SELECT * FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC',
@@ -194,7 +202,9 @@  discard block
 block discarded – undo
194 202
     
195 203
         // Check if there are any subtasks to process
196 204
         if (empty($subtasks)) {
197
-            if (LOG_TASKS=== true) $this->logger->log('No subtask was found for task: ' . $this->taskId, 'DEBUG');
205
+            if (LOG_TASKS=== true) {
206
+                $this->logger->log('No subtask was found for task: ' . $this->taskId, 'DEBUG');
207
+            }
198 208
             return;
199 209
         }
200 210
     
@@ -204,7 +214,9 @@  discard block
 block discarded – undo
204 214
                 // Get the subtask data
205 215
                 $subtaskData = json_decode($subtask['task'], true);
206 216
 
207
-                if (LOG_TASKS=== true) $this->logger->log('Processing subtask: ' . $subtaskData['step'], 'DEBUG');
217
+                if (LOG_TASKS=== true) {
218
+                    $this->logger->log('Processing subtask: ' . $subtaskData['step'], 'DEBUG');
219
+                }
208 220
 
209 221
                 // Mark subtask as in progress
210 222
                 DB::update(
Please login to merge, or discard this patch.
sources/items.queries.php 1 patch
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1228,7 +1228,9 @@  discard block
 block discarded – undo
1228 1228
                 );
1229 1229
 
1230 1230
                 // Create a task to create sharekeys for users
1231
-                if (WIP=== true) error_log('createTaskForItem - new password for this item - '.$post_password ." -- ". $pw);
1231
+                if (WIP=== true) {
1232
+                    error_log('createTaskForItem - new password for this item - '.$post_password ." -- ". $pw);
1233
+                }
1232 1234
                 $tasksToBePerformed = ['item_password'];
1233 1235
                 $encryptionTaskIsRequested = true;
1234 1236
             } else {
@@ -1553,7 +1555,9 @@  discard block
 block discarded – undo
1553 1555
 
1554 1556
             // create a task for all fields updated
1555 1557
             if ($encryptionTaskIsRequested === true && (int) $dataItem['perso'] !== 1) {
1556
-                if (WIP === true) error_log('createTaskForItem - '.print_r($tasksToBePerformed, true));
1558
+                if (WIP === true) {
1559
+                    error_log('createTaskForItem - '.print_r($tasksToBePerformed, true));
1560
+                }
1557 1561
                 createTaskForItem(
1558 1562
                     'item_update_create_keys',
1559 1563
                     array_unique($tasksToBePerformed),
@@ -2103,7 +2107,9 @@  discard block
 block discarded – undo
2103 2107
                 $inputData['itemId']
2104 2108
             );
2105 2109
             foreach ($rows as $record) {
2106
-                if ($record['raison'] === NULL) continue;
2110
+                if ($record['raison'] === NULL) {
2111
+                    continue;
2112
+                }
2107 2113
                 $reason = explode(':', $record['raison']);
2108 2114
                 if (count($reason) > 0) {
2109 2115
                     $sentence = date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['date']) . ' - '
@@ -4819,8 +4825,9 @@  discard block
 block discarded – undo
4819 4825
                 $ids = $tree->getDescendants($folder['id'], true, false, true);
4820 4826
 
4821 4827
                 // This folder is owned by user
4822
-                if (in_array($inputData['folderId'], $ids))
4823
-                    $accessLevel = 30;
4828
+                if (in_array($inputData['folderId'], $ids)) {
4829
+                                    $accessLevel = 30;
4830
+                }
4824 4831
             }
4825 4832
         }
4826 4833
 
Please login to merge, or discard this patch.
scripts/traits/MigrateUserHandlerTrait.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,13 +45,17 @@  discard block
 block discarded – undo
45 45
         );
46 46
     
47 47
         if (empty($subtasks)) {
48
-            if (LOG_TASKS=== true) $this->logger->log("No subtask was found for task {$this->taskId}");
48
+            if (LOG_TASKS=== true) {
49
+                $this->logger->log("No subtask was found for task {$this->taskId}");
50
+            }
49 51
             return;
50 52
         }
51 53
     
52 54
         // Process each subtask
53 55
         foreach ($subtasks as $subtask) {
54
-            if (LOG_TASKS=== true) $this->logger->log("Processing subtask {$subtask['increment_id']} for task {$this->taskId}");
56
+            if (LOG_TASKS=== true) {
57
+                $this->logger->log("Processing subtask {$subtask['increment_id']} for task {$this->taskId}");
58
+            }
55 59
             $this->processMigratePersonalItemsSubtask($subtask, $arguments);
56 60
         }
57 61
     
@@ -88,7 +92,9 @@  discard block
 block discarded – undo
88 92
                 $subtask['increment_id']
89 93
             );
90 94
             
91
-            if (LOG_TASKS=== true) $this->logger->log("Subtask is in progress: ".$taskData['step'], 'INFO');
95
+            if (LOG_TASKS=== true) {
96
+                $this->logger->log("Subtask is in progress: ".$taskData['step'], 'INFO');
97
+            }
92 98
             switch ($taskData['step'] ?? '') {
93 99
                 case 'user-personal-items-migration-step10':
94 100
                     $this->migratePersonalItemsStep10($taskData, $arguments);
Please login to merge, or discard this patch.
scripts/traits/UserHandlerTrait.php 1 patch
Braces   +13 added lines, -5 removed lines patch added patch discarded remove patch
@@ -55,13 +55,17 @@  discard block
 block discarded – undo
55 55
         );
56 56
     
57 57
         if (empty($subtasks)) {
58
-            if (LOG_TASKS=== true) $this->logger->log("No subtask was found for task {$this->taskId}");
58
+            if (LOG_TASKS=== true) {
59
+                $this->logger->log("No subtask was found for task {$this->taskId}");
60
+            }
59 61
             return;
60 62
         }
61 63
     
62 64
         // Process each subtask
63 65
         foreach ($subtasks as $subtask) {
64
-            if (LOG_TASKS=== true) $this->logger->log("Processing subtask {$subtask['increment_id']} for task {$this->taskId}");
66
+            if (LOG_TASKS=== true) {
67
+                $this->logger->log("Processing subtask {$subtask['increment_id']} for task {$this->taskId}");
68
+            }
65 69
             $this->processGenerateUserKeysSubtask($subtask, $arguments);
66 70
         }
67 71
     
@@ -98,7 +102,9 @@  discard block
 block discarded – undo
98 102
                 $subtask['increment_id']
99 103
             );
100 104
             
101
-            if (LOG_TASKS=== true) $this->logger->log("Subtask is in progress: ".$taskData['step'], 'INFO');
105
+            if (LOG_TASKS=== true) {
106
+                $this->logger->log("Subtask is in progress: ".$taskData['step'], 'INFO');
107
+            }
102 108
             switch ($taskData['step'] ?? '') {
103 109
                 case 'step0':
104 110
                     $this->generateNewUserStep0($arguments);
@@ -165,7 +171,9 @@  discard block
 block discarded – undo
165 171
     private function generateNewUserStep0($arguments) {
166 172
         // CLear old sharekeys
167 173
         if ($arguments['user_self_change'] === 0) {
168
-            if (LOG_TASKS=== true) $this->logger->log("Deleting old sharekeys for user {$arguments['new_user_id']}", 'INFO');
174
+            if (LOG_TASKS=== true) {
175
+                $this->logger->log("Deleting old sharekeys for user {$arguments['new_user_id']}", 'INFO');
176
+            }
169 177
             deleteUserObjetsKeys($arguments['new_user_id'], $this->settings);
170 178
         }
171 179
     }
@@ -780,7 +788,7 @@  discard block
 block discarded – undo
780 788
                 'login' => $userInfo['login'],
781 789
                 'name' => $userInfo['name'],
782 790
             ];
783
-        }else {
791
+        } else {
784 792
             // Normal case
785 793
             return [
786 794
                 'private_key' => decryptPrivateKey($pwd, $userInfo['private_key']),
Please login to merge, or discard this patch.
pages/admin.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -490,8 +490,7 @@
 block discarded – undo
490 490
                                         </div>
491 491
         <?php
492 492
     }
493
-}
494
-catch (Exception $e) {
493
+} catch (Exception $e) {
495 494
     if (defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
496 495
         error_log('TEAMPASS Error - admin page - '.$e->getMessage());
497 496
     }
Please login to merge, or discard this patch.
scripts/traits/ItemHandlerTrait.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 trait ItemHandlerTrait {    
30 30
 
31 31
     private function generateUserPasswordKeys($arguments) {
32
-        if (LOG_TASKS=== true) $this->logger->log('Processing generateUserPasswordKeys : '.print_r($arguments, true), 'DEBUG');
32
+        if (LOG_TASKS=== true) {
33
+            $this->logger->log('Processing generateUserPasswordKeys : '.print_r($arguments, true), 'DEBUG');
34
+        }
33 35
         // Generate keys for user passwords   
34 36
         storeUsersShareKey(
35 37
             'sharekeys_items',
@@ -49,7 +51,9 @@  discard block
 block discarded – undo
49 51
      * @param array $taskData
50 52
      */
51 53
     private function generateUserFileKeys($taskData) {    
52
-        if (LOG_TASKS=== true) $this->logger->log('Processing generateUserFileKeys : '.print_r($taskData, true), 'DEBUG');
54
+        if (LOG_TASKS=== true) {
55
+            $this->logger->log('Processing generateUserFileKeys : '.print_r($taskData, true), 'DEBUG');
56
+        }
53 57
         foreach($taskData['files_keys'] as $file) {
54 58
             storeUsersShareKey(
55 59
                 'sharekeys_files',
@@ -70,7 +74,9 @@  discard block
 block discarded – undo
70 74
      * @param array $arguments
71 75
      */
72 76
     private function generateUserFieldKeys($arguments) {
73
-        if (LOG_TASKS=== true) $this->logger->log('Processing generateUserFieldKeys : '.print_r($arguments, true), 'DEBUG');
77
+        if (LOG_TASKS=== true) {
78
+            $this->logger->log('Processing generateUserFieldKeys : '.print_r($arguments, true), 'DEBUG');
79
+        }
74 80
         foreach($arguments['fields_keys'] as $field) {
75 81
             $this->logger->log('Processing generateUserFieldKeys for: ' . $field['object_id'], 'DEBUG');
76 82
             storeUsersShareKey(
Please login to merge, or discard this patch.
sources/main.functions.php 1 patch
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -2604,7 +2604,9 @@  discard block
 block discarded – undo
2604 2604
 function encryptUserObjectKey(string $key, string $publicKey): string
2605 2605
 {
2606 2606
     // Empty password
2607
-    if (empty($key)) return '';
2607
+    if (empty($key)) {
2608
+        return '';
2609
+    }
2608 2610
 
2609 2611
     // Sanitize
2610 2612
     $antiXss = new AntiXSS();
@@ -2753,7 +2755,9 @@  discard block
 block discarded – undo
2753 2755
         ];
2754 2756
     }
2755 2757
 
2756
-    if (WIP) error_log('DEBUG: File image url -> '.filter_var($safeFilePath, FILTER_SANITIZE_URL));
2758
+    if (WIP) {
2759
+        error_log('DEBUG: File image url -> '.filter_var($safeFilePath, FILTER_SANITIZE_URL));
2760
+    }
2757 2761
 
2758 2762
     // Decrypt file content and return
2759 2763
     return base64_encode($cipher->decrypt($ciphertext));
@@ -4232,7 +4236,9 @@  discard block
 block discarded – undo
4232 4236
         $taskName = [$taskName];
4233 4237
     }
4234 4238
     foreach($taskName as $task) {
4235
-        if (WIP === true) error_log('createTaskForItem - task: '.$task);
4239
+        if (WIP === true) {
4240
+            error_log('createTaskForItem - task: '.$task);
4241
+        }
4236 4242
         switch ($task) {
4237 4243
             case 'item_password':
4238 4244
                 
@@ -4665,19 +4671,22 @@  discard block
 block discarded – undo
4665 4671
 
4666 4672
             // Organisation name (removed username@ and .tld)
4667 4673
             $domain = explode('.', $emailParts[1]);
4668
-            if (count($domain) > 1)
4669
-                $forbiddenWords[] = $domain[0];
4674
+            if (count($domain) > 1) {
4675
+                            $forbiddenWords[] = $domain[0];
4676
+            }
4670 4677
         }
4671 4678
     }
4672 4679
 
4673 4680
     // Search forbidden words in password
4674 4681
     foreach ($forbiddenWords as $word) {
4675
-        if (empty($word))
4676
-            continue;
4682
+        if (empty($word)) {
4683
+                    continue;
4684
+        }
4677 4685
 
4678 4686
         // Stop if forbidden word found in password
4679
-        if (stripos($password, $word) !== false)
4680
-            return false;
4687
+        if (stripos($password, $word) !== false) {
4688
+                    return false;
4689
+        }
4681 4690
     }
4682 4691
 
4683 4692
     // Get password complexity
Please login to merge, or discard this patch.