Passed
Pull Request — master (#4822)
by Nils
06:23
created
sources/identify.php 1 patch
Spacing   +41 added lines, -42 removed lines patch added patch discarded remove patch
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
         return $dataReceived;
475 475
     }
476 476
 
477
-    private function handleDuoAuthentication(array $dataReceived): array|false
477
+    private function handleDuoAuthentication(array $dataReceived): array | false
478 478
     {
479 479
         if (!$this->isDuoAuthInProgress($dataReceived)) {
480 480
             return $dataReceived;
@@ -646,8 +646,7 @@  discard block
 block discarded – undo
646 646
         }
647 647
 
648 648
         // Setup API key
649
-        $apiKey = empty($userInfo['api_key']) ? '' : 
650
-            base64_decode(decryptUserObjectKey($userInfo['api_key'], $returnKeys['private_key_clear']));
649
+        $apiKey = empty($userInfo['api_key']) ? '' : base64_decode(decryptUserObjectKey($userInfo['api_key'], $returnKeys['private_key_clear']));
651 650
         $this->session->set('user-api_key', $apiKey);
652 651
     }
653 652
 
@@ -668,7 +667,7 @@  discard block
 block discarded – undo
668 667
         if (!is_null($userInfo['roles_from_ad_groups'])) {
669 668
             $userInfo['fonction_id'] = empty($userInfo['fonction_id']) 
670 669
                 ? $userInfo['roles_from_ad_groups'] 
671
-                : $userInfo['fonction_id'] . ';' . $userInfo['roles_from_ad_groups'];
670
+                : $userInfo['fonction_id'].';'.$userInfo['roles_from_ad_groups'];
672 671
         }
673 672
 
674 673
         $this->session->set('user-roles', $userInfo['fonction_id']);
@@ -688,7 +687,7 @@  discard block
 block discarded – undo
688 687
         }
689 688
 
690 689
         $rolesList = DB::query(
691
-            'SELECT id, title, complexity FROM ' . prefixTable('roles_title') . ' WHERE id IN %li',
690
+            'SELECT id, title, complexity FROM '.prefixTable('roles_title').' WHERE id IN %li',
692 691
             $this->session->get('user-roles_array')
693 692
         );
694 693
 
@@ -842,7 +841,7 @@  discard block
 block discarded – undo
842 841
     private function setupUserCache(array $userInfo): void
843 842
     {
844 843
         $cacheTreeData = DB::queryFirstRow(
845
-            'SELECT visible_folders FROM ' . prefixTable('cache_tree') . ' WHERE user_id=%i',
844
+            'SELECT visible_folders FROM '.prefixTable('cache_tree').' WHERE user_id=%i',
846 845
             (int) $this->session->get('user-id')
847 846
         );
848 847
 
@@ -873,7 +872,7 @@  discard block
 block discarded – undo
873 872
         foreach ($this->session->get('user-latest_items') as $item) {
874 873
             if (!empty($item)) {
875 874
                 $dataLastItems = DB::queryFirstRow(
876
-                    'SELECT id,label,id_tree FROM ' . prefixTable('items') . ' WHERE id=%i',
875
+                    'SELECT id,label,id_tree FROM '.prefixTable('items').' WHERE id=%i',
877 876
                     $item
878 877
                 );
879 878
                 
@@ -882,7 +881,7 @@  discard block
 block discarded – undo
882 881
                     [
883 882
                         'id' => $item,
884 883
                         'label' => $dataLastItems['label'],
885
-                        'url' => 'index.php?page=items&group=' . $dataLastItems['id_tree'] . '&id=' . $item,
884
+                        'url' => 'index.php?page=items&group='.$dataLastItems['id_tree'].'&id='.$item,
886 885
                     ],
887 886
                     'add'
888 887
                 );
@@ -898,7 +897,7 @@  discard block
 block discarded – undo
898 897
         }
899 898
 
900 899
         $adminUser = DB::queryFirstRow(
901
-            'SELECT email FROM ' . prefixTable('users') . " WHERE admin = %i and email != ''", 
900
+            'SELECT email FROM '.prefixTable('users')." WHERE admin = %i and email != ''", 
902 901
             1
903 902
         );
904 903
         
@@ -911,7 +910,7 @@  discard block
 block discarded – undo
911 910
             str_replace(
912 911
                 ['#tp_user#', '#tp_date#', '#tp_time#'],
913 912
                 [
914
-                    ' ' . $this->session->get('user-login') . ' (IP: ' . getClientIpServer() . ')',
913
+                    ' '.$this->session->get('user-login').' (IP: '.getClientIpServer().')',
915 914
                     date($this->settings['date_format'], (int) $this->session->get('user-last_connection')),
916 915
                     date($this->settings['time_format'], (int) $this->session->get('user-last_connection')),
917 916
                 ],
@@ -1059,7 +1058,7 @@  discard block
 block discarded – undo
1059 1058
 {
1060 1059
     $rows = DB::query(
1061 1060
         'SELECT date
1062
-        FROM ' . prefixTable('log_system') . "
1061
+        FROM ' . prefixTable('log_system')."
1063 1062
         WHERE field_1 = %s
1064 1063
         AND type = 'failed_auth'
1065 1064
         AND label = 'password_is_not_correct'
@@ -1073,7 +1072,7 @@  discard block
 block discarded – undo
1073 1072
         foreach ($rows as $record) {
1074 1073
             array_push(
1075 1074
                 $arrAttempts,
1076
-                date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['date'])
1075
+                date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['date'])
1077 1076
             );
1078 1077
         }
1079 1078
     }
@@ -1108,7 +1107,7 @@  discard block
 block discarded – undo
1108 1107
     $ldapConnection
1109 1108
 ) : bool
1110 1109
 {
1111
-    include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
1110
+    include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
1112 1111
 
1113 1112
     if ((int) $userInfoDisabled === 1) {
1114 1113
         return false;
@@ -1303,7 +1302,7 @@  discard block
 block discarded – undo
1303 1302
     } catch (Exception $e) {
1304 1303
         return [
1305 1304
             'error' => true,
1306
-            'message' => "Error: " . $e->getMessage(),
1305
+            'message' => "Error: ".$e->getMessage(),
1307 1306
         ];
1308 1307
     }
1309 1308
 }
@@ -1334,7 +1333,7 @@  discard block
 block discarded – undo
1334 1333
                 'type' => 'OpenLDAP'
1335 1334
             ];
1336 1335
         default:
1337
-            throw new Exception("Unsupported LDAP type: " . $SETTINGS['ldap_type']);
1336
+            throw new Exception("Unsupported LDAP type: ".$SETTINGS['ldap_type']);
1338 1337
     }
1339 1338
 }
1340 1339
 
@@ -1471,7 +1470,7 @@  discard block
 block discarded – undo
1471 1470
         );
1472 1471
     }
1473 1472
     
1474
-    throw new Exception("Unsupported LDAP type: " . $ldapHandler['type']);
1473
+    throw new Exception("Unsupported LDAP type: ".$ldapHandler['type']);
1475 1474
 }
1476 1475
 
1477 1476
 /**
@@ -1488,12 +1487,12 @@  discard block
 block discarded – undo
1488 1487
     if (isset($SETTINGS['enable_ad_users_with_ad_groups']) === true && (int) $SETTINGS['enable_ad_users_with_ad_groups'] === 1) {
1489 1488
         // Get user groups from AD
1490 1489
         $user_ad_groups = [];
1491
-        foreach($groups as $group) {
1490
+        foreach ($groups as $group) {
1492 1491
             //print_r($group);
1493 1492
             // get relation role id for AD group
1494 1493
             $role = DB::queryFirstRow(
1495 1494
                 'SELECT lgr.role_id
1496
-                FROM ' . prefixTable('ldap_groups_roles') . ' AS lgr
1495
+                FROM ' . prefixTable('ldap_groups_roles').' AS lgr
1497 1496
                 WHERE lgr.ldap_group_id = %s',
1498 1497
                 $group
1499 1498
             );
@@ -1624,7 +1623,7 @@  discard block
 block discarded – undo
1624 1623
             // Check if exists in DB
1625 1624
             $groupData = DB::queryFirstRow(
1626 1625
                 'SELECT id
1627
-                FROM ' . prefixTable('roles_title') . '
1626
+                FROM ' . prefixTable('roles_title').'
1628 1627
                 WHERE title = %s',
1629 1628
                 $group["displayName"]
1630 1629
             );
@@ -1765,7 +1764,7 @@  discard block
 block discarded – undo
1765 1764
             
1766 1765
             // generate new QR
1767 1766
             $new_2fa_qr = $tfa->getQRCodeImageAsDataUri(
1768
-                'Teampass - ' . $username,
1767
+                'Teampass - '.$username,
1769 1768
                 $userInfo['ga']
1770 1769
             );
1771 1770
             // clear temporary code from DB
@@ -1778,7 +1777,7 @@  discard block
 block discarded – undo
1778 1777
                 $userInfo['id']
1779 1778
             );
1780 1779
             $firstTime = [
1781
-                'value' => '<img src="' . $new_2fa_qr . '">',
1780
+                'value' => '<img src="'.$new_2fa_qr.'">',
1782 1781
                 'user_admin' => isset($sessionAdmin) ? (int) $sessionAdmin : '',
1783 1782
                 'initial_url' => isset($sessionUrl) === true ? $sessionUrl : '',
1784 1783
                 'pwd_attempts' => (int) $sessionPwdAttempts,
@@ -1934,7 +1933,7 @@  discard block
 block discarded – undo
1934 1933
         }*/
1935 1934
         return [
1936 1935
             'error' => true,
1937
-            'message' => $duo_error . $lang->get('duo_error_check_config'),
1936
+            'message' => $duo_error.$lang->get('duo_error_check_config'),
1938 1937
             'pwd_attempts' => (int) $sessionPwdAttempts,
1939 1938
             'debug_message' => $e->getMessage(),
1940 1939
             'proceedIdentification' => false,
@@ -1950,7 +1949,7 @@  discard block
 block discarded – undo
1950 1949
         } catch (DuoException $e) {
1951 1950
             return [
1952 1951
                 'error' => true,
1953
-                'message' => $duo_error . $lang->get('duo_error_url'),
1952
+                'message' => $duo_error.$lang->get('duo_error_url'),
1954 1953
                 'pwd_attempts' => (int) $sessionPwdAttempts,
1955 1954
                 'debug_message' => $e->getMessage(),
1956 1955
                 'proceedIdentification' => false,
@@ -1958,7 +1957,7 @@  discard block
 block discarded – undo
1958 1957
         }
1959 1958
         
1960 1959
         // Somethimes Duo return success but fail to return a URL, double check if the URL has been created
1961
-        if (!empty($duo_redirect_url) && filter_var($duo_redirect_url,FILTER_SANITIZE_URL)) {
1960
+        if (!empty($duo_redirect_url) && filter_var($duo_redirect_url, FILTER_SANITIZE_URL)) {
1962 1961
             // Since Duo Universal requires a redirect, let's store some info when the user get's back after completing the Duo prompt
1963 1962
             $key = hash('sha256', $duo_state);
1964 1963
             $iv = substr(hash('sha256', $duo_state), 0, 16);
@@ -1986,7 +1985,7 @@  discard block
 block discarded – undo
1986 1985
         } else {
1987 1986
             return [
1988 1987
                 'error' => true,
1989
-                'message' => $duo_error . $lang->get('duo_error_url'),
1988
+                'message' => $duo_error.$lang->get('duo_error_url'),
1990 1989
                 'pwd_attempts' => (int) $sessionPwdAttempts,
1991 1990
                 'proceedIdentification' => false,
1992 1991
             ];
@@ -2007,8 +2006,8 @@  discard block
 block discarded – undo
2007 2006
         // return the response (which should be the user name)
2008 2007
         if ($decoded_token['preferred_username'] === $username) {
2009 2008
             $session->set('user-duo_status', 'COMPLET');
2010
-            $session->set('user-duo_state','');
2011
-            $session->set('user-duo_data','');
2009
+            $session->set('user-duo_state', '');
2010
+            $session->set('user-duo_data', '');
2012 2011
             $session->set('user-login', $username);
2013 2012
 
2014 2013
             return [
@@ -2019,9 +2018,9 @@  discard block
 block discarded – undo
2019 2018
             ];
2020 2019
         } else {
2021 2020
             // Something wrong, username from the original Duo request is different than the one received now
2022
-            $session->set('user-duo_status','');
2023
-            $session->set('user-duo_state','');
2024
-            $session->set('user-duo_data','');
2021
+            $session->set('user-duo_status', '');
2022
+            $session->set('user-duo_state', '');
2023
+            $session->set('user-duo_data', '');
2025 2024
 
2026 2025
             return [
2027 2026
                 'error' => true,
@@ -2032,9 +2031,9 @@  discard block
 block discarded – undo
2032 2031
         }
2033 2032
     }
2034 2033
     // If we are here something wrong
2035
-    $session->set('user-duo_status','');
2036
-    $session->set('user-duo_state','');
2037
-    $session->set('user-duo_data','');
2034
+    $session->set('user-duo_status', '');
2035
+    $session->set('user-duo_state', '');
2036
+    $session->set('user-duo_data', '');
2038 2037
     return [
2039 2038
         'error' => true,
2040 2039
         'message' => $lang->get('duo_login_mismatch'),
@@ -2146,7 +2145,7 @@  discard block
 block discarded – undo
2146 2145
         // Check for existing lock
2147 2146
         $unlock_at = DB::queryFirstField(
2148 2147
             'SELECT MAX(unlock_at)
2149
-             FROM ' . prefixTable('auth_failures') . '
2148
+             FROM ' . prefixTable('auth_failures').'
2150 2149
              WHERE unlock_at > %s
2151 2150
              AND ((source = %s AND value = %s) OR (source = %s AND value = %s))',
2152 2151
             date('Y-m-d H:i:s', time()),
@@ -2168,8 +2167,8 @@  discard block
 block discarded – undo
2168 2167
         // Get user info from DB
2169 2168
         $data = DB::queryFirstRow(
2170 2169
             'SELECT u.*, a.value AS api_key
2171
-            FROM ' . prefixTable('users') . ' AS u
2172
-            LEFT JOIN ' . prefixTable('api') . ' AS a ON (u.id = a.user_id)
2170
+            FROM ' . prefixTable('users').' AS u
2171
+            LEFT JOIN ' . prefixTable('api').' AS a ON (u.id = a.user_id)
2173 2172
             WHERE login = %s AND deleted_at IS NULL',
2174 2173
             $login
2175 2174
         );
@@ -2287,7 +2286,7 @@  discard block
 block discarded – undo
2287 2286
             'array' => [
2288 2287
                 'value' => 'bruteforce_wait',
2289 2288
                 'error' => true,
2290
-                'message' => $lang->get('bruteforce_wait') . (string) $e->getMessage(),
2289
+                'message' => $lang->get('bruteforce_wait').(string) $e->getMessage(),
2291 2290
             ]
2292 2291
         ];
2293 2292
     }
@@ -2824,15 +2823,15 @@  discard block
 block discarded – undo
2824 2823
 
2825 2824
             if ($ret['error'] !== false) {
2826 2825
                 logEvents($SETTINGS, 'failed_auth', 'bad_duo_mfa', '', stripslashes($username), stripslashes($username));
2827
-                $session->set('user-duo_status','');
2828
-                $session->set('user-duo_state','');
2829
-                $session->set('user-duo_data','');
2826
+                $session->set('user-duo_status', '');
2827
+                $session->set('user-duo_state', '');
2828
+                $session->set('user-duo_data', '');
2830 2829
                 return [
2831 2830
                     'error' => true,
2832 2831
                     'mfaData' => $ret,
2833 2832
                     'mfaQRCodeInfos' => false,
2834 2833
                 ];
2835
-            } else if ($ret['duo_url_ready'] === true){
2834
+            } else if ($ret['duo_url_ready'] === true) {
2836 2835
                 return [
2837 2836
                     'error' => false,
2838 2837
                     'mfaData' => $ret,
@@ -2896,7 +2895,7 @@  discard block
 block discarded – undo
2896 2895
     // Count failed attempts from this source
2897 2896
     $count = DB::queryFirstField(
2898 2897
         'SELECT COUNT(*)
2899
-        FROM ' . prefixTable('auth_failures') . '
2898
+        FROM ' . prefixTable('auth_failures').'
2900 2899
         WHERE source = %s AND value = %s',
2901 2900
         $source,
2902 2901
         $value
Please login to merge, or discard this patch.
sources/main.functions.php 1 patch
Spacing   +163 added lines, -165 removed lines patch added patch discarded remove patch
@@ -129,19 +129,19 @@  discard block
 block discarded – undo
129 129
             $text = Crypto::decrypt($message, $key);
130 130
         }
131 131
     } catch (CryptoException\WrongKeyOrModifiedCiphertextException $ex) {
132
-        error_log('TEAMPASS-Error-Wrong key or modified ciphertext: ' . $ex->getMessage());
132
+        error_log('TEAMPASS-Error-Wrong key or modified ciphertext: '.$ex->getMessage());
133 133
         $err = 'wrong_key_or_modified_ciphertext';
134 134
     } catch (CryptoException\BadFormatException $ex) {
135
-        error_log('TEAMPASS-Error-Bad format exception: ' . $ex->getMessage());
135
+        error_log('TEAMPASS-Error-Bad format exception: '.$ex->getMessage());
136 136
         $err = 'bad_format';
137 137
     } catch (CryptoException\EnvironmentIsBrokenException $ex) {
138
-        error_log('TEAMPASS-Error-Environment: ' . $ex->getMessage());
138
+        error_log('TEAMPASS-Error-Environment: '.$ex->getMessage());
139 139
         $err = 'environment_error';
140 140
     } catch (CryptoException\IOException $ex) {
141
-        error_log('TEAMPASS-Error-IO: ' . $ex->getMessage());
141
+        error_log('TEAMPASS-Error-IO: '.$ex->getMessage());
142 142
         $err = 'io_error';
143 143
     } catch (Exception $ex) {
144
-        error_log('TEAMPASS-Error-Unexpected exception: ' . $ex->getMessage());
144
+        error_log('TEAMPASS-Error-Unexpected exception: '.$ex->getMessage());
145 145
         $err = 'unexpected_error';
146 146
     }
147 147
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
  */
227 227
 function trimElement($chaine, string $element): string
228 228
 {
229
-    if (! empty($chaine)) {
229
+    if (!empty($chaine)) {
230 230
         if (is_array($chaine) === true) {
231 231
             $chaine = implode(';', $chaine);
232 232
         }
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
  */
275 275
 function db_error_handler(array $params): void
276 276
 {
277
-    echo 'Error: ' . $params['error'] . "<br>\n";
278
-    echo 'Query: ' . $params['query'] . "<br>\n";
277
+    echo 'Error: '.$params['error']."<br>\n";
278
+    echo 'Query: '.$params['query']."<br>\n";
279 279
     throw new Exception('Error - Query', 1);
280 280
 }
281 281
 
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
     $session->set('user-forbiden_personal_folders', []);
354 354
     
355 355
     // Get list of Folders
356
-    $rows = DB::query('SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i', 0);
356
+    $rows = DB::query('SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i', 0);
357 357
     foreach ($rows as $record) {
358 358
         array_push($groupesVisibles, $record['id']);
359 359
     }
@@ -363,20 +363,20 @@  discard block
 block discarded – undo
363 363
     // get complete list of ROLES
364 364
     $tmp = explode(';', $idFonctions);
365 365
     $rows = DB::query(
366
-        'SELECT * FROM ' . prefixTable('roles_title') . '
366
+        'SELECT * FROM '.prefixTable('roles_title').'
367 367
         ORDER BY title ASC'
368 368
     );
369 369
     foreach ($rows as $record) {
370
-        if (! empty($record['id']) && ! in_array($record['id'], $tmp)) {
370
+        if (!empty($record['id']) && !in_array($record['id'], $tmp)) {
371 371
             array_push($tmp, $record['id']);
372 372
         }
373 373
     }
374 374
     $session->set('user-roles', implode(';', $tmp));
375 375
     $session->set('user-admin', 1);
376 376
     // Check if admin has created Folders and Roles
377
-    DB::query('SELECT * FROM ' . prefixTable('nested_tree') . '');
377
+    DB::query('SELECT * FROM '.prefixTable('nested_tree').'');
378 378
     $session->set('user-nb_folders', DB::count());
379
-    DB::query('SELECT * FROM ' . prefixTable('roles_title'));
379
+    DB::query('SELECT * FROM '.prefixTable('roles_title'));
380 380
     $session->set('user-nb_roles', DB::count());
381 381
 
382 382
     return true;
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
     // Does this user is allowed to see other items
460 460
     $inc = 0;
461 461
     $rows = DB::query(
462
-        'SELECT id, id_tree FROM ' . prefixTable('items') . '
462
+        'SELECT id, id_tree FROM '.prefixTable('items').'
463 463
             WHERE restricted_to LIKE %ss AND inactif = %s'.
464 464
             (count($allowedFolders) > 0 ? ' AND id_tree NOT IN ('.implode(',', $allowedFolders).')' : ''),
465 465
         $globalsUserId,
@@ -476,8 +476,8 @@  discard block
 block discarded – undo
476 476
     // Check for the users roles if some specific rights exist on items
477 477
     $rows = DB::query(
478 478
         'SELECT i.id_tree, r.item_id
479
-        FROM ' . prefixTable('items') . ' as i
480
-        INNER JOIN ' . prefixTable('restriction_to_roles') . ' as r ON (r.item_id=i.id)
479
+        FROM ' . prefixTable('items').' as i
480
+        INNER JOIN ' . prefixTable('restriction_to_roles').' as r ON (r.item_id=i.id)
481 481
         WHERE i.id_tree <> "" '.
482 482
         (count($userRoles) > 0 ? 'AND r.role_id IN %li ' : '').
483 483
         'ORDER BY i.id_tree ASC',
@@ -531,18 +531,18 @@  discard block
 block discarded – undo
531 531
         ), SORT_NUMERIC)
532 532
     );
533 533
     // Folders and Roles numbers
534
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('nested_tree') . '');
535
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('nested_tree') . '');
534
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('nested_tree').'');
535
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('nested_tree').'');
536 536
     $session->set('user-nb_folders', DB::count());
537
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('roles_title'));
538
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('roles_title'));
537
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('roles_title'));
538
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('roles_title'));
539 539
     $session->set('user-nb_roles', DB::count());
540 540
     // check if change proposals on User's items
541 541
     if (isset($SETTINGS['enable_suggestion']) === true && (int) $SETTINGS['enable_suggestion'] === 1) {
542 542
         $countNewItems = DB::query(
543 543
             'SELECT COUNT(*)
544
-            FROM ' . prefixTable('items_change') . ' AS c
545
-            LEFT JOIN ' . prefixTable('log_items') . ' AS i ON (c.item_id = i.id_item)
544
+            FROM ' . prefixTable('items_change').' AS c
545
+            LEFT JOIN ' . prefixTable('log_items').' AS i ON (c.item_id = i.id_item)
546 546
             WHERE i.action = %s AND i.id_user = %i',
547 547
             'at_creation',
548 548
             $globalsUserId
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 {
570 570
     $rows = DB::query(
571 571
         'SELECT *
572
-        FROM ' . prefixTable('roles_values') . '
572
+        FROM ' . prefixTable('roles_values').'
573 573
         WHERE type IN %ls'.(count($userRoles) > 0 ? ' AND role_id IN %li' : ''),
574 574
         ['W', 'ND', 'NE', 'NDNE', 'R'],
575 575
         $userRoles,
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
     ) {
637 637
         $persoFld = DB::queryFirstRow(
638 638
             'SELECT id
639
-            FROM ' . prefixTable('nested_tree') . '
639
+            FROM ' . prefixTable('nested_tree').'
640 640
             WHERE title = %s AND personal_folder = %i'.
641 641
             (count($allowedFolders) > 0 ? ' AND id NOT IN ('.implode(',', $allowedFolders).')' : ''),
642 642
             $globalsUserId,
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
     }
670 670
     $persoFlds = DB::query(
671 671
         'SELECT id
672
-        FROM ' . prefixTable('nested_tree') . '
672
+        FROM ' . prefixTable('nested_tree').'
673 673
         WHERE %l',
674 674
         $where
675 675
     );
@@ -737,12 +737,12 @@  discard block
 block discarded – undo
737 737
     //Load Tree
738 738
     $tree = new NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title');
739 739
     // truncate table
740
-    DB::query('TRUNCATE TABLE ' . prefixTable('cache'));
740
+    DB::query('TRUNCATE TABLE '.prefixTable('cache'));
741 741
     // reload date
742 742
     $rows = DB::query(
743 743
         'SELECT *
744
-        FROM ' . prefixTable('items') . ' as i
745
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
744
+        FROM ' . prefixTable('items').' as i
745
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
746 746
         AND l.action = %s
747 747
         AND i.inactif = %i',
748 748
         'at_creation',
@@ -754,18 +754,18 @@  discard block
 block discarded – undo
754 754
             $tags = '';
755 755
             $itemTags = DB::query(
756 756
                 'SELECT tag
757
-                FROM ' . prefixTable('tags') . '
757
+                FROM ' . prefixTable('tags').'
758 758
                 WHERE item_id = %i AND tag != ""',
759 759
                 $record['id']
760 760
             );
761 761
             foreach ($itemTags as $itemTag) {
762
-                $tags .= $itemTag['tag'] . ' ';
762
+                $tags .= $itemTag['tag'].' ';
763 763
             }
764 764
 
765 765
             // Get renewal period
766 766
             $resNT = DB::queryFirstRow(
767 767
                 'SELECT renewal_period
768
-                FROM ' . prefixTable('nested_tree') . '
768
+                FROM ' . prefixTable('nested_tree').'
769 769
                 WHERE id = %i',
770 770
                 $record['id_tree']
771 771
             );
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
                     // Is this a User id?
779 779
                     $user = DB::queryFirstRow(
780 780
                         'SELECT id, login
781
-                        FROM ' . prefixTable('users') . '
781
+                        FROM ' . prefixTable('users').'
782 782
                         WHERE id = %i',
783 783
                         $elem->title
784 784
                     );
@@ -796,11 +796,11 @@  discard block
 block discarded – undo
796 796
                     'id' => $record['id'],
797 797
                     'label' => $record['label'],
798 798
                     'description' => $record['description'] ?? '',
799
-                    'url' => isset($record['url']) && ! empty($record['url']) ? $record['url'] : '0',
799
+                    'url' => isset($record['url']) && !empty($record['url']) ? $record['url'] : '0',
800 800
                     'tags' => $tags,
801 801
                     'id_tree' => $record['id_tree'],
802 802
                     'perso' => $record['perso'],
803
-                    'restricted_to' => isset($record['restricted_to']) && ! empty($record['restricted_to']) ? $record['restricted_to'] : '0',
803
+                    'restricted_to' => isset($record['restricted_to']) && !empty($record['restricted_to']) ? $record['restricted_to'] : '0',
804 804
                     'login' => $record['login'] ?? '',
805 805
                     'folder' => implode(' » ', $folder),
806 806
                     'author' => $record['id_user'],
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
     // get new value from db
830 830
     $data = DB::queryFirstRow(
831 831
         'SELECT label, description, id_tree, perso, restricted_to, login, url
832
-        FROM ' . prefixTable('items') . '
832
+        FROM ' . prefixTable('items').'
833 833
         WHERE id=%i',
834 834
         $ident
835 835
     );
@@ -837,12 +837,12 @@  discard block
 block discarded – undo
837 837
     $tags = '';
838 838
     $itemTags = DB::query(
839 839
         'SELECT tag
840
-            FROM ' . prefixTable('tags') . '
840
+            FROM ' . prefixTable('tags').'
841 841
             WHERE item_id = %i AND tag != ""',
842 842
         $ident
843 843
     );
844 844
     foreach ($itemTags as $itemTag) {
845
-        $tags .= $itemTag['tag'] . ' ';
845
+        $tags .= $itemTag['tag'].' ';
846 846
     }
847 847
     // form id_tree to full foldername
848 848
     $folder = [];
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
             // Is this a User id?
854 854
             $user = DB::queryFirstRow(
855 855
                 'SELECT id, login
856
-                FROM ' . prefixTable('users') . '
856
+                FROM ' . prefixTable('users').'
857 857
                 WHERE id = %i',
858 858
                 $elem->title
859 859
             );
@@ -871,10 +871,10 @@  discard block
 block discarded – undo
871 871
             'label' => $data['label'],
872 872
             'description' => $data['description'],
873 873
             'tags' => $tags,
874
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
874
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
875 875
             'id_tree' => $data['id_tree'],
876 876
             'perso' => $data['perso'],
877
-            'restricted_to' => isset($data['restricted_to']) && ! empty($data['restricted_to']) ? $data['restricted_to'] : '0',
877
+            'restricted_to' => isset($data['restricted_to']) && !empty($data['restricted_to']) ? $data['restricted_to'] : '0',
878 878
             'login' => $data['login'] ?? '',
879 879
             'folder' => implode(' » ', $folder),
880 880
             'author' => $session->get('user-id'),
@@ -904,8 +904,8 @@  discard block
 block discarded – undo
904 904
     // get new value from db
905 905
     $data = DB::queryFirstRow(
906 906
         'SELECT i.label, i.description, i.id_tree as id_tree, i.perso, i.restricted_to, i.id, i.login, i.url, l.date
907
-        FROM ' . prefixTable('items') . ' as i
908
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
907
+        FROM ' . prefixTable('items').' as i
908
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
909 909
         WHERE i.id = %i
910 910
         AND l.action = %s',
911 911
         $ident,
@@ -915,12 +915,12 @@  discard block
 block discarded – undo
915 915
     $tags = '';
916 916
     $itemTags = DB::query(
917 917
         'SELECT tag
918
-            FROM ' . prefixTable('tags') . '
918
+            FROM ' . prefixTable('tags').'
919 919
             WHERE item_id = %i AND tag != ""',
920 920
         $ident
921 921
     );
922 922
     foreach ($itemTags as $itemTag) {
923
-        $tags .= $itemTag['tag'] . ' ';
923
+        $tags .= $itemTag['tag'].' ';
924 924
     }
925 925
     // form id_tree to full foldername
926 926
     $folder = [];
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
             // Is this a User id?
932 932
             $user = DB::queryFirstRow(
933 933
                 'SELECT id, login
934
-                FROM ' . prefixTable('users') . '
934
+                FROM ' . prefixTable('users').'
935 935
                 WHERE id = %i',
936 936
                 $elem->title
937 937
             );
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
             'label' => $data['label'],
951 951
             'description' => $data['description'],
952 952
             'tags' => empty($tags) === false ? $tags : 'None',
953
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
953
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
954 954
             'id_tree' => $data['id_tree'],
955 955
             'perso' => isset($data['perso']) && empty($data['perso']) === false && $data['perso'] !== 'None' ? $data['perso'] : '0',
956 956
             'restricted_to' => isset($data['restricted_to']) && empty($data['restricted_to']) === false ? $data['restricted_to'] : '0',
@@ -972,53 +972,53 @@  discard block
 block discarded – undo
972 972
 function getStatisticsData(array $SETTINGS): array
973 973
 {
974 974
     DB::query(
975
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
975
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
976 976
         0
977 977
     );
978 978
     $counter_folders = DB::count();
979 979
     DB::query(
980
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
980
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
981 981
         1
982 982
     );
983 983
     $counter_folders_perso = DB::count();
984 984
     DB::query(
985
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
985
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
986 986
         0
987 987
     );
988 988
     $counter_items = DB::count();
989 989
         DB::query(
990
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
990
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
991 991
         1
992 992
     );
993 993
     $counter_items_perso = DB::count();
994 994
         DB::query(
995
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE login NOT IN (%s, %s, %s)',
995
+        'SELECT id FROM '.prefixTable('users').' WHERE login NOT IN (%s, %s, %s)',
996 996
         'OTV', 'TP', 'API'
997 997
     );
998 998
     $counter_users = DB::count();
999 999
         DB::query(
1000
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE admin = %i',
1000
+        'SELECT id FROM '.prefixTable('users').' WHERE admin = %i',
1001 1001
         1
1002 1002
     );
1003 1003
     $admins = DB::count();
1004 1004
     DB::query(
1005
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE gestionnaire = %i',
1005
+        'SELECT id FROM '.prefixTable('users').' WHERE gestionnaire = %i',
1006 1006
         1
1007 1007
     );
1008 1008
     $managers = DB::count();
1009 1009
     DB::query(
1010
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE read_only = %i',
1010
+        'SELECT id FROM '.prefixTable('users').' WHERE read_only = %i',
1011 1011
         1
1012 1012
     );
1013 1013
     $readOnly = DB::count();
1014 1014
     // list the languages
1015 1015
     $usedLang = [];
1016 1016
     $tp_languages = DB::query(
1017
-        'SELECT name FROM ' . prefixTable('languages')
1017
+        'SELECT name FROM '.prefixTable('languages')
1018 1018
     );
1019 1019
     foreach ($tp_languages as $tp_language) {
1020 1020
         DB::query(
1021
-            'SELECT * FROM ' . prefixTable('users') . ' WHERE user_language = %s',
1021
+            'SELECT * FROM '.prefixTable('users').' WHERE user_language = %s',
1022 1022
             $tp_language['name']
1023 1023
         );
1024 1024
         $usedLang[$tp_language['name']] = round((DB::count() * 100 / $counter_users), 0);
@@ -1027,12 +1027,12 @@  discard block
 block discarded – undo
1027 1027
     // get list of ips
1028 1028
     $usedIp = [];
1029 1029
     $tp_ips = DB::query(
1030
-        'SELECT user_ip FROM ' . prefixTable('users')
1030
+        'SELECT user_ip FROM '.prefixTable('users')
1031 1031
     );
1032 1032
     foreach ($tp_ips as $ip) {
1033 1033
         if (array_key_exists($ip['user_ip'], $usedIp)) {
1034 1034
             $usedIp[$ip['user_ip']] += $usedIp[$ip['user_ip']];
1035
-        } elseif (! empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
1035
+        } elseif (!empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
1036 1036
             $usedIp[$ip['user_ip']] = 1;
1037 1037
         }
1038 1038
     }
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
         <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;">
1128 1128
         <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;">
1129 1129
         <br><div style="float:right;">' .
1130
-        $textMail .
1130
+        $textMail.
1131 1131
         '<br><br></td></tr></table>
1132 1132
     </td></tr></table>
1133 1133
     <br></body></html>';
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
 {
1209 1209
     array_walk_recursive(
1210 1210
         $array,
1211
-        static function (&$item): void {
1211
+        static function(&$item): void {
1212 1212
             if (mb_detect_encoding((string) $item, 'utf-8', true) === false) {
1213 1213
                 $item = mb_convert_encoding($item, 'ISO-8859-1', 'UTF-8');
1214 1214
             }
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
  */
1320 1320
 function prefixTable(string $table): string
1321 1321
 {
1322
-    $safeTable = htmlspecialchars(DB_PREFIX . $table);
1322
+    $safeTable = htmlspecialchars(DB_PREFIX.$table);
1323 1323
     return $safeTable;
1324 1324
 }
1325 1325
 
@@ -1436,7 +1436,7 @@  discard block
 block discarded – undo
1436 1436
 function send_syslog($message, $host, $port, $component = 'teampass'): void
1437 1437
 {
1438 1438
     $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
1439
-    $syslog_message = '<123>' . date('M d H:i:s ') . $component . ': ' . $message;
1439
+    $syslog_message = '<123>'.date('M d H:i:s ').$component.': '.$message;
1440 1440
     socket_sendto($sock, (string) $syslog_message, strlen($syslog_message), 0, (string) $host, (int) $port);
1441 1441
     socket_close($sock);
1442 1442
 }
@@ -1483,14 +1483,14 @@  discard block
 block discarded – undo
1483 1483
     if (isset($SETTINGS['syslog_enable']) === true && (int) $SETTINGS['syslog_enable'] === 1) {
1484 1484
         if ($type === 'user_mngt') {
1485 1485
             send_syslog(
1486
-                'action=' . str_replace('at_', '', $label) . ' attribute=user user=' . $who . ' userid="' . $login . '" change="' . $field_1 . '" ',
1486
+                'action='.str_replace('at_', '', $label).' attribute=user user='.$who.' userid="'.$login.'" change="'.$field_1.'" ',
1487 1487
                 $SETTINGS['syslog_host'],
1488 1488
                 $SETTINGS['syslog_port'],
1489 1489
                 'teampass'
1490 1490
             );
1491 1491
         } else {
1492 1492
             send_syslog(
1493
-                'action=' . $type . ' attribute=' . $label . ' user=' . $who . ' userid="' . $login . '" ',
1493
+                'action='.$type.' attribute='.$label.' user='.$who.' userid="'.$login.'" ',
1494 1494
                 $SETTINGS['syslog_host'],
1495 1495
                 $SETTINGS['syslog_port'],
1496 1496
                 'teampass'
@@ -1565,7 +1565,7 @@  discard block
 block discarded – undo
1565 1565
         if (empty($item_label) === true) {
1566 1566
             $dataItem = DB::queryFirstRow(
1567 1567
                 'SELECT id, id_tree, label
1568
-                FROM ' . prefixTable('items') . '
1568
+                FROM ' . prefixTable('items').'
1569 1569
                 WHERE id = %i',
1570 1570
                 $item_id
1571 1571
             );
@@ -1573,11 +1573,11 @@  discard block
 block discarded – undo
1573 1573
         }
1574 1574
 
1575 1575
         send_syslog(
1576
-            'action=' . str_replace('at_', '', $action) .
1577
-                ' attribute=' . str_replace('at_', '', $attribute[0]) .
1578
-                ' itemno=' . $item_id .
1579
-                ' user=' . (is_null($login) === true ? '' : addslashes((string) $login)) .
1580
-                ' itemname="' . addslashes($item_label) . '"',
1576
+            'action='.str_replace('at_', '', $action).
1577
+                ' attribute='.str_replace('at_', '', $attribute[0]).
1578
+                ' itemno='.$item_id.
1579
+                ' user='.(is_null($login) === true ? '' : addslashes((string) $login)).
1580
+                ' itemname="'.addslashes($item_label).'"',
1581 1581
             $SETTINGS['syslog_host'],
1582 1582
             $SETTINGS['syslog_port'],
1583 1583
             'teampass'
@@ -1608,8 +1608,8 @@  discard block
 block discarded – undo
1608 1608
     // send email to user that what to be notified
1609 1609
     $notification = DB::queryFirstField(
1610 1610
         'SELECT email
1611
-        FROM ' . prefixTable('notification') . ' AS n
1612
-        INNER JOIN ' . prefixTable('users') . ' AS u ON (n.user_id = u.id)
1611
+        FROM ' . prefixTable('notification').' AS n
1612
+        INNER JOIN ' . prefixTable('users').' AS u ON (n.user_id = u.id)
1613 1613
         WHERE n.item_id = %i AND n.user_id != %i',
1614 1614
         $item_id,
1615 1615
         $globalsUserId
@@ -1620,7 +1620,7 @@  discard block
 block discarded – undo
1620 1620
         // Get list of changes
1621 1621
         $htmlChanges = '<ul>';
1622 1622
         foreach ($changes as $change) {
1623
-            $htmlChanges .= '<li>' . $change . '</li>';
1623
+            $htmlChanges .= '<li>'.$change.'</li>';
1624 1624
         }
1625 1625
         $htmlChanges .= '</ul>';
1626 1626
         // send email
@@ -1657,15 +1657,15 @@  discard block
 block discarded – undo
1657 1657
     $path = '';
1658 1658
     foreach ($arbo as $elem) {
1659 1659
         if (empty($path) === true) {
1660
-            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES) . ' ';
1660
+            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES).' ';
1661 1661
         } else {
1662
-            $path .= '&#8594; ' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1662
+            $path .= '&#8594; '.htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1663 1663
         }
1664 1664
     }
1665 1665
 
1666 1666
     // Build text to show user
1667 1667
     if (empty($label) === false) {
1668
-        return empty($path) === true ? addslashes($label) : addslashes($label) . ' (' . $path . ')';
1668
+        return empty($path) === true ? addslashes($label) : addslashes($label).' ('.$path.')';
1669 1669
     }
1670 1670
     return empty($path) === true ? '' : $path;
1671 1671
 }
@@ -1721,7 +1721,7 @@  discard block
 block discarded – undo
1721 1721
 {
1722 1722
     // Perform a copy if the file exists
1723 1723
     if (file_exists($configFilePath)) {
1724
-        $backupFilePath = $configFilePath . '.' . date('Y_m_d_His', time());
1724
+        $backupFilePath = $configFilePath.'.'.date('Y_m_d_His', time());
1725 1725
         if (!copy($configFilePath, $backupFilePath)) {
1726 1726
             return "ERROR: Could not copy file '$configFilePath'";
1727 1727
         }
@@ -1729,10 +1729,10 @@  discard block
 block discarded – undo
1729 1729
 
1730 1730
     // Regenerate the config file
1731 1731
     $data = ["<?php\n", "global \$SETTINGS;\n", "\$SETTINGS = array (\n"];
1732
-    $rows = DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s', 'admin');
1732
+    $rows = DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type=%s', 'admin');
1733 1733
     foreach ($rows as $record) {
1734 1734
         $value = getEncryptedValue($record['valeur'], $record['is_encrypted']);
1735
-        $data[] = "    '{$record['intitule']}' => '". htmlspecialchars_decode($value, ENT_COMPAT) . "',\n";
1735
+        $data[] = "    '{$record['intitule']}' => '".htmlspecialchars_decode($value, ENT_COMPAT)."',\n";
1736 1736
     }
1737 1737
     $data[] = ");\n";
1738 1738
     $data = array_unique($data);
@@ -1777,7 +1777,7 @@  discard block
 block discarded – undo
1777 1777
 {
1778 1778
     global $SETTINGS;
1779 1779
     /* LOAD CPASSMAN SETTINGS */
1780
-    if (! isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
1780
+    if (!isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
1781 1781
         $SETTINGS = [];
1782 1782
         $SETTINGS['duplicate_folder'] = 0;
1783 1783
         //by default, this is set to 0;
@@ -1787,7 +1787,7 @@  discard block
 block discarded – undo
1787 1787
         //by default, this value is set to 5;
1788 1788
         $settings = [];
1789 1789
         $rows = DB::query(
1790
-            'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s_type OR type=%s_type2',
1790
+            'SELECT * FROM '.prefixTable('misc').' WHERE type=%s_type OR type=%s_type2',
1791 1791
             [
1792 1792
                 'type' => 'admin',
1793 1793
                 'type2' => 'settings',
@@ -1819,7 +1819,7 @@  discard block
 block discarded – undo
1819 1819
     $source_cf = [];
1820 1820
     $rows = DB::query(
1821 1821
         'SELECT id_category
1822
-            FROM ' . prefixTable('categories_folders') . '
1822
+            FROM ' . prefixTable('categories_folders').'
1823 1823
             WHERE id_folder = %i',
1824 1824
         $source_id
1825 1825
     );
@@ -1830,7 +1830,7 @@  discard block
 block discarded – undo
1830 1830
     $target_cf = [];
1831 1831
     $rows = DB::query(
1832 1832
         'SELECT id_category
1833
-            FROM ' . prefixTable('categories_folders') . '
1833
+            FROM ' . prefixTable('categories_folders').'
1834 1834
             WHERE id_folder = %i',
1835 1835
         $target_id
1836 1836
     );
@@ -1925,10 +1925,10 @@  discard block
 block discarded – undo
1925 1925
     } catch (CryptoException\WrongKeyOrModifiedCiphertextException $ex) {
1926 1926
         $err = 'wrong_key';
1927 1927
     } catch (CryptoException\EnvironmentIsBrokenException $ex) {
1928
-        error_log('TEAMPASS-Error-Environment: ' . $ex->getMessage());
1928
+        error_log('TEAMPASS-Error-Environment: '.$ex->getMessage());
1929 1929
         $err = 'environment_error';
1930 1930
     } catch (CryptoException\IOException $ex) {
1931
-        error_log('TEAMPASS-Error-General: ' . $ex->getMessage());
1931
+        error_log('TEAMPASS-Error-General: '.$ex->getMessage());
1932 1932
         $err = 'general_error';
1933 1933
     }
1934 1934
 
@@ -1961,10 +1961,10 @@  discard block
 block discarded – undo
1961 1961
     } catch (CryptoException\WrongKeyOrModifiedCiphertextException $ex) {
1962 1962
         $err = 'wrong_key';
1963 1963
     } catch (CryptoException\EnvironmentIsBrokenException $ex) {
1964
-        error_log('TEAMPASS-Error-Environment: ' . $ex->getMessage());
1964
+        error_log('TEAMPASS-Error-Environment: '.$ex->getMessage());
1965 1965
         $err = 'environment_error';
1966 1966
     } catch (CryptoException\IOException $ex) {
1967
-        error_log('TEAMPASS-Error-General: ' . $ex->getMessage());
1967
+        error_log('TEAMPASS-Error-General: '.$ex->getMessage());
1968 1968
         $err = 'general_error';
1969 1969
     }
1970 1970
 
@@ -2050,7 +2050,7 @@  discard block
 block discarded – undo
2050 2050
 ) {
2051 2051
     // Check if the path exists
2052 2052
     $path = basename($path);
2053
-    if (! file_exists($path)) {
2053
+    if (!file_exists($path)) {
2054 2054
         return false;
2055 2055
     }
2056 2056
 
@@ -2103,7 +2103,7 @@  discard block
 block discarded – undo
2103 2103
     // Load item data
2104 2104
     $data = DB::queryFirstRow(
2105 2105
         'SELECT id_tree
2106
-        FROM ' . prefixTable('items') . '
2106
+        FROM ' . prefixTable('items').'
2107 2107
         WHERE id = %i',
2108 2108
         $item_id
2109 2109
     );
@@ -2166,7 +2166,7 @@  discard block
 block discarded – undo
2166 2166
         }
2167 2167
         $host .= substr(explode(".", $email[1])[0], -1, 1);
2168 2168
     }
2169
-    $email = $name . "@" . $host . "." . explode(".", $email[1])[1];
2169
+    $email = $name."@".$host.".".explode(".", $email[1])[1];
2170 2170
     return $email;
2171 2171
 }
2172 2172
 
@@ -2197,11 +2197,11 @@  discard block
 block discarded – undo
2197 2197
 function formatSizeUnits(int $bytes): string
2198 2198
 {
2199 2199
     if ($bytes >= 1073741824) {
2200
-        $bytes = number_format($bytes / 1073741824, 2) . ' GB';
2200
+        $bytes = number_format($bytes / 1073741824, 2).' GB';
2201 2201
     } elseif ($bytes >= 1048576) {
2202
-        $bytes = number_format($bytes / 1048576, 2) . ' MB';
2202
+        $bytes = number_format($bytes / 1048576, 2).' MB';
2203 2203
     } elseif ($bytes >= 1024) {
2204
-        $bytes = number_format($bytes / 1024, 2) . ' KB';
2204
+        $bytes = number_format($bytes / 1024, 2).' KB';
2205 2205
     } elseif ($bytes > 1) {
2206 2206
         $bytes .= ' bytes';
2207 2207
     } elseif ($bytes === 1) {
@@ -2450,7 +2450,7 @@  discard block
 block discarded – undo
2450 2450
     $cipher->enableContinuousBuffer();
2451 2451
 
2452 2452
     // Encrypt the file content
2453
-    $filePath = filter_var($fileInPath . '/' . $fileInName, FILTER_SANITIZE_URL);
2453
+    $filePath = filter_var($fileInPath.'/'.$fileInName, FILTER_SANITIZE_URL);
2454 2454
     $fileContent = file_get_contents($filePath);
2455 2455
     $plaintext = $fileContent;
2456 2456
     $ciphertext = $cipher->encrypt($plaintext);
@@ -2458,9 +2458,9 @@  discard block
 block discarded – undo
2458 2458
     // Save new file
2459 2459
     // deepcode ignore InsecureHash: is simply used to get a unique name
2460 2460
     $hash = uniqid('', true);
2461
-    $fileOut = $fileInPath . '/' . TP_FILE_PREFIX . $hash;
2461
+    $fileOut = $fileInPath.'/'.TP_FILE_PREFIX.$hash;
2462 2462
     file_put_contents($fileOut, $ciphertext);
2463
-    unlink($fileInPath . '/' . $fileInName);
2463
+    unlink($fileInPath.'/'.$fileInName);
2464 2464
     return [
2465 2465
         'fileHash' => base64_encode($hash),
2466 2466
         'objectKey' => base64_encode($objectKey),
@@ -2476,9 +2476,9 @@  discard block
 block discarded – undo
2476 2476
  *
2477 2477
  * @return string|array
2478 2478
  */
2479
-function decryptFile(string $fileName, string $filePath, string $key): string|array
2479
+function decryptFile(string $fileName, string $filePath, string $key): string | array
2480 2480
 {
2481
-    if (! defined('FILE_BUFFER_SIZE')) {
2481
+    if (!defined('FILE_BUFFER_SIZE')) {
2482 2482
         define('FILE_BUFFER_SIZE', 128 * 1024);
2483 2483
     }
2484 2484
     
@@ -2495,7 +2495,7 @@  discard block
 block discarded – undo
2495 2495
     $cipher->enableContinuousBuffer();
2496 2496
     $cipher->disablePadding();
2497 2497
     // Get file content
2498
-    $safeFilePath = realpath($filePath . '/' . TP_FILE_PREFIX . $safeFileName);
2498
+    $safeFilePath = realpath($filePath.'/'.TP_FILE_PREFIX.$safeFileName);
2499 2499
     if ($safeFilePath !== false && file_exists($safeFilePath)) {
2500 2500
         $ciphertext = file_get_contents(filter_var($safeFilePath, FILTER_SANITIZE_URL));
2501 2501
     } else {
@@ -2591,7 +2591,7 @@  discard block
 block discarded – undo
2591 2591
         // Only create the sharekey for a user
2592 2592
         $user = DB::queryFirstRow(
2593 2593
             'SELECT public_key
2594
-            FROM ' . prefixTable('users') . '
2594
+            FROM ' . prefixTable('users').'
2595 2595
             WHERE id = %i
2596 2596
             AND public_key != ""',
2597 2597
             $userId
@@ -2632,7 +2632,7 @@  discard block
 block discarded – undo
2632 2632
         }
2633 2633
         $users = DB::query(
2634 2634
             'SELECT id, public_key
2635
-            FROM ' . prefixTable('users') . '
2635
+            FROM ' . prefixTable('users').'
2636 2636
             WHERE id NOT IN %li
2637 2637
             AND public_key != ""',
2638 2638
             $user_ids
@@ -2641,7 +2641,7 @@  discard block
 block discarded – undo
2641 2641
         foreach ($users as $user) {
2642 2642
             // Insert in DB the new object key for this item by user
2643 2643
             if (count($objectKeyArray) === 0) {
2644
-                if (WIP === true) error_log('TEAMPASS Debug - storeUsersShareKey case1 - ' . $object_name . ' - ' . $post_object_id . ' - ' . $user['id'] . ' - ' . $objectKey);
2644
+                if (WIP === true) error_log('TEAMPASS Debug - storeUsersShareKey case1 - '.$object_name.' - '.$post_object_id.' - '.$user['id'].' - '.$objectKey);
2645 2645
                 DB::insert(
2646 2646
                     $object_name,
2647 2647
                     [
@@ -2655,7 +2655,7 @@  discard block
 block discarded – undo
2655 2655
                 );
2656 2656
             } else {
2657 2657
                 foreach ($objectKeyArray as $object) {
2658
-                    if (WIP === true) error_log('TEAMPASS Debug - storeUsersShareKey case2 - ' . $object_name . ' - ' . $object['objectId'] . ' - ' . $user['id'] . ' - ' . $object['objectKey']);
2658
+                    if (WIP === true) error_log('TEAMPASS Debug - storeUsersShareKey case2 - '.$object_name.' - '.$object['objectId'].' - '.$user['id'].' - '.$object['objectKey']);
2659 2659
                     DB::insert(
2660 2660
                         $object_name,
2661 2661
                         [
@@ -2683,7 +2683,7 @@  discard block
 block discarded – undo
2683 2683
 function isBase64(string $str): bool
2684 2684
 {
2685 2685
     $str = (string) trim($str);
2686
-    if (! isset($str[0])) {
2686
+    if (!isset($str[0])) {
2687 2687
         return false;
2688 2688
     }
2689 2689
 
@@ -2757,7 +2757,7 @@  discard block
 block discarded – undo
2757 2757
     } catch (\LdapRecord\Auth\BindException $e) {
2758 2758
         $error = $e->getDetailedError();
2759 2759
         if ($error && defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
2760
-            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage(). " - ".$error->getDiagnosticMessage());
2760
+            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage()." - ".$error->getDiagnosticMessage());
2761 2761
         }
2762 2762
         // deepcode ignore ServerLeak: No important data is sent
2763 2763
         echo 'An error occurred.';
@@ -2774,7 +2774,7 @@  discard block
 block discarded – undo
2774 2774
     } catch (\LdapRecord\Auth\BindException $e) {
2775 2775
         $error = $e->getDetailedError();
2776 2776
         if ($error && defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
2777
-            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage(). " - ".$error->getDiagnosticMessage());
2777
+            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage()." - ".$error->getDiagnosticMessage());
2778 2778
         }
2779 2779
         // deepcode ignore ServerLeak: No important data is sent
2780 2780
         echo 'An error occurred.';
@@ -2801,7 +2801,7 @@  discard block
 block discarded – undo
2801 2801
     // expect if personal item
2802 2802
     DB::delete(
2803 2803
         prefixTable('sharekeys_items'),
2804
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
2804
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
2805 2805
         $userId
2806 2806
     );
2807 2807
     // Remove all item sharekeys files
@@ -2809,8 +2809,8 @@  discard block
 block discarded – undo
2809 2809
         prefixTable('sharekeys_files'),
2810 2810
         'user_id = %i AND object_id NOT IN (
2811 2811
             SELECT f.id 
2812
-            FROM ' . prefixTable('items') . ' AS i 
2813
-            INNER JOIN ' . prefixTable('files') . ' AS f ON f.id_item = i.id
2812
+            FROM ' . prefixTable('items').' AS i 
2813
+            INNER JOIN ' . prefixTable('files').' AS f ON f.id_item = i.id
2814 2814
             WHERE i.perso = 1
2815 2815
         )',
2816 2816
         $userId
@@ -2820,8 +2820,8 @@  discard block
 block discarded – undo
2820 2820
         prefixTable('sharekeys_fields'),
2821 2821
         'user_id = %i AND object_id NOT IN (
2822 2822
             SELECT c.id 
2823
-            FROM ' . prefixTable('items') . ' AS i 
2824
-            INNER JOIN ' . prefixTable('categories_items') . ' AS c ON c.item_id = i.id
2823
+            FROM ' . prefixTable('items').' AS i 
2824
+            INNER JOIN ' . prefixTable('categories_items').' AS c ON c.item_id = i.id
2825 2825
             WHERE i.perso = 1
2826 2826
         )',
2827 2827
         $userId
@@ -2829,13 +2829,13 @@  discard block
 block discarded – undo
2829 2829
     // Remove all item sharekeys logs
2830 2830
     DB::delete(
2831 2831
         prefixTable('sharekeys_logs'),
2832
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
2832
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
2833 2833
         $userId
2834 2834
     );
2835 2835
     // Remove all item sharekeys suggestions
2836 2836
     DB::delete(
2837 2837
         prefixTable('sharekeys_suggestions'),
2838
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
2838
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
2839 2839
         $userId
2840 2840
     );
2841 2841
     return false;
@@ -2856,7 +2856,7 @@  discard block
 block discarded – undo
2856 2856
         foreach (DateTimeZone::listIdentifiers() as $timezone) {
2857 2857
             $now->setTimezone(new DateTimeZone($timezone));
2858 2858
             $offsets[] = $offset = $now->getOffset();
2859
-            $timezones[$timezone] = '(' . format_GMT_offset($offset) . ') ' . format_timezone_name($timezone);
2859
+            $timezones[$timezone] = '('.format_GMT_offset($offset).') '.format_timezone_name($timezone);
2860 2860
         }
2861 2861
 
2862 2862
         array_multisort($offsets, $timezones);
@@ -2876,7 +2876,7 @@  discard block
 block discarded – undo
2876 2876
 {
2877 2877
     $hours = intval($offset / 3600);
2878 2878
     $minutes = abs(intval($offset % 3600 / 60));
2879
-    return 'GMT' . ($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
2879
+    return 'GMT'.($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
2880 2880
 }
2881 2881
 
2882 2882
 /**
@@ -2975,8 +2975,7 @@  discard block
 block discarded – undo
2975 2975
 {
2976 2976
     if (isset($array[$key]) === true
2977 2977
         && (is_int($value) === true ?
2978
-            (int) $array[$key] === $value :
2979
-            (string) $array[$key] === $value)
2978
+            (int) $array[$key] === $value : (string) $array[$key] === $value)
2980 2979
     ) {
2981 2980
         return true;
2982 2981
     }
@@ -2998,8 +2997,7 @@  discard block
 block discarded – undo
2998 2997
 {
2999 2998
     if (isset($var) === false
3000 2999
         || (is_int($value) === true ?
3001
-            (int) $var === $value :
3002
-            (string) $var === $value)
3000
+            (int) $var === $value : (string) $var === $value)
3003 3001
     ) {
3004 3002
         return true;
3005 3003
     }
@@ -3050,7 +3048,7 @@  discard block
 block discarded – undo
3050 3048
  */
3051 3049
 function isSetArrayOfValues(array $arrayOfValues): bool
3052 3050
 {
3053
-    foreach($arrayOfValues as $value) {
3051
+    foreach ($arrayOfValues as $value) {
3054 3052
         if (isset($value) === false) {
3055 3053
             return false;
3056 3054
         }
@@ -3072,7 +3070,7 @@  discard block
 block discarded – undo
3072 3070
     /*PHP8 - integer|string*/$value
3073 3071
 ) : bool
3074 3072
 {
3075
-    foreach($arrayOfVars as $variable) {
3073
+    foreach ($arrayOfVars as $variable) {
3076 3074
         if ($variable !== $value) {
3077 3075
             return false;
3078 3076
         }
@@ -3092,7 +3090,7 @@  discard block
 block discarded – undo
3092 3090
     /*PHP8 - integer|string*/$value
3093 3091
 ) : bool
3094 3092
 {
3095
-    foreach($arrayOfVars as $variable) {
3093
+    foreach ($arrayOfVars as $variable) {
3096 3094
         if ($variable === $value) {
3097 3095
             return true;
3098 3096
         }
@@ -3106,7 +3104,7 @@  discard block
 block discarded – undo
3106 3104
  * @param string|int|null $value
3107 3105
  * @return boolean
3108 3106
  */
3109
-function isValueSetNullEmpty(string|int|null $value) : bool
3107
+function isValueSetNullEmpty(string | int | null $value) : bool
3110 3108
 {
3111 3109
     if (is_null($value) === true || empty($value) === true) {
3112 3110
         return true;
@@ -3161,7 +3159,7 @@  discard block
 block discarded – undo
3161 3159
  * @param array     $filters
3162 3160
  * @return array|string
3163 3161
  */
3164
-function dataSanitizer(array $data, array $filters): array|string
3162
+function dataSanitizer(array $data, array $filters): array | string
3165 3163
 {
3166 3164
     // Load Sanitizer library
3167 3165
     $sanitizer = new Sanitizer($data, $filters);
@@ -3190,7 +3188,7 @@  discard block
 block discarded – undo
3190 3188
     // Exists ?
3191 3189
     $userCacheId = DB::queryFirstRow(
3192 3190
         'SELECT increment_id
3193
-        FROM ' . prefixTable('cache_tree') . '
3191
+        FROM ' . prefixTable('cache_tree').'
3194 3192
         WHERE user_id = %i',
3195 3193
         $user_id
3196 3194
     );
@@ -3241,7 +3239,7 @@  discard block
 block discarded – undo
3241 3239
  */
3242 3240
 function pourcentage(float $nombre, float $total, float $pourcentage): float
3243 3241
 { 
3244
-    $resultat = ($nombre/$total) * $pourcentage;
3242
+    $resultat = ($nombre / $total) * $pourcentage;
3245 3243
     return round($resultat);
3246 3244
 }
3247 3245
 
@@ -3271,7 +3269,7 @@  discard block
 block discarded – undo
3271 3269
 
3272 3270
     // Get last folder update
3273 3271
     $lastFolderChange = DB::queryFirstRow(
3274
-        'SELECT valeur FROM ' . prefixTable('misc') . '
3272
+        'SELECT valeur FROM '.prefixTable('misc').'
3275 3273
         WHERE type = %s AND intitule = %s',
3276 3274
         'timestamp',
3277 3275
         'last_folder_change'
@@ -3302,7 +3300,7 @@  discard block
 block discarded – undo
3302 3300
     // Does this user has a tree cache
3303 3301
     $userCacheTree = DB::queryFirstRow(
3304 3302
         'SELECT '.$fieldName.'
3305
-        FROM ' . prefixTable('cache_tree') . '
3303
+        FROM ' . prefixTable('cache_tree').'
3306 3304
         WHERE user_id = %i',
3307 3305
         $session->get('user-id')
3308 3306
     );
@@ -3345,7 +3343,7 @@  discard block
 block discarded – undo
3345 3343
     if (count($folderIds) === 0) {
3346 3344
         $folderIds = DB::queryFirstColumn(
3347 3345
             'SELECT id
3348
-            FROM ' . prefixTable('nested_tree') . '
3346
+            FROM ' . prefixTable('nested_tree').'
3349 3347
             WHERE personal_folder=%i',
3350 3348
             0
3351 3349
         );
@@ -3362,8 +3360,8 @@  discard block
 block discarded – undo
3362 3360
         $rows_tmp = DB::query(
3363 3361
             'SELECT c.id, c.title, c.level, c.type, c.masked, c.order, c.encrypted_data, c.role_visibility, c.is_mandatory,
3364 3362
             f.id_category AS category_id
3365
-            FROM ' . prefixTable('categories_folders') . ' AS f
3366
-            INNER JOIN ' . prefixTable('categories') . ' AS c ON (f.id_category = c.parent_id)
3363
+            FROM ' . prefixTable('categories_folders').' AS f
3364
+            INNER JOIN ' . prefixTable('categories').' AS c ON (f.id_category = c.parent_id)
3367 3365
             WHERE id_folder=%i',
3368 3366
             $folder
3369 3367
         );
@@ -3389,7 +3387,7 @@  discard block
 block discarded – undo
3389 3387
         $valTemp = '';
3390 3388
         $data = DB::queryFirstRow(
3391 3389
             'SELECT valeur
3392
-            FROM ' . prefixTable('misc') . '
3390
+            FROM ' . prefixTable('misc').'
3393 3391
             WHERE type = %s AND intitule=%i',
3394 3392
             'complex',
3395 3393
             $folder
@@ -3406,14 +3404,14 @@  discard block
 block discarded – undo
3406 3404
         $valTemp = '';
3407 3405
         $rows_tmp = DB::query(
3408 3406
             'SELECT t.title
3409
-            FROM ' . prefixTable('roles_values') . ' as v
3410
-            INNER JOIN ' . prefixTable('roles_title') . ' as t ON (v.role_id = t.id)
3407
+            FROM ' . prefixTable('roles_values').' as v
3408
+            INNER JOIN ' . prefixTable('roles_title').' as t ON (v.role_id = t.id)
3411 3409
             WHERE v.folder_id = %i
3412 3410
             GROUP BY title',
3413 3411
             $folder
3414 3412
         );
3415 3413
         foreach ($rows_tmp as $record) {
3416
-            $valTemp .= (empty($valTemp) === true ? '' : ' - ') . $record['title'];
3414
+            $valTemp .= (empty($valTemp) === true ? '' : ' - ').$record['title'];
3417 3415
         }
3418 3416
         $arr_data['visibilityRoles'] = $valTemp;
3419 3417
 
@@ -3446,7 +3444,7 @@  discard block
 block discarded – undo
3446 3444
         // loop on users and check if user has this role
3447 3445
         $rows = DB::query(
3448 3446
             'SELECT id, fonction_id
3449
-            FROM ' . prefixTable('users') . '
3447
+            FROM ' . prefixTable('users').'
3450 3448
             WHERE id != %i AND admin = 0 AND fonction_id IS NOT NULL AND fonction_id != ""',
3451 3449
             $session->get('user-id')
3452 3450
         );
@@ -3478,7 +3476,7 @@  discard block
 block discarded – undo
3478 3476
 
3479 3477
     $val = DB::queryFirstRow(
3480 3478
         'SELECT *
3481
-        FROM ' . prefixTable('users') . '
3479
+        FROM ' . prefixTable('users').'
3482 3480
         WHERE id = %i',
3483 3481
         $userId
3484 3482
     );
@@ -3494,12 +3492,12 @@  discard block
 block discarded – undo
3494 3492
 function upgradeRequired(): bool
3495 3493
 {
3496 3494
     // Get settings.php
3497
-    include_once __DIR__. '/../includes/config/settings.php';
3495
+    include_once __DIR__.'/../includes/config/settings.php';
3498 3496
 
3499 3497
     // Get timestamp in DB
3500 3498
     $val = DB::queryFirstRow(
3501 3499
         'SELECT valeur
3502
-        FROM ' . prefixTable('misc') . '
3500
+        FROM ' . prefixTable('misc').'
3503 3501
         WHERE type = %s AND intitule = %s',
3504 3502
         'admin',
3505 3503
         'upgrade_timestamp'
@@ -3547,7 +3545,7 @@  discard block
 block discarded – undo
3547 3545
         $session = SessionManager::getSession();
3548 3546
         $lang = new Language($session->get('user-language') ?? 'english');
3549 3547
 
3550
-        error_log('TEAMPASS Debug - handleUserKeys - userId: ' . $userId . ' - generate_user_new_password: ' . ($generate_user_new_password ? 'true' : 'false'));
3548
+        error_log('TEAMPASS Debug - handleUserKeys - userId: '.$userId.' - generate_user_new_password: '.($generate_user_new_password ? 'true' : 'false'));
3551 3549
         // Validate user existence
3552 3550
         $userTP = validateUserExistence($userId);
3553 3551
         if ($userTP === null) {
@@ -3636,7 +3634,7 @@  discard block
 block discarded – undo
3636 3634
 function validateUserExistence(int $userId): ?array {
3637 3635
     $userTP = DB::queryFirstRow(
3638 3636
         'SELECT pw, public_key, private_key
3639
-        FROM ' . prefixTable('users') . '
3637
+        FROM ' . prefixTable('users').'
3640 3638
         WHERE id = %i',
3641 3639
         TP_USER_ID
3642 3640
     );
@@ -3708,7 +3706,7 @@  discard block
 block discarded – undo
3708 3706
 ): bool {
3709 3707
     $session = SessionManager::getSession();
3710 3708
     $passwordManager = new PasswordManager();
3711
-    $affectedRows  = DB::update(
3709
+    $affectedRows = DB::update(
3712 3710
         prefixTable('users'),
3713 3711
         [
3714 3712
             'pw' => $passwordManager->hashPassword($passwordClear),
@@ -3821,19 +3819,19 @@  discard block
 block discarded – undo
3821 3819
 
3822 3820
     // Prepare the subtask queries
3823 3821
     $queries = [
3824
-        'step20' => 'SELECT * FROM ' . prefixTable('items'),
3822
+        'step20' => 'SELECT * FROM '.prefixTable('items'),
3825 3823
 
3826
-        'step30' => 'SELECT * FROM ' . prefixTable('log_items') . 
3824
+        'step30' => 'SELECT * FROM '.prefixTable('log_items'). 
3827 3825
                     ' WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"',
3828 3826
 
3829
-        'step40' => 'SELECT * FROM ' . prefixTable('categories_items') . 
3827
+        'step40' => 'SELECT * FROM '.prefixTable('categories_items'). 
3830 3828
                     ' WHERE encryption_type = "teampass_aes"',
3831 3829
 
3832
-        'step50' => 'SELECT * FROM ' . prefixTable('suggestion'),
3830
+        'step50' => 'SELECT * FROM '.prefixTable('suggestion'),
3833 3831
 
3834
-        'step60' => 'SELECT * FROM ' . prefixTable('files') . ' AS f
3835
-                        INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = f.id_item
3836
-                        WHERE f.status = "' . TP_ENCRYPTION_NAME . '"'
3832
+        'step60' => 'SELECT * FROM '.prefixTable('files').' AS f
3833
+                        INNER JOIN ' . prefixTable('items').' AS i ON i.id = f.id_item
3834
+                        WHERE f.status = "' . TP_ENCRYPTION_NAME.'"'
3837 3835
     ];
3838 3836
 
3839 3837
     // Perform loop on $queries to create sub-tasks
@@ -4023,7 +4021,7 @@  discard block
 block discarded – undo
4023 4021
  */
4024 4022
 function createTaskForItem(
4025 4023
     string $processType,
4026
-    string|array $taskName,
4024
+    string | array $taskName,
4027 4025
     int $itemId,
4028 4026
     int $userId,
4029 4027
     string $objectKey,
@@ -4047,7 +4045,7 @@  discard block
 block discarded – undo
4047 4045
                 'object_key' => $objectKey,
4048 4046
                 'author' => (int) $userId,
4049 4047
             ]),
4050
-            'item_id' => (int) $parentId !== -1 ?  $parentId : null,
4048
+            'item_id' => (int) $parentId !== -1 ? $parentId : null,
4051 4049
         )
4052 4050
     );
4053 4051
     $processId = DB::insertId();
@@ -4057,7 +4055,7 @@  discard block
 block discarded – undo
4057 4055
     if (is_array($taskName) === false) {
4058 4056
         $taskName = [$taskName];
4059 4057
     }
4060
-    foreach($taskName as $task) {
4058
+    foreach ($taskName as $task) {
4061 4059
         if (WIP === true) error_log('createTaskForItem - task: '.$task);
4062 4060
         switch ($task) {
4063 4061
             case 'item_password':
@@ -4154,7 +4152,7 @@  discard block
 block discarded – undo
4154 4152
  * @param integer $user_id
4155 4153
  * @return void
4156 4154
  */
4157
-function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id=0)
4155
+function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id = 0)
4158 4156
 {
4159 4157
     if ($allUsers === true) {
4160 4158
         // Load class DB
@@ -4164,7 +4162,7 @@  discard block
 block discarded – undo
4164 4162
 
4165 4163
         $users = DB::query(
4166 4164
             'SELECT id
4167
-            FROM ' . prefixTable('users') . '
4165
+            FROM ' . prefixTable('users').'
4168 4166
             WHERE id NOT IN ('.OTV_USER_ID.', '.TP_USER_ID.', '.SSH_USER_ID.', '.API_USER_ID.')
4169 4167
             ORDER BY login ASC'
4170 4168
         );
@@ -4182,7 +4180,7 @@  discard block
 block discarded – undo
4182 4180
  * @param integer $user_id
4183 4181
  * @return void
4184 4182
  */
4185
-function purgeUnnecessaryKeysForUser(int $user_id=0)
4183
+function purgeUnnecessaryKeysForUser(int $user_id = 0)
4186 4184
 {
4187 4185
     if ($user_id === 0) {
4188 4186
         return;
@@ -4193,8 +4191,8 @@  discard block
 block discarded – undo
4193 4191
 
4194 4192
     $personalItems = DB::queryFirstColumn(
4195 4193
         'SELECT id
4196
-        FROM ' . prefixTable('items') . ' AS i
4197
-        INNER JOIN ' . prefixTable('log_items') . ' AS li ON li.id_item = i.id
4194
+        FROM ' . prefixTable('items').' AS i
4195
+        INNER JOIN ' . prefixTable('log_items').' AS li ON li.id_item = i.id
4198 4196
         WHERE i.perso = 1 AND li.action = "at_creation" AND li.id_user IN (%i, '.TP_USER_ID.')',
4199 4197
         $user_id
4200 4198
     );
@@ -4243,7 +4241,7 @@  discard block
 block discarded – undo
4243 4241
     // Check if user exists
4244 4242
     $userInfo = DB::queryFirstRow(
4245 4243
         'SELECT login
4246
-        FROM ' . prefixTable('users') . '
4244
+        FROM ' . prefixTable('users').'
4247 4245
         WHERE id = %i',
4248 4246
         $userId
4249 4247
     );
@@ -4252,7 +4250,7 @@  discard block
 block discarded – undo
4252 4250
         $now = (int) time();
4253 4251
         // Prepare file content
4254 4252
         $export_value = file_get_contents(__DIR__."/../includes/core/teampass_ascii.txt")."\n".
4255
-            "Generation date: ".date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now)."\n\n".
4253
+            "Generation date: ".date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now)."\n\n".
4256 4254
             "RECOVERY KEYS - Not to be shared - To be store safely\n\n".
4257 4255
             "Public Key:\n".$session->get('user-public_key')."\n\n".
4258 4256
             "Private Key:\n".$session->get('user-private_key')."\n\n";
@@ -4275,7 +4273,7 @@  discard block
 block discarded – undo
4275 4273
         return prepareExchangedData(
4276 4274
             array(
4277 4275
                 'error' => false,
4278
-                'datetime' => date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now),
4276
+                'datetime' => date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now),
4279 4277
                 'timestamp' => $now,
4280 4278
                 'content' => base64_encode($export_value),
4281 4279
                 'login' => $userInfo['login'],
@@ -4301,8 +4299,8 @@  discard block
 block discarded – undo
4301 4299
  */
4302 4300
 function loadClasses(string $className = ''): void
4303 4301
 {
4304
-    require_once __DIR__. '/../includes/config/include.php';
4305
-    require_once __DIR__. '/../includes/config/settings.php';
4302
+    require_once __DIR__.'/../includes/config/include.php';
4303
+    require_once __DIR__.'/../includes/config/settings.php';
4306 4304
     require_once __DIR__.'/../vendor/autoload.php';
4307 4305
 
4308 4306
     if (defined('DB_PASSWD_CLEAR') === false) {
@@ -4515,7 +4513,7 @@  discard block
 block discarded – undo
4515 4513
 
4516 4514
     // Get current user hash
4517 4515
     $userHash = DB::queryFirstRow(
4518
-        "SELECT pw FROM " . prefixtable('users') . " WHERE id = %d;",
4516
+        "SELECT pw FROM ".prefixtable('users')." WHERE id = %d;",
4519 4517
         $session->get('user-id')
4520 4518
     )['pw'];
4521 4519
 
@@ -4563,11 +4561,11 @@  discard block
 block discarded – undo
4563 4561
         }
4564 4562
         
4565 4563
         // Alternative: serialize ou json selon le contexte
4566
-        return get_class($value) . (method_exists($value, 'getId') ? '#' . $value->getId() : '');
4564
+        return get_class($value).(method_exists($value, 'getId') ? '#'.$value->getId() : '');
4567 4565
     }
4568 4566
     
4569 4567
     if (is_resource($value)) {
4570
-        return 'Resource#' . get_resource_id($value) . ' of type ' . get_resource_type($value);
4568
+        return 'Resource#'.get_resource_id($value).' of type '.get_resource_type($value);
4571 4569
     }
4572 4570
     
4573 4571
     // Cas par défaut
Please login to merge, or discard this patch.
sources/main.queries.php 1 patch
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 ) {
82 82
     // Not allowed page
83 83
     $session->set('system-error_code', ERR_NOT_ALLOWED);
84
-    include $SETTINGS['cpassman_dir'] . '/error.php';
84
+    include $SETTINGS['cpassman_dir'].'/error.php';
85 85
     exit;
86 86
 }
87 87
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 
270 270
             // Get current user hash
271 271
             $userHash = DB::queryFirstRow(
272
-                "SELECT pw FROM " . prefixtable('users') . " WHERE id = %d;",
272
+                "SELECT pw FROM ".prefixtable('users')." WHERE id = %d;",
273 273
                 $session->get('user-id')
274 274
             )['pw'];
275 275
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
  * @param string $post_key
325 325
  * @return string
326 326
  */
327
-function userHandler(string $post_type, array|null|string $dataReceived, array $SETTINGS, string $post_key): string
327
+function userHandler(string $post_type, array | null | string $dataReceived, array $SETTINGS, string $post_key): string
328 328
 {
329 329
     $session = SessionManager::getSession();
330 330
 
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
     if (isset($dataReceived['user_id'])) {
360 360
         // Get info about user to modify
361 361
         $targetUserInfos = DB::queryFirstRow(
362
-            'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM ' . prefixTable('users') . '
362
+            'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM '.prefixTable('users').'
363 363
             WHERE id = %i',
364 364
             $dataReceived['user_id']
365 365
         );
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
         case 'mail_me'://action_mail
509 509
             // Get info about user to send email
510 510
             $data_user = DB::queryFirstRow(
511
-                'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM ' . prefixTable('users') . '
511
+                'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM '.prefixTable('users').'
512 512
                 WHERE email = %s',
513 513
                 filter_var($dataReceived['receipt'], FILTER_SANITIZE_FULL_SPECIAL_CHARS)
514 514
             );
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
     if (isset($dataReceived['user_id'])) {
622 622
         // Get info about user to modify
623 623
         $targetUserInfos = DB::queryFirstRow(
624
-            'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM ' . prefixTable('users') . '
624
+            'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM '.prefixTable('users').'
625 625
             WHERE id = %i',
626 626
             $dataReceived['user_id']
627 627
         );
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 
701 701
             // Get current user hash
702 702
             $userHash = DB::queryFirstRow(
703
-                "SELECT pw FROM " . prefixtable('users') . " WHERE id = %d;",
703
+                "SELECT pw FROM ".prefixtable('users')." WHERE id = %d;",
704 704
                 $session->get('user-id')
705 705
             )['pw'];
706 706
 
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 
739 739
                 // Get current user hash
740 740
                 $userHash = DB::queryFirstRow(
741
-                    "SELECT pw FROM " . prefixtable('users') . " WHERE id = %d;",
741
+                    "SELECT pw FROM ".prefixtable('users')." WHERE id = %d;",
742 742
                     $session->get('user-id')
743 743
                 )['pw'];
744 744
 
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
 
783 783
                 // Get current user hash
784 784
                 $userHash = DB::queryFirstRow(
785
-                    "SELECT pw FROM " . prefixtable('users') . " WHERE id = %i;",
785
+                    "SELECT pw FROM ".prefixtable('users')." WHERE id = %i;",
786 786
                     $session->get('user-id')
787 787
                 )['pw'];
788 788
 
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
     }
862 862
 
863 863
     return prepareSuccessResponse([
864
-        'count' => getNumberOfItemsToTreat((int)$userId, $SETTINGS)
864
+        'count' => getNumberOfItemsToTreat((int) $userId, $SETTINGS)
865 865
     ]);
866 866
 }
867 867
 
@@ -955,12 +955,12 @@  discard block
 block discarded – undo
955 955
     }
956 956
 
957 957
     $token = GenerateCryptKey(
958
-        (int)$params['size'],
959
-        (bool)$params['secure'],
960
-        (bool)$params['numeric'],
961
-        (bool)$params['capital'],
962
-        (bool)$params['symbols'],
963
-        (bool)$params['lowercase']
958
+        (int) $params['size'],
959
+        (bool) $params['secure'],
960
+        (bool) $params['numeric'],
961
+        (bool) $params['capital'],
962
+        (bool) $params['symbols'],
963
+        (bool) $params['lowercase']
964 964
     );
965 965
 
966 966
     DB::insert(prefixTable('tokens'), [
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
         'token' => $token,
969 969
         'reason' => $params['reason'],
970 970
         'creation_timestamp' => time(),
971
-        'end_timestamp' => time() + (int)$params['duration'],
971
+        'end_timestamp' => time() + (int) $params['duration'],
972 972
     ]);
973 973
 
974 974
     return prepareSuccessResponse(['token' => $token]);
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
 
1016 1016
 
1017 1017
 
1018
-function utilsHandler(string $post_type, array|null|string $dataReceived, array $SETTINGS): string
1018
+function utilsHandler(string $post_type, array | null | string $dataReceived, array $SETTINGS): string
1019 1019
 {
1020 1020
     switch ($post_type) {
1021 1021
         /*
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
         array(
1085 1085
             'error' => false,
1086 1086
             'timestamp' => $session->get('user-session_duration'),
1087
-            'max_time_to_add' => intdiv((($maximum_session_expiration_time*60) - ((int) $session->get('user-session_duration') - time())), 60),
1087
+            'max_time_to_add' => intdiv((($maximum_session_expiration_time * 60) - ((int) $session->get('user-session_duration') - time())), 60),
1088 1088
             'max_session_duration' => $maximum_session_expiration_time,
1089 1089
         ),
1090 1090
         'encode'
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
     // get number of items
1137 1137
     DB::queryFirstRow(
1138 1138
         'SELECT increment_id
1139
-        FROM ' . prefixTable('sharekeys_items') .
1139
+        FROM ' . prefixTable('sharekeys_items').
1140 1140
         ' WHERE user_id = %i',
1141 1141
         $userId
1142 1142
     );
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
         // check if expected security level is reached
1192 1192
         $dataUser = DB::queryFirstRow(
1193 1193
             'SELECT *
1194
-            FROM ' . prefixTable('users') . ' WHERE id = %i',
1194
+            FROM ' . prefixTable('users').' WHERE id = %i',
1195 1195
             $post_user_id
1196 1196
         );
1197 1197
 
@@ -1212,8 +1212,8 @@  discard block
 block discarded – undo
1212 1212
         if (empty($dataUser['fonction_id']) === false) {
1213 1213
             $data = DB::queryFirstRow(
1214 1214
                 'SELECT complexity
1215
-                FROM ' . prefixTable('roles_title') . '
1216
-                WHERE id IN (' . $dataUser['fonction_id'] . ')
1215
+                FROM ' . prefixTable('roles_title').'
1216
+                WHERE id IN (' . $dataUser['fonction_id'].')
1217 1217
                 ORDER BY complexity DESC'
1218 1218
             );
1219 1219
         } else {
@@ -1226,8 +1226,8 @@  discard block
 block discarded – undo
1226 1226
             return prepareExchangedData(
1227 1227
                 array(
1228 1228
                     'error' => true,
1229
-                    'message' => '<div style="margin:10px 0 10px 15px;">' . $lang->get('complexity_level_not_reached') . '.<br>' .
1230
-                        $lang->get('expected_complexity_level') . ': <b>' . TP_PW_COMPLEXITY[$data['complexity']][1] . '</b></div>',
1229
+                    'message' => '<div style="margin:10px 0 10px 15px;">'.$lang->get('complexity_level_not_reached').'.<br>'.
1230
+                        $lang->get('expected_complexity_level').': <b>'.TP_PW_COMPLEXITY[$data['complexity']][1].'</b></div>',
1231 1231
                 ),
1232 1232
                 'encode'
1233 1233
             );
@@ -1331,14 +1331,14 @@  discard block
 block discarded – undo
1331 1331
         // Get data about user
1332 1332
         $dataUser = DB::queryFirstRow(
1333 1333
             'SELECT id, email, pw
1334
-            FROM ' . prefixTable('users') . '
1334
+            FROM ' . prefixTable('users').'
1335 1335
             WHERE login = %s',
1336 1336
             $post_login
1337 1337
         );
1338 1338
     } else {
1339 1339
         $dataUser = DB::queryFirstRow(
1340 1340
             'SELECT id, login, email, pw
1341
-            FROM ' . prefixTable('users') . '
1341
+            FROM ' . prefixTable('users').'
1342 1342
             WHERE id = %i',
1343 1343
             $post_id
1344 1344
         );
@@ -1392,7 +1392,7 @@  discard block
 block discarded – undo
1392 1392
     // Check if token already used
1393 1393
     $dataToken = DB::queryFirstRow(
1394 1394
         'SELECT end_timestamp, reason
1395
-        FROM ' . prefixTable('tokens') . '
1395
+        FROM ' . prefixTable('tokens').'
1396 1396
         WHERE token = %s AND user_id = %i',
1397 1397
         $post_token,
1398 1398
         $dataUser['id']
@@ -1403,11 +1403,11 @@  discard block
 block discarded – undo
1403 1403
         return prepareExchangedData(
1404 1404
             array(
1405 1405
                 'error' => true,
1406
-                'message' => 'TOKEN already used',//$lang->get('no_email_set'),
1406
+                'message' => 'TOKEN already used', //$lang->get('no_email_set'),
1407 1407
             ),
1408 1408
             'encode'
1409 1409
         );
1410
-    } elseif(DB::count() === 0) {
1410
+    } elseif (DB::count() === 0) {
1411 1411
         // Store token for this action
1412 1412
         DB::insert(
1413 1413
             prefixTable('tokens'),
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
                 'email' => $dataUser['email'],
1470 1470
                 'email_result' => str_replace(
1471 1471
                     '#email#',
1472
-                    '<b>' . obfuscateEmail($dataUser['email']) . '</b>',
1472
+                    '<b>'.obfuscateEmail($dataUser['email']).'</b>',
1473 1473
                     addslashes($lang->get('admin_email_result_ok'))
1474 1474
                 ),
1475 1475
             ),
@@ -1485,7 +1485,7 @@  discard block
 block discarded – undo
1485 1485
             'email' => $dataUser['email'],
1486 1486
             'email_result' => str_replace(
1487 1487
                 '#email#',
1488
-                '<b>' . obfuscateEmail($dataUser['email']) . '</b>',
1488
+                '<b>'.obfuscateEmail($dataUser['email']).'</b>',
1489 1489
                 addslashes($lang->get('admin_email_result_ok'))
1490 1490
             ),
1491 1491
         ),
@@ -1502,7 +1502,7 @@  discard block
 block discarded – undo
1502 1502
 
1503 1503
     if (isKeyExistingAndEqual('enable_send_email_on_user_login', 1, $SETTINGS) === true) {
1504 1504
         $row = DB::queryFirstRow(
1505
-            'SELECT valeur FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s',
1505
+            'SELECT valeur FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s',
1506 1506
             'cron',
1507 1507
             'sending_emails'
1508 1508
         );
@@ -1510,7 +1510,7 @@  discard block
 block discarded – undo
1510 1510
         if ((int) (time() - $row['valeur']) >= 300 || (int) $row['valeur'] === 0) {
1511 1511
             $rows = DB::query(
1512 1512
                 'SELECT *
1513
-                FROM ' . prefixTable('emails') .
1513
+                FROM ' . prefixTable('emails').
1514 1514
                 ' WHERE status != %s',
1515 1515
                 'sent'
1516 1516
             );
@@ -1562,8 +1562,8 @@  discard block
 block discarded – undo
1562 1562
     $arr_html = array();
1563 1563
     $rows = DB::query(
1564 1564
         'SELECT i.id AS id, i.label AS label, i.id_tree AS id_tree, l.date, i.perso AS perso, i.restricted_to AS restricted
1565
-        FROM ' . prefixTable('log_items') . ' AS l
1566
-        RIGHT JOIN ' . prefixTable('items') . ' AS i ON (l.id_item = i.id)
1565
+        FROM ' . prefixTable('log_items').' AS l
1566
+        RIGHT JOIN ' . prefixTable('items').' AS i ON (l.id_item = i.id)
1567 1567
         WHERE l.action = %s AND l.id_user = %i
1568 1568
         ORDER BY l.date DESC
1569 1569
         LIMIT 0, 100',
@@ -1595,7 +1595,7 @@  discard block
 block discarded – undo
1595 1595
     if (isKeyExistingAndEqual('enable_suggestion', 1, $SETTINGS) === true
1596 1596
         && ((int) $session->get('user-admin') === 1 || (int) $session->get('user-manager') === 1)
1597 1597
     ) {
1598
-        DB::query('SELECT * FROM ' . prefixTable('suggestion'));
1598
+        DB::query('SELECT * FROM '.prefixTable('suggestion'));
1599 1599
         $nb_suggestions_waiting = DB::count();
1600 1600
     }
1601 1601
 
@@ -1630,13 +1630,13 @@  discard block
 block discarded – undo
1630 1630
             if ($data === 'stat_languages') {
1631 1631
                 $tmp = '';
1632 1632
                 foreach ($stats_data[$data] as $key => $value) {
1633
-                    $tmp .= $tmp === '' ? $key . '-' . $value : ',' . $key . '-' . $value;
1633
+                    $tmp .= $tmp === '' ? $key.'-'.$value : ','.$key.'-'.$value;
1634 1634
                 }
1635 1635
                 $statsToSend[$data] = $tmp;
1636 1636
             } elseif ($data === 'stat_country') {
1637 1637
                 $tmp = '';
1638 1638
                 foreach ($stats_data[$data] as $key => $value) {
1639
-                    $tmp .= $tmp === '' ? $key . '-' . $value : ',' . $key . '-' . $value;
1639
+                    $tmp .= $tmp === '' ? $key.'-'.$value : ','.$key.'-'.$value;
1640 1640
                 }
1641 1641
                 $statsToSend[$data] = $tmp;
1642 1642
             } else {
@@ -1715,7 +1715,7 @@  discard block
 block discarded – undo
1715 1715
     $anonymUrl = '';
1716 1716
     if (!empty($urlFound)) {
1717 1717
         $parsed = parse_url($urlFound);
1718
-        $anonymUrl = $parsed['scheme'] . '://<anonym_url>' . ($parsed['path'] ?? '');
1718
+        $anonymUrl = $parsed['scheme'].'://<anonym_url>'.($parsed['path'] ?? '');
1719 1719
     }
1720 1720
 
1721 1721
     // Filtrage et tri des réglages
@@ -1736,21 +1736,21 @@  discard block
 block discarded – undo
1736 1736
     // Récupère dernière erreur PHP
1737 1737
     $phpError = error_get_last();
1738 1738
     $phpErrorMsg = $phpError
1739
-        ? $phpError['message'] . ' - ' . $phpError['file'] . ' (' . $phpError['line'] . ')'
1739
+        ? $phpError['message'].' - '.$phpError['file'].' ('.$phpError['line'].')'
1740 1740
         : $lang->get('no_error_logged');
1741 1741
 
1742 1742
     // Dernières erreurs Teampass
1743 1743
     $teampassErrors = [];
1744 1744
     $errors = DB::query(
1745 1745
         'SELECT label, date AS error_date
1746
-         FROM ' . prefixTable('log_system') . "
1746
+         FROM ' . prefixTable('log_system')."
1747 1747
          WHERE `type` = 'error'
1748 1748
          ORDER BY `date` DESC
1749 1749
          LIMIT 10"
1750 1750
     );
1751 1751
 
1752 1752
     foreach ($errors as $record) {
1753
-        $teampassErrors[] = ' * ' . date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['error_date']) . ' - ' . $record['label'];
1753
+        $teampassErrors[] = ' * '.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['error_date']).' - '.$record['label'];
1754 1754
     }
1755 1755
     $teampassErrors = count($teampassErrors) > 0 ? implode("\n", $teampassErrors) : $lang->get('no_error_logged');
1756 1756
 
@@ -1845,7 +1845,7 @@  discard block
 block discarded – undo
1845 1845
         // Check if user exists
1846 1846
         $userInfo = DB::queryFirstRow(
1847 1847
             'SELECT public_key, private_key, pw, auth_type
1848
-            FROM ' . prefixTable('users') . '
1848
+            FROM ' . prefixTable('users').'
1849 1849
             WHERE id = %i',
1850 1850
             $post_user_id
1851 1851
         );
@@ -1854,9 +1854,9 @@  discard block
 block discarded – undo
1854 1854
             // Get one item
1855 1855
             $currentUserKey = DB::queryFirstRow(
1856 1856
                 'SELECT object_id, share_key, increment_id
1857
-                FROM ' . prefixTable('sharekeys_items') . ' AS si
1858
-                INNER JOIN ' . prefixTable('items') . ' AS i ON  (i.id = si.object_id)
1859
-                INNER JOIN ' . prefixTable('nested_tree') . ' AS nt ON  (i.id_tree = nt.id)
1857
+                FROM ' . prefixTable('sharekeys_items').' AS si
1858
+                INNER JOIN ' . prefixTable('items').' AS i ON  (i.id = si.object_id)
1859
+                INNER JOIN ' . prefixTable('nested_tree').' AS nt ON  (i.id_tree = nt.id)
1860 1860
                 WHERE user_id = %i AND nt.personal_folder = %i',
1861 1861
                 $post_user_id,
1862 1862
                 0
@@ -1950,7 +1950,7 @@  discard block
 block discarded – undo
1950 1950
         // Get user info
1951 1951
         $userData = DB::queryFirstRow(
1952 1952
             'SELECT private_key
1953
-            FROM ' . prefixTable('users') . '
1953
+            FROM ' . prefixTable('users').'
1954 1954
             WHERE id = %i',
1955 1955
             $post_user_id
1956 1956
         );
@@ -2031,7 +2031,7 @@  discard block
 block discarded – undo
2031 2031
         // Get user info
2032 2032
         $userData = DB::queryFirstRow(
2033 2033
             'SELECT email, auth_type, login
2034
-            FROM ' . prefixTable('users') . '
2034
+            FROM ' . prefixTable('users').'
2035 2035
             WHERE id = %i',
2036 2036
             $post_user_id
2037 2037
         );
@@ -2129,7 +2129,7 @@  discard block
 block discarded – undo
2129 2129
         // Get user info
2130 2130
         $userData = DB::queryFirstRow(
2131 2131
             'SELECT email, auth_type, login
2132
-            FROM ' . prefixTable('users') . '
2132
+            FROM ' . prefixTable('users').'
2133 2133
             WHERE id = %i',
2134 2134
             $post_user_id
2135 2135
         );
@@ -2195,7 +2195,7 @@  discard block
 block discarded – undo
2195 2195
         // Check if user exists
2196 2196
         DB::queryFirstRow(
2197 2197
             'SELECT *
2198
-            FROM ' . prefixTable('users') . '
2198
+            FROM ' . prefixTable('users').'
2199 2199
             WHERE id = %i',
2200 2200
             $post_user_id
2201 2201
         );
@@ -2265,7 +2265,7 @@  discard block
 block discarded – undo
2265 2265
         // Check if user exists
2266 2266
         $userInfo = DB::queryFirstRow(
2267 2267
             'SELECT public_key
2268
-            FROM ' . prefixTable('users') . '
2268
+            FROM ' . prefixTable('users').'
2269 2269
             WHERE id = %i',
2270 2270
             $post_user_id
2271 2271
         );
@@ -2413,15 +2413,15 @@  discard block
 block discarded – undo
2413 2413
     // Loop on items
2414 2414
     $rows = DB::query(
2415 2415
         'SELECT id, pw
2416
-        FROM ' . prefixTable('items') . '
2416
+        FROM ' . prefixTable('items').'
2417 2417
         WHERE perso = 0
2418
-        LIMIT ' . $post_start . ', ' . $post_length
2418
+        LIMIT ' . $post_start.', '.$post_length
2419 2419
     );
2420 2420
     foreach ($rows as $record) {
2421 2421
         // Get itemKey from current user
2422 2422
         $currentUserKey = DB::queryFirstRow(
2423 2423
             'SELECT share_key, increment_id
2424
-            FROM ' . prefixTable('sharekeys_items') . '
2424
+            FROM ' . prefixTable('sharekeys_items').'
2425 2425
             WHERE object_id = %i AND user_id = %i',
2426 2426
             $record['id'],
2427 2427
             $session->get('user-id')
@@ -2453,7 +2453,7 @@  discard block
 block discarded – undo
2453 2453
             if ((int) $post_user_id !== (int) $session->get('user-id')) {
2454 2454
                 $currentUserKey = DB::queryFirstRow(
2455 2455
                     'SELECT increment_id
2456
-                    FROM ' . prefixTable('sharekeys_items') . '
2456
+                    FROM ' . prefixTable('sharekeys_items').'
2457 2457
                     WHERE object_id = %i AND user_id = %i',
2458 2458
                     $record['id'],
2459 2459
                     $post_user_id
@@ -2486,7 +2486,7 @@  discard block
 block discarded – undo
2486 2486
     // SHould we change step?
2487 2487
     DB::query(
2488 2488
         'SELECT *
2489
-        FROM ' . prefixTable('items') . '
2489
+        FROM ' . prefixTable('items').'
2490 2490
         WHERE perso = 0'
2491 2491
     );
2492 2492
 
@@ -2511,15 +2511,15 @@  discard block
 block discarded – undo
2511 2511
     // Loop on logs
2512 2512
     $rows = DB::query(
2513 2513
         'SELECT increment_id
2514
-        FROM ' . prefixTable('log_items') . '
2514
+        FROM ' . prefixTable('log_items').'
2515 2515
         WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"
2516
-        LIMIT ' . $post_start . ', ' . $post_length
2516
+        LIMIT ' . $post_start.', '.$post_length
2517 2517
     );
2518 2518
     foreach ($rows as $record) {
2519 2519
         // Get itemKey from current user
2520 2520
         $currentUserKey = DB::queryFirstRow(
2521 2521
             'SELECT share_key
2522
-            FROM ' . prefixTable('sharekeys_logs') . '
2522
+            FROM ' . prefixTable('sharekeys_logs').'
2523 2523
             WHERE object_id = %i AND user_id = %i',
2524 2524
             $record['increment_id'],
2525 2525
             $session->get('user-id')
@@ -2551,7 +2551,7 @@  discard block
 block discarded – undo
2551 2551
             if ((int) $post_user_id !== (int) $session->get('user-id')) {
2552 2552
                 $currentUserKey = DB::queryFirstRow(
2553 2553
                     'SELECT increment_id
2554
-                    FROM ' . prefixTable('sharekeys_items') . '
2554
+                    FROM ' . prefixTable('sharekeys_items').'
2555 2555
                     WHERE object_id = %i AND user_id = %i',
2556 2556
                     $record['id'],
2557 2557
                     $post_user_id
@@ -2573,7 +2573,7 @@  discard block
 block discarded – undo
2573 2573
     // SHould we change step?
2574 2574
     DB::query(
2575 2575
         'SELECT increment_id
2576
-        FROM ' . prefixTable('log_items') . '
2576
+        FROM ' . prefixTable('log_items').'
2577 2577
         WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"'
2578 2578
     );
2579 2579
 
@@ -2598,15 +2598,15 @@  discard block
 block discarded – undo
2598 2598
     // Loop on fields
2599 2599
     $rows = DB::query(
2600 2600
         'SELECT id
2601
-        FROM ' . prefixTable('categories_items') . '
2601
+        FROM ' . prefixTable('categories_items').'
2602 2602
         WHERE encryption_type = "teampass_aes"
2603
-        LIMIT ' . $post_start . ', ' . $post_length
2603
+        LIMIT ' . $post_start.', '.$post_length
2604 2604
     );
2605 2605
     foreach ($rows as $record) {
2606 2606
         // Get itemKey from current user
2607 2607
         $currentUserKey = DB::queryFirstRow(
2608 2608
             'SELECT share_key
2609
-            FROM ' . prefixTable('sharekeys_fields') . '
2609
+            FROM ' . prefixTable('sharekeys_fields').'
2610 2610
             WHERE object_id = %i AND user_id = %i',
2611 2611
             $record['id'],
2612 2612
             $session->get('user-id')
@@ -2638,7 +2638,7 @@  discard block
 block discarded – undo
2638 2638
             if ((int) $post_user_id !== (int) $session->get('user-id')) {
2639 2639
                 $currentUserKey = DB::queryFirstRow(
2640 2640
                     'SELECT increment_id
2641
-                    FROM ' . prefixTable('sharekeys_items') . '
2641
+                    FROM ' . prefixTable('sharekeys_items').'
2642 2642
                     WHERE object_id = %i AND user_id = %i',
2643 2643
                     $record['id'],
2644 2644
                     $post_user_id
@@ -2660,7 +2660,7 @@  discard block
 block discarded – undo
2660 2660
     // SHould we change step?
2661 2661
     DB::query(
2662 2662
         'SELECT *
2663
-        FROM ' . prefixTable('categories_items') . '
2663
+        FROM ' . prefixTable('categories_items').'
2664 2664
         WHERE encryption_type = "teampass_aes"'
2665 2665
     );
2666 2666
 
@@ -2685,14 +2685,14 @@  discard block
 block discarded – undo
2685 2685
     // Loop on suggestions
2686 2686
     $rows = DB::query(
2687 2687
         'SELECT id
2688
-        FROM ' . prefixTable('suggestion') . '
2689
-        LIMIT ' . $post_start . ', ' . $post_length
2688
+        FROM ' . prefixTable('suggestion').'
2689
+        LIMIT ' . $post_start.', '.$post_length
2690 2690
     );
2691 2691
     foreach ($rows as $record) {
2692 2692
         // Get itemKey from current user
2693 2693
         $currentUserKey = DB::queryFirstRow(
2694 2694
             'SELECT share_key
2695
-            FROM ' . prefixTable('sharekeys_suggestions') . '
2695
+            FROM ' . prefixTable('sharekeys_suggestions').'
2696 2696
             WHERE object_id = %i AND user_id = %i',
2697 2697
             $record['id'],
2698 2698
             $session->get('user-id')
@@ -2724,7 +2724,7 @@  discard block
 block discarded – undo
2724 2724
             if ((int) $post_user_id !== (int) $session->get('user-id')) {
2725 2725
                 $currentUserKey = DB::queryFirstRow(
2726 2726
                     'SELECT increment_id
2727
-                    FROM ' . prefixTable('sharekeys_items') . '
2727
+                    FROM ' . prefixTable('sharekeys_items').'
2728 2728
                     WHERE object_id = %i AND user_id = %i',
2729 2729
                     $record['id'],
2730 2730
                     $post_user_id
@@ -2770,15 +2770,15 @@  discard block
 block discarded – undo
2770 2770
     // Loop on files
2771 2771
     $rows = DB::query(
2772 2772
         'SELECT id
2773
-        FROM ' . prefixTable('files') . '
2774
-        WHERE status = "' . TP_ENCRYPTION_NAME . '"
2775
-        LIMIT ' . $post_start . ', ' . $post_length
2773
+        FROM ' . prefixTable('files').'
2774
+        WHERE status = "' . TP_ENCRYPTION_NAME.'"
2775
+        LIMIT ' . $post_start.', '.$post_length
2776 2776
     ); //aes_encryption
2777 2777
     foreach ($rows as $record) {
2778 2778
         // Get itemKey from current user
2779 2779
         $currentUserKey = DB::queryFirstRow(
2780 2780
             'SELECT share_key
2781
-            FROM ' . prefixTable('sharekeys_files') . '
2781
+            FROM ' . prefixTable('sharekeys_files').'
2782 2782
             WHERE object_id = %i AND user_id = %i',
2783 2783
             $record['id'],
2784 2784
             $session->get('user-id')
@@ -2810,7 +2810,7 @@  discard block
 block discarded – undo
2810 2810
             if ((int) $post_user_id !== (int) $session->get('user-id')) {
2811 2811
                 $currentUserKey = DB::queryFirstRow(
2812 2812
                     'SELECT increment_id
2813
-                    FROM ' . prefixTable('sharekeys_items') . '
2813
+                    FROM ' . prefixTable('sharekeys_items').'
2814 2814
                     WHERE object_id = %i AND user_id = %i',
2815 2815
                     $record['id'],
2816 2816
                     $post_user_id
@@ -2832,8 +2832,8 @@  discard block
 block discarded – undo
2832 2832
     // SHould we change step?
2833 2833
     DB::query(
2834 2834
         'SELECT *
2835
-        FROM ' . prefixTable('files') . '
2836
-        WHERE status = "' . TP_ENCRYPTION_NAME . '"'
2835
+        FROM ' . prefixTable('files').'
2836
+        WHERE status = "' . TP_ENCRYPTION_NAME.'"'
2837 2837
     );
2838 2838
 
2839 2839
     $next_start = (int) $post_start + (int) $post_length;
@@ -2866,9 +2866,9 @@  discard block
 block discarded – undo
2866 2866
     if (count($session->get('user-personal_folders')) > 0) {
2867 2867
         $rows = DB::query(
2868 2868
             'SELECT id, pw
2869
-            FROM ' . prefixTable('items') . '
2869
+            FROM ' . prefixTable('items').'
2870 2870
             WHERE perso = 1 AND id_tree IN %ls AND encryption_type = %s
2871
-            LIMIT ' . $post_start . ', ' . $post_length,
2871
+            LIMIT ' . $post_start.', '.$post_length,
2872 2872
             $session->get('user-personal_folders'),
2873 2873
             "defuse"
2874 2874
         );
@@ -2876,7 +2876,7 @@  discard block
 block discarded – undo
2876 2876
             // Get itemKey from current user
2877 2877
             $currentUserKey = DB::queryFirstRow(
2878 2878
                 'SELECT share_key, increment_id
2879
-                FROM ' . prefixTable('sharekeys_items') . '
2879
+                FROM ' . prefixTable('sharekeys_items').'
2880 2880
                 WHERE object_id = %i AND user_id = %i',
2881 2881
                 $record['id'],
2882 2882
                 $session->get('user-id')
@@ -2903,7 +2903,7 @@  discard block
 block discarded – undo
2903 2903
                 if ((int) $post_user_id !== (int) $session->get('user-id')) {
2904 2904
                     $currentUserKey = DB::queryFirstRow(
2905 2905
                         'SELECT increment_id
2906
-                        FROM ' . prefixTable('sharekeys_items') . '
2906
+                        FROM ' . prefixTable('sharekeys_items').'
2907 2907
                         WHERE object_id = %i AND user_id = %i',
2908 2908
                         $record['id'],
2909 2909
                         $post_user_id
@@ -2926,7 +2926,7 @@  discard block
 block discarded – undo
2926 2926
     // SHould we change step?
2927 2927
     DB::query(
2928 2928
         'SELECT *
2929
-        FROM ' . prefixTable('items') . '
2929
+        FROM ' . prefixTable('items').'
2930 2930
         WHERE perso = 0'
2931 2931
     );
2932 2932
 
@@ -2954,7 +2954,7 @@  discard block
 block discarded – undo
2954 2954
         // Check if user exists
2955 2955
         $userInfo = DB::queryFirstRow(
2956 2956
             'SELECT public_key, encrypted_psk
2957
-            FROM ' . prefixTable('users') . '
2957
+            FROM ' . prefixTable('users').'
2958 2958
             WHERE id = %i',
2959 2959
             $post_user_id
2960 2960
         );
@@ -2980,7 +2980,7 @@  discard block
 block discarded – undo
2980 2980
                 if ($post_counterItemsToTreat === -1) {
2981 2981
                     DB::query(
2982 2982
                         'SELECT id
2983
-                        FROM ' . prefixTable('items') . '
2983
+                        FROM ' . prefixTable('items').'
2984 2984
                         WHERE perso = 1 AND id_tree IN %ls AND encryption_type != %s',
2985 2985
                         $session->get('user-personal_folders'),
2986 2986
                         'teampass_aes'
@@ -2993,7 +2993,7 @@  discard block
 block discarded – undo
2993 2993
                 // Loop on persoanl items
2994 2994
                 $rows = DB::query(
2995 2995
                     'SELECT id, pw
2996
-                    FROM ' . prefixTable('items') . '
2996
+                    FROM ' . prefixTable('items').'
2997 2997
                     WHERE perso = 1 AND id_tree IN %ls AND encryption_type != %s
2998 2998
                     LIMIT ' . $post_length,
2999 2999
                     $session->get('user-personal_folders'),
@@ -3037,7 +3037,7 @@  discard block
 block discarded – undo
3037 3037
                     // Loop on files
3038 3038
                     $rows = DB::query(
3039 3039
                         'SELECT id, file
3040
-                        FROM ' . prefixTable('files') . '
3040
+                        FROM ' . prefixTable('files').'
3041 3041
                         WHERE status != %s
3042 3042
                         AND id_item = %i',
3043 3043
                         TP_ENCRYPTION_NAME,
@@ -3048,13 +3048,13 @@  discard block
 block discarded – undo
3048 3048
                         // Now decrypt the file
3049 3049
                         prepareFileWithDefuse(
3050 3050
                             'decrypt',
3051
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record2['file'],
3052
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record2['file'] . '.delete',
3051
+                            $SETTINGS['path_to_upload_folder'].'/'.$record2['file'],
3052
+                            $SETTINGS['path_to_upload_folder'].'/'.$record2['file'].'.delete',
3053 3053
                             $post_user_psk
3054 3054
                         );
3055 3055
 
3056 3056
                         // Encrypt the file
3057
-                        $encryptedFile = encryptFile($record2['file'] . '.delete', $SETTINGS['path_to_upload_folder']);
3057
+                        $encryptedFile = encryptFile($record2['file'].'.delete', $SETTINGS['path_to_upload_folder']);
3058 3058
 
3059 3059
                         DB::update(
3060 3060
                             prefixTable('files'),
@@ -3077,7 +3077,7 @@  discard block
 block discarded – undo
3077 3077
                         );
3078 3078
 
3079 3079
                         // Unlink original file
3080
-                        unlink($SETTINGS['path_to_upload_folder'] . '/' . $record2['file']);
3080
+                        unlink($SETTINGS['path_to_upload_folder'].'/'.$record2['file']);
3081 3081
                     }
3082 3082
                 }
3083 3083
 
@@ -3085,7 +3085,7 @@  discard block
 block discarded – undo
3085 3085
                 $next_start = (int) $post_start + (int) $post_length;
3086 3086
                 DB::query(
3087 3087
                     'SELECT id
3088
-                    FROM ' . prefixTable('items') . '
3088
+                    FROM ' . prefixTable('items').'
3089 3089
                     WHERE perso = 1 AND id_tree IN %ls AND encryption_type != %s',
3090 3090
                     $session->get('user-personal_folders'),
3091 3091
                     'teampass_aes'
@@ -3155,7 +3155,7 @@  discard block
 block discarded – undo
3155 3155
         // Get user info
3156 3156
         $userData = DB::queryFirstRow(
3157 3157
             'SELECT special, auth_type, is_ready_for_usage, ongoing_process_id, otp_provided, keys_recovery_time
3158
-            FROM ' . prefixTable('users') . '
3158
+            FROM ' . prefixTable('users').'
3159 3159
             WHERE id = %i',
3160 3160
             $post_user_id
3161 3161
         );
@@ -3202,7 +3202,7 @@  discard block
 block discarded – undo
3202 3202
         // Get user info
3203 3203
         $userData = DB::queryFirstRow(
3204 3204
             'SELECT auth_type, login, private_key
3205
-            FROM ' . prefixTable('users') . '
3205
+            FROM ' . prefixTable('users').'
3206 3206
             WHERE id = %i',
3207 3207
             $post_user_id
3208 3208
         );
@@ -3252,7 +3252,7 @@  discard block
 block discarded – undo
3252 3252
                 return prepareExchangedData(
3253 3253
                     array(
3254 3254
                         'error' => false,
3255
-                        'message' => $lang->get('done'),'',
3255
+                        'message' => $lang->get('done'), '',
3256 3256
                     ),
3257 3257
                     'encode'
3258 3258
                 );
@@ -3300,7 +3300,7 @@  discard block
 block discarded – undo
3300 3300
         // Get user info
3301 3301
         $userData = DB::queryFirstRow(
3302 3302
             'SELECT auth_type, login, private_key, special
3303
-            FROM ' . prefixTable('users') . '
3303
+            FROM ' . prefixTable('users').'
3304 3304
             WHERE id = %i',
3305 3305
             $post_user_id
3306 3306
         );
@@ -3334,7 +3334,7 @@  discard block
 block discarded – undo
3334 3334
                 return prepareExchangedData(
3335 3335
                     array(
3336 3336
                         'error' => false,
3337
-                        'message' => $lang->get('done'),'',
3337
+                        'message' => $lang->get('done'), '',
3338 3338
                     ),
3339 3339
                     'encode'
3340 3340
                 );
@@ -3356,8 +3356,8 @@  discard block
 block discarded – undo
3356 3356
             // Get one itemKey from current user
3357 3357
             $currentUserKey = DB::queryFirstRow(
3358 3358
                 'SELECT ski.share_key, ski.increment_id, l.id_user
3359
-                FROM ' . prefixTable('sharekeys_items') . ' AS ski
3360
-                INNER JOIN ' . prefixTable('log_items') . ' AS l ON ski.object_id = l.id_item
3359
+                FROM ' . prefixTable('sharekeys_items').' AS ski
3360
+                INNER JOIN ' . prefixTable('log_items').' AS l ON ski.object_id = l.id_item
3361 3361
                 WHERE ski.user_id = %i
3362 3362
                 ORDER BY RAND()
3363 3363
                 LIMIT 1',
@@ -3447,7 +3447,7 @@  discard block
 block discarded – undo
3447 3447
             $session->get('user-id')
3448 3448
         );
3449 3449
         // Return data
3450
-        return '[{"new_value":"' . $session->get('user-session_duration') . '"}]';
3450
+        return '[{"new_value":"'.$session->get('user-session_duration').'"}]';
3451 3451
     }
3452 3452
     
3453 3453
     return '[{"new_value":"expired"}]';
Please login to merge, or discard this patch.