Passed
Pull Request — master (#4948)
by Nils
07:11
created
scripts/background_tasks___worker.php 2 patches
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -64,7 +64,9 @@  discard block
 block discarded – undo
64 64
      */
65 65
     public function execute() {
66 66
         try {
67
-            if (LOG_TASKS=== true) $this->logger->log('Processing task: ' . print_r($this->taskData, true), 'DEBUG');
67
+            if (LOG_TASKS=== true) {
68
+                $this->logger->log('Processing task: ' . print_r($this->taskData, true), 'DEBUG');
69
+            }
68 70
             // Dispatch selon le type de processus
69 71
             switch ($this->processType) {
70 72
                 case 'item_copy':
@@ -136,7 +138,9 @@  discard block
 block discarded – undo
136 138
             $arguments = '';
137 139
         }
138 140
 
139
-        if (LOG_TASKS=== true) $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG');
141
+        if (LOG_TASKS=== true) {
142
+            $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG');
143
+        }
140 144
 
141 145
         // Add 'arguments' only if not empty
142 146
         if (!empty($arguments)) {
@@ -150,7 +154,9 @@  discard block
 block discarded – undo
150 154
             'increment_id = %i',
151 155
             $this->taskId
152 156
         );
153
-        if (LOG_TASKS=== true) $this->logger->log('Finishing task: ' . $this->taskId, 'DEBUG');
157
+        if (LOG_TASKS=== true) {
158
+            $this->logger->log('Finishing task: ' . $this->taskId, 'DEBUG');
159
+        }
154 160
     }
155 161
 
156 162
     /**
@@ -185,7 +191,9 @@  discard block
 block discarded – undo
185 191
      * @return void
186 192
      */
187 193
     private function processSubTasks($arguments) {
188
-        if (LOG_TASKS=== true) $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG');
194
+        if (LOG_TASKS=== true) {
195
+            $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG');
196
+        }
189 197
         // Get all subtasks related to this task
190 198
         $subtasks = DB::query(
191 199
             'SELECT * FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC',
@@ -194,7 +202,9 @@  discard block
 block discarded – undo
194 202
     
195 203
         // Check if there are any subtasks to process
196 204
         if (empty($subtasks)) {
197
-            if (LOG_TASKS=== true) $this->logger->log('No subtask was found for task: ' . $this->taskId, 'DEBUG');
205
+            if (LOG_TASKS=== true) {
206
+                $this->logger->log('No subtask was found for task: ' . $this->taskId, 'DEBUG');
207
+            }
198 208
             return;
199 209
         }
200 210
     
@@ -204,7 +214,9 @@  discard block
 block discarded – undo
204 214
                 // Get the subtask data
205 215
                 $subtaskData = json_decode($subtask['task'], true);
206 216
 
207
-                if (LOG_TASKS=== true) $this->logger->log('Processing subtask: ' . $subtaskData['step'], 'DEBUG');
217
+                if (LOG_TASKS=== true) {
218
+                    $this->logger->log('Processing subtask: ' . $subtaskData['step'], 'DEBUG');
219
+                }
208 220
 
209 221
                 // Mark subtask as in progress
210 222
                 DB::update(
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 require_once __DIR__.'/traits/UserHandlerTrait.php';
34 34
 require_once __DIR__.'/traits/EmailTrait.php';
35 35
 require_once __DIR__.'/traits/MigrateUserHandlerTrait.php';
36
-require_once __DIR__ . '/taskLogger.php';
36
+require_once __DIR__.'/taskLogger.php';
37 37
 
38 38
 class TaskWorker {
39 39
     use ItemHandlerTrait;
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public function execute() {
68 68
         try {
69
-            if (LOG_TASKS=== true) $this->logger->log('Processing task: ' . print_r($this->taskData, true), 'DEBUG');
69
+            if (LOG_TASKS === true) $this->logger->log('Processing task: '.print_r($this->taskData, true), 'DEBUG');
70 70
             // Dispatch selon le type de processus
71 71
             switch ($this->processType) {
72 72
                 case 'item_copy':
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
             $arguments = '';
142 142
         }
143 143
 
144
-        if (LOG_TASKS=== true) $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG');
144
+        if (LOG_TASKS === true) $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG');
145 145
 
146 146
         // Add 'arguments' only if not empty
147 147
         if (!empty($arguments)) {
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
             'increment_id = %i',
156 156
             $this->taskId
157 157
         );
158
-        if (LOG_TASKS=== true) $this->logger->log('Finishing task: ' . $this->taskId, 'DEBUG');
158
+        if (LOG_TASKS === true) $this->logger->log('Finishing task: '.$this->taskId, 'DEBUG');
159 159
     }
160 160
 
161 161
     /**
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
             'increment_id = %i',
179 179
             $this->taskId
180 180
         );
181
-        $this->logger->log('Task failure: ' . $e->getMessage(), 'ERROR');
181
+        $this->logger->log('Task failure: '.$e->getMessage(), 'ERROR');
182 182
     }
183 183
 
184 184
     /**
@@ -190,16 +190,16 @@  discard block
 block discarded – undo
190 190
      * @return void
191 191
      */
192 192
     private function processSubTasks($arguments) {
193
-        if (LOG_TASKS=== true) $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG');
193
+        if (LOG_TASKS === true) $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG');
194 194
         // Get all subtasks related to this task
195 195
         $subtasks = DB::query(
196
-            'SELECT * FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC',
196
+            'SELECT * FROM '.prefixTable('background_subtasks').' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC',
197 197
             $this->taskId
198 198
         );
199 199
     
200 200
         // Check if there are any subtasks to process
201 201
         if (empty($subtasks)) {
202
-            if (LOG_TASKS=== true) $this->logger->log('No subtask was found for task: ' . $this->taskId, 'DEBUG');
202
+            if (LOG_TASKS === true) $this->logger->log('No subtask was found for task: '.$this->taskId, 'DEBUG');
203 203
             return;
204 204
         }
205 205
     
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
                 // Get the subtask data
210 210
                 $subtaskData = json_decode($subtask['task'], true);
211 211
 
212
-                if (LOG_TASKS=== true) $this->logger->log('Processing subtask: ' . $subtaskData['step'], 'DEBUG');
212
+                if (LOG_TASKS === true) $this->logger->log('Processing subtask: '.$subtaskData['step'], 'DEBUG');
213 213
 
214 214
                 // Mark subtask as in progress
215 215
                 DB::update(
@@ -261,13 +261,13 @@  discard block
 block discarded – undo
261 261
                     $subtask['increment_id']
262 262
                 );
263 263
         
264
-                $this->logger->log('processSubTasks : ' . $e->getMessage(), 'ERROR');
264
+                $this->logger->log('processSubTasks : '.$e->getMessage(), 'ERROR');
265 265
             }
266 266
         }
267 267
     
268 268
         // Are all subtasks completed?
269 269
         $remainingSubtasks = DB::queryFirstField(
270
-            'SELECT COUNT(*) FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0',
270
+            'SELECT COUNT(*) FROM '.prefixTable('background_subtasks').' WHERE task_id = %i AND is_in_progress = 0',
271 271
             $this->taskId
272 272
         );
273 273
     
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
     error_log("Usage: php background_tasks___worker.php <task_id> <process_type> [<task_data>]");
284 284
     exit(1);
285 285
 }
286
-$taskId = (int)$argv[1];
286
+$taskId = (int) $argv[1];
287 287
 $processType = $argv[2];
288 288
 $taskData = $argv[3] ?? null;
289 289
 if ($taskData) {
Please login to merge, or discard this patch.
sources/export.queries.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 ) {
79 79
     // Not allowed page
80 80
     $session->set('system-error_code', ERR_NOT_ALLOWED);
81
-    include $SETTINGS['cpassman_dir'] . '/error.php';
81
+    include $SETTINGS['cpassman_dir'].'/error.php';
82 82
     exit;
83 83
 }
84 84
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 $antiXss = new AntiXSS();
101 101
 
102 102
 // User's language loading
103
-require_once $SETTINGS['cpassman_dir'] . '/includes/language/' . $session->get('user-language') . '.php';
103
+require_once $SETTINGS['cpassman_dir'].'/includes/language/'.$session->get('user-language').'.php';
104 104
 
105 105
 // Prepare POST variables
106 106
 $id = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT);
@@ -151,9 +151,9 @@  discard block
 block discarded – undo
151 151
                         'SELECT i.id as id, i.id_tree as id_tree, i.restricted_to as restricted_to, i.perso as perso,
152 152
                             i.label as label, i.description as description, i.pw as pw, i.login as login, i.url as url,
153 153
                             i.email as email,l.date as date, i.pw_iv as pw_iv,n.renewal_period as renewal_period
154
-                        FROM ' . prefixTable('items') . ' as i
155
-                        INNER JOIN ' . prefixTable('nested_tree') . ' as n ON (i.id_tree = n.id)
156
-                        INNER JOIN ' . prefixTable('log_items') . ' as l ON (i.id = l.id_item)
154
+                        FROM ' . prefixTable('items').' as i
155
+                        INNER JOIN ' . prefixTable('nested_tree').' as n ON (i.id_tree = n.id)
156
+                        INNER JOIN ' . prefixTable('log_items').' as l ON (i.id = l.id_item)
157 157
                         WHERE i.inactif = %i
158 158
                         AND i.id_tree= %i
159 159
                         AND (l.action = %s OR (l.action = %s AND l.raison LIKE %s))
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
                                 // Run query
177 177
                                 $dataItem = DB::queryFirstRow(
178 178
                                     'SELECT i.pw AS pw, s.share_key AS share_key
179
-                                    FROM ' . prefixTable('items') . ' AS i
180
-                                    INNER JOIN ' . prefixTable('sharekeys_items') . ' AS s ON (s.object_id = i.id)
179
+                                    FROM ' . prefixTable('items').' AS i
180
+                                    INNER JOIN ' . prefixTable('sharekeys_items').' AS s ON (s.object_id = i.id)
181 181
                                     WHERE user_id = %i AND i.id = %i',
182 182
                                     $session->get('user-id'),
183 183
                                     $record['id']
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
                                 $arr_kbs = [];
202 202
                                 $rows_kb = DB::query(
203 203
                                     'SELECT b.label, b.id
204
-                                    FROM ' . prefixTable('kb_items') . ' AS a
205
-                                    INNER JOIN ' . prefixTable('kb') . ' AS b ON (a.kb_id = b.id)
204
+                                    FROM ' . prefixTable('kb_items').' AS a
205
+                                    INNER JOIN ' . prefixTable('kb').' AS b ON (a.kb_id = b.id)
206 206
                                     WHERE a.item_id = %i',
207 207
                                     $record['id']
208 208
                                 );
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
                                 $arr_tags = [];
215 215
                                 $rows_tag = DB::query(
216 216
                                     'SELECT tag
217
-                                    FROM ' . prefixTable('tags') . '
217
+                                    FROM ' . prefixTable('tags').'
218 218
                                     WHERE item_id = %i',
219 219
                                     $record['id']
220 220
                                 );
@@ -226,18 +226,18 @@  discard block
 block discarded – undo
226 226
                                 $arr_trees = [];
227 227
                                 $rows_child_tree = DB::query(
228 228
                                     'SELECT t.id, t.title
229
-                                    FROM ' . prefixTable('nested_tree') . ' AS t
230
-                                    INNER JOIN ' . prefixTable('items') . ' AS i ON (t.id = i.id_tree)
229
+                                    FROM ' . prefixTable('nested_tree').' AS t
230
+                                    INNER JOIN ' . prefixTable('items').' AS i ON (t.id = i.id_tree)
231 231
                                     WHERE i.id = %i',
232 232
                                     $record['id']
233 233
                                 );
234 234
                                 foreach ($rows_child_tree as $rec_child_tree) {
235 235
                                     $stack = array();
236 236
                                     $parent = $rec_child_tree['id'];
237
-                                    while($parent != 0){
237
+                                    while ($parent != 0) {
238 238
                                         $rows_parent_tree = DB::query(
239 239
                                             'SELECT parent_id, title
240
-                                            FROM ' . prefixTable('nested_tree') . '
240
+                                            FROM ' . prefixTable('nested_tree').'
241 241
                                             WHERE id = %i',
242 242
                                             $parent
243 243
                                         );
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
             // Prepare variables
325 325
             $post_export_tag = filter_var($dataReceived['export_tag'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
326 326
             if (empty($post_export_tag) === false) {
327
-                DB::query('DELETE FROM ' . prefixTable('export') . ' WHERE export_tag = %s', $post_export_tag);
327
+                DB::query('DELETE FROM '.prefixTable('export').' WHERE export_tag = %s', $post_export_tag);
328 328
             }
329 329
             break;
330 330
 
@@ -374,9 +374,9 @@  discard block
 block discarded – undo
374 374
                         l.date as date, i.pw_iv as pw_iv,
375 375
                         n.renewal_period as renewal_period,
376 376
                         i.id_tree as tree_id
377
-                        FROM ' . prefixTable('items') . ' as i
378
-                        INNER JOIN ' . prefixTable('nested_tree') . ' as n ON (i.id_tree = n.id)
379
-                        INNER JOIN ' . prefixTable('log_items') . ' as l ON (i.id = l.id_item)
377
+                        FROM ' . prefixTable('items').' as i
378
+                        INNER JOIN ' . prefixTable('nested_tree').' as n ON (i.id_tree = n.id)
379
+                        INNER JOIN ' . prefixTable('log_items').' as l ON (i.id = l.id_item)
380 380
                         WHERE i.inactif = %i
381 381
                         AND i.id_tree= %i
382 382
                         AND (l.action = %s OR (l.action = %s AND l.raison LIKE %s))
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
                             // Run query
403 403
                             $dataItem = DB::queryFirstRow(
404 404
                                 'SELECT i.pw AS pw, s.share_key AS share_key
405
-                                FROM ' . prefixTable('items') . ' AS i
406
-                                INNER JOIN ' . prefixTable('sharekeys_items') . ' AS s ON (s.object_id = i.id)
405
+                                FROM ' . prefixTable('items').' AS i
406
+                                INNER JOIN ' . prefixTable('sharekeys_items').' AS s ON (s.object_id = i.id)
407 407
                                 WHERE user_id = %i AND i.id = %i',
408 408
                                 $session->get('user-id'),
409 409
                                 $record['id']
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
                             $arr_kbs = '';
428 428
                             $rows_kb = DB::query(
429 429
                                 'SELECT b.label, b.id
430
-                                FROM ' . prefixTable('kb_items') . ' AS a
431
-                                INNER JOIN ' . prefixTable('kb') . ' AS b ON (a.kb_id = b.id)
430
+                                FROM ' . prefixTable('kb_items').' AS a
431
+                                INNER JOIN ' . prefixTable('kb').' AS b ON (a.kb_id = b.id)
432 432
                                 WHERE a.item_id = %i',
433 433
                                 $record['id']
434 434
                             );
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
                                 if (empty($arr_kbs)) {
437 437
                                     $arr_kbs = $rec_kb['label'];
438 438
                                 } else {
439
-                                    $arr_kbs .= ' | ' . $rec_kb['label'];
439
+                                    $arr_kbs .= ' | '.$rec_kb['label'];
440 440
                                 }
441 441
                             }
442 442
 
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
                             $arr_tags = '';
445 445
                             $rows_tag = DB::query(
446 446
                                 'SELECT tag
447
-                                FROM ' . prefixTable('tags') . '
447
+                                FROM ' . prefixTable('tags').'
448 448
                                 WHERE item_id = %i',
449 449
                                 $record['id']
450 450
                             );
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
                                 if (empty($arr_tags)) {
453 453
                                     $arr_tags = $rec_tag['tag'];
454 454
                                 } else {
455
-                                    $arr_tags .= ' ' . $rec_tag['tag'];
455
+                                    $arr_tags .= ' '.$rec_tag['tag'];
456 456
                                 }
457 457
                             }
458 458
 
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
             // query
531 531
             $rows = DB::query(
532 532
                 'SELECT * 
533
-                FROM ' . prefixTable('export') . ' 
533
+                FROM ' . prefixTable('export').' 
534 534
                 WHERE export_tag = %s',
535 535
                 $dataReceived['export_tag']
536 536
             );
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
                 $prev_path = '';
543 543
 
544 544
                 //Prepare the PDF file
545
-                require_once $SETTINGS['cpassman_dir'] . '/vendor/tecnickcom/tcpdf/tcpdf.php';
545
+                require_once $SETTINGS['cpassman_dir'].'/vendor/tecnickcom/tcpdf/tcpdf.php';
546 546
 
547 547
                 $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
548 548
                 $pdf->SetProtection(array('print'), $dataReceived['pdf_password'], null);
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 
555 555
                 // set default header data
556 556
                 $pdf->SetHeaderData(
557
-                    $SETTINGS['cpassman_dir'] . '/includes/images/teampass-logo2-home.png',
557
+                    $SETTINGS['cpassman_dir'].'/includes/images/teampass-logo2-home.png',
558 558
                     PDF_HEADER_LOGO_WIDTH,
559 559
                     'Teampass export',
560 560
                     $session->get('user-lastname')." ".$session->get('user-name').' @ '.date($SETTINGS['date_format']." ".$SETTINGS['time_format'], (int) time())
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
                 logEvents($SETTINGS, 'pdf_export', '', (string) $session->get('user-id'), $session->get('user-login'));
665 665
 
666 666
                 //clean table
667
-                DB::query('TRUNCATE TABLE ' . prefixTable('export'));
667
+                DB::query('TRUNCATE TABLE '.prefixTable('export'));
668 668
 
669 669
                 // Clean any content of the output buffer
670 670
                 ob_end_clean();
@@ -702,13 +702,13 @@  discard block
 block discarded – undo
702 702
             // step 1:
703 703
             // - prepare export file
704 704
             // - get full list of objects id to export
705
-            include $SETTINGS['cpassman_dir'] . '/includes/config/include.php';
705
+            include $SETTINGS['cpassman_dir'].'/includes/config/include.php';
706 706
             $idsList = array();
707 707
 
708 708
             // query
709 709
             $rows = DB::query(
710 710
                 'SELECT * 
711
-                FROM ' . prefixTable('export') . ' 
711
+                FROM ' . prefixTable('export').' 
712 712
                 WHERE export_tag = %s',
713 713
                 $inputData['export_tag']
714 714
             );
@@ -745,13 +745,13 @@  discard block
 block discarded – undo
745 745
             }
746 746
             // prepare export file
747 747
             //save the file
748
-            $outstream = fopen($SETTINGS['path_to_files_folder'] . (substr($SETTINGS['path_to_files_folder'] , -1) === '/' ? '' : '/') . $inputData['filename'], 'w');
748
+            $outstream = fopen($SETTINGS['path_to_files_folder'].(substr($SETTINGS['path_to_files_folder'], -1) === '/' ? '' : '/').$inputData['filename'], 'w');
749 749
             if ($outstream === false) {
750 750
                 echo (string) prepareExchangedData(
751 751
                     [
752 752
                         'error' => true,
753 753
                         'message' => $lang->get('error_while_creating_file'),
754
-                        'detail' => $SETTINGS['path_to_files_folder'] . $inputData['filename'],
754
+                        'detail' => $SETTINGS['path_to_files_folder'].$inputData['filename'],
755 755
                     ],
756 756
                     'encode'
757 757
                 );
@@ -777,12 +777,12 @@  discard block
 block discarded – undo
777 777
     </style>
778 778
     </head>
779 779
     <body>
780
-    <input type="hidden" id="generation_date" value="' . GibberishAES::enc(/** @scrutinizer ignore-type */ (string) time(), $inputData['password']) . '" />
780
+    <input type="hidden" id="generation_date" value="' . GibberishAES::enc(/** @scrutinizer ignore-type */ (string) time(), $inputData['password']).'" />
781 781
     <div id="header">
782
-    ' . TP_TOOL_NAME . ' - Off Line mode
782
+    ' . TP_TOOL_NAME.' - Off Line mode
783 783
     </div>
784 784
     <div style="margin:10px; font-size:9px;">
785
-    <i>This page was generated by <b>' . $session->get('user-name') . ' ' . $session->get('user-lastname') . '</b>, the ' . date('Y/m/d H:i:s') . '.</i>
785
+    <i>This page was generated by <b>' . $session->get('user-name').' '.$session->get('user-lastname').'</b>, the '.date('Y/m/d H:i:s').'.</i>
786 786
     <span id="info_page" style="margin-left:20px; font-weight:bold; font-size: 14px; color:red;"></span>
787 787
     </div>
788 788
     <div id="information"></div>
@@ -793,11 +793,11 @@  discard block
 block discarded – undo
793 793
     <div>
794 794
     <table id="itemsTable">
795 795
         <thead><tr>
796
-            <th style="width:15%;">' . $lang->get('label') . '</th>
797
-            <th style="width:10%;">' . $lang->get('pw') . '</th>
798
-            <th style="width:30%;">' . $lang->get('description') . '</th>
799
-            <th style="width:5%;">' . $lang->get('user_login') . '</th>
800
-            <th style="width:20%;">' . $lang->get('url') . '</th>
796
+            <th style="width:15%;">' . $lang->get('label').'</th>
797
+            <th style="width:10%;">' . $lang->get('pw').'</th>
798
+            <th style="width:30%;">' . $lang->get('description').'</th>
799
+            <th style="width:5%;">' . $lang->get('user_login').'</th>
800
+            <th style="width:20%;">' . $lang->get('url').'</th>
801 801
         </tr></thead>
802 802
         <tbody id="itemsTable_tbody">'
803 803
             );
@@ -811,8 +811,8 @@  discard block
 block discarded – undo
811 811
                     'loop' => true,
812 812
                     'ids_list' => json_encode($idsList),
813 813
                     'ids_count' => count($idsList),
814
-                    'file_path' => $SETTINGS['path_to_files_folder'] . (substr($SETTINGS['path_to_files_folder'] , -1) === '/' ? '' : '/') . $inputData['filename'],
815
-                    'file_link' => $SETTINGS['url_to_files_folder'] . (substr($SETTINGS['path_to_files_folder'] , -1) === '/' ? '' : '/') . $inputData['filename'],
814
+                    'file_path' => $SETTINGS['path_to_files_folder'].(substr($SETTINGS['path_to_files_folder'], -1) === '/' ? '' : '/').$inputData['filename'],
815
+                    'file_link' => $SETTINGS['url_to_files_folder'].(substr($SETTINGS['path_to_files_folder'], -1) === '/' ? '' : '/').$inputData['filename'],
816 816
                     'export_tag' => $inputData['export_tag'],
817 817
                 ],
818 818
                 'encode'
@@ -851,12 +851,12 @@  discard block
 block discarded – undo
851 851
             $full_listing = array();
852 852
             $items_id_list = array();
853 853
             $outstream = '';
854
-            include $SETTINGS['cpassman_dir'] . '/includes/config/include.php';
854
+            include $SETTINGS['cpassman_dir'].'/includes/config/include.php';
855 855
 
856 856
             // query
857 857
             $rows = DB::query(
858 858
                 'SELECT * 
859
-                FROM ' . prefixTable('export') . ' 
859
+                FROM ' . prefixTable('export').' 
860 860
                 WHERE export_tag = %s AND item_id IN %ls',
861 861
                 $inputData['export_tag'],
862 862
                 $inputData['idsList']
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
                         [
871 871
                             'error' => true,
872 872
                             'message' => $lang->get('error_while_creating_file'),
873
-                            'detail' => $SETTINGS['path_to_files_folder'] . $inputData['filename'],
873
+                            'detail' => $SETTINGS['path_to_files_folder'].$inputData['filename'],
874 874
                         ],
875 875
                         'encode'
876 876
                     );
@@ -903,13 +903,13 @@  discard block
 block discarded – undo
903 903
                         if (empty($arboHtml)) {
904 904
                             $arboHtml = $arboHtml_tmp;
905 905
                         } else {
906
-                            $arboHtml .= ' » ' . $arboHtml_tmp;
906
+                            $arboHtml .= ' » '.$arboHtml_tmp;
907 907
                         }
908 908
                     }
909 909
                     fputs(
910 910
                         $outstream,
911 911
                         '
912
-        <tr class="path"><td colspan="5">' . $arboHtml . '</td></tr>'
912
+        <tr class="path"><td colspan="5">' . $arboHtml.'</td></tr>'
913 913
                     );
914 914
                     $idTree = $record['folder_id'];
915 915
 
@@ -917,12 +917,12 @@  discard block
 block discarded – undo
917 917
                     fputs(
918 918
                         $outstream,
919 919
                         '
920
-        <tr class="' . $lineType . '">
921
-            <td>' . addslashes($record['label']) . '</td>
922
-            <td align="center"><span class="span_pw" id="span_' . $record['item_id'] . '"><a href="#" onclick="decryptme(' . $record['item_id'] . ', \'' . $encPw . '\');return false;">Decrypt </a></span><input type="hidden" id="hide_' . $record['item_id'] . '" value="' . $encPw . '" /></td>
923
-            <td>' . (empty($record['description']) === true ? '&nbsp;' : addslashes(str_replace(array(';', '<br />'), array('|', "\n\r"), stripslashes(mb_convert_encoding($record['description'], 'ISO-8859-1', 'UTF-8'))))) . '</td>
924
-            <td align="center">' . (empty($record['login']) === true ? '&nbsp;' : addslashes($record['login'])) . '</td>
925
-            <td align="center">' . (empty($record['url']) === true ? '&nbsp;' : addslashes($record['url'])) . '</td>
920
+        <tr class="' . $lineType.'">
921
+            <td>' . addslashes($record['label']).'</td>
922
+            <td align="center"><span class="span_pw" id="span_' . $record['item_id'].'"><a href="#" onclick="decryptme('.$record['item_id'].', \''.$encPw.'\');return false;">Decrypt </a></span><input type="hidden" id="hide_'.$record['item_id'].'" value="'.$encPw.'" /></td>
923
+            <td>' . (empty($record['description']) === true ? '&nbsp;' : addslashes(str_replace(array(';', '<br />'), array('|', "\n\r"), stripslashes(mb_convert_encoding($record['description'], 'ISO-8859-1', 'UTF-8'))))).'</td>
924
+            <td align="center">' . (empty($record['login']) === true ? '&nbsp;' : addslashes($record['login'])).'</td>
925
+            <td align="center">' . (empty($record['url']) === true ? '&nbsp;' : addslashes($record['url'])).'</td>
926 926
         </tr>'
927 927
                     );
928 928
                 }
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
             $inputData['password'] = (string) filter_var($dataReceived['password'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
972 972
             
973 973
             // Load includes
974
-            include $SETTINGS['cpassman_dir'] . '/includes/config/include.php';
974
+            include $SETTINGS['cpassman_dir'].'/includes/config/include.php';
975 975
 
976 976
             // read the content of the temporary file
977 977
             $handle = fopen($inputData['filename'].'.txt', 'r');
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
                     [
981 981
                         'error' => true,
982 982
                         'message' => $lang->get('error_while_creating_file'),
983
-                        'detail' => $SETTINGS['path_to_files_folder'] . $inputData['filename'],
983
+                        'detail' => $SETTINGS['path_to_files_folder'].$inputData['filename'],
984 984
                     ],
985 985
                     'encode'
986 986
                 );
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
                     [
993 993
                         'error' => true,
994 994
                         'message' => $lang->get('error_while_creating_file'),
995
-                        'detail' => $SETTINGS['path_to_files_folder'] . $inputData['filename'],
995
+                        'detail' => $SETTINGS['path_to_files_folder'].$inputData['filename'],
996 996
                     ],
997 997
                     'encode'
998 998
                 );
@@ -1008,9 +1008,9 @@  discard block
 block discarded – undo
1008 1008
             $chunks = explode('|#|#|', chunk_split($contents, 10000, '|#|#|'));
1009 1009
             foreach ($chunks as $chunk) {
1010 1010
                 if (empty($encrypted_text) === true) {
1011
-                    $encrypted_text = GibberishAES::enc(/** @scrutinizer ignore-type */ $chunk, $inputData['password'] );
1011
+                    $encrypted_text = GibberishAES::enc(/** @scrutinizer ignore-type */ $chunk, $inputData['password']);
1012 1012
                 } else {
1013
-                    $encrypted_text .= '|#|#|' . GibberishAES::enc(/** @scrutinizer ignore-type */ $chunk, $inputData['password'] );
1013
+                    $encrypted_text .= '|#|#|'.GibberishAES::enc(/** @scrutinizer ignore-type */ $chunk, $inputData['password']);
1014 1014
                 }
1015 1015
             }
1016 1016
 
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
                     [
1022 1022
                         'error' => true,
1023 1023
                         'message' => $lang->get('error_while_creating_file'),
1024
-                        'detail' => $SETTINGS['path_to_files_folder'] . $inputData['filename'],
1024
+                        'detail' => $SETTINGS['path_to_files_folder'].$inputData['filename'],
1025 1025
                     ],
1026 1026
                     'encode'
1027 1027
                 );
@@ -1034,9 +1034,9 @@  discard block
 block discarded – undo
1034 1034
         </table></div>
1035 1035
         <input type="button" value="Hide all" onclick="hideAll()" />
1036 1036
         <div id="footer" style="text-align:center;">
1037
-            <a href="https://teampass.net/about/" target="_blank">' . TP_TOOL_NAME . '&nbsp;' . TP_VERSION . '&nbsp;' . TP_COPYRIGHT . '</a>
1037
+            <a href="https://teampass.net/about/" target="_blank">' . TP_TOOL_NAME.'&nbsp;'.TP_VERSION.'&nbsp;'.TP_COPYRIGHT.'</a>
1038 1038
         </div>
1039
-        <div id="enc_html" style="display:none;">' . $encrypted_text . '</div>
1039
+        <div id="enc_html" style="display:none;">' . $encrypted_text.'</div>
1040 1040
         </body>
1041 1041
     </html>
1042 1042
     <script type="text/javascript">
@@ -1139,12 +1139,12 @@  discard block
 block discarded – undo
1139 1139
             fclose($outstream);
1140 1140
 
1141 1141
             //clean table
1142
-            DB::query('TRUNCATE TABLE ' . prefixTable('export'));
1142
+            DB::query('TRUNCATE TABLE '.prefixTable('export'));
1143 1143
 
1144 1144
             echo (string) prepareExchangedData(
1145 1145
                 [
1146 1146
                     'error' => false,
1147
-                    'filelink' => $inputData['file_link'] ,
1147
+                    'filelink' => $inputData['file_link'],
1148 1148
                 ],
1149 1149
                 'encode'
1150 1150
             );
Please login to merge, or discard this patch.
sources/downloadFile.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 ) {
77 77
     // Not allowed page
78 78
     $session->set('system-error_code', ERR_NOT_ALLOWED);
79
-    include $SETTINGS['cpassman_dir'] . '/error.php';
79
+    include $SETTINGS['cpassman_dir'].'/error.php';
80 80
     exit;
81 81
 }
82 82
 
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
     
135 135
     header('Content-Description: File Transfer');
136 136
     header('Content-Type: application/octet-stream');
137
-    header('Content-Disposition: attachment; filename="' . $safeFilename . '"');
137
+    header('Content-Disposition: attachment; filename="'.$safeFilename.'"');
138 138
     header('Cache-Control: must-revalidate, no-cache, no-store');
139 139
     header('Pragma: public');
140 140
     header('Expires: 0');
141 141
     
142 142
     if ($filesize !== null) {
143
-        header('Content-Length: ' . $filesize);
143
+        header('Content-Length: '.$filesize);
144 144
     }
145 145
 }
146 146
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
         return false;
153 153
     }
154 154
     
155
-    $filepath = $basePath . '/' . basename($filename);
155
+    $filepath = $basePath.'/'.basename($filename);
156 156
     
157 157
     // Security: Verify the resolved path is within the allowed directory
158 158
     $realBasePath = realpath($basePath);
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
     $file_info = DB::queryFirstRow(
231 231
         'SELECT f.id AS id, f.file AS file, f.name AS name, f.status AS status, f.extension AS extension,
232 232
         s.share_key AS share_key
233
-        FROM ' . prefixTable('files') . ' AS f
234
-        INNER JOIN ' . prefixTable('sharekeys_files') . ' AS s ON (f.id = s.object_id)
233
+        FROM ' . prefixTable('files').' AS f
234
+        INNER JOIN ' . prefixTable('sharekeys_files').' AS s ON (f.id = s.object_id)
235 235
         WHERE s.user_id = %i AND s.object_id = %i',
236 236
         $session->get('user-id'),
237 237
         $get_fileid
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
         // Get unencrypted file info
252 252
         $file_info = DB::queryFirstRow(
253 253
             'SELECT f.id AS id, f.file AS file, f.name AS name, f.status AS status, f.extension AS extension
254
-            FROM ' . prefixTable('files') . ' AS f
254
+            FROM ' . prefixTable('files').' AS f
255 255
             WHERE f.id = %i',
256 256
             $get_fileid
257 257
         );
@@ -263,13 +263,13 @@  discard block
 block discarded – undo
263 263
     
264 264
     // Prepare filename for download
265 265
     $filename = str_replace('b64:', '', $file_info['name']);
266
-    $filename = basename($filename, '.' . $file_info['extension']);
266
+    $filename = basename($filename, '.'.$file_info['extension']);
267 267
     $filename = isBase64($filename) === true ? base64_decode($filename) : $filename;
268
-    $filename = $filename . '.' . $file_info['extension'];
268
+    $filename = $filename.'.'.$file_info['extension'];
269 269
     
270 270
     // Determine file path
271
-    $candidatePath1 = $SETTINGS['path_to_upload_folder'] . '/' . TP_FILE_PREFIX . $file_info['file'];
272
-    $candidatePath2 = $SETTINGS['path_to_upload_folder'] . '/' . TP_FILE_PREFIX . base64_decode($file_info['file']);
271
+    $candidatePath1 = $SETTINGS['path_to_upload_folder'].'/'.TP_FILE_PREFIX.$file_info['file'];
272
+    $candidatePath2 = $SETTINGS['path_to_upload_folder'].'/'.TP_FILE_PREFIX.base64_decode($file_info['file']);
273 273
     
274 274
     $filePath = false;
275 275
     if (file_exists($candidatePath1)) {
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
     }
280 280
     
281 281
     if (WIP === true) {
282
-        error_log('downloadFile.php: filePath: ' . $filePath . " - ");
282
+        error_log('downloadFile.php: filePath: '.$filePath." - ");
283 283
     }
284 284
     
285 285
     // Validate file path and security
Please login to merge, or discard this patch.
sources/backups.queries.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 ) {
78 78
     // Not allowed page
79 79
     $session->set('system-error_code', ERR_NOT_ALLOWED);
80
-    include $SETTINGS['cpassman_dir'] . '/error.php';
80
+    include $SETTINGS['cpassman_dir'].'/error.php';
81 81
     exit;
82 82
 }
83 83
 
@@ -138,14 +138,14 @@  discard block
 block discarded – undo
138 138
             // Prepare variables
139 139
             $post_key = filter_var($dataReceived['encryptionKey'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
140 140
         
141
-            require_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
141
+            require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
142 142
         
143 143
             // get a token
144 144
             $token = GenerateCryptKey(20, false, true, true, false, true);
145 145
         
146 146
             //save file
147
-            $filename = time() . '-' . $token . '.sql';
148
-            $filepath = $SETTINGS['path_to_files_folder'] . '/' . $filename;
147
+            $filename = time().'-'.$token.'.sql';
148
+            $filepath = $SETTINGS['path_to_files_folder'].'/'.$filename;
149 149
             $handle = fopen($filepath, 'w+');
150 150
             
151 151
             if ($handle === false) {
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
             $tables = array();
164 164
             $result = DB::query('SHOW TABLES');
165 165
             foreach ($result as $row) {
166
-                $tables[] = $row['Tables_in_' . DB_NAME];
166
+                $tables[] = $row['Tables_in_'.DB_NAME];
167 167
             }
168 168
         
169 169
             $backupSuccess = true;
@@ -173,9 +173,9 @@  discard block
 block discarded – undo
173 173
                 if (empty($pre) || substr_count($table, $pre) > 0) {
174 174
                     $table = safeString($table);
175 175
                     // Write table drop and creation
176
-                    fwrite($handle, 'DROP TABLE IF EXISTS ' . $table . ";\n");
177
-                    $row2 = DB::queryFirstRow('SHOW CREATE TABLE ' . $table);
178
-                    fwrite($handle, safeString($row2['Create Table']) . ";\n\n");
176
+                    fwrite($handle, 'DROP TABLE IF EXISTS '.$table.";\n");
177
+                    $row2 = DB::queryFirstRow('SHOW CREATE TABLE '.$table);
178
+                    fwrite($handle, safeString($row2['Create Table']).";\n\n");
179 179
         
180 180
                     // Get field information
181 181
                     DB::query(
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
                         }
201 201
                         
202 202
                         foreach ($rows as $record) {
203
-                            $insertQuery = 'INSERT INTO ' . $table . ' VALUES(';
203
+                            $insertQuery = 'INSERT INTO '.$table.' VALUES(';
204 204
                             $values = array();
205 205
                             
206 206
                             foreach ($record as $value) {
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
                                 if ($value === null) {
209 209
                                     $values[] = 'NULL';
210 210
                                 } else {
211
-                                    $values[] = '"' . addslashes(preg_replace("/\n/", '\\n', $value)) . '"';
211
+                                    $values[] = '"'.addslashes(preg_replace("/\n/", '\\n', $value)).'"';
212 212
                                 }
213 213
                             }
214 214
                             
215
-                            $insertQuery .= implode(',', $values) . ");\n";
215
+                            $insertQuery .= implode(',', $values).");\n";
216 216
                             fwrite($handle, $insertQuery);
217 217
                             
218 218
                             // Flush buffer periodically to free memory
@@ -242,14 +242,14 @@  discard block
 block discarded – undo
242 242
                 prepareFileWithDefuse(
243 243
                     'encrypt',
244 244
                     $filepath,
245
-                    $SETTINGS['path_to_files_folder'] . '/defuse_temp_' . $filename,
245
+                    $SETTINGS['path_to_files_folder'].'/defuse_temp_'.$filename,
246 246
                     $post_key
247 247
                 );
248 248
         
249 249
                 // Do clean
250 250
                 unlink($filepath);
251 251
                 rename(
252
-                    $SETTINGS['path_to_files_folder'] . '/defuse_temp_' . $filename,
252
+                    $SETTINGS['path_to_files_folder'].'/defuse_temp_'.$filename,
253 253
                     $filepath
254 254
                 );
255 255
             }
@@ -271,9 +271,9 @@  discard block
 block discarded – undo
271 271
                 array(
272 272
                     'error' => false,
273 273
                     'message' => '',
274
-                    'download' => 'sources/downloadFile.php?name=' . urlencode($filename) .
275
-                        '&action=backup&file=' . $filename . '&type=sql&key=' . $session->get('key') . '&key_tmp=' .
276
-                        $session->get('user-key_tmp') . '&pathIsFiles=1',
274
+                    'download' => 'sources/downloadFile.php?name='.urlencode($filename).
275
+                        '&action=backup&file='.$filename.'&type=sql&key='.$session->get('key').'&key_tmp='.
276
+                        $session->get('user-key_tmp').'&pathIsFiles=1',
277 277
                 ),
278 278
                 'encode'
279 279
             );
@@ -334,13 +334,13 @@  discard block
 block discarded – undo
334 334
                 error_log('DEBUG: Offset -> '.$post_offset.'/'.$post_totalSize.' | File -> '.$post_clearFilename.' | key -> '.$post_key);
335 335
             }
336 336
         
337
-            include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
337
+            include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
338 338
         
339 339
             if (empty($post_clearFilename) === true) {
340 340
                 // Get filename from database
341 341
                 $data = DB::queryFirstRow(
342 342
                     'SELECT valeur
343
-                    FROM ' . prefixTable('misc') . '
343
+                    FROM ' . prefixTable('misc').'
344 344
                     WHERE increment_id = %i',
345 345
                     $post_backupFile
346 346
                 );
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
                 $post_backupFile = safeString($data['valeur']);
368 368
                 
369 369
                 // Verify file exists
370
-                if (!file_exists($SETTINGS['path_to_files_folder'] . '/' . $post_backupFile)) {
370
+                if (!file_exists($SETTINGS['path_to_files_folder'].'/'.$post_backupFile)) {
371 371
                     echo prepareExchangedData(
372 372
                         array(
373 373
                             'error' => true,
@@ -384,8 +384,8 @@  discard block
 block discarded – undo
384 384
                     // Decrypt the file
385 385
                     $ret = prepareFileWithDefuse(
386 386
                         'decrypt',
387
-                        $SETTINGS['path_to_files_folder'] . '/' . $post_backupFile,
388
-                        $SETTINGS['path_to_files_folder'] . '/defuse_temp_' . $post_backupFile,
387
+                        $SETTINGS['path_to_files_folder'].'/'.$post_backupFile,
388
+                        $SETTINGS['path_to_files_folder'].'/defuse_temp_'.$post_backupFile,
389 389
                         $post_key
390 390
                     );
391 391
                     
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
                     }
403 403
         
404 404
                     // Do clean
405
-                    fileDelete($SETTINGS['path_to_files_folder'] . '/' . $post_backupFile, $SETTINGS);
406
-                    $post_backupFile = $SETTINGS['path_to_files_folder'] . '/defuse_temp_' . $post_backupFile;
405
+                    fileDelete($SETTINGS['path_to_files_folder'].'/'.$post_backupFile, $SETTINGS);
406
+                    $post_backupFile = $SETTINGS['path_to_files_folder'].'/defuse_temp_'.$post_backupFile;
407 407
                 } else {
408 408
                     echo prepareExchangedData(
409 409
                         array(
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
                                 DB::query($query);
488 488
                                 $executedQueries++;
489 489
                             } catch (Exception $e) {
490
-                                $errors[] = "Error executing query: " . $e->getMessage() . " - Query: " . substr($query, 0, 100) . "...";
490
+                                $errors[] = "Error executing query: ".$e->getMessage()." - Query: ".substr($query, 0, 100)."...";
491 491
                             }
492 492
                             $query = '';
493 493
                         }
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
                 }
514 514
                 // Rollback transaction on any exception
515 515
                 DB::rollback();
516
-                $errors[] = "Transaction failed: " . $e->getMessage();
516
+                $errors[] = "Transaction failed: ".$e->getMessage();
517 517
             }
518 518
         
519 519
             // Calculate the new offset
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
                 echo prepareExchangedData(
529 529
                     array(
530 530
                         'error' => true,
531
-                        'message' => 'Errors occurred during import: ' . implode('; ', $errors),
531
+                        'message' => 'Errors occurred during import: '.implode('; ', $errors),
532 532
                         'newOffset' => $newOffset,
533 533
                         'totalSize' => $post_totalSize,
534 534
                         'clearFilename' => $post_backupFile,
Please login to merge, or discard this patch.
api/Controller/Api/ItemController.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
      */
41 41
     private function getUserPrivateKey(array $userData): ?string
42 42
     {
43
-        include_once API_ROOT_PATH . '/inc/jwt_utils.php';
43
+        include_once API_ROOT_PATH.'/inc/jwt_utils.php';
44 44
 
45 45
         // Verify session_key exists in JWT payload
46 46
         if (!isset($userData['session_key']) || empty($userData['session_key'])) {
47
-            error_log('getUserPrivateKey: Missing session_key in JWT token for user ID ' . $userData['id']);
47
+            error_log('getUserPrivateKey: Missing session_key in JWT token for user ID '.$userData['id']);
48 48
             return null;
49 49
         }
50 50
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
             // SQL where clause with folders list
89 89
             if (isset($arrQueryStringParams['folders']) === true) {
90 90
                 // convert the folders to an array
91
-                $arrQueryStringParams['folders'] = explode(',', str_replace( array('[',']') , ''  , $arrQueryStringParams['folders']));
91
+                $arrQueryStringParams['folders'] = explode(',', str_replace(array('[', ']'), '', $arrQueryStringParams['folders']));
92 92
 
93 93
                 // ensure to only use the intersection
94 94
                 $foldersList = implode(',', array_intersect($arrQueryStringParams['folders'], $userData['folders_list']));
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
                 } else {
257 257
                     // Gérer le cas où les paramètres ne sont pas un tableau
258 258
                     $strErrorDesc = 'Data not consistent';
259
-                    $strErrorHeader = 'Expected array, received ' . gettype($arrQueryStringParams);
259
+                    $strErrorHeader = 'Expected array, received '.gettype($arrQueryStringParams);
260 260
                 }
261 261
             }
262 262
         } else {
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
             // SQL where clause with item id
308 308
             if (isset($arrQueryStringParams['id']) === true) {
309 309
                 // build sql where clause by ID
310
-                $sqlExtra = ' WHERE i.id = '.$arrQueryStringParams['id'] . $sql_constraint;
310
+                $sqlExtra = ' WHERE i.id = '.$arrQueryStringParams['id'].$sql_constraint;
311 311
             } else if (isset($arrQueryStringParams['label']) === true) {
312 312
                 // build sql where clause by LABEL
313
-                $sqlExtra = ' WHERE i.label '.(isset($arrQueryStringParams['like']) === true && (int) $arrQueryStringParams['like'] === 1 ? ' LIKE '.$arrQueryStringParams['label'] : ' = '.$arrQueryStringParams['label']) . $sql_constraint;
313
+                $sqlExtra = ' WHERE i.label '.(isset($arrQueryStringParams['like']) === true && (int) $arrQueryStringParams['like'] === 1 ? ' LIKE '.$arrQueryStringParams['label'] : ' = '.$arrQueryStringParams['label']).$sql_constraint;
314 314
             } else if (isset($arrQueryStringParams['description']) === true) {
315 315
                 // build sql where clause by LABEL
316 316
                 $sqlExtra = ' WHERE i.description '.(isset($arrQueryStringParams['like']) === true && (int) $arrQueryStringParams['like'] === 1 ? ' LIKE '.$arrQueryStringParams['description'] : ' = '.$arrQueryStringParams['description']).$sql_constraint;
Please login to merge, or discard this patch.
api/Model/AuthModel.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -231,7 +231,7 @@
 block discarded – undo
231 231
         $configManager = new ConfigManager();
232 232
         $SETTINGS = $configManager->getAllSettings();
233 233
 
234
-		$payload = [
234
+        $payload = [
235 235
             'username' => $login,
236 236
             'id' => $id,
237 237
             'exp' => (time() + $SETTINGS['api_token_duration'] + 600),
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     public function getUserAuth(string $login, string $password, string $apikey): array
50 50
     {
51 51
         // Sanitize
52
-        include_once API_ROOT_PATH . '/../sources/main.functions.php';
52
+        include_once API_ROOT_PATH.'/../sources/main.functions.php';
53 53
         $inputData = dataSanitizer(
54 54
             [
55 55
                 'login' => isset($login) === true ? $login : '',
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
             // Check if user exists
75 75
             $userInfo = DB::queryfirstrow(
76 76
                 "SELECT u.id, u.pw, u.login, u.admin, u.gestionnaire, u.can_manage_all_users, u.fonction_id, u.can_create_root_folder, u.public_key, u.private_key, u.personal_folder, u.fonction_id, u.groupes_visibles, u.groupes_interdits, a.value AS user_api_key, a.allowed_folders as user_api_allowed_folders, a.enabled, a.allowed_to_create, a.allowed_to_read, a.allowed_to_update, a.allowed_to_delete
77
-                FROM " . prefixTable('users') . " AS u
78
-                INNER JOIN " . prefixTable('api') . " AS a ON (a.user_id=u.id)
77
+                FROM " . prefixTable('users')." AS u
78
+                INNER JOIN " . prefixTable('api')." AS a ON (a.user_id=u.id)
79 79
                 WHERE login = %s",
80 80
                 $inputData['login']
81 81
             );
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
                 // Encrypt the decrypted private key with the session key
120 120
                 // This allows us to store it securely in the database without exposing it
121
-                require_once API_ROOT_PATH . '/inc/encryption_utils.php';
121
+                require_once API_ROOT_PATH.'/inc/encryption_utils.php';
122 122
                 $encryptedPrivateKey = encrypt_with_session_key($privateKeyClear, $sessionKey);
123 123
 
124 124
                 if ($encryptedPrivateKey === false) {
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
         if (count($userFunctionId) > 0) {
286 286
             $rows = DB::query(
287 287
                 'SELECT * 
288
-                FROM ' . prefixTable('roles_values') . '
288
+                FROM ' . prefixTable('roles_values').'
289 289
                 WHERE role_id IN %li  AND type IN ("W", "ND", "NE", "NDNE", "R")',
290 290
                 $userFunctionId
291 291
             );
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
         $inc = 0;
312 312
         $rows = DB::query(
313 313
             'SELECT id, id_tree 
314
-            FROM ' . prefixTable('items') . '
314
+            FROM ' . prefixTable('items').'
315 315
             WHERE restricted_to LIKE %s'.
316 316
             (count($userFunctionId) > 0 ? ' AND id_tree NOT IN %li' : ''),
317 317
             $userInfo['id'],
@@ -326,8 +326,8 @@  discard block
 block discarded – undo
326 326
         // Check for the users roles if some specific rights exist on items
327 327
         $rows = DB::query(
328 328
             'SELECT i.id_tree, r.item_id
329
-            FROM ' . prefixTable('items') . ' AS i
330
-            INNER JOIN ' . prefixTable('restriction_to_roles') . ' AS r ON (r.item_id=i.id)
329
+            FROM ' . prefixTable('items').' AS i
330
+            INNER JOIN ' . prefixTable('restriction_to_roles').' AS r ON (r.item_id=i.id)
331 331
             WHERE '.(count($userFunctionId) > 0 ? ' id_tree NOT IN %li AND ' : '').' i.id_tree != ""
332 332
             ORDER BY i.id_tree ASC',
333 333
             count($userFunctionId) > 0 ? $userFunctionId : DB::sqleval('0')
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
         // Add all personal folders
344 344
         $rows = DB::queryFirstRow(
345 345
             'SELECT id 
346
-            FROM ' . prefixTable('nested_tree') . '
346
+            FROM ' . prefixTable('nested_tree').'
347 347
             WHERE title = %i AND personal_folder = 1'.
348 348
             (count($userFunctionId) > 0 ? ' AND id NOT IN %li' : ''),
349 349
             $userInfo['id'],
Please login to merge, or discard this patch.
api/inc/bootstrap.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -25,18 +25,18 @@  discard block
 block discarded – undo
25 25
 
26 26
 use TeampassClasses\ConfigManager\ConfigManager;
27 27
 
28
-define("API_ROOT_PATH", __DIR__ . "/..");
28
+define("API_ROOT_PATH", __DIR__."/..");
29 29
 
30 30
 // include main configuration file
31
-require API_ROOT_PATH . '/../sources/main.functions.php';
31
+require API_ROOT_PATH.'/../sources/main.functions.php';
32 32
 
33 33
 // include the base controller file
34
-require API_ROOT_PATH . "/Controller/Api/BaseController.php";
34
+require API_ROOT_PATH."/Controller/Api/BaseController.php";
35 35
 
36 36
 // include the use model file
37
-require API_ROOT_PATH . "/Model/UserModel.php";
38
-require API_ROOT_PATH . "/Model/ItemModel.php";
39
-require API_ROOT_PATH . "/Model/FolderModel.php";
37
+require API_ROOT_PATH."/Model/UserModel.php";
38
+require API_ROOT_PATH."/Model/ItemModel.php";
39
+require API_ROOT_PATH."/Model/FolderModel.php";
40 40
 
41 41
 /**
42 42
  * Launch expected action for ITEM
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
         return;
57 57
     }
58 58
     // Perform the action
59
-    require API_ROOT_PATH . "/Controller/Api/ItemController.php";    
59
+    require API_ROOT_PATH."/Controller/Api/ItemController.php";    
60 60
     $objFeedController = new ItemController();
61
-    $strMethodName = $actions[0] . 'Action';
61
+    $strMethodName = $actions[0].'Action';
62 62
     $objFeedController->{$strMethodName}($userData);
63 63
 }
64 64
 
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
         return;
81 81
     }
82 82
     // Perform the action
83
-    require API_ROOT_PATH . "/Controller/Api/FolderController.php";
83
+    require API_ROOT_PATH."/Controller/Api/FolderController.php";
84 84
     $objFeedController = new FolderController();
85
-    $strMethodName = $actions[0] . 'Action';
85
+    $strMethodName = $actions[0].'Action';
86 86
     $objFeedController->{$strMethodName}($userData);
87 87
 }
88 88
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
  */
140 140
 function verifyAuth(): string
141 141
 {
142
-    include_once API_ROOT_PATH . '/inc/jwt_utils.php';
142
+    include_once API_ROOT_PATH.'/inc/jwt_utils.php';
143 143
     $bearer_token = get_bearer_token();
144 144
 
145 145
     if (empty($bearer_token) === false && is_jwt_valid($bearer_token) === true) {
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
  */
170 170
 function getDataFromToken(): string
171 171
 {
172
-    include_once API_ROOT_PATH . '/inc/jwt_utils.php';
172
+    include_once API_ROOT_PATH.'/inc/jwt_utils.php';
173 173
     $bearer_token = get_bearer_token();
174 174
 
175 175
     if (empty($bearer_token) === false) {
Please login to merge, or discard this patch.
api/inc/encryption_utils.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 function encrypt_with_session_key(string $data, string $key)
48 48
 {
49 49
     if (strlen($key) !== 32) {
50
-        error_log('[API] encrypt_with_session_key: Invalid key length. Expected 32 bytes, got ' . strlen($key));
50
+        error_log('[API] encrypt_with_session_key: Invalid key length. Expected 32 bytes, got '.strlen($key));
51 51
         return false;
52 52
     }
53 53
 
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
 
75 75
         // Combine nonce + tag + ciphertext and encode in base64
76 76
         // Format: [12 bytes nonce][16 bytes tag][variable ciphertext]
77
-        return base64_encode($nonce . $tag . $ciphertext);
77
+        return base64_encode($nonce.$tag.$ciphertext);
78 78
 
79 79
     } catch (Exception $e) {
80
-        error_log('[API] encrypt_with_session_key: Exception - ' . $e->getMessage());
80
+        error_log('[API] encrypt_with_session_key: Exception - '.$e->getMessage());
81 81
         return false;
82 82
     }
83 83
 }
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 function decrypt_with_session_key(string $encryptedData, string $key)
96 96
 {
97 97
     if (strlen($key) !== 32) {
98
-        error_log('[API] decrypt_with_session_key: Invalid key length. Expected 32 bytes, got ' . strlen($key));
98
+        error_log('[API] decrypt_with_session_key: Invalid key length. Expected 32 bytes, got '.strlen($key));
99 99
         return false;
100 100
     }
101 101
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         return $plaintext;
137 137
 
138 138
     } catch (Exception $e) {
139
-        error_log('[API] decrypt_with_session_key: Exception - ' . $e->getMessage());
139
+        error_log('[API] decrypt_with_session_key: Exception - '.$e->getMessage());
140 140
         return false;
141 141
     }
142 142
 }
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.