Passed
Push — master ( 2b4eae...097631 )
by Nils
06:26
created
sources/main.functions.php 1 patch
Spacing   +153 added lines, -156 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
 // Load config if $SETTINGS not defined
53 53
 if (isset($SETTINGS['cpassman_dir']) === false || empty($SETTINGS['cpassman_dir']) === true) {
54
-    include_once __DIR__ . '/../includes/config/tp.config.php';
54
+    include_once __DIR__.'/../includes/config/tp.config.php';
55 55
 }
56 56
 
57 57
 header('Content-type: text/html; charset=utf-8');
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
             and improve performance by avoiding to include the file for every missing strings.
86 86
         */
87 87
         if (isset($_SESSION['teampass']) === false || isset($_SESSION['teampass']['en_lang'][trim($string)]) === false) {
88
-            $_SESSION['teampass']['en_lang'] = include_once __DIR__. '/../includes/language/english.php';
88
+            $_SESSION['teampass']['en_lang'] = include_once __DIR__.'/../includes/language/english.php';
89 89
             $session_language = isset($_SESSION['teampass']['en_lang'][trim($string)]) === false ? '' : $_SESSION['teampass']['en_lang'][trim($string)];
90 90
         } else {
91 91
             $session_language = $_SESSION['teampass']['en_lang'][trim($string)];
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
  */
334 334
 function trimElement($chaine, string $element): string
335 335
 {
336
-    if (! empty($chaine)) {
336
+    if (!empty($chaine)) {
337 337
         if (is_array($chaine) === true) {
338 338
             $chaine = implode(';', $chaine);
339 339
         }
@@ -381,8 +381,8 @@  discard block
 block discarded – undo
381 381
  */
382 382
 function db_error_handler(array $params): void
383 383
 {
384
-    echo 'Error: ' . $params['error'] . "<br>\n";
385
-    echo 'Query: ' . $params['query'] . "<br>\n";
384
+    echo 'Error: '.$params['error']."<br>\n";
385
+    echo 'Query: '.$params['query']."<br>\n";
386 386
     throw new Exception('Error - Query', 1);
387 387
 }
388 388
 
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
     $globalsVisibleFolders = $superGlobal->get('groupes_visibles', 'SESSION');
477 477
     $globalsPersonalVisibleFolders = $superGlobal->get('personal_visible_groups', 'SESSION');
478 478
     // Get list of Folders
479
-    $rows = DB::query('SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i', 0);
479
+    $rows = DB::query('SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i', 0);
480 480
     foreach ($rows as $record) {
481 481
         array_push($groupesVisibles, $record['id']);
482 482
     }
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
     }
496 496
     // Get ID of personal folder
497 497
     $persfld = DB::queryfirstrow(
498
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE title = %s',
498
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE title = %s',
499 499
         $globalsUserId
500 500
     );
501 501
     if (empty($persfld['id']) === false) {
@@ -516,20 +516,20 @@  discard block
 block discarded – undo
516 516
     // get complete list of ROLES
517 517
     $tmp = explode(';', $idFonctions);
518 518
     $rows = DB::query(
519
-        'SELECT * FROM ' . prefixTable('roles_title') . '
519
+        'SELECT * FROM '.prefixTable('roles_title').'
520 520
         ORDER BY title ASC'
521 521
     );
522 522
     foreach ($rows as $record) {
523
-        if (! empty($record['id']) && ! in_array($record['id'], $tmp)) {
523
+        if (!empty($record['id']) && !in_array($record['id'], $tmp)) {
524 524
             array_push($tmp, $record['id']);
525 525
         }
526 526
     }
527 527
     $superGlobal->put('fonction_id', implode(';', $tmp), 'SESSION');
528 528
     $superGlobal->put('is_admin', 1, 'SESSION');
529 529
     // Check if admin has created Folders and Roles
530
-    DB::query('SELECT * FROM ' . prefixTable('nested_tree') . '');
530
+    DB::query('SELECT * FROM '.prefixTable('nested_tree').'');
531 531
     $superGlobal->put('nb_folders', DB::count(), 'SESSION');
532
-    DB::query('SELECT * FROM ' . prefixTable('roles_title'));
532
+    DB::query('SELECT * FROM '.prefixTable('roles_title'));
533 533
     $superGlobal->put('nb_roles', DB::count(), 'SESSION');
534 534
 
535 535
     return true;
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
     // Does this user is allowed to see other items
614 614
     $inc = 0;
615 615
     $rows = DB::query(
616
-        'SELECT id, id_tree FROM ' . prefixTable('items') . '
616
+        'SELECT id, id_tree FROM '.prefixTable('items').'
617 617
             WHERE restricted_to LIKE %ss AND inactif = %s'.
618 618
             (count($allowedFolders) > 0 ? ' AND id_tree NOT IN ('.implode(',', $allowedFolders).')' : ''),
619 619
         $globalsUserId,
@@ -630,8 +630,8 @@  discard block
 block discarded – undo
630 630
     // Check for the users roles if some specific rights exist on items
631 631
     $rows = DB::query(
632 632
         'SELECT i.id_tree, r.item_id
633
-        FROM ' . prefixTable('items') . ' as i
634
-        INNER JOIN ' . prefixTable('restriction_to_roles') . ' as r ON (r.item_id=i.id)
633
+        FROM ' . prefixTable('items').' as i
634
+        INNER JOIN ' . prefixTable('restriction_to_roles').' as r ON (r.item_id=i.id)
635 635
         WHERE i.id_tree <> "" '.
636 636
         (count($userRoles) > 0 ? 'AND r.role_id IN %li ' : '').
637 637
         'ORDER BY i.id_tree ASC',
@@ -686,16 +686,16 @@  discard block
 block discarded – undo
686 686
         'SESSION'
687 687
     );
688 688
     // Folders and Roles numbers
689
-    DB::queryfirstrow('SELECT id FROM ' . prefixTable('nested_tree') . '');
689
+    DB::queryfirstrow('SELECT id FROM '.prefixTable('nested_tree').'');
690 690
     $superGlobal->put('nb_folders', DB::count(), 'SESSION');
691
-    DB::queryfirstrow('SELECT id FROM ' . prefixTable('roles_title'));
691
+    DB::queryfirstrow('SELECT id FROM '.prefixTable('roles_title'));
692 692
     $superGlobal->put('nb_roles', DB::count(), 'SESSION');
693 693
     // check if change proposals on User's items
694 694
     if (isset($SETTINGS['enable_suggestion']) === true && (int) $SETTINGS['enable_suggestion'] === 1) {
695 695
         $countNewItems = DB::query(
696 696
             'SELECT COUNT(*)
697
-            FROM ' . prefixTable('items_change') . ' AS c
698
-            LEFT JOIN ' . prefixTable('log_items') . ' AS i ON (c.item_id = i.id_item)
697
+            FROM ' . prefixTable('items_change').' AS c
698
+            LEFT JOIN ' . prefixTable('log_items').' AS i ON (c.item_id = i.id_item)
699 699
             WHERE i.action = %s AND i.id_user = %i',
700 700
             'at_creation',
701 701
             $globalsUserId
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 {
723 723
     $rows = DB::query(
724 724
         'SELECT *
725
-        FROM ' . prefixTable('roles_values') . '
725
+        FROM ' . prefixTable('roles_values').'
726 726
         WHERE type IN %ls'.(count($userRoles) > 0 ? ' AND role_id IN %li' : ''),
727 727
         ['W', 'ND', 'NE', 'NDNE', 'R'],
728 728
         $userRoles,
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
     ) {
790 790
         $persoFld = DB::queryfirstrow(
791 791
             'SELECT id
792
-            FROM ' . prefixTable('nested_tree') . '
792
+            FROM ' . prefixTable('nested_tree').'
793 793
             WHERE title = %s AND personal_folder = %i'.
794 794
             (count($allowedFolders) > 0 ? ' AND id NOT IN ('.implode(',', $allowedFolders).')' : ''),
795 795
             $globalsUserId,
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
     }
823 823
     $persoFlds = DB::query(
824 824
         'SELECT id
825
-        FROM ' . prefixTable('nested_tree') . '
825
+        FROM ' . prefixTable('nested_tree').'
826 826
         WHERE %l',
827 827
         $where
828 828
     );
@@ -892,12 +892,12 @@  discard block
 block discarded – undo
892 892
     //Load Tree
893 893
     $tree = new NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title');
894 894
     // truncate table
895
-    DB::query('TRUNCATE TABLE ' . prefixTable('cache'));
895
+    DB::query('TRUNCATE TABLE '.prefixTable('cache'));
896 896
     // reload date
897 897
     $rows = DB::query(
898 898
         'SELECT *
899
-        FROM ' . prefixTable('items') . ' as i
900
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
899
+        FROM ' . prefixTable('items').' as i
900
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
901 901
         AND l.action = %s
902 902
         AND i.inactif = %i',
903 903
         'at_creation',
@@ -909,18 +909,18 @@  discard block
 block discarded – undo
909 909
             $tags = '';
910 910
             $itemTags = DB::query(
911 911
                 'SELECT tag
912
-                FROM ' . prefixTable('tags') . '
912
+                FROM ' . prefixTable('tags').'
913 913
                 WHERE item_id = %i AND tag != ""',
914 914
                 $record['id']
915 915
             );
916 916
             foreach ($itemTags as $itemTag) {
917
-                $tags .= $itemTag['tag'] . ' ';
917
+                $tags .= $itemTag['tag'].' ';
918 918
             }
919 919
 
920 920
             // Get renewal period
921 921
             $resNT = DB::queryfirstrow(
922 922
                 'SELECT renewal_period
923
-                FROM ' . prefixTable('nested_tree') . '
923
+                FROM ' . prefixTable('nested_tree').'
924 924
                 WHERE id = %i',
925 925
                 $record['id_tree']
926 926
             );
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
                     // Is this a User id?
934 934
                     $user = DB::queryfirstrow(
935 935
                         'SELECT id, login
936
-                        FROM ' . prefixTable('users') . '
936
+                        FROM ' . prefixTable('users').'
937 937
                         WHERE id = %i',
938 938
                         $elem->title
939 939
                     );
@@ -951,11 +951,11 @@  discard block
 block discarded – undo
951 951
                     'id' => $record['id'],
952 952
                     'label' => $record['label'],
953 953
                     'description' => $record['description'] ?? '',
954
-                    'url' => isset($record['url']) && ! empty($record['url']) ? $record['url'] : '0',
954
+                    'url' => isset($record['url']) && !empty($record['url']) ? $record['url'] : '0',
955 955
                     'tags' => $tags,
956 956
                     'id_tree' => $record['id_tree'],
957 957
                     'perso' => $record['perso'],
958
-                    'restricted_to' => isset($record['restricted_to']) && ! empty($record['restricted_to']) ? $record['restricted_to'] : '0',
958
+                    'restricted_to' => isset($record['restricted_to']) && !empty($record['restricted_to']) ? $record['restricted_to'] : '0',
959 959
                     'login' => $record['login'] ?? '',
960 960
                     'folder' => implode(' > ', $folder),
961 961
                     'author' => $record['id_user'],
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
     // get new value from db
988 988
     $data = DB::queryfirstrow(
989 989
         'SELECT label, description, id_tree, perso, restricted_to, login, url
990
-        FROM ' . prefixTable('items') . '
990
+        FROM ' . prefixTable('items').'
991 991
         WHERE id=%i',
992 992
         $ident
993 993
     );
@@ -995,12 +995,12 @@  discard block
 block discarded – undo
995 995
     $tags = '';
996 996
     $itemTags = DB::query(
997 997
         'SELECT tag
998
-            FROM ' . prefixTable('tags') . '
998
+            FROM ' . prefixTable('tags').'
999 999
             WHERE item_id = %i AND tag != ""',
1000 1000
         $ident
1001 1001
     );
1002 1002
     foreach ($itemTags as $itemTag) {
1003
-        $tags .= $itemTag['tag'] . ' ';
1003
+        $tags .= $itemTag['tag'].' ';
1004 1004
     }
1005 1005
     // form id_tree to full foldername
1006 1006
     $folder = [];
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
             // Is this a User id?
1012 1012
             $user = DB::queryfirstrow(
1013 1013
                 'SELECT id, login
1014
-                FROM ' . prefixTable('users') . '
1014
+                FROM ' . prefixTable('users').'
1015 1015
                 WHERE id = %i',
1016 1016
                 $elem->title
1017 1017
             );
@@ -1029,10 +1029,10 @@  discard block
 block discarded – undo
1029 1029
             'label' => $data['label'],
1030 1030
             'description' => $data['description'],
1031 1031
             'tags' => $tags,
1032
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
1032
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
1033 1033
             'id_tree' => $data['id_tree'],
1034 1034
             'perso' => $data['perso'],
1035
-            'restricted_to' => isset($data['restricted_to']) && ! empty($data['restricted_to']) ? $data['restricted_to'] : '0',
1035
+            'restricted_to' => isset($data['restricted_to']) && !empty($data['restricted_to']) ? $data['restricted_to'] : '0',
1036 1036
             'login' => $data['login'] ?? '',
1037 1037
             'folder' => implode(' » ', $folder),
1038 1038
             'author' => $superGlobal->get('user_id', 'SESSION'),
@@ -1064,8 +1064,8 @@  discard block
 block discarded – undo
1064 1064
     // get new value from db
1065 1065
     $data = DB::queryFirstRow(
1066 1066
         'SELECT i.label, i.description, i.id_tree as id_tree, i.perso, i.restricted_to, i.id, i.login, i.url, l.date
1067
-        FROM ' . prefixTable('items') . ' as i
1068
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
1067
+        FROM ' . prefixTable('items').' as i
1068
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
1069 1069
         WHERE i.id = %i
1070 1070
         AND l.action = %s',
1071 1071
         $ident,
@@ -1075,12 +1075,12 @@  discard block
 block discarded – undo
1075 1075
     $tags = '';
1076 1076
     $itemTags = DB::query(
1077 1077
         'SELECT tag
1078
-            FROM ' . prefixTable('tags') . '
1078
+            FROM ' . prefixTable('tags').'
1079 1079
             WHERE item_id = %i AND tag != ""',
1080 1080
         $ident
1081 1081
     );
1082 1082
     foreach ($itemTags as $itemTag) {
1083
-        $tags .= $itemTag['tag'] . ' ';
1083
+        $tags .= $itemTag['tag'].' ';
1084 1084
     }
1085 1085
     // form id_tree to full foldername
1086 1086
     $folder = [];
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
             // Is this a User id?
1092 1092
             $user = DB::queryfirstrow(
1093 1093
                 'SELECT id, login
1094
-                FROM ' . prefixTable('users') . '
1094
+                FROM ' . prefixTable('users').'
1095 1095
                 WHERE id = %i',
1096 1096
                 $elem->title
1097 1097
             );
@@ -1110,7 +1110,7 @@  discard block
 block discarded – undo
1110 1110
             'label' => $data['label'],
1111 1111
             'description' => $data['description'],
1112 1112
             'tags' => isset($tags) && empty($tags) === false ? $tags : 'None',
1113
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
1113
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
1114 1114
             'id_tree' => $data['id_tree'],
1115 1115
             'perso' => isset($data['perso']) && empty($data['perso']) === false && $data['perso'] !== 'None' ? $data['perso'] : '0',
1116 1116
             'restricted_to' => isset($data['restricted_to']) && empty($data['restricted_to']) === false ? $data['restricted_to'] : '0',
@@ -1132,52 +1132,52 @@  discard block
 block discarded – undo
1132 1132
 function getStatisticsData(array $SETTINGS): array
1133 1133
 {
1134 1134
     DB::query(
1135
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
1135
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
1136 1136
         0
1137 1137
     );
1138 1138
     $counter_folders = DB::count();
1139 1139
     DB::query(
1140
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
1140
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
1141 1141
         1
1142 1142
     );
1143 1143
     $counter_folders_perso = DB::count();
1144 1144
     DB::query(
1145
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
1145
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
1146 1146
         0
1147 1147
     );
1148 1148
     $counter_items = DB::count();
1149 1149
         DB::query(
1150
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
1150
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
1151 1151
         1
1152 1152
     );
1153 1153
     $counter_items_perso = DB::count();
1154 1154
         DB::query(
1155
-        'SELECT id FROM ' . prefixTable('users') . ''
1155
+        'SELECT id FROM '.prefixTable('users').''
1156 1156
     );
1157 1157
     $counter_users = DB::count();
1158 1158
         DB::query(
1159
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE admin = %i',
1159
+        'SELECT id FROM '.prefixTable('users').' WHERE admin = %i',
1160 1160
         1
1161 1161
     );
1162 1162
     $admins = DB::count();
1163 1163
     DB::query(
1164
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE gestionnaire = %i',
1164
+        'SELECT id FROM '.prefixTable('users').' WHERE gestionnaire = %i',
1165 1165
         1
1166 1166
     );
1167 1167
     $managers = DB::count();
1168 1168
     DB::query(
1169
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE read_only = %i',
1169
+        'SELECT id FROM '.prefixTable('users').' WHERE read_only = %i',
1170 1170
         1
1171 1171
     );
1172 1172
     $readOnly = DB::count();
1173 1173
     // list the languages
1174 1174
     $usedLang = [];
1175 1175
     $tp_languages = DB::query(
1176
-        'SELECT name FROM ' . prefixTable('languages')
1176
+        'SELECT name FROM '.prefixTable('languages')
1177 1177
     );
1178 1178
     foreach ($tp_languages as $tp_language) {
1179 1179
         DB::query(
1180
-            'SELECT * FROM ' . prefixTable('users') . ' WHERE user_language = %s',
1180
+            'SELECT * FROM '.prefixTable('users').' WHERE user_language = %s',
1181 1181
             $tp_language['name']
1182 1182
         );
1183 1183
         $usedLang[$tp_language['name']] = round((DB::count() * 100 / $counter_users), 0);
@@ -1186,12 +1186,12 @@  discard block
 block discarded – undo
1186 1186
     // get list of ips
1187 1187
     $usedIp = [];
1188 1188
     $tp_ips = DB::query(
1189
-        'SELECT user_ip FROM ' . prefixTable('users')
1189
+        'SELECT user_ip FROM '.prefixTable('users')
1190 1190
     );
1191 1191
     foreach ($tp_ips as $ip) {
1192 1192
         if (array_key_exists($ip['user_ip'], $usedIp)) {
1193 1193
             $usedIp[$ip['user_ip']] += $usedIp[$ip['user_ip']];
1194
-        } elseif (! empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
1194
+        } elseif (!empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
1195 1195
             $usedIp[$ip['user_ip']] = 1;
1196 1196
         }
1197 1197
     }
@@ -1344,12 +1344,12 @@  discard block
 block discarded – undo
1344 1344
     // Load superglobal
1345 1345
     $superGlobal = new SuperGlobal();
1346 1346
     // Get user language
1347
-    include_once $SETTINGS['cpassman_dir'] . '/includes/language/' . (null !== $superGlobal->get('user_language', 'SESSION', 'user') ? $superGlobal->get('user_language', 'SESSION', 'user') : 'english') . '.php';
1347
+    include_once $SETTINGS['cpassman_dir'].'/includes/language/'.(null !== $superGlobal->get('user_language', 'SESSION', 'user') ? $superGlobal->get('user_language', 'SESSION', 'user') : 'english').'.php';
1348 1348
     // load PHPMailer
1349 1349
     $mail = new PHPMailer(true);
1350 1350
 
1351 1351
     // send to user
1352
-    $mail->setLanguage('en', $SETTINGS['cpassman_dir'] . '/includes/libraries/PHPMailer/PHPMailer/language/');
1352
+    $mail->setLanguage('en', $SETTINGS['cpassman_dir'].'/includes/libraries/PHPMailer/PHPMailer/language/');
1353 1353
     $mail->SMTPDebug = isset($SETTINGS['email_debug_level']) === true && $cron === false && $silent === false ? $SETTINGS['email_debug_level'] : 0;
1354 1354
     $mail->Port = (int) $SETTINGS['email_port'];
1355 1355
     //COULD BE USED
@@ -1439,7 +1439,7 @@  discard block
 block discarded – undo
1439 1439
         <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;">
1440 1440
         <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;">
1441 1441
         <br><div style="float:right;">' .
1442
-        $textMail .
1442
+        $textMail.
1443 1443
         '<br><br></td></tr></table>
1444 1444
     </td></tr></table>
1445 1445
     <br></body></html>';
@@ -1452,7 +1452,7 @@  discard block
 block discarded – undo
1452 1452
  */
1453 1453
 function generateKey(): string
1454 1454
 {
1455
-    return substr(md5(rand() . rand()), 0, 15);
1455
+    return substr(md5(rand().rand()), 0, 15);
1456 1456
 }
1457 1457
 
1458 1458
 /**
@@ -1530,7 +1530,7 @@  discard block
 block discarded – undo
1530 1530
 {
1531 1531
     array_walk_recursive(
1532 1532
         $array,
1533
-        static function (&$item): void {
1533
+        static function(&$item): void {
1534 1534
             if (mb_detect_encoding((string) $item, 'utf-8', true) === false) {
1535 1535
                 $item = utf8_encode($item);
1536 1536
             }
@@ -1551,7 +1551,7 @@  discard block
 block discarded – undo
1551 1551
  */
1552 1552
 function prepareExchangedData($teampassDir, $data, string $type, ?string $key = null)
1553 1553
 {
1554
-    $teampassDir = __DIR__ . '/..';
1554
+    $teampassDir = __DIR__.'/..';
1555 1555
     // Load superglobal
1556 1556
     $superGlobal = new SuperGlobal();
1557 1557
 
@@ -1633,7 +1633,7 @@  discard block
 block discarded – undo
1633 1633
  */
1634 1634
 function prefixTable(string $table): string
1635 1635
 {
1636
-    $safeTable = htmlspecialchars(DB_PREFIX . $table);
1636
+    $safeTable = htmlspecialchars(DB_PREFIX.$table);
1637 1637
     if (empty($safeTable) === false) {
1638 1638
         // sanitize string
1639 1639
         return $safeTable;
@@ -1697,7 +1697,7 @@  discard block
 block discarded – undo
1697 1697
 function send_syslog($message, $host, $port, $component = 'teampass'): void
1698 1698
 {
1699 1699
     $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
1700
-    $syslog_message = '<123>' . date('M d H:i:s ') . $component . ': ' . $message;
1700
+    $syslog_message = '<123>'.date('M d H:i:s ').$component.': '.$message;
1701 1701
     socket_sendto($sock, (string) $syslog_message, strlen($syslog_message), 0, (string) $host, (int) $port);
1702 1702
     socket_close($sock);
1703 1703
 }
@@ -1744,14 +1744,14 @@  discard block
 block discarded – undo
1744 1744
     if (isset($SETTINGS['syslog_enable']) === true && (int) $SETTINGS['syslog_enable'] === 1) {
1745 1745
         if ($type === 'user_mngt') {
1746 1746
             send_syslog(
1747
-                'action=' . str_replace('at_', '', $label) . ' attribute=user user=' . $who . ' userid="' . $login . '" change="' . $field_1 . '" ',
1747
+                'action='.str_replace('at_', '', $label).' attribute=user user='.$who.' userid="'.$login.'" change="'.$field_1.'" ',
1748 1748
                 $SETTINGS['syslog_host'],
1749 1749
                 $SETTINGS['syslog_port'],
1750 1750
                 'teampass'
1751 1751
             );
1752 1752
         } else {
1753 1753
             send_syslog(
1754
-                'action=' . $type . ' attribute=' . $label . ' user=' . $who . ' userid="' . $login . '" ',
1754
+                'action='.$type.' attribute='.$label.' user='.$who.' userid="'.$login.'" ',
1755 1755
                 $SETTINGS['syslog_host'],
1756 1756
                 $SETTINGS['syslog_port'],
1757 1757
                 'teampass'
@@ -1825,7 +1825,7 @@  discard block
 block discarded – undo
1825 1825
         if (empty($item_label) === true) {
1826 1826
             $dataItem = DB::queryfirstrow(
1827 1827
                 'SELECT id, id_tree, label
1828
-                FROM ' . prefixTable('items') . '
1828
+                FROM ' . prefixTable('items').'
1829 1829
                 WHERE id = %i',
1830 1830
                 $item_id
1831 1831
             );
@@ -1833,11 +1833,11 @@  discard block
 block discarded – undo
1833 1833
         }
1834 1834
 
1835 1835
         send_syslog(
1836
-            'action=' . str_replace('at_', '', $action) .
1837
-                ' attribute=' . str_replace('at_', '', $attribute[0]) .
1838
-                ' itemno=' . $item_id .
1839
-                ' user=' . is_null($login) === true ? '' : addslashes((string) $login) .
1840
-                ' itemname="' . addslashes($item_label) . '"',
1836
+            'action='.str_replace('at_', '', $action).
1837
+                ' attribute='.str_replace('at_', '', $attribute[0]).
1838
+                ' itemno='.$item_id.
1839
+                ' user='.is_null($login) === true ? '' : addslashes((string) $login).
1840
+                ' itemname="'.addslashes($item_label).'"',
1841 1841
             $SETTINGS['syslog_host'],
1842 1842
             $SETTINGS['syslog_port'],
1843 1843
             'teampass'
@@ -1925,8 +1925,8 @@  discard block
 block discarded – undo
1925 1925
     $notification = DB::queryOneColumn(
1926 1926
         'email',
1927 1927
         'SELECT *
1928
-        FROM ' . prefixTable('notification') . ' AS n
1929
-        INNER JOIN ' . prefixTable('users') . ' AS u ON (n.user_id = u.id)
1928
+        FROM ' . prefixTable('notification').' AS n
1929
+        INNER JOIN ' . prefixTable('users').' AS u ON (n.user_id = u.id)
1930 1930
         WHERE n.item_id = %i AND n.user_id != %i',
1931 1931
         $item_id,
1932 1932
         $globalsUserId
@@ -1937,7 +1937,7 @@  discard block
 block discarded – undo
1937 1937
         // Get list of changes
1938 1938
         $htmlChanges = '<ul>';
1939 1939
         foreach ($changes as $change) {
1940
-            $htmlChanges .= '<li>' . $change . '</li>';
1940
+            $htmlChanges .= '<li>'.$change.'</li>';
1941 1941
         }
1942 1942
         $htmlChanges .= '</ul>';
1943 1943
         // send email
@@ -1974,15 +1974,15 @@  discard block
 block discarded – undo
1974 1974
     $path = '';
1975 1975
     foreach ($arbo as $elem) {
1976 1976
         if (empty($path) === true) {
1977
-            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES) . ' ';
1977
+            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES).' ';
1978 1978
         } else {
1979
-            $path .= '&#8594; ' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1979
+            $path .= '&#8594; '.htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1980 1980
         }
1981 1981
     }
1982 1982
 
1983 1983
     // Build text to show user
1984 1984
     if (empty($label) === false) {
1985
-        return empty($path) === true ? addslashes($label) : addslashes($label) . ' (' . $path . ')';
1985
+        return empty($path) === true ? addslashes($label) : addslashes($label).' ('.$path.')';
1986 1986
     }
1987 1987
     return empty($path) === true ? '' : $path;
1988 1988
 }
@@ -2039,7 +2039,7 @@  discard block
 block discarded – undo
2039 2039
  */
2040 2040
 function handleConfigFile($action, $SETTINGS, $field = null, $value = null)
2041 2041
 {
2042
-    $tp_config_file = $SETTINGS['cpassman_dir'] . '/includes/config/tp.config.php';
2042
+    $tp_config_file = $SETTINGS['cpassman_dir'].'/includes/config/tp.config.php';
2043 2043
 
2044 2044
     // Load class DB
2045 2045
     loadClasses('DB');
@@ -2047,8 +2047,8 @@  discard block
 block discarded – undo
2047 2047
     if (file_exists($tp_config_file) === false || $action === 'rebuild') {
2048 2048
         // perform a copy
2049 2049
         if (file_exists($tp_config_file)) {
2050
-            if (! copy($tp_config_file, $tp_config_file . '.' . date('Y_m_d_His', time()))) {
2051
-                return "ERROR: Could not copy file '" . $tp_config_file . "'";
2050
+            if (!copy($tp_config_file, $tp_config_file.'.'.date('Y_m_d_His', time()))) {
2051
+                return "ERROR: Could not copy file '".$tp_config_file."'";
2052 2052
             }
2053 2053
         }
2054 2054
 
@@ -2058,11 +2058,11 @@  discard block
 block discarded – undo
2058 2058
         $data[1] = "global \$SETTINGS;\n";
2059 2059
         $data[2] = "\$SETTINGS = array (\n";
2060 2060
         $rows = DB::query(
2061
-            'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s',
2061
+            'SELECT * FROM '.prefixTable('misc').' WHERE type=%s',
2062 2062
             'admin'
2063 2063
         );
2064 2064
         foreach ($rows as $record) {
2065
-            array_push($data, "    '" . $record['intitule'] . "' => '" . htmlspecialchars_decode($record['valeur'], ENT_COMPAT) . "',\n");
2065
+            array_push($data, "    '".$record['intitule']."' => '".htmlspecialchars_decode($record['valeur'], ENT_COMPAT)."',\n");
2066 2066
         }
2067 2067
         array_push($data, ");\n");
2068 2068
         $data = array_unique($data);
@@ -2076,15 +2076,15 @@  discard block
 block discarded – undo
2076 2076
                 break;
2077 2077
             }
2078 2078
 
2079
-            if (stristr($line, "'" . $field . "' => '")) {
2080
-                $data[$inc] = "    '" . $field . "' => '" . htmlspecialchars_decode($value, ENT_COMPAT) . "',\n";
2079
+            if (stristr($line, "'".$field."' => '")) {
2080
+                $data[$inc] = "    '".$field."' => '".htmlspecialchars_decode($value, ENT_COMPAT)."',\n";
2081 2081
                 $bFound = true;
2082 2082
                 break;
2083 2083
             }
2084 2084
             ++$inc;
2085 2085
         }
2086 2086
         if ($bFound === false) {
2087
-            $data[$inc] = "    '" . $field . "' => '" . htmlspecialchars_decode($value, ENT_COMPAT). "',\n);\n";
2087
+            $data[$inc] = "    '".$field."' => '".htmlspecialchars_decode($value, ENT_COMPAT)."',\n);\n";
2088 2088
         }
2089 2089
     }
2090 2090
 
@@ -2114,7 +2114,7 @@  discard block
 block discarded – undo
2114 2114
 {
2115 2115
     global $SETTINGS;
2116 2116
     /* LOAD CPASSMAN SETTINGS */
2117
-    if (! isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
2117
+    if (!isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
2118 2118
         $SETTINGS = [];
2119 2119
         $SETTINGS['duplicate_folder'] = 0;
2120 2120
         //by default, this is set to 0;
@@ -2124,7 +2124,7 @@  discard block
 block discarded – undo
2124 2124
         //by default, this value is set to 5;
2125 2125
         $settings = [];
2126 2126
         $rows = DB::query(
2127
-            'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s_type OR type=%s_type2',
2127
+            'SELECT * FROM '.prefixTable('misc').' WHERE type=%s_type OR type=%s_type2',
2128 2128
             [
2129 2129
                 'type' => 'admin',
2130 2130
                 'type2' => 'settings',
@@ -2156,7 +2156,7 @@  discard block
 block discarded – undo
2156 2156
     $source_cf = [];
2157 2157
     $rows = DB::QUERY(
2158 2158
         'SELECT id_category
2159
-            FROM ' . prefixTable('categories_folders') . '
2159
+            FROM ' . prefixTable('categories_folders').'
2160 2160
             WHERE id_folder = %i',
2161 2161
         $source_id
2162 2162
     );
@@ -2167,7 +2167,7 @@  discard block
 block discarded – undo
2167 2167
     $target_cf = [];
2168 2168
     $rows = DB::QUERY(
2169 2169
         'SELECT id_category
2170
-            FROM ' . prefixTable('categories_folders') . '
2170
+            FROM ' . prefixTable('categories_folders').'
2171 2171
             WHERE id_folder = %i',
2172 2172
         $target_id
2173 2173
     );
@@ -2420,7 +2420,7 @@  discard block
 block discarded – undo
2420 2420
     int  $dirPerm = 0755
2421 2421
 ) {
2422 2422
     // Check if the path exists
2423
-    if (! file_exists($path)) {
2423
+    if (!file_exists($path)) {
2424 2424
         return false;
2425 2425
     }
2426 2426
 
@@ -2473,7 +2473,7 @@  discard block
 block discarded – undo
2473 2473
     // Load item data
2474 2474
     $data = DB::queryFirstRow(
2475 2475
         'SELECT id_tree
2476
-        FROM ' . prefixTable('items') . '
2476
+        FROM ' . prefixTable('items').'
2477 2477
         WHERE id = %i',
2478 2478
         $item_id
2479 2479
     );
@@ -2536,7 +2536,7 @@  discard block
 block discarded – undo
2536 2536
         }
2537 2537
         $host .= substr(explode(".", $email[1])[0], -1, 1);
2538 2538
     }
2539
-    $email = $name . "@" . $host . "." . explode(".", $email[1])[1];
2539
+    $email = $name."@".$host.".".explode(".", $email[1])[1];
2540 2540
     return $email;
2541 2541
 }
2542 2542
 
@@ -2558,7 +2558,7 @@  discard block
 block discarded – undo
2558 2558
     loadClasses('DB');
2559 2559
     // Insert log in DB
2560 2560
     return DB::query(
2561
-        'SELECT ' . $fields . '
2561
+        'SELECT '.$fields.'
2562 2562
         FROM ' . prefixTable($table)
2563 2563
     );
2564 2564
 }
@@ -2573,11 +2573,11 @@  discard block
 block discarded – undo
2573 2573
 function formatSizeUnits(int $bytes): string
2574 2574
 {
2575 2575
     if ($bytes >= 1073741824) {
2576
-        $bytes = number_format($bytes / 1073741824, 2) . ' GB';
2576
+        $bytes = number_format($bytes / 1073741824, 2).' GB';
2577 2577
     } elseif ($bytes >= 1048576) {
2578
-        $bytes = number_format($bytes / 1048576, 2) . ' MB';
2578
+        $bytes = number_format($bytes / 1048576, 2).' MB';
2579 2579
     } elseif ($bytes >= 1024) {
2580
-        $bytes = number_format($bytes / 1024, 2) . ' KB';
2580
+        $bytes = number_format($bytes / 1024, 2).' KB';
2581 2581
     } elseif ($bytes > 1) {
2582 2582
         $bytes .= ' bytes';
2583 2583
     } elseif ($bytes === 1) {
@@ -2771,14 +2771,14 @@  discard block
 block discarded – undo
2771 2771
 
2772 2772
     // Encrypt the file content
2773 2773
     $plaintext = file_get_contents(
2774
-        filter_var($fileInPath . '/' . $fileInName, FILTER_SANITIZE_URL)
2774
+        filter_var($fileInPath.'/'.$fileInName, FILTER_SANITIZE_URL)
2775 2775
     );
2776 2776
     $ciphertext = $cipher->encrypt($plaintext);
2777 2777
     // Save new file
2778 2778
     $hash = md5($plaintext);
2779
-    $fileOut = $fileInPath . '/' . TP_FILE_PREFIX . $hash;
2779
+    $fileOut = $fileInPath.'/'.TP_FILE_PREFIX.$hash;
2780 2780
     file_put_contents($fileOut, $ciphertext);
2781
-    unlink($fileInPath . '/' . $fileInName);
2781
+    unlink($fileInPath.'/'.$fileInName);
2782 2782
     return [
2783 2783
         'fileHash' => base64_encode($hash),
2784 2784
         'objectKey' => base64_encode($objectKey),
@@ -2796,7 +2796,7 @@  discard block
 block discarded – undo
2796 2796
  */
2797 2797
 function decryptFile(string $fileName, string $filePath, string $key): string
2798 2798
 {
2799
-    if (! defined('FILE_BUFFER_SIZE')) {
2799
+    if (!defined('FILE_BUFFER_SIZE')) {
2800 2800
         define('FILE_BUFFER_SIZE', 128 * 1024);
2801 2801
     }
2802 2802
 
@@ -2810,7 +2810,7 @@  discard block
 block discarded – undo
2810 2810
     $cipher->enableContinuousBuffer();
2811 2811
     $cipher->disablePadding();
2812 2812
     // Get file content
2813
-    $ciphertext = file_get_contents($filePath . '/' . TP_FILE_PREFIX . $fileName);
2813
+    $ciphertext = file_get_contents($filePath.'/'.TP_FILE_PREFIX.$fileName);
2814 2814
     // Decrypt file content and return
2815 2815
     return base64_encode($cipher->decrypt($ciphertext));
2816 2816
 }
@@ -2891,8 +2891,8 @@  discard block
 block discarded – undo
2891 2891
         // Only create the sharekey for a user
2892 2892
         $user = DB::queryFirstRow(
2893 2893
             'SELECT public_key
2894
-            FROM ' . prefixTable('users') . '
2895
-            WHERE id = ' . (int) $superGlobal->get('user_id', 'SESSION') . '
2894
+            FROM ' . prefixTable('users').'
2895
+            WHERE id = ' . (int) $superGlobal->get('user_id', 'SESSION').'
2896 2896
             AND public_key != ""'
2897 2897
         );
2898 2898
 
@@ -2928,10 +2928,9 @@  discard block
 block discarded – undo
2928 2928
         //DB::debugmode(true);
2929 2929
         $users = DB::query(
2930 2930
             'SELECT id, public_key
2931
-            FROM ' . prefixTable('users') . '
2931
+            FROM ' . prefixTable('users').'
2932 2932
             WHERE ' . ($onlyForUser === true ? 
2933
-                'id IN ("' . TP_USER_ID . '","' . $superGlobal->get('user_id', 'SESSION') . '") ' : 
2934
-                'id NOT IN ("' . OTV_USER_ID . '","' . SSH_USER_ID . '","' . API_USER_ID . '") ') . '
2933
+                'id IN ("'.TP_USER_ID.'","'.$superGlobal->get('user_id', 'SESSION').'") ' : 'id NOT IN ("'.OTV_USER_ID.'","'.SSH_USER_ID.'","'.API_USER_ID.'") ').'
2935 2934
             AND public_key != ""'
2936 2935
         );
2937 2936
         //DB::debugmode(false);
@@ -2978,7 +2977,7 @@  discard block
 block discarded – undo
2978 2977
 function isBase64(string $str): bool
2979 2978
 {
2980 2979
     $str = (string) trim($str);
2981
-    if (! isset($str[0])) {
2980
+    if (!isset($str[0])) {
2982 2981
         return false;
2983 2982
     }
2984 2983
 
@@ -3051,7 +3050,7 @@  discard block
 block discarded – undo
3051 3050
         $connection->connect();
3052 3051
     } catch (\LdapRecord\Auth\BindException $e) {
3053 3052
         $error = $e->getDetailedError();
3054
-        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage(). '<br>'.$error->getDiagnosticMessage();
3053
+        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage().'<br>'.$error->getDiagnosticMessage();
3055 3054
         return false;
3056 3055
     }
3057 3056
 
@@ -3064,7 +3063,7 @@  discard block
 block discarded – undo
3064 3063
         }
3065 3064
     } catch (\LdapRecord\Auth\BindException $e) {
3066 3065
         $error = $e->getDetailedError();
3067
-        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage(). '<br>'.$error->getDiagnosticMessage();
3066
+        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage().'<br>'.$error->getDiagnosticMessage();
3068 3067
         return false;
3069 3068
     }
3070 3069
 
@@ -3088,7 +3087,7 @@  discard block
 block discarded – undo
3088 3087
     // expect if personal item
3089 3088
     DB::delete(
3090 3089
         prefixTable('sharekeys_items'),
3091
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
3090
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
3092 3091
         $userId
3093 3092
     );
3094 3093
     // Remove all item sharekeys files
@@ -3096,8 +3095,8 @@  discard block
 block discarded – undo
3096 3095
         prefixTable('sharekeys_files'),
3097 3096
         'user_id = %i AND object_id NOT IN (
3098 3097
             SELECT f.id 
3099
-            FROM ' . prefixTable('items') . ' AS i 
3100
-            INNER JOIN ' . prefixTable('files') . ' AS f ON f.id_item = i.id
3098
+            FROM ' . prefixTable('items').' AS i 
3099
+            INNER JOIN ' . prefixTable('files').' AS f ON f.id_item = i.id
3101 3100
             WHERE i.perso = 1
3102 3101
         )',
3103 3102
         $userId
@@ -3107,8 +3106,8 @@  discard block
 block discarded – undo
3107 3106
         prefixTable('sharekeys_fields'),
3108 3107
         'user_id = %i AND object_id NOT IN (
3109 3108
             SELECT c.id 
3110
-            FROM ' . prefixTable('items') . ' AS i 
3111
-            INNER JOIN ' . prefixTable('categories_items') . ' AS c ON c.item_id = i.id
3109
+            FROM ' . prefixTable('items').' AS i 
3110
+            INNER JOIN ' . prefixTable('categories_items').' AS c ON c.item_id = i.id
3112 3111
             WHERE i.perso = 1
3113 3112
         )',
3114 3113
         $userId
@@ -3116,13 +3115,13 @@  discard block
 block discarded – undo
3116 3115
     // Remove all item sharekeys logs
3117 3116
     DB::delete(
3118 3117
         prefixTable('sharekeys_logs'),
3119
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
3118
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
3120 3119
         $userId
3121 3120
     );
3122 3121
     // Remove all item sharekeys suggestions
3123 3122
     DB::delete(
3124 3123
         prefixTable('sharekeys_suggestions'),
3125
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
3124
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
3126 3125
         $userId
3127 3126
     );
3128 3127
     return false;
@@ -3143,7 +3142,7 @@  discard block
 block discarded – undo
3143 3142
         foreach (DateTimeZone::listIdentifiers() as $timezone) {
3144 3143
             $now->setTimezone(new DateTimeZone($timezone));
3145 3144
             $offsets[] = $offset = $now->getOffset();
3146
-            $timezones[$timezone] = '(' . format_GMT_offset($offset) . ') ' . format_timezone_name($timezone);
3145
+            $timezones[$timezone] = '('.format_GMT_offset($offset).') '.format_timezone_name($timezone);
3147 3146
         }
3148 3147
 
3149 3148
         array_multisort($offsets, $timezones);
@@ -3163,7 +3162,7 @@  discard block
 block discarded – undo
3163 3162
 {
3164 3163
     $hours = intval($offset / 3600);
3165 3164
     $minutes = abs(intval($offset % 3600 / 60));
3166
-    return 'GMT' . ($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
3165
+    return 'GMT'.($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
3167 3166
 }
3168 3167
 
3169 3168
 /**
@@ -3263,8 +3262,7 @@  discard block
 block discarded – undo
3263 3262
 {
3264 3263
     if (isset($array[$key]) === true
3265 3264
         && (is_int($value) === true ?
3266
-            (int) $array[$key] === $value :
3267
-            (string) $array[$key] === $value)
3265
+            (int) $array[$key] === $value : (string) $array[$key] === $value)
3268 3266
     ) {
3269 3267
         return true;
3270 3268
     }
@@ -3286,8 +3284,7 @@  discard block
 block discarded – undo
3286 3284
 {
3287 3285
     if (isset($var) === false
3288 3286
         || (is_int($value) === true ?
3289
-            (int) $var === $value :
3290
-            (string) $var === $value)
3287
+            (int) $var === $value : (string) $var === $value)
3291 3288
     ) {
3292 3289
         return true;
3293 3290
     }
@@ -3338,7 +3335,7 @@  discard block
 block discarded – undo
3338 3335
  */
3339 3336
 function isSetArrayOfValues(array $arrayOfValues): bool
3340 3337
 {
3341
-    foreach($arrayOfValues as $value) {
3338
+    foreach ($arrayOfValues as $value) {
3342 3339
         if (isset($value) === false) {
3343 3340
             return false;
3344 3341
         }
@@ -3360,7 +3357,7 @@  discard block
 block discarded – undo
3360 3357
     /*PHP8 - integer|string*/$value
3361 3358
 ) : bool
3362 3359
 {
3363
-    foreach($arrayOfVars as $variable) {
3360
+    foreach ($arrayOfVars as $variable) {
3364 3361
         if ($variable !== $value) {
3365 3362
             return false;
3366 3363
         }
@@ -3380,7 +3377,7 @@  discard block
 block discarded – undo
3380 3377
     /*PHP8 - integer|string*/$value
3381 3378
 ) : bool
3382 3379
 {
3383
-    foreach($arrayOfVars as $variable) {
3380
+    foreach ($arrayOfVars as $variable) {
3384 3381
         if ($variable === $value) {
3385 3382
             return true;
3386 3383
         }
@@ -3449,7 +3446,7 @@  discard block
 block discarded – undo
3449 3446
 function dataSanitizer(
3450 3447
     array $data,
3451 3448
     array $filters,
3452
-    string $path = __DIR__. '/..' // Path to Teampass root
3449
+    string $path = __DIR__.'/..' // Path to Teampass root
3453 3450
 )
3454 3451
 {
3455 3452
     // Load Sanitizer library
@@ -3479,7 +3476,7 @@  discard block
 block discarded – undo
3479 3476
     // Exists ?
3480 3477
     $userCacheId = DB::queryfirstrow(
3481 3478
         'SELECT increment_id
3482
-        FROM ' . prefixTable('cache_tree') . '
3479
+        FROM ' . prefixTable('cache_tree').'
3483 3480
         WHERE user_id = %i',
3484 3481
         $user_id
3485 3482
     );
@@ -3528,7 +3525,7 @@  discard block
 block discarded – undo
3528 3525
  */
3529 3526
 function pourcentage(float $nombre, float $total, float $pourcentage): float
3530 3527
 { 
3531
-    $resultat = ($nombre/$total) * $pourcentage;
3528
+    $resultat = ($nombre / $total) * $pourcentage;
3532 3529
     return round($resultat);
3533 3530
 }
3534 3531
 
@@ -3556,7 +3553,7 @@  discard block
 block discarded – undo
3556 3553
 
3557 3554
     // Get last folder update
3558 3555
     $lastFolderChange = DB::queryfirstrow(
3559
-        'SELECT valeur FROM ' . prefixTable('misc') . '
3556
+        'SELECT valeur FROM '.prefixTable('misc').'
3560 3557
         WHERE type = %s AND intitule = %s',
3561 3558
         'timestamp',
3562 3559
         'last_folder_change'
@@ -3586,7 +3583,7 @@  discard block
 block discarded – undo
3586 3583
     // Does this user has a tree cache
3587 3584
     $userCacheTree = DB::queryfirstrow(
3588 3585
         'SELECT '.$fieldName.'
3589
-        FROM ' . prefixTable('cache_tree') . '
3586
+        FROM ' . prefixTable('cache_tree').'
3590 3587
         WHERE user_id = %i',
3591 3588
         $_SESSION['user_id']
3592 3589
     );
@@ -3623,7 +3620,7 @@  discard block
 block discarded – undo
3623 3620
     if (count($folderIds) === 0) {
3624 3621
         $folderIds = DB::queryFirstColumn(
3625 3622
             'SELECT id
3626
-            FROM ' . prefixTable('nested_tree') . '
3623
+            FROM ' . prefixTable('nested_tree').'
3627 3624
             WHERE personal_folder=%i',
3628 3625
             0
3629 3626
         );
@@ -3640,8 +3637,8 @@  discard block
 block discarded – undo
3640 3637
         $rows_tmp = DB::query(
3641 3638
             'SELECT c.id, c.title, c.level, c.type, c.masked, c.order, c.encrypted_data, c.role_visibility, c.is_mandatory,
3642 3639
             f.id_category AS category_id
3643
-            FROM ' . prefixTable('categories_folders') . ' AS f
3644
-            INNER JOIN ' . prefixTable('categories') . ' AS c ON (f.id_category = c.parent_id)
3640
+            FROM ' . prefixTable('categories_folders').' AS f
3641
+            INNER JOIN ' . prefixTable('categories').' AS c ON (f.id_category = c.parent_id)
3645 3642
             WHERE id_folder=%i',
3646 3643
             $folder
3647 3644
         );
@@ -3667,7 +3664,7 @@  discard block
 block discarded – undo
3667 3664
         $valTemp = '';
3668 3665
         $data = DB::queryFirstRow(
3669 3666
             'SELECT valeur
3670
-            FROM ' . prefixTable('misc') . '
3667
+            FROM ' . prefixTable('misc').'
3671 3668
             WHERE type = %s AND intitule=%i',
3672 3669
             'complex',
3673 3670
             $folder
@@ -3684,14 +3681,14 @@  discard block
 block discarded – undo
3684 3681
         $valTemp = '';
3685 3682
         $rows_tmp = DB::query(
3686 3683
             'SELECT t.title
3687
-            FROM ' . prefixTable('roles_values') . ' as v
3688
-            INNER JOIN ' . prefixTable('roles_title') . ' as t ON (v.role_id = t.id)
3684
+            FROM ' . prefixTable('roles_values').' as v
3685
+            INNER JOIN ' . prefixTable('roles_title').' as t ON (v.role_id = t.id)
3689 3686
             WHERE v.folder_id = %i
3690 3687
             GROUP BY title',
3691 3688
             $folder
3692 3689
         );
3693 3690
         foreach ($rows_tmp as $record) {
3694
-            $valTemp .= (empty($valTemp) === true ? '' : ' - ') . $record['title'];
3691
+            $valTemp .= (empty($valTemp) === true ? '' : ' - ').$record['title'];
3695 3692
         }
3696 3693
         $arr_data['visibilityRoles'] = $valTemp;
3697 3694
 
@@ -3723,7 +3720,7 @@  discard block
 block discarded – undo
3723 3720
         // loop on users and check if user has this role
3724 3721
         $rows = DB::query(
3725 3722
             'SELECT id, fonction_id
3726
-            FROM ' . prefixTable('users') . '
3723
+            FROM ' . prefixTable('users').'
3727 3724
             WHERE id != %i AND admin = 0 AND fonction_id IS NOT NULL AND fonction_id != ""',
3728 3725
             $_SESSION['user_id']
3729 3726
         );
@@ -3762,7 +3759,7 @@  discard block
 block discarded – undo
3762 3759
 
3763 3760
     $val = DB::queryfirstrow(
3764 3761
         'SELECT *
3765
-        FROM ' . prefixTable('users') . '
3762
+        FROM ' . prefixTable('users').'
3766 3763
         WHERE id = %i',
3767 3764
         $userId
3768 3765
     );
@@ -3778,12 +3775,12 @@  discard block
 block discarded – undo
3778 3775
 function upgradeRequired(): bool
3779 3776
 {
3780 3777
     // Get settings.php
3781
-    include_once __DIR__. '/../includes/config/settings.php';
3778
+    include_once __DIR__.'/../includes/config/settings.php';
3782 3779
 
3783 3780
     // Get timestamp in DB
3784 3781
     $val = DB::queryfirstrow(
3785 3782
         'SELECT valeur
3786
-        FROM ' . prefixTable('misc') . '
3783
+        FROM ' . prefixTable('misc').'
3787 3784
         WHERE type = %s AND intitule = %s',
3788 3785
         'admin',
3789 3786
         'upgrade_timestamp'
@@ -3836,7 +3833,7 @@  discard block
 block discarded – undo
3836 3833
     // prepapre background tasks for item keys generation        
3837 3834
     $userTP = DB::queryFirstRow(
3838 3835
         'SELECT pw, public_key, private_key
3839
-        FROM ' . prefixTable('users') . '
3836
+        FROM ' . prefixTable('users').'
3840 3837
         WHERE id = %i',
3841 3838
         TP_USER_ID
3842 3839
     );
@@ -3862,7 +3859,7 @@  discard block
 block discarded – undo
3862 3859
         }
3863 3860
 
3864 3861
         // Generate new keys
3865
-        if ($user_self_change === true && empty($recovery_public_key) === false && empty($recovery_private_key) === false){
3862
+        if ($user_self_change === true && empty($recovery_public_key) === false && empty($recovery_private_key) === false) {
3866 3863
             $userKeys = [
3867 3864
                 'public_key' => $recovery_public_key,
3868 3865
                 'private_key_clear' => $recovery_private_key,
@@ -3902,8 +3899,8 @@  discard block
 block discarded – undo
3902 3899
                 'process_type' => 'create_user_keys',
3903 3900
                 'arguments' => json_encode([
3904 3901
                     'new_user_id' => (int) $userId,
3905
-                    'new_user_pwd' => cryption($passwordClear, '','encrypt')['string'],
3906
-                    'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '','encrypt')['string'],
3902
+                    'new_user_pwd' => cryption($passwordClear, '', 'encrypt')['string'],
3903
+                    'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '', 'encrypt')['string'],
3907 3904
                     'owner_id' => (int) TP_USER_ID,
3908 3905
                     'creator_pwd' => $userTP['pw'],
3909 3906
                     'send_email' => $sendEmailToUser === true ? 1 : 0,
@@ -4200,7 +4197,7 @@  discard block
 block discarded – undo
4200 4197
  * @param integer $user_id
4201 4198
  * @return void
4202 4199
  */
4203
-function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id=0)
4200
+function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id = 0)
4204 4201
 {
4205 4202
     if ($allUsers === true) {
4206 4203
         // Load class DB
@@ -4208,7 +4205,7 @@  discard block
 block discarded – undo
4208 4205
 
4209 4206
         $users = DB::query(
4210 4207
             'SELECT id
4211
-            FROM ' . prefixTable('users') . '
4208
+            FROM ' . prefixTable('users').'
4212 4209
             WHERE id NOT IN ('.OTV_USER_ID.', '.TP_USER_ID.', '.SSH_USER_ID.', '.API_USER_ID.')
4213 4210
             ORDER BY login ASC'
4214 4211
         );
@@ -4226,7 +4223,7 @@  discard block
 block discarded – undo
4226 4223
  * @param integer $user_id
4227 4224
  * @return void
4228 4225
  */
4229
-function purgeUnnecessaryKeysForUser(int $user_id=0)
4226
+function purgeUnnecessaryKeysForUser(int $user_id = 0)
4230 4227
 {
4231 4228
     if ($user_id === 0) {
4232 4229
         return;
@@ -4237,8 +4234,8 @@  discard block
 block discarded – undo
4237 4234
 
4238 4235
     $personalItems = DB::queryFirstColumn(
4239 4236
         'SELECT id
4240
-        FROM ' . prefixTable('items') . ' AS i
4241
-        INNER JOIN ' . prefixTable('log_items') . ' AS li ON li.id_item = i.id
4237
+        FROM ' . prefixTable('items').' AS i
4238
+        INNER JOIN ' . prefixTable('log_items').' AS li ON li.id_item = i.id
4242 4239
         WHERE i.perso = 1 AND li.action = "at_creation" AND li.id_user IN (%i, '.TP_USER_ID.')',
4243 4240
         $user_id
4244 4241
     );
@@ -4286,7 +4283,7 @@  discard block
 block discarded – undo
4286 4283
     // Check if user exists
4287 4284
     $userInfo = DB::queryFirstRow(
4288 4285
         'SELECT pw, public_key, private_key, login, name
4289
-        FROM ' . prefixTable('users') . '
4286
+        FROM ' . prefixTable('users').'
4290 4287
         WHERE id = %i',
4291 4288
         $userId
4292 4289
     );
@@ -4296,7 +4293,7 @@  discard block
 block discarded – undo
4296 4293
 
4297 4294
         // Prepare file content
4298 4295
         $export_value = file_get_contents(__DIR__."/../includes/core/teampass_ascii.txt")."\n".
4299
-            "Generation date: ".date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now)."\n\n".
4296
+            "Generation date: ".date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now)."\n\n".
4300 4297
             "RECOVERY KEYS - Not to be shared - To be store safely\n\n".
4301 4298
             "Public Key:\n".$userInfo['public_key']."\n\n".
4302 4299
             "Private Key:\n".decryptPrivateKey($_SESSION['user_pwd'], $userInfo['private_key'])."\n\n";
@@ -4320,7 +4317,7 @@  discard block
 block discarded – undo
4320 4317
             __DIR__.'/..',
4321 4318
             array(
4322 4319
                 'error' => false,
4323
-                'datetime' => date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now),
4320
+                'datetime' => date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now),
4324 4321
                 'timestamp' => $now,
4325 4322
                 'content' => base64_encode($export_value),
4326 4323
                 'login' => $userInfo['login'],
@@ -4347,9 +4344,9 @@  discard block
 block discarded – undo
4347 4344
  */
4348 4345
 function loadClasses(string $className = ''): void
4349 4346
 {
4350
-    include_once __DIR__. '/../sources/main.functions.php';
4351
-    include_once __DIR__. '/../includes/config/include.php';
4352
-    include_once __DIR__. '/../includes/config/settings.php';
4347
+    include_once __DIR__.'/../sources/main.functions.php';
4348
+    include_once __DIR__.'/../includes/config/include.php';
4349
+    include_once __DIR__.'/../includes/config/settings.php';
4353 4350
     require_once __DIR__.'/../vendor/autoload.php';
4354 4351
 
4355 4352
     if (defined('DB_PASSWD_CLEAR') === false) {
@@ -4380,7 +4377,7 @@  discard block
 block discarded – undo
4380 4377
 function getCurrectPage($SETTINGS)
4381 4378
 {
4382 4379
     // Load libraries
4383
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
4380
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
4384 4381
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
4385 4382
 
4386 4383
     // Parse the url
Please login to merge, or discard this patch.