Passed
Pull Request — master (#4676)
by Nils
10:05 queued 03:59
created
scripts/background_tasks___worker.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 require_once __DIR__.'/traits/ItemHandlerTrait.php';
33 33
 require_once __DIR__.'/traits/UserHandlerTrait.php';
34 34
 require_once __DIR__.'/traits/EmailTrait.php';
35
-require_once __DIR__ . '/taskLogger.php';
35
+require_once __DIR__.'/taskLogger.php';
36 36
 
37 37
 class TaskWorker {
38 38
     use ItemHandlerTrait;
@@ -64,7 +64,7 @@  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) $this->logger->log('Processing task: '.print_r($this->taskData, true), 'DEBUG');
68 68
             // Dispatch selon le type de processus
69 69
             switch ($this->processType) {
70 70
                 case 'item_copy':
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
             $arguments = '';
137 137
         }
138 138
 
139
-        if (LOG_TASKS=== true) $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG');
139
+        if (LOG_TASKS === true) $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG');
140 140
 
141 141
         // Add 'arguments' only if not empty
142 142
         if (!empty($arguments)) {
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
             'increment_id = %i',
151 151
             $this->taskId
152 152
         );
153
-        if (LOG_TASKS=== true) $this->logger->log('Finishing task: ' . $this->taskId, 'DEBUG');
153
+        if (LOG_TASKS === true) $this->logger->log('Finishing task: '.$this->taskId, 'DEBUG');
154 154
     }
155 155
 
156 156
     /**
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
             'increment_id = %i',
174 174
             $this->taskId
175 175
         );
176
-        $this->logger->log('Task failure: ' . $e->getMessage(), 'ERROR');
176
+        $this->logger->log('Task failure: '.$e->getMessage(), 'ERROR');
177 177
     }
178 178
 
179 179
     /**
@@ -185,16 +185,16 @@  discard block
 block discarded – undo
185 185
      * @return void
186 186
      */
187 187
     private function processSubTasks($arguments) {
188
-        if (LOG_TASKS=== true) $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG');
188
+        if (LOG_TASKS === true) $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG');
189 189
         // Get all subtasks related to this task
190 190
         $subtasks = DB::query(
191
-            'SELECT * FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC',
191
+            'SELECT * FROM '.prefixTable('background_subtasks').' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC',
192 192
             $this->taskId
193 193
         );
194 194
     
195 195
         // Check if there are any subtasks to process
196 196
         if (empty($subtasks)) {
197
-            if (LOG_TASKS=== true) $this->logger->log('No subtask was found for task: ' . $this->taskId, 'DEBUG');
197
+            if (LOG_TASKS === true) $this->logger->log('No subtask was found for task: '.$this->taskId, 'DEBUG');
198 198
             return;
199 199
         }
200 200
     
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
                 // Get the subtask data
205 205
                 $subtaskData = json_decode($subtask['task'], true);
206 206
 
207
-                if (LOG_TASKS=== true) $this->logger->log('Processing subtask: ' . $subtaskData['step'], 'DEBUG');
207
+                if (LOG_TASKS === true) $this->logger->log('Processing subtask: '.$subtaskData['step'], 'DEBUG');
208 208
 
209 209
                 // Process the subtask based on its type
210 210
                 switch ($subtaskData['step'] ?? '') {
@@ -248,13 +248,13 @@  discard block
 block discarded – undo
248 248
                     $subtask['increment_id']
249 249
                 );
250 250
         
251
-                $this->logger->log('processSubTasks : ' . $e->getMessage(), 'ERROR');
251
+                $this->logger->log('processSubTasks : '.$e->getMessage(), 'ERROR');
252 252
             }
253 253
         }
254 254
     
255 255
         // Are all subtasks completed?
256 256
         $remainingSubtasks = DB::queryFirstField(
257
-            'SELECT COUNT(*) FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0',
257
+            'SELECT COUNT(*) FROM '.prefixTable('background_subtasks').' WHERE task_id = %i AND is_in_progress = 0',
258 258
             $this->taskId
259 259
         );
260 260
     
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
     error_log("Usage: php background_tasks___worker.php <task_id> <process_type> [<task_data>]");
271 271
     exit(1);
272 272
 }
273
-$taskId = (int)$argv[1];
273
+$taskId = (int) $argv[1];
274 274
 $processType = $argv[2];
275 275
 $taskData = $argv[3] ?? null;
276 276
 if ($taskData) {
Please login to merge, or discard this 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
                 // Process the subtask based on its type
210 222
                 switch ($subtaskData['step'] ?? '') {
Please login to merge, or discard this patch.
scripts/background_tasks___handler.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 use TeampassClasses\ConfigManager\ConfigManager;
31 31
 
32 32
 require_once __DIR__.'/../sources/main.functions.php';
33
-require_once __DIR__ . '/taskLogger.php';
33
+require_once __DIR__.'/taskLogger.php';
34 34
 
35 35
 class BackgroundTasksHandler {
36 36
     private $settings;
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     public function processBackgroundTasks() {
56 56
         // Prevent multiple concurrent executions
57 57
         if (!$this->acquireProcessLock()) {
58
-            if (LOG_TASKS=== true) $this->logger->log('Process already running', 'INFO');
58
+            if (LOG_TASKS === true) $this->logger->log('Process already running', 'INFO');
59 59
             return false;
60 60
         }
61 61
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
             $this->processTaskBatches();
65 65
             $this->performMaintenanceTasks();
66 66
         } catch (Exception $e) {
67
-            if (LOG_TASKS=== true) $this->logger->log('Task processing error: ' . $e->getMessage(), 'ERROR');
67
+            if (LOG_TASKS === true) $this->logger->log('Task processing error: '.$e->getMessage(), 'ERROR');
68 68
         } finally {
69 69
             $this->releaseProcessLock();
70 70
         }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             return false;
84 84
         }
85 85
         
86
-        fwrite($fp, (string)getmypid());
86
+        fwrite($fp, (string) getmypid());
87 87
         return true;
88 88
     }
89 89
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     private function cleanupStaleTasks() {
102 102
         // Mark tasks as failed if they've been running too long
103 103
         DB::query(
104
-            'UPDATE ' . prefixTable('background_tasks') . ' 
104
+            'UPDATE '.prefixTable('background_tasks').' 
105 105
             SET is_in_progress = -1, 
106 106
                 finished_at = %i, 
107 107
                 status = "failed"
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
 
114 114
         // Remove very old failed tasks
115 115
         DB::query(
116
-            'DELETE t, st FROM ' . prefixTable('background_tasks') . ' t
117
-            INNER JOIN ' . prefixTable('background_subtasks') . ' st ON (t.increment_id = st.task_id)
116
+            'DELETE t, st FROM '.prefixTable('background_tasks').' t
117
+            INNER JOIN ' . prefixTable('background_subtasks').' st ON (t.increment_id = st.task_id)
118 118
             WHERE t.finished_at > %i 
119 119
             AND t.status = %s',
120 120
             time() - $this->maxTimeBeforeRemoval,
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
         
132 132
         // Check if the maximum number of parallel tasks is reached
133 133
         if ($runningTasks >= $this->maxParallelTasks) {
134
-            if (LOG_TASKS=== true) $this->logger->log('Wait ... '.$runningTasks.' out of '.$this->maxParallelTasks.' are already running ', 'INFO');
134
+            if (LOG_TASKS === true) $this->logger->log('Wait ... '.$runningTasks.' out of '.$this->maxParallelTasks.' are already running ', 'INFO');
135 135
             return;
136 136
         }
137 137
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         // Fetch next batch of tasks
141 141
         $tasks = DB::query(
142 142
             'SELECT increment_id, process_type, arguments 
143
-            FROM ' . prefixTable('background_tasks') . '
143
+            FROM ' . prefixTable('background_tasks').'
144 144
             WHERE is_in_progress = 0 
145 145
             AND (finished_at IS NULL OR finished_at = "")
146 146
             ORDER BY increment_id ASC
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         );
150 150
 
151 151
         foreach ($tasks as $task) {
152
-            if (LOG_TASKS=== true) $this->logger->log('Launching '.$task['increment_id'], 'INFO');
152
+            if (LOG_TASKS === true) $this->logger->log('Launching '.$task['increment_id'], 'INFO');
153 153
             $this->processIndividualTask($task);
154 154
         }
155 155
     }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      * @param array $task The task to process.
161 161
      */
162 162
     private function processIndividualTask(array $task) {
163
-        if (LOG_TASKS=== true)  $this->logger->log('Starting task: ' . print_r($task, true), 'INFO');
163
+        if (LOG_TASKS === true)  $this->logger->log('Starting task: '.print_r($task, true), 'INFO');
164 164
 
165 165
         // Store progress in the database        
166 166
         DB::update(
@@ -177,18 +177,18 @@  discard block
 block discarded – undo
177 177
         // Prepare process
178 178
         $process = new Process([
179 179
             PHP_BINARY,
180
-            __DIR__ . '/background_tasks___worker.php',
180
+            __DIR__.'/background_tasks___worker.php',
181 181
             $task['increment_id'],
182 182
             $task['process_type'],
183 183
             $task['arguments']
184 184
         ]);
185 185
 
186 186
         // Launch process
187
-        try{
187
+        try {
188 188
             $process->mustRun();
189 189
 
190 190
         } catch (Exception $e) {
191
-            if (LOG_TASKS=== true) $this->logger->log('Error launching task: ' . $e->getMessage(), 'ERROR');
191
+            if (LOG_TASKS === true) $this->logger->log('Error launching task: '.$e->getMessage(), 'ERROR');
192 192
             DB::update(
193 193
                 prefixTable('background_tasks'),
194 194
                 [
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
     private function countRunningTasks(): int {
210 210
         return DB::queryFirstField(
211 211
             'SELECT COUNT(*) 
212
-            FROM ' . prefixTable('background_tasks') . ' 
212
+            FROM ' . prefixTable('background_tasks').' 
213 213
             WHERE is_in_progress = 1'
214 214
         );
215 215
     }
@@ -230,10 +230,10 @@  discard block
 block discarded – undo
230 230
      */
231 231
     private function cleanMultipleItemsEdition() {
232 232
         DB::query(
233
-            'DELETE i1 FROM ' . prefixTable('items_edition') . ' i1
233
+            'DELETE i1 FROM '.prefixTable('items_edition').' i1
234 234
             JOIN (
235 235
                 SELECT user_id, item_id, MIN(timestamp) AS oldest_timestamp
236
-                FROM ' . prefixTable('items_edition') . '
236
+                FROM ' . prefixTable('items_edition').'
237 237
                 GROUP BY user_id, item_id
238 238
             ) i2 ON i1.user_id = i2.user_id AND i1.item_id = i2.item_id
239 239
             WHERE i1.timestamp > i2.oldest_timestamp'
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
      */
247 247
     private function handleItemTokensExpiration() {
248 248
         DB::query(
249
-            'DELETE FROM ' . prefixTable('items_edition') . '
249
+            'DELETE FROM '.prefixTable('items_edition').'
250 250
             WHERE timestamp < %i',
251 251
             time() - ($this->settings['delay_item_edition'] * 60 ?: EDITION_LOCK_PERIOD)
252 252
         );
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
         // 1. Get all finished tasks older than the cutoff timestamp
264 264
         //    and that are not in progress
265 265
         $tasks = DB::query(
266
-            'SELECT increment_id FROM ' . prefixTable('background_tasks') . '
266
+            'SELECT increment_id FROM '.prefixTable('background_tasks').'
267 267
             WHERE status = %s AND is_in_progress = %i AND finished_at < %s',
268 268
             'completed',
269 269
             -1,
@@ -278,19 +278,19 @@  discard block
 block discarded – undo
278 278
     
279 279
         // 2. Delete all subtasks related to these tasks
280 280
         DB::query(
281
-            'DELETE FROM ' . prefixTable('background_subtasks') . '
281
+            'DELETE FROM '.prefixTable('background_subtasks').'
282 282
             WHERE task_id IN %ls',
283 283
             $taskIds
284 284
         );
285 285
     
286 286
         // 3. Delete the tasks themselves
287 287
         DB::query(
288
-            'DELETE FROM ' . prefixTable('background_tasks') . '
288
+            'DELETE FROM '.prefixTable('background_tasks').'
289 289
             WHERE increment_id IN %ls',
290 290
             $taskIds
291 291
         );
292 292
     
293
-        if (LOG_TASKS=== true) $this->logger->log('Old finished tasks cleaned: ' . count($taskIds), 'INFO');
293
+        if (LOG_TASKS === true) $this->logger->log('Old finished tasks cleaned: '.count($taskIds), 'INFO');
294 294
     }
295 295
 }
296 296
 
@@ -304,5 +304,5 @@  discard block
 block discarded – undo
304 304
     $tasksHandler = new BackgroundTasksHandler($settings);
305 305
     $tasksHandler->processBackgroundTasks();
306 306
 } catch (Exception $e) {
307
-    error_log('Teampass Background Tasks Error: ' . $e->getMessage());
307
+    error_log('Teampass Background Tasks Error: '.$e->getMessage());
308 308
 }
309 309
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +21 added lines, -7 removed lines patch added patch discarded remove patch
@@ -55,7 +55,9 @@  discard block
 block discarded – undo
55 55
     public function processBackgroundTasks() {
56 56
         // Prevent multiple concurrent executions
57 57
         if (!$this->acquireProcessLock()) {
58
-            if (LOG_TASKS=== true) $this->logger->log('Process already running', 'INFO');
58
+            if (LOG_TASKS=== true) {
59
+                $this->logger->log('Process already running', 'INFO');
60
+            }
59 61
             return false;
60 62
         }
61 63
 
@@ -64,7 +66,9 @@  discard block
 block discarded – undo
64 66
             $this->processTaskBatches();
65 67
             $this->performMaintenanceTasks();
66 68
         } catch (Exception $e) {
67
-            if (LOG_TASKS=== true) $this->logger->log('Task processing error: ' . $e->getMessage(), 'ERROR');
69
+            if (LOG_TASKS=== true) {
70
+                $this->logger->log('Task processing error: ' . $e->getMessage(), 'ERROR');
71
+            }
68 72
         } finally {
69 73
             $this->releaseProcessLock();
70 74
         }
@@ -131,7 +135,9 @@  discard block
 block discarded – undo
131 135
         
132 136
         // Check if the maximum number of parallel tasks is reached
133 137
         if ($runningTasks >= $this->maxParallelTasks) {
134
-            if (LOG_TASKS=== true) $this->logger->log('Wait ... '.$runningTasks.' out of '.$this->maxParallelTasks.' are already running ', 'INFO');
138
+            if (LOG_TASKS=== true) {
139
+                $this->logger->log('Wait ... '.$runningTasks.' out of '.$this->maxParallelTasks.' are already running ', 'INFO');
140
+            }
135 141
             return;
136 142
         }
137 143
 
@@ -149,7 +155,9 @@  discard block
 block discarded – undo
149 155
         );
150 156
 
151 157
         foreach ($tasks as $task) {
152
-            if (LOG_TASKS=== true) $this->logger->log('Launching '.$task['increment_id'], 'INFO');
158
+            if (LOG_TASKS=== true) {
159
+                $this->logger->log('Launching '.$task['increment_id'], 'INFO');
160
+            }
153 161
             $this->processIndividualTask($task);
154 162
         }
155 163
     }
@@ -160,7 +168,9 @@  discard block
 block discarded – undo
160 168
      * @param array $task The task to process.
161 169
      */
162 170
     private function processIndividualTask(array $task) {
163
-        if (LOG_TASKS=== true)  $this->logger->log('Starting task: ' . print_r($task, true), 'INFO');
171
+        if (LOG_TASKS=== true) {
172
+            $this->logger->log('Starting task: ' . print_r($task, true), 'INFO');
173
+        }
164 174
 
165 175
         // Store progress in the database        
166 176
         DB::update(
@@ -188,7 +198,9 @@  discard block
 block discarded – undo
188 198
             $process->mustRun();
189 199
 
190 200
         } catch (Exception $e) {
191
-            if (LOG_TASKS=== true) $this->logger->log('Error launching task: ' . $e->getMessage(), 'ERROR');
201
+            if (LOG_TASKS=== true) {
202
+                $this->logger->log('Error launching task: ' . $e->getMessage(), 'ERROR');
203
+            }
192 204
             DB::update(
193 205
                 prefixTable('background_tasks'),
194 206
                 [
@@ -290,7 +302,9 @@  discard block
 block discarded – undo
290 302
             $taskIds
291 303
         );
292 304
     
293
-        if (LOG_TASKS=== true) $this->logger->log('Old finished tasks cleaned: ' . count($taskIds), 'INFO');
305
+        if (LOG_TASKS=== true) {
306
+            $this->logger->log('Old finished tasks cleaned: ' . count($taskIds), 'INFO');
307
+        }
294 308
     }
295 309
 }
296 310
 
Please login to merge, or discard this patch.
sources/folders.queries.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -137,14 +137,14 @@  discard block
 block discarded – undo
137 137
                     && $t->personal_folder == 0
138 138
                 ) {
139 139
                     // get $t->parent_id
140
-                    $data = DB::queryFirstRow('SELECT title FROM ' . prefixTable('nested_tree') . ' WHERE id = %i', $t->parent_id);
140
+                    $data = DB::queryFirstRow('SELECT title FROM '.prefixTable('nested_tree').' WHERE id = %i', $t->parent_id);
141 141
                     if ($t->nlevel == 1) {
142 142
                         $data['title'] = $lang->get('root');
143 143
                     }
144 144
 
145 145
                     // get rights on this folder
146 146
                     $arrayRights = array();
147
-                    $rows = DB::query('SELECT fonction_id  FROM ' . prefixTable('rights') . ' WHERE authorized=%i AND tree_id = %i', 1, $t->id);
147
+                    $rows = DB::query('SELECT fonction_id  FROM '.prefixTable('rights').' WHERE authorized=%i AND tree_id = %i', 1, $t->id);
148 148
                     foreach ($rows as $record) {
149 149
                         array_push($arrayRights, $record['fonction_id']);
150 150
                     }
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
                         'SELECT m.valeur AS valeur, n.renewal_period AS renewal_period,
163 163
                         n.bloquer_creation AS bloquer_creation, n.bloquer_modification AS bloquer_modification,
164 164
                         n.fa_icon, n.fa_icon_selected
165
-                        FROM ' . prefixTable('misc') . ' AS m,
166
-                        ' . prefixTable('nested_tree') . ' AS n
165
+                        FROM ' . prefixTable('misc').' AS m,
166
+                        ' . prefixTable('nested_tree').' AS n
167 167
                         WHERE m.type=%s AND m.intitule = n.id AND m.intitule = %i',
168 168
                         'complex',
169 169
                         $t->id
@@ -191,16 +191,16 @@  discard block
 block discarded – undo
191 191
                         $arrayColumns['folderComplexity'] = '';
192 192
                     }
193 193
 
194
-                    if (is_null($node_data)=== false) {
194
+                    if (is_null($node_data) === false) {
195 195
                         $arrayColumns['renewalPeriod'] = (int) $node_data['renewal_period'];
196 196
                     } else {
197
-                        $arrayColumns['renewalPeriod']=0;
197
+                        $arrayColumns['renewalPeriod'] = 0;
198 198
                     }
199 199
 
200 200
                     //col7
201 201
                     $data7 = DB::queryFirstRow(
202 202
                         'SELECT bloquer_creation,bloquer_modification
203
-                        FROM ' . prefixTable('nested_tree') . '
203
+                        FROM ' . prefixTable('nested_tree').'
204 204
                         WHERE id = %i',
205 205
                         intval($t->id)
206 206
                     );
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
             // Get info about this folder
359 359
             $dataFolder = DB::queryFirstRow(
360 360
                 'SELECT *
361
-                FROM ' . prefixTable('nested_tree') . '
361
+                FROM ' . prefixTable('nested_tree').'
362 362
                 WHERE id = %i',
363 363
                 $inputData['id']
364 364
             );
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
             //check if parent folder is personal
395 395
             $dataParent = DB::queryFirstRow(
396 396
                 'SELECT personal_folder, bloquer_creation, bloquer_modification
397
-                FROM ' . prefixTable('nested_tree') . '
397
+                FROM ' . prefixTable('nested_tree').'
398 398
                 WHERE id = %i',
399 399
                 $inputData['parentId']
400 400
             );
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
                     // get complexity level for this folder
424 424
                     $data = DB::queryFirstRow(
425 425
                         'SELECT valeur
426
-                        FROM ' . prefixTable('misc') . '
426
+                        FROM ' . prefixTable('misc').'
427 427
                         WHERE intitule = %i AND type = %s',
428 428
                         $inputData['parentId'],
429 429
                         'complex'
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
                             array(
435 435
                                 'error' => true,
436 436
                                 'message' => $lang->get('error_folder_complexity_lower_than_top_folder')
437
-                                    . ' [<b>' . TP_PW_COMPLEXITY[$data['valeur']][1] . '</b>]',
437
+                                    . ' [<b>'.TP_PW_COMPLEXITY[$data['valeur']][1].'</b>]',
438 438
                             ),
439 439
                             'encode'
440 440
                         );
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
             // Check if parent folder is personal
595 595
             $dataParent = DB::queryFirstRow(
596 596
                 'SELECT personal_folder
597
-                FROM ' . prefixTable('nested_tree') . '
597
+                FROM ' . prefixTable('nested_tree').'
598 598
                 WHERE id = %i',
599 599
                 $inputData['parentId']
600 600
             );
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
             echo prepareExchangedData(
635 635
                 array(
636 636
                     'error' => $creationStatus['error'],
637
-                    'message' => $creationStatus['error'] === true ? $lang->get('error_not_allowed_to') : $lang->get('folder_created') ,
637
+                    'message' => $creationStatus['error'] === true ? $lang->get('error_not_allowed_to') : $lang->get('folder_created'),
638 638
                     'newId' => $creationStatus['newId'],
639 639
                 ),
640 640
                 'encode'
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
                 echo prepareExchangedData(
683 683
                     array(
684 684
                         'error' => true,
685
-                        'message' => $lang->get('error_not_allowed_to'). " (You can't delete the root folder)",
685
+                        'message' => $lang->get('error_not_allowed_to')." (You can't delete the root folder)",
686 686
                     ),
687 687
                     'encode'
688 688
                 );
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
             // Ensure that user has access to all folders
693 693
             $foldersAccessible = DB::query(
694 694
                 'SELECT id
695
-                FROM ' . prefixTable('nested_tree') . '
695
+                FROM ' . prefixTable('nested_tree').'
696 696
                 WHERE id IN %li AND id IN %li',
697 697
                 $post_folders,
698 698
                 $session->get('user-accessible_folders')
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
                 echo prepareExchangedData(
707 707
                     array(
708 708
                         'error' => true,
709
-                        'message' => $lang->get('error_not_allowed_to') . ' (The following folders are not accessible or do not exist: ' . implode(', ', $missingFolders) . ')',
709
+                        'message' => $lang->get('error_not_allowed_to').' (The following folders are not accessible or do not exist: '.implode(', ', $missingFolders).')',
710 710
                     ),
711 711
                     'encode'
712 712
                 );
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
                 // Check if parent folder is personal
724 724
                 $dataParent = DB::queryFirstRow(
725 725
                     'SELECT personal_folder
726
-                    FROM ' . prefixTable('nested_tree') . '
726
+                    FROM ' . prefixTable('nested_tree').'
727 727
                     WHERE id = %i',
728 728
                     $folderId
729 729
                 );
@@ -769,10 +769,10 @@  discard block
 block discarded – undo
769 769
                                 prefixTable('misc'),
770 770
                                 array(
771 771
                                     'type' => 'folder_deleted',
772
-                                    'intitule' => 'f' . $thisSubFolders->id,
773
-                                    'valeur' => $thisSubFolders->id . ', ' . $thisSubFolders->parent_id . ', ' .
774
-                                        $thisSubFolders->title . ', ' . $thisSubFolders->nleft . ', ' . $thisSubFolders->nright . ', ' .
775
-                                        $thisSubFolders->nlevel . ', 0, 0, 0, 0',
772
+                                    'intitule' => 'f'.$thisSubFolders->id,
773
+                                    'valeur' => $thisSubFolders->id.', '.$thisSubFolders->parent_id.', '.
774
+                                        $thisSubFolders->title.', '.$thisSubFolders->nleft.', '.$thisSubFolders->nright.', '.
775
+                                        $thisSubFolders->nlevel.', 0, 0, 0, 0',
776 776
                                     'created_at' => time(),
777 777
                                 )
778 778
                             );
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 
782 782
                             //delete items & logs
783 783
                             $itemsInSubFolder = DB::query(
784
-                                'SELECT id FROM ' . prefixTable('items') . ' 
784
+                                'SELECT id FROM '.prefixTable('items').' 
785 785
                                 WHERE id_tree=%i', 
786 786
                                 $thisSubFolders->id
787 787
                             );
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
                                 }
812 812
 
813 813
                                 //Update CACHE table
814
-                                updateCacheTable('delete_value',(int) $item['id']);
814
+                                updateCacheTable('delete_value', (int) $item['id']);
815 815
                             }
816 816
 
817 817
                             //Actualize the variable
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
             // Check if target parent folder is personal
919 919
             $dataParent = DB::queryFirstRow(
920 920
                 'SELECT personal_folder
921
-                FROM ' . prefixTable('nested_tree') . '
921
+                FROM ' . prefixTable('nested_tree').'
922 922
                 WHERE id = %i',
923 923
                 $post_target_folder_id
924 924
             );
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
                 // get complexity of current node
973 973
                 $nodeComplexity = DB::queryFirstRow(
974 974
                     'SELECT valeur
975
-                    FROM ' . prefixTable('misc') . '
975
+                    FROM ' . prefixTable('misc').'
976 976
                     WHERE intitule = %i AND type= %s',
977 977
                     $nodeInfo->id,
978 978
                     'complex'
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
                 // If it is a subfolder, then give access to it for all roles that allows the parent folder
1050 1050
                 $rows = DB::query(
1051 1051
                     'SELECT role_id, type
1052
-                    FROM ' . prefixTable('roles_values') . '
1052
+                    FROM ' . prefixTable('roles_values').'
1053 1053
                     WHERE folder_id = %i',
1054 1054
                     $parentId
1055 1055
                 );
@@ -1057,7 +1057,7 @@  discard block
 block discarded – undo
1057 1057
                     // Add access to this subfolder after checking that it is not already set
1058 1058
                     DB::query(
1059 1059
                         'SELECT *
1060
-                        FROM ' . prefixTable('roles_values') . '
1060
+                        FROM ' . prefixTable('roles_values').'
1061 1061
                         WHERE folder_id = %i AND role_id = %i',
1062 1062
                         $newFolderId,
1063 1063
                         $record['role_id']
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
                 // if parent folder has Custom Fields Categories then add to this child one too
1078 1078
                 $rows = DB::query(
1079 1079
                     'SELECT id_category
1080
-                    FROM ' . prefixTable('categories_folders') . '
1080
+                    FROM ' . prefixTable('categories_folders').'
1081 1081
                     WHERE id_folder = %i',
1082 1082
                     $nodeInfo->id
1083 1083
                 );
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
 
1097 1097
                 $rows = DB::query(
1098 1098
                     'SELECT *
1099
-                    FROM ' . prefixTable('items') . '
1099
+                    FROM ' . prefixTable('items').'
1100 1100
                     WHERE id_tree = %i',
1101 1101
                     $nodeInfo->id
1102 1102
                 );
@@ -1105,7 +1105,7 @@  discard block
 block discarded – undo
1105 1105
                     // if it is then don't copy it
1106 1106
                     $item_deleted = DB::queryFirstRow(
1107 1107
                         'SELECT *
1108
-                        FROM ' . prefixTable('log_items') . '
1108
+                        FROM ' . prefixTable('log_items').'
1109 1109
                         WHERE id_item = %i AND action = %s
1110 1110
                         ORDER BY date DESC
1111 1111
                         LIMIT 0, 1',
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
 
1117 1117
                     $item_restored = DB::queryFirstRow(
1118 1118
                         'SELECT *
1119
-                        FROM ' . prefixTable('log_items') . '
1119
+                        FROM ' . prefixTable('log_items').'
1120 1120
                         WHERE id_item = %i AND action = %s
1121 1121
                         ORDER BY date DESC
1122 1122
                         LIMIT 0, 1',
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
                         // Get the ITEM object key for the user
1132 1132
                         $userKey = DB::queryFirstRow(
1133 1133
                             'SELECT share_key
1134
-                            FROM ' . prefixTable('sharekeys_items') . '
1134
+                            FROM ' . prefixTable('sharekeys_items').'
1135 1135
                             WHERE user_id = %i AND object_id = %i',
1136 1136
                             $session->get('user-id'),
1137 1137
                             $record['id']
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
                     // Get path
1294 1294
                     $text = '';
1295 1295
                     foreach ($tree->getPath($folder->id, false) as $fld) {
1296
-                        $text .= empty($text) === true ? '     [<i>' . $fld->title : ' > ' . $fld->title;
1296
+                        $text .= empty($text) === true ? '     [<i>'.$fld->title : ' > '.$fld->title;
1297 1297
                     }
1298 1298
 
1299 1299
                     // Save array
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
                             'id' => (int) $folder->id,
1304 1304
                             'label' => $folder->title,
1305 1305
                             'level' => $folder->nlevel,
1306
-                            'path' => empty($text) === true ? '' : $text . '</i>]'
1306
+                            'path' => empty($text) === true ? '' : $text.'</i>]'
1307 1307
                         )
1308 1308
                     );
1309 1309
                 }
Please login to merge, or discard this patch.
sources/main.functions.php 1 patch
Spacing   +160 added lines, -162 removed lines patch added patch discarded remove patch
@@ -134,19 +134,19 @@  discard block
 block discarded – undo
134 134
             $text = Crypto::decrypt($message, $key);
135 135
         }
136 136
     } catch (CryptoException\WrongKeyOrModifiedCiphertextException $ex) {
137
-        error_log('TEAMPASS-Error-Wrong key or modified ciphertext: ' . $ex->getMessage());
137
+        error_log('TEAMPASS-Error-Wrong key or modified ciphertext: '.$ex->getMessage());
138 138
         $err = 'wrong_key_or_modified_ciphertext';
139 139
     } catch (CryptoException\BadFormatException $ex) {
140
-        error_log('TEAMPASS-Error-Bad format exception: ' . $ex->getMessage());
140
+        error_log('TEAMPASS-Error-Bad format exception: '.$ex->getMessage());
141 141
         $err = 'bad_format';
142 142
     } catch (CryptoException\EnvironmentIsBrokenException $ex) {
143
-        error_log('TEAMPASS-Error-Environment: ' . $ex->getMessage());
143
+        error_log('TEAMPASS-Error-Environment: '.$ex->getMessage());
144 144
         $err = 'environment_error';
145 145
     } catch (CryptoException\IOException $ex) {
146
-        error_log('TEAMPASS-Error-IO: ' . $ex->getMessage());
146
+        error_log('TEAMPASS-Error-IO: '.$ex->getMessage());
147 147
         $err = 'io_error';
148 148
     } catch (Exception $ex) {
149
-        error_log('TEAMPASS-Error-Unexpected exception: ' . $ex->getMessage());
149
+        error_log('TEAMPASS-Error-Unexpected exception: '.$ex->getMessage());
150 150
         $err = 'unexpected_error';
151 151
     }
152 152
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
  */
232 232
 function trimElement($chaine, string $element): string
233 233
 {
234
-    if (! empty($chaine)) {
234
+    if (!empty($chaine)) {
235 235
         if (is_array($chaine) === true) {
236 236
             $chaine = implode(';', $chaine);
237 237
         }
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
  */
280 280
 function db_error_handler(array $params): void
281 281
 {
282
-    echo 'Error: ' . $params['error'] . "<br>\n";
283
-    echo 'Query: ' . $params['query'] . "<br>\n";
282
+    echo 'Error: '.$params['error']."<br>\n";
283
+    echo 'Query: '.$params['query']."<br>\n";
284 284
     throw new Exception('Error - Query', 1);
285 285
 }
286 286
 
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
     $session->set('user-forbiden_personal_folders', []);
359 359
     
360 360
     // Get list of Folders
361
-    $rows = DB::query('SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i', 0);
361
+    $rows = DB::query('SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i', 0);
362 362
     foreach ($rows as $record) {
363 363
         array_push($groupesVisibles, $record['id']);
364 364
     }
@@ -368,20 +368,20 @@  discard block
 block discarded – undo
368 368
     // get complete list of ROLES
369 369
     $tmp = explode(';', $idFonctions);
370 370
     $rows = DB::query(
371
-        'SELECT * FROM ' . prefixTable('roles_title') . '
371
+        'SELECT * FROM '.prefixTable('roles_title').'
372 372
         ORDER BY title ASC'
373 373
     );
374 374
     foreach ($rows as $record) {
375
-        if (! empty($record['id']) && ! in_array($record['id'], $tmp)) {
375
+        if (!empty($record['id']) && !in_array($record['id'], $tmp)) {
376 376
             array_push($tmp, $record['id']);
377 377
         }
378 378
     }
379 379
     $session->set('user-roles', implode(';', $tmp));
380 380
     $session->set('user-admin', 1);
381 381
     // Check if admin has created Folders and Roles
382
-    DB::query('SELECT * FROM ' . prefixTable('nested_tree') . '');
382
+    DB::query('SELECT * FROM '.prefixTable('nested_tree').'');
383 383
     $session->set('user-nb_folders', DB::count());
384
-    DB::query('SELECT * FROM ' . prefixTable('roles_title'));
384
+    DB::query('SELECT * FROM '.prefixTable('roles_title'));
385 385
     $session->set('user-nb_roles', DB::count());
386 386
 
387 387
     return true;
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
     // Does this user is allowed to see other items
465 465
     $inc = 0;
466 466
     $rows = DB::query(
467
-        'SELECT id, id_tree FROM ' . prefixTable('items') . '
467
+        'SELECT id, id_tree FROM '.prefixTable('items').'
468 468
             WHERE restricted_to LIKE %ss AND inactif = %s'.
469 469
             (count($allowedFolders) > 0 ? ' AND id_tree NOT IN ('.implode(',', $allowedFolders).')' : ''),
470 470
         $globalsUserId,
@@ -481,8 +481,8 @@  discard block
 block discarded – undo
481 481
     // Check for the users roles if some specific rights exist on items
482 482
     $rows = DB::query(
483 483
         'SELECT i.id_tree, r.item_id
484
-        FROM ' . prefixTable('items') . ' as i
485
-        INNER JOIN ' . prefixTable('restriction_to_roles') . ' as r ON (r.item_id=i.id)
484
+        FROM ' . prefixTable('items').' as i
485
+        INNER JOIN ' . prefixTable('restriction_to_roles').' as r ON (r.item_id=i.id)
486 486
         WHERE i.id_tree <> "" '.
487 487
         (count($userRoles) > 0 ? 'AND r.role_id IN %li ' : '').
488 488
         'ORDER BY i.id_tree ASC',
@@ -536,16 +536,16 @@  discard block
 block discarded – undo
536 536
         ), SORT_NUMERIC)
537 537
     );
538 538
     // Folders and Roles numbers
539
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('nested_tree') . '');
539
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('nested_tree').'');
540 540
     $session->set('user-nb_folders', DB::count());
541
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('roles_title'));
541
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('roles_title'));
542 542
     $session->set('user-nb_roles', DB::count());
543 543
     // check if change proposals on User's items
544 544
     if (isset($SETTINGS['enable_suggestion']) === true && (int) $SETTINGS['enable_suggestion'] === 1) {
545 545
         $countNewItems = DB::query(
546 546
             'SELECT COUNT(*)
547
-            FROM ' . prefixTable('items_change') . ' AS c
548
-            LEFT JOIN ' . prefixTable('log_items') . ' AS i ON (c.item_id = i.id_item)
547
+            FROM ' . prefixTable('items_change').' AS c
548
+            LEFT JOIN ' . prefixTable('log_items').' AS i ON (c.item_id = i.id_item)
549 549
             WHERE i.action = %s AND i.id_user = %i',
550 550
             'at_creation',
551 551
             $globalsUserId
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 {
573 573
     $rows = DB::query(
574 574
         'SELECT *
575
-        FROM ' . prefixTable('roles_values') . '
575
+        FROM ' . prefixTable('roles_values').'
576 576
         WHERE type IN %ls'.(count($userRoles) > 0 ? ' AND role_id IN %li' : ''),
577 577
         ['W', 'ND', 'NE', 'NDNE', 'R'],
578 578
         $userRoles,
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
     ) {
640 640
         $persoFld = DB::queryFirstRow(
641 641
             'SELECT id
642
-            FROM ' . prefixTable('nested_tree') . '
642
+            FROM ' . prefixTable('nested_tree').'
643 643
             WHERE title = %s AND personal_folder = %i'.
644 644
             (count($allowedFolders) > 0 ? ' AND id NOT IN ('.implode(',', $allowedFolders).')' : ''),
645 645
             $globalsUserId,
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
     }
673 673
     $persoFlds = DB::query(
674 674
         'SELECT id
675
-        FROM ' . prefixTable('nested_tree') . '
675
+        FROM ' . prefixTable('nested_tree').'
676 676
         WHERE %l',
677 677
         $where
678 678
     );
@@ -740,12 +740,12 @@  discard block
 block discarded – undo
740 740
     //Load Tree
741 741
     $tree = new NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title');
742 742
     // truncate table
743
-    DB::query('TRUNCATE TABLE ' . prefixTable('cache'));
743
+    DB::query('TRUNCATE TABLE '.prefixTable('cache'));
744 744
     // reload date
745 745
     $rows = DB::query(
746 746
         'SELECT *
747
-        FROM ' . prefixTable('items') . ' as i
748
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
747
+        FROM ' . prefixTable('items').' as i
748
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
749 749
         AND l.action = %s
750 750
         AND i.inactif = %i',
751 751
         'at_creation',
@@ -757,18 +757,18 @@  discard block
 block discarded – undo
757 757
             $tags = '';
758 758
             $itemTags = DB::query(
759 759
                 'SELECT tag
760
-                FROM ' . prefixTable('tags') . '
760
+                FROM ' . prefixTable('tags').'
761 761
                 WHERE item_id = %i AND tag != ""',
762 762
                 $record['id']
763 763
             );
764 764
             foreach ($itemTags as $itemTag) {
765
-                $tags .= $itemTag['tag'] . ' ';
765
+                $tags .= $itemTag['tag'].' ';
766 766
             }
767 767
 
768 768
             // Get renewal period
769 769
             $resNT = DB::queryFirstRow(
770 770
                 'SELECT renewal_period
771
-                FROM ' . prefixTable('nested_tree') . '
771
+                FROM ' . prefixTable('nested_tree').'
772 772
                 WHERE id = %i',
773 773
                 $record['id_tree']
774 774
             );
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
                     // Is this a User id?
782 782
                     $user = DB::queryFirstRow(
783 783
                         'SELECT id, login
784
-                        FROM ' . prefixTable('users') . '
784
+                        FROM ' . prefixTable('users').'
785 785
                         WHERE id = %i',
786 786
                         $elem->title
787 787
                     );
@@ -799,11 +799,11 @@  discard block
 block discarded – undo
799 799
                     'id' => $record['id'],
800 800
                     'label' => $record['label'],
801 801
                     'description' => $record['description'] ?? '',
802
-                    'url' => isset($record['url']) && ! empty($record['url']) ? $record['url'] : '0',
802
+                    'url' => isset($record['url']) && !empty($record['url']) ? $record['url'] : '0',
803 803
                     'tags' => $tags,
804 804
                     'id_tree' => $record['id_tree'],
805 805
                     'perso' => $record['perso'],
806
-                    'restricted_to' => isset($record['restricted_to']) && ! empty($record['restricted_to']) ? $record['restricted_to'] : '0',
806
+                    'restricted_to' => isset($record['restricted_to']) && !empty($record['restricted_to']) ? $record['restricted_to'] : '0',
807 807
                     'login' => $record['login'] ?? '',
808 808
                     'folder' => implode(' > ', $folder),
809 809
                     'author' => $record['id_user'],
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
     // get new value from db
833 833
     $data = DB::queryFirstRow(
834 834
         'SELECT label, description, id_tree, perso, restricted_to, login, url
835
-        FROM ' . prefixTable('items') . '
835
+        FROM ' . prefixTable('items').'
836 836
         WHERE id=%i',
837 837
         $ident
838 838
     );
@@ -840,12 +840,12 @@  discard block
 block discarded – undo
840 840
     $tags = '';
841 841
     $itemTags = DB::query(
842 842
         'SELECT tag
843
-            FROM ' . prefixTable('tags') . '
843
+            FROM ' . prefixTable('tags').'
844 844
             WHERE item_id = %i AND tag != ""',
845 845
         $ident
846 846
     );
847 847
     foreach ($itemTags as $itemTag) {
848
-        $tags .= $itemTag['tag'] . ' ';
848
+        $tags .= $itemTag['tag'].' ';
849 849
     }
850 850
     // form id_tree to full foldername
851 851
     $folder = [];
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
             // Is this a User id?
857 857
             $user = DB::queryFirstRow(
858 858
                 'SELECT id, login
859
-                FROM ' . prefixTable('users') . '
859
+                FROM ' . prefixTable('users').'
860 860
                 WHERE id = %i',
861 861
                 $elem->title
862 862
             );
@@ -874,10 +874,10 @@  discard block
 block discarded – undo
874 874
             'label' => $data['label'],
875 875
             'description' => $data['description'],
876 876
             'tags' => $tags,
877
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
877
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
878 878
             'id_tree' => $data['id_tree'],
879 879
             'perso' => $data['perso'],
880
-            'restricted_to' => isset($data['restricted_to']) && ! empty($data['restricted_to']) ? $data['restricted_to'] : '0',
880
+            'restricted_to' => isset($data['restricted_to']) && !empty($data['restricted_to']) ? $data['restricted_to'] : '0',
881 881
             'login' => $data['login'] ?? '',
882 882
             'folder' => implode(' » ', $folder),
883 883
             'author' => $session->get('user-id'),
@@ -907,8 +907,8 @@  discard block
 block discarded – undo
907 907
     // get new value from db
908 908
     $data = DB::queryFirstRow(
909 909
         'SELECT i.label, i.description, i.id_tree as id_tree, i.perso, i.restricted_to, i.id, i.login, i.url, l.date
910
-        FROM ' . prefixTable('items') . ' as i
911
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
910
+        FROM ' . prefixTable('items').' as i
911
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
912 912
         WHERE i.id = %i
913 913
         AND l.action = %s',
914 914
         $ident,
@@ -918,12 +918,12 @@  discard block
 block discarded – undo
918 918
     $tags = '';
919 919
     $itemTags = DB::query(
920 920
         'SELECT tag
921
-            FROM ' . prefixTable('tags') . '
921
+            FROM ' . prefixTable('tags').'
922 922
             WHERE item_id = %i AND tag != ""',
923 923
         $ident
924 924
     );
925 925
     foreach ($itemTags as $itemTag) {
926
-        $tags .= $itemTag['tag'] . ' ';
926
+        $tags .= $itemTag['tag'].' ';
927 927
     }
928 928
     // form id_tree to full foldername
929 929
     $folder = [];
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
             // Is this a User id?
935 935
             $user = DB::queryFirstRow(
936 936
                 'SELECT id, login
937
-                FROM ' . prefixTable('users') . '
937
+                FROM ' . prefixTable('users').'
938 938
                 WHERE id = %i',
939 939
                 $elem->title
940 940
             );
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
             'label' => $data['label'],
954 954
             'description' => $data['description'],
955 955
             'tags' => empty($tags) === false ? $tags : 'None',
956
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
956
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
957 957
             'id_tree' => $data['id_tree'],
958 958
             'perso' => isset($data['perso']) && empty($data['perso']) === false && $data['perso'] !== 'None' ? $data['perso'] : '0',
959 959
             'restricted_to' => isset($data['restricted_to']) && empty($data['restricted_to']) === false ? $data['restricted_to'] : '0',
@@ -975,53 +975,53 @@  discard block
 block discarded – undo
975 975
 function getStatisticsData(array $SETTINGS): array
976 976
 {
977 977
     DB::query(
978
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
978
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
979 979
         0
980 980
     );
981 981
     $counter_folders = DB::count();
982 982
     DB::query(
983
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
983
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
984 984
         1
985 985
     );
986 986
     $counter_folders_perso = DB::count();
987 987
     DB::query(
988
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
988
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
989 989
         0
990 990
     );
991 991
     $counter_items = DB::count();
992 992
         DB::query(
993
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
993
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
994 994
         1
995 995
     );
996 996
     $counter_items_perso = DB::count();
997 997
         DB::query(
998
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE login NOT IN (%s, %s, %s)',
998
+        'SELECT id FROM '.prefixTable('users').' WHERE login NOT IN (%s, %s, %s)',
999 999
         'OTV', 'TP', 'API'
1000 1000
     );
1001 1001
     $counter_users = DB::count();
1002 1002
         DB::query(
1003
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE admin = %i',
1003
+        'SELECT id FROM '.prefixTable('users').' WHERE admin = %i',
1004 1004
         1
1005 1005
     );
1006 1006
     $admins = DB::count();
1007 1007
     DB::query(
1008
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE gestionnaire = %i',
1008
+        'SELECT id FROM '.prefixTable('users').' WHERE gestionnaire = %i',
1009 1009
         1
1010 1010
     );
1011 1011
     $managers = DB::count();
1012 1012
     DB::query(
1013
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE read_only = %i',
1013
+        'SELECT id FROM '.prefixTable('users').' WHERE read_only = %i',
1014 1014
         1
1015 1015
     );
1016 1016
     $readOnly = DB::count();
1017 1017
     // list the languages
1018 1018
     $usedLang = [];
1019 1019
     $tp_languages = DB::query(
1020
-        'SELECT name FROM ' . prefixTable('languages')
1020
+        'SELECT name FROM '.prefixTable('languages')
1021 1021
     );
1022 1022
     foreach ($tp_languages as $tp_language) {
1023 1023
         DB::query(
1024
-            'SELECT * FROM ' . prefixTable('users') . ' WHERE user_language = %s',
1024
+            'SELECT * FROM '.prefixTable('users').' WHERE user_language = %s',
1025 1025
             $tp_language['name']
1026 1026
         );
1027 1027
         $usedLang[$tp_language['name']] = round((DB::count() * 100 / $counter_users), 0);
@@ -1030,12 +1030,12 @@  discard block
 block discarded – undo
1030 1030
     // get list of ips
1031 1031
     $usedIp = [];
1032 1032
     $tp_ips = DB::query(
1033
-        'SELECT user_ip FROM ' . prefixTable('users')
1033
+        'SELECT user_ip FROM '.prefixTable('users')
1034 1034
     );
1035 1035
     foreach ($tp_ips as $ip) {
1036 1036
         if (array_key_exists($ip['user_ip'], $usedIp)) {
1037 1037
             $usedIp[$ip['user_ip']] += $usedIp[$ip['user_ip']];
1038
-        } elseif (! empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
1038
+        } elseif (!empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
1039 1039
             $usedIp[$ip['user_ip']] = 1;
1040 1040
         }
1041 1041
     }
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
         <table width="600" cellpadding="0" cellspacing="0" border="0" class="container" bgcolor="#ffffff" style="border-spacing: 0; border-bottom: 1px solid #e0e0e0; box-shadow: 0 0 3px #ddd; color: #434343; font-family: Helvetica, Verdana, sans-serif;">
1131 1131
         <tr><td class="container-padding" bgcolor="#ffffff" style="border-collapse: collapse; border-left: 1px solid #e0e0e0; background-color: #ffffff; padding-left: 30px; padding-right: 30px;">
1132 1132
         <br><div style="float:right;">' .
1133
-        $textMail .
1133
+        $textMail.
1134 1134
         '<br><br></td></tr></table>
1135 1135
     </td></tr></table>
1136 1136
     <br></body></html>';
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
 {
1212 1212
     array_walk_recursive(
1213 1213
         $array,
1214
-        static function (&$item): void {
1214
+        static function(&$item): void {
1215 1215
             if (mb_detect_encoding((string) $item, 'utf-8', true) === false) {
1216 1216
                 $item = mb_convert_encoding($item, 'ISO-8859-1', 'UTF-8');
1217 1217
             }
@@ -1322,7 +1322,7 @@  discard block
 block discarded – undo
1322 1322
  */
1323 1323
 function prefixTable(string $table): string
1324 1324
 {
1325
-    $safeTable = htmlspecialchars(DB_PREFIX . $table);
1325
+    $safeTable = htmlspecialchars(DB_PREFIX.$table);
1326 1326
     return $safeTable;
1327 1327
 }
1328 1328
 
@@ -1439,7 +1439,7 @@  discard block
 block discarded – undo
1439 1439
 function send_syslog($message, $host, $port, $component = 'teampass'): void
1440 1440
 {
1441 1441
     $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
1442
-    $syslog_message = '<123>' . date('M d H:i:s ') . $component . ': ' . $message;
1442
+    $syslog_message = '<123>'.date('M d H:i:s ').$component.': '.$message;
1443 1443
     socket_sendto($sock, (string) $syslog_message, strlen($syslog_message), 0, (string) $host, (int) $port);
1444 1444
     socket_close($sock);
1445 1445
 }
@@ -1486,14 +1486,14 @@  discard block
 block discarded – undo
1486 1486
     if (isset($SETTINGS['syslog_enable']) === true && (int) $SETTINGS['syslog_enable'] === 1) {
1487 1487
         if ($type === 'user_mngt') {
1488 1488
             send_syslog(
1489
-                'action=' . str_replace('at_', '', $label) . ' attribute=user user=' . $who . ' userid="' . $login . '" change="' . $field_1 . '" ',
1489
+                'action='.str_replace('at_', '', $label).' attribute=user user='.$who.' userid="'.$login.'" change="'.$field_1.'" ',
1490 1490
                 $SETTINGS['syslog_host'],
1491 1491
                 $SETTINGS['syslog_port'],
1492 1492
                 'teampass'
1493 1493
             );
1494 1494
         } else {
1495 1495
             send_syslog(
1496
-                'action=' . $type . ' attribute=' . $label . ' user=' . $who . ' userid="' . $login . '" ',
1496
+                'action='.$type.' attribute='.$label.' user='.$who.' userid="'.$login.'" ',
1497 1497
                 $SETTINGS['syslog_host'],
1498 1498
                 $SETTINGS['syslog_port'],
1499 1499
                 'teampass'
@@ -1568,7 +1568,7 @@  discard block
 block discarded – undo
1568 1568
         if (empty($item_label) === true) {
1569 1569
             $dataItem = DB::queryFirstRow(
1570 1570
                 'SELECT id, id_tree, label
1571
-                FROM ' . prefixTable('items') . '
1571
+                FROM ' . prefixTable('items').'
1572 1572
                 WHERE id = %i',
1573 1573
                 $item_id
1574 1574
             );
@@ -1576,11 +1576,11 @@  discard block
 block discarded – undo
1576 1576
         }
1577 1577
 
1578 1578
         send_syslog(
1579
-            'action=' . str_replace('at_', '', $action) .
1580
-                ' attribute=' . str_replace('at_', '', $attribute[0]) .
1581
-                ' itemno=' . $item_id .
1582
-                ' user=' . (is_null($login) === true ? '' : addslashes((string) $login)) .
1583
-                ' itemname="' . addslashes($item_label) . '"',
1579
+            'action='.str_replace('at_', '', $action).
1580
+                ' attribute='.str_replace('at_', '', $attribute[0]).
1581
+                ' itemno='.$item_id.
1582
+                ' user='.(is_null($login) === true ? '' : addslashes((string) $login)).
1583
+                ' itemname="'.addslashes($item_label).'"',
1584 1584
             $SETTINGS['syslog_host'],
1585 1585
             $SETTINGS['syslog_port'],
1586 1586
             'teampass'
@@ -1611,8 +1611,8 @@  discard block
 block discarded – undo
1611 1611
     // send email to user that what to be notified
1612 1612
     $notification = DB::queryFirstColumn(
1613 1613
         'SELECT email
1614
-        FROM ' . prefixTable('notification') . ' AS n
1615
-        INNER JOIN ' . prefixTable('users') . ' AS u ON (n.user_id = u.id)
1614
+        FROM ' . prefixTable('notification').' AS n
1615
+        INNER JOIN ' . prefixTable('users').' AS u ON (n.user_id = u.id)
1616 1616
         WHERE n.item_id = %i AND n.user_id != %i',
1617 1617
         $item_id,
1618 1618
         $globalsUserId
@@ -1623,7 +1623,7 @@  discard block
 block discarded – undo
1623 1623
         // Get list of changes
1624 1624
         $htmlChanges = '<ul>';
1625 1625
         foreach ($changes as $change) {
1626
-            $htmlChanges .= '<li>' . $change . '</li>';
1626
+            $htmlChanges .= '<li>'.$change.'</li>';
1627 1627
         }
1628 1628
         $htmlChanges .= '</ul>';
1629 1629
         // send email
@@ -1660,15 +1660,15 @@  discard block
 block discarded – undo
1660 1660
     $path = '';
1661 1661
     foreach ($arbo as $elem) {
1662 1662
         if (empty($path) === true) {
1663
-            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES) . ' ';
1663
+            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES).' ';
1664 1664
         } else {
1665
-            $path .= '&#8594; ' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1665
+            $path .= '&#8594; '.htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1666 1666
         }
1667 1667
     }
1668 1668
 
1669 1669
     // Build text to show user
1670 1670
     if (empty($label) === false) {
1671
-        return empty($path) === true ? addslashes($label) : addslashes($label) . ' (' . $path . ')';
1671
+        return empty($path) === true ? addslashes($label) : addslashes($label).' ('.$path.')';
1672 1672
     }
1673 1673
     return empty($path) === true ? '' : $path;
1674 1674
 }
@@ -1724,7 +1724,7 @@  discard block
 block discarded – undo
1724 1724
 {
1725 1725
     // Perform a copy if the file exists
1726 1726
     if (file_exists($configFilePath)) {
1727
-        $backupFilePath = $configFilePath . '.' . date('Y_m_d_His', time());
1727
+        $backupFilePath = $configFilePath.'.'.date('Y_m_d_His', time());
1728 1728
         if (!copy($configFilePath, $backupFilePath)) {
1729 1729
             return "ERROR: Could not copy file '$configFilePath'";
1730 1730
         }
@@ -1732,10 +1732,10 @@  discard block
 block discarded – undo
1732 1732
 
1733 1733
     // Regenerate the config file
1734 1734
     $data = ["<?php\n", "global \$SETTINGS;\n", "\$SETTINGS = array (\n"];
1735
-    $rows = DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s', 'admin');
1735
+    $rows = DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type=%s', 'admin');
1736 1736
     foreach ($rows as $record) {
1737 1737
         $value = getEncryptedValue($record['valeur'], $record['is_encrypted']);
1738
-        $data[] = "    '{$record['intitule']}' => '". htmlspecialchars_decode($value, ENT_COMPAT) . "',\n";
1738
+        $data[] = "    '{$record['intitule']}' => '".htmlspecialchars_decode($value, ENT_COMPAT)."',\n";
1739 1739
     }
1740 1740
     $data[] = ");\n";
1741 1741
     $data = array_unique($data);
@@ -1780,7 +1780,7 @@  discard block
 block discarded – undo
1780 1780
 {
1781 1781
     global $SETTINGS;
1782 1782
     /* LOAD CPASSMAN SETTINGS */
1783
-    if (! isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
1783
+    if (!isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
1784 1784
         $SETTINGS = [];
1785 1785
         $SETTINGS['duplicate_folder'] = 0;
1786 1786
         //by default, this is set to 0;
@@ -1790,7 +1790,7 @@  discard block
 block discarded – undo
1790 1790
         //by default, this value is set to 5;
1791 1791
         $settings = [];
1792 1792
         $rows = DB::query(
1793
-            'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s_type OR type=%s_type2',
1793
+            'SELECT * FROM '.prefixTable('misc').' WHERE type=%s_type OR type=%s_type2',
1794 1794
             [
1795 1795
                 'type' => 'admin',
1796 1796
                 'type2' => 'settings',
@@ -1822,7 +1822,7 @@  discard block
 block discarded – undo
1822 1822
     $source_cf = [];
1823 1823
     $rows = DB::query(
1824 1824
         'SELECT id_category
1825
-            FROM ' . prefixTable('categories_folders') . '
1825
+            FROM ' . prefixTable('categories_folders').'
1826 1826
             WHERE id_folder = %i',
1827 1827
         $source_id
1828 1828
     );
@@ -1833,7 +1833,7 @@  discard block
 block discarded – undo
1833 1833
     $target_cf = [];
1834 1834
     $rows = DB::query(
1835 1835
         'SELECT id_category
1836
-            FROM ' . prefixTable('categories_folders') . '
1836
+            FROM ' . prefixTable('categories_folders').'
1837 1837
             WHERE id_folder = %i',
1838 1838
         $target_id
1839 1839
     );
@@ -1928,10 +1928,10 @@  discard block
 block discarded – undo
1928 1928
     } catch (CryptoException\WrongKeyOrModifiedCiphertextException $ex) {
1929 1929
         $err = 'wrong_key';
1930 1930
     } catch (CryptoException\EnvironmentIsBrokenException $ex) {
1931
-        error_log('TEAMPASS-Error-Environment: ' . $ex->getMessage());
1931
+        error_log('TEAMPASS-Error-Environment: '.$ex->getMessage());
1932 1932
         $err = 'environment_error';
1933 1933
     } catch (CryptoException\IOException $ex) {
1934
-        error_log('TEAMPASS-Error-General: ' . $ex->getMessage());
1934
+        error_log('TEAMPASS-Error-General: '.$ex->getMessage());
1935 1935
         $err = 'general_error';
1936 1936
     }
1937 1937
 
@@ -1964,10 +1964,10 @@  discard block
 block discarded – undo
1964 1964
     } catch (CryptoException\WrongKeyOrModifiedCiphertextException $ex) {
1965 1965
         $err = 'wrong_key';
1966 1966
     } catch (CryptoException\EnvironmentIsBrokenException $ex) {
1967
-        error_log('TEAMPASS-Error-Environment: ' . $ex->getMessage());
1967
+        error_log('TEAMPASS-Error-Environment: '.$ex->getMessage());
1968 1968
         $err = 'environment_error';
1969 1969
     } catch (CryptoException\IOException $ex) {
1970
-        error_log('TEAMPASS-Error-General: ' . $ex->getMessage());
1970
+        error_log('TEAMPASS-Error-General: '.$ex->getMessage());
1971 1971
         $err = 'general_error';
1972 1972
     }
1973 1973
 
@@ -2053,7 +2053,7 @@  discard block
 block discarded – undo
2053 2053
 ) {
2054 2054
     // Check if the path exists
2055 2055
     $path = basename($path);
2056
-    if (! file_exists($path)) {
2056
+    if (!file_exists($path)) {
2057 2057
         return false;
2058 2058
     }
2059 2059
 
@@ -2106,7 +2106,7 @@  discard block
 block discarded – undo
2106 2106
     // Load item data
2107 2107
     $data = DB::queryFirstRow(
2108 2108
         'SELECT id_tree
2109
-        FROM ' . prefixTable('items') . '
2109
+        FROM ' . prefixTable('items').'
2110 2110
         WHERE id = %i',
2111 2111
         $item_id
2112 2112
     );
@@ -2169,7 +2169,7 @@  discard block
 block discarded – undo
2169 2169
         }
2170 2170
         $host .= substr(explode(".", $email[1])[0], -1, 1);
2171 2171
     }
2172
-    $email = $name . "@" . $host . "." . explode(".", $email[1])[1];
2172
+    $email = $name."@".$host.".".explode(".", $email[1])[1];
2173 2173
     return $email;
2174 2174
 }
2175 2175
 
@@ -2200,11 +2200,11 @@  discard block
 block discarded – undo
2200 2200
 function formatSizeUnits(int $bytes): string
2201 2201
 {
2202 2202
     if ($bytes >= 1073741824) {
2203
-        $bytes = number_format($bytes / 1073741824, 2) . ' GB';
2203
+        $bytes = number_format($bytes / 1073741824, 2).' GB';
2204 2204
     } elseif ($bytes >= 1048576) {
2205
-        $bytes = number_format($bytes / 1048576, 2) . ' MB';
2205
+        $bytes = number_format($bytes / 1048576, 2).' MB';
2206 2206
     } elseif ($bytes >= 1024) {
2207
-        $bytes = number_format($bytes / 1024, 2) . ' KB';
2207
+        $bytes = number_format($bytes / 1024, 2).' KB';
2208 2208
     } elseif ($bytes > 1) {
2209 2209
         $bytes .= ' bytes';
2210 2210
     } elseif ($bytes === 1) {
@@ -2453,7 +2453,7 @@  discard block
 block discarded – undo
2453 2453
     $cipher->enableContinuousBuffer();
2454 2454
 
2455 2455
     // Encrypt the file content
2456
-    $filePath = filter_var($fileInPath . '/' . $fileInName, FILTER_SANITIZE_URL);
2456
+    $filePath = filter_var($fileInPath.'/'.$fileInName, FILTER_SANITIZE_URL);
2457 2457
     $fileContent = file_get_contents($filePath);
2458 2458
     $plaintext = $fileContent;
2459 2459
     $ciphertext = $cipher->encrypt($plaintext);
@@ -2461,9 +2461,9 @@  discard block
 block discarded – undo
2461 2461
     // Save new file
2462 2462
     // deepcode ignore InsecureHash: is simply used to get a unique name
2463 2463
     $hash = uniqid('', true);
2464
-    $fileOut = $fileInPath . '/' . TP_FILE_PREFIX . $hash;
2464
+    $fileOut = $fileInPath.'/'.TP_FILE_PREFIX.$hash;
2465 2465
     file_put_contents($fileOut, $ciphertext);
2466
-    unlink($fileInPath . '/' . $fileInName);
2466
+    unlink($fileInPath.'/'.$fileInName);
2467 2467
     return [
2468 2468
         'fileHash' => base64_encode($hash),
2469 2469
         'objectKey' => base64_encode($objectKey),
@@ -2479,9 +2479,9 @@  discard block
 block discarded – undo
2479 2479
  *
2480 2480
  * @return string|array
2481 2481
  */
2482
-function decryptFile(string $fileName, string $filePath, string $key): string|array
2482
+function decryptFile(string $fileName, string $filePath, string $key): string | array
2483 2483
 {
2484
-    if (! defined('FILE_BUFFER_SIZE')) {
2484
+    if (!defined('FILE_BUFFER_SIZE')) {
2485 2485
         define('FILE_BUFFER_SIZE', 128 * 1024);
2486 2486
     }
2487 2487
     
@@ -2498,7 +2498,7 @@  discard block
 block discarded – undo
2498 2498
     $cipher->enableContinuousBuffer();
2499 2499
     $cipher->disablePadding();
2500 2500
     // Get file content
2501
-    $safeFilePath = realpath($filePath . '/' . TP_FILE_PREFIX . $safeFileName);
2501
+    $safeFilePath = realpath($filePath.'/'.TP_FILE_PREFIX.$safeFileName);
2502 2502
     if ($safeFilePath !== false && file_exists($safeFilePath)) {
2503 2503
         $ciphertext = file_get_contents(filter_var($safeFilePath, FILTER_SANITIZE_URL));
2504 2504
     } else {
@@ -2594,7 +2594,7 @@  discard block
 block discarded – undo
2594 2594
         // Only create the sharekey for a user
2595 2595
         $user = DB::queryFirstRow(
2596 2596
             'SELECT public_key
2597
-            FROM ' . prefixTable('users') . '
2597
+            FROM ' . prefixTable('users').'
2598 2598
             WHERE id = %i
2599 2599
             AND public_key != ""',
2600 2600
             $userId
@@ -2635,7 +2635,7 @@  discard block
 block discarded – undo
2635 2635
         }
2636 2636
         $users = DB::query(
2637 2637
             'SELECT id, public_key
2638
-            FROM ' . prefixTable('users') . '
2638
+            FROM ' . prefixTable('users').'
2639 2639
             WHERE id NOT IN %li
2640 2640
             AND public_key != ""',
2641 2641
             $user_ids
@@ -2644,7 +2644,7 @@  discard block
 block discarded – undo
2644 2644
         foreach ($users as $user) {
2645 2645
             // Insert in DB the new object key for this item by user
2646 2646
             if (count($objectKeyArray) === 0) {
2647
-                if (WIP === true) error_log('TEAMPASS Debug - storeUsersShareKey case1 - ' . $object_name . ' - ' . $post_object_id . ' - ' . $user['id'] . ' - ' . $objectKey);
2647
+                if (WIP === true) error_log('TEAMPASS Debug - storeUsersShareKey case1 - '.$object_name.' - '.$post_object_id.' - '.$user['id'].' - '.$objectKey);
2648 2648
                 DB::insert(
2649 2649
                     $object_name,
2650 2650
                     [
@@ -2658,7 +2658,7 @@  discard block
 block discarded – undo
2658 2658
                 );
2659 2659
             } else {
2660 2660
                 foreach ($objectKeyArray as $object) {
2661
-                    if (WIP === true) error_log('TEAMPASS Debug - storeUsersShareKey case2 - ' . $object_name . ' - ' . $object['objectId'] . ' - ' . $user['id'] . ' - ' . $object['objectKey']);
2661
+                    if (WIP === true) error_log('TEAMPASS Debug - storeUsersShareKey case2 - '.$object_name.' - '.$object['objectId'].' - '.$user['id'].' - '.$object['objectKey']);
2662 2662
                     DB::insert(
2663 2663
                         $object_name,
2664 2664
                         [
@@ -2686,7 +2686,7 @@  discard block
 block discarded – undo
2686 2686
 function isBase64(string $str): bool
2687 2687
 {
2688 2688
     $str = (string) trim($str);
2689
-    if (! isset($str[0])) {
2689
+    if (!isset($str[0])) {
2690 2690
         return false;
2691 2691
     }
2692 2692
 
@@ -2760,7 +2760,7 @@  discard block
 block discarded – undo
2760 2760
     } catch (\LdapRecord\Auth\BindException $e) {
2761 2761
         $error = $e->getDetailedError();
2762 2762
         if ($error && defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
2763
-            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage(). " - ".$error->getDiagnosticMessage());
2763
+            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage()." - ".$error->getDiagnosticMessage());
2764 2764
         }
2765 2765
         // deepcode ignore ServerLeak: No important data is sent
2766 2766
         echo 'An error occurred.';
@@ -2777,7 +2777,7 @@  discard block
 block discarded – undo
2777 2777
     } catch (\LdapRecord\Auth\BindException $e) {
2778 2778
         $error = $e->getDetailedError();
2779 2779
         if ($error && defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
2780
-            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage(). " - ".$error->getDiagnosticMessage());
2780
+            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage()." - ".$error->getDiagnosticMessage());
2781 2781
         }
2782 2782
         // deepcode ignore ServerLeak: No important data is sent
2783 2783
         echo 'An error occurred.';
@@ -2804,7 +2804,7 @@  discard block
 block discarded – undo
2804 2804
     // expect if personal item
2805 2805
     DB::delete(
2806 2806
         prefixTable('sharekeys_items'),
2807
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
2807
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
2808 2808
         $userId
2809 2809
     );
2810 2810
     // Remove all item sharekeys files
@@ -2812,8 +2812,8 @@  discard block
 block discarded – undo
2812 2812
         prefixTable('sharekeys_files'),
2813 2813
         'user_id = %i AND object_id NOT IN (
2814 2814
             SELECT f.id 
2815
-            FROM ' . prefixTable('items') . ' AS i 
2816
-            INNER JOIN ' . prefixTable('files') . ' AS f ON f.id_item = i.id
2815
+            FROM ' . prefixTable('items').' AS i 
2816
+            INNER JOIN ' . prefixTable('files').' AS f ON f.id_item = i.id
2817 2817
             WHERE i.perso = 1
2818 2818
         )',
2819 2819
         $userId
@@ -2823,8 +2823,8 @@  discard block
 block discarded – undo
2823 2823
         prefixTable('sharekeys_fields'),
2824 2824
         'user_id = %i AND object_id NOT IN (
2825 2825
             SELECT c.id 
2826
-            FROM ' . prefixTable('items') . ' AS i 
2827
-            INNER JOIN ' . prefixTable('categories_items') . ' AS c ON c.item_id = i.id
2826
+            FROM ' . prefixTable('items').' AS i 
2827
+            INNER JOIN ' . prefixTable('categories_items').' AS c ON c.item_id = i.id
2828 2828
             WHERE i.perso = 1
2829 2829
         )',
2830 2830
         $userId
@@ -2832,13 +2832,13 @@  discard block
 block discarded – undo
2832 2832
     // Remove all item sharekeys logs
2833 2833
     DB::delete(
2834 2834
         prefixTable('sharekeys_logs'),
2835
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
2835
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
2836 2836
         $userId
2837 2837
     );
2838 2838
     // Remove all item sharekeys suggestions
2839 2839
     DB::delete(
2840 2840
         prefixTable('sharekeys_suggestions'),
2841
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
2841
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
2842 2842
         $userId
2843 2843
     );
2844 2844
     return false;
@@ -2859,7 +2859,7 @@  discard block
 block discarded – undo
2859 2859
         foreach (DateTimeZone::listIdentifiers() as $timezone) {
2860 2860
             $now->setTimezone(new DateTimeZone($timezone));
2861 2861
             $offsets[] = $offset = $now->getOffset();
2862
-            $timezones[$timezone] = '(' . format_GMT_offset($offset) . ') ' . format_timezone_name($timezone);
2862
+            $timezones[$timezone] = '('.format_GMT_offset($offset).') '.format_timezone_name($timezone);
2863 2863
         }
2864 2864
 
2865 2865
         array_multisort($offsets, $timezones);
@@ -2879,7 +2879,7 @@  discard block
 block discarded – undo
2879 2879
 {
2880 2880
     $hours = intval($offset / 3600);
2881 2881
     $minutes = abs(intval($offset % 3600 / 60));
2882
-    return 'GMT' . ($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
2882
+    return 'GMT'.($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
2883 2883
 }
2884 2884
 
2885 2885
 /**
@@ -2978,8 +2978,7 @@  discard block
 block discarded – undo
2978 2978
 {
2979 2979
     if (isset($array[$key]) === true
2980 2980
         && (is_int($value) === true ?
2981
-            (int) $array[$key] === $value :
2982
-            (string) $array[$key] === $value)
2981
+            (int) $array[$key] === $value : (string) $array[$key] === $value)
2983 2982
     ) {
2984 2983
         return true;
2985 2984
     }
@@ -3001,8 +3000,7 @@  discard block
 block discarded – undo
3001 3000
 {
3002 3001
     if (isset($var) === false
3003 3002
         || (is_int($value) === true ?
3004
-            (int) $var === $value :
3005
-            (string) $var === $value)
3003
+            (int) $var === $value : (string) $var === $value)
3006 3004
     ) {
3007 3005
         return true;
3008 3006
     }
@@ -3053,7 +3051,7 @@  discard block
 block discarded – undo
3053 3051
  */
3054 3052
 function isSetArrayOfValues(array $arrayOfValues): bool
3055 3053
 {
3056
-    foreach($arrayOfValues as $value) {
3054
+    foreach ($arrayOfValues as $value) {
3057 3055
         if (isset($value) === false) {
3058 3056
             return false;
3059 3057
         }
@@ -3075,7 +3073,7 @@  discard block
 block discarded – undo
3075 3073
     /*PHP8 - integer|string*/$value
3076 3074
 ) : bool
3077 3075
 {
3078
-    foreach($arrayOfVars as $variable) {
3076
+    foreach ($arrayOfVars as $variable) {
3079 3077
         if ($variable !== $value) {
3080 3078
             return false;
3081 3079
         }
@@ -3095,7 +3093,7 @@  discard block
 block discarded – undo
3095 3093
     /*PHP8 - integer|string*/$value
3096 3094
 ) : bool
3097 3095
 {
3098
-    foreach($arrayOfVars as $variable) {
3096
+    foreach ($arrayOfVars as $variable) {
3099 3097
         if ($variable === $value) {
3100 3098
             return true;
3101 3099
         }
@@ -3109,7 +3107,7 @@  discard block
 block discarded – undo
3109 3107
  * @param string|int|null $value
3110 3108
  * @return boolean
3111 3109
  */
3112
-function isValueSetNullEmpty(string|int|null $value) : bool
3110
+function isValueSetNullEmpty(string | int | null $value) : bool
3113 3111
 {
3114 3112
     if (is_null($value) || empty($value)) {
3115 3113
         return true;
@@ -3164,7 +3162,7 @@  discard block
 block discarded – undo
3164 3162
  * @param array     $filters
3165 3163
  * @return array|string
3166 3164
  */
3167
-function dataSanitizer(array $data, array $filters): array|string
3165
+function dataSanitizer(array $data, array $filters): array | string
3168 3166
 {
3169 3167
     // Load Sanitizer library
3170 3168
     $sanitizer = new Sanitizer($data, $filters);
@@ -3193,7 +3191,7 @@  discard block
 block discarded – undo
3193 3191
     // Exists ?
3194 3192
     $userCacheId = DB::queryFirstRow(
3195 3193
         'SELECT increment_id
3196
-        FROM ' . prefixTable('cache_tree') . '
3194
+        FROM ' . prefixTable('cache_tree').'
3197 3195
         WHERE user_id = %i',
3198 3196
         $user_id
3199 3197
     );
@@ -3244,7 +3242,7 @@  discard block
 block discarded – undo
3244 3242
  */
3245 3243
 function pourcentage(float $nombre, float $total, float $pourcentage): float
3246 3244
 { 
3247
-    $resultat = ($nombre/$total) * $pourcentage;
3245
+    $resultat = ($nombre / $total) * $pourcentage;
3248 3246
     return round($resultat);
3249 3247
 }
3250 3248
 
@@ -3274,7 +3272,7 @@  discard block
 block discarded – undo
3274 3272
 
3275 3273
     // Get last folder update
3276 3274
     $lastFolderChange = DB::queryFirstRow(
3277
-        'SELECT valeur FROM ' . prefixTable('misc') . '
3275
+        'SELECT valeur FROM '.prefixTable('misc').'
3278 3276
         WHERE type = %s AND intitule = %s',
3279 3277
         'timestamp',
3280 3278
         'last_folder_change'
@@ -3305,7 +3303,7 @@  discard block
 block discarded – undo
3305 3303
     // Does this user has a tree cache
3306 3304
     $userCacheTree = DB::queryFirstRow(
3307 3305
         'SELECT '.$fieldName.'
3308
-        FROM ' . prefixTable('cache_tree') . '
3306
+        FROM ' . prefixTable('cache_tree').'
3309 3307
         WHERE user_id = %i',
3310 3308
         $session->get('user-id')
3311 3309
     );
@@ -3348,7 +3346,7 @@  discard block
 block discarded – undo
3348 3346
     if (count($folderIds) === 0) {
3349 3347
         $folderIds = DB::queryFirstColumn(
3350 3348
             'SELECT id
3351
-            FROM ' . prefixTable('nested_tree') . '
3349
+            FROM ' . prefixTable('nested_tree').'
3352 3350
             WHERE personal_folder=%i',
3353 3351
             0
3354 3352
         );
@@ -3365,8 +3363,8 @@  discard block
 block discarded – undo
3365 3363
         $rows_tmp = DB::query(
3366 3364
             'SELECT c.id, c.title, c.level, c.type, c.masked, c.order, c.encrypted_data, c.role_visibility, c.is_mandatory,
3367 3365
             f.id_category AS category_id
3368
-            FROM ' . prefixTable('categories_folders') . ' AS f
3369
-            INNER JOIN ' . prefixTable('categories') . ' AS c ON (f.id_category = c.parent_id)
3366
+            FROM ' . prefixTable('categories_folders').' AS f
3367
+            INNER JOIN ' . prefixTable('categories').' AS c ON (f.id_category = c.parent_id)
3370 3368
             WHERE id_folder=%i',
3371 3369
             $folder
3372 3370
         );
@@ -3392,7 +3390,7 @@  discard block
 block discarded – undo
3392 3390
         $valTemp = '';
3393 3391
         $data = DB::queryFirstRow(
3394 3392
             'SELECT valeur
3395
-            FROM ' . prefixTable('misc') . '
3393
+            FROM ' . prefixTable('misc').'
3396 3394
             WHERE type = %s AND intitule=%i',
3397 3395
             'complex',
3398 3396
             $folder
@@ -3409,14 +3407,14 @@  discard block
 block discarded – undo
3409 3407
         $valTemp = '';
3410 3408
         $rows_tmp = DB::query(
3411 3409
             'SELECT t.title
3412
-            FROM ' . prefixTable('roles_values') . ' as v
3413
-            INNER JOIN ' . prefixTable('roles_title') . ' as t ON (v.role_id = t.id)
3410
+            FROM ' . prefixTable('roles_values').' as v
3411
+            INNER JOIN ' . prefixTable('roles_title').' as t ON (v.role_id = t.id)
3414 3412
             WHERE v.folder_id = %i
3415 3413
             GROUP BY title',
3416 3414
             $folder
3417 3415
         );
3418 3416
         foreach ($rows_tmp as $record) {
3419
-            $valTemp .= (empty($valTemp) === true ? '' : ' - ') . $record['title'];
3417
+            $valTemp .= (empty($valTemp) === true ? '' : ' - ').$record['title'];
3420 3418
         }
3421 3419
         $arr_data['visibilityRoles'] = $valTemp;
3422 3420
 
@@ -3449,7 +3447,7 @@  discard block
 block discarded – undo
3449 3447
         // loop on users and check if user has this role
3450 3448
         $rows = DB::query(
3451 3449
             'SELECT id, fonction_id
3452
-            FROM ' . prefixTable('users') . '
3450
+            FROM ' . prefixTable('users').'
3453 3451
             WHERE id != %i AND admin = 0 AND fonction_id IS NOT NULL AND fonction_id != ""',
3454 3452
             $session->get('user-id')
3455 3453
         );
@@ -3481,7 +3479,7 @@  discard block
 block discarded – undo
3481 3479
 
3482 3480
     $val = DB::queryFirstRow(
3483 3481
         'SELECT *
3484
-        FROM ' . prefixTable('users') . '
3482
+        FROM ' . prefixTable('users').'
3485 3483
         WHERE id = %i',
3486 3484
         $userId
3487 3485
     );
@@ -3497,12 +3495,12 @@  discard block
 block discarded – undo
3497 3495
 function upgradeRequired(): bool
3498 3496
 {
3499 3497
     // Get settings.php
3500
-    include_once __DIR__. '/../includes/config/settings.php';
3498
+    include_once __DIR__.'/../includes/config/settings.php';
3501 3499
 
3502 3500
     // Get timestamp in DB
3503 3501
     $val = DB::queryFirstRow(
3504 3502
         'SELECT valeur
3505
-        FROM ' . prefixTable('misc') . '
3503
+        FROM ' . prefixTable('misc').'
3506 3504
         WHERE type = %s AND intitule = %s',
3507 3505
         'admin',
3508 3506
         'upgrade_timestamp'
@@ -3553,7 +3551,7 @@  discard block
 block discarded – undo
3553 3551
     // prepapre background tasks for item keys generation        
3554 3552
     $userTP = DB::queryFirstRow(
3555 3553
         'SELECT pw, public_key, private_key
3556
-        FROM ' . prefixTable('users') . '
3554
+        FROM ' . prefixTable('users').'
3557 3555
         WHERE id = %i',
3558 3556
         TP_USER_ID
3559 3557
     );
@@ -3614,7 +3612,7 @@  discard block
 block discarded – undo
3614 3612
     }
3615 3613
 
3616 3614
     // Generate new keys
3617
-    if ($user_self_change === true && empty($recovery_public_key) === false && empty($recovery_private_key) === false){
3615
+    if ($user_self_change === true && empty($recovery_public_key) === false && empty($recovery_private_key) === false) {
3618 3616
         $userKeys = [
3619 3617
             'public_key' => $recovery_public_key,
3620 3618
             'private_key_clear' => $recovery_private_key,
@@ -3657,8 +3655,8 @@  discard block
 block discarded – undo
3657 3655
             'process_type' => 'create_user_keys',
3658 3656
             'arguments' => json_encode([
3659 3657
                 'new_user_id' => (int) $userId,
3660
-                'new_user_pwd' => cryption($passwordClear, '','encrypt')['string'],
3661
-                'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '','encrypt')['string'],
3658
+                'new_user_pwd' => cryption($passwordClear, '', 'encrypt')['string'],
3659
+                'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '', 'encrypt')['string'],
3662 3660
                 'owner_id' => (int) TP_USER_ID,
3663 3661
                 'creator_pwd' => $userTP['pw'],
3664 3662
                 'send_email' => $sendEmailToUser === true ? 1 : 0,
@@ -3729,19 +3727,19 @@  discard block
 block discarded – undo
3729 3727
 
3730 3728
     // Prepare the subtask queries
3731 3729
     $queries = [
3732
-        'step20' => 'SELECT * FROM ' . prefixTable('items'),
3730
+        'step20' => 'SELECT * FROM '.prefixTable('items'),
3733 3731
 
3734
-        'step30' => 'SELECT * FROM ' . prefixTable('log_items') . 
3732
+        'step30' => 'SELECT * FROM '.prefixTable('log_items'). 
3735 3733
                     ' WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"',
3736 3734
 
3737
-        'step40' => 'SELECT * FROM ' . prefixTable('categories_items') . 
3735
+        'step40' => 'SELECT * FROM '.prefixTable('categories_items'). 
3738 3736
                     ' WHERE encryption_type = "teampass_aes"',
3739 3737
 
3740
-        'step50' => 'SELECT * FROM ' . prefixTable('suggestion'),
3738
+        'step50' => 'SELECT * FROM '.prefixTable('suggestion'),
3741 3739
 
3742
-        'step60' => 'SELECT * FROM ' . prefixTable('files') . ' AS f
3743
-                        INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = f.id_item
3744
-                        WHERE f.status = "' . TP_ENCRYPTION_NAME . '"'
3740
+        'step60' => 'SELECT * FROM '.prefixTable('files').' AS f
3741
+                        INNER JOIN ' . prefixTable('items').' AS i ON i.id = f.id_item
3742
+                        WHERE f.status = "' . TP_ENCRYPTION_NAME.'"'
3745 3743
     ];
3746 3744
 
3747 3745
     // Perform loop on $queries to create sub-tasks
@@ -3931,7 +3929,7 @@  discard block
 block discarded – undo
3931 3929
  */
3932 3930
 function createTaskForItem(
3933 3931
     string $processType,
3934
-    string|array $taskName,
3932
+    string | array $taskName,
3935 3933
     int $itemId,
3936 3934
     int $userId,
3937 3935
     string $objectKey,
@@ -3955,7 +3953,7 @@  discard block
 block discarded – undo
3955 3953
                 'object_key' => $objectKey,
3956 3954
                 'author' => (int) $userId,
3957 3955
             ]),
3958
-            'item_id' => (int) $parentId !== -1 ?  $parentId : null,
3956
+            'item_id' => (int) $parentId !== -1 ? $parentId : null,
3959 3957
         )
3960 3958
     );
3961 3959
     $processId = DB::insertId();
@@ -3965,7 +3963,7 @@  discard block
 block discarded – undo
3965 3963
     if (is_array($taskName) === false) {
3966 3964
         $taskName = [$taskName];
3967 3965
     }
3968
-    foreach($taskName as $task) {
3966
+    foreach ($taskName as $task) {
3969 3967
         if (WIP === true) error_log('createTaskForItem - task: '.$task);
3970 3968
         switch ($task) {
3971 3969
             case 'item_password':
@@ -4062,7 +4060,7 @@  discard block
 block discarded – undo
4062 4060
  * @param integer $user_id
4063 4061
  * @return void
4064 4062
  */
4065
-function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id=0)
4063
+function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id = 0)
4066 4064
 {
4067 4065
     if ($allUsers === true) {
4068 4066
         // Load class DB
@@ -4072,7 +4070,7 @@  discard block
 block discarded – undo
4072 4070
 
4073 4071
         $users = DB::query(
4074 4072
             'SELECT id
4075
-            FROM ' . prefixTable('users') . '
4073
+            FROM ' . prefixTable('users').'
4076 4074
             WHERE id NOT IN ('.OTV_USER_ID.', '.TP_USER_ID.', '.SSH_USER_ID.', '.API_USER_ID.')
4077 4075
             ORDER BY login ASC'
4078 4076
         );
@@ -4090,7 +4088,7 @@  discard block
 block discarded – undo
4090 4088
  * @param integer $user_id
4091 4089
  * @return void
4092 4090
  */
4093
-function purgeUnnecessaryKeysForUser(int $user_id=0)
4091
+function purgeUnnecessaryKeysForUser(int $user_id = 0)
4094 4092
 {
4095 4093
     if ($user_id === 0) {
4096 4094
         return;
@@ -4101,8 +4099,8 @@  discard block
 block discarded – undo
4101 4099
 
4102 4100
     $personalItems = DB::queryFirstColumn(
4103 4101
         'SELECT id
4104
-        FROM ' . prefixTable('items') . ' AS i
4105
-        INNER JOIN ' . prefixTable('log_items') . ' AS li ON li.id_item = i.id
4102
+        FROM ' . prefixTable('items').' AS i
4103
+        INNER JOIN ' . prefixTable('log_items').' AS li ON li.id_item = i.id
4106 4104
         WHERE i.perso = 1 AND li.action = "at_creation" AND li.id_user IN (%i, '.TP_USER_ID.')',
4107 4105
         $user_id
4108 4106
     );
@@ -4151,7 +4149,7 @@  discard block
 block discarded – undo
4151 4149
     // Check if user exists
4152 4150
     $userInfo = DB::queryFirstRow(
4153 4151
         'SELECT login
4154
-        FROM ' . prefixTable('users') . '
4152
+        FROM ' . prefixTable('users').'
4155 4153
         WHERE id = %i',
4156 4154
         $userId
4157 4155
     );
@@ -4160,7 +4158,7 @@  discard block
 block discarded – undo
4160 4158
         $now = (int) time();
4161 4159
         // Prepare file content
4162 4160
         $export_value = file_get_contents(__DIR__."/../includes/core/teampass_ascii.txt")."\n".
4163
-            "Generation date: ".date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now)."\n\n".
4161
+            "Generation date: ".date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now)."\n\n".
4164 4162
             "RECOVERY KEYS - Not to be shared - To be store safely\n\n".
4165 4163
             "Public Key:\n".$session->get('user-public_key')."\n\n".
4166 4164
             "Private Key:\n".$session->get('user-private_key')."\n\n";
@@ -4183,7 +4181,7 @@  discard block
 block discarded – undo
4183 4181
         return prepareExchangedData(
4184 4182
             array(
4185 4183
                 'error' => false,
4186
-                'datetime' => date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now),
4184
+                'datetime' => date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now),
4187 4185
                 'timestamp' => $now,
4188 4186
                 'content' => base64_encode($export_value),
4189 4187
                 'login' => $userInfo['login'],
@@ -4209,8 +4207,8 @@  discard block
 block discarded – undo
4209 4207
  */
4210 4208
 function loadClasses(string $className = ''): void
4211 4209
 {
4212
-    require_once __DIR__. '/../includes/config/include.php';
4213
-    require_once __DIR__. '/../includes/config/settings.php';
4210
+    require_once __DIR__.'/../includes/config/include.php';
4211
+    require_once __DIR__.'/../includes/config/settings.php';
4214 4212
     require_once __DIR__.'/../vendor/autoload.php';
4215 4213
 
4216 4214
     if (defined('DB_PASSWD_CLEAR') === false) {
@@ -4420,7 +4418,7 @@  discard block
 block discarded – undo
4420 4418
 
4421 4419
     // Get current user hash
4422 4420
     $userHash = DB::queryFirstRow(
4423
-        "SELECT pw FROM " . prefixtable('users') . " WHERE id = %d;",
4421
+        "SELECT pw FROM ".prefixtable('users')." WHERE id = %d;",
4424 4422
         $session->get('user-id')
4425 4423
     )['pw'];
4426 4424
 
Please login to merge, or discard this patch.