Passed
Push — master ( 8df915...875b7f )
by Nils
10:39
created
sources/main.functions.php 1 patch
Spacing   +282 added lines, -284 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
 // Load config if $SETTINGS not defined
35 35
 if (isset($SETTINGS['cpassman_dir']) === false || empty($SETTINGS['cpassman_dir']) === true) {
36
-    include_once __DIR__ . '/../includes/config/tp.config.php';
36
+    include_once __DIR__.'/../includes/config/tp.config.php';
37 37
 }
38 38
 
39 39
 header('Content-type: text/html; charset=utf-8');
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
             and improve performance by avoiding to include the file for every missing strings.
64 64
         */
65 65
         if (isset($_SESSION['teampass']) === false || isset($_SESSION['teampass']['en_lang'][trim($string)]) === false) {
66
-            $_SESSION['teampass']['en_lang'] = include_once __DIR__. '/../includes/language/english.php';
66
+            $_SESSION['teampass']['en_lang'] = include_once __DIR__.'/../includes/language/english.php';
67 67
             $session_language = isset($_SESSION['teampass']['en_lang'][trim($string)]) === false ? '' : $_SESSION['teampass']['en_lang'][trim($string)];
68 68
         } else {
69 69
             $session_language = $_SESSION['teampass']['en_lang'][trim($string)];
@@ -122,20 +122,20 @@  discard block
 block discarded – undo
122 122
     
123 123
     $path = __DIR__.'/../includes/libraries/Encryption/Encryption/';
124 124
 
125
-    include_once $path . 'Exception/CryptoException.php';
126
-    include_once $path . 'Exception/BadFormatException.php';
127
-    include_once $path . 'Exception/EnvironmentIsBrokenException.php';
128
-    include_once $path . 'Exception/IOException.php';
129
-    include_once $path . 'Exception/WrongKeyOrModifiedCiphertextException.php';
130
-    include_once $path . 'Crypto.php';
131
-    include_once $path . 'Encoding.php';
132
-    include_once $path . 'DerivedKeys.php';
133
-    include_once $path . 'Key.php';
134
-    include_once $path . 'KeyOrPassword.php';
135
-    include_once $path . 'File.php';
136
-    include_once $path . 'RuntimeTests.php';
137
-    include_once $path . 'KeyProtectedByPassword.php';
138
-    include_once $path . 'Core.php';
125
+    include_once $path.'Exception/CryptoException.php';
126
+    include_once $path.'Exception/BadFormatException.php';
127
+    include_once $path.'Exception/EnvironmentIsBrokenException.php';
128
+    include_once $path.'Exception/IOException.php';
129
+    include_once $path.'Exception/WrongKeyOrModifiedCiphertextException.php';
130
+    include_once $path.'Crypto.php';
131
+    include_once $path.'Encoding.php';
132
+    include_once $path.'DerivedKeys.php';
133
+    include_once $path.'Key.php';
134
+    include_once $path.'KeyOrPassword.php';
135
+    include_once $path.'File.php';
136
+    include_once $path.'RuntimeTests.php';
137
+    include_once $path.'KeyProtectedByPassword.php';
138
+    include_once $path.'Core.php';
139 139
     
140 140
     // convert KEY
141 141
     $key = \Defuse\Crypto\Key::loadFromAsciiSafeString($ascii_key);
@@ -180,20 +180,20 @@  discard block
 block discarded – undo
180 180
         $path = '../includes/libraries/Encryption/Encryption/';
181 181
     }
182 182
 
183
-    include_once $path . 'Exception/CryptoException.php';
184
-    include_once $path . 'Exception/BadFormatException.php';
185
-    include_once $path . 'Exception/EnvironmentIsBrokenException.php';
186
-    include_once $path . 'Exception/IOException.php';
187
-    include_once $path . 'Exception/WrongKeyOrModifiedCiphertextException.php';
188
-    include_once $path . 'Crypto.php';
189
-    include_once $path . 'Encoding.php';
190
-    include_once $path . 'DerivedKeys.php';
191
-    include_once $path . 'Key.php';
192
-    include_once $path . 'KeyOrPassword.php';
193
-    include_once $path . 'File.php';
194
-    include_once $path . 'RuntimeTests.php';
195
-    include_once $path . 'KeyProtectedByPassword.php';
196
-    include_once $path . 'Core.php';
183
+    include_once $path.'Exception/CryptoException.php';
184
+    include_once $path.'Exception/BadFormatException.php';
185
+    include_once $path.'Exception/EnvironmentIsBrokenException.php';
186
+    include_once $path.'Exception/IOException.php';
187
+    include_once $path.'Exception/WrongKeyOrModifiedCiphertextException.php';
188
+    include_once $path.'Crypto.php';
189
+    include_once $path.'Encoding.php';
190
+    include_once $path.'DerivedKeys.php';
191
+    include_once $path.'Key.php';
192
+    include_once $path.'KeyOrPassword.php';
193
+    include_once $path.'File.php';
194
+    include_once $path.'RuntimeTests.php';
195
+    include_once $path.'KeyProtectedByPassword.php';
196
+    include_once $path.'Core.php';
197 197
 
198 198
     $key = \Defuse\Crypto\Key::createNewRandomKey();
199 199
     $key = $key->saveToAsciiSafeString();
@@ -218,20 +218,20 @@  discard block
 block discarded – undo
218 218
         $path = '../includes/libraries/Encryption/Encryption/';
219 219
     }
220 220
 
221
-    include_once $path . 'Exception/CryptoException.php';
222
-    include_once $path . 'Exception/BadFormatException.php';
223
-    include_once $path . 'Exception/EnvironmentIsBrokenException.php';
224
-    include_once $path . 'Exception/IOException.php';
225
-    include_once $path . 'Exception/WrongKeyOrModifiedCiphertextException.php';
226
-    include_once $path . 'Crypto.php';
227
-    include_once $path . 'Encoding.php';
228
-    include_once $path . 'DerivedKeys.php';
229
-    include_once $path . 'Key.php';
230
-    include_once $path . 'KeyOrPassword.php';
231
-    include_once $path . 'File.php';
232
-    include_once $path . 'RuntimeTests.php';
233
-    include_once $path . 'KeyProtectedByPassword.php';
234
-    include_once $path . 'Core.php';
221
+    include_once $path.'Exception/CryptoException.php';
222
+    include_once $path.'Exception/BadFormatException.php';
223
+    include_once $path.'Exception/EnvironmentIsBrokenException.php';
224
+    include_once $path.'Exception/IOException.php';
225
+    include_once $path.'Exception/WrongKeyOrModifiedCiphertextException.php';
226
+    include_once $path.'Crypto.php';
227
+    include_once $path.'Encoding.php';
228
+    include_once $path.'DerivedKeys.php';
229
+    include_once $path.'Key.php';
230
+    include_once $path.'KeyOrPassword.php';
231
+    include_once $path.'File.php';
232
+    include_once $path.'RuntimeTests.php';
233
+    include_once $path.'KeyProtectedByPassword.php';
234
+    include_once $path.'Core.php';
235 235
     
236 236
     $protected_key = \Defuse\Crypto\KeyProtectedByPassword::createRandomPasswordProtectedKey($psk);
237 237
     return $protected_key->saveToAsciiSafeString(); // save this in user table
@@ -256,20 +256,20 @@  discard block
 block discarded – undo
256 256
         $path = '../includes/libraries/Encryption/Encryption/';
257 257
     }
258 258
 
259
-    include_once $path . 'Exception/CryptoException.php';
260
-    include_once $path . 'Exception/BadFormatException.php';
261
-    include_once $path . 'Exception/EnvironmentIsBrokenException.php';
262
-    include_once $path . 'Exception/IOException.php';
263
-    include_once $path . 'Exception/WrongKeyOrModifiedCiphertextException.php';
264
-    include_once $path . 'Crypto.php';
265
-    include_once $path . 'Encoding.php';
266
-    include_once $path . 'DerivedKeys.php';
267
-    include_once $path . 'Key.php';
268
-    include_once $path . 'KeyOrPassword.php';
269
-    include_once $path . 'File.php';
270
-    include_once $path . 'RuntimeTests.php';
271
-    include_once $path . 'KeyProtectedByPassword.php';
272
-    include_once $path . 'Core.php';
259
+    include_once $path.'Exception/CryptoException.php';
260
+    include_once $path.'Exception/BadFormatException.php';
261
+    include_once $path.'Exception/EnvironmentIsBrokenException.php';
262
+    include_once $path.'Exception/IOException.php';
263
+    include_once $path.'Exception/WrongKeyOrModifiedCiphertextException.php';
264
+    include_once $path.'Crypto.php';
265
+    include_once $path.'Encoding.php';
266
+    include_once $path.'DerivedKeys.php';
267
+    include_once $path.'Key.php';
268
+    include_once $path.'KeyOrPassword.php';
269
+    include_once $path.'File.php';
270
+    include_once $path.'RuntimeTests.php';
271
+    include_once $path.'KeyProtectedByPassword.php';
272
+    include_once $path.'Core.php';
273 273
 
274 274
     try {
275 275
         $protected_key_encoded = \Defuse\Crypto\KeyProtectedByPassword::loadFromAsciiSafeString($protected_key_encoded);
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
  */
312 312
 function trimElement($chaine, string $element): string
313 313
 {
314
-    if (! empty($chaine)) {
314
+    if (!empty($chaine)) {
315 315
         if (is_array($chaine) === true) {
316 316
             $chaine = implode(';', $chaine);
317 317
         }
@@ -359,8 +359,8 @@  discard block
 block discarded – undo
359 359
  */
360 360
 function db_error_handler(array $params): void
361 361
 {
362
-    echo 'Error: ' . $params['error'] . "<br>\n";
363
-    echo 'Query: ' . $params['query'] . "<br>\n";
362
+    echo 'Error: '.$params['error']."<br>\n";
363
+    echo 'Query: '.$params['query']."<br>\n";
364 364
     throw new Exception('Error - Query', 1);
365 365
 }
366 366
 
@@ -382,12 +382,12 @@  discard block
 block discarded – undo
382 382
     $SETTINGS
383 383
 ) {
384 384
     //load ClassLoader
385
-    include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php';
385
+    include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php';
386 386
     // Load superglobal
387
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
387
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
388 388
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
389 389
     //Connect to DB
390
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
390
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
391 391
     if (defined('DB_PASSWD_CLEAR') === false) {
392 392
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
393 393
     }
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
     DB::$ssl = DB_SSL;
401 401
     DB::$connect_options = DB_CONNECT_OPTIONS;
402 402
     //Build tree
403
-    $tree = new SplClassLoader('Tree\NestedTree', $SETTINGS['cpassman_dir'] . '/includes/libraries');
403
+    $tree = new SplClassLoader('Tree\NestedTree', $SETTINGS['cpassman_dir'].'/includes/libraries');
404 404
     $tree->register();
405 405
     $tree = new Tree\NestedTree\NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title');
406 406
 
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 function identAdmin($idFonctions, $SETTINGS, $tree)
446 446
 {
447 447
     // Load superglobal
448
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
448
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
449 449
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
450 450
     // Init
451 451
     $groupesVisibles = [];
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
     $globalsVisibleFolders = $superGlobal->get('groupes_visibles', 'SESSION');
465 465
     $globalsPersonalVisibleFolders = $superGlobal->get('personal_visible_groups', 'SESSION');
466 466
     // Get list of Folders
467
-    $rows = DB::query('SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i', 0);
467
+    $rows = DB::query('SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i', 0);
468 468
     foreach ($rows as $record) {
469 469
         array_push($groupesVisibles, $record['id']);
470 470
     }
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
     }
484 484
     // Get ID of personal folder
485 485
     $persfld = DB::queryfirstrow(
486
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE title = %s',
486
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE title = %s',
487 487
         $globalsUserId
488 488
     );
489 489
     if (empty($persfld['id']) === false) {
@@ -504,20 +504,20 @@  discard block
 block discarded – undo
504 504
     // get complete list of ROLES
505 505
     $tmp = explode(';', $idFonctions);
506 506
     $rows = DB::query(
507
-        'SELECT * FROM ' . prefixTable('roles_title') . '
507
+        'SELECT * FROM '.prefixTable('roles_title').'
508 508
         ORDER BY title ASC'
509 509
     );
510 510
     foreach ($rows as $record) {
511
-        if (! empty($record['id']) && ! in_array($record['id'], $tmp)) {
511
+        if (!empty($record['id']) && !in_array($record['id'], $tmp)) {
512 512
             array_push($tmp, $record['id']);
513 513
         }
514 514
     }
515 515
     $superGlobal->put('fonction_id', implode(';', $tmp), 'SESSION');
516 516
     $superGlobal->put('is_admin', 1, 'SESSION');
517 517
     // Check if admin has created Folders and Roles
518
-    DB::query('SELECT * FROM ' . prefixTable('nested_tree') . '');
518
+    DB::query('SELECT * FROM '.prefixTable('nested_tree').'');
519 519
     $superGlobal->put('nb_folders', DB::count(), 'SESSION');
520
-    DB::query('SELECT * FROM ' . prefixTable('roles_title'));
520
+    DB::query('SELECT * FROM '.prefixTable('roles_title'));
521 521
     $superGlobal->put('nb_roles', DB::count(), 'SESSION');
522 522
 
523 523
     return true;
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
     object $tree
564 564
 ) {
565 565
     // Load superglobal
566
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
566
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
567 567
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
568 568
     // Init
569 569
     $superGlobal->put('groupes_visibles', [], 'SESSION');
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
     // Does this user is allowed to see other items
603 603
     $inc = 0;
604 604
     $rows = DB::query(
605
-        'SELECT id, id_tree FROM ' . prefixTable('items') . '
605
+        'SELECT id, id_tree FROM '.prefixTable('items').'
606 606
             WHERE restricted_to LIKE %ss AND inactif = %s'.
607 607
             (count($allowedFolders) > 0 ? ' AND id_tree NOT IN ('.implode(',', $allowedFolders).')' : ''),
608 608
         $globalsUserId,
@@ -619,8 +619,8 @@  discard block
 block discarded – undo
619 619
     // Check for the users roles if some specific rights exist on items
620 620
     $rows = DB::query(
621 621
         'SELECT i.id_tree, r.item_id
622
-        FROM ' . prefixTable('items') . ' as i
623
-        INNER JOIN ' . prefixTable('restriction_to_roles') . ' as r ON (r.item_id=i.id)
622
+        FROM ' . prefixTable('items').' as i
623
+        INNER JOIN ' . prefixTable('restriction_to_roles').' as r ON (r.item_id=i.id)
624 624
         WHERE i.id_tree <> "" '.
625 625
         (count($userRoles) > 0 ? 'AND r.role_id IN %li ' : '').
626 626
         'ORDER BY i.id_tree ASC',
@@ -675,16 +675,16 @@  discard block
 block discarded – undo
675 675
         'SESSION'
676 676
     );
677 677
     // Folders and Roles numbers
678
-    DB::queryfirstrow('SELECT id FROM ' . prefixTable('nested_tree') . '');
678
+    DB::queryfirstrow('SELECT id FROM '.prefixTable('nested_tree').'');
679 679
     $superGlobal->put('nb_folders', DB::count(), 'SESSION');
680
-    DB::queryfirstrow('SELECT id FROM ' . prefixTable('roles_title'));
680
+    DB::queryfirstrow('SELECT id FROM '.prefixTable('roles_title'));
681 681
     $superGlobal->put('nb_roles', DB::count(), 'SESSION');
682 682
     // check if change proposals on User's items
683 683
     if (isset($SETTINGS['enable_suggestion']) === true && (int) $SETTINGS['enable_suggestion'] === 1) {
684 684
         $countNewItems = DB::query(
685 685
             'SELECT COUNT(*)
686
-            FROM ' . prefixTable('items_change') . ' AS c
687
-            LEFT JOIN ' . prefixTable('log_items') . ' AS i ON (c.item_id = i.id_item)
686
+            FROM ' . prefixTable('items_change').' AS c
687
+            LEFT JOIN ' . prefixTable('log_items').' AS i ON (c.item_id = i.id_item)
688 688
             WHERE i.action = %s AND i.id_user = %i',
689 689
             'at_creation',
690 690
             $globalsUserId
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
 {
712 712
     $rows = DB::query(
713 713
         'SELECT *
714
-        FROM ' . prefixTable('roles_values') . '
714
+        FROM ' . prefixTable('roles_values').'
715 715
         WHERE type IN %ls'.(count($userRoles) > 0 ? ' AND role_id IN %li' : ''),
716 716
         ['W', 'ND', 'NE', 'NDNE', 'R'],
717 717
         $userRoles,
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
     ) {
779 779
         $persoFld = DB::queryfirstrow(
780 780
             'SELECT id
781
-            FROM ' . prefixTable('nested_tree') . '
781
+            FROM ' . prefixTable('nested_tree').'
782 782
             WHERE title = %s AND personal_folder = %i'.
783 783
             (count($allowedFolders) > 0 ? ' AND id NOT IN ('.implode(',', $allowedFolders).')' : ''),
784 784
             $globalsUserId,
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
     }
812 812
     $persoFlds = DB::query(
813 813
         'SELECT id
814
-        FROM ' . prefixTable('nested_tree') . '
814
+        FROM ' . prefixTable('nested_tree').'
815 815
         WHERE %l',
816 816
         $where
817 817
     );
@@ -875,9 +875,9 @@  discard block
 block discarded – undo
875 875
  */
876 876
 function cacheTableRefresh(array $SETTINGS): void
877 877
 {
878
-    include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php';
878
+    include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php';
879 879
     //Connect to DB
880
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
880
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
881 881
     if (defined('DB_PASSWD_CLEAR') === false) {
882 882
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
883 883
     }
@@ -890,16 +890,16 @@  discard block
 block discarded – undo
890 890
     DB::$ssl = DB_SSL;
891 891
     DB::$connect_options = DB_CONNECT_OPTIONS;
892 892
     //Load Tree
893
-    $tree = new SplClassLoader('Tree\NestedTree', $SETTINGS['cpassman_dir'] .'/includes/libraries');
893
+    $tree = new SplClassLoader('Tree\NestedTree', $SETTINGS['cpassman_dir'].'/includes/libraries');
894 894
     $tree->register();
895 895
     $tree = new Tree\NestedTree\NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title');
896 896
     // truncate table
897
-    DB::query('TRUNCATE TABLE ' . prefixTable('cache'));
897
+    DB::query('TRUNCATE TABLE '.prefixTable('cache'));
898 898
     // reload date
899 899
     $rows = DB::query(
900 900
         'SELECT *
901
-        FROM ' . prefixTable('items') . ' as i
902
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
901
+        FROM ' . prefixTable('items').' as i
902
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
903 903
         AND l.action = %s
904 904
         AND i.inactif = %i',
905 905
         'at_creation',
@@ -911,18 +911,18 @@  discard block
 block discarded – undo
911 911
             $tags = '';
912 912
             $itemTags = DB::query(
913 913
                 'SELECT tag
914
-                FROM ' . prefixTable('tags') . '
914
+                FROM ' . prefixTable('tags').'
915 915
                 WHERE item_id = %i AND tag != ""',
916 916
                 $record['id']
917 917
             );
918 918
             foreach ($itemTags as $itemTag) {
919
-                $tags .= $itemTag['tag'] . ' ';
919
+                $tags .= $itemTag['tag'].' ';
920 920
             }
921 921
 
922 922
             // Get renewal period
923 923
             $resNT = DB::queryfirstrow(
924 924
                 'SELECT renewal_period
925
-                FROM ' . prefixTable('nested_tree') . '
925
+                FROM ' . prefixTable('nested_tree').'
926 926
                 WHERE id = %i',
927 927
                 $record['id_tree']
928 928
             );
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
                     // Is this a User id?
936 936
                     $user = DB::queryfirstrow(
937 937
                         'SELECT id, login
938
-                        FROM ' . prefixTable('users') . '
938
+                        FROM ' . prefixTable('users').'
939 939
                         WHERE id = %i',
940 940
                         $elem->title
941 941
                     );
@@ -953,11 +953,11 @@  discard block
 block discarded – undo
953 953
                     'id' => $record['id'],
954 954
                     'label' => $record['label'],
955 955
                     'description' => $record['description'] ?? '',
956
-                    'url' => isset($record['url']) && ! empty($record['url']) ? $record['url'] : '0',
956
+                    'url' => isset($record['url']) && !empty($record['url']) ? $record['url'] : '0',
957 957
                     'tags' => $tags,
958 958
                     'id_tree' => $record['id_tree'],
959 959
                     'perso' => $record['perso'],
960
-                    'restricted_to' => isset($record['restricted_to']) && ! empty($record['restricted_to']) ? $record['restricted_to'] : '0',
960
+                    'restricted_to' => isset($record['restricted_to']) && !empty($record['restricted_to']) ? $record['restricted_to'] : '0',
961 961
                     'login' => $record['login'] ?? '',
962 962
                     'folder' => implode(' > ', $folder),
963 963
                     'author' => $record['id_user'],
@@ -979,12 +979,12 @@  discard block
 block discarded – undo
979 979
  */
980 980
 function cacheTableUpdate(array $SETTINGS, ?int $ident = null): void
981 981
 {
982
-    include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php';
982
+    include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php';
983 983
     // Load superglobal
984
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
984
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
985 985
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
986 986
     //Connect to DB
987
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
987
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
988 988
     if (defined('DB_PASSWD_CLEAR') === false) {
989 989
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
990 990
     }
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
     // get new value from db
1004 1004
     $data = DB::queryfirstrow(
1005 1005
         'SELECT label, description, id_tree, perso, restricted_to, login, url
1006
-        FROM ' . prefixTable('items') . '
1006
+        FROM ' . prefixTable('items').'
1007 1007
         WHERE id=%i',
1008 1008
         $ident
1009 1009
     );
@@ -1011,12 +1011,12 @@  discard block
 block discarded – undo
1011 1011
     $tags = '';
1012 1012
     $itemTags = DB::query(
1013 1013
         'SELECT tag
1014
-            FROM ' . prefixTable('tags') . '
1014
+            FROM ' . prefixTable('tags').'
1015 1015
             WHERE item_id = %i AND tag != ""',
1016 1016
         $ident
1017 1017
     );
1018 1018
     foreach ($itemTags as $itemTag) {
1019
-        $tags .= $itemTag['tag'] . ' ';
1019
+        $tags .= $itemTag['tag'].' ';
1020 1020
     }
1021 1021
     // form id_tree to full foldername
1022 1022
     $folder = [];
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
             // Is this a User id?
1028 1028
             $user = DB::queryfirstrow(
1029 1029
                 'SELECT id, login
1030
-                FROM ' . prefixTable('users') . '
1030
+                FROM ' . prefixTable('users').'
1031 1031
                 WHERE id = %i',
1032 1032
                 $elem->title
1033 1033
             );
@@ -1045,10 +1045,10 @@  discard block
 block discarded – undo
1045 1045
             'label' => $data['label'],
1046 1046
             'description' => $data['description'],
1047 1047
             'tags' => $tags,
1048
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
1048
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
1049 1049
             'id_tree' => $data['id_tree'],
1050 1050
             'perso' => $data['perso'],
1051
-            'restricted_to' => isset($data['restricted_to']) && ! empty($data['restricted_to']) ? $data['restricted_to'] : '0',
1051
+            'restricted_to' => isset($data['restricted_to']) && !empty($data['restricted_to']) ? $data['restricted_to'] : '0',
1052 1052
             'login' => $data['login'] ?? '',
1053 1053
             'folder' => implode(' » ', $folder),
1054 1054
             'author' => $superGlobal->get('user_id', 'SESSION'),
@@ -1068,14 +1068,14 @@  discard block
 block discarded – undo
1068 1068
  */
1069 1069
 function cacheTableAdd(array $SETTINGS, ?int $ident = null): void
1070 1070
 {
1071
-    include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php';
1071
+    include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php';
1072 1072
     // Load superglobal
1073
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
1073
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
1074 1074
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
1075 1075
     // Get superglobals
1076 1076
     $globalsUserId = $superGlobal->get('user_id', 'SESSION');
1077 1077
     //Connect to DB
1078
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
1078
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
1079 1079
     if (defined('DB_PASSWD_CLEAR') === false) {
1080 1080
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
1081 1081
     }
@@ -1094,8 +1094,8 @@  discard block
 block discarded – undo
1094 1094
     // get new value from db
1095 1095
     $data = DB::queryFirstRow(
1096 1096
         'SELECT i.label, i.description, i.id_tree as id_tree, i.perso, i.restricted_to, i.id, i.login, i.url, l.date
1097
-        FROM ' . prefixTable('items') . ' as i
1098
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
1097
+        FROM ' . prefixTable('items').' as i
1098
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
1099 1099
         WHERE i.id = %i
1100 1100
         AND l.action = %s',
1101 1101
         $ident,
@@ -1105,12 +1105,12 @@  discard block
 block discarded – undo
1105 1105
     $tags = '';
1106 1106
     $itemTags = DB::query(
1107 1107
         'SELECT tag
1108
-            FROM ' . prefixTable('tags') . '
1108
+            FROM ' . prefixTable('tags').'
1109 1109
             WHERE item_id = %i AND tag != ""',
1110 1110
         $ident
1111 1111
     );
1112 1112
     foreach ($itemTags as $itemTag) {
1113
-        $tags .= $itemTag['tag'] . ' ';
1113
+        $tags .= $itemTag['tag'].' ';
1114 1114
     }
1115 1115
     // form id_tree to full foldername
1116 1116
     $folder = [];
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
             // Is this a User id?
1122 1122
             $user = DB::queryfirstrow(
1123 1123
                 'SELECT id, login
1124
-                FROM ' . prefixTable('users') . '
1124
+                FROM ' . prefixTable('users').'
1125 1125
                 WHERE id = %i',
1126 1126
                 $elem->title
1127 1127
             );
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
             'label' => $data['label'],
1141 1141
             'description' => $data['description'],
1142 1142
             'tags' => isset($tags) && empty($tags) === false ? $tags : 'None',
1143
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
1143
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
1144 1144
             'id_tree' => $data['id_tree'],
1145 1145
             'perso' => isset($data['perso']) && empty($data['perso']) === false && $data['perso'] !== 'None' ? $data['perso'] : '0',
1146 1146
             'restricted_to' => isset($data['restricted_to']) && empty($data['restricted_to']) === false ? $data['restricted_to'] : '0',
@@ -1162,52 +1162,52 @@  discard block
 block discarded – undo
1162 1162
 function getStatisticsData(array $SETTINGS): array
1163 1163
 {
1164 1164
     DB::query(
1165
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
1165
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
1166 1166
         0
1167 1167
     );
1168 1168
     $counter_folders = DB::count();
1169 1169
     DB::query(
1170
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
1170
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
1171 1171
         1
1172 1172
     );
1173 1173
     $counter_folders_perso = DB::count();
1174 1174
     DB::query(
1175
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
1175
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
1176 1176
         0
1177 1177
     );
1178 1178
     $counter_items = DB::count();
1179 1179
         DB::query(
1180
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
1180
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
1181 1181
         1
1182 1182
     );
1183 1183
     $counter_items_perso = DB::count();
1184 1184
         DB::query(
1185
-        'SELECT id FROM ' . prefixTable('users') . ''
1185
+        'SELECT id FROM '.prefixTable('users').''
1186 1186
     );
1187 1187
     $counter_users = DB::count();
1188 1188
         DB::query(
1189
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE admin = %i',
1189
+        'SELECT id FROM '.prefixTable('users').' WHERE admin = %i',
1190 1190
         1
1191 1191
     );
1192 1192
     $admins = DB::count();
1193 1193
     DB::query(
1194
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE gestionnaire = %i',
1194
+        'SELECT id FROM '.prefixTable('users').' WHERE gestionnaire = %i',
1195 1195
         1
1196 1196
     );
1197 1197
     $managers = DB::count();
1198 1198
     DB::query(
1199
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE read_only = %i',
1199
+        'SELECT id FROM '.prefixTable('users').' WHERE read_only = %i',
1200 1200
         1
1201 1201
     );
1202 1202
     $readOnly = DB::count();
1203 1203
     // list the languages
1204 1204
     $usedLang = [];
1205 1205
     $tp_languages = DB::query(
1206
-        'SELECT name FROM ' . prefixTable('languages')
1206
+        'SELECT name FROM '.prefixTable('languages')
1207 1207
     );
1208 1208
     foreach ($tp_languages as $tp_language) {
1209 1209
         DB::query(
1210
-            'SELECT * FROM ' . prefixTable('users') . ' WHERE user_language = %s',
1210
+            'SELECT * FROM '.prefixTable('users').' WHERE user_language = %s',
1211 1211
             $tp_language['name']
1212 1212
         );
1213 1213
         $usedLang[$tp_language['name']] = round((DB::count() * 100 / $counter_users), 0);
@@ -1216,12 +1216,12 @@  discard block
 block discarded – undo
1216 1216
     // get list of ips
1217 1217
     $usedIp = [];
1218 1218
     $tp_ips = DB::query(
1219
-        'SELECT user_ip FROM ' . prefixTable('users')
1219
+        'SELECT user_ip FROM '.prefixTable('users')
1220 1220
     );
1221 1221
     foreach ($tp_ips as $ip) {
1222 1222
         if (array_key_exists($ip['user_ip'], $usedIp)) {
1223 1223
             $usedIp[$ip['user_ip']] += $usedIp[$ip['user_ip']];
1224
-        } elseif (! empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
1224
+        } elseif (!empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
1225 1225
             $usedIp[$ip['user_ip']] = 1;
1226 1226
         }
1227 1227
     }
@@ -1374,19 +1374,19 @@  discard block
 block discarded – undo
1374 1374
     // Load settings
1375 1375
     //include_once $SETTINGS['cpassman_dir'] . '/includes/config/settings.php';
1376 1376
     // Load superglobal
1377
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
1377
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
1378 1378
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
1379 1379
     // Get user language
1380
-    include_once $SETTINGS['cpassman_dir'] . '/includes/language/' . (null !== $superGlobal->get('user_language', 'SESSION', 'user') ? $superGlobal->get('user_language', 'SESSION', 'user') : 'english') . '.php';
1380
+    include_once $SETTINGS['cpassman_dir'].'/includes/language/'.(null !== $superGlobal->get('user_language', 'SESSION', 'user') ? $superGlobal->get('user_language', 'SESSION', 'user') : 'english').'.php';
1381 1381
     // Load library
1382
-    include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php';
1382
+    include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php';
1383 1383
     // load PHPMailer
1384
-    $mail = new SplClassLoader('PHPMailer\PHPMailer', $SETTINGS['cpassman_dir'] . '/includes/libraries');
1384
+    $mail = new SplClassLoader('PHPMailer\PHPMailer', $SETTINGS['cpassman_dir'].'/includes/libraries');
1385 1385
     $mail->register();
1386 1386
     $mail = new PHPMailer\PHPMailer\PHPMailer(true);
1387 1387
 
1388 1388
     // send to user
1389
-    $mail->setLanguage('en', $SETTINGS['cpassman_dir'] . '/includes/libraries/PHPMailer/PHPMailer/language/');
1389
+    $mail->setLanguage('en', $SETTINGS['cpassman_dir'].'/includes/libraries/PHPMailer/PHPMailer/language/');
1390 1390
     $mail->SMTPDebug = isset($SETTINGS['email_debug_level']) === true && $cron === false && $silent === false ? $SETTINGS['email_debug_level'] : 0;
1391 1391
     $mail->Port = (int) $SETTINGS['email_port'];
1392 1392
     //COULD BE USED
@@ -1476,7 +1476,7 @@  discard block
 block discarded – undo
1476 1476
         <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;">
1477 1477
         <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;">
1478 1478
         <br><div style="float:right;">' .
1479
-        $textMail .
1479
+        $textMail.
1480 1480
         '<br><br></td></tr></table>
1481 1481
     </td></tr></table>
1482 1482
     <br></body></html>';
@@ -1489,7 +1489,7 @@  discard block
 block discarded – undo
1489 1489
  */
1490 1490
 function generateKey(): string
1491 1491
 {
1492
-    return substr(md5(rand() . rand()), 0, 15);
1492
+    return substr(md5(rand().rand()), 0, 15);
1493 1493
 }
1494 1494
 
1495 1495
 /**
@@ -1567,7 +1567,7 @@  discard block
 block discarded – undo
1567 1567
 {
1568 1568
     array_walk_recursive(
1569 1569
         $array,
1570
-        static function (&$item): void {
1570
+        static function(&$item): void {
1571 1571
             if (mb_detect_encoding((string) $item, 'utf-8', true) === false) {
1572 1572
                 $item = utf8_encode($item);
1573 1573
             }
@@ -1588,9 +1588,9 @@  discard block
 block discarded – undo
1588 1588
  */
1589 1589
 function prepareExchangedData($teampassDir, $data, string $type, ?string $key = null)
1590 1590
 {
1591
-    $teampassDir = __DIR__ . '/..';
1591
+    $teampassDir = __DIR__.'/..';
1592 1592
     // Load superglobal
1593
-    include_once $teampassDir . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
1593
+    include_once $teampassDir.'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
1594 1594
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
1595 1595
     // Get superglobals
1596 1596
     if ($key !== null) {
@@ -1601,10 +1601,10 @@  discard block
 block discarded – undo
1601 1601
     }
1602 1602
 
1603 1603
     //load Encoding
1604
-    include_once $teampassDir . '/includes/libraries/ForceUTF8/Encoding.php';
1604
+    include_once $teampassDir.'/includes/libraries/ForceUTF8/Encoding.php';
1605 1605
     
1606 1606
     //Load CRYPTOJS
1607
-    include_once $teampassDir . '/includes/libraries/Encryption/CryptoJs/Encryption.php';
1607
+    include_once $teampassDir.'/includes/libraries/Encryption/CryptoJs/Encryption.php';
1608 1608
 
1609 1609
     // Perform
1610 1610
     if ($type === 'encode' && is_array($data) === true) {
@@ -1676,8 +1676,8 @@  discard block
 block discarded – undo
1676 1676
  */
1677 1677
 function prefixTable(string $table): string
1678 1678
 {
1679
-    $safeTable = htmlspecialchars(DB_PREFIX . $table);
1680
-    if (! empty($safeTable)) {
1679
+    $safeTable = htmlspecialchars(DB_PREFIX.$table);
1680
+    if (!empty($safeTable)) {
1681 1681
         // sanitize string
1682 1682
         return $safeTable;
1683 1683
     }
@@ -1707,13 +1707,13 @@  discard block
 block discarded – undo
1707 1707
     bool $lowercase = false,
1708 1708
     array $SETTINGS = []
1709 1709
 ): string {
1710
-    include_once __DIR__ . '/../sources/SplClassLoader.php';
1711
-    $generator = new SplClassLoader('PasswordGenerator\Generator', __DIR__. '/../includes/libraries');
1710
+    include_once __DIR__.'/../sources/SplClassLoader.php';
1711
+    $generator = new SplClassLoader('PasswordGenerator\Generator', __DIR__.'/../includes/libraries');
1712 1712
     $generator->register();
1713 1713
     $generator = new PasswordGenerator\Generator\ComputerPasswordGenerator();
1714 1714
     // Is PHP7 being used?
1715 1715
     if (version_compare(PHP_VERSION, '7.0.0', '>=')) {
1716
-        $php7generator = new SplClassLoader('PasswordGenerator\RandomGenerator', __DIR__ . '/../includes/libraries');
1716
+        $php7generator = new SplClassLoader('PasswordGenerator\RandomGenerator', __DIR__.'/../includes/libraries');
1717 1717
         $php7generator->register();
1718 1718
         $generator->setRandomGenerator(new PasswordGenerator\RandomGenerator\Php7RandomGenerator());
1719 1719
     }
@@ -1748,7 +1748,7 @@  discard block
 block discarded – undo
1748 1748
 function send_syslog($message, $host, $port, $component = 'teampass'): void
1749 1749
 {
1750 1750
     $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
1751
-    $syslog_message = '<123>' . date('M d H:i:s ') . $component . ': ' . $message;
1751
+    $syslog_message = '<123>'.date('M d H:i:s ').$component.': '.$message;
1752 1752
     socket_sendto($sock, (string) $syslog_message, strlen($syslog_message), 0, (string) $host, (int) $port);
1753 1753
     socket_close($sock);
1754 1754
 }
@@ -1779,7 +1779,7 @@  discard block
 block discarded – undo
1779 1779
     }
1780 1780
 
1781 1781
     // include librairies & connect to DB
1782
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
1782
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
1783 1783
     if (defined('DB_PASSWD_CLEAR') === false) {
1784 1784
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
1785 1785
     }
@@ -1805,14 +1805,14 @@  discard block
 block discarded – undo
1805 1805
     if (isset($SETTINGS['syslog_enable']) === true && (int) $SETTINGS['syslog_enable'] === 1) {
1806 1806
         if ($type === 'user_mngt') {
1807 1807
             send_syslog(
1808
-                'action=' . str_replace('at_', '', $label) . ' attribute=user user=' . $who . ' userid="' . $login . '" change="' . $field_1 . '" ',
1808
+                'action='.str_replace('at_', '', $label).' attribute=user user='.$who.' userid="'.$login.'" change="'.$field_1.'" ',
1809 1809
                 $SETTINGS['syslog_host'],
1810 1810
                 $SETTINGS['syslog_port'],
1811 1811
                 'teampass'
1812 1812
             );
1813 1813
         } else {
1814 1814
             send_syslog(
1815
-                'action=' . $type . ' attribute=' . $label . ' user=' . $who . ' userid="' . $login . '" ',
1815
+                'action='.$type.' attribute='.$label.' user='.$who.' userid="'.$login.'" ',
1816 1816
                 $SETTINGS['syslog_host'],
1817 1817
                 $SETTINGS['syslog_port'],
1818 1818
                 'teampass'
@@ -1847,7 +1847,7 @@  discard block
 block discarded – undo
1847 1847
     ?string $time = null
1848 1848
 ): void {
1849 1849
     // include librairies & connect to DB
1850
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
1850
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
1851 1851
     if (defined('DB_PASSWD_CLEAR') === false) {
1852 1852
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
1853 1853
     }
@@ -1893,7 +1893,7 @@  discard block
 block discarded – undo
1893 1893
         if (empty($item_label) === true) {
1894 1894
             $dataItem = DB::queryfirstrow(
1895 1895
                 'SELECT id, id_tree, label
1896
-                FROM ' . prefixTable('items') . '
1896
+                FROM ' . prefixTable('items').'
1897 1897
                 WHERE id = %i',
1898 1898
                 $item_id
1899 1899
             );
@@ -1901,11 +1901,11 @@  discard block
 block discarded – undo
1901 1901
         }
1902 1902
 
1903 1903
         send_syslog(
1904
-            'action=' . str_replace('at_', '', $action) .
1905
-                ' attribute=' . str_replace('at_', '', $attribute[0]) .
1906
-                ' itemno=' . $item_id .
1907
-                ' user=' . is_null($login) === true ? '' : addslashes((string) $login) .
1908
-                ' itemname="' . addslashes($item_label) . '"',
1904
+            'action='.str_replace('at_', '', $action).
1905
+                ' attribute='.str_replace('at_', '', $attribute[0]).
1906
+                ' itemno='.$item_id.
1907
+                ' user='.is_null($login) === true ? '' : addslashes((string) $login).
1908
+                ' itemname="'.addslashes($item_label).'"',
1909 1909
             $SETTINGS['syslog_host'],
1910 1910
             $SETTINGS['syslog_port'],
1911 1911
             'teampass'
@@ -1984,7 +1984,7 @@  discard block
 block discarded – undo
1984 1984
 function notifyChangesToSubscribers(int $item_id, string $label, array $changes, array $SETTINGS): void
1985 1985
 {
1986 1986
     // Load superglobal
1987
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
1987
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
1988 1988
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
1989 1989
     // Get superglobals
1990 1990
     $globalsUserId = $superGlobal->get('user_id', 'SESSION');
@@ -1994,8 +1994,8 @@  discard block
 block discarded – undo
1994 1994
     $notification = DB::queryOneColumn(
1995 1995
         'email',
1996 1996
         'SELECT *
1997
-        FROM ' . prefixTable('notification') . ' AS n
1998
-        INNER JOIN ' . prefixTable('users') . ' AS u ON (n.user_id = u.id)
1997
+        FROM ' . prefixTable('notification').' AS n
1998
+        INNER JOIN ' . prefixTable('users').' AS u ON (n.user_id = u.id)
1999 1999
         WHERE n.item_id = %i AND n.user_id != %i',
2000 2000
         $item_id,
2001 2001
         $globalsUserId
@@ -2006,7 +2006,7 @@  discard block
 block discarded – undo
2006 2006
         // Get list of changes
2007 2007
         $htmlChanges = '<ul>';
2008 2008
         foreach ($changes as $change) {
2009
-            $htmlChanges .= '<li>' . $change . '</li>';
2009
+            $htmlChanges .= '<li>'.$change.'</li>';
2010 2010
         }
2011 2011
         $htmlChanges .= '</ul>';
2012 2012
         // send email
@@ -2039,7 +2039,7 @@  discard block
 block discarded – undo
2039 2039
 function geItemReadablePath(int $id_tree, string $label, array $SETTINGS): string
2040 2040
 {
2041 2041
     // Class loader
2042
-    include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php';
2042
+    include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php';
2043 2043
     //Load Tree
2044 2044
     $tree = new SplClassLoader('Tree\NestedTree', '../includes/libraries');
2045 2045
     $tree->register();
@@ -2048,15 +2048,15 @@  discard block
 block discarded – undo
2048 2048
     $path = '';
2049 2049
     foreach ($arbo as $elem) {
2050 2050
         if (empty($path) === true) {
2051
-            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES) . ' ';
2051
+            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES).' ';
2052 2052
         } else {
2053
-            $path .= '&#8594; ' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
2053
+            $path .= '&#8594; '.htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
2054 2054
         }
2055 2055
     }
2056 2056
 
2057 2057
     // Build text to show user
2058 2058
     if (empty($label) === false) {
2059
-        return empty($path) === true ? addslashes($label) : addslashes($label) . ' (' . $path . ')';
2059
+        return empty($path) === true ? addslashes($label) : addslashes($label).' ('.$path.')';
2060 2060
     }
2061 2061
     return empty($path) === true ? '' : $path;
2062 2062
 }
@@ -2113,9 +2113,9 @@  discard block
 block discarded – undo
2113 2113
  */
2114 2114
 function handleConfigFile($action, $SETTINGS, $field = null, $value = null)
2115 2115
 {
2116
-    $tp_config_file = $SETTINGS['cpassman_dir'] . '/includes/config/tp.config.php';
2116
+    $tp_config_file = $SETTINGS['cpassman_dir'].'/includes/config/tp.config.php';
2117 2117
     // include librairies & connect to DB
2118
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
2118
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
2119 2119
     if (defined('DB_PASSWD_CLEAR') === false) {
2120 2120
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
2121 2121
     }
@@ -2130,8 +2130,8 @@  discard block
 block discarded – undo
2130 2130
     if (file_exists($tp_config_file) === false || $action === 'rebuild') {
2131 2131
         // perform a copy
2132 2132
         if (file_exists($tp_config_file)) {
2133
-            if (! copy($tp_config_file, $tp_config_file . '.' . date('Y_m_d_His', time()))) {
2134
-                return "ERROR: Could not copy file '" . $tp_config_file . "'";
2133
+            if (!copy($tp_config_file, $tp_config_file.'.'.date('Y_m_d_His', time()))) {
2134
+                return "ERROR: Could not copy file '".$tp_config_file."'";
2135 2135
             }
2136 2136
         }
2137 2137
 
@@ -2141,11 +2141,11 @@  discard block
 block discarded – undo
2141 2141
         $data[1] = "global \$SETTINGS;\n";
2142 2142
         $data[2] = "\$SETTINGS = array (\n";
2143 2143
         $rows = DB::query(
2144
-            'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s',
2144
+            'SELECT * FROM '.prefixTable('misc').' WHERE type=%s',
2145 2145
             'admin'
2146 2146
         );
2147 2147
         foreach ($rows as $record) {
2148
-            array_push($data, "    '" . $record['intitule'] . "' => '" . htmlspecialchars_decode($record['valeur'], ENT_COMPAT) . "',\n");
2148
+            array_push($data, "    '".$record['intitule']."' => '".htmlspecialchars_decode($record['valeur'], ENT_COMPAT)."',\n");
2149 2149
         }
2150 2150
         array_push($data, ");\n");
2151 2151
         $data = array_unique($data);
@@ -2159,15 +2159,15 @@  discard block
 block discarded – undo
2159 2159
                 break;
2160 2160
             }
2161 2161
 
2162
-            if (stristr($line, "'" . $field . "' => '")) {
2163
-                $data[$inc] = "    '" . $field . "' => '" . htmlspecialchars_decode($value, ENT_COMPAT) . "',\n";
2162
+            if (stristr($line, "'".$field."' => '")) {
2163
+                $data[$inc] = "    '".$field."' => '".htmlspecialchars_decode($value, ENT_COMPAT)."',\n";
2164 2164
                 $bFound = true;
2165 2165
                 break;
2166 2166
             }
2167 2167
             ++$inc;
2168 2168
         }
2169 2169
         if ($bFound === false) {
2170
-            $data[$inc] = "    '" . $field . "' => '" . htmlspecialchars_decode($value, ENT_COMPAT). "',\n);\n";
2170
+            $data[$inc] = "    '".$field."' => '".htmlspecialchars_decode($value, ENT_COMPAT)."',\n);\n";
2171 2171
         }
2172 2172
     }
2173 2173
 
@@ -2197,7 +2197,7 @@  discard block
 block discarded – undo
2197 2197
 {
2198 2198
     global $SETTINGS;
2199 2199
     /* LOAD CPASSMAN SETTINGS */
2200
-    if (! isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
2200
+    if (!isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
2201 2201
         $SETTINGS = [];
2202 2202
         $SETTINGS['duplicate_folder'] = 0;
2203 2203
         //by default, this is set to 0;
@@ -2207,7 +2207,7 @@  discard block
 block discarded – undo
2207 2207
         //by default, this value is set to 5;
2208 2208
         $settings = [];
2209 2209
         $rows = DB::query(
2210
-            'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s_type OR type=%s_type2',
2210
+            'SELECT * FROM '.prefixTable('misc').' WHERE type=%s_type OR type=%s_type2',
2211 2211
             [
2212 2212
                 'type' => 'admin',
2213 2213
                 'type2' => 'settings',
@@ -2239,7 +2239,7 @@  discard block
 block discarded – undo
2239 2239
     $source_cf = [];
2240 2240
     $rows = DB::QUERY(
2241 2241
         'SELECT id_category
2242
-            FROM ' . prefixTable('categories_folders') . '
2242
+            FROM ' . prefixTable('categories_folders').'
2243 2243
             WHERE id_folder = %i',
2244 2244
         $source_id
2245 2245
     );
@@ -2250,7 +2250,7 @@  discard block
 block discarded – undo
2250 2250
     $target_cf = [];
2251 2251
     $rows = DB::QUERY(
2252 2252
         'SELECT id_category
2253
-            FROM ' . prefixTable('categories_folders') . '
2253
+            FROM ' . prefixTable('categories_folders').'
2254 2254
             WHERE id_folder = %i',
2255 2255
         $target_id
2256 2256
     );
@@ -2285,9 +2285,9 @@  discard block
 block discarded – undo
2285 2285
     string $password = null
2286 2286
 ) {
2287 2287
     // Load AntiXSS
2288
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/portable-ascii-master/src/voku/helper/ASCII.php';
2289
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/portable-utf8-master/src/voku/helper/UTF8.php';
2290
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/anti-xss-master/src/voku/helper/AntiXSS.php';
2288
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/portable-ascii-master/src/voku/helper/ASCII.php';
2289
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/portable-utf8-master/src/voku/helper/UTF8.php';
2290
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/anti-xss-master/src/voku/helper/AntiXSS.php';
2291 2291
     $antiXss = new voku\helper\AntiXSS();
2292 2292
     // Protect against bad inputs
2293 2293
     if (is_array($source_file) === true || is_array($target_file) === true) {
@@ -2344,20 +2344,20 @@  discard block
 block discarded – undo
2344 2344
 ) {
2345 2345
     // load PhpEncryption library
2346 2346
     $path_to_encryption = '/includes/libraries/Encryption/Encryption/';
2347
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Exception/CryptoException.php';
2348
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Exception/BadFormatException.php';
2349
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Exception/IOException.php';
2350
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Exception/EnvironmentIsBrokenException.php';
2351
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Exception/WrongKeyOrModifiedCiphertextException.php';
2352
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Crypto.php';
2353
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Encoding.php';
2354
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'DerivedKeys.php';
2355
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Key.php';
2356
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'KeyOrPassword.php';
2357
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'File.php';
2358
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'RuntimeTests.php';
2359
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'KeyProtectedByPassword.php';
2360
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Core.php';
2347
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Exception/CryptoException.php';
2348
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Exception/BadFormatException.php';
2349
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Exception/IOException.php';
2350
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Exception/EnvironmentIsBrokenException.php';
2351
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Exception/WrongKeyOrModifiedCiphertextException.php';
2352
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Crypto.php';
2353
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Encoding.php';
2354
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'DerivedKeys.php';
2355
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Key.php';
2356
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'KeyOrPassword.php';
2357
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'File.php';
2358
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'RuntimeTests.php';
2359
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'KeyProtectedByPassword.php';
2360
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Core.php';
2361 2361
     try {
2362 2362
         \Defuse\Crypto\File::encryptFileWithPassword(
2363 2363
             $source_file,
@@ -2394,20 +2394,20 @@  discard block
 block discarded – undo
2394 2394
 ) {
2395 2395
     // load PhpEncryption library
2396 2396
     $path_to_encryption = '/includes/libraries/Encryption/Encryption/';
2397
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Exception/CryptoException.php';
2398
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Exception/BadFormatException.php';
2399
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Exception/IOException.php';
2400
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Exception/EnvironmentIsBrokenException.php';
2401
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Exception/WrongKeyOrModifiedCiphertextException.php';
2402
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Crypto.php';
2403
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Encoding.php';
2404
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'DerivedKeys.php';
2405
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Key.php';
2406
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'KeyOrPassword.php';
2407
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'File.php';
2408
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'RuntimeTests.php';
2409
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'KeyProtectedByPassword.php';
2410
-    include_once $SETTINGS['cpassman_dir'] . $path_to_encryption . 'Core.php';
2397
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Exception/CryptoException.php';
2398
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Exception/BadFormatException.php';
2399
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Exception/IOException.php';
2400
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Exception/EnvironmentIsBrokenException.php';
2401
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Exception/WrongKeyOrModifiedCiphertextException.php';
2402
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Crypto.php';
2403
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Encoding.php';
2404
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'DerivedKeys.php';
2405
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Key.php';
2406
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'KeyOrPassword.php';
2407
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'File.php';
2408
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'RuntimeTests.php';
2409
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'KeyProtectedByPassword.php';
2410
+    include_once $SETTINGS['cpassman_dir'].$path_to_encryption.'Core.php';
2411 2411
     try {
2412 2412
         \Defuse\Crypto\File::decryptFileWithPassword(
2413 2413
             $source_file,
@@ -2454,9 +2454,9 @@  discard block
 block discarded – undo
2454 2454
 function fileDelete(string $file, array $SETTINGS): void
2455 2455
 {
2456 2456
     // Load AntiXSS
2457
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/portable-ascii-master/src/voku/helper/ASCII.php';
2458
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/portable-utf8-master/src/voku/helper/UTF8.php';
2459
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/anti-xss-master/src/voku/helper/AntiXSS.php';
2457
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/portable-ascii-master/src/voku/helper/ASCII.php';
2458
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/portable-utf8-master/src/voku/helper/UTF8.php';
2459
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/anti-xss-master/src/voku/helper/AntiXSS.php';
2460 2460
     $antiXss = new voku\helper\AntiXSS();
2461 2461
     $file = $antiXss->xss_clean($file);
2462 2462
     if (is_file($file)) {
@@ -2506,7 +2506,7 @@  discard block
 block discarded – undo
2506 2506
     int  $dirPerm = 0755
2507 2507
 ) {
2508 2508
     // Check if the path exists
2509
-    if (! file_exists($path)) {
2509
+    if (!file_exists($path)) {
2510 2510
         return false;
2511 2511
     }
2512 2512
 
@@ -2544,7 +2544,7 @@  discard block
 block discarded – undo
2544 2544
  */
2545 2545
 function accessToItemIsGranted(int $item_id, array $SETTINGS)
2546 2546
 {
2547
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
2547
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
2548 2548
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
2549 2549
     // Prepare superGlobal variables
2550 2550
     $session_groupes_visibles = $superGlobal->get('groupes_visibles', 'SESSION');
@@ -2552,7 +2552,7 @@  discard block
 block discarded – undo
2552 2552
     // Load item data
2553 2553
     $data = DB::queryFirstRow(
2554 2554
         'SELECT id_tree
2555
-        FROM ' . prefixTable('items') . '
2555
+        FROM ' . prefixTable('items').'
2556 2556
         WHERE id = %i',
2557 2557
         $item_id
2558 2558
     );
@@ -2615,7 +2615,7 @@  discard block
 block discarded – undo
2615 2615
         }
2616 2616
         $host .= substr(explode(".", $email[1])[0], -1, 1);
2617 2617
     }
2618
-    $email = $name . "@" . $host . "." . explode(".", $email[1])[1];
2618
+    $email = $name."@".$host.".".explode(".", $email[1])[1];
2619 2619
     return $email;
2620 2620
 }
2621 2621
 
@@ -2631,8 +2631,8 @@  discard block
 block discarded – undo
2631 2631
 function performDBQuery(array $SETTINGS, string $fields, string $table): array
2632 2632
 {
2633 2633
     // include librairies & connect to DB
2634
-    include_once $SETTINGS['cpassman_dir'] . '/includes/config/settings.php';
2635
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
2634
+    include_once $SETTINGS['cpassman_dir'].'/includes/config/settings.php';
2635
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
2636 2636
     if (defined('DB_PASSWD_CLEAR') === false) {
2637 2637
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
2638 2638
     }
@@ -2646,7 +2646,7 @@  discard block
 block discarded – undo
2646 2646
     DB::$connect_options = DB_CONNECT_OPTIONS;
2647 2647
     // Insert log in DB
2648 2648
     return DB::query(
2649
-        'SELECT ' . $fields . '
2649
+        'SELECT '.$fields.'
2650 2650
         FROM ' . prefixTable($table)
2651 2651
     );
2652 2652
 }
@@ -2661,11 +2661,11 @@  discard block
 block discarded – undo
2661 2661
 function formatSizeUnits(int $bytes): string
2662 2662
 {
2663 2663
     if ($bytes >= 1073741824) {
2664
-        $bytes = number_format($bytes / 1073741824, 2) . ' GB';
2664
+        $bytes = number_format($bytes / 1073741824, 2).' GB';
2665 2665
     } elseif ($bytes >= 1048576) {
2666
-        $bytes = number_format($bytes / 1048576, 2) . ' MB';
2666
+        $bytes = number_format($bytes / 1048576, 2).' MB';
2667 2667
     } elseif ($bytes >= 1024) {
2668
-        $bytes = number_format($bytes / 1024, 2) . ' KB';
2668
+        $bytes = number_format($bytes / 1024, 2).' KB';
2669 2669
     } elseif ($bytes > 1) {
2670 2670
         $bytes .= ' bytes';
2671 2671
     } elseif ($bytes === 1) {
@@ -2880,14 +2880,14 @@  discard block
 block discarded – undo
2880 2880
 
2881 2881
     // Encrypt the file content
2882 2882
     $plaintext = file_get_contents(
2883
-        filter_var($fileInPath . '/' . $fileInName, FILTER_SANITIZE_URL)
2883
+        filter_var($fileInPath.'/'.$fileInName, FILTER_SANITIZE_URL)
2884 2884
     );
2885 2885
     $ciphertext = $cipher->encrypt($plaintext);
2886 2886
     // Save new file
2887 2887
     $hash = md5($plaintext);
2888
-    $fileOut = $fileInPath . '/' . TP_FILE_PREFIX . $hash;
2888
+    $fileOut = $fileInPath.'/'.TP_FILE_PREFIX.$hash;
2889 2889
     file_put_contents($fileOut, $ciphertext);
2890
-    unlink($fileInPath . '/' . $fileInName);
2890
+    unlink($fileInPath.'/'.$fileInName);
2891 2891
     return [
2892 2892
         'fileHash' => base64_encode($hash),
2893 2893
         'objectKey' => base64_encode($objectKey),
@@ -2905,7 +2905,7 @@  discard block
 block discarded – undo
2905 2905
  */
2906 2906
 function decryptFile(string $fileName, string $filePath, string $key): string
2907 2907
 {
2908
-    if (! defined('FILE_BUFFER_SIZE')) {
2908
+    if (!defined('FILE_BUFFER_SIZE')) {
2909 2909
         define('FILE_BUFFER_SIZE', 128 * 1024);
2910 2910
     }
2911 2911
 
@@ -2924,7 +2924,7 @@  discard block
 block discarded – undo
2924 2924
     $cipher->enableContinuousBuffer();
2925 2925
     $cipher->disablePadding();
2926 2926
     // Get file content
2927
-    $ciphertext = file_get_contents($filePath . '/' . TP_FILE_PREFIX . $fileName);
2927
+    $ciphertext = file_get_contents($filePath.'/'.TP_FILE_PREFIX.$fileName);
2928 2928
     // Decrypt file content and return
2929 2929
     return base64_encode($cipher->decrypt($ciphertext));
2930 2930
 }
@@ -2978,8 +2978,8 @@  discard block
 block discarded – undo
2978 2978
     array $SETTINGS
2979 2979
 ): void {
2980 2980
     // include librairies & connect to DB
2981
-    include_once $SETTINGS['cpassman_dir'] . '/includes/config/settings.php';
2982
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
2981
+    include_once $SETTINGS['cpassman_dir'].'/includes/config/settings.php';
2982
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
2983 2983
     if (defined('DB_PASSWD_CLEAR') === false) {
2984 2984
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
2985 2985
     }
@@ -2998,7 +2998,7 @@  discard block
 block discarded – undo
2998 2998
         $post_object_id
2999 2999
     );
3000 3000
     // Superglobals
3001
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
3001
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/protect/SuperGlobal/SuperGlobal.php';
3002 3002
     $superGlobal = new protect\SuperGlobal\SuperGlobal();
3003 3003
     // Prepare superGlobal variables
3004 3004
     $sessionPpersonaFolders = $superGlobal->get('personal_folders', 'SESSION');
@@ -3023,8 +3023,8 @@  discard block
 block discarded – undo
3023 3023
         // Create sharekey for each user
3024 3024
         $users = DB::query(
3025 3025
             'SELECT id, public_key
3026
-            FROM ' . prefixTable('users') . '
3027
-            WHERE id NOT IN ("' . OTV_USER_ID . '","' . SSH_USER_ID . '","' . API_USER_ID . '")
3026
+            FROM ' . prefixTable('users').'
3027
+            WHERE id NOT IN ("' . OTV_USER_ID.'","'.SSH_USER_ID.'","'.API_USER_ID.'")
3028 3028
             AND public_key != ""'
3029 3029
         );
3030 3030
         foreach ($users as $user) {
@@ -3054,7 +3054,7 @@  discard block
 block discarded – undo
3054 3054
 function isBase64(string $str): bool
3055 3055
 {
3056 3056
     $str = (string) trim($str);
3057
-    if (! isset($str[0])) {
3057
+    if (!isset($str[0])) {
3058 3058
         return false;
3059 3059
     }
3060 3060
 
@@ -3122,12 +3122,12 @@  discard block
 block discarded – undo
3122 3122
         ],
3123 3123
     ];
3124 3124
     // Load expected libraries
3125
-    require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Tightenco/Collect/Support/Traits/Macroable.php';
3126
-    require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Tightenco/Collect/Support/Arr.php';
3127
-    require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/LdapRecord/DetectsErrors.php';
3128
-    require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/LdapRecord/Connection.php';
3129
-    require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/LdapRecord/LdapInterface.php';
3130
-    require_once $SETTINGS['cpassman_dir'] . '/includes/libraries/LdapRecord/Ldap.php';
3125
+    require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Tightenco/Collect/Support/Traits/Macroable.php';
3126
+    require_once $SETTINGS['cpassman_dir'].'/includes/libraries/Tightenco/Collect/Support/Arr.php';
3127
+    require_once $SETTINGS['cpassman_dir'].'/includes/libraries/LdapRecord/DetectsErrors.php';
3128
+    require_once $SETTINGS['cpassman_dir'].'/includes/libraries/LdapRecord/Connection.php';
3129
+    require_once $SETTINGS['cpassman_dir'].'/includes/libraries/LdapRecord/LdapInterface.php';
3130
+    require_once $SETTINGS['cpassman_dir'].'/includes/libraries/LdapRecord/Ldap.php';
3131 3131
     $ad = new SplClassLoader('LdapRecord', '../includes/libraries');
3132 3132
     $ad->register();
3133 3133
     $connection = new Connection($config);
@@ -3136,7 +3136,7 @@  discard block
 block discarded – undo
3136 3136
         $connection->connect();
3137 3137
     } catch (\LdapRecord\Auth\BindException $e) {
3138 3138
         $error = $e->getDetailedError();
3139
-        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage(). '<br>'.$error->getDiagnosticMessage();
3139
+        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage().'<br>'.$error->getDiagnosticMessage();
3140 3140
         return false;
3141 3141
     }
3142 3142
 
@@ -3149,7 +3149,7 @@  discard block
 block discarded – undo
3149 3149
         }
3150 3150
     } catch (\LdapRecord\Auth\BindException $e) {
3151 3151
         $error = $e->getDetailedError();
3152
-        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage(). '<br>'.$error->getDiagnosticMessage();
3152
+        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage().'<br>'.$error->getDiagnosticMessage();
3153 3153
         return false;
3154 3154
     }
3155 3155
 
@@ -3167,8 +3167,8 @@  discard block
 block discarded – undo
3167 3167
 function deleteUserObjetsKeys(int $userId, array $SETTINGS = []): bool
3168 3168
 {
3169 3169
     // include librairies & connect to DB
3170
-    include_once __DIR__. '/../includes/config/settings.php';
3171
-    include_once __DIR__. '/../includes/libraries/Database/Meekrodb/db.class.php';
3170
+    include_once __DIR__.'/../includes/config/settings.php';
3171
+    include_once __DIR__.'/../includes/libraries/Database/Meekrodb/db.class.php';
3172 3172
     if (defined('DB_PASSWD_CLEAR') === false) {
3173 3173
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
3174 3174
     }
@@ -3228,7 +3228,7 @@  discard block
 block discarded – undo
3228 3228
         foreach (DateTimeZone::listIdentifiers() as $timezone) {
3229 3229
             $now->setTimezone(new DateTimeZone($timezone));
3230 3230
             $offsets[] = $offset = $now->getOffset();
3231
-            $timezones[$timezone] = '(' . format_GMT_offset($offset) . ') ' . format_timezone_name($timezone);
3231
+            $timezones[$timezone] = '('.format_GMT_offset($offset).') '.format_timezone_name($timezone);
3232 3232
         }
3233 3233
 
3234 3234
         array_multisort($offsets, $timezones);
@@ -3248,7 +3248,7 @@  discard block
 block discarded – undo
3248 3248
 {
3249 3249
     $hours = intval($offset / 3600);
3250 3250
     $minutes = abs(intval($offset % 3600 / 60));
3251
-    return 'GMT' . ($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
3251
+    return 'GMT'.($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
3252 3252
 }
3253 3253
 
3254 3254
 /**
@@ -3348,8 +3348,7 @@  discard block
 block discarded – undo
3348 3348
 {
3349 3349
     if (isset($array[$key]) === true
3350 3350
         && (is_int($value) === true ?
3351
-            (int) $array[$key] === $value :
3352
-            (string) $array[$key] === $value)
3351
+            (int) $array[$key] === $value : (string) $array[$key] === $value)
3353 3352
     ) {
3354 3353
         return true;
3355 3354
     }
@@ -3371,8 +3370,7 @@  discard block
 block discarded – undo
3371 3370
 {
3372 3371
     if (isset($var) === false
3373 3372
         || (is_int($value) === true ?
3374
-            (int) $var === $value :
3375
-            (string) $var === $value)
3373
+            (int) $var === $value : (string) $var === $value)
3376 3374
     ) {
3377 3375
         return true;
3378 3376
     }
@@ -3423,7 +3421,7 @@  discard block
 block discarded – undo
3423 3421
  */
3424 3422
 function isSetArrayOfValues(array $arrayOfValues): bool
3425 3423
 {
3426
-    foreach($arrayOfValues as $value) {
3424
+    foreach ($arrayOfValues as $value) {
3427 3425
         if (isset($value) === false) {
3428 3426
             return false;
3429 3427
         }
@@ -3445,7 +3443,7 @@  discard block
 block discarded – undo
3445 3443
     /*PHP8 - integer|string*/$value
3446 3444
 ) : bool
3447 3445
 {
3448
-    foreach($arrayOfVars as $variable) {
3446
+    foreach ($arrayOfVars as $variable) {
3449 3447
         if ($variable !== $value) {
3450 3448
             return false;
3451 3449
         }
@@ -3465,7 +3463,7 @@  discard block
 block discarded – undo
3465 3463
     /*PHP8 - integer|string*/$value
3466 3464
 ) : bool
3467 3465
 {
3468
-    foreach($arrayOfVars as $variable) {
3466
+    foreach ($arrayOfVars as $variable) {
3469 3467
         if ($variable === $value) {
3470 3468
             return true;
3471 3469
         }
@@ -3534,26 +3532,26 @@  discard block
 block discarded – undo
3534 3532
 function dataSanitizer(
3535 3533
     array $data,
3536 3534
     array $filters,
3537
-    string $path = __DIR__. '/..' // Path to Teampass root
3535
+    string $path = __DIR__.'/..' // Path to Teampass root
3538 3536
 )
3539 3537
 {
3540 3538
     // Load Sanitizer library
3541
-    require_once $path . '/includes/libraries/Illuminate/Support/Traits/Macroable.php';
3542
-    require_once $path . '/includes/libraries/Illuminate/Support/Str.php';
3543
-    require_once $path . '/includes/libraries/Illuminate/Validation/ValidationRuleParser.php';
3544
-    require_once $path . '/includes/libraries/Illuminate/Support/Arr.php';
3545
-    require_once $path . '/includes/libraries/Elegant/sanitizer/Contracts/Filter.php';
3546
-    require_once $path . '/includes/libraries/Elegant/sanitizer/Filters/Trim.php';
3547
-    require_once $path . '/includes/libraries/Elegant/sanitizer/Filters/Cast.php';
3548
-    require_once $path . '/includes/libraries/Elegant/sanitizer/Filters/EscapeHTML.php';
3549
-    require_once $path . '/includes/libraries/Elegant/sanitizer/Filters/EmptyStringToNull.php';
3550
-    require_once $path . '/includes/libraries/Elegant/sanitizer/Sanitizer.php';
3539
+    require_once $path.'/includes/libraries/Illuminate/Support/Traits/Macroable.php';
3540
+    require_once $path.'/includes/libraries/Illuminate/Support/Str.php';
3541
+    require_once $path.'/includes/libraries/Illuminate/Validation/ValidationRuleParser.php';
3542
+    require_once $path.'/includes/libraries/Illuminate/Support/Arr.php';
3543
+    require_once $path.'/includes/libraries/Elegant/sanitizer/Contracts/Filter.php';
3544
+    require_once $path.'/includes/libraries/Elegant/sanitizer/Filters/Trim.php';
3545
+    require_once $path.'/includes/libraries/Elegant/sanitizer/Filters/Cast.php';
3546
+    require_once $path.'/includes/libraries/Elegant/sanitizer/Filters/EscapeHTML.php';
3547
+    require_once $path.'/includes/libraries/Elegant/sanitizer/Filters/EmptyStringToNull.php';
3548
+    require_once $path.'/includes/libraries/Elegant/sanitizer/Sanitizer.php';
3551 3549
     $sanitizer = new Elegant\sanitizer\Sanitizer($data, $filters);
3552 3550
 
3553 3551
     // Load AntiXSS
3554
-    include_once $path. '/includes/libraries/portable-ascii-master/src/voku/helper/ASCII.php';
3555
-    include_once $path . '/includes/libraries/portable-utf8-master/src/voku/helper/UTF8.php';
3556
-    include_once $path . '/includes/libraries/anti-xss-master/src/voku/helper/AntiXSS.php';
3552
+    include_once $path.'/includes/libraries/portable-ascii-master/src/voku/helper/ASCII.php';
3553
+    include_once $path.'/includes/libraries/portable-utf8-master/src/voku/helper/UTF8.php';
3554
+    include_once $path.'/includes/libraries/anti-xss-master/src/voku/helper/AntiXSS.php';
3557 3555
     $antiXss = new voku\helper\AntiXSS();
3558 3556
 
3559 3557
     // Sanitize post and get variables
@@ -3571,9 +3569,9 @@  discard block
 block discarded – undo
3571 3569
  */
3572 3570
 function cacheTreeUserHandler(int $user_id, string $data, array $SETTINGS, string $field_update = '')
3573 3571
 {
3574
-    include_once $SETTINGS['cpassman_dir'] . '/sources/SplClassLoader.php';
3572
+    include_once $SETTINGS['cpassman_dir'].'/sources/SplClassLoader.php';
3575 3573
     //Connect to DB
3576
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
3574
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Database/Meekrodb/db.class.php';
3577 3575
     if (defined('DB_PASSWD_CLEAR') === false) {
3578 3576
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, $SETTINGS));
3579 3577
     }
@@ -3589,7 +3587,7 @@  discard block
 block discarded – undo
3589 3587
     // Exists ?
3590 3588
     $userCacheId = DB::queryfirstrow(
3591 3589
         'SELECT increment_id
3592
-        FROM ' . prefixTable('cache_tree') . '
3590
+        FROM ' . prefixTable('cache_tree').'
3593 3591
         WHERE user_id = %i',
3594 3592
         $user_id
3595 3593
     );
@@ -3638,7 +3636,7 @@  discard block
 block discarded – undo
3638 3636
  */
3639 3637
 function pourcentage(float $nombre, float $total, float $pourcentage): float
3640 3638
 { 
3641
-    $resultat = ($nombre/$total) * $pourcentage;
3639
+    $resultat = ($nombre / $total) * $pourcentage;
3642 3640
     return round($resultat);
3643 3641
 }
3644 3642
 
@@ -3666,7 +3664,7 @@  discard block
 block discarded – undo
3666 3664
 
3667 3665
     // Get last folder update
3668 3666
     $lastFolderChange = DB::queryfirstrow(
3669
-        'SELECT valeur FROM ' . prefixTable('misc') . '
3667
+        'SELECT valeur FROM '.prefixTable('misc').'
3670 3668
         WHERE type = %s AND intitule = %s',
3671 3669
         'timestamp',
3672 3670
         'last_folder_change'
@@ -3696,7 +3694,7 @@  discard block
 block discarded – undo
3696 3694
     // Does this user has a tree cache
3697 3695
     $userCacheTree = DB::queryfirstrow(
3698 3696
         'SELECT '.$fieldName.'
3699
-        FROM ' . prefixTable('cache_tree') . '
3697
+        FROM ' . prefixTable('cache_tree').'
3700 3698
         WHERE user_id = %i',
3701 3699
         $_SESSION['user_id']
3702 3700
     );
@@ -3725,10 +3723,10 @@  discard block
 block discarded – undo
3725 3723
 )
3726 3724
 {
3727 3725
     //load ClassLoader
3728
-    include_once __DIR__. '/../sources/SplClassLoader.php';
3726
+    include_once __DIR__.'/../sources/SplClassLoader.php';
3729 3727
     
3730 3728
     //Connect to DB
3731
-    include_once __DIR__. '/../includes/libraries/Database/Meekrodb/db.class.php';
3729
+    include_once __DIR__.'/../includes/libraries/Database/Meekrodb/db.class.php';
3732 3730
     if (defined('DB_PASSWD_CLEAR') === false) {
3733 3731
         define('DB_PASSWD_CLEAR', defuseReturnDecrypted(DB_PASSWD, []));
3734 3732
     }
@@ -3747,7 +3745,7 @@  discard block
 block discarded – undo
3747 3745
     if (count($folderIds) === 0) {
3748 3746
         $folderIds = DB::queryFirstColumn(
3749 3747
             'SELECT id
3750
-            FROM ' . prefixTable('nested_tree') . '
3748
+            FROM ' . prefixTable('nested_tree').'
3751 3749
             WHERE personal_folder=%i',
3752 3750
             0
3753 3751
         );
@@ -3764,8 +3762,8 @@  discard block
 block discarded – undo
3764 3762
         $rows_tmp = DB::query(
3765 3763
             'SELECT c.id, c.title, c.level, c.type, c.masked, c.order, c.encrypted_data, c.role_visibility, c.is_mandatory,
3766 3764
             f.id_category AS category_id
3767
-            FROM ' . prefixTable('categories_folders') . ' AS f
3768
-            INNER JOIN ' . prefixTable('categories') . ' AS c ON (f.id_category = c.parent_id)
3765
+            FROM ' . prefixTable('categories_folders').' AS f
3766
+            INNER JOIN ' . prefixTable('categories').' AS c ON (f.id_category = c.parent_id)
3769 3767
             WHERE id_folder=%i',
3770 3768
             $folder
3771 3769
         );
@@ -3791,7 +3789,7 @@  discard block
 block discarded – undo
3791 3789
         $valTemp = '';
3792 3790
         $data = DB::queryFirstRow(
3793 3791
             'SELECT valeur
3794
-            FROM ' . prefixTable('misc') . '
3792
+            FROM ' . prefixTable('misc').'
3795 3793
             WHERE type = %s AND intitule=%i',
3796 3794
             'complex',
3797 3795
             $folder
@@ -3808,14 +3806,14 @@  discard block
 block discarded – undo
3808 3806
         $valTemp = '';
3809 3807
         $rows_tmp = DB::query(
3810 3808
             'SELECT t.title
3811
-            FROM ' . prefixTable('roles_values') . ' as v
3812
-            INNER JOIN ' . prefixTable('roles_title') . ' as t ON (v.role_id = t.id)
3809
+            FROM ' . prefixTable('roles_values').' as v
3810
+            INNER JOIN ' . prefixTable('roles_title').' as t ON (v.role_id = t.id)
3813 3811
             WHERE v.folder_id = %i
3814 3812
             GROUP BY title',
3815 3813
             $folder
3816 3814
         );
3817 3815
         foreach ($rows_tmp as $record) {
3818
-            $valTemp .= (empty($valTemp) === true ? '' : ' - ') . $record['title'];
3816
+            $valTemp .= (empty($valTemp) === true ? '' : ' - ').$record['title'];
3819 3817
         }
3820 3818
         $arr_data['visibilityRoles'] = $valTemp;
3821 3819
 
@@ -3847,7 +3845,7 @@  discard block
 block discarded – undo
3847 3845
         // loop on users and check if user has this role
3848 3846
         $rows = DB::query(
3849 3847
             'SELECT id, fonction_id
3850
-            FROM ' . prefixTable('users') . '
3848
+            FROM ' . prefixTable('users').'
3851 3849
             WHERE id != %i AND admin = 0 AND fonction_id IS NOT NULL AND fonction_id != ""',
3852 3850
             $_SESSION['user_id']
3853 3851
         );
@@ -3886,7 +3884,7 @@  discard block
 block discarded – undo
3886 3884
 
3887 3885
     $val = DB::queryfirstrow(
3888 3886
         'SELECT *
3889
-        FROM ' . prefixTable('users') . '
3887
+        FROM ' . prefixTable('users').'
3890 3888
         WHERE id = %i',
3891 3889
         $userId
3892 3890
     );
@@ -3902,12 +3900,12 @@  discard block
 block discarded – undo
3902 3900
 function upgradeRequired(): bool
3903 3901
 {
3904 3902
     // Get settings.php
3905
-    include_once __DIR__. '/../includes/config/settings.php';
3903
+    include_once __DIR__.'/../includes/config/settings.php';
3906 3904
 
3907 3905
     // Get timestamp in DB
3908 3906
     $val = DB::queryfirstrow(
3909 3907
         'SELECT valeur
3910
-        FROM ' . prefixTable('misc') . '
3908
+        FROM ' . prefixTable('misc').'
3911 3909
         WHERE type = %s AND intitule = %s',
3912 3910
         'admin',
3913 3911
         'upgrade_timestamp'
@@ -3954,7 +3952,7 @@  discard block
 block discarded – undo
3954 3952
     // prepapre background tasks for item keys generation        
3955 3953
     $userTP = DB::queryFirstRow(
3956 3954
         'SELECT pw, public_key, private_key
3957
-        FROM ' . prefixTable('users') . '
3955
+        FROM ' . prefixTable('users').'
3958 3956
         WHERE id = %i',
3959 3957
         TP_USER_ID
3960 3958
     );
@@ -4008,8 +4006,8 @@  discard block
 block discarded – undo
4008 4006
                 'process_type' => 'create_user_keys',
4009 4007
                 'arguments' => json_encode([
4010 4008
                     'new_user_id' => (int) $userId,
4011
-                    'new_user_pwd' => cryption($passwordClear, '','encrypt')['string'],
4012
-                    'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '','encrypt')['string'],
4009
+                    'new_user_pwd' => cryption($passwordClear, '', 'encrypt')['string'],
4010
+                    'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '', 'encrypt')['string'],
4013 4011
                     'owner_id' => (int) TP_USER_ID,
4014 4012
                     'creator_pwd' => $userTP['pw'],
4015 4013
                     'send_email' => $sendEmailToUser === true ? 1 : 0,
Please login to merge, or discard this patch.