Passed
Push — master ( e2329e...d01db6 )
by Nils
06:08
created
sources/main.functions.php 1 patch
Spacing   +153 added lines, -156 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
 // Load config if $SETTINGS not defined
57 57
 if (isset($SETTINGS['cpassman_dir']) === false || empty($SETTINGS['cpassman_dir']) === true) {
58
-    include_once __DIR__ . '/../includes/config/tp.config.php';
58
+    include_once __DIR__.'/../includes/config/tp.config.php';
59 59
 }
60 60
 
61 61
 header('Content-type: text/html; charset=utf-8');
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
             and improve performance by avoiding to include the file for every missing strings.
89 89
         */
90 90
         if (isset($_SESSION['teampass']) === false || isset($_SESSION['teampass']['en_lang'][trim($string)]) === false) {
91
-            $_SESSION['teampass']['en_lang'] = include_once __DIR__. '/../includes/language/english.php';
91
+            $_SESSION['teampass']['en_lang'] = include_once __DIR__.'/../includes/language/english.php';
92 92
             $session_language = isset($_SESSION['teampass']['en_lang'][trim($string)]) === false ? '' : $_SESSION['teampass']['en_lang'][trim($string)];
93 93
         } else {
94 94
             $session_language = $_SESSION['teampass']['en_lang'][trim($string)];
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     if (empty($session_language) === true) {
99 99
         return trim($string);
100 100
     }
101
-    return (string) $antiXss->xss_clean($session_language);//esc_html($session_language);
101
+    return (string) $antiXss->xss_clean($session_language); //esc_html($session_language);
102 102
 }
103 103
 
104 104
 /**
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
             $str = substr($str, 2);
144 144
         }
145 145
     } else {
146
-        if (substr($str, 0, 2 ) === "0x") {
146
+        if (substr($str, 0, 2) === "0x") {
147 147
             $str = substr($str, 2);
148 148
         }
149 149
     }
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
  */
269 269
 function trimElement($chaine, string $element): string
270 270
 {
271
-    if (! empty($chaine)) {
271
+    if (!empty($chaine)) {
272 272
         if (is_array($chaine) === true) {
273 273
             $chaine = implode(';', $chaine);
274 274
         }
@@ -316,8 +316,8 @@  discard block
 block discarded – undo
316 316
  */
317 317
 function db_error_handler(array $params): void
318 318
 {
319
-    echo 'Error: ' . $params['error'] . "<br>\n";
320
-    echo 'Query: ' . $params['query'] . "<br>\n";
319
+    echo 'Error: '.$params['error']."<br>\n";
320
+    echo 'Query: '.$params['query']."<br>\n";
321 321
     throw new Exception('Error - Query', 1);
322 322
 }
323 323
 
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
     $globalsVisibleFolders = $superGlobal->get('groupes_visibles', 'SESSION');
401 401
     $globalsPersonalVisibleFolders = $superGlobal->get('personal_visible_groups', 'SESSION');
402 402
     // Get list of Folders
403
-    $rows = DB::query('SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i', 0);
403
+    $rows = DB::query('SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i', 0);
404 404
     foreach ($rows as $record) {
405 405
         array_push($groupesVisibles, $record['id']);
406 406
     }
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
     }
420 420
     // Get ID of personal folder
421 421
     $persfld = DB::queryfirstrow(
422
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE title = %s',
422
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE title = %s',
423 423
         $globalsUserId
424 424
     );
425 425
     if (empty($persfld['id']) === false) {
@@ -439,20 +439,20 @@  discard block
 block discarded – undo
439 439
     // get complete list of ROLES
440 440
     $tmp = explode(';', $idFonctions);
441 441
     $rows = DB::query(
442
-        'SELECT * FROM ' . prefixTable('roles_title') . '
442
+        'SELECT * FROM '.prefixTable('roles_title').'
443 443
         ORDER BY title ASC'
444 444
     );
445 445
     foreach ($rows as $record) {
446
-        if (! empty($record['id']) && ! in_array($record['id'], $tmp)) {
446
+        if (!empty($record['id']) && !in_array($record['id'], $tmp)) {
447 447
             array_push($tmp, $record['id']);
448 448
         }
449 449
     }
450 450
     $superGlobal->put('fonction_id', implode(';', $tmp), 'SESSION');
451 451
     $superGlobal->put('is_admin', 1, 'SESSION');
452 452
     // Check if admin has created Folders and Roles
453
-    DB::query('SELECT * FROM ' . prefixTable('nested_tree') . '');
453
+    DB::query('SELECT * FROM '.prefixTable('nested_tree').'');
454 454
     $superGlobal->put('nb_folders', DB::count(), 'SESSION');
455
-    DB::query('SELECT * FROM ' . prefixTable('roles_title'));
455
+    DB::query('SELECT * FROM '.prefixTable('roles_title'));
456 456
     $superGlobal->put('nb_roles', DB::count(), 'SESSION');
457 457
 
458 458
     return true;
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
     // Does this user is allowed to see other items
537 537
     $inc = 0;
538 538
     $rows = DB::query(
539
-        'SELECT id, id_tree FROM ' . prefixTable('items') . '
539
+        'SELECT id, id_tree FROM '.prefixTable('items').'
540 540
             WHERE restricted_to LIKE %ss AND inactif = %s'.
541 541
             (count($allowedFolders) > 0 ? ' AND id_tree NOT IN ('.implode(',', $allowedFolders).')' : ''),
542 542
         $globalsUserId,
@@ -553,8 +553,8 @@  discard block
 block discarded – undo
553 553
     // Check for the users roles if some specific rights exist on items
554 554
     $rows = DB::query(
555 555
         'SELECT i.id_tree, r.item_id
556
-        FROM ' . prefixTable('items') . ' as i
557
-        INNER JOIN ' . prefixTable('restriction_to_roles') . ' as r ON (r.item_id=i.id)
556
+        FROM ' . prefixTable('items').' as i
557
+        INNER JOIN ' . prefixTable('restriction_to_roles').' as r ON (r.item_id=i.id)
558 558
         WHERE i.id_tree <> "" '.
559 559
         (count($userRoles) > 0 ? 'AND r.role_id IN %li ' : '').
560 560
         'ORDER BY i.id_tree ASC',
@@ -609,16 +609,16 @@  discard block
 block discarded – undo
609 609
         'SESSION'
610 610
     );
611 611
     // Folders and Roles numbers
612
-    DB::queryfirstrow('SELECT id FROM ' . prefixTable('nested_tree') . '');
612
+    DB::queryfirstrow('SELECT id FROM '.prefixTable('nested_tree').'');
613 613
     $superGlobal->put('nb_folders', DB::count(), 'SESSION');
614
-    DB::queryfirstrow('SELECT id FROM ' . prefixTable('roles_title'));
614
+    DB::queryfirstrow('SELECT id FROM '.prefixTable('roles_title'));
615 615
     $superGlobal->put('nb_roles', DB::count(), 'SESSION');
616 616
     // check if change proposals on User's items
617 617
     if (isset($SETTINGS['enable_suggestion']) === true && (int) $SETTINGS['enable_suggestion'] === 1) {
618 618
         $countNewItems = DB::query(
619 619
             'SELECT COUNT(*)
620
-            FROM ' . prefixTable('items_change') . ' AS c
621
-            LEFT JOIN ' . prefixTable('log_items') . ' AS i ON (c.item_id = i.id_item)
620
+            FROM ' . prefixTable('items_change').' AS c
621
+            LEFT JOIN ' . prefixTable('log_items').' AS i ON (c.item_id = i.id_item)
622 622
             WHERE i.action = %s AND i.id_user = %i',
623 623
             'at_creation',
624 624
             $globalsUserId
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 {
646 646
     $rows = DB::query(
647 647
         'SELECT *
648
-        FROM ' . prefixTable('roles_values') . '
648
+        FROM ' . prefixTable('roles_values').'
649 649
         WHERE type IN %ls'.(count($userRoles) > 0 ? ' AND role_id IN %li' : ''),
650 650
         ['W', 'ND', 'NE', 'NDNE', 'R'],
651 651
         $userRoles,
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
     ) {
713 713
         $persoFld = DB::queryfirstrow(
714 714
             'SELECT id
715
-            FROM ' . prefixTable('nested_tree') . '
715
+            FROM ' . prefixTable('nested_tree').'
716 716
             WHERE title = %s AND personal_folder = %i'.
717 717
             (count($allowedFolders) > 0 ? ' AND id NOT IN ('.implode(',', $allowedFolders).')' : ''),
718 718
             $globalsUserId,
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
     }
746 746
     $persoFlds = DB::query(
747 747
         'SELECT id
748
-        FROM ' . prefixTable('nested_tree') . '
748
+        FROM ' . prefixTable('nested_tree').'
749 749
         WHERE %l',
750 750
         $where
751 751
     );
@@ -813,12 +813,12 @@  discard block
 block discarded – undo
813 813
     //Load Tree
814 814
     $tree = new NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title');
815 815
     // truncate table
816
-    DB::query('TRUNCATE TABLE ' . prefixTable('cache'));
816
+    DB::query('TRUNCATE TABLE '.prefixTable('cache'));
817 817
     // reload date
818 818
     $rows = DB::query(
819 819
         'SELECT *
820
-        FROM ' . prefixTable('items') . ' as i
821
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
820
+        FROM ' . prefixTable('items').' as i
821
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
822 822
         AND l.action = %s
823 823
         AND i.inactif = %i',
824 824
         'at_creation',
@@ -830,18 +830,18 @@  discard block
 block discarded – undo
830 830
             $tags = '';
831 831
             $itemTags = DB::query(
832 832
                 'SELECT tag
833
-                FROM ' . prefixTable('tags') . '
833
+                FROM ' . prefixTable('tags').'
834 834
                 WHERE item_id = %i AND tag != ""',
835 835
                 $record['id']
836 836
             );
837 837
             foreach ($itemTags as $itemTag) {
838
-                $tags .= $itemTag['tag'] . ' ';
838
+                $tags .= $itemTag['tag'].' ';
839 839
             }
840 840
 
841 841
             // Get renewal period
842 842
             $resNT = DB::queryfirstrow(
843 843
                 'SELECT renewal_period
844
-                FROM ' . prefixTable('nested_tree') . '
844
+                FROM ' . prefixTable('nested_tree').'
845 845
                 WHERE id = %i',
846 846
                 $record['id_tree']
847 847
             );
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
                     // Is this a User id?
855 855
                     $user = DB::queryfirstrow(
856 856
                         'SELECT id, login
857
-                        FROM ' . prefixTable('users') . '
857
+                        FROM ' . prefixTable('users').'
858 858
                         WHERE id = %i',
859 859
                         $elem->title
860 860
                     );
@@ -872,11 +872,11 @@  discard block
 block discarded – undo
872 872
                     'id' => $record['id'],
873 873
                     'label' => $record['label'],
874 874
                     'description' => $record['description'] ?? '',
875
-                    'url' => isset($record['url']) && ! empty($record['url']) ? $record['url'] : '0',
875
+                    'url' => isset($record['url']) && !empty($record['url']) ? $record['url'] : '0',
876 876
                     'tags' => $tags,
877 877
                     'id_tree' => $record['id_tree'],
878 878
                     'perso' => $record['perso'],
879
-                    'restricted_to' => isset($record['restricted_to']) && ! empty($record['restricted_to']) ? $record['restricted_to'] : '0',
879
+                    'restricted_to' => isset($record['restricted_to']) && !empty($record['restricted_to']) ? $record['restricted_to'] : '0',
880 880
                     'login' => $record['login'] ?? '',
881 881
                     'folder' => implode(' > ', $folder),
882 882
                     'author' => $record['id_user'],
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
     // get new value from db
907 907
     $data = DB::queryfirstrow(
908 908
         'SELECT label, description, id_tree, perso, restricted_to, login, url
909
-        FROM ' . prefixTable('items') . '
909
+        FROM ' . prefixTable('items').'
910 910
         WHERE id=%i',
911 911
         $ident
912 912
     );
@@ -914,12 +914,12 @@  discard block
 block discarded – undo
914 914
     $tags = '';
915 915
     $itemTags = DB::query(
916 916
         'SELECT tag
917
-            FROM ' . prefixTable('tags') . '
917
+            FROM ' . prefixTable('tags').'
918 918
             WHERE item_id = %i AND tag != ""',
919 919
         $ident
920 920
     );
921 921
     foreach ($itemTags as $itemTag) {
922
-        $tags .= $itemTag['tag'] . ' ';
922
+        $tags .= $itemTag['tag'].' ';
923 923
     }
924 924
     // form id_tree to full foldername
925 925
     $folder = [];
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
             // Is this a User id?
931 931
             $user = DB::queryfirstrow(
932 932
                 'SELECT id, login
933
-                FROM ' . prefixTable('users') . '
933
+                FROM ' . prefixTable('users').'
934 934
                 WHERE id = %i',
935 935
                 $elem->title
936 936
             );
@@ -948,10 +948,10 @@  discard block
 block discarded – undo
948 948
             'label' => $data['label'],
949 949
             'description' => $data['description'],
950 950
             'tags' => $tags,
951
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
951
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
952 952
             'id_tree' => $data['id_tree'],
953 953
             'perso' => $data['perso'],
954
-            'restricted_to' => isset($data['restricted_to']) && ! empty($data['restricted_to']) ? $data['restricted_to'] : '0',
954
+            'restricted_to' => isset($data['restricted_to']) && !empty($data['restricted_to']) ? $data['restricted_to'] : '0',
955 955
             'login' => $data['login'] ?? '',
956 956
             'folder' => implode(' » ', $folder),
957 957
             'author' => $superGlobal->get('user_id', 'SESSION'),
@@ -982,8 +982,8 @@  discard block
 block discarded – undo
982 982
     // get new value from db
983 983
     $data = DB::queryFirstRow(
984 984
         'SELECT i.label, i.description, i.id_tree as id_tree, i.perso, i.restricted_to, i.id, i.login, i.url, l.date
985
-        FROM ' . prefixTable('items') . ' as i
986
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
985
+        FROM ' . prefixTable('items').' as i
986
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
987 987
         WHERE i.id = %i
988 988
         AND l.action = %s',
989 989
         $ident,
@@ -993,12 +993,12 @@  discard block
 block discarded – undo
993 993
     $tags = '';
994 994
     $itemTags = DB::query(
995 995
         'SELECT tag
996
-            FROM ' . prefixTable('tags') . '
996
+            FROM ' . prefixTable('tags').'
997 997
             WHERE item_id = %i AND tag != ""',
998 998
         $ident
999 999
     );
1000 1000
     foreach ($itemTags as $itemTag) {
1001
-        $tags .= $itemTag['tag'] . ' ';
1001
+        $tags .= $itemTag['tag'].' ';
1002 1002
     }
1003 1003
     // form id_tree to full foldername
1004 1004
     $folder = [];
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
             // Is this a User id?
1010 1010
             $user = DB::queryfirstrow(
1011 1011
                 'SELECT id, login
1012
-                FROM ' . prefixTable('users') . '
1012
+                FROM ' . prefixTable('users').'
1013 1013
                 WHERE id = %i',
1014 1014
                 $elem->title
1015 1015
             );
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
             'label' => $data['label'],
1029 1029
             'description' => $data['description'],
1030 1030
             'tags' => isset($tags) && empty($tags) === false ? $tags : 'None',
1031
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
1031
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
1032 1032
             'id_tree' => $data['id_tree'],
1033 1033
             'perso' => isset($data['perso']) && empty($data['perso']) === false && $data['perso'] !== 'None' ? $data['perso'] : '0',
1034 1034
             'restricted_to' => isset($data['restricted_to']) && empty($data['restricted_to']) === false ? $data['restricted_to'] : '0',
@@ -1050,52 +1050,52 @@  discard block
 block discarded – undo
1050 1050
 function getStatisticsData(array $SETTINGS): array
1051 1051
 {
1052 1052
     DB::query(
1053
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
1053
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
1054 1054
         0
1055 1055
     );
1056 1056
     $counter_folders = DB::count();
1057 1057
     DB::query(
1058
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
1058
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
1059 1059
         1
1060 1060
     );
1061 1061
     $counter_folders_perso = DB::count();
1062 1062
     DB::query(
1063
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
1063
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
1064 1064
         0
1065 1065
     );
1066 1066
     $counter_items = DB::count();
1067 1067
         DB::query(
1068
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
1068
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
1069 1069
         1
1070 1070
     );
1071 1071
     $counter_items_perso = DB::count();
1072 1072
         DB::query(
1073
-        'SELECT id FROM ' . prefixTable('users') . ''
1073
+        'SELECT id FROM '.prefixTable('users').''
1074 1074
     );
1075 1075
     $counter_users = DB::count();
1076 1076
         DB::query(
1077
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE admin = %i',
1077
+        'SELECT id FROM '.prefixTable('users').' WHERE admin = %i',
1078 1078
         1
1079 1079
     );
1080 1080
     $admins = DB::count();
1081 1081
     DB::query(
1082
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE gestionnaire = %i',
1082
+        'SELECT id FROM '.prefixTable('users').' WHERE gestionnaire = %i',
1083 1083
         1
1084 1084
     );
1085 1085
     $managers = DB::count();
1086 1086
     DB::query(
1087
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE read_only = %i',
1087
+        'SELECT id FROM '.prefixTable('users').' WHERE read_only = %i',
1088 1088
         1
1089 1089
     );
1090 1090
     $readOnly = DB::count();
1091 1091
     // list the languages
1092 1092
     $usedLang = [];
1093 1093
     $tp_languages = DB::query(
1094
-        'SELECT name FROM ' . prefixTable('languages')
1094
+        'SELECT name FROM '.prefixTable('languages')
1095 1095
     );
1096 1096
     foreach ($tp_languages as $tp_language) {
1097 1097
         DB::query(
1098
-            'SELECT * FROM ' . prefixTable('users') . ' WHERE user_language = %s',
1098
+            'SELECT * FROM '.prefixTable('users').' WHERE user_language = %s',
1099 1099
             $tp_language['name']
1100 1100
         );
1101 1101
         $usedLang[$tp_language['name']] = round((DB::count() * 100 / $counter_users), 0);
@@ -1104,12 +1104,12 @@  discard block
 block discarded – undo
1104 1104
     // get list of ips
1105 1105
     $usedIp = [];
1106 1106
     $tp_ips = DB::query(
1107
-        'SELECT user_ip FROM ' . prefixTable('users')
1107
+        'SELECT user_ip FROM '.prefixTable('users')
1108 1108
     );
1109 1109
     foreach ($tp_ips as $ip) {
1110 1110
         if (array_key_exists($ip['user_ip'], $usedIp)) {
1111 1111
             $usedIp[$ip['user_ip']] += $usedIp[$ip['user_ip']];
1112
-        } elseif (! empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
1112
+        } elseif (!empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
1113 1113
             $usedIp[$ip['user_ip']] = 1;
1114 1114
         }
1115 1115
     }
@@ -1262,12 +1262,12 @@  discard block
 block discarded – undo
1262 1262
     // Load superglobal
1263 1263
     $superGlobal = new SuperGlobal();
1264 1264
     // Get user language
1265
-    include_once $SETTINGS['cpassman_dir'] . '/includes/language/' . (null !== $superGlobal->get('user_language', 'SESSION', 'user') ? $superGlobal->get('user_language', 'SESSION', 'user') : 'english') . '.php';
1265
+    include_once $SETTINGS['cpassman_dir'].'/includes/language/'.(null !== $superGlobal->get('user_language', 'SESSION', 'user') ? $superGlobal->get('user_language', 'SESSION', 'user') : 'english').'.php';
1266 1266
     // load PHPMailer
1267 1267
     $mail = new PHPMailer(true);
1268 1268
 
1269 1269
     // send to user
1270
-    $mail->setLanguage('en', $SETTINGS['cpassman_dir'] . '/vendor/phpmailer/phpmailer/language/');
1270
+    $mail->setLanguage('en', $SETTINGS['cpassman_dir'].'/vendor/phpmailer/phpmailer/language/');
1271 1271
     $mail->SMTPDebug = isset($SETTINGS['email_debug_level']) === true && $cron === false && $silent === false ? $SETTINGS['email_debug_level'] : 0;
1272 1272
     $mail->Port = (int) $SETTINGS['email_port'];
1273 1273
     //COULD BE USED
@@ -1357,7 +1357,7 @@  discard block
 block discarded – undo
1357 1357
         <table width="600" cellpadding="0" cellspacing="0" border="0" class="container" bgcolor="#ffffff" style="border-spacing: 0; border-bottom: 1px solid #e0e0e0; box-shadow: 0 0 3px #ddd; color: #434343; font-family: Helvetica, Verdana, sans-serif;">
1358 1358
         <tr><td class="container-padding" bgcolor="#ffffff" style="border-collapse: collapse; border-left: 1px solid #e0e0e0; background-color: #ffffff; padding-left: 30px; padding-right: 30px;">
1359 1359
         <br><div style="float:right;">' .
1360
-        $textMail .
1360
+        $textMail.
1361 1361
         '<br><br></td></tr></table>
1362 1362
     </td></tr></table>
1363 1363
     <br></body></html>';
@@ -1370,7 +1370,7 @@  discard block
 block discarded – undo
1370 1370
  */
1371 1371
 function generateKey(): string
1372 1372
 {
1373
-    return substr(md5(rand() . rand()), 0, 15);
1373
+    return substr(md5(rand().rand()), 0, 15);
1374 1374
 }
1375 1375
 
1376 1376
 /**
@@ -1448,7 +1448,7 @@  discard block
 block discarded – undo
1448 1448
 {
1449 1449
     array_walk_recursive(
1450 1450
         $array,
1451
-        static function (&$item): void {
1451
+        static function(&$item): void {
1452 1452
             if (mb_detect_encoding((string) $item, 'utf-8', true) === false) {
1453 1453
                 $item = utf8_encode($item);
1454 1454
             }
@@ -1550,7 +1550,7 @@  discard block
 block discarded – undo
1550 1550
  */
1551 1551
 function prefixTable(string $table): string
1552 1552
 {
1553
-    $safeTable = htmlspecialchars(DB_PREFIX . $table);
1553
+    $safeTable = htmlspecialchars(DB_PREFIX.$table);
1554 1554
     if (empty($safeTable) === false) {
1555 1555
         // sanitize string
1556 1556
         return $safeTable;
@@ -1614,7 +1614,7 @@  discard block
 block discarded – undo
1614 1614
 function send_syslog($message, $host, $port, $component = 'teampass'): void
1615 1615
 {
1616 1616
     $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
1617
-    $syslog_message = '<123>' . date('M d H:i:s ') . $component . ': ' . $message;
1617
+    $syslog_message = '<123>'.date('M d H:i:s ').$component.': '.$message;
1618 1618
     socket_sendto($sock, (string) $syslog_message, strlen($syslog_message), 0, (string) $host, (int) $port);
1619 1619
     socket_close($sock);
1620 1620
 }
@@ -1661,14 +1661,14 @@  discard block
 block discarded – undo
1661 1661
     if (isset($SETTINGS['syslog_enable']) === true && (int) $SETTINGS['syslog_enable'] === 1) {
1662 1662
         if ($type === 'user_mngt') {
1663 1663
             send_syslog(
1664
-                'action=' . str_replace('at_', '', $label) . ' attribute=user user=' . $who . ' userid="' . $login . '" change="' . $field_1 . '" ',
1664
+                'action='.str_replace('at_', '', $label).' attribute=user user='.$who.' userid="'.$login.'" change="'.$field_1.'" ',
1665 1665
                 $SETTINGS['syslog_host'],
1666 1666
                 $SETTINGS['syslog_port'],
1667 1667
                 'teampass'
1668 1668
             );
1669 1669
         } else {
1670 1670
             send_syslog(
1671
-                'action=' . $type . ' attribute=' . $label . ' user=' . $who . ' userid="' . $login . '" ',
1671
+                'action='.$type.' attribute='.$label.' user='.$who.' userid="'.$login.'" ',
1672 1672
                 $SETTINGS['syslog_host'],
1673 1673
                 $SETTINGS['syslog_port'],
1674 1674
                 'teampass'
@@ -1742,7 +1742,7 @@  discard block
 block discarded – undo
1742 1742
         if (empty($item_label) === true) {
1743 1743
             $dataItem = DB::queryfirstrow(
1744 1744
                 'SELECT id, id_tree, label
1745
-                FROM ' . prefixTable('items') . '
1745
+                FROM ' . prefixTable('items').'
1746 1746
                 WHERE id = %i',
1747 1747
                 $item_id
1748 1748
             );
@@ -1750,11 +1750,11 @@  discard block
 block discarded – undo
1750 1750
         }
1751 1751
 
1752 1752
         send_syslog(
1753
-            'action=' . str_replace('at_', '', $action) .
1754
-                ' attribute=' . str_replace('at_', '', $attribute[0]) .
1755
-                ' itemno=' . $item_id .
1756
-                ' user=' . is_null($login) === true ? '' : addslashes((string) $login) .
1757
-                ' itemname="' . addslashes($item_label) . '"',
1753
+            'action='.str_replace('at_', '', $action).
1754
+                ' attribute='.str_replace('at_', '', $attribute[0]).
1755
+                ' itemno='.$item_id.
1756
+                ' user='.is_null($login) === true ? '' : addslashes((string) $login).
1757
+                ' itemname="'.addslashes($item_label).'"',
1758 1758
             $SETTINGS['syslog_host'],
1759 1759
             $SETTINGS['syslog_port'],
1760 1760
             'teampass'
@@ -1842,8 +1842,8 @@  discard block
 block discarded – undo
1842 1842
     $notification = DB::queryOneColumn(
1843 1843
         'email',
1844 1844
         'SELECT *
1845
-        FROM ' . prefixTable('notification') . ' AS n
1846
-        INNER JOIN ' . prefixTable('users') . ' AS u ON (n.user_id = u.id)
1845
+        FROM ' . prefixTable('notification').' AS n
1846
+        INNER JOIN ' . prefixTable('users').' AS u ON (n.user_id = u.id)
1847 1847
         WHERE n.item_id = %i AND n.user_id != %i',
1848 1848
         $item_id,
1849 1849
         $globalsUserId
@@ -1854,7 +1854,7 @@  discard block
 block discarded – undo
1854 1854
         // Get list of changes
1855 1855
         $htmlChanges = '<ul>';
1856 1856
         foreach ($changes as $change) {
1857
-            $htmlChanges .= '<li>' . $change . '</li>';
1857
+            $htmlChanges .= '<li>'.$change.'</li>';
1858 1858
         }
1859 1859
         $htmlChanges .= '</ul>';
1860 1860
         // send email
@@ -1891,15 +1891,15 @@  discard block
 block discarded – undo
1891 1891
     $path = '';
1892 1892
     foreach ($arbo as $elem) {
1893 1893
         if (empty($path) === true) {
1894
-            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES) . ' ';
1894
+            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES).' ';
1895 1895
         } else {
1896
-            $path .= '&#8594; ' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1896
+            $path .= '&#8594; '.htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1897 1897
         }
1898 1898
     }
1899 1899
 
1900 1900
     // Build text to show user
1901 1901
     if (empty($label) === false) {
1902
-        return empty($path) === true ? addslashes($label) : addslashes($label) . ' (' . $path . ')';
1902
+        return empty($path) === true ? addslashes($label) : addslashes($label).' ('.$path.')';
1903 1903
     }
1904 1904
     return empty($path) === true ? '' : $path;
1905 1905
 }
@@ -1956,7 +1956,7 @@  discard block
 block discarded – undo
1956 1956
  */
1957 1957
 function handleConfigFile($action, $SETTINGS, $field = null, $value = null)
1958 1958
 {
1959
-    $tp_config_file = $SETTINGS['cpassman_dir'] . '/includes/config/tp.config.php';
1959
+    $tp_config_file = $SETTINGS['cpassman_dir'].'/includes/config/tp.config.php';
1960 1960
 
1961 1961
     // Load class DB
1962 1962
     loadClasses('DB');
@@ -1964,8 +1964,8 @@  discard block
 block discarded – undo
1964 1964
     if (file_exists($tp_config_file) === false || $action === 'rebuild') {
1965 1965
         // perform a copy
1966 1966
         if (file_exists($tp_config_file)) {
1967
-            if (! copy($tp_config_file, $tp_config_file . '.' . date('Y_m_d_His', time()))) {
1968
-                return "ERROR: Could not copy file '" . $tp_config_file . "'";
1967
+            if (!copy($tp_config_file, $tp_config_file.'.'.date('Y_m_d_His', time()))) {
1968
+                return "ERROR: Could not copy file '".$tp_config_file."'";
1969 1969
             }
1970 1970
         }
1971 1971
 
@@ -1975,11 +1975,11 @@  discard block
 block discarded – undo
1975 1975
         $data[1] = "global \$SETTINGS;\n";
1976 1976
         $data[2] = "\$SETTINGS = array (\n";
1977 1977
         $rows = DB::query(
1978
-            'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s',
1978
+            'SELECT * FROM '.prefixTable('misc').' WHERE type=%s',
1979 1979
             'admin'
1980 1980
         );
1981 1981
         foreach ($rows as $record) {
1982
-            array_push($data, "    '" . $record['intitule'] . "' => '" . htmlspecialchars_decode($record['valeur'], ENT_COMPAT) . "',\n");
1982
+            array_push($data, "    '".$record['intitule']."' => '".htmlspecialchars_decode($record['valeur'], ENT_COMPAT)."',\n");
1983 1983
         }
1984 1984
         array_push($data, ");\n");
1985 1985
         $data = array_unique($data);
@@ -1993,15 +1993,15 @@  discard block
 block discarded – undo
1993 1993
                 break;
1994 1994
             }
1995 1995
 
1996
-            if (stristr($line, "'" . $field . "' => '")) {
1997
-                $data[$inc] = "    '" . $field . "' => '" . htmlspecialchars_decode($value ?? '', ENT_COMPAT) . "',\n";
1996
+            if (stristr($line, "'".$field."' => '")) {
1997
+                $data[$inc] = "    '".$field."' => '".htmlspecialchars_decode($value ?? '', ENT_COMPAT)."',\n";
1998 1998
                 $bFound = true;
1999 1999
                 break;
2000 2000
             }
2001 2001
             ++$inc;
2002 2002
         }
2003 2003
         if ($bFound === false) {
2004
-            $data[$inc] = "    '" . $field . "' => '" . htmlspecialchars_decode($value ?? '', ENT_COMPAT). "',\n);\n";
2004
+            $data[$inc] = "    '".$field."' => '".htmlspecialchars_decode($value ?? '', ENT_COMPAT)."',\n);\n";
2005 2005
         }
2006 2006
     }
2007 2007
 
@@ -2031,7 +2031,7 @@  discard block
 block discarded – undo
2031 2031
 {
2032 2032
     global $SETTINGS;
2033 2033
     /* LOAD CPASSMAN SETTINGS */
2034
-    if (! isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
2034
+    if (!isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
2035 2035
         $SETTINGS = [];
2036 2036
         $SETTINGS['duplicate_folder'] = 0;
2037 2037
         //by default, this is set to 0;
@@ -2041,7 +2041,7 @@  discard block
 block discarded – undo
2041 2041
         //by default, this value is set to 5;
2042 2042
         $settings = [];
2043 2043
         $rows = DB::query(
2044
-            'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s_type OR type=%s_type2',
2044
+            'SELECT * FROM '.prefixTable('misc').' WHERE type=%s_type OR type=%s_type2',
2045 2045
             [
2046 2046
                 'type' => 'admin',
2047 2047
                 'type2' => 'settings',
@@ -2073,7 +2073,7 @@  discard block
 block discarded – undo
2073 2073
     $source_cf = [];
2074 2074
     $rows = DB::QUERY(
2075 2075
         'SELECT id_category
2076
-            FROM ' . prefixTable('categories_folders') . '
2076
+            FROM ' . prefixTable('categories_folders').'
2077 2077
             WHERE id_folder = %i',
2078 2078
         $source_id
2079 2079
     );
@@ -2084,7 +2084,7 @@  discard block
 block discarded – undo
2084 2084
     $target_cf = [];
2085 2085
     $rows = DB::QUERY(
2086 2086
         'SELECT id_category
2087
-            FROM ' . prefixTable('categories_folders') . '
2087
+            FROM ' . prefixTable('categories_folders').'
2088 2088
             WHERE id_folder = %i',
2089 2089
         $target_id
2090 2090
     );
@@ -2302,7 +2302,7 @@  discard block
 block discarded – undo
2302 2302
     int  $dirPerm = 0755
2303 2303
 ) {
2304 2304
     // Check if the path exists
2305
-    if (! file_exists($path)) {
2305
+    if (!file_exists($path)) {
2306 2306
         return false;
2307 2307
     }
2308 2308
 
@@ -2355,7 +2355,7 @@  discard block
 block discarded – undo
2355 2355
     // Load item data
2356 2356
     $data = DB::queryFirstRow(
2357 2357
         'SELECT id_tree
2358
-        FROM ' . prefixTable('items') . '
2358
+        FROM ' . prefixTable('items').'
2359 2359
         WHERE id = %i',
2360 2360
         $item_id
2361 2361
     );
@@ -2418,7 +2418,7 @@  discard block
 block discarded – undo
2418 2418
         }
2419 2419
         $host .= substr(explode(".", $email[1])[0], -1, 1);
2420 2420
     }
2421
-    $email = $name . "@" . $host . "." . explode(".", $email[1])[1];
2421
+    $email = $name."@".$host.".".explode(".", $email[1])[1];
2422 2422
     return $email;
2423 2423
 }
2424 2424
 
@@ -2441,7 +2441,7 @@  discard block
 block discarded – undo
2441 2441
     
2442 2442
     // Insert log in DB
2443 2443
     return DB::query(
2444
-        'SELECT ' . $fields . '
2444
+        'SELECT '.$fields.'
2445 2445
         FROM ' . prefixTable($table)
2446 2446
     );
2447 2447
 }
@@ -2456,11 +2456,11 @@  discard block
 block discarded – undo
2456 2456
 function formatSizeUnits(int $bytes): string
2457 2457
 {
2458 2458
     if ($bytes >= 1073741824) {
2459
-        $bytes = number_format($bytes / 1073741824, 2) . ' GB';
2459
+        $bytes = number_format($bytes / 1073741824, 2).' GB';
2460 2460
     } elseif ($bytes >= 1048576) {
2461
-        $bytes = number_format($bytes / 1048576, 2) . ' MB';
2461
+        $bytes = number_format($bytes / 1048576, 2).' MB';
2462 2462
     } elseif ($bytes >= 1024) {
2463
-        $bytes = number_format($bytes / 1024, 2) . ' KB';
2463
+        $bytes = number_format($bytes / 1024, 2).' KB';
2464 2464
     } elseif ($bytes > 1) {
2465 2465
         $bytes .= ' bytes';
2466 2466
     } elseif ($bytes === 1) {
@@ -2705,14 +2705,14 @@  discard block
 block discarded – undo
2705 2705
 
2706 2706
         // Encrypt the file content
2707 2707
         $plaintext = file_get_contents(
2708
-            filter_var($fileInPath . '/' . $fileInName, FILTER_SANITIZE_URL)
2708
+            filter_var($fileInPath.'/'.$fileInName, FILTER_SANITIZE_URL)
2709 2709
         );
2710 2710
         $ciphertext = $cipher->encrypt($plaintext);
2711 2711
         // Save new file
2712 2712
         $hash = md5($plaintext);
2713
-        $fileOut = $fileInPath . '/' . TP_FILE_PREFIX . $hash;
2713
+        $fileOut = $fileInPath.'/'.TP_FILE_PREFIX.$hash;
2714 2714
         file_put_contents($fileOut, $ciphertext);
2715
-        unlink($fileInPath . '/' . $fileInName);
2715
+        unlink($fileInPath.'/'.$fileInName);
2716 2716
         return [
2717 2717
             'fileHash' => base64_encode($hash),
2718 2718
             'objectKey' => base64_encode($objectKey),
@@ -2733,7 +2733,7 @@  discard block
 block discarded – undo
2733 2733
  */
2734 2734
 function decryptFile(string $fileName, string $filePath, string $key): string
2735 2735
 {
2736
-    if (! defined('FILE_BUFFER_SIZE')) {
2736
+    if (!defined('FILE_BUFFER_SIZE')) {
2737 2737
         define('FILE_BUFFER_SIZE', 128 * 1024);
2738 2738
     }
2739 2739
     
@@ -2749,7 +2749,7 @@  discard block
 block discarded – undo
2749 2749
         $cipher->enableContinuousBuffer();
2750 2750
         $cipher->disablePadding();
2751 2751
         // Get file content
2752
-        $ciphertext = file_get_contents($filePath . '/' . TP_FILE_PREFIX . $fileName);
2752
+        $ciphertext = file_get_contents($filePath.'/'.TP_FILE_PREFIX.$fileName);
2753 2753
         // Decrypt file content and return
2754 2754
         return base64_encode($cipher->decrypt($ciphertext));
2755 2755
     /*} else {
@@ -2833,8 +2833,8 @@  discard block
 block discarded – undo
2833 2833
         // Only create the sharekey for a user
2834 2834
         $user = DB::queryFirstRow(
2835 2835
             'SELECT public_key
2836
-            FROM ' . prefixTable('users') . '
2837
-            WHERE id = ' . (int) $superGlobal->get('user_id', 'SESSION') . '
2836
+            FROM ' . prefixTable('users').'
2837
+            WHERE id = ' . (int) $superGlobal->get('user_id', 'SESSION').'
2838 2838
             AND public_key != ""'
2839 2839
         );
2840 2840
 
@@ -2870,10 +2870,9 @@  discard block
 block discarded – undo
2870 2870
         //DB::debugmode(true);
2871 2871
         $users = DB::query(
2872 2872
             'SELECT id, public_key
2873
-            FROM ' . prefixTable('users') . '
2873
+            FROM ' . prefixTable('users').'
2874 2874
             WHERE ' . ($onlyForUser === true ? 
2875
-                'id IN ("' . TP_USER_ID . '","' . $superGlobal->get('user_id', 'SESSION') . '") ' : 
2876
-                'id NOT IN ("' . OTV_USER_ID . '","' . SSH_USER_ID . '","' . API_USER_ID . '") ') . '
2875
+                'id IN ("'.TP_USER_ID.'","'.$superGlobal->get('user_id', 'SESSION').'") ' : 'id NOT IN ("'.OTV_USER_ID.'","'.SSH_USER_ID.'","'.API_USER_ID.'") ').'
2877 2876
             AND public_key != ""'
2878 2877
         );
2879 2878
         //DB::debugmode(false);
@@ -2920,7 +2919,7 @@  discard block
 block discarded – undo
2920 2919
 function isBase64(string $str): bool
2921 2920
 {
2922 2921
     $str = (string) trim($str);
2923
-    if (! isset($str[0])) {
2922
+    if (!isset($str[0])) {
2924 2923
         return false;
2925 2924
     }
2926 2925
 
@@ -2993,7 +2992,7 @@  discard block
 block discarded – undo
2993 2992
         $connection->connect();
2994 2993
     } catch (\LdapRecord\Auth\BindException $e) {
2995 2994
         $error = $e->getDetailedError();
2996
-        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage(). '<br>'.$error->getDiagnosticMessage();
2995
+        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage().'<br>'.$error->getDiagnosticMessage();
2997 2996
         return false;
2998 2997
     }
2999 2998
 
@@ -3006,7 +3005,7 @@  discard block
 block discarded – undo
3006 3005
         }
3007 3006
     } catch (\LdapRecord\Auth\BindException $e) {
3008 3007
         $error = $e->getDetailedError();
3009
-        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage(). '<br>'.$error->getDiagnosticMessage();
3008
+        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage().'<br>'.$error->getDiagnosticMessage();
3010 3009
         return false;
3011 3010
     }
3012 3011
 
@@ -3030,7 +3029,7 @@  discard block
 block discarded – undo
3030 3029
     // expect if personal item
3031 3030
     DB::delete(
3032 3031
         prefixTable('sharekeys_items'),
3033
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
3032
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
3034 3033
         $userId
3035 3034
     );
3036 3035
     // Remove all item sharekeys files
@@ -3038,8 +3037,8 @@  discard block
 block discarded – undo
3038 3037
         prefixTable('sharekeys_files'),
3039 3038
         'user_id = %i AND object_id NOT IN (
3040 3039
             SELECT f.id 
3041
-            FROM ' . prefixTable('items') . ' AS i 
3042
-            INNER JOIN ' . prefixTable('files') . ' AS f ON f.id_item = i.id
3040
+            FROM ' . prefixTable('items').' AS i 
3041
+            INNER JOIN ' . prefixTable('files').' AS f ON f.id_item = i.id
3043 3042
             WHERE i.perso = 1
3044 3043
         )',
3045 3044
         $userId
@@ -3049,8 +3048,8 @@  discard block
 block discarded – undo
3049 3048
         prefixTable('sharekeys_fields'),
3050 3049
         'user_id = %i AND object_id NOT IN (
3051 3050
             SELECT c.id 
3052
-            FROM ' . prefixTable('items') . ' AS i 
3053
-            INNER JOIN ' . prefixTable('categories_items') . ' AS c ON c.item_id = i.id
3051
+            FROM ' . prefixTable('items').' AS i 
3052
+            INNER JOIN ' . prefixTable('categories_items').' AS c ON c.item_id = i.id
3054 3053
             WHERE i.perso = 1
3055 3054
         )',
3056 3055
         $userId
@@ -3058,13 +3057,13 @@  discard block
 block discarded – undo
3058 3057
     // Remove all item sharekeys logs
3059 3058
     DB::delete(
3060 3059
         prefixTable('sharekeys_logs'),
3061
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
3060
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
3062 3061
         $userId
3063 3062
     );
3064 3063
     // Remove all item sharekeys suggestions
3065 3064
     DB::delete(
3066 3065
         prefixTable('sharekeys_suggestions'),
3067
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
3066
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
3068 3067
         $userId
3069 3068
     );
3070 3069
     return false;
@@ -3085,7 +3084,7 @@  discard block
 block discarded – undo
3085 3084
         foreach (DateTimeZone::listIdentifiers() as $timezone) {
3086 3085
             $now->setTimezone(new DateTimeZone($timezone));
3087 3086
             $offsets[] = $offset = $now->getOffset();
3088
-            $timezones[$timezone] = '(' . format_GMT_offset($offset) . ') ' . format_timezone_name($timezone);
3087
+            $timezones[$timezone] = '('.format_GMT_offset($offset).') '.format_timezone_name($timezone);
3089 3088
         }
3090 3089
 
3091 3090
         array_multisort($offsets, $timezones);
@@ -3105,7 +3104,7 @@  discard block
 block discarded – undo
3105 3104
 {
3106 3105
     $hours = intval($offset / 3600);
3107 3106
     $minutes = abs(intval($offset % 3600 / 60));
3108
-    return 'GMT' . ($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
3107
+    return 'GMT'.($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
3109 3108
 }
3110 3109
 
3111 3110
 /**
@@ -3205,8 +3204,7 @@  discard block
 block discarded – undo
3205 3204
 {
3206 3205
     if (isset($array[$key]) === true
3207 3206
         && (is_int($value) === true ?
3208
-            (int) $array[$key] === $value :
3209
-            (string) $array[$key] === $value)
3207
+            (int) $array[$key] === $value : (string) $array[$key] === $value)
3210 3208
     ) {
3211 3209
         return true;
3212 3210
     }
@@ -3228,8 +3226,7 @@  discard block
 block discarded – undo
3228 3226
 {
3229 3227
     if (isset($var) === false
3230 3228
         || (is_int($value) === true ?
3231
-            (int) $var === $value :
3232
-            (string) $var === $value)
3229
+            (int) $var === $value : (string) $var === $value)
3233 3230
     ) {
3234 3231
         return true;
3235 3232
     }
@@ -3280,7 +3277,7 @@  discard block
 block discarded – undo
3280 3277
  */
3281 3278
 function isSetArrayOfValues(array $arrayOfValues): bool
3282 3279
 {
3283
-    foreach($arrayOfValues as $value) {
3280
+    foreach ($arrayOfValues as $value) {
3284 3281
         if (isset($value) === false) {
3285 3282
             return false;
3286 3283
         }
@@ -3302,7 +3299,7 @@  discard block
 block discarded – undo
3302 3299
     /*PHP8 - integer|string*/$value
3303 3300
 ) : bool
3304 3301
 {
3305
-    foreach($arrayOfVars as $variable) {
3302
+    foreach ($arrayOfVars as $variable) {
3306 3303
         if ($variable !== $value) {
3307 3304
             return false;
3308 3305
         }
@@ -3322,7 +3319,7 @@  discard block
 block discarded – undo
3322 3319
     /*PHP8 - integer|string*/$value
3323 3320
 ) : bool
3324 3321
 {
3325
-    foreach($arrayOfVars as $variable) {
3322
+    foreach ($arrayOfVars as $variable) {
3326 3323
         if ($variable === $value) {
3327 3324
             return true;
3328 3325
         }
@@ -3391,7 +3388,7 @@  discard block
 block discarded – undo
3391 3388
 function dataSanitizer(
3392 3389
     array $data,
3393 3390
     array $filters,
3394
-    string $path = __DIR__. '/..' // Path to Teampass root
3391
+    string $path = __DIR__.'/..' // Path to Teampass root
3395 3392
 )
3396 3393
 {
3397 3394
     // Load Sanitizer library
@@ -3421,7 +3418,7 @@  discard block
 block discarded – undo
3421 3418
     // Exists ?
3422 3419
     $userCacheId = DB::queryfirstrow(
3423 3420
         'SELECT increment_id
3424
-        FROM ' . prefixTable('cache_tree') . '
3421
+        FROM ' . prefixTable('cache_tree').'
3425 3422
         WHERE user_id = %i',
3426 3423
         $user_id
3427 3424
     );
@@ -3470,7 +3467,7 @@  discard block
 block discarded – undo
3470 3467
  */
3471 3468
 function pourcentage(float $nombre, float $total, float $pourcentage): float
3472 3469
 { 
3473
-    $resultat = ($nombre/$total) * $pourcentage;
3470
+    $resultat = ($nombre / $total) * $pourcentage;
3474 3471
     return round($resultat);
3475 3472
 }
3476 3473
 
@@ -3498,7 +3495,7 @@  discard block
 block discarded – undo
3498 3495
 
3499 3496
     // Get last folder update
3500 3497
     $lastFolderChange = DB::queryfirstrow(
3501
-        'SELECT valeur FROM ' . prefixTable('misc') . '
3498
+        'SELECT valeur FROM '.prefixTable('misc').'
3502 3499
         WHERE type = %s AND intitule = %s',
3503 3500
         'timestamp',
3504 3501
         'last_folder_change'
@@ -3528,7 +3525,7 @@  discard block
 block discarded – undo
3528 3525
     // Does this user has a tree cache
3529 3526
     $userCacheTree = DB::queryfirstrow(
3530 3527
         'SELECT '.$fieldName.'
3531
-        FROM ' . prefixTable('cache_tree') . '
3528
+        FROM ' . prefixTable('cache_tree').'
3532 3529
         WHERE user_id = %i',
3533 3530
         $_SESSION['user_id']
3534 3531
     );
@@ -3565,7 +3562,7 @@  discard block
 block discarded – undo
3565 3562
     if (count($folderIds) === 0) {
3566 3563
         $folderIds = DB::queryFirstColumn(
3567 3564
             'SELECT id
3568
-            FROM ' . prefixTable('nested_tree') . '
3565
+            FROM ' . prefixTable('nested_tree').'
3569 3566
             WHERE personal_folder=%i',
3570 3567
             0
3571 3568
         );
@@ -3582,8 +3579,8 @@  discard block
 block discarded – undo
3582 3579
         $rows_tmp = DB::query(
3583 3580
             'SELECT c.id, c.title, c.level, c.type, c.masked, c.order, c.encrypted_data, c.role_visibility, c.is_mandatory,
3584 3581
             f.id_category AS category_id
3585
-            FROM ' . prefixTable('categories_folders') . ' AS f
3586
-            INNER JOIN ' . prefixTable('categories') . ' AS c ON (f.id_category = c.parent_id)
3582
+            FROM ' . prefixTable('categories_folders').' AS f
3583
+            INNER JOIN ' . prefixTable('categories').' AS c ON (f.id_category = c.parent_id)
3587 3584
             WHERE id_folder=%i',
3588 3585
             $folder
3589 3586
         );
@@ -3609,7 +3606,7 @@  discard block
 block discarded – undo
3609 3606
         $valTemp = '';
3610 3607
         $data = DB::queryFirstRow(
3611 3608
             'SELECT valeur
3612
-            FROM ' . prefixTable('misc') . '
3609
+            FROM ' . prefixTable('misc').'
3613 3610
             WHERE type = %s AND intitule=%i',
3614 3611
             'complex',
3615 3612
             $folder
@@ -3626,14 +3623,14 @@  discard block
 block discarded – undo
3626 3623
         $valTemp = '';
3627 3624
         $rows_tmp = DB::query(
3628 3625
             'SELECT t.title
3629
-            FROM ' . prefixTable('roles_values') . ' as v
3630
-            INNER JOIN ' . prefixTable('roles_title') . ' as t ON (v.role_id = t.id)
3626
+            FROM ' . prefixTable('roles_values').' as v
3627
+            INNER JOIN ' . prefixTable('roles_title').' as t ON (v.role_id = t.id)
3631 3628
             WHERE v.folder_id = %i
3632 3629
             GROUP BY title',
3633 3630
             $folder
3634 3631
         );
3635 3632
         foreach ($rows_tmp as $record) {
3636
-            $valTemp .= (empty($valTemp) === true ? '' : ' - ') . $record['title'];
3633
+            $valTemp .= (empty($valTemp) === true ? '' : ' - ').$record['title'];
3637 3634
         }
3638 3635
         $arr_data['visibilityRoles'] = $valTemp;
3639 3636
 
@@ -3665,7 +3662,7 @@  discard block
 block discarded – undo
3665 3662
         // loop on users and check if user has this role
3666 3663
         $rows = DB::query(
3667 3664
             'SELECT id, fonction_id
3668
-            FROM ' . prefixTable('users') . '
3665
+            FROM ' . prefixTable('users').'
3669 3666
             WHERE id != %i AND admin = 0 AND fonction_id IS NOT NULL AND fonction_id != ""',
3670 3667
             $_SESSION['user_id']
3671 3668
         );
@@ -3704,7 +3701,7 @@  discard block
 block discarded – undo
3704 3701
 
3705 3702
     $val = DB::queryfirstrow(
3706 3703
         'SELECT *
3707
-        FROM ' . prefixTable('users') . '
3704
+        FROM ' . prefixTable('users').'
3708 3705
         WHERE id = %i',
3709 3706
         $userId
3710 3707
     );
@@ -3720,12 +3717,12 @@  discard block
 block discarded – undo
3720 3717
 function upgradeRequired(): bool
3721 3718
 {
3722 3719
     // Get settings.php
3723
-    include_once __DIR__. '/../includes/config/settings.php';
3720
+    include_once __DIR__.'/../includes/config/settings.php';
3724 3721
 
3725 3722
     // Get timestamp in DB
3726 3723
     $val = DB::queryfirstrow(
3727 3724
         'SELECT valeur
3728
-        FROM ' . prefixTable('misc') . '
3725
+        FROM ' . prefixTable('misc').'
3729 3726
         WHERE type = %s AND intitule = %s',
3730 3727
         'admin',
3731 3728
         'upgrade_timestamp'
@@ -3778,7 +3775,7 @@  discard block
 block discarded – undo
3778 3775
     // prepapre background tasks for item keys generation        
3779 3776
     $userTP = DB::queryFirstRow(
3780 3777
         'SELECT pw, public_key, private_key
3781
-        FROM ' . prefixTable('users') . '
3778
+        FROM ' . prefixTable('users').'
3782 3779
         WHERE id = %i',
3783 3780
         TP_USER_ID
3784 3781
     );
@@ -3803,7 +3800,7 @@  discard block
 block discarded – undo
3803 3800
         }
3804 3801
 
3805 3802
         // Generate new keys
3806
-        if ($user_self_change === true && empty($recovery_public_key) === false && empty($recovery_private_key) === false){
3803
+        if ($user_self_change === true && empty($recovery_public_key) === false && empty($recovery_private_key) === false) {
3807 3804
             $userKeys = [
3808 3805
                 'public_key' => $recovery_public_key,
3809 3806
                 'private_key_clear' => $recovery_private_key,
@@ -3843,8 +3840,8 @@  discard block
 block discarded – undo
3843 3840
                 'process_type' => 'create_user_keys',
3844 3841
                 'arguments' => json_encode([
3845 3842
                     'new_user_id' => (int) $userId,
3846
-                    'new_user_pwd' => cryption($passwordClear, '','encrypt')['string'],
3847
-                    'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '','encrypt')['string'],
3843
+                    'new_user_pwd' => cryption($passwordClear, '', 'encrypt')['string'],
3844
+                    'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '', 'encrypt')['string'],
3848 3845
                     'owner_id' => (int) TP_USER_ID,
3849 3846
                     'creator_pwd' => $userTP['pw'],
3850 3847
                     'send_email' => $sendEmailToUser === true ? 1 : 0,
@@ -4140,7 +4137,7 @@  discard block
 block discarded – undo
4140 4137
  * @param integer $user_id
4141 4138
  * @return void
4142 4139
  */
4143
-function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id=0)
4140
+function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id = 0)
4144 4141
 {
4145 4142
     if ($allUsers === true) {
4146 4143
         // Load class DB
@@ -4150,7 +4147,7 @@  discard block
 block discarded – undo
4150 4147
 
4151 4148
         $users = DB::query(
4152 4149
             'SELECT id
4153
-            FROM ' . prefixTable('users') . '
4150
+            FROM ' . prefixTable('users').'
4154 4151
             WHERE id NOT IN ('.OTV_USER_ID.', '.TP_USER_ID.', '.SSH_USER_ID.', '.API_USER_ID.')
4155 4152
             ORDER BY login ASC'
4156 4153
         );
@@ -4168,7 +4165,7 @@  discard block
 block discarded – undo
4168 4165
  * @param integer $user_id
4169 4166
  * @return void
4170 4167
  */
4171
-function purgeUnnecessaryKeysForUser(int $user_id=0)
4168
+function purgeUnnecessaryKeysForUser(int $user_id = 0)
4172 4169
 {
4173 4170
     if ($user_id === 0) {
4174 4171
         return;
@@ -4179,8 +4176,8 @@  discard block
 block discarded – undo
4179 4176
 
4180 4177
     $personalItems = DB::queryFirstColumn(
4181 4178
         'SELECT id
4182
-        FROM ' . prefixTable('items') . ' AS i
4183
-        INNER JOIN ' . prefixTable('log_items') . ' AS li ON li.id_item = i.id
4179
+        FROM ' . prefixTable('items').' AS i
4180
+        INNER JOIN ' . prefixTable('log_items').' AS li ON li.id_item = i.id
4184 4181
         WHERE i.perso = 1 AND li.action = "at_creation" AND li.id_user IN (%i, '.TP_USER_ID.')',
4185 4182
         $user_id
4186 4183
     );
@@ -4228,7 +4225,7 @@  discard block
 block discarded – undo
4228 4225
     // Check if user exists
4229 4226
     $userInfo = DB::queryFirstRow(
4230 4227
         'SELECT pw, public_key, private_key, login, name
4231
-        FROM ' . prefixTable('users') . '
4228
+        FROM ' . prefixTable('users').'
4232 4229
         WHERE id = %i',
4233 4230
         $userId
4234 4231
     );
@@ -4238,7 +4235,7 @@  discard block
 block discarded – undo
4238 4235
 
4239 4236
         // Prepare file content
4240 4237
         $export_value = file_get_contents(__DIR__."/../includes/core/teampass_ascii.txt")."\n".
4241
-            "Generation date: ".date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now)."\n\n".
4238
+            "Generation date: ".date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now)."\n\n".
4242 4239
             "RECOVERY KEYS - Not to be shared - To be store safely\n\n".
4243 4240
             "Public Key:\n".$userInfo['public_key']."\n\n".
4244 4241
             "Private Key:\n".decryptPrivateKey($_SESSION['user_pwd'], $userInfo['private_key'])."\n\n";
@@ -4261,7 +4258,7 @@  discard block
 block discarded – undo
4261 4258
         return prepareExchangedData(
4262 4259
             array(
4263 4260
                 'error' => false,
4264
-                'datetime' => date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now),
4261
+                'datetime' => date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now),
4265 4262
                 'timestamp' => $now,
4266 4263
                 'content' => base64_encode($export_value),
4267 4264
                 'login' => $userInfo['login'],
@@ -4287,10 +4284,10 @@  discard block
 block discarded – undo
4287 4284
  */
4288 4285
 function loadClasses(string $className = ''): void
4289 4286
 {
4290
-    require_once __DIR__. '/../includes/config/include.php';
4291
-    require_once __DIR__. '/../includes/config/settings.php';
4287
+    require_once __DIR__.'/../includes/config/include.php';
4288
+    require_once __DIR__.'/../includes/config/settings.php';
4292 4289
     if (phpversion() < 8) {
4293
-        require_once __DIR__. '/../includes/libraries/string.polyfill.php';
4290
+        require_once __DIR__.'/../includes/libraries/string.polyfill.php';
4294 4291
     }
4295 4292
     require_once __DIR__.'/../vendor/autoload.php';
4296 4293
 
Please login to merge, or discard this patch.