Passed
Pull Request — master (#4948)
by Nils
07:11
created
pages/utilities.logs.js.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@
 block discarded – undo
71 71
 if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('utilities.logs') === false) {
72 72
     // Not allowed page
73 73
     $session->set('system-error_code', ERR_NOT_ALLOWED);
74
-    include $SETTINGS['cpassman_dir'] . '/error.php';
74
+    include $SETTINGS['cpassman_dir'].'/error.php';
75 75
     exit;
76 76
 }
77 77
 ?>
Please login to merge, or discard this patch.
sources/fields.queries.php 1 patch
Spacing   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 ) {
68 68
     // Not allowed page
69 69
     $session->set('system-error_code', ERR_NOT_ALLOWED);
70
-    include $SETTINGS['cpassman_dir'] . '/error.php';
70
+    include $SETTINGS['cpassman_dir'].'/error.php';
71 71
     exit;
72 72
 }
73 73
 
@@ -538,8 +538,7 @@  discard block
 block discarded – undo
538 538
             $post_masked = filter_var($dataReceived['masked'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
539 539
             $post_encrypted = filter_var($dataReceived['encrypted'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
540 540
             $post_roles = filter_var_array($dataReceived['roles'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
541
-            $post_fieldId = isset($dataReceived['fieldId']) === false ? '' :
542
-                filter_var($dataReceived['fieldId'], FILTER_SANITIZE_NUMBER_INT);
541
+            $post_fieldId = isset($dataReceived['fieldId']) === false ? '' : filter_var($dataReceived['fieldId'], FILTER_SANITIZE_NUMBER_INT);
543 542
 
544 543
             if (empty($post_fieldId) === false) {
545 544
                 // UPDATE FIELD
@@ -555,7 +554,7 @@  discard block
 block discarded – undo
555 554
                         'encrypted_data' => $post_encrypted,
556 555
                         'is_mandatory' => $post_mandatory,
557 556
                         'masked' => $post_masked,
558
-                        'role_visibility' => is_null($post_roles) === true || count($post_roles) ===0 ? '' : implode(',', $post_roles),
557
+                        'role_visibility' => is_null($post_roles) === true || count($post_roles) === 0 ? '' : implode(',', $post_roles),
559 558
                         'order' => calculateOrder($post_fieldId, $post_order),
560 559
                     ),
561 560
                     'id = %i',
Please login to merge, or discard this patch.
sources/utils.queries.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
 ) {
70 70
     // Not allowed page
71 71
     $session->set('system-error_code', ERR_NOT_ALLOWED);
72
-    include $SETTINGS['cpassman_dir'] . '/error.php';
72
+    include $SETTINGS['cpassman_dir'].'/error.php';
73 73
     exit;
74 74
 }
75 75
 
Please login to merge, or discard this patch.
sources/favourites.queries.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
 ) {
70 70
     // Not allowed page
71 71
     $session->set('system-error_code', ERR_NOT_ALLOWED);
72
-    include $SETTINGS['cpassman_dir'] . '/error.php';
72
+    include $SETTINGS['cpassman_dir'].'/error.php';
73 73
     exit;
74 74
 }
75 75
 
Please login to merge, or discard this patch.
pages/backups.js.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('backups') === false) {
69 69
     // Not allowed page
70 70
     $session->set('system-error_code', ERR_NOT_ALLOWED);
71
-    include $SETTINGS['cpassman_dir'] . '/error.php';
71
+    include $SETTINGS['cpassman_dir'].'/error.php';
72 72
     exit;
73 73
 }
74 74
 ?>
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
                             // ERROR
138 138
                             toastr.remove();
139 139
                             toastr.error(
140
-                                '<?php echo $lang->get('server_answer_error') . '<br />' . $lang->get('server_returned_data') . ':<br />'; ?>' + data.error,
140
+                                '<?php echo $lang->get('server_answer_error').'<br />'.$lang->get('server_returned_data').':<br />'; ?>' + data.error,
141 141
                                 '<?php echo $lang->get('error'); ?>', {
142 142
                                     timeOut: 5000,
143 143
                                     progressBar: true
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
                                         // error
165 165
                                         toastr.remove();
166 166
                                         toastr.error(
167
-                                            '<?php echo $lang->get('server_answer_error') . '<br />' . $lang->get('server_returned_data') . ':<br />'; ?>' + data.error,
167
+                                            '<?php echo $lang->get('server_answer_error').'<br />'.$lang->get('server_returned_data').':<br />'; ?>' + data.error,
168 168
                                             '<?php echo $lang->get('error'); ?>', {
169 169
                                                 timeOut: 5000,
170 170
                                                 progressBar: true
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
                             // ERROR
236 236
                             toastr.remove();
237 237
                             toastr.error(
238
-                                '<?php echo $lang->get('server_answer_error') . '<br />' . $lang->get('server_returned_data') . ':<br />'; ?>' + data.error,
238
+                                '<?php echo $lang->get('server_answer_error').'<br />'.$lang->get('server_returned_data').':<br />'; ?>' + data.error,
239 239
                                 '<?php echo $lang->get('error'); ?>', {
240 240
                                     timeOut: 5000,
241 241
                                     progressBar: true
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
     // PREPARE UPLOADER with plupload
272 272
 <?php
273 273
 $maxFileSize = (strrpos($SETTINGS['upload_maxfilesize'], 'mb') === false)
274
-    ? $SETTINGS['upload_maxfilesize'] . 'mb'
274
+    ? $SETTINGS['upload_maxfilesize'].'mb'
275 275
     : $SETTINGS['upload_maxfilesize'];
276 276
 ?>
277 277
 
Please login to merge, or discard this patch.
pages/utilities.logs.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('utilities.logs') === false) {
67 67
     // Not allowed page
68 68
     $session->set('system-error_code', ERR_NOT_ALLOWED);
69
-    include $SETTINGS['cpassman_dir'] . '/error.php';
69
+    include $SETTINGS['cpassman_dir'].'/error.php';
70 70
     exit;
71 71
 }
72 72
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
                                             echo $session->has('user-admin') && (int) $session->get('user-admin') && null !== $session->get('user-admin') && (int) $session->get('user-admin') === 1 ? '' : ' hidden';
204 204
                                             ?>">
205 205
                         <div class="form-group">
206
-                            <h5><i class="fas fa-broom mr-2"></i><?php echo $lang->get('purge') . ' ' . $lang->get('date_range'); ?></h5>
206
+                            <h5><i class="fas fa-broom mr-2"></i><?php echo $lang->get('purge').' '.$lang->get('date_range'); ?></h5>
207 207
                             <div class="input-group">
208 208
                                 <div class="input-group-prepend">
209 209
                                     <span class="input-group-text">
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
                                     <select class="form-control" id="purge-filter-user">
227 227
                                         <option value="-1"><?php echo $lang->get('all'); ?></option>
228 228
                                     <?php
229
-                                    $rows = DB::query('SELECT id, name, lastname FROM ' . prefixTable('users') . ' WHERE admin = 0');
229
+                                    $rows = DB::query('SELECT id, name, lastname FROM '.prefixTable('users').' WHERE admin = 0');
230 230
 foreach ($rows as $record) {
231 231
     echo '
232 232
                                         <option value="'.$record['id'].'">'.$record['name'].' '.$record['lastname'].'</option>';
Please login to merge, or discard this patch.
error.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
     // Update table by deleting ID
61 61
     if ($session->has('user-id') && null !== $session->get('user-id')) {
62 62
         DB::update(
63
-            DB_PREFIX . 'users',
63
+            DB_PREFIX.'users',
64 64
             [
65 65
                 'key_tempo' => '',
66 66
             ],
Please login to merge, or discard this patch.
sources/main.functions.php 3 patches
Indentation   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2225,7 +2225,7 @@  discard block
 block discarded – undo
2225 2225
  * <tt>exec("find ".$path." -type d -exec chmod 755 {} \;");</tt>
2226 2226
  *
2227 2227
  * @author Jeppe Toustrup (tenzer at tenzer dot dk)
2228
-  *
2228
+ *
2229 2229
  * @param string $path      An either relative or absolute path to a file or directory which should be processed.
2230 2230
  * @param int    $filePerm The permissions any found files should get.
2231 2231
  * @param int    $dirPerm  The permissions any found folder should get.
@@ -3848,7 +3848,6 @@  discard block
 block discarded – undo
3848 3848
  * @param integer $processId
3849 3849
  * @param integer $nbItemsToTreat
3850 3850
  * @return void
3851
- 
3852 3851
  */
3853 3852
 function createUserTasks($processId, $nbItemsToTreat): void
3854 3853
 {
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -2604,7 +2604,9 @@  discard block
 block discarded – undo
2604 2604
 function encryptUserObjectKey(string $key, string $publicKey): string
2605 2605
 {
2606 2606
     // Empty password
2607
-    if (empty($key)) return '';
2607
+    if (empty($key)) {
2608
+        return '';
2609
+    }
2608 2610
 
2609 2611
     // Sanitize
2610 2612
     $antiXss = new AntiXSS();
@@ -2753,7 +2755,9 @@  discard block
 block discarded – undo
2753 2755
         ];
2754 2756
     }
2755 2757
 
2756
-    if (WIP) error_log('DEBUG: File image url -> '.filter_var($safeFilePath, FILTER_SANITIZE_URL));
2758
+    if (WIP) {
2759
+        error_log('DEBUG: File image url -> '.filter_var($safeFilePath, FILTER_SANITIZE_URL));
2760
+    }
2757 2761
 
2758 2762
     // Decrypt file content and return
2759 2763
     return base64_encode($cipher->decrypt($ciphertext));
@@ -4232,7 +4236,9 @@  discard block
 block discarded – undo
4232 4236
         $taskName = [$taskName];
4233 4237
     }
4234 4238
     foreach($taskName as $task) {
4235
-        if (WIP === true) error_log('createTaskForItem - task: '.$task);
4239
+        if (WIP === true) {
4240
+            error_log('createTaskForItem - task: '.$task);
4241
+        }
4236 4242
         switch ($task) {
4237 4243
             case 'item_password':
4238 4244
                 
@@ -4665,19 +4671,22 @@  discard block
 block discarded – undo
4665 4671
 
4666 4672
             // Organisation name (removed username@ and .tld)
4667 4673
             $domain = explode('.', $emailParts[1]);
4668
-            if (count($domain) > 1)
4669
-                $forbiddenWords[] = $domain[0];
4674
+            if (count($domain) > 1) {
4675
+                            $forbiddenWords[] = $domain[0];
4676
+            }
4670 4677
         }
4671 4678
     }
4672 4679
 
4673 4680
     // Search forbidden words in password
4674 4681
     foreach ($forbiddenWords as $word) {
4675
-        if (empty($word))
4676
-            continue;
4682
+        if (empty($word)) {
4683
+                    continue;
4684
+        }
4677 4685
 
4678 4686
         // Stop if forbidden word found in password
4679
-        if (stripos($password, $word) !== false)
4680
-            return false;
4687
+        if (stripos($password, $word) !== false) {
4688
+                    return false;
4689
+        }
4681 4690
     }
4682 4691
 
4683 4692
     // Get password complexity
Please login to merge, or discard this patch.
Spacing   +193 added lines, -195 removed lines patch added patch discarded remove patch
@@ -99,19 +99,19 @@  discard block
 block discarded – undo
99 99
             $text = Crypto::decrypt($message, $key);
100 100
         }
101 101
     } catch (CryptoException\WrongKeyOrModifiedCiphertextException $ex) {
102
-        error_log('TEAMPASS-Error-Wrong key or modified ciphertext: ' . $ex->getMessage());
102
+        error_log('TEAMPASS-Error-Wrong key or modified ciphertext: '.$ex->getMessage());
103 103
         $err = 'wrong_key_or_modified_ciphertext';
104 104
     } catch (CryptoException\BadFormatException $ex) {
105
-        error_log('TEAMPASS-Error-Bad format exception: ' . $ex->getMessage());
105
+        error_log('TEAMPASS-Error-Bad format exception: '.$ex->getMessage());
106 106
         $err = 'bad_format';
107 107
     } catch (CryptoException\EnvironmentIsBrokenException $ex) {
108
-        error_log('TEAMPASS-Error-Environment: ' . $ex->getMessage());
108
+        error_log('TEAMPASS-Error-Environment: '.$ex->getMessage());
109 109
         $err = 'environment_error';
110 110
     } catch (CryptoException\IOException $ex) {
111
-        error_log('TEAMPASS-Error-IO: ' . $ex->getMessage());
111
+        error_log('TEAMPASS-Error-IO: '.$ex->getMessage());
112 112
         $err = 'io_error';
113 113
     } catch (Exception $ex) {
114
-        error_log('TEAMPASS-Error-Unexpected exception: ' . $ex->getMessage());
114
+        error_log('TEAMPASS-Error-Unexpected exception: '.$ex->getMessage());
115 115
         $err = 'unexpected_error';
116 116
     }
117 117
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
  */
197 197
 function trimElement($chaine, string $element): string
198 198
 {
199
-    if (! empty($chaine)) {
199
+    if (!empty($chaine)) {
200 200
         if (is_array($chaine) === true) {
201 201
             $chaine = implode(';', $chaine);
202 202
         }
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
  */
245 245
 function db_error_handler(array $params): void
246 246
 {
247
-    echo 'Error: ' . $params['error'] . "<br>\n";
248
-    echo 'Query: ' . $params['query'] . "<br>\n";
247
+    echo 'Error: '.$params['error']."<br>\n";
248
+    echo 'Query: '.$params['query']."<br>\n";
249 249
     throw new Exception('Error - Query', 1);
250 250
 }
251 251
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
     $session->set('user-forbiden_personal_folders', []);
320 320
     
321 321
     // Get list of Folders
322
-    $rows = DB::query('SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i', 0);
322
+    $rows = DB::query('SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i', 0);
323 323
     foreach ($rows as $record) {
324 324
         array_push($groupesVisibles, $record['id']);
325 325
     }
@@ -328,20 +328,20 @@  discard block
 block discarded – undo
328 328
     // get complete list of ROLES
329 329
     $tmp = array_filter(explode(';', $idFonctions !== null ? $idFonctions : ''));
330 330
     $rows = DB::query(
331
-        'SELECT * FROM ' . prefixTable('roles_title') . '
331
+        'SELECT * FROM '.prefixTable('roles_title').'
332 332
         ORDER BY title ASC'
333 333
     );
334 334
     foreach ($rows as $record) {
335
-        if (! empty($record['id']) && ! in_array($record['id'], $tmp)) {
335
+        if (!empty($record['id']) && !in_array($record['id'], $tmp)) {
336 336
             array_push($tmp, $record['id']);
337 337
         }
338 338
     }
339 339
     $session->set('user-roles', implode(';', $tmp));
340 340
     $session->set('user-admin', 1);
341 341
     // Check if admin has created Folders and Roles
342
-    DB::query('SELECT * FROM ' . prefixTable('nested_tree') . '');
342
+    DB::query('SELECT * FROM '.prefixTable('nested_tree').'');
343 343
     $session->set('user-nb_folders', DB::count());
344
-    DB::query('SELECT * FROM ' . prefixTable('roles_title'));
344
+    DB::query('SELECT * FROM '.prefixTable('roles_title'));
345 345
     $session->set('user-nb_roles', DB::count());
346 346
 
347 347
     return true;
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
     // Does this user is allowed to see other items
425 425
     $inc = 0;
426 426
     $rows = DB::query(
427
-        'SELECT id, id_tree FROM ' . prefixTable('items') . '
427
+        'SELECT id, id_tree FROM '.prefixTable('items').'
428 428
             WHERE restricted_to LIKE %ss AND inactif = %s'.
429 429
             (count($allowedFolders) > 0 ? ' AND id_tree NOT IN ('.implode(',', $allowedFolders).')' : ''),
430 430
         $globalsUserId,
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
     // Check for the users roles if some specific rights exist on items
442 442
     $rows = DB::query(
443 443
         'SELECT i.id_tree, r.item_id
444
-        FROM ' . prefixTable('items') . ' as i
445
-        INNER JOIN ' . prefixTable('restriction_to_roles') . ' as r ON (r.item_id=i.id)
444
+        FROM ' . prefixTable('items').' as i
445
+        INNER JOIN ' . prefixTable('restriction_to_roles').' as r ON (r.item_id=i.id)
446 446
         WHERE i.id_tree <> "" '.
447 447
         (count($userRoles) > 0 ? 'AND r.role_id IN %li ' : '').
448 448
         'ORDER BY i.id_tree ASC',
@@ -486,18 +486,18 @@  discard block
 block discarded – undo
486 486
     $session->set('system-list_restricted_folders_for_items', $restrictedFoldersForItems);
487 487
     $session->set('user-forbiden_personal_folders', $noAccessPersonalFolders);
488 488
     // Folders and Roles numbers
489
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('nested_tree') . '');
490
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('nested_tree') . '');
489
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('nested_tree').'');
490
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('nested_tree').'');
491 491
     $session->set('user-nb_folders', DB::count());
492
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('roles_title'));
493
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('roles_title'));
492
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('roles_title'));
493
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('roles_title'));
494 494
     $session->set('user-nb_roles', DB::count());
495 495
     // check if change proposals on User's items
496 496
     if (isset($SETTINGS['enable_suggestion']) === true && (int) $SETTINGS['enable_suggestion'] === 1) {
497 497
         $countNewItems = DB::query(
498 498
             'SELECT COUNT(*)
499
-            FROM ' . prefixTable('items_change') . ' AS c
500
-            LEFT JOIN ' . prefixTable('log_items') . ' AS i ON (c.item_id = i.id_item)
499
+            FROM ' . prefixTable('items_change').' AS c
500
+            LEFT JOIN ' . prefixTable('log_items').' AS i ON (c.item_id = i.id_item)
501 501
             WHERE i.action = %s AND i.id_user = %i',
502 502
             'at_creation',
503 503
             $globalsUserId
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 {
525 525
     $rows = DB::query(
526 526
         'SELECT *
527
-        FROM ' . prefixTable('roles_values') . '
527
+        FROM ' . prefixTable('roles_values').'
528 528
         WHERE type IN %ls'.(count($userRoles) > 0 ? ' AND role_id IN %li' : ''),
529 529
         ['W', 'ND', 'NE', 'NDNE', 'R'],
530 530
         $userRoles,
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
     ) {
592 592
         $persoFld = DB::queryFirstRow(
593 593
             'SELECT id
594
-            FROM ' . prefixTable('nested_tree') . '
594
+            FROM ' . prefixTable('nested_tree').'
595 595
             WHERE title = %s AND personal_folder = %i'.
596 596
             (count($allowedFolders) > 0 ? ' AND id NOT IN ('.implode(',', $allowedFolders).')' : ''),
597 597
             $globalsUserId,
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
     }
625 625
     $persoFlds = DB::query(
626 626
         'SELECT id
627
-        FROM ' . prefixTable('nested_tree') . '
627
+        FROM ' . prefixTable('nested_tree').'
628 628
         WHERE %l',
629 629
         $where
630 630
     );
@@ -692,12 +692,12 @@  discard block
 block discarded – undo
692 692
     //Load Tree
693 693
     $tree = new NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title');
694 694
     // truncate table
695
-    DB::query('TRUNCATE TABLE ' . prefixTable('cache'));
695
+    DB::query('TRUNCATE TABLE '.prefixTable('cache'));
696 696
     // reload date
697 697
     $rows = DB::query(
698 698
         'SELECT *
699
-        FROM ' . prefixTable('items') . ' as i
700
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
699
+        FROM ' . prefixTable('items').' as i
700
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
701 701
         AND l.action = %s
702 702
         AND i.inactif = %i',
703 703
         'at_creation',
@@ -709,18 +709,18 @@  discard block
 block discarded – undo
709 709
             $tags = '';
710 710
             $itemTags = DB::query(
711 711
                 'SELECT tag
712
-                FROM ' . prefixTable('tags') . '
712
+                FROM ' . prefixTable('tags').'
713 713
                 WHERE item_id = %i AND tag != ""',
714 714
                 $record['id']
715 715
             );
716 716
             foreach ($itemTags as $itemTag) {
717
-                $tags .= $itemTag['tag'] . ' ';
717
+                $tags .= $itemTag['tag'].' ';
718 718
             }
719 719
 
720 720
             // Get renewal period
721 721
             $resNT = DB::queryFirstRow(
722 722
                 'SELECT renewal_period
723
-                FROM ' . prefixTable('nested_tree') . '
723
+                FROM ' . prefixTable('nested_tree').'
724 724
                 WHERE id = %i',
725 725
                 $record['id_tree']
726 726
             );
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
                     // Is this a User id?
734 734
                     $user = DB::queryFirstRow(
735 735
                         'SELECT login
736
-                        FROM ' . prefixTable('users') . '
736
+                        FROM ' . prefixTable('users').'
737 737
                         WHERE id = %i',
738 738
                         $elem->title
739 739
                     );
@@ -751,11 +751,11 @@  discard block
 block discarded – undo
751 751
                     'id' => $record['id'],
752 752
                     'label' => $record['label'],
753 753
                     'description' => $record['description'] ?? '',
754
-                    'url' => isset($record['url']) && ! empty($record['url']) ? $record['url'] : '0',
754
+                    'url' => isset($record['url']) && !empty($record['url']) ? $record['url'] : '0',
755 755
                     'tags' => $tags,
756 756
                     'id_tree' => $record['id_tree'],
757 757
                     'perso' => $record['perso'],
758
-                    'restricted_to' => isset($record['restricted_to']) && ! empty($record['restricted_to']) ? $record['restricted_to'] : '0',
758
+                    'restricted_to' => isset($record['restricted_to']) && !empty($record['restricted_to']) ? $record['restricted_to'] : '0',
759 759
                     'login' => $record['login'] ?? '',
760 760
                     'folder' => implode(' » ', $folder),
761 761
                     'author' => $record['id_user'],
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
     // get new value from db
785 785
     $data = DB::queryFirstRow(
786 786
         'SELECT label, description, id_tree, perso, restricted_to, login, url
787
-        FROM ' . prefixTable('items') . '
787
+        FROM ' . prefixTable('items').'
788 788
         WHERE id=%i',
789 789
         $ident
790 790
     );
@@ -792,12 +792,12 @@  discard block
 block discarded – undo
792 792
     $tags = '';
793 793
     $itemTags = DB::query(
794 794
         'SELECT tag
795
-            FROM ' . prefixTable('tags') . '
795
+            FROM ' . prefixTable('tags').'
796 796
             WHERE item_id = %i AND tag != ""',
797 797
         $ident
798 798
     );
799 799
     foreach ($itemTags as $itemTag) {
800
-        $tags .= $itemTag['tag'] . ' ';
800
+        $tags .= $itemTag['tag'].' ';
801 801
     }
802 802
     // form id_tree to full foldername
803 803
     $folder = [];
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
             // Is this a User id?
809 809
             $user = DB::queryFirstRow(
810 810
                 'SELECT id, login
811
-                FROM ' . prefixTable('users') . '
811
+                FROM ' . prefixTable('users').'
812 812
                 WHERE id = %i',
813 813
                 $elem->title
814 814
             );
@@ -826,10 +826,10 @@  discard block
 block discarded – undo
826 826
             'label' => $data['label'],
827 827
             'description' => $data['description'],
828 828
             'tags' => $tags,
829
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
829
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
830 830
             'id_tree' => $data['id_tree'],
831 831
             'perso' => $data['perso'],
832
-            'restricted_to' => isset($data['restricted_to']) && ! empty($data['restricted_to']) ? $data['restricted_to'] : '0',
832
+            'restricted_to' => isset($data['restricted_to']) && !empty($data['restricted_to']) ? $data['restricted_to'] : '0',
833 833
             'login' => $data['login'] ?? '',
834 834
             'folder' => implode(' » ', $folder),
835 835
             'author' => $session->get('user-id'),
@@ -859,8 +859,8 @@  discard block
 block discarded – undo
859 859
     // get new value from db
860 860
     $data = DB::queryFirstRow(
861 861
         'SELECT i.label, i.description, i.id_tree as id_tree, i.perso, i.restricted_to, i.id, i.login, i.url, l.date
862
-        FROM ' . prefixTable('items') . ' as i
863
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
862
+        FROM ' . prefixTable('items').' as i
863
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
864 864
         WHERE i.id = %i
865 865
         AND l.action = %s',
866 866
         $ident,
@@ -870,12 +870,12 @@  discard block
 block discarded – undo
870 870
     $tags = '';
871 871
     $itemTags = DB::query(
872 872
         'SELECT tag
873
-            FROM ' . prefixTable('tags') . '
873
+            FROM ' . prefixTable('tags').'
874 874
             WHERE item_id = %i AND tag != ""',
875 875
         $ident
876 876
     );
877 877
     foreach ($itemTags as $itemTag) {
878
-        $tags .= $itemTag['tag'] . ' ';
878
+        $tags .= $itemTag['tag'].' ';
879 879
     }
880 880
     // form id_tree to full foldername
881 881
     $folder = [];
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
             // Is this a User id?
887 887
             $user = DB::queryFirstRow(
888 888
                 'SELECT id, login
889
-                FROM ' . prefixTable('users') . '
889
+                FROM ' . prefixTable('users').'
890 890
                 WHERE id = %i',
891 891
                 $elem->title
892 892
             );
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
             'label' => $data['label'],
906 906
             'description' => $data['description'],
907 907
             'tags' => empty($tags) === false ? $tags : 'None',
908
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
908
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
909 909
             'id_tree' => $data['id_tree'],
910 910
             'perso' => isset($data['perso']) && empty($data['perso']) === false && $data['perso'] !== 'None' ? $data['perso'] : '0',
911 911
             'restricted_to' => isset($data['restricted_to']) && empty($data['restricted_to']) === false ? $data['restricted_to'] : '0',
@@ -927,53 +927,53 @@  discard block
 block discarded – undo
927 927
 function getStatisticsData(array $SETTINGS): array
928 928
 {
929 929
     DB::query(
930
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
930
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
931 931
         0
932 932
     );
933 933
     $counter_folders = DB::count();
934 934
     DB::query(
935
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
935
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
936 936
         1
937 937
     );
938 938
     $counter_folders_perso = DB::count();
939 939
     DB::query(
940
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
940
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
941 941
         0
942 942
     );
943 943
     $counter_items = DB::count();
944 944
         DB::query(
945
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
945
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
946 946
         1
947 947
     );
948 948
     $counter_items_perso = DB::count();
949 949
         DB::query(
950
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE login NOT IN (%s, %s, %s)',
950
+        'SELECT id FROM '.prefixTable('users').' WHERE login NOT IN (%s, %s, %s)',
951 951
         'OTV', 'TP', 'API'
952 952
     );
953 953
     $counter_users = DB::count();
954 954
         DB::query(
955
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE admin = %i',
955
+        'SELECT id FROM '.prefixTable('users').' WHERE admin = %i',
956 956
         1
957 957
     );
958 958
     $admins = DB::count();
959 959
     DB::query(
960
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE gestionnaire = %i',
960
+        'SELECT id FROM '.prefixTable('users').' WHERE gestionnaire = %i',
961 961
         1
962 962
     );
963 963
     $managers = DB::count();
964 964
     DB::query(
965
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE read_only = %i',
965
+        'SELECT id FROM '.prefixTable('users').' WHERE read_only = %i',
966 966
         1
967 967
     );
968 968
     $readOnly = DB::count();
969 969
     // list the languages
970 970
     $usedLang = [];
971 971
     $tp_languages = DB::query(
972
-        'SELECT name FROM ' . prefixTable('languages')
972
+        'SELECT name FROM '.prefixTable('languages')
973 973
     );
974 974
     foreach ($tp_languages as $tp_language) {
975 975
         DB::query(
976
-            'SELECT * FROM ' . prefixTable('users') . ' WHERE user_language = %s',
976
+            'SELECT * FROM '.prefixTable('users').' WHERE user_language = %s',
977 977
             $tp_language['name']
978 978
         );
979 979
         $usedLang[$tp_language['name']] = round((DB::count() * 100 / $counter_users), 0);
@@ -982,12 +982,12 @@  discard block
 block discarded – undo
982 982
     // get list of ips
983 983
     $usedIp = [];
984 984
     $tp_ips = DB::query(
985
-        'SELECT user_ip FROM ' . prefixTable('users')
985
+        'SELECT user_ip FROM '.prefixTable('users')
986 986
     );
987 987
     foreach ($tp_ips as $ip) {
988 988
         if (array_key_exists($ip['user_ip'], $usedIp)) {
989 989
             $usedIp[$ip['user_ip']] += $usedIp[$ip['user_ip']];
990
-        } elseif (! empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
990
+        } elseif (!empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
991 991
             $usedIp[$ip['user_ip']] = 1;
992 992
         }
993 993
     }
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
         <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;">
1083 1083
         <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;">
1084 1084
         <br><div style="float:right;">' .
1085
-        $textMail .
1085
+        $textMail.
1086 1086
         '<br><br></td></tr></table>
1087 1087
     </td></tr></table>
1088 1088
     <br></body></html>';
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
 {
1164 1164
     array_walk_recursive(
1165 1165
         $array,
1166
-        static function (&$item): void {
1166
+        static function(&$item): void {
1167 1167
             if (mb_detect_encoding((string) $item, 'utf-8', true) === false) {
1168 1168
                 $item = mb_convert_encoding($item, 'ISO-8859-1', 'UTF-8');
1169 1169
             }
@@ -1274,7 +1274,7 @@  discard block
 block discarded – undo
1274 1274
  */
1275 1275
 function prefixTable(string $table): string
1276 1276
 {
1277
-    $safeTable = htmlspecialchars(DB_PREFIX . $table);
1277
+    $safeTable = htmlspecialchars(DB_PREFIX.$table);
1278 1278
     return $safeTable;
1279 1279
 }
1280 1280
 
@@ -1391,7 +1391,7 @@  discard block
 block discarded – undo
1391 1391
 function send_syslog($message, $host, $port, $component = 'teampass'): void
1392 1392
 {
1393 1393
     $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
1394
-    $syslog_message = '<123>' . date('M d H:i:s ') . $component . ': ' . $message;
1394
+    $syslog_message = '<123>'.date('M d H:i:s ').$component.': '.$message;
1395 1395
     socket_sendto($sock, (string) $syslog_message, strlen($syslog_message), 0, (string) $host, (int) $port);
1396 1396
     socket_close($sock);
1397 1397
 }
@@ -1438,14 +1438,14 @@  discard block
 block discarded – undo
1438 1438
     if (isset($SETTINGS['syslog_enable']) === true && (int) $SETTINGS['syslog_enable'] === 1) {
1439 1439
         if ($type === 'user_mngt') {
1440 1440
             send_syslog(
1441
-                'action=' . str_replace('at_', '', $label) . ' attribute=user user=' . $who . ' userid="' . $login . '" change="' . $field_1 . '" ',
1441
+                'action='.str_replace('at_', '', $label).' attribute=user user='.$who.' userid="'.$login.'" change="'.$field_1.'" ',
1442 1442
                 $SETTINGS['syslog_host'],
1443 1443
                 $SETTINGS['syslog_port'],
1444 1444
                 'teampass'
1445 1445
             );
1446 1446
         } else {
1447 1447
             send_syslog(
1448
-                'action=' . $type . ' attribute=' . $label . ' user=' . $who . ' userid="' . $login . '" ',
1448
+                'action='.$type.' attribute='.$label.' user='.$who.' userid="'.$login.'" ',
1449 1449
                 $SETTINGS['syslog_host'],
1450 1450
                 $SETTINGS['syslog_port'],
1451 1451
                 'teampass'
@@ -1520,7 +1520,7 @@  discard block
 block discarded – undo
1520 1520
         if (empty($item_label) === true) {
1521 1521
             $dataItem = DB::queryFirstRow(
1522 1522
                 'SELECT id, id_tree, label
1523
-                FROM ' . prefixTable('items') . '
1523
+                FROM ' . prefixTable('items').'
1524 1524
                 WHERE id = %i',
1525 1525
                 $item_id
1526 1526
             );
@@ -1528,11 +1528,11 @@  discard block
 block discarded – undo
1528 1528
         }
1529 1529
 
1530 1530
         send_syslog(
1531
-            'action=' . str_replace('at_', '', $action) .
1532
-                ' attribute=' . str_replace('at_', '', $attribute[0]) .
1533
-                ' itemno=' . $item_id .
1534
-                ' user=' . (is_null($login) === true ? '' : addslashes((string) $login)) .
1535
-                ' itemname="' . addslashes($item_label) . '"',
1531
+            'action='.str_replace('at_', '', $action).
1532
+                ' attribute='.str_replace('at_', '', $attribute[0]).
1533
+                ' itemno='.$item_id.
1534
+                ' user='.(is_null($login) === true ? '' : addslashes((string) $login)).
1535
+                ' itemname="'.addslashes($item_label).'"',
1536 1536
             $SETTINGS['syslog_host'],
1537 1537
             $SETTINGS['syslog_port'],
1538 1538
             'teampass'
@@ -1563,8 +1563,8 @@  discard block
 block discarded – undo
1563 1563
     // send email to user that what to be notified
1564 1564
     $notification = DB::queryFirstField(
1565 1565
         'SELECT email
1566
-        FROM ' . prefixTable('notification') . ' AS n
1567
-        INNER JOIN ' . prefixTable('users') . ' AS u ON (n.user_id = u.id)
1566
+        FROM ' . prefixTable('notification').' AS n
1567
+        INNER JOIN ' . prefixTable('users').' AS u ON (n.user_id = u.id)
1568 1568
         WHERE n.item_id = %i AND n.user_id != %i',
1569 1569
         $item_id,
1570 1570
         $globalsUserId
@@ -1575,7 +1575,7 @@  discard block
 block discarded – undo
1575 1575
         // Get list of changes
1576 1576
         $htmlChanges = '<ul>';
1577 1577
         foreach ($changes as $change) {
1578
-            $htmlChanges .= '<li>' . $change . '</li>';
1578
+            $htmlChanges .= '<li>'.$change.'</li>';
1579 1579
         }
1580 1580
         $htmlChanges .= '</ul>';
1581 1581
         // send email
@@ -1612,15 +1612,15 @@  discard block
 block discarded – undo
1612 1612
     $path = '';
1613 1613
     foreach ($arbo as $elem) {
1614 1614
         if (empty($path) === true) {
1615
-            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES) . ' ';
1615
+            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES).' ';
1616 1616
         } else {
1617
-            $path .= '&#8594; ' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1617
+            $path .= '&#8594; '.htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1618 1618
         }
1619 1619
     }
1620 1620
 
1621 1621
     // Build text to show user
1622 1622
     if (empty($label) === false) {
1623
-        return empty($path) === true ? addslashes($label) : addslashes($label) . ' (' . $path . ')';
1623
+        return empty($path) === true ? addslashes($label) : addslashes($label).' ('.$path.')';
1624 1624
     }
1625 1625
     return empty($path) === true ? '' : $path;
1626 1626
 }
@@ -1676,7 +1676,7 @@  discard block
 block discarded – undo
1676 1676
 {
1677 1677
     // Perform a copy if the file exists
1678 1678
     if (file_exists($configFilePath)) {
1679
-        $backupFilePath = $configFilePath . '.' . date('Y_m_d_His', time());
1679
+        $backupFilePath = $configFilePath.'.'.date('Y_m_d_His', time());
1680 1680
         if (!copy($configFilePath, $backupFilePath)) {
1681 1681
             return "ERROR: Could not copy file '$configFilePath'";
1682 1682
         }
@@ -1684,10 +1684,10 @@  discard block
 block discarded – undo
1684 1684
 
1685 1685
     // Regenerate the config file
1686 1686
     $data = ["<?php\n", "global \$SETTINGS;\n", "\$SETTINGS = array (\n"];
1687
-    $rows = DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s', 'admin');
1687
+    $rows = DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type=%s', 'admin');
1688 1688
     foreach ($rows as $record) {
1689 1689
         $value = getEncryptedValue($record['valeur'], $record['is_encrypted']);
1690
-        $data[] = "    '{$record['intitule']}' => '". htmlspecialchars_decode($value, ENT_COMPAT) . "',\n";
1690
+        $data[] = "    '{$record['intitule']}' => '".htmlspecialchars_decode($value, ENT_COMPAT)."',\n";
1691 1691
     }
1692 1692
     $data[] = ");\n";
1693 1693
     $data = array_unique($data);
@@ -1732,7 +1732,7 @@  discard block
 block discarded – undo
1732 1732
 {
1733 1733
     global $SETTINGS;
1734 1734
     /* LOAD CPASSMAN SETTINGS */
1735
-    if (! isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
1735
+    if (!isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
1736 1736
         $SETTINGS = [];
1737 1737
         $SETTINGS['duplicate_folder'] = 0;
1738 1738
         //by default, this is set to 0;
@@ -1742,7 +1742,7 @@  discard block
 block discarded – undo
1742 1742
         //by default, this value is set to 5;
1743 1743
         $settings = [];
1744 1744
         $rows = DB::query(
1745
-            'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s_type OR type=%s_type2',
1745
+            'SELECT * FROM '.prefixTable('misc').' WHERE type=%s_type OR type=%s_type2',
1746 1746
             [
1747 1747
                 'type' => 'admin',
1748 1748
                 'type2' => 'settings',
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
     $source_cf = [];
1775 1775
     $rows = DB::query(
1776 1776
         'SELECT id_category
1777
-            FROM ' . prefixTable('categories_folders') . '
1777
+            FROM ' . prefixTable('categories_folders').'
1778 1778
             WHERE id_folder = %i',
1779 1779
         $source_id
1780 1780
     );
@@ -1785,7 +1785,7 @@  discard block
 block discarded – undo
1785 1785
     $target_cf = [];
1786 1786
     $rows = DB::query(
1787 1787
         'SELECT id_category
1788
-            FROM ' . prefixTable('categories_folders') . '
1788
+            FROM ' . prefixTable('categories_folders').'
1789 1789
             WHERE id_folder = %i',
1790 1790
         $target_id
1791 1791
     );
@@ -1880,10 +1880,10 @@  discard block
 block discarded – undo
1880 1880
     } catch (CryptoException\WrongKeyOrModifiedCiphertextException $ex) {
1881 1881
         $err = 'wrong_key';
1882 1882
     } catch (CryptoException\EnvironmentIsBrokenException $ex) {
1883
-        error_log('TEAMPASS-Error-Environment: ' . $ex->getMessage());
1883
+        error_log('TEAMPASS-Error-Environment: '.$ex->getMessage());
1884 1884
         $err = 'environment_error';
1885 1885
     } catch (CryptoException\IOException $ex) {
1886
-        error_log('TEAMPASS-Error-General: ' . $ex->getMessage());
1886
+        error_log('TEAMPASS-Error-General: '.$ex->getMessage());
1887 1887
         $err = 'general_error';
1888 1888
     }
1889 1889
 
@@ -1915,10 +1915,10 @@  discard block
 block discarded – undo
1915 1915
     } catch (CryptoException\WrongKeyOrModifiedCiphertextException $ex) {
1916 1916
         $err = 'wrong_key';
1917 1917
     } catch (CryptoException\EnvironmentIsBrokenException $ex) {
1918
-        error_log('TEAMPASS-Error-Environment: ' . $ex->getMessage());
1918
+        error_log('TEAMPASS-Error-Environment: '.$ex->getMessage());
1919 1919
         $err = 'environment_error';
1920 1920
     } catch (CryptoException\IOException $ex) {
1921
-        error_log('TEAMPASS-Error-General: ' . $ex->getMessage());
1921
+        error_log('TEAMPASS-Error-General: '.$ex->getMessage());
1922 1922
         $err = 'general_error';
1923 1923
     }
1924 1924
 
@@ -2004,7 +2004,7 @@  discard block
 block discarded – undo
2004 2004
 ) {
2005 2005
     // Check if the path exists
2006 2006
     $path = basename($path);
2007
-    if (! file_exists($path)) {
2007
+    if (!file_exists($path)) {
2008 2008
         return false;
2009 2009
     }
2010 2010
 
@@ -2057,7 +2057,7 @@  discard block
 block discarded – undo
2057 2057
     // Load item data
2058 2058
     $data = DB::queryFirstRow(
2059 2059
         'SELECT id_tree
2060
-        FROM ' . prefixTable('items') . '
2060
+        FROM ' . prefixTable('items').'
2061 2061
         WHERE id = %i',
2062 2062
         $item_id
2063 2063
     );
@@ -2120,7 +2120,7 @@  discard block
 block discarded – undo
2120 2120
         }
2121 2121
         $host .= substr(explode(".", $email[1])[0], -1, 1);
2122 2122
     }
2123
-    $email = $name . "@" . $host . "." . explode(".", $email[1])[1];
2123
+    $email = $name."@".$host.".".explode(".", $email[1])[1];
2124 2124
     return $email;
2125 2125
 }
2126 2126
 
@@ -2151,11 +2151,11 @@  discard block
 block discarded – undo
2151 2151
 function formatSizeUnits(int $bytes): string
2152 2152
 {
2153 2153
     if ($bytes >= 1073741824) {
2154
-        $bytes = number_format($bytes / 1073741824, 2) . ' GB';
2154
+        $bytes = number_format($bytes / 1073741824, 2).' GB';
2155 2155
     } elseif ($bytes >= 1048576) {
2156
-        $bytes = number_format($bytes / 1048576, 2) . ' MB';
2156
+        $bytes = number_format($bytes / 1048576, 2).' MB';
2157 2157
     } elseif ($bytes >= 1024) {
2158
-        $bytes = number_format($bytes / 1024, 2) . ' KB';
2158
+        $bytes = number_format($bytes / 1024, 2).' KB';
2159 2159
     } elseif ($bytes > 1) {
2160 2160
         $bytes .= ' bytes';
2161 2161
     } elseif ($bytes === 1) {
@@ -2322,7 +2322,7 @@  discard block
 block discarded – undo
2322 2322
  */
2323 2323
 function generateKeyIntegrityHash(string $userSeed, string $publicKey, string $serverSecret): string
2324 2324
 {
2325
-    return hash_hmac('sha256', $userSeed . $publicKey, $serverSecret);
2325
+    return hash_hmac('sha256', $userSeed.$publicKey, $serverSecret);
2326 2326
 }
2327 2327
 
2328 2328
 /**
@@ -2397,7 +2397,7 @@  discard block
 block discarded – undo
2397 2397
                 'security_alert',
2398 2398
                 'key_integrity_check_failed',
2399 2399
                 (string) $userInfo['id'],
2400
-                'User: ' . $userInfo['login']
2400
+                'User: '.$userInfo['login']
2401 2401
             );
2402 2402
             return [
2403 2403
                 'success' => false,
@@ -2444,7 +2444,7 @@  discard block
 block discarded – undo
2444 2444
             'user_connection',
2445 2445
             'auto_reencryption_success',
2446 2446
             (string) $userInfo['id'],
2447
-            'User: ' . $userInfo['login']
2447
+            'User: '.$userInfo['login']
2448 2448
         );
2449 2449
 
2450 2450
         // Store in session for immediate use
@@ -2463,12 +2463,12 @@  discard block
 block discarded – undo
2463 2463
             'security_alert',
2464 2464
             'auto_reencryption_failed',
2465 2465
             (string) $userInfo['id'],
2466
-            'User: ' . $userInfo['login'] . ' - Error: ' . $e->getMessage()
2466
+            'User: '.$userInfo['login'].' - Error: '.$e->getMessage()
2467 2467
         );
2468 2468
 
2469 2469
         return [
2470 2470
             'success' => false,
2471
-            'error' => 'decryption_failed: ' . $e->getMessage(),
2471
+            'error' => 'decryption_failed: '.$e->getMessage(),
2472 2472
             'private_key_clear' => '',
2473 2473
         ];
2474 2474
     }
@@ -2535,7 +2535,7 @@  discard block
 block discarded – undo
2535 2535
         'security_alert',
2536 2536
         'auto_reencryption_critical_failure',
2537 2537
         (string) $userId,
2538
-        'User: ' . $userInfo['login'] . ' - disabled due to key recovery failure'
2538
+        'User: '.$userInfo['login'].' - disabled due to key recovery failure'
2539 2539
     );
2540 2540
 
2541 2541
     return false;
@@ -2693,7 +2693,7 @@  discard block
 block discarded – undo
2693 2693
     $cipher->enableContinuousBuffer();
2694 2694
 
2695 2695
     // Encrypt the file content
2696
-    $filePath = filter_var($fileInPath . '/' . $fileInName, FILTER_SANITIZE_URL);
2696
+    $filePath = filter_var($fileInPath.'/'.$fileInName, FILTER_SANITIZE_URL);
2697 2697
     $fileContent = file_get_contents($filePath);
2698 2698
     $plaintext = $fileContent;
2699 2699
     $ciphertext = $cipher->encrypt($plaintext);
@@ -2701,9 +2701,9 @@  discard block
 block discarded – undo
2701 2701
     // Save new file
2702 2702
     // deepcode ignore InsecureHash: is simply used to get a unique name
2703 2703
     $hash = uniqid('', true);
2704
-    $fileOut = $fileInPath . '/' . TP_FILE_PREFIX . $hash;
2704
+    $fileOut = $fileInPath.'/'.TP_FILE_PREFIX.$hash;
2705 2705
     file_put_contents($fileOut, $ciphertext);
2706
-    unlink($fileInPath . '/' . $fileInName);
2706
+    unlink($fileInPath.'/'.$fileInName);
2707 2707
     return [
2708 2708
         'fileHash' => base64_encode($hash),
2709 2709
         'objectKey' => base64_encode($objectKey),
@@ -2719,9 +2719,9 @@  discard block
 block discarded – undo
2719 2719
  *
2720 2720
  * @return string|array
2721 2721
  */
2722
-function decryptFile(string $fileName, string $filePath, string $key): string|array
2722
+function decryptFile(string $fileName, string $filePath, string $key): string | array
2723 2723
 {
2724
-    if (! defined('FILE_BUFFER_SIZE')) {
2724
+    if (!defined('FILE_BUFFER_SIZE')) {
2725 2725
         define('FILE_BUFFER_SIZE', 128 * 1024);
2726 2726
     }
2727 2727
     
@@ -2738,7 +2738,7 @@  discard block
 block discarded – undo
2738 2738
     $cipher->enableContinuousBuffer();
2739 2739
     $cipher->disablePadding();
2740 2740
     // Get file content
2741
-    $safeFilePath = realpath($filePath . '/' . TP_FILE_PREFIX . $safeFileName);
2741
+    $safeFilePath = realpath($filePath.'/'.TP_FILE_PREFIX.$safeFileName);
2742 2742
     if ($safeFilePath !== false && file_exists($safeFilePath)) {
2743 2743
         $ciphertext = file_get_contents(filter_var($safeFilePath, FILTER_SANITIZE_URL));
2744 2744
     } else {
@@ -2834,7 +2834,7 @@  discard block
 block discarded – undo
2834 2834
     }
2835 2835
     $users = DB::query(
2836 2836
         'SELECT id, public_key
2837
-        FROM ' . prefixTable('users') . '
2837
+        FROM ' . prefixTable('users').'
2838 2838
         WHERE id NOT IN %li
2839 2839
         AND public_key != ""',
2840 2840
         $user_ids
@@ -2843,7 +2843,7 @@  discard block
 block discarded – undo
2843 2843
         // Insert in DB the new object key for this item by user
2844 2844
         if (count($objectKeyArray) === 0) {
2845 2845
             if (WIP === true) {
2846
-                error_log('TEAMPASS Debug - storeUsersShareKey case1 - ' . $object_name . ' - ' . $post_object_id . ' - ' . $user['id']);
2846
+                error_log('TEAMPASS Debug - storeUsersShareKey case1 - '.$object_name.' - '.$post_object_id.' - '.$user['id']);
2847 2847
             }
2848 2848
             
2849 2849
             insertOrUpdateSharekey(
@@ -2855,7 +2855,7 @@  discard block
 block discarded – undo
2855 2855
         } else {
2856 2856
             foreach ($objectKeyArray as $object) {
2857 2857
                 if (WIP === true) {
2858
-                    error_log('TEAMPASS Debug - storeUsersShareKey case2 - ' . $object_name . ' - ' . $object['objectId'] . ' - ' . $user['id']);
2858
+                    error_log('TEAMPASS Debug - storeUsersShareKey case2 - '.$object_name.' - '.$object['objectId'].' - '.$user['id']);
2859 2859
                 }
2860 2860
                 
2861 2861
                 insertOrUpdateSharekey(
@@ -2887,7 +2887,7 @@  discard block
 block discarded – undo
2887 2887
 ): bool {
2888 2888
     try {
2889 2889
         DB::query(
2890
-            'INSERT INTO ' . $tableName . ' 
2890
+            'INSERT INTO '.$tableName.' 
2891 2891
             (object_id, user_id, share_key) 
2892 2892
             VALUES (%i, %i, %s)
2893 2893
             ON DUPLICATE KEY UPDATE share_key = VALUES(share_key)',
@@ -2897,7 +2897,7 @@  discard block
 block discarded – undo
2897 2897
         );
2898 2898
         return true;
2899 2899
     } catch (Exception $e) {
2900
-        error_log('TEAMPASS Error - insertOrUpdateSharekey: ' . $e->getMessage());
2900
+        error_log('TEAMPASS Error - insertOrUpdateSharekey: '.$e->getMessage());
2901 2901
         return false;
2902 2902
     }
2903 2903
 }
@@ -2912,7 +2912,7 @@  discard block
 block discarded – undo
2912 2912
 function isBase64(string $str): bool
2913 2913
 {
2914 2914
     $str = (string) trim($str);
2915
-    if (! isset($str[0])) {
2915
+    if (!isset($str[0])) {
2916 2916
         return false;
2917 2917
     }
2918 2918
 
@@ -2986,7 +2986,7 @@  discard block
 block discarded – undo
2986 2986
     } catch (\LdapRecord\Auth\BindException $e) {
2987 2987
         $error = $e->getDetailedError();
2988 2988
         if ($error && defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
2989
-            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage(). " - ".$error->getDiagnosticMessage());
2989
+            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage()." - ".$error->getDiagnosticMessage());
2990 2990
         }
2991 2991
         // deepcode ignore ServerLeak: No important data is sent
2992 2992
         echo 'An error occurred.';
@@ -3003,7 +3003,7 @@  discard block
 block discarded – undo
3003 3003
     } catch (\LdapRecord\Auth\BindException $e) {
3004 3004
         $error = $e->getDetailedError();
3005 3005
         if ($error && defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
3006
-            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage(). " - ".$error->getDiagnosticMessage());
3006
+            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage()." - ".$error->getDiagnosticMessage());
3007 3007
         }
3008 3008
         // deepcode ignore ServerLeak: No important data is sent
3009 3009
         echo 'An error occurred.';
@@ -3039,7 +3039,7 @@  discard block
 block discarded – undo
3039 3039
     // expect if personal item
3040 3040
     DB::delete(
3041 3041
         prefixTable('sharekeys_items'),
3042
-        'user_id = %i',// AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)'',
3042
+        'user_id = %i', // AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)'',
3043 3043
         $userId
3044 3044
     );
3045 3045
     // Remove all item sharekeys files
@@ -3063,7 +3063,7 @@  discard block
 block discarded – undo
3063 3063
     // Remove all item sharekeys suggestions
3064 3064
     DB::delete(
3065 3065
         prefixTable('sharekeys_suggestions'),
3066
-        'user_id = %i',// AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
3066
+        'user_id = %i', // AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
3067 3067
         $userId
3068 3068
     );
3069 3069
     return false;
@@ -3084,7 +3084,7 @@  discard block
 block discarded – undo
3084 3084
         foreach (DateTimeZone::listIdentifiers() as $timezone) {
3085 3085
             $now->setTimezone(new DateTimeZone($timezone));
3086 3086
             $offsets[] = $offset = $now->getOffset();
3087
-            $timezones[$timezone] = '(' . format_GMT_offset($offset) . ') ' . format_timezone_name($timezone);
3087
+            $timezones[$timezone] = '('.format_GMT_offset($offset).') '.format_timezone_name($timezone);
3088 3088
         }
3089 3089
 
3090 3090
         array_multisort($offsets, $timezones);
@@ -3104,7 +3104,7 @@  discard block
 block discarded – undo
3104 3104
 {
3105 3105
     $hours = intval($offset / 3600);
3106 3106
     $minutes = abs(intval($offset % 3600 / 60));
3107
-    return 'GMT' . ($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
3107
+    return 'GMT'.($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
3108 3108
 }
3109 3109
 
3110 3110
 /**
@@ -3203,8 +3203,7 @@  discard block
 block discarded – undo
3203 3203
 {
3204 3204
     if (isset($array[$key]) === true
3205 3205
         && (is_int($value) === true ?
3206
-            (int) $array[$key] === $value :
3207
-            (string) $array[$key] === $value)
3206
+            (int) $array[$key] === $value : (string) $array[$key] === $value)
3208 3207
     ) {
3209 3208
         return true;
3210 3209
     }
@@ -3226,8 +3225,7 @@  discard block
 block discarded – undo
3226 3225
 {
3227 3226
     if (isset($var) === false
3228 3227
         || (is_int($value) === true ?
3229
-            (int) $var === $value :
3230
-            (string) $var === $value)
3228
+            (int) $var === $value : (string) $var === $value)
3231 3229
     ) {
3232 3230
         return true;
3233 3231
     }
@@ -3278,7 +3276,7 @@  discard block
 block discarded – undo
3278 3276
  */
3279 3277
 function isSetArrayOfValues(array $arrayOfValues): bool
3280 3278
 {
3281
-    foreach($arrayOfValues as $value) {
3279
+    foreach ($arrayOfValues as $value) {
3282 3280
         if (isset($value) === false) {
3283 3281
             return false;
3284 3282
         }
@@ -3300,7 +3298,7 @@  discard block
 block discarded – undo
3300 3298
     /*PHP8 - integer|string*/$value
3301 3299
 ) : bool
3302 3300
 {
3303
-    foreach($arrayOfVars as $variable) {
3301
+    foreach ($arrayOfVars as $variable) {
3304 3302
         if ($variable !== $value) {
3305 3303
             return false;
3306 3304
         }
@@ -3320,7 +3318,7 @@  discard block
 block discarded – undo
3320 3318
     /*PHP8 - integer|string*/$value
3321 3319
 ) : bool
3322 3320
 {
3323
-    foreach($arrayOfVars as $variable) {
3321
+    foreach ($arrayOfVars as $variable) {
3324 3322
         if ($variable === $value) {
3325 3323
             return true;
3326 3324
         }
@@ -3334,7 +3332,7 @@  discard block
 block discarded – undo
3334 3332
  * @param string|int|null $value
3335 3333
  * @return boolean
3336 3334
  */
3337
-function isValueSetNullEmpty(string|int|null $value) : bool
3335
+function isValueSetNullEmpty(string | int | null $value) : bool
3338 3336
 {
3339 3337
     if (is_null($value) === true || empty($value) === true) {
3340 3338
         return true;
@@ -3389,7 +3387,7 @@  discard block
 block discarded – undo
3389 3387
  * @param array     $filters
3390 3388
  * @return array|string
3391 3389
  */
3392
-function dataSanitizer(array $data, array $filters): array|string
3390
+function dataSanitizer(array $data, array $filters): array | string
3393 3391
 {
3394 3392
     // Load Sanitizer library
3395 3393
     $sanitizer = new Sanitizer($data, $filters);
@@ -3418,7 +3416,7 @@  discard block
 block discarded – undo
3418 3416
     // Exists ?
3419 3417
     $userCacheId = DB::queryFirstRow(
3420 3418
         'SELECT increment_id
3421
-        FROM ' . prefixTable('cache_tree') . '
3419
+        FROM ' . prefixTable('cache_tree').'
3422 3420
         WHERE user_id = %i',
3423 3421
         $user_id
3424 3422
     );
@@ -3469,7 +3467,7 @@  discard block
 block discarded – undo
3469 3467
  */
3470 3468
 function pourcentage(float $nombre, float $total, float $pourcentage): float
3471 3469
 { 
3472
-    $resultat = ($nombre/$total) * $pourcentage;
3470
+    $resultat = ($nombre / $total) * $pourcentage;
3473 3471
     return round($resultat);
3474 3472
 }
3475 3473
 
@@ -3499,7 +3497,7 @@  discard block
 block discarded – undo
3499 3497
 
3500 3498
     // Get last folder update
3501 3499
     $lastFolderChange = DB::queryFirstRow(
3502
-        'SELECT valeur FROM ' . prefixTable('misc') . '
3500
+        'SELECT valeur FROM '.prefixTable('misc').'
3503 3501
         WHERE type = %s AND intitule = %s',
3504 3502
         'timestamp',
3505 3503
         'last_folder_change'
@@ -3520,7 +3518,7 @@  discard block
 block discarded – undo
3520 3518
     // Does this user has a tree cache
3521 3519
     $userCacheTree = DB::queryFirstRow(
3522 3520
         'SELECT '.$fieldName.'
3523
-        FROM ' . prefixTable('cache_tree') . '
3521
+        FROM ' . prefixTable('cache_tree').'
3524 3522
         WHERE user_id = %i',
3525 3523
         $session->get('user-id')
3526 3524
     );
@@ -3558,7 +3556,7 @@  discard block
 block discarded – undo
3558 3556
     if (count($folderIds) === 0) {
3559 3557
         $folderIds = DB::queryFirstColumn(
3560 3558
             'SELECT id
3561
-            FROM ' . prefixTable('nested_tree') . '
3559
+            FROM ' . prefixTable('nested_tree').'
3562 3560
             WHERE personal_folder=%i',
3563 3561
             0
3564 3562
         );
@@ -3575,8 +3573,8 @@  discard block
 block discarded – undo
3575 3573
         $rows_tmp = DB::query(
3576 3574
             'SELECT c.id, c.title, c.level, c.type, c.masked, c.order, c.encrypted_data, c.role_visibility, c.is_mandatory,
3577 3575
             f.id_category AS category_id
3578
-            FROM ' . prefixTable('categories_folders') . ' AS f
3579
-            INNER JOIN ' . prefixTable('categories') . ' AS c ON (f.id_category = c.parent_id)
3576
+            FROM ' . prefixTable('categories_folders').' AS f
3577
+            INNER JOIN ' . prefixTable('categories').' AS c ON (f.id_category = c.parent_id)
3580 3578
             WHERE id_folder=%i',
3581 3579
             $folder
3582 3580
         );
@@ -3602,7 +3600,7 @@  discard block
 block discarded – undo
3602 3600
         $valTemp = '';
3603 3601
         $data = DB::queryFirstRow(
3604 3602
             'SELECT valeur
3605
-            FROM ' . prefixTable('misc') . '
3603
+            FROM ' . prefixTable('misc').'
3606 3604
             WHERE type = %s AND intitule=%i',
3607 3605
             'complex',
3608 3606
             $folder
@@ -3619,14 +3617,14 @@  discard block
 block discarded – undo
3619 3617
         $valTemp = '';
3620 3618
         $rows_tmp = DB::query(
3621 3619
             'SELECT t.title
3622
-            FROM ' . prefixTable('roles_values') . ' as v
3623
-            INNER JOIN ' . prefixTable('roles_title') . ' as t ON (v.role_id = t.id)
3620
+            FROM ' . prefixTable('roles_values').' as v
3621
+            INNER JOIN ' . prefixTable('roles_title').' as t ON (v.role_id = t.id)
3624 3622
             WHERE v.folder_id = %i
3625 3623
             GROUP BY title',
3626 3624
             $folder
3627 3625
         );
3628 3626
         foreach ($rows_tmp as $record) {
3629
-            $valTemp .= (empty($valTemp) === true ? '' : ' - ') . $record['title'];
3627
+            $valTemp .= (empty($valTemp) === true ? '' : ' - ').$record['title'];
3630 3628
         }
3631 3629
         $arr_data['visibilityRoles'] = $valTemp;
3632 3630
 
@@ -3659,7 +3657,7 @@  discard block
 block discarded – undo
3659 3657
         // loop on users and check if user has this role
3660 3658
         $rows = DB::query(
3661 3659
             'SELECT id, fonction_id
3662
-            FROM ' . prefixTable('users') . '
3660
+            FROM ' . prefixTable('users').'
3663 3661
             WHERE id != %i AND admin = 0 AND fonction_id IS NOT NULL AND fonction_id != ""',
3664 3662
             $session->get('user-id')
3665 3663
         );
@@ -3691,7 +3689,7 @@  discard block
 block discarded – undo
3691 3689
 
3692 3690
     $val = DB::queryFirstRow(
3693 3691
         'SELECT *
3694
-        FROM ' . prefixTable('users') . '
3692
+        FROM ' . prefixTable('users').'
3695 3693
         WHERE id = %i',
3696 3694
         $userId
3697 3695
     );
@@ -3707,12 +3705,12 @@  discard block
 block discarded – undo
3707 3705
 function upgradeRequired(): bool
3708 3706
 {
3709 3707
     // Get settings.php
3710
-    include_once __DIR__. '/../includes/config/settings.php';
3708
+    include_once __DIR__.'/../includes/config/settings.php';
3711 3709
 
3712 3710
     // Get timestamp in DB
3713 3711
     $val = DB::queryFirstRow(
3714 3712
         'SELECT valeur
3715
-        FROM ' . prefixTable('misc') . '
3713
+        FROM ' . prefixTable('misc').'
3716 3714
         WHERE type = %s AND intitule = %s',
3717 3715
         'admin',
3718 3716
         'upgrade_timestamp'
@@ -3765,7 +3763,7 @@  discard block
 block discarded – undo
3765 3763
     // prepapre background tasks for item keys generation        
3766 3764
     $userTP = DB::queryFirstRow(
3767 3765
         'SELECT pw, public_key, private_key
3768
-        FROM ' . prefixTable('users') . '
3766
+        FROM ' . prefixTable('users').'
3769 3767
         WHERE id = %i',
3770 3768
         TP_USER_ID
3771 3769
     );
@@ -3826,7 +3824,7 @@  discard block
 block discarded – undo
3826 3824
     }
3827 3825
 
3828 3826
     // Generate new keys
3829
-    if ($user_self_change === true && empty($recovery_public_key) === false && empty($recovery_private_key) === false){
3827
+    if ($user_self_change === true && empty($recovery_public_key) === false && empty($recovery_private_key) === false) {
3830 3828
         $userKeys = [
3831 3829
             'public_key' => $recovery_public_key,
3832 3830
             'private_key_clear' => $recovery_private_key,
@@ -3877,8 +3875,8 @@  discard block
 block discarded – undo
3877 3875
             'process_type' => 'create_user_keys',
3878 3876
             'arguments' => json_encode([
3879 3877
                 'new_user_id' => (int) $userId,
3880
-                'new_user_pwd' => cryption($passwordClear, '','encrypt')['string'],
3881
-                'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '','encrypt')['string'],
3878
+                'new_user_pwd' => cryption($passwordClear, '', 'encrypt')['string'],
3879
+                'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '', 'encrypt')['string'],
3882 3880
                 'owner_id' => (int) TP_USER_ID,
3883 3881
                 'creator_pwd' => $userTP['pw'],
3884 3882
                 'send_email' => $sendEmailToUser === true ? 1 : 0,
@@ -3950,19 +3948,19 @@  discard block
 block discarded – undo
3950 3948
 
3951 3949
     // Prepare the subtask queries
3952 3950
     $queries = [
3953
-        'step20' => 'SELECT * FROM ' . prefixTable('items'),
3951
+        'step20' => 'SELECT * FROM '.prefixTable('items'),
3954 3952
 
3955
-        'step30' => 'SELECT * FROM ' . prefixTable('log_items') . 
3953
+        'step30' => 'SELECT * FROM '.prefixTable('log_items'). 
3956 3954
                     ' WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"',
3957 3955
 
3958
-        'step40' => 'SELECT * FROM ' . prefixTable('categories_items') . 
3956
+        'step40' => 'SELECT * FROM '.prefixTable('categories_items'). 
3959 3957
                     ' WHERE encryption_type = "teampass_aes"',
3960 3958
 
3961
-        'step50' => 'SELECT * FROM ' . prefixTable('suggestion'),
3959
+        'step50' => 'SELECT * FROM '.prefixTable('suggestion'),
3962 3960
 
3963
-        'step60' => 'SELECT * FROM ' . prefixTable('files') . ' AS f
3964
-                        INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = f.id_item
3965
-                        WHERE f.status = "' . TP_ENCRYPTION_NAME . '"'
3961
+        'step60' => 'SELECT * FROM '.prefixTable('files').' AS f
3962
+                        INNER JOIN ' . prefixTable('items').' AS i ON i.id = f.id_item
3963
+                        WHERE f.status = "' . TP_ENCRYPTION_NAME.'"'
3966 3964
     ];
3967 3965
 
3968 3966
     // Perform loop on $queries to create sub-tasks
@@ -4152,7 +4150,7 @@  discard block
 block discarded – undo
4152 4150
  */
4153 4151
 function createTaskForItem(
4154 4152
     string $processType,
4155
-    string|array $taskName,
4153
+    string | array $taskName,
4156 4154
     int $itemId,
4157 4155
     int $userId,
4158 4156
     string $objectKey,
@@ -4176,7 +4174,7 @@  discard block
 block discarded – undo
4176 4174
                 'object_key' => $objectKey,
4177 4175
                 'author' => (int) $userId,
4178 4176
             ]),
4179
-            'item_id' => (int) $parentId !== -1 ?  $parentId : null,
4177
+            'item_id' => (int) $parentId !== -1 ? $parentId : null,
4180 4178
         )
4181 4179
     );
4182 4180
     $processId = DB::insertId();
@@ -4186,7 +4184,7 @@  discard block
 block discarded – undo
4186 4184
     if (is_array($taskName) === false) {
4187 4185
         $taskName = [$taskName];
4188 4186
     }
4189
-    foreach($taskName as $task) {
4187
+    foreach ($taskName as $task) {
4190 4188
         if (WIP === true) error_log('createTaskForItem - task: '.$task);
4191 4189
         switch ($task) {
4192 4190
             case 'item_password':
@@ -4283,7 +4281,7 @@  discard block
 block discarded – undo
4283 4281
  * @param integer $user_id
4284 4282
  * @return void
4285 4283
  */
4286
-function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id=0)
4284
+function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id = 0)
4287 4285
 {
4288 4286
     if ($allUsers === true) {
4289 4287
         // Load class DB
@@ -4293,7 +4291,7 @@  discard block
 block discarded – undo
4293 4291
 
4294 4292
         $users = DB::query(
4295 4293
             'SELECT id
4296
-            FROM ' . prefixTable('users') . '
4294
+            FROM ' . prefixTable('users').'
4297 4295
             WHERE id NOT IN ('.OTV_USER_ID.', '.TP_USER_ID.', '.SSH_USER_ID.', '.API_USER_ID.')
4298 4296
             ORDER BY login ASC'
4299 4297
         );
@@ -4311,7 +4309,7 @@  discard block
 block discarded – undo
4311 4309
  * @param integer $user_id
4312 4310
  * @return void
4313 4311
  */
4314
-function purgeUnnecessaryKeysForUser(int $user_id=0)
4312
+function purgeUnnecessaryKeysForUser(int $user_id = 0)
4315 4313
 {
4316 4314
     if ($user_id === 0) {
4317 4315
         return;
@@ -4322,8 +4320,8 @@  discard block
 block discarded – undo
4322 4320
 
4323 4321
     $personalItems = DB::queryFirstColumn(
4324 4322
         'SELECT id
4325
-        FROM ' . prefixTable('items') . ' AS i
4326
-        INNER JOIN ' . prefixTable('log_items') . ' AS li ON li.id_item = i.id
4323
+        FROM ' . prefixTable('items').' AS i
4324
+        INNER JOIN ' . prefixTable('log_items').' AS li ON li.id_item = i.id
4327 4325
         WHERE i.perso = 1 AND li.action = "at_creation" AND li.id_user IN (%i, '.TP_USER_ID.')',
4328 4326
         $user_id
4329 4327
     );
@@ -4333,28 +4331,28 @@  discard block
 block discarded – undo
4333 4331
             prefixTable('sharekeys_items'),
4334 4332
             'object_id IN %li AND user_id NOT IN %ls',
4335 4333
             $personalItems,
4336
-            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4334
+            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4337 4335
         );
4338 4336
         // Files keys
4339 4337
         DB::delete(
4340 4338
             prefixTable('sharekeys_files'),
4341 4339
             'object_id IN %li AND user_id NOT IN %ls',
4342 4340
             $personalItems,
4343
-            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4341
+            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4344 4342
         );
4345 4343
         // Fields keys
4346 4344
         DB::delete(
4347 4345
             prefixTable('sharekeys_fields'),
4348 4346
             'object_id IN %li AND user_id NOT IN %ls',
4349 4347
             $personalItems,
4350
-            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4348
+            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4351 4349
         );
4352 4350
         // Logs keys
4353 4351
         DB::delete(
4354 4352
             prefixTable('sharekeys_logs'),
4355 4353
             'object_id IN %li AND user_id NOT IN %ls',
4356 4354
             $personalItems,
4357
-            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4355
+            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4358 4356
         );
4359 4357
     }
4360 4358
 }
@@ -4372,7 +4370,7 @@  discard block
 block discarded – undo
4372 4370
     // Check if user exists
4373 4371
     $userInfo = DB::queryFirstRow(
4374 4372
         'SELECT login
4375
-        FROM ' . prefixTable('users') . '
4373
+        FROM ' . prefixTable('users').'
4376 4374
         WHERE id = %i',
4377 4375
         $userId
4378 4376
     );
@@ -4381,7 +4379,7 @@  discard block
 block discarded – undo
4381 4379
         $now = (int) time();
4382 4380
         // Prepare file content
4383 4381
         $export_value = file_get_contents(__DIR__."/../includes/core/teampass_ascii.txt")."\n".
4384
-            "Generation date: ".date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now)."\n\n".
4382
+            "Generation date: ".date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now)."\n\n".
4385 4383
             "RECOVERY KEYS - Not to be shared - To be store safely\n\n".
4386 4384
             "Public Key:\n".$session->get('user-public_key')."\n\n".
4387 4385
             "Private Key:\n".$session->get('user-private_key')."\n\n";
@@ -4404,7 +4402,7 @@  discard block
 block discarded – undo
4404 4402
         return prepareExchangedData(
4405 4403
             array(
4406 4404
                 'error' => false,
4407
-                'datetime' => date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now),
4405
+                'datetime' => date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now),
4408 4406
                 'timestamp' => $now,
4409 4407
                 'content' => base64_encode($export_value),
4410 4408
                 'login' => $userInfo['login'],
@@ -4430,8 +4428,8 @@  discard block
 block discarded – undo
4430 4428
  */
4431 4429
 function loadClasses(string $className = ''): void
4432 4430
 {
4433
-    require_once __DIR__. '/../includes/config/include.php';
4434
-    require_once __DIR__. '/../includes/config/settings.php';
4431
+    require_once __DIR__.'/../includes/config/include.php';
4432
+    require_once __DIR__.'/../includes/config/settings.php';
4435 4433
     require_once __DIR__.'/../vendor/autoload.php';
4436 4434
 
4437 4435
     if (defined('DB_PASSWD_CLEAR') === false) {
@@ -4644,7 +4642,7 @@  discard block
 block discarded – undo
4644 4642
 
4645 4643
     // Get current user hash
4646 4644
     $userHash = DB::queryFirstRow(
4647
-        "SELECT pw FROM " . prefixtable('users') . " WHERE id = %d;",
4645
+        "SELECT pw FROM ".prefixtable('users')." WHERE id = %d;",
4648 4646
         $session->get('user-id')
4649 4647
     )['pw'];
4650 4648
 
@@ -4692,11 +4690,11 @@  discard block
 block discarded – undo
4692 4690
         }
4693 4691
         
4694 4692
         // Alternative: serialize ou json selon le contexte
4695
-        return get_class($value) . (method_exists($value, 'getId') ? '#' . $value->getId() : '');
4693
+        return get_class($value).(method_exists($value, 'getId') ? '#'.$value->getId() : '');
4696 4694
     }
4697 4695
     
4698 4696
     if (is_resource($value)) {
4699
-        return 'Resource#' . get_resource_id($value) . ' of type ' . get_resource_type($value);
4697
+        return 'Resource#'.get_resource_id($value).' of type '.get_resource_type($value);
4700 4698
     }
4701 4699
     
4702 4700
     // Cas par défaut
@@ -4716,7 +4714,7 @@  discard block
 block discarded – undo
4716 4714
     // Refuse access if user does not exist and/or is admin
4717 4715
     $user = DB::queryFirstRow(
4718 4716
         'SELECT admin
4719
-        FROM ' . prefixTable('users') . '
4717
+        FROM ' . prefixTable('users').'
4720 4718
         WHERE id = %i',
4721 4719
         $userId
4722 4720
     );
@@ -4727,8 +4725,8 @@  discard block
 block discarded – undo
4727 4725
     // Get file info
4728 4726
     $file = DB::queryFirstRow(
4729 4727
         'SELECT f.id_item, i.id_tree
4730
-        FROM ' . prefixTable('files') . ' as f
4731
-        INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = f.id_item
4728
+        FROM ' . prefixTable('files').' as f
4729
+        INNER JOIN ' . prefixTable('items').' AS i ON i.id = f.id_item
4732 4730
         WHERE f.id = %i',
4733 4731
         $fileId
4734 4732
     );
@@ -4737,7 +4735,7 @@  discard block
 block discarded – undo
4737 4735
     }
4738 4736
 
4739 4737
     // Check if user has access to the item
4740
-    include_once __DIR__. '/items.queries.php';
4738
+    include_once __DIR__.'/items.queries.php';
4741 4739
     $itemAccess = getCurrentAccessRights(
4742 4740
         (int) filter_var($userId, FILTER_SANITIZE_NUMBER_INT),
4743 4741
         (int) filter_var($file['id_item'], FILTER_SANITIZE_NUMBER_INT),
@@ -4770,7 +4768,7 @@  discard block
 block discarded – undo
4770 4768
     // Refuse access if user does not exist and/or is not admin
4771 4769
     $user = DB::queryFirstRow(
4772 4770
         'SELECT admin
4773
-        FROM ' . prefixTable('users') . '
4771
+        FROM ' . prefixTable('users').'
4774 4772
         WHERE id = %i',
4775 4773
         $userId
4776 4774
     );
@@ -4781,7 +4779,7 @@  discard block
 block discarded – undo
4781 4779
     // Ensure that user has performed the backup
4782 4780
     DB::queryFirstRow(
4783 4781
         'SELECT f.id
4784
-        FROM ' . prefixTable('log_system') . ' as f
4782
+        FROM ' . prefixTable('log_system').' as f
4785 4783
         WHERE f.type = %s AND f.label = %s AND f.qui = %i AND f.field_1 = %s',
4786 4784
         'admin_action',
4787 4785
         'dataBase backup',
@@ -4808,7 +4806,7 @@  discard block
 block discarded – undo
4808 4806
     // Refuse access if user does not exist and/or is admin
4809 4807
     $user = DB::queryFirstRow(
4810 4808
         'SELECT admin
4811
-        FROM ' . prefixTable('users') . '
4809
+        FROM ' . prefixTable('users').'
4812 4810
         WHERE id = %i',
4813 4811
         $userId
4814 4812
     );
@@ -4819,7 +4817,7 @@  discard block
 block discarded – undo
4819 4817
     // Get item info
4820 4818
     $item = DB::queryFirstRow(
4821 4819
         'SELECT i.perso, i.id_tree
4822
-        FROM ' . prefixTable('items') . ' as i
4820
+        FROM ' . prefixTable('items').' as i
4823 4821
         WHERE i.id = %i',
4824 4822
         $itemId
4825 4823
     );
@@ -4830,7 +4828,7 @@  discard block
 block discarded – undo
4830 4828
     // Get item owner
4831 4829
     $itemOwner = DB::queryFirstRow(
4832 4830
         'SELECT li.id_user
4833
-        FROM ' . prefixTable('log_items') . ' as li
4831
+        FROM ' . prefixTable('log_items').' as li
4834 4832
         WHERE li.id_item = %i AND li.action = %s',
4835 4833
         $itemId,
4836 4834
         'at_creation'
@@ -4844,25 +4842,25 @@  discard block
 block discarded – undo
4844 4842
         prefixTable('sharekeys_items'),
4845 4843
         'object_id = %i AND user_id NOT IN %ls',
4846 4844
         $itemId,
4847
-        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4845
+        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4848 4846
     );
4849 4847
     DB::delete(
4850 4848
         prefixTable('sharekeys_files'),
4851 4849
         'object_id IN (SELECT id FROM '.prefixTable('files').' WHERE id_item = %i) AND user_id NOT IN %ls',
4852 4850
         $itemId,
4853
-        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4851
+        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4854 4852
     );
4855 4853
     DB::delete(
4856 4854
         prefixTable('sharekeys_fields'),
4857 4855
         'object_id IN (SELECT id FROM '.prefixTable('fields').' WHERE id_item = %i) AND user_id NOT IN %ls',
4858 4856
         $itemId,
4859
-        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4857
+        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4860 4858
     );
4861 4859
     DB::delete(
4862 4860
         prefixTable('sharekeys_logs'),
4863 4861
         'object_id IN (SELECT id FROM '.prefixTable('log_items').' WHERE id_item = %i) AND user_id NOT IN %ls',
4864 4862
         $itemId,
4865
-        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4863
+        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4866 4864
     );
4867 4865
 
4868 4866
     return true;
@@ -4934,7 +4932,7 @@  discard block
 block discarded – undo
4934 4932
     
4935 4933
     // 2. Check if user actually has personal items to migrate
4936 4934
     $personalFolderId = DB::queryFirstField(
4937
-        "SELECT id FROM ".prefixTable('nested_tree') ."
4935
+        "SELECT id FROM ".prefixTable('nested_tree')."
4938 4936
          WHERE personal_folder = 1 
4939 4937
          AND title = %s",
4940 4938
         $userId
@@ -5014,8 +5012,8 @@  discard block
 block discarded – undo
5014 5012
             'process_type' => 'migrate_user_personal_items',
5015 5013
             'arguments' => json_encode([
5016 5014
                 'user_id' => (int) $userId,
5017
-                'user_pwd' => cryption($passwordClear, '','encrypt')['string'],
5018
-                'user_private_key' => cryption($privateKeyDecrypted, '','encrypt')['string'],
5015
+                'user_pwd' => cryption($passwordClear, '', 'encrypt')['string'],
5016
+                'user_private_key' => cryption($privateKeyDecrypted, '', 'encrypt')['string'],
5019 5017
                 'personal_folders_ids' => $personalFolderIds,
5020 5018
             ]),
5021 5019
             'is_in_progress' => 0,
@@ -5044,19 +5042,19 @@  discard block
 block discarded – undo
5044 5042
 {
5045 5043
     // Prepare the subtask queries
5046 5044
     $queries = [
5047
-        'user-personal-items-migration-step10' => 'SELECT * FROM ' . prefixTable('items'),
5045
+        'user-personal-items-migration-step10' => 'SELECT * FROM '.prefixTable('items'),
5048 5046
 
5049
-        'user-personal-items-migration-step20' => 'SELECT * FROM ' . prefixTable('log_items') . 
5047
+        'user-personal-items-migration-step20' => 'SELECT * FROM '.prefixTable('log_items'). 
5050 5048
                     ' WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"',
5051 5049
 
5052
-        'user-personal-items-migration-step30' => 'SELECT * FROM ' . prefixTable('categories_items') . 
5050
+        'user-personal-items-migration-step30' => 'SELECT * FROM '.prefixTable('categories_items'). 
5053 5051
                     ' WHERE encryption_type = "teampass_aes"',
5054 5052
 
5055
-        'user-personal-items-migration-step40' => 'SELECT * FROM ' . prefixTable('suggestion'),
5053
+        'user-personal-items-migration-step40' => 'SELECT * FROM '.prefixTable('suggestion'),
5056 5054
 
5057
-        'user-personal-items-migration-step50' => 'SELECT * FROM ' . prefixTable('files') . ' AS f
5058
-                        INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = f.id_item
5059
-                        WHERE f.status = "' . TP_ENCRYPTION_NAME . '"'
5055
+        'user-personal-items-migration-step50' => 'SELECT * FROM '.prefixTable('files').' AS f
5056
+                        INNER JOIN ' . prefixTable('items').' AS i ON i.id = f.id_item
5057
+                        WHERE f.status = "' . TP_ENCRYPTION_NAME.'"'
5060 5058
     ];
5061 5059
 
5062 5060
     // Perform loop on $queries to create sub-tasks
Please login to merge, or discard this patch.
pages/backups.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('backups') === false) {
69 69
     // Not allowed page
70 70
     $session->set('system-error_code', ERR_NOT_ALLOWED);
71
-    include $SETTINGS['cpassman_dir'] . '/error.php';
71
+    include $SETTINGS['cpassman_dir'].'/error.php';
72 72
     exit;
73 73
 }
74 74
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
                                             </div>
179 179
                                             <div class="alert alert-info ml-2 mt-3 mr-2 hidden" id="onthefly-restore-progress">
180 180
                                                 <h5><i class="icon fa fa-info mr-2"></i><?php echo $lang->get('in_progress'); ?></h5>
181
-                                                <i class="mr-2 fa-solid fa-rocket fa-beat"></i><?php echo $lang->get('restore_in_progress');?> <b><span id="onthefly-restore-progress-text">0</span>%</b>
181
+                                                <i class="mr-2 fa-solid fa-rocket fa-beat"></i><?php echo $lang->get('restore_in_progress'); ?> <b><span id="onthefly-restore-progress-text">0</span>%</b>
182 182
                                             </div>
183 183
                                             <div class="row mt-3 hidden" id="onthefly-restore-finished"></div>
184 184
                                             <div class="row mt-3">
Please login to merge, or discard this patch.