Passed
Push — master ( fd9d0d...11c950 )
by Nils
07:12
created
sources/backups.queries.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 ) {
69 69
     // Not allowed page
70 70
     $superGlobal->put('code', ERR_NOT_ALLOWED, 'SESSION', 'error');
71
-    include $SETTINGS['cpassman_dir'] . '/error.php';
71
+    include $SETTINGS['cpassman_dir'].'/error.php';
72 72
     exit;
73 73
 }
74 74
 
@@ -129,21 +129,21 @@  discard block
 block discarded – undo
129 129
             // Prepare variables
130 130
             $post_key = filter_var($dataReceived['encryptionKey'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
131 131
 
132
-            require_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
132
+            require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
133 133
             $return = '';
134 134
 
135 135
             //Get all tables
136 136
             $tables = array();
137 137
             $result = DB::query('SHOW TABLES');
138 138
             foreach ($result as $row) {
139
-                $tables[] = $row['Tables_in_' . DB_NAME];
139
+                $tables[] = $row['Tables_in_'.DB_NAME];
140 140
             }
141 141
 
142 142
             //cycle through
143 143
             foreach ($tables as $table) {
144 144
                 if (empty($pre) || substr_count($table, $pre) > 0) {
145 145
                     // Do query
146
-                    $result = DB::queryRaw('SELECT * FROM ' . $table);
146
+                    $result = DB::queryRaw('SELECT * FROM '.$table);
147 147
                     DB::queryRaw(
148 148
                         'SELECT *
149 149
                         FROM INFORMATION_SCHEMA.COLUMNS
@@ -155,19 +155,19 @@  discard block
 block discarded – undo
155 155
                     $numFields = DB::count();
156 156
 
157 157
                     // prepare a drop table
158
-                    $return .= 'DROP TABLE ' . $table . ';';
159
-                    $row2 = DB::queryfirstrow('SHOW CREATE TABLE ' . $table);
160
-                    $return .= "\n\n" . $row2['Create Table'] . ";\n\n";
158
+                    $return .= 'DROP TABLE '.$table.';';
159
+                    $row2 = DB::queryfirstrow('SHOW CREATE TABLE '.$table);
160
+                    $return .= "\n\n".$row2['Create Table'].";\n\n";
161 161
 
162 162
                     //prepare all fields and datas
163 163
                     for ($i = 0; $i < $numFields; ++$i) {
164 164
                         while ($row = $result->fetch_row()) {
165
-                            $return .= 'INSERT INTO ' . $table . ' VALUES(';
165
+                            $return .= 'INSERT INTO '.$table.' VALUES(';
166 166
                             for ($j = 0; $j < $numFields; ++$j) {
167 167
                                 $row[$j] = is_null($row[$j]) === false ? addslashes($row[$j]) : '';
168 168
                                 $row[$j] = preg_replace("/\n/", '\\n', $row[$j]);
169 169
                                 if (isset($row[$j])) {
170
-                                    $return .= '"' . $row[$j] . '"';
170
+                                    $return .= '"'.$row[$j].'"';
171 171
                                 } else {
172 172
                                     $return .= 'NULL';
173 173
                                 }
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
                 $token = GenerateCryptKey(20, false, true, true, false, true, $SETTINGS);
188 188
 
189 189
                 //save file
190
-                $filename = time() . '-' . $token . '.sql';
191
-                $handle = fopen($SETTINGS['path_to_files_folder'] . '/' . $filename, 'w+');
190
+                $filename = time().'-'.$token.'.sql';
191
+                $handle = fopen($SETTINGS['path_to_files_folder'].'/'.$filename, 'w+');
192 192
                 if ($handle !== false) {
193 193
                     //write file
194 194
                     fwrite($handle, $return);
@@ -200,17 +200,17 @@  discard block
 block discarded – undo
200 200
                     // Encrypt the file
201 201
                     prepareFileWithDefuse(
202 202
                         'encrypt',
203
-                        $SETTINGS['path_to_files_folder'] . '/' . $filename,
204
-                        $SETTINGS['path_to_files_folder'] . '/defuse_temp_' . $filename,
203
+                        $SETTINGS['path_to_files_folder'].'/'.$filename,
204
+                        $SETTINGS['path_to_files_folder'].'/defuse_temp_'.$filename,
205 205
                         $SETTINGS,
206 206
                         $post_key
207 207
                     );
208 208
 
209 209
                     // Do clean
210
-                    unlink($SETTINGS['path_to_files_folder'] . '/' . $filename);
210
+                    unlink($SETTINGS['path_to_files_folder'].'/'.$filename);
211 211
                     rename(
212
-                        $SETTINGS['path_to_files_folder'] . '/defuse_temp_' . $filename,
213
-                        $SETTINGS['path_to_files_folder'] . '/' . $filename
212
+                        $SETTINGS['path_to_files_folder'].'/defuse_temp_'.$filename,
213
+                        $SETTINGS['path_to_files_folder'].'/'.$filename
214 214
                     );
215 215
                 }
216 216
 
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
                     array(
231 231
                         'error' => false,
232 232
                         'message' => '',
233
-                        'download' => 'sources/downloadFile.php?name=' . urlencode($filename) .
234
-                            '&sub=files&file=' . $filename . '&type=sql&key=' . $superGlobal->get('key', 'SESSION') . '&key_tmp=' .
235
-                            $_SESSION['key_tmp'] . '&pathIsFiles=1',
233
+                        'download' => 'sources/downloadFile.php?name='.urlencode($filename).
234
+                            '&sub=files&file='.$filename.'&type=sql&key='.$superGlobal->get('key', 'SESSION').'&key_tmp='.
235
+                            $_SESSION['key_tmp'].'&pathIsFiles=1',
236 236
                     ),
237 237
                     'encode'
238 238
                 );
@@ -281,12 +281,12 @@  discard block
 block discarded – undo
281 281
             $post_key = filter_var($dataReceived['encryptionKey'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
282 282
             $post_backupFile = filter_var($dataReceived['backupFile'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
283 283
 
284
-            include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
284
+            include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
285 285
 
286 286
             // Get filename from database
287 287
             $data = DB::queryFirstRow(
288 288
                 'SELECT valeur
289
-                FROM ' . prefixTable('misc') . '
289
+                FROM ' . prefixTable('misc').'
290 290
                 WHERE increment_id = %i',
291 291
                 $post_backupFile
292 292
             );
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
                 // Decrypt the file
306 306
                 $ret = prepareFileWithDefuse(
307 307
                     'decrypt',
308
-                    $SETTINGS['path_to_files_folder'] . '/' . $post_backupFile,
309
-                    $SETTINGS['path_to_files_folder'] . '/defuse_temp_' . $post_backupFile,
308
+                    $SETTINGS['path_to_files_folder'].'/'.$post_backupFile,
309
+                    $SETTINGS['path_to_files_folder'].'/defuse_temp_'.$post_backupFile,
310 310
                     $SETTINGS,
311 311
                     $post_key
312 312
                 );
@@ -323,10 +323,10 @@  discard block
 block discarded – undo
323 323
                 }
324 324
 
325 325
                 // Do clean
326
-                fileDelete($SETTINGS['path_to_files_folder'] . '/' . $post_backupFile, $SETTINGS);
327
-                $post_backupFile = $SETTINGS['path_to_files_folder'] . '/defuse_temp_' . $post_backupFile;
326
+                fileDelete($SETTINGS['path_to_files_folder'].'/'.$post_backupFile, $SETTINGS);
327
+                $post_backupFile = $SETTINGS['path_to_files_folder'].'/defuse_temp_'.$post_backupFile;
328 328
             } else {
329
-                $post_backupFile = $SETTINGS['path_to_files_folder'] . '/' . $post_backupFile;
329
+                $post_backupFile = $SETTINGS['path_to_files_folder'].'/'.$post_backupFile;
330 330
             }
331 331
 
332 332
             //read sql file
Please login to merge, or discard this patch.
sources/admin.queries.php 1 patch
Spacing   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('admin') === false) {
72 72
     // Not allowed page
73 73
     $superGlobal->put('code', ERR_NOT_ALLOWED, 'SESSION', 'error');
74
-    include $SETTINGS['cpassman_dir'] . '/error.php';
74
+    include $SETTINGS['cpassman_dir'].'/error.php';
75 75
     exit;
76 76
 }
77 77
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                         array(
122 122
                             'http' => array(
123 123
                                 'ignore_errors' => true,
124
-                                'proxy' => $SETTINGS['proxy_ip'] . ':' . $SETTINGS['proxy_port'],
124
+                                'proxy' => $SETTINGS['proxy_ip'].':'.$SETTINGS['proxy_port'],
125 125
                             ),
126 126
                         )
127 127
                     );
@@ -140,16 +140,16 @@  discard block
 block discarded – undo
140 140
                     $json_array = json_decode($json, true);
141 141
 
142 142
                     // About version
143
-                    $text .= '<li><u>' . $LANG['your_version'] . '</u> : ' . TP_VERSION;
143
+                    $text .= '<li><u>'.$LANG['your_version'].'</u> : '.TP_VERSION;
144 144
                     if (floatval(TP_VERSION) < floatval($json_array['info']['version'])) {
145
-                        $text .= '&nbsp;&nbsp;<b>' . $LANG['please_update'] . '</b>';
145
+                        $text .= '&nbsp;&nbsp;<b>'.$LANG['please_update'].'</b>';
146 146
                     }
147 147
                     $text .= '</li>';
148 148
 
149 149
                     // Libraries
150 150
                     $text .= '<li><u>Libraries</u> :</li>';
151 151
                     foreach ($json_array['libraries'] as $key => $val) {
152
-                        $text .= "<li>&nbsp;<span class='fa fa-caret-right'></span>&nbsp;" . $key . " (<a href='" . $val . "' target='_blank'>" . $val . '</a>)</li>';
152
+                        $text .= "<li>&nbsp;<span class='fa fa-caret-right'></span>&nbsp;".$key." (<a href='".$val."' target='_blank'>".$val.'</a>)</li>';
153 153
                     }
154 154
                 }
155 155
             } else {
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         }
161 161
         $text .= '</ul>';
162 162
 
163
-        echo '[{"error":"' . $error . '" , "output":"' . str_replace(array("\n", "\t", "\r"), '', $text) . '"}]';
163
+        echo '[{"error":"'.$error.'" , "output":"'.str_replace(array("\n", "\t", "\r"), '', $text).'"}]';
164 164
         break;
165 165
         
166 166
 
@@ -190,21 +190,21 @@  discard block
 block discarded – undo
190 190
             break;
191 191
         }
192 192
 
193
-        require_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
193
+        require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
194 194
         $return = '';
195 195
 
196 196
         //Get all tables
197 197
         $tables = array();
198 198
         $result = DB::query('SHOW TABLES');
199 199
         foreach ($result as $row) {
200
-            $tables[] = $row['Tables_in_' . $database];
200
+            $tables[] = $row['Tables_in_'.$database];
201 201
         }
202 202
 
203 203
         //cycle through
204 204
         foreach ($tables as $table) {
205 205
             if (defined('DB_PREFIX') || substr_count($table, DB_PREFIX) > 0) {
206 206
                 // Do query
207
-                $result = DB::queryRaw('SELECT * FROM ' . $table);
207
+                $result = DB::queryRaw('SELECT * FROM '.$table);
208 208
                 DB::queryRaw(
209 209
                     'SELECT *
210 210
                     FROM INFORMATION_SCHEMA.COLUMNS
@@ -216,19 +216,19 @@  discard block
 block discarded – undo
216 216
                 $numFields = DB::count();
217 217
 
218 218
                 // prepare a drop table
219
-                $return .= 'DROP TABLE ' . $table . ';';
220
-                $row2 = DB::queryfirstrow('SHOW CREATE TABLE ' . $table);
221
-                $return .= "\n\n" . $row2['Create Table'] . ";\n\n";
219
+                $return .= 'DROP TABLE '.$table.';';
220
+                $row2 = DB::queryfirstrow('SHOW CREATE TABLE '.$table);
221
+                $return .= "\n\n".$row2['Create Table'].";\n\n";
222 222
 
223 223
                 //prepare all fields and datas
224 224
                 for ($i = 0; $i < $numFields; ++$i) {
225 225
                     while ($row = $result->fetch_row()) {
226
-                        $return .= 'INSERT INTO ' . $table . ' VALUES(';
226
+                        $return .= 'INSERT INTO '.$table.' VALUES(';
227 227
                         for ($j = 0; $j < $numFields; ++$j) {
228 228
                             $row[$j] = addslashes($row[$j]);
229 229
                             $row[$j] = preg_replace("/\n/", '\\n', $row[$j]);
230 230
                             if (isset($row[$j])) {
231
-                                $return .= '"' . $row[$j] . '"';
231
+                                $return .= '"'.$row[$j].'"';
232 232
                             } else {
233 233
                                 $return .= 'NULL';
234 234
                             }
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
             $token = GenerateCryptKey(20, false, true, true, false, true, $SETTINGS);
249 249
 
250 250
             //save file
251
-            $filename = time() . '-' . $token . '.sql';
252
-            $handle = fopen($SETTINGS['path_to_files_folder'] . '/' . $filename, 'w+');
251
+            $filename = time().'-'.$token.'.sql';
252
+            $handle = fopen($SETTINGS['path_to_files_folder'].'/'.$filename, 'w+');
253 253
             if ($handle !== false) {
254 254
                 //write file
255 255
                 fwrite($handle, $return);
@@ -261,17 +261,17 @@  discard block
 block discarded – undo
261 261
                 // Encrypt the file
262 262
                 prepareFileWithDefuse(
263 263
                     'encrypt',
264
-                    $SETTINGS['path_to_files_folder'] . '/' . $filename,
265
-                    $SETTINGS['path_to_files_folder'] . '/defuse_temp_' . $filename,
264
+                    $SETTINGS['path_to_files_folder'].'/'.$filename,
265
+                    $SETTINGS['path_to_files_folder'].'/defuse_temp_'.$filename,
266 266
                     $SETTINGS,
267 267
                     $post_option
268 268
                 );
269 269
 
270 270
                 // Do clean
271
-                unlink($SETTINGS['path_to_files_folder'] . '/' . $filename);
271
+                unlink($SETTINGS['path_to_files_folder'].'/'.$filename);
272 272
                 rename(
273
-                    $SETTINGS['path_to_files_folder'] . '/defuse_temp_' . $filename,
274
-                    $SETTINGS['path_to_files_folder'] . '/' . $filename
273
+                    $SETTINGS['path_to_files_folder'].'/defuse_temp_'.$filename,
274
+                    $SETTINGS['path_to_files_folder'].'/'.$filename
275 275
                 );
276 276
             }
277 277
 
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
             //update LOG
282 282
             logEvents($SETTINGS, 'admin_action', 'dataBase backup', (string) $_SESSION['user_id'], $_SESSION['login']);
283 283
 
284
-            echo '[{"result":"db_backup" , "href":"sources/downloadFile.php?name=' . urlencode($filename) . '&sub=files&file=' . $filename . '&type=sql&key=' . $superGlobal->get('key', 'SESSION') . '&key_tmp=' . $_SESSION['key_tmp'] . '&pathIsFiles=1"}]';
284
+            echo '[{"result":"db_backup" , "href":"sources/downloadFile.php?name='.urlencode($filename).'&sub=files&file='.$filename.'&type=sql&key='.$superGlobal->get('key', 'SESSION').'&key_tmp='.$_SESSION['key_tmp'].'&pathIsFiles=1"}]';
285 285
         }
286 286
         break;
287 287
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
             );
311 311
             break;
312 312
         }
313
-        include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
313
+        include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
314 314
 
315 315
         $dataPost = explode('&', $post_option);
316 316
         $file = htmlspecialchars($dataPost[0]);
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
         // Get filename from database
320 320
         $data = DB::queryFirstRow(
321 321
             'SELECT valeur
322
-            FROM ' . prefixTable('misc') . '
322
+            FROM ' . prefixTable('misc').'
323 323
             WHERE increment_id = %i',
324 324
             $file
325 325
         );
@@ -338,22 +338,22 @@  discard block
 block discarded – undo
338 338
             // Decrypt the file
339 339
             $ret = prepareFileWithDefuse(
340 340
                 'decrypt',
341
-                $SETTINGS['path_to_files_folder'] . '/' . $file,
342
-                $SETTINGS['path_to_files_folder'] . '/defuse_temp_' . $file,
341
+                $SETTINGS['path_to_files_folder'].'/'.$file,
342
+                $SETTINGS['path_to_files_folder'].'/defuse_temp_'.$file,
343 343
                 $SETTINGS,
344 344
                 $key
345 345
             );
346 346
 
347 347
             if (empty($ret) === false) {
348
-                echo '[{"result":"db_restore" , "message":"' . $ret . '"}]';
348
+                echo '[{"result":"db_restore" , "message":"'.$ret.'"}]';
349 349
                 break;
350 350
             }
351 351
 
352 352
             // Do clean
353
-            fileDelete($SETTINGS['path_to_files_folder'] . '/' . $file, $SETTINGS);
354
-            $file = $SETTINGS['path_to_files_folder'] . '/defuse_temp_' . $file;
353
+            fileDelete($SETTINGS['path_to_files_folder'].'/'.$file, $SETTINGS);
354
+            $file = $SETTINGS['path_to_files_folder'].'/defuse_temp_'.$file;
355 355
         } else {
356
-            $file = $SETTINGS['path_to_files_folder'] . '/' . $file;
356
+            $file = $SETTINGS['path_to_files_folder'].'/'.$file;
357 357
         }
358 358
 
359 359
         //read sql file
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
         fclose($handle);
371 371
 
372 372
         //delete file
373
-        unlink($SETTINGS['path_to_files_folder'] . '/' . $file);
373
+        unlink($SETTINGS['path_to_files_folder'].'/'.$file);
374 374
 
375 375
         //Show done
376 376
         echo '[{"result":"db_restore" , "message":""}]';
@@ -408,8 +408,8 @@  discard block
 block discarded – undo
408 408
             foreach ($table as $i => $tablename) {
409 409
                 if (substr_count($tablename, DB_PREFIX) > 0) {
410 410
                     // launch optimization quieries
411
-                    DB::query('ANALYZE TABLE `' . $tablename . '`');
412
-                    DB::query('OPTIMIZE TABLE `' . $tablename . '`');
411
+                    DB::query('ANALYZE TABLE `'.$tablename.'`');
412
+                    DB::query('OPTIMIZE TABLE `'.$tablename.'`');
413 413
                 }
414 414
             }
415 415
         }
@@ -417,12 +417,12 @@  discard block
 block discarded – undo
417 417
         //Clean up LOG_ITEMS table
418 418
         $rows = DB::query(
419 419
             'SELECT id
420
-            FROM ' . prefixTable('items') . '
420
+            FROM ' . prefixTable('items').'
421 421
             ORDER BY id ASC'
422 422
         );
423 423
         foreach ($rows as $item) {
424 424
             DB::query(
425
-                'SELECT * FROM ' . prefixTable('log_items') . ' WHERE id_item = %i AND action = %s',
425
+                'SELECT * FROM '.prefixTable('log_items').' WHERE id_item = %i AND action = %s',
426 426
                 $item['id'],
427 427
                 'at_creation'
428 428
             );
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
             if ($counter === 0) {
431 431
                 //Create new at_creation entry
432 432
                 $rowTmp = DB::queryFirstRow(
433
-                    'SELECT date, id_user FROM ' . prefixTable('log_items') . ' WHERE id_item=%i ORDER BY date ASC',
433
+                    'SELECT date, id_user FROM '.prefixTable('log_items').' WHERE id_item=%i ORDER BY date ASC',
434 434
                     $item['id']
435 435
                 );
436 436
                 DB::insert(
@@ -460,8 +460,8 @@  discard block
 block discarded – undo
460 460
         echo prepareExchangedData(
461 461
             array(
462 462
                 'error' => false,
463
-                'message' => $lang->get('last_execution') . ' ' .
464
-                    date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) time()) .
463
+                'message' => $lang->get('last_execution').' '.
464
+                    date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) time()).
465 465
                     '<i class="fas fa-check text-success ml-2"></i>',
466 466
             ),
467 467
             'encode'
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
             break;
498 498
         }
499 499
 
500
-        require_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
500
+        require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
501 501
         updateCacheTable('reload', NULL);
502 502
 
503 503
         // Log
@@ -513,8 +513,8 @@  discard block
 block discarded – undo
513 513
         echo prepareExchangedData(
514 514
             [
515 515
                 'error' => false,
516
-                'message' => $lang->get('last_execution') . ' ' .
517
-                    date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) time()) .
516
+                'message' => $lang->get('last_execution').' '.
517
+                    date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) time()).
518 518
                     '<i class="fas fa-check text-success mr-2"></i>',
519 519
             ],
520 520
             'encode'
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
         }
550 550
 
551 551
         // Perform
552
-        include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
552
+        include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
553 553
         $ret = handleConfigFile('rebuild', $SETTINGS);
554 554
 
555 555
         // Log
@@ -576,8 +576,8 @@  discard block
 block discarded – undo
576 576
         echo prepareExchangedData(
577 577
             array(
578 578
                 'error' => false,
579
-                'message' => $lang->get('last_execution') . ' ' .
580
-                    date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) time()) .
579
+                'message' => $lang->get('last_execution').' '.
580
+                    date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) time()).
581 581
                     '<i class="fas fa-check text-success ml-2"></i>',
582 582
             ),
583 583
             'encode'
@@ -617,18 +617,18 @@  discard block
 block discarded – undo
617 617
         $filename = $post_option;
618 618
         $tp_settings = [];
619 619
         //get backups infos
620
-        $rows = DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s', 'admin');
620
+        $rows = DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s', 'admin');
621 621
         foreach ($rows as $record) {
622 622
             $tp_settings[$record['intitule']] = $record['valeur'];
623 623
         }
624 624
 
625 625
         // check if backup file is in DB.
626 626
         // If YES then it is encrypted with DEFUSE
627
-        $bck = DB::queryFirstRow('SELECT valeur FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'backup', 'filename');
627
+        $bck = DB::queryFirstRow('SELECT valeur FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'backup', 'filename');
628 628
 
629 629
         //read file
630 630
         $return = '';
631
-        $Fnm = $tp_settings['bck_script_path'] . '/' . $filename . '.sql';
631
+        $Fnm = $tp_settings['bck_script_path'].'/'.$filename.'.sql';
632 632
         if (file_exists($Fnm)) {
633 633
             if (!empty($bck) && $bck['valeur'] === $filename) {
634 634
                 $err = '';
@@ -636,8 +636,8 @@  discard block
 block discarded – undo
636 636
                 // it means that file is DEFUSE encrypted
637 637
                 try {
638 638
                     File::decryptFileWithPassword(
639
-                        $SETTINGS['bck_script_path'] . '/' . $post_option . '.sql',
640
-                        $SETTINGS['bck_script_path'] . '/' . str_replace('encrypted', 'clear', $filename) . '.sql',
639
+                        $SETTINGS['bck_script_path'].'/'.$post_option.'.sql',
640
+                        $SETTINGS['bck_script_path'].'/'.str_replace('encrypted', 'clear', $filename).'.sql',
641 641
                         base64_decode($SETTINGS['bck_script_key'])
642 642
                     );
643 643
                 } catch (CryptoException\WrongKeyOrModifiedCiphertextException $ex) {
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
                 }
646 646
 
647 647
                 if (!empty($err)) {
648
-                    echo '[{ "result":"backup_decrypt_fails" , "msg":"' . $err . '"}]';
648
+                    echo '[{ "result":"backup_decrypt_fails" , "msg":"'.$err.'"}]';
649 649
                     break;
650 650
                 }
651 651
             } else {
@@ -664,19 +664,19 @@  discard block
 block discarded – undo
664 664
                 );
665 665
 
666 666
                 //save the file
667
-                $handle = fopen($tp_settings['bck_script_path'] . '/' . $filename . '.clear.sql', 'w+');
667
+                $handle = fopen($tp_settings['bck_script_path'].'/'.$filename.'.clear.sql', 'w+');
668 668
                 if ($handle !== false && is_null($return) === false) {
669 669
                     fwrite($handle, /** @scrutinizer ignore-type */ $return);
670 670
                 }
671 671
                 fclose($handle);
672 672
             }
673 673
             $result = 'backup_decrypt_success';
674
-            $msg = $tp_settings['bck_script_path'] . '/' . $filename . '.clear.sql';
674
+            $msg = $tp_settings['bck_script_path'].'/'.$filename.'.clear.sql';
675 675
         } else {
676 676
             $result = 'backup_decrypt_fails';
677
-            $msg = 'File not found: ' . $Fnm;
677
+            $msg = 'File not found: '.$Fnm;
678 678
         }
679
-        echo '[{ "result":"' . $result . '" , "msg":"' . $msg . '"}]';
679
+        echo '[{ "result":"'.$result.'" , "msg":"'.$msg.'"}]';
680 680
         break;
681 681
 
682 682
         /*
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
         $_SESSION['reencrypt_old_salt'] = file_get_contents(SECUREPATH.'/'.SECUREFILE);
714 714
 
715 715
         // generate new saltkey
716
-        $old_sk_filename = SECUREPATH.'/'.SECUREFILE . date('Y_m_d', mktime(0, 0, 0, (int) date('m'), (int) date('d'), (int) date('y'))) . '.' . time();
716
+        $old_sk_filename = SECUREPATH.'/'.SECUREFILE.date('Y_m_d', mktime(0, 0, 0, (int) date('m'), (int) date('d'), (int) date('y'))).'.'.time();
717 717
         copy(
718 718
             SECUREPATH.'/'.SECUREFILE,
719 719
             $old_sk_filename
@@ -741,13 +741,13 @@  discard block
 block discarded – undo
741 741
         logEvents($SETTINGS, 'system', 'change_salt_key', (string) $_SESSION['user_id'], $_SESSION['login']);
742 742
 
743 743
         // get number of items to change
744
-        DB::query('SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i', 0);
744
+        DB::query('SELECT id FROM '.prefixTable('items').' WHERE perso = %i', 0);
745 745
         $nb_of_items = DB::count();
746 746
 
747 747
         // create backup table
748
-        DB::query('DROP TABLE IF EXISTS ' . prefixTable('sk_reencrypt_backup'));
748
+        DB::query('DROP TABLE IF EXISTS '.prefixTable('sk_reencrypt_backup'));
749 749
         DB::query(
750
-            'CREATE TABLE `' . prefixTable('sk_reencrypt_backup') . '` (
750
+            'CREATE TABLE `'.prefixTable('sk_reencrypt_backup').'` (
751 751
             `id` int(12) NOT null AUTO_INCREMENT,
752 752
             `current_table` varchar(100) NOT NULL,
753 753
             `current_field` varchar(500) NOT NULL,
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
         );
776 776
 
777 777
         // delete previous backup files
778
-        $files = glob($SETTINGS['path_to_upload_folder'] . '/*'); // get all file names
778
+        $files = glob($SETTINGS['path_to_upload_folder'].'/*'); // get all file names
779 779
         foreach ($files as $file) { // iterate files
780 780
             if (is_file($file)) {
781 781
                 $file_parts = pathinfo($file);
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
                 echo prepareExchangedData(
858 858
                     array(
859 859
                         'error' => true,
860
-                        'message' => 'Input `' . $objects[0] . '` is not allowed',
860
+                        'message' => 'Input `'.$objects[0].'` is not allowed',
861 861
                         'nbOfItems' => '',
862 862
                         'nextAction' => '',
863 863
                     ),
@@ -870,9 +870,9 @@  discard block
 block discarded – undo
870 870
                 //change all encrypted data in Items (passwords)
871 871
                 $rows = DB::query(
872 872
                     'SELECT id, pw, pw_iv
873
-                    FROM ' . prefixTable('items') . '
873
+                    FROM ' . prefixTable('items').'
874 874
                     WHERE perso = %s
875
-                    LIMIT ' . $post_start . ', ' . $post_length,
875
+                    LIMIT ' . $post_start.', '.$post_length,
876 876
                     '0'
877 877
                 );
878 878
                 foreach ($rows as $record) {
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
                             'current_field' => 'pw',
885 885
                             'value_id' => $record['id'],
886 886
                             'value' => $record['pw'],
887
-                            'current_sql' => 'UPDATE ' . prefixTable('items') . " SET pw = '" . $record['pw'] . "' WHERE id = '" . $record['id'] . "';",
887
+                            'current_sql' => 'UPDATE '.prefixTable('items')." SET pw = '".$record['pw']."' WHERE id = '".$record['id']."';",
888 888
                             'value2' => 'none',
889 889
                             'result' => 'none',
890 890
                         )
@@ -933,9 +933,9 @@  discard block
 block discarded – undo
933 933
                 //change all encrypted data in Logs (passwords)
934 934
                 $rows = DB::query(
935 935
                     'SELECT raison, increment_id
936
-                    FROM ' . prefixTable('log_items') . "
936
+                    FROM ' . prefixTable('log_items')."
937 937
                     WHERE action = %s AND raison LIKE 'at_pw :%'
938
-                    LIMIT " . $post_start . ', ' . $post_length,
938
+                    LIMIT " . $post_start.', '.$post_length,
939 939
                     'at_modification'
940 940
                 );
941 941
                 foreach ($rows as $record) {
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
                             'current_field' => 'raison',
948 948
                             'value_id' => $record['increment_id'],
949 949
                             'value' => $record['raison'],
950
-                            'current_sql' => 'UPDATE ' . prefixTable('log_items') . " SET raison = '" . $record['raison'] . "' WHERE increment_id = '" . $record['increment_id'] . "';",
950
+                            'current_sql' => 'UPDATE '.prefixTable('log_items')." SET raison = '".$record['raison']."' WHERE increment_id = '".$record['increment_id']."';",
951 951
                             'value2' => 'none',
952 952
                             'result' => 'none',
953 953
                         )
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
                         DB::update(
976 976
                             prefixTable('log_items'),
977 977
                             array(
978
-                                'raison' => 'at_pw :' . $encrypt['string'],
978
+                                'raison' => 'at_pw :'.$encrypt['string'],
979 979
                                 'encryption_type' => 'defuse',
980 980
                             ),
981 981
                             'increment_id = %i',
@@ -1000,8 +1000,8 @@  discard block
 block discarded – undo
1000 1000
                 //change all encrypted data in CATEGORIES (passwords)
1001 1001
                 $rows = DB::query(
1002 1002
                     'SELECT id, data
1003
-                    FROM ' . prefixTable('categories_items') . '
1004
-                    LIMIT ' . $post_start . ', ' . $post_length
1003
+                    FROM ' . prefixTable('categories_items').'
1004
+                    LIMIT ' . $post_start.', '.$post_length
1005 1005
                 );
1006 1006
                 foreach ($rows as $record) {
1007 1007
                     // backup data
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
                             'current_field' => 'data',
1013 1013
                             'value_id' => $record['id'],
1014 1014
                             'value' => $record['data'],
1015
-                            'current_sql' => 'UPDATE ' . prefixTable('categories_items') . " SET data = '" . $record['data'] . "' WHERE id = '" . $record['id'] . "';",
1015
+                            'current_sql' => 'UPDATE '.prefixTable('categories_items')." SET data = '".$record['data']."' WHERE id = '".$record['id']."';",
1016 1016
                             'value2' => 'none',
1017 1017
                             'result' => 'none',
1018 1018
                         )
@@ -1060,9 +1060,9 @@  discard block
 block discarded – undo
1060 1060
                 // Change all encrypted data in FILES (passwords)
1061 1061
                 $rows = DB::query(
1062 1062
                     'SELECT id, file, status
1063
-                    FROM ' . prefixTable('files') . "
1063
+                    FROM ' . prefixTable('files')."
1064 1064
                     WHERE status = 'encrypted'
1065
-                    LIMIT " . $post_start . ', ' . $post_length
1065
+                    LIMIT " . $post_start.', '.$post_length
1066 1066
                 );
1067 1067
                 foreach ($rows as $record) {
1068 1068
                     // backup data
@@ -1080,20 +1080,20 @@  discard block
 block discarded – undo
1080 1080
                     );
1081 1081
                     $newID = DB::insertId();
1082 1082
 
1083
-                    if (file_exists($SETTINGS['path_to_upload_folder'] . '/' . $record['file'])) {
1083
+                    if (file_exists($SETTINGS['path_to_upload_folder'].'/'.$record['file'])) {
1084 1084
                         // make a copy of file
1085 1085
                         if (!copy(
1086
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record['file'],
1087
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record['file'] . '.copy'
1086
+                            $SETTINGS['path_to_upload_folder'].'/'.$record['file'],
1087
+                            $SETTINGS['path_to_upload_folder'].'/'.$record['file'].'.copy'
1088 1088
                         )) {
1089 1089
                             $error = 'Copy not possible';
1090 1090
                             exit;
1091 1091
                         } else {
1092 1092
                             // prepare a bck of file (that will not be deleted)
1093
-                            $backup_filename = $record['file'] . '.bck-change-sk.' . time();
1093
+                            $backup_filename = $record['file'].'.bck-change-sk.'.time();
1094 1094
                             copy(
1095
-                                $SETTINGS['path_to_upload_folder'] . '/' . $record['file'],
1096
-                                $SETTINGS['path_to_upload_folder'] . '/' . $backup_filename
1095
+                                $SETTINGS['path_to_upload_folder'].'/'.$record['file'],
1096
+                                $SETTINGS['path_to_upload_folder'].'/'.$backup_filename
1097 1097
                             );
1098 1098
                         }
1099 1099
 
@@ -1101,24 +1101,24 @@  discard block
 block discarded – undo
1101 1101
                         // STEP1 - Do decryption
1102 1102
                         prepareFileWithDefuse(
1103 1103
                             'decrypt',
1104
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record['file'],
1105
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record['file'] . '_encrypted',
1104
+                            $SETTINGS['path_to_upload_folder'].'/'.$record['file'],
1105
+                            $SETTINGS['path_to_upload_folder'].'/'.$record['file'].'_encrypted',
1106 1106
                             $SETTINGS
1107 1107
                         );
1108 1108
 
1109 1109
                         // Do cleanup of files
1110
-                        unlink($SETTINGS['path_to_upload_folder'] . '/' . $record['file']);
1110
+                        unlink($SETTINGS['path_to_upload_folder'].'/'.$record['file']);
1111 1111
 
1112 1112
                         // STEP2 - Do encryption
1113 1113
                         prepareFileWithDefuse(
1114 1114
                             'encryp',
1115
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record['file'] . '_encrypted',
1116
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record['file'],
1115
+                            $SETTINGS['path_to_upload_folder'].'/'.$record['file'].'_encrypted',
1116
+                            $SETTINGS['path_to_upload_folder'].'/'.$record['file'],
1117 1117
                             $SETTINGS
1118 1118
                         );
1119 1119
 
1120 1120
                         // Do cleanup of files
1121
-                        unlink($SETTINGS['path_to_upload_folder'] . '/' . $record['file'] . '_encrypted');
1121
+                        unlink($SETTINGS['path_to_upload_folder'].'/'.$record['file'].'_encrypted');
1122 1122
 
1123 1123
                         // Update backup table
1124 1124
                         DB::update(
@@ -1144,13 +1144,13 @@  discard block
 block discarded – undo
1144 1144
                 // do some things for new object
1145 1145
                 if (isset($objects[0])) {
1146 1146
                     if ($objects[0] === 'logs') {
1147
-                        DB::query('SELECT increment_id FROM ' . prefixTable('log_items') . " WHERE action = %s AND raison LIKE 'at_pw :%'", 'at_modification');
1147
+                        DB::query('SELECT increment_id FROM '.prefixTable('log_items')." WHERE action = %s AND raison LIKE 'at_pw :%'", 'at_modification');
1148 1148
                     } elseif ($objects[0] === 'files') {
1149
-                        DB::query('SELECT id FROM ' . prefixTable('files'));
1149
+                        DB::query('SELECT id FROM '.prefixTable('files'));
1150 1150
                     } elseif ($objects[0] === 'categories') {
1151
-                        DB::query('SELECT id FROM ' . prefixTable('categories_items'));
1151
+                        DB::query('SELECT id FROM '.prefixTable('categories_items'));
1152 1152
                     } elseif ($objects[0] === 'custfields') {
1153
-                        DB::query('SELECT raison FROM ' . prefixTable('log_items') . " WHERE action = %s AND raison LIKE 'at_pw :%'", 'at_modification');
1153
+                        DB::query('SELECT raison FROM '.prefixTable('log_items')." WHERE action = %s AND raison LIKE 'at_pw :%'", 'at_modification');
1154 1154
                     }
1155 1155
                     $nb_of_items = DB::count();
1156 1156
                 } else {
@@ -1269,12 +1269,12 @@  discard block
 block discarded – undo
1269 1269
                 );
1270 1270
             } elseif ($record['current_table'] === 'files') {
1271 1271
                 // restore backup file
1272
-                if (file_exists($SETTINGS['path_to_upload_folder'] . '/' . $record['value'])) {
1273
-                    unlink($SETTINGS['path_to_upload_folder'] . '/' . $record['value']);
1274
-                    if (file_exists($SETTINGS['path_to_upload_folder'] . '/' . $record['value2'])) {
1272
+                if (file_exists($SETTINGS['path_to_upload_folder'].'/'.$record['value'])) {
1273
+                    unlink($SETTINGS['path_to_upload_folder'].'/'.$record['value']);
1274
+                    if (file_exists($SETTINGS['path_to_upload_folder'].'/'.$record['value2'])) {
1275 1275
                         rename(
1276
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record['value2'],
1277
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record['value']
1276
+                            $SETTINGS['path_to_upload_folder'].'/'.$record['value2'],
1277
+                            $SETTINGS['path_to_upload_folder'].'/'.$record['value']
1278 1278
                         );
1279 1279
                     }
1280 1280
                 }
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
         }
1294 1294
 
1295 1295
         // drop table
1296
-        DB::query('DROP TABLE IF EXISTS ' . prefixTable('sk_reencrypt_backup'));
1296
+        DB::query('DROP TABLE IF EXISTS '.prefixTable('sk_reencrypt_backup'));
1297 1297
 
1298 1298
         // Send back
1299 1299
         echo prepareExchangedData(
@@ -1336,17 +1336,17 @@  discard block
 block discarded – undo
1336 1336
         // delete files
1337 1337
         $rows = DB::query(
1338 1338
             'SELECT value, value2
1339
-            FROM ' . prefixTable('sk_reencrypt_backup') . "
1339
+            FROM ' . prefixTable('sk_reencrypt_backup')."
1340 1340
             WHERE current_table = 'files'"
1341 1341
         );
1342 1342
         foreach ($rows as $record) {
1343
-            if (file_exists($SETTINGS['path_to_upload_folder'] . '/' . $record['value2'])) {
1344
-                unlink($SETTINGS['path_to_upload_folder'] . '/' . $record['value2']);
1343
+            if (file_exists($SETTINGS['path_to_upload_folder'].'/'.$record['value2'])) {
1344
+                unlink($SETTINGS['path_to_upload_folder'].'/'.$record['value2']);
1345 1345
             }
1346 1346
         }
1347 1347
 
1348 1348
         // drop table
1349
-        DB::query('DROP TABLE IF EXISTS ' . prefixTable('sk_reencrypt_backup'));
1349
+        DB::query('DROP TABLE IF EXISTS '.prefixTable('sk_reencrypt_backup'));
1350 1350
 
1351 1351
         echo '[{"status":"done"}]';
1352 1352
         break;
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
                 'encode'
1378 1378
             );
1379 1379
         } else {
1380
-            require_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
1380
+            require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
1381 1381
 
1382 1382
             //send email
1383 1383
             sendEmail(
@@ -1412,11 +1412,11 @@  discard block
 block discarded – undo
1412 1412
             break;
1413 1413
         }
1414 1414
 
1415
-        include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
1415
+        include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
1416 1416
 
1417 1417
         $rows = DB::query(
1418 1418
             'SELECT *
1419
-            FROM ' . prefixTable('emails') . '
1419
+            FROM ' . prefixTable('emails').'
1420 1420
             WHERE status = %s OR status = %s',
1421 1421
             'not_sent',
1422 1422
             ''
@@ -1501,9 +1501,9 @@  discard block
 block discarded – undo
1501 1501
             break;
1502 1502
         }
1503 1503
 
1504
-        include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
1504
+        include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
1505 1505
 
1506
-        $rows = DB::query('SELECT * FROM ' . prefixTable('emails') . ' WHERE status = %s OR status = %s', 'not_sent', '');
1506
+        $rows = DB::query('SELECT * FROM '.prefixTable('emails').' WHERE status = %s OR status = %s', 'not_sent', '');
1507 1507
         foreach ($rows as $record) {
1508 1508
             //send email
1509 1509
             $ret = json_decode(
@@ -1571,7 +1571,7 @@  discard block
 block discarded – undo
1571 1571
             break;
1572 1572
         }
1573 1573
 
1574
-        require_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
1574
+        require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
1575 1575
 
1576 1576
         // init
1577 1577
         $filesList = array();
@@ -1584,7 +1584,7 @@  discard block
 block discarded – undo
1584 1584
                 FROM ' . prefixTable('files')
1585 1585
             );
1586 1586
             foreach ($rows as $record) {
1587
-                if (is_file($SETTINGS['path_to_upload_folder'] . '/' . $record['file'])) {
1587
+                if (is_file($SETTINGS['path_to_upload_folder'].'/'.$record['file'])) {
1588 1588
                     $addFile = false;
1589 1589
                     if (($post_option === 'attachments-decrypt' && $record['status'] === 'encrypted')
1590 1590
                         || ($post_option === 'attachments-encrypt' && $record['status'] === 'clear')
@@ -1649,8 +1649,8 @@  discard block
 block discarded – undo
1649 1649
         $post_list = filter_var_array($post_list, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
1650 1650
         $post_counter = filter_var($post_counter, FILTER_SANITIZE_NUMBER_INT);
1651 1651
 
1652
-        include $SETTINGS['cpassman_dir'] . '/includes/config/settings.php';
1653
-        include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
1652
+        include $SETTINGS['cpassman_dir'].'/includes/config/settings.php';
1653
+        include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
1654 1654
 
1655 1655
         $cpt = 0;
1656 1656
         $continu = true;
@@ -1663,35 +1663,35 @@  discard block
 block discarded – undo
1663 1663
                 // Get file name
1664 1664
                 $file_info = DB::queryfirstrow(
1665 1665
                     'SELECT file
1666
-                    FROM ' . prefixTable('files') . '
1666
+                    FROM ' . prefixTable('files').'
1667 1667
                     WHERE id = %i',
1668 1668
                     $file
1669 1669
                 );
1670 1670
 
1671 1671
                 // skip file is Coherancey not respected
1672
-                if (is_file($SETTINGS['path_to_upload_folder'] . '/' . $file_info['file'])) {
1672
+                if (is_file($SETTINGS['path_to_upload_folder'].'/'.$file_info['file'])) {
1673 1673
                     // Case where we want to decrypt
1674 1674
                     if ($post_option === 'decrypt') {
1675 1675
                         prepareFileWithDefuse(
1676 1676
                             'decrypt',
1677
-                            $SETTINGS['path_to_upload_folder'] . '/' . $file_info['file'],
1678
-                            $SETTINGS['path_to_upload_folder'] . '/defuse_temp_' . $file_info['file'],
1677
+                            $SETTINGS['path_to_upload_folder'].'/'.$file_info['file'],
1678
+                            $SETTINGS['path_to_upload_folder'].'/defuse_temp_'.$file_info['file'],
1679 1679
                             $SETTINGS
1680 1680
                         );
1681 1681
                         // Case where we want to encrypt
1682 1682
                     } elseif ($post_option === 'encrypt') {
1683 1683
                         prepareFileWithDefuse(
1684 1684
                             'encrypt',
1685
-                            $SETTINGS['path_to_upload_folder'] . '/' . $file_info['file'],
1686
-                            $SETTINGS['path_to_upload_folder'] . '/defuse_temp_' . $file_info['file'],
1685
+                            $SETTINGS['path_to_upload_folder'].'/'.$file_info['file'],
1686
+                            $SETTINGS['path_to_upload_folder'].'/defuse_temp_'.$file_info['file'],
1687 1687
                             $SETTINGS
1688 1688
                         );
1689 1689
                     }
1690 1690
                     // Do file cleanup
1691
-                    fileDelete($SETTINGS['path_to_upload_folder'] . '/' . $file_info['file'], $SETTINGS);
1691
+                    fileDelete($SETTINGS['path_to_upload_folder'].'/'.$file_info['file'], $SETTINGS);
1692 1692
                     rename(
1693
-                        $SETTINGS['path_to_upload_folder'] . '/defuse_temp_' . $file_info['file'],
1694
-                        $SETTINGS['path_to_upload_folder'] . '/' . $file_info['file']
1693
+                        $SETTINGS['path_to_upload_folder'].'/defuse_temp_'.$file_info['file'],
1694
+                        $SETTINGS['path_to_upload_folder'].'/'.$file_info['file']
1695 1695
                     );
1696 1696
 
1697 1697
                     // store in DB
@@ -1726,8 +1726,8 @@  discard block
 block discarded – undo
1726 1726
                 $post_option === 'attachments-decrypt' ? 'clear' : 'encrypted'
1727 1727
             );
1728 1728
 
1729
-            $message = $lang->get('last_execution') . ' ' .
1730
-                date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) time()) .
1729
+            $message = $lang->get('last_execution').' '.
1730
+                date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) time()).
1731 1731
                 '<i class="fas fa-check text-success ml-2 mr-3"></i>';
1732 1732
         }
1733 1733
 
@@ -1821,7 +1821,7 @@  discard block
 block discarded – undo
1821 1821
             $post_id = filter_var($dataReceived['id'], FILTER_SANITIZE_NUMBER_INT);
1822 1822
 
1823 1823
             DB::query(
1824
-                'DELETE FROM ' . prefixTable('api') . ' WHERE increment_id = %i',
1824
+                'DELETE FROM '.prefixTable('api').' WHERE increment_id = %i',
1825 1825
                 $post_id
1826 1826
             );
1827 1827
         }
@@ -1916,7 +1916,7 @@  discard block
 block discarded – undo
1916 1916
             // Delete existing key
1917 1917
         } elseif (null !== $post_action && $post_action === 'delete') {
1918 1918
             $post_id = filter_var($dataReceived['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
1919
-            DB::query('DELETE FROM ' . prefixTable('api') . ' WHERE increment_id=%i', $post_id);
1919
+            DB::query('DELETE FROM '.prefixTable('api').' WHERE increment_id=%i', $post_id);
1920 1920
         }
1921 1921
 
1922 1922
         echo prepareExchangedData(
@@ -1931,7 +1931,7 @@  discard block
 block discarded – undo
1931 1931
 
1932 1932
     case 'save_api_status':
1933 1933
         // Do query
1934
-        DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'api');
1934
+        DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'api');
1935 1935
         $counter = DB::count();
1936 1936
         if ($counter === 0) {
1937 1937
             DB::insert(
@@ -1958,7 +1958,7 @@  discard block
 block discarded – undo
1958 1958
 
1959 1959
     case 'run_duo_config_check':
1960 1960
         //Libraries call
1961
-        require_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
1961
+        require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
1962 1962
         // Check KEY
1963 1963
         if ($post_key !== $superGlobal->get('key', 'SESSION')) {
1964 1964
             echo prepareExchangedData(
@@ -2001,7 +2001,7 @@  discard block
 block discarded – undo
2001 2001
             echo prepareExchangedData(
2002 2002
                     array(
2003 2003
                         'error' => true,
2004
-                        'message' => $lang->get('duo_config_error') . "<br/>Duo: " . $e->getMessage(),
2004
+                        'message' => $lang->get('duo_config_error')."<br/>Duo: ".$e->getMessage(),
2005 2005
                     ),
2006 2006
                     'encode'
2007 2007
             );
@@ -2021,7 +2021,7 @@  discard block
 block discarded – undo
2021 2021
                 $duo_error = $lang->get('duo_error_secure');
2022 2022
                 $data["duo_check"] = "failed";
2023 2023
             }*/
2024
-            $duo_error = $lang->get('duo_error_check_config') . "<br/>Duo: " . $e->getMessage();
2024
+            $duo_error = $lang->get('duo_error_check_config')."<br/>Duo: ".$e->getMessage();
2025 2025
             echo prepareExchangedData(
2026 2026
                     array(
2027 2027
                         'error' => true,
@@ -2066,7 +2066,7 @@  discard block
 block discarded – undo
2066 2066
         } else {
2067 2067
             $tmp = 1;
2068 2068
         }
2069
-        DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'google_authentication');
2069
+        DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'google_authentication');
2070 2070
         $counter = DB::count();
2071 2071
         if ($counter === 0) {
2072 2072
             DB::insert(
@@ -2092,7 +2092,7 @@  discard block
 block discarded – undo
2092 2092
 
2093 2093
         // ga_website_name
2094 2094
         if (is_null($dataReceived['ga_website_name']) === false) {
2095
-            DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'ga_website_name');
2095
+            DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'ga_website_name');
2096 2096
             $counter = DB::count();
2097 2097
             if ($counter === 0) {
2098 2098
                 DB::insert(
@@ -2123,7 +2123,7 @@  discard block
 block discarded – undo
2123 2123
         }
2124 2124
 
2125 2125
         // send data
2126
-        echo '[{"result" : "' . addslashes($LANG['done']) . '" , "error" : ""}]';
2126
+        echo '[{"result" : "'.addslashes($LANG['done']).'" , "error" : ""}]';
2127 2127
         break;
2128 2128
 
2129 2129
     case 'save_agses_options':
@@ -2146,7 +2146,7 @@  discard block
 block discarded – undo
2146 2146
 
2147 2147
         // agses_hosted_url
2148 2148
         if (!is_null($dataReceived['agses_hosted_url'])) {
2149
-            DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'agses_hosted_url');
2149
+            DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'agses_hosted_url');
2150 2150
             $counter = DB::count();
2151 2151
             if ($counter === 0) {
2152 2152
                 DB::insert(
@@ -2175,7 +2175,7 @@  discard block
 block discarded – undo
2175 2175
 
2176 2176
         // agses_hosted_id
2177 2177
         if (!is_null($dataReceived['agses_hosted_id'])) {
2178
-            DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'agses_hosted_id');
2178
+            DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'agses_hosted_id');
2179 2179
             $counter = DB::count();
2180 2180
             if ($counter === 0) {
2181 2181
                 DB::insert(
@@ -2204,7 +2204,7 @@  discard block
 block discarded – undo
2204 2204
 
2205 2205
         // agses_hosted_apikey
2206 2206
         if (!is_null($dataReceived['agses_hosted_apikey'])) {
2207
-            DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'agses_hosted_apikey');
2207
+            DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'agses_hosted_apikey');
2208 2208
             $counter = DB::count();
2209 2209
             if ($counter === 0) {
2210 2210
                 DB::insert(
@@ -2232,7 +2232,7 @@  discard block
 block discarded – undo
2232 2232
         }
2233 2233
 
2234 2234
         // send data
2235
-        echo '[{"result" : "' . addslashes($LANG['done']) . '" , "error" : ""}]';
2235
+        echo '[{"result" : "'.addslashes($LANG['done']).'" , "error" : ""}]';
2236 2236
         break;
2237 2237
 
2238 2238
     case 'save_option_change':
@@ -2272,7 +2272,7 @@  discard block
 block discarded – undo
2272 2272
 
2273 2273
         // Check if setting is already in DB. If NO then insert, if YES then update.
2274 2274
         $data = DB::query(
2275
-            'SELECT * FROM ' . prefixTable('misc') . '
2275
+            'SELECT * FROM '.prefixTable('misc').'
2276 2276
             WHERE type = %s AND intitule = %s',
2277 2277
             'admin',
2278 2278
             $post_field
@@ -2294,7 +2294,7 @@  discard block
 block discarded – undo
2294 2294
                     array(
2295 2295
                         'valeur' => time(),
2296 2296
                         'type' => 'admin',
2297
-                        'intitule' => $post_field . '_time',
2297
+                        'intitule' => $post_field.'_time',
2298 2298
                     )
2299 2299
                 );
2300 2300
             }
@@ -2312,10 +2312,10 @@  discard block
 block discarded – undo
2312 2312
             if ($post_field === 'send_stats') {
2313 2313
                 // Check if previous time exists, if not them insert this value in DB
2314 2314
                 DB::query(
2315
-                    'SELECT * FROM ' . prefixTable('misc') . '
2315
+                    'SELECT * FROM '.prefixTable('misc').'
2316 2316
                     WHERE type = %s AND intitule = %s',
2317 2317
                     'admin',
2318
-                    $post_field . '_time'
2318
+                    $post_field.'_time'
2319 2319
                 );
2320 2320
                 $counter = DB::count();
2321 2321
                 if ($counter === 0) {
@@ -2324,7 +2324,7 @@  discard block
 block discarded – undo
2324 2324
                         array(
2325 2325
                             'valeur' => 0,
2326 2326
                             'type' => 'admin',
2327
-                            'intitule' => $post_field . '_time',
2327
+                            'intitule' => $post_field.'_time',
2328 2328
                         )
2329 2329
                     );
2330 2330
                 } else {
@@ -2344,13 +2344,13 @@  discard block
 block discarded – undo
2344 2344
         // special Cases
2345 2345
         if ($post_field === 'cpassman_url') {
2346 2346
             // update also jsUrl for CSFP protection
2347
-            $jsUrl = $post_value . '/includes/libraries/csrfp/js/csrfprotector.js';
2347
+            $jsUrl = $post_value.'/includes/libraries/csrfp/js/csrfprotector.js';
2348 2348
             $csrfp_file = '../includes/libraries/csrfp/libs/csrfp.config.php';
2349 2349
             $data = file_get_contents($csrfp_file);
2350 2350
             $posJsUrl = strpos($data, '"jsUrl" => "');
2351 2351
             $posEndLine = strpos($data, '",', $posJsUrl);
2352 2352
             $line = substr($data, $posJsUrl, ($posEndLine - $posJsUrl + 2));
2353
-            $newdata = str_replace($line, '"jsUrl" => "' . filter_var($jsUrl, FILTER_SANITIZE_FULL_SPECIAL_CHARS) . '",', $data);
2353
+            $newdata = str_replace($line, '"jsUrl" => "'.filter_var($jsUrl, FILTER_SANITIZE_FULL_SPECIAL_CHARS).'",', $data);
2354 2354
             file_put_contents($csrfp_file, $newdata);
2355 2355
         } elseif ($post_field === 'restricted_to_input' && (int) $post_value === 0) {
2356 2356
             DB::update(
@@ -2379,7 +2379,7 @@  discard block
 block discarded – undo
2379 2379
         echo prepareExchangedData(
2380 2380
             array(
2381 2381
                 'error' => false,
2382
-                'misc' => $counter . ' ; ' . $SETTINGS[$post_field],
2382
+                'misc' => $counter.' ; '.$SETTINGS[$post_field],
2383 2383
                 'message' => empty($post_translate) === false ? $lang->get($post_translate) : '',
2384 2384
             ),
2385 2385
             'encode'
@@ -2422,7 +2422,7 @@  discard block
 block discarded – undo
2422 2422
 
2423 2423
         // send statistics
2424 2424
         if (null !== $post_status) {
2425
-            DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'send_stats');
2425
+            DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'send_stats');
2426 2426
             $counter = DB::count();
2427 2427
             if ($counter === 0) {
2428 2428
                 DB::insert(
@@ -2454,7 +2454,7 @@  discard block
 block discarded – undo
2454 2454
 
2455 2455
         // send statistics items
2456 2456
         if (null !== $post_list) {
2457
-            DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'send_statistics_items');
2457
+            DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'send_statistics_items');
2458 2458
             $counter = DB::count();
2459 2459
             if ($counter === 0) {
2460 2460
                 DB::insert(
@@ -2501,7 +2501,7 @@  discard block
 block discarded – undo
2501 2501
             break;
2502 2502
         }
2503 2503
 
2504
-        if (DB::query("SHOW TABLES LIKE '" . prefixTable('sk_reencrypt_backup') . "'")) {
2504
+        if (DB::query("SHOW TABLES LIKE '".prefixTable('sk_reencrypt_backup')."'")) {
2505 2505
             if (DB::count() === 1) {
2506 2506
                 echo 1;
2507 2507
             } else {
@@ -2539,7 +2539,7 @@  discard block
 block discarded – undo
2539 2539
 
2540 2540
         $rows = DB::query(
2541 2541
             'SELECT id, title
2542
-                FROM ' . prefixTable('roles_title') . '
2542
+                FROM ' . prefixTable('roles_title').'
2543 2543
                 ORDER BY title ASC'
2544 2544
         );
2545 2545
         foreach ($rows as $record) {
Please login to merge, or discard this patch.
api/Model/Database.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         try {
32 32
             $this->connection = new \mysqli(DB_HOST, DB_USER, DB_PASSWD_CLEAR, DB_NAME);
33 33
 
34
-            if ( mysqli_connect_errno()) {
34
+            if (mysqli_connect_errno()) {
35 35
                 throw new Exception("Could not connect to database.");   
36 36
             }
37 37
         } catch (Exception $e) {
@@ -39,37 +39,37 @@  discard block
 block discarded – undo
39 39
         }           
40 40
     }
41 41
 
42
-    public function select($query = "" , $params = [])
42
+    public function select($query = "", $params = [])
43 43
     {
44 44
         try {
45
-            $stmt = $this->executeStatement( $query , $params );
45
+            $stmt = $this->executeStatement($query, $params);
46 46
             $result = $stmt->get_result()->fetch_all(MYSQLI_ASSOC);               
47 47
             $stmt->close();
48 48
 
49 49
             return $result;
50
-        } catch(Exception $e) {
51
-            throw New Exception( $e->getMessage() );
50
+        } catch (Exception $e) {
51
+            throw New Exception($e->getMessage());
52 52
         }
53 53
     }
54 54
 
55
-    private function executeStatement($query = "" , $params = [])
55
+    private function executeStatement($query = "", $params = [])
56 56
     {
57 57
         try {
58
-            $stmt = $this->connection->prepare( $query );
58
+            $stmt = $this->connection->prepare($query);
59 59
 
60
-            if($stmt === false) {
61
-                throw New Exception("Unable to do prepared statement: " . $query);
60
+            if ($stmt === false) {
61
+                throw New Exception("Unable to do prepared statement: ".$query);
62 62
             }
63 63
 
64
-            if( $params ) {
64
+            if ($params) {
65 65
                 $stmt->bind_param($params[0], $params[1]);
66 66
             }
67 67
 
68 68
             $stmt->execute();
69 69
 
70 70
             return $stmt;
71
-        } catch(Exception $e) {
72
-            throw New Exception( $e->getMessage() );
71
+        } catch (Exception $e) {
72
+            throw New Exception($e->getMessage());
73 73
         }   
74 74
     }
75 75
 }
76 76
\ No newline at end of file
Please login to merge, or discard this patch.