Passed
Push — master ( 3254be...12c274 )
by Nils
06:09
created
sources/logs.datatables.php 1 patch
Spacing   +24 added lines, -26 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
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     
169 169
     // Output
170 170
     $sOutput = '{';
171
-    $sOutput .= '"sEcho": '. $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
171
+    $sOutput .= '"sEcho": '.$request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
172 172
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
173 173
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
174 174
     $sOutput .= '"aaData": ';
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 
242 242
     // Output
243 243
     $sOutput = '{';
244
-    $sOutput .= '"sEcho": '. $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
244
+    $sOutput .= '"sEcho": '.$request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
245 245
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
246 246
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
247 247
     $sOutput .= '"aaData": ';
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 
315 315
     // Output
316 316
     $sOutput = '{';
317
-    $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
317
+    $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
318 318
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
319 319
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
320 320
     $sOutput .= '"aaData": ';
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 
388 388
     // Output
389 389
     $sOutput = '{';
390
-    $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
390
+    $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
391 391
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
392 392
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
393 393
     $sOutput .= '"aaData": [ ';
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 
491 491
     // Output
492 492
     $sOutput = '{';
493
-    $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
493
+    $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
494 494
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
495 495
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
496 496
     $sOutput .= '"aaData": [ ';
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
         $iTotal = 0;
574 574
     }
575 575
     $sOutput = '{';
576
-    $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
576
+    $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
577 577
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
578 578
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
579 579
     $sOutput .= '"aaData": ';
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
 
650 650
     // Output
651 651
     $sOutput = '{';
652
-    $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
652
+    $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
653 653
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
654 654
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
655 655
     $sOutput .= '"aaData": ';
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 
719 719
     // Output
720 720
     $sOutput = '{';
721
-    $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
721
+    $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
722 722
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
723 723
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
724 724
     $sOutput .= '"aaData": ';
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 
792 792
     // Output
793 793
     $sOutput = '{';
794
-    $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
794
+    $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
795 795
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
796 796
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
797 797
     $sOutput .= '"aaData": ';
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
             FROM '.prefixTable('background_tasks').' AS p 
869 869
             LEFT JOIN '.prefixTable('users').' AS u ON %l
870 870
             WHERE %l ORDER BY %l %l LIMIT %i, %i';
871
-    $params = ['u.id = json_extract(p.arguments, "$[0]")',$sWhere, $orderColumn, $orderDirection, $sLimitStart, $sLimitLength];
871
+    $params = ['u.id = json_extract(p.arguments, "$[0]")', $sWhere, $orderColumn, $orderDirection, $sLimitStart, $sLimitLength];
872 872
 
873 873
     // Get the records
874 874
     $rows = DB::query($sql, ...$params);
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
 
877 877
     // Output
878 878
     $sOutput = '{';
879
-    $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
879
+    $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
880 880
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
881 881
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
882 882
     $sOutput .= '"aaData": ';
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
         //col1
892 892
         $sOutput .= '"<span data-done=\"'.$record['is_in_progress'].'\" data-type=\"'.$record['process_type'].'\" data-process-id=\"'.$record['increment_id'].'\"></span>", ';
893 893
         //col2
894
-        $sOutput .= '"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['created_at']).'", ';
894
+        $sOutput .= '"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['created_at']).'", ';
895 895
         //col3
896 896
         //$sOutput .= '"'.($record['updated_at'] === '' ? '-' : date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['updated_at'])).'", ';
897 897
         $sOutput .= '"<div class=\"progress mt-2\"><div class=\"progress-bar\" style=\"width: '.$subtaskProgress.'\">'.$subtaskProgress.'</div></div>", ';
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
         // col5
902 902
         if (in_array($record['process_type'], array('create_user_keys', 'item_copy')) === true) {
903 903
             $data_user = DB::queryFirstRow(
904
-                'SELECT name, lastname FROM ' . prefixTable('users') . '
904
+                'SELECT name, lastname FROM '.prefixTable('users').'
905 905
                 WHERE id = %i',
906 906
                 json_decode($record['arguments'], true)['new_user_id']
907 907
             );
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
     FROM '.prefixTable('background_tasks').' AS p 
967 967
     LEFT JOIN '.prefixTable('users').' AS u ON %l
968 968
     WHERE %l ORDER BY %l %l LIMIT %i, %i';
969
-    $params = ['u.id = json_extract(p.arguments, "$[0]")',$sWhere, $orderColumn, $orderDirection, $sLimitStart, $sLimitLength];
969
+    $params = ['u.id = json_extract(p.arguments, "$[0]")', $sWhere, $orderColumn, $orderDirection, $sLimitStart, $sLimitLength];
970 970
 
971 971
     // Get the records
972 972
     $rows = DB::query($sql, ...$params);
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
 
975 975
     // Output
976 976
     $sOutput = '{';
977
-    $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
977
+    $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
978 978
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
979 979
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
980 980
     $sOutput .= '"aaData": ';
@@ -992,13 +992,12 @@  discard block
 block discarded – undo
992 992
         $errMsg = preg_replace('/\r\n|\r|\n/', ' ', $errMsg);
993 993
         $sOutput .= json_encode($errMsg, JSON_UNESCAPED_UNICODE).', ';
994 994
         //col2
995
-        $sOutput .= '"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['created_at']).'", ';
995
+        $sOutput .= '"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['created_at']).'", ';
996 996
         //col3
997 997
         $sOutput .= is_null($record['started_at']) === false ?
998
-            ('"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['started_at']).'", ') :
999
-                ('"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['created_at']).'", ');
998
+            ('"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['started_at']).'", ') : ('"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['created_at']).'", ');
1000 999
         //col4
1001
-        $sOutput .= '"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['finished_at']).'", '; 
1000
+        $sOutput .= '"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['finished_at']).'", '; 
1002 1001
         // col7
1003 1002
         $sOutput .= '"'.gmdate('H:i:s', (int) $record['finished_at'] - (is_null($record['started_at']) === false ? (int) $record['started_at'] : (int) $record['created_at'])).'",';
1004 1003
         //col5
@@ -1021,11 +1020,10 @@  discard block
 block discarded – undo
1021 1020
         // col6
1022 1021
         $arguments = json_decode($record['arguments'], true);
1023 1022
         $newUserId = array_key_exists('new_user_id', $arguments) ? 
1024
-            $arguments['new_user_id'] : 
1025
-            (array_key_exists('user_id', $arguments) ? $arguments['user_id'] : null);
1023
+            $arguments['new_user_id'] : (array_key_exists('user_id', $arguments) ? $arguments['user_id'] : null);
1026 1024
         if ($record['process_type'] === 'create_user_keys' && is_null($newUserId) === false && empty($newUserId) === false) {
1027 1025
             $data_user = DB::queryFirstRow(
1028
-                'SELECT name, lastname, login FROM ' . prefixTable('users') . '
1026
+                'SELECT name, lastname, login FROM '.prefixTable('users').'
1029 1027
                 WHERE id = %i',
1030 1028
                 $newUserId
1031 1029
             );
@@ -1041,7 +1039,7 @@  discard block
 block discarded – undo
1041 1039
         } elseif ($record['process_type'] === 'user_build_cache_tree') {
1042 1040
             $user = json_decode($record['arguments'], true)['user_id'];
1043 1041
             $data_user = DB::queryFirstRow(
1044
-                'SELECT name, lastname, login FROM ' . prefixTable('users') . '
1042
+                'SELECT name, lastname, login FROM '.prefixTable('users').'
1045 1043
                 WHERE id = %i',
1046 1044
                 $user
1047 1045
             );
@@ -1075,7 +1073,7 @@  discard block
 block discarded – undo
1075 1073
 {
1076 1074
     $subtasks = DB::query(
1077 1075
         'SELECT *
1078
-        FROM ' . prefixTable('background_subtasks') . '
1076
+        FROM ' . prefixTable('background_subtasks').'
1079 1077
         WHERE task_id = %i',
1080 1078
         $id
1081 1079
     );
@@ -1091,5 +1089,5 @@  discard block
 block discarded – undo
1091 1089
         $i++;
1092 1090
     }
1093 1091
 
1094
-    return ($finished_nb !== 0 ? pourcentage($finished_nb, $nb, 100) : 0) .'%';
1092
+    return ($finished_nb !== 0 ? pourcentage($finished_nb, $nb, 100) : 0).'%';
1095 1093
 }
Please login to merge, or discard this patch.
sources/items.queries.php 1 patch
Spacing   +282 added lines, -283 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 ) {
80 80
     // Not allowed page
81 81
     $session->set('system-error_code', ERR_NOT_ALLOWED);
82
-    include $SETTINGS['cpassman_dir'] . '/error.php';
82
+    include $SETTINGS['cpassman_dir'].'/error.php';
83 83
     exit;
84 84
 }
85 85
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     date_default_timezone_set('UTC');
105 105
 }
106 106
 
107
-require_once $SETTINGS['cpassman_dir'] . '/includes/language/' . $session->get('user-language') . '.php';
107
+require_once $SETTINGS['cpassman_dir'].'/includes/language/'.$session->get('user-language').'.php';
108 108
 header('Content-type: text/html; charset=utf-8');
109 109
 header('Cache-Control: no-cache, must-revalidate');
110 110
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
             // About special settings
367 367
             $dataFolderSettings = DB::queryFirstRow(
368 368
                 'SELECT bloquer_creation, bloquer_modification, personal_folder
369
-                FROM ' . prefixTable('nested_tree') . ' 
369
+                FROM ' . prefixTable('nested_tree').' 
370 370
                 WHERE id = %i',
371 371
                 $inputData['folderId']
372 372
             );
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
             // Get folder complexity
384 384
             $folderComplexity = DB::queryFirstRow(
385 385
                 'SELECT valeur
386
-                FROM ' . prefixTable('misc') . '
386
+                FROM ' . prefixTable('misc').'
387 387
                 WHERE type = %s AND intitule = %i',
388 388
                 'complex',
389 389
                 $inputData['folderId']
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
             $itemExists = 0;
409 409
             $newID = '';
410 410
             $data = DB::queryFirstRow(
411
-                'SELECT * FROM ' . prefixTable('items') . '
411
+                'SELECT * FROM '.prefixTable('items').'
412 412
                 WHERE label = %s AND inactif = %i',
413 413
                 $inputData['label'],
414 414
                 0
@@ -489,8 +489,8 @@  discard block
 block discarded – undo
489 489
                     (int) $post_folder_is_personal,
490 490
                     (int) $newID,
491 491
                     $cryptedStuff['objectKey'],
492
-                    true,   // only for the item creator
493
-                    false,  // no delete all
492
+                    true, // only for the item creator
493
+                    false, // no delete all
494 494
                 );
495 495
 
496 496
                 // update fields
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
                             // should we encrypt the data
504 504
                             $dataTmp = DB::queryFirstRow(
505 505
                                 'SELECT encrypted_data
506
-                                FROM ' . prefixTable('categories') . '
506
+                                FROM ' . prefixTable('categories').'
507 507
                                 WHERE id = %i',
508 508
                                 $field['id']
509 509
                             );
@@ -532,8 +532,8 @@  discard block
 block discarded – undo
532 532
                                     (int) $post_folder_is_personal,
533 533
                                     (int) $newObjectId,
534 534
                                     $cryptedStuff['objectKey'],
535
-                                    true,   // only for the item creator
536
-                                    false,  // delete all
535
+                                    true, // only for the item creator
536
+                                    false, // delete all
537 537
                                 );
538 538
 
539 539
                                 array_push(
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
                 ) {
570 570
                     DB::queryFirstRow(
571 571
                         'SELECT *
572
-                        FROM ' . prefixTable('templates') . '
572
+                        FROM ' . prefixTable('templates').'
573 573
                         WHERE item_id = %i',
574 574
                         $newID
575 575
                     );
@@ -638,11 +638,11 @@  discard block
 block discarded – undo
638 638
                 ) {
639 639
                     foreach ($post_restricted_to as $userRest) {
640 640
                         if (empty($userRest) === false) {
641
-                            $dataTmp = DB::queryFirstRow('SELECT login FROM ' . prefixTable('users') . ' WHERE id= %i', $userRest);
641
+                            $dataTmp = DB::queryFirstRow('SELECT login FROM '.prefixTable('users').' WHERE id= %i', $userRest);
642 642
                             if (empty($listOfRestricted)) {
643 643
                                 $listOfRestricted = $dataTmp['login'];
644 644
                             } else {
645
-                                $listOfRestricted .= ';' . $dataTmp['login'];
645
+                                $listOfRestricted .= ';'.$dataTmp['login'];
646 646
                             }
647 647
                         }
648 648
                     }
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
                             if (empty($userRest) === false) {
659 659
                                 $dataTmp = DB::queryFirstRow(
660 660
                                     'SELECT login
661
-                                    FROM ' . prefixTable('users') . '
661
+                                    FROM ' . prefixTable('users').'
662 662
                                     WHERE id= %i',
663 663
                                     $userRest
664 664
                                 );
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
                                 if (empty($oldRestrictionList) === true) {
667 667
                                     $oldRestrictionList = $dataTmp['login'];
668 668
                                 } else {
669
-                                    $oldRestrictionList .= ';' . $dataTmp['login'];
669
+                                    $oldRestrictionList .= ';'.$dataTmp['login'];
670 670
                                 }
671 671
                             }
672 672
                         }
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
                 if (empty($post_uploaded_file_id) === false) {
730 730
                     $rows = DB::query(
731 731
                         'SELECT id
732
-                        FROM ' . prefixTable('files') . '
732
+                        FROM ' . prefixTable('files').'
733 733
                         WHERE id_item = %s',
734 734
                         $post_uploaded_file_id
735 735
                     );
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
                                     $lang->get('email_subject_item_updated'),
786 786
                                     str_replace(
787 787
                                         array('#label', '#link'),
788
-                                            array($path, $SETTINGS['email_server_url'] . '/index.php?page=items&group=' . $inputData['folderId'] . '&id=' . $newID . $lang['email_body3']),
788
+                                            array($path, $SETTINGS['email_server_url'].'/index.php?page=items&group='.$inputData['folderId'].'&id='.$newID.$lang['email_body3']),
789 789
                                             $lang->get('new_item_email_body')
790 790
                                     ),
791 791
                                     $emailAddress,
@@ -889,11 +889,11 @@  discard block
 block discarded – undo
889 889
         // Prepare variables
890 890
         $itemInfos = array();
891 891
         $inputData['label'] = isset($dataReceived['label']) && is_string($dataReceived['label']) ? filter_var($dataReceived['label'], FILTER_SANITIZE_FULL_SPECIAL_CHARS) : '';
892
-        $post_url = isset($dataReceived['url'])=== true ? filter_var(htmlspecialchars_decode($dataReceived['url']), FILTER_SANITIZE_URL) : '';
892
+        $post_url = isset($dataReceived['url']) === true ? filter_var(htmlspecialchars_decode($dataReceived['url']), FILTER_SANITIZE_URL) : '';
893 893
         $post_password = $original_pw = isset($dataReceived['pw']) && is_string($dataReceived['pw']) ? htmlspecialchars_decode($dataReceived['pw']) : '';
894 894
         $post_login = isset($dataReceived['login']) && is_string($dataReceived['login']) ? filter_var(htmlspecialchars_decode($dataReceived['login']), FILTER_SANITIZE_FULL_SPECIAL_CHARS) : '';
895
-        $post_tags = isset($dataReceived['tags'])=== true ? htmlspecialchars($dataReceived['tags']) : '';
896
-        $post_email = isset($dataReceived['email'])=== true ? filter_var(htmlspecialchars_decode($dataReceived['email']), FILTER_SANITIZE_EMAIL) : '';
895
+        $post_tags = isset($dataReceived['tags']) === true ? htmlspecialchars($dataReceived['tags']) : '';
896
+        $post_email = isset($dataReceived['email']) === true ? filter_var(htmlspecialchars_decode($dataReceived['email']), FILTER_SANITIZE_EMAIL) : '';
897 897
         $post_template_id = (int) filter_var($dataReceived['template_id'], FILTER_SANITIZE_NUMBER_INT);
898 898
         $inputData['itemId'] = (int) filter_var($dataReceived['id'], FILTER_SANITIZE_NUMBER_INT);
899 899
         $post_anyone_can_modify = (int) filter_var($dataReceived['anyone_can_modify'], FILTER_SANITIZE_NUMBER_INT);
@@ -924,8 +924,7 @@  discard block
 block discarded – undo
924 924
         $post_to_be_deleted_after_date = isset($dataReceived['to_be_deleted_after_date']) === true ? filter_var(
925 925
                 $dataReceived['to_be_deleted_after_date'],
926 926
                 FILTER_SANITIZE_FULL_SPECIAL_CHARS
927
-            ) :
928
-            '';
927
+            ) : '';
929 928
         $post_fields = (filter_var_array(
930 929
             $dataReceived['fields'],
931 930
             FILTER_SANITIZE_FULL_SPECIAL_CHARS
@@ -985,7 +984,7 @@  discard block
 block discarded – undo
985 984
         // About special settings
986 985
         $dataFolderSettings = DB::queryFirstRow(
987 986
             'SELECT bloquer_creation, bloquer_modification, personal_folder, title
988
-            FROM ' . prefixTable('nested_tree') . ' 
987
+            FROM ' . prefixTable('nested_tree').' 
989 988
             WHERE id = %i',
990 989
             $inputData['folderId']
991 990
         );
@@ -1001,7 +1000,7 @@  discard block
 block discarded – undo
1001 1000
         // Get folder complexity
1002 1001
         $folderComplexity = DB::queryFirstRow(
1003 1002
             'SELECT valeur
1004
-            FROM ' . prefixTable('misc') . '
1003
+            FROM ' . prefixTable('misc').'
1005 1004
             WHERE type = %s AND intitule = %i',
1006 1005
             'complex',
1007 1006
             $inputData['folderId']
@@ -1047,8 +1046,8 @@  discard block
 block discarded – undo
1047 1046
         $dataItem = DB::queryFirstRow(
1048 1047
             'SELECT i.*,
1049 1048
             IFNULL(l.id_user, 0) AS id_user
1050
-            FROM ' . prefixTable('items') . ' as i
1051
-            LEFT JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id AND l.action = %s)
1049
+            FROM ' . prefixTable('items').' as i
1050
+            LEFT JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id AND l.action = %s)
1052 1051
             WHERE i.id=%i',
1053 1052
             'at_creation',
1054 1053
             $inputData['itemId']
@@ -1090,7 +1089,7 @@  discard block
 block discarded – undo
1090 1089
         // Does the user has the sharekey for this item?
1091 1090
         DB::query(
1092 1091
             'SELECT *
1093
-            FROM ' . prefixTable('sharekeys_items') . '
1092
+            FROM ' . prefixTable('sharekeys_items').'
1094 1093
             WHERE object_id = %i AND user_id = %s',
1095 1094
             $inputData['itemId'],
1096 1095
             $session->get('user-id')
@@ -1151,9 +1150,9 @@  discard block
 block discarded – undo
1151 1150
                 'SELECT i.id as id, i.label as label, i.description as description, i.pw as pw, i.url as url, i.id_tree as id_tree, i.perso as perso, i.login as login, 
1152 1151
                 i.inactif as inactif, i.restricted_to as restricted_to, i.anyone_can_modify as anyone_can_modify, i.email as email, i.notification as notification,
1153 1152
                 u.login as user_login, u.email as user_email
1154
-                FROM ' . prefixTable('items') . ' as i
1155
-                LEFT JOIN ' . prefixTable('log_items') . ' as l ON (i.id=l.id_item AND l.action = %s)
1156
-                LEFT JOIN ' . prefixTable('users') . ' as u ON (u.id=l.id_user)
1153
+                FROM ' . prefixTable('items').' as i
1154
+                LEFT JOIN ' . prefixTable('log_items').' as l ON (i.id=l.id_item AND l.action = %s)
1155
+                LEFT JOIN ' . prefixTable('users').' as u ON (u.id=l.id_user)
1157 1156
                 WHERE i.id=%i',
1158 1157
                 'at_creation',
1159 1158
                 $inputData['itemId']
@@ -1162,7 +1161,7 @@  discard block
 block discarded – undo
1162 1161
             // Should we log a password change?
1163 1162
             $userKey = DB::queryFirstRow(
1164 1163
                 'SELECT share_key
1165
-                FROM ' . prefixTable('sharekeys_items') . '
1164
+                FROM ' . prefixTable('sharekeys_items').'
1166 1165
                 WHERE user_id = %i AND object_id = %i',
1167 1166
                 $session->get('user-id'),
1168 1167
                 $inputData['itemId']
@@ -1226,12 +1225,12 @@  discard block
 block discarded – undo
1226 1225
                     (int) $post_folder_is_personal,
1227 1226
                     (int) $inputData['itemId'],
1228 1227
                     $encrypted_password_key,
1229
-                    true,   // only for the item creator
1230
-                    true,   // delete all
1228
+                    true, // only for the item creator
1229
+                    true, // delete all
1231 1230
                 );
1232 1231
 
1233 1232
                 // Create a task to create sharekeys for users
1234
-                if (WIP=== true) error_log('createTaskForItem - new password for this item - '.$post_password ." -- ". $pw);
1233
+                if (WIP === true) error_log('createTaskForItem - new password for this item - '.$post_password." -- ".$pw);
1235 1234
                 $tasksToBePerformed = ['item_password'];
1236 1235
                 $encryptionTaskIsRequested = true;
1237 1236
             } else {
@@ -1242,7 +1241,7 @@  discard block
 block discarded – undo
1242 1241
             // Get list of tags
1243 1242
             $itemTags = DB::queryFirstColumn(
1244 1243
                 'SELECT tag
1245
-                FROM ' . prefixTable('tags') . '
1244
+                FROM ' . prefixTable('tags').'
1246 1245
                 WHERE item_id = %i',
1247 1246
                 $inputData['itemId']
1248 1247
             );
@@ -1288,7 +1287,7 @@  discard block
 block discarded – undo
1288 1287
                     $session->get('user-id'),
1289 1288
                     'at_modification',
1290 1289
                     $session->get('user-login'),
1291
-                    'at_tag : ' . implode(' ', $itemTags) . ' => ' . $post_tags
1290
+                    'at_tag : '.implode(' ', $itemTags).' => '.$post_tags
1292 1291
                 );
1293 1292
             }
1294 1293
 
@@ -1333,8 +1332,8 @@  discard block
 block discarded – undo
1333 1332
                             'SELECT c.id AS id, c.title AS title, i.data AS data, i.data_iv AS data_iv,
1334 1333
                             i.encryption_type AS encryption_type, c.encrypted_data AS encrypted_data,
1335 1334
                             c.masked AS masked, i.id AS field_item_id
1336
-                            FROM ' . prefixTable('categories_items') . ' AS i
1337
-                            INNER JOIN ' . prefixTable('categories') . ' AS c ON (i.field_id=c.id)
1335
+                            FROM ' . prefixTable('categories_items').' AS i
1336
+                            INNER JOIN ' . prefixTable('categories').' AS c ON (i.field_id=c.id)
1338 1337
                             WHERE i.field_id = %i AND i.item_id = %i',
1339 1338
                             $field['id'],
1340 1339
                             $inputData['itemId']
@@ -1350,7 +1349,7 @@  discard block
 block discarded – undo
1350 1349
                             // Perform new query
1351 1350
                             $dataTmpCat = DB::queryFirstRow(
1352 1351
                                 'SELECT id, title, encrypted_data, masked
1353
-                                FROM ' . prefixTable('categories') . '
1352
+                                FROM ' . prefixTable('categories').'
1354 1353
                                 WHERE id = %i',
1355 1354
                                 $field['id']
1356 1355
                             );
@@ -1380,8 +1379,8 @@  discard block
 block discarded – undo
1380 1379
                                     (int) $post_folder_is_personal,
1381 1380
                                     (int) $newId,
1382 1381
                                     $cryptedStuff['objectKey'],
1383
-                                    true,   // only for the item creator
1384
-                                    true,   // delete all
1382
+                                    true, // only for the item creator
1383
+                                    true, // delete all
1385 1384
                                 );
1386 1385
 
1387 1386
                                 // update value
@@ -1431,7 +1430,7 @@  discard block
 block discarded – undo
1431 1430
                                 $session->get('user-id'),
1432 1431
                                 'at_modification',
1433 1432
                                 $session->get('user-login'),
1434
-                                'at_field : ' . $dataTmpCat['title'] . ' : ' . $field['value']
1433
+                                'at_field : '.$dataTmpCat['title'].' : '.$field['value']
1435 1434
                             );
1436 1435
                         } else {
1437 1436
                             // Case where the field already exists
@@ -1440,7 +1439,7 @@  discard block
 block discarded – undo
1440 1439
                                 // Get user sharekey for this field
1441 1440
                                 $userKey = DB::queryFirstRow(
1442 1441
                                     'SELECT share_key
1443
-                                    FROM ' . prefixTable('sharekeys_fields') . '
1442
+                                    FROM ' . prefixTable('sharekeys_fields').'
1444 1443
                                     WHERE user_id = %i AND object_id = %i',
1445 1444
                                     $session->get('user-id'),
1446 1445
                                     $dataTmpCat['field_item_id']
@@ -1479,8 +1478,8 @@  discard block
 block discarded – undo
1479 1478
                                         (int) $post_folder_is_personal,
1480 1479
                                         (int) $dataTmpCat['field_item_id'],
1481 1480
                                         $cryptedStuff['objectKey'],
1482
-                                        true,   // only for the item creator
1483
-                                        true,   // delete all
1481
+                                        true, // only for the item creator
1482
+                                        true, // delete all
1484 1483
                                     );
1485 1484
 
1486 1485
                                     if ($encryptedFieldIsChanged === false) {
@@ -1522,7 +1521,7 @@  discard block
 block discarded – undo
1522 1521
                                     $session->get('user-id'),
1523 1522
                                     'at_modification',
1524 1523
                                     $session->get('user-login'),
1525
-                                    'at_field : ' . $dataTmpCat['title'] . ' => ' . $oldVal
1524
+                                    'at_field : '.$dataTmpCat['title'].' => '.$oldVal
1526 1525
                                 );
1527 1526
                             }
1528 1527
                         }
@@ -1576,7 +1575,7 @@  discard block
 block discarded – undo
1576 1575
             ) {
1577 1576
                 DB::queryFirstRow(
1578 1577
                     'SELECT *
1579
-                    FROM ' . prefixTable('templates') . '
1578
+                    FROM ' . prefixTable('templates').'
1580 1579
                     WHERE item_id = %i',
1581 1580
                     $inputData['itemId']
1582 1581
                 );
@@ -1619,7 +1618,7 @@  discard block
 block discarded – undo
1619 1618
                 // check if elem exists in Table. If not add it or update it.
1620 1619
                 DB::query(
1621 1620
                     'SELECT *
1622
-                    FROM ' . prefixTable('automatic_del') . '
1621
+                    FROM ' . prefixTable('automatic_del').'
1623 1622
                     WHERE item_id = %i',
1624 1623
                     $inputData['itemId']
1625 1624
                 );
@@ -1646,7 +1645,7 @@  discard block
 block discarded – undo
1646 1645
                         // Store updates performed
1647 1646
                         array_push(
1648 1647
                             $arrayOfChanges,
1649
-                            $lang->get('automatic_deletion_engaged') . ': ' . $lang->get('enabled')
1648
+                            $lang->get('automatic_deletion_engaged').': '.$lang->get('enabled')
1650 1649
                         );
1651 1650
 
1652 1651
                         // update LOG
@@ -1689,7 +1688,7 @@  discard block
 block discarded – undo
1689 1688
                         // Store updates performed
1690 1689
                         array_push(
1691 1690
                             $arrayOfChanges,
1692
-                            $lang->get('automatic_deletion_engaged') . ': ' . $lang->get('disabled')
1691
+                            $lang->get('automatic_deletion_engaged').': '.$lang->get('disabled')
1693 1692
                         );
1694 1693
 
1695 1694
                         // update LOG
@@ -1717,7 +1716,7 @@  discard block
 block discarded – undo
1717 1716
                     if (empty($userId) === false) {
1718 1717
                         $dataTmp = DB::queryFirstRow(
1719 1718
                             'SELECT id, name, lastname
1720
-                            FROM ' . prefixTable('users') . '
1719
+                            FROM ' . prefixTable('users').'
1721 1720
                             WHERE id= %i',
1722 1721
                             $userId
1723 1722
                         );
@@ -1725,7 +1724,7 @@  discard block
 block discarded – undo
1725 1724
                         // Add to array
1726 1725
                         array_push(
1727 1726
                             $arrayOfUsersRestriction,
1728
-                            $dataTmp['name'] . ' ' . $dataTmp['lastname']
1727
+                            $dataTmp['name'].' '.$dataTmp['lastname']
1729 1728
                         );
1730 1729
                         array_push(
1731 1730
                             $arrayOfUsersIdRestriction,
@@ -1756,8 +1755,8 @@  discard block
 block discarded – undo
1756 1755
                 // get values before deleting them
1757 1756
                 $rows = DB::query(
1758 1757
                     'SELECT t.title, t.id AS id
1759
-                    FROM ' . prefixTable('roles_title') . ' as t
1760
-                    INNER JOIN ' . prefixTable('restriction_to_roles') . ' as r ON (t.id=r.role_id)
1758
+                    FROM ' . prefixTable('roles_title').' as t
1759
+                    INNER JOIN ' . prefixTable('restriction_to_roles').' as r ON (t.id=r.role_id)
1761 1760
                     WHERE r.item_id = %i
1762 1761
                     ORDER BY t.title ASC',
1763 1762
                     $inputData['itemId']
@@ -1791,7 +1790,7 @@  discard block
 block discarded – undo
1791 1790
                         );
1792 1791
                         $dataTmp = DB::queryFirstRow(
1793 1792
                             'SELECT title
1794
-                            FROM ' . prefixTable('roles_title') . '
1793
+                            FROM ' . prefixTable('roles_title').'
1795 1794
                             WHERE id = %i',
1796 1795
                             $role
1797 1796
                         );
@@ -1819,7 +1818,7 @@  discard block
 block discarded – undo
1819 1818
             // Get current status
1820 1819
             $otpStatus = DB::queryFirstRow(
1821 1820
                 'SELECT enabled as otp_is_enabled, phone_number, secret
1822
-                FROM ' . prefixTable('items_otp') . '
1821
+                FROM ' . prefixTable('items_otp').'
1823 1822
                 WHERE item_id = %i',
1824 1823
                 $inputData['itemId']
1825 1824
             );
@@ -1833,7 +1832,7 @@  discard block
 block discarded – undo
1833 1832
                     'decrypt'
1834 1833
                 )['string'];
1835 1834
             } else {
1836
-                $currentsecret='';
1835
+                $currentsecret = '';
1837 1836
             }
1838 1837
 
1839 1838
             // If OTP secret provided then encrypt it
@@ -1883,7 +1882,7 @@  discard block
 block discarded – undo
1883 1882
                         $session->get('user-id'),
1884 1883
                         'at_modification',
1885 1884
                         $session->get('user-login'),
1886
-                        'at_otp_status:' . ((int) $post_otp_is_enabled === 0 ? 'disabled' : 'enabled')
1885
+                        'at_otp_status:'.((int) $post_otp_is_enabled === 0 ? 'disabled' : 'enabled')
1887 1886
                     );
1888 1887
                 }
1889 1888
                 if ($otpStatus['phone_number'] !== $post_otp_phone_number) {
@@ -1894,7 +1893,7 @@  discard block
 block discarded – undo
1894 1893
                         $session->get('user-id'),
1895 1894
                         'at_modification',
1896 1895
                         $session->get('user-login'),
1897
-                        'at_phone_number:' . $otpStatus['phone_number'] . ' => ' . $post_otp_phone_number
1896
+                        'at_phone_number:'.$otpStatus['phone_number'].' => '.$post_otp_phone_number
1898 1897
                     );
1899 1898
                 }
1900 1899
                 if ($currentsecret !== $post_otp_secret) {
@@ -1943,8 +1942,8 @@  discard block
 block discarded – undo
1943 1942
                     $session->get('user-id'),
1944 1943
                     'at_modification',
1945 1944
                     $session->get('user-login'),
1946
-                    'at_restriction : ' . (count($diffUsersRestiction) > 0 ?
1947
-                        implode(', ', $arrayOfUsersRestriction) . (count($diffRolesRestiction) > 0 ? ', ' : '') : '') . (count($diffRolesRestiction) > 0 ? implode(', ', $arrayOfRestrictionRoles) : '')
1945
+                    'at_restriction : '.(count($diffUsersRestiction) > 0 ?
1946
+                        implode(', ', $arrayOfUsersRestriction).(count($diffRolesRestiction) > 0 ? ', ' : '') : '').(count($diffRolesRestiction) > 0 ? implode(', ', $arrayOfRestrictionRoles) : '')
1948 1947
                 );
1949 1948
             }
1950 1949
 
@@ -1964,7 +1963,7 @@  discard block
 block discarded – undo
1964 1963
                     $session->get('user-id'),
1965 1964
                     'at_modification',
1966 1965
                     $session->get('user-login'),
1967
-                    'at_label : ' . $data['label'] . ' => ' . $inputData['label']
1966
+                    'at_label : '.$data['label'].' => '.$inputData['label']
1968 1967
                 );
1969 1968
             }
1970 1969
             // LOGIN
@@ -1983,7 +1982,7 @@  discard block
 block discarded – undo
1983 1982
                     $session->get('user-id'),
1984 1983
                     'at_modification',
1985 1984
                     $session->get('user-login'),
1986
-                    'at_login : ' . $data['login'] . ' => ' . $post_login
1985
+                    'at_login : '.$data['login'].' => '.$post_login
1987 1986
                 );
1988 1987
             }
1989 1988
             // EMAIL
@@ -2002,7 +2001,7 @@  discard block
 block discarded – undo
2002 2001
                     $session->get('user-id'),
2003 2002
                     'at_modification',
2004 2003
                     $session->get('user-login'),
2005
-                    'at_email : ' . $data['email'] . ' => ' . $post_email
2004
+                    'at_email : '.$data['email'].' => '.$post_email
2006 2005
                 );
2007 2006
             }
2008 2007
             // URL
@@ -2021,7 +2020,7 @@  discard block
 block discarded – undo
2021 2020
                     $session->get('user-id'),
2022 2021
                     'at_modification',
2023 2022
                     $session->get('user-login'),
2024
-                    'at_url : ' . $data['url'] . ' => ' . $post_url
2023
+                    'at_url : '.$data['url'].' => '.$post_url
2025 2024
                 );
2026 2025
             }
2027 2026
             // DESCRIPTION
@@ -2047,7 +2046,7 @@  discard block
 block discarded – undo
2047 2046
             // FOLDER
2048 2047
             if ((int) $data['id_tree'] !== (int) $inputData['folderId']) {
2049 2048
                 // Get name of folders
2050
-                $dataTmp = DB::query('SELECT title FROM ' . prefixTable('nested_tree') . ' WHERE id IN %li', array($data['id_tree'], $inputData['folderId']));
2049
+                $dataTmp = DB::query('SELECT title FROM '.prefixTable('nested_tree').' WHERE id IN %li', array($data['id_tree'], $inputData['folderId']));
2051 2050
 
2052 2051
                 // Store updates performed
2053 2052
                 array_push(
@@ -2063,7 +2062,7 @@  discard block
 block discarded – undo
2063 2062
                     $session->get('user-id'),
2064 2063
                     'at_modification',
2065 2064
                     $session->get('user-login'),
2066
-                    'at_category : ' . $dataTmp[0]['title'] . ' => ' . $dataTmp[1]['title']
2065
+                    'at_category : '.$dataTmp[0]['title'].' => '.$dataTmp[1]['title']
2067 2066
                 );
2068 2067
             }
2069 2068
             // ANYONE_CAN_MODIFY
@@ -2071,7 +2070,7 @@  discard block
 block discarded – undo
2071 2070
                 // Store updates performed
2072 2071
                 array_push(
2073 2072
                     $arrayOfChanges,
2074
-                    $lang->get('at_anyoneconmodify') . ': ' . ((int) $post_anyone_can_modify === 0 ? $lang->get('disabled') : $lang->get('enabled'))
2073
+                    $lang->get('at_anyoneconmodify').': '.((int) $post_anyone_can_modify === 0 ? $lang->get('disabled') : $lang->get('enabled'))
2075 2074
                 );
2076 2075
 
2077 2076
                 // Log
@@ -2082,7 +2081,7 @@  discard block
 block discarded – undo
2082 2081
                     $session->get('user-id'),
2083 2082
                     'at_modification',
2084 2083
                     $session->get('user-login'),
2085
-                    'at_anyoneconmodify : ' . ((int) $post_anyone_can_modify === 0 ? 'disabled' : 'enabled')
2084
+                    'at_anyoneconmodify : '.((int) $post_anyone_can_modify === 0 ? 'disabled' : 'enabled')
2086 2085
                 );
2087 2086
             }
2088 2087
 
@@ -2090,8 +2089,8 @@  discard block
 block discarded – undo
2090 2089
             $dataItem = DB::queryFirstRow(
2091 2090
                 'SELECT i.*,
2092 2091
             IFNULL(l.id_user, 0) AS id_user
2093
-            FROM ' . prefixTable('items') . ' as i
2094
-            LEFT JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id AND l.action = %s)
2092
+            FROM ' . prefixTable('items').' as i
2093
+            LEFT JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id AND l.action = %s)
2095 2094
             WHERE i.id=%i',
2096 2095
             'at_creation',
2097 2096
             $inputData['itemId']
@@ -2100,8 +2099,8 @@  discard block
 block discarded – undo
2100 2099
             $history = '';
2101 2100
             $rows = DB::query(
2102 2101
                 'SELECT l.date as date, l.action as action, l.raison as raison, u.login as login
2103
-                FROM ' . prefixTable('log_items') . ' as l
2104
-                LEFT JOIN ' . prefixTable('users') . ' as u ON (l.id_user=u.id)
2102
+                FROM ' . prefixTable('log_items').' as l
2103
+                LEFT JOIN ' . prefixTable('users').' as u ON (l.id_user=u.id)
2105 2104
                 WHERE l.action <> %s AND id_item=%s',
2106 2105
                 'at_shown',
2107 2106
                 $inputData['itemId']
@@ -2110,14 +2109,14 @@  discard block
 block discarded – undo
2110 2109
                 if ($record['raison'] === NULL) continue;
2111 2110
                 $reason = explode(':', $record['raison']);
2112 2111
                 if (count($reason) > 0) {
2113
-                    $sentence = date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['date']) . ' - '
2114
-                        . $record['login'] . ' - ' . $lang->get($record['action']) . ' - '
2115
-                        . (empty($record['raison']) === false ? (count($reason) > 1 ? $lang->get(trim($reason[0])) . ' : ' . $reason[1]
2112
+                    $sentence = date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['date']).' - '
2113
+                        . $record['login'].' - '.$lang->get($record['action']).' - '
2114
+                        . (empty($record['raison']) === false ? (count($reason) > 1 ? $lang->get(trim($reason[0])).' : '.$reason[1]
2116 2115
                             : $lang->get(trim($reason[0]))) : '');
2117 2116
                     if (empty($history)) {
2118 2117
                         $history = $sentence;
2119 2118
                     } else {
2120
-                        $history .= '<br />' . $sentence;
2119
+                        $history .= '<br />'.$sentence;
2121 2120
                     }
2122 2121
                 }
2123 2122
             }
@@ -2255,7 +2254,7 @@  discard block
 block discarded – undo
2255 2254
         ) {
2256 2255
             // load the original record into an array
2257 2256
             $originalRecord = DB::queryFirstRow(
2258
-                'SELECT * FROM ' . prefixTable('items') . '
2257
+                'SELECT * FROM '.prefixTable('items').'
2259 2258
                 WHERE id = %i',
2260 2259
                 $inputData['itemId']
2261 2260
             );
@@ -2274,7 +2273,7 @@  discard block
 block discarded – undo
2274 2273
 
2275 2274
             // Load the destination folder record into an array
2276 2275
             $dataDestination = DB::queryFirstRow(
2277
-                'SELECT personal_folder FROM ' . prefixTable('nested_tree') . '
2276
+                'SELECT personal_folder FROM '.prefixTable('nested_tree').'
2278 2277
                 WHERE id = %i',
2279 2278
                 $post_dest_id
2280 2279
             );
@@ -2282,7 +2281,7 @@  discard block
 block discarded – undo
2282 2281
             // Get the ITEM object key for the user
2283 2282
             $userKey = DB::queryFirstRow(
2284 2283
                 'SELECT share_key
2285
-                FROM ' . prefixTable('sharekeys_items') . '
2284
+                FROM ' . prefixTable('sharekeys_items').'
2286 2285
                 WHERE user_id = %i AND object_id = %i',
2287 2286
                 $session->get('user-id'),
2288 2287
                 $inputData['itemId']
@@ -2359,8 +2358,8 @@  discard block
 block discarded – undo
2359 2358
             // Manage Custom Fields
2360 2359
             $rows = DB::query(
2361 2360
                 'SELECT ci.id AS id, ci.data AS data, ci.field_id AS field_id, c.encrypted_data AS encrypted_data
2362
-                FROM ' . prefixTable('categories_items') . ' AS ci
2363
-                INNER JOIN ' . prefixTable('categories') . ' AS c ON (c.id = ci.field_id)
2361
+                FROM ' . prefixTable('categories_items').' AS ci
2362
+                INNER JOIN ' . prefixTable('categories').' AS c ON (c.id = ci.field_id)
2364 2363
                 WHERE ci.item_id = %i',
2365 2364
                 $inputData['itemId']
2366 2365
             );
@@ -2372,7 +2371,7 @@  discard block
 block discarded – undo
2372 2371
                     // Get user key
2373 2372
                     $userKey = DB::queryFirstRow(
2374 2373
                         'SELECT share_key
2375
-                        FROM ' . prefixTable('sharekeys_fields') . '
2374
+                        FROM ' . prefixTable('sharekeys_fields').'
2376 2375
                         WHERE user_id = %i AND object_id = %i',
2377 2376
                         $session->get('user-id'),
2378 2377
                         $field['id']
@@ -2439,15 +2438,15 @@  discard block
 block discarded – undo
2439 2438
             $rows = DB::query(
2440 2439
                 'SELECT f.id AS id, f.file AS file, f.name AS name, f.status AS status, f.extension AS extension,
2441 2440
                 f.size AS size, f.type AS type, s.share_key AS share_key
2442
-                FROM ' . prefixTable('files') . ' AS f
2443
-                INNER JOIN ' . prefixTable('sharekeys_files') . ' AS s ON (f.id = s.object_id)
2441
+                FROM ' . prefixTable('files').' AS f
2442
+                INNER JOIN ' . prefixTable('sharekeys_files').' AS s ON (f.id = s.object_id)
2444 2443
                 WHERE s.user_id = %i AND f.id_item = %i',
2445 2444
                 $session->get('user-id'),
2446 2445
                 $inputData['itemId']
2447 2446
             );
2448 2447
             foreach ($rows as $record) {
2449 2448
                 // Check if file still exists
2450
-                if (file_exists($SETTINGS['path_to_upload_folder'] . DIRECTORY_SEPARATOR . TP_FILE_PREFIX . base64_decode($record['file'])) === true) {
2449
+                if (file_exists($SETTINGS['path_to_upload_folder'].DIRECTORY_SEPARATOR.TP_FILE_PREFIX.base64_decode($record['file'])) === true) {
2451 2450
                     // Step1 - decrypt the file
2452 2451
                     // deepcode ignore PT: path is sanitized inside decryptFile()
2453 2452
                     $fileContent = decryptFile(
@@ -2458,8 +2457,8 @@  discard block
 block discarded – undo
2458 2457
 
2459 2458
                     // Step2 - create file
2460 2459
                     // deepcode ignore InsecureHash: md5 is used jonly for file name in order to get a hashed value in database
2461
-                    $newFileName = md5(time() . '_' . $record['id']) . '.' . $record['extension'];
2462
-                    $outstream = fopen($SETTINGS['path_to_upload_folder'] . DIRECTORY_SEPARATOR . $newFileName, 'ab');
2460
+                    $newFileName = md5(time().'_'.$record['id']).'.'.$record['extension'];
2461
+                    $outstream = fopen($SETTINGS['path_to_upload_folder'].DIRECTORY_SEPARATOR.$newFileName, 'ab');
2463 2462
                     if ($outstream === false) {
2464 2463
                         echo prepareExchangedData(
2465 2464
                             array(
@@ -2532,7 +2531,7 @@  discard block
 block discarded – undo
2532 2531
 
2533 2532
             // -------------------------
2534 2533
             // Add specific restrictions
2535
-            $rows = DB::query('SELECT * FROM ' . prefixTable('restriction_to_roles') . ' WHERE item_id = %i', $inputData['itemId']);
2534
+            $rows = DB::query('SELECT * FROM '.prefixTable('restriction_to_roles').' WHERE item_id = %i', $inputData['itemId']);
2536 2535
             foreach ($rows as $record) {
2537 2536
                 DB::insert(
2538 2537
                     prefixTable('restriction_to_roles'),
@@ -2544,7 +2543,7 @@  discard block
 block discarded – undo
2544 2543
             }
2545 2544
 
2546 2545
             // Add Tags
2547
-            $rows = DB::query('SELECT * FROM ' . prefixTable('tags') . ' WHERE item_id = %i', $inputData['itemId']);
2546
+            $rows = DB::query('SELECT * FROM '.prefixTable('tags').' WHERE item_id = %i', $inputData['itemId']);
2548 2547
             foreach ($rows as $record) {
2549 2548
                 DB::insert(
2550 2549
                     prefixTable('tags'),
@@ -2646,7 +2645,7 @@  discard block
 block discarded – undo
2646 2645
         // then we can show it
2647 2646
         $item_deleted = DB::queryFirstRow(
2648 2647
             'SELECT *
2649
-            FROM ' . prefixTable('log_items') . '
2648
+            FROM ' . prefixTable('log_items').'
2650 2649
             WHERE id_item = %i AND action = %s
2651 2650
             ORDER BY date DESC
2652 2651
             LIMIT 0, 1',
@@ -2657,7 +2656,7 @@  discard block
 block discarded – undo
2657 2656
 
2658 2657
         $item_restored = DB::queryFirstRow(
2659 2658
             'SELECT *
2660
-            FROM ' . prefixTable('log_items') . '
2659
+            FROM ' . prefixTable('log_items').'
2661 2660
             WHERE id_item = %i AND action = %s
2662 2661
             ORDER BY date DESC
2663 2662
             LIMIT 0, 1',
@@ -2682,8 +2681,8 @@  discard block
 block discarded – undo
2682 2681
         $dataItem = DB::queryFirstRow(
2683 2682
             'SELECT i.*,
2684 2683
             IFNULL(l.id_user, 0) AS id_user
2685
-            FROM ' . prefixTable('items') . ' as i
2686
-            LEFT JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id AND l.action = %s)
2684
+            FROM ' . prefixTable('items').' as i
2685
+            LEFT JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id AND l.action = %s)
2687 2686
             WHERE i.id=%i',
2688 2687
             'at_creation',
2689 2688
             $inputData['id']
@@ -2692,7 +2691,7 @@  discard block
 block discarded – undo
2692 2691
         // Notification
2693 2692
         DB::queryFirstRow(
2694 2693
             'SELECT *
2695
-            FROM ' . prefixTable('notification') . '
2694
+            FROM ' . prefixTable('notification').'
2696 2695
             WHERE item_id = %i AND user_id = %i',
2697 2696
             $inputData['id'],
2698 2697
             $session->get('user-id')
@@ -2711,7 +2710,7 @@  discard block
 block discarded – undo
2711 2710
 
2712 2711
         // manage case of API user
2713 2712
         if ($dataItem['id_user'] === API_USER_ID) {
2714
-            $arrData['author'] = 'API [' . $dataItem['description'] . ']';
2713
+            $arrData['author'] = 'API ['.$dataItem['description'].']';
2715 2714
             $arrData['id_user'] = API_USER_ID;
2716 2715
             $arrData['author_email'] = '';
2717 2716
             $arrData['notification_status'] = false;
@@ -2721,7 +2720,7 @@  discard block
 block discarded – undo
2721 2720
         $tags = array();
2722 2721
         $rows = DB::query(
2723 2722
             'SELECT tag
2724
-            FROM ' . prefixTable('tags') . '
2723
+            FROM ' . prefixTable('tags').'
2725 2724
             WHERE item_id = %i',
2726 2725
             $inputData['id']
2727 2726
         );
@@ -2745,7 +2744,7 @@  discard block
 block discarded – undo
2745 2744
         // Check if user has a role that is accepted
2746 2745
         $rows_tmp = DB::query(
2747 2746
             'SELECT role_id
2748
-            FROM ' . prefixTable('restriction_to_roles') . '
2747
+            FROM ' . prefixTable('restriction_to_roles').'
2749 2748
             WHERE item_id=%i',
2750 2749
             $inputData['id']
2751 2750
         );
@@ -2759,7 +2758,7 @@  discard block
 block discarded – undo
2759 2758
         // Get the object key for the user
2760 2759
         $userKeys = DB::query(
2761 2760
             'SELECT share_key
2762
-            FROM ' . prefixTable('sharekeys_items') . '
2761
+            FROM ' . prefixTable('sharekeys_items').'
2763 2762
             WHERE user_id = %i AND object_id = %i',
2764 2763
             $session->get('user-id'),
2765 2764
             $inputData['id']
@@ -2872,8 +2871,8 @@  discard block
 block discarded – undo
2872 2871
                 // Add restriction if item is restricted to roles
2873 2872
                 $rows = DB::query(
2874 2873
                     'SELECT t.title, t.id
2875
-                    FROM ' . prefixTable('roles_title') . ' AS t
2876
-                    INNER JOIN ' . prefixTable('restriction_to_roles') . ' AS r ON (t.id=r.role_id)
2874
+                    FROM ' . prefixTable('roles_title').' AS t
2875
+                    INNER JOIN ' . prefixTable('restriction_to_roles').' AS r ON (t.id=r.role_id)
2877 2876
                     WHERE r.item_id = %i
2878 2877
                     ORDER BY t.title ASC',
2879 2878
                     $inputData['id']
@@ -2889,8 +2888,8 @@  discard block
 block discarded – undo
2889 2888
                 $tmp = array();
2890 2889
                 $rows = DB::query(
2891 2890
                     'SELECT k.label, k.id
2892
-                    FROM ' . prefixTable('kb_items') . ' as i
2893
-                    INNER JOIN ' . prefixTable('kb') . ' as k ON (i.kb_id=k.id)
2891
+                    FROM ' . prefixTable('kb_items').' as i
2892
+                    INNER JOIN ' . prefixTable('kb').' as k ON (i.kb_id=k.id)
2894 2893
                     WHERE i.item_id = %i
2895 2894
                     ORDER BY k.label ASC',
2896 2895
                     $inputData['id']
@@ -2973,7 +2972,7 @@  discard block
 block discarded – undo
2973 2972
                 $arrCatList = array();
2974 2973
                 $rows_tmp = DB::query(
2975 2974
                     'SELECT id_category
2976
-                    FROM ' . prefixTable('categories_folders') . '
2975
+                    FROM ' . prefixTable('categories_folders').'
2977 2976
                     WHERE id_folder=%i',
2978 2977
                     $inputData['folderId']
2979 2978
                 );
@@ -2988,8 +2987,8 @@  discard block
 block discarded – undo
2988 2987
                         'SELECT i.id AS id, i.field_id AS field_id, i.data AS data, i.item_id AS item_id,
2989 2988
                         i.encryption_type AS encryption_type, c.encrypted_data AS encrypted_data, c.parent_id AS parent_id,
2990 2989
                         c.type as field_type, c.masked AS field_masked, c.role_visibility AS role_visibility
2991
-                        FROM ' . prefixTable('categories_items') . ' AS i
2992
-                        INNER JOIN ' . prefixTable('categories') . ' AS c ON (i.field_id=c.id)
2990
+                        FROM ' . prefixTable('categories_items').' AS i
2991
+                        INNER JOIN ' . prefixTable('categories').' AS c ON (i.field_id=c.id)
2993 2992
                         WHERE i.item_id=%i AND c.parent_id IN %ls',
2994 2993
                         $inputData['id'],
2995 2994
                         $arrCatList
@@ -3000,7 +2999,7 @@  discard block
 block discarded – undo
3000 2999
                         //db::debugmode(true);
3001 3000
                         $userKey = DB::queryFirstRow(
3002 3001
                             'SELECT share_key
3003
-                            FROM ' . prefixTable('sharekeys_fields') . '
3002
+                            FROM ' . prefixTable('sharekeys_fields').'
3004 3003
                             WHERE user_id = %i AND object_id = %i',
3005 3004
                             $session->get('user-id'),
3006 3005
                             $row['id']
@@ -3018,7 +3017,7 @@  discard block
 block discarded – undo
3018 3017
                         } else if (DB::count() === 0 && (int) $row['encrypted_data'] === 0) {
3019 3018
                             // Data is not encrypted in DB
3020 3019
                             $fieldText = [
3021
-                                'string' => $row['data'],//#3945 - isBase64($row['data']) === true ? base64_decode($row['data']) : 
3020
+                                'string' => $row['data'], //#3945 - isBase64($row['data']) === true ? base64_decode($row['data']) : 
3022 3021
                                 'encrypted' => false,
3023 3022
                                 'error' => false,
3024 3023
                             ];
@@ -3063,7 +3062,7 @@  discard block
 block discarded – undo
3063 3062
             if (isset($SETTINGS['item_creation_templates']) && (int) $SETTINGS['item_creation_templates'] === 1) {
3064 3063
                 $rows_tmp = DB::queryFirstRow(
3065 3064
                     'SELECT category_id
3066
-                    FROM ' . prefixTable('templates') . '
3065
+                    FROM ' . prefixTable('templates').'
3067 3066
                     WHERE item_id = %i',
3068 3067
                     $inputData['id']
3069 3068
                 );
@@ -3080,7 +3079,7 @@  discard block
 block discarded – undo
3080 3079
             // Evaluate if item is ready for all users
3081 3080
             $rows_tmp = DB::queryFirstRow(
3082 3081
                 'SELECT finished_at
3083
-                FROM ' . prefixTable('background_tasks') . '
3082
+                FROM ' . prefixTable('background_tasks').'
3084 3083
                 WHERE item_id = %i',
3085 3084
                 $inputData['id']
3086 3085
             );
@@ -3097,7 +3096,7 @@  discard block
 block discarded – undo
3097 3096
                 // Is the Item to be deleted?
3098 3097
                 $dataDelete = DB::queryFirstRow(
3099 3098
                     'SELECT * 
3100
-                    FROM ' . prefixTable('automatic_del') . '
3099
+                    FROM ' . prefixTable('automatic_del').'
3101 3100
                     WHERE item_id = %i',
3102 3101
                     $inputData['id']
3103 3102
                 );
@@ -3178,14 +3177,14 @@  discard block
 block discarded – undo
3178 3177
                     if (empty($userRest) === false) {
3179 3178
                         $dataTmp = DB::queryFirstRow(
3180 3179
                             'SELECT login
3181
-                            FROM ' . prefixTable('users') . '
3180
+                            FROM ' . prefixTable('users').'
3182 3181
                             WHERE id= %i',
3183 3182
                             $userRest
3184 3183
                         );
3185 3184
                         if (empty($listOfRestricted)) {
3186 3185
                             $listOfRestricted = $dataTmp['login'];
3187 3186
                         } else {
3188
-                            $listOfRestricted .= ';' . $dataTmp['login'];
3187
+                            $listOfRestricted .= ';'.$dataTmp['login'];
3189 3188
                         }
3190 3189
                     }
3191 3190
                 }
@@ -3259,9 +3258,9 @@  discard block
 block discarded – undo
3259 3258
         // Load item data
3260 3259
         $dataItem = DB::queryFirstRow(
3261 3260
             'SELECT i.*, n.title AS folder_title, o.enabled AS otp_for_item_enabled, o.phone_number AS otp_phone_number, o.secret AS otp_secret
3262
-            FROM ' . prefixTable('items') . ' AS i
3263
-            INNER JOIN ' . prefixTable('nested_tree') . ' AS n ON (i.id_tree = n.id)
3264
-            LEFT JOIN ' . prefixTable('items_otp') . ' AS o ON (o.item_id = i.id)
3261
+            FROM ' . prefixTable('items').' AS i
3262
+            INNER JOIN ' . prefixTable('nested_tree').' AS n ON (i.id_tree = n.id)
3263
+            LEFT JOIN ' . prefixTable('items_otp').' AS o ON (o.item_id = i.id)
3265 3264
             WHERE i.id = %i',
3266 3265
             $inputData['id']
3267 3266
         );
@@ -3283,7 +3282,7 @@  discard block
 block discarded – undo
3283 3282
         // Check if user has a role that is accepted
3284 3283
         $rows_tmp = DB::query(
3285 3284
             'SELECT role_id
3286
-            FROM ' . prefixTable('restriction_to_roles') . '
3285
+            FROM ' . prefixTable('restriction_to_roles').'
3287 3286
             WHERE item_id=%i',
3288 3287
             $inputData['id']
3289 3288
         );
@@ -3315,12 +3314,12 @@  discard block
 block discarded – undo
3315 3314
             // launch query
3316 3315
             $rows = DB::query(
3317 3316
                 'SELECT id, name, file, extension, size
3318
-                FROM ' . prefixTable('files') . '
3317
+                FROM ' . prefixTable('files').'
3319 3318
                 WHERE id_item = %i AND confirmed = 1',
3320 3319
                 $inputData['id']
3321 3320
             );
3322 3321
             foreach ($rows as $record) {
3323
-                $filename = basename($record['name'], '.' . $record['extension']);
3322
+                $filename = basename($record['name'], '.'.$record['extension']);
3324 3323
                 $filename = isBase64($filename) === true ? base64_decode($filename) : $filename;
3325 3324
 
3326 3325
                 array_push(
@@ -3333,7 +3332,7 @@  discard block
 block discarded – undo
3333 3332
                         'is_image' => in_array(strtolower($record['extension']), TP_IMAGE_FILE_EXT) === true ? 1 : 0,
3334 3333
                         'id' => $record['id'],
3335 3334
                         'key' => $session->get('user-key_tmp'),
3336
-                        'internalFilename' => basename($record['name'], '.' . $record['extension']),
3335
+                        'internalFilename' => basename($record['name'], '.'.$record['extension']),
3337 3336
                     )
3338 3337
                 );
3339 3338
             }
@@ -3375,8 +3374,8 @@  discard block
 block discarded – undo
3375 3374
             $listOptionsForRoles = array();
3376 3375
             $rows = DB::query(
3377 3376
                 'SELECT r.role_id AS role_id, t.title AS title
3378
-                FROM ' . prefixTable('roles_values') . ' AS r
3379
-                INNER JOIN ' . prefixTable('roles_title') . ' AS t ON (r.role_id = t.id)
3377
+                FROM ' . prefixTable('roles_values').' AS r
3378
+                INNER JOIN ' . prefixTable('roles_title').' AS t ON (r.role_id = t.id)
3380 3379
                 WHERE r.folder_id = %i',
3381 3380
                 $dataItem['id_tree']
3382 3381
             );
@@ -3390,8 +3389,8 @@  discard block
 block discarded – undo
3390 3389
                 );
3391 3390
                 $rows2 = DB::query(
3392 3391
                     'SELECT DISTINCT u.id, u.login, u.email, u.name, u.lastname, ur.role_id AS fonction_id
3393
-                    FROM ' . prefixTable('users') . ' AS u
3394
-                    INNER JOIN ' . prefixTable('users_roles') . ' AS ur ON (u.id = ur.user_id)
3392
+                    FROM ' . prefixTable('users').' AS u
3393
+                    INNER JOIN ' . prefixTable('users_roles').' AS ur ON (u.id = ur.user_id)
3395 3394
                     WHERE ur.role_id = %i AND ur.source = %s',
3396 3395
                     $record['role_id'],
3397 3396
                     'manual'
@@ -3408,7 +3407,7 @@  discard block
 block discarded – undo
3408 3407
                                 array(
3409 3408
                                     'id' => (int) $record2['id'],
3410 3409
                                     'login' => $record2['login'],
3411
-                                    'name' => $record2['name'] . ' ' . $record2['lastname'],
3410
+                                    'name' => $record2['name'].' '.$record2['lastname'],
3412 3411
                                     'email' => $record2['email'],
3413 3412
                                 )
3414 3413
                             );
@@ -3427,16 +3426,16 @@  discard block
 block discarded – undo
3427 3426
                 $path = '';
3428 3427
                 foreach ($arbo as $elem) {
3429 3428
                     if (empty($path) === true) {
3430
-                        $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES) . ' ';
3429
+                        $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES).' ';
3431 3430
                     } else {
3432
-                        $path .= '&#8594; ' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
3431
+                        $path .= '&#8594; '.htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
3433 3432
                     }
3434 3433
                 }
3435 3434
                 // Build text to show user
3436 3435
                 if (empty($path) === true) {
3437 3436
                     $path = addslashes($dataItem['label']);
3438 3437
                 } else {
3439
-                    $path = addslashes($dataItem['label']) . ' (' . $path . ')';
3438
+                    $path = addslashes($dataItem['label']).' ('.$path.')';
3440 3439
                 }
3441 3440
 
3442 3441
                 // Add Admins to notification list if expected
@@ -3459,7 +3458,7 @@  discard block
 block discarded – undo
3459 3458
                         array(
3460 3459
                             addslashes($session->get('user-login')),
3461 3460
                             $path,
3462
-                            $SETTINGS['cpassman_url'] . '/index.php?page=items&group=' . $dataItem['id_tree'] . '&id=' . $dataItem['id'],
3461
+                            $SETTINGS['cpassman_url'].'/index.php?page=items&group='.$dataItem['id_tree'].'&id='.$dataItem['id'],
3463 3462
                         ),
3464 3463
                         $lang->get('email_on_open_notification_mail')
3465 3464
                     ),
@@ -3469,7 +3468,7 @@  discard block
 block discarded – undo
3469 3468
             }
3470 3469
 
3471 3470
             // has this item a change proposal
3472
-            DB::query('SELECT * FROM ' . prefixTable('items_change') . ' WHERE item_id = %i', $inputData['id']);
3471
+            DB::query('SELECT * FROM '.prefixTable('items_change').' WHERE item_id = %i', $inputData['id']);
3473 3472
             $returnArray['has_change_proposal'] = DB::count();
3474 3473
 
3475 3474
             // Setting
@@ -3480,7 +3479,7 @@  discard block
 block discarded – undo
3480 3479
             if (isset($SETTINGS['otv_is_enabled']) === true && (int) $SETTINGS['otv_is_enabled'] === 1) {
3481 3480
                 DB::query(
3482 3481
                     'SELECT *
3483
-                    FROM ' . prefixTable('otv') . '
3482
+                    FROM ' . prefixTable('otv').'
3484 3483
                     WHERE item_id = %i
3485 3484
                     AND time_limit > %i',
3486 3485
                     $inputData['id'],
@@ -3579,7 +3578,7 @@  discard block
 block discarded – undo
3579 3578
         // Load item data
3580 3579
         $data = DB::queryFirstRow(
3581 3580
             'SELECT id_tree, id, label
3582
-            FROM ' . prefixTable('items') . '
3581
+            FROM ' . prefixTable('items').'
3583 3582
             WHERE id = %i OR item_key = %s',
3584 3583
             $inputData['itemId'],
3585 3584
             $inputData['itemKey']
@@ -3670,7 +3669,7 @@  discard block
 block discarded – undo
3670 3669
         // Load item data
3671 3670
         $dataItem = DB::queryFirstRow(
3672 3671
             'SELECT secret, enabled
3673
-            FROM ' . prefixTable('items_otp') . '
3672
+            FROM ' . prefixTable('items_otp').'
3674 3673
             WHERE item_id = %i',
3675 3674
             $inputData['id']
3676 3675
         );
@@ -3752,13 +3751,13 @@  discard block
 block discarded – undo
3752 3751
 
3753 3752
         // Check if user is allowed to access this folder
3754 3753
         if (!in_array($inputData['folderId'], $session->get('user-accessible_folders'))) {
3755
-            echo '[{"error" : "' . $lang->get('error_not_allowed_to') . '"}]';
3754
+            echo '[{"error" : "'.$lang->get('error_not_allowed_to').'"}]';
3756 3755
             break;
3757 3756
         }
3758 3757
 
3759 3758
         // Check if title doesn't contains html codes
3760 3759
         if (preg_match_all('|<[^>]+>(.*)</[^>]+>|U', $title, $out)) {
3761
-            echo '[ { "error" : "' . $lang->get('error_html_codes') . '" } ]';
3760
+            echo '[ { "error" : "'.$lang->get('error_html_codes').'" } ]';
3762 3761
             break;
3763 3762
         }
3764 3763
         // check that title is not numeric
@@ -3769,9 +3768,9 @@  discard block
 block discarded – undo
3769 3768
 
3770 3769
         // Check if duplicate folders name are allowed
3771 3770
         if (isset($SETTINGS['duplicate_folder']) && $SETTINGS['duplicate_folder'] === '0') {
3772
-            $data = DB::queryFirstRow('SELECT id, title FROM ' . prefixTable('nested_tree') . ' WHERE title = %s', $title);
3771
+            $data = DB::queryFirstRow('SELECT id, title FROM '.prefixTable('nested_tree').' WHERE title = %s', $title);
3773 3772
             if (empty($data['id']) === false && $dataReceived['folder'] !== $data['id']) {
3774
-                echo '[ { "error" : "' . $lang->get('error_group_exist') . '" } ]';
3773
+                echo '[ { "error" : "'.$lang->get('error_group_exist').'" } ]';
3775 3774
                 break;
3776 3775
             }
3777 3776
         }
@@ -3779,7 +3778,7 @@  discard block
 block discarded – undo
3779 3778
         // query on folder
3780 3779
         $data = DB::queryFirstRow(
3781 3780
             'SELECT parent_id, personal_folder
3782
-            FROM ' . prefixTable('nested_tree') . '
3781
+            FROM ' . prefixTable('nested_tree').'
3783 3782
             WHERE id = %i',
3784 3783
             $inputData['folderId']
3785 3784
         );
@@ -3789,20 +3788,20 @@  discard block
 block discarded – undo
3789 3788
         if ($session->get('user-admin') !== 1 && $session->get('user-manager') !== 1 && $data['personal_folder'] === '0') {
3790 3789
             $data = DB::queryFirstRow(
3791 3790
                 'SELECT valeur
3792
-                FROM ' . prefixTable('misc') . '
3791
+                FROM ' . prefixTable('misc').'
3793 3792
                 WHERE intitule = %i AND type = %s',
3794 3793
                 $data['parent_id'],
3795 3794
                 'complex'
3796 3795
             );
3797 3796
             if (intval($dataReceived['complexity']) < intval($data['valeur'])) {
3798
-                echo '[ { "error" : "' . $lang->get('error_folder_complexity_lower_than_top_folder') . ' [<b>' . TP_PW_COMPLEXITY[$data['valeur']][1] . '</b>]"} ]';
3797
+                echo '[ { "error" : "'.$lang->get('error_folder_complexity_lower_than_top_folder').' [<b>'.TP_PW_COMPLEXITY[$data['valeur']][1].'</b>]"} ]';
3799 3798
                 break;
3800 3799
             }
3801 3800
         }
3802 3801
 
3803 3802
         // update Folders table
3804 3803
         $tmp = DB::queryFirstRow(
3805
-            'SELECT title, parent_id, personal_folder FROM ' . prefixTable('nested_tree') . ' WHERE id = %i',
3804
+            'SELECT title, parent_id, personal_folder FROM '.prefixTable('nested_tree').' WHERE id = %i',
3806 3805
             $dataReceived['folder']
3807 3806
         );
3808 3807
         if ($tmp['parent_id'] !== 0 || $tmp['title'] !== $session->get('user-id') || $tmp['personal_folder'] !== 1) {
@@ -3916,7 +3915,7 @@  discard block
 block discarded – undo
3916 3915
             $uniqueLoadData['path'] = $arr_arbo;
3917 3916
 
3918 3917
             // store last folder accessed in cookie
3919
-            $arr_cookie_options = array (
3918
+            $arr_cookie_options = array(
3920 3919
                 'expires' => time() + TP_ONE_DAY_SECONDS * 5,
3921 3920
                 'path' => '/', 
3922 3921
                 'secure' => true,
@@ -3931,7 +3930,7 @@  discard block
 block discarded – undo
3931 3930
             foreach ($session->get('user-roles_array') as $role) {
3932 3931
                 $roleQ = DB::queryFirstRow(
3933 3932
                     'SELECT allow_pw_change
3934
-                    FROM ' . prefixTable('roles_title') . '
3933
+                    FROM ' . prefixTable('roles_title').'
3935 3934
                     WHERE id = %i',
3936 3935
                     $role
3937 3936
                 );
@@ -3962,11 +3961,11 @@  discard block
 block discarded – undo
3962 3961
                 
3963 3962
                 foreach ($session->get('user-roles_array') as $role) {
3964 3963
                     $access = DB::queryFirstRow(
3965
-                        'SELECT type FROM ' . prefixTable('roles_values') . ' WHERE role_id = %i AND folder_id = %i',
3964
+                        'SELECT type FROM '.prefixTable('roles_values').' WHERE role_id = %i AND folder_id = %i',
3966 3965
                         $role,
3967 3966
                         $inputData['id']
3968 3967
                     );
3969
-                    if (DB::count()>0) {
3968
+                    if (DB::count() > 0) {
3970 3969
                         if ($access['type'] === 'R') {
3971 3970
                             array_push($arrTmp, 10);
3972 3971
                         } elseif ($access['type'] === 'W') {
@@ -4031,7 +4030,7 @@  discard block
 block discarded – undo
4031 4030
             } else {
4032 4031
                 DB::query(
4033 4032
                     'SELECT *
4034
-                    FROM ' . prefixTable('items') . '
4033
+                    FROM ' . prefixTable('items').'
4035 4034
                     WHERE inactif = %i',
4036 4035
                     0
4037 4036
                 );
@@ -4041,7 +4040,7 @@  discard block
 block discarded – undo
4041 4040
 
4042 4041
             // Get folder complexity
4043 4042
             $folderComplexity = DB::queryFirstRow(
4044
-                'SELECT valeur FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %i',
4043
+                'SELECT valeur FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %i',
4045 4044
                 'complex',
4046 4045
                 $inputData['id']
4047 4046
             );
@@ -4053,7 +4052,7 @@  discard block
 block discarded – undo
4053 4052
             if (isset($SETTINGS['item_extra_fields']) && (int) $SETTINGS['item_extra_fields'] === 1) {
4054 4053
                 $folderRow = DB::query(
4055 4054
                     'SELECT id_category
4056
-                    FROM ' . prefixTable('categories_folders') . '
4055
+                    FROM ' . prefixTable('categories_folders').'
4057 4056
                     WHERE id_folder = %i',
4058 4057
                     $inputData['id']
4059 4058
                 );
@@ -4109,8 +4108,8 @@  discard block
 block discarded – undo
4109 4108
                 $where->add('i.inactif=%i', 0);
4110 4109
                 $where->add('i.deleted_at IS NULL');
4111 4110
 
4112
-                $query_limit = ' LIMIT ' .
4113
-                    $start . ',' .
4111
+                $query_limit = ' LIMIT '.
4112
+                    $start.','.
4114 4113
                     $post_nb_items_to_display_once;
4115 4114
                     
4116 4115
                 $rows = DB::query(
@@ -4118,8 +4117,8 @@  discard block
 block discarded – undo
4118 4117
                     i.label, i.description, i.pw, i.login,
4119 4118
                     i.anyone_can_modify, i.id_tree AS tree_id, i.fa_icon,
4120 4119
                     n.renewal_period, i.url AS link, i.email
4121
-                    FROM ' . prefixTable('items') . ' AS i
4122
-                    INNER JOIN ' . prefixTable('nested_tree') . ' AS n ON (i.id_tree = n.id)
4120
+                    FROM ' . prefixTable('items').' AS i
4121
+                    INNER JOIN ' . prefixTable('nested_tree').' AS n ON (i.id_tree = n.id)
4123 4122
                     WHERE %l
4124 4123
                     ORDER BY i.label ASC' . $query_limit,
4125 4124
                     $where
@@ -4133,8 +4132,8 @@  discard block
 block discarded – undo
4133 4132
                     i.label, i.description, i.pw, i.login,
4134 4133
                     i.anyone_can_modify, i.id_tree AS tree_id, i.fa_icon,
4135 4134
                     n.renewal_period, i.url AS link, i.email
4136
-                    FROM ' . prefixTable('items') . ' AS i
4137
-                    INNER JOIN ' . prefixTable('nested_tree') . ' AS n ON (i.id_tree = n.id)
4135
+                    FROM ' . prefixTable('items').' AS i
4136
+                    INNER JOIN ' . prefixTable('nested_tree').' AS n ON (i.id_tree = n.id)
4138 4137
                     WHERE %l
4139 4138
                     ORDER BY i.label ASC',
4140 4139
                     $where
@@ -4164,7 +4163,7 @@  discard block
 block discarded – undo
4164 4163
                     $item_is_restricted_to_role = false;
4165 4164
                     DB::queryFirstRow(
4166 4165
                         'SELECT role_id
4167
-                        FROM ' . prefixTable('restriction_to_roles') . '
4166
+                        FROM ' . prefixTable('restriction_to_roles').'
4168 4167
                         WHERE item_id = %i',
4169 4168
                         $record['id']
4170 4169
                     );
@@ -4176,7 +4175,7 @@  discard block
 block discarded – undo
4176 4175
                     $user_is_included_in_role = false;
4177 4176
                     DB::query(
4178 4177
                         'SELECT role_id
4179
-                        FROM ' . prefixTable('restriction_to_roles') . '
4178
+                        FROM ' . prefixTable('restriction_to_roles').'
4180 4179
                         WHERE item_id = %i AND role_id IN %ls',
4181 4180
                         $record['id'],
4182 4181
                         $session->get('user-roles_array')
@@ -4201,11 +4200,11 @@  discard block
 block discarded – undo
4201 4200
                     }
4202 4201
 
4203 4202
                     // Get Expiration date
4204
-                    $sql = 'SELECT date FROM ' . prefixTable('log_items') 
4205
-                        . " WHERE action = 'at_creation' AND id_item=" . $record['id']
4206
-                        . ' union all SELECT date FROM '. prefixTable('log_items') 
4203
+                    $sql = 'SELECT date FROM '.prefixTable('log_items') 
4204
+                        . " WHERE action = 'at_creation' AND id_item=".$record['id']
4205
+                        . ' union all SELECT date FROM '.prefixTable('log_items') 
4207 4206
                         . " WHERE action = 'at_modification' AND raison = 'at_pw'
4208
-                        AND id_item=" . $record['id'] . " ORDER BY date DESC LIMIT 1";
4207
+                        AND id_item=" . $record['id']." ORDER BY date DESC LIMIT 1";
4209 4208
                     $record['date'] = DB::queryFirstRow($sql)['date'];
4210 4209
 
4211 4210
                     // Check if item is expired
@@ -4394,8 +4393,8 @@  discard block
 block discarded – undo
4394 4393
         if ((int) $start === 0) {
4395 4394
             DB::query(
4396 4395
                 'SELECT i.id
4397
-                FROM ' . prefixTable('items') . ' as i
4398
-                INNER JOIN ' . prefixTable('nested_tree') . ' as n ON (i.id_tree = n.id)
4396
+                FROM ' . prefixTable('items').' as i
4397
+                INNER JOIN ' . prefixTable('nested_tree').' as n ON (i.id_tree = n.id)
4399 4398
                 WHERE %l',
4400 4399
                 $where
4401 4400
             );
@@ -4455,8 +4454,8 @@  discard block
 block discarded – undo
4455 4454
         $dataItem = DB::queryFirstRow(
4456 4455
             'SELECT i.pw AS pw, s.share_key AS share_key, i.id AS id,
4457 4456
                     i.label AS label, i.id_tree AS id_tree
4458
-            FROM ' . prefixTable('items') . ' AS i
4459
-            INNER JOIN ' . prefixTable('sharekeys_items') . ' AS s ON (s.object_id = i.id)
4457
+            FROM ' . prefixTable('items').' AS i
4458
+            INNER JOIN ' . prefixTable('sharekeys_items').' AS s ON (s.object_id = i.id)
4460 4459
             WHERE user_id = %i AND (i.item_key = %s OR i.id = %i)',
4461 4460
             $session->get('user-id'),
4462 4461
             $inputData['itemKey'] ?? '',
@@ -4568,7 +4567,7 @@  discard block
 block discarded – undo
4568 4567
         // do query on this folder
4569 4568
         $data_this_folder = DB::queryFirstRow(
4570 4569
             'SELECT id, personal_folder, title
4571
-            FROM ' . prefixTable('nested_tree') . '
4570
+            FROM ' . prefixTable('nested_tree').'
4572 4571
             WHERE id = %s',
4573 4572
             $inputData['folderId']
4574 4573
         );
@@ -4608,8 +4607,8 @@  discard block
 block discarded – undo
4608 4607
         $visibilite = '';
4609 4608
         $data = DB::queryFirstRow(
4610 4609
             'SELECT m.valeur, n.personal_folder
4611
-            FROM ' . prefixTable('misc') . ' AS m
4612
-            INNER JOIN ' . prefixTable('nested_tree') . ' AS n ON (m.intitule = n.id)
4610
+            FROM ' . prefixTable('misc').' AS m
4611
+            INNER JOIN ' . prefixTable('nested_tree').' AS n ON (m.intitule = n.id)
4613 4612
             WHERE type=%s AND intitule = %s',
4614 4613
             'complex',
4615 4614
             $inputData['folderId']
@@ -4622,8 +4621,8 @@  discard block
 block discarded – undo
4622 4621
             // Prepare Item actual visibility (what Users/Roles can see it)
4623 4622
             $rows = DB::query(
4624 4623
                 'SELECT t.title
4625
-                FROM ' . prefixTable('roles_values') . ' as v
4626
-                INNER JOIN ' . prefixTable('roles_title') . ' as t ON (v.role_id = t.id)
4624
+                FROM ' . prefixTable('roles_values').' as v
4625
+                INNER JOIN ' . prefixTable('roles_title').' as t ON (v.role_id = t.id)
4627 4626
                 WHERE v.folder_id = %i
4628 4627
                 GROUP BY title',
4629 4628
                 $inputData['folderId']
@@ -4632,7 +4631,7 @@  discard block
 block discarded – undo
4632 4631
                 if (empty($visibilite)) {
4633 4632
                     $visibilite = $record['title'];
4634 4633
                 } else {
4635
-                    $visibilite .= ' - ' . $record['title'];
4634
+                    $visibilite .= ' - '.$record['title'];
4636 4635
                 }
4637 4636
             }
4638 4637
         } else {
@@ -4642,14 +4641,14 @@  discard block
 block discarded – undo
4642 4641
             // do new query to know if current folder is pf
4643 4642
             $data_pf = DB::queryFirstRow(
4644 4643
                 'SELECT personal_folder
4645
-                FROM ' . prefixTable('nested_tree') . '
4644
+                FROM ' . prefixTable('nested_tree').'
4646 4645
                 WHERE id = %s',
4647 4646
                 $inputData['folderId']
4648 4647
             );
4649 4648
             
4650 4649
             $folder_is_personal = $data_pf !== null ? (int) $data_pf['personal_folder'] : 0;
4651 4650
             
4652
-            $visibilite = $session->get('user-name') . ' ' . $session->get('user-lastname') . ' (' . $session->get('user-login') . ')';
4651
+            $visibilite = $session->get('user-name').' '.$session->get('user-lastname').' ('.$session->get('user-login').')';
4653 4652
         }
4654 4653
 
4655 4654
         recupDroitCreationSansComplexite($inputData['folderId']);
@@ -4659,8 +4658,8 @@  discard block
 block discarded – undo
4659 4658
         $listOptionsForRoles = array();
4660 4659
         $rows = DB::query(
4661 4660
             'SELECT r.role_id AS role_id, t.title AS title
4662
-            FROM ' . prefixTable('roles_values') . ' AS r
4663
-            INNER JOIN ' . prefixTable('roles_title') . ' AS t ON (r.role_id = t.id)
4661
+            FROM ' . prefixTable('roles_values').' AS r
4662
+            INNER JOIN ' . prefixTable('roles_title').' AS t ON (r.role_id = t.id)
4664 4663
             WHERE r.folder_id = %i',
4665 4664
             $inputData['folderId']
4666 4665
         );
@@ -4675,8 +4674,8 @@  discard block
 block discarded – undo
4675 4674
             $rows2 = DB::query(
4676 4675
                 'SELECT u.id, u.login, u.email, u.name, u.lastname,
4677 4676
                 GROUP_CONCAT(DISTINCT ur.role_id ORDER BY ur.role_id SEPARATOR ";") AS fonction_id
4678
-                FROM ' . prefixTable('users') . ' AS u
4679
-                INNER JOIN ' . prefixTable('users_roles') . ' AS ur ON (u.id = ur.user_id)
4677
+                FROM ' . prefixTable('users').' AS u
4678
+                INNER JOIN ' . prefixTable('users_roles').' AS ur ON (u.id = ur.user_id)
4680 4679
                 WHERE u.admin = 0 AND ur.source = %s
4681 4680
                 GROUP BY u.id',
4682 4681
                 'manual'
@@ -4692,7 +4691,7 @@  discard block
 block discarded – undo
4692 4691
                             array(
4693 4692
                                 'id' => $record2['id'],
4694 4693
                                 'login' => $record2['login'],
4695
-                                'name' => $record2['name'] . ' ' . $record2['lastname'],
4694
+                                'name' => $record2['name'].' '.$record2['lastname'],
4696 4695
                                 'email' => $record2['email'],
4697 4696
                             )
4698 4697
                         );
@@ -4709,12 +4708,12 @@  discard block
 block discarded – undo
4709 4708
             foreach ($session->get('user-roles_array') as $role) {
4710 4709
                 $access = DB::queryFirstRow(
4711 4710
                     'SELECT type
4712
-                    FROM ' . prefixTable('roles_values') . '
4711
+                    FROM ' . prefixTable('roles_values').'
4713 4712
                     WHERE role_id = %i AND folder_id = %i',
4714 4713
                     $role,
4715 4714
                     $inputData['folderId']
4716 4715
                 );
4717
-                if (DB::count()>0) {
4716
+                if (DB::count() > 0) {
4718 4717
                     if ($access['type'] === 'R') {
4719 4718
                         array_push($arrTmp, 10);
4720 4719
                     } elseif ($access['type'] === 'W') {
@@ -4742,7 +4741,7 @@  discard block
 block discarded – undo
4742 4741
             // Check if personal folder is owned by user
4743 4742
             $folder = DB::queryFirstRow(
4744 4743
                 'SELECT id
4745
-                FROM ' . prefixTable('nested_tree') . '
4744
+                FROM ' . prefixTable('nested_tree').'
4746 4745
                 WHERE title = %s',
4747 4746
                 $session->get('user-id'),
4748 4747
             );
@@ -4847,7 +4846,7 @@  discard block
 block discarded – undo
4847 4846
         // Get some info before deleting
4848 4847
         $data = DB::queryFirstRow(
4849 4848
             'SELECT name, id_item, file
4850
-            FROM ' . prefixTable('files') . '
4849
+            FROM ' . prefixTable('files').'
4851 4850
             WHERE id = %i',
4852 4851
             $fileId
4853 4852
         );
@@ -4855,7 +4854,7 @@  discard block
 block discarded – undo
4855 4854
         // Load item data
4856 4855
         $data_item = DB::queryFirstRow(
4857 4856
             'SELECT id_tree
4858
-            FROM ' . prefixTable('items') . '
4857
+            FROM ' . prefixTable('items').'
4859 4858
             WHERE id = %i',
4860 4859
             $data['id_item']
4861 4860
         );
@@ -4885,7 +4884,7 @@  discard block
 block discarded – undo
4885 4884
                 $session->get('user-id'),
4886 4885
                 'at_modification',
4887 4886
                 $session->get('user-login'),
4888
-                'at_del_file : ' . $data['name']
4887
+                'at_del_file : '.$data['name']
4889 4888
             );
4890 4889
 
4891 4890
             // DElete sharekeys
@@ -4896,7 +4895,7 @@  discard block
 block discarded – undo
4896 4895
             );
4897 4896
 
4898 4897
             // Delete file from server
4899
-            $fileToDelete = $SETTINGS['path_to_upload_folder'] . '/' . TP_FILE_PREFIX . base64_decode($data['file']);
4898
+            $fileToDelete = $SETTINGS['path_to_upload_folder'].'/'.TP_FILE_PREFIX.base64_decode($data['file']);
4900 4899
             $fileToDelete = realpath($fileToDelete);
4901 4900
             if ($fileToDelete && strpos($fileToDelete, $SETTINGS['path_to_upload_folder']) === 0) {
4902 4901
                 fileDelete($fileToDelete, $SETTINGS);
@@ -4950,7 +4949,7 @@  discard block
 block discarded – undo
4950 4949
             // Update SESSION with this new favourite
4951 4950
             $data = DB::queryFirstRow(
4952 4951
                 'SELECT label,id_tree
4953
-                FROM ' . prefixTable('items') . '
4952
+                FROM ' . prefixTable('items').'
4954 4953
                 WHERE id = %i',
4955 4954
                 $inputData['itemId']
4956 4955
             );
@@ -4959,7 +4958,7 @@  discard block
 block discarded – undo
4959 4958
                 [
4960 4959
                     $inputData['itemId'] => [
4961 4960
                         'label' => $data['label'],
4962
-                        'url' => 'index.php?page=items&amp;group=' . $data['id_tree'] . '&amp;id=' . $inputData['itemId'],
4961
+                        'url' => 'index.php?page=items&amp;group='.$data['id_tree'].'&amp;id='.$inputData['itemId'],
4963 4962
                     ],
4964 4963
                 ],
4965 4964
                 'add'
@@ -5028,8 +5027,8 @@  discard block
 block discarded – undo
5028 5027
         // get data about item
5029 5028
         $dataSource = DB::queryFirstRow(
5030 5029
             'SELECT i.pw, f.personal_folder,i.id_tree, f.title,i.label
5031
-            FROM ' . prefixTable('items') . ' as i
5032
-            INNER JOIN ' . prefixTable('nested_tree') . ' as f ON (i.id_tree=f.id)
5030
+            FROM ' . prefixTable('items').' as i
5031
+            INNER JOIN ' . prefixTable('nested_tree').' as f ON (i.id_tree=f.id)
5033 5032
             WHERE i.id=%i',
5034 5033
             $inputData['itemId']
5035 5034
         );
@@ -5073,7 +5072,7 @@  discard block
 block discarded – undo
5073 5072
         // get data about new folder
5074 5073
         $dataDestination = DB::queryFirstRow(
5075 5074
             'SELECT personal_folder, title
5076
-            FROM ' . prefixTable('nested_tree') . '
5075
+            FROM ' . prefixTable('nested_tree').'
5077 5076
             WHERE id = %i',
5078 5077
             $inputData['folderId']
5079 5078
         );
@@ -5126,7 +5125,7 @@  discard block
 block discarded – undo
5126 5125
             // Get fields for this Item
5127 5126
             $rows = DB::query(
5128 5127
                 'SELECT id
5129
-                FROM ' . prefixTable('categories_items') . '
5128
+                FROM ' . prefixTable('categories_items').'
5130 5129
                 WHERE item_id = %i',
5131 5130
                 $inputData['itemId']
5132 5131
             );
@@ -5143,7 +5142,7 @@  discard block
 block discarded – undo
5143 5142
             // Get FILES for this Item
5144 5143
             $rows = DB::query(
5145 5144
                 'SELECT id
5146
-                FROM ' . prefixTable('files') . '
5145
+                FROM ' . prefixTable('files').'
5147 5146
                 WHERE id_item = %i',
5148 5147
                 $inputData['itemId']
5149 5148
             );
@@ -5190,7 +5189,7 @@  discard block
 block discarded – undo
5190 5189
             // Get the ITEM object key for the user
5191 5190
             $userKey = DB::queryFirstRow(
5192 5191
                 'SELECT share_key
5193
-                FROM ' . prefixTable('sharekeys_items') . '
5192
+                FROM ' . prefixTable('sharekeys_items').'
5194 5193
                 WHERE user_id = %i AND object_id = %i',
5195 5194
                 $session->get('user-id'),
5196 5195
                 $inputData['itemId']
@@ -5201,7 +5200,7 @@  discard block
 block discarded – undo
5201 5200
                 // This is a public object
5202 5201
                 $users = DB::query(
5203 5202
                     'SELECT id, public_key
5204
-                    FROM ' . prefixTable('users') . '
5203
+                    FROM ' . prefixTable('users').'
5205 5204
                     WHERE id NOT IN %li
5206 5205
                     AND public_key != ""',
5207 5206
                     $tpUsersIDs
@@ -5221,14 +5220,14 @@  discard block
 block discarded – undo
5221 5220
             // Get fields for this Item
5222 5221
             $rows = DB::query(
5223 5222
                 'SELECT id
5224
-                FROM ' . prefixTable('categories_items') . '
5223
+                FROM ' . prefixTable('categories_items').'
5225 5224
                 WHERE item_id = %i',
5226 5225
                 $inputData['itemId']
5227 5226
             );
5228 5227
             foreach ($rows as $field) {
5229 5228
                 $userKey = DB::queryFirstRow(
5230 5229
                     'SELECT share_key
5231
-                    FROM ' . prefixTable('sharekeys_fields') . '
5230
+                    FROM ' . prefixTable('sharekeys_fields').'
5232 5231
                     WHERE user_id = %i AND object_id = %i',
5233 5232
                     $session->get('user-id'),
5234 5233
                     $field['id']
@@ -5239,7 +5238,7 @@  discard block
 block discarded – undo
5239 5238
                     // This is a public object
5240 5239
                     $users = DB::query(
5241 5240
                         'SELECT id, public_key
5242
-                        FROM ' . prefixTable('users') . '
5241
+                        FROM ' . prefixTable('users').'
5243 5242
                         WHERE id NOT IN %li
5244 5243
                         AND public_key != ""',
5245 5244
                         $tpUsersIDs
@@ -5260,14 +5259,14 @@  discard block
 block discarded – undo
5260 5259
             // Get FILES for this Item
5261 5260
             $rows = DB::query(
5262 5261
                 'SELECT id
5263
-                FROM ' . prefixTable('files') . '
5262
+                FROM ' . prefixTable('files').'
5264 5263
                 WHERE id_item = %i',
5265 5264
                 $inputData['itemId']
5266 5265
             );
5267 5266
             foreach ($rows as $attachment) {
5268 5267
                 $userKey = DB::queryFirstRow(
5269 5268
                     'SELECT share_key
5270
-                    FROM ' . prefixTable('sharekeys_files') . '
5269
+                    FROM ' . prefixTable('sharekeys_files').'
5271 5270
                     WHERE user_id = %i AND object_id = %i',
5272 5271
                     $session->get('user-id'),
5273 5272
                     $attachment['id']
@@ -5278,7 +5277,7 @@  discard block
 block discarded – undo
5278 5277
                     // This is a public object
5279 5278
                     $users = DB::query(
5280 5279
                         'SELECT id, public_key
5281
-                        FROM ' . prefixTable('users') . '
5280
+                        FROM ' . prefixTable('users').'
5282 5281
                         WHERE id NOT IN %li
5283 5282
                         AND public_key != ""',
5284 5283
                         $tpUsersIDs
@@ -5317,7 +5316,7 @@  discard block
 block discarded – undo
5317 5316
             $session->get('user-id'),
5318 5317
             'at_modification',
5319 5318
             $session->get('user-login'),
5320
-            'at_moved : ' . $dataSource['title'] . ' -> ' . $dataDestination['title']
5319
+            'at_moved : '.$dataSource['title'].' -> '.$dataDestination['title']
5321 5320
         );
5322 5321
 
5323 5322
         // Update cache table
@@ -5376,8 +5375,8 @@  discard block
 block discarded – undo
5376 5375
                 // get data about item
5377 5376
                 $dataSource = DB::queryFirstRow(
5378 5377
                     'SELECT i.pw, f.personal_folder,i.id_tree, f.title,i.label
5379
-                    FROM ' . prefixTable('items') . ' as i
5380
-                    INNER JOIN ' . prefixTable('nested_tree') . ' as f ON (i.id_tree=f.id)
5378
+                    FROM ' . prefixTable('items').' as i
5379
+                    INNER JOIN ' . prefixTable('nested_tree').' as f ON (i.id_tree=f.id)
5381 5380
                     WHERE i.id=%i',
5382 5381
                     $item_id
5383 5382
                 );
@@ -5399,7 +5398,7 @@  discard block
 block discarded – undo
5399 5398
 
5400 5399
                 // get data about new folder
5401 5400
                 $dataDestination = DB::queryFirstRow(
5402
-                    'SELECT personal_folder, title FROM ' . prefixTable('nested_tree') . ' WHERE id = %i',
5401
+                    'SELECT personal_folder, title FROM '.prefixTable('nested_tree').' WHERE id = %i',
5403 5402
                     $inputData['folderId']
5404 5403
                 );
5405 5404
 
@@ -5433,14 +5432,14 @@  discard block
 block discarded – undo
5433 5432
                         prefixTable('sharekeys_items'),
5434 5433
                         'object_id = %i AND user_id NOT IN %ls',
5435 5434
                         $item_id,
5436
-                        [$session->get('user-id'), TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
5435
+                        [$session->get('user-id'), TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
5437 5436
                     );
5438 5437
 
5439 5438
                     // Remove all item sharekeys fields
5440 5439
                     // Get fields for this Item
5441 5440
                     $rows = DB::query(
5442 5441
                         'SELECT id
5443
-                        FROM ' . prefixTable('categories_items') . '
5442
+                        FROM ' . prefixTable('categories_items').'
5444 5443
                         WHERE item_id = %i',
5445 5444
                         $item_id
5446 5445
                     );
@@ -5457,7 +5456,7 @@  discard block
 block discarded – undo
5457 5456
                     // Get FILES for this Item
5458 5457
                     $rows = DB::query(
5459 5458
                         'SELECT id
5460
-                        FROM ' . prefixTable('files') . '
5459
+                        FROM ' . prefixTable('files').'
5461 5460
                         WHERE id_item = %i',
5462 5461
                         $item_id
5463 5462
                     );
@@ -5512,7 +5511,7 @@  discard block
 block discarded – undo
5512 5511
                     // Get the ITEM object key for the user
5513 5512
                     $userKey = DB::queryFirstRow(
5514 5513
                         'SELECT share_key
5515
-                        FROM ' . prefixTable('sharekeys_items') . '
5514
+                        FROM ' . prefixTable('sharekeys_items').'
5516 5515
                         WHERE user_id = %i AND object_id = %i',
5517 5516
                         $session->get('user-id'),
5518 5517
                         $item_id
@@ -5523,7 +5522,7 @@  discard block
 block discarded – undo
5523 5522
                         // This is a public object
5524 5523
                         $users = DB::query(
5525 5524
                             'SELECT id, public_key
5526
-                            FROM ' . prefixTable('users') . '
5525
+                            FROM ' . prefixTable('users').'
5527 5526
                             WHERE id NOT IN %li
5528 5527
                             AND public_key != ""',
5529 5528
                             $tpUsersIDs
@@ -5544,14 +5543,14 @@  discard block
 block discarded – undo
5544 5543
                     // Get fields for this Item
5545 5544
                     $rows = DB::query(
5546 5545
                         'SELECT id
5547
-                        FROM ' . prefixTable('categories_items') . '
5546
+                        FROM ' . prefixTable('categories_items').'
5548 5547
                         WHERE item_id = %i',
5549 5548
                         $item_id
5550 5549
                     );
5551 5550
                     foreach ($rows as $field) {
5552 5551
                         $userKey = DB::queryFirstRow(
5553 5552
                             'SELECT share_key
5554
-                            FROM ' . prefixTable('sharekeys_fields') . '
5553
+                            FROM ' . prefixTable('sharekeys_fields').'
5555 5554
                             WHERE user_id = %i AND object_id = %i',
5556 5555
                             $session->get('user-id'),
5557 5556
                             $field['id']
@@ -5562,7 +5561,7 @@  discard block
 block discarded – undo
5562 5561
                             // This is a public object
5563 5562
                             $users = DB::query(
5564 5563
                                 'SELECT id, public_key
5565
-                                FROM ' . prefixTable('users') . '
5564
+                                FROM ' . prefixTable('users').'
5566 5565
                                 WHERE id NOT IN %li
5567 5566
                                 AND public_key != ""',
5568 5567
                                 $tpUsersIDs
@@ -5584,14 +5583,14 @@  discard block
 block discarded – undo
5584 5583
                     // Get FILES for this Item
5585 5584
                     $rows = DB::query(
5586 5585
                         'SELECT id
5587
-                        FROM ' . prefixTable('files') . '
5586
+                        FROM ' . prefixTable('files').'
5588 5587
                         WHERE id_item = %i',
5589 5588
                         $item_id
5590 5589
                     );
5591 5590
                     foreach ($rows as $attachment) {
5592 5591
                         $userKey = DB::queryFirstRow(
5593 5592
                             'SELECT share_key
5594
-                            FROM ' . prefixTable('sharekeys_files') . '
5593
+                            FROM ' . prefixTable('sharekeys_files').'
5595 5594
                             WHERE user_id = %i AND object_id = %i',
5596 5595
                             $session->get('user-id'),
5597 5596
                             $attachment['id']
@@ -5602,7 +5601,7 @@  discard block
 block discarded – undo
5602 5601
                             // This is a public object
5603 5602
                             $users = DB::query(
5604 5603
                                 'SELECT id, public_key
5605
-                                FROM ' . prefixTable('users') . '
5604
+                                FROM ' . prefixTable('users').'
5606 5605
                                 WHERE id NOT IN %li
5607 5606
                                 AND public_key != ""',
5608 5607
                                 $tpUsersIDs
@@ -5640,13 +5639,13 @@  discard block
 block discarded – undo
5640 5639
                     $session->get('user-id'),
5641 5640
                     'at_modification',
5642 5641
                     $session->get('user-login'),
5643
-                    'at_moved : ' . $dataSource['title'] . ' -> ' . $dataDestination['title']
5642
+                    'at_moved : '.$dataSource['title'].' -> '.$dataDestination['title']
5644 5643
                 );
5645 5644
             }
5646 5645
         }
5647 5646
 
5648 5647
         // reload cache table
5649
-        require_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
5648
+        require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
5650 5649
         updateCacheTable('reload', null);
5651 5650
 
5652 5651
         echo (string) prepareExchangedData(
@@ -5710,7 +5709,7 @@  discard block
 block discarded – undo
5710 5709
                 // get info
5711 5710
                 $dataSource = DB::queryFirstRow(
5712 5711
                     'SELECT label, id_tree
5713
-                    FROM ' . prefixTable('items') . '
5712
+                    FROM ' . prefixTable('items').'
5714 5713
                     WHERE id=%i',
5715 5714
                     $item_id
5716 5715
                 );
@@ -5811,14 +5810,14 @@  discard block
 block discarded – undo
5811 5810
             // Variables
5812 5811
             $dataAuthor = DB::queryFirstRow(
5813 5812
                 'SELECT email,login
5814
-                FROM ' . prefixTable('users') . '
5813
+                FROM ' . prefixTable('users').'
5815 5814
                 WHERE id = %i',
5816 5815
                 $post_content[1]
5817 5816
             );
5818 5817
 
5819 5818
             $dataItem = DB::queryFirstRow(
5820 5819
                 'SELECT label, id_tree
5821
-                FROM ' . prefixTable('items') . '
5820
+                FROM ' . prefixTable('items').'
5822 5821
                 WHERE id = %i',
5823 5822
                 $post_content[0]
5824 5823
             );
@@ -5835,7 +5834,7 @@  discard block
 block discarded – undo
5835 5834
                 $lang->get('email_request_access_subject'),
5836 5835
                 str_replace(
5837 5836
                     array('#tp_item_author#', '#tp_user#', '#tp_item#'),
5838
-                    array(' ' . addslashes($dataAuthor['login']), addslashes($session->get('user-login')), $path),
5837
+                    array(' '.addslashes($dataAuthor['login']), addslashes($session->get('user-login')), $path),
5839 5838
                     $lang->get('email_request_access_mail')
5840 5839
                 ),
5841 5840
                 $dataAuthor['email'],
@@ -5844,7 +5843,7 @@  discard block
 block discarded – undo
5844 5843
         } elseif ($inputData['cat'] === 'share_this_item') {
5845 5844
             $dataItem = DB::queryFirstRow(
5846 5845
                 'SELECT label,id_tree
5847
-                FROM ' . prefixTable('items') . '
5846
+                FROM ' . prefixTable('items').'
5848 5847
                 WHERE id= %i',
5849 5848
                 $inputData['id']
5850 5849
             );
@@ -5867,7 +5866,7 @@  discard block
 block discarded – undo
5867 5866
                     ),
5868 5867
                     array(
5869 5868
                         empty($SETTINGS['email_server_url']) === false ?
5870
-                            $SETTINGS['email_server_url'] . '/index.php?page=items&group=' . $dataItem['id_tree'] . '&id=' . $inputData['id'] : $SETTINGS['cpassman_url'] . '/index.php?page=items&group=' . $dataItem['id_tree'] . '&id=' . $inputData['id'],
5869
+                            $SETTINGS['email_server_url'].'/index.php?page=items&group='.$dataItem['id_tree'].'&id='.$inputData['id'] : $SETTINGS['cpassman_url'].'/index.php?page=items&group='.$dataItem['id_tree'].'&id='.$inputData['id'],
5871 5870
                         addslashes($session->get('user-login')),
5872 5871
                         addslashes($path),
5873 5872
                     ),
@@ -5917,8 +5916,8 @@  discard block
 block discarded – undo
5917 5916
         $dataItem = DB::queryFirstRow(
5918 5917
             'SELECT i.*,
5919 5918
             IFNULL(l.id_user, 0) AS id_user
5920
-            FROM ' . prefixTable('items') . ' as i
5921
-            LEFT JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id AND l.action = %s)
5919
+            FROM ' . prefixTable('items').' as i
5920
+            LEFT JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id AND l.action = %s)
5922 5921
             WHERE i.id=%i',
5923 5922
             'at_creation',
5924 5923
             $item_id
@@ -5947,18 +5946,18 @@  discard block
 block discarded – undo
5947 5946
                 $session->get('user-login'),
5948 5947
                 htmlspecialchars_decode($label, ENT_QUOTES),
5949 5948
                 null,
5950
-                (string) dateToStamp($date.' '.$time, $SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'])
5949
+                (string) dateToStamp($date.' '.$time, $SETTINGS['date_format'].' '.$SETTINGS['time_format'])
5951 5950
             );
5952 5951
             // Prepare new line
5953 5952
             $data = DB::queryFirstRow(
5954
-                'SELECT * FROM ' . prefixTable('log_items') . ' WHERE id_item = %i ORDER BY date DESC',
5953
+                'SELECT * FROM '.prefixTable('log_items').' WHERE id_item = %i ORDER BY date DESC',
5955 5954
                 $item_id
5956 5955
             );
5957
-            $historic = date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $data['date']) . ' - ' . $session->get('user-login') . ' - ' . $lang->get($data['action']) . ' - ' . $data['raison'];
5956
+            $historic = date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $data['date']).' - '.$session->get('user-login').' - '.$lang->get($data['action']).' - '.$data['raison'];
5958 5957
             // send back
5959 5958
             $data = array(
5960 5959
                 'error' => '',
5961
-                'new_line' => '<br>' . addslashes($historic),
5960
+                'new_line' => '<br>'.addslashes($historic),
5962 5961
             );
5963 5962
             echo (string) prepareExchangedData(
5964 5963
                 $data,
@@ -6033,8 +6032,8 @@  discard block
 block discarded – undo
6033 6032
         // Should we log a password change?
6034 6033
         $itemQ = DB::queryFirstRow(
6035 6034
             'SELECT s.share_key, i.pw
6036
-            FROM ' . prefixTable('items') . ' AS i
6037
-            INNER JOIN ' . prefixTable('sharekeys_items') . ' AS s ON (i.id = s.object_id)
6035
+            FROM ' . prefixTable('items').' AS i
6036
+            INNER JOIN ' . prefixTable('sharekeys_items').' AS s ON (i.id = s.object_id)
6038 6037
             WHERE s.user_id = %i AND s.object_id = %i',
6039 6038
             $session->get('user-id'),
6040 6039
             $dataReceived['id']
@@ -6089,7 +6088,7 @@  discard block
 block discarded – undo
6089 6088
         if (isset($SETTINGS['otv_expiration_period']) === false) {
6090 6089
             $SETTINGS['otv_expiration_period'] = 7;
6091 6090
         }
6092
-        $url = $SETTINGS['cpassman_url'] . '/index.php?' . http_build_query($otv_session);
6091
+        $url = $SETTINGS['cpassman_url'].'/index.php?'.http_build_query($otv_session);
6093 6092
 
6094 6093
         echo json_encode(
6095 6094
             array(
@@ -6120,7 +6119,7 @@  discard block
 block discarded – undo
6120 6119
         // get parameters from original link
6121 6120
         $url = $dataReceived['original_link'];
6122 6121
         $parts = parse_url($url);
6123
-        if(isset($parts['query'])){
6122
+        if (isset($parts['query'])) {
6124 6123
             parse_str($parts['query'], $orignal_link_parameters);
6125 6124
         } else {
6126 6125
             $orignal_link_parameters = array();
@@ -6151,13 +6150,13 @@  discard block
 block discarded – undo
6151 6150
             $domain_scheme = parse_url($SETTINGS['cpassman_url'], PHP_URL_SCHEME);
6152 6151
             $domain_host = parse_url($SETTINGS['cpassman_url'], PHP_URL_HOST);
6153 6152
             if (str_contains($domain_host, 'www.') === true) {
6154
-                $domain_host = (string) $SETTINGS['otv_subdomain'] . '.' . substr($domain_host, 4);
6153
+                $domain_host = (string) $SETTINGS['otv_subdomain'].'.'.substr($domain_host, 4);
6155 6154
             } else {
6156
-                $domain_host = (string) $SETTINGS['otv_subdomain'] . '.' . $domain_host;
6155
+                $domain_host = (string) $SETTINGS['otv_subdomain'].'.'.$domain_host;
6157 6156
             }
6158
-            $url = $domain_scheme.'://'.$domain_host . '/index.php?'.http_build_query($otv_session);
6157
+            $url = $domain_scheme.'://'.$domain_host.'/index.php?'.http_build_query($otv_session);
6159 6158
         } else {
6160
-            $url = $SETTINGS['cpassman_url'] . '/index.php?'.http_build_query($otv_session);
6159
+            $url = $SETTINGS['cpassman_url'].'/index.php?'.http_build_query($otv_session);
6161 6160
         }
6162 6161
 
6163 6162
         echo (string) prepareExchangedData(
@@ -6192,8 +6191,8 @@  discard block
 block discarded – undo
6192 6191
             'SELECT f.id AS id, f.file AS file, f.name AS name, f.status AS status,
6193 6192
             f.extension AS extension, f.type AS type,
6194 6193
             s.share_key AS share_key
6195
-            FROM ' . prefixTable('files') . ' AS f
6196
-            INNER JOIN ' . prefixTable('sharekeys_files') . ' AS s ON (f.id = s.object_id)
6194
+            FROM ' . prefixTable('files').' AS f
6195
+            INNER JOIN ' . prefixTable('sharekeys_files').' AS s ON (f.id = s.object_id)
6197 6196
             WHERE s.user_id = %i AND s.object_id = %i',
6198 6197
             $session->get('user-id'),
6199 6198
             $inputData['id']
@@ -6214,7 +6213,7 @@  discard block
 block discarded – undo
6214 6213
         //$fileName = basename($file_info['name'], '.'.$file_info['extension']);
6215 6214
 
6216 6215
         // prepare image info
6217
-        $post_title = basename($file_info['name'], '.' . $file_info['extension']);
6216
+        $post_title = basename($file_info['name'], '.'.$file_info['extension']);
6218 6217
         $post_title = isBase64($post_title) === true ? base64_decode($post_title) : $post_title;
6219 6218
         
6220 6219
         // Get image content
@@ -6241,7 +6240,7 @@  discard block
 block discarded – undo
6241 6240
         echo (string) prepareExchangedData(
6242 6241
             array(
6243 6242
                 'error' => false,
6244
-                'filename' => $post_title . '.' . $file_info['extension'],
6243
+                'filename' => $post_title.'.'.$file_info['extension'],
6245 6244
                 'file_type' => $file_info['type'],
6246 6245
                 'file_content' => $fileContent,
6247 6246
             ),
@@ -6353,7 +6352,7 @@  discard block
 block discarded – undo
6353 6352
                     $arbo = $tree->getPath($folder->id, false);
6354 6353
                     $path = '';
6355 6354
                     foreach ($arbo as $elem) {
6356
-                        $path = (empty($path) ? '' : $path . ' / ') . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
6355
+                        $path = (empty($path) ? '' : $path.' / ').htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
6357 6356
                     }
6358 6357
 
6359 6358
                     // Build array
@@ -6420,7 +6419,7 @@  discard block
 block discarded – undo
6420 6419
         if (is_array($foldersArray) === true && $inputData['data'] !== '[null]') {
6421 6420
             $rows = DB::query(
6422 6421
                 'SELECT id, categories
6423
-                FROM ' . prefixTable('nested_tree') . '
6422
+                FROM ' . prefixTable('nested_tree').'
6424 6423
                 WHERE id IN (%l)',
6425 6424
                 implode(',', $foldersArray)
6426 6425
             );
@@ -6438,7 +6437,7 @@  discard block
 block discarded – undo
6438 6437
             if (count($ids) > 0) {
6439 6438
                 $subfolders = DB::queryFirstColumn(
6440 6439
                     'SELECT title
6441
-                    FROM ' . prefixTable('nested_tree') . '
6440
+                    FROM ' . prefixTable('nested_tree').'
6442 6441
                     WHERE id IN %li',
6443 6442
                     $ids
6444 6443
                 );
@@ -6474,7 +6473,7 @@  discard block
 block discarded – undo
6474 6473
         // get item info
6475 6474
         $dataItem = DB::queryFirstRow(
6476 6475
             'SELECT *
6477
-            FROM ' . prefixTable('items') . '
6476
+            FROM ' . prefixTable('items').'
6478 6477
             WHERE id=%i',
6479 6478
             $inputData['itemId']
6480 6479
         );
@@ -6486,8 +6485,8 @@  discard block
 block discarded – undo
6486 6485
             'SELECT l.date as date, l.action as action, l.raison as raison,
6487 6486
                 u.login as login, u.avatar_thumb as avatar_thumb, u.name as name, u.lastname as lastname,
6488 6487
                 l.old_value as old_value
6489
-            FROM ' . prefixTable('log_items') . ' as l
6490
-            INNER JOIN ' . prefixTable('users') . ' as u ON (l.id_user=u.id)
6488
+            FROM ' . prefixTable('log_items').' as l
6489
+            INNER JOIN ' . prefixTable('users').' as u ON (l.id_user=u.id)
6491 6490
             WHERE id_item=%i AND l.action NOT IN (%l)
6492 6491
             ORDER BY date DESC',
6493 6492
             $inputData['itemId'],
@@ -6502,18 +6501,18 @@  discard block
 block discarded – undo
6502 6501
             
6503 6502
             // imported via API
6504 6503
             if (empty($record['login']) === true) {
6505
-                $record['login'] = $lang->get('imported_via_api') . ' [' . $record['raison'] . ']';
6504
+                $record['login'] = $lang->get('imported_via_api').' ['.$record['raison'].']';
6506 6505
             }
6507 6506
             
6508 6507
             // Prepare avatar
6509 6508
             if (isset($record['avatar_thumb']) && empty($record['avatar_thumb']) === false) {
6510
-                if (file_exists($SETTINGS['cpassman_dir'] . '/includes/avatars/' . $record['avatar_thumb'])) {
6511
-                    $avatar = $SETTINGS['cpassman_url'] . '/includes/avatars/' . $record['avatar_thumb'];
6509
+                if (file_exists($SETTINGS['cpassman_dir'].'/includes/avatars/'.$record['avatar_thumb'])) {
6510
+                    $avatar = $SETTINGS['cpassman_url'].'/includes/avatars/'.$record['avatar_thumb'];
6512 6511
                 } else {
6513
-                    $avatar = $SETTINGS['cpassman_url'] . '/includes/images/photo.jpg';
6512
+                    $avatar = $SETTINGS['cpassman_url'].'/includes/images/photo.jpg';
6514 6513
                 }
6515 6514
             } else {
6516
-                $avatar = $SETTINGS['cpassman_url'] . '/includes/images/photo.jpg';
6515
+                $avatar = $SETTINGS['cpassman_url'].'/includes/images/photo.jpg';
6517 6516
             }
6518 6517
 
6519 6518
             // Prepare action
@@ -6533,7 +6532,7 @@  discard block
 block discarded – undo
6533 6532
                         $previous_passwords, 
6534 6533
                         [
6535 6534
                             'password' => htmlentities($previous_pwd['string']),
6536
-                            'date' => date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['date']),
6535
+                            'date' => date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['date']),
6537 6536
                         ]
6538 6537
                     );
6539 6538
                 }
@@ -6546,19 +6545,19 @@  discard block
 block discarded – undo
6546 6545
                 $action = $lang->get($reason[0]);
6547 6546
                 if ($reason[0] === 'at_moved') {
6548 6547
                     $tmp = explode(' -> ', $reason[1]);
6549
-                    $detail = $lang->get('from') . ' <span class="font-weight-light">' . $tmp[0] . '</span> ' . $lang->get('to') . ' <span class="font-weight-light">' . $tmp[1] . ' </span>';
6548
+                    $detail = $lang->get('from').' <span class="font-weight-light">'.$tmp[0].'</span> '.$lang->get('to').' <span class="font-weight-light">'.$tmp[1].' </span>';
6550 6549
                 } elseif ($reason[0] === 'at_field') {
6551 6550
                     $tmp = explode(' => ', $reason[1]);
6552 6551
                     if (count($tmp) > 1) {
6553
-                        $detail = '<b>' . trim($tmp[0]) . '</b> | ' . $lang->get('previous_value') .
6554
-                            ': <span class="font-weight-light">' . trim($tmp[1]) . '</span>';
6552
+                        $detail = '<b>'.trim($tmp[0]).'</b> | '.$lang->get('previous_value').
6553
+                            ': <span class="font-weight-light">'.trim($tmp[1]).'</span>';
6555 6554
                     } else {
6556 6555
                         $detail = trim($reason[1]);
6557 6556
                     }
6558 6557
                 } elseif (in_array($reason[0], array('at_restriction', 'at_email', 'at_login', 'at_label', 'at_url', 'at_tag')) === true) {
6559 6558
                     $tmp = explode(' => ', $reason[1]);
6560 6559
                     $detail = empty(trim($tmp[0])) === true ?
6561
-                        $lang->get('no_previous_value') : $lang->get('previous_value') . ': <span class="font-weight-light">' . $tmp[0] . ' </span>';
6560
+                        $lang->get('no_previous_value') : $lang->get('previous_value').': <span class="font-weight-light">'.$tmp[0].' </span>';
6562 6561
                 } elseif ($reason[0] === 'at_automatic_del') {
6563 6562
                     $detail = $lang->get($reason[1]);
6564 6563
                 } elseif ($reason[0] === 'at_anyoneconmodify' || $reason[0] === 'at_otp_status' || $reason[0] === 'at_otp_secret' || $reason[0] === 'at_phone_number') {
@@ -6567,7 +6566,7 @@  discard block
 block discarded – undo
6567 6566
                     $tmp = explode(':', $reason[1]);
6568 6567
                     $tmp = explode('.', $tmp[0]);
6569 6568
                     $detail = isBase64($tmp[0]) === true ?
6570
-                        base64_decode($tmp[0]) . '.' . $tmp[1] : $tmp[0];
6569
+                        base64_decode($tmp[0]).'.'.$tmp[1] : $tmp[0];
6571 6570
                 } elseif ($reason[0] === 'at_import') {
6572 6571
                     $detail = '';
6573 6572
                 } elseif (in_array($reason[0], array('csv', 'pdf')) === true) {
@@ -6586,8 +6585,8 @@  discard block
 block discarded – undo
6586 6585
                 array(
6587 6586
                     'avatar' => $avatar,
6588 6587
                     'login' => $record['login'],
6589
-                    'name' => $record['name'] . ' ' . $record['lastname'],
6590
-                    'date' => date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['date']),
6588
+                    'name' => $record['name'].' '.$record['lastname'],
6589
+                    'date' => date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['date']),
6591 6590
                     'action' => $action,
6592 6591
                     'detail' => $detail,
6593 6592
                 )
@@ -6675,11 +6674,11 @@  discard block
 block discarded – undo
6675 6674
 
6676 6675
         // get some info to add to the notification email
6677 6676
         $resp_user = DB::queryFirstRow(
6678
-            'SELECT login FROM ' . prefixTable('users') . ' WHERE id = %i',
6677
+            'SELECT login FROM '.prefixTable('users').' WHERE id = %i',
6679 6678
             $session->get('user-id')
6680 6679
         );
6681 6680
         $resp_folder = DB::queryFirstRow(
6682
-            'SELECT title FROM ' . prefixTable('nested_tree') . ' WHERE id = %i',
6681
+            'SELECT title FROM '.prefixTable('nested_tree').' WHERE id = %i',
6683 6682
             $folder
6684 6683
         );
6685 6684
 
@@ -6688,7 +6687,7 @@  discard block
 block discarded – undo
6688 6687
         $emailService = new EmailService();
6689 6688
         $rows = DB::query(
6690 6689
             'SELECT email
6691
-            FROM ' . prefixTable('users') . '
6690
+            FROM ' . prefixTable('users').'
6692 6691
             WHERE `gestionnaire` = %i AND `email` IS NOT NULL',
6693 6692
             1
6694 6693
         );
@@ -6734,7 +6733,7 @@  discard block
 block discarded – undo
6734 6733
         // Send email
6735 6734
         $dataItem = DB::queryFirstRow(
6736 6735
             'SELECT label, id_tree
6737
-            FROM ' . prefixTable('items') . '
6736
+            FROM ' . prefixTable('items').'
6738 6737
             WHERE id = %i',
6739 6738
             $inputData['itemId']
6740 6739
         );
@@ -6788,7 +6787,7 @@  discard block
 block discarded – undo
6788 6787
 
6789 6788
         DB::query(
6790 6789
             'SELECT *
6791
-            FROM ' . prefixTable('notification') . '
6790
+            FROM ' . prefixTable('notification').'
6792 6791
             WHERE item_id = %i AND user_id = %i',
6793 6792
             $inputData['itemId'],
6794 6793
             $session->get('user-id')
@@ -6860,7 +6859,7 @@  discard block
 block discarded – undo
6860 6859
         // And related logs
6861 6860
         $rows = DB::query(
6862 6861
             'SELECT id, file AS filename
6863
-            FROM ' . prefixTable('files') . '
6862
+            FROM ' . prefixTable('files').'
6864 6863
             WHERE id_item = %i AND confirmed = %i',
6865 6864
             $inputData['itemId'],
6866 6865
             0
@@ -6874,12 +6873,12 @@  discard block
 block discarded – undo
6874 6873
             );
6875 6874
 
6876 6875
             // Delete file on server
6877
-            unlink($SETTINGS['path_to_upload_folder'] . '/' . TP_FILE_PREFIX . base64_decode($file['filename']));
6876
+            unlink($SETTINGS['path_to_upload_folder'].'/'.TP_FILE_PREFIX.base64_decode($file['filename']));
6878 6877
 
6879 6878
             // Delete related logs
6880 6879
             $logFile = DB::query(
6881 6880
                 'SELECT increment_id, raison
6882
-                FROM ' . prefixTable('log_items') . '
6881
+                FROM ' . prefixTable('log_items').'
6883 6882
                 WHERE id_item = %i AND id_user = %i AND action = %s AND raison LIKE "at_add_file :%"',
6884 6883
                 $inputData['itemId'],
6885 6884
                 $session->get('user-id'),
@@ -6938,7 +6937,7 @@  discard block
 block discarded – undo
6938 6937
         // Confirm attachments
6939 6938
         $rows = DB::query(
6940 6939
             'SELECT id, file AS filename
6941
-            FROM ' . prefixTable('files') . '
6940
+            FROM ' . prefixTable('files').'
6942 6941
             WHERE id_item = %i AND confirmed = %i',
6943 6942
             $inputData['itemId'],
6944 6943
             0
@@ -7054,7 +7053,7 @@  discard block
 block discarded – undo
7054 7053
             $successfulDeletions = array();
7055 7054
             $failedDeletions = array();
7056 7055
 
7057
-            foreach( $selectedItemIds as $itemId) {
7056
+            foreach ($selectedItemIds as $itemId) {
7058 7057
                 // Check that user can access this item
7059 7058
                 $granted = accessToItemIsGranted((int) $itemId, $SETTINGS);
7060 7059
                 if ($granted !== true) {
@@ -7065,7 +7064,7 @@  discard block
 block discarded – undo
7065 7064
                 // Load item data
7066 7065
                 $data = DB::queryFirstRow(
7067 7066
                     'SELECT id_tree, id, label
7068
-                    FROM ' . prefixTable('items') . '
7067
+                    FROM ' . prefixTable('items').'
7069 7068
                     WHERE id = %i',
7070 7069
                     $itemId
7071 7070
                 );
@@ -7148,15 +7147,15 @@  discard block
 block discarded – undo
7148 7147
         case 'autocomplete_tags':
7149 7148
             // Get a list off all existing TAGS
7150 7149
             $listOfTags = '';
7151
-            $rows = DB::query('SELECT tag FROM ' . prefixTable('tags') . ' WHERE tag LIKE %ss GROUP BY tag', $inputData['getTerm']);
7150
+            $rows = DB::query('SELECT tag FROM '.prefixTable('tags').' WHERE tag LIKE %ss GROUP BY tag', $inputData['getTerm']);
7152 7151
             foreach ($rows as $record) {
7153 7152
                 if (empty($listOfTags)) {
7154
-                    $listOfTags = '"' . $record['tag'] . '"';
7153
+                    $listOfTags = '"'.$record['tag'].'"';
7155 7154
                 } else {
7156
-                    $listOfTags .= ', "' . $record['tag'] . '"';
7155
+                    $listOfTags .= ', "'.$record['tag'].'"';
7157 7156
                 }
7158 7157
             }
7159
-            echo '[' . $listOfTags . ']';
7158
+            echo '['.$listOfTags.']';
7160 7159
             break;
7161 7160
     }
7162 7161
 }
@@ -7172,7 +7171,7 @@  discard block
 block discarded – undo
7172 7171
 {
7173 7172
     $data = DB::queryFirstRow(
7174 7173
         'SELECT bloquer_creation, bloquer_modification, personal_folder
7175
-        FROM ' . prefixTable('nested_tree') . ' WHERE id = %i',
7174
+        FROM ' . prefixTable('nested_tree').' WHERE id = %i',
7176 7175
         $groupe
7177 7176
     );
7178 7177
     // Check if it's in a personal folder. If yes, then force complexity overhead.
@@ -7292,7 +7291,7 @@  discard block
 block discarded – undo
7292 7291
     // Get item date
7293 7292
     $itemRestrictedUsersList = DB::queryFirstRow(
7294 7293
         'SELECT restricted_to
7295
-         FROM ' . prefixTable('items') . '
7294
+         FROM ' . prefixTable('items').'
7296 7295
          WHERE id = %i',
7297 7296
         $itemId
7298 7297
     );
@@ -7325,7 +7324,7 @@  discard block
 block discarded – undo
7325 7324
     $now = time();
7326 7325
     $editionLocks = DB::query(
7327 7326
         'SELECT timestamp, user_id, increment_id
7328
-         FROM ' . prefixTable('items_edition') . '
7327
+         FROM ' . prefixTable('items_edition').'
7329 7328
          WHERE item_id = %i 
7330 7329
          ORDER BY increment_id DESC',
7331 7330
         $itemId
@@ -7371,7 +7370,7 @@  discard block
 block discarded – undo
7371 7370
 
7372 7371
         // Delete related background tasks if any
7373 7372
         $task = DB::queryFirstRow(
7374
-            'SELECT increment_id FROM ' . prefixTable('background_tasks') . '
7373
+            'SELECT increment_id FROM '.prefixTable('background_tasks').'
7375 7374
              WHERE item_id = %i AND finished_at = ""',
7376 7375
             $itemId
7377 7376
         );
@@ -7384,7 +7383,7 @@  discard block
 block discarded – undo
7384 7383
         // Check if encryption process is still running
7385 7384
         DB::queryFirstRow(
7386 7385
             'SELECT JSON_EXTRACT(arguments, "$.all_users_except_id") AS all_users_except_id
7387
-             FROM ' . prefixTable('background_tasks') . '
7386
+             FROM ' . prefixTable('background_tasks').'
7388 7387
              WHERE item_id = %i AND finished_at = ""
7389 7388
              ORDER BY increment_id DESC',
7390 7389
             $itemId
@@ -7405,7 +7404,7 @@  discard block
 block discarded – undo
7405 7404
         }
7406 7405
 
7407 7406
         return [
7408
-            'status' => true,   // Encryption in progress
7407
+            'status' => true, // Encryption in progress
7409 7408
             'delay' => $delay - $elapsed, // Time remaining before the lock expires
7410 7409
         ];
7411 7410
     }
@@ -7450,7 +7449,7 @@  discard block
 block discarded – undo
7450 7449
 {
7451 7450
     // Check if there's an ongoing background encryption process for the item
7452 7451
     $ongoingProcess = DB::queryFirstRow(
7453
-        'SELECT 1 FROM ' . prefixTable('background_tasks') . ' WHERE item_id = %i AND finished_at = "" LIMIT 1', 
7452
+        'SELECT 1 FROM '.prefixTable('background_tasks').' WHERE item_id = %i AND finished_at = "" LIMIT 1', 
7454 7453
         $itemId
7455 7454
     );
7456 7455
 
@@ -7468,7 +7467,7 @@  discard block
 block discarded – undo
7468 7467
 function getUserVisibleFolders(int $userId): array
7469 7468
 {
7470 7469
     // Query to retrieve visible folders for the user
7471
-    $data = DB::queryFirstRow('SELECT visible_folders FROM ' . prefixTable('cache_tree') . ' WHERE user_id = %i', $userId);
7470
+    $data = DB::queryFirstRow('SELECT visible_folders FROM '.prefixTable('cache_tree').' WHERE user_id = %i', $userId);
7472 7471
     
7473 7472
     // Decode JSON data into an array; return an empty array if the data is invalid
7474 7473
     return json_decode($data['visible_folders'], true) ?? [];
@@ -7492,7 +7491,7 @@  discard block
 block discarded – undo
7492 7491
 
7493 7492
     // Query the access rights for the given roles and folder
7494 7493
     $accessTypes = DB::queryFirstColumn(
7495
-        'SELECT DISTINCT type FROM ' . prefixTable('roles_values') . ' WHERE role_id IN %ls AND folder_id = %i', 
7494
+        'SELECT DISTINCT type FROM '.prefixTable('roles_values').' WHERE role_id IN %ls AND folder_id = %i', 
7496 7495
         $roles, 
7497 7496
         $treeId
7498 7497
     );
Please login to merge, or discard this patch.
sources/main.queries.php 1 patch
Spacing   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 ) {
80 80
     // Not allowed page
81 81
     $session->set('system-error_code', ERR_NOT_ALLOWED);
82
-    include $SETTINGS['cpassman_dir'] . '/error.php';
82
+    include $SETTINGS['cpassman_dir'].'/error.php';
83 83
     exit;
84 84
 }
85 85
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
  * @param array $SETTINGS
208 208
  * @return string
209 209
  */
210
-function passwordHandler(string $post_type, array|null|string $dataReceived, array $SETTINGS): string
210
+function passwordHandler(string $post_type, array | null | string $dataReceived, array $SETTINGS): string
211 211
 {
212 212
     $session = SessionManager::getSession();
213 213
     $lang = new Language($session->get('user-language') ?? 'english');
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 
277 277
             // Get current user hash
278 278
             $userHash = DB::queryFirstRow(
279
-                "SELECT pw FROM " . prefixtable('users') . " WHERE id = %d;",
279
+                "SELECT pw FROM ".prefixtable('users')." WHERE id = %d;",
280 280
                 $session->get('user-id')
281 281
             )['pw'];
282 282
 
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
  * @param string $post_key
333 333
  * @return string
334 334
  */
335
-function userHandler(string $post_type, array|null|string $dataReceived, array $SETTINGS, string $post_key): string
335
+function userHandler(string $post_type, array | null | string $dataReceived, array $SETTINGS, string $post_key): string
336 336
 {
337 337
     $session = SessionManager::getSession();
338 338
 
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
     if (isset($dataReceived['user_id'])) {
368 368
         // Get info about user to modify
369 369
         $targetUserInfos = DB::queryFirstRow(
370
-            'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM ' . prefixTable('users') . '
370
+            'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM '.prefixTable('users').'
371 371
             WHERE id = %i',
372 372
             $dataReceived['user_id']
373 373
         );
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
         case 'mail_me'://action_mail
517 517
             // Get info about user to send email
518 518
             $data_user = DB::queryFirstRow(
519
-                'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM ' . prefixTable('users') . '
519
+                'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM '.prefixTable('users').'
520 520
                 WHERE email = %s',
521 521
                 filter_var($dataReceived['receipt'], FILTER_SANITIZE_FULL_SPECIAL_CHARS)
522 522
             );
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
     if (isset($dataReceived['user_id'])) {
637 637
         // Get info about user to modify
638 638
         $targetUserInfos = DB::queryFirstRow(
639
-            'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM ' . prefixTable('users') . '
639
+            'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM '.prefixTable('users').'
640 640
             WHERE id = %i',
641 641
             $dataReceived['user_id']
642 642
         );
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
 
721 721
             // Get current user hash
722 722
             $userHash = DB::queryFirstRow(
723
-                "SELECT pw FROM " . prefixtable('users') . " WHERE id = %d;",
723
+                "SELECT pw FROM ".prefixtable('users')." WHERE id = %d;",
724 724
                 $session->get('user-id')
725 725
             )['pw'];
726 726
 
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
 
759 759
                 // Get current user hash
760 760
                 $userHash = DB::queryFirstRow(
761
-                    "SELECT pw FROM " . prefixtable('users') . " WHERE id = %d;",
761
+                    "SELECT pw FROM ".prefixtable('users')." WHERE id = %d;",
762 762
                     $session->get('user-id')
763 763
                 )['pw'];
764 764
 
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 
804 804
                 // Get current user hash
805 805
                 $userHash = DB::queryFirstRow(
806
-                    "SELECT pw FROM " . prefixtable('users') . " WHERE id = %i;",
806
+                    "SELECT pw FROM ".prefixtable('users')." WHERE id = %i;",
807 807
                     $session->get('user-id')
808 808
                 )['pw'];
809 809
 
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
  * @param array $SETTINGS
856 856
  * @return string
857 857
  */
858
-function systemHandler(string $post_type, array|null|string $dataReceived, array $SETTINGS): string
858
+function systemHandler(string $post_type, array | null | string $dataReceived, array $SETTINGS): string
859 859
 {
860 860
     $session = SessionManager::getSession();
861 861
     switch ($post_type) {
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
                 )
957 957
             );
958 958
 
959
-            return '[{"token" : "' . $token . '"}]';
959
+            return '[{"token" : "'.$token.'"}]';
960 960
         
961 961
 
962 962
         /*
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
 }
996 996
 
997 997
 
998
-function utilsHandler(string $post_type, array|null|string $dataReceived, array $SETTINGS): string
998
+function utilsHandler(string $post_type, array | null | string $dataReceived, array $SETTINGS): string
999 999
 {
1000 1000
     switch ($post_type) {
1001 1001
         /*
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
         array(
1065 1065
             'error' => false,
1066 1066
             'timestamp' => $session->get('user-session_duration'),
1067
-            'max_time_to_add' => intdiv((($maximum_session_expiration_time*60) - ((int) $session->get('user-session_duration') - time())), 60),
1067
+            'max_time_to_add' => intdiv((($maximum_session_expiration_time * 60) - ((int) $session->get('user-session_duration') - time())), 60),
1068 1068
             'max_session_duration' => $maximum_session_expiration_time,
1069 1069
         ),
1070 1070
         'encode'
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
     // get number of items
1117 1117
     DB::queryFirstRow(
1118 1118
         'SELECT increment_id
1119
-        FROM ' . prefixTable('sharekeys_items') .
1119
+        FROM ' . prefixTable('sharekeys_items').
1120 1120
         ' WHERE user_id = %i',
1121 1121
         $userId
1122 1122
     );
@@ -1171,7 +1171,7 @@  discard block
 block discarded – undo
1171 1171
         // check if expected security level is reached
1172 1172
         $dataUser = DB::queryFirstRow(
1173 1173
             'SELECT *
1174
-            FROM ' . prefixTable('users') . ' WHERE id = %i',
1174
+            FROM ' . prefixTable('users').' WHERE id = %i',
1175 1175
             $post_user_id
1176 1176
         );
1177 1177
 
@@ -1192,8 +1192,8 @@  discard block
 block discarded – undo
1192 1192
         if (empty($dataUser['fonction_id']) === false) {
1193 1193
             $data = DB::queryFirstRow(
1194 1194
                 'SELECT complexity
1195
-                FROM ' . prefixTable('roles_title') . '
1196
-                WHERE id IN (' . $dataUser['fonction_id'] . ')
1195
+                FROM ' . prefixTable('roles_title').'
1196
+                WHERE id IN (' . $dataUser['fonction_id'].')
1197 1197
                 ORDER BY complexity DESC'
1198 1198
             );
1199 1199
         } else {
@@ -1206,8 +1206,8 @@  discard block
 block discarded – undo
1206 1206
             return prepareExchangedData(
1207 1207
                 array(
1208 1208
                     'error' => true,
1209
-                    'message' => '<div style="margin:10px 0 10px 15px;">' . $lang->get('complexity_level_not_reached') . '.<br>' .
1210
-                        $lang->get('expected_complexity_level') . ': <b>' . TP_PW_COMPLEXITY[$data['complexity']][1] . '</b></div>',
1209
+                    'message' => '<div style="margin:10px 0 10px 15px;">'.$lang->get('complexity_level_not_reached').'.<br>'.
1210
+                        $lang->get('expected_complexity_level').': <b>'.TP_PW_COMPLEXITY[$data['complexity']][1].'</b></div>',
1211 1211
                 ),
1212 1212
                 'encode'
1213 1213
             );
@@ -1311,14 +1311,14 @@  discard block
 block discarded – undo
1311 1311
         // Get data about user
1312 1312
         $dataUser = DB::queryFirstRow(
1313 1313
             'SELECT id, email, pw
1314
-            FROM ' . prefixTable('users') . '
1314
+            FROM ' . prefixTable('users').'
1315 1315
             WHERE login = %s',
1316 1316
             $post_login
1317 1317
         );
1318 1318
     } else {
1319 1319
         $dataUser = DB::queryFirstRow(
1320 1320
             'SELECT id, login, email, pw
1321
-            FROM ' . prefixTable('users') . '
1321
+            FROM ' . prefixTable('users').'
1322 1322
             WHERE id = %i',
1323 1323
             $post_id
1324 1324
         );
@@ -1372,7 +1372,7 @@  discard block
 block discarded – undo
1372 1372
     // Check if token already used
1373 1373
     $dataToken = DB::queryFirstRow(
1374 1374
         'SELECT end_timestamp, reason
1375
-        FROM ' . prefixTable('tokens') . '
1375
+        FROM ' . prefixTable('tokens').'
1376 1376
         WHERE token = %s AND user_id = %i',
1377 1377
         $post_token,
1378 1378
         $dataUser['id']
@@ -1383,11 +1383,11 @@  discard block
 block discarded – undo
1383 1383
         return prepareExchangedData(
1384 1384
             array(
1385 1385
                 'error' => true,
1386
-                'message' => 'TOKEN already used',//$lang->get('no_email_set'),
1386
+                'message' => 'TOKEN already used', //$lang->get('no_email_set'),
1387 1387
             ),
1388 1388
             'encode'
1389 1389
         );
1390
-    } elseif(DB::count() === 0) {
1390
+    } elseif (DB::count() === 0) {
1391 1391
         // Store token for this action
1392 1392
         DB::insert(
1393 1393
             prefixTable('tokens'),
@@ -1449,7 +1449,7 @@  discard block
 block discarded – undo
1449 1449
                 'email' => $dataUser['email'],
1450 1450
                 'email_result' => str_replace(
1451 1451
                     '#email#',
1452
-                    '<b>' . obfuscateEmail($dataUser['email']) . '</b>',
1452
+                    '<b>'.obfuscateEmail($dataUser['email']).'</b>',
1453 1453
                     addslashes($lang->get('admin_email_result_ok'))
1454 1454
                 ),
1455 1455
             ),
@@ -1465,7 +1465,7 @@  discard block
 block discarded – undo
1465 1465
             'email' => $dataUser['email'],
1466 1466
             'email_result' => str_replace(
1467 1467
                 '#email#',
1468
-                '<b>' . obfuscateEmail($dataUser['email']) . '</b>',
1468
+                '<b>'.obfuscateEmail($dataUser['email']).'</b>',
1469 1469
                 addslashes($lang->get('admin_email_result_ok'))
1470 1470
             ),
1471 1471
         ),
@@ -1482,7 +1482,7 @@  discard block
 block discarded – undo
1482 1482
 
1483 1483
     if (isKeyExistingAndEqual('enable_send_email_on_user_login', 1, $SETTINGS) === true) {
1484 1484
         $row = DB::queryFirstRow(
1485
-            'SELECT valeur FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s',
1485
+            'SELECT valeur FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s',
1486 1486
             'cron',
1487 1487
             'sending_emails'
1488 1488
         );
@@ -1490,7 +1490,7 @@  discard block
 block discarded – undo
1490 1490
         if ((int) (time() - $row['valeur']) >= 300 || (int) $row['valeur'] === 0) {
1491 1491
             $rows = DB::query(
1492 1492
                 'SELECT *
1493
-                FROM ' . prefixTable('emails') .
1493
+                FROM ' . prefixTable('emails').
1494 1494
                 ' WHERE status != %s',
1495 1495
                 'sent'
1496 1496
             );
@@ -1542,8 +1542,8 @@  discard block
 block discarded – undo
1542 1542
     $arr_html = array();
1543 1543
     $rows = DB::query(
1544 1544
         'SELECT i.id AS id, i.label AS label, i.id_tree AS id_tree, l.date, i.perso AS perso, i.restricted_to AS restricted
1545
-        FROM ' . prefixTable('log_items') . ' AS l
1546
-        RIGHT JOIN ' . prefixTable('items') . ' AS i ON (l.id_item = i.id)
1545
+        FROM ' . prefixTable('log_items').' AS l
1546
+        RIGHT JOIN ' . prefixTable('items').' AS i ON (l.id_item = i.id)
1547 1547
         WHERE l.action = %s AND l.id_user = %i
1548 1548
         ORDER BY l.date DESC
1549 1549
         LIMIT 0, 100',
@@ -1575,7 +1575,7 @@  discard block
 block discarded – undo
1575 1575
     if (isKeyExistingAndEqual('enable_suggestion', 1, $SETTINGS) === true
1576 1576
         && ((int) $session->get('user-admin') === 1 || (int) $session->get('user-manager') === 1)
1577 1577
     ) {
1578
-        DB::query('SELECT * FROM ' . prefixTable('suggestion'));
1578
+        DB::query('SELECT * FROM '.prefixTable('suggestion'));
1579 1579
         $nb_suggestions_waiting = DB::count();
1580 1580
     }
1581 1581
 
@@ -1610,13 +1610,13 @@  discard block
 block discarded – undo
1610 1610
             if ($data === 'stat_languages') {
1611 1611
                 $tmp = '';
1612 1612
                 foreach ($stats_data[$data] as $key => $value) {
1613
-                    $tmp .= $tmp === '' ? $key . '-' . $value : ',' . $key . '-' . $value;
1613
+                    $tmp .= $tmp === '' ? $key.'-'.$value : ','.$key.'-'.$value;
1614 1614
                 }
1615 1615
                 $statsToSend[$data] = $tmp;
1616 1616
             } elseif ($data === 'stat_country') {
1617 1617
                 $tmp = '';
1618 1618
                 foreach ($stats_data[$data] as $key => $value) {
1619
-                    $tmp .= $tmp === '' ? $key . '-' . $value : ',' . $key . '-' . $value;
1619
+                    $tmp .= $tmp === '' ? $key.'-'.$value : ','.$key.'-'.$value;
1620 1620
                 }
1621 1621
                 $statsToSend[$data] = $tmp;
1622 1622
             } else {
@@ -1703,7 +1703,7 @@  discard block
 block discarded – undo
1703 1703
             $url_found = $value;
1704 1704
             if (empty($url_found) === false) {
1705 1705
                 $tmp = parse_url($url_found);
1706
-                $anonym_url = $tmp['scheme'] . '://<anonym_url>' . (isset($tmp['path']) === true ? $tmp['path'] : '');
1706
+                $anonym_url = $tmp['scheme'].'://<anonym_url>'.(isset($tmp['path']) === true ? $tmp['path'] : '');
1707 1707
                 $value = $anonym_url;
1708 1708
             } else {
1709 1709
                 $value = '';
@@ -1733,7 +1733,7 @@  discard block
 block discarded – undo
1733 1733
     $teampass_errors = '';
1734 1734
     $rows = DB::query(
1735 1735
         'SELECT label, date AS error_date
1736
-        FROM ' . prefixTable('log_system') . "
1736
+        FROM ' . prefixTable('log_system')."
1737 1737
         WHERE `type` LIKE 'error'
1738 1738
         ORDER BY `date` DESC
1739 1739
         LIMIT 0, 10"
@@ -1741,9 +1741,9 @@  discard block
 block discarded – undo
1741 1741
     if (DB::count() > 0) {
1742 1742
         foreach ($rows as $record) {
1743 1743
             if (empty($teampass_errors) === true) {
1744
-                $teampass_errors = ' * ' . date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['error_date']) . ' - ' . $record['label'];
1744
+                $teampass_errors = ' * '.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['error_date']).' - '.$record['label'];
1745 1745
             } else {
1746
-                $teampass_errors .= ' * ' . date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['error_date']) . ' - ' . $record['label'];
1746
+                $teampass_errors .= ' * '.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['error_date']).' - '.$record['label'];
1747 1747
             }
1748 1748
         }
1749 1749
     }
@@ -1755,7 +1755,7 @@  discard block
 block discarded – undo
1755 1755
 
1756 1756
     // Now prepare text
1757 1757
     $txt = '### Page on which it happened
1758
-' . $data['current_page'] . '
1758
+' . $data['current_page'].'
1759 1759
 
1760 1760
 ### Steps to reproduce
1761 1761
 1.
@@ -1770,39 +1770,39 @@  discard block
 block discarded – undo
1770 1770
 Tell us what happens instead
1771 1771
 
1772 1772
 ### Server configuration
1773
-**Operating system**: ' . php_uname() . '
1773
+**Operating system**: ' . php_uname().'
1774 1774
 
1775
-**Web server:** ' . $_SERVER['SERVER_SOFTWARE'] . '
1775
+**Web server:** ' . $_SERVER['SERVER_SOFTWARE'].'
1776 1776
 
1777
-**Database:** ' . ($link === false ? $lang->get('undefined') : mysqli_get_server_info($link)) . '
1777
+**Database:** ' . ($link === false ? $lang->get('undefined') : mysqli_get_server_info($link)).'
1778 1778
 
1779
-**PHP version:** ' . PHP_VERSION . '
1779
+**PHP version:** ' . PHP_VERSION.'
1780 1780
 
1781
-**Teampass version:** ' . TP_VERSION . '.' . TP_VERSION_MINOR . '
1781
+**Teampass version:** ' . TP_VERSION.'.'.TP_VERSION_MINOR.'
1782 1782
 
1783 1783
 **Teampass configuration variables:**
1784 1784
 ```
1785
-' . $list_of_options . '
1785
+' . $list_of_options.'
1786 1786
 ```
1787 1787
 
1788 1788
 **Updated from an older Teampass or fresh install:**
1789 1789
 
1790 1790
 ### Client configuration
1791 1791
 
1792
-**Browser:** ' . $data['browser_name'] . ' - ' . $data['browser_version'] . '
1792
+**Browser:** ' . $data['browser_name'].' - '.$data['browser_version'].'
1793 1793
 
1794
-**Operating system:** ' . $data['os'] . ' - ' . $data['os_archi'] . 'bits
1794
+**Operating system:** ' . $data['os'].' - '.$data['os_archi'].'bits
1795 1795
 
1796 1796
 ### Logs
1797 1797
 
1798 1798
 #### Web server error log
1799 1799
 ```
1800
-' . $err['message'] . ' - ' . $err['file'] . ' (' . $err['line'] . ')
1800
+' . $err['message'].' - '.$err['file'].' ('.$err['line'].')
1801 1801
 ```
1802 1802
 
1803 1803
 #### Teampass 10 last system errors
1804 1804
 ```
1805
-' . $teampass_errors . '
1805
+' . $teampass_errors.'
1806 1806
 ```
1807 1807
 
1808 1808
 #### Log from the web-browser developer console (CTRL + SHIFT + i)
@@ -1844,7 +1844,7 @@  discard block
 block discarded – undo
1844 1844
         // Check if user exists
1845 1845
         $userInfo = DB::queryFirstRow(
1846 1846
             'SELECT public_key, private_key, pw, auth_type
1847
-            FROM ' . prefixTable('users') . '
1847
+            FROM ' . prefixTable('users').'
1848 1848
             WHERE id = %i',
1849 1849
             $post_user_id
1850 1850
         );
@@ -1853,9 +1853,9 @@  discard block
 block discarded – undo
1853 1853
             // Get one item
1854 1854
             $currentUserKey = DB::queryFirstRow(
1855 1855
                 'SELECT object_id, share_key, increment_id
1856
-                FROM ' . prefixTable('sharekeys_items') . ' AS si
1857
-                INNER JOIN ' . prefixTable('items') . ' AS i ON  (i.id = si.object_id)
1858
-                INNER JOIN ' . prefixTable('nested_tree') . ' AS nt ON  (i.id_tree = nt.id)
1856
+                FROM ' . prefixTable('sharekeys_items').' AS si
1857
+                INNER JOIN ' . prefixTable('items').' AS i ON  (i.id = si.object_id)
1858
+                INNER JOIN ' . prefixTable('nested_tree').' AS nt ON  (i.id_tree = nt.id)
1859 1859
                 WHERE user_id = %i AND nt.personal_folder = %i',
1860 1860
                 $post_user_id,
1861 1861
                 0
@@ -1974,7 +1974,7 @@  discard block
 block discarded – undo
1974 1974
         // Get user info
1975 1975
         $userData = DB::queryFirstRow(
1976 1976
             'SELECT private_key
1977
-            FROM ' . prefixTable('users') . '
1977
+            FROM ' . prefixTable('users').'
1978 1978
             WHERE id = %i',
1979 1979
             $post_user_id
1980 1980
         );
@@ -2066,7 +2066,7 @@  discard block
 block discarded – undo
2066 2066
         // Get user info
2067 2067
         $userData = DB::queryFirstRow(
2068 2068
             'SELECT email, auth_type, login
2069
-            FROM ' . prefixTable('users') . '
2069
+            FROM ' . prefixTable('users').'
2070 2070
             WHERE id = %i',
2071 2071
             $post_user_id
2072 2072
         );
@@ -2164,7 +2164,7 @@  discard block
 block discarded – undo
2164 2164
         // Get user info
2165 2165
         $userData = DB::queryFirstRow(
2166 2166
             'SELECT email, auth_type, login
2167
-            FROM ' . prefixTable('users') . '
2167
+            FROM ' . prefixTable('users').'
2168 2168
             WHERE id = %i',
2169 2169
             $userId
2170 2170
         );
@@ -2223,7 +2223,7 @@  discard block
 block discarded – undo
2223 2223
         // Check if user exists
2224 2224
         DB::queryFirstRow(
2225 2225
             'SELECT *
2226
-            FROM ' . prefixTable('users') . '
2226
+            FROM ' . prefixTable('users').'
2227 2227
             WHERE id = %i',
2228 2228
             $post_user_id
2229 2229
         );
@@ -2293,7 +2293,7 @@  discard block
 block discarded – undo
2293 2293
         // Check if user exists
2294 2294
         $userInfo = DB::queryFirstRow(
2295 2295
             'SELECT public_key
2296
-            FROM ' . prefixTable('users') . '
2296
+            FROM ' . prefixTable('users').'
2297 2297
             WHERE id = %i',
2298 2298
             $post_user_id
2299 2299
         );
@@ -2441,15 +2441,15 @@  discard block
 block discarded – undo
2441 2441
     // Loop on items
2442 2442
     $rows = DB::query(
2443 2443
         'SELECT id, pw
2444
-        FROM ' . prefixTable('items') . '
2444
+        FROM ' . prefixTable('items').'
2445 2445
         WHERE perso = 0
2446
-        LIMIT ' . $post_start . ', ' . $post_length
2446
+        LIMIT ' . $post_start.', '.$post_length
2447 2447
     );
2448 2448
     foreach ($rows as $record) {
2449 2449
         // Get itemKey from current user
2450 2450
         $currentUserKey = DB::queryFirstRow(
2451 2451
             'SELECT share_key, increment_id
2452
-            FROM ' . prefixTable('sharekeys_items') . '
2452
+            FROM ' . prefixTable('sharekeys_items').'
2453 2453
             WHERE object_id = %i AND user_id = %i',
2454 2454
             $record['id'],
2455 2455
             $session->get('user-id')
@@ -2479,7 +2479,7 @@  discard block
 block discarded – undo
2479 2479
             if ((int) $post_user_id !== (int) $session->get('user-id')) {
2480 2480
                 $currentUserKey = DB::queryFirstRow(
2481 2481
                     'SELECT increment_id
2482
-                    FROM ' . prefixTable('sharekeys_items') . '
2482
+                    FROM ' . prefixTable('sharekeys_items').'
2483 2483
                     WHERE object_id = %i AND user_id = %i',
2484 2484
                     $record['id'],
2485 2485
                     $post_user_id
@@ -2510,7 +2510,7 @@  discard block
 block discarded – undo
2510 2510
     // SHould we change step?
2511 2511
     DB::query(
2512 2512
         'SELECT *
2513
-        FROM ' . prefixTable('items') . '
2513
+        FROM ' . prefixTable('items').'
2514 2514
         WHERE perso = 0'
2515 2515
     );
2516 2516
 
@@ -2535,15 +2535,15 @@  discard block
 block discarded – undo
2535 2535
     // Loop on logs
2536 2536
     $rows = DB::query(
2537 2537
         'SELECT increment_id
2538
-        FROM ' . prefixTable('log_items') . '
2538
+        FROM ' . prefixTable('log_items').'
2539 2539
         WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"
2540
-        LIMIT ' . $post_start . ', ' . $post_length
2540
+        LIMIT ' . $post_start.', '.$post_length
2541 2541
     );
2542 2542
     foreach ($rows as $record) {
2543 2543
         // Get itemKey from current user
2544 2544
         $currentUserKey = DB::queryFirstRow(
2545 2545
             'SELECT share_key
2546
-            FROM ' . prefixTable('sharekeys_logs') . '
2546
+            FROM ' . prefixTable('sharekeys_logs').'
2547 2547
             WHERE object_id = %i AND user_id = %i',
2548 2548
             $record['increment_id'],
2549 2549
             $session->get('user-id')
@@ -2573,7 +2573,7 @@  discard block
 block discarded – undo
2573 2573
             if ((int) $post_user_id !== (int) $session->get('user-id')) {
2574 2574
                 $currentUserKey = DB::queryFirstRow(
2575 2575
                     'SELECT increment_id
2576
-                    FROM ' . prefixTable('sharekeys_items') . '
2576
+                    FROM ' . prefixTable('sharekeys_items').'
2577 2577
                     WHERE object_id = %i AND user_id = %i',
2578 2578
                     $record['id'],
2579 2579
                     $post_user_id
@@ -2595,7 +2595,7 @@  discard block
 block discarded – undo
2595 2595
     // SHould we change step?
2596 2596
     DB::query(
2597 2597
         'SELECT increment_id
2598
-        FROM ' . prefixTable('log_items') . '
2598
+        FROM ' . prefixTable('log_items').'
2599 2599
         WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"'
2600 2600
     );
2601 2601
 
@@ -2620,15 +2620,15 @@  discard block
 block discarded – undo
2620 2620
     // Loop on fields
2621 2621
     $rows = DB::query(
2622 2622
         'SELECT id
2623
-        FROM ' . prefixTable('categories_items') . '
2623
+        FROM ' . prefixTable('categories_items').'
2624 2624
         WHERE encryption_type = "teampass_aes"
2625
-        LIMIT ' . $post_start . ', ' . $post_length
2625
+        LIMIT ' . $post_start.', '.$post_length
2626 2626
     );
2627 2627
     foreach ($rows as $record) {
2628 2628
         // Get itemKey from current user
2629 2629
         $currentUserKey = DB::queryFirstRow(
2630 2630
             'SELECT share_key
2631
-            FROM ' . prefixTable('sharekeys_fields') . '
2631
+            FROM ' . prefixTable('sharekeys_fields').'
2632 2632
             WHERE object_id = %i AND user_id = %i',
2633 2633
             $record['id'],
2634 2634
             $session->get('user-id')
@@ -2658,7 +2658,7 @@  discard block
 block discarded – undo
2658 2658
             if ((int) $post_user_id !== (int) $session->get('user-id')) {
2659 2659
                 $currentUserKey = DB::queryFirstRow(
2660 2660
                     'SELECT increment_id
2661
-                    FROM ' . prefixTable('sharekeys_items') . '
2661
+                    FROM ' . prefixTable('sharekeys_items').'
2662 2662
                     WHERE object_id = %i AND user_id = %i',
2663 2663
                     $record['id'],
2664 2664
                     $post_user_id
@@ -2680,7 +2680,7 @@  discard block
 block discarded – undo
2680 2680
     // SHould we change step?
2681 2681
     DB::query(
2682 2682
         'SELECT *
2683
-        FROM ' . prefixTable('categories_items') . '
2683
+        FROM ' . prefixTable('categories_items').'
2684 2684
         WHERE encryption_type = "teampass_aes"'
2685 2685
     );
2686 2686
 
@@ -2705,14 +2705,14 @@  discard block
 block discarded – undo
2705 2705
     // Loop on suggestions
2706 2706
     $rows = DB::query(
2707 2707
         'SELECT id
2708
-        FROM ' . prefixTable('suggestion') . '
2709
-        LIMIT ' . $post_start . ', ' . $post_length
2708
+        FROM ' . prefixTable('suggestion').'
2709
+        LIMIT ' . $post_start.', '.$post_length
2710 2710
     );
2711 2711
     foreach ($rows as $record) {
2712 2712
         // Get itemKey from current user
2713 2713
         $currentUserKey = DB::queryFirstRow(
2714 2714
             'SELECT share_key
2715
-            FROM ' . prefixTable('sharekeys_suggestions') . '
2715
+            FROM ' . prefixTable('sharekeys_suggestions').'
2716 2716
             WHERE object_id = %i AND user_id = %i',
2717 2717
             $record['id'],
2718 2718
             $session->get('user-id')
@@ -2742,7 +2742,7 @@  discard block
 block discarded – undo
2742 2742
             if ((int) $post_user_id !== (int) $session->get('user-id')) {
2743 2743
                 $currentUserKey = DB::queryFirstRow(
2744 2744
                     'SELECT increment_id
2745
-                    FROM ' . prefixTable('sharekeys_items') . '
2745
+                    FROM ' . prefixTable('sharekeys_items').'
2746 2746
                     WHERE object_id = %i AND user_id = %i',
2747 2747
                     $record['id'],
2748 2748
                     $post_user_id
@@ -2788,15 +2788,15 @@  discard block
 block discarded – undo
2788 2788
     // Loop on files
2789 2789
     $rows = DB::query(
2790 2790
         'SELECT id
2791
-        FROM ' . prefixTable('files') . '
2792
-        WHERE status = "' . TP_ENCRYPTION_NAME . '"
2793
-        LIMIT ' . $post_start . ', ' . $post_length
2791
+        FROM ' . prefixTable('files').'
2792
+        WHERE status = "' . TP_ENCRYPTION_NAME.'"
2793
+        LIMIT ' . $post_start.', '.$post_length
2794 2794
     ); //aes_encryption
2795 2795
     foreach ($rows as $record) {
2796 2796
         // Get itemKey from current user
2797 2797
         $currentUserKey = DB::queryFirstRow(
2798 2798
             'SELECT share_key
2799
-            FROM ' . prefixTable('sharekeys_files') . '
2799
+            FROM ' . prefixTable('sharekeys_files').'
2800 2800
             WHERE object_id = %i AND user_id = %i',
2801 2801
             $record['id'],
2802 2802
             $session->get('user-id')
@@ -2826,7 +2826,7 @@  discard block
 block discarded – undo
2826 2826
             if ((int) $post_user_id !== (int) $session->get('user-id')) {
2827 2827
                 $currentUserKey = DB::queryFirstRow(
2828 2828
                     'SELECT increment_id
2829
-                    FROM ' . prefixTable('sharekeys_items') . '
2829
+                    FROM ' . prefixTable('sharekeys_items').'
2830 2830
                     WHERE object_id = %i AND user_id = %i',
2831 2831
                     $record['id'],
2832 2832
                     $post_user_id
@@ -2848,8 +2848,8 @@  discard block
 block discarded – undo
2848 2848
     // SHould we change step?
2849 2849
     DB::query(
2850 2850
         'SELECT *
2851
-        FROM ' . prefixTable('files') . '
2852
-        WHERE status = "' . TP_ENCRYPTION_NAME . '"'
2851
+        FROM ' . prefixTable('files').'
2852
+        WHERE status = "' . TP_ENCRYPTION_NAME.'"'
2853 2853
     );
2854 2854
 
2855 2855
     $next_start = (int) $post_start + (int) $post_length;
@@ -2882,9 +2882,9 @@  discard block
 block discarded – undo
2882 2882
     if (count($session->get('user-personal_folders')) > 0) {
2883 2883
         $rows = DB::query(
2884 2884
             'SELECT id, pw
2885
-            FROM ' . prefixTable('items') . '
2885
+            FROM ' . prefixTable('items').'
2886 2886
             WHERE perso = 1 AND id_tree IN %ls AND encryption_type = %s
2887
-            LIMIT ' . $post_start . ', ' . $post_length,
2887
+            LIMIT ' . $post_start.', '.$post_length,
2888 2888
             $session->get('user-personal_folders'),
2889 2889
             "defuse"
2890 2890
         );
@@ -2892,7 +2892,7 @@  discard block
 block discarded – undo
2892 2892
             // Get itemKey from current user
2893 2893
             $currentUserKey = DB::queryFirstRow(
2894 2894
                 'SELECT share_key, increment_id
2895
-                FROM ' . prefixTable('sharekeys_items') . '
2895
+                FROM ' . prefixTable('sharekeys_items').'
2896 2896
                 WHERE object_id = %i AND user_id = %i',
2897 2897
                 $record['id'],
2898 2898
                 $session->get('user-id')
@@ -2917,7 +2917,7 @@  discard block
 block discarded – undo
2917 2917
                 if ((int) $post_user_id !== (int) $session->get('user-id')) {
2918 2918
                     $currentUserKey = DB::queryFirstRow(
2919 2919
                         'SELECT increment_id
2920
-                        FROM ' . prefixTable('sharekeys_items') . '
2920
+                        FROM ' . prefixTable('sharekeys_items').'
2921 2921
                         WHERE object_id = %i AND user_id = %i',
2922 2922
                         $record['id'],
2923 2923
                         $post_user_id
@@ -2940,7 +2940,7 @@  discard block
 block discarded – undo
2940 2940
     // SHould we change step?
2941 2941
     DB::query(
2942 2942
         'SELECT *
2943
-        FROM ' . prefixTable('items') . '
2943
+        FROM ' . prefixTable('items').'
2944 2944
         WHERE perso = 0'
2945 2945
     );
2946 2946
 
@@ -2968,7 +2968,7 @@  discard block
 block discarded – undo
2968 2968
         // Check if user exists
2969 2969
         $userInfo = DB::queryFirstRow(
2970 2970
             'SELECT public_key, encrypted_psk
2971
-            FROM ' . prefixTable('users') . '
2971
+            FROM ' . prefixTable('users').'
2972 2972
             WHERE id = %i',
2973 2973
             $post_user_id
2974 2974
         );
@@ -2994,7 +2994,7 @@  discard block
 block discarded – undo
2994 2994
                 if ($post_counterItemsToTreat === -1) {
2995 2995
                     DB::query(
2996 2996
                         'SELECT id
2997
-                        FROM ' . prefixTable('items') . '
2997
+                        FROM ' . prefixTable('items').'
2998 2998
                         WHERE perso = 1 AND id_tree IN %ls AND encryption_type != %s',
2999 2999
                         $session->get('user-personal_folders'),
3000 3000
                         'teampass_aes'
@@ -3007,7 +3007,7 @@  discard block
 block discarded – undo
3007 3007
                 // Loop on persoanl items
3008 3008
                 $rows = DB::query(
3009 3009
                     'SELECT id, pw
3010
-                    FROM ' . prefixTable('items') . '
3010
+                    FROM ' . prefixTable('items').'
3011 3011
                     WHERE perso = 1 AND id_tree IN %ls AND encryption_type != %s
3012 3012
                     LIMIT ' . $post_length,
3013 3013
                     $session->get('user-personal_folders'),
@@ -3049,7 +3049,7 @@  discard block
 block discarded – undo
3049 3049
                     // Loop on files
3050 3050
                     $rows = DB::query(
3051 3051
                         'SELECT id, file
3052
-                        FROM ' . prefixTable('files') . '
3052
+                        FROM ' . prefixTable('files').'
3053 3053
                         WHERE status != %s
3054 3054
                         AND id_item = %i',
3055 3055
                         TP_ENCRYPTION_NAME,
@@ -3060,13 +3060,13 @@  discard block
 block discarded – undo
3060 3060
                         // Now decrypt the file
3061 3061
                         prepareFileWithDefuse(
3062 3062
                             'decrypt',
3063
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record2['file'],
3064
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record2['file'] . '.delete',
3063
+                            $SETTINGS['path_to_upload_folder'].'/'.$record2['file'],
3064
+                            $SETTINGS['path_to_upload_folder'].'/'.$record2['file'].'.delete',
3065 3065
                             $post_user_psk
3066 3066
                         );
3067 3067
 
3068 3068
                         // Encrypt the file
3069
-                        $encryptedFile = encryptFile($record2['file'] . '.delete', $SETTINGS['path_to_upload_folder']);
3069
+                        $encryptedFile = encryptFile($record2['file'].'.delete', $SETTINGS['path_to_upload_folder']);
3070 3070
 
3071 3071
                         DB::update(
3072 3072
                             prefixTable('files'),
@@ -3087,7 +3087,7 @@  discard block
 block discarded – undo
3087 3087
                         );
3088 3088
 
3089 3089
                         // Unlink original file
3090
-                        unlink($SETTINGS['path_to_upload_folder'] . '/' . $record2['file']);
3090
+                        unlink($SETTINGS['path_to_upload_folder'].'/'.$record2['file']);
3091 3091
                     }
3092 3092
                 }
3093 3093
 
@@ -3095,7 +3095,7 @@  discard block
 block discarded – undo
3095 3095
                 $next_start = (int) $post_start + (int) $post_length;
3096 3096
                 DB::query(
3097 3097
                     'SELECT id
3098
-                    FROM ' . prefixTable('items') . '
3098
+                    FROM ' . prefixTable('items').'
3099 3099
                     WHERE perso = 1 AND id_tree IN %ls AND encryption_type != %s',
3100 3100
                     $session->get('user-personal_folders'),
3101 3101
                     'teampass_aes'
@@ -3165,7 +3165,7 @@  discard block
 block discarded – undo
3165 3165
         // Get user info
3166 3166
         $userData = DB::queryFirstRow(
3167 3167
             'SELECT special, auth_type, is_ready_for_usage, ongoing_process_id, otp_provided, personal_items_migrated
3168
-            FROM ' . prefixTable('users') . '
3168
+            FROM ' . prefixTable('users').'
3169 3169
             WHERE id = %i',
3170 3170
             $post_user_id
3171 3171
         );
@@ -3212,7 +3212,7 @@  discard block
 block discarded – undo
3212 3212
         // Get user info
3213 3213
         $userData = DB::queryFirstRow(
3214 3214
             'SELECT auth_type, login, private_key
3215
-            FROM ' . prefixTable('users') . '
3215
+            FROM ' . prefixTable('users').'
3216 3216
             WHERE id = %i',
3217 3217
             $post_user_id
3218 3218
         );
@@ -3262,7 +3262,7 @@  discard block
 block discarded – undo
3262 3262
                 return prepareExchangedData(
3263 3263
                     array(
3264 3264
                         'error' => false,
3265
-                        'message' => $lang->get('done'),'',
3265
+                        'message' => $lang->get('done'), '',
3266 3266
                     ),
3267 3267
                     'encode'
3268 3268
                 );
@@ -3311,7 +3311,7 @@  discard block
 block discarded – undo
3311 3311
         // Get user info
3312 3312
         $userData = DB::queryFirstRow(
3313 3313
             'SELECT u.auth_type, u.login, u.private_key, u.special
3314
-            FROM ' . prefixTable('users') . ' AS u
3314
+            FROM ' . prefixTable('users').' AS u
3315 3315
             WHERE u.id = %i',
3316 3316
             $post_user_id
3317 3317
         );
@@ -3347,7 +3347,7 @@  discard block
 block discarded – undo
3347 3347
                     return prepareExchangedData(
3348 3348
                         array(
3349 3349
                             'error' => false,
3350
-                            'message' => $lang->get('done'),'',
3350
+                            'message' => $lang->get('done'), '',
3351 3351
                         ),
3352 3352
                         'encode'
3353 3353
                     );
@@ -3368,8 +3368,8 @@  discard block
 block discarded – undo
3368 3368
                 // Get one itemKey from current user
3369 3369
                 $currentUserKey = DB::queryFirstRow(
3370 3370
                     'SELECT ski.share_key, ski.increment_id
3371
-                    FROM ' . prefixTable('sharekeys_items') . ' AS ski
3372
-                    INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = ski.object_id
3371
+                    FROM ' . prefixTable('sharekeys_items').' AS ski
3372
+                    INNER JOIN ' . prefixTable('items').' AS i ON i.id = ski.object_id
3373 3373
                     WHERE ski.user_id = %i AND ski.share_key != ""
3374 3374
                     ORDER BY RAND()
3375 3375
                     LIMIT 1',
@@ -3436,8 +3436,8 @@  discard block
 block discarded – undo
3436 3436
                             'process_type' => 'create_user_keys',
3437 3437
                             'arguments' => json_encode([
3438 3438
                                 'new_user_id' => (int) $post_user_id,
3439
-                                'new_user_pwd' => cryption($post_previous_pwd, '','encrypt')['string'],
3440
-                                'new_user_private_key' => cryption($validPreviousKey['private_key'], '','encrypt')['string'],
3439
+                                'new_user_pwd' => cryption($post_previous_pwd, '', 'encrypt')['string'],
3440
+                                'new_user_private_key' => cryption($validPreviousKey['private_key'], '', 'encrypt')['string'],
3441 3441
                                 'send_email' => 0,
3442 3442
                                 'otp_provided_new_value' => 0,
3443 3443
                                 'user_self_change' => 1,
@@ -3506,7 +3506,7 @@  discard block
 block discarded – undo
3506 3506
             id,
3507 3507
             private_key,
3508 3508
             created_at
3509
-        FROM " . prefixTable('user_private_keys') . "
3509
+        FROM " . prefixTable('user_private_keys')."
3510 3510
         WHERE user_id = %i
3511 3511
         ORDER BY created_at DESC, id DESC",
3512 3512
         $userId
@@ -3528,8 +3528,8 @@  discard block
 block discarded – undo
3528 3528
             // Select one personal item share_key to test decryption
3529 3529
             $currentUserItemKey = DB::queryFirstRow(
3530 3530
                 'SELECT si.share_key, si.increment_id, i.perso
3531
-                FROM ' . prefixTable('sharekeys_items') . ' AS si
3532
-                INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = si.object_id
3531
+                FROM ' . prefixTable('sharekeys_items').' AS si
3532
+                INNER JOIN ' . prefixTable('items').' AS i ON i.id = si.object_id
3533 3533
                 WHERE si.user_id = %i AND i.perso = 1 AND si.share_key != ""
3534 3534
                 ORDER BY RAND()
3535 3535
                 LIMIT 1',
@@ -3580,7 +3580,7 @@  discard block
 block discarded – undo
3580 3580
             $session->get('user-id')
3581 3581
         );
3582 3582
         // Return data
3583
-        return '[{"new_value":"' . $session->get('user-session_duration') . '"}]';
3583
+        return '[{"new_value":"'.$session->get('user-session_duration').'"}]';
3584 3584
     }
3585 3585
     
3586 3586
     return '[{"new_value":"expired"}]';
@@ -3630,8 +3630,8 @@  discard block
 block discarded – undo
3630 3630
 {
3631 3631
     $personalItems = DB::query(
3632 3632
         'SELECT i.id, i.pw, s.share_key, s.increment_id
3633
-        FROM ' . prefixTable('items') . ' i
3634
-        INNER JOIN ' . prefixTable('sharekeys_items') . ' s ON i.id = s.object_id
3633
+        FROM ' . prefixTable('items').' i
3634
+        INNER JOIN ' . prefixTable('sharekeys_items').' s ON i.id = s.object_id
3635 3635
         WHERE i.perso = %i
3636 3636
         AND s.user_id = %i',
3637 3637
         1,
@@ -3686,8 +3686,8 @@  discard block
 block discarded – undo
3686 3686
     if ($skipPasswordChange === true) {
3687 3687
         // Remove all sharekeys for personal items
3688 3688
         DB::query(
3689
-            'UPDATE ' . prefixTable('sharekeys_items') . ' AS ski
3690
-            INNER JOIN ' . prefixTable('items') . ' AS i ON ski.object_id = i.id
3689
+            'UPDATE '.prefixTable('sharekeys_items').' AS ski
3690
+            INNER JOIN ' . prefixTable('items').' AS i ON ski.object_id = i.id
3691 3691
             SET ski.share_key = ""
3692 3692
             WHERE i.perso = 1
3693 3693
             AND ski.user_id = %i',
@@ -3696,8 +3696,8 @@  discard block
 block discarded – undo
3696 3696
 
3697 3697
         // Remove all sharekeys for personal files
3698 3698
         DB::query(
3699
-            'UPDATE ' . prefixTable('sharekeys_files') . ' AS skf
3700
-            INNER JOIN ' . prefixTable('items') . ' AS i ON skf.object_id = i.id
3699
+            'UPDATE '.prefixTable('sharekeys_files').' AS skf
3700
+            INNER JOIN ' . prefixTable('items').' AS i ON skf.object_id = i.id
3701 3701
             SET skf.share_key = ""
3702 3702
             WHERE i.perso = 1
3703 3703
             AND skf.user_id = %i',
@@ -3706,8 +3706,8 @@  discard block
 block discarded – undo
3706 3706
 
3707 3707
         // Remove all sharekeys for personal fields
3708 3708
         DB::query(
3709
-            'UPDATE ' . prefixTable('sharekeys_fields') . ' AS skf
3710
-            INNER JOIN ' . prefixTable('items') . ' AS i ON skf.object_id = i.id
3709
+            'UPDATE '.prefixTable('sharekeys_fields').' AS skf
3710
+            INNER JOIN ' . prefixTable('items').' AS i ON skf.object_id = i.id
3711 3711
             SET skf.share_key = ""
3712 3712
             WHERE i.perso = 1
3713 3713
             AND skf.user_id = %i',
@@ -3751,8 +3751,8 @@  discard block
 block discarded – undo
3751 3751
                 'process_type' => 'create_user_keys',
3752 3752
                 'arguments' => json_encode([
3753 3753
                     'new_user_id' => (int) $userId,
3754
-                    'new_user_pwd' => cryption($userCurrentPwd, '','encrypt')['string'],
3755
-                    'new_user_private_key' => cryption($validPreviousKey['private_key'], '','encrypt')['string'],
3754
+                    'new_user_pwd' => cryption($userCurrentPwd, '', 'encrypt')['string'],
3755
+                    'new_user_private_key' => cryption($validPreviousKey['private_key'], '', 'encrypt')['string'],
3756 3756
                     'send_email' => 0,
3757 3757
                     'otp_provided_new_value' => 0,
3758 3758
                     'user_self_change' => 1,
Please login to merge, or discard this patch.
sources/utils.queries.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 ) {
74 74
     // Not allowed page
75 75
     $session->set('system-error_code', ERR_NOT_ALLOWED);
76
-    include $SETTINGS['cpassman_dir'] . '/error.php';
76
+    include $SETTINGS['cpassman_dir'].'/error.php';
77 77
     exit;
78 78
 }
79 79
 
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
                             i.label as label, i.description as description, i.pw as pw, i.login as login, i.pw_iv as pw_iv,
122 122
                             IFNULL(l.date, 0) as date,
123 123
                             n.renewal_period as renewal_period
124
-                        FROM ' . prefixTable('items') . ' as i
125
-                        INNER JOIN ' . prefixTable('nested_tree') . ' as n ON (i.id_tree = n.id)
126
-                        LEFT JOIN ' . prefixTable('log_items') . ' as l
124
+                        FROM ' . prefixTable('items').' as i
125
+                        INNER JOIN ' . prefixTable('nested_tree').' as n ON (i.id_tree = n.id)
126
+                        LEFT JOIN ' . prefixTable('log_items').' as l
127 127
                             ON (i.id = l.id_item AND (l.action = %s OR (l.action = %s AND l.raison LIKE %s)))
128 128
                         WHERE i.inactif = %i
129 129
                         AND i.id_tree= %i
Please login to merge, or discard this patch.
sources/tools.queries.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('tools') === false) {
71 71
     // Not allowed page
72 72
     $session->set('system-error_code', ERR_NOT_ALLOWED);
73
-    include $SETTINGS['cpassman_dir'] . '/error.php';
73
+    include $SETTINGS['cpassman_dir'].'/error.php';
74 74
     exit;
75 75
 }
76 76
 
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
         // Get TP_USER info
336 336
         $userInfo = DB::queryFirstRow(
337 337
             'SELECT pw, public_key, private_key, login, name
338
-            FROM ' . prefixTable('users') . '
338
+            FROM ' . prefixTable('users').'
339 339
             WHERE id = %i',
340 340
             TP_USER_ID
341 341
         );
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
         // Get one itemKey from current user
373 373
         $currentUserKey = DB::queryFirstRow(
374 374
             'SELECT ski.share_key, ski.increment_id AS increment_id
375
-            FROM ' . prefixTable('sharekeys_items') . ' AS ski
376
-            INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = ski.object_id
375
+            FROM ' . prefixTable('sharekeys_items').' AS ski
376
+            INNER JOIN ' . prefixTable('items').' AS i ON i.id = ski.object_id
377 377
             WHERE ski.user_id = %i AND ski.share_key != ""
378 378
             ORDER BY RAND()
379 379
             LIMIT 1',
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
         // Get user info
455 455
         $userInfo = DB::queryFirstRow(
456 456
             'SELECT public_key, private_key
457
-            FROM ' . prefixTable('users') . '
457
+            FROM ' . prefixTable('users').'
458 458
             WHERE id = %i',
459 459
             $userId
460 460
         );
@@ -477,8 +477,8 @@  discard block
 block discarded – undo
477 477
         // Get one itemKey from current user
478 478
         $currentUserKey = DB::queryFirstRow(
479 479
             'SELECT ski.share_key, ski.increment_id AS increment_id
480
-            FROM ' . prefixTable('sharekeys_items') . ' AS ski
481
-            INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = ski.object_id
480
+            FROM ' . prefixTable('sharekeys_items').' AS ski
481
+            INNER JOIN ' . prefixTable('items').' AS i ON i.id = ski.object_id
482 482
             WHERE ski.user_id = %i AND ski.share_key != ""
483 483
             ORDER BY RAND()
484 484
             LIMIT 1',
@@ -516,8 +516,8 @@  discard block
 block discarded – undo
516 516
                 // Get number of users to treat
517 517
                 DB::query(
518 518
                     'SELECT i.id 
519
-                    FROM ' . prefixTable('items') . ' AS i
520
-                    INNER JOIN ' . prefixTable('sharekeys_items') . ' AS si ON i.id = si.object_id
519
+                    FROM ' . prefixTable('items').' AS i
520
+                    INNER JOIN ' . prefixTable('sharekeys_items').' AS si ON i.id = si.object_id
521 521
                     WHERE i.perso = %i AND si.user_id = %i;',
522 522
                     0,
523 523
                     $userId
@@ -599,11 +599,11 @@  discard block
 block discarded – undo
599 599
             // Loop on items
600 600
             $rows = DB::query(
601 601
                 'SELECT si.object_id AS object_id, si.share_key AS share_key, i.pw AS pw, si.increment_id as increment_id
602
-                FROM ' . prefixTable('sharekeys_items') . ' AS si
603
-                INNER JOIN ' . prefixTable('items') . ' AS i ON (i.id = si.object_id)
602
+                FROM ' . prefixTable('sharekeys_items').' AS si
603
+                INNER JOIN ' . prefixTable('items').' AS i ON (i.id = si.object_id)
604 604
                 WHERE si.user_id = %i
605 605
                 ORDER BY si.increment_id ASC
606
-                LIMIT ' . $startIndex . ', ' . $limit,
606
+                LIMIT ' . $startIndex.', '.$limit,
607 607
                 $userId
608 608
             );        
609 609
             
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
                     // It will be updated if already exists
628 628
                     $currentTPUserKey = DB::queryFirstRow(
629 629
                         'SELECT increment_id, user_id, share_key
630
-                        FROM ' . prefixTable('sharekeys_items') . '
630
+                        FROM ' . prefixTable('sharekeys_items').'
631 631
                         WHERE object_id = %i AND user_id = %i',
632 632
                         $record['object_id'],
633 633
                         TP_USER_ID
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
             DB::commit();
664 664
         } catch (Exception $e) {
665 665
             DB::rollback();
666
-            error_log("Teampass - Error: Keys treatment: " . $e->getMessage());
666
+            error_log("Teampass - Error: Keys treatment: ".$e->getMessage());
667 667
         }
668 668
 
669 669
         $nextIndex = (int) $startIndex + (int) $limit;
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
             // Get PT_USER info
720 720
             DB::queryFirstRow(
721 721
                 'SELECT operation_code
722
-                FROM ' . prefixTable('sharekeys_backup') . '
722
+                FROM ' . prefixTable('sharekeys_backup').'
723 723
                 WHERE operation_code = %s',
724 724
                 $operationCode
725 725
             );
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
                 // using increment_id_value in order to update the correct record
730 730
                 $rows = DB::query(
731 731
                     'SELECT *
732
-                    FROM ' . prefixTable('sharekeys_backup') . '
732
+                    FROM ' . prefixTable('sharekeys_backup').'
733 733
                     WHERE operation_code = %s',
734 734
                     $operationCode
735 735
                 );
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
 
749 749
                 // Delete all sharekeys for this operation
750 750
                 DB::query(
751
-                    'DELETE FROM ' . prefixTable('sharekeys_backup') . '
751
+                    'DELETE FROM '.prefixTable('sharekeys_backup').'
752 752
                     WHERE operation_code = %i',
753 753
                     $operationCode
754 754
                 );
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
             // Get operation info
812 812
             DB::query(
813 813
                 'SELECT operation_code
814
-                FROM ' . prefixTable('sharekeys_backup') . '
814
+                FROM ' . prefixTable('sharekeys_backup').'
815 815
                 WHERE operation_code = %s',
816 816
                 $operationCode
817 817
             );
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
             if ($nbKeys > 0) {
821 821
                 // Delete all sharekeys for this operation
822 822
                 DB::query(
823
-                    'DELETE FROM ' . prefixTable('sharekeys_backup') . '
823
+                    'DELETE FROM '.prefixTable('sharekeys_backup').'
824 824
                     WHERE operation_code = %s',
825 825
                     $operationCode
826 826
                 );
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);
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
                         'SELECT i.id as id, i.id_tree as id_tree, i.restricted_to as restricted_to, i.perso as perso,
153 153
                             i.label as label, i.description as description, i.pw as pw, i.login as login, i.url as url,
154 154
                             i.email as email, IFNULL(l.date, 0) as date, i.pw_iv as pw_iv, n.renewal_period as renewal_period
155
-                        FROM ' . prefixTable('items') . ' as i
156
-                        INNER JOIN ' . prefixTable('nested_tree') . ' as n ON (i.id_tree = n.id)
157
-                        LEFT JOIN ' . prefixTable('log_items') . ' as l
155
+                        FROM ' . prefixTable('items').' as i
156
+                        INNER JOIN ' . prefixTable('nested_tree').' as n ON (i.id_tree = n.id)
157
+                        LEFT JOIN ' . prefixTable('log_items').' as l
158 158
                             ON (i.id = l.id_item AND (l.action = %s OR (l.action = %s AND l.raison LIKE %s)))
159 159
                         WHERE i.inactif = %i
160 160
                         AND i.id_tree= %i
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
                                 // Run query
178 178
                                 $dataItem = DB::queryFirstRow(
179 179
                                     'SELECT i.pw AS pw, s.share_key AS share_key
180
-                                    FROM ' . prefixTable('items') . ' AS i
181
-                                    INNER JOIN ' . prefixTable('sharekeys_items') . ' AS s ON (s.object_id = i.id)
180
+                                    FROM ' . prefixTable('items').' AS i
181
+                                    INNER JOIN ' . prefixTable('sharekeys_items').' AS s ON (s.object_id = i.id)
182 182
                                     WHERE user_id = %i AND i.id = %i',
183 183
                                     $session->get('user-id'),
184 184
                                     $record['id']
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
                                 $arr_kbs = [];
203 203
                                 $rows_kb = DB::query(
204 204
                                     'SELECT b.label, b.id
205
-                                    FROM ' . prefixTable('kb_items') . ' AS a
206
-                                    INNER JOIN ' . prefixTable('kb') . ' AS b ON (a.kb_id = b.id)
205
+                                    FROM ' . prefixTable('kb_items').' AS a
206
+                                    INNER JOIN ' . prefixTable('kb').' AS b ON (a.kb_id = b.id)
207 207
                                     WHERE a.item_id = %i',
208 208
                                     $record['id']
209 209
                                 );
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
                                 $arr_tags = [];
216 216
                                 $rows_tag = DB::query(
217 217
                                     'SELECT tag
218
-                                    FROM ' . prefixTable('tags') . '
218
+                                    FROM ' . prefixTable('tags').'
219 219
                                     WHERE item_id = %i',
220 220
                                     $record['id']
221 221
                                 );
@@ -227,18 +227,18 @@  discard block
 block discarded – undo
227 227
                                 $arr_trees = [];
228 228
                                 $rows_child_tree = DB::query(
229 229
                                     'SELECT t.id, t.title
230
-                                    FROM ' . prefixTable('nested_tree') . ' AS t
231
-                                    INNER JOIN ' . prefixTable('items') . ' AS i ON (t.id = i.id_tree)
230
+                                    FROM ' . prefixTable('nested_tree').' AS t
231
+                                    INNER JOIN ' . prefixTable('items').' AS i ON (t.id = i.id_tree)
232 232
                                     WHERE i.id = %i',
233 233
                                     $record['id']
234 234
                                 );
235 235
                                 foreach ($rows_child_tree as $rec_child_tree) {
236 236
                                     $stack = array();
237 237
                                     $parent = $rec_child_tree['id'];
238
-                                    while($parent != 0){
238
+                                    while ($parent != 0) {
239 239
                                         $rows_parent_tree = DB::query(
240 240
                                             'SELECT parent_id, title
241
-                                            FROM ' . prefixTable('nested_tree') . '
241
+                                            FROM ' . prefixTable('nested_tree').'
242 242
                                             WHERE id = %i',
243 243
                                             $parent
244 244
                                         );
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
             // Prepare variables
326 326
             $post_export_tag = filter_var($dataReceived['export_tag'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
327 327
             if (empty($post_export_tag) === false) {
328
-                DB::query('DELETE FROM ' . prefixTable('export') . ' WHERE export_tag = %s', $post_export_tag);
328
+                DB::query('DELETE FROM '.prefixTable('export').' WHERE export_tag = %s', $post_export_tag);
329 329
             }
330 330
             break;
331 331
 
@@ -375,9 +375,9 @@  discard block
 block discarded – undo
375 375
                         IFNULL(l.date, 0) as date, i.pw_iv as pw_iv,
376 376
                         n.renewal_period as renewal_period,
377 377
                         i.id_tree as tree_id
378
-                        FROM ' . prefixTable('items') . ' as i
379
-                        INNER JOIN ' . prefixTable('nested_tree') . ' as n ON (i.id_tree = n.id)
380
-                        LEFT JOIN ' . prefixTable('log_items') . ' as l
378
+                        FROM ' . prefixTable('items').' as i
379
+                        INNER JOIN ' . prefixTable('nested_tree').' as n ON (i.id_tree = n.id)
380
+                        LEFT JOIN ' . prefixTable('log_items').' as l
381 381
                             ON (i.id = l.id_item AND (l.action = %s OR (l.action = %s AND l.raison LIKE %s)))
382 382
                         WHERE i.inactif = %i
383 383
                         AND i.id_tree= %i
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
                             // Run query
404 404
                             $dataItem = DB::queryFirstRow(
405 405
                                 'SELECT i.pw AS pw, s.share_key AS share_key
406
-                                FROM ' . prefixTable('items') . ' AS i
407
-                                INNER JOIN ' . prefixTable('sharekeys_items') . ' AS s ON (s.object_id = i.id)
406
+                                FROM ' . prefixTable('items').' AS i
407
+                                INNER JOIN ' . prefixTable('sharekeys_items').' AS s ON (s.object_id = i.id)
408 408
                                 WHERE user_id = %i AND i.id = %i',
409 409
                                 $session->get('user-id'),
410 410
                                 $record['id']
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 428
                             $arr_kbs = '';
429 429
                             $rows_kb = DB::query(
430 430
                                 'SELECT b.label, b.id
431
-                                FROM ' . prefixTable('kb_items') . ' AS a
432
-                                INNER JOIN ' . prefixTable('kb') . ' AS b ON (a.kb_id = b.id)
431
+                                FROM ' . prefixTable('kb_items').' AS a
432
+                                INNER JOIN ' . prefixTable('kb').' AS b ON (a.kb_id = b.id)
433 433
                                 WHERE a.item_id = %i',
434 434
                                 $record['id']
435 435
                             );
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
                                 if (empty($arr_kbs)) {
438 438
                                     $arr_kbs = $rec_kb['label'];
439 439
                                 } else {
440
-                                    $arr_kbs .= ' | ' . $rec_kb['label'];
440
+                                    $arr_kbs .= ' | '.$rec_kb['label'];
441 441
                                 }
442 442
                             }
443 443
 
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
                             $arr_tags = '';
446 446
                             $rows_tag = DB::query(
447 447
                                 'SELECT tag
448
-                                FROM ' . prefixTable('tags') . '
448
+                                FROM ' . prefixTable('tags').'
449 449
                                 WHERE item_id = %i',
450 450
                                 $record['id']
451 451
                             );
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
                                 if (empty($arr_tags)) {
454 454
                                     $arr_tags = $rec_tag['tag'];
455 455
                                 } else {
456
-                                    $arr_tags .= ' ' . $rec_tag['tag'];
456
+                                    $arr_tags .= ' '.$rec_tag['tag'];
457 457
                                 }
458 458
                             }
459 459
 
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
             // query
532 532
             $rows = DB::query(
533 533
                 'SELECT * 
534
-                FROM ' . prefixTable('export') . ' 
534
+                FROM ' . prefixTable('export').' 
535 535
                 WHERE export_tag = %s',
536 536
                 $dataReceived['export_tag']
537 537
             );
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
                 $prev_path = '';
544 544
 
545 545
                 //Prepare the PDF file
546
-                require_once $SETTINGS['cpassman_dir'] . '/vendor/tecnickcom/tcpdf/tcpdf.php';
546
+                require_once $SETTINGS['cpassman_dir'].'/vendor/tecnickcom/tcpdf/tcpdf.php';
547 547
 
548 548
                 $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
549 549
                 $pdf->SetProtection(array('print'), $dataReceived['pdf_password'], null);
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 
556 556
                 // set default header data
557 557
                 $pdf->SetHeaderData(
558
-                    $SETTINGS['cpassman_dir'] . '/includes/images/teampass-logo2-home.png',
558
+                    $SETTINGS['cpassman_dir'].'/includes/images/teampass-logo2-home.png',
559 559
                     PDF_HEADER_LOGO_WIDTH,
560 560
                     'Teampass export',
561 561
                     $session->get('user-lastname')." ".$session->get('user-name').' @ '.date($SETTINGS['date_format']." ".$SETTINGS['time_format'], (int) time())
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
                 logEvents($SETTINGS, 'pdf_export', '', (string) $session->get('user-id'), $session->get('user-login'));
666 666
 
667 667
                 //clean table
668
-                DB::query('TRUNCATE TABLE ' . prefixTable('export'));
668
+                DB::query('TRUNCATE TABLE '.prefixTable('export'));
669 669
 
670 670
                 // Clean any content of the output buffer
671 671
                 ob_end_clean();
@@ -704,13 +704,13 @@  discard block
 block discarded – undo
704 704
             // step 1:
705 705
             // - prepare export file
706 706
             // - get full list of objects id to export
707
-            include $SETTINGS['cpassman_dir'] . '/includes/config/include.php';
707
+            include $SETTINGS['cpassman_dir'].'/includes/config/include.php';
708 708
             $idsList = array();
709 709
 
710 710
             // query
711 711
             $rows = DB::query(
712 712
                 'SELECT * 
713
-                FROM ' . prefixTable('export') . ' 
713
+                FROM ' . prefixTable('export').' 
714 714
                 WHERE export_tag = %s',
715 715
                 $inputData['export_tag']
716 716
             );
@@ -747,13 +747,13 @@  discard block
 block discarded – undo
747 747
             }
748 748
             // prepare export file
749 749
             //save the file
750
-            $outstream = fopen($SETTINGS['path_to_files_folder'] . (substr($SETTINGS['path_to_files_folder'] , -1) === '/' ? '' : '/') . $inputData['filename'], 'w');
750
+            $outstream = fopen($SETTINGS['path_to_files_folder'].(substr($SETTINGS['path_to_files_folder'], -1) === '/' ? '' : '/').$inputData['filename'], 'w');
751 751
             if ($outstream === false) {
752 752
                 echo (string) prepareExchangedData(
753 753
                     [
754 754
                         'error' => true,
755 755
                         'message' => $lang->get('error_while_creating_file'),
756
-                        'detail' => $SETTINGS['path_to_files_folder'] . $inputData['filename'],
756
+                        'detail' => $SETTINGS['path_to_files_folder'].$inputData['filename'],
757 757
                     ],
758 758
                     'encode'
759 759
                 );
@@ -779,12 +779,12 @@  discard block
 block discarded – undo
779 779
     </style>
780 780
     </head>
781 781
     <body>
782
-    <input type="hidden" id="generation_date" value="' . GibberishAES::enc(/** @scrutinizer ignore-type */ (string) time(), $inputData['password']) . '" />
782
+    <input type="hidden" id="generation_date" value="' . GibberishAES::enc(/** @scrutinizer ignore-type */ (string) time(), $inputData['password']).'" />
783 783
     <div id="header">
784
-    ' . TP_TOOL_NAME . ' - Off Line mode
784
+    ' . TP_TOOL_NAME.' - Off Line mode
785 785
     </div>
786 786
     <div style="margin:10px; font-size:9px;">
787
-    <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>
787
+    <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>
788 788
     <span id="info_page" style="margin-left:20px; font-weight:bold; font-size: 14px; color:red;"></span>
789 789
     </div>
790 790
     <div id="information"></div>
@@ -795,11 +795,11 @@  discard block
 block discarded – undo
795 795
     <div>
796 796
     <table id="itemsTable">
797 797
         <thead><tr>
798
-            <th style="width:15%;">' . $lang->get('label') . '</th>
799
-            <th style="width:10%;">' . $lang->get('pw') . '</th>
800
-            <th style="width:30%;">' . $lang->get('description') . '</th>
801
-            <th style="width:5%;">' . $lang->get('user_login') . '</th>
802
-            <th style="width:20%;">' . $lang->get('url') . '</th>
798
+            <th style="width:15%;">' . $lang->get('label').'</th>
799
+            <th style="width:10%;">' . $lang->get('pw').'</th>
800
+            <th style="width:30%;">' . $lang->get('description').'</th>
801
+            <th style="width:5%;">' . $lang->get('user_login').'</th>
802
+            <th style="width:20%;">' . $lang->get('url').'</th>
803 803
         </tr></thead>
804 804
         <tbody id="itemsTable_tbody">'
805 805
             );
@@ -813,8 +813,8 @@  discard block
 block discarded – undo
813 813
                     'loop' => true,
814 814
                     'ids_list' => json_encode($idsList),
815 815
                     'ids_count' => count($idsList),
816
-                    'file_path' => $SETTINGS['path_to_files_folder'] . (substr($SETTINGS['path_to_files_folder'] , -1) === '/' ? '' : '/') . $inputData['filename'],
817
-                    'file_link' => $SETTINGS['url_to_files_folder'] . (substr($SETTINGS['path_to_files_folder'] , -1) === '/' ? '' : '/') . $inputData['filename'],
816
+                    'file_path' => $SETTINGS['path_to_files_folder'].(substr($SETTINGS['path_to_files_folder'], -1) === '/' ? '' : '/').$inputData['filename'],
817
+                    'file_link' => $SETTINGS['url_to_files_folder'].(substr($SETTINGS['path_to_files_folder'], -1) === '/' ? '' : '/').$inputData['filename'],
818 818
                     'export_tag' => $inputData['export_tag'],
819 819
                 ],
820 820
                 'encode'
@@ -854,12 +854,12 @@  discard block
 block discarded – undo
854 854
             $full_listing = array();
855 855
             $items_id_list = array();
856 856
             $outstream = '';
857
-            include $SETTINGS['cpassman_dir'] . '/includes/config/include.php';
857
+            include $SETTINGS['cpassman_dir'].'/includes/config/include.php';
858 858
 
859 859
             // query
860 860
             $rows = DB::query(
861 861
                 'SELECT * 
862
-                FROM ' . prefixTable('export') . ' 
862
+                FROM ' . prefixTable('export').' 
863 863
                 WHERE export_tag = %s AND item_id IN %ls',
864 864
                 $inputData['export_tag'],
865 865
                 $inputData['idsList']
@@ -873,7 +873,7 @@  discard block
 block discarded – undo
873 873
                         [
874 874
                             'error' => true,
875 875
                             'message' => $lang->get('error_while_creating_file'),
876
-                            'detail' => $SETTINGS['path_to_files_folder'] . $inputData['filename'],
876
+                            'detail' => $SETTINGS['path_to_files_folder'].$inputData['filename'],
877 877
                         ],
878 878
                         'encode'
879 879
                     );
@@ -906,13 +906,13 @@  discard block
 block discarded – undo
906 906
                         if (empty($arboHtml)) {
907 907
                             $arboHtml = $arboHtml_tmp;
908 908
                         } else {
909
-                            $arboHtml .= ' » ' . $arboHtml_tmp;
909
+                            $arboHtml .= ' » '.$arboHtml_tmp;
910 910
                         }
911 911
                     }
912 912
                     fputs(
913 913
                         $outstream,
914 914
                         '
915
-        <tr class="path"><td colspan="5">' . $arboHtml . '</td></tr>'
915
+        <tr class="path"><td colspan="5">' . $arboHtml.'</td></tr>'
916 916
                     );
917 917
                     $idTree = $record['folder_id'];
918 918
 
@@ -920,12 +920,12 @@  discard block
 block discarded – undo
920 920
                     fputs(
921 921
                         $outstream,
922 922
                         '
923
-        <tr class="' . $lineType . '">
924
-            <td>' . addslashes($record['label']) . '</td>
925
-            <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>
926
-            <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>
927
-            <td align="center">' . (empty($record['login']) === true ? '&nbsp;' : addslashes($record['login'])) . '</td>
928
-            <td align="center">' . (empty($record['url']) === true ? '&nbsp;' : addslashes($record['url'])) . '</td>
923
+        <tr class="' . $lineType.'">
924
+            <td>' . addslashes($record['label']).'</td>
925
+            <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>
926
+            <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>
927
+            <td align="center">' . (empty($record['login']) === true ? '&nbsp;' : addslashes($record['login'])).'</td>
928
+            <td align="center">' . (empty($record['url']) === true ? '&nbsp;' : addslashes($record['url'])).'</td>
929 929
         </tr>'
930 930
                     );
931 931
                 }
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
             $inputData['password'] = (string) $dataReceived['password'];
976 976
             
977 977
             // Load includes
978
-            include $SETTINGS['cpassman_dir'] . '/includes/config/include.php';
978
+            include $SETTINGS['cpassman_dir'].'/includes/config/include.php';
979 979
 
980 980
             // read the content of the temporary file
981 981
             $handle = fopen($inputData['filename'].'.txt', 'r');
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
                     [
985 985
                         'error' => true,
986 986
                         'message' => $lang->get('error_while_creating_file'),
987
-                        'detail' => $SETTINGS['path_to_files_folder'] . $inputData['filename'],
987
+                        'detail' => $SETTINGS['path_to_files_folder'].$inputData['filename'],
988 988
                     ],
989 989
                     'encode'
990 990
                 );
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
                     [
997 997
                         'error' => true,
998 998
                         'message' => $lang->get('error_while_creating_file'),
999
-                        'detail' => $SETTINGS['path_to_files_folder'] . $inputData['filename'],
999
+                        'detail' => $SETTINGS['path_to_files_folder'].$inputData['filename'],
1000 1000
                     ],
1001 1001
                     'encode'
1002 1002
                 );
@@ -1012,9 +1012,9 @@  discard block
 block discarded – undo
1012 1012
             $chunks = explode('|#|#|', chunk_split($contents, 10000, '|#|#|'));
1013 1013
             foreach ($chunks as $chunk) {
1014 1014
                 if (empty($encrypted_text) === true) {
1015
-                    $encrypted_text = GibberishAES::enc(/** @scrutinizer ignore-type */ $chunk, $inputData['password'] );
1015
+                    $encrypted_text = GibberishAES::enc(/** @scrutinizer ignore-type */ $chunk, $inputData['password']);
1016 1016
                 } else {
1017
-                    $encrypted_text .= '|#|#|' . GibberishAES::enc(/** @scrutinizer ignore-type */ $chunk, $inputData['password'] );
1017
+                    $encrypted_text .= '|#|#|'.GibberishAES::enc(/** @scrutinizer ignore-type */ $chunk, $inputData['password']);
1018 1018
                 }
1019 1019
             }
1020 1020
 
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
                     [
1026 1026
                         'error' => true,
1027 1027
                         'message' => $lang->get('error_while_creating_file'),
1028
-                        'detail' => $SETTINGS['path_to_files_folder'] . $inputData['filename'],
1028
+                        'detail' => $SETTINGS['path_to_files_folder'].$inputData['filename'],
1029 1029
                     ],
1030 1030
                     'encode'
1031 1031
                 );
@@ -1038,9 +1038,9 @@  discard block
 block discarded – undo
1038 1038
         </table></div>
1039 1039
         <input type="button" value="Hide all" onclick="hideAll()" />
1040 1040
         <div id="footer" style="text-align:center;">
1041
-            <a href="https://teampass.net/about/" target="_blank">' . TP_TOOL_NAME . '&nbsp;' . TP_VERSION . '&nbsp;' . TP_COPYRIGHT . '</a>
1041
+            <a href="https://teampass.net/about/" target="_blank">' . TP_TOOL_NAME.'&nbsp;'.TP_VERSION.'&nbsp;'.TP_COPYRIGHT.'</a>
1042 1042
         </div>
1043
-        <div id="enc_html" style="display:none;">' . $encrypted_text . '</div>
1043
+        <div id="enc_html" style="display:none;">' . $encrypted_text.'</div>
1044 1044
         </body>
1045 1045
     </html>
1046 1046
     <script type="text/javascript">
@@ -1143,12 +1143,12 @@  discard block
 block discarded – undo
1143 1143
             fclose($outstream);
1144 1144
 
1145 1145
             //clean table
1146
-            DB::query('TRUNCATE TABLE ' . prefixTable('export'));
1146
+            DB::query('TRUNCATE TABLE '.prefixTable('export'));
1147 1147
 
1148 1148
             echo (string) prepareExchangedData(
1149 1149
                 [
1150 1150
                     'error' => false,
1151
-                    'filelink' => $inputData['file_link'] ,
1151
+                    'filelink' => $inputData['file_link'],
1152 1152
                 ],
1153 1153
                 'encode'
1154 1154
             );
Please login to merge, or discard this patch.
sources/backups.queries.php 1 patch
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
 // Load functions
42 42
 require_once 'main.functions.php';
43
-require_once __DIR__ . '/backup.functions.php';
43
+require_once __DIR__.'/backup.functions.php';
44 44
 $session = SessionManager::getSession();
45 45
 
46 46
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     ) {
106 106
         // Not allowed page
107 107
         $session->set('system-error_code', ERR_NOT_ALLOWED);
108
-        include $SETTINGS['cpassman_dir'] . '/error.php';
108
+        include $SETTINGS['cpassman_dir'].'/error.php';
109 109
         exit;
110 110
     }
111 111
 }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     function tpGetSettingsValue(string $key, string $default = ''): string
146 146
     {
147 147
         $val = DB::queryFirstField(
148
-            'SELECT valeur FROM ' . prefixTable('misc') . ' WHERE type=%s AND intitule=%s LIMIT 1',
148
+            'SELECT valeur FROM '.prefixTable('misc').' WHERE type=%s AND intitule=%s LIMIT 1',
149 149
             'settings',
150 150
             $key
151 151
         );
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
     function tpUpsertSettingsValue(string $key, string $value): void
160 160
     {
161 161
         $exists = DB::queryFirstField(
162
-            'SELECT 1 FROM ' . prefixTable('misc') . ' WHERE type=%s AND intitule=%s LIMIT 1',
162
+            'SELECT 1 FROM '.prefixTable('misc').' WHERE type=%s AND intitule=%s LIMIT 1',
163 163
             'settings',
164 164
             $key
165 165
         );
166 166
 
167
-        if ((int)$exists === 1) {
167
+        if ((int) $exists === 1) {
168 168
             DB::update(
169 169
                 prefixTable('misc'),
170 170
                 ['valeur' => $value],
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
     function tpGetAdminTimezoneName(): string
187 187
     {
188 188
         $tz = DB::queryFirstField(
189
-            'SELECT valeur FROM ' . prefixTable('misc') . ' WHERE type=%s AND intitule=%s LIMIT 1',
189
+            'SELECT valeur FROM '.prefixTable('misc').' WHERE type=%s AND intitule=%s LIMIT 1',
190 190
             'admin',
191 191
             'timezone'
192 192
         );
@@ -241,14 +241,14 @@  discard block
 block discarded – undo
241 241
                 exit;
242 242
             }
243 243
 
244
-            $baseFilesDir = (string) ($SETTINGS['path_to_files_folder'] ?? (__DIR__ . '/../files'));
245
-            $dir = (string) tpGetSettingsValue('bck_scheduled_output_dir', rtrim($baseFilesDir, '/') . '/backups');
246
-            $fp = rtrim($dir, '/') . '/' . $get_file;
244
+            $baseFilesDir = (string) ($SETTINGS['path_to_files_folder'] ?? (__DIR__.'/../files'));
245
+            $dir = (string) tpGetSettingsValue('bck_scheduled_output_dir', rtrim($baseFilesDir, '/').'/backups');
246
+            $fp = rtrim($dir, '/').'/'.$get_file;
247 247
 
248 248
             $dirReal = realpath($dir);
249 249
             $fpReal = realpath($fp);
250 250
 
251
-            if ($dirReal === false || $fpReal === false || strpos($fpReal, $dirReal . DIRECTORY_SEPARATOR) !== 0 || is_file($fpReal) === false) {
251
+            if ($dirReal === false || $fpReal === false || strpos($fpReal, $dirReal.DIRECTORY_SEPARATOR) !== 0 || is_file($fpReal) === false) {
252 252
                 header('HTTP/1.1 404 Not Found');
253 253
                 exit;
254 254
             }
@@ -280,13 +280,13 @@  discard block
 block discarded – undo
280 280
 
281 281
             header('Content-Description: File Transfer');
282 282
             header('Content-Type: application/octet-stream');
283
-            header('Content-Disposition: attachment; filename="' . $get_file . '"');
283
+            header('Content-Disposition: attachment; filename="'.$get_file.'"');
284 284
             header('Content-Transfer-Encoding: binary');
285 285
             header('Expires: 0');
286 286
             header('Cache-Control: private, must-revalidate');
287 287
             header('Pragma: public');
288 288
             if ($size > 0) {
289
-                header('Content-Length: ' . $size);
289
+                header('Content-Length: '.$size);
290 290
             }
291 291
 
292 292
             readfile($fpReal);
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
             // Prepare variables
325 325
             $encryptionKey = filter_var($dataReceived['encryptionKey'] ?? '', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
326 326
         
327
-            require_once __DIR__ . '/backup.functions.php';
327
+            require_once __DIR__.'/backup.functions.php';
328 328
 
329 329
             $backupResult = tpCreateDatabaseBackup($SETTINGS, $encryptionKey);
330 330
 
@@ -358,9 +358,9 @@  discard block
 block discarded – undo
358 358
                 array(
359 359
                     'error' => false,
360 360
                     'message' => '',
361
-                    'download' => 'sources/downloadFile.php?name=' . urlencode($filename) .
362
-                        '&action=backup&file=' . $filename . '&type=sql&key=' . $session->get('key') . '&key_tmp=' .
363
-                        $session->get('user-key_tmp') . '&pathIsFiles=1',
361
+                    'download' => 'sources/downloadFile.php?name='.urlencode($filename).
362
+                        '&action=backup&file='.$filename.'&type=sql&key='.$session->get('key').'&key_tmp='.
363
+                        $session->get('user-key_tmp').'&pathIsFiles=1',
364 364
                 ),
365 365
                 'encode'
366 366
             );
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
          * ============================================================ */
371 371
 
372 372
         case 'scheduled_get_settings':
373
-            if ($post_key !== $session->get('key') || (int)$session->get('user-admin') !== 1) {
373
+            if ($post_key !== $session->get('key') || (int) $session->get('user-admin') !== 1) {
374 374
                 echo prepareExchangedData(['error' => true, 'message' => 'Not allowed'], 'encode');
375 375
                 break;
376 376
             }
@@ -401,12 +401,12 @@  discard block
 block discarded – undo
401 401
 
402 402
         case 'disk_usage':
403 403
             // Provide disk usage information for the storage containing the <files> directory
404
-            if ($post_key !== $session->get('key') || (int)$session->get('user-admin') !== 1) {
404
+            if ($post_key !== $session->get('key') || (int) $session->get('user-admin') !== 1) {
405 405
                 echo prepareExchangedData(['error' => true, 'message' => 'Not allowed'], 'encode');
406 406
                 break;
407 407
             }
408 408
 
409
-            $baseFilesDir = (string)($SETTINGS['path_to_files_folder'] ?? (__DIR__ . '/../files'));
409
+            $baseFilesDir = (string) ($SETTINGS['path_to_files_folder'] ?? (__DIR__.'/../files'));
410 410
             $dirReal = realpath($baseFilesDir);
411 411
 
412 412
             if ($dirReal === false) {
@@ -417,21 +417,21 @@  discard block
 block discarded – undo
417 417
             $total = @disk_total_space($dirReal);
418 418
             $free = @disk_free_space($dirReal);
419 419
 
420
-            if ($total === false || $free === false || (float)$total <= 0) {
420
+            if ($total === false || $free === false || (float) $total <= 0) {
421 421
                 echo prepareExchangedData(['error' => true, 'message' => 'Unable to read disk usage'], 'encode');
422 422
                 break;
423 423
             }
424 424
 
425
-            $used = max(0.0, (float)$total - (float)$free);
426
-            $pct = round(($used / (float)$total) * 100, 1);
425
+            $used = max(0.0, (float) $total - (float) $free);
426
+            $pct = round(($used / (float) $total) * 100, 1);
427 427
 
428
-            $label = tpFormatBytes($used) . ' / ' . tpFormatBytes((float)$total);
428
+            $label = tpFormatBytes($used).' / '.tpFormatBytes((float) $total);
429 429
             $tooltip = sprintf(
430 430
                 $lang->get('bck_storage_usage_tooltip'),
431 431
                 tpFormatBytes($used),
432
-                tpFormatBytes((float)$total),
433
-                (string)$pct,
434
-                tpFormatBytes((float)$free),
432
+                tpFormatBytes((float) $total),
433
+                (string) $pct,
434
+                tpFormatBytes((float) $free),
435 435
                 $dirReal
436 436
             );
437 437
 
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
             break;
484 484
 
485 485
         case 'scheduled_save_settings':
486
-            if ($post_key !== $session->get('key') || (int)$session->get('user-admin') !== 1) {
486
+            if ($post_key !== $session->get('key') || (int) $session->get('user-admin') !== 1) {
487 487
                 echo prepareExchangedData(['error' => true, 'message' => 'Not allowed'], 'encode');
488 488
                 break;
489 489
             }
@@ -491,15 +491,15 @@  discard block
 block discarded – undo
491 491
             $dataReceived = prepareExchangedData($post_data, 'decode');
492 492
             if (!is_array($dataReceived)) $dataReceived = [];
493 493
 
494
-            $enabled = (int)($dataReceived['enabled'] ?? 0);
494
+            $enabled = (int) ($dataReceived['enabled'] ?? 0);
495 495
             $enabled = ($enabled === 1) ? 1 : 0;
496 496
 
497
-            $frequency = (string)($dataReceived['frequency'] ?? 'daily');
497
+            $frequency = (string) ($dataReceived['frequency'] ?? 'daily');
498 498
             if (!in_array($frequency, ['daily', 'weekly', 'monthly'], true)) {
499 499
                 $frequency = 'daily';
500 500
             }
501 501
 
502
-            $timeStr = (string)($dataReceived['time'] ?? '02:00');
502
+            $timeStr = (string) ($dataReceived['time'] ?? '02:00');
503 503
             if (!preg_match('/^\d{2}:\d{2}$/', $timeStr)) {
504 504
                 $timeStr = '02:00';
505 505
             } else {
@@ -509,22 +509,22 @@  discard block
 block discarded – undo
509 509
                 }
510 510
             }
511 511
 
512
-            $dow = (int)($dataReceived['dow'] ?? 1);
512
+            $dow = (int) ($dataReceived['dow'] ?? 1);
513 513
             if ($dow < 1 || $dow > 7) $dow = 1;
514 514
 
515
-            $dom = (int)($dataReceived['dom'] ?? 1);
515
+            $dom = (int) ($dataReceived['dom'] ?? 1);
516 516
             if ($dom < 1) $dom = 1;
517 517
             if ($dom > 31) $dom = 31;
518 518
 
519
-            $retentionDays = (int)($dataReceived['retention_days'] ?? 30);
519
+            $retentionDays = (int) ($dataReceived['retention_days'] ?? 30);
520 520
             if ($retentionDays < 1) $retentionDays = 1;
521 521
             if ($retentionDays > 3650) $retentionDays = 3650;
522 522
 
523 523
             // Output dir: default to <files>/backups
524
-            $baseFilesDir = (string)($SETTINGS['path_to_files_folder'] ?? (__DIR__ . '/../files'));
525
-            $defaultDir = rtrim($baseFilesDir, '/') . '/backups';
524
+            $baseFilesDir = (string) ($SETTINGS['path_to_files_folder'] ?? (__DIR__.'/../files'));
525
+            $defaultDir = rtrim($baseFilesDir, '/').'/backups';
526 526
 
527
-            $outputDir = trim((string)($dataReceived['output_dir'] ?? ''));
527
+            $outputDir = trim((string) ($dataReceived['output_dir'] ?? ''));
528 528
             if ($outputDir === '') $outputDir = $defaultDir;
529 529
 
530 530
             // Safety: prevent path traversal / outside files folder
@@ -537,13 +537,13 @@  discard block
 block discarded – undo
537 537
                 break;
538 538
             }
539 539
 
540
-            tpUpsertSettingsValue('bck_scheduled_enabled', (string)$enabled);
540
+            tpUpsertSettingsValue('bck_scheduled_enabled', (string) $enabled);
541 541
             tpUpsertSettingsValue('bck_scheduled_frequency', $frequency);
542 542
             tpUpsertSettingsValue('bck_scheduled_time', $timeStr);
543
-            tpUpsertSettingsValue('bck_scheduled_dow', (string)$dow);
544
-            tpUpsertSettingsValue('bck_scheduled_dom', (string)$dom);
543
+            tpUpsertSettingsValue('bck_scheduled_dow', (string) $dow);
544
+            tpUpsertSettingsValue('bck_scheduled_dom', (string) $dom);
545 545
             tpUpsertSettingsValue('bck_scheduled_output_dir', $dirReal);
546
-            tpUpsertSettingsValue('bck_scheduled_retention_days', (string)$retentionDays);
546
+            tpUpsertSettingsValue('bck_scheduled_retention_days', (string) $retentionDays);
547 547
 
548 548
             // Force re-init of next_run_at so handler recomputes cleanly
549 549
             tpUpsertSettingsValue('bck_scheduled_next_run_at', '0');
@@ -552,13 +552,13 @@  discard block
 block discarded – undo
552 552
             break;
553 553
 
554 554
         case 'scheduled_list_backups':
555
-            if ($post_key !== $session->get('key') || (int)$session->get('user-admin') !== 1) {
555
+            if ($post_key !== $session->get('key') || (int) $session->get('user-admin') !== 1) {
556 556
                 echo prepareExchangedData(['error' => true, 'message' => 'Not allowed'], 'encode');
557 557
                 break;
558 558
             }
559 559
 
560
-            $baseFilesDir = (string)($SETTINGS['path_to_files_folder'] ?? (__DIR__ . '/../files'));
561
-            $dir = (string)tpGetSettingsValue('bck_scheduled_output_dir', rtrim($baseFilesDir, '/') . '/backups');
560
+            $baseFilesDir = (string) ($SETTINGS['path_to_files_folder'] ?? (__DIR__.'/../files'));
561
+            $dir = (string) tpGetSettingsValue('bck_scheduled_output_dir', rtrim($baseFilesDir, '/').'/backups');
562 562
             @mkdir($dir, 0770, true);
563 563
             // Build a relative path from files/ root (output_dir can be a subfolder)
564 564
             $filesRoot = realpath($baseFilesDir);
@@ -578,15 +578,15 @@  discard block
 block discarded – undo
578 578
 
579 579
 
580 580
             $files = [];
581
-            foreach (glob(rtrim($dir, '/') . '/scheduled-*.sql') ?: [] as $fp) {
581
+            foreach (glob(rtrim($dir, '/').'/scheduled-*.sql') ?: [] as $fp) {
582 582
                 $bn = basename($fp);
583 583
                 $files[] = [
584 584
                     'name' => $bn,
585
-                    'size_bytes' => (int)@filesize($fp),
586
-                    'mtime' => (int)@filemtime($fp),
587
-                    'download' => 'sources/backups.queries.php?type=scheduled_download_backup&file=' . urlencode($bn)
588
-                        . '&key=' . urlencode((string) $session->get('key'))
589
-                        . '&key_tmp=' . urlencode($keyTmp),
585
+                    'size_bytes' => (int) @filesize($fp),
586
+                    'mtime' => (int) @filemtime($fp),
587
+                    'download' => 'sources/backups.queries.php?type=scheduled_download_backup&file='.urlencode($bn)
588
+                        . '&key='.urlencode((string) $session->get('key'))
589
+                        . '&key_tmp='.urlencode($keyTmp),
590 590
                 ];
591 591
             }
592 592
 
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
             break;
597 597
 
598 598
         case 'scheduled_delete_backup':
599
-            if ($post_key !== $session->get('key') || (int)$session->get('user-admin') !== 1) {
599
+            if ($post_key !== $session->get('key') || (int) $session->get('user-admin') !== 1) {
600 600
                 echo prepareExchangedData(['error' => true, 'message' => 'Not allowed'], 'encode');
601 601
                 break;
602 602
             }
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
             $dataReceived = prepareExchangedData($post_data, 'decode');
605 605
             if (!is_array($dataReceived)) $dataReceived = [];
606 606
 
607
-            $file = (string)($dataReceived['file'] ?? '');
607
+            $file = (string) ($dataReceived['file'] ?? '');
608 608
             $file = basename($file);
609 609
 
610 610
             if ($file === '' || strpos($file, 'scheduled-') !== 0 || !str_ends_with($file, '.sql')) {
@@ -612,9 +612,9 @@  discard block
 block discarded – undo
612 612
                 break;
613 613
             }
614 614
 
615
-            $baseFilesDir = (string)($SETTINGS['path_to_files_folder'] ?? (__DIR__ . '/../files'));
616
-            $dir = (string)tpGetSettingsValue('bck_scheduled_output_dir', rtrim($baseFilesDir, '/') . '/backups');
617
-            $fp = rtrim($dir, '/') . '/' . $file;
615
+            $baseFilesDir = (string) ($SETTINGS['path_to_files_folder'] ?? (__DIR__.'/../files'));
616
+            $dir = (string) tpGetSettingsValue('bck_scheduled_output_dir', rtrim($baseFilesDir, '/').'/backups');
617
+            $fp = rtrim($dir, '/').'/'.$file;
618 618
 
619 619
 
620 620
             if (file_exists($fp) && is_file($fp)) {
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
             break;
632 632
 
633 633
         case 'check_connected_users':
634
-            if ($post_key !== $session->get('key') || (int)$session->get('user-admin') !== 1) {
634
+            if ($post_key !== $session->get('key') || (int) $session->get('user-admin') !== 1) {
635 635
                 echo prepareExchangedData(['error' => true, 'message' => 'Not allowed'], 'encode');
636 636
                 break;
637 637
             }
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
             }
643 643
 
644 644
             $connectedCount = (int) DB::queryFirstField(
645
-                'SELECT COUNT(*) FROM ' . prefixTable('users') . ' WHERE session_end >= %i AND id != %i',
645
+                'SELECT COUNT(*) FROM '.prefixTable('users').' WHERE session_end >= %i AND id != %i',
646 646
                 time(),
647 647
                 $excludeUserId
648 648
             );
@@ -651,19 +651,19 @@  discard block
 block discarded – undo
651 651
             break;
652 652
 
653 653
         case 'scheduled_run_now':
654
-            if ($post_key !== $session->get('key') || (int)$session->get('user-admin') !== 1) {
654
+            if ($post_key !== $session->get('key') || (int) $session->get('user-admin') !== 1) {
655 655
                 echo prepareExchangedData(['error' => true, 'message' => 'Not allowed'], 'encode');
656 656
                 break;
657 657
             }
658 658
 
659 659
             $now = time();
660
-            $baseFilesDir = (string)($SETTINGS['path_to_files_folder'] ?? (__DIR__ . '/../files'));
661
-            $dir = (string)tpGetSettingsValue('bck_scheduled_output_dir', rtrim($baseFilesDir, '/') . '/backups');
660
+            $baseFilesDir = (string) ($SETTINGS['path_to_files_folder'] ?? (__DIR__.'/../files'));
661
+            $dir = (string) tpGetSettingsValue('bck_scheduled_output_dir', rtrim($baseFilesDir, '/').'/backups');
662 662
             @mkdir($dir, 0770, true);
663 663
 
664 664
             // avoid duplicates
665
-            $pending = (int)DB::queryFirstField(
666
-                'SELECT COUNT(*) FROM ' . prefixTable('background_tasks') . '
665
+            $pending = (int) DB::queryFirstField(
666
+                'SELECT COUNT(*) FROM '.prefixTable('background_tasks').'
667 667
                  WHERE process_type=%s AND is_in_progress IN (0,1)
668 668
                    AND (finished_at IS NULL OR finished_at = "" OR finished_at = 0)',
669 669
                 'database_backup'
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
             DB::insert(
677 677
                 prefixTable('background_tasks'),
678 678
                 [
679
-                    'created_at' => (string)$now,
679
+                    'created_at' => (string) $now,
680 680
                     'process_type' => 'database_backup',
681 681
                     'arguments' => json_encode(['output_dir' => $dir, 'source' => 'scheduler', 'initiator_user_id' => (int) $session->get('user-id')], JSON_UNESCAPED_SLASHES),
682 682
                     'is_in_progress' => 0,
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
                 ]
685 685
             );
686 686
 
687
-            tpUpsertSettingsValue('bck_scheduled_last_run_at', (string)$now);
687
+            tpUpsertSettingsValue('bck_scheduled_last_run_at', (string) $now);
688 688
             tpUpsertSettingsValue('bck_scheduled_last_status', 'queued');
689 689
             tpUpsertSettingsValue('bck_scheduled_last_message', 'Task enqueued by UI');
690 690
 
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 
694 694
         case 'onthefly_delete_backup':
695 695
             // Delete an on-the-fly backup file stored in <files> directory
696
-            if ($post_key !== $session->get('key') || (int)$session->get('user-admin') !== 1) {
696
+            if ($post_key !== $session->get('key') || (int) $session->get('user-admin') !== 1) {
697 697
                 echo prepareExchangedData(
698 698
                     array(
699 699
                         'error' => true,
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
             }
706 706
 
707 707
             $dataReceived = prepareExchangedData($post_data, 'decode');
708
-            $fileToDelete = isset($dataReceived['file']) === true ? (string)$dataReceived['file'] : '';
708
+            $fileToDelete = isset($dataReceived['file']) === true ? (string) $dataReceived['file'] : '';
709 709
             $bn = basename($fileToDelete);
710 710
 
711 711
             // Safety checks
@@ -732,9 +732,9 @@  discard block
 block discarded – undo
732 732
                 break;
733 733
             }
734 734
 
735
-            $baseFilesDir = (string)($SETTINGS['path_to_files_folder'] ?? (__DIR__ . '/../files'));
735
+            $baseFilesDir = (string) ($SETTINGS['path_to_files_folder'] ?? (__DIR__.'/../files'));
736 736
             $dir = rtrim($baseFilesDir, '/');
737
-            $fullPath = $dir . '/' . $bn;
737
+            $fullPath = $dir.'/'.$bn;
738 738
 
739 739
             if (file_exists($fullPath) === false) {
740 740
                 echo prepareExchangedData(
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
 
774 774
         case 'onthefly_list_backups':
775 775
             // List on-the-fly backup files stored directly in <files> directory (not in /backups for scheduled)
776
-            if ($post_key !== $session->get('key') || (int)$session->get('user-admin') !== 1) {
776
+            if ($post_key !== $session->get('key') || (int) $session->get('user-admin') !== 1) {
777 777
                 echo prepareExchangedData(
778 778
                     array(
779 779
                         'error' => true,
@@ -784,11 +784,11 @@  discard block
 block discarded – undo
784 784
                 break;
785 785
             }
786 786
 
787
-            $baseFilesDir = (string)($SETTINGS['path_to_files_folder'] ?? (__DIR__ . '/../files'));
787
+            $baseFilesDir = (string) ($SETTINGS['path_to_files_folder'] ?? (__DIR__.'/../files'));
788 788
             $dir = rtrim($baseFilesDir, '/');
789 789
 
790 790
             $files = array();
791
-            $paths = glob($dir . '/*.sql');
791
+            $paths = glob($dir.'/*.sql');
792 792
             if ($paths === false) {
793 793
                 $paths = array();
794 794
             }
@@ -813,17 +813,17 @@  discard block
 block discarded – undo
813 813
 
814 814
                 $files[] = array(
815 815
                     'name' => $bn,
816
-                    'size_bytes' => (int)@filesize($fp),
817
-                    'mtime' => (int)@filemtime($fp),
818
-                    'download' => 'sources/downloadFile.php?name=' . urlencode($bn) .
819
-                        '&action=backup&file=' . urlencode($bn) .
820
-                        '&type=sql&key=' . $session->get('key') .
821
-                        '&key_tmp=' . $session->get('user-key_tmp') .
816
+                    'size_bytes' => (int) @filesize($fp),
817
+                    'mtime' => (int) @filemtime($fp),
818
+                    'download' => 'sources/downloadFile.php?name='.urlencode($bn).
819
+                        '&action=backup&file='.urlencode($bn).
820
+                        '&type=sql&key='.$session->get('key').
821
+                        '&key_tmp='.$session->get('user-key_tmp').
822 822
                         '&pathIsFiles=1',
823 823
                 );
824 824
             }
825 825
 
826
-            usort($files, static function ($a, $b) {
826
+            usort($files, static function($a, $b) {
827 827
                 return ($b['mtime'] ?? 0) <=> ($a['mtime'] ?? 0);
828 828
             });
829 829
 
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
             $post_clearFilename = filter_var(($dataReceived['clearFilename'] ?? ''), FILTER_SANITIZE_FULL_SPECIAL_CHARS);
894 894
 
895 895
             $post_serverScope = filter_var(($dataReceived['serverScope'] ?? ''), FILTER_SANITIZE_FULL_SPECIAL_CHARS);
896
-            $post_serverFile  = filter_var(($dataReceived['serverFile']  ?? ''), FILTER_SANITIZE_FULL_SPECIAL_CHARS);
896
+            $post_serverFile  = filter_var(($dataReceived['serverFile'] ?? ''), FILTER_SANITIZE_FULL_SPECIAL_CHARS);
897 897
 
898 898
             // Scheduled backups must always be decrypted with the instance key (server-side).
899 899
             // Ignore any key coming from the UI to avoid mismatches.
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
             }
903 903
             // Ensure all strings we send back through prepareExchangedData() are JSON-safe.
904 904
             // This avoids PHP "malformed UTF-8" warnings when restore errors contain binary/latin1 bytes.
905
-            $tpSafeJsonString = static function ($value): string {
905
+            $tpSafeJsonString = static function($value): string {
906 906
                 if ($value === null) {
907 907
                     return '';
908 908
                 }
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
                     $isUtf8 = (@preg_match('//u', $str) === 1);
923 923
                 }
924 924
                 if ($isUtf8 === false) {
925
-                    return '[hex]' . bin2hex($str);
925
+                    return '[hex]'.bin2hex($str);
926 926
                 }
927 927
 
928 928
                 // Strip ASCII control chars that could pollute JSON.
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
             // Restore session + concurrency lock management.
939 939
             // - We keep a token in session to allow chunked restore even while DB is being replaced.
940 940
             // - We also block starting a second restore in the same session (double click / 2 tabs).
941
-            $clearRestoreState = static function ($session): void {
941
+            $clearRestoreState = static function($session): void {
942 942
                             $tmp = (string) ($session->get('restore-temp-file') ?? '');
943 943
                             if ($tmp !== '' && file_exists($tmp) === true && strpos(basename($tmp), 'defuse_temp_restore_') === 0 && is_file($tmp)) {
944 944
                                 if (is_writable($tmp)) {
@@ -1041,9 +1041,9 @@  discard block
 block discarded – undo
1041 1041
                 error_log('DEBUG: Offset -> '.$post_offset.'/'.$post_totalSize.' | File -> '.$post_clearFilename);
1042 1042
             }
1043 1043
         
1044
-            include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
1044
+            include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
1045 1045
         
1046
-            include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
1046
+            include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
1047 1047
 
1048 1048
             /*
1049 1049
              * Restore workflow
@@ -1080,12 +1080,12 @@  discard block
 block discarded – undo
1080 1080
 
1081 1081
                     // Scheduled backups are stored in configured output directory
1082 1082
                     if ($post_serverScope === 'scheduled') {
1083
-                        $baseFilesDir = (string) ($SETTINGS['path_to_files_folder'] ?? (__DIR__ . '/../files'));
1084
-                        $dir = (string) tpGetSettingsValue('bck_scheduled_output_dir', rtrim($baseFilesDir, '/') . '/backups');
1083
+                        $baseFilesDir = (string) ($SETTINGS['path_to_files_folder'] ?? (__DIR__.'/../files'));
1084
+                        $dir = (string) tpGetSettingsValue('bck_scheduled_output_dir', rtrim($baseFilesDir, '/').'/backups');
1085 1085
                         $baseDir = rtrim($dir, '/');
1086 1086
                     }
1087 1087
 
1088
-                    $serverPath = $baseDir . '/' . $bn;
1088
+                    $serverPath = $baseDir.'/'.$bn;
1089 1089
 
1090 1090
                     if (file_exists($serverPath) === false) {
1091 1091
                         try {
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
                         );
1121 1121
 
1122 1122
                         try {
1123
-                            $msg = 'dataBase restore started (scope=' . $post_serverScope . ', file=' . $bn . ')';
1123
+                            $msg = 'dataBase restore started (scope='.$post_serverScope.', file='.$bn.')';
1124 1124
                             logEvents(
1125 1125
                                 $SETTINGS,
1126 1126
                                 'admin_action',
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
 
1148 1148
                     // Find filename from DB (misc)
1149 1149
                     $data = DB::queryFirstRow(
1150
-                        'SELECT valeur FROM ' . prefixTable('misc') . ' WHERE increment_id = %i LIMIT 1',
1150
+                        'SELECT valeur FROM '.prefixTable('misc').' WHERE increment_id = %i LIMIT 1',
1151 1151
                         $legacyOperationId
1152 1152
                     );
1153 1153
 
@@ -1172,7 +1172,7 @@  discard block
 block discarded – undo
1172 1172
                     }
1173 1173
 
1174 1174
                     $bn = safeString($data['valeur']);
1175
-                    $serverPath = rtrim((string) $SETTINGS['path_to_files_folder'], '/') . '/' . $bn;
1175
+                    $serverPath = rtrim((string) $SETTINGS['path_to_files_folder'], '/').'/'.$bn;
1176 1176
 
1177 1177
                     if (file_exists($serverPath) === false) {
1178 1178
                         try {
@@ -1206,7 +1206,7 @@  discard block
 block discarded – undo
1206 1206
 
1207 1207
                 // Decrypt to a dedicated temp file (unique)
1208 1208
                 $tmpDecrypted = rtrim((string) $SETTINGS['path_to_files_folder'], '/')
1209
-                    . '/defuse_temp_restore_' . (int) $session->get('user-id') . '_' . time() . '_' . $bn;
1209
+                    . '/defuse_temp_restore_'.(int) $session->get('user-id').'_'.time().'_'.$bn;
1210 1210
 
1211 1211
                 // Build the list of keys we can try to decrypt with.
1212 1212
                 // - on-the-fly: uses the key provided by the UI
@@ -1265,7 +1265,7 @@  discard block
 block discarded – undo
1265 1265
                         array(
1266 1266
                             'error' => true,
1267 1267
                             'error_code' => 'DECRYPT_FAILED',
1268
-                            'message' => 'Unable to decrypt backup: ' . $tpSafeJsonString((string) ($decRet['message'] ?? 'unknown error')),
1268
+                            'message' => 'Unable to decrypt backup: '.$tpSafeJsonString((string) ($decRet['message'] ?? 'unknown error')),
1269 1269
                         ),
1270 1270
                         'encode'
1271 1271
                     );
@@ -1419,7 +1419,7 @@  discard block
 block discarded – undo
1419 1419
                             } catch (Exception $e) {
1420 1420
                                 $snippet = substr($query, 0, 120);
1421 1421
                                 $snippet = $tpSafeJsonString($snippet);
1422
-                                $errors[] = 'Error executing query: ' . $tpSafeJsonString($e->getMessage()) . ' - Query: ' . $snippet . '...';
1422
+                                $errors[] = 'Error executing query: '.$tpSafeJsonString($e->getMessage()).' - Query: '.$snippet.'...';
1423 1423
                             }
1424 1424
                             $query = '';
1425 1425
                         }
@@ -1445,7 +1445,7 @@  discard block
 block discarded – undo
1445 1445
                 }
1446 1446
                 // Rollback transaction on any exception
1447 1447
                 DB::rollback();
1448
-                $errors[] = 'Transaction failed: ' . $tpSafeJsonString($e->getMessage());
1448
+                $errors[] = 'Transaction failed: '.$tpSafeJsonString($e->getMessage());
1449 1449
             }
1450 1450
         
1451 1451
             // Calculate the new offset
@@ -1472,7 +1472,7 @@  discard block
 block discarded – undo
1472 1472
         logEvents(
1473 1473
             $SETTINGS,
1474 1474
             'admin_action',
1475
-            'dataBase restore failed' . ($scope !== '' ? ' (scope=' . $scope . ')' : ''),
1475
+            'dataBase restore failed'.($scope !== '' ? ' (scope='.$scope.')' : ''),
1476 1476
             (string) $session->get('user-id'),
1477 1477
             $session->get('user-login')
1478 1478
         );
@@ -1485,7 +1485,7 @@  discard block
 block discarded – undo
1485 1485
     echo prepareExchangedData(
1486 1486
         array(
1487 1487
             'error' => true,
1488
-            'message' => 'Errors occurred during import: ' . implode('; ', ($post_serverScope === 'scheduled' ? array_map($tpSafeJsonString, $errors) : $errors)),
1488
+            'message' => 'Errors occurred during import: '.implode('; ', ($post_serverScope === 'scheduled' ? array_map($tpSafeJsonString, $errors) : $errors)),
1489 1489
             'newOffset' => $newOffset,
1490 1490
             'totalSize' => $post_totalSize,
1491 1491
             'clearFilename' => $post_backupFile,
@@ -1566,15 +1566,15 @@  discard block
 block discarded – undo
1566 1566
     if ($scope !== '' || $fileLabel !== '' || $duration > 0) {
1567 1567
         $parts = array();
1568 1568
         if ($scope !== '') {
1569
-            $parts[] = 'scope=' . $scope;
1569
+            $parts[] = 'scope='.$scope;
1570 1570
         }
1571 1571
         if ($fileLabel !== '') {
1572
-            $parts[] = 'file=' . $fileLabel;
1572
+            $parts[] = 'file='.$fileLabel;
1573 1573
         }
1574 1574
         if ($duration > 0) {
1575
-            $parts[] = 'duration=' . $duration . 's';
1575
+            $parts[] = 'duration='.$duration.'s';
1576 1576
         }
1577
-        $msg .= ' (' . implode(', ', $parts) . ')';
1577
+        $msg .= ' ('.implode(', ', $parts).')';
1578 1578
     }
1579 1579
 
1580 1580
     logEvents(
Please login to merge, or discard this patch.
sources/users.queries.php 1 patch
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('profile') === false) {
75 75
     // Not allowed page
76 76
     $session->set('system-error_code', ERR_NOT_ALLOWED);
77
-    include $SETTINGS['cpassman_dir'] . '/error.php';
77
+    include $SETTINGS['cpassman_dir'].'/error.php';
78 78
     exit;
79 79
 }
80 80
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 
146 146
         // Get info about user to modify
147 147
         $targetUserInfos = DB::queryFirstRow(
148
-            'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM ' . prefixTable('users') . '
148
+            'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM '.prefixTable('users').'
149 149
             WHERE id = %i',
150 150
             (int) $dataReceived['user_id']
151 151
         );
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
             // Check if user exists (active or soft-deleted)
278 278
             $existingUser = DB::queryFirstRow(
279 279
                 'SELECT id, login, deleted_at
280
-                FROM ' . prefixTable('users') . '
280
+                FROM ' . prefixTable('users').'
281 281
                 WHERE (login = %s AND deleted_at IS NULL)
282 282
                 OR (login LIKE %s AND deleted_at IS NOT NULL)',
283 283
                 $login,
284
-                $login . '_deleted_%'
284
+                $login.'_deleted_%'
285 285
             );
286 286
 
287 287
             if (is_null($existingUser)) {
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
                 // Check if it's a soft-deleted user
466 466
                 $errorMessage = $lang->get('error_user_exists');
467 467
                 if (empty($deletedUser) === false) {
468
-                    $errorMessage = 'A deleted user with this login already exists (ID: ' . $deletedUser['id'] . '). Please restore the user instead of creating a new one.';
468
+                    $errorMessage = 'A deleted user with this login already exists (ID: '.$deletedUser['id'].'). Please restore the user instead of creating a new one.';
469 469
                 }
470 470
 
471 471
                 echo prepareExchangedData(
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
             }
505 505
 
506 506
             // Prepare variables
507
-            $userId  = filter_var($dataReceived['user_id'], FILTER_SANITIZE_NUMBER_INT);
507
+            $userId = filter_var($dataReceived['user_id'], FILTER_SANITIZE_NUMBER_INT);
508 508
 
509 509
             if (empty($userId)) {
510 510
                 echo prepareExchangedData(
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 
520 520
             // Get info about user to delete
521 521
             $data_user = DB::queryFirstRow(
522
-                'SELECT login, admin, isAdministratedByRole FROM ' . prefixTable('users') . '
522
+                'SELECT login, admin, isAdministratedByRole FROM '.prefixTable('users').'
523 523
                 WHERE id = %i',
524 524
                 $userId 
525 525
             );        
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
                     || ((int) $session->get('user-can_manage_all_users') === 1 && (int) $data_user['admin'] !== 1)
537 537
                 ) {
538 538
                     $timestamp = time();
539
-                    $deletedSuffix = '_deleted_' . $timestamp;
539
+                    $deletedSuffix = '_deleted_'.$timestamp;
540 540
 
541 541
                     // delete user in database
542 542
                     DB::update(
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
                     logEvents($SETTINGS, 'user_mngt', 'at_user_deleted', (string) $session->get('user-id'), $session->get('user-login'), $userId);
556 556
 
557 557
                     // Count deleted users
558
-                    $deletedAccountsCount = (int) DB::queryFirstField("SELECT COUNT(id) FROM " . prefixTable('users') . " WHERE deleted_at IS NOT NULL");
558
+                    $deletedAccountsCount = (int) DB::queryFirstField("SELECT COUNT(id) FROM ".prefixTable('users')." WHERE deleted_at IS NOT NULL");
559 559
 
560 560
                     DB::commit();
561 561
 
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
                 echo prepareExchangedData(
585 585
                     [
586 586
                         'error' => true,
587
-                        'message' => $lang->get('error') . ': ' . $e->getMessage(),
587
+                        'message' => $lang->get('error').': '.$e->getMessage(),
588 588
                     ],
589 589
                     'encode'
590 590
                 );
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
             $return = array();
599 599
             // Check if folder exists
600 600
             $data = DB::query(
601
-                'SELECT * FROM ' . prefixTable('nested_tree') . '
601
+                'SELECT * FROM '.prefixTable('nested_tree').'
602 602
                 WHERE title = %s AND parent_id = %i',
603 603
                 filter_input(INPUT_POST, 'domain', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
604 604
                 '0'
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
             }
612 612
             // Check if role exists
613 613
             $data = DB::query(
614
-                'SELECT * FROM ' . prefixTable('roles_title') . '
614
+                'SELECT * FROM '.prefixTable('roles_title').'
615 615
                 WHERE title = %s',
616 616
                 filter_input(INPUT_POST, 'domain', FILTER_SANITIZE_FULL_SPECIAL_CHARS)
617 617
             );
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
             // Get info about user to delete
641 641
             $data_user = DB::queryFirstRow(
642 642
                 'SELECT admin, isAdministratedByRole, gestionnaire
643
-                FROM ' . prefixTable('users') . '
643
+                FROM ' . prefixTable('users').'
644 644
                 WHERE id = %i',
645 645
                 $post_user_id
646 646
             );
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
                 if ($excludeUserId > 0) {
692 692
                     $rows = DB::query(
693 693
                         'SELECT id
694
-                         FROM ' . prefixTable('users') . '
694
+                         FROM ' . prefixTable('users').'
695 695
                          WHERE session_end >= %i AND id != %i',
696 696
                         $now,
697 697
                         $excludeUserId
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
                 } else {
700 700
                     $rows = DB::query(
701 701
                         'SELECT id
702
-                         FROM ' . prefixTable('users') . '
702
+                         FROM ' . prefixTable('users').'
703 703
                          WHERE session_end >= %i',
704 704
                         $now
705 705
                     );
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
                 $session->set('user-roles_array', explode(';', $session->get('user-roles')));
793 793
                 $rows = DB::query('
794 794
                     SELECT id,title,creator_id 
795
-                    FROM ' . prefixTable('roles_title') .'
795
+                    FROM ' . prefixTable('roles_title').'
796 796
                     WHERE id IN %li',
797 797
                     $session->get('user-roles_array')
798 798
                 );
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
                 $rolesList = array();
831 831
                 $managedBy = array();
832 832
                 $selected = '';
833
-                $rows = DB::query('SELECT id,title FROM ' . prefixTable('roles_title') . ' ORDER BY title ASC');
833
+                $rows = DB::query('SELECT id,title FROM '.prefixTable('roles_title').' ORDER BY title ASC');
834 834
                 foreach ($rows as $reccord) {
835 835
                     $rolesList[$reccord['id']] = array('id' => $reccord['id'], 'title' => $reccord['title']);
836 836
                 }
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
                         array_push(
862 862
                             $managedBy,
863 863
                             array(
864
-                                'title' => $lang->get('managers_of') . ' ' . $fonction['title'],
864
+                                'title' => $lang->get('managers_of').' '.$fonction['title'],
865 865
                                 'id' => $fonction['id'],
866 866
                                 'selected' => $selected,
867 867
                             )
@@ -943,9 +943,9 @@  discard block
 block discarded – undo
943 943
 
944 944
                 // get USER STATUS
945 945
                 if ($rowUser['disabled'] == 1) {
946
-                    $arrData['info'] = $lang->get('user_info_locked') . '<br><input type="checkbox" value="unlock" name="1" class="chk">&nbsp;<label for="1">' . $lang->get('user_info_unlock_question') . '</label><br><input type="checkbox"  value="delete" id="account_delete" class="chk mr-2" name="2" onclick="confirmDeletion()">label for="2">' . $lang->get('user_info_delete_question') . '</label>';
946
+                    $arrData['info'] = $lang->get('user_info_locked').'<br><input type="checkbox" value="unlock" name="1" class="chk">&nbsp;<label for="1">'.$lang->get('user_info_unlock_question').'</label><br><input type="checkbox"  value="delete" id="account_delete" class="chk mr-2" name="2" onclick="confirmDeletion()">label for="2">'.$lang->get('user_info_delete_question').'</label>';
947 947
                 } else {
948
-                    $arrData['info'] = $lang->get('user_info_active') . '<br><input type="checkbox" value="lock" class="chk">&nbsp;' . $lang->get('user_info_lock_question');
948
+                    $arrData['info'] = $lang->get('user_info_active').'<br><input type="checkbox" value="lock" class="chk">&nbsp;'.$lang->get('user_info_lock_question');
949 949
                 }
950 950
 
951 951
                 $arrData['error'] = false;
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
             // Get info about user to modify
1034 1034
             $data_user = DB::queryFirstRow(
1035 1035
                 'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole 
1036
-                FROM ' . prefixTable('users') . '
1036
+                FROM ' . prefixTable('users').'
1037 1037
                 WHERE id = %i',
1038 1038
                 $post_id
1039 1039
             );
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
                 // count number of admins
1045 1045
                 $users = DB::query(
1046 1046
                     'SELECT id
1047
-                    FROM ' . prefixTable('users') . '
1047
+                    FROM ' . prefixTable('users').'
1048 1048
                     WHERE admin = 1 AND email != "" AND pw != "" AND id != %i',
1049 1049
                     $post_id
1050 1050
                 );
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
             // Exclude roles from AD - PR #3635
1068 1068
             $adRolesResult = DB::query(
1069 1069
                 'SELECT role_id
1070
-                FROM ' . prefixTable('users_roles') . '
1070
+                FROM ' . prefixTable('users_roles').'
1071 1071
                 WHERE user_id = %i AND source = %s',
1072 1072
                 $post_id,
1073 1073
                 'ad'
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
                     );
1171 1171
                     // delete personal folder and subfolders
1172 1172
                     $data = DB::queryFirstRow(
1173
-                        'SELECT id FROM ' . prefixTable('nested_tree') . '
1173
+                        'SELECT id FROM '.prefixTable('nested_tree').'
1174 1174
                         WHERE title = %s AND personal_folder = %i',
1175 1175
                         $post_id,
1176 1176
                         '1'
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
                             DB::delete(prefixTable('nested_tree'), 'id = %i AND personal_folder = %i', $folder->id, '1');
1184 1184
                             // delete items & logs
1185 1185
                             $items = DB::query(
1186
-                                'SELECT id FROM ' . prefixTable('items') . '
1186
+                                'SELECT id FROM '.prefixTable('items').'
1187 1187
                                 WHERE id_tree=%i AND perso = %i',
1188 1188
                                 $folder->id,
1189 1189
                                 '1'
@@ -1277,7 +1277,7 @@  discard block
 block discarded – undo
1277 1277
 
1278 1278
                     // update LOG
1279 1279
                     if ($oldData['email'] !== $post_email) {
1280
-                        logEvents($SETTINGS, 'user_mngt', 'at_user_email_changed:' . $oldData['email'], (string) $session->get('user-id'), $session->get('user-login'), $post_id);
1280
+                        logEvents($SETTINGS, 'user_mngt', 'at_user_email_changed:'.$oldData['email'], (string) $session->get('user-id'), $session->get('user-login'), $post_id);
1281 1281
                     }
1282 1282
                 }
1283 1283
                 echo prepareExchangedData(
@@ -1326,7 +1326,7 @@  discard block
 block discarded – undo
1326 1326
 
1327 1327
             $login = (string) filter_input(INPUT_POST, 'login', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
1328 1328
             DB::queryFirstRow(
1329
-                'SELECT * FROM ' . prefixTable('users') . '
1329
+                'SELECT * FROM '.prefixTable('users').'
1330 1330
                 WHERE (login = %s AND deleted_at IS NULL) 
1331 1331
                 OR login LIKE %s',
1332 1332
                 $login,
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
             $html = '';
1386 1386
 
1387 1387
             if (isset($SETTINGS['ldap_mode']) === true && (int) $SETTINGS['ldap_mode'] === 1 && isset($SETTINGS['enable_ad_users_with_ad_groups']) === true && (int) $SETTINGS['enable_ad_users_with_ad_groups'] === 1) {
1388
-                $rowUser['fonction_id'] = empty($rowUser['fonction_id'])  === true ? $rowUser['roles_from_ad_groups'] : $rowUser['fonction_id']. ';' . $rowUser['roles_from_ad_groups'];
1388
+                $rowUser['fonction_id'] = empty($rowUser['fonction_id']) === true ? $rowUser['roles_from_ad_groups'] : $rowUser['fonction_id'].';'.$rowUser['roles_from_ad_groups'];
1389 1389
             }
1390 1390
             $arrData['functions'] = array_filter(explode(';', $rowUser['fonction_id']));
1391 1391
             $arrData['allowed_folders'] = array_filter(explode(';', $rowUser['groupes_visibles']));
@@ -1396,8 +1396,8 @@  discard block
 block discarded – undo
1396 1396
                 // refine folders based upon roles
1397 1397
                 $rows = DB::query(
1398 1398
                     'SELECT rv.folder_id, rv.type
1399
-                    FROM ' . prefixTable('roles_values') . ' as rv
1400
-                    INNER JOIN ' . prefixTable('nested_tree') . ' as nt ON rv.folder_id = nt.id
1399
+                    FROM ' . prefixTable('roles_values').' as rv
1400
+                    INNER JOIN ' . prefixTable('nested_tree').' as nt ON rv.folder_id = nt.id
1401 1401
                     WHERE rv.role_id IN %ls AND nt.personal_folder = 0
1402 1402
                     ORDER BY rv.folder_id ASC',
1403 1403
                     $arrData['functions']
@@ -1420,7 +1420,7 @@  discard block
 block discarded – undo
1420 1420
                 }
1421 1421
 
1422 1422
                 // add allowed folders
1423
-                foreach($arrData['allowed_folders'] as $Fld) {
1423
+                foreach ($arrData['allowed_folders'] as $Fld) {
1424 1424
                     array_push($arrFolders, array('id' => $Fld, 'type' => 'W', 'special' => true));
1425 1425
                 }
1426 1426
                 
@@ -1435,7 +1435,7 @@  discard block
 block discarded – undo
1435 1435
                             // get folder name
1436 1436
                             $row = DB::queryFirstRow(
1437 1437
                                 'SELECT title, nlevel, id
1438
-                                FROM ' . prefixTable('nested_tree') . '
1438
+                                FROM ' . prefixTable('nested_tree').'
1439 1439
                                 WHERE id = %i',
1440 1440
                                 $fld['id']
1441 1441
                             );
@@ -1453,8 +1453,8 @@  discard block
 block discarded – undo
1453 1453
                     }
1454 1454
                 }
1455 1455
 
1456
-                $html_full = '<table id="table-folders" class="table table-bordered table-striped dt-responsive nowrap" style="width:100%"><tbody>' .
1457
-                    $html . '</tbody></table>';
1456
+                $html_full = '<table id="table-folders" class="table table-bordered table-striped dt-responsive nowrap" style="width:100%"><tbody>'.
1457
+                    $html.'</tbody></table>';
1458 1458
             } else {
1459 1459
                 $html_full = '';
1460 1460
             }
@@ -1508,10 +1508,10 @@  discard block
 block discarded – undo
1508 1508
                     GROUP_CONCAT(DISTINCT CASE WHEN ur.source = "manual" THEN ur.role_id END ORDER BY ur.role_id SEPARATOR ";") AS fonction_id,
1509 1509
                     GROUP_CONCAT(DISTINCT ug.group_id ORDER BY ug.group_id SEPARATOR ";") AS groupes_visibles,
1510 1510
                     GROUP_CONCAT(DISTINCT ugf.group_id ORDER BY ugf.group_id SEPARATOR ";") AS groupes_interdits
1511
-                    FROM ' . prefixTable('users') . ' AS u
1512
-                    LEFT JOIN ' . prefixTable('users_roles') . ' AS ur ON (u.id = ur.user_id)
1513
-                    LEFT JOIN ' . prefixTable('users_groups') . ' AS ug ON (u.id = ug.user_id)
1514
-                    LEFT JOIN ' . prefixTable('users_groups_forbidden') . ' AS ugf ON (u.id = ugf.user_id)
1511
+                    FROM ' . prefixTable('users').' AS u
1512
+                    LEFT JOIN ' . prefixTable('users_roles').' AS ur ON (u.id = ur.user_id)
1513
+                    LEFT JOIN ' . prefixTable('users_groups').' AS ug ON (u.id = ug.user_id)
1514
+                    LEFT JOIN ' . prefixTable('users_groups_forbidden').' AS ugf ON (u.id = ugf.user_id)
1515 1515
                     WHERE u.admin = %i AND u.isAdministratedByRole IN %ls AND u.deleted_at IS NULL AND u.disabled = %i
1516 1516
                     GROUP BY u.id',
1517 1517
                     0,
@@ -1524,10 +1524,10 @@  discard block
 block discarded – undo
1524 1524
                     GROUP_CONCAT(DISTINCT CASE WHEN ur.source = "manual" THEN ur.role_id END ORDER BY ur.role_id SEPARATOR ";") AS fonction_id,
1525 1525
                     GROUP_CONCAT(DISTINCT ug.group_id ORDER BY ug.group_id SEPARATOR ";") AS groupes_visibles,
1526 1526
                     GROUP_CONCAT(DISTINCT ugf.group_id ORDER BY ugf.group_id SEPARATOR ";") AS groupes_interdits
1527
-                    FROM ' . prefixTable('users') . ' AS u
1528
-                    LEFT JOIN ' . prefixTable('users_roles') . ' AS ur ON (u.id = ur.user_id)
1529
-                    LEFT JOIN ' . prefixTable('users_groups') . ' AS ug ON (u.id = ug.user_id)
1530
-                    LEFT JOIN ' . prefixTable('users_groups_forbidden') . ' AS ugf ON (u.id = ugf.user_id)
1527
+                    FROM ' . prefixTable('users').' AS u
1528
+                    LEFT JOIN ' . prefixTable('users_roles').' AS ur ON (u.id = ur.user_id)
1529
+                    LEFT JOIN ' . prefixTable('users_groups').' AS ug ON (u.id = ug.user_id)
1530
+                    LEFT JOIN ' . prefixTable('users_groups_forbidden').' AS ugf ON (u.id = ugf.user_id)
1531 1531
                     WHERE u.admin = %i AND u.deleted_at IS NULL AND u.disabled = %i
1532 1532
                     GROUP BY u.id',
1533 1533
                     0,
@@ -1548,7 +1548,7 @@  discard block
 block discarded – undo
1548 1548
                     foreach (explode(';', $record['fonction_id']) as $group) {
1549 1549
                         if (!empty($group)) {
1550 1550
                             $tmp = DB::queryFirstRow(
1551
-                                'SELECT id, title FROM ' . prefixTable('roles_title') . '
1551
+                                'SELECT id, title FROM '.prefixTable('roles_title').'
1552 1552
                                 WHERE id = %i',
1553 1553
                                 $group
1554 1554
                             );
@@ -1562,7 +1562,7 @@  discard block
 block discarded – undo
1562 1562
 
1563 1563
                 // Get managed_by
1564 1564
                 $managedBy = DB::queryFirstRow(
1565
-                    'SELECT id, title FROM ' . prefixTable('roles_title') . '
1565
+                    'SELECT id, title FROM '.prefixTable('roles_title').'
1566 1566
                     WHERE id = %i',
1567 1567
                     $record['isAdministratedByRole']
1568 1568
                 );
@@ -1574,7 +1574,7 @@  discard block
 block discarded – undo
1574 1574
                     foreach (explode(';', $record['groupes_visibles']) as $role) {
1575 1575
                         if (!empty($role)) {
1576 1576
                             $tmp = DB::queryFirstRow(
1577
-                                'SELECT id, title FROM ' . prefixTable('nested_tree') . '
1577
+                                'SELECT id, title FROM '.prefixTable('nested_tree').'
1578 1578
                                 WHERE id = %i',
1579 1579
                                 $role
1580 1580
                             );
@@ -1591,7 +1591,7 @@  discard block
 block discarded – undo
1591 1591
                     foreach (explode(';', $record['groupes_interdits']) as $role) {
1592 1592
                         if (!empty($role)) {
1593 1593
                             $tmp = DB::queryFirstRow(
1594
-                                'SELECT id, title FROM ' . prefixTable('nested_tree') . '
1594
+                                'SELECT id, title FROM '.prefixTable('nested_tree').'
1595 1595
                                 WHERE id = %i',
1596 1596
                                 $role
1597 1597
                             );
@@ -1713,7 +1713,7 @@  discard block
 block discarded – undo
1713 1713
 
1714 1714
             // Get info about user
1715 1715
             $data_user = DB::queryFirstRow(
1716
-                'SELECT admin, isAdministratedByRole FROM ' . prefixTable('users') . '
1716
+                'SELECT admin, isAdministratedByRole FROM '.prefixTable('users').'
1717 1717
                 WHERE id = %i',
1718 1718
                 $inputData['source_id']
1719 1719
             );
@@ -1961,14 +1961,14 @@  discard block
 block discarded – undo
1961 1961
             if (empty($post_context) === false && $post_context === 'add_one_role_to_user') {
1962 1962
                 $data_user = DB::queryFirstRow(
1963 1963
                     'SELECT fonction_id, public_key
1964
-                    FROM ' . prefixTable('users') . '
1964
+                    FROM ' . prefixTable('users').'
1965 1965
                     WHERE id = %i',
1966 1966
                     $post_user_id
1967 1967
                 );
1968 1968
 
1969 1969
                 if ($data_user) {
1970 1970
                     // Ensure array is unique
1971
-                    $post_new_value = str_replace(',', ';', $data_user['fonction_id']) . ';' . $post_new_value;
1971
+                    $post_new_value = str_replace(',', ';', $data_user['fonction_id']).';'.$post_new_value;
1972 1972
                     $post_new_value = implode(';', array_unique(explode(';', $post_new_value)));
1973 1973
                 } else {
1974 1974
                     // User not found
@@ -1984,14 +1984,14 @@  discard block
 block discarded – undo
1984 1984
             }
1985 1985
 
1986 1986
             // Manage specific case of api key
1987
-            if($post_field === 'user_api_key') {
1987
+            if ($post_field === 'user_api_key') {
1988 1988
                 $encrypted_key = encryptUserObjectKey(base64_encode($post_new_value), $session->get('user-public_key'));
1989 1989
                 $session->set('user-api_key', $post_new_value);
1990 1990
 
1991 1991
                 // test if user has an api key
1992 1992
                 $data_user = DB::queryFirstRow(
1993 1993
                     'SELECT value
1994
-                    FROM ' . prefixTable('api') . '
1994
+                    FROM ' . prefixTable('api').'
1995 1995
                     WHERE user_id = %i',
1996 1996
                     $post_user_id
1997 1997
                 );
@@ -2111,7 +2111,7 @@  discard block
 block discarded – undo
2111 2111
             } catch (\LdapRecord\Auth\BindException $e) {
2112 2112
                 $error = $e->getDetailedError();
2113 2113
                 if ($error && defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
2114
-                    error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage(). " - ".$error->getDiagnosticMessage());
2114
+                    error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage()." - ".$error->getDiagnosticMessage());
2115 2115
                 }
2116 2116
                 // deepcode ignore ServerLeak: No important data is sent and it is encrypted before sending
2117 2117
                 echo prepareExchangedData(
@@ -2145,7 +2145,7 @@  discard block
 block discarded – undo
2145 2145
             } catch (\LdapRecord\Auth\BindException $e) {
2146 2146
                 $error = $e->getDetailedError();
2147 2147
                 if ($error && defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
2148
-                    error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage(). " - ".$error->getDiagnosticMessage());
2148
+                    error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage()." - ".$error->getDiagnosticMessage());
2149 2149
                 }
2150 2150
                 // deepcode ignore ServerLeak: No important data is sent and it is encrypted before sending
2151 2151
                 echo prepareExchangedData(
@@ -2162,7 +2162,7 @@  discard block
 block discarded – undo
2162 2162
                 if (isset($adUser[$SETTINGS['ldap_user_attribute']][0]) === false) continue;
2163 2163
                 // Build the list of all groups in AD
2164 2164
                 if (isset($adUser['memberof']) === true) {
2165
-                    foreach($adUser['memberof'] as $j => $adUserGroup) {
2165
+                    foreach ($adUser['memberof'] as $j => $adUserGroup) {
2166 2166
                         if (empty($adUserGroup) === false && $j !== "count") {
2167 2167
                             $adGroup = substr($adUserGroup, 3, strpos($adUserGroup, ',') - 3);
2168 2168
                             if (in_array($adGroup, $adRoles) === false && empty($adGroup) === false) {
@@ -2275,7 +2275,7 @@  discard block
 block discarded – undo
2275 2275
 
2276 2276
             // Get all groups in Teampass
2277 2277
             $teampassRoles = array();
2278
-            $rows = DB::query('SELECT id,title FROM ' . prefixTable('roles_title'));
2278
+            $rows = DB::query('SELECT id,title FROM '.prefixTable('roles_title'));
2279 2279
             foreach ($rows as $record) {
2280 2280
                 array_push(
2281 2281
                     $teampassRoles,
@@ -2340,7 +2340,7 @@  discard block
 block discarded – undo
2340 2340
             // Check if user already exists
2341 2341
             $data = DB::query(
2342 2342
                 'SELECT id
2343
-                FROM ' . prefixTable('users') . '
2343
+                FROM ' . prefixTable('users').'
2344 2344
                 WHERE login = %s',
2345 2345
                 $post_login
2346 2346
             );
@@ -2534,7 +2534,7 @@  discard block
 block discarded – undo
2534 2534
             // Check if user already exists
2535 2535
             DB::query(
2536 2536
                 'SELECT id
2537
-                FROM ' . prefixTable('users') . '
2537
+                FROM ' . prefixTable('users').'
2538 2538
                 WHERE id = %i',
2539 2539
                 $post_id
2540 2540
             );
@@ -2596,7 +2596,7 @@  discard block
 block discarded – undo
2596 2596
             // Get all groups in Teampass
2597 2597
             $teampassRoles = array();
2598 2598
             $titleToIdMap = [];
2599
-            $rows = DB::query('SELECT id,title FROM ' . prefixTable('roles_title'));
2599
+            $rows = DB::query('SELECT id,title FROM '.prefixTable('roles_title'));
2600 2600
             foreach ($rows as $record) {
2601 2601
                 array_push(
2602 2602
                     $teampassRoles,
@@ -2641,7 +2641,7 @@  discard block
 block discarded – undo
2641 2641
                     // Get his ID and auth type
2642 2642
                     $userInfo = DB::queryFirstRow(
2643 2643
                         'SELECT id, login, auth_type
2644
-                        FROM ' . prefixTable('users') . '
2644
+                        FROM ' . prefixTable('users').'
2645 2645
                         WHERE login = %s',
2646 2646
                         $userLogin
2647 2647
                     );
@@ -2650,7 +2650,7 @@  discard block
 block discarded – undo
2650 2650
                     $userGroupsInTeampass = [];
2651 2651
                     if ($userInfo !== null) {
2652 2652
                         $userRoles = DB::query(
2653
-                            'SELECT role_id FROM ' . prefixTable('users_roles') . '
2653
+                            'SELECT role_id FROM '.prefixTable('users_roles').'
2654 2654
                             WHERE user_id = %i',
2655 2655
                             $userInfo['id']
2656 2656
                         );
@@ -2759,7 +2759,7 @@  discard block
 block discarded – undo
2759 2759
             // Check if user already exists
2760 2760
             DB::query(
2761 2761
                 'SELECT id
2762
-                FROM ' . prefixTable('users') . '
2762
+                FROM ' . prefixTable('users').'
2763 2763
                 WHERE id = %i',
2764 2764
                 $post_id
2765 2765
             );
@@ -2825,7 +2825,7 @@  discard block
 block discarded – undo
2825 2825
             // Search TP_USER in db        
2826 2826
             $userTP = DB::queryFirstRow(
2827 2827
                 'SELECT pw
2828
-                FROM ' . prefixTable('users') . '
2828
+                FROM ' . prefixTable('users').'
2829 2829
                 WHERE id = %i',
2830 2830
                 TP_USER_ID
2831 2831
             );
@@ -2848,7 +2848,7 @@  discard block
 block discarded – undo
2848 2848
                     'arguments' => json_encode([
2849 2849
                         'new_user_id' => (int) $post_user_id,
2850 2850
                         'new_user_pwd' => '',
2851
-                        'new_user_code' => cryption($post_user_code, '','encrypt', $SETTINGS)['string'],
2851
+                        'new_user_code' => cryption($post_user_code, '', 'encrypt', $SETTINGS)['string'],
2852 2852
                         'owner_id' => (int) TP_USER_ID,
2853 2853
                         'creator_pwd' => $userTP['pw'],
2854 2854
                         'email_body' => $lang->get('email_body_user_config_5'),
@@ -2955,17 +2955,17 @@  discard block
 block discarded – undo
2955 2955
             // get user info
2956 2956
             $processesProgress = DB::query(
2957 2957
                 'SELECT u.ongoing_process_id, pt.task, pt.updated_at, pt.finished_at, pt.is_in_progress
2958
-                FROM ' . prefixTable('users') . ' AS u
2959
-                INNER JOIN ' . prefixTable('background_subtasks') . ' AS pt ON (pt.task_id = u.ongoing_process_id)
2958
+                FROM ' . prefixTable('users').' AS u
2959
+                INNER JOIN ' . prefixTable('background_subtasks').' AS pt ON (pt.task_id = u.ongoing_process_id)
2960 2960
                 WHERE u.id = %i',
2961 2961
                 $user_id
2962 2962
             );
2963 2963
 
2964 2964
             $finished_steps = 0;
2965 2965
             $nb_steps = count($processesProgress);
2966
-            foreach($processesProgress as $process) {
2966
+            foreach ($processesProgress as $process) {
2967 2967
                 if ((int) $process['is_in_progress'] === -1) {
2968
-                    $finished_steps ++;
2968
+                    $finished_steps++;
2969 2969
                 }
2970 2970
             }
2971 2971
 
@@ -2974,7 +2974,7 @@  discard block
 block discarded – undo
2974 2974
                     'error' => false,
2975 2975
                     'message' => '',
2976 2976
                     'user_id' => $user_id,
2977
-                    'status' => $finished_steps === $nb_steps ? 'finished' : number_format($finished_steps/$nb_steps*100, 0).'%',
2977
+                    'status' => $finished_steps === $nb_steps ? 'finished' : number_format($finished_steps / $nb_steps * 100, 0).'%',
2978 2978
                     'debug' => $finished_steps.",".$nb_steps,
2979 2979
                 ),
2980 2980
                 'encode'
@@ -3107,7 +3107,7 @@  discard block
 block discarded – undo
3107 3107
             }
3108 3108
             
3109 3109
             $result = purgeDeletedUserById($userId);
3110
-            $deletedAccountsCount = (int) DB::queryFirstField("SELECT COUNT(id) FROM " . prefixTable('users') . " WHERE deleted_at IS NOT NULL");
3110
+            $deletedAccountsCount = (int) DB::queryFirstField("SELECT COUNT(id) FROM ".prefixTable('users')." WHERE deleted_at IS NOT NULL");
3111 3111
 
3112 3112
             echo prepareExchangedData(
3113 3113
                 [
@@ -3147,13 +3147,13 @@  discard block
 block discarded – undo
3147 3147
 
3148 3148
             // Prepare variables
3149 3149
             $daysRetention = filter_var($dataReceived['days_retention'], FILTER_SANITIZE_NUMBER_INT);
3150
-            $daysRetention = empty($daysRetention) ? 90 : (int)$daysRetention;
3150
+            $daysRetention = empty($daysRetention) ? 90 : (int) $daysRetention;
3151 3151
             $cutoffTimestamp = time() - ($daysRetention * 86400);
3152 3152
             
3153 3153
             try {
3154 3154
                 // Get list of users to delete
3155 3155
                 $users = DB::query(
3156
-                    "SELECT id FROM " . prefixTable("users") . " 
3156
+                    "SELECT id FROM ".prefixTable("users")." 
3157 3157
                     WHERE deleted_at IS NOT NULL 
3158 3158
                     AND deleted_at > 0
3159 3159
                     AND deleted_at < %i
@@ -3177,7 +3177,7 @@  discard block
 block discarded – undo
3177 3177
                 echo prepareExchangedData(
3178 3178
                     [
3179 3179
                         'error' => true,
3180
-                        'message' => $lang->get('error') . ': ' . $e->getMessage(),
3180
+                        'message' => $lang->get('error').': '.$e->getMessage(),
3181 3181
                     ],
3182 3182
                     'encode'
3183 3183
                 );
@@ -3231,10 +3231,10 @@  discard block
 block discarded – undo
3231 3231
             
3232 3232
             $purgedCount = 0;
3233 3233
             $errors = [];
3234
-            $cutoffTimestamp = time() - ((int)$daysRetention * 86400);        
3234
+            $cutoffTimestamp = time() - ((int) $daysRetention * 86400);        
3235 3235
                         
3236 3236
             foreach ($userIds as $userId) {
3237
-                $userId = (int)$userId;
3237
+                $userId = (int) $userId;
3238 3238
                 
3239 3239
                 try {
3240 3240
                     $result = purgeDeletedUserById($userId);
@@ -3242,11 +3242,11 @@  discard block
 block discarded – undo
3242 3242
                     
3243 3243
                 } catch (Exception $e) {
3244 3244
                     DB::rollback();
3245
-                    $errors[] = "User ID $userId: " . $e->getMessage();
3245
+                    $errors[] = "User ID $userId: ".$e->getMessage();
3246 3246
                 }
3247 3247
             }
3248 3248
             
3249
-            $deletedAccountsCount = (int) DB::queryFirstField("SELECT COUNT(id) FROM " . prefixTable('users') . " WHERE deleted_at IS NOT NULL");
3249
+            $deletedAccountsCount = (int) DB::queryFirstField("SELECT COUNT(id) FROM ".prefixTable('users')." WHERE deleted_at IS NOT NULL");
3250 3250
 
3251 3251
             echo prepareExchangedData(
3252 3252
                 [
@@ -3254,7 +3254,7 @@  discard block
 block discarded – undo
3254 3254
                     'purged_count' => $purgedCount,
3255 3255
                     'total_in_batch' => count($userIds),
3256 3256
                     'errors' => $errors,
3257
-                    'message' => $purgedCount . ' user(s) purged in this batch',
3257
+                    'message' => $purgedCount.' user(s) purged in this batch',
3258 3258
                     'deletedAccountsCount' => $deletedAccountsCount,
3259 3259
                 ],
3260 3260
                 'encode'
@@ -3289,7 +3289,7 @@  discard block
 block discarded – undo
3289 3289
             
3290 3290
             // Get info about user
3291 3291
             $data_user = DB::queryFirstRow(
3292
-                'SELECT login FROM ' . prefixTable('users') . ' WHERE id = %i',
3292
+                'SELECT login FROM '.prefixTable('users').' WHERE id = %i',
3293 3293
                 $userId
3294 3294
             );
3295 3295
             
@@ -3302,12 +3302,12 @@  discard block
 block discarded – undo
3302 3302
             }
3303 3303
             
3304 3304
             // Remove user suffix "_deleted_timestamp"
3305
-            $deletedSuffix = '_deleted_' . substr($data_user['login'], strrpos($data_user['login'], '_deleted_') + 9);
3305
+            $deletedSuffix = '_deleted_'.substr($data_user['login'], strrpos($data_user['login'], '_deleted_') + 9);
3306 3306
             $originalLogin = str_replace($deletedSuffix, '', $data_user['login']);
3307 3307
                         
3308 3308
             // Check if an active user with the original login already exists
3309 3309
             $existingUser = DB::queryFirstRow(
3310
-                'SELECT id FROM ' . prefixTable('users') . '
3310
+                'SELECT id FROM '.prefixTable('users').'
3311 3311
                 WHERE login = %s AND deleted_at IS NULL AND id != %i',
3312 3312
                 $originalLogin,
3313 3313
                 $userId
@@ -3317,7 +3317,7 @@  discard block
 block discarded – undo
3317 3317
                 echo prepareExchangedData(
3318 3318
                     array(
3319 3319
                         'error' => true,
3320
-                        'message' => 'Cannot restore user: an active user with login "' . $originalLogin . '" already exists (ID: ' . $existingUser['id'] . ')'
3320
+                        'message' => 'Cannot restore user: an active user with login "'.$originalLogin.'" already exists (ID: '.$existingUser['id'].')'
3321 3321
                     ),
3322 3322
                     'encode'
3323 3323
                 );
@@ -3350,7 +3350,7 @@  discard block
 block discarded – undo
3350 3350
 
3351 3351
     // Get info about user
3352 3352
     $data_user = DB::queryFirstRow(
3353
-        'SELECT admin, isAdministratedByRole FROM ' . prefixTable('users') . '
3353
+        'SELECT admin, isAdministratedByRole FROM '.prefixTable('users').'
3354 3354
         WHERE id = %i',
3355 3355
         $value[1]
3356 3356
     );
@@ -3384,7 +3384,7 @@  discard block
 block discarded – undo
3384 3384
             logEvents(
3385 3385
                 $SETTINGS,
3386 3386
                 'user_mngt',
3387
-                'at_user_new_' . $value[0] . ':' . $value[1],
3387
+                'at_user_new_'.$value[0].':'.$value[1],
3388 3388
                 (string) $session->get('user-id'),
3389 3389
                 $session->get('user-login'),
3390 3390
                 filter_input(INPUT_POST, 'id', FILTER_SANITIZE_FULL_SPECIAL_CHARS)
@@ -3419,7 +3419,7 @@  discard block
 block discarded – undo
3419 3419
 
3420 3420
     // Get info about user
3421 3421
     $data_user = DB::queryFirstRow(
3422
-        'SELECT admin, isAdministratedByRole FROM ' . prefixTable('users') . '
3422
+        'SELECT admin, isAdministratedByRole FROM '.prefixTable('users').'
3423 3423
         WHERE id = %i',
3424 3424
         $id[1]
3425 3425
     );
@@ -3458,7 +3458,7 @@  discard block
 block discarded – undo
3458 3458
     $users = DB::query(
3459 3459
         "SELECT id, login, email, deleted_at, 
3460 3460
                 DATEDIFF(NOW(), FROM_UNIXTIME(deleted_at)) as days_since_deletion
3461
-         FROM " . prefixTable("users") . " 
3461
+         FROM " . prefixTable("users")." 
3462 3462
          WHERE deleted_at IS NOT NULL 
3463 3463
          AND deleted_at > 0
3464 3464
          ORDER BY deleted_at DESC"
@@ -3484,7 +3484,7 @@  discard block
 block discarded – undo
3484 3484
     
3485 3485
     // Vérifier que l'utilisateur est bien marqué deleted
3486 3486
     $user = DB::queryFirstRow(
3487
-        "SELECT id, login, deleted_at FROM " . prefixTable("users") . " 
3487
+        "SELECT id, login, deleted_at FROM ".prefixTable("users")." 
3488 3488
          WHERE id = %i 
3489 3489
          AND deleted_at IS NOT NULL 
3490 3490
          AND deleted_at > 0",
@@ -3524,7 +3524,7 @@  discard block
 block discarded – undo
3524 3524
 
3525 3525
         // delete personal folder and subfolders
3526 3526
         $data = DB::queryFirstRow(
3527
-            'SELECT id FROM ' . prefixTable('nested_tree') . '
3527
+            'SELECT id FROM '.prefixTable('nested_tree').'
3528 3528
             WHERE title = %s AND personal_folder = %i',
3529 3529
             $userId,
3530 3530
             '1'
@@ -3546,7 +3546,7 @@  discard block
 block discarded – undo
3546 3546
                 DB::delete(prefixTable('nested_tree'), 'id = %i AND personal_folder = %i', $folder->id, '1');
3547 3547
                 // delete items & logs
3548 3548
                 $items = DB::query(
3549
-                    'SELECT id FROM ' . prefixTable('items') . '
3549
+                    'SELECT id FROM '.prefixTable('items').'
3550 3550
                     WHERE id_tree=%i AND perso = %i',
3551 3551
                     $folder->id,
3552 3552
                     '1'
@@ -3576,7 +3576,7 @@  discard block
 block discarded – undo
3576 3576
         // Delete any process related to user
3577 3577
         $processes = DB::query(
3578 3578
             'SELECT increment_id
3579
-            FROM ' . prefixTable('background_tasks') . '
3579
+            FROM ' . prefixTable('background_tasks').'
3580 3580
             WHERE JSON_EXTRACT(arguments, "$.new_user_id") = %i',
3581 3581
             $userId
3582 3582
         );
Please login to merge, or discard this patch.
scripts/background_tasks___worker.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 require_once __DIR__.'/traits/UserHandlerTrait.php';
34 34
 require_once __DIR__.'/traits/EmailTrait.php';
35 35
 require_once __DIR__.'/traits/MigrateUserHandlerTrait.php';
36
-require_once __DIR__ . '/taskLogger.php';
36
+require_once __DIR__.'/taskLogger.php';
37 37
 
38 38
 class TaskWorker {
39 39
     use ItemHandlerTrait;
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public function execute() {
68 68
         try {
69
-            if (LOG_TASKS=== true) $this->logger->log('Processing task: ' . print_r($this->taskData, true), 'DEBUG');
69
+            if (LOG_TASKS === true) $this->logger->log('Processing task: '.print_r($this->taskData, true), 'DEBUG');
70 70
             // Dispatch selon le type de processus
71 71
             switch ($this->processType) {
72 72
                 case 'item_copy':
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
      */
115 115
     private function handleDatabaseBackup(array $taskData): void
116 116
     {
117
-        require_once __DIR__ . '/../sources/backup.functions.php';
117
+        require_once __DIR__.'/../sources/backup.functions.php';
118 118
 
119 119
         // Default target dir: <path_to_files_folder>/backups
120
-        $baseFilesDir = (string)($this->settings['path_to_files_folder'] ?? (__DIR__ . '/../files'));
121
-        $targetDir = rtrim($baseFilesDir, '/') . '/backups';
120
+        $baseFilesDir = (string) ($this->settings['path_to_files_folder'] ?? (__DIR__.'/../files'));
121
+        $targetDir = rtrim($baseFilesDir, '/').'/backups';
122 122
 
123 123
         // Allow override via task arguments (optional)
124 124
         if (!empty($taskData['output_dir']) && is_string($taskData['output_dir'])) {
@@ -127,15 +127,15 @@  discard block
 block discarded – undo
127 127
 
128 128
         if (!is_dir($targetDir)) {
129 129
             if (!@mkdir($targetDir, 0770, true) && !is_dir($targetDir)) {
130
-                throw new Exception('Cannot create backup target dir: ' . $targetDir);
130
+                throw new Exception('Cannot create backup target dir: '.$targetDir);
131 131
             }
132 132
         }
133 133
         if (!is_writable($targetDir)) {
134
-            throw new Exception('Backup target dir is not writable: ' . $targetDir);
134
+            throw new Exception('Backup target dir is not writable: '.$targetDir);
135 135
         }
136 136
 
137 137
         // Use stored encryption key (same as UI)
138
-        $encryptionKey = (string)($this->settings['bck_script_passkey'] ?? '');
138
+        $encryptionKey = (string) ($this->settings['bck_script_passkey'] ?? '');
139 139
         if ($encryptionKey === '') {
140 140
             throw new Exception('Missing encryption key (bck_script_passkey).');
141 141
         }
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
 
152 152
     if ($excludeUserId > 0) {
153 153
         $connectedUsers = DB::query(
154
-            'SELECT id FROM ' . prefixTable('users') . ' WHERE session_end >= %i AND id != %i',
154
+            'SELECT id FROM '.prefixTable('users').' WHERE session_end >= %i AND id != %i',
155 155
             $now,
156 156
             $excludeUserId
157 157
         );
158 158
     } else {
159 159
         $connectedUsers = DB::query(
160
-            'SELECT id FROM ' . prefixTable('users') . ' WHERE session_end >= %i',
160
+            'SELECT id FROM '.prefixTable('users').' WHERE session_end >= %i',
161 161
             $now
162 162
         );
163 163
     }
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
 
190 190
         // Store a tiny summary for the task completion "arguments" field (no secrets)
191 191
         $this->taskData['backup_file'] = $res['filename'] ?? '';
192
-        $this->taskData['backup_size_bytes'] = (int)($res['size_bytes'] ?? 0);
193
-        $this->taskData['backup_encrypted'] = (bool)($res['encrypted'] ?? false);
192
+        $this->taskData['backup_size_bytes'] = (int) ($res['size_bytes'] ?? 0);
193
+        $this->taskData['backup_encrypted'] = (bool) ($res['encrypted'] ?? false);
194 194
 
195 195
         // Retention purge (scheduled backups only)
196
-        $backupSource = (string)($taskData['source'] ?? '');
197
-        $backupDir = (string)($taskData['output_dir'] ?? '');   // from task arguments (reliable)
196
+        $backupSource = (string) ($taskData['source'] ?? '');
197
+        $backupDir = (string) ($taskData['output_dir'] ?? ''); // from task arguments (reliable)
198 198
         if ($backupDir === '') {
199 199
             $backupDir = (string) $targetDir;
200 200
         }
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
         $this->taskData['output_dir'] = $backupDir;
204 204
 
205 205
         if ($backupSource === 'scheduler' && $backupDir !== '') {
206
-            $days = (int)$this->getMiscSetting('bck_scheduled_retention_days', '30');
206
+            $days = (int) $this->getMiscSetting('bck_scheduled_retention_days', '30');
207 207
             $deleted = $this->purgeOldScheduledBackups($backupDir, $days);
208 208
 
209
-            $this->upsertMiscSetting('bck_scheduled_last_purge_at', (string)time());
210
-            $this->upsertMiscSetting('bck_scheduled_last_purge_deleted', (string)$deleted);
209
+            $this->upsertMiscSetting('bck_scheduled_last_purge_at', (string) time());
210
+            $this->upsertMiscSetting('bck_scheduled_last_purge_deleted', (string) $deleted);
211 211
 
212 212
             if (LOG_TASKS === true) {
213 213
                 $this->logger->log("database_backup: purge retention={$days}d dir={$backupDir} deleted={$deleted}", 'INFO');
@@ -216,12 +216,12 @@  discard block
 block discarded – undo
216 216
 
217 217
         // If launched by scheduler, update scheduler status in teampass_misc
218 218
         if (!empty($taskData['source']) && $taskData['source'] === 'scheduler') {
219
-            $this->updateSchedulerState('completed', 'Backup created: ' . ($this->taskData['backup_file'] ?? ''));
219
+            $this->updateSchedulerState('completed', 'Backup created: '.($this->taskData['backup_file'] ?? ''));
220 220
         }
221 221
 
222 222
         if (LOG_TASKS === true) {
223 223
             $this->logger->log(
224
-                'database_backup: created ' . ($this->taskData['backup_file'] ?? '') . ' (' . $this->taskData['backup_size_bytes'] . ' bytes)',
224
+                'database_backup: created '.($this->taskData['backup_file'] ?? '').' ('.$this->taskData['backup_size_bytes'].' bytes)',
225 225
                 'INFO'
226 226
             );
227 227
         }
@@ -237,15 +237,15 @@  discard block
 block discarded – undo
237 237
     {
238 238
         $this->upsertMiscSetting('bck_scheduled_last_status', $status);
239 239
         $this->upsertMiscSetting('bck_scheduled_last_message', mb_substr($message, 0, 500));
240
-        $this->upsertMiscSetting('bck_scheduled_last_completed_at', (string)time());
240
+        $this->upsertMiscSetting('bck_scheduled_last_completed_at', (string) time());
241 241
     }
242 242
 
243 243
     private function upsertMiscSetting(string $key, string $value): void
244 244
     {
245 245
         $table = prefixTable('misc');
246 246
 
247
-        $exists = (int)DB::queryFirstField(
248
-            'SELECT COUNT(*) FROM ' . $table . ' WHERE type = %s AND intitule = %s',
247
+        $exists = (int) DB::queryFirstField(
248
+            'SELECT COUNT(*) FROM '.$table.' WHERE type = %s AND intitule = %s',
249 249
             'settings',
250 250
             $key
251 251
         );
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
         $table = prefixTable('misc');
263 263
 
264 264
         $val = DB::queryFirstField(
265
-            'SELECT valeur FROM ' . $table . ' WHERE type = %s AND intitule = %s LIMIT 1',
265
+            'SELECT valeur FROM '.$table.' WHERE type = %s AND intitule = %s LIMIT 1',
266 266
             'settings',
267 267
             $key
268 268
         );
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
         $cutoff = time() - ($retentionDays * 86400);
288 288
         $deleted = 0;
289 289
 
290
-        foreach (glob(rtrim($dir, '/') . '/scheduled-*.sql') as $file) {
290
+        foreach (glob(rtrim($dir, '/').'/scheduled-*.sql') as $file) {
291 291
             if (!is_file($file)) {
292 292
                 continue;
293 293
             }
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
             'is_in_progress' => -1,
310 310
             'finished_at' => time(),
311 311
             'status' => 'completed',
312
-            'error_message' => null,   // <-- on efface toute erreur précédente
312
+            'error_message' => null, // <-- on efface toute erreur précédente
313 313
         ];
314 314
 
315 315
         // Prepare anonimzation of arguments
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
             $arguments = '';
346 346
         }
347 347
 
348
-        if (LOG_TASKS=== true) $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG');
348
+        if (LOG_TASKS === true) $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG');
349 349
 
350 350
         // Add 'arguments' only if not empty
351 351
         if (!empty($arguments)) {
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
             $this->taskId
361 361
         );
362 362
 
363
-        if (LOG_TASKS=== true) $this->logger->log('Finishing task: ' . $this->taskId, 'DEBUG');
363
+        if (LOG_TASKS === true) $this->logger->log('Finishing task: '.$this->taskId, 'DEBUG');
364 364
     }
365 365
 
366 366
     /**
@@ -383,15 +383,15 @@  discard block
 block discarded – undo
383 383
             'increment_id = %i',
384 384
             $this->taskId
385 385
         );
386
-        $this->logger->log('Task failure: ' . $e->getMessage(), 'ERROR');
386
+        $this->logger->log('Task failure: '.$e->getMessage(), 'ERROR');
387 387
     // Purge retention even on failure (safe: only scheduled-*.sql)
388
-        $backupDir = (string)($this->taskData['output_dir'] ?? '');
388
+        $backupDir = (string) ($this->taskData['output_dir'] ?? '');
389 389
         if ($backupDir !== '' && is_dir($backupDir)) {
390
-        $days = (int)$this->getMiscSetting('bck_scheduled_retention_days', '30');
390
+        $days = (int) $this->getMiscSetting('bck_scheduled_retention_days', '30');
391 391
         $deleted = $this->purgeOldScheduledBackups($backupDir, $days);
392 392
 
393
-        $this->upsertMiscSetting('bck_scheduled_last_purge_at', (string)time());
394
-        $this->upsertMiscSetting('bck_scheduled_last_purge_deleted', (string)$deleted);
393
+        $this->upsertMiscSetting('bck_scheduled_last_purge_at', (string) time());
394
+        $this->upsertMiscSetting('bck_scheduled_last_purge_deleted', (string) $deleted);
395 395
         }
396 396
     }
397 397
 
@@ -404,16 +404,16 @@  discard block
 block discarded – undo
404 404
      * @return void
405 405
      */
406 406
     private function processSubTasks($arguments) {
407
-        if (LOG_TASKS=== true) $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG');
407
+        if (LOG_TASKS === true) $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG');
408 408
         // Get all subtasks related to this task
409 409
         $subtasks = DB::query(
410
-            'SELECT * FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC',
410
+            'SELECT * FROM '.prefixTable('background_subtasks').' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC',
411 411
             $this->taskId
412 412
         );
413 413
     
414 414
         // Check if there are any subtasks to process
415 415
         if (empty($subtasks)) {
416
-            if (LOG_TASKS=== true) $this->logger->log('No subtask was found for task: ' . $this->taskId, 'DEBUG');
416
+            if (LOG_TASKS === true) $this->logger->log('No subtask was found for task: '.$this->taskId, 'DEBUG');
417 417
             return;
418 418
         }
419 419
     
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
                 // Get the subtask data
424 424
                 $subtaskData = json_decode($subtask['task'], true);
425 425
 
426
-                if (LOG_TASKS=== true) $this->logger->log('Processing subtask: ' . $subtaskData['step'], 'DEBUG');
426
+                if (LOG_TASKS === true) $this->logger->log('Processing subtask: '.$subtaskData['step'], 'DEBUG');
427 427
 
428 428
                 // Mark subtask as in progress
429 429
                 DB::update(
@@ -475,13 +475,13 @@  discard block
 block discarded – undo
475 475
                     $subtask['increment_id']
476 476
                 );
477 477
         
478
-                $this->logger->log('processSubTasks : ' . $e->getMessage(), 'ERROR');
478
+                $this->logger->log('processSubTasks : '.$e->getMessage(), 'ERROR');
479 479
             }
480 480
         }
481 481
     
482 482
         // Are all subtasks completed?
483 483
         $remainingSubtasks = DB::queryFirstField(
484
-            'SELECT COUNT(*) FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0',
484
+            'SELECT COUNT(*) FROM '.prefixTable('background_subtasks').' WHERE task_id = %i AND is_in_progress = 0',
485 485
             $this->taskId
486 486
         );
487 487
     
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
     error_log("Usage: php background_tasks___worker.php <task_id> <process_type> [<task_data>]");
498 498
     exit(1);
499 499
 }
500
-$taskId = (int)$argv[1];
500
+$taskId = (int) $argv[1];
501 501
 $processType = $argv[2];
502 502
 $taskData = $argv[3] ?? null;
503 503
 if ($taskData) {
Please login to merge, or discard this patch.