Passed
Push — master ( 106709...350f1a )
by Nils
07:20
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.
Spacing   +194 added lines, -196 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
 
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
     $session->set('user-forbiden_personal_folders', []);
324 324
     
325 325
     // Get list of Folders
326
-    $rows = DB::query('SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i', 0);
326
+    $rows = DB::query('SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i', 0);
327 327
     foreach ($rows as $record) {
328 328
         array_push($groupesVisibles, $record['id']);
329 329
     }
@@ -332,20 +332,20 @@  discard block
 block discarded – undo
332 332
     // get complete list of ROLES
333 333
     $tmp = explode(';', $idFonctions);
334 334
     $rows = DB::query(
335
-        'SELECT * FROM ' . prefixTable('roles_title') . '
335
+        'SELECT * FROM '.prefixTable('roles_title').'
336 336
         ORDER BY title ASC'
337 337
     );
338 338
     foreach ($rows as $record) {
339
-        if (! empty($record['id']) && ! in_array($record['id'], $tmp)) {
339
+        if (!empty($record['id']) && !in_array($record['id'], $tmp)) {
340 340
             array_push($tmp, $record['id']);
341 341
         }
342 342
     }
343 343
     $session->set('user-roles', implode(';', $tmp));
344 344
     $session->set('user-admin', 1);
345 345
     // Check if admin has created Folders and Roles
346
-    DB::query('SELECT * FROM ' . prefixTable('nested_tree') . '');
346
+    DB::query('SELECT * FROM '.prefixTable('nested_tree').'');
347 347
     $session->set('user-nb_folders', DB::count());
348
-    DB::query('SELECT * FROM ' . prefixTable('roles_title'));
348
+    DB::query('SELECT * FROM '.prefixTable('roles_title'));
349 349
     $session->set('user-nb_roles', DB::count());
350 350
 
351 351
     return true;
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
     // Does this user is allowed to see other items
429 429
     $inc = 0;
430 430
     $rows = DB::query(
431
-        'SELECT id, id_tree FROM ' . prefixTable('items') . '
431
+        'SELECT id, id_tree FROM '.prefixTable('items').'
432 432
             WHERE restricted_to LIKE %ss AND inactif = %s'.
433 433
             (count($allowedFolders) > 0 ? ' AND id_tree NOT IN ('.implode(',', $allowedFolders).')' : ''),
434 434
         $globalsUserId,
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
     // Check for the users roles if some specific rights exist on items
446 446
     $rows = DB::query(
447 447
         'SELECT i.id_tree, r.item_id
448
-        FROM ' . prefixTable('items') . ' as i
449
-        INNER JOIN ' . prefixTable('restriction_to_roles') . ' as r ON (r.item_id=i.id)
448
+        FROM ' . prefixTable('items').' as i
449
+        INNER JOIN ' . prefixTable('restriction_to_roles').' as r ON (r.item_id=i.id)
450 450
         WHERE i.id_tree <> "" '.
451 451
         (count($userRoles) > 0 ? 'AND r.role_id IN %li ' : '').
452 452
         'ORDER BY i.id_tree ASC',
@@ -490,18 +490,18 @@  discard block
 block discarded – undo
490 490
     $session->set('system-list_restricted_folders_for_items', $restrictedFoldersForItems);
491 491
     $session->set('user-forbiden_personal_folders', $noAccessPersonalFolders);
492 492
     // Folders and Roles numbers
493
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('nested_tree') . '');
494
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('nested_tree') . '');
493
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('nested_tree').'');
494
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('nested_tree').'');
495 495
     $session->set('user-nb_folders', DB::count());
496
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('roles_title'));
497
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('roles_title'));
496
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('roles_title'));
497
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('roles_title'));
498 498
     $session->set('user-nb_roles', DB::count());
499 499
     // check if change proposals on User's items
500 500
     if (isset($SETTINGS['enable_suggestion']) === true && (int) $SETTINGS['enable_suggestion'] === 1) {
501 501
         $countNewItems = DB::query(
502 502
             'SELECT COUNT(*)
503
-            FROM ' . prefixTable('items_change') . ' AS c
504
-            LEFT JOIN ' . prefixTable('log_items') . ' AS i ON (c.item_id = i.id_item)
503
+            FROM ' . prefixTable('items_change').' AS c
504
+            LEFT JOIN ' . prefixTable('log_items').' AS i ON (c.item_id = i.id_item)
505 505
             WHERE i.action = %s AND i.id_user = %i',
506 506
             'at_creation',
507 507
             $globalsUserId
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 {
529 529
     $rows = DB::query(
530 530
         'SELECT *
531
-        FROM ' . prefixTable('roles_values') . '
531
+        FROM ' . prefixTable('roles_values').'
532 532
         WHERE type IN %ls'.(count($userRoles) > 0 ? ' AND role_id IN %li' : ''),
533 533
         ['W', 'ND', 'NE', 'NDNE', 'R'],
534 534
         $userRoles,
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
     ) {
596 596
         $persoFld = DB::queryFirstRow(
597 597
             'SELECT id
598
-            FROM ' . prefixTable('nested_tree') . '
598
+            FROM ' . prefixTable('nested_tree').'
599 599
             WHERE title = %s AND personal_folder = %i'.
600 600
             (count($allowedFolders) > 0 ? ' AND id NOT IN ('.implode(',', $allowedFolders).')' : ''),
601 601
             $globalsUserId,
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
     }
629 629
     $persoFlds = DB::query(
630 630
         'SELECT id
631
-        FROM ' . prefixTable('nested_tree') . '
631
+        FROM ' . prefixTable('nested_tree').'
632 632
         WHERE %l',
633 633
         $where
634 634
     );
@@ -696,12 +696,12 @@  discard block
 block discarded – undo
696 696
     //Load Tree
697 697
     $tree = new NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title');
698 698
     // truncate table
699
-    DB::query('TRUNCATE TABLE ' . prefixTable('cache'));
699
+    DB::query('TRUNCATE TABLE '.prefixTable('cache'));
700 700
     // reload date
701 701
     $rows = DB::query(
702 702
         'SELECT *
703
-        FROM ' . prefixTable('items') . ' as i
704
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
703
+        FROM ' . prefixTable('items').' as i
704
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
705 705
         AND l.action = %s
706 706
         AND i.inactif = %i',
707 707
         'at_creation',
@@ -713,18 +713,18 @@  discard block
 block discarded – undo
713 713
             $tags = '';
714 714
             $itemTags = DB::query(
715 715
                 'SELECT tag
716
-                FROM ' . prefixTable('tags') . '
716
+                FROM ' . prefixTable('tags').'
717 717
                 WHERE item_id = %i AND tag != ""',
718 718
                 $record['id']
719 719
             );
720 720
             foreach ($itemTags as $itemTag) {
721
-                $tags .= $itemTag['tag'] . ' ';
721
+                $tags .= $itemTag['tag'].' ';
722 722
             }
723 723
 
724 724
             // Get renewal period
725 725
             $resNT = DB::queryFirstRow(
726 726
                 'SELECT renewal_period
727
-                FROM ' . prefixTable('nested_tree') . '
727
+                FROM ' . prefixTable('nested_tree').'
728 728
                 WHERE id = %i',
729 729
                 $record['id_tree']
730 730
             );
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
                     // Is this a User id?
738 738
                     $user = DB::queryFirstRow(
739 739
                         'SELECT id, login
740
-                        FROM ' . prefixTable('users') . '
740
+                        FROM ' . prefixTable('users').'
741 741
                         WHERE id = %i',
742 742
                         $elem->title
743 743
                     );
@@ -755,11 +755,11 @@  discard block
 block discarded – undo
755 755
                     'id' => $record['id'],
756 756
                     'label' => $record['label'],
757 757
                     'description' => $record['description'] ?? '',
758
-                    'url' => isset($record['url']) && ! empty($record['url']) ? $record['url'] : '0',
758
+                    'url' => isset($record['url']) && !empty($record['url']) ? $record['url'] : '0',
759 759
                     'tags' => $tags,
760 760
                     'id_tree' => $record['id_tree'],
761 761
                     'perso' => $record['perso'],
762
-                    'restricted_to' => isset($record['restricted_to']) && ! empty($record['restricted_to']) ? $record['restricted_to'] : '0',
762
+                    'restricted_to' => isset($record['restricted_to']) && !empty($record['restricted_to']) ? $record['restricted_to'] : '0',
763 763
                     'login' => $record['login'] ?? '',
764 764
                     'folder' => implode(' » ', $folder),
765 765
                     'author' => $record['id_user'],
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
     // get new value from db
789 789
     $data = DB::queryFirstRow(
790 790
         'SELECT label, description, id_tree, perso, restricted_to, login, url
791
-        FROM ' . prefixTable('items') . '
791
+        FROM ' . prefixTable('items').'
792 792
         WHERE id=%i',
793 793
         $ident
794 794
     );
@@ -796,12 +796,12 @@  discard block
 block discarded – undo
796 796
     $tags = '';
797 797
     $itemTags = DB::query(
798 798
         'SELECT tag
799
-            FROM ' . prefixTable('tags') . '
799
+            FROM ' . prefixTable('tags').'
800 800
             WHERE item_id = %i AND tag != ""',
801 801
         $ident
802 802
     );
803 803
     foreach ($itemTags as $itemTag) {
804
-        $tags .= $itemTag['tag'] . ' ';
804
+        $tags .= $itemTag['tag'].' ';
805 805
     }
806 806
     // form id_tree to full foldername
807 807
     $folder = [];
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
             // Is this a User id?
813 813
             $user = DB::queryFirstRow(
814 814
                 'SELECT id, login
815
-                FROM ' . prefixTable('users') . '
815
+                FROM ' . prefixTable('users').'
816 816
                 WHERE id = %i',
817 817
                 $elem->title
818 818
             );
@@ -830,10 +830,10 @@  discard block
 block discarded – undo
830 830
             'label' => $data['label'],
831 831
             'description' => $data['description'],
832 832
             'tags' => $tags,
833
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
833
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
834 834
             'id_tree' => $data['id_tree'],
835 835
             'perso' => $data['perso'],
836
-            'restricted_to' => isset($data['restricted_to']) && ! empty($data['restricted_to']) ? $data['restricted_to'] : '0',
836
+            'restricted_to' => isset($data['restricted_to']) && !empty($data['restricted_to']) ? $data['restricted_to'] : '0',
837 837
             'login' => $data['login'] ?? '',
838 838
             'folder' => implode(' » ', $folder),
839 839
             'author' => $session->get('user-id'),
@@ -863,8 +863,8 @@  discard block
 block discarded – undo
863 863
     // get new value from db
864 864
     $data = DB::queryFirstRow(
865 865
         'SELECT i.label, i.description, i.id_tree as id_tree, i.perso, i.restricted_to, i.id, i.login, i.url, l.date
866
-        FROM ' . prefixTable('items') . ' as i
867
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
866
+        FROM ' . prefixTable('items').' as i
867
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
868 868
         WHERE i.id = %i
869 869
         AND l.action = %s',
870 870
         $ident,
@@ -874,12 +874,12 @@  discard block
 block discarded – undo
874 874
     $tags = '';
875 875
     $itemTags = DB::query(
876 876
         'SELECT tag
877
-            FROM ' . prefixTable('tags') . '
877
+            FROM ' . prefixTable('tags').'
878 878
             WHERE item_id = %i AND tag != ""',
879 879
         $ident
880 880
     );
881 881
     foreach ($itemTags as $itemTag) {
882
-        $tags .= $itemTag['tag'] . ' ';
882
+        $tags .= $itemTag['tag'].' ';
883 883
     }
884 884
     // form id_tree to full foldername
885 885
     $folder = [];
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
             // Is this a User id?
891 891
             $user = DB::queryFirstRow(
892 892
                 'SELECT id, login
893
-                FROM ' . prefixTable('users') . '
893
+                FROM ' . prefixTable('users').'
894 894
                 WHERE id = %i',
895 895
                 $elem->title
896 896
             );
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
             'label' => $data['label'],
910 910
             'description' => $data['description'],
911 911
             'tags' => empty($tags) === false ? $tags : 'None',
912
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
912
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
913 913
             'id_tree' => $data['id_tree'],
914 914
             'perso' => isset($data['perso']) && empty($data['perso']) === false && $data['perso'] !== 'None' ? $data['perso'] : '0',
915 915
             'restricted_to' => isset($data['restricted_to']) && empty($data['restricted_to']) === false ? $data['restricted_to'] : '0',
@@ -931,53 +931,53 @@  discard block
 block discarded – undo
931 931
 function getStatisticsData(array $SETTINGS): array
932 932
 {
933 933
     DB::query(
934
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
934
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
935 935
         0
936 936
     );
937 937
     $counter_folders = DB::count();
938 938
     DB::query(
939
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
939
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
940 940
         1
941 941
     );
942 942
     $counter_folders_perso = DB::count();
943 943
     DB::query(
944
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
944
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
945 945
         0
946 946
     );
947 947
     $counter_items = DB::count();
948 948
         DB::query(
949
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
949
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
950 950
         1
951 951
     );
952 952
     $counter_items_perso = DB::count();
953 953
         DB::query(
954
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE login NOT IN (%s, %s, %s)',
954
+        'SELECT id FROM '.prefixTable('users').' WHERE login NOT IN (%s, %s, %s)',
955 955
         'OTV', 'TP', 'API'
956 956
     );
957 957
     $counter_users = DB::count();
958 958
         DB::query(
959
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE admin = %i',
959
+        'SELECT id FROM '.prefixTable('users').' WHERE admin = %i',
960 960
         1
961 961
     );
962 962
     $admins = DB::count();
963 963
     DB::query(
964
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE gestionnaire = %i',
964
+        'SELECT id FROM '.prefixTable('users').' WHERE gestionnaire = %i',
965 965
         1
966 966
     );
967 967
     $managers = DB::count();
968 968
     DB::query(
969
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE read_only = %i',
969
+        'SELECT id FROM '.prefixTable('users').' WHERE read_only = %i',
970 970
         1
971 971
     );
972 972
     $readOnly = DB::count();
973 973
     // list the languages
974 974
     $usedLang = [];
975 975
     $tp_languages = DB::query(
976
-        'SELECT name FROM ' . prefixTable('languages')
976
+        'SELECT name FROM '.prefixTable('languages')
977 977
     );
978 978
     foreach ($tp_languages as $tp_language) {
979 979
         DB::query(
980
-            'SELECT * FROM ' . prefixTable('users') . ' WHERE user_language = %s',
980
+            'SELECT * FROM '.prefixTable('users').' WHERE user_language = %s',
981 981
             $tp_language['name']
982 982
         );
983 983
         $usedLang[$tp_language['name']] = round((DB::count() * 100 / $counter_users), 0);
@@ -986,12 +986,12 @@  discard block
 block discarded – undo
986 986
     // get list of ips
987 987
     $usedIp = [];
988 988
     $tp_ips = DB::query(
989
-        'SELECT user_ip FROM ' . prefixTable('users')
989
+        'SELECT user_ip FROM '.prefixTable('users')
990 990
     );
991 991
     foreach ($tp_ips as $ip) {
992 992
         if (array_key_exists($ip['user_ip'], $usedIp)) {
993 993
             $usedIp[$ip['user_ip']] += $usedIp[$ip['user_ip']];
994
-        } elseif (! empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
994
+        } elseif (!empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
995 995
             $usedIp[$ip['user_ip']] = 1;
996 996
         }
997 997
     }
@@ -1086,7 +1086,7 @@  discard block
 block discarded – undo
1086 1086
         <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;">
1087 1087
         <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;">
1088 1088
         <br><div style="float:right;">' .
1089
-        $textMail .
1089
+        $textMail.
1090 1090
         '<br><br></td></tr></table>
1091 1091
     </td></tr></table>
1092 1092
     <br></body></html>';
@@ -1167,7 +1167,7 @@  discard block
 block discarded – undo
1167 1167
 {
1168 1168
     array_walk_recursive(
1169 1169
         $array,
1170
-        static function (&$item): void {
1170
+        static function(&$item): void {
1171 1171
             if (mb_detect_encoding((string) $item, 'utf-8', true) === false) {
1172 1172
                 $item = mb_convert_encoding($item, 'ISO-8859-1', 'UTF-8');
1173 1173
             }
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
  */
1279 1279
 function prefixTable(string $table): string
1280 1280
 {
1281
-    $safeTable = htmlspecialchars(DB_PREFIX . $table);
1281
+    $safeTable = htmlspecialchars(DB_PREFIX.$table);
1282 1282
     return $safeTable;
1283 1283
 }
1284 1284
 
@@ -1395,7 +1395,7 @@  discard block
 block discarded – undo
1395 1395
 function send_syslog($message, $host, $port, $component = 'teampass'): void
1396 1396
 {
1397 1397
     $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
1398
-    $syslog_message = '<123>' . date('M d H:i:s ') . $component . ': ' . $message;
1398
+    $syslog_message = '<123>'.date('M d H:i:s ').$component.': '.$message;
1399 1399
     socket_sendto($sock, (string) $syslog_message, strlen($syslog_message), 0, (string) $host, (int) $port);
1400 1400
     socket_close($sock);
1401 1401
 }
@@ -1442,14 +1442,14 @@  discard block
 block discarded – undo
1442 1442
     if (isset($SETTINGS['syslog_enable']) === true && (int) $SETTINGS['syslog_enable'] === 1) {
1443 1443
         if ($type === 'user_mngt') {
1444 1444
             send_syslog(
1445
-                'action=' . str_replace('at_', '', $label) . ' attribute=user user=' . $who . ' userid="' . $login . '" change="' . $field_1 . '" ',
1445
+                'action='.str_replace('at_', '', $label).' attribute=user user='.$who.' userid="'.$login.'" change="'.$field_1.'" ',
1446 1446
                 $SETTINGS['syslog_host'],
1447 1447
                 $SETTINGS['syslog_port'],
1448 1448
                 'teampass'
1449 1449
             );
1450 1450
         } else {
1451 1451
             send_syslog(
1452
-                'action=' . $type . ' attribute=' . $label . ' user=' . $who . ' userid="' . $login . '" ',
1452
+                'action='.$type.' attribute='.$label.' user='.$who.' userid="'.$login.'" ',
1453 1453
                 $SETTINGS['syslog_host'],
1454 1454
                 $SETTINGS['syslog_port'],
1455 1455
                 'teampass'
@@ -1524,7 +1524,7 @@  discard block
 block discarded – undo
1524 1524
         if (empty($item_label) === true) {
1525 1525
             $dataItem = DB::queryFirstRow(
1526 1526
                 'SELECT id, id_tree, label
1527
-                FROM ' . prefixTable('items') . '
1527
+                FROM ' . prefixTable('items').'
1528 1528
                 WHERE id = %i',
1529 1529
                 $item_id
1530 1530
             );
@@ -1532,11 +1532,11 @@  discard block
 block discarded – undo
1532 1532
         }
1533 1533
 
1534 1534
         send_syslog(
1535
-            'action=' . str_replace('at_', '', $action) .
1536
-                ' attribute=' . str_replace('at_', '', $attribute[0]) .
1537
-                ' itemno=' . $item_id .
1538
-                ' user=' . (is_null($login) === true ? '' : addslashes((string) $login)) .
1539
-                ' itemname="' . addslashes($item_label) . '"',
1535
+            'action='.str_replace('at_', '', $action).
1536
+                ' attribute='.str_replace('at_', '', $attribute[0]).
1537
+                ' itemno='.$item_id.
1538
+                ' user='.(is_null($login) === true ? '' : addslashes((string) $login)).
1539
+                ' itemname="'.addslashes($item_label).'"',
1540 1540
             $SETTINGS['syslog_host'],
1541 1541
             $SETTINGS['syslog_port'],
1542 1542
             'teampass'
@@ -1567,8 +1567,8 @@  discard block
 block discarded – undo
1567 1567
     // send email to user that what to be notified
1568 1568
     $notification = DB::queryFirstField(
1569 1569
         'SELECT email
1570
-        FROM ' . prefixTable('notification') . ' AS n
1571
-        INNER JOIN ' . prefixTable('users') . ' AS u ON (n.user_id = u.id)
1570
+        FROM ' . prefixTable('notification').' AS n
1571
+        INNER JOIN ' . prefixTable('users').' AS u ON (n.user_id = u.id)
1572 1572
         WHERE n.item_id = %i AND n.user_id != %i',
1573 1573
         $item_id,
1574 1574
         $globalsUserId
@@ -1579,7 +1579,7 @@  discard block
 block discarded – undo
1579 1579
         // Get list of changes
1580 1580
         $htmlChanges = '<ul>';
1581 1581
         foreach ($changes as $change) {
1582
-            $htmlChanges .= '<li>' . $change . '</li>';
1582
+            $htmlChanges .= '<li>'.$change.'</li>';
1583 1583
         }
1584 1584
         $htmlChanges .= '</ul>';
1585 1585
         // send email
@@ -1616,15 +1616,15 @@  discard block
 block discarded – undo
1616 1616
     $path = '';
1617 1617
     foreach ($arbo as $elem) {
1618 1618
         if (empty($path) === true) {
1619
-            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES) . ' ';
1619
+            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES).' ';
1620 1620
         } else {
1621
-            $path .= '&#8594; ' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1621
+            $path .= '&#8594; '.htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1622 1622
         }
1623 1623
     }
1624 1624
 
1625 1625
     // Build text to show user
1626 1626
     if (empty($label) === false) {
1627
-        return empty($path) === true ? addslashes($label) : addslashes($label) . ' (' . $path . ')';
1627
+        return empty($path) === true ? addslashes($label) : addslashes($label).' ('.$path.')';
1628 1628
     }
1629 1629
     return empty($path) === true ? '' : $path;
1630 1630
 }
@@ -1680,7 +1680,7 @@  discard block
 block discarded – undo
1680 1680
 {
1681 1681
     // Perform a copy if the file exists
1682 1682
     if (file_exists($configFilePath)) {
1683
-        $backupFilePath = $configFilePath . '.' . date('Y_m_d_His', time());
1683
+        $backupFilePath = $configFilePath.'.'.date('Y_m_d_His', time());
1684 1684
         if (!copy($configFilePath, $backupFilePath)) {
1685 1685
             return "ERROR: Could not copy file '$configFilePath'";
1686 1686
         }
@@ -1688,10 +1688,10 @@  discard block
 block discarded – undo
1688 1688
 
1689 1689
     // Regenerate the config file
1690 1690
     $data = ["<?php\n", "global \$SETTINGS;\n", "\$SETTINGS = array (\n"];
1691
-    $rows = DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s', 'admin');
1691
+    $rows = DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type=%s', 'admin');
1692 1692
     foreach ($rows as $record) {
1693 1693
         $value = getEncryptedValue($record['valeur'], $record['is_encrypted']);
1694
-        $data[] = "    '{$record['intitule']}' => '". htmlspecialchars_decode($value, ENT_COMPAT) . "',\n";
1694
+        $data[] = "    '{$record['intitule']}' => '".htmlspecialchars_decode($value, ENT_COMPAT)."',\n";
1695 1695
     }
1696 1696
     $data[] = ");\n";
1697 1697
     $data = array_unique($data);
@@ -1736,7 +1736,7 @@  discard block
 block discarded – undo
1736 1736
 {
1737 1737
     global $SETTINGS;
1738 1738
     /* LOAD CPASSMAN SETTINGS */
1739
-    if (! isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
1739
+    if (!isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
1740 1740
         $SETTINGS = [];
1741 1741
         $SETTINGS['duplicate_folder'] = 0;
1742 1742
         //by default, this is set to 0;
@@ -1746,7 +1746,7 @@  discard block
 block discarded – undo
1746 1746
         //by default, this value is set to 5;
1747 1747
         $settings = [];
1748 1748
         $rows = DB::query(
1749
-            'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s_type OR type=%s_type2',
1749
+            'SELECT * FROM '.prefixTable('misc').' WHERE type=%s_type OR type=%s_type2',
1750 1750
             [
1751 1751
                 'type' => 'admin',
1752 1752
                 'type2' => 'settings',
@@ -1778,7 +1778,7 @@  discard block
 block discarded – undo
1778 1778
     $source_cf = [];
1779 1779
     $rows = DB::query(
1780 1780
         'SELECT id_category
1781
-            FROM ' . prefixTable('categories_folders') . '
1781
+            FROM ' . prefixTable('categories_folders').'
1782 1782
             WHERE id_folder = %i',
1783 1783
         $source_id
1784 1784
     );
@@ -1789,7 +1789,7 @@  discard block
 block discarded – undo
1789 1789
     $target_cf = [];
1790 1790
     $rows = DB::query(
1791 1791
         'SELECT id_category
1792
-            FROM ' . prefixTable('categories_folders') . '
1792
+            FROM ' . prefixTable('categories_folders').'
1793 1793
             WHERE id_folder = %i',
1794 1794
         $target_id
1795 1795
     );
@@ -1884,10 +1884,10 @@  discard block
 block discarded – undo
1884 1884
     } catch (CryptoException\WrongKeyOrModifiedCiphertextException $ex) {
1885 1885
         $err = 'wrong_key';
1886 1886
     } catch (CryptoException\EnvironmentIsBrokenException $ex) {
1887
-        error_log('TEAMPASS-Error-Environment: ' . $ex->getMessage());
1887
+        error_log('TEAMPASS-Error-Environment: '.$ex->getMessage());
1888 1888
         $err = 'environment_error';
1889 1889
     } catch (CryptoException\IOException $ex) {
1890
-        error_log('TEAMPASS-Error-General: ' . $ex->getMessage());
1890
+        error_log('TEAMPASS-Error-General: '.$ex->getMessage());
1891 1891
         $err = 'general_error';
1892 1892
     }
1893 1893
 
@@ -1919,10 +1919,10 @@  discard block
 block discarded – undo
1919 1919
     } catch (CryptoException\WrongKeyOrModifiedCiphertextException $ex) {
1920 1920
         $err = 'wrong_key';
1921 1921
     } catch (CryptoException\EnvironmentIsBrokenException $ex) {
1922
-        error_log('TEAMPASS-Error-Environment: ' . $ex->getMessage());
1922
+        error_log('TEAMPASS-Error-Environment: '.$ex->getMessage());
1923 1923
         $err = 'environment_error';
1924 1924
     } catch (CryptoException\IOException $ex) {
1925
-        error_log('TEAMPASS-Error-General: ' . $ex->getMessage());
1925
+        error_log('TEAMPASS-Error-General: '.$ex->getMessage());
1926 1926
         $err = 'general_error';
1927 1927
     }
1928 1928
 
@@ -2008,7 +2008,7 @@  discard block
 block discarded – undo
2008 2008
 ) {
2009 2009
     // Check if the path exists
2010 2010
     $path = basename($path);
2011
-    if (! file_exists($path)) {
2011
+    if (!file_exists($path)) {
2012 2012
         return false;
2013 2013
     }
2014 2014
 
@@ -2061,7 +2061,7 @@  discard block
 block discarded – undo
2061 2061
     // Load item data
2062 2062
     $data = DB::queryFirstRow(
2063 2063
         'SELECT id_tree
2064
-        FROM ' . prefixTable('items') . '
2064
+        FROM ' . prefixTable('items').'
2065 2065
         WHERE id = %i',
2066 2066
         $item_id
2067 2067
     );
@@ -2124,7 +2124,7 @@  discard block
 block discarded – undo
2124 2124
         }
2125 2125
         $host .= substr(explode(".", $email[1])[0], -1, 1);
2126 2126
     }
2127
-    $email = $name . "@" . $host . "." . explode(".", $email[1])[1];
2127
+    $email = $name."@".$host.".".explode(".", $email[1])[1];
2128 2128
     return $email;
2129 2129
 }
2130 2130
 
@@ -2155,11 +2155,11 @@  discard block
 block discarded – undo
2155 2155
 function formatSizeUnits(int $bytes): string
2156 2156
 {
2157 2157
     if ($bytes >= 1073741824) {
2158
-        $bytes = number_format($bytes / 1073741824, 2) . ' GB';
2158
+        $bytes = number_format($bytes / 1073741824, 2).' GB';
2159 2159
     } elseif ($bytes >= 1048576) {
2160
-        $bytes = number_format($bytes / 1048576, 2) . ' MB';
2160
+        $bytes = number_format($bytes / 1048576, 2).' MB';
2161 2161
     } elseif ($bytes >= 1024) {
2162
-        $bytes = number_format($bytes / 1024, 2) . ' KB';
2162
+        $bytes = number_format($bytes / 1024, 2).' KB';
2163 2163
     } elseif ($bytes > 1) {
2164 2164
         $bytes .= ' bytes';
2165 2165
     } elseif ($bytes === 1) {
@@ -2326,7 +2326,7 @@  discard block
 block discarded – undo
2326 2326
  */
2327 2327
 function generateKeyIntegrityHash(string $userSeed, string $publicKey, string $serverSecret): string
2328 2328
 {
2329
-    return hash_hmac('sha256', $userSeed . $publicKey, $serverSecret);
2329
+    return hash_hmac('sha256', $userSeed.$publicKey, $serverSecret);
2330 2330
 }
2331 2331
 
2332 2332
 /**
@@ -2401,7 +2401,7 @@  discard block
 block discarded – undo
2401 2401
                 'security_alert',
2402 2402
                 'key_integrity_check_failed',
2403 2403
                 (string) $userInfo['id'],
2404
-                'User: ' . $userInfo['login']
2404
+                'User: '.$userInfo['login']
2405 2405
             );
2406 2406
             return [
2407 2407
                 'success' => false,
@@ -2448,7 +2448,7 @@  discard block
 block discarded – undo
2448 2448
             'user_connection',
2449 2449
             'auto_reencryption_success',
2450 2450
             (string) $userInfo['id'],
2451
-            'User: ' . $userInfo['login']
2451
+            'User: '.$userInfo['login']
2452 2452
         );
2453 2453
 
2454 2454
         // Store in session for immediate use
@@ -2467,12 +2467,12 @@  discard block
 block discarded – undo
2467 2467
             'security_alert',
2468 2468
             'auto_reencryption_failed',
2469 2469
             (string) $userInfo['id'],
2470
-            'User: ' . $userInfo['login'] . ' - Error: ' . $e->getMessage()
2470
+            'User: '.$userInfo['login'].' - Error: '.$e->getMessage()
2471 2471
         );
2472 2472
 
2473 2473
         return [
2474 2474
             'success' => false,
2475
-            'error' => 'decryption_failed: ' . $e->getMessage(),
2475
+            'error' => 'decryption_failed: '.$e->getMessage(),
2476 2476
             'private_key_clear' => '',
2477 2477
         ];
2478 2478
     }
@@ -2539,7 +2539,7 @@  discard block
 block discarded – undo
2539 2539
         'security_alert',
2540 2540
         'auto_reencryption_critical_failure',
2541 2541
         (string) $userId,
2542
-        'User: ' . $userInfo['login'] . ' - disabled due to key recovery failure'
2542
+        'User: '.$userInfo['login'].' - disabled due to key recovery failure'
2543 2543
     );
2544 2544
 
2545 2545
     return false;
@@ -2697,7 +2697,7 @@  discard block
 block discarded – undo
2697 2697
     $cipher->enableContinuousBuffer();
2698 2698
 
2699 2699
     // Encrypt the file content
2700
-    $filePath = filter_var($fileInPath . '/' . $fileInName, FILTER_SANITIZE_URL);
2700
+    $filePath = filter_var($fileInPath.'/'.$fileInName, FILTER_SANITIZE_URL);
2701 2701
     $fileContent = file_get_contents($filePath);
2702 2702
     $plaintext = $fileContent;
2703 2703
     $ciphertext = $cipher->encrypt($plaintext);
@@ -2705,9 +2705,9 @@  discard block
 block discarded – undo
2705 2705
     // Save new file
2706 2706
     // deepcode ignore InsecureHash: is simply used to get a unique name
2707 2707
     $hash = uniqid('', true);
2708
-    $fileOut = $fileInPath . '/' . TP_FILE_PREFIX . $hash;
2708
+    $fileOut = $fileInPath.'/'.TP_FILE_PREFIX.$hash;
2709 2709
     file_put_contents($fileOut, $ciphertext);
2710
-    unlink($fileInPath . '/' . $fileInName);
2710
+    unlink($fileInPath.'/'.$fileInName);
2711 2711
     return [
2712 2712
         'fileHash' => base64_encode($hash),
2713 2713
         'objectKey' => base64_encode($objectKey),
@@ -2723,9 +2723,9 @@  discard block
 block discarded – undo
2723 2723
  *
2724 2724
  * @return string|array
2725 2725
  */
2726
-function decryptFile(string $fileName, string $filePath, string $key): string|array
2726
+function decryptFile(string $fileName, string $filePath, string $key): string | array
2727 2727
 {
2728
-    if (! defined('FILE_BUFFER_SIZE')) {
2728
+    if (!defined('FILE_BUFFER_SIZE')) {
2729 2729
         define('FILE_BUFFER_SIZE', 128 * 1024);
2730 2730
     }
2731 2731
     
@@ -2742,7 +2742,7 @@  discard block
 block discarded – undo
2742 2742
     $cipher->enableContinuousBuffer();
2743 2743
     $cipher->disablePadding();
2744 2744
     // Get file content
2745
-    $safeFilePath = realpath($filePath . '/' . TP_FILE_PREFIX . $safeFileName);
2745
+    $safeFilePath = realpath($filePath.'/'.TP_FILE_PREFIX.$safeFileName);
2746 2746
     if ($safeFilePath !== false && file_exists($safeFilePath)) {
2747 2747
         $ciphertext = file_get_contents(filter_var($safeFilePath, FILTER_SANITIZE_URL));
2748 2748
     } else {
@@ -2839,7 +2839,7 @@  discard block
 block discarded – undo
2839 2839
         // Get public keys for all target users
2840 2840
         $users = DB::query(
2841 2841
             'SELECT id, public_key
2842
-            FROM ' . prefixTable('users') . '
2842
+            FROM ' . prefixTable('users').'
2843 2843
             WHERE id IN %li
2844 2844
             AND public_key != ""',
2845 2845
             $userIds
@@ -2878,7 +2878,7 @@  discard block
 block discarded – undo
2878 2878
         }
2879 2879
         $users = DB::query(
2880 2880
             'SELECT id, public_key
2881
-            FROM ' . prefixTable('users') . '
2881
+            FROM ' . prefixTable('users').'
2882 2882
             WHERE id NOT IN %li
2883 2883
             AND public_key != ""',
2884 2884
             $user_ids
@@ -2887,7 +2887,7 @@  discard block
 block discarded – undo
2887 2887
             // Insert in DB the new object key for this item by user
2888 2888
             if (count($objectKeyArray) === 0) {
2889 2889
                 if (WIP === true) {
2890
-                    error_log('TEAMPASS Debug - storeUsersShareKey case1 - ' . $object_name . ' - ' . $post_object_id . ' - ' . $user['id']);
2890
+                    error_log('TEAMPASS Debug - storeUsersShareKey case1 - '.$object_name.' - '.$post_object_id.' - '.$user['id']);
2891 2891
                 }
2892 2892
                 
2893 2893
                 insertOrUpdateSharekey(
@@ -2899,7 +2899,7 @@  discard block
 block discarded – undo
2899 2899
             } else {
2900 2900
                 foreach ($objectKeyArray as $object) {
2901 2901
                     if (WIP === true) {
2902
-                        error_log('TEAMPASS Debug - storeUsersShareKey case2 - ' . $object_name . ' - ' . $object['objectId'] . ' - ' . $user['id']);
2902
+                        error_log('TEAMPASS Debug - storeUsersShareKey case2 - '.$object_name.' - '.$object['objectId'].' - '.$user['id']);
2903 2903
                     }
2904 2904
                     
2905 2905
                     insertOrUpdateSharekey(
@@ -2932,7 +2932,7 @@  discard block
 block discarded – undo
2932 2932
 ): bool {
2933 2933
     try {
2934 2934
         DB::query(
2935
-            'INSERT INTO ' . $tableName . ' 
2935
+            'INSERT INTO '.$tableName.' 
2936 2936
             (object_id, user_id, share_key) 
2937 2937
             VALUES (%i, %i, %s)
2938 2938
             ON DUPLICATE KEY UPDATE share_key = VALUES(share_key)',
@@ -2942,7 +2942,7 @@  discard block
 block discarded – undo
2942 2942
         );
2943 2943
         return true;
2944 2944
     } catch (Exception $e) {
2945
-        error_log('TEAMPASS Error - insertOrUpdateSharekey: ' . $e->getMessage());
2945
+        error_log('TEAMPASS Error - insertOrUpdateSharekey: '.$e->getMessage());
2946 2946
         return false;
2947 2947
     }
2948 2948
 }
@@ -2957,7 +2957,7 @@  discard block
 block discarded – undo
2957 2957
 function isBase64(string $str): bool
2958 2958
 {
2959 2959
     $str = (string) trim($str);
2960
-    if (! isset($str[0])) {
2960
+    if (!isset($str[0])) {
2961 2961
         return false;
2962 2962
     }
2963 2963
 
@@ -3031,7 +3031,7 @@  discard block
 block discarded – undo
3031 3031
     } catch (\LdapRecord\Auth\BindException $e) {
3032 3032
         $error = $e->getDetailedError();
3033 3033
         if ($error && defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
3034
-            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage(). " - ".$error->getDiagnosticMessage());
3034
+            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage()." - ".$error->getDiagnosticMessage());
3035 3035
         }
3036 3036
         // deepcode ignore ServerLeak: No important data is sent
3037 3037
         echo 'An error occurred.';
@@ -3048,7 +3048,7 @@  discard block
 block discarded – undo
3048 3048
     } catch (\LdapRecord\Auth\BindException $e) {
3049 3049
         $error = $e->getDetailedError();
3050 3050
         if ($error && defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
3051
-            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage(). " - ".$error->getDiagnosticMessage());
3051
+            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage()." - ".$error->getDiagnosticMessage());
3052 3052
         }
3053 3053
         // deepcode ignore ServerLeak: No important data is sent
3054 3054
         echo 'An error occurred.';
@@ -3084,7 +3084,7 @@  discard block
 block discarded – undo
3084 3084
     // expect if personal item
3085 3085
     DB::delete(
3086 3086
         prefixTable('sharekeys_items'),
3087
-        'user_id = %i',// AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)'',
3087
+        'user_id = %i', // AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)'',
3088 3088
         $userId
3089 3089
     );
3090 3090
     // Remove all item sharekeys files
@@ -3108,7 +3108,7 @@  discard block
 block discarded – undo
3108 3108
     // Remove all item sharekeys suggestions
3109 3109
     DB::delete(
3110 3110
         prefixTable('sharekeys_suggestions'),
3111
-        'user_id = %i',// AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
3111
+        'user_id = %i', // AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
3112 3112
         $userId
3113 3113
     );
3114 3114
     return false;
@@ -3129,7 +3129,7 @@  discard block
 block discarded – undo
3129 3129
         foreach (DateTimeZone::listIdentifiers() as $timezone) {
3130 3130
             $now->setTimezone(new DateTimeZone($timezone));
3131 3131
             $offsets[] = $offset = $now->getOffset();
3132
-            $timezones[$timezone] = '(' . format_GMT_offset($offset) . ') ' . format_timezone_name($timezone);
3132
+            $timezones[$timezone] = '('.format_GMT_offset($offset).') '.format_timezone_name($timezone);
3133 3133
         }
3134 3134
 
3135 3135
         array_multisort($offsets, $timezones);
@@ -3149,7 +3149,7 @@  discard block
 block discarded – undo
3149 3149
 {
3150 3150
     $hours = intval($offset / 3600);
3151 3151
     $minutes = abs(intval($offset % 3600 / 60));
3152
-    return 'GMT' . ($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
3152
+    return 'GMT'.($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
3153 3153
 }
3154 3154
 
3155 3155
 /**
@@ -3248,8 +3248,7 @@  discard block
 block discarded – undo
3248 3248
 {
3249 3249
     if (isset($array[$key]) === true
3250 3250
         && (is_int($value) === true ?
3251
-            (int) $array[$key] === $value :
3252
-            (string) $array[$key] === $value)
3251
+            (int) $array[$key] === $value : (string) $array[$key] === $value)
3253 3252
     ) {
3254 3253
         return true;
3255 3254
     }
@@ -3271,8 +3270,7 @@  discard block
 block discarded – undo
3271 3270
 {
3272 3271
     if (isset($var) === false
3273 3272
         || (is_int($value) === true ?
3274
-            (int) $var === $value :
3275
-            (string) $var === $value)
3273
+            (int) $var === $value : (string) $var === $value)
3276 3274
     ) {
3277 3275
         return true;
3278 3276
     }
@@ -3323,7 +3321,7 @@  discard block
 block discarded – undo
3323 3321
  */
3324 3322
 function isSetArrayOfValues(array $arrayOfValues): bool
3325 3323
 {
3326
-    foreach($arrayOfValues as $value) {
3324
+    foreach ($arrayOfValues as $value) {
3327 3325
         if (isset($value) === false) {
3328 3326
             return false;
3329 3327
         }
@@ -3345,7 +3343,7 @@  discard block
 block discarded – undo
3345 3343
     /*PHP8 - integer|string*/$value
3346 3344
 ) : bool
3347 3345
 {
3348
-    foreach($arrayOfVars as $variable) {
3346
+    foreach ($arrayOfVars as $variable) {
3349 3347
         if ($variable !== $value) {
3350 3348
             return false;
3351 3349
         }
@@ -3365,7 +3363,7 @@  discard block
 block discarded – undo
3365 3363
     /*PHP8 - integer|string*/$value
3366 3364
 ) : bool
3367 3365
 {
3368
-    foreach($arrayOfVars as $variable) {
3366
+    foreach ($arrayOfVars as $variable) {
3369 3367
         if ($variable === $value) {
3370 3368
             return true;
3371 3369
         }
@@ -3379,7 +3377,7 @@  discard block
 block discarded – undo
3379 3377
  * @param string|int|null $value
3380 3378
  * @return boolean
3381 3379
  */
3382
-function isValueSetNullEmpty(string|int|null $value) : bool
3380
+function isValueSetNullEmpty(string | int | null $value) : bool
3383 3381
 {
3384 3382
     if (is_null($value) === true || empty($value) === true) {
3385 3383
         return true;
@@ -3434,7 +3432,7 @@  discard block
 block discarded – undo
3434 3432
  * @param array     $filters
3435 3433
  * @return array|string
3436 3434
  */
3437
-function dataSanitizer(array $data, array $filters): array|string
3435
+function dataSanitizer(array $data, array $filters): array | string
3438 3436
 {
3439 3437
     // Load Sanitizer library
3440 3438
     $sanitizer = new Sanitizer($data, $filters);
@@ -3463,7 +3461,7 @@  discard block
 block discarded – undo
3463 3461
     // Exists ?
3464 3462
     $userCacheId = DB::queryFirstRow(
3465 3463
         'SELECT increment_id
3466
-        FROM ' . prefixTable('cache_tree') . '
3464
+        FROM ' . prefixTable('cache_tree').'
3467 3465
         WHERE user_id = %i',
3468 3466
         $user_id
3469 3467
     );
@@ -3514,7 +3512,7 @@  discard block
 block discarded – undo
3514 3512
  */
3515 3513
 function pourcentage(float $nombre, float $total, float $pourcentage): float
3516 3514
 { 
3517
-    $resultat = ($nombre/$total) * $pourcentage;
3515
+    $resultat = ($nombre / $total) * $pourcentage;
3518 3516
     return round($resultat);
3519 3517
 }
3520 3518
 
@@ -3544,7 +3542,7 @@  discard block
 block discarded – undo
3544 3542
 
3545 3543
     // Get last folder update
3546 3544
     $lastFolderChange = DB::queryFirstRow(
3547
-        'SELECT valeur FROM ' . prefixTable('misc') . '
3545
+        'SELECT valeur FROM '.prefixTable('misc').'
3548 3546
         WHERE type = %s AND intitule = %s',
3549 3547
         'timestamp',
3550 3548
         'last_folder_change'
@@ -3565,7 +3563,7 @@  discard block
 block discarded – undo
3565 3563
     // Does this user has a tree cache
3566 3564
     $userCacheTree = DB::queryFirstRow(
3567 3565
         'SELECT '.$fieldName.'
3568
-        FROM ' . prefixTable('cache_tree') . '
3566
+        FROM ' . prefixTable('cache_tree').'
3569 3567
         WHERE user_id = %i',
3570 3568
         $session->get('user-id')
3571 3569
     );
@@ -3603,7 +3601,7 @@  discard block
 block discarded – undo
3603 3601
     if (count($folderIds) === 0) {
3604 3602
         $folderIds = DB::queryFirstColumn(
3605 3603
             'SELECT id
3606
-            FROM ' . prefixTable('nested_tree') . '
3604
+            FROM ' . prefixTable('nested_tree').'
3607 3605
             WHERE personal_folder=%i',
3608 3606
             0
3609 3607
         );
@@ -3620,8 +3618,8 @@  discard block
 block discarded – undo
3620 3618
         $rows_tmp = DB::query(
3621 3619
             'SELECT c.id, c.title, c.level, c.type, c.masked, c.order, c.encrypted_data, c.role_visibility, c.is_mandatory,
3622 3620
             f.id_category AS category_id
3623
-            FROM ' . prefixTable('categories_folders') . ' AS f
3624
-            INNER JOIN ' . prefixTable('categories') . ' AS c ON (f.id_category = c.parent_id)
3621
+            FROM ' . prefixTable('categories_folders').' AS f
3622
+            INNER JOIN ' . prefixTable('categories').' AS c ON (f.id_category = c.parent_id)
3625 3623
             WHERE id_folder=%i',
3626 3624
             $folder
3627 3625
         );
@@ -3647,7 +3645,7 @@  discard block
 block discarded – undo
3647 3645
         $valTemp = '';
3648 3646
         $data = DB::queryFirstRow(
3649 3647
             'SELECT valeur
3650
-            FROM ' . prefixTable('misc') . '
3648
+            FROM ' . prefixTable('misc').'
3651 3649
             WHERE type = %s AND intitule=%i',
3652 3650
             'complex',
3653 3651
             $folder
@@ -3664,14 +3662,14 @@  discard block
 block discarded – undo
3664 3662
         $valTemp = '';
3665 3663
         $rows_tmp = DB::query(
3666 3664
             'SELECT t.title
3667
-            FROM ' . prefixTable('roles_values') . ' as v
3668
-            INNER JOIN ' . prefixTable('roles_title') . ' as t ON (v.role_id = t.id)
3665
+            FROM ' . prefixTable('roles_values').' as v
3666
+            INNER JOIN ' . prefixTable('roles_title').' as t ON (v.role_id = t.id)
3669 3667
             WHERE v.folder_id = %i
3670 3668
             GROUP BY title',
3671 3669
             $folder
3672 3670
         );
3673 3671
         foreach ($rows_tmp as $record) {
3674
-            $valTemp .= (empty($valTemp) === true ? '' : ' - ') . $record['title'];
3672
+            $valTemp .= (empty($valTemp) === true ? '' : ' - ').$record['title'];
3675 3673
         }
3676 3674
         $arr_data['visibilityRoles'] = $valTemp;
3677 3675
 
@@ -3704,7 +3702,7 @@  discard block
 block discarded – undo
3704 3702
         // loop on users and check if user has this role
3705 3703
         $rows = DB::query(
3706 3704
             'SELECT id, fonction_id
3707
-            FROM ' . prefixTable('users') . '
3705
+            FROM ' . prefixTable('users').'
3708 3706
             WHERE id != %i AND admin = 0 AND fonction_id IS NOT NULL AND fonction_id != ""',
3709 3707
             $session->get('user-id')
3710 3708
         );
@@ -3736,7 +3734,7 @@  discard block
 block discarded – undo
3736 3734
 
3737 3735
     $val = DB::queryFirstRow(
3738 3736
         'SELECT *
3739
-        FROM ' . prefixTable('users') . '
3737
+        FROM ' . prefixTable('users').'
3740 3738
         WHERE id = %i',
3741 3739
         $userId
3742 3740
     );
@@ -3752,12 +3750,12 @@  discard block
 block discarded – undo
3752 3750
 function upgradeRequired(): bool
3753 3751
 {
3754 3752
     // Get settings.php
3755
-    include_once __DIR__. '/../includes/config/settings.php';
3753
+    include_once __DIR__.'/../includes/config/settings.php';
3756 3754
 
3757 3755
     // Get timestamp in DB
3758 3756
     $val = DB::queryFirstRow(
3759 3757
         'SELECT valeur
3760
-        FROM ' . prefixTable('misc') . '
3758
+        FROM ' . prefixTable('misc').'
3761 3759
         WHERE type = %s AND intitule = %s',
3762 3760
         'admin',
3763 3761
         'upgrade_timestamp'
@@ -3810,7 +3808,7 @@  discard block
 block discarded – undo
3810 3808
     // prepapre background tasks for item keys generation        
3811 3809
     $userTP = DB::queryFirstRow(
3812 3810
         'SELECT pw, public_key, private_key
3813
-        FROM ' . prefixTable('users') . '
3811
+        FROM ' . prefixTable('users').'
3814 3812
         WHERE id = %i',
3815 3813
         TP_USER_ID
3816 3814
     );
@@ -3871,7 +3869,7 @@  discard block
 block discarded – undo
3871 3869
     }
3872 3870
 
3873 3871
     // Generate new keys
3874
-    if ($user_self_change === true && empty($recovery_public_key) === false && empty($recovery_private_key) === false){
3872
+    if ($user_self_change === true && empty($recovery_public_key) === false && empty($recovery_private_key) === false) {
3875 3873
         $userKeys = [
3876 3874
             'public_key' => $recovery_public_key,
3877 3875
             'private_key_clear' => $recovery_private_key,
@@ -3922,8 +3920,8 @@  discard block
 block discarded – undo
3922 3920
             'process_type' => 'create_user_keys',
3923 3921
             'arguments' => json_encode([
3924 3922
                 'new_user_id' => (int) $userId,
3925
-                'new_user_pwd' => cryption($passwordClear, '','encrypt')['string'],
3926
-                'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '','encrypt')['string'],
3923
+                'new_user_pwd' => cryption($passwordClear, '', 'encrypt')['string'],
3924
+                'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '', 'encrypt')['string'],
3927 3925
                 'owner_id' => (int) TP_USER_ID,
3928 3926
                 'creator_pwd' => $userTP['pw'],
3929 3927
                 'send_email' => $sendEmailToUser === true ? 1 : 0,
@@ -3995,19 +3993,19 @@  discard block
 block discarded – undo
3995 3993
 
3996 3994
     // Prepare the subtask queries
3997 3995
     $queries = [
3998
-        'step20' => 'SELECT * FROM ' . prefixTable('items'),
3996
+        'step20' => 'SELECT * FROM '.prefixTable('items'),
3999 3997
 
4000
-        'step30' => 'SELECT * FROM ' . prefixTable('log_items') . 
3998
+        'step30' => 'SELECT * FROM '.prefixTable('log_items'). 
4001 3999
                     ' WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"',
4002 4000
 
4003
-        'step40' => 'SELECT * FROM ' . prefixTable('categories_items') . 
4001
+        'step40' => 'SELECT * FROM '.prefixTable('categories_items'). 
4004 4002
                     ' WHERE encryption_type = "teampass_aes"',
4005 4003
 
4006
-        'step50' => 'SELECT * FROM ' . prefixTable('suggestion'),
4004
+        'step50' => 'SELECT * FROM '.prefixTable('suggestion'),
4007 4005
 
4008
-        'step60' => 'SELECT * FROM ' . prefixTable('files') . ' AS f
4009
-                        INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = f.id_item
4010
-                        WHERE f.status = "' . TP_ENCRYPTION_NAME . '"'
4006
+        'step60' => 'SELECT * FROM '.prefixTable('files').' AS f
4007
+                        INNER JOIN ' . prefixTable('items').' AS i ON i.id = f.id_item
4008
+                        WHERE f.status = "' . TP_ENCRYPTION_NAME.'"'
4011 4009
     ];
4012 4010
 
4013 4011
     // Perform loop on $queries to create sub-tasks
@@ -4197,7 +4195,7 @@  discard block
 block discarded – undo
4197 4195
  */
4198 4196
 function createTaskForItem(
4199 4197
     string $processType,
4200
-    string|array $taskName,
4198
+    string | array $taskName,
4201 4199
     int $itemId,
4202 4200
     int $userId,
4203 4201
     string $objectKey,
@@ -4221,7 +4219,7 @@  discard block
 block discarded – undo
4221 4219
                 'object_key' => $objectKey,
4222 4220
                 'author' => (int) $userId,
4223 4221
             ]),
4224
-            'item_id' => (int) $parentId !== -1 ?  $parentId : null,
4222
+            'item_id' => (int) $parentId !== -1 ? $parentId : null,
4225 4223
         )
4226 4224
     );
4227 4225
     $processId = DB::insertId();
@@ -4231,7 +4229,7 @@  discard block
 block discarded – undo
4231 4229
     if (is_array($taskName) === false) {
4232 4230
         $taskName = [$taskName];
4233 4231
     }
4234
-    foreach($taskName as $task) {
4232
+    foreach ($taskName as $task) {
4235 4233
         if (WIP === true) error_log('createTaskForItem - task: '.$task);
4236 4234
         switch ($task) {
4237 4235
             case 'item_password':
@@ -4328,7 +4326,7 @@  discard block
 block discarded – undo
4328 4326
  * @param integer $user_id
4329 4327
  * @return void
4330 4328
  */
4331
-function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id=0)
4329
+function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id = 0)
4332 4330
 {
4333 4331
     if ($allUsers === true) {
4334 4332
         // Load class DB
@@ -4338,7 +4336,7 @@  discard block
 block discarded – undo
4338 4336
 
4339 4337
         $users = DB::query(
4340 4338
             'SELECT id
4341
-            FROM ' . prefixTable('users') . '
4339
+            FROM ' . prefixTable('users').'
4342 4340
             WHERE id NOT IN ('.OTV_USER_ID.', '.TP_USER_ID.', '.SSH_USER_ID.', '.API_USER_ID.')
4343 4341
             ORDER BY login ASC'
4344 4342
         );
@@ -4356,7 +4354,7 @@  discard block
 block discarded – undo
4356 4354
  * @param integer $user_id
4357 4355
  * @return void
4358 4356
  */
4359
-function purgeUnnecessaryKeysForUser(int $user_id=0)
4357
+function purgeUnnecessaryKeysForUser(int $user_id = 0)
4360 4358
 {
4361 4359
     if ($user_id === 0) {
4362 4360
         return;
@@ -4367,8 +4365,8 @@  discard block
 block discarded – undo
4367 4365
 
4368 4366
     $personalItems = DB::queryFirstColumn(
4369 4367
         'SELECT id
4370
-        FROM ' . prefixTable('items') . ' AS i
4371
-        INNER JOIN ' . prefixTable('log_items') . ' AS li ON li.id_item = i.id
4368
+        FROM ' . prefixTable('items').' AS i
4369
+        INNER JOIN ' . prefixTable('log_items').' AS li ON li.id_item = i.id
4372 4370
         WHERE i.perso = 1 AND li.action = "at_creation" AND li.id_user IN (%i, '.TP_USER_ID.')',
4373 4371
         $user_id
4374 4372
     );
@@ -4378,28 +4376,28 @@  discard block
 block discarded – undo
4378 4376
             prefixTable('sharekeys_items'),
4379 4377
             'object_id IN %li AND user_id NOT IN %ls',
4380 4378
             $personalItems,
4381
-            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4379
+            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4382 4380
         );
4383 4381
         // Files keys
4384 4382
         DB::delete(
4385 4383
             prefixTable('sharekeys_files'),
4386 4384
             'object_id IN %li AND user_id NOT IN %ls',
4387 4385
             $personalItems,
4388
-            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4386
+            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4389 4387
         );
4390 4388
         // Fields keys
4391 4389
         DB::delete(
4392 4390
             prefixTable('sharekeys_fields'),
4393 4391
             'object_id IN %li AND user_id NOT IN %ls',
4394 4392
             $personalItems,
4395
-            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4393
+            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4396 4394
         );
4397 4395
         // Logs keys
4398 4396
         DB::delete(
4399 4397
             prefixTable('sharekeys_logs'),
4400 4398
             'object_id IN %li AND user_id NOT IN %ls',
4401 4399
             $personalItems,
4402
-            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4400
+            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4403 4401
         );
4404 4402
     }
4405 4403
 }
@@ -4417,7 +4415,7 @@  discard block
 block discarded – undo
4417 4415
     // Check if user exists
4418 4416
     $userInfo = DB::queryFirstRow(
4419 4417
         'SELECT login
4420
-        FROM ' . prefixTable('users') . '
4418
+        FROM ' . prefixTable('users').'
4421 4419
         WHERE id = %i',
4422 4420
         $userId
4423 4421
     );
@@ -4426,7 +4424,7 @@  discard block
 block discarded – undo
4426 4424
         $now = (int) time();
4427 4425
         // Prepare file content
4428 4426
         $export_value = file_get_contents(__DIR__."/../includes/core/teampass_ascii.txt")."\n".
4429
-            "Generation date: ".date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now)."\n\n".
4427
+            "Generation date: ".date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now)."\n\n".
4430 4428
             "RECOVERY KEYS - Not to be shared - To be store safely\n\n".
4431 4429
             "Public Key:\n".$session->get('user-public_key')."\n\n".
4432 4430
             "Private Key:\n".$session->get('user-private_key')."\n\n";
@@ -4449,7 +4447,7 @@  discard block
 block discarded – undo
4449 4447
         return prepareExchangedData(
4450 4448
             array(
4451 4449
                 'error' => false,
4452
-                'datetime' => date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now),
4450
+                'datetime' => date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now),
4453 4451
                 'timestamp' => $now,
4454 4452
                 'content' => base64_encode($export_value),
4455 4453
                 'login' => $userInfo['login'],
@@ -4475,8 +4473,8 @@  discard block
 block discarded – undo
4475 4473
  */
4476 4474
 function loadClasses(string $className = ''): void
4477 4475
 {
4478
-    require_once __DIR__. '/../includes/config/include.php';
4479
-    require_once __DIR__. '/../includes/config/settings.php';
4476
+    require_once __DIR__.'/../includes/config/include.php';
4477
+    require_once __DIR__.'/../includes/config/settings.php';
4480 4478
     require_once __DIR__.'/../vendor/autoload.php';
4481 4479
 
4482 4480
     if (defined('DB_PASSWD_CLEAR') === false) {
@@ -4689,7 +4687,7 @@  discard block
 block discarded – undo
4689 4687
 
4690 4688
     // Get current user hash
4691 4689
     $userHash = DB::queryFirstRow(
4692
-        "SELECT pw FROM " . prefixtable('users') . " WHERE id = %d;",
4690
+        "SELECT pw FROM ".prefixtable('users')." WHERE id = %d;",
4693 4691
         $session->get('user-id')
4694 4692
     )['pw'];
4695 4693
 
@@ -4737,11 +4735,11 @@  discard block
 block discarded – undo
4737 4735
         }
4738 4736
         
4739 4737
         // Alternative: serialize ou json selon le contexte
4740
-        return get_class($value) . (method_exists($value, 'getId') ? '#' . $value->getId() : '');
4738
+        return get_class($value).(method_exists($value, 'getId') ? '#'.$value->getId() : '');
4741 4739
     }
4742 4740
     
4743 4741
     if (is_resource($value)) {
4744
-        return 'Resource#' . get_resource_id($value) . ' of type ' . get_resource_type($value);
4742
+        return 'Resource#'.get_resource_id($value).' of type '.get_resource_type($value);
4745 4743
     }
4746 4744
     
4747 4745
     // Cas par défaut
@@ -4761,7 +4759,7 @@  discard block
 block discarded – undo
4761 4759
     // Refuse access if user does not exist and/or is admin
4762 4760
     $user = DB::queryFirstRow(
4763 4761
         'SELECT admin
4764
-        FROM ' . prefixTable('users') . '
4762
+        FROM ' . prefixTable('users').'
4765 4763
         WHERE id = %i',
4766 4764
         $userId
4767 4765
     );
@@ -4772,8 +4770,8 @@  discard block
 block discarded – undo
4772 4770
     // Get file info
4773 4771
     $file = DB::queryFirstRow(
4774 4772
         'SELECT f.id_item, i.id_tree
4775
-        FROM ' . prefixTable('files') . ' as f
4776
-        INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = f.id_item
4773
+        FROM ' . prefixTable('files').' as f
4774
+        INNER JOIN ' . prefixTable('items').' AS i ON i.id = f.id_item
4777 4775
         WHERE f.id = %i',
4778 4776
         $fileId
4779 4777
     );
@@ -4782,7 +4780,7 @@  discard block
 block discarded – undo
4782 4780
     }
4783 4781
 
4784 4782
     // Check if user has access to the item
4785
-    include_once __DIR__. '/items.queries.php';
4783
+    include_once __DIR__.'/items.queries.php';
4786 4784
     $itemAccess = getCurrentAccessRights(
4787 4785
         (int) filter_var($userId, FILTER_SANITIZE_NUMBER_INT),
4788 4786
         (int) filter_var($file['id_item'], FILTER_SANITIZE_NUMBER_INT),
@@ -4815,7 +4813,7 @@  discard block
 block discarded – undo
4815 4813
     // Refuse access if user does not exist and/or is not admin
4816 4814
     $user = DB::queryFirstRow(
4817 4815
         'SELECT admin
4818
-        FROM ' . prefixTable('users') . '
4816
+        FROM ' . prefixTable('users').'
4819 4817
         WHERE id = %i',
4820 4818
         $userId
4821 4819
     );
@@ -4826,7 +4824,7 @@  discard block
 block discarded – undo
4826 4824
     // Ensure that user has performed the backup
4827 4825
     DB::queryFirstRow(
4828 4826
         'SELECT f.id
4829
-        FROM ' . prefixTable('log_system') . ' as f
4827
+        FROM ' . prefixTable('log_system').' as f
4830 4828
         WHERE f.type = %s AND f.label = %s AND f.qui = %i AND f.field_1 = %s',
4831 4829
         'admin_action',
4832 4830
         'dataBase backup',
@@ -4853,7 +4851,7 @@  discard block
 block discarded – undo
4853 4851
     // Refuse access if user does not exist and/or is admin
4854 4852
     $user = DB::queryFirstRow(
4855 4853
         'SELECT admin
4856
-        FROM ' . prefixTable('users') . '
4854
+        FROM ' . prefixTable('users').'
4857 4855
         WHERE id = %i',
4858 4856
         $userId
4859 4857
     );
@@ -4864,7 +4862,7 @@  discard block
 block discarded – undo
4864 4862
     // Get item info
4865 4863
     $item = DB::queryFirstRow(
4866 4864
         'SELECT i.perso, i.id_tree
4867
-        FROM ' . prefixTable('items') . ' as i
4865
+        FROM ' . prefixTable('items').' as i
4868 4866
         WHERE i.id = %i',
4869 4867
         $itemId
4870 4868
     );
@@ -4875,7 +4873,7 @@  discard block
 block discarded – undo
4875 4873
     // Get item owner
4876 4874
     $itemOwner = DB::queryFirstRow(
4877 4875
         'SELECT li.id_user
4878
-        FROM ' . prefixTable('log_items') . ' as li
4876
+        FROM ' . prefixTable('log_items').' as li
4879 4877
         WHERE li.id_item = %i AND li.action = %s',
4880 4878
         $itemId,
4881 4879
         'at_creation'
@@ -4889,25 +4887,25 @@  discard block
 block discarded – undo
4889 4887
         prefixTable('sharekeys_items'),
4890 4888
         'object_id = %i AND user_id NOT IN %ls',
4891 4889
         $itemId,
4892
-        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4890
+        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4893 4891
     );
4894 4892
     DB::delete(
4895 4893
         prefixTable('sharekeys_files'),
4896 4894
         'object_id IN (SELECT id FROM '.prefixTable('files').' WHERE id_item = %i) AND user_id NOT IN %ls',
4897 4895
         $itemId,
4898
-        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4896
+        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4899 4897
     );
4900 4898
     DB::delete(
4901 4899
         prefixTable('sharekeys_fields'),
4902 4900
         'object_id IN (SELECT id FROM '.prefixTable('fields').' WHERE id_item = %i) AND user_id NOT IN %ls',
4903 4901
         $itemId,
4904
-        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4902
+        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4905 4903
     );
4906 4904
     DB::delete(
4907 4905
         prefixTable('sharekeys_logs'),
4908 4906
         'object_id IN (SELECT id FROM '.prefixTable('log_items').' WHERE id_item = %i) AND user_id NOT IN %ls',
4909 4907
         $itemId,
4910
-        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4908
+        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4911 4909
     );
4912 4910
 
4913 4911
     return true;
@@ -4979,7 +4977,7 @@  discard block
 block discarded – undo
4979 4977
     
4980 4978
     // 2. Check if user actually has personal items to migrate
4981 4979
     $personalFolderId = DB::queryFirstField(
4982
-        "SELECT id FROM ".prefixTable('nested_tree') ."
4980
+        "SELECT id FROM ".prefixTable('nested_tree')."
4983 4981
          WHERE personal_folder = 1 
4984 4982
          AND title = %s",
4985 4983
         $userId
@@ -5059,8 +5057,8 @@  discard block
 block discarded – undo
5059 5057
             'process_type' => 'migrate_user_personal_items',
5060 5058
             'arguments' => json_encode([
5061 5059
                 'user_id' => (int) $userId,
5062
-                'user_pwd' => cryption($passwordClear, '','encrypt')['string'],
5063
-                'user_private_key' => cryption($privateKeyDecrypted, '','encrypt')['string'],
5060
+                'user_pwd' => cryption($passwordClear, '', 'encrypt')['string'],
5061
+                'user_private_key' => cryption($privateKeyDecrypted, '', 'encrypt')['string'],
5064 5062
                 'personal_folders_ids' => $personalFolderIds,
5065 5063
             ]),
5066 5064
             'is_in_progress' => 0,
@@ -5089,19 +5087,19 @@  discard block
 block discarded – undo
5089 5087
 {
5090 5088
     // Prepare the subtask queries
5091 5089
     $queries = [
5092
-        'user-personal-items-migration-step10' => 'SELECT * FROM ' . prefixTable('items'),
5090
+        'user-personal-items-migration-step10' => 'SELECT * FROM '.prefixTable('items'),
5093 5091
 
5094
-        'user-personal-items-migration-step20' => 'SELECT * FROM ' . prefixTable('log_items') . 
5092
+        'user-personal-items-migration-step20' => 'SELECT * FROM '.prefixTable('log_items'). 
5095 5093
                     ' WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"',
5096 5094
 
5097
-        'user-personal-items-migration-step30' => 'SELECT * FROM ' . prefixTable('categories_items') . 
5095
+        'user-personal-items-migration-step30' => 'SELECT * FROM '.prefixTable('categories_items'). 
5098 5096
                     ' WHERE encryption_type = "teampass_aes"',
5099 5097
 
5100
-        'user-personal-items-migration-step40' => 'SELECT * FROM ' . prefixTable('suggestion'),
5098
+        'user-personal-items-migration-step40' => 'SELECT * FROM '.prefixTable('suggestion'),
5101 5099
 
5102
-        'user-personal-items-migration-step50' => 'SELECT * FROM ' . prefixTable('files') . ' AS f
5103
-                        INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = f.id_item
5104
-                        WHERE f.status = "' . TP_ENCRYPTION_NAME . '"'
5100
+        'user-personal-items-migration-step50' => 'SELECT * FROM '.prefixTable('files').' AS f
5101
+                        INNER JOIN ' . prefixTable('items').' AS i ON i.id = f.id_item
5102
+                        WHERE f.status = "' . TP_ENCRYPTION_NAME.'"'
5105 5103
     ];
5106 5104
 
5107 5105
     // Perform loop on $queries to create sub-tasks
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.
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.