Passed
Push — master ( e824e6...9b9d31 )
by Nils
05:57
created
pages/import.js.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('import') === false) {
73 73
     // Not allowed page
74 74
     $session->set('system-error_code', ERR_NOT_ALLOWED);
75
-    include $SETTINGS['cpassman_dir'] . '/error.php';
75
+    include $SETTINGS['cpassman_dir'].'/error.php';
76 76
     exit;
77 77
 }
78 78
 ?>
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
                     const errorMessages = JSON.parse(response.message);
512 512
                     let errorHtml = '<ul>';
513 513
                     errorMessages.forEach(function(error) {
514
-                        errorHtml += '<li><?php echo $lang->get('import_error_folder_creation');?> "<b>'+error.errorPath+'</b>": '+error.errorMessage+'</li>';
514
+                        errorHtml += '<li><?php echo $lang->get('import_error_folder_creation'); ?> "<b>'+error.errorPath+'</b>": '+error.errorMessage+'</li>';
515 515
                     });
516 516
 
517 517
                     $('#import-feedback-progress-text').html(
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
                                     // Isolate first item
998 998
                                     if (itemsList.length > 0) {
999 999
                                         $('#import-feedback-progress-text')
1000
-                                            .html('<i class="fa-solid fa-cog fa-spin ml-4 mr-2"></i><?php echo $lang->get('operation_progress');?> ('+((counter*100)/itemsNumber).toFixed(0)+'%)');
1000
+                                            .html('<i class="fa-solid fa-cog fa-spin ml-4 mr-2"></i><?php echo $lang->get('operation_progress'); ?> ('+((counter*100)/itemsNumber).toFixed(0)+'%)');
1001 1001
 
1002 1002
                                         data = {
1003 1003
                                             'edit-all': $('#import-keepass-edit-all-checkbox').prop('checked') === true ? 1 : 0,
Please login to merge, or discard this patch.
sources/expired.datatables.php 1 patch
Spacing   +20 added lines, -20 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
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 // Is a date sent?
102 102
 $dateCriteria = $request->query->get('dateCriteria');
103 103
 if ($dateCriteria !== null && !empty($dateCriteria)) {
104
-    $sWhere .= ' AND a.del_value < ' . round(filter_var($dateCriteria, FILTER_SANITIZE_NUMBER_INT) / 1000, 0);
104
+    $sWhere .= ' AND a.del_value < '.round(filter_var($dateCriteria, FILTER_SANITIZE_NUMBER_INT) / 1000, 0);
105 105
 }
106 106
 //echo $sWhere;
107 107
 /* BUILD QUERY */
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 $start = $request->query->getInt('start', 0);
111 111
 $length = $request->query->getInt('length', -1);
112 112
 if ($length !== -1) {
113
-    $sLimit = ' LIMIT ' . $start . ', ' . $length;
113
+    $sLimit = ' LIMIT '.$start.', '.$length;
114 114
 }
115 115
 
116 116
 //Ordering
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         $columnIndex = filter_var($order[0]['column'], FILTER_SANITIZE_NUMBER_INT);
124 124
 
125 125
         if (array_key_exists($columnIndex, $aColumns)) {
126
-            $sOrder .= $aColumns[$columnIndex] . ' ' . $order[0]['dir'];
126
+            $sOrder .= $aColumns[$columnIndex].' '.$order[0]['dir'];
127 127
         }
128 128
 
129 129
         // Supprimez la virgule finale si elle existe
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
 
148 148
     if ($letter !== '' && $letter !== 'None') {
149 149
         $sWhere .= ' AND ';
150
-        $sWhere .= $aColumns[1] . " LIKE '" . $letter . "%' OR ";
151
-        $sWhere .= $aColumns[2] . " LIKE '" . $letter . "%' OR ";
152
-        $sWhere .= $aColumns[3] . " LIKE '" . $letter . "%' ";
150
+        $sWhere .= $aColumns[1]." LIKE '".$letter."%' OR ";
151
+        $sWhere .= $aColumns[2]." LIKE '".$letter."%' OR ";
152
+        $sWhere .= $aColumns[3]." LIKE '".$letter."%' ";
153 153
     }
154 154
 }
155 155
 
@@ -160,26 +160,26 @@  discard block
 block discarded – undo
160 160
 
161 161
         if ($searchValue !== '') {
162 162
             $sWhere = ' AND ';
163
-            $sWhere .= $aColumns[1] . " LIKE '" . $searchValue . "%' OR ";
164
-            $sWhere .= $aColumns[2] . " LIKE '" . $searchValue . "%' OR ";
165
-            $sWhere .= $aColumns[3] . " LIKE '" . $searchValue . "%' ";
163
+            $sWhere .= $aColumns[1]." LIKE '".$searchValue."%' OR ";
164
+            $sWhere .= $aColumns[2]." LIKE '".$searchValue."%' OR ";
165
+            $sWhere .= $aColumns[3]." LIKE '".$searchValue."%' ";
166 166
         }
167 167
     }
168 168
 }
169 169
 
170 170
 $rows = DB::query(
171 171
     'SELECT a.item_id, i.label, a.del_value, i.id_tree
172
-    FROM ' . prefixTable('automatic_del') . ' AS a
173
-    INNER JOIN ' . prefixTable('items') . ' AS i ON (i.id = a.item_id)' .
172
+    FROM ' . prefixTable('automatic_del').' AS a
173
+    INNER JOIN ' . prefixTable('items').' AS i ON (i.id = a.item_id)'.
174 174
     $sWhere.
175 175
     (string) $sOrder
176 176
 );
177 177
 $iTotal = DB::count();
178 178
 $rows = DB::query(
179 179
     'SELECT a.item_id, i.label, a.del_value, i.id_tree
180
-    FROM ' . prefixTable('automatic_del') . ' AS a
181
-    INNER JOIN ' . prefixTable('items') . ' AS i ON (i.id = a.item_id)' .
182
-        $sWhere .
180
+    FROM ' . prefixTable('automatic_del').' AS a
181
+    INNER JOIN ' . prefixTable('items').' AS i ON (i.id = a.item_id)'.
182
+        $sWhere.
183 183
         $sLimit
184 184
 );
185 185
 $iFilteredTotal = DB::count();
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
    * Output
188 188
 */
189 189
 $sOutput = '{';
190
-$sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
190
+$sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
191 191
 $sOutput .= '"iTotalRecords": '.$iTotal.', ';
192 192
 $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
193 193
 $sOutput .= '"aaData": ';
@@ -201,18 +201,18 @@  discard block
 block discarded – undo
201 201
     // start the line
202 202
     $sOutput .= '[';
203 203
     // Column 1
204
-    $sOutput .= '"<i class=\"fas fa-external-link-alt pointer text-primary mr-2\" onclick=\"showItemCard($(this))\" data-item-id=\"' . $record['item_id'] . '\"  data-item-tree-id=\"' . $record['id_tree'] . '\"></i>", ';
204
+    $sOutput .= '"<i class=\"fas fa-external-link-alt pointer text-primary mr-2\" onclick=\"showItemCard($(this))\" data-item-id=\"'.$record['item_id'].'\"  data-item-tree-id=\"'.$record['id_tree'].'\"></i>", ';
205 205
     // Column 2
206
-    $sOutput .= '"' . $record['label'] . '", ';
206
+    $sOutput .= '"'.$record['label'].'", ';
207 207
     // Column 3
208
-    $sOutput .= '"' . date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['del_value']) . '", ';
208
+    $sOutput .= '"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['del_value']).'", ';
209 209
     // Column 4
210 210
     $path = [];
211 211
     $treeDesc = $tree->getPath($record['id_tree'], true);
212 212
     foreach ($treeDesc as $t) {
213 213
         array_push($path, $t->title);
214 214
     }
215
-    $sOutput .= '"' . implode('<i class=\"fas fa-angle-right ml-1 mr-1\"></i>', $path) . '"],';
215
+    $sOutput .= '"'.implode('<i class=\"fas fa-angle-right ml-1 mr-1\"></i>', $path).'"],';
216 216
 }
217 217
 
218 218
 if (count($rows) > 0) {
Please login to merge, or discard this patch.
scripts/background_tasks___handler.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 use TeampassClasses\ConfigManager\ConfigManager;
31 31
 
32 32
 require_once __DIR__.'/../sources/main.functions.php';
33
-require_once __DIR__ . '/taskLogger.php';
33
+require_once __DIR__.'/taskLogger.php';
34 34
 
35 35
 class BackgroundTasksHandler {
36 36
     private $settings;
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     public function processBackgroundTasks() {
56 56
         // Prevent multiple concurrent executions
57 57
         if (!$this->acquireProcessLock()) {
58
-            if (LOG_TASKS=== true) $this->logger->log('Process already running', 'INFO');
58
+            if (LOG_TASKS === true) $this->logger->log('Process already running', 'INFO');
59 59
             return false;
60 60
         }
61 61
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
             $this->processTaskBatches();
65 65
             $this->performMaintenanceTasks();
66 66
         } catch (Exception $e) {
67
-            if (LOG_TASKS=== true) $this->logger->log('Task processing error: ' . $e->getMessage(), 'ERROR');
67
+            if (LOG_TASKS === true) $this->logger->log('Task processing error: '.$e->getMessage(), 'ERROR');
68 68
         } finally {
69 69
             $this->releaseProcessLock();
70 70
         }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             return false;
84 84
         }
85 85
         
86
-        fwrite($fp, (string)getmypid());
86
+        fwrite($fp, (string) getmypid());
87 87
         return true;
88 88
     }
89 89
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     private function cleanupStaleTasks() {
102 102
         // Mark tasks as failed if they've been running too long
103 103
         DB::query(
104
-            'UPDATE ' . prefixTable('background_tasks') . ' 
104
+            'UPDATE '.prefixTable('background_tasks').' 
105 105
             SET is_in_progress = -1, 
106 106
                 finished_at = %i, 
107 107
                 status = "failed",
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 
115 115
         // Remove very old failed tasks
116 116
         DB::query(
117
-            'DELETE t, st FROM ' . prefixTable('background_tasks') . ' t
118
-            INNER JOIN ' . prefixTable('background_subtasks') . ' st ON (t.increment_id = st.task_id)
117
+            'DELETE t, st FROM '.prefixTable('background_tasks').' t
118
+            INNER JOIN ' . prefixTable('background_subtasks').' st ON (t.increment_id = st.task_id)
119 119
             WHERE t.finished_at < %i 
120 120
             AND t.status = %s',
121 121
             time() - $this->maxTimeBeforeRemoval,
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         
133 133
         // Check if the maximum number of parallel tasks is reached
134 134
         if ($runningTasks >= $this->maxParallelTasks) {
135
-            if (LOG_TASKS=== true) $this->logger->log('Wait ... '.$runningTasks.' out of '.$this->maxParallelTasks.' are already running ', 'INFO');
135
+            if (LOG_TASKS === true) $this->logger->log('Wait ... '.$runningTasks.' out of '.$this->maxParallelTasks.' are already running ', 'INFO');
136 136
             return;
137 137
         }
138 138
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
         // Fetch next batch of tasks
142 142
         $tasks = DB::query(
143 143
             'SELECT increment_id, process_type, arguments 
144
-            FROM ' . prefixTable('background_tasks') . '
144
+            FROM ' . prefixTable('background_tasks').'
145 145
             WHERE is_in_progress = 0 
146 146
             AND (finished_at IS NULL OR finished_at = "")
147 147
             ORDER BY increment_id ASC
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         );
151 151
 
152 152
         foreach ($tasks as $task) {
153
-            if (LOG_TASKS=== true) $this->logger->log('Launching '.$task['increment_id'], 'INFO');
153
+            if (LOG_TASKS === true) $this->logger->log('Launching '.$task['increment_id'], 'INFO');
154 154
             $this->processIndividualTask($task);
155 155
         }
156 156
     }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
      * @param array $task The task to process.
162 162
      */
163 163
     private function processIndividualTask(array $task) {
164
-        if (LOG_TASKS=== true)  $this->logger->log('Starting task: ' . print_r($task, true), 'INFO');
164
+        if (LOG_TASKS === true)  $this->logger->log('Starting task: '.print_r($task, true), 'INFO');
165 165
 
166 166
         // Store progress in the database        
167 167
         DB::update(
@@ -179,19 +179,19 @@  discard block
 block discarded – undo
179 179
         // Prepare process
180 180
         $process = new Process([
181 181
             PHP_BINARY,
182
-            __DIR__ . '/background_tasks___worker.php',
182
+            __DIR__.'/background_tasks___worker.php',
183 183
             $task['increment_id'],
184 184
             $task['process_type'],
185 185
             $task['arguments']
186 186
         ]);
187 187
 
188 188
         // Launch process
189
-        try{
189
+        try {
190 190
             $process->setTimeout($this->maxExecutionTime);
191 191
             $process->mustRun();
192 192
 
193 193
         } catch (Exception $e) {
194
-            if (LOG_TASKS=== true) $this->logger->log('Error launching task: ' . $e->getMessage(), 'ERROR');
194
+            if (LOG_TASKS === true) $this->logger->log('Error launching task: '.$e->getMessage(), 'ERROR');
195 195
             DB::update(
196 196
                 prefixTable('background_tasks'),
197 197
                 [
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
     private function countRunningTasks(): int {
214 214
         return DB::queryFirstField(
215 215
             'SELECT COUNT(*) 
216
-            FROM ' . prefixTable('background_tasks') . ' 
216
+            FROM ' . prefixTable('background_tasks').' 
217 217
             WHERE is_in_progress = 1'
218 218
         );
219 219
     }
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
      */
235 235
     private function cleanMultipleItemsEdition() {
236 236
         DB::query(
237
-            'DELETE i1 FROM ' . prefixTable('items_edition') . ' i1
237
+            'DELETE i1 FROM '.prefixTable('items_edition').' i1
238 238
             JOIN (
239 239
                 SELECT user_id, item_id, MIN(timestamp) AS oldest_timestamp
240
-                FROM ' . prefixTable('items_edition') . '
240
+                FROM ' . prefixTable('items_edition').'
241 241
                 GROUP BY user_id, item_id
242 242
             ) i2 ON i1.user_id = i2.user_id AND i1.item_id = i2.item_id
243 243
             WHERE i1.timestamp > i2.oldest_timestamp'
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
      */
251 251
     private function handleItemTokensExpiration() {
252 252
         DB::query(
253
-            'DELETE FROM ' . prefixTable('items_edition') . '
253
+            'DELETE FROM '.prefixTable('items_edition').'
254 254
             WHERE timestamp < %i',
255 255
             time() - ($this->settings['delay_item_edition'] * 60 ?: EDITION_LOCK_PERIOD)
256 256
         );
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
         // 1. Get all finished tasks older than the cutoff timestamp
268 268
         //    and that are not in progress
269 269
         $tasks = DB::query(
270
-            'SELECT increment_id FROM ' . prefixTable('background_tasks') . '
270
+            'SELECT increment_id FROM '.prefixTable('background_tasks').'
271 271
             WHERE status = %s AND is_in_progress = %i AND finished_at < %s',
272 272
             'completed',
273 273
             -1,
@@ -282,19 +282,19 @@  discard block
 block discarded – undo
282 282
     
283 283
         // 2. Delete all subtasks related to these tasks
284 284
         DB::query(
285
-            'DELETE FROM ' . prefixTable('background_subtasks') . '
285
+            'DELETE FROM '.prefixTable('background_subtasks').'
286 286
             WHERE task_id IN %ls',
287 287
             $taskIds
288 288
         );
289 289
     
290 290
         // 3. Delete the tasks themselves
291 291
         DB::query(
292
-            'DELETE FROM ' . prefixTable('background_tasks') . '
292
+            'DELETE FROM '.prefixTable('background_tasks').'
293 293
             WHERE increment_id IN %ls',
294 294
             $taskIds
295 295
         );
296 296
     
297
-        if (LOG_TASKS=== true) $this->logger->log('Old finished tasks cleaned: ' . count($taskIds), 'INFO');
297
+        if (LOG_TASKS === true) $this->logger->log('Old finished tasks cleaned: '.count($taskIds), 'INFO');
298 298
     }
299 299
 }
300 300
 
@@ -308,5 +308,5 @@  discard block
 block discarded – undo
308 308
     $tasksHandler = new BackgroundTasksHandler($settings);
309 309
     $tasksHandler->processBackgroundTasks();
310 310
 } catch (Exception $e) {
311
-    error_log('Teampass Background Tasks Error: ' . $e->getMessage());
311
+    error_log('Teampass Background Tasks Error: '.$e->getMessage());
312 312
 }
313 313
\ No newline at end of file
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 1 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.