Passed
Push — wip_sessions ( 830972...dba0a8 )
by Nils
06:24
created
scripts/background_tasks___do_calculation.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     // get count of Items in this folder
72 72
     $get = DB::queryfirstrow(
73 73
         'SELECT count(*) as num_results
74
-        FROM ' . prefixTable('items') . '
74
+        FROM ' . prefixTable('items').'
75 75
         WHERE inactif = %i AND id_tree = %i',
76 76
         0,
77 77
         $child->id
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
     $ret[$child->id]['id'] = $child->id;
81 81
 
82 82
     // get number of subfolders
83
-    $nodeDescendants =$tree->getDescendants($child->id, false, false, true);
83
+    $nodeDescendants = $tree->getDescendants($child->id, false, false, true);
84 84
     $ret[$child->id]['subfoldersCount'] = count($nodeDescendants);
85 85
 
86 86
     // get items number in subfolders
87 87
     if (count($nodeDescendants) > 0) {
88 88
         $get = DB::queryfirstrow(
89 89
             'SELECT count(*) as num_results
90
-            FROM ' . prefixTable('items') . '
90
+            FROM ' . prefixTable('items').'
91 91
             WHERE inactif = %i AND id_tree IN (%l)',
92 92
             0,
93 93
             implode(',', $nodeDescendants)
Please login to merge, or discard this patch.
scripts/background_tasks___items_handler.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 DB::debugmode(false);
75 75
 $process_to_perform = DB::queryfirstrow(
76 76
     'SELECT *
77
-    FROM ' . prefixTable('processes') . '
77
+    FROM ' . prefixTable('processes').'
78 78
     WHERE is_in_progress = %i AND process_type IN ("item_copy", "new_item", "update_item")
79 79
     ORDER BY increment_id ASC',
80 80
     1
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     // search for next process to handle
92 92
     $process_to_perform = DB::queryfirstrow(
93 93
         'SELECT *
94
-        FROM ' . prefixTable('processes') . '
94
+        FROM ' . prefixTable('processes').'
95 95
         WHERE is_in_progress = %i AND finished_at = "" AND process_type IN ("item_copy", "new_item", "update_item")
96 96
         ORDER BY increment_id ASC',
97 97
         0
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
             $process_to_perform['increment_id']
109 109
         );
110 110
 
111
-        provideLog('[PROCESS][#'. $process_to_perform['increment_id'].'][START]', $SETTINGS);
111
+        provideLog('[PROCESS][#'.$process_to_perform['increment_id'].'][START]', $SETTINGS);
112 112
         handleTask(
113 113
             $process_to_perform['increment_id'],
114 114
             json_decode($process_to_perform['arguments'], true),
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 // launch a new iterative process
126 126
 $process_to_perform = DB::queryfirstrow(
127 127
     'SELECT *
128
-    FROM ' . prefixTable('processes') . '
128
+    FROM ' . prefixTable('processes').'
129 129
     WHERE is_in_progress = %i AND process_type IN ("item_copy", "new_item", "update_item")
130 130
     ORDER BY increment_id ASC',
131 131
     1
@@ -147,10 +147,10 @@  discard block
 block discarded – undo
147 147
  */
148 148
 function handleTask(int $processId, array $ProcessArguments, array $SETTINGS): bool
149 149
 {
150
-    provideLog('[PROCESS][#'. $processId.'][START]', $SETTINGS);
150
+    provideLog('[PROCESS][#'.$processId.'][START]', $SETTINGS);
151 151
     $task_to_perform = DB::queryfirstrow(
152 152
         'SELECT *
153
-        FROM ' . prefixTable('processes_tasks') . '
153
+        FROM ' . prefixTable('processes_tasks').'
154 154
         WHERE process_id = %i AND finished_at IS NULL
155 155
         ORDER BY increment_id ASC',
156 156
         $processId
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         // check if a linux process is not currently on going
164 164
         // if sub_task_in_progress === 1 then exit
165 165
         if ((int) $task_to_perform['sub_task_in_progress'] === 0) {
166
-            provideLog('[TASK][#'. $task_to_perform['increment_id'].'][START]', $SETTINGS);
166
+            provideLog('[TASK][#'.$task_to_perform['increment_id'].'][START]', $SETTINGS);
167 167
 
168 168
             // handle next task
169 169
             $args = json_decode($task_to_perform['task'], true);
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
             DB::update(
245 245
                 prefixTable('processes_tasks'),
246 246
                 array(
247
-                    'sub_task_in_progress' => 0,    // flag sub task is no more in prgoress
247
+                    'sub_task_in_progress' => 0, // flag sub task is no more in prgoress
248 248
                     'task' => json_encode(["status" => "Done"]),
249 249
                     'is_in_progress' => -1,
250 250
                     'finished_at' => time(),
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 
279 279
         } else {
280 280
             // Task is currently being in progress by another server process
281
-            provideLog('[TASK][#'. $task_to_perform['increment_id'].'][WARNING] Similar task already being processes', $SETTINGS);
281
+            provideLog('[TASK][#'.$task_to_perform['increment_id'].'][WARNING] Similar task already being processes', $SETTINGS);
282 282
             return false;
283 283
         }
284 284
     }
Please login to merge, or discard this patch.
scripts/task_maintenance_reload_cache_table.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -74,8 +74,8 @@
 block discarded – undo
74 74
 function reloadCacheTable(): void
75 75
 {
76 76
     // Load expected files
77
-    require_once __DIR__. '/../sources/main.functions.php';
78
-    include __DIR__. '/../includes/config/tp.config.php';
77
+    require_once __DIR__.'/../sources/main.functions.php';
78
+    include __DIR__.'/../includes/config/tp.config.php';
79 79
 
80 80
     updateCacheTable('reload', NULL);
81 81
 }
82 82
\ No newline at end of file
Please login to merge, or discard this patch.
api/Model/ItemModel.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  */
25 25
 use TeampassClasses\NestedTree\NestedTree;
26 26
 
27
-require_once API_ROOT_PATH . "/Model/Database.php";
27
+require_once API_ROOT_PATH."/Model/Database.php";
28 28
 
29 29
 class ItemModel extends Database
30 30
 {
@@ -46,16 +46,16 @@  discard block
 block discarded – undo
46 46
             "SELECT i.id, label, description, i.pw, i.url, i.id_tree, i.login, i.email, i.viewed_no, i.fa_icon, i.inactif, i.perso, t.title as folder_label
47 47
             FROM ".prefixTable('items')." as i
48 48
             LEFT JOIN ".prefixTable('nested_tree')." as t ON (t.id = i.id_tree) ".
49
-            $sqlExtra . 
50
-            " ORDER BY i.id ASC" .
49
+            $sqlExtra. 
50
+            " ORDER BY i.id ASC".
51 51
             //($limit > 0 ? " LIMIT ?". ["i", $limit] : '')
52
-            ($limit > 0 ? " LIMIT ". $limit : '')
52
+            ($limit > 0 ? " LIMIT ".$limit : '')
53 53
         );
54 54
         $ret = [];
55 55
         foreach ($rows as $row) {
56 56
             $userKey = $this->select(
57 57
                 'SELECT share_key
58
-                FROM ' . prefixTable('sharekeys_items') . '
58
+                FROM ' . prefixTable('sharekeys_items').'
59 59
                 WHERE user_id = '.$userId.' AND object_id = '.$row['id']                
60 60
             );
61 61
             if (count($userKey) === 0 || empty($row['pw']) === true) {
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
                 if (empty($path) === true) {
90 90
                     $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
91 91
                 } else {
92
-                    $path .= '/' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
92
+                    $path .= '/'.htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
93 93
                 }
94 94
             }
95 95
 
Please login to merge, or discard this patch.
api/index.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 header("Access-Control-Allow-Methods: POST");
31 31
 header("Access-Control-Max-Age: 3600");
32 32
 header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
33
-require __DIR__ . "/inc/bootstrap.php";
33
+require __DIR__."/inc/bootstrap.php";
34 34
 
35 35
 // sanitize url segments
36 36
 $base = new BaseController();
37 37
 $uri = $base->getUriSegments();
38 38
 if (is_array($uri) === false || is_string($uri) === true) {
39
-    $uri = [$uri];  // ensure $uril is table
39
+    $uri = [$uri]; // ensure $uril is table
40 40
 }
41 41
 
42 42
 // Prepare DB password
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 if ($uri[0] === 'authorize') {
53 53
     // Is API enabled in Teampass settings
54 54
     if ($apiStatus['error'] === false) {
55
-        require API_ROOT_PATH . "/Controller/Api/AuthController.php";
55
+        require API_ROOT_PATH."/Controller/Api/AuthController.php";
56 56
         $objFeedController = new AuthController();
57
-        $strMethodName = $uri[0] . 'Action';
57
+        $strMethodName = $uri[0].'Action';
58 58
         $objFeedController->{$strMethodName}();
59 59
     } else {
60 60
         // Error management
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 
81 81
     // action related to USER
82 82
     } elseif ($controller === 'user') {
83
-        require API_ROOT_PATH . "/Controller/Api/UserController.php";
83
+        require API_ROOT_PATH."/Controller/Api/UserController.php";
84 84
         $objFeedController = new UserController();
85
-        $strMethodName = (string) $action . 'Action';
85
+        $strMethodName = (string) $action.'Action';
86 86
         $objFeedController->{$strMethodName}();
87 87
 
88 88
     // action related to ITEM
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
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 
161 161
                             // Show passwords inputs and form
162 162
                             $('#dialog-user-change-password-info')
163
-                                .html('<i class="icon fa-solid fa-info mr-2"></i><?php echo $lang->get('user_has_to_change_password_info');?>')
163
+                                .html('<i class="icon fa-solid fa-info mr-2"></i><?php echo $lang->get('user_has_to_change_password_info'); ?>')
164 164
                                 .removeClass('hidden');
165 165
                             $('#dialog-user-change-password').removeClass('hidden');
166 166
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 
174 174
                             // Show passwords inputs and form
175 175
                             $('#dialog-ldap-user-change-password-info')
176
-                                .html('<i class="icon fa-solid fa-info mr-2"></i><?php echo $lang->get('ldap_user_has_changed_his_password');?>')
176
+                                .html('<i class="icon fa-solid fa-info mr-2"></i><?php echo $lang->get('ldap_user_has_changed_his_password'); ?>')
177 177
                                 .removeClass('hidden');
178 178
                             $('#dialog-ldap-user-change-password').removeClass('hidden');
179 179
                             
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
         /*console.log('User has to regenerate keys')
301 301
         // HIde
302 302
         $('.content-header, .content').addClass('hidden');
303
-        $('#dialog-user-temporary-code-info').html('<i class="icon fa-solid fa-info mr-2"></i><?php echo $lang->get('renecyption_expected');?>');
303
+        $('#dialog-user-temporary-code-info').html('<i class="icon fa-solid fa-info mr-2"></i><?php echo $lang->get('renecyption_expected'); ?>');
304 304
 
305 305
         // Show passwords inputs and form
306 306
         $('#dialog-user-temporary-code').removeClass('hidden');
@@ -382,13 +382,13 @@  discard block
 block discarded – undo
382 382
             {
383 383
                 if (step === 'psk') {
384 384
                     // Inform user
385
-                    $("#user-current-defuse-psk-progress").html('<b><?php echo $lang->get('encryption_keys'); ?> </b> [' + start + ' - ' + (parseInt(start) + <?php echo NUMBER_ITEMS_IN_BATCH;?>) + '] ' +
385
+                    $("#user-current-defuse-psk-progress").html('<b><?php echo $lang->get('encryption_keys'); ?> </b> [' + start + ' - ' + (parseInt(start) + <?php echo NUMBER_ITEMS_IN_BATCH; ?>) + '] ' +
386 386
                         '... <?php echo $lang->get('please_wait'); ?><i class="fa-solid fa-spinner fa-pulse ml-3 text-primary"></i>');
387 387
 
388 388
                     var data = {
389 389
                         'userPsk' : $('#user-current-defuse-psk').val(),
390 390
                             'start': start,
391
-                            'length': <?php echo NUMBER_ITEMS_IN_BATCH;?>,
391
+                            'length': <?php echo NUMBER_ITEMS_IN_BATCH; ?>,
392 392
                             'user_id': userId,
393 393
                     };
394 394
                     // Do query
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 
466 466
                 // Show passwords inputs and form
467 467
                 $('#dialog-ldap-user-change-password-info')
468
-                    .html('<i class="icon fa-solid fa-info mr-2"></i><?php echo $lang->get('ldap_user_has_changed_his_password');?>')
468
+                    .html('<i class="icon fa-solid fa-info mr-2"></i><?php echo $lang->get('ldap_user_has_changed_his_password'); ?>')
469 469
                     .removeClass('hidden');
470 470
                 $('#dialog-ldap-user-change-password').removeClass('hidden');
471 471
 
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
                                 '</div>' +
555 555
                             '</div>' +
556 556
                         '</div>' +
557
-                        '<div class="row mt-2<?php echo isset($SETTINGS['enable_pf_feature']) === true && (int) $SETTINGS['enable_pf_feature'] === 1  ? '' : ' hidden'; ?>">' +
557
+                        '<div class="row mt-2<?php echo isset($SETTINGS['enable_pf_feature']) === true && (int) $SETTINGS['enable_pf_feature'] === 1 ? '' : ' hidden'; ?>">' +
558 558
                             '<h6><?php echo $lang->get('provide_recovery_keys'); ?></h6>' +
559 559
                             '<div class="input-group mb-2">' +
560 560
                                 '<div class="input-group-prepend">' +
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
                                 '<textarea rows="2" id="recovery-private-key" class="form-control form-item-control"></textarea>' +
570 570
                             '</div>' +
571 571
                         '</div>' +
572
-                        '<div class="row mt-2<?php echo isset($SETTINGS['enable_pf_feature']) === true && (int) $SETTINGS['enable_pf_feature'] === 1  ? '' : ' hidden'; ?>">' +
572
+                        '<div class="row mt-2<?php echo isset($SETTINGS['enable_pf_feature']) === true && (int) $SETTINGS['enable_pf_feature'] === 1 ? '' : ' hidden'; ?>">' +
573 573
                             '<div class="alert" id="confirm-no-recovery-keys-div">' +
574 574
                                 '<div class="form-check">' +
575 575
                                     '<input type="checkbox" class="form-check-input" id="confirm-no-recovery-keys">' +
@@ -1073,15 +1073,15 @@  discard block
 block discarded – undo
1073 1073
             // Prepare data
1074 1074
             var data = {
1075 1075
                 'receipt': $('#temp-user-email').val(),
1076
-                'subject': '[Teampass] <?php echo $lang->get('your_new_password');?>',
1077
-                'body': '<?php echo $lang->get('email_body_temporary_login_password');?>',
1076
+                'subject': '[Teampass] <?php echo $lang->get('your_new_password'); ?>',
1077
+                'body': '<?php echo $lang->get('email_body_temporary_login_password'); ?>',
1078 1078
                 'pre_replace' : {
1079 1079
                     '#enc_code#' : $('#temp-user-pwd').val(),
1080 1080
                 }
1081 1081
             }
1082 1082
             if (debugJavascript === true) console.log(data);
1083 1083
             // Prepare form
1084
-            $('#dialog-admin-change-user-password-info').html('<?php echo $lang->get('sending_email_message');?>');
1084
+            $('#dialog-admin-change-user-password-info').html('<?php echo $lang->get('sending_email_message'); ?>');
1085 1085
             toastr.remove();
1086 1086
             toastr.info(
1087 1087
                 '<?php echo $lang->get('in_progress'); ?><i class="fa-solid fa-circle-notch fa-spin fa-2x ml-3"></i>'
@@ -1593,7 +1593,7 @@  discard block
 block discarded – undo
1593 1593
                         '#warningModal',
1594 1594
                         '<i class="fa-solid fa-clock fa-lg warning mr-2"></i><?php echo $lang->get('index_add_one_hour'); ?>',
1595 1595
                         '<div class="form-group">' +
1596
-                        '<label for="warningModal-input" class="col-form-label"><?php echo $lang->get('extend_session_duration_by') . ' (' . $lang->get('minutes') . ')'; ?>:</label>' +
1596
+                        '<label for="warningModal-input" class="col-form-label"><?php echo $lang->get('extend_session_duration_by').' ('.$lang->get('minutes').')'; ?>:</label>' +
1597 1597
                         '<input type="number" max="'+(60*60*24)+'" class="form-control" id="warningModal-input" value="60">' +
1598 1598
                         '</div>' +
1599 1599
                         '<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.
scripts/background_tasks___user_keys_creation.php 1 patch
Spacing   +43 added lines, -44 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 DB::debugmode(false);
77 77
 $process_to_perform = DB::queryfirstrow(
78 78
     'SELECT *
79
-    FROM ' . prefixTable('processes') . '
79
+    FROM ' . prefixTable('processes').'
80 80
     WHERE is_in_progress = %i AND process_type = %s
81 81
     ORDER BY increment_id ASC',
82 82
     1,
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     // search for next process to handle
97 97
     $process_to_perform = DB::queryfirstrow(
98 98
         'SELECT *
99
-        FROM ' . prefixTable('processes') . '
99
+        FROM ' . prefixTable('processes').'
100 100
         WHERE is_in_progress = %i AND finished_at = "" AND process_type = %s
101 101
         ORDER BY increment_id ASC',
102 102
         0,
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
             $process_to_perform['increment_id']
115 115
         );
116 116
 
117
-        provideLog('[PROCESS][#'. $process_to_perform['increment_id'].'][START]', $SETTINGS);
117
+        provideLog('[PROCESS][#'.$process_to_perform['increment_id'].'][START]', $SETTINGS);
118 118
         handleTask(
119 119
             $process_to_perform['increment_id'],
120 120
             json_decode($process_to_perform['arguments'], true),
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 // launch a new iterative process
130 130
 $process_to_perform = DB::queryfirstrow(
131 131
     'SELECT *
132
-    FROM ' . prefixTable('processes') . '
132
+    FROM ' . prefixTable('processes').'
133 133
     WHERE is_in_progress = %i AND process_type = %s
134 134
     ORDER BY increment_id ASC',
135 135
     1,
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
  */
154 154
 function handleTask(int $processId, array $ProcessArguments, array $SETTINGS): bool
155 155
 {
156
-    provideLog('[PROCESS][#'. $processId.'][START]', $SETTINGS);
156
+    provideLog('[PROCESS][#'.$processId.'][START]', $SETTINGS);
157 157
     //DB::debugmode(false);
158 158
     $task_to_perform = DB::queryfirstrow(
159 159
         'SELECT *
160
-        FROM ' . prefixTable('processes_tasks') . '
160
+        FROM ' . prefixTable('processes_tasks').'
161 161
         WHERE process_id = %i AND finished_at IS NULL
162 162
         ORDER BY increment_id ASC',
163 163
         $processId
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
         // check if a linux process is not currently on going
173 173
         // if sub_task_in_progress === 1 then exit
174 174
         if ((int) $task_to_perform['sub_task_in_progress'] === 0) {
175
-            provideLog('[TASK][#'. $task_to_perform['increment_id'].'][START]', $SETTINGS);
175
+            provideLog('[TASK][#'.$task_to_perform['increment_id'].'][START]', $SETTINGS);
176 176
 
177 177
             // handle next task
178 178
             $args = json_decode($task_to_perform['task'], true);
@@ -225,10 +225,9 @@  discard block
 block discarded – undo
225 225
             DB::update(
226 226
                 prefixTable('processes_tasks'),
227 227
                 array(
228
-                    'sub_task_in_progress' => 0,    // flag sub task is no more in prgoress
228
+                    'sub_task_in_progress' => 0, // flag sub task is no more in prgoress
229 229
                     'task' => $taskStatus['new_action'] !== $args['step'] ? 
230
-                    json_encode(["status" => "Done"]) :
231
-                    json_encode([
230
+                    json_encode(["status" => "Done"]) : json_encode([
232 231
                         "step" => $taskStatus['new_action'],
233 232
                         "index" => $taskStatus['new_index'],
234 233
                         "nb" => isset($SETTINGS['maximum_number_of_items_to_treat']) === true ? $SETTINGS['maximum_number_of_items_to_treat'] : $args['nb'],
@@ -264,7 +263,7 @@  discard block
 block discarded – undo
264 263
 
265 264
         } else {
266 265
             // Task is currently being in progress by another server process
267
-            provideLog('[TASK][#'. $task_to_perform['increment_id'].'][WARNING] Similar task already being processes', $SETTINGS);
266
+            provideLog('[TASK][#'.$task_to_perform['increment_id'].'][WARNING] Similar task already being processes', $SETTINGS);
268 267
             return false;
269 268
         }
270 269
     }
@@ -297,7 +296,7 @@  discard block
 block discarded – undo
297 296
         // Check if user exists
298 297
         $userInfo = DB::queryFirstRow(
299 298
             'SELECT public_key, private_key
300
-            FROM ' . prefixTable('users') . '
299
+            FROM ' . prefixTable('users').'
301 300
             WHERE id = %i',
302 301
             $post_user_id
303 302
         );
@@ -426,13 +425,13 @@  discard block
 block discarded – undo
426 425
 {
427 426
     $userInfo = DB::queryFirstRow(
428 427
         'SELECT pw, public_key, private_key, login, name
429
-        FROM ' . prefixTable('users') . '
428
+        FROM ' . prefixTable('users').'
430 429
         WHERE id = %i',
431 430
         $owner_id
432 431
     );
433 432
     
434 433
     // decrypt owner password
435
-    $pwd = cryption($owner_pwd, '','decrypt', $SETTINGS)['string'];
434
+    $pwd = cryption($owner_pwd, '', 'decrypt', $SETTINGS)['string'];
436 435
     provideLog('[USER][INFO] ID:'.$owner_id, $SETTINGS);
437 436
     //provideLog('[DEBUG] '.$pwd." -- ", $SETTINGS);
438 437
     // decrypt private key and send back
@@ -471,17 +470,17 @@  discard block
 block discarded – undo
471 470
     // Loop on items
472 471
     $rows = DB::query(
473 472
         'SELECT id, pw, perso
474
-        FROM ' . prefixTable('items') . '
473
+        FROM ' . prefixTable('items').'
475 474
         '.(isset($extra_arguments['only_personal_items']) === true && $extra_arguments['only_personal_items'] === 1 ? 'WHERE perso = 1' : '').'
476 475
         ORDER BY id ASC
477
-        LIMIT ' . $post_start . ', ' . $post_length
476
+        LIMIT ' . $post_start.', '.$post_length
478 477
     );
479 478
     //    WHERE perso = 0
480 479
     foreach ($rows as $record) {
481 480
         // Get itemKey from current user
482 481
         $currentUserKey = DB::queryFirstRow(
483 482
             'SELECT share_key, increment_id
484
-            FROM ' . prefixTable('sharekeys_items') . '
483
+            FROM ' . prefixTable('sharekeys_items').'
485 484
             WHERE object_id = %i AND user_id = %i',
486 485
             $record['id'],
487 486
             //$extra_arguments['owner_id']
@@ -510,7 +509,7 @@  discard block
 block discarded – undo
510 509
         
511 510
         $currentUserKey = DB::queryFirstRow(
512 511
             'SELECT increment_id
513
-            FROM ' . prefixTable('sharekeys_items') . '
512
+            FROM ' . prefixTable('sharekeys_items').'
514 513
             WHERE object_id = %i AND user_id = %i',
515 514
             $record['id'],
516 515
             $post_user_id
@@ -581,15 +580,15 @@  discard block
 block discarded – undo
581 580
     // Loop on logs
582 581
     $rows = DB::query(
583 582
         'SELECT increment_id
584
-        FROM ' . prefixTable('log_items') . '
583
+        FROM ' . prefixTable('log_items').'
585 584
         WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"
586
-        LIMIT ' . $post_start . ', ' . $post_length
585
+        LIMIT ' . $post_start.', '.$post_length
587 586
     );
588 587
     foreach ($rows as $record) {
589 588
         // Get itemKey from current user
590 589
         $currentUserKey = DB::queryFirstRow(
591 590
             'SELECT share_key
592
-            FROM ' . prefixTable('sharekeys_logs') . '
591
+            FROM ' . prefixTable('sharekeys_logs').'
593 592
             WHERE object_id = %i AND user_id = %i',
594 593
             $record['increment_id'],
595 594
             $extra_arguments['owner_id']
@@ -621,7 +620,7 @@  discard block
 block discarded – undo
621 620
             if ((int) $post_user_id !== (int) $extra_arguments['owner_id']) {
622 621
                 $currentUserKey = DB::queryFirstRow(
623 622
                     'SELECT increment_id
624
-                    FROM ' . prefixTable('sharekeys_items') . '
623
+                    FROM ' . prefixTable('sharekeys_items').'
625 624
                     WHERE object_id = %i AND user_id = %i',
626 625
                     $record['id'],
627 626
                     $post_user_id
@@ -643,7 +642,7 @@  discard block
 block discarded – undo
643 642
     // SHould we change step?
644 643
     DB::query(
645 644
         'SELECT increment_id
646
-        FROM ' . prefixTable('log_items') . '
645
+        FROM ' . prefixTable('log_items').'
647 646
         WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"'
648 647
     );
649 648
 
@@ -683,15 +682,15 @@  discard block
 block discarded – undo
683 682
     // Loop on fields
684 683
     $rows = DB::query(
685 684
         'SELECT id
686
-        FROM ' . prefixTable('categories_items') . '
685
+        FROM ' . prefixTable('categories_items').'
687 686
         WHERE encryption_type = "teampass_aes"
688
-        LIMIT ' . $post_start . ', ' . $post_length
687
+        LIMIT ' . $post_start.', '.$post_length
689 688
     );
690 689
     foreach ($rows as $record) {
691 690
         // Get itemKey from current user
692 691
         $currentUserKey = DB::queryFirstRow(
693 692
             'SELECT share_key
694
-            FROM ' . prefixTable('sharekeys_fields') . '
693
+            FROM ' . prefixTable('sharekeys_fields').'
695 694
             WHERE object_id = %i AND user_id = %i',
696 695
             $record['id'],
697 696
             $extra_arguments['owner_id']
@@ -719,7 +718,7 @@  discard block
 block discarded – undo
719 718
                 if ((int) $post_user_id !== (int) $extra_arguments['owner_id']) {
720 719
                     $currentUserKey = DB::queryFirstRow(
721 720
                         'SELECT increment_id
722
-                        FROM ' . prefixTable('sharekeys_items') . '
721
+                        FROM ' . prefixTable('sharekeys_items').'
723 722
                         WHERE object_id = %i AND user_id = %i',
724 723
                         $record['id'],
725 724
                         $post_user_id
@@ -742,7 +741,7 @@  discard block
 block discarded – undo
742 741
     // SHould we change step?
743 742
     DB::query(
744 743
         'SELECT *
745
-        FROM ' . prefixTable('categories_items') . '
744
+        FROM ' . prefixTable('categories_items').'
746 745
         WHERE encryption_type = "teampass_aes"'
747 746
     );
748 747
 
@@ -782,14 +781,14 @@  discard block
 block discarded – undo
782 781
     // Loop on suggestions
783 782
     $rows = DB::query(
784 783
         'SELECT id
785
-        FROM ' . prefixTable('suggestion') . '
786
-        LIMIT ' . $post_start . ', ' . $post_length
784
+        FROM ' . prefixTable('suggestion').'
785
+        LIMIT ' . $post_start.', '.$post_length
787 786
     );
788 787
     foreach ($rows as $record) {
789 788
         // Get itemKey from current user
790 789
         $currentUserKey = DB::queryFirstRow(
791 790
             'SELECT share_key
792
-            FROM ' . prefixTable('sharekeys_suggestions') . '
791
+            FROM ' . prefixTable('sharekeys_suggestions').'
793 792
             WHERE object_id = %i AND user_id = %i',
794 793
             $record['id'],
795 794
             $extra_arguments['owner_id']
@@ -821,7 +820,7 @@  discard block
 block discarded – undo
821 820
             if ((int) $post_user_id !== (int) $extra_arguments['owner_id']) {
822 821
                 $currentUserKey = DB::queryFirstRow(
823 822
                     'SELECT increment_id
824
-                    FROM ' . prefixTable('sharekeys_items') . '
823
+                    FROM ' . prefixTable('sharekeys_items').'
825 824
                     WHERE object_id = %i AND user_id = %i',
826 825
                     $record['id'],
827 826
                     $post_user_id
@@ -881,16 +880,16 @@  discard block
 block discarded – undo
881 880
     // Loop on files
882 881
     $rows = DB::query(
883 882
         'SELECT f.id AS id, i.perso AS perso
884
-        FROM ' . prefixTable('files') . ' AS f
885
-        INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = f.id_item
886
-        WHERE f.status = "' . TP_ENCRYPTION_NAME . '"
887
-        LIMIT ' . $post_start . ', ' . $post_length
883
+        FROM ' . prefixTable('files').' AS f
884
+        INNER JOIN ' . prefixTable('items').' AS i ON i.id = f.id_item
885
+        WHERE f.status = "' . TP_ENCRYPTION_NAME.'"
886
+        LIMIT ' . $post_start.', '.$post_length
888 887
     ); //aes_encryption
889 888
     foreach ($rows as $record) {
890 889
         // Get itemKey from current user
891 890
         $currentUserKey = DB::queryFirstRow(
892 891
             'SELECT share_key, increment_id
893
-            FROM ' . prefixTable('sharekeys_files') . '
892
+            FROM ' . prefixTable('sharekeys_files').'
894 893
             WHERE object_id = %i AND user_id = %i',
895 894
             $record['id'],
896 895
             (int) $record['perso'] === 0 ? $extra_arguments['owner_id'] : $extra_arguments['new_user_id']
@@ -918,7 +917,7 @@  discard block
 block discarded – undo
918 917
 
919 918
         $currentUserKey = DB::queryFirstRow(
920 919
             'SELECT increment_id
921
-            FROM ' . prefixTable('sharekeys_files') . '
920
+            FROM ' . prefixTable('sharekeys_files').'
922 921
             WHERE object_id = %i AND user_id = %i',
923 922
             $record['id'],
924 923
             $post_user_id
@@ -980,8 +979,8 @@  discard block
 block discarded – undo
980 979
     // SHould we change step? Finished ?
981 980
     DB::query(
982 981
         'SELECT *
983
-        FROM ' . prefixTable('files') . '
984
-        WHERE status = "' . TP_ENCRYPTION_NAME . '"'
982
+        FROM ' . prefixTable('files').'
983
+        WHERE status = "' . TP_ENCRYPTION_NAME.'"'
985 984
     );
986 985
     $counter = DB::count();
987 986
     $next_start = (int) $post_start + (int) $post_length;
@@ -1045,7 +1044,7 @@  discard block
 block discarded – undo
1045 1044
     // get user info
1046 1045
     $userInfo = DB::queryFirstRow(
1047 1046
         'SELECT email, login, auth_type, special, lastname, name
1048
-        FROM ' . prefixTable('users') . '
1047
+        FROM ' . prefixTable('users').'
1049 1048
         WHERE id = %i',
1050 1049
         $extra_arguments['new_user_id']
1051 1050
     );
@@ -1059,13 +1058,13 @@  discard block
 block discarded – undo
1059 1058
         sendMailToUser(
1060 1059
             filter_var($userInfo['email'], FILTER_SANITIZE_FULL_SPECIAL_CHARS),
1061 1060
             empty($extra_arguments['email_body']) === false ? $extra_arguments['email_body'] : $lang->get('email_body_user_config_1'),
1062
-            'TEAMPASS - ' . $lang->get('login_credentials'),
1061
+            'TEAMPASS - '.$lang->get('login_credentials'),
1063 1062
             (array) filter_var_array(
1064 1063
                 [
1065
-                    '#code#' => cryption($extra_arguments['new_user_code'], '','decrypt', $SETTINGS)['string'],
1064
+                    '#code#' => cryption($extra_arguments['new_user_code'], '', 'decrypt', $SETTINGS)['string'],
1066 1065
                     '#lastname#' => isset($userInfo['name']) === true ? $userInfo['name'] : '',
1067 1066
                     '#login#' => isset($userInfo['login']) === true ? $userInfo['login'] : '',
1068
-                    '#password#' => cryption($extra_arguments['new_user_pwd'], '','decrypt', $SETTINGS)['string'],
1067
+                    '#password#' => cryption($extra_arguments['new_user_pwd'], '', 'decrypt', $SETTINGS)['string'],
1069 1068
                 ],
1070 1069
                 FILTER_SANITIZE_FULL_SPECIAL_CHARS
1071 1070
             ),
Please login to merge, or discard this patch.
api/Model/Database.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         try {
32 32
             $this->connection = new \mysqli(DB_HOST, DB_USER, DB_PASSWD_CLEAR, DB_NAME);
33 33
 
34
-            if ( mysqli_connect_errno()) {
34
+            if (mysqli_connect_errno()) {
35 35
                 throw new Exception("Could not connect to database.");   
36 36
             }
37 37
         } catch (Exception $e) {
@@ -39,37 +39,37 @@  discard block
 block discarded – undo
39 39
         }           
40 40
     }
41 41
 
42
-    public function select($query = "" , $params = [])
42
+    public function select($query = "", $params = [])
43 43
     {
44 44
         try {
45
-            $stmt = $this->executeStatement( $query , $params );
45
+            $stmt = $this->executeStatement($query, $params);
46 46
             $result = $stmt->get_result()->fetch_all(MYSQLI_ASSOC);               
47 47
             $stmt->close();
48 48
 
49 49
             return $result;
50
-        } catch(Exception $e) {
51
-            throw New Exception( $e->getMessage() );
50
+        } catch (Exception $e) {
51
+            throw New Exception($e->getMessage());
52 52
         }
53 53
     }
54 54
 
55
-    private function executeStatement($query = "" , $params = [])
55
+    private function executeStatement($query = "", $params = [])
56 56
     {
57 57
         try {
58
-            $stmt = $this->connection->prepare( $query );
58
+            $stmt = $this->connection->prepare($query);
59 59
 
60
-            if($stmt === false) {
61
-                throw New Exception("Unable to do prepared statement: " . $query);
60
+            if ($stmt === false) {
61
+                throw New Exception("Unable to do prepared statement: ".$query);
62 62
             }
63 63
 
64
-            if( $params ) {
64
+            if ($params) {
65 65
                 $stmt->bind_param($params[0], $params[1]);
66 66
             }
67 67
 
68 68
             $stmt->execute();
69 69
 
70 70
             return $stmt;
71
-        } catch(Exception $e) {
72
-            throw New Exception( $e->getMessage() );
71
+        } catch (Exception $e) {
72
+            throw New Exception($e->getMessage());
73 73
         }   
74 74
     }
75 75
 }
76 76
\ No newline at end of file
Please login to merge, or discard this patch.
api/inc/bootstrap.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -26,22 +26,22 @@  discard block
 block discarded – undo
26 26
 
27 27
 use TeampassClasses\SuperGlobal\SuperGlobal;
28 28
 
29
-define("API_ROOT_PATH", __DIR__ . "/..");
29
+define("API_ROOT_PATH", __DIR__."/..");
30 30
 
31 31
 // include main configuration file
32
-require API_ROOT_PATH . '/../sources/main.functions.php';
32
+require API_ROOT_PATH.'/../sources/main.functions.php';
33 33
 
34 34
 // init
35 35
 loadClasses('DB');
36 36
 $superGlobal = new SuperGlobal();
37 37
 
38 38
 // include the base controller file
39
-require API_ROOT_PATH . "/Controller/Api/BaseController.php";
39
+require API_ROOT_PATH."/Controller/Api/BaseController.php";
40 40
 
41 41
 // include the use model file
42
-require API_ROOT_PATH . "/Model/UserModel.php";
43
-require API_ROOT_PATH . "/Model/ItemModel.php";
44
-require API_ROOT_PATH . "/Model/FolderModel.php";
42
+require API_ROOT_PATH."/Model/UserModel.php";
43
+require API_ROOT_PATH."/Model/ItemModel.php";
44
+require API_ROOT_PATH."/Model/FolderModel.php";
45 45
 
46 46
 /**
47 47
  * Launch expected action for ITEM
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
  */
53 53
 function itemAction(array $actions, array $userData)
54 54
 {
55
-    require API_ROOT_PATH . "/Controller/Api/ItemController.php";
55
+    require API_ROOT_PATH."/Controller/Api/ItemController.php";
56 56
     
57 57
     $objFeedController = new ItemController();
58
-    $strMethodName = $actions[0] . 'Action';
58
+    $strMethodName = $actions[0].'Action';
59 59
     $objFeedController->{$strMethodName}($userData);
60 60
 }
61 61
 
@@ -68,10 +68,10 @@  discard block
 block discarded – undo
68 68
  */
69 69
 function folderAction(array $actions, array $userData)
70 70
 {
71
-    require API_ROOT_PATH . "/Controller/Api/FolderController.php";
71
+    require API_ROOT_PATH."/Controller/Api/FolderController.php";
72 72
 
73 73
     $objFeedController = new FolderController();
74
-    $strMethodName = $actions[0] . 'Action';
74
+    $strMethodName = $actions[0].'Action';
75 75
     $objFeedController->{$strMethodName}($userData);
76 76
 }
77 77
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
  */
83 83
 function apiIsEnabled(): string
84 84
 {
85
-    include API_ROOT_PATH . '/../includes/config/tp.config.php';
85
+    include API_ROOT_PATH.'/../includes/config/tp.config.php';
86 86
 
87 87
     if (isset($SETTINGS) === true && isset($SETTINGS['api']) === true && (int) $SETTINGS['api'] === 1) {
88 88
         return json_encode(
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
  */
112 112
 function verifyAuth(): string
113 113
 {
114
-    include_once API_ROOT_PATH . '/inc/jwt_utils.php';
114
+    include_once API_ROOT_PATH.'/inc/jwt_utils.php';
115 115
     $bearer_token = get_bearer_token();
116 116
 
117 117
     if (empty($bearer_token) === false && is_jwt_valid($bearer_token) === true) {
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
  */
142 142
 function getDataFromToken(): string
143 143
 {
144
-    include_once API_ROOT_PATH . '/inc/jwt_utils.php';
144
+    include_once API_ROOT_PATH.'/inc/jwt_utils.php';
145 145
     $bearer_token = get_bearer_token();
146 146
 
147 147
     if (empty($bearer_token) === false) {
Please login to merge, or discard this patch.