Passed
Push — master ( 8995ac...1b609d )
by Nils
06:33
created
scripts/traits/UserHandlerTrait.php 1 patch
Spacing   +30 added lines, -30 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
     
@@ -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
             WHERE perso =  %i
199 199
             ORDER BY id ASC
200 200
             LIMIT %i, %i',
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
             // Get itemKey from current user
208 208
             $currentUserKey = DB::queryFirstRow(
209 209
                 'SELECT share_key, increment_id
210
-                FROM ' . prefixTable('sharekeys_items') . '
210
+                FROM ' . prefixTable('sharekeys_items').'
211 211
                 WHERE object_id = %i AND user_id = %i',
212 212
                 $record['id'],
213 213
                 (int) $record['perso'] === 0 ? $arguments['owner_id'] : $arguments['new_user_id']
@@ -312,16 +312,16 @@  discard block
 block discarded – undo
312 312
         // Loop on logs
313 313
         $rows = DB::query(
314 314
             'SELECT increment_id
315
-            FROM ' . prefixTable('log_items') . '
315
+            FROM ' . prefixTable('log_items').'
316 316
             WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"
317 317
             ORDER BY increment_id ASC
318
-            LIMIT ' . $taskData['index'] . ', ' . $taskData['nb']
318
+            LIMIT ' . $taskData['index'].', '.$taskData['nb']
319 319
         );
320 320
         foreach ($rows as $record) {
321 321
             // Get itemKey from current user
322 322
             $currentUserKey = DB::queryFirstRow(
323 323
                 'SELECT share_key
324
-                FROM ' . prefixTable('sharekeys_logs') . '
324
+                FROM ' . prefixTable('sharekeys_logs').'
325 325
                 WHERE object_id = %i AND user_id = %i',
326 326
                 $record['increment_id'],
327 327
                 $arguments['owner_id']
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
                 if ((int) $arguments['new_user_id'] !== (int) $arguments['owner_id']) {
354 354
                     $currentUserKey = DB::queryFirstRow(
355 355
                         'SELECT increment_id
356
-                        FROM ' . prefixTable('sharekeys_items') . '
356
+                        FROM ' . prefixTable('sharekeys_items').'
357 357
                         WHERE object_id = %i AND user_id = %i',
358 358
                         $record['id'],
359 359
                         $arguments['new_user_id']
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         // Loop on fields
402 402
         $rows = DB::query(
403 403
             'SELECT id
404
-            FROM ' . prefixTable('categories_items') . '
404
+            FROM ' . prefixTable('categories_items').'
405 405
             WHERE encryption_type = "teampass_aes"
406 406
             ORDER BY id ASC
407 407
             LIMIT %i, %i',
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
             // Get itemKey from current user
413 413
             $currentUserKey = DB::queryFirstRow(
414 414
                 'SELECT share_key
415
-                FROM ' . prefixTable('sharekeys_fields') . '
415
+                FROM ' . prefixTable('sharekeys_fields').'
416 416
                 WHERE object_id = %i AND user_id = %i',
417 417
                 $record['id'],
418 418
                 $arguments['owner_id']
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
                     if ((int) $arguments['new_user_id'] !== (int) $arguments['owner_id']) {
441 441
                         $currentUserKey = DB::queryFirstRow(
442 442
                             'SELECT increment_id
443
-                            FROM ' . prefixTable('sharekeys_items') . '
443
+                            FROM ' . prefixTable('sharekeys_items').'
444 444
                             WHERE object_id = %i AND user_id = %i',
445 445
                             $record['id'],
446 446
                             $arguments['new_user_id']
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
         // Loop on suggestions
490 490
         $rows = DB::query(
491 491
             'SELECT id
492
-            FROM ' . prefixTable('suggestion') . '
492
+            FROM ' . prefixTable('suggestion').'
493 493
             ORDER BY id ASC
494 494
             LIMIT %i, %i',
495 495
             $taskData['index'],
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
             // Get itemKey from current user
500 500
             $currentUserKey = DB::queryFirstRow(
501 501
                 'SELECT share_key
502
-                FROM ' . prefixTable('sharekeys_suggestions') . '
502
+                FROM ' . prefixTable('sharekeys_suggestions').'
503 503
                 WHERE object_id = %i AND user_id = %i',
504 504
                 $record['id'],
505 505
                 $arguments['owner_id']
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
                 if ((int) $arguments['new_user_id'] !== (int) $arguments['owner_id']) {
532 532
                     $currentUserKey = DB::queryFirstRow(
533 533
                         'SELECT increment_id
534
-                        FROM ' . prefixTable('sharekeys_items') . '
534
+                        FROM ' . prefixTable('sharekeys_items').'
535 535
                         WHERE object_id = %i AND user_id = %i',
536 536
                         $record['id'],
537 537
                         $arguments['new_user_id']
@@ -579,9 +579,9 @@  discard block
 block discarded – undo
579 579
         // Loop on files
580 580
         $rows = DB::query(
581 581
             'SELECT f.id AS id, i.perso AS perso
582
-            FROM ' . prefixTable('files') . ' AS f
583
-            INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = f.id_item
584
-            WHERE f.status = "' . TP_ENCRYPTION_NAME . '"
582
+            FROM ' . prefixTable('files').' AS f
583
+            INNER JOIN ' . prefixTable('items').' AS i ON i.id = f.id_item
584
+            WHERE f.status = "' . TP_ENCRYPTION_NAME.'"
585 585
             LIMIT %i, %i',
586 586
             $taskData['index'],
587 587
             $taskData['nb']
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
             // Get itemKey from current user
591 591
             $currentUserKey = DB::queryFirstRow(
592 592
                 'SELECT share_key, increment_id
593
-                FROM ' . prefixTable('sharekeys_files') . '
593
+                FROM ' . prefixTable('sharekeys_files').'
594 594
                 WHERE object_id = %i AND user_id = %i',
595 595
                 $record['id'],
596 596
                 (int) $record['perso'] === 0 ? $arguments['owner_id'] : $arguments['new_user_id']
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 
619 619
             $currentUserKey = DB::queryFirstRow(
620 620
                 'SELECT increment_id
621
-                FROM ' . prefixTable('sharekeys_files') . '
621
+                FROM ' . prefixTable('sharekeys_files').'
622 622
                 WHERE object_id = %i AND user_id = %i',
623 623
                 $record['id'],
624 624
                 $arguments['new_user_id']
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
         // get user info
699 699
         $userInfo = DB::queryFirstRow(
700 700
             'SELECT u.email, u.login, u.auth_type, u.special, u.lastname, u.name
701
-            FROM ' . prefixTable('users') . ' AS u
701
+            FROM ' . prefixTable('users').' AS u
702 702
             WHERE u.id = %i',
703 703
             $arguments['new_user_id']
704 704
         );
@@ -713,10 +713,10 @@  discard block
 block discarded – undo
713 713
                 filter_var($userInfo['email'], FILTER_SANITIZE_EMAIL),
714 714
                 // @scrutinizer ignore-type
715 715
                 empty($arguments['email_body']) === false ? $arguments['email_body'] : $lang->get('email_body_user_config_1'),
716
-                'TEAMPASS - ' . $lang->get('login_credentials'),
716
+                'TEAMPASS - '.$lang->get('login_credentials'),
717 717
                 (array) filter_var_array(
718 718
                     [
719
-                        '#code#' => cryption($arguments['new_user_code'], '','decrypt', $this->settings)['string'],
719
+                        '#code#' => cryption($arguments['new_user_code'], '', 'decrypt', $this->settings)['string'],
720 720
                         '#lastname#' => isset($userInfo['name']) === true ? $userInfo['name'] : '',
721 721
                         '#login#' => isset($userInfo['login']) === true ? $userInfo['login'] : '',
722 722
                     ],
@@ -780,24 +780,24 @@  discard block
 block discarded – undo
780 780
     private function getOwnerInfos(int $owner_id, string $owner_pwd, int $only_personal_items = 0, string $owner_private_key = ''): array {
781 781
         $userInfo = DB::queryFirstRow(
782 782
             'SELECT pw, public_key, private_key, login, name
783
-            FROM ' . prefixTable('users') . '
783
+            FROM ' . prefixTable('users').'
784 784
             WHERE id = %i',
785 785
             $owner_id
786 786
         );
787 787
 
788 788
         // decrypt owner password 
789
-        $pwd = cryption($owner_pwd, '','decrypt', $this->settings)['string'];
789
+        $pwd = cryption($owner_pwd, '', 'decrypt', $this->settings)['string'];
790 790
 
791 791
         // decrypt private key and send back
792 792
         if ((int) $only_personal_items === 1 && empty($owner_private_key) === false) {
793 793
             // Explicitely case where we only want personal items and where user has provided his private key
794 794
             return [
795
-                'private_key' => cryption($owner_private_key, '','decrypt')['string'],
795
+                'private_key' => cryption($owner_private_key, '', 'decrypt')['string'],
796 796
                 'public_key' => $userInfo['public_key'],
797 797
                 'login' => $userInfo['login'],
798 798
                 'name' => $userInfo['name'],
799 799
             ];
800
-        }else {
800
+        } else {
801 801
             // Normal case
802 802
             return [
803 803
                 'private_key' => decryptPrivateKey($pwd, $userInfo['private_key']),
Please login to merge, or discard this patch.
pages/api.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('api') === false) {
70 70
     // Not allowed page
71 71
     $session->set('system-error_code', ERR_NOT_ALLOWED);
72
-    include $SETTINGS['cpassman_dir'] . '/error.php';
72
+    include $SETTINGS['cpassman_dir'].'/error.php';
73 73
     exit;
74 74
 }
75 75
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                                     <?php
161 161
                                     $rowsKeys = DB::query(
162 162
                                         'SELECT *
163
-                                        FROM ' . prefixTable('api') . '
163
+                                        FROM ' . prefixTable('api').'
164 164
                                         WHERE type = %s
165 165
                                         ORDER BY timestamp ASC',
166 166
                                         'key'
@@ -183,15 +183,15 @@  discard block
 block discarded – undo
183 183
                                             <?php
184 184
                                             foreach ($rowsKeys as $key) {
185 185
                                                 echo '
186
-                                                    <tr data-id="' . $key['increment_id'] . '">
187
-                                                    <td width="50px"><i class="fas fa-trash infotip pointer delete-api-key" title="' . $lang->get('del_button') . '"></i></td>
188
-                                                    <td><span class="edit-api-key pointer">' . $key['label'] . '</span></td>
189
-                                                    <td>' . $key['value']. '</td>   
190
-                                                    <td><i class="fas '.((int) $key['enabled'] === 1 ? 'fa-toggle-on text-info' : 'fa-toggle-off').' mr-1 text-center pointer api-clickme-action" data-field="enabled" data-increment-id="' . $key['increment_id'] . '"></i></td>
191
-                                                    <td><i class="fas '.((int) $key['allowed_to_create'] === 1 ? 'fa-toggle-on text-info' : 'fa-toggle-off').' mr-1 text-center pointer api-clickme-action" data-field="allowed_to_create" data-increment-id="' . $key['increment_id'] . '"></i></td>
192
-                                                    <td><i class="fas '.((int) $key['allowed_to_read'] === 1 ? 'fa-toggle-on text-info' : 'fa-toggle-off').' mr-1 text-center pointer api-clickme-action" data-field="allowed_to_read" data-increment-id="' . $key['increment_id'] . '"></i></td>
193
-                                                    <td><i class="fas '.((int) $key['allowed_to_update'] === 1 ? 'fa-toggle-on text-info' : 'fa-toggle-off').' mr-1 text-center pointer api-clickme-action" data-field="allowed_to_update" data-increment-id="' . $key['increment_id'] . '"></i></td>
194
-                                                    <td><i class="fas '.((int) $key['allowed_to_delete'] === 1 ? 'fa-toggle-on text-info' : 'fa-toggle-off').' mr-1 text-center pointer api-clickme-action" data-field="allowed_to_delete" data-increment-id="' . $key['increment_id'] . '"></i></td>                   
186
+                                                    <tr data-id="' . $key['increment_id'].'">
187
+                                                    <td width="50px"><i class="fas fa-trash infotip pointer delete-api-key" title="' . $lang->get('del_button').'"></i></td>
188
+                                                    <td><span class="edit-api-key pointer">' . $key['label'].'</span></td>
189
+                                                    <td>' . $key['value'].'</td>   
190
+                                                    <td><i class="fas '.((int) $key['enabled'] === 1 ? 'fa-toggle-on text-info' : 'fa-toggle-off').' mr-1 text-center pointer api-clickme-action" data-field="enabled" data-increment-id="'.$key['increment_id'].'"></i></td>
191
+                                                    <td><i class="fas '.((int) $key['allowed_to_create'] === 1 ? 'fa-toggle-on text-info' : 'fa-toggle-off').' mr-1 text-center pointer api-clickme-action" data-field="allowed_to_create" data-increment-id="'.$key['increment_id'].'"></i></td>
192
+                                                    <td><i class="fas '.((int) $key['allowed_to_read'] === 1 ? 'fa-toggle-on text-info' : 'fa-toggle-off').' mr-1 text-center pointer api-clickme-action" data-field="allowed_to_read" data-increment-id="'.$key['increment_id'].'"></i></td>
193
+                                                    <td><i class="fas '.((int) $key['allowed_to_update'] === 1 ? 'fa-toggle-on text-info' : 'fa-toggle-off').' mr-1 text-center pointer api-clickme-action" data-field="allowed_to_update" data-increment-id="'.$key['increment_id'].'"></i></td>
194
+                                                    <td><i class="fas '.((int) $key['allowed_to_delete'] === 1 ? 'fa-toggle-on text-info' : 'fa-toggle-off').' mr-1 text-center pointer api-clickme-action" data-field="allowed_to_delete" data-increment-id="'.$key['increment_id'].'"></i></td>                   
195 195
                                                 </tr>';
196 196
                                             } ?>
197 197
                                         </tbody>
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
                                 <div class="col-12 mt-4" id="table-api-ip">
227 227
                                     <?php
228 228
                                     $rowsIps = DB::query(
229
-                                                'SELECT increment_id, label, timestamp value FROM ' . prefixTable('api') . '
229
+                                                'SELECT increment_id, label, timestamp value FROM '.prefixTable('api').'
230 230
                                                 WHERE type = %s
231 231
                                                 ORDER BY timestamp ASC',
232 232
                                                 'ip'
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
                                             <?php
245 245
                                             foreach ($rowsIps as $ip) {
246 246
                                                 echo '
247
-                                                <tr data-id="' . $ip['increment_id'] . '">
248
-                                                    <td width="50px"><i class="fas fa-trash infotip pointer delete-api-ip" title="' . $lang->get('del_button') . '"></i></td>
249
-                                                    <td><span class="edit-api-ip pointer" data-field="label">' . $ip['label'] . '</span></td>
250
-                                                    <td><span class="edit-api-ip pointer" data-field="value">' . $ip['value'] . '</span></td>
247
+                                                <tr data-id="' . $ip['increment_id'].'">
248
+                                                    <td width="50px"><i class="fas fa-trash infotip pointer delete-api-ip" title="' . $lang->get('del_button').'"></i></td>
249
+                                                    <td><span class="edit-api-ip pointer" data-field="label">' . $ip['label'].'</span></td>
250
+                                                    <td><span class="edit-api-ip pointer" data-field="value">' . $ip['value'].'</span></td>
251 251
                                                 </tr>';
252 252
                                             } ?>
253 253
                                         </tbody>
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
                                     <?php
292 292
                                     $rowsKeys = DB::query(
293 293
                                         'SELECT a.*, u.name, u.lastname, u.login
294
-                                        FROM ' . prefixTable('api') . ' AS a
295
-                                        INNER JOIN ' . prefixTable('users') . ' AS u ON a.user_id = u.id
294
+                                        FROM ' . prefixTable('api').' AS a
295
+                                        INNER JOIN ' . prefixTable('users').' AS u ON a.user_id = u.id
296 296
                                         WHERE a.type = %s AND u.disabled = %i AND u.deleted_at IS NULL AND u.id NOT IN %li AND u.admin = %i
297 297
                                         ORDER BY u.login ASC',
298 298
                                         'user',
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
                                             <?php
317 317
                                             foreach ($rowsKeys as $key) {
318 318
                                                 echo '
319
-                                                    <tr data-id="' . $key['increment_id'] . '">
320
-                                                    <td>' . $key['name'] . ' ' . $key['lastname'] . ' (<i>'.$key['login'].'</i>)</td>
321
-                                                    <td><i class="fas '.((int) $key['enabled'] === 1 ? 'fa-toggle-on text-info' : 'fa-toggle-off').' mr-1 text-center pointer api-clickme-action" data-field="enabled" data-increment-id="' . $key['increment_id'] . '"></i></td>
322
-                                                    <td><i class="fas '.((int) $key['allowed_to_create'] === 1 ? 'fa-toggle-on text-info' : 'fa-toggle-off').' mr-1 text-center pointer api-clickme-action" data-field="allowed_to_create" data-increment-id="' . $key['increment_id'] . '"></i></td>
323
-                                                    <td><i class="fas '.((int) $key['allowed_to_read'] === 1 ? 'fa-toggle-on text-info' : 'fa-toggle-off').' mr-1 text-center pointer api-clickme-action" data-field="allowed_to_read" data-increment-id="' . $key['increment_id'] . '"></i></td>
324
-                                                    <td><i class="fas '.((int) $key['allowed_to_update'] === 1 ? 'fa-toggle-on text-info' : 'fa-toggle-off').' mr-1 text-center pointer api-clickme-action" data-field="allowed_to_update" data-increment-id="' . $key['increment_id'] . '"></i></td>
325
-                                                    <td><i class="fas '.((int) $key['allowed_to_delete'] === 1 ? 'fa-toggle-on text-info' : 'fa-toggle-off').' mr-1 text-center pointer api-clickme-action" data-field="allowed_to_delete" data-increment-id="' . $key['increment_id'] . '"></i></td>
319
+                                                    <tr data-id="' . $key['increment_id'].'">
320
+                                                    <td>' . $key['name'].' '.$key['lastname'].' (<i>'.$key['login'].'</i>)</td>
321
+                                                    <td><i class="fas '.((int) $key['enabled'] === 1 ? 'fa-toggle-on text-info' : 'fa-toggle-off').' mr-1 text-center pointer api-clickme-action" data-field="enabled" data-increment-id="'.$key['increment_id'].'"></i></td>
322
+                                                    <td><i class="fas '.((int) $key['allowed_to_create'] === 1 ? 'fa-toggle-on text-info' : 'fa-toggle-off').' mr-1 text-center pointer api-clickme-action" data-field="allowed_to_create" data-increment-id="'.$key['increment_id'].'"></i></td>
323
+                                                    <td><i class="fas '.((int) $key['allowed_to_read'] === 1 ? 'fa-toggle-on text-info' : 'fa-toggle-off').' mr-1 text-center pointer api-clickme-action" data-field="allowed_to_read" data-increment-id="'.$key['increment_id'].'"></i></td>
324
+                                                    <td><i class="fas '.((int) $key['allowed_to_update'] === 1 ? 'fa-toggle-on text-info' : 'fa-toggle-off').' mr-1 text-center pointer api-clickme-action" data-field="allowed_to_update" data-increment-id="'.$key['increment_id'].'"></i></td>
325
+                                                    <td><i class="fas '.((int) $key['allowed_to_delete'] === 1 ? 'fa-toggle-on text-info' : 'fa-toggle-off').' mr-1 text-center pointer api-clickme-action" data-field="allowed_to_delete" data-increment-id="'.$key['increment_id'].'"></i></td>
326 326
                                                 </tr>';
327 327
                                             } ?>
328 328
                                         </tbody>
Please login to merge, or discard this patch.