Passed
Push — master ( 6bf24f...97d9b0 )
by Nils
06:28 queued 11s
created
scripts/traits/UserHandlerTrait.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -50,24 +50,24 @@  discard block
 block discarded – undo
50 50
     private function generateUserKeys($arguments) {
51 51
         // Get all subtasks related to this task
52 52
         $subtasks = DB::query(
53
-            'SELECT * FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC',
53
+            'SELECT * FROM '.prefixTable('background_subtasks').' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC',
54 54
             $this->taskId
55 55
         );
56 56
     
57 57
         if (empty($subtasks)) {
58
-            if (LOG_TASKS=== true) $this->logger->log("No subtask was found for task {$this->taskId}");
58
+            if (LOG_TASKS === true) $this->logger->log("No subtask was found for task {$this->taskId}");
59 59
             return;
60 60
         }
61 61
     
62 62
         // Process each subtask
63 63
         foreach ($subtasks as $subtask) {
64
-            if (LOG_TASKS=== true) $this->logger->log("Processing subtask {$subtask['increment_id']} for task {$this->taskId}");
64
+            if (LOG_TASKS === true) $this->logger->log("Processing subtask {$subtask['increment_id']} for task {$this->taskId}");
65 65
             $this->processGenerateUserKeysSubtask($subtask, $arguments);
66 66
         }
67 67
     
68 68
         // Are all subtasks completed?
69 69
         $remainingSubtasks = DB::queryFirstField(
70
-            'SELECT COUNT(*) FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0',
70
+            'SELECT COUNT(*) FROM '.prefixTable('background_subtasks').' WHERE task_id = %i AND is_in_progress = 0',
71 71
             $this->taskId
72 72
         );    
73 73
         if ($remainingSubtasks == 0) {
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
                 $subtask['increment_id']
99 99
             );
100 100
             
101
-            if (LOG_TASKS=== true) $this->logger->log("Subtask is in progress: ".$taskData['step'], 'INFO');
101
+            if (LOG_TASKS === true) $this->logger->log("Subtask is in progress: ".$taskData['step'], 'INFO');
102 102
             switch ($taskData['step'] ?? '') {
103 103
                 case 'step0':
104 104
                     $this->generateNewUserStep0($arguments);
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
                 $subtask['increment_id']
153 153
             );
154 154
             
155
-            $this->logger->log("Subtask {$subtask['increment_id']} failure: " . $e->getMessage(), 'ERROR');
155
+            $this->logger->log("Subtask {$subtask['increment_id']} failure: ".$e->getMessage(), 'ERROR');
156 156
         }
157 157
     }
158 158
     
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
     private function generateNewUserStep0($arguments) {
166 166
         // CLear old sharekeys
167 167
         if ($arguments['user_self_change'] === 0) {
168
-            if (LOG_TASKS=== true) $this->logger->log("Deleting old sharekeys for user {$arguments['new_user_id']}", 'INFO');
168
+            if (LOG_TASKS === true) $this->logger->log("Deleting old sharekeys for user {$arguments['new_user_id']}", 'INFO');
169 169
             deleteUserObjetsKeys($arguments['new_user_id'], $this->settings);
170 170
         }
171 171
     }
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
         // Loop on items
195 195
         $rows = DB::query(
196 196
             'SELECT id, pw, perso
197
-            FROM ' . prefixTable('items') . '
197
+            FROM ' . prefixTable('items').'
198 198
             ORDER BY id ASC
199 199
             LIMIT %i, %i',
200 200
             $taskData['index'],
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
             // Get itemKey from current user
206 206
             $itemShareKey = DB::queryFirstRow(
207 207
                 'SELECT share_key, increment_id
208
-                FROM ' . prefixTable('sharekeys_items') . '
208
+                FROM ' . prefixTable('sharekeys_items').'
209 209
                 WHERE object_id = %i AND user_id = %i',
210 210
                 $record['id'],
211 211
                 (int) $arguments['owner_id']
@@ -268,16 +268,16 @@  discard block
 block discarded – undo
268 268
         // Loop on logs
269 269
         $rows = DB::query(
270 270
             'SELECT increment_id
271
-            FROM ' . prefixTable('log_items') . '
271
+            FROM ' . prefixTable('log_items').'
272 272
             WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"
273 273
             ORDER BY increment_id ASC
274
-            LIMIT ' . $taskData['index'] . ', ' . $taskData['nb']
274
+            LIMIT ' . $taskData['index'].', '.$taskData['nb']
275 275
         );
276 276
         foreach ($rows as $record) {
277 277
             // Get itemKey from current user
278 278
             $currentUserKey = DB::queryFirstRow(
279 279
                 'SELECT share_key
280
-                FROM ' . prefixTable('sharekeys_logs') . '
280
+                FROM ' . prefixTable('sharekeys_logs').'
281 281
                 WHERE object_id = %i AND user_id = %i',
282 282
                 $record['increment_id'],
283 283
                 $arguments['owner_id']
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
         // Loop on fields
333 333
         $rows = DB::query(
334 334
             'SELECT id
335
-            FROM ' . prefixTable('categories_items') . '
335
+            FROM ' . prefixTable('categories_items').'
336 336
             WHERE encryption_type = "teampass_aes"
337 337
             ORDER BY id ASC
338 338
             LIMIT %i, %i',
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
             // Get itemKey from current user
344 344
             $currentUserKey = DB::queryFirstRow(
345 345
                 'SELECT share_key
346
-                FROM ' . prefixTable('sharekeys_fields') . '
346
+                FROM ' . prefixTable('sharekeys_fields').'
347 347
                 WHERE object_id = %i AND user_id = %i',
348 348
                 $record['id'],
349 349
                 $arguments['owner_id']
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
         // Loop on suggestions
399 399
         $rows = DB::query(
400 400
             'SELECT id
401
-            FROM ' . prefixTable('suggestion') . '
401
+            FROM ' . prefixTable('suggestion').'
402 402
             ORDER BY id ASC
403 403
             LIMIT %i, %i',
404 404
             $taskData['index'],
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
             // Get itemKey from current user
409 409
             $currentUserKey = DB::queryFirstRow(
410 410
                 'SELECT share_key
411
-                FROM ' . prefixTable('sharekeys_suggestions') . '
411
+                FROM ' . prefixTable('sharekeys_suggestions').'
412 412
                 WHERE object_id = %i AND user_id = %i',
413 413
                 $record['id'],
414 414
                 $arguments['owner_id']
@@ -463,9 +463,9 @@  discard block
 block discarded – undo
463 463
         // Loop on files
464 464
         $rows = DB::query(
465 465
             'SELECT f.id AS id, i.perso AS perso
466
-            FROM ' . prefixTable('files') . ' AS f
467
-            INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = f.id_item
468
-            WHERE f.status = "' . TP_ENCRYPTION_NAME . '"
466
+            FROM ' . prefixTable('files').' AS f
467
+            INNER JOIN ' . prefixTable('items').' AS i ON i.id = f.id_item
468
+            WHERE f.status = "' . TP_ENCRYPTION_NAME.'"
469 469
             LIMIT %i, %i',
470 470
             $taskData['index'],
471 471
             $taskData['nb']
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
             // Get itemKey from current user
475 475
             $currentUserKey = DB::queryFirstRow(
476 476
                 'SELECT share_key, increment_id
477
-                FROM ' . prefixTable('sharekeys_files') . '
477
+                FROM ' . prefixTable('sharekeys_files').'
478 478
                 WHERE object_id = %i AND user_id = %i',
479 479
                 $record['id'],
480 480
                 (int) $record['perso'] === 0 ? $arguments['owner_id'] : $arguments['new_user_id']
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
         // get user info
560 560
         $userInfo = DB::queryFirstRow(
561 561
             'SELECT u.email, u.login, u.auth_type, u.special, u.lastname, u.name
562
-            FROM ' . prefixTable('users') . ' AS u
562
+            FROM ' . prefixTable('users').' AS u
563 563
             WHERE u.id = %i',
564 564
             $arguments['new_user_id']
565 565
         );
@@ -574,10 +574,10 @@  discard block
 block discarded – undo
574 574
                 filter_var($userInfo['email'], FILTER_SANITIZE_EMAIL),
575 575
                 // @scrutinizer ignore-type
576 576
                 empty($arguments['email_body']) === false ? $arguments['email_body'] : $lang->get('email_body_user_config_1'),
577
-                'TEAMPASS - ' . $lang->get('login_credentials'),
577
+                'TEAMPASS - '.$lang->get('login_credentials'),
578 578
                 (array) filter_var_array(
579 579
                     [
580
-                        '#code#' => cryption($arguments['new_user_code'], '','decrypt', $this->settings)['string'],
580
+                        '#code#' => cryption($arguments['new_user_code'], '', 'decrypt', $this->settings)['string'],
581 581
                         '#lastname#' => isset($userInfo['name']) === true ? $userInfo['name'] : '',
582 582
                         '#login#' => isset($userInfo['login']) === true ? $userInfo['login'] : '',
583 583
                     ],
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 
590 590
             // Prepare initial cache
591 591
             $userCache = DB::query(
592
-                'SELECT * FROM ' . prefixTable('cache_tree') . ' WHERE user_id = %i',
592
+                'SELECT * FROM '.prefixTable('cache_tree').' WHERE user_id = %i',
593 593
                 $arguments['new_user_id']
594 594
             );
595 595
             if (empty($userCache)) {
@@ -662,24 +662,24 @@  discard block
 block discarded – undo
662 662
     private function getOwnerInfos(int $owner_id, string $owner_pwd, ?int $only_personal_items = 0, ?string $owner_private_key = ''): array {
663 663
         $userInfo = DB::queryFirstRow(
664 664
             'SELECT pw, public_key, private_key, login, name
665
-            FROM ' . prefixTable('users') . '
665
+            FROM ' . prefixTable('users').'
666 666
             WHERE id = %i',
667 667
             $owner_id
668 668
         );
669 669
 
670 670
         // decrypt owner password 
671
-        $pwd = cryption($owner_pwd, '','decrypt', $this->settings)['string'];
671
+        $pwd = cryption($owner_pwd, '', 'decrypt', $this->settings)['string'];
672 672
 
673 673
         // decrypt private key and send back
674 674
         if ((int) $only_personal_items === 1 && empty($owner_private_key) === false) {
675 675
             // Explicitely case where we only want personal items and where user has provided his private key
676 676
             return [
677
-                'private_key' => cryption($owner_private_key, '','decrypt')['string'],
677
+                'private_key' => cryption($owner_private_key, '', 'decrypt')['string'],
678 678
                 'public_key' => $userInfo['public_key'],
679 679
                 'login' => $userInfo['login'],
680 680
                 'name' => $userInfo['name'],
681 681
             ];
682
-        }else {
682
+        } else {
683 683
             // Normal case
684 684
             return [
685 685
                 'private_key' => decryptPrivateKey($pwd, $userInfo['private_key']),
Please login to merge, or discard this patch.
sources/users.queries.php 1 patch
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('profile') === false) {
75 75
     // Not allowed page
76 76
     $session->set('system-error_code', ERR_NOT_ALLOWED);
77
-    include $SETTINGS['cpassman_dir'] . '/error.php';
77
+    include $SETTINGS['cpassman_dir'].'/error.php';
78 78
     exit;
79 79
 }
80 80
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 
146 146
         // Get info about user to modify
147 147
         $targetUserInfos = DB::queryFirstRow(
148
-            'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM ' . prefixTable('users') . '
148
+            'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM '.prefixTable('users').'
149 149
             WHERE id = %i',
150 150
             (int) $dataReceived['user_id']
151 151
         );
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
             // Check if user already exists (active user)
278 278
             $data = DB::query(
279 279
                 'SELECT id, fonction_id, groupes_interdits, groupes_visibles
280
-                FROM ' . prefixTable('users') . '
280
+                FROM ' . prefixTable('users').'
281 281
                 WHERE login = %s
282 282
                 AND deleted_at IS NULL',
283 283
                 $login
@@ -286,10 +286,10 @@  discard block
 block discarded – undo
286 286
             // Check if a soft-deleted user with this login exists
287 287
             $deletedUser = DB::queryFirstRow(
288 288
                 'SELECT id, login, deleted_at
289
-                FROM ' . prefixTable('users') . '
289
+                FROM ' . prefixTable('users').'
290 290
                 WHERE login LIKE %s
291 291
                 AND deleted_at IS NOT NULL',
292
-                $login . '_deleted_%'
292
+                $login.'_deleted_%'
293 293
             );
294 294
 
295 295
             if (DB::count() === 0 && empty($deletedUser) === true) {
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
                 // Check if it's a soft-deleted user
470 470
                 $errorMessage = $lang->get('error_user_exists');
471 471
                 if (empty($deletedUser) === false) {
472
-                    $errorMessage = 'A deleted user with this login already exists (ID: ' . $deletedUser['id'] . '). Please restore the user instead of creating a new one.';
472
+                    $errorMessage = 'A deleted user with this login already exists (ID: '.$deletedUser['id'].'). Please restore the user instead of creating a new one.';
473 473
                 }
474 474
 
475 475
                 echo prepareExchangedData(
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
             }
509 509
 
510 510
             // Prepare variables
511
-            $userId  = filter_var($dataReceived['user_id'], FILTER_SANITIZE_NUMBER_INT);
511
+            $userId = filter_var($dataReceived['user_id'], FILTER_SANITIZE_NUMBER_INT);
512 512
 
513 513
             if (empty($userId)) {
514 514
                 echo prepareExchangedData(
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 
524 524
             // Get info about user to delete
525 525
             $data_user = DB::queryFirstRow(
526
-                'SELECT login, admin, isAdministratedByRole FROM ' . prefixTable('users') . '
526
+                'SELECT login, admin, isAdministratedByRole FROM '.prefixTable('users').'
527 527
                 WHERE id = %i',
528 528
                 $userId 
529 529
             );        
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
                     || ((int) $session->get('user-can_manage_all_users') === 1 && (int) $data_user['admin'] !== 1)
541 541
                 ) {
542 542
                     $timestamp = time();
543
-                    $deletedSuffix = '_deleted_' . $timestamp;
543
+                    $deletedSuffix = '_deleted_'.$timestamp;
544 544
 
545 545
                     // delete user in database
546 546
                     DB::update(
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
                     logEvents($SETTINGS, 'user_mngt', 'at_user_deleted', (string) $session->get('user-id'), $session->get('user-login'), $userId);
561 561
 
562 562
                     // Count deleted users
563
-                    $deletedAccountsCount = (int) DB::queryFirstField("SELECT COUNT(id) FROM " . prefixTable('users') . " WHERE deleted_at IS NOT NULL");
563
+                    $deletedAccountsCount = (int) DB::queryFirstField("SELECT COUNT(id) FROM ".prefixTable('users')." WHERE deleted_at IS NOT NULL");
564 564
 
565 565
                     DB::commit();
566 566
 
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
                 echo prepareExchangedData(
590 590
                     [
591 591
                         'error' => true,
592
-                        'message' => $lang->get('error') . ': ' . $e->getMessage(),
592
+                        'message' => $lang->get('error').': '.$e->getMessage(),
593 593
                     ],
594 594
                     'encode'
595 595
                 );
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
             $return = array();
604 604
             // Check if folder exists
605 605
             $data = DB::query(
606
-                'SELECT * FROM ' . prefixTable('nested_tree') . '
606
+                'SELECT * FROM '.prefixTable('nested_tree').'
607 607
                 WHERE title = %s AND parent_id = %i',
608 608
                 filter_input(INPUT_POST, 'domain', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
609 609
                 '0'
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
             }
617 617
             // Check if role exists
618 618
             $data = DB::query(
619
-                'SELECT * FROM ' . prefixTable('roles_title') . '
619
+                'SELECT * FROM '.prefixTable('roles_title').'
620 620
                 WHERE title = %s',
621 621
                 filter_input(INPUT_POST, 'domain', FILTER_SANITIZE_FULL_SPECIAL_CHARS)
622 622
             );
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
             // Get info about user to delete
646 646
             $data_user = DB::queryFirstRow(
647 647
                 'SELECT admin, isAdministratedByRole, gestionnaire
648
-                FROM ' . prefixTable('users') . '
648
+                FROM ' . prefixTable('users').'
649 649
                 WHERE id = %i',
650 650
                 $post_user_id
651 651
             );
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
             // Get info about user
702 702
             $rowUser = DB::queryFirstRow(
703 703
                 'SELECT *
704
-                FROM ' . prefixTable('users') . '
704
+                FROM ' . prefixTable('users').'
705 705
                 WHERE id = %i',
706 706
                 $post_id
707 707
             );
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
                 $session->set('user-roles_array', explode(';', $session->get('user-roles')));
730 730
                 $rows = DB::query('
731 731
                     SELECT id,title,creator_id 
732
-                    FROM ' . prefixTable('roles_title') .'
732
+                    FROM ' . prefixTable('roles_title').'
733 733
                     WHERE id IN %li',
734 734
                     $session->get('user-roles_array')
735 735
                 );
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
                 $rolesList = array();
768 768
                 $managedBy = array();
769 769
                 $selected = '';
770
-                $rows = DB::query('SELECT id,title FROM ' . prefixTable('roles_title') . ' ORDER BY title ASC');
770
+                $rows = DB::query('SELECT id,title FROM '.prefixTable('roles_title').' ORDER BY title ASC');
771 771
                 foreach ($rows as $reccord) {
772 772
                     $rolesList[$reccord['id']] = array('id' => $reccord['id'], 'title' => $reccord['title']);
773 773
                 }
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
                         array_push(
799 799
                             $managedBy,
800 800
                             array(
801
-                                'title' => $lang->get('managers_of') . ' ' . $fonction['title'],
801
+                                'title' => $lang->get('managers_of').' '.$fonction['title'],
802 802
                                 'id' => $fonction['id'],
803 803
                                 'selected' => $selected,
804 804
                             )
@@ -880,9 +880,9 @@  discard block
 block discarded – undo
880 880
 
881 881
                 // get USER STATUS
882 882
                 if ($rowUser['disabled'] == 1) {
883
-                    $arrData['info'] = $lang->get('user_info_locked') . '<br><input type="checkbox" value="unlock" name="1" class="chk">&nbsp;<label for="1">' . $lang->get('user_info_unlock_question') . '</label><br><input type="checkbox"  value="delete" id="account_delete" class="chk mr-2" name="2" onclick="confirmDeletion()">label for="2">' . $lang->get('user_info_delete_question') . '</label>';
883
+                    $arrData['info'] = $lang->get('user_info_locked').'<br><input type="checkbox" value="unlock" name="1" class="chk">&nbsp;<label for="1">'.$lang->get('user_info_unlock_question').'</label><br><input type="checkbox"  value="delete" id="account_delete" class="chk mr-2" name="2" onclick="confirmDeletion()">label for="2">'.$lang->get('user_info_delete_question').'</label>';
884 884
                 } else {
885
-                    $arrData['info'] = $lang->get('user_info_active') . '<br><input type="checkbox" value="lock" class="chk">&nbsp;' . $lang->get('user_info_lock_question');
885
+                    $arrData['info'] = $lang->get('user_info_active').'<br><input type="checkbox" value="lock" class="chk">&nbsp;'.$lang->get('user_info_lock_question');
886 886
                 }
887 887
 
888 888
                 $arrData['error'] = false;
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
 
970 970
             // Get info about user to modify
971 971
             $data_user = DB::queryFirstRow(
972
-                'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM ' . prefixTable('users') . '
972
+                'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM '.prefixTable('users').'
973 973
                 WHERE id = %i',
974 974
                 $post_id
975 975
             );
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
                 // count number of admins
981 981
                 $users = DB::query(
982 982
                     'SELECT id
983
-                    FROM ' . prefixTable('users') . '
983
+                    FROM ' . prefixTable('users').'
984 984
                     WHERE admin = 1 AND email != "" AND pw != "" AND id != %i',
985 985
                     $post_id
986 986
                 );
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
             // Exclude roles from AD - PR #3635
1004 1004
             $adRoles = DB::query(
1005 1005
                 'SELECT roles_from_ad_groups
1006
-                FROM ' . prefixTable('users') . '
1006
+                FROM ' . prefixTable('users').'
1007 1007
                 WHERE id = %i',
1008 1008
                 $post_id
1009 1009
             )[0]['roles_from_ad_groups'];
@@ -1105,7 +1105,7 @@  discard block
 block discarded – undo
1105 1105
                     );
1106 1106
                     // delete personal folder and subfolders
1107 1107
                     $data = DB::queryFirstRow(
1108
-                        'SELECT id FROM ' . prefixTable('nested_tree') . '
1108
+                        'SELECT id FROM '.prefixTable('nested_tree').'
1109 1109
                         WHERE title = %s AND personal_folder = %i',
1110 1110
                         $post_id,
1111 1111
                         '1'
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
                             DB::delete(prefixTable('nested_tree'), 'id = %i AND personal_folder = %i', $folder->id, '1');
1119 1119
                             // delete items & logs
1120 1120
                             $items = DB::query(
1121
-                                'SELECT id FROM ' . prefixTable('items') . '
1121
+                                'SELECT id FROM '.prefixTable('items').'
1122 1122
                                 WHERE id_tree=%i AND perso = %i',
1123 1123
                                 $folder->id,
1124 1124
                                 '1'
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
                 } else {
1140 1140
                     // Get old data about user
1141 1141
                     $oldData = DB::queryFirstRow(
1142
-                        'SELECT * FROM ' . prefixTable('users') . '
1142
+                        'SELECT * FROM '.prefixTable('users').'
1143 1143
                         WHERE id = %i',
1144 1144
                         $post_id
1145 1145
                     );
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 
1177 1177
                     // update LOG
1178 1178
                     if ($oldData['email'] !== $post_email) {
1179
-                        logEvents($SETTINGS, 'user_mngt', 'at_user_email_changed:' . $oldData['email'], (string) $session->get('user-id'), $session->get('user-login'), $post_id);
1179
+                        logEvents($SETTINGS, 'user_mngt', 'at_user_email_changed:'.$oldData['email'], (string) $session->get('user-id'), $session->get('user-login'), $post_id);
1180 1180
                     }
1181 1181
                 }
1182 1182
                 echo prepareExchangedData(
@@ -1225,7 +1225,7 @@  discard block
 block discarded – undo
1225 1225
 
1226 1226
             $login = (string) filter_input(INPUT_POST, 'login', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
1227 1227
             DB::queryFirstRow(
1228
-                'SELECT * FROM ' . prefixTable('users') . '
1228
+                'SELECT * FROM '.prefixTable('users').'
1229 1229
                 WHERE (login = %s AND deleted_at IS NULL) 
1230 1230
                 OR login LIKE %s',
1231 1231
                 $login,
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
             // get User info
1279 1279
             $rowUser = DB::queryFirstRow(
1280 1280
                 'SELECT id, login, name, lastname, email, disabled, fonction_id, groupes_interdits, groupes_visibles, isAdministratedByRole, avatar_thumb, roles_from_ad_groups
1281
-                FROM ' . prefixTable('users') . '
1281
+                FROM ' . prefixTable('users').'
1282 1282
                 WHERE id = %i',
1283 1283
                 $post_id
1284 1284
             );
@@ -1289,7 +1289,7 @@  discard block
 block discarded – undo
1289 1289
             $html = '';
1290 1290
 
1291 1291
             if (isset($SETTINGS['ldap_mode']) === true && (int) $SETTINGS['ldap_mode'] === 1 && isset($SETTINGS['enable_ad_users_with_ad_groups']) === true && (int) $SETTINGS['enable_ad_users_with_ad_groups'] === 1) {
1292
-                $rowUser['fonction_id'] = empty($rowUser['fonction_id'])  === true ? $rowUser['roles_from_ad_groups'] : $rowUser['fonction_id']. ';' . $rowUser['roles_from_ad_groups'];
1292
+                $rowUser['fonction_id'] = empty($rowUser['fonction_id']) === true ? $rowUser['roles_from_ad_groups'] : $rowUser['fonction_id'].';'.$rowUser['roles_from_ad_groups'];
1293 1293
             }
1294 1294
             $arrData['functions'] = array_filter(explode(';', $rowUser['fonction_id']));
1295 1295
             $arrData['allowed_folders'] = array_filter(explode(';', $rowUser['groupes_visibles']));
@@ -1300,8 +1300,8 @@  discard block
 block discarded – undo
1300 1300
                 // refine folders based upon roles
1301 1301
                 $rows = DB::query(
1302 1302
                     'SELECT rv.folder_id, rv.type
1303
-                    FROM ' . prefixTable('roles_values') . ' as rv
1304
-                    INNER JOIN ' . prefixTable('nested_tree') . ' as nt ON rv.folder_id = nt.id
1303
+                    FROM ' . prefixTable('roles_values').' as rv
1304
+                    INNER JOIN ' . prefixTable('nested_tree').' as nt ON rv.folder_id = nt.id
1305 1305
                     WHERE rv.role_id IN %ls AND nt.personal_folder = 0
1306 1306
                     ORDER BY rv.folder_id ASC',
1307 1307
                     $arrData['functions']
@@ -1324,7 +1324,7 @@  discard block
 block discarded – undo
1324 1324
                 }
1325 1325
 
1326 1326
                 // add allowed folders
1327
-                foreach($arrData['allowed_folders'] as $Fld) {
1327
+                foreach ($arrData['allowed_folders'] as $Fld) {
1328 1328
                     array_push($arrFolders, array('id' => $Fld, 'type' => 'W', 'special' => true));
1329 1329
                 }
1330 1330
                 
@@ -1339,7 +1339,7 @@  discard block
 block discarded – undo
1339 1339
                             // get folder name
1340 1340
                             $row = DB::queryFirstRow(
1341 1341
                                 'SELECT title, nlevel, id
1342
-                                FROM ' . prefixTable('nested_tree') . '
1342
+                                FROM ' . prefixTable('nested_tree').'
1343 1343
                                 WHERE id = %i',
1344 1344
                                 $fld['id']
1345 1345
                             );
@@ -1357,8 +1357,8 @@  discard block
 block discarded – undo
1357 1357
                     }
1358 1358
                 }
1359 1359
 
1360
-                $html_full = '<table id="table-folders" class="table table-bordered table-striped dt-responsive nowrap" style="width:100%"><tbody>' .
1361
-                    $html . '</tbody></table>';
1360
+                $html_full = '<table id="table-folders" class="table table-bordered table-striped dt-responsive nowrap" style="width:100%"><tbody>'.
1361
+                    $html.'</tbody></table>';
1362 1362
             } else {
1363 1363
                 $html_full = '';
1364 1364
             }
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
             if ((int) $session->get('user-admin') === 0 && (int) $session->get('user-can_manage_all_users') === 0) {
1409 1409
                 $rows = DB::query(
1410 1410
                     'SELECT *
1411
-                    FROM ' . prefixTable('users') . '
1411
+                    FROM ' . prefixTable('users').'
1412 1412
                     WHERE admin = %i AND isAdministratedByRole IN %ls AND deleted_at IS NULL and disabled = %i',
1413 1413
                     0,
1414 1414
                     array_filter($session->get('user-roles_array')),
@@ -1417,7 +1417,7 @@  discard block
 block discarded – undo
1417 1417
             } else {
1418 1418
                 $rows = DB::query(
1419 1419
                     'SELECT *
1420
-                    FROM ' . prefixTable('users') . '
1420
+                    FROM ' . prefixTable('users').'
1421 1421
                     WHERE admin = %i AND deleted_at IS NULL and disabled = %i',
1422 1422
                     0,
1423 1423
                     0
@@ -1430,7 +1430,7 @@  discard block
 block discarded – undo
1430 1430
                 $groupIds = [];
1431 1431
                 foreach (explode(';', $record['fonction_id']) as $group) {
1432 1432
                     $tmp = DB::queryFirstRow(
1433
-                        'SELECT id, title FROM ' . prefixTable('roles_title') . '
1433
+                        'SELECT id, title FROM '.prefixTable('roles_title').'
1434 1434
                         WHERE id = %i',
1435 1435
                         $group
1436 1436
                     );
@@ -1442,7 +1442,7 @@  discard block
 block discarded – undo
1442 1442
 
1443 1443
                 // Get managed_by
1444 1444
                 $managedBy = DB::queryFirstRow(
1445
-                    'SELECT id, title FROM ' . prefixTable('roles_title') . '
1445
+                    'SELECT id, title FROM '.prefixTable('roles_title').'
1446 1446
                     WHERE id = %i',
1447 1447
                     $record['isAdministratedByRole']
1448 1448
                 );
@@ -1452,7 +1452,7 @@  discard block
 block discarded – undo
1452 1452
                 $foldersAllowedIds = [];
1453 1453
                 foreach (explode(';', $record['groupes_visibles']) as $role) {
1454 1454
                     $tmp = DB::queryFirstRow(
1455
-                        'SELECT id, title FROM ' . prefixTable('nested_tree') . '
1455
+                        'SELECT id, title FROM '.prefixTable('nested_tree').'
1456 1456
                         WHERE id = %i',
1457 1457
                         $role
1458 1458
                     );
@@ -1465,7 +1465,7 @@  discard block
 block discarded – undo
1465 1465
                 $foldersForbiddenIds = [];
1466 1466
                 foreach (explode(';', $record['groupes_interdits']) as $role) {
1467 1467
                     $tmp = DB::queryFirstRow(
1468
-                        'SELECT id, title FROM ' . prefixTable('nested_tree') . '
1468
+                        'SELECT id, title FROM '.prefixTable('nested_tree').'
1469 1469
                         WHERE id = %i',
1470 1470
                         $role
1471 1471
                     );
@@ -1483,7 +1483,7 @@  discard block
 block discarded – undo
1483 1483
                         'login' => $record['login'],
1484 1484
                         'groups' => implode(', ', $groups),
1485 1485
                         'groupIds' => $groupIds,
1486
-                        'managedBy' => $managedBy=== null ? $lang->get('administrator') : $managedBy['title'],
1486
+                        'managedBy' => $managedBy === null ? $lang->get('administrator') : $managedBy['title'],
1487 1487
                         'managedById' => $managedBy === null ? 0 : $managedBy['id'],
1488 1488
                         'foldersAllowed' => implode(', ', $foldersAllowed),
1489 1489
                         'foldersAllowedIds' => $foldersAllowedIds,
@@ -1584,7 +1584,7 @@  discard block
 block discarded – undo
1584 1584
 
1585 1585
             // Get info about user
1586 1586
             $data_user = DB::queryFirstRow(
1587
-                'SELECT admin, isAdministratedByRole FROM ' . prefixTable('users') . '
1587
+                'SELECT admin, isAdministratedByRole FROM '.prefixTable('users').'
1588 1588
                 WHERE id = %i',
1589 1589
                 $inputData['source_id']
1590 1590
             );
@@ -1816,14 +1816,14 @@  discard block
 block discarded – undo
1816 1816
             if (empty($post_context) === false && $post_context === 'add_one_role_to_user') {
1817 1817
                 $data_user = DB::queryFirstRow(
1818 1818
                     'SELECT fonction_id, public_key
1819
-                    FROM ' . prefixTable('users') . '
1819
+                    FROM ' . prefixTable('users').'
1820 1820
                     WHERE id = %i',
1821 1821
                     $post_user_id
1822 1822
                 );
1823 1823
 
1824 1824
                 if ($data_user) {
1825 1825
                     // Ensure array is unique
1826
-                    $post_new_value = str_replace(',', ';', $data_user['fonction_id']) . ';' . $post_new_value;
1826
+                    $post_new_value = str_replace(',', ';', $data_user['fonction_id']).';'.$post_new_value;
1827 1827
                     $post_new_value = implode(';', array_unique(explode(';', $post_new_value)));
1828 1828
                 } else {
1829 1829
                     // User not found
@@ -1839,14 +1839,14 @@  discard block
 block discarded – undo
1839 1839
             }
1840 1840
 
1841 1841
             // Manage specific case of api key
1842
-            if($post_field === 'user_api_key') {
1842
+            if ($post_field === 'user_api_key') {
1843 1843
                 $encrypted_key = encryptUserObjectKey(base64_encode($post_new_value), $session->get('user-public_key'));
1844 1844
                 $session->set('user-api_key', $post_new_value);
1845 1845
 
1846 1846
                 // test if user has an api key
1847 1847
                 $data_user = DB::queryFirstRow(
1848 1848
                     'SELECT value
1849
-                    FROM ' . prefixTable('api') . '
1849
+                    FROM ' . prefixTable('api').'
1850 1850
                     WHERE user_id = %i',
1851 1851
                     $post_user_id
1852 1852
                 );
@@ -1966,7 +1966,7 @@  discard block
 block discarded – undo
1966 1966
             } catch (\LdapRecord\Auth\BindException $e) {
1967 1967
                 $error = $e->getDetailedError();
1968 1968
                 if ($error && defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
1969
-                    error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage(). " - ".$error->getDiagnosticMessage());
1969
+                    error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage()." - ".$error->getDiagnosticMessage());
1970 1970
                 }
1971 1971
                 // deepcode ignore ServerLeak: No important data is sent and it is encrypted before sending
1972 1972
                 echo prepareExchangedData(
@@ -1996,7 +1996,7 @@  discard block
 block discarded – undo
1996 1996
             } catch (\LdapRecord\Auth\BindException $e) {
1997 1997
                 $error = $e->getDetailedError();
1998 1998
                 if ($error && defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
1999
-                    error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage(). " - ".$error->getDiagnosticMessage());
1999
+                    error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage()." - ".$error->getDiagnosticMessage());
2000 2000
                 }
2001 2001
                 // deepcode ignore ServerLeak: No important data is sent and it is encrypted before sending
2002 2002
                 echo prepareExchangedData(
@@ -2013,7 +2013,7 @@  discard block
 block discarded – undo
2013 2013
                 if (isset($adUser[$SETTINGS['ldap_user_attribute']][0]) === false) continue;
2014 2014
                 // Build the list of all groups in AD
2015 2015
                 if (isset($adUser['memberof']) === true) {
2016
-                    foreach($adUser['memberof'] as $j => $adUserGroup) {
2016
+                    foreach ($adUser['memberof'] as $j => $adUserGroup) {
2017 2017
                         if (empty($adUserGroup) === false && $j !== "count") {
2018 2018
                             $adGroup = substr($adUserGroup, 3, strpos($adUserGroup, ',') - 3);
2019 2019
                             if (in_array($adGroup, $adRoles) === false && empty($adGroup) === false) {
@@ -2029,7 +2029,7 @@  discard block
 block discarded – undo
2029 2029
                     // Get his ID
2030 2030
                     $userInfo = DB::queryFirstRow(
2031 2031
                         'SELECT id, login, fonction_id, auth_type
2032
-                        FROM ' . prefixTable('users') . '
2032
+                        FROM ' . prefixTable('users').'
2033 2033
                         WHERE login = %s',
2034 2034
                         $userLogin
2035 2035
                     );
@@ -2065,7 +2065,7 @@  discard block
 block discarded – undo
2065 2065
 
2066 2066
             // Get all groups in Teampass
2067 2067
             $teampassRoles = array();
2068
-            $rows = DB::query('SELECT id,title FROM ' . prefixTable('roles_title'));
2068
+            $rows = DB::query('SELECT id,title FROM '.prefixTable('roles_title'));
2069 2069
             foreach ($rows as $record) {
2070 2070
                 array_push(
2071 2071
                     $teampassRoles,
@@ -2130,7 +2130,7 @@  discard block
 block discarded – undo
2130 2130
             // Check if user already exists
2131 2131
             $data = DB::query(
2132 2132
                 'SELECT id, fonction_id, groupes_interdits, groupes_visibles
2133
-                FROM ' . prefixTable('users') . '
2133
+                FROM ' . prefixTable('users').'
2134 2134
                 WHERE login = %s',
2135 2135
                 $post_login
2136 2136
             );
@@ -2325,7 +2325,7 @@  discard block
 block discarded – undo
2325 2325
             // Check if user already exists
2326 2326
             DB::query(
2327 2327
                 'SELECT id
2328
-                FROM ' . prefixTable('users') . '
2328
+                FROM ' . prefixTable('users').'
2329 2329
                 WHERE id = %i',
2330 2330
                 $post_id
2331 2331
             );
@@ -2387,7 +2387,7 @@  discard block
 block discarded – undo
2387 2387
             // Get all groups in Teampass
2388 2388
             $teampassRoles = array();
2389 2389
             $titleToIdMap = [];
2390
-            $rows = DB::query('SELECT id,title FROM ' . prefixTable('roles_title'));
2390
+            $rows = DB::query('SELECT id,title FROM '.prefixTable('roles_title'));
2391 2391
             foreach ($rows as $record) {
2392 2392
                 array_push(
2393 2393
                     $teampassRoles,
@@ -2433,7 +2433,7 @@  discard block
 block discarded – undo
2433 2433
                     // Get his ID
2434 2434
                     $userInfo = DB::queryFirstRow(
2435 2435
                         'SELECT id, login, fonction_id, auth_type
2436
-                        FROM ' . prefixTable('users') . '
2436
+                        FROM ' . prefixTable('users').'
2437 2437
                         WHERE login = %s',
2438 2438
                         $userLogin
2439 2439
                     );
@@ -2540,7 +2540,7 @@  discard block
 block discarded – undo
2540 2540
             // Check if user already exists
2541 2541
             DB::query(
2542 2542
                 'SELECT id
2543
-                FROM ' . prefixTable('users') . '
2543
+                FROM ' . prefixTable('users').'
2544 2544
                 WHERE id = %i',
2545 2545
                 $post_id
2546 2546
             );
@@ -2606,7 +2606,7 @@  discard block
 block discarded – undo
2606 2606
             // Search TP_USER in db        
2607 2607
             $userTP = DB::queryFirstRow(
2608 2608
                 'SELECT pw
2609
-                FROM ' . prefixTable('users') . '
2609
+                FROM ' . prefixTable('users').'
2610 2610
                 WHERE id = %i',
2611 2611
                 TP_USER_ID
2612 2612
             );
@@ -2629,7 +2629,7 @@  discard block
 block discarded – undo
2629 2629
                     'arguments' => json_encode([
2630 2630
                         'new_user_id' => (int) $post_user_id,
2631 2631
                         'new_user_pwd' => '',
2632
-                        'new_user_code' => cryption($post_user_code, '','encrypt', $SETTINGS)['string'],
2632
+                        'new_user_code' => cryption($post_user_code, '', 'encrypt', $SETTINGS)['string'],
2633 2633
                         'owner_id' => (int) TP_USER_ID,
2634 2634
                         'creator_pwd' => $userTP['pw'],
2635 2635
                         'email_body' => $lang->get('email_body_user_config_5'),
@@ -2736,17 +2736,17 @@  discard block
 block discarded – undo
2736 2736
             // get user info
2737 2737
             $processesProgress = DB::query(
2738 2738
                 'SELECT u.ongoing_process_id, pt.task, pt.updated_at, pt.finished_at, pt.is_in_progress
2739
-                FROM ' . prefixTable('users') . ' AS u
2740
-                INNER JOIN ' . prefixTable('background_subtasks') . ' AS pt ON (pt.task_id = u.ongoing_process_id)
2739
+                FROM ' . prefixTable('users').' AS u
2740
+                INNER JOIN ' . prefixTable('background_subtasks').' AS pt ON (pt.task_id = u.ongoing_process_id)
2741 2741
                 WHERE u.id = %i',
2742 2742
                 $user_id
2743 2743
             );
2744 2744
 
2745 2745
             $finished_steps = 0;
2746 2746
             $nb_steps = count($processesProgress);
2747
-            foreach($processesProgress as $process) {
2747
+            foreach ($processesProgress as $process) {
2748 2748
                 if ((int) $process['is_in_progress'] === -1) {
2749
-                    $finished_steps ++;
2749
+                    $finished_steps++;
2750 2750
                 }
2751 2751
             }
2752 2752
 
@@ -2755,7 +2755,7 @@  discard block
 block discarded – undo
2755 2755
                     'error' => false,
2756 2756
                     'message' => '',
2757 2757
                     'user_id' => $user_id,
2758
-                    'status' => $finished_steps === $nb_steps ? 'finished' : number_format($finished_steps/$nb_steps*100, 0).'%',
2758
+                    'status' => $finished_steps === $nb_steps ? 'finished' : number_format($finished_steps / $nb_steps * 100, 0).'%',
2759 2759
                     'debug' => $finished_steps.",".$nb_steps,
2760 2760
                 ),
2761 2761
                 'encode'
@@ -2888,7 +2888,7 @@  discard block
 block discarded – undo
2888 2888
             }
2889 2889
             
2890 2890
             $result = purgeDeletedUserById($userId);
2891
-            $deletedAccountsCount = (int) DB::queryFirstField("SELECT COUNT(id) FROM " . prefixTable('users') . " WHERE deleted_at IS NOT NULL");
2891
+            $deletedAccountsCount = (int) DB::queryFirstField("SELECT COUNT(id) FROM ".prefixTable('users')." WHERE deleted_at IS NOT NULL");
2892 2892
 
2893 2893
             echo prepareExchangedData(
2894 2894
                 [
@@ -2928,13 +2928,13 @@  discard block
 block discarded – undo
2928 2928
 
2929 2929
             // Prepare variables
2930 2930
             $daysRetention = filter_var($dataReceived['days_retention'], FILTER_SANITIZE_NUMBER_INT);
2931
-            $daysRetention = empty($daysRetention) ? 90 : (int)$daysRetention;
2931
+            $daysRetention = empty($daysRetention) ? 90 : (int) $daysRetention;
2932 2932
             $cutoffTimestamp = time() - ($daysRetention * 86400);
2933 2933
             
2934 2934
             try {
2935 2935
                 // Get list of users to delete
2936 2936
                 $users = DB::query(
2937
-                    "SELECT id FROM " . prefixTable("users") . " 
2937
+                    "SELECT id FROM ".prefixTable("users")." 
2938 2938
                     WHERE deleted_at IS NOT NULL 
2939 2939
                     AND deleted_at > 0
2940 2940
                     AND deleted_at < %i
@@ -2958,7 +2958,7 @@  discard block
 block discarded – undo
2958 2958
                 echo prepareExchangedData(
2959 2959
                     [
2960 2960
                         'error' => true,
2961
-                        'message' => $lang->get('error') . ': ' . $e->getMessage(),
2961
+                        'message' => $lang->get('error').': '.$e->getMessage(),
2962 2962
                     ],
2963 2963
                     'encode'
2964 2964
                 );
@@ -3012,10 +3012,10 @@  discard block
 block discarded – undo
3012 3012
             
3013 3013
             $purgedCount = 0;
3014 3014
             $errors = [];
3015
-            $cutoffTimestamp = time() - ((int)$daysRetention * 86400);        
3015
+            $cutoffTimestamp = time() - ((int) $daysRetention * 86400);        
3016 3016
                         
3017 3017
             foreach ($userIds as $userId) {
3018
-                $userId = (int)$userId;
3018
+                $userId = (int) $userId;
3019 3019
                 
3020 3020
                 try {
3021 3021
                     $result = purgeDeletedUserById($userId);
@@ -3023,11 +3023,11 @@  discard block
 block discarded – undo
3023 3023
                     
3024 3024
                 } catch (Exception $e) {
3025 3025
                     DB::rollback();
3026
-                    $errors[] = "User ID $userId: " . $e->getMessage();
3026
+                    $errors[] = "User ID $userId: ".$e->getMessage();
3027 3027
                 }
3028 3028
             }
3029 3029
             
3030
-            $deletedAccountsCount = (int) DB::queryFirstField("SELECT COUNT(id) FROM " . prefixTable('users') . " WHERE deleted_at IS NOT NULL");
3030
+            $deletedAccountsCount = (int) DB::queryFirstField("SELECT COUNT(id) FROM ".prefixTable('users')." WHERE deleted_at IS NOT NULL");
3031 3031
 
3032 3032
             echo prepareExchangedData(
3033 3033
                 [
@@ -3035,7 +3035,7 @@  discard block
 block discarded – undo
3035 3035
                     'purged_count' => $purgedCount,
3036 3036
                     'total_in_batch' => count($userIds),
3037 3037
                     'errors' => $errors,
3038
-                    'message' => $purgedCount . ' user(s) purged in this batch',
3038
+                    'message' => $purgedCount.' user(s) purged in this batch',
3039 3039
                     'deletedAccountsCount' => $deletedAccountsCount,
3040 3040
                 ],
3041 3041
                 'encode'
@@ -3070,7 +3070,7 @@  discard block
 block discarded – undo
3070 3070
             
3071 3071
             // Get info about user
3072 3072
             $data_user = DB::queryFirstRow(
3073
-                'SELECT login FROM ' . prefixTable('users') . ' WHERE id = %i',
3073
+                'SELECT login FROM '.prefixTable('users').' WHERE id = %i',
3074 3074
                 $userId
3075 3075
             );
3076 3076
             
@@ -3083,12 +3083,12 @@  discard block
 block discarded – undo
3083 3083
             }
3084 3084
             
3085 3085
             // Remove user suffix "_deleted_timestamp"
3086
-            $deletedSuffix = '_deleted_' . substr($data_user['login'], strrpos($data_user['login'], '_deleted_') + 9);
3086
+            $deletedSuffix = '_deleted_'.substr($data_user['login'], strrpos($data_user['login'], '_deleted_') + 9);
3087 3087
             $originalLogin = str_replace($deletedSuffix, '', $data_user['login']);
3088 3088
                         
3089 3089
             // Check if an active user with the original login already exists
3090 3090
             $existingUser = DB::queryFirstRow(
3091
-                'SELECT id FROM ' . prefixTable('users') . '
3091
+                'SELECT id FROM '.prefixTable('users').'
3092 3092
                 WHERE login = %s AND deleted_at IS NULL AND id != %i',
3093 3093
                 $originalLogin,
3094 3094
                 $userId
@@ -3098,7 +3098,7 @@  discard block
 block discarded – undo
3098 3098
                 echo prepareExchangedData(
3099 3099
                     array(
3100 3100
                         'error' => true,
3101
-                        'message' => 'Cannot restore user: an active user with login "' . $originalLogin . '" already exists (ID: ' . $existingUser['id'] . ')'
3101
+                        'message' => 'Cannot restore user: an active user with login "'.$originalLogin.'" already exists (ID: '.$existingUser['id'].')'
3102 3102
                     ),
3103 3103
                     'encode'
3104 3104
                 );
@@ -3131,7 +3131,7 @@  discard block
 block discarded – undo
3131 3131
 
3132 3132
     // Get info about user
3133 3133
     $data_user = DB::queryFirstRow(
3134
-        'SELECT admin, isAdministratedByRole FROM ' . prefixTable('users') . '
3134
+        'SELECT admin, isAdministratedByRole FROM '.prefixTable('users').'
3135 3135
         WHERE id = %i',
3136 3136
         $value[1]
3137 3137
     );
@@ -3165,7 +3165,7 @@  discard block
 block discarded – undo
3165 3165
             logEvents(
3166 3166
                 $SETTINGS,
3167 3167
                 'user_mngt',
3168
-                'at_user_new_' . $value[0] . ':' . $value[1],
3168
+                'at_user_new_'.$value[0].':'.$value[1],
3169 3169
                 (string) $session->get('user-id'),
3170 3170
                 $session->get('user-login'),
3171 3171
                 filter_input(INPUT_POST, 'id', FILTER_SANITIZE_FULL_SPECIAL_CHARS)
@@ -3200,7 +3200,7 @@  discard block
 block discarded – undo
3200 3200
 
3201 3201
     // Get info about user
3202 3202
     $data_user = DB::queryFirstRow(
3203
-        'SELECT admin, isAdministratedByRole FROM ' . prefixTable('users') . '
3203
+        'SELECT admin, isAdministratedByRole FROM '.prefixTable('users').'
3204 3204
         WHERE id = %i',
3205 3205
         $id[1]
3206 3206
     );
@@ -3239,7 +3239,7 @@  discard block
 block discarded – undo
3239 3239
     $users = DB::query(
3240 3240
         "SELECT id, login, email, deleted_at, 
3241 3241
                 DATEDIFF(NOW(), FROM_UNIXTIME(deleted_at)) as days_since_deletion
3242
-         FROM " . prefixTable("users") . " 
3242
+         FROM " . prefixTable("users")." 
3243 3243
          WHERE deleted_at IS NOT NULL 
3244 3244
          AND deleted_at > 0
3245 3245
          ORDER BY deleted_at DESC"
@@ -3265,7 +3265,7 @@  discard block
 block discarded – undo
3265 3265
     
3266 3266
     // Vérifier que l'utilisateur est bien marqué deleted
3267 3267
     $user = DB::queryFirstRow(
3268
-        "SELECT id, login, deleted_at FROM " . prefixTable("users") . " 
3268
+        "SELECT id, login, deleted_at FROM ".prefixTable("users")." 
3269 3269
          WHERE id = %i 
3270 3270
          AND deleted_at IS NOT NULL 
3271 3271
          AND deleted_at > 0",
@@ -3305,7 +3305,7 @@  discard block
 block discarded – undo
3305 3305
 
3306 3306
         // delete personal folder and subfolders
3307 3307
         $data = DB::queryFirstRow(
3308
-            'SELECT id FROM ' . prefixTable('nested_tree') . '
3308
+            'SELECT id FROM '.prefixTable('nested_tree').'
3309 3309
             WHERE title = %s AND personal_folder = %i',
3310 3310
             $userId,
3311 3311
             '1'
@@ -3327,7 +3327,7 @@  discard block
 block discarded – undo
3327 3327
                 DB::delete(prefixTable('nested_tree'), 'id = %i AND personal_folder = %i', $folder->id, '1');
3328 3328
                 // delete items & logs
3329 3329
                 $items = DB::query(
3330
-                    'SELECT id FROM ' . prefixTable('items') . '
3330
+                    'SELECT id FROM '.prefixTable('items').'
3331 3331
                     WHERE id_tree=%i AND perso = %i',
3332 3332
                     $folder->id,
3333 3333
                     '1'
@@ -3357,7 +3357,7 @@  discard block
 block discarded – undo
3357 3357
         // Delete any process related to user
3358 3358
         $processes = DB::query(
3359 3359
             'SELECT increment_id
3360
-            FROM ' . prefixTable('background_tasks') . '
3360
+            FROM ' . prefixTable('background_tasks').'
3361 3361
             WHERE JSON_EXTRACT(arguments, "$.new_user_id") = %i',
3362 3362
             $userId
3363 3363
         );
Please login to merge, or discard this patch.
includes/core/load.js.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 
330 330
                             // Show passwords inputs and form
331 331
                             $('#dialog-user-change-password-info')
332
-                                .html('<i class="icon fa-solid fa-info mr-2"></i><?php echo $lang->get('user_has_to_change_password_info');?>')
332
+                                .html('<i class="icon fa-solid fa-info mr-2"></i><?php echo $lang->get('user_has_to_change_password_info'); ?>')
333 333
                                 .removeClass('hidden');
334 334
                             $('#dialog-user-change-password').removeClass('hidden');
335 335
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 
343 343
                             // Show passwords inputs and form
344 344
                             $('#dialog-ldap-user-change-password-info')
345
-                                .html('<i class="icon fa-solid fa-info mr-2"></i><?php echo $lang->get('ldap_user_has_changed_his_password');?>')
345
+                                .html('<i class="icon fa-solid fa-info mr-2"></i><?php echo $lang->get('ldap_user_has_changed_his_password'); ?>')
346 346
                                 .removeClass('hidden');
347 347
                             $('#dialog-ldap-user-change-password').removeClass('hidden');
348 348
                             
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 
372 372
                             if (data.queryResults.auth_type === 'oauth2') {
373 373
                                 // LDAP or local account to OAuth2 account
374
-                                var info_message = '<?php echo $lang->get('oauth2_need_user_old_password');?>';
374
+                                var info_message = '<?php echo $lang->get('oauth2_need_user_old_password'); ?>';
375 375
 
376 376
                                 // Hide the "new password" field that users can't fill in manually
377 377
                                 $('#new-password-field').hide();
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
                                 $('#dialog-ldap-user-change-password-current').val(oauth2_encryption_hash);
384 384
                             } else {
385 385
                                 // LDAP password updated
386
-                                var info_message = '<?php echo $lang->get('ldap_user_has_changed_his_password');?>';
386
+                                var info_message = '<?php echo $lang->get('ldap_user_has_changed_his_password'); ?>';
387 387
                             }
388 388
 
389 389
                             // Display info tip
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
         /*console.log('User has to regenerate keys')
508 508
         // HIde
509 509
         $('.content-header, .content').addClass('hidden');
510
-        $('#dialog-user-temporary-code-info').html('<i class="icon fa-solid fa-info mr-2"></i><?php echo $lang->get('renecyption_expected');?>');
510
+        $('#dialog-user-temporary-code-info').html('<i class="icon fa-solid fa-info mr-2"></i><?php echo $lang->get('renecyption_expected'); ?>');
511 511
 
512 512
         // Show passwords inputs and form
513 513
         $('#dialog-user-temporary-code').removeClass('hidden');
@@ -533,13 +533,13 @@  discard block
 block discarded – undo
533 533
             {
534 534
                 if (step === 'psk') {
535 535
                     // Inform user
536
-                    $("#user-current-defuse-psk-progress").html('<b><?php echo $lang->get('encryption_keys'); ?> </b> [' + start + ' - ' + (parseInt(start) + <?php echo NUMBER_ITEMS_IN_BATCH;?>) + '] ' +
536
+                    $("#user-current-defuse-psk-progress").html('<b><?php echo $lang->get('encryption_keys'); ?> </b> [' + start + ' - ' + (parseInt(start) + <?php echo NUMBER_ITEMS_IN_BATCH; ?>) + '] ' +
537 537
                         '... <?php echo $lang->get('please_wait'); ?><i class="fa-solid fa-spinner fa-pulse ml-3 text-primary"></i>');
538 538
 
539 539
                     var data = {
540 540
                         'userPsk' : $('#user-current-defuse-psk').val(),
541 541
                         'start': start,
542
-                        'length': <?php echo NUMBER_ITEMS_IN_BATCH;?>,
542
+                        'length': <?php echo NUMBER_ITEMS_IN_BATCH; ?>,
543 543
                         'user_id': userId,
544 544
                         'counterItemsToTreat': counterItemsToTreat
545 545
                     };
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 
621 621
                 // Show passwords inputs and form
622 622
                 $('#dialog-ldap-user-change-password-info')
623
-                    .html('<i class="icon fa-solid fa-info mr-2"></i><?php echo $lang->get('ldap_user_has_changed_his_password');?>')
623
+                    .html('<i class="icon fa-solid fa-info mr-2"></i><?php echo $lang->get('ldap_user_has_changed_his_password'); ?>')
624 624
                     .removeClass('hidden');
625 625
                 $('#dialog-ldap-user-change-password').removeClass('hidden');
626 626
 
@@ -1257,15 +1257,15 @@  discard block
 block discarded – undo
1257 1257
             // Prepare data
1258 1258
             var data = {
1259 1259
                 'receipt': $('#temp-user-email').val(),
1260
-                'subject': '[Teampass] <?php echo $lang->get('your_new_password');?>',
1261
-                'body': '<?php echo $lang->get('email_body_temporary_login_password');?>',
1260
+                'subject': '[Teampass] <?php echo $lang->get('your_new_password'); ?>',
1261
+                'body': '<?php echo $lang->get('email_body_temporary_login_password'); ?>',
1262 1262
                 'pre_replace' : {
1263 1263
                     '#enc_code#' : $('#temp-user-pwd').val(),
1264 1264
                 }
1265 1265
             }
1266 1266
             if (debugJavascript === true) console.log(data);
1267 1267
             // Prepare form
1268
-            $('#dialog-admin-change-user-password-info').html('<?php echo $lang->get('sending_email_message');?>');
1268
+            $('#dialog-admin-change-user-password-info').html('<?php echo $lang->get('sending_email_message'); ?>');
1269 1269
             toastr.remove();
1270 1270
             toastr.info(
1271 1271
                 '<?php echo $lang->get('in_progress'); ?><i class="fa-solid fa-circle-notch fa-spin fa-2x ml-3"></i>'
@@ -1796,7 +1796,7 @@  discard block
 block discarded – undo
1796 1796
                         '#warningModal',
1797 1797
                         '<i class="fa-solid fa-clock fa-lg warning mr-2"></i><?php echo $lang->get('index_add_one_hour'); ?>',
1798 1798
                         '<div class="form-group">' +
1799
-                        '<label for="warningModal-input" class="col-form-label"><?php echo $lang->get('extend_session_duration_by') . ' (' . $lang->get('minutes') . ')'; ?>:</label>' +
1799
+                        '<label for="warningModal-input" class="col-form-label"><?php echo $lang->get('extend_session_duration_by').' ('.$lang->get('minutes').')'; ?>:</label>' +
1800 1800
                         '<input type="number" max="'+(60*60*24)+'" class="form-control" id="warningModal-input" value="60">' +
1801 1801
                         '</div>' +
1802 1802
                         '<div class="form-text text-muted"><i class=\"fa-solid fa-info-circle mr-2\"></i><?php echo $lang->get('maximum_session_expiration_time'); ?>: '+data.max_session_duration+'</div>',
Please login to merge, or discard this patch.
sources/main.queries.php 1 patch
Spacing   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 ) {
80 80
     // Not allowed page
81 81
     $session->set('system-error_code', ERR_NOT_ALLOWED);
82
-    include $SETTINGS['cpassman_dir'] . '/error.php';
82
+    include $SETTINGS['cpassman_dir'].'/error.php';
83 83
     exit;
84 84
 }
85 85
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
  * @param array $SETTINGS
208 208
  * @return string
209 209
  */
210
-function passwordHandler(string $post_type, array|null|string $dataReceived, array $SETTINGS): string
210
+function passwordHandler(string $post_type, array | null | string $dataReceived, array $SETTINGS): string
211 211
 {
212 212
     $session = SessionManager::getSession();
213 213
     $lang = new Language($session->get('user-language') ?? 'english');
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
             // Get current user hash
277 277
             $userHash = DB::queryFirstRow(
278
-                "SELECT pw FROM " . prefixtable('users') . " WHERE id = %d;",
278
+                "SELECT pw FROM ".prefixtable('users')." WHERE id = %d;",
279 279
                 $session->get('user-id')
280 280
             )['pw'];
281 281
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
  * @param string $post_key
331 331
  * @return string
332 332
  */
333
-function userHandler(string $post_type, array|null|string $dataReceived, array $SETTINGS, string $post_key): string
333
+function userHandler(string $post_type, array | null | string $dataReceived, array $SETTINGS, string $post_key): string
334 334
 {
335 335
     $session = SessionManager::getSession();
336 336
 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
     if (isset($dataReceived['user_id'])) {
366 366
         // Get info about user to modify
367 367
         $targetUserInfos = DB::queryFirstRow(
368
-            'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM ' . prefixTable('users') . '
368
+            'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM '.prefixTable('users').'
369 369
             WHERE id = %i',
370 370
             $dataReceived['user_id']
371 371
         );
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
         case 'mail_me'://action_mail
515 515
             // Get info about user to send email
516 516
             $data_user = DB::queryFirstRow(
517
-                'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM ' . prefixTable('users') . '
517
+                'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM '.prefixTable('users').'
518 518
                 WHERE email = %s',
519 519
                 filter_var($dataReceived['receipt'], FILTER_SANITIZE_FULL_SPECIAL_CHARS)
520 520
             );
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
     if (isset($dataReceived['user_id'])) {
635 635
         // Get info about user to modify
636 636
         $targetUserInfos = DB::queryFirstRow(
637
-            'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM ' . prefixTable('users') . '
637
+            'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM '.prefixTable('users').'
638 638
             WHERE id = %i',
639 639
             $dataReceived['user_id']
640 640
         );
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 
719 719
             // Get current user hash
720 720
             $userHash = DB::queryFirstRow(
721
-                "SELECT pw FROM " . prefixtable('users') . " WHERE id = %d;",
721
+                "SELECT pw FROM ".prefixtable('users')." WHERE id = %d;",
722 722
                 $session->get('user-id')
723 723
             )['pw'];
724 724
 
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 
757 757
                 // Get current user hash
758 758
                 $userHash = DB::queryFirstRow(
759
-                    "SELECT pw FROM " . prefixtable('users') . " WHERE id = %d;",
759
+                    "SELECT pw FROM ".prefixtable('users')." WHERE id = %d;",
760 760
                     $session->get('user-id')
761 761
                 )['pw'];
762 762
 
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
 
802 802
                 // Get current user hash
803 803
                 $userHash = DB::queryFirstRow(
804
-                    "SELECT pw FROM " . prefixtable('users') . " WHERE id = %i;",
804
+                    "SELECT pw FROM ".prefixtable('users')." WHERE id = %i;",
805 805
                     $session->get('user-id')
806 806
                 )['pw'];
807 807
 
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
  * @param array $SETTINGS
854 854
  * @return string
855 855
  */
856
-function systemHandler(string $post_type, array|null|string $dataReceived, array $SETTINGS): string
856
+function systemHandler(string $post_type, array | null | string $dataReceived, array $SETTINGS): string
857 857
 {
858 858
     $session = SessionManager::getSession();
859 859
     switch ($post_type) {
@@ -954,7 +954,7 @@  discard block
 block discarded – undo
954 954
                 )
955 955
             );
956 956
 
957
-            return '[{"token" : "' . $token . '"}]';
957
+            return '[{"token" : "'.$token.'"}]';
958 958
 
959 959
         /*
960 960
         * Default case
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
 }
971 971
 
972 972
 
973
-function utilsHandler(string $post_type, array|null|string $dataReceived, array $SETTINGS): string
973
+function utilsHandler(string $post_type, array | null | string $dataReceived, array $SETTINGS): string
974 974
 {
975 975
     switch ($post_type) {
976 976
         /*
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
         array(
1040 1040
             'error' => false,
1041 1041
             'timestamp' => $session->get('user-session_duration'),
1042
-            'max_time_to_add' => intdiv((($maximum_session_expiration_time*60) - ((int) $session->get('user-session_duration') - time())), 60),
1042
+            'max_time_to_add' => intdiv((($maximum_session_expiration_time * 60) - ((int) $session->get('user-session_duration') - time())), 60),
1043 1043
             'max_session_duration' => $maximum_session_expiration_time,
1044 1044
         ),
1045 1045
         'encode'
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
     // get number of items
1092 1092
     DB::queryFirstRow(
1093 1093
         'SELECT increment_id
1094
-        FROM ' . prefixTable('sharekeys_items') .
1094
+        FROM ' . prefixTable('sharekeys_items').
1095 1095
         ' WHERE user_id = %i',
1096 1096
         $userId
1097 1097
     );
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
         // check if expected security level is reached
1147 1147
         $dataUser = DB::queryFirstRow(
1148 1148
             'SELECT *
1149
-            FROM ' . prefixTable('users') . ' WHERE id = %i',
1149
+            FROM ' . prefixTable('users').' WHERE id = %i',
1150 1150
             $post_user_id
1151 1151
         );
1152 1152
 
@@ -1167,8 +1167,8 @@  discard block
 block discarded – undo
1167 1167
         if (empty($dataUser['fonction_id']) === false) {
1168 1168
             $data = DB::queryFirstRow(
1169 1169
                 'SELECT complexity
1170
-                FROM ' . prefixTable('roles_title') . '
1171
-                WHERE id IN (' . $dataUser['fonction_id'] . ')
1170
+                FROM ' . prefixTable('roles_title').'
1171
+                WHERE id IN (' . $dataUser['fonction_id'].')
1172 1172
                 ORDER BY complexity DESC'
1173 1173
             );
1174 1174
         } else {
@@ -1181,8 +1181,8 @@  discard block
 block discarded – undo
1181 1181
             return prepareExchangedData(
1182 1182
                 array(
1183 1183
                     'error' => true,
1184
-                    'message' => '<div style="margin:10px 0 10px 15px;">' . $lang->get('complexity_level_not_reached') . '.<br>' .
1185
-                        $lang->get('expected_complexity_level') . ': <b>' . TP_PW_COMPLEXITY[$data['complexity']][1] . '</b></div>',
1184
+                    'message' => '<div style="margin:10px 0 10px 15px;">'.$lang->get('complexity_level_not_reached').'.<br>'.
1185
+                        $lang->get('expected_complexity_level').': <b>'.TP_PW_COMPLEXITY[$data['complexity']][1].'</b></div>',
1186 1186
                 ),
1187 1187
                 'encode'
1188 1188
             );
@@ -1286,14 +1286,14 @@  discard block
 block discarded – undo
1286 1286
         // Get data about user
1287 1287
         $dataUser = DB::queryFirstRow(
1288 1288
             'SELECT id, email, pw
1289
-            FROM ' . prefixTable('users') . '
1289
+            FROM ' . prefixTable('users').'
1290 1290
             WHERE login = %s',
1291 1291
             $post_login
1292 1292
         );
1293 1293
     } else {
1294 1294
         $dataUser = DB::queryFirstRow(
1295 1295
             'SELECT id, login, email, pw
1296
-            FROM ' . prefixTable('users') . '
1296
+            FROM ' . prefixTable('users').'
1297 1297
             WHERE id = %i',
1298 1298
             $post_id
1299 1299
         );
@@ -1347,7 +1347,7 @@  discard block
 block discarded – undo
1347 1347
     // Check if token already used
1348 1348
     $dataToken = DB::queryFirstRow(
1349 1349
         'SELECT end_timestamp, reason
1350
-        FROM ' . prefixTable('tokens') . '
1350
+        FROM ' . prefixTable('tokens').'
1351 1351
         WHERE token = %s AND user_id = %i',
1352 1352
         $post_token,
1353 1353
         $dataUser['id']
@@ -1358,11 +1358,11 @@  discard block
 block discarded – undo
1358 1358
         return prepareExchangedData(
1359 1359
             array(
1360 1360
                 'error' => true,
1361
-                'message' => 'TOKEN already used',//$lang->get('no_email_set'),
1361
+                'message' => 'TOKEN already used', //$lang->get('no_email_set'),
1362 1362
             ),
1363 1363
             'encode'
1364 1364
         );
1365
-    } elseif(DB::count() === 0) {
1365
+    } elseif (DB::count() === 0) {
1366 1366
         // Store token for this action
1367 1367
         DB::insert(
1368 1368
             prefixTable('tokens'),
@@ -1424,7 +1424,7 @@  discard block
 block discarded – undo
1424 1424
                 'email' => $dataUser['email'],
1425 1425
                 'email_result' => str_replace(
1426 1426
                     '#email#',
1427
-                    '<b>' . obfuscateEmail($dataUser['email']) . '</b>',
1427
+                    '<b>'.obfuscateEmail($dataUser['email']).'</b>',
1428 1428
                     addslashes($lang->get('admin_email_result_ok'))
1429 1429
                 ),
1430 1430
             ),
@@ -1440,7 +1440,7 @@  discard block
 block discarded – undo
1440 1440
             'email' => $dataUser['email'],
1441 1441
             'email_result' => str_replace(
1442 1442
                 '#email#',
1443
-                '<b>' . obfuscateEmail($dataUser['email']) . '</b>',
1443
+                '<b>'.obfuscateEmail($dataUser['email']).'</b>',
1444 1444
                 addslashes($lang->get('admin_email_result_ok'))
1445 1445
             ),
1446 1446
         ),
@@ -1457,7 +1457,7 @@  discard block
 block discarded – undo
1457 1457
 
1458 1458
     if (isKeyExistingAndEqual('enable_send_email_on_user_login', 1, $SETTINGS) === true) {
1459 1459
         $row = DB::queryFirstRow(
1460
-            'SELECT valeur FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s',
1460
+            'SELECT valeur FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s',
1461 1461
             'cron',
1462 1462
             'sending_emails'
1463 1463
         );
@@ -1465,7 +1465,7 @@  discard block
 block discarded – undo
1465 1465
         if ((int) (time() - $row['valeur']) >= 300 || (int) $row['valeur'] === 0) {
1466 1466
             $rows = DB::query(
1467 1467
                 'SELECT *
1468
-                FROM ' . prefixTable('emails') .
1468
+                FROM ' . prefixTable('emails').
1469 1469
                 ' WHERE status != %s',
1470 1470
                 'sent'
1471 1471
             );
@@ -1517,8 +1517,8 @@  discard block
 block discarded – undo
1517 1517
     $arr_html = array();
1518 1518
     $rows = DB::query(
1519 1519
         'SELECT i.id AS id, i.label AS label, i.id_tree AS id_tree, l.date, i.perso AS perso, i.restricted_to AS restricted
1520
-        FROM ' . prefixTable('log_items') . ' AS l
1521
-        RIGHT JOIN ' . prefixTable('items') . ' AS i ON (l.id_item = i.id)
1520
+        FROM ' . prefixTable('log_items').' AS l
1521
+        RIGHT JOIN ' . prefixTable('items').' AS i ON (l.id_item = i.id)
1522 1522
         WHERE l.action = %s AND l.id_user = %i
1523 1523
         ORDER BY l.date DESC
1524 1524
         LIMIT 0, 100',
@@ -1550,7 +1550,7 @@  discard block
 block discarded – undo
1550 1550
     if (isKeyExistingAndEqual('enable_suggestion', 1, $SETTINGS) === true
1551 1551
         && ((int) $session->get('user-admin') === 1 || (int) $session->get('user-manager') === 1)
1552 1552
     ) {
1553
-        DB::query('SELECT * FROM ' . prefixTable('suggestion'));
1553
+        DB::query('SELECT * FROM '.prefixTable('suggestion'));
1554 1554
         $nb_suggestions_waiting = DB::count();
1555 1555
     }
1556 1556
 
@@ -1585,13 +1585,13 @@  discard block
 block discarded – undo
1585 1585
             if ($data === 'stat_languages') {
1586 1586
                 $tmp = '';
1587 1587
                 foreach ($stats_data[$data] as $key => $value) {
1588
-                    $tmp .= $tmp === '' ? $key . '-' . $value : ',' . $key . '-' . $value;
1588
+                    $tmp .= $tmp === '' ? $key.'-'.$value : ','.$key.'-'.$value;
1589 1589
                 }
1590 1590
                 $statsToSend[$data] = $tmp;
1591 1591
             } elseif ($data === 'stat_country') {
1592 1592
                 $tmp = '';
1593 1593
                 foreach ($stats_data[$data] as $key => $value) {
1594
-                    $tmp .= $tmp === '' ? $key . '-' . $value : ',' . $key . '-' . $value;
1594
+                    $tmp .= $tmp === '' ? $key.'-'.$value : ','.$key.'-'.$value;
1595 1595
                 }
1596 1596
                 $statsToSend[$data] = $tmp;
1597 1597
             } else {
@@ -1678,7 +1678,7 @@  discard block
 block discarded – undo
1678 1678
             $url_found = $value;
1679 1679
             if (empty($url_found) === false) {
1680 1680
                 $tmp = parse_url($url_found);
1681
-                $anonym_url = $tmp['scheme'] . '://<anonym_url>' . (isset($tmp['path']) === true ? $tmp['path'] : '');
1681
+                $anonym_url = $tmp['scheme'].'://<anonym_url>'.(isset($tmp['path']) === true ? $tmp['path'] : '');
1682 1682
                 $value = $anonym_url;
1683 1683
             } else {
1684 1684
                 $value = '';
@@ -1708,7 +1708,7 @@  discard block
 block discarded – undo
1708 1708
     $teampass_errors = '';
1709 1709
     $rows = DB::query(
1710 1710
         'SELECT label, date AS error_date
1711
-        FROM ' . prefixTable('log_system') . "
1711
+        FROM ' . prefixTable('log_system')."
1712 1712
         WHERE `type` LIKE 'error'
1713 1713
         ORDER BY `date` DESC
1714 1714
         LIMIT 0, 10"
@@ -1716,9 +1716,9 @@  discard block
 block discarded – undo
1716 1716
     if (DB::count() > 0) {
1717 1717
         foreach ($rows as $record) {
1718 1718
             if (empty($teampass_errors) === true) {
1719
-                $teampass_errors = ' * ' . date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['error_date']) . ' - ' . $record['label'];
1719
+                $teampass_errors = ' * '.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['error_date']).' - '.$record['label'];
1720 1720
             } else {
1721
-                $teampass_errors .= ' * ' . date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['error_date']) . ' - ' . $record['label'];
1721
+                $teampass_errors .= ' * '.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['error_date']).' - '.$record['label'];
1722 1722
             }
1723 1723
         }
1724 1724
     }
@@ -1730,7 +1730,7 @@  discard block
 block discarded – undo
1730 1730
 
1731 1731
     // Now prepare text
1732 1732
     $txt = '### Page on which it happened
1733
-' . $data['current_page'] . '
1733
+' . $data['current_page'].'
1734 1734
 
1735 1735
 ### Steps to reproduce
1736 1736
 1.
@@ -1745,39 +1745,39 @@  discard block
 block discarded – undo
1745 1745
 Tell us what happens instead
1746 1746
 
1747 1747
 ### Server configuration
1748
-**Operating system**: ' . php_uname() . '
1748
+**Operating system**: ' . php_uname().'
1749 1749
 
1750
-**Web server:** ' . $_SERVER['SERVER_SOFTWARE'] . '
1750
+**Web server:** ' . $_SERVER['SERVER_SOFTWARE'].'
1751 1751
 
1752
-**Database:** ' . ($link === false ? $lang->get('undefined') : mysqli_get_server_info($link)) . '
1752
+**Database:** ' . ($link === false ? $lang->get('undefined') : mysqli_get_server_info($link)).'
1753 1753
 
1754
-**PHP version:** ' . PHP_VERSION . '
1754
+**PHP version:** ' . PHP_VERSION.'
1755 1755
 
1756
-**Teampass version:** ' . TP_VERSION . '.' . TP_VERSION_MINOR . '
1756
+**Teampass version:** ' . TP_VERSION.'.'.TP_VERSION_MINOR.'
1757 1757
 
1758 1758
 **Teampass configuration variables:**
1759 1759
 ```
1760
-' . $list_of_options . '
1760
+' . $list_of_options.'
1761 1761
 ```
1762 1762
 
1763 1763
 **Updated from an older Teampass or fresh install:**
1764 1764
 
1765 1765
 ### Client configuration
1766 1766
 
1767
-**Browser:** ' . $data['browser_name'] . ' - ' . $data['browser_version'] . '
1767
+**Browser:** ' . $data['browser_name'].' - '.$data['browser_version'].'
1768 1768
 
1769
-**Operating system:** ' . $data['os'] . ' - ' . $data['os_archi'] . 'bits
1769
+**Operating system:** ' . $data['os'].' - '.$data['os_archi'].'bits
1770 1770
 
1771 1771
 ### Logs
1772 1772
 
1773 1773
 #### Web server error log
1774 1774
 ```
1775
-' . $err['message'] . ' - ' . $err['file'] . ' (' . $err['line'] . ')
1775
+' . $err['message'].' - '.$err['file'].' ('.$err['line'].')
1776 1776
 ```
1777 1777
 
1778 1778
 #### Teampass 10 last system errors
1779 1779
 ```
1780
-' . $teampass_errors . '
1780
+' . $teampass_errors.'
1781 1781
 ```
1782 1782
 
1783 1783
 #### Log from the web-browser developer console (CTRL + SHIFT + i)
@@ -1819,7 +1819,7 @@  discard block
 block discarded – undo
1819 1819
         // Check if user exists
1820 1820
         $userInfo = DB::queryFirstRow(
1821 1821
             'SELECT public_key, private_key, pw, auth_type
1822
-            FROM ' . prefixTable('users') . '
1822
+            FROM ' . prefixTable('users').'
1823 1823
             WHERE id = %i',
1824 1824
             $post_user_id
1825 1825
         );
@@ -1828,9 +1828,9 @@  discard block
 block discarded – undo
1828 1828
             // Get one item
1829 1829
             $currentUserKey = DB::queryFirstRow(
1830 1830
                 'SELECT object_id, share_key, increment_id
1831
-                FROM ' . prefixTable('sharekeys_items') . ' AS si
1832
-                INNER JOIN ' . prefixTable('items') . ' AS i ON  (i.id = si.object_id)
1833
-                INNER JOIN ' . prefixTable('nested_tree') . ' AS nt ON  (i.id_tree = nt.id)
1831
+                FROM ' . prefixTable('sharekeys_items').' AS si
1832
+                INNER JOIN ' . prefixTable('items').' AS i ON  (i.id = si.object_id)
1833
+                INNER JOIN ' . prefixTable('nested_tree').' AS nt ON  (i.id_tree = nt.id)
1834 1834
                 WHERE user_id = %i AND nt.personal_folder = %i',
1835 1835
                 $post_user_id,
1836 1836
                 0
@@ -1949,7 +1949,7 @@  discard block
 block discarded – undo
1949 1949
         // Get user info
1950 1950
         $userData = DB::queryFirstRow(
1951 1951
             'SELECT private_key
1952
-            FROM ' . prefixTable('users') . '
1952
+            FROM ' . prefixTable('users').'
1953 1953
             WHERE id = %i',
1954 1954
             $post_user_id
1955 1955
         );
@@ -2041,7 +2041,7 @@  discard block
 block discarded – undo
2041 2041
         // Get user info
2042 2042
         $userData = DB::queryFirstRow(
2043 2043
             'SELECT email, auth_type, login
2044
-            FROM ' . prefixTable('users') . '
2044
+            FROM ' . prefixTable('users').'
2045 2045
             WHERE id = %i',
2046 2046
             $post_user_id
2047 2047
         );
@@ -2139,7 +2139,7 @@  discard block
 block discarded – undo
2139 2139
         // Get user info
2140 2140
         $userData = DB::queryFirstRow(
2141 2141
             'SELECT email, auth_type, login
2142
-            FROM ' . prefixTable('users') . '
2142
+            FROM ' . prefixTable('users').'
2143 2143
             WHERE id = %i',
2144 2144
             $userId
2145 2145
         );
@@ -2198,7 +2198,7 @@  discard block
 block discarded – undo
2198 2198
         // Check if user exists
2199 2199
         DB::queryFirstRow(
2200 2200
             'SELECT *
2201
-            FROM ' . prefixTable('users') . '
2201
+            FROM ' . prefixTable('users').'
2202 2202
             WHERE id = %i',
2203 2203
             $post_user_id
2204 2204
         );
@@ -2268,7 +2268,7 @@  discard block
 block discarded – undo
2268 2268
         // Check if user exists
2269 2269
         $userInfo = DB::queryFirstRow(
2270 2270
             'SELECT public_key
2271
-            FROM ' . prefixTable('users') . '
2271
+            FROM ' . prefixTable('users').'
2272 2272
             WHERE id = %i',
2273 2273
             $post_user_id
2274 2274
         );
@@ -2416,15 +2416,15 @@  discard block
 block discarded – undo
2416 2416
     // Loop on items
2417 2417
     $rows = DB::query(
2418 2418
         'SELECT id, pw
2419
-        FROM ' . prefixTable('items') . '
2419
+        FROM ' . prefixTable('items').'
2420 2420
         WHERE perso = 0
2421
-        LIMIT ' . $post_start . ', ' . $post_length
2421
+        LIMIT ' . $post_start.', '.$post_length
2422 2422
     );
2423 2423
     foreach ($rows as $record) {
2424 2424
         // Get itemKey from current user
2425 2425
         $currentUserKey = DB::queryFirstRow(
2426 2426
             'SELECT share_key, increment_id
2427
-            FROM ' . prefixTable('sharekeys_items') . '
2427
+            FROM ' . prefixTable('sharekeys_items').'
2428 2428
             WHERE object_id = %i AND user_id = %i',
2429 2429
             $record['id'],
2430 2430
             $session->get('user-id')
@@ -2454,7 +2454,7 @@  discard block
 block discarded – undo
2454 2454
             if ((int) $post_user_id !== (int) $session->get('user-id')) {
2455 2455
                 $currentUserKey = DB::queryFirstRow(
2456 2456
                     'SELECT increment_id
2457
-                    FROM ' . prefixTable('sharekeys_items') . '
2457
+                    FROM ' . prefixTable('sharekeys_items').'
2458 2458
                     WHERE object_id = %i AND user_id = %i',
2459 2459
                     $record['id'],
2460 2460
                     $post_user_id
@@ -2485,7 +2485,7 @@  discard block
 block discarded – undo
2485 2485
     // SHould we change step?
2486 2486
     DB::query(
2487 2487
         'SELECT *
2488
-        FROM ' . prefixTable('items') . '
2488
+        FROM ' . prefixTable('items').'
2489 2489
         WHERE perso = 0'
2490 2490
     );
2491 2491
 
@@ -2510,15 +2510,15 @@  discard block
 block discarded – undo
2510 2510
     // Loop on logs
2511 2511
     $rows = DB::query(
2512 2512
         'SELECT increment_id
2513
-        FROM ' . prefixTable('log_items') . '
2513
+        FROM ' . prefixTable('log_items').'
2514 2514
         WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"
2515
-        LIMIT ' . $post_start . ', ' . $post_length
2515
+        LIMIT ' . $post_start.', '.$post_length
2516 2516
     );
2517 2517
     foreach ($rows as $record) {
2518 2518
         // Get itemKey from current user
2519 2519
         $currentUserKey = DB::queryFirstRow(
2520 2520
             'SELECT share_key
2521
-            FROM ' . prefixTable('sharekeys_logs') . '
2521
+            FROM ' . prefixTable('sharekeys_logs').'
2522 2522
             WHERE object_id = %i AND user_id = %i',
2523 2523
             $record['increment_id'],
2524 2524
             $session->get('user-id')
@@ -2548,7 +2548,7 @@  discard block
 block discarded – undo
2548 2548
             if ((int) $post_user_id !== (int) $session->get('user-id')) {
2549 2549
                 $currentUserKey = DB::queryFirstRow(
2550 2550
                     'SELECT increment_id
2551
-                    FROM ' . prefixTable('sharekeys_items') . '
2551
+                    FROM ' . prefixTable('sharekeys_items').'
2552 2552
                     WHERE object_id = %i AND user_id = %i',
2553 2553
                     $record['id'],
2554 2554
                     $post_user_id
@@ -2570,7 +2570,7 @@  discard block
 block discarded – undo
2570 2570
     // SHould we change step?
2571 2571
     DB::query(
2572 2572
         'SELECT increment_id
2573
-        FROM ' . prefixTable('log_items') . '
2573
+        FROM ' . prefixTable('log_items').'
2574 2574
         WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"'
2575 2575
     );
2576 2576
 
@@ -2595,15 +2595,15 @@  discard block
 block discarded – undo
2595 2595
     // Loop on fields
2596 2596
     $rows = DB::query(
2597 2597
         'SELECT id
2598
-        FROM ' . prefixTable('categories_items') . '
2598
+        FROM ' . prefixTable('categories_items').'
2599 2599
         WHERE encryption_type = "teampass_aes"
2600
-        LIMIT ' . $post_start . ', ' . $post_length
2600
+        LIMIT ' . $post_start.', '.$post_length
2601 2601
     );
2602 2602
     foreach ($rows as $record) {
2603 2603
         // Get itemKey from current user
2604 2604
         $currentUserKey = DB::queryFirstRow(
2605 2605
             'SELECT share_key
2606
-            FROM ' . prefixTable('sharekeys_fields') . '
2606
+            FROM ' . prefixTable('sharekeys_fields').'
2607 2607
             WHERE object_id = %i AND user_id = %i',
2608 2608
             $record['id'],
2609 2609
             $session->get('user-id')
@@ -2633,7 +2633,7 @@  discard block
 block discarded – undo
2633 2633
             if ((int) $post_user_id !== (int) $session->get('user-id')) {
2634 2634
                 $currentUserKey = DB::queryFirstRow(
2635 2635
                     'SELECT increment_id
2636
-                    FROM ' . prefixTable('sharekeys_items') . '
2636
+                    FROM ' . prefixTable('sharekeys_items').'
2637 2637
                     WHERE object_id = %i AND user_id = %i',
2638 2638
                     $record['id'],
2639 2639
                     $post_user_id
@@ -2655,7 +2655,7 @@  discard block
 block discarded – undo
2655 2655
     // SHould we change step?
2656 2656
     DB::query(
2657 2657
         'SELECT *
2658
-        FROM ' . prefixTable('categories_items') . '
2658
+        FROM ' . prefixTable('categories_items').'
2659 2659
         WHERE encryption_type = "teampass_aes"'
2660 2660
     );
2661 2661
 
@@ -2680,14 +2680,14 @@  discard block
 block discarded – undo
2680 2680
     // Loop on suggestions
2681 2681
     $rows = DB::query(
2682 2682
         'SELECT id
2683
-        FROM ' . prefixTable('suggestion') . '
2684
-        LIMIT ' . $post_start . ', ' . $post_length
2683
+        FROM ' . prefixTable('suggestion').'
2684
+        LIMIT ' . $post_start.', '.$post_length
2685 2685
     );
2686 2686
     foreach ($rows as $record) {
2687 2687
         // Get itemKey from current user
2688 2688
         $currentUserKey = DB::queryFirstRow(
2689 2689
             'SELECT share_key
2690
-            FROM ' . prefixTable('sharekeys_suggestions') . '
2690
+            FROM ' . prefixTable('sharekeys_suggestions').'
2691 2691
             WHERE object_id = %i AND user_id = %i',
2692 2692
             $record['id'],
2693 2693
             $session->get('user-id')
@@ -2717,7 +2717,7 @@  discard block
 block discarded – undo
2717 2717
             if ((int) $post_user_id !== (int) $session->get('user-id')) {
2718 2718
                 $currentUserKey = DB::queryFirstRow(
2719 2719
                     'SELECT increment_id
2720
-                    FROM ' . prefixTable('sharekeys_items') . '
2720
+                    FROM ' . prefixTable('sharekeys_items').'
2721 2721
                     WHERE object_id = %i AND user_id = %i',
2722 2722
                     $record['id'],
2723 2723
                     $post_user_id
@@ -2763,15 +2763,15 @@  discard block
 block discarded – undo
2763 2763
     // Loop on files
2764 2764
     $rows = DB::query(
2765 2765
         'SELECT id
2766
-        FROM ' . prefixTable('files') . '
2767
-        WHERE status = "' . TP_ENCRYPTION_NAME . '"
2768
-        LIMIT ' . $post_start . ', ' . $post_length
2766
+        FROM ' . prefixTable('files').'
2767
+        WHERE status = "' . TP_ENCRYPTION_NAME.'"
2768
+        LIMIT ' . $post_start.', '.$post_length
2769 2769
     ); //aes_encryption
2770 2770
     foreach ($rows as $record) {
2771 2771
         // Get itemKey from current user
2772 2772
         $currentUserKey = DB::queryFirstRow(
2773 2773
             'SELECT share_key
2774
-            FROM ' . prefixTable('sharekeys_files') . '
2774
+            FROM ' . prefixTable('sharekeys_files').'
2775 2775
             WHERE object_id = %i AND user_id = %i',
2776 2776
             $record['id'],
2777 2777
             $session->get('user-id')
@@ -2801,7 +2801,7 @@  discard block
 block discarded – undo
2801 2801
             if ((int) $post_user_id !== (int) $session->get('user-id')) {
2802 2802
                 $currentUserKey = DB::queryFirstRow(
2803 2803
                     'SELECT increment_id
2804
-                    FROM ' . prefixTable('sharekeys_items') . '
2804
+                    FROM ' . prefixTable('sharekeys_items').'
2805 2805
                     WHERE object_id = %i AND user_id = %i',
2806 2806
                     $record['id'],
2807 2807
                     $post_user_id
@@ -2823,8 +2823,8 @@  discard block
 block discarded – undo
2823 2823
     // SHould we change step?
2824 2824
     DB::query(
2825 2825
         'SELECT *
2826
-        FROM ' . prefixTable('files') . '
2827
-        WHERE status = "' . TP_ENCRYPTION_NAME . '"'
2826
+        FROM ' . prefixTable('files').'
2827
+        WHERE status = "' . TP_ENCRYPTION_NAME.'"'
2828 2828
     );
2829 2829
 
2830 2830
     $next_start = (int) $post_start + (int) $post_length;
@@ -2857,9 +2857,9 @@  discard block
 block discarded – undo
2857 2857
     if (count($session->get('user-personal_folders')) > 0) {
2858 2858
         $rows = DB::query(
2859 2859
             'SELECT id, pw
2860
-            FROM ' . prefixTable('items') . '
2860
+            FROM ' . prefixTable('items').'
2861 2861
             WHERE perso = 1 AND id_tree IN %ls AND encryption_type = %s
2862
-            LIMIT ' . $post_start . ', ' . $post_length,
2862
+            LIMIT ' . $post_start.', '.$post_length,
2863 2863
             $session->get('user-personal_folders'),
2864 2864
             "defuse"
2865 2865
         );
@@ -2867,7 +2867,7 @@  discard block
 block discarded – undo
2867 2867
             // Get itemKey from current user
2868 2868
             $currentUserKey = DB::queryFirstRow(
2869 2869
                 'SELECT share_key, increment_id
2870
-                FROM ' . prefixTable('sharekeys_items') . '
2870
+                FROM ' . prefixTable('sharekeys_items').'
2871 2871
                 WHERE object_id = %i AND user_id = %i',
2872 2872
                 $record['id'],
2873 2873
                 $session->get('user-id')
@@ -2892,7 +2892,7 @@  discard block
 block discarded – undo
2892 2892
                 if ((int) $post_user_id !== (int) $session->get('user-id')) {
2893 2893
                     $currentUserKey = DB::queryFirstRow(
2894 2894
                         'SELECT increment_id
2895
-                        FROM ' . prefixTable('sharekeys_items') . '
2895
+                        FROM ' . prefixTable('sharekeys_items').'
2896 2896
                         WHERE object_id = %i AND user_id = %i',
2897 2897
                         $record['id'],
2898 2898
                         $post_user_id
@@ -2915,7 +2915,7 @@  discard block
 block discarded – undo
2915 2915
     // SHould we change step?
2916 2916
     DB::query(
2917 2917
         'SELECT *
2918
-        FROM ' . prefixTable('items') . '
2918
+        FROM ' . prefixTable('items').'
2919 2919
         WHERE perso = 0'
2920 2920
     );
2921 2921
 
@@ -2943,7 +2943,7 @@  discard block
 block discarded – undo
2943 2943
         // Check if user exists
2944 2944
         $userInfo = DB::queryFirstRow(
2945 2945
             'SELECT public_key, encrypted_psk
2946
-            FROM ' . prefixTable('users') . '
2946
+            FROM ' . prefixTable('users').'
2947 2947
             WHERE id = %i',
2948 2948
             $post_user_id
2949 2949
         );
@@ -2969,7 +2969,7 @@  discard block
 block discarded – undo
2969 2969
                 if ($post_counterItemsToTreat === -1) {
2970 2970
                     DB::query(
2971 2971
                         'SELECT id
2972
-                        FROM ' . prefixTable('items') . '
2972
+                        FROM ' . prefixTable('items').'
2973 2973
                         WHERE perso = 1 AND id_tree IN %ls AND encryption_type != %s',
2974 2974
                         $session->get('user-personal_folders'),
2975 2975
                         'teampass_aes'
@@ -2982,7 +2982,7 @@  discard block
 block discarded – undo
2982 2982
                 // Loop on persoanl items
2983 2983
                 $rows = DB::query(
2984 2984
                     'SELECT id, pw
2985
-                    FROM ' . prefixTable('items') . '
2985
+                    FROM ' . prefixTable('items').'
2986 2986
                     WHERE perso = 1 AND id_tree IN %ls AND encryption_type != %s
2987 2987
                     LIMIT ' . $post_length,
2988 2988
                     $session->get('user-personal_folders'),
@@ -3024,7 +3024,7 @@  discard block
 block discarded – undo
3024 3024
                     // Loop on files
3025 3025
                     $rows = DB::query(
3026 3026
                         'SELECT id, file
3027
-                        FROM ' . prefixTable('files') . '
3027
+                        FROM ' . prefixTable('files').'
3028 3028
                         WHERE status != %s
3029 3029
                         AND id_item = %i',
3030 3030
                         TP_ENCRYPTION_NAME,
@@ -3035,13 +3035,13 @@  discard block
 block discarded – undo
3035 3035
                         // Now decrypt the file
3036 3036
                         prepareFileWithDefuse(
3037 3037
                             'decrypt',
3038
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record2['file'],
3039
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record2['file'] . '.delete',
3038
+                            $SETTINGS['path_to_upload_folder'].'/'.$record2['file'],
3039
+                            $SETTINGS['path_to_upload_folder'].'/'.$record2['file'].'.delete',
3040 3040
                             $post_user_psk
3041 3041
                         );
3042 3042
 
3043 3043
                         // Encrypt the file
3044
-                        $encryptedFile = encryptFile($record2['file'] . '.delete', $SETTINGS['path_to_upload_folder']);
3044
+                        $encryptedFile = encryptFile($record2['file'].'.delete', $SETTINGS['path_to_upload_folder']);
3045 3045
 
3046 3046
                         DB::update(
3047 3047
                             prefixTable('files'),
@@ -3062,7 +3062,7 @@  discard block
 block discarded – undo
3062 3062
                         );
3063 3063
 
3064 3064
                         // Unlink original file
3065
-                        unlink($SETTINGS['path_to_upload_folder'] . '/' . $record2['file']);
3065
+                        unlink($SETTINGS['path_to_upload_folder'].'/'.$record2['file']);
3066 3066
                     }
3067 3067
                 }
3068 3068
 
@@ -3070,7 +3070,7 @@  discard block
 block discarded – undo
3070 3070
                 $next_start = (int) $post_start + (int) $post_length;
3071 3071
                 DB::query(
3072 3072
                     'SELECT id
3073
-                    FROM ' . prefixTable('items') . '
3073
+                    FROM ' . prefixTable('items').'
3074 3074
                     WHERE perso = 1 AND id_tree IN %ls AND encryption_type != %s',
3075 3075
                     $session->get('user-personal_folders'),
3076 3076
                     'teampass_aes'
@@ -3140,7 +3140,7 @@  discard block
 block discarded – undo
3140 3140
         // Get user info
3141 3141
         $userData = DB::queryFirstRow(
3142 3142
             'SELECT special, auth_type, is_ready_for_usage, ongoing_process_id, otp_provided, personal_items_migrated
3143
-            FROM ' . prefixTable('users') . '
3143
+            FROM ' . prefixTable('users').'
3144 3144
             WHERE id = %i',
3145 3145
             $post_user_id
3146 3146
         );
@@ -3187,7 +3187,7 @@  discard block
 block discarded – undo
3187 3187
         // Get user info
3188 3188
         $userData = DB::queryFirstRow(
3189 3189
             'SELECT auth_type, login, private_key
3190
-            FROM ' . prefixTable('users') . '
3190
+            FROM ' . prefixTable('users').'
3191 3191
             WHERE id = %i',
3192 3192
             $post_user_id
3193 3193
         );
@@ -3237,7 +3237,7 @@  discard block
 block discarded – undo
3237 3237
                 return prepareExchangedData(
3238 3238
                     array(
3239 3239
                         'error' => false,
3240
-                        'message' => $lang->get('done'),'',
3240
+                        'message' => $lang->get('done'), '',
3241 3241
                     ),
3242 3242
                     'encode'
3243 3243
                 );
@@ -3286,7 +3286,7 @@  discard block
 block discarded – undo
3286 3286
         // Get user info
3287 3287
         $userData = DB::queryFirstRow(
3288 3288
             'SELECT u.auth_type, u.login, u.private_key, u.special
3289
-            FROM ' . prefixTable('users') . ' AS u
3289
+            FROM ' . prefixTable('users').' AS u
3290 3290
             WHERE u.id = %i',
3291 3291
             $post_user_id
3292 3292
         );
@@ -3322,7 +3322,7 @@  discard block
 block discarded – undo
3322 3322
                     return prepareExchangedData(
3323 3323
                         array(
3324 3324
                             'error' => false,
3325
-                            'message' => $lang->get('done'),'',
3325
+                            'message' => $lang->get('done'), '',
3326 3326
                         ),
3327 3327
                         'encode'
3328 3328
                     );
@@ -3343,8 +3343,8 @@  discard block
 block discarded – undo
3343 3343
                 // Get one itemKey from current user
3344 3344
                 $currentUserKey = DB::queryFirstRow(
3345 3345
                     'SELECT ski.share_key, ski.increment_id, l.id_user
3346
-                    FROM ' . prefixTable('sharekeys_items') . ' AS ski
3347
-                    INNER JOIN ' . prefixTable('log_items') . ' AS l ON ski.object_id = l.id_item
3346
+                    FROM ' . prefixTable('sharekeys_items').' AS ski
3347
+                    INNER JOIN ' . prefixTable('log_items').' AS l ON ski.object_id = l.id_item
3348 3348
                     WHERE ski.user_id = %i
3349 3349
                     ORDER BY RAND()
3350 3350
                     LIMIT 1',
@@ -3411,8 +3411,8 @@  discard block
 block discarded – undo
3411 3411
                             'process_type' => 'create_user_keys',
3412 3412
                             'arguments' => json_encode([
3413 3413
                                 'new_user_id' => (int) $post_user_id,
3414
-                                'new_user_pwd' => cryption($post_previous_pwd, '','encrypt')['string'],
3415
-                                'new_user_private_key' => cryption($validPreviousKey['private_key'], '','encrypt')['string'],
3414
+                                'new_user_pwd' => cryption($post_previous_pwd, '', 'encrypt')['string'],
3415
+                                'new_user_private_key' => cryption($validPreviousKey['private_key'], '', 'encrypt')['string'],
3416 3416
                                 'send_email' => 0,
3417 3417
                                 'otp_provided_new_value' => 0,
3418 3418
                                 'user_self_change' => 1,
@@ -3481,7 +3481,7 @@  discard block
 block discarded – undo
3481 3481
             id,
3482 3482
             private_key,
3483 3483
             created_at
3484
-        FROM " . prefixTable('user_private_keys') . "
3484
+        FROM " . prefixTable('user_private_keys')."
3485 3485
         WHERE user_id = %i
3486 3486
         ORDER BY created_at DESC, id DESC",
3487 3487
         $userId
@@ -3503,9 +3503,9 @@  discard block
 block discarded – undo
3503 3503
             // Select one personal item share_key to test decryption
3504 3504
             $currentUserItemKey = DB::queryFirstRow(
3505 3505
                 'SELECT si.share_key, si.increment_id, l.id_user, i.perso
3506
-                FROM ' . prefixTable('sharekeys_items') . ' AS si
3507
-                INNER JOIN ' . prefixTable('log_items') . ' AS l ON si.object_id = l.id_item
3508
-                INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = l.id_item
3506
+                FROM ' . prefixTable('sharekeys_items').' AS si
3507
+                INNER JOIN ' . prefixTable('log_items').' AS l ON si.object_id = l.id_item
3508
+                INNER JOIN ' . prefixTable('items').' AS i ON i.id = l.id_item
3509 3509
                 WHERE si.user_id = %i AND i.perso = 1 AND si.share_key != ""
3510 3510
                 ORDER BY RAND()
3511 3511
                 LIMIT 1',
@@ -3556,7 +3556,7 @@  discard block
 block discarded – undo
3556 3556
             $session->get('user-id')
3557 3557
         );
3558 3558
         // Return data
3559
-        return '[{"new_value":"' . $session->get('user-session_duration') . '"}]';
3559
+        return '[{"new_value":"'.$session->get('user-session_duration').'"}]';
3560 3560
     }
3561 3561
     
3562 3562
     return '[{"new_value":"expired"}]';
@@ -3606,8 +3606,8 @@  discard block
 block discarded – undo
3606 3606
 {
3607 3607
     $personalItems = DB::query(
3608 3608
         'SELECT i.id, i.pw, s.share_key, s.increment_id
3609
-        FROM ' . prefixTable('items') . ' i
3610
-        INNER JOIN ' . prefixTable('sharekeys_items') . ' s ON i.id = s.object_id
3609
+        FROM ' . prefixTable('items').' i
3610
+        INNER JOIN ' . prefixTable('sharekeys_items').' s ON i.id = s.object_id
3611 3611
         WHERE i.perso = %i
3612 3612
         AND s.user_id = %i',
3613 3613
         1,
@@ -3662,8 +3662,8 @@  discard block
 block discarded – undo
3662 3662
     if ($skipPasswordChange === true) {
3663 3663
         // Remove all sharekeys for personal items
3664 3664
         DB::query(
3665
-            'UPDATE ' . prefixTable('sharekeys_items') . ' AS ski
3666
-            INNER JOIN ' . prefixTable('items') . ' AS i ON ski.object_id = i.id
3665
+            'UPDATE '.prefixTable('sharekeys_items').' AS ski
3666
+            INNER JOIN ' . prefixTable('items').' AS i ON ski.object_id = i.id
3667 3667
             SET ski.share_key = ""
3668 3668
             WHERE i.perso = 1
3669 3669
             AND ski.user_id = %i',
@@ -3672,8 +3672,8 @@  discard block
 block discarded – undo
3672 3672
 
3673 3673
         // Remove all sharekeys for personal files
3674 3674
         DB::query(
3675
-            'UPDATE ' . prefixTable('sharekeys_files') . ' AS skf
3676
-            INNER JOIN ' . prefixTable('items') . ' AS i ON skf.object_id = i.id
3675
+            'UPDATE '.prefixTable('sharekeys_files').' AS skf
3676
+            INNER JOIN ' . prefixTable('items').' AS i ON skf.object_id = i.id
3677 3677
             SET skf.share_key = ""
3678 3678
             WHERE i.perso = 1
3679 3679
             AND skf.user_id = %i',
@@ -3682,8 +3682,8 @@  discard block
 block discarded – undo
3682 3682
 
3683 3683
         // Remove all sharekeys for personal fields
3684 3684
         DB::query(
3685
-            'UPDATE ' . prefixTable('sharekeys_fields') . ' AS skf
3686
-            INNER JOIN ' . prefixTable('items') . ' AS i ON skf.object_id = i.id
3685
+            'UPDATE '.prefixTable('sharekeys_fields').' AS skf
3686
+            INNER JOIN ' . prefixTable('items').' AS i ON skf.object_id = i.id
3687 3687
             SET skf.share_key = ""
3688 3688
             WHERE i.perso = 1
3689 3689
             AND skf.user_id = %i',
@@ -3727,8 +3727,8 @@  discard block
 block discarded – undo
3727 3727
                 'process_type' => 'create_user_keys',
3728 3728
                 'arguments' => json_encode([
3729 3729
                     'new_user_id' => (int) $userId,
3730
-                    'new_user_pwd' => cryption($userCurrentPwd, '','encrypt')['string'],
3731
-                    'new_user_private_key' => cryption($validPreviousKey['private_key'], '','encrypt')['string'],
3730
+                    'new_user_pwd' => cryption($userCurrentPwd, '', 'encrypt')['string'],
3731
+                    'new_user_private_key' => cryption($validPreviousKey['private_key'], '', 'encrypt')['string'],
3732 3732
                     'send_email' => 0,
3733 3733
                     'otp_provided_new_value' => 0,
3734 3734
                     'user_self_change' => 1,
Please login to merge, or discard this patch.
sources/identify.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     $sessionPwdAttempts = $session->get('pwd_attempts');
147 147
     $sessionUrl = $session->get('user-initial_url');
148 148
     $server = [];
149
-    $server['PHP_AUTH_USER'] =  $request->getUser();
149
+    $server['PHP_AUTH_USER'] = $request->getUser();
150 150
     $server['PHP_AUTH_PW'] = $request->getPassword();
151 151
     
152 152
     // decrypt and retreive data in JSON format
@@ -166,18 +166,18 @@  discard block
 block discarded – undo
166 166
     }
167 167
 
168 168
     // Check if Duo auth is in progress and pass the pw and login back to the standard login process
169
-    if(
169
+    if (
170 170
         isKeyExistingAndEqual('duo', 1, $SETTINGS) === true
171 171
         && $dataReceived['user_2fa_selection'] === 'duo'
172 172
         && $session->get('user-duo_status') === 'IN_PROGRESS'
173 173
         && !empty($dataReceived['duo_state'])
174
-    ){
174
+    ) {
175 175
         $key = hash('sha256', $dataReceived['duo_state']);
176 176
         $iv = substr(hash('sha256', $dataReceived['duo_state']), 0, 16);
177 177
         $duo_data_dec = openssl_decrypt(base64_decode($session->get('user-duo_data')), 'AES-256-CBC', $key, 0, $iv);
178 178
         // Clear the data from the Duo process to continue clean with the standard login process
179
-        $session->set('user-duo_data','');
180
-        if($duo_data_dec === false) {
179
+        $session->set('user-duo_data', '');
180
+        if ($duo_data_dec === false) {
181 181
             // Add failed authentication log
182 182
             addFailedAuthentication(filter_var($dataReceived['login'], FILTER_SANITIZE_FULL_SPECIAL_CHARS), getClientIpServer());
183 183
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
         $dataReceived['login'] = $duo_data['duo_login'];
196 196
     }
197 197
 
198
-    if(isset($dataReceived['pw']) === false || isset($dataReceived['login']) === false) {
198
+    if (isset($dataReceived['pw']) === false || isset($dataReceived['login']) === false) {
199 199
         echo json_encode([
200 200
             'data' => prepareExchangedData(
201 201
                 [
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
                 0,
504 504
                 (string) $return,
505 505
                 (array) $userInfo ?? [],
506
-                false,  // not success
506
+                false, // not success
507 507
                 'user_is_locked',
508 508
                 $lang->get('account_is_locked')
509 509
             ),
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
             (int) $sessionPwdAttempts,
520 520
             (string) $return,
521 521
             (array) $userInfo ?? [],
522
-            false,  // not success
522
+            false, // not success
523 523
             true,
524 524
             $lang->get('error_not_allowed_to_authenticate')
525 525
         ),
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
     // Get cache tree info
802 802
     $cacheTreeData = DB::queryFirstRow(
803 803
         'SELECT visible_folders
804
-        FROM ' . prefixTable('cache_tree') . '
804
+        FROM ' . prefixTable('cache_tree').'
805 805
         WHERE user_id=%i',
806 806
         (int) $session->get('user-id')
807 807
     );
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
         && (int) $userInfo['admin'] !== 1
833 833
     ) {
834 834
         // get all Admin users
835
-        $val = DB::queryFirstRow('SELECT email FROM ' . prefixTable('users') . " WHERE admin = %i and email != ''", 1);
835
+        $val = DB::queryFirstRow('SELECT email FROM '.prefixTable('users')." WHERE admin = %i and email != ''", 1);
836 836
         if (DB::count() > 0) {
837 837
             // Add email to table
838 838
             prepareSendingEmail(
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
                         '#tp_time#',
845 845
                     ],
846 846
                     [
847
-                        ' ' . $session->get('user-login') . ' (IP: ' . getClientIpServer() . ')',
847
+                        ' '.$session->get('user-login').' (IP: '.getClientIpServer().')',
848 848
                         date($SETTINGS['date_format'], (int) time()),
849 849
                         date($SETTINGS['time_format'], (int) time()),
850 850
                     ],
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
     if (is_null($userInfo['roles_from_ad_groups']) === false) {
952 952
         $userInfo['fonction_id'] = empty($userInfo['fonction_id']) === true 
953 953
             ? $userInfo['roles_from_ad_groups'] 
954
-            : $userInfo['fonction_id'] . ';' . $userInfo['roles_from_ad_groups'];
954
+            : $userInfo['fonction_id'].';'.$userInfo['roles_from_ad_groups'];
955 955
     }
956 956
     
957 957
     // Store roles in session
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
         // Get roles from database
969 969
         $rolesList = DB::query(
970 970
             'SELECT id, title, complexity
971
-            FROM ' . prefixTable('roles_title') . '
971
+            FROM ' . prefixTable('roles_title').'
972 972
             WHERE id IN %li',
973 973
             $session->get('user-roles_array')
974 974
         );
@@ -1057,7 +1057,7 @@  discard block
 block discarded – undo
1057 1057
 {
1058 1058
     $rows = DB::query(
1059 1059
         'SELECT date
1060
-        FROM ' . prefixTable('log_system') . "
1060
+        FROM ' . prefixTable('log_system')."
1061 1061
         WHERE field_1 = %s
1062 1062
         AND type = 'failed_auth'
1063 1063
         AND label = 'password_is_not_correct'
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
         foreach ($rows as $record) {
1072 1072
             array_push(
1073 1073
                 $arrAttempts,
1074
-                date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['date'])
1074
+                date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['date'])
1075 1075
             );
1076 1076
         }
1077 1077
     }
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
     $ldapConnection
1107 1107
 ) : bool
1108 1108
 {
1109
-    include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
1109
+    include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
1110 1110
 
1111 1111
     if ((int) $userInfoDisabled === 1) {
1112 1112
         return false;
@@ -1194,7 +1194,7 @@  discard block
 block discarded – undo
1194 1194
         // If user has seed but no backup, create it on first successful login
1195 1195
         if (!empty($userInfo['user_derivation_seed']) && empty($userInfo['private_key_backup'])) {
1196 1196
             if (defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
1197
-                error_log('TEAMPASS Transparent Recovery - Creating backup for user ' . ($userInfo['login'] ?? 'unknown'));
1197
+                error_log('TEAMPASS Transparent Recovery - Creating backup for user '.($userInfo['login'] ?? 'unknown'));
1198 1198
             }
1199 1199
 
1200 1200
             $derivedKey = deriveBackupKey($userInfo['user_derivation_seed'], $userInfo['public_key'], $SETTINGS);
@@ -1364,7 +1364,7 @@  discard block
 block discarded – undo
1364 1364
     } catch (Exception $e) {
1365 1365
         return [
1366 1366
             'error' => true,
1367
-            'message' => "Error: " . $e->getMessage(),
1367
+            'message' => "Error: ".$e->getMessage(),
1368 1368
         ];
1369 1369
     }
1370 1370
 }
@@ -1395,7 +1395,7 @@  discard block
 block discarded – undo
1395 1395
                 'type' => 'OpenLDAP'
1396 1396
             ];
1397 1397
         default:
1398
-            throw new Exception("Unsupported LDAP type: " . $SETTINGS['ldap_type']);
1398
+            throw new Exception("Unsupported LDAP type: ".$SETTINGS['ldap_type']);
1399 1399
     }
1400 1400
 }
1401 1401
 
@@ -1532,7 +1532,7 @@  discard block
 block discarded – undo
1532 1532
         );
1533 1533
     }
1534 1534
     
1535
-    throw new Exception("Unsupported LDAP type: " . $ldapHandler['type']);
1535
+    throw new Exception("Unsupported LDAP type: ".$ldapHandler['type']);
1536 1536
 }
1537 1537
 
1538 1538
 /**
@@ -1549,12 +1549,12 @@  discard block
 block discarded – undo
1549 1549
     if (isset($SETTINGS['enable_ad_users_with_ad_groups']) === true && (int) $SETTINGS['enable_ad_users_with_ad_groups'] === 1) {
1550 1550
         // Get user groups from AD
1551 1551
         $user_ad_groups = [];
1552
-        foreach($groups as $group) {
1552
+        foreach ($groups as $group) {
1553 1553
             //print_r($group);
1554 1554
             // get relation role id for AD group
1555 1555
             $role = DB::queryFirstRow(
1556 1556
                 'SELECT lgr.role_id
1557
-                FROM ' . prefixTable('ldap_groups_roles') . ' AS lgr
1557
+                FROM ' . prefixTable('ldap_groups_roles').' AS lgr
1558 1558
                 WHERE lgr.ldap_group_id = %s',
1559 1559
                 $group
1560 1560
             );
@@ -1617,7 +1617,7 @@  discard block
 block discarded – undo
1617 1617
     $passwordManager = new PasswordManager();
1618 1618
     
1619 1619
     // Migrate password if needed
1620
-    $result  = $passwordManager->migratePassword(
1620
+    $result = $passwordManager->migratePassword(
1621 1621
         $userInfo['pw'],
1622 1622
         $passwordClear,
1623 1623
         (int) $userInfo['id']
@@ -1695,7 +1695,7 @@  discard block
 block discarded – undo
1695 1695
             // Check if exists in DB
1696 1696
             $groupData = DB::queryFirstRow(
1697 1697
                 'SELECT id
1698
-                FROM ' . prefixTable('roles_title') . '
1698
+                FROM ' . prefixTable('roles_title').'
1699 1699
                 WHERE title = %s',
1700 1700
                 $group["displayName"]
1701 1701
             );
@@ -1844,7 +1844,7 @@  discard block
 block discarded – undo
1844 1844
             
1845 1845
             // generate new QR
1846 1846
             $new_2fa_qr = $tfa->getQRCodeImageAsDataUri(
1847
-                'Teampass - ' . $username,
1847
+                'Teampass - '.$username,
1848 1848
                 $userInfo['ga']
1849 1849
             );
1850 1850
             // clear temporary code from DB
@@ -1857,7 +1857,7 @@  discard block
 block discarded – undo
1857 1857
                 $userInfo['id']
1858 1858
             );
1859 1859
             $firstTime = [
1860
-                'value' => '<img src="' . $new_2fa_qr . '">',
1860
+                'value' => '<img src="'.$new_2fa_qr.'">',
1861 1861
                 'user_admin' => isset($sessionAdmin) ? (int) $sessionAdmin : '',
1862 1862
                 'initial_url' => isset($sessionUrl) === true ? $sessionUrl : '',
1863 1863
                 'pwd_attempts' => (int) $sessionPwdAttempts,
@@ -2013,7 +2013,7 @@  discard block
 block discarded – undo
2013 2013
         }*/
2014 2014
         return [
2015 2015
             'error' => true,
2016
-            'message' => $duo_error . $lang->get('duo_error_check_config'),
2016
+            'message' => $duo_error.$lang->get('duo_error_check_config'),
2017 2017
             'pwd_attempts' => (int) $sessionPwdAttempts,
2018 2018
             'debug_message' => $e->getMessage(),
2019 2019
             'proceedIdentification' => false,
@@ -2029,7 +2029,7 @@  discard block
 block discarded – undo
2029 2029
         } catch (DuoException $e) {
2030 2030
             return [
2031 2031
                 'error' => true,
2032
-                'message' => $duo_error . $lang->get('duo_error_url'),
2032
+                'message' => $duo_error.$lang->get('duo_error_url'),
2033 2033
                 'pwd_attempts' => (int) $sessionPwdAttempts,
2034 2034
                 'debug_message' => $e->getMessage(),
2035 2035
                 'proceedIdentification' => false,
@@ -2037,7 +2037,7 @@  discard block
 block discarded – undo
2037 2037
         }
2038 2038
         
2039 2039
         // Somethimes Duo return success but fail to return a URL, double check if the URL has been created
2040
-        if (!empty($duo_redirect_url) && filter_var($duo_redirect_url,FILTER_SANITIZE_URL)) {
2040
+        if (!empty($duo_redirect_url) && filter_var($duo_redirect_url, FILTER_SANITIZE_URL)) {
2041 2041
             // Since Duo Universal requires a redirect, let's store some info when the user get's back after completing the Duo prompt
2042 2042
             $key = hash('sha256', $duo_state);
2043 2043
             $iv = substr(hash('sha256', $duo_state), 0, 16);
@@ -2065,7 +2065,7 @@  discard block
 block discarded – undo
2065 2065
         } else {
2066 2066
             return [
2067 2067
                 'error' => true,
2068
-                'message' => $duo_error . $lang->get('duo_error_url'),
2068
+                'message' => $duo_error.$lang->get('duo_error_url'),
2069 2069
                 'pwd_attempts' => (int) $sessionPwdAttempts,
2070 2070
                 'proceedIdentification' => false,
2071 2071
             ];
@@ -2086,8 +2086,8 @@  discard block
 block discarded – undo
2086 2086
         // return the response (which should be the user name)
2087 2087
         if ($decoded_token['preferred_username'] === $username) {
2088 2088
             $session->set('user-duo_status', 'COMPLET');
2089
-            $session->set('user-duo_state','');
2090
-            $session->set('user-duo_data','');
2089
+            $session->set('user-duo_state', '');
2090
+            $session->set('user-duo_data', '');
2091 2091
             $session->set('user-login', $username);
2092 2092
 
2093 2093
             return [
@@ -2098,9 +2098,9 @@  discard block
 block discarded – undo
2098 2098
             ];
2099 2099
         } else {
2100 2100
             // Something wrong, username from the original Duo request is different than the one received now
2101
-            $session->set('user-duo_status','');
2102
-            $session->set('user-duo_state','');
2103
-            $session->set('user-duo_data','');
2101
+            $session->set('user-duo_status', '');
2102
+            $session->set('user-duo_state', '');
2103
+            $session->set('user-duo_data', '');
2104 2104
 
2105 2105
             return [
2106 2106
                 'error' => true,
@@ -2111,9 +2111,9 @@  discard block
 block discarded – undo
2111 2111
         }
2112 2112
     }
2113 2113
     // If we are here something wrong
2114
-    $session->set('user-duo_status','');
2115
-    $session->set('user-duo_state','');
2116
-    $session->set('user-duo_data','');
2114
+    $session->set('user-duo_status', '');
2115
+    $session->set('user-duo_state', '');
2116
+    $session->set('user-duo_data', '');
2117 2117
     return [
2118 2118
         'error' => true,
2119 2119
         'message' => $lang->get('duo_login_mismatch'),
@@ -2232,7 +2232,7 @@  discard block
 block discarded – undo
2232 2232
         // Check for existing lock
2233 2233
         $unlock_at = DB::queryFirstField(
2234 2234
             'SELECT MAX(unlock_at)
2235
-             FROM ' . prefixTable('auth_failures') . '
2235
+             FROM ' . prefixTable('auth_failures').'
2236 2236
              WHERE unlock_at > %s
2237 2237
              AND ((source = %s AND value = %s) OR (source = %s AND value = %s))',
2238 2238
             date('Y-m-d H:i:s', time()),
@@ -2254,8 +2254,8 @@  discard block
 block discarded – undo
2254 2254
         // Get user info from DB
2255 2255
         $data = DB::queryFirstRow(
2256 2256
             'SELECT u.*, a.value AS api_key
2257
-            FROM ' . prefixTable('users') . ' AS u
2258
-            LEFT JOIN ' . prefixTable('api') . ' AS a ON (u.id = a.user_id)
2257
+            FROM ' . prefixTable('users').' AS u
2258
+            LEFT JOIN ' . prefixTable('api').' AS a ON (u.id = a.user_id)
2259 2259
             WHERE login = %s AND deleted_at IS NULL',
2260 2260
             $login
2261 2261
         );
@@ -2274,9 +2274,9 @@  discard block
 block discarded – undo
2274 2274
         // Check if similar login deleted exists
2275 2275
         DB::queryFirstRow(
2276 2276
             'SELECT id, login
2277
-            FROM ' . prefixTable('users') . '
2277
+            FROM ' . prefixTable('users').'
2278 2278
             WHERE login LIKE %s AND deleted_at IS NOT NULL',
2279
-            $login . '_deleted_%'
2279
+            $login.'_deleted_%'
2280 2280
         );
2281 2281
 
2282 2282
         if (DB::count() > 0) {
@@ -2386,7 +2386,7 @@  discard block
 block discarded – undo
2386 2386
             'array' => [
2387 2387
                 'value' => 'bruteforce_wait',
2388 2388
                 'error' => true,
2389
-                'message' => $lang->get('bruteforce_wait') . (string) $e->getMessage(),
2389
+                'message' => $lang->get('bruteforce_wait').(string) $e->getMessage(),
2390 2390
             ]
2391 2391
         ];
2392 2392
     }
@@ -2491,7 +2491,7 @@  discard block
 block discarded – undo
2491 2491
     // Clean previous failed attempts
2492 2492
     $failedTasks = DB::query(
2493 2493
         'SELECT increment_id
2494
-        FROM ' . prefixTable('background_tasks') . '
2494
+        FROM ' . prefixTable('background_tasks').'
2495 2495
         WHERE process_type = %s
2496 2496
         AND JSON_EXTRACT(arguments, "$.new_user_id") = %i
2497 2497
         AND status = %s',
@@ -2608,7 +2608,7 @@  discard block
 block discarded – undo
2608 2608
                         $userKeys['public_key']
2609 2609
                     );
2610 2610
                 }*/
2611
-                    error_log('Switch user ' . $username . ' auth_type to oauth2');
2611
+                    error_log('Switch user '.$username.' auth_type to oauth2');
2612 2612
                 // Update user in database:
2613 2613
                 DB::update(
2614 2614
                     prefixTable('users'),
@@ -2832,12 +2832,12 @@  discard block
 block discarded – undo
2832 2832
 {
2833 2833
     // Find the latest "create_user_keys" task for the given user_id
2834 2834
     $latestTask = DB::queryFirstRow(
2835
-        'SELECT arguments, status FROM ' . prefixTable('background_tasks') . '
2835
+        'SELECT arguments, status FROM '.prefixTable('background_tasks').'
2836 2836
         WHERE process_type = %s
2837 2837
         AND arguments LIKE %s
2838 2838
         ORDER BY increment_id DESC
2839 2839
         LIMIT 1',
2840
-        'create_user_keys', '%"new_user_id":' . $userId . '%'
2840
+        'create_user_keys', '%"new_user_id":'.$userId.'%'
2841 2841
     );
2842 2842
 
2843 2843
     // If a failed task is found, return an error message
@@ -3049,15 +3049,15 @@  discard block
 block discarded – undo
3049 3049
 
3050 3050
             if ($ret['error'] !== false) {
3051 3051
                 logEvents($SETTINGS, 'failed_auth', 'bad_duo_mfa', '', stripslashes($username), stripslashes($username));
3052
-                $session->set('user-duo_status','');
3053
-                $session->set('user-duo_state','');
3054
-                $session->set('user-duo_data','');
3052
+                $session->set('user-duo_status', '');
3053
+                $session->set('user-duo_state', '');
3054
+                $session->set('user-duo_data', '');
3055 3055
                 return [
3056 3056
                     'error' => true,
3057 3057
                     'mfaData' => $ret,
3058 3058
                     'mfaQRCodeInfos' => false,
3059 3059
                 ];
3060
-            } else if ($ret['duo_url_ready'] === true){
3060
+            } else if ($ret['duo_url_ready'] === true) {
3061 3061
                 return [
3062 3062
                     'error' => false,
3063 3063
                     'mfaData' => $ret,
@@ -3121,7 +3121,7 @@  discard block
 block discarded – undo
3121 3121
     // Count failed attempts from this source
3122 3122
     $count = DB::queryFirstField(
3123 3123
         'SELECT COUNT(*)
3124
-        FROM ' . prefixTable('auth_failures') . '
3124
+        FROM ' . prefixTable('auth_failures').'
3125 3125
         WHERE source = %s AND value = %s',
3126 3126
         $source,
3127 3127
         $value
Please login to merge, or discard this patch.
pages/users.js.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('users') === false) {
73 73
     // Not allowed page
74 74
     $session->set('system-error_code', ERR_NOT_ALLOWED);
75
-    include $SETTINGS['cpassman_dir'] . '/error.php';
75
+    include $SETTINGS['cpassman_dir'].'/error.php';
76 76
     exit;
77 77
 }
78 78
 ?>
@@ -307,8 +307,8 @@  discard block
 block discarded – undo
307 307
         if (store.get('teampassApplication').formUserAction === "add_new_user") {
308 308
             var data = {
309 309
                 'receipt': $('#form-email').val(),
310
-                'subject': 'TEAMPASS - <?php echo $lang->get('temporary_encryption_code');?>',
311
-                'body': '<?php echo $lang->get('email_body_new_user');?>',
310
+                'subject': 'TEAMPASS - <?php echo $lang->get('temporary_encryption_code'); ?>',
311
+                'body': '<?php echo $lang->get('email_body_new_user'); ?>',
312 312
                 'pre_replace' : {
313 313
                     '#code#' : store.get('teampassUser').admin_new_user_temporary_encryption_code,
314 314
                     '#login#' : store.get('teampassUser').admin_new_user_login,
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
         } else {
319 319
             var data = {
320 320
                 'receipt': $('#form-email').val(),
321
-                'subject': 'TEAMPASS - <?php echo $lang->get('temporary_encryption_code');?>',
322
-                'body': '<?php echo $lang->get('email_body_temporary_encryption_code');?>',
321
+                'subject': 'TEAMPASS - <?php echo $lang->get('temporary_encryption_code'); ?>',
322
+                'body': '<?php echo $lang->get('email_body_temporary_encryption_code'); ?>',
323 323
                 'pre_replace' : {
324 324
                     '#enc_code#' : store.get('teampassUser').admin_new_user_temporary_encryption_code,
325 325
                 }
@@ -514,13 +514,13 @@  discard block
 block discarded – undo
514 514
             }
515 515
             // Inform user
516 516
             $("#warningModalBody").html('<b><?php echo $lang->get('encryption_keys'); ?> - ' +
517
-                stepText + '</b> [' + start + ' - ' + (parseInt(start) + <?php echo NUMBER_ITEMS_IN_BATCH;?>) + ']<span id="warningModalBody_extra">' + $nbItemsToConvert + '</span> ' +
517
+                stepText + '</b> [' + start + ' - ' + (parseInt(start) + <?php echo NUMBER_ITEMS_IN_BATCH; ?>) + ']<span id="warningModalBody_extra">' + $nbItemsToConvert + '</span> ' +
518 518
                 '... <?php echo $lang->get('please_wait'); ?><i class="fa-solid fa-spinner fa-pulse ml-3 text-primary"></i>');
519 519
 
520 520
             var data = {
521 521
                 action: step,
522 522
                 start: start,
523
-                length: <?php echo NUMBER_ITEMS_IN_BATCH;?>,
523
+                length: <?php echo NUMBER_ITEMS_IN_BATCH; ?>,
524 524
                 user_id: userId,
525 525
             }
526 526
             if (debugJavascript === true) {
@@ -1417,7 +1417,7 @@  discard block
 block discarded – undo
1417 1417
                         } else {
1418 1418
                             // Show icon or not
1419 1419
                             if ($('#user-disabled').prop('checked') === true) {
1420
-                                $('#user-login-'+userID).before('<i class="fa-solid fa-user-slash infotip text-danger mr-2" title="<?php echo $lang->get('account_is_locked');?>" id="user-disable-'+userID+'"></i>');
1420
+                                $('#user-login-'+userID).before('<i class="fa-solid fa-user-slash infotip text-danger mr-2" title="<?php echo $lang->get('account_is_locked'); ?>" id="user-disable-'+userID+'"></i>');
1421 1421
                             } else {
1422 1422
                                 $('#user-disable-'+userID).remove();
1423 1423
                             }
Please login to merge, or discard this patch.