Passed
Push — dev ( 3ad29f...97f4bd )
by Nils
08:12
created
pages/suggestion.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -43,16 +43,16 @@
 block discarded – undo
43 43
 }
44 44
 
45 45
 /* do checks */
46
-require_once $SETTINGS['cpassman_dir'] . '/sources/checks.php';
47
-if (! checkUser($_SESSION['user_id'], $_SESSION['key'], curPage($SETTINGS), $SETTINGS)) {
46
+require_once $SETTINGS['cpassman_dir'].'/sources/checks.php';
47
+if (!checkUser($_SESSION['user_id'], $_SESSION['key'], curPage($SETTINGS), $SETTINGS)) {
48 48
     $_SESSION['error']['code'] = ERR_NOT_ALLOWED;
49 49
     //not allowed page
50
-    include $SETTINGS['cpassman_dir'] . '/error.php';
50
+    include $SETTINGS['cpassman_dir'].'/error.php';
51 51
     exit;
52 52
 }
53 53
 
54 54
 // Load
55
-require_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
55
+require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
56 56
 
57 57
 ?>
58 58
 
Please login to merge, or discard this patch.
pages/kb.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -43,16 +43,16 @@
 block discarded – undo
43 43
 }
44 44
 
45 45
 /* do checks */
46
-require_once $SETTINGS['cpassman_dir'] . '/sources/checks.php';
47
-if (! checkUser($_SESSION['user_id'], $_SESSION['key'], curPage($SETTINGS), $SETTINGS)) {
46
+require_once $SETTINGS['cpassman_dir'].'/sources/checks.php';
47
+if (!checkUser($_SESSION['user_id'], $_SESSION['key'], curPage($SETTINGS), $SETTINGS)) {
48 48
     $_SESSION['error']['code'] = ERR_NOT_ALLOWED;
49 49
     //not allowed page
50
-    include $SETTINGS['cpassman_dir'] . '/error.php';
50
+    include $SETTINGS['cpassman_dir'].'/error.php';
51 51
     exit;
52 52
 }
53 53
 
54 54
 // Load
55
-require_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
55
+require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
56 56
 
57 57
 ?>
58 58
 
Please login to merge, or discard this patch.
sources/main.functions.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2226,7 +2226,7 @@
 block discarded – undo
2226 2226
  * <tt>exec("find ".$path." -type d -exec chmod 755 {} \;");</tt>
2227 2227
  *
2228 2228
  * @author Jeppe Toustrup (tenzer at tenzer dot dk)
2229
-  *
2229
+ *
2230 2230
  * @param string $path      An either relative or absolute path to a file or directory which should be processed.
2231 2231
  * @param int    $filePerm The permissions any found files should get.
2232 2232
  * @param int    $dirPerm  The permissions any found folder should get.
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3886,7 +3886,9 @@
 block discarded – undo
3886 3886
     );
3887 3887
     
3888 3888
     // if not exists then error
3889
-    if (is_null($val) === true || count($val) === 0 || defined('UPGRADE_MIN_DATE') === false) return true;
3889
+    if (is_null($val) === true || count($val) === 0 || defined('UPGRADE_MIN_DATE') === false) {
3890
+        return true;
3891
+    }
3890 3892
 
3891 3893
     // if empty or too old then error
3892 3894
     if (empty($val['valeur']) === true || (int) $val['valeur'] < (int) UPGRADE_MIN_DATE) {
Please login to merge, or discard this patch.
Spacing   +150 added lines, -153 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
 // Load config if $SETTINGS not defined
52 52
 if (isset($SETTINGS['cpassman_dir']) === false || empty($SETTINGS['cpassman_dir']) === true) {
53
-    include_once __DIR__ . '/../includes/config/tp.config.php';
53
+    include_once __DIR__.'/../includes/config/tp.config.php';
54 54
 }
55 55
 
56 56
 header('Content-type: text/html; charset=utf-8');
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             and improve performance by avoiding to include the file for every missing strings.
84 84
         */
85 85
         if (isset($_SESSION['teampass']) === false || isset($_SESSION['teampass']['en_lang'][trim($string)]) === false) {
86
-            $_SESSION['teampass']['en_lang'] = include_once __DIR__. '/../includes/language/english.php';
86
+            $_SESSION['teampass']['en_lang'] = include_once __DIR__.'/../includes/language/english.php';
87 87
             $session_language = isset($_SESSION['teampass']['en_lang'][trim($string)]) === false ? '' : $_SESSION['teampass']['en_lang'][trim($string)];
88 88
         } else {
89 89
             $session_language = $_SESSION['teampass']['en_lang'][trim($string)];
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
  */
258 258
 function trimElement($chaine, string $element): string
259 259
 {
260
-    if (! empty($chaine)) {
260
+    if (!empty($chaine)) {
261 261
         if (is_array($chaine) === true) {
262 262
             $chaine = implode(';', $chaine);
263 263
         }
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
  */
306 306
 function db_error_handler(array $params): void
307 307
 {
308
-    echo 'Error: ' . $params['error'] . "<br>\n";
309
-    echo 'Query: ' . $params['query'] . "<br>\n";
308
+    echo 'Error: '.$params['error']."<br>\n";
309
+    echo 'Query: '.$params['query']."<br>\n";
310 310
     throw new Exception('Error - Query', 1);
311 311
 }
312 312
 
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
     $globalsVisibleFolders = $superGlobal->get('groupes_visibles', 'SESSION');
390 390
     $globalsPersonalVisibleFolders = $superGlobal->get('personal_visible_groups', 'SESSION');
391 391
     // Get list of Folders
392
-    $rows = DB::query('SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i', 0);
392
+    $rows = DB::query('SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i', 0);
393 393
     foreach ($rows as $record) {
394 394
         array_push($groupesVisibles, $record['id']);
395 395
     }
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
     }
409 409
     // Get ID of personal folder
410 410
     $persfld = DB::queryfirstrow(
411
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE title = %s',
411
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE title = %s',
412 412
         $globalsUserId
413 413
     );
414 414
     if (empty($persfld['id']) === false) {
@@ -429,20 +429,20 @@  discard block
 block discarded – undo
429 429
     // get complete list of ROLES
430 430
     $tmp = explode(';', $idFonctions);
431 431
     $rows = DB::query(
432
-        'SELECT * FROM ' . prefixTable('roles_title') . '
432
+        'SELECT * FROM '.prefixTable('roles_title').'
433 433
         ORDER BY title ASC'
434 434
     );
435 435
     foreach ($rows as $record) {
436
-        if (! empty($record['id']) && ! in_array($record['id'], $tmp)) {
436
+        if (!empty($record['id']) && !in_array($record['id'], $tmp)) {
437 437
             array_push($tmp, $record['id']);
438 438
         }
439 439
     }
440 440
     $superGlobal->put('fonction_id', implode(';', $tmp), 'SESSION');
441 441
     $superGlobal->put('is_admin', 1, 'SESSION');
442 442
     // Check if admin has created Folders and Roles
443
-    DB::query('SELECT * FROM ' . prefixTable('nested_tree') . '');
443
+    DB::query('SELECT * FROM '.prefixTable('nested_tree').'');
444 444
     $superGlobal->put('nb_folders', DB::count(), 'SESSION');
445
-    DB::query('SELECT * FROM ' . prefixTable('roles_title'));
445
+    DB::query('SELECT * FROM '.prefixTable('roles_title'));
446 446
     $superGlobal->put('nb_roles', DB::count(), 'SESSION');
447 447
 
448 448
     return true;
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
     // Does this user is allowed to see other items
527 527
     $inc = 0;
528 528
     $rows = DB::query(
529
-        'SELECT id, id_tree FROM ' . prefixTable('items') . '
529
+        'SELECT id, id_tree FROM '.prefixTable('items').'
530 530
             WHERE restricted_to LIKE %ss AND inactif = %s'.
531 531
             (count($allowedFolders) > 0 ? ' AND id_tree NOT IN ('.implode(',', $allowedFolders).')' : ''),
532 532
         $globalsUserId,
@@ -543,8 +543,8 @@  discard block
 block discarded – undo
543 543
     // Check for the users roles if some specific rights exist on items
544 544
     $rows = DB::query(
545 545
         'SELECT i.id_tree, r.item_id
546
-        FROM ' . prefixTable('items') . ' as i
547
-        INNER JOIN ' . prefixTable('restriction_to_roles') . ' as r ON (r.item_id=i.id)
546
+        FROM ' . prefixTable('items').' as i
547
+        INNER JOIN ' . prefixTable('restriction_to_roles').' as r ON (r.item_id=i.id)
548 548
         WHERE i.id_tree <> "" '.
549 549
         (count($userRoles) > 0 ? 'AND r.role_id IN %li ' : '').
550 550
         'ORDER BY i.id_tree ASC',
@@ -599,16 +599,16 @@  discard block
 block discarded – undo
599 599
         'SESSION'
600 600
     );
601 601
     // Folders and Roles numbers
602
-    DB::queryfirstrow('SELECT id FROM ' . prefixTable('nested_tree') . '');
602
+    DB::queryfirstrow('SELECT id FROM '.prefixTable('nested_tree').'');
603 603
     $superGlobal->put('nb_folders', DB::count(), 'SESSION');
604
-    DB::queryfirstrow('SELECT id FROM ' . prefixTable('roles_title'));
604
+    DB::queryfirstrow('SELECT id FROM '.prefixTable('roles_title'));
605 605
     $superGlobal->put('nb_roles', DB::count(), 'SESSION');
606 606
     // check if change proposals on User's items
607 607
     if (isset($SETTINGS['enable_suggestion']) === true && (int) $SETTINGS['enable_suggestion'] === 1) {
608 608
         $countNewItems = DB::query(
609 609
             'SELECT COUNT(*)
610
-            FROM ' . prefixTable('items_change') . ' AS c
611
-            LEFT JOIN ' . prefixTable('log_items') . ' AS i ON (c.item_id = i.id_item)
610
+            FROM ' . prefixTable('items_change').' AS c
611
+            LEFT JOIN ' . prefixTable('log_items').' AS i ON (c.item_id = i.id_item)
612 612
             WHERE i.action = %s AND i.id_user = %i',
613 613
             'at_creation',
614 614
             $globalsUserId
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 {
636 636
     $rows = DB::query(
637 637
         'SELECT *
638
-        FROM ' . prefixTable('roles_values') . '
638
+        FROM ' . prefixTable('roles_values').'
639 639
         WHERE type IN %ls'.(count($userRoles) > 0 ? ' AND role_id IN %li' : ''),
640 640
         ['W', 'ND', 'NE', 'NDNE', 'R'],
641 641
         $userRoles,
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
     ) {
703 703
         $persoFld = DB::queryfirstrow(
704 704
             'SELECT id
705
-            FROM ' . prefixTable('nested_tree') . '
705
+            FROM ' . prefixTable('nested_tree').'
706 706
             WHERE title = %s AND personal_folder = %i'.
707 707
             (count($allowedFolders) > 0 ? ' AND id NOT IN ('.implode(',', $allowedFolders).')' : ''),
708 708
             $globalsUserId,
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
     }
736 736
     $persoFlds = DB::query(
737 737
         'SELECT id
738
-        FROM ' . prefixTable('nested_tree') . '
738
+        FROM ' . prefixTable('nested_tree').'
739 739
         WHERE %l',
740 740
         $where
741 741
     );
@@ -805,12 +805,12 @@  discard block
 block discarded – undo
805 805
     //Load Tree
806 806
     $tree = new NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title');
807 807
     // truncate table
808
-    DB::query('TRUNCATE TABLE ' . prefixTable('cache'));
808
+    DB::query('TRUNCATE TABLE '.prefixTable('cache'));
809 809
     // reload date
810 810
     $rows = DB::query(
811 811
         'SELECT *
812
-        FROM ' . prefixTable('items') . ' as i
813
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
812
+        FROM ' . prefixTable('items').' as i
813
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
814 814
         AND l.action = %s
815 815
         AND i.inactif = %i',
816 816
         'at_creation',
@@ -822,18 +822,18 @@  discard block
 block discarded – undo
822 822
             $tags = '';
823 823
             $itemTags = DB::query(
824 824
                 'SELECT tag
825
-                FROM ' . prefixTable('tags') . '
825
+                FROM ' . prefixTable('tags').'
826 826
                 WHERE item_id = %i AND tag != ""',
827 827
                 $record['id']
828 828
             );
829 829
             foreach ($itemTags as $itemTag) {
830
-                $tags .= $itemTag['tag'] . ' ';
830
+                $tags .= $itemTag['tag'].' ';
831 831
             }
832 832
 
833 833
             // Get renewal period
834 834
             $resNT = DB::queryfirstrow(
835 835
                 'SELECT renewal_period
836
-                FROM ' . prefixTable('nested_tree') . '
836
+                FROM ' . prefixTable('nested_tree').'
837 837
                 WHERE id = %i',
838 838
                 $record['id_tree']
839 839
             );
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
                     // Is this a User id?
847 847
                     $user = DB::queryfirstrow(
848 848
                         'SELECT id, login
849
-                        FROM ' . prefixTable('users') . '
849
+                        FROM ' . prefixTable('users').'
850 850
                         WHERE id = %i',
851 851
                         $elem->title
852 852
                     );
@@ -864,11 +864,11 @@  discard block
 block discarded – undo
864 864
                     'id' => $record['id'],
865 865
                     'label' => $record['label'],
866 866
                     'description' => $record['description'] ?? '',
867
-                    'url' => isset($record['url']) && ! empty($record['url']) ? $record['url'] : '0',
867
+                    'url' => isset($record['url']) && !empty($record['url']) ? $record['url'] : '0',
868 868
                     'tags' => $tags,
869 869
                     'id_tree' => $record['id_tree'],
870 870
                     'perso' => $record['perso'],
871
-                    'restricted_to' => isset($record['restricted_to']) && ! empty($record['restricted_to']) ? $record['restricted_to'] : '0',
871
+                    'restricted_to' => isset($record['restricted_to']) && !empty($record['restricted_to']) ? $record['restricted_to'] : '0',
872 872
                     'login' => $record['login'] ?? '',
873 873
                     'folder' => implode(' > ', $folder),
874 874
                     'author' => $record['id_user'],
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
     // get new value from db
901 901
     $data = DB::queryfirstrow(
902 902
         'SELECT label, description, id_tree, perso, restricted_to, login, url
903
-        FROM ' . prefixTable('items') . '
903
+        FROM ' . prefixTable('items').'
904 904
         WHERE id=%i',
905 905
         $ident
906 906
     );
@@ -908,12 +908,12 @@  discard block
 block discarded – undo
908 908
     $tags = '';
909 909
     $itemTags = DB::query(
910 910
         'SELECT tag
911
-            FROM ' . prefixTable('tags') . '
911
+            FROM ' . prefixTable('tags').'
912 912
             WHERE item_id = %i AND tag != ""',
913 913
         $ident
914 914
     );
915 915
     foreach ($itemTags as $itemTag) {
916
-        $tags .= $itemTag['tag'] . ' ';
916
+        $tags .= $itemTag['tag'].' ';
917 917
     }
918 918
     // form id_tree to full foldername
919 919
     $folder = [];
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
             // Is this a User id?
925 925
             $user = DB::queryfirstrow(
926 926
                 'SELECT id, login
927
-                FROM ' . prefixTable('users') . '
927
+                FROM ' . prefixTable('users').'
928 928
                 WHERE id = %i',
929 929
                 $elem->title
930 930
             );
@@ -942,10 +942,10 @@  discard block
 block discarded – undo
942 942
             'label' => $data['label'],
943 943
             'description' => $data['description'],
944 944
             'tags' => $tags,
945
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
945
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
946 946
             'id_tree' => $data['id_tree'],
947 947
             'perso' => $data['perso'],
948
-            'restricted_to' => isset($data['restricted_to']) && ! empty($data['restricted_to']) ? $data['restricted_to'] : '0',
948
+            'restricted_to' => isset($data['restricted_to']) && !empty($data['restricted_to']) ? $data['restricted_to'] : '0',
949 949
             'login' => $data['login'] ?? '',
950 950
             'folder' => implode(' » ', $folder),
951 951
             'author' => $superGlobal->get('user_id', 'SESSION'),
@@ -977,8 +977,8 @@  discard block
 block discarded – undo
977 977
     // get new value from db
978 978
     $data = DB::queryFirstRow(
979 979
         'SELECT i.label, i.description, i.id_tree as id_tree, i.perso, i.restricted_to, i.id, i.login, i.url, l.date
980
-        FROM ' . prefixTable('items') . ' as i
981
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
980
+        FROM ' . prefixTable('items').' as i
981
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
982 982
         WHERE i.id = %i
983 983
         AND l.action = %s',
984 984
         $ident,
@@ -988,12 +988,12 @@  discard block
 block discarded – undo
988 988
     $tags = '';
989 989
     $itemTags = DB::query(
990 990
         'SELECT tag
991
-            FROM ' . prefixTable('tags') . '
991
+            FROM ' . prefixTable('tags').'
992 992
             WHERE item_id = %i AND tag != ""',
993 993
         $ident
994 994
     );
995 995
     foreach ($itemTags as $itemTag) {
996
-        $tags .= $itemTag['tag'] . ' ';
996
+        $tags .= $itemTag['tag'].' ';
997 997
     }
998 998
     // form id_tree to full foldername
999 999
     $folder = [];
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
             // Is this a User id?
1005 1005
             $user = DB::queryfirstrow(
1006 1006
                 'SELECT id, login
1007
-                FROM ' . prefixTable('users') . '
1007
+                FROM ' . prefixTable('users').'
1008 1008
                 WHERE id = %i',
1009 1009
                 $elem->title
1010 1010
             );
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
             'label' => $data['label'],
1024 1024
             'description' => $data['description'],
1025 1025
             'tags' => isset($tags) && empty($tags) === false ? $tags : 'None',
1026
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
1026
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
1027 1027
             'id_tree' => $data['id_tree'],
1028 1028
             'perso' => isset($data['perso']) && empty($data['perso']) === false && $data['perso'] !== 'None' ? $data['perso'] : '0',
1029 1029
             'restricted_to' => isset($data['restricted_to']) && empty($data['restricted_to']) === false ? $data['restricted_to'] : '0',
@@ -1045,52 +1045,52 @@  discard block
 block discarded – undo
1045 1045
 function getStatisticsData(array $SETTINGS): array
1046 1046
 {
1047 1047
     DB::query(
1048
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
1048
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
1049 1049
         0
1050 1050
     );
1051 1051
     $counter_folders = DB::count();
1052 1052
     DB::query(
1053
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
1053
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
1054 1054
         1
1055 1055
     );
1056 1056
     $counter_folders_perso = DB::count();
1057 1057
     DB::query(
1058
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
1058
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
1059 1059
         0
1060 1060
     );
1061 1061
     $counter_items = DB::count();
1062 1062
         DB::query(
1063
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
1063
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
1064 1064
         1
1065 1065
     );
1066 1066
     $counter_items_perso = DB::count();
1067 1067
         DB::query(
1068
-        'SELECT id FROM ' . prefixTable('users') . ''
1068
+        'SELECT id FROM '.prefixTable('users').''
1069 1069
     );
1070 1070
     $counter_users = DB::count();
1071 1071
         DB::query(
1072
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE admin = %i',
1072
+        'SELECT id FROM '.prefixTable('users').' WHERE admin = %i',
1073 1073
         1
1074 1074
     );
1075 1075
     $admins = DB::count();
1076 1076
     DB::query(
1077
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE gestionnaire = %i',
1077
+        'SELECT id FROM '.prefixTable('users').' WHERE gestionnaire = %i',
1078 1078
         1
1079 1079
     );
1080 1080
     $managers = DB::count();
1081 1081
     DB::query(
1082
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE read_only = %i',
1082
+        'SELECT id FROM '.prefixTable('users').' WHERE read_only = %i',
1083 1083
         1
1084 1084
     );
1085 1085
     $readOnly = DB::count();
1086 1086
     // list the languages
1087 1087
     $usedLang = [];
1088 1088
     $tp_languages = DB::query(
1089
-        'SELECT name FROM ' . prefixTable('languages')
1089
+        'SELECT name FROM '.prefixTable('languages')
1090 1090
     );
1091 1091
     foreach ($tp_languages as $tp_language) {
1092 1092
         DB::query(
1093
-            'SELECT * FROM ' . prefixTable('users') . ' WHERE user_language = %s',
1093
+            'SELECT * FROM '.prefixTable('users').' WHERE user_language = %s',
1094 1094
             $tp_language['name']
1095 1095
         );
1096 1096
         $usedLang[$tp_language['name']] = round((DB::count() * 100 / $counter_users), 0);
@@ -1099,12 +1099,12 @@  discard block
 block discarded – undo
1099 1099
     // get list of ips
1100 1100
     $usedIp = [];
1101 1101
     $tp_ips = DB::query(
1102
-        'SELECT user_ip FROM ' . prefixTable('users')
1102
+        'SELECT user_ip FROM '.prefixTable('users')
1103 1103
     );
1104 1104
     foreach ($tp_ips as $ip) {
1105 1105
         if (array_key_exists($ip['user_ip'], $usedIp)) {
1106 1106
             $usedIp[$ip['user_ip']] += $usedIp[$ip['user_ip']];
1107
-        } elseif (! empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
1107
+        } elseif (!empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
1108 1108
             $usedIp[$ip['user_ip']] = 1;
1109 1109
         }
1110 1110
     }
@@ -1257,12 +1257,12 @@  discard block
 block discarded – undo
1257 1257
     // Load superglobal
1258 1258
     $superGlobal = new SuperGlobal();
1259 1259
     // Get user language
1260
-    include_once $SETTINGS['cpassman_dir'] . '/includes/language/' . (null !== $superGlobal->get('user_language', 'SESSION', 'user') ? $superGlobal->get('user_language', 'SESSION', 'user') : 'english') . '.php';
1260
+    include_once $SETTINGS['cpassman_dir'].'/includes/language/'.(null !== $superGlobal->get('user_language', 'SESSION', 'user') ? $superGlobal->get('user_language', 'SESSION', 'user') : 'english').'.php';
1261 1261
     // load PHPMailer
1262 1262
     $mail = new PHPMailer(true);
1263 1263
 
1264 1264
     // send to user
1265
-    $mail->setLanguage('en', $SETTINGS['cpassman_dir'] . '/vendor/phpmailer/phpmailer/language/');
1265
+    $mail->setLanguage('en', $SETTINGS['cpassman_dir'].'/vendor/phpmailer/phpmailer/language/');
1266 1266
     $mail->SMTPDebug = isset($SETTINGS['email_debug_level']) === true && $cron === false && $silent === false ? $SETTINGS['email_debug_level'] : 0;
1267 1267
     $mail->Port = (int) $SETTINGS['email_port'];
1268 1268
     //COULD BE USED
@@ -1352,7 +1352,7 @@  discard block
 block discarded – undo
1352 1352
         <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;">
1353 1353
         <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;">
1354 1354
         <br><div style="float:right;">' .
1355
-        $textMail .
1355
+        $textMail.
1356 1356
         '<br><br></td></tr></table>
1357 1357
     </td></tr></table>
1358 1358
     <br></body></html>';
@@ -1365,7 +1365,7 @@  discard block
 block discarded – undo
1365 1365
  */
1366 1366
 function generateKey(): string
1367 1367
 {
1368
-    return substr(md5(rand() . rand()), 0, 15);
1368
+    return substr(md5(rand().rand()), 0, 15);
1369 1369
 }
1370 1370
 
1371 1371
 /**
@@ -1443,7 +1443,7 @@  discard block
 block discarded – undo
1443 1443
 {
1444 1444
     array_walk_recursive(
1445 1445
         $array,
1446
-        static function (&$item): void {
1446
+        static function(&$item): void {
1447 1447
             if (mb_detect_encoding((string) $item, 'utf-8', true) === false) {
1448 1448
                 $item = utf8_encode($item);
1449 1449
             }
@@ -1544,7 +1544,7 @@  discard block
 block discarded – undo
1544 1544
  */
1545 1545
 function prefixTable(string $table): string
1546 1546
 {
1547
-    $safeTable = htmlspecialchars(DB_PREFIX . $table);
1547
+    $safeTable = htmlspecialchars(DB_PREFIX.$table);
1548 1548
     if (empty($safeTable) === false) {
1549 1549
         // sanitize string
1550 1550
         return $safeTable;
@@ -1608,7 +1608,7 @@  discard block
 block discarded – undo
1608 1608
 function send_syslog($message, $host, $port, $component = 'teampass'): void
1609 1609
 {
1610 1610
     $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
1611
-    $syslog_message = '<123>' . date('M d H:i:s ') . $component . ': ' . $message;
1611
+    $syslog_message = '<123>'.date('M d H:i:s ').$component.': '.$message;
1612 1612
     socket_sendto($sock, (string) $syslog_message, strlen($syslog_message), 0, (string) $host, (int) $port);
1613 1613
     socket_close($sock);
1614 1614
 }
@@ -1655,14 +1655,14 @@  discard block
 block discarded – undo
1655 1655
     if (isset($SETTINGS['syslog_enable']) === true && (int) $SETTINGS['syslog_enable'] === 1) {
1656 1656
         if ($type === 'user_mngt') {
1657 1657
             send_syslog(
1658
-                'action=' . str_replace('at_', '', $label) . ' attribute=user user=' . $who . ' userid="' . $login . '" change="' . $field_1 . '" ',
1658
+                'action='.str_replace('at_', '', $label).' attribute=user user='.$who.' userid="'.$login.'" change="'.$field_1.'" ',
1659 1659
                 $SETTINGS['syslog_host'],
1660 1660
                 $SETTINGS['syslog_port'],
1661 1661
                 'teampass'
1662 1662
             );
1663 1663
         } else {
1664 1664
             send_syslog(
1665
-                'action=' . $type . ' attribute=' . $label . ' user=' . $who . ' userid="' . $login . '" ',
1665
+                'action='.$type.' attribute='.$label.' user='.$who.' userid="'.$login.'" ',
1666 1666
                 $SETTINGS['syslog_host'],
1667 1667
                 $SETTINGS['syslog_port'],
1668 1668
                 'teampass'
@@ -1736,7 +1736,7 @@  discard block
 block discarded – undo
1736 1736
         if (empty($item_label) === true) {
1737 1737
             $dataItem = DB::queryfirstrow(
1738 1738
                 'SELECT id, id_tree, label
1739
-                FROM ' . prefixTable('items') . '
1739
+                FROM ' . prefixTable('items').'
1740 1740
                 WHERE id = %i',
1741 1741
                 $item_id
1742 1742
             );
@@ -1744,11 +1744,11 @@  discard block
 block discarded – undo
1744 1744
         }
1745 1745
 
1746 1746
         send_syslog(
1747
-            'action=' . str_replace('at_', '', $action) .
1748
-                ' attribute=' . str_replace('at_', '', $attribute[0]) .
1749
-                ' itemno=' . $item_id .
1750
-                ' user=' . is_null($login) === true ? '' : addslashes((string) $login) .
1751
-                ' itemname="' . addslashes($item_label) . '"',
1747
+            'action='.str_replace('at_', '', $action).
1748
+                ' attribute='.str_replace('at_', '', $attribute[0]).
1749
+                ' itemno='.$item_id.
1750
+                ' user='.is_null($login) === true ? '' : addslashes((string) $login).
1751
+                ' itemname="'.addslashes($item_label).'"',
1752 1752
             $SETTINGS['syslog_host'],
1753 1753
             $SETTINGS['syslog_port'],
1754 1754
             'teampass'
@@ -1836,8 +1836,8 @@  discard block
 block discarded – undo
1836 1836
     $notification = DB::queryOneColumn(
1837 1837
         'email',
1838 1838
         'SELECT *
1839
-        FROM ' . prefixTable('notification') . ' AS n
1840
-        INNER JOIN ' . prefixTable('users') . ' AS u ON (n.user_id = u.id)
1839
+        FROM ' . prefixTable('notification').' AS n
1840
+        INNER JOIN ' . prefixTable('users').' AS u ON (n.user_id = u.id)
1841 1841
         WHERE n.item_id = %i AND n.user_id != %i',
1842 1842
         $item_id,
1843 1843
         $globalsUserId
@@ -1848,7 +1848,7 @@  discard block
 block discarded – undo
1848 1848
         // Get list of changes
1849 1849
         $htmlChanges = '<ul>';
1850 1850
         foreach ($changes as $change) {
1851
-            $htmlChanges .= '<li>' . $change . '</li>';
1851
+            $htmlChanges .= '<li>'.$change.'</li>';
1852 1852
         }
1853 1853
         $htmlChanges .= '</ul>';
1854 1854
         // send email
@@ -1885,15 +1885,15 @@  discard block
 block discarded – undo
1885 1885
     $path = '';
1886 1886
     foreach ($arbo as $elem) {
1887 1887
         if (empty($path) === true) {
1888
-            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES) . ' ';
1888
+            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES).' ';
1889 1889
         } else {
1890
-            $path .= '&#8594; ' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1890
+            $path .= '&#8594; '.htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1891 1891
         }
1892 1892
     }
1893 1893
 
1894 1894
     // Build text to show user
1895 1895
     if (empty($label) === false) {
1896
-        return empty($path) === true ? addslashes($label) : addslashes($label) . ' (' . $path . ')';
1896
+        return empty($path) === true ? addslashes($label) : addslashes($label).' ('.$path.')';
1897 1897
     }
1898 1898
     return empty($path) === true ? '' : $path;
1899 1899
 }
@@ -1950,7 +1950,7 @@  discard block
 block discarded – undo
1950 1950
  */
1951 1951
 function handleConfigFile($action, $SETTINGS, $field = null, $value = null)
1952 1952
 {
1953
-    $tp_config_file = $SETTINGS['cpassman_dir'] . '/includes/config/tp.config.php';
1953
+    $tp_config_file = $SETTINGS['cpassman_dir'].'/includes/config/tp.config.php';
1954 1954
 
1955 1955
     // Load class DB
1956 1956
     loadClasses('DB');
@@ -1958,8 +1958,8 @@  discard block
 block discarded – undo
1958 1958
     if (file_exists($tp_config_file) === false || $action === 'rebuild') {
1959 1959
         // perform a copy
1960 1960
         if (file_exists($tp_config_file)) {
1961
-            if (! copy($tp_config_file, $tp_config_file . '.' . date('Y_m_d_His', time()))) {
1962
-                return "ERROR: Could not copy file '" . $tp_config_file . "'";
1961
+            if (!copy($tp_config_file, $tp_config_file.'.'.date('Y_m_d_His', time()))) {
1962
+                return "ERROR: Could not copy file '".$tp_config_file."'";
1963 1963
             }
1964 1964
         }
1965 1965
 
@@ -1969,11 +1969,11 @@  discard block
 block discarded – undo
1969 1969
         $data[1] = "global \$SETTINGS;\n";
1970 1970
         $data[2] = "\$SETTINGS = array (\n";
1971 1971
         $rows = DB::query(
1972
-            'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s',
1972
+            'SELECT * FROM '.prefixTable('misc').' WHERE type=%s',
1973 1973
             'admin'
1974 1974
         );
1975 1975
         foreach ($rows as $record) {
1976
-            array_push($data, "    '" . $record['intitule'] . "' => '" . htmlspecialchars_decode($record['valeur'], ENT_COMPAT) . "',\n");
1976
+            array_push($data, "    '".$record['intitule']."' => '".htmlspecialchars_decode($record['valeur'], ENT_COMPAT)."',\n");
1977 1977
         }
1978 1978
         array_push($data, ");\n");
1979 1979
         $data = array_unique($data);
@@ -1987,15 +1987,15 @@  discard block
 block discarded – undo
1987 1987
                 break;
1988 1988
             }
1989 1989
 
1990
-            if (stristr($line, "'" . $field . "' => '")) {
1991
-                $data[$inc] = "    '" . $field . "' => '" . htmlspecialchars_decode($value, ENT_COMPAT) . "',\n";
1990
+            if (stristr($line, "'".$field."' => '")) {
1991
+                $data[$inc] = "    '".$field."' => '".htmlspecialchars_decode($value, ENT_COMPAT)."',\n";
1992 1992
                 $bFound = true;
1993 1993
                 break;
1994 1994
             }
1995 1995
             ++$inc;
1996 1996
         }
1997 1997
         if ($bFound === false) {
1998
-            $data[$inc] = "    '" . $field . "' => '" . htmlspecialchars_decode($value, ENT_COMPAT). "',\n);\n";
1998
+            $data[$inc] = "    '".$field."' => '".htmlspecialchars_decode($value, ENT_COMPAT)."',\n);\n";
1999 1999
         }
2000 2000
     }
2001 2001
 
@@ -2025,7 +2025,7 @@  discard block
 block discarded – undo
2025 2025
 {
2026 2026
     global $SETTINGS;
2027 2027
     /* LOAD CPASSMAN SETTINGS */
2028
-    if (! isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
2028
+    if (!isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
2029 2029
         $SETTINGS = [];
2030 2030
         $SETTINGS['duplicate_folder'] = 0;
2031 2031
         //by default, this is set to 0;
@@ -2035,7 +2035,7 @@  discard block
 block discarded – undo
2035 2035
         //by default, this value is set to 5;
2036 2036
         $settings = [];
2037 2037
         $rows = DB::query(
2038
-            'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s_type OR type=%s_type2',
2038
+            'SELECT * FROM '.prefixTable('misc').' WHERE type=%s_type OR type=%s_type2',
2039 2039
             [
2040 2040
                 'type' => 'admin',
2041 2041
                 'type2' => 'settings',
@@ -2067,7 +2067,7 @@  discard block
 block discarded – undo
2067 2067
     $source_cf = [];
2068 2068
     $rows = DB::QUERY(
2069 2069
         'SELECT id_category
2070
-            FROM ' . prefixTable('categories_folders') . '
2070
+            FROM ' . prefixTable('categories_folders').'
2071 2071
             WHERE id_folder = %i',
2072 2072
         $source_id
2073 2073
     );
@@ -2078,7 +2078,7 @@  discard block
 block discarded – undo
2078 2078
     $target_cf = [];
2079 2079
     $rows = DB::QUERY(
2080 2080
         'SELECT id_category
2081
-            FROM ' . prefixTable('categories_folders') . '
2081
+            FROM ' . prefixTable('categories_folders').'
2082 2082
             WHERE id_folder = %i',
2083 2083
         $target_id
2084 2084
     );
@@ -2296,7 +2296,7 @@  discard block
 block discarded – undo
2296 2296
     int  $dirPerm = 0755
2297 2297
 ) {
2298 2298
     // Check if the path exists
2299
-    if (! file_exists($path)) {
2299
+    if (!file_exists($path)) {
2300 2300
         return false;
2301 2301
     }
2302 2302
 
@@ -2349,7 +2349,7 @@  discard block
 block discarded – undo
2349 2349
     // Load item data
2350 2350
     $data = DB::queryFirstRow(
2351 2351
         'SELECT id_tree
2352
-        FROM ' . prefixTable('items') . '
2352
+        FROM ' . prefixTable('items').'
2353 2353
         WHERE id = %i',
2354 2354
         $item_id
2355 2355
     );
@@ -2412,7 +2412,7 @@  discard block
 block discarded – undo
2412 2412
         }
2413 2413
         $host .= substr(explode(".", $email[1])[0], -1, 1);
2414 2414
     }
2415
-    $email = $name . "@" . $host . "." . explode(".", $email[1])[1];
2415
+    $email = $name."@".$host.".".explode(".", $email[1])[1];
2416 2416
     return $email;
2417 2417
 }
2418 2418
 
@@ -2434,7 +2434,7 @@  discard block
 block discarded – undo
2434 2434
     loadClasses('DB');
2435 2435
     // Insert log in DB
2436 2436
     return DB::query(
2437
-        'SELECT ' . $fields . '
2437
+        'SELECT '.$fields.'
2438 2438
         FROM ' . prefixTable($table)
2439 2439
     );
2440 2440
 }
@@ -2449,11 +2449,11 @@  discard block
 block discarded – undo
2449 2449
 function formatSizeUnits(int $bytes): string
2450 2450
 {
2451 2451
     if ($bytes >= 1073741824) {
2452
-        $bytes = number_format($bytes / 1073741824, 2) . ' GB';
2452
+        $bytes = number_format($bytes / 1073741824, 2).' GB';
2453 2453
     } elseif ($bytes >= 1048576) {
2454
-        $bytes = number_format($bytes / 1048576, 2) . ' MB';
2454
+        $bytes = number_format($bytes / 1048576, 2).' MB';
2455 2455
     } elseif ($bytes >= 1024) {
2456
-        $bytes = number_format($bytes / 1024, 2) . ' KB';
2456
+        $bytes = number_format($bytes / 1024, 2).' KB';
2457 2457
     } elseif ($bytes > 1) {
2458 2458
         $bytes .= ' bytes';
2459 2459
     } elseif ($bytes === 1) {
@@ -2647,14 +2647,14 @@  discard block
 block discarded – undo
2647 2647
 
2648 2648
     // Encrypt the file content
2649 2649
     $plaintext = file_get_contents(
2650
-        filter_var($fileInPath . '/' . $fileInName, FILTER_SANITIZE_URL)
2650
+        filter_var($fileInPath.'/'.$fileInName, FILTER_SANITIZE_URL)
2651 2651
     );
2652 2652
     $ciphertext = $cipher->encrypt($plaintext);
2653 2653
     // Save new file
2654 2654
     $hash = md5($plaintext);
2655
-    $fileOut = $fileInPath . '/' . TP_FILE_PREFIX . $hash;
2655
+    $fileOut = $fileInPath.'/'.TP_FILE_PREFIX.$hash;
2656 2656
     file_put_contents($fileOut, $ciphertext);
2657
-    unlink($fileInPath . '/' . $fileInName);
2657
+    unlink($fileInPath.'/'.$fileInName);
2658 2658
     return [
2659 2659
         'fileHash' => base64_encode($hash),
2660 2660
         'objectKey' => base64_encode($objectKey),
@@ -2672,7 +2672,7 @@  discard block
 block discarded – undo
2672 2672
  */
2673 2673
 function decryptFile(string $fileName, string $filePath, string $key): string
2674 2674
 {
2675
-    if (! defined('FILE_BUFFER_SIZE')) {
2675
+    if (!defined('FILE_BUFFER_SIZE')) {
2676 2676
         define('FILE_BUFFER_SIZE', 128 * 1024);
2677 2677
     }
2678 2678
 
@@ -2686,7 +2686,7 @@  discard block
 block discarded – undo
2686 2686
     $cipher->enableContinuousBuffer();
2687 2687
     $cipher->disablePadding();
2688 2688
     // Get file content
2689
-    $ciphertext = file_get_contents($filePath . '/' . TP_FILE_PREFIX . $fileName);
2689
+    $ciphertext = file_get_contents($filePath.'/'.TP_FILE_PREFIX.$fileName);
2690 2690
     // Decrypt file content and return
2691 2691
     return base64_encode($cipher->decrypt($ciphertext));
2692 2692
 }
@@ -2767,8 +2767,8 @@  discard block
 block discarded – undo
2767 2767
         // Only create the sharekey for a user
2768 2768
         $user = DB::queryFirstRow(
2769 2769
             'SELECT public_key
2770
-            FROM ' . prefixTable('users') . '
2771
-            WHERE id = ' . (int) $superGlobal->get('user_id', 'SESSION') . '
2770
+            FROM ' . prefixTable('users').'
2771
+            WHERE id = ' . (int) $superGlobal->get('user_id', 'SESSION').'
2772 2772
             AND public_key != ""'
2773 2773
         );
2774 2774
 
@@ -2804,10 +2804,9 @@  discard block
 block discarded – undo
2804 2804
         //DB::debugmode(true);
2805 2805
         $users = DB::query(
2806 2806
             'SELECT id, public_key
2807
-            FROM ' . prefixTable('users') . '
2807
+            FROM ' . prefixTable('users').'
2808 2808
             WHERE ' . ($onlyForUser === true ? 
2809
-                'id IN ("' . TP_USER_ID . '","' . $superGlobal->get('user_id', 'SESSION') . '") ' : 
2810
-                'id NOT IN ("' . OTV_USER_ID . '","' . SSH_USER_ID . '","' . API_USER_ID . '") ') . '
2809
+                'id IN ("'.TP_USER_ID.'","'.$superGlobal->get('user_id', 'SESSION').'") ' : 'id NOT IN ("'.OTV_USER_ID.'","'.SSH_USER_ID.'","'.API_USER_ID.'") ').'
2811 2810
             AND public_key != ""'
2812 2811
         );
2813 2812
         //DB::debugmode(false);
@@ -2854,7 +2853,7 @@  discard block
 block discarded – undo
2854 2853
 function isBase64(string $str): bool
2855 2854
 {
2856 2855
     $str = (string) trim($str);
2857
-    if (! isset($str[0])) {
2856
+    if (!isset($str[0])) {
2858 2857
         return false;
2859 2858
     }
2860 2859
 
@@ -2927,7 +2926,7 @@  discard block
 block discarded – undo
2927 2926
         $connection->connect();
2928 2927
     } catch (\LdapRecord\Auth\BindException $e) {
2929 2928
         $error = $e->getDetailedError();
2930
-        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage(). '<br>'.$error->getDiagnosticMessage();
2929
+        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage().'<br>'.$error->getDiagnosticMessage();
2931 2930
         return false;
2932 2931
     }
2933 2932
 
@@ -2940,7 +2939,7 @@  discard block
 block discarded – undo
2940 2939
         }
2941 2940
     } catch (\LdapRecord\Auth\BindException $e) {
2942 2941
         $error = $e->getDetailedError();
2943
-        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage(). '<br>'.$error->getDiagnosticMessage();
2942
+        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage().'<br>'.$error->getDiagnosticMessage();
2944 2943
         return false;
2945 2944
     }
2946 2945
 
@@ -2964,7 +2963,7 @@  discard block
 block discarded – undo
2964 2963
     // expect if personal item
2965 2964
     DB::delete(
2966 2965
         prefixTable('sharekeys_items'),
2967
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
2966
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
2968 2967
         $userId
2969 2968
     );
2970 2969
     // Remove all item sharekeys files
@@ -2972,8 +2971,8 @@  discard block
 block discarded – undo
2972 2971
         prefixTable('sharekeys_files'),
2973 2972
         'user_id = %i AND object_id NOT IN (
2974 2973
             SELECT f.id 
2975
-            FROM ' . prefixTable('items') . ' AS i 
2976
-            INNER JOIN ' . prefixTable('files') . ' AS f ON f.id_item = i.id
2974
+            FROM ' . prefixTable('items').' AS i 
2975
+            INNER JOIN ' . prefixTable('files').' AS f ON f.id_item = i.id
2977 2976
             WHERE i.perso = 1
2978 2977
         )',
2979 2978
         $userId
@@ -2983,8 +2982,8 @@  discard block
 block discarded – undo
2983 2982
         prefixTable('sharekeys_fields'),
2984 2983
         'user_id = %i AND object_id NOT IN (
2985 2984
             SELECT c.id 
2986
-            FROM ' . prefixTable('items') . ' AS i 
2987
-            INNER JOIN ' . prefixTable('categories_items') . ' AS c ON c.item_id = i.id
2985
+            FROM ' . prefixTable('items').' AS i 
2986
+            INNER JOIN ' . prefixTable('categories_items').' AS c ON c.item_id = i.id
2988 2987
             WHERE i.perso = 1
2989 2988
         )',
2990 2989
         $userId
@@ -2992,13 +2991,13 @@  discard block
 block discarded – undo
2992 2991
     // Remove all item sharekeys logs
2993 2992
     DB::delete(
2994 2993
         prefixTable('sharekeys_logs'),
2995
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
2994
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
2996 2995
         $userId
2997 2996
     );
2998 2997
     // Remove all item sharekeys suggestions
2999 2998
     DB::delete(
3000 2999
         prefixTable('sharekeys_suggestions'),
3001
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
3000
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
3002 3001
         $userId
3003 3002
     );
3004 3003
     return false;
@@ -3019,7 +3018,7 @@  discard block
 block discarded – undo
3019 3018
         foreach (DateTimeZone::listIdentifiers() as $timezone) {
3020 3019
             $now->setTimezone(new DateTimeZone($timezone));
3021 3020
             $offsets[] = $offset = $now->getOffset();
3022
-            $timezones[$timezone] = '(' . format_GMT_offset($offset) . ') ' . format_timezone_name($timezone);
3021
+            $timezones[$timezone] = '('.format_GMT_offset($offset).') '.format_timezone_name($timezone);
3023 3022
         }
3024 3023
 
3025 3024
         array_multisort($offsets, $timezones);
@@ -3039,7 +3038,7 @@  discard block
 block discarded – undo
3039 3038
 {
3040 3039
     $hours = intval($offset / 3600);
3041 3040
     $minutes = abs(intval($offset % 3600 / 60));
3042
-    return 'GMT' . ($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
3041
+    return 'GMT'.($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
3043 3042
 }
3044 3043
 
3045 3044
 /**
@@ -3139,8 +3138,7 @@  discard block
 block discarded – undo
3139 3138
 {
3140 3139
     if (isset($array[$key]) === true
3141 3140
         && (is_int($value) === true ?
3142
-            (int) $array[$key] === $value :
3143
-            (string) $array[$key] === $value)
3141
+            (int) $array[$key] === $value : (string) $array[$key] === $value)
3144 3142
     ) {
3145 3143
         return true;
3146 3144
     }
@@ -3162,8 +3160,7 @@  discard block
 block discarded – undo
3162 3160
 {
3163 3161
     if (isset($var) === false
3164 3162
         || (is_int($value) === true ?
3165
-            (int) $var === $value :
3166
-            (string) $var === $value)
3163
+            (int) $var === $value : (string) $var === $value)
3167 3164
     ) {
3168 3165
         return true;
3169 3166
     }
@@ -3214,7 +3211,7 @@  discard block
 block discarded – undo
3214 3211
  */
3215 3212
 function isSetArrayOfValues(array $arrayOfValues): bool
3216 3213
 {
3217
-    foreach($arrayOfValues as $value) {
3214
+    foreach ($arrayOfValues as $value) {
3218 3215
         if (isset($value) === false) {
3219 3216
             return false;
3220 3217
         }
@@ -3236,7 +3233,7 @@  discard block
 block discarded – undo
3236 3233
     /*PHP8 - integer|string*/$value
3237 3234
 ) : bool
3238 3235
 {
3239
-    foreach($arrayOfVars as $variable) {
3236
+    foreach ($arrayOfVars as $variable) {
3240 3237
         if ($variable !== $value) {
3241 3238
             return false;
3242 3239
         }
@@ -3256,7 +3253,7 @@  discard block
 block discarded – undo
3256 3253
     /*PHP8 - integer|string*/$value
3257 3254
 ) : bool
3258 3255
 {
3259
-    foreach($arrayOfVars as $variable) {
3256
+    foreach ($arrayOfVars as $variable) {
3260 3257
         if ($variable === $value) {
3261 3258
             return true;
3262 3259
         }
@@ -3325,7 +3322,7 @@  discard block
 block discarded – undo
3325 3322
 function dataSanitizer(
3326 3323
     array $data,
3327 3324
     array $filters,
3328
-    string $path = __DIR__. '/..' // Path to Teampass root
3325
+    string $path = __DIR__.'/..' // Path to Teampass root
3329 3326
 )
3330 3327
 {
3331 3328
     // Load Sanitizer library
@@ -3355,7 +3352,7 @@  discard block
 block discarded – undo
3355 3352
     // Exists ?
3356 3353
     $userCacheId = DB::queryfirstrow(
3357 3354
         'SELECT increment_id
3358
-        FROM ' . prefixTable('cache_tree') . '
3355
+        FROM ' . prefixTable('cache_tree').'
3359 3356
         WHERE user_id = %i',
3360 3357
         $user_id
3361 3358
     );
@@ -3404,7 +3401,7 @@  discard block
 block discarded – undo
3404 3401
  */
3405 3402
 function pourcentage(float $nombre, float $total, float $pourcentage): float
3406 3403
 { 
3407
-    $resultat = ($nombre/$total) * $pourcentage;
3404
+    $resultat = ($nombre / $total) * $pourcentage;
3408 3405
     return round($resultat);
3409 3406
 }
3410 3407
 
@@ -3432,7 +3429,7 @@  discard block
 block discarded – undo
3432 3429
 
3433 3430
     // Get last folder update
3434 3431
     $lastFolderChange = DB::queryfirstrow(
3435
-        'SELECT valeur FROM ' . prefixTable('misc') . '
3432
+        'SELECT valeur FROM '.prefixTable('misc').'
3436 3433
         WHERE type = %s AND intitule = %s',
3437 3434
         'timestamp',
3438 3435
         'last_folder_change'
@@ -3462,7 +3459,7 @@  discard block
 block discarded – undo
3462 3459
     // Does this user has a tree cache
3463 3460
     $userCacheTree = DB::queryfirstrow(
3464 3461
         'SELECT '.$fieldName.'
3465
-        FROM ' . prefixTable('cache_tree') . '
3462
+        FROM ' . prefixTable('cache_tree').'
3466 3463
         WHERE user_id = %i',
3467 3464
         $_SESSION['user_id']
3468 3465
     );
@@ -3499,7 +3496,7 @@  discard block
 block discarded – undo
3499 3496
     if (count($folderIds) === 0) {
3500 3497
         $folderIds = DB::queryFirstColumn(
3501 3498
             'SELECT id
3502
-            FROM ' . prefixTable('nested_tree') . '
3499
+            FROM ' . prefixTable('nested_tree').'
3503 3500
             WHERE personal_folder=%i',
3504 3501
             0
3505 3502
         );
@@ -3516,8 +3513,8 @@  discard block
 block discarded – undo
3516 3513
         $rows_tmp = DB::query(
3517 3514
             'SELECT c.id, c.title, c.level, c.type, c.masked, c.order, c.encrypted_data, c.role_visibility, c.is_mandatory,
3518 3515
             f.id_category AS category_id
3519
-            FROM ' . prefixTable('categories_folders') . ' AS f
3520
-            INNER JOIN ' . prefixTable('categories') . ' AS c ON (f.id_category = c.parent_id)
3516
+            FROM ' . prefixTable('categories_folders').' AS f
3517
+            INNER JOIN ' . prefixTable('categories').' AS c ON (f.id_category = c.parent_id)
3521 3518
             WHERE id_folder=%i',
3522 3519
             $folder
3523 3520
         );
@@ -3543,7 +3540,7 @@  discard block
 block discarded – undo
3543 3540
         $valTemp = '';
3544 3541
         $data = DB::queryFirstRow(
3545 3542
             'SELECT valeur
3546
-            FROM ' . prefixTable('misc') . '
3543
+            FROM ' . prefixTable('misc').'
3547 3544
             WHERE type = %s AND intitule=%i',
3548 3545
             'complex',
3549 3546
             $folder
@@ -3560,14 +3557,14 @@  discard block
 block discarded – undo
3560 3557
         $valTemp = '';
3561 3558
         $rows_tmp = DB::query(
3562 3559
             'SELECT t.title
3563
-            FROM ' . prefixTable('roles_values') . ' as v
3564
-            INNER JOIN ' . prefixTable('roles_title') . ' as t ON (v.role_id = t.id)
3560
+            FROM ' . prefixTable('roles_values').' as v
3561
+            INNER JOIN ' . prefixTable('roles_title').' as t ON (v.role_id = t.id)
3565 3562
             WHERE v.folder_id = %i
3566 3563
             GROUP BY title',
3567 3564
             $folder
3568 3565
         );
3569 3566
         foreach ($rows_tmp as $record) {
3570
-            $valTemp .= (empty($valTemp) === true ? '' : ' - ') . $record['title'];
3567
+            $valTemp .= (empty($valTemp) === true ? '' : ' - ').$record['title'];
3571 3568
         }
3572 3569
         $arr_data['visibilityRoles'] = $valTemp;
3573 3570
 
@@ -3599,7 +3596,7 @@  discard block
 block discarded – undo
3599 3596
         // loop on users and check if user has this role
3600 3597
         $rows = DB::query(
3601 3598
             'SELECT id, fonction_id
3602
-            FROM ' . prefixTable('users') . '
3599
+            FROM ' . prefixTable('users').'
3603 3600
             WHERE id != %i AND admin = 0 AND fonction_id IS NOT NULL AND fonction_id != ""',
3604 3601
             $_SESSION['user_id']
3605 3602
         );
@@ -3638,7 +3635,7 @@  discard block
 block discarded – undo
3638 3635
 
3639 3636
     $val = DB::queryfirstrow(
3640 3637
         'SELECT *
3641
-        FROM ' . prefixTable('users') . '
3638
+        FROM ' . prefixTable('users').'
3642 3639
         WHERE id = %i',
3643 3640
         $userId
3644 3641
     );
@@ -3654,12 +3651,12 @@  discard block
 block discarded – undo
3654 3651
 function upgradeRequired(): bool
3655 3652
 {
3656 3653
     // Get settings.php
3657
-    include_once __DIR__. '/../includes/config/settings.php';
3654
+    include_once __DIR__.'/../includes/config/settings.php';
3658 3655
 
3659 3656
     // Get timestamp in DB
3660 3657
     $val = DB::queryfirstrow(
3661 3658
         'SELECT valeur
3662
-        FROM ' . prefixTable('misc') . '
3659
+        FROM ' . prefixTable('misc').'
3663 3660
         WHERE type = %s AND intitule = %s',
3664 3661
         'admin',
3665 3662
         'upgrade_timestamp'
@@ -3712,7 +3709,7 @@  discard block
 block discarded – undo
3712 3709
     // prepapre background tasks for item keys generation        
3713 3710
     $userTP = DB::queryFirstRow(
3714 3711
         'SELECT pw, public_key, private_key
3715
-        FROM ' . prefixTable('users') . '
3712
+        FROM ' . prefixTable('users').'
3716 3713
         WHERE id = %i',
3717 3714
         TP_USER_ID
3718 3715
     );
@@ -3737,7 +3734,7 @@  discard block
 block discarded – undo
3737 3734
         }
3738 3735
 
3739 3736
         // Generate new keys
3740
-        if ($user_self_change === true && empty($recovery_public_key) === false && empty($recovery_private_key) === false){
3737
+        if ($user_self_change === true && empty($recovery_public_key) === false && empty($recovery_private_key) === false) {
3741 3738
             $userKeys = [
3742 3739
                 'public_key' => $recovery_public_key,
3743 3740
                 'private_key_clear' => $recovery_private_key,
@@ -3777,8 +3774,8 @@  discard block
 block discarded – undo
3777 3774
                 'process_type' => 'create_user_keys',
3778 3775
                 'arguments' => json_encode([
3779 3776
                     'new_user_id' => (int) $userId,
3780
-                    'new_user_pwd' => cryption($passwordClear, '','encrypt')['string'],
3781
-                    'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '','encrypt')['string'],
3777
+                    'new_user_pwd' => cryption($passwordClear, '', 'encrypt')['string'],
3778
+                    'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '', 'encrypt')['string'],
3782 3779
                     'owner_id' => (int) TP_USER_ID,
3783 3780
                     'creator_pwd' => $userTP['pw'],
3784 3781
                     'send_email' => $sendEmailToUser === true ? 1 : 0,
@@ -4074,7 +4071,7 @@  discard block
 block discarded – undo
4074 4071
  * @param integer $user_id
4075 4072
  * @return void
4076 4073
  */
4077
-function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id=0)
4074
+function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id = 0)
4078 4075
 {
4079 4076
     if ($allUsers === true) {
4080 4077
         // Load class DB
@@ -4082,7 +4079,7 @@  discard block
 block discarded – undo
4082 4079
 
4083 4080
         $users = DB::query(
4084 4081
             'SELECT id
4085
-            FROM ' . prefixTable('users') . '
4082
+            FROM ' . prefixTable('users').'
4086 4083
             WHERE id NOT IN ('.OTV_USER_ID.', '.TP_USER_ID.', '.SSH_USER_ID.', '.API_USER_ID.')
4087 4084
             ORDER BY login ASC'
4088 4085
         );
@@ -4100,7 +4097,7 @@  discard block
 block discarded – undo
4100 4097
  * @param integer $user_id
4101 4098
  * @return void
4102 4099
  */
4103
-function purgeUnnecessaryKeysForUser(int $user_id=0)
4100
+function purgeUnnecessaryKeysForUser(int $user_id = 0)
4104 4101
 {
4105 4102
     if ($user_id === 0) {
4106 4103
         return;
@@ -4111,8 +4108,8 @@  discard block
 block discarded – undo
4111 4108
 
4112 4109
     $personalItems = DB::queryFirstColumn(
4113 4110
         'SELECT id
4114
-        FROM ' . prefixTable('items') . ' AS i
4115
-        INNER JOIN ' . prefixTable('log_items') . ' AS li ON li.id_item = i.id
4111
+        FROM ' . prefixTable('items').' AS i
4112
+        INNER JOIN ' . prefixTable('log_items').' AS li ON li.id_item = i.id
4116 4113
         WHERE i.perso = 1 AND li.action = "at_creation" AND li.id_user IN (%i, '.TP_USER_ID.')',
4117 4114
         $user_id
4118 4115
     );
@@ -4160,7 +4157,7 @@  discard block
 block discarded – undo
4160 4157
     // Check if user exists
4161 4158
     $userInfo = DB::queryFirstRow(
4162 4159
         'SELECT pw, public_key, private_key, login, name
4163
-        FROM ' . prefixTable('users') . '
4160
+        FROM ' . prefixTable('users').'
4164 4161
         WHERE id = %i',
4165 4162
         $userId
4166 4163
     );
@@ -4170,7 +4167,7 @@  discard block
 block discarded – undo
4170 4167
 
4171 4168
         // Prepare file content
4172 4169
         $export_value = file_get_contents(__DIR__."/../includes/core/teampass_ascii.txt")."\n".
4173
-            "Generation date: ".date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now)."\n\n".
4170
+            "Generation date: ".date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now)."\n\n".
4174 4171
             "RECOVERY KEYS - Not to be shared - To be store safely\n\n".
4175 4172
             "Public Key:\n".$userInfo['public_key']."\n\n".
4176 4173
             "Private Key:\n".decryptPrivateKey($_SESSION['user_pwd'], $userInfo['private_key'])."\n\n";
@@ -4193,7 +4190,7 @@  discard block
 block discarded – undo
4193 4190
         return prepareExchangedData(
4194 4191
             array(
4195 4192
                 'error' => false,
4196
-                'datetime' => date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now),
4193
+                'datetime' => date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now),
4197 4194
                 'timestamp' => $now,
4198 4195
                 'content' => base64_encode($export_value),
4199 4196
                 'login' => $userInfo['login'],
@@ -4219,8 +4216,8 @@  discard block
 block discarded – undo
4219 4216
  */
4220 4217
 function loadClasses(string $className = ''): void
4221 4218
 {
4222
-    require_once __DIR__. '/../includes/config/include.php';
4223
-    require_once __DIR__. '/../includes/config/settings.php';
4219
+    require_once __DIR__.'/../includes/config/include.php';
4220
+    require_once __DIR__.'/../includes/config/settings.php';
4224 4221
     require_once __DIR__.'/../vendor/autoload.php';
4225 4222
 
4226 4223
     if (defined('DB_PASSWD_CLEAR') === false) {
Please login to merge, or discard this patch.
api/Model/Operation.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
                 "error" => '',
39 39
             );
40 40
     
41
-        }catch (Exception $e) {    
41
+        } catch (Exception $e) {    
42 42
             return false;
43 43
         }
44 44
     }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
                 "error" => '',
41 41
             );
42 42
     
43
-        }catch (Exception $e) {    
43
+        } catch (Exception $e) {    
44 44
             return false;
45 45
         }
46 46
     }
Please login to merge, or discard this patch.
api/Model/Database.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
         try {
31 31
             $this->connection = new mysqli(DB_HOST, DB_USER, DB_PASSWD_CLEAR, DB_NAME);
32 32
 
33
-            if ( mysqli_connect_errno()) {
33
+            if (mysqli_connect_errno()) {
34 34
                 throw new Exception("Could not connect to database.");   
35 35
             }
36 36
         } catch (Exception $e) {
@@ -38,38 +38,38 @@  discard block
 block discarded – undo
38 38
         }           
39 39
     }
40 40
  
41
-    public function select($query = "" , $params = [])
41
+    public function select($query = "", $params = [])
42 42
     {
43 43
         try {
44
-            $stmt = $this->executeStatement( $query , $params );
44
+            $stmt = $this->executeStatement($query, $params);
45 45
             $result = $stmt->get_result()->fetch_all(MYSQLI_ASSOC);               
46 46
             $stmt->close();
47 47
  
48 48
             return $result;
49
-        } catch(Exception $e) {
50
-            throw New Exception( $e->getMessage() );
49
+        } catch (Exception $e) {
50
+            throw New Exception($e->getMessage());
51 51
             return false;
52 52
         }
53 53
     }
54 54
  
55
-    private function executeStatement($query = "" , $params = [])
55
+    private function executeStatement($query = "", $params = [])
56 56
     {
57 57
         try {
58
-            $stmt = $this->connection->prepare( $query );
58
+            $stmt = $this->connection->prepare($query);
59 59
  
60
-            if($stmt === false) {
61
-                throw New Exception("Unable to do prepared statement: " . $query);
60
+            if ($stmt === false) {
61
+                throw New Exception("Unable to do prepared statement: ".$query);
62 62
             }
63 63
  
64
-            if( $params ) {
64
+            if ($params) {
65 65
                 $stmt->bind_param($params[0], $params[1]);
66 66
             }
67 67
  
68 68
             $stmt->execute();
69 69
  
70 70
             return $stmt;
71
-        } catch(Exception $e) {
72
-            throw New Exception( $e->getMessage() );
71
+        } catch (Exception $e) {
72
+            throw New Exception($e->getMessage());
73 73
         }   
74 74
     }
75 75
 }
76 76
\ No newline at end of file
Please login to merge, or discard this patch.
api/Model/UserModel.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
  *
22 22
  * @see       https://www.teampass.net
23 23
  */
24
-require_once API_ROOT_PATH . "/Model/Database.php";
24
+require_once API_ROOT_PATH."/Model/Database.php";
25 25
 
26 26
 class UserModel extends Database
27 27
 {
Please login to merge, or discard this patch.
api/Model/AuthModel.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     {
95 95
         require API_ROOT_PATH . '/../includes/config/tp.config.php';
96 96
         $headers = ['alg'=>'HS256','typ'=>'JWT'];
97
-		$payload = [
97
+        $payload = [
98 98
             'username' => $login,
99 99
             'id' => $id, 
100 100
             'exp' => (time() + $SETTINGS['api_token_duration'] + 600),
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
         ];
106 106
 
107 107
         include_once API_ROOT_PATH . '/inc/jwt_utils.php';
108
-		return ['token' => generate_jwt($headers, $payload)];
108
+        return ['token' => generate_jwt($headers, $payload)];
109 109
     }
110 110
 
111 111
     //end createUserJWT
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 Use PasswordLib\PasswordLib;
26 26
 Use TeampassClasses\NestedTree\NestedTree;
27 27
 
28
-require_once API_ROOT_PATH . "/Model/Database.php";
28
+require_once API_ROOT_PATH."/Model/Database.php";
29 29
 
30 30
 
31 31
 class AuthModel extends Database
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     public function getUserAuth(string $login, string $password, string $apikey): array
44 44
     {
45 45
         // Sanitize
46
-        include_once API_ROOT_PATH . '/../sources/main.functions.php';
46
+        include_once API_ROOT_PATH.'/../sources/main.functions.php';
47 47
         $inputData = dataSanitizer(
48 48
             [
49 49
                 'login' => isset($login) === true ? $login : '',
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
                 'password' => 'trim|escape',
56 56
                 'apikey' => 'trim|escape',
57 57
             ],
58
-            API_ROOT_PATH . '/..'
58
+            API_ROOT_PATH.'/..'
59 59
         );
60 60
         if (empty($inputData['login']) === true || empty($inputData['apikey']) === true) {
61 61
             return ["error" => "Login failed0.", "info" => "Empty entry"];
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         // Check apikey
65 65
         if (empty($inputData['password']) === true) {
66 66
             // case where it is a generic key
67
-            $apiInfo = $this->select("SELECT count(*) FROM " . prefixTable('api') . " WHERE value='".$inputData['apikey']."' AND label='".$inputData['login']."'");
67
+            $apiInfo = $this->select("SELECT count(*) FROM ".prefixTable('api')." WHERE value='".$inputData['apikey']."' AND label='".$inputData['login']."'");
68 68
             if ((int) $apiInfo[0]['count(*)'] === 0) {
69 69
                 return ["error" => "Login failed1.", "info" => "apikey : Not valid"];
70 70
             }
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
             // Check if user exists
76 76
             $userInfoRes = $this->select(
77 77
                 "SELECT u.id, u.pw, u.public_key, u.private_key, u.personal_folder, u.fonction_id, u.groupes_visibles, u.groupes_interdits, a.value AS user_api_key
78
-                FROM " . prefixTable('users') . " AS u
79
-                INNER JOIN " . prefixTable('api') . " AS a ON (a.user_id=u.id)
78
+                FROM " . prefixTable('users')." AS u
79
+                INNER JOIN " . prefixTable('api')." AS a ON (a.user_id=u.id)
80 80
                 WHERE login='".$inputData['login']."'");
81 81
             if (count($userInfoRes) === 0) {
82 82
                 return ["error" => "Login failed3.", "info" => "apikey : Not valid"];
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
      */
130 130
     private function createUserJWT(int $id, string $login, int $pf_enabled, string $pubkey, string $privkey, string $folders, string $items): array
131 131
     {
132
-        require API_ROOT_PATH . '/../includes/config/tp.config.php';
133
-        $headers = ['alg'=>'HS256','typ'=>'JWT'];
132
+        require API_ROOT_PATH.'/../includes/config/tp.config.php';
133
+        $headers = ['alg'=>'HS256', 'typ'=>'JWT'];
134 134
 		$payload = [
135 135
             'username' => $login,
136 136
             'id' => $id, 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
             'restricted_items_list' => $items,
143 143
         ];
144 144
 
145
-        include_once API_ROOT_PATH . '/inc/jwt_utils.php';
145
+        include_once API_ROOT_PATH.'/inc/jwt_utils.php';
146 146
 		return ['token' => generate_jwt($headers, $payload)];
147 147
     }
148 148
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 
175 175
         // Get folders from the roles
176 176
         if (empty($userFunctionId) === false) {
177
-            $rows = $this->select("SELECT * FROM " . prefixTable('roles_values') . " WHERE role_id IN (".$userFunctionId.") AND type IN ('W', 'ND', 'NE', 'NDNE', 'R')");
177
+            $rows = $this->select("SELECT * FROM ".prefixTable('roles_values')." WHERE role_id IN (".$userFunctionId.") AND type IN ('W', 'ND', 'NE', 'NDNE', 'R')");
178 178
             foreach ($rows as $record) {
179 179
                 if ($record['type'] === 'R') {
180 180
                     array_push($readOnlyFolders, $record['folder_id']);
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
         
196 196
         // Does this user is allowed to see other items
197 197
         $inc = 0;
198
-        $rows = $this->select("SELECT id, id_tree FROM " . prefixTable('items') . " WHERE restricted_to LIKE '".$userInfo['id']."'".
198
+        $rows = $this->select("SELECT id, id_tree FROM ".prefixTable('items')." WHERE restricted_to LIKE '".$userInfo['id']."'".
199 199
             (empty($userFunctionId) === false ? ' AND id_tree NOT IN ('.$userFunctionId.')' : ''));
200 200
         foreach ($rows as $record) {
201 201
             // Exclude restriction on item if folder is fully accessible
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 
206 206
         // Check for the users roles if some specific rights exist on items
207 207
         $rows = $this->select("SELECT i.id_tree, r.item_id
208
-            FROM " . prefixTable('items') . " as i
209
-            INNER JOIN " . prefixTable('restriction_to_roles') . " as r ON (r.item_id=i.id)
208
+            FROM " . prefixTable('items')." as i
209
+            INNER JOIN " . prefixTable('restriction_to_roles')." as r ON (r.item_id=i.id)
210 210
             WHERE ".(empty($userFunctionId) === false ? ' id_tree NOT IN ('.$userFunctionId.') AND ' : '')." i.id_tree != ''
211 211
             ORDER BY i.id_tree ASC");
212 212
         foreach ($rows as $record) {
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
         // Add all personal folders
221 221
         $rows = $this->select(
222 222
             'SELECT id
223
-            FROM ' . prefixTable('nested_tree') . '
223
+            FROM ' . prefixTable('nested_tree').'
224 224
             WHERE title = '.$userInfo['id'].' AND personal_folder = 1'.
225 225
             (empty($userFunctionId) === false ? ' AND id NOT IN ('.$userFunctionId.')' : '').
226 226
             ' LIMIT 0,1'
Please login to merge, or discard this patch.
api/Model/FolderModel.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         $ret = [];
35 35
 
36 36
         foreach ($rows as $row) {
37
-			$isVisible = in_array((int) $row['id'], $foldersId);
37
+            $isVisible = in_array((int) $row['id'], $foldersId);
38 38
             $childrens = $this->getFoldersChildren($row['id'], $foldersId);
39 39
 
40 40
             if ($isVisible || count($childrens) > 0) {
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
                     [
44 44
                         'id' => (int) $row['id'],
45 45
                         'title' => $row['title'],
46
-						'isVisible' => $isVisible,
46
+                        'isVisible' => $isVisible,
47 47
                         'childrens' => $childrens
48 48
                     ]
49 49
                 );
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 
64 64
         if ( count($childrens) > 0) {
65 65
             foreach ($childrens as $children) {
66
-				$isVisible = in_array((int) $children['id'], $foldersId);
66
+                $isVisible = in_array((int) $children['id'], $foldersId);
67 67
                 $childs = $this->getFoldersChildren($children['id'], $foldersId);
68 68
 
69 69
                 if (in_array((int) $children['id'], $foldersId) || count($childs) > 0) {
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                         [
73 73
                             'id' => (int) $children['id'],
74 74
                             'title' => $children['title'],
75
-							'isVisible' => $isVisible,
75
+                            'isVisible' => $isVisible,
76 76
                             'childrens' => $childs
77 77
                         ]
78 78
                     );
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
  *
23 23
  * @see       https://www.teampass.net
24 24
  */
25
-require_once API_ROOT_PATH . "/Model/Database.php";
25
+require_once API_ROOT_PATH."/Model/Database.php";
26 26
  
27 27
 class FolderModel extends Database
28 28
 {
29 29
     public function getFoldersInfo(array $foldersId): array
30 30
     {
31
-        $rows = $this->select( "SELECT id, title FROM " . prefixTable('nested_tree') . " WHERE nlevel=1" );
31
+        $rows = $this->select("SELECT id, title FROM ".prefixTable('nested_tree')." WHERE nlevel=1");
32 32
 
33 33
         $ret = [];
34 34
 
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
     private function getFoldersChildren(int $parentId, array $foldersId): array
56 56
     {
57 57
         $ret = [];
58
-        $childrens = $this->select('SELECT id, title FROM ' . prefixTable('nested_tree') . ' WHERE parent_id=' . $parentId);
58
+        $childrens = $this->select('SELECT id, title FROM '.prefixTable('nested_tree').' WHERE parent_id='.$parentId);
59 59
 
60
-        if ( count($childrens) > 0) {
60
+        if (count($childrens) > 0) {
61 61
             foreach ($childrens as $children) {
62 62
 				$isVisible = in_array((int) $children['id'], $foldersId);
63 63
                 $childs = $this->getFoldersChildren($children['id'], $foldersId);
Please login to merge, or discard this patch.
api/Controller/Api/ItemController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             // SQL where clause with folders list
53 53
             if (isset($arrQueryStringParams['folders']) === true) {
54 54
                 // convert the folders to an array
55
-                $arrQueryStringParams['folders'] = explode(',', str_replace( array('[',']') , ''  , $arrQueryStringParams['folders']));
55
+                $arrQueryStringParams['folders'] = explode(',', str_replace(array('[', ']'), '', $arrQueryStringParams['folders']));
56 56
 
57 57
                 // ensure to only use the intersection
58 58
                 $foldersList = implode(',', array_intersect($arrQueryStringParams['folders'], $userData['folders_list']));
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
             // SQL where clause with item id
127 127
             if (isset($arrQueryStringParams['id']) === true) {
128 128
                 // build sql where clause by ID
129
-                $sqlExtra = ' WHERE i.id = '.$arrQueryStringParams['id'] . $sql_constraint;
129
+                $sqlExtra = ' WHERE i.id = '.$arrQueryStringParams['id'].$sql_constraint;
130 130
             } else if (isset($arrQueryStringParams['label']) === true) {
131 131
                 // build sql where clause by LABEL
132
-                $sqlExtra = ' WHERE i.label '.(isset($arrQueryStringParams['like']) === true && (int) $arrQueryStringParams['like'] === 1 ? ' LIKE '.$arrQueryStringParams['label'] : ' = '.$arrQueryStringParams['label']) . $sql_constraint;
132
+                $sqlExtra = ' WHERE i.label '.(isset($arrQueryStringParams['like']) === true && (int) $arrQueryStringParams['like'] === 1 ? ' LIKE '.$arrQueryStringParams['label'] : ' = '.$arrQueryStringParams['label']).$sql_constraint;
133 133
             } else if (isset($arrQueryStringParams['description']) === true) {
134 134
                 // build sql where clause by LABEL
135 135
                 $sqlExtra = ' WHERE i.description '.(isset($arrQueryStringParams['like']) === true && (int) $arrQueryStringParams['like'] === 1 ? ' LIKE '.$arrQueryStringParams['description'] : ' = '.$arrQueryStringParams['description']).$sql_constraint;
Please login to merge, or discard this patch.