Passed
Push — master ( 29ea3c...1f091d )
by Nils
10:51
created
index.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -80,8 +80,9 @@  discard block
 block discarded – undo
80 80
 $session = SessionManager::getSession();
81 81
 
82 82
 // Random encryption key
83
-if ($session->get('key') === null)
83
+if ($session->get('key') === null) {
84 84
     $session->set('key', generateQuickPassword(30, false));
85
+}
85 86
 
86 87
 $request = SymfonyRequest::createFromGlobals();
87 88
 $configManager = new ConfigManager();
@@ -980,7 +981,10 @@  discard block
 block discarded – undo
980 981
                                     <input type="password" class="form-control" id="dialog-ldap-user-build-keys-database-code">
981 982
                                     <br/>
982 983
                                 </div>
983
-                                <div class="input-group mb-3<?php if ($session_auth_type === 'oauth2') echo ' hidden'; ?>">
984
+                                <div class="input-group mb-3<?php if ($session_auth_type === 'oauth2') {
985
+    echo ' hidden';
986
+}
987
+?>">
984 988
                                     <div class="input-group-prepend">
985 989
                                         <span class="input-group-text"><?php echo $lang->get('provide_your_current_password'); ?></span>
986 990
                                     </div>
Please login to merge, or discard this patch.
includes/language/english.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@
 block discarded – undo
28 28
  * @see       https://www.teampass.net
29 29
  */
30 30
 
31
- // TO REMOVE
32
- // - selected_items_to_be_imported
31
+    // TO REMOVE
32
+    // - selected_items_to_be_imported
33 33
 
34 34
 return array(
35 35
     'suggested_value' => 'Suggested value',
Please login to merge, or discard this patch.
api/Controller/Api/BaseController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         $requestUri = $request->getRequestUri();
48 48
 
49 49
         $uri = parse_url($requestUri, PHP_URL_PATH);
50
-        $uri = explode( '/', $uri );
50
+        $uri = explode('/', $uri);
51 51
         return $this->sanitizeUrl(array_slice($uri, ((int) array_search('index.php', $uri) + 1)));
52 52
     }
53 53
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     {
61 61
         $request = symfonyRequest::createFromGlobals();
62 62
         $queryString = $request->getQueryString();
63
-<<<<<<< HEAD
63
+<< << <<< HEAD
64 64
         if ($request->getContentTypeFormat() !== 'json') {
65 65
 =======
66 66
         if ($request->getContentTypeFormat() != 'application/json') {
Please login to merge, or discard this patch.
sources/downloadFile.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 ) {
77 77
     // Not allowed page
78 78
     $session->set('system-error_code', ERR_NOT_ALLOWED);
79
-    include $SETTINGS['cpassman_dir'] . '/error.php';
79
+    include $SETTINGS['cpassman_dir'].'/error.php';
80 80
     exit;
81 81
 }
82 82
 
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
 $get_filename = str_replace('"', '\"', $get_filename);
119 119
 
120 120
 // Use Content-Disposition header with double quotes around filename
121
-header('Content-Disposition: attachment; filename="' . rawurldecode($get_filename) . '"');
121
+header('Content-Disposition: attachment; filename="'.rawurldecode($get_filename).'"');
122 122
 header('Content-Type: application/octet-stream');
123 123
 header('Cache-Control: must-revalidate, no-cache, no-store');
124 124
 header('Expires: 0');
125 125
 if (null !== $request->query->get('pathIsFiles') && (int) $get_pathIsFiles === 1) {
126
-    $filepath = $SETTINGS['path_to_files_folder'] . '/' . basename($get_filename);
126
+    $filepath = $SETTINGS['path_to_files_folder'].'/'.basename($get_filename);
127 127
     
128 128
     // Check if the file exists and is within the allowed directory
129 129
     if (!userHasAccessToFile($session->get('user-id'), $get_fileid)) {
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
     $file_info = DB::queryFirstRow(
139 139
         'SELECT f.id AS id, f.file AS file, f.name AS name, f.status AS status, f.extension AS extension,
140 140
         s.share_key AS share_key
141
-        FROM ' . prefixTable('files') . ' AS f
142
-        INNER JOIN ' . prefixTable('sharekeys_files') . ' AS s ON (f.id = s.object_id)
141
+        FROM ' . prefixTable('files').' AS f
142
+        INNER JOIN ' . prefixTable('sharekeys_files').' AS s ON (f.id = s.object_id)
143 143
         WHERE s.user_id = %i AND s.object_id = %i',
144 144
         $session->get('user-id'),
145 145
         $get_fileid
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
         // if not encrypted
159 159
         $file_info = DB::queryFirstRow(
160 160
             'SELECT f.id AS id, f.file AS file, f.name AS name, f.status AS status, f.extension AS extension
161
-            FROM ' . prefixTable('files') . ' AS f
161
+            FROM ' . prefixTable('files').' AS f
162 162
             WHERE f.id = %i',
163 163
             $get_fileid
164 164
         );
@@ -166,28 +166,28 @@  discard block
 block discarded – undo
166 166
     }
167 167
 
168 168
     // Set the filename of the download
169
-    $filename = str_replace('b64:','', $file_info['name']);
169
+    $filename = str_replace('b64:', '', $file_info['name']);
170 170
     $filename = basename($filename, '.'.$file_info['extension']);
171 171
     $filename = isBase64($filename) === true ? base64_decode($filename) : $filename;
172
-    $filename = $filename . '.' . $file_info['extension'];
172
+    $filename = $filename.'.'.$file_info['extension'];
173 173
     // Get the full path to the file to be downloaded
174
-    if (file_exists($SETTINGS['path_to_upload_folder'] . '/' .TP_FILE_PREFIX . $file_info['file'])) {
175
-        $filePath = $SETTINGS['path_to_upload_folder'] . '/' . TP_FILE_PREFIX . $file_info['file'];
174
+    if (file_exists($SETTINGS['path_to_upload_folder'].'/'.TP_FILE_PREFIX.$file_info['file'])) {
175
+        $filePath = $SETTINGS['path_to_upload_folder'].'/'.TP_FILE_PREFIX.$file_info['file'];
176 176
     } else {
177
-        $filePath = $SETTINGS['path_to_upload_folder'] . '/' . TP_FILE_PREFIX . base64_decode($file_info['file']);
177
+        $filePath = $SETTINGS['path_to_upload_folder'].'/'.TP_FILE_PREFIX.base64_decode($file_info['file']);
178 178
     }
179 179
     $filePath = realpath($filePath);
180 180
 
181
-    if (WIP === true) error_log('downloadFile.php: filePath: ' . $filePath." - ");
181
+    if (WIP === true) error_log('downloadFile.php: filePath: '.$filePath." - ");
182 182
 
183 183
     if ($filePath && is_readable($filePath) && strpos($filePath, realpath($SETTINGS['path_to_upload_folder'])) === 0) {
184 184
         header('Content-Description: File Transfer');
185 185
         header('Content-Type: application/octet-stream');
186
-        header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
186
+        header('Content-Disposition: attachment; filename="'.basename($filename).'"');
187 187
         header('Expires: 0');
188 188
         header('Cache-Control: must-revalidate');
189 189
         header('Pragma: public');
190
-        header('Content-Length: ' . filesize($filePath));
190
+        header('Content-Length: '.filesize($filePath));
191 191
         flush(); // Clear system output buffer
192 192
         if (empty($fileContent) === true) {
193 193
             // deepcode ignore PT: File and path are secured directly inside the function decryptFile()
Please login to merge, or discard this patch.
sources/identify.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     $sessionPwdAttempts = $session->get('pwd_attempts');
148 148
     $sessionUrl = $session->get('user-initial_url');
149 149
     $server = [];
150
-    $server['PHP_AUTH_USER'] =  $request->getUser();
150
+    $server['PHP_AUTH_USER'] = $request->getUser();
151 151
     $server['PHP_AUTH_PW'] = $request->getPassword();
152 152
     
153 153
     // decrypt and retreive data in JSON format
@@ -167,18 +167,18 @@  discard block
 block discarded – undo
167 167
     }
168 168
 
169 169
     // Check if Duo auth is in progress and pass the pw and login back to the standard login process
170
-    if(
170
+    if (
171 171
         isKeyExistingAndEqual('duo', 1, $SETTINGS) === true
172 172
         && $dataReceived['user_2fa_selection'] === 'duo'
173 173
         && $session->get('user-duo_status') === 'IN_PROGRESS'
174 174
         && !empty($dataReceived['duo_state'])
175
-    ){
175
+    ) {
176 176
         $key = hash('sha256', $dataReceived['duo_state']);
177 177
         $iv = substr(hash('sha256', $dataReceived['duo_state']), 0, 16);
178 178
         $duo_data_dec = openssl_decrypt(base64_decode($session->get('user-duo_data')), 'AES-256-CBC', $key, 0, $iv);
179 179
         // Clear the data from the Duo process to continue clean with the standard login process
180
-        $session->set('user-duo_data','');
181
-        if($duo_data_dec === false) {
180
+        $session->set('user-duo_data', '');
181
+        if ($duo_data_dec === false) {
182 182
             // Add failed authentication log
183 183
             addFailedAuthentication(filter_var($dataReceived['login'], FILTER_SANITIZE_FULL_SPECIAL_CHARS), getClientIpServer());
184 184
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         $dataReceived['login'] = $duo_data['duo_login'];
197 197
     }
198 198
 
199
-    if(isset($dataReceived['pw']) === false || isset($dataReceived['login']) === false) {
199
+    if (isset($dataReceived['pw']) === false || isset($dataReceived['login']) === false) {
200 200
         echo json_encode([
201 201
             'data' => prepareExchangedData(
202 202
                 [
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
         }
556 556
         // Append with roles from AD groups
557 557
         if (is_null($userInfo['roles_from_ad_groups']) === false) {
558
-            $userInfo['fonction_id'] = empty($userInfo['fonction_id'])  === true ? $userInfo['roles_from_ad_groups'] : $userInfo['fonction_id']. ';' . $userInfo['roles_from_ad_groups'];
558
+            $userInfo['fonction_id'] = empty($userInfo['fonction_id']) === true ? $userInfo['roles_from_ad_groups'] : $userInfo['fonction_id'].';'.$userInfo['roles_from_ad_groups'];
559 559
         }
560 560
         // store
561 561
         $session->set('user-roles', $userInfo['fonction_id']);
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
         if (count($session->get('user-roles_array')) > 0) {
568 568
             $rolesList = DB::query(
569 569
                 'SELECT id, title, complexity
570
-                FROM ' . prefixTable('roles_title') . '
570
+                FROM ' . prefixTable('roles_title').'
571 571
                 WHERE id IN %li',
572 572
                 $session->get('user-roles_array')
573 573
             );
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
             if ($adjustPermissions) {
614 614
                 $session->set('user-admin', (int) $userInfo['admin']);
615 615
                 $session->set('user-manager', (int) $userInfo['gestionnaire']);
616
-                $session->set('user-can_manage_all_users',(int)  $userInfo['can_manage_all_users']);
616
+                $session->set('user-can_manage_all_users', (int) $userInfo['can_manage_all_users']);
617 617
                 $session->set('user-read_only', (int) $userInfo['read_only']);
618 618
                 DB::update(
619 619
                     prefixTable('users'),
@@ -682,10 +682,10 @@  discard block
 block discarded – undo
682 682
         // Get last seen items
683 683
         $session->set('user-nb_roles', 0);
684 684
         foreach ($session->get('user-latest_items') as $item) {
685
-            if (! empty($item)) {
685
+            if (!empty($item)) {
686 686
                 $dataLastItems = DB::queryFirstRow(
687 687
                     'SELECT id,label,id_tree
688
-                    FROM ' . prefixTable('items') . '
688
+                    FROM ' . prefixTable('items').'
689 689
                     WHERE id=%i',
690 690
                     $item
691 691
                 );
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
         // Get cahce tree info
696 696
         $cacheTreeData = DB::queryFirstRow(
697 697
             'SELECT visible_folders
698
-            FROM ' . prefixTable('cache_tree') . '
698
+            FROM ' . prefixTable('cache_tree').'
699 699
             WHERE user_id=%i',
700 700
             (int) $session->get('user-id')
701 701
         );
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
             && (int) $sessionAdmin !== 1
728 728
         ) {
729 729
             // get all Admin users
730
-            $val = DB::queryFirstRow('SELECT email FROM ' . prefixTable('users') . " WHERE admin = %i and email != ''", 1);
730
+            $val = DB::queryFirstRow('SELECT email FROM '.prefixTable('users')." WHERE admin = %i and email != ''", 1);
731 731
             if (DB::count() > 0) {
732 732
                 // Add email to table
733 733
                 prepareSendingEmail(
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
                             '#tp_time#',
740 740
                         ],
741 741
                         [
742
-                            ' ' . $session->get('user-login') . ' (IP: ' . getClientIpServer() . ')',
742
+                            ' '.$session->get('user-login').' (IP: '.getClientIpServer().')',
743 743
                             date($SETTINGS['date_format'], (int) $session->get('user-last_connection')),
744 744
                             date($SETTINGS['time_format'], (int) $session->get('user-last_connection')),
745 745
                         ],
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 {
851 851
     $rows = DB::query(
852 852
         'SELECT date
853
-        FROM ' . prefixTable('log_system') . "
853
+        FROM ' . prefixTable('log_system')."
854 854
         WHERE field_1 = %s
855 855
         AND type = 'failed_auth'
856 856
         AND label = 'password_is_not_correct'
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
         foreach ($rows as $record) {
865 865
             array_push(
866 866
                 $arrAttempts,
867
-                date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['date'])
867
+                date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['date'])
868 868
             );
869 869
         }
870 870
     }
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
     $ldapConnection
900 900
 ) : bool
901 901
 {
902
-    include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
902
+    include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
903 903
 
904 904
     if ((int) $userInfoDisabled === 1) {
905 905
         return false;
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
     } catch (Exception $e) {
1095 1095
         return [
1096 1096
             'error' => true,
1097
-            'message' => "Error: " . $e->getMessage(),
1097
+            'message' => "Error: ".$e->getMessage(),
1098 1098
         ];
1099 1099
     }
1100 1100
 }
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
                 'type' => 'OpenLDAP'
1126 1126
             ];
1127 1127
         default:
1128
-            throw new Exception("Unsupported LDAP type: " . $SETTINGS['ldap_type']);
1128
+            throw new Exception("Unsupported LDAP type: ".$SETTINGS['ldap_type']);
1129 1129
     }
1130 1130
 }
1131 1131
 
@@ -1262,7 +1262,7 @@  discard block
 block discarded – undo
1262 1262
         );
1263 1263
     }
1264 1264
     
1265
-    throw new Exception("Unsupported LDAP type: " . $ldapHandler['type']);
1265
+    throw new Exception("Unsupported LDAP type: ".$ldapHandler['type']);
1266 1266
 }
1267 1267
 
1268 1268
 /**
@@ -1279,12 +1279,12 @@  discard block
 block discarded – undo
1279 1279
     if (isset($SETTINGS['enable_ad_users_with_ad_groups']) === true && (int) $SETTINGS['enable_ad_users_with_ad_groups'] === 1) {
1280 1280
         // Get user groups from AD
1281 1281
         $user_ad_groups = [];
1282
-        foreach($groups as $group) {
1282
+        foreach ($groups as $group) {
1283 1283
             //print_r($group);
1284 1284
             // get relation role id for AD group
1285 1285
             $role = DB::queryFirstRow(
1286 1286
                 'SELECT lgr.role_id
1287
-                FROM ' . prefixTable('ldap_groups_roles') . ' AS lgr
1287
+                FROM ' . prefixTable('ldap_groups_roles').' AS lgr
1288 1288
                 WHERE lgr.ldap_group_id = %s',
1289 1289
                 $group
1290 1290
             );
@@ -1347,7 +1347,7 @@  discard block
 block discarded – undo
1347 1347
     $passwordManager = new PasswordManager();
1348 1348
     
1349 1349
     // Migrate password if needed
1350
-    $result  = $passwordManager->migratePassword(
1350
+    $result = $passwordManager->migratePassword(
1351 1351
         $userInfo['pw'],
1352 1352
         $passwordClear,
1353 1353
         (int) $userInfo['id']
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
             // Check if exists in DB
1419 1419
             $groupData = DB::queryFirstRow(
1420 1420
                 'SELECT id
1421
-                FROM ' . prefixTable('roles_title') . '
1421
+                FROM ' . prefixTable('roles_title').'
1422 1422
                 WHERE title = %s',
1423 1423
                 $group["displayName"]
1424 1424
             );
@@ -1559,7 +1559,7 @@  discard block
 block discarded – undo
1559 1559
             
1560 1560
             // generate new QR
1561 1561
             $new_2fa_qr = $tfa->getQRCodeImageAsDataUri(
1562
-                'Teampass - ' . $username,
1562
+                'Teampass - '.$username,
1563 1563
                 $userInfo['ga']
1564 1564
             );
1565 1565
             // clear temporary code from DB
@@ -1572,7 +1572,7 @@  discard block
 block discarded – undo
1572 1572
                 $userInfo['id']
1573 1573
             );
1574 1574
             $firstTime = [
1575
-                'value' => '<img src="' . $new_2fa_qr . '">',
1575
+                'value' => '<img src="'.$new_2fa_qr.'">',
1576 1576
                 'user_admin' => isset($sessionAdmin) ? (int) $sessionAdmin : '',
1577 1577
                 'initial_url' => isset($sessionUrl) === true ? $sessionUrl : '',
1578 1578
                 'pwd_attempts' => (int) $sessionPwdAttempts,
@@ -1728,7 +1728,7 @@  discard block
 block discarded – undo
1728 1728
         }*/
1729 1729
         return [
1730 1730
             'error' => true,
1731
-            'message' => $duo_error . $lang->get('duo_error_check_config'),
1731
+            'message' => $duo_error.$lang->get('duo_error_check_config'),
1732 1732
             'pwd_attempts' => (int) $sessionPwdAttempts,
1733 1733
             'debug_message' => $e->getMessage(),
1734 1734
             'proceedIdentification' => false,
@@ -1744,7 +1744,7 @@  discard block
 block discarded – undo
1744 1744
         } catch (DuoException $e) {
1745 1745
             return [
1746 1746
                 'error' => true,
1747
-                'message' => $duo_error . $lang->get('duo_error_url'),
1747
+                'message' => $duo_error.$lang->get('duo_error_url'),
1748 1748
                 'pwd_attempts' => (int) $sessionPwdAttempts,
1749 1749
                 'debug_message' => $e->getMessage(),
1750 1750
                 'proceedIdentification' => false,
@@ -1752,7 +1752,7 @@  discard block
 block discarded – undo
1752 1752
         }
1753 1753
         
1754 1754
         // Somethimes Duo return success but fail to return a URL, double check if the URL has been created
1755
-        if (!empty($duo_redirect_url) && filter_var($duo_redirect_url,FILTER_SANITIZE_URL)) {
1755
+        if (!empty($duo_redirect_url) && filter_var($duo_redirect_url, FILTER_SANITIZE_URL)) {
1756 1756
             // Since Duo Universal requires a redirect, let's store some info when the user get's back after completing the Duo prompt
1757 1757
             $key = hash('sha256', $duo_state);
1758 1758
             $iv = substr(hash('sha256', $duo_state), 0, 16);
@@ -1780,7 +1780,7 @@  discard block
 block discarded – undo
1780 1780
         } else {
1781 1781
             return [
1782 1782
                 'error' => true,
1783
-                'message' => $duo_error . $lang->get('duo_error_url'),
1783
+                'message' => $duo_error.$lang->get('duo_error_url'),
1784 1784
                 'pwd_attempts' => (int) $sessionPwdAttempts,
1785 1785
                 'proceedIdentification' => false,
1786 1786
             ];
@@ -1801,8 +1801,8 @@  discard block
 block discarded – undo
1801 1801
         // return the response (which should be the user name)
1802 1802
         if ($decoded_token['preferred_username'] === $username) {
1803 1803
             $session->set('user-duo_status', 'COMPLET');
1804
-            $session->set('user-duo_state','');
1805
-            $session->set('user-duo_data','');
1804
+            $session->set('user-duo_state', '');
1805
+            $session->set('user-duo_data', '');
1806 1806
             $session->set('user-login', $username);
1807 1807
 
1808 1808
             return [
@@ -1813,9 +1813,9 @@  discard block
 block discarded – undo
1813 1813
             ];
1814 1814
         } else {
1815 1815
             // Something wrong, username from the original Duo request is different than the one received now
1816
-            $session->set('user-duo_status','');
1817
-            $session->set('user-duo_state','');
1818
-            $session->set('user-duo_data','');
1816
+            $session->set('user-duo_status', '');
1817
+            $session->set('user-duo_state', '');
1818
+            $session->set('user-duo_data', '');
1819 1819
 
1820 1820
             return [
1821 1821
                 'error' => true,
@@ -1826,9 +1826,9 @@  discard block
 block discarded – undo
1826 1826
         }
1827 1827
     }
1828 1828
     // If we are here something wrong
1829
-    $session->set('user-duo_status','');
1830
-    $session->set('user-duo_state','');
1831
-    $session->set('user-duo_data','');
1829
+    $session->set('user-duo_status', '');
1830
+    $session->set('user-duo_state', '');
1831
+    $session->set('user-duo_data', '');
1832 1832
     return [
1833 1833
         'error' => true,
1834 1834
         'message' => $lang->get('duo_login_mismatch'),
@@ -1947,7 +1947,7 @@  discard block
 block discarded – undo
1947 1947
         // Check for existing lock
1948 1948
         $unlock_at = DB::queryFirstField(
1949 1949
             'SELECT MAX(unlock_at)
1950
-             FROM ' . prefixTable('auth_failures') . '
1950
+             FROM ' . prefixTable('auth_failures').'
1951 1951
              WHERE unlock_at > %s
1952 1952
              AND ((source = %s AND value = %s) OR (source = %s AND value = %s))',
1953 1953
             date('Y-m-d H:i:s', time()),
@@ -1969,8 +1969,8 @@  discard block
 block discarded – undo
1969 1969
         // Get user info from DB
1970 1970
         $data = DB::queryFirstRow(
1971 1971
             'SELECT u.*, a.value AS api_key
1972
-            FROM ' . prefixTable('users') . ' AS u
1973
-            LEFT JOIN ' . prefixTable('api') . ' AS a ON (u.id = a.user_id)
1972
+            FROM ' . prefixTable('users').' AS u
1973
+            LEFT JOIN ' . prefixTable('api').' AS a ON (u.id = a.user_id)
1974 1974
             WHERE login = %s AND deleted_at IS NULL',
1975 1975
             $login
1976 1976
         );
@@ -2088,7 +2088,7 @@  discard block
 block discarded – undo
2088 2088
             'array' => [
2089 2089
                 'value' => 'bruteforce_wait',
2090 2090
                 'error' => true,
2091
-                'message' => $lang->get('bruteforce_wait') . (string) $e->getMessage(),
2091
+                'message' => $lang->get('bruteforce_wait').(string) $e->getMessage(),
2092 2092
             ]
2093 2093
         ];
2094 2094
     }
@@ -2193,7 +2193,7 @@  discard block
 block discarded – undo
2193 2193
     // Clean previous failed attempts
2194 2194
     $failedTasks = DB::query(
2195 2195
         'SELECT increment_id
2196
-        FROM ' . prefixTable('background_tasks') . '
2196
+        FROM ' . prefixTable('background_tasks').'
2197 2197
         WHERE process_type = %s
2198 2198
         AND JSON_EXTRACT(arguments, "$.new_user_id") = %i
2199 2199
         AND status = %s',
@@ -2516,12 +2516,12 @@  discard block
 block discarded – undo
2516 2516
 {
2517 2517
     // Find the latest "create_user_keys" task for the given user_id
2518 2518
     $latestTask = DB::queryFirstRow(
2519
-        'SELECT arguments, status FROM ' . prefixTable('background_tasks') . '
2519
+        'SELECT arguments, status FROM '.prefixTable('background_tasks').'
2520 2520
         WHERE process_type = %s
2521 2521
         AND arguments LIKE %s
2522 2522
         ORDER BY increment_id DESC
2523 2523
         LIMIT 1',
2524
-        'create_user_keys', '%"new_user_id":' . $userId . '%'
2524
+        'create_user_keys', '%"new_user_id":'.$userId.'%'
2525 2525
     );
2526 2526
 
2527 2527
     // If a failed task is found, return an error message
@@ -2733,15 +2733,15 @@  discard block
 block discarded – undo
2733 2733
 
2734 2734
             if ($ret['error'] !== false) {
2735 2735
                 logEvents($SETTINGS, 'failed_auth', 'bad_duo_mfa', '', stripslashes($username), stripslashes($username));
2736
-                $session->set('user-duo_status','');
2737
-                $session->set('user-duo_state','');
2738
-                $session->set('user-duo_data','');
2736
+                $session->set('user-duo_status', '');
2737
+                $session->set('user-duo_state', '');
2738
+                $session->set('user-duo_data', '');
2739 2739
                 return [
2740 2740
                     'error' => true,
2741 2741
                     'mfaData' => $ret,
2742 2742
                     'mfaQRCodeInfos' => false,
2743 2743
                 ];
2744
-            } else if ($ret['duo_url_ready'] === true){
2744
+            } else if ($ret['duo_url_ready'] === true) {
2745 2745
                 return [
2746 2746
                     'error' => false,
2747 2747
                     'mfaData' => $ret,
@@ -2805,7 +2805,7 @@  discard block
 block discarded – undo
2805 2805
     // Count failed attempts from this source
2806 2806
     $count = DB::queryFirstField(
2807 2807
         'SELECT COUNT(*)
2808
-        FROM ' . prefixTable('auth_failures') . '
2808
+        FROM ' . prefixTable('auth_failures').'
2809 2809
         WHERE source = %s AND value = %s',
2810 2810
         $source,
2811 2811
         $value
Please login to merge, or discard this patch.
sources/admin.queries.php 1 patch
Spacing   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('admin') === false) {
73 73
     // Not allowed page
74 74
     $session->set('system-error_code', ERR_NOT_ALLOWED);
75
-    include $SETTINGS['cpassman_dir'] . '/error.php';
75
+    include $SETTINGS['cpassman_dir'].'/error.php';
76 76
     exit;
77 77
 }
78 78
 
@@ -133,14 +133,14 @@  discard block
 block discarded – undo
133 133
             break;
134 134
         }
135 135
 
136
-        require_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
136
+        require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
137 137
         $return = '';
138 138
 
139 139
         //Get all tables
140 140
         $tables = array();
141 141
         $result = DB::query('SHOW TABLES');
142 142
         foreach ($result as $row) {
143
-            $tables[] = $row['Tables_in_' . DB_NAME];
143
+            $tables[] = $row['Tables_in_'.DB_NAME];
144 144
         }
145 145
 
146 146
         //cycle through
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
             if (defined('DB_PREFIX') || substr_count($table, DB_PREFIX) > 0) {
149 149
                 $table = (is_string($table) ? $table : strval($table));
150 150
                 // Do query
151
-                $result = DB::query('SELECT * FROM ' . $table);
151
+                $result = DB::query('SELECT * FROM '.$table);
152 152
                 DB::query(
153 153
                     'SELECT *
154 154
                     FROM INFORMATION_SCHEMA.COLUMNS
@@ -160,20 +160,20 @@  discard block
 block discarded – undo
160 160
                 $numFields = DB::count();
161 161
 
162 162
                 // prepare a drop table
163
-                $return .= 'DROP TABLE ' . $table . ';';
164
-                $row2 = DB::queryFirstRow('SHOW CREATE TABLE ' . $table);
165
-                $return .= "\n\n" . strval($row2['Create Table']) . ";\n\n";
163
+                $return .= 'DROP TABLE '.$table.';';
164
+                $row2 = DB::queryFirstRow('SHOW CREATE TABLE '.$table);
165
+                $return .= "\n\n".strval($row2['Create Table']).";\n\n";
166 166
 
167 167
                 //prepare all fields and datas
168 168
                 for ($i = 0; $i < $numFields; ++$i) {
169 169
                     if (is_object($result)) {
170 170
                         while ($row = $result->fetch_row()) {
171
-                            $return .= 'INSERT INTO ' . $table . ' VALUES(';
171
+                            $return .= 'INSERT INTO '.$table.' VALUES(';
172 172
                             for ($j = 0; $j < $numFields; ++$j) {
173 173
                                 $row[$j] = addslashes($row[$j]);
174 174
                                 $row[$j] = preg_replace("/\n/", '\\n', $row[$j]);
175 175
                                 if (isset($row[$j])) {
176
-                                    $return .= '"' . $row[$j] . '"';
176
+                                    $return .= '"'.$row[$j].'"';
177 177
                                 } else {
178 178
                                     $return .= 'NULL';
179 179
                                 }
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
             $token = GenerateCryptKey(20, false, true, true, false, true);
195 195
 
196 196
             //save file
197
-            $filename = time() . '-' . $token . '.sql';
198
-            $handle = fopen($SETTINGS['path_to_files_folder'] . '/' . $filename, 'w+');
197
+            $filename = time().'-'.$token.'.sql';
198
+            $handle = fopen($SETTINGS['path_to_files_folder'].'/'.$filename, 'w+');
199 199
             if ($handle !== false) {
200 200
                 //write file
201 201
                 fwrite($handle, $return);
@@ -207,16 +207,16 @@  discard block
 block discarded – undo
207 207
                 // Encrypt the file
208 208
                 prepareFileWithDefuse(
209 209
                     'encrypt',
210
-                    $SETTINGS['path_to_files_folder'] . '/' . $filename,
211
-                    $SETTINGS['path_to_files_folder'] . '/defuse_temp_' . $filename,
210
+                    $SETTINGS['path_to_files_folder'].'/'.$filename,
211
+                    $SETTINGS['path_to_files_folder'].'/defuse_temp_'.$filename,
212 212
                     $post_option
213 213
                 );
214 214
 
215 215
                 // Do clean
216
-                unlink($SETTINGS['path_to_files_folder'] . '/' . $filename);
216
+                unlink($SETTINGS['path_to_files_folder'].'/'.$filename);
217 217
                 rename(
218
-                    $SETTINGS['path_to_files_folder'] . '/defuse_temp_' . $filename,
219
-                    $SETTINGS['path_to_files_folder'] . '/' . $filename
218
+                    $SETTINGS['path_to_files_folder'].'/defuse_temp_'.$filename,
219
+                    $SETTINGS['path_to_files_folder'].'/'.$filename
220 220
                 );
221 221
             }
222 222
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
             //update LOG
227 227
             logEvents($SETTINGS, 'admin_action', 'dataBase backup', (string) $session->get('user-id'), $session->get('user-login'));
228 228
 
229
-            echo '[{"result":"db_backup" , "href":"sources/downloadFile.php?name=' . urlencode($filename) . '&sub=files&file=' . $filename . '&type=sql&key=' . $session->get('key') . '&key_tmp=' . $session->get('user-key_tmp') . '&pathIsFiles=1"}]';
229
+            echo '[{"result":"db_backup" , "href":"sources/downloadFile.php?name='.urlencode($filename).'&sub=files&file='.$filename.'&type=sql&key='.$session->get('key').'&key_tmp='.$session->get('user-key_tmp').'&pathIsFiles=1"}]';
230 230
         }
231 231
         break;
232 232
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
             );
256 256
             break;
257 257
         }
258
-        include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
258
+        include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
259 259
 
260 260
         $dataPost = explode('&', $post_option);
261 261
         $file = htmlspecialchars($dataPost[0]);
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
         // Get filename from database
265 265
         $data = DB::queryFirstRow(
266 266
             'SELECT valeur
267
-            FROM ' . prefixTable('misc') . '
267
+            FROM ' . prefixTable('misc').'
268 268
             WHERE increment_id = %i',
269 269
             $file
270 270
         );
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
             // Decrypt the file
284 284
             $ret = prepareFileWithDefuse(
285 285
                 'decrypt',
286
-                $SETTINGS['path_to_files_folder'] . '/' . $file,
287
-                $SETTINGS['path_to_files_folder'] . '/defuse_temp_' . $file,
286
+                $SETTINGS['path_to_files_folder'].'/'.$file,
287
+                $SETTINGS['path_to_files_folder'].'/defuse_temp_'.$file,
288 288
                 $key
289 289
             );
290 290
 
@@ -295,10 +295,10 @@  discard block
 block discarded – undo
295 295
             }
296 296
 
297 297
             // Do clean
298
-            fileDelete($SETTINGS['path_to_files_folder'] . '/' . $file, $SETTINGS);
299
-            $file = $SETTINGS['path_to_files_folder'] . '/defuse_temp_' . $file;
298
+            fileDelete($SETTINGS['path_to_files_folder'].'/'.$file, $SETTINGS);
299
+            $file = $SETTINGS['path_to_files_folder'].'/defuse_temp_'.$file;
300 300
         } else {
301
-            $file = $SETTINGS['path_to_files_folder'] . '/' . $file;
301
+            $file = $SETTINGS['path_to_files_folder'].'/'.$file;
302 302
         }
303 303
 
304 304
         //read sql file
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
         fclose($handle);
316 316
 
317 317
         //delete file
318
-        unlink($SETTINGS['path_to_files_folder'] . '/' . $file);
318
+        unlink($SETTINGS['path_to_files_folder'].'/'.$file);
319 319
 
320 320
         //Show done
321 321
         echo '[{"result":"db_restore" , "message":""}]';
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
                 $tablename = (is_string($tablename) ? $tablename : strval($tablename));
355 355
                 if (substr_count($tablename, DB_PREFIX) > 0) {
356 356
                     // launch optimization quieries
357
-                    DB::query('ANALYZE TABLE `' . $tablename . '`');
358
-                    DB::query('OPTIMIZE TABLE `' . $tablename . '`');
357
+                    DB::query('ANALYZE TABLE `'.$tablename.'`');
358
+                    DB::query('OPTIMIZE TABLE `'.$tablename.'`');
359 359
                 }
360 360
             }
361 361
         }
@@ -363,12 +363,12 @@  discard block
 block discarded – undo
363 363
         //Clean up LOG_ITEMS table
364 364
         $rows = DB::query(
365 365
             'SELECT id
366
-            FROM ' . prefixTable('items') . '
366
+            FROM ' . prefixTable('items').'
367 367
             ORDER BY id ASC'
368 368
         );
369 369
         foreach ($rows as $item) {
370 370
             DB::query(
371
-                'SELECT * FROM ' . prefixTable('log_items') . ' WHERE id_item = %i AND action = %s',
371
+                'SELECT * FROM '.prefixTable('log_items').' WHERE id_item = %i AND action = %s',
372 372
                 $item['id'],
373 373
                 'at_creation'
374 374
             );
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
             if ($counter === 0) {
377 377
                 //Create new at_creation entry
378 378
                 $rowTmp = DB::queryFirstRow(
379
-                    'SELECT date, id_user FROM ' . prefixTable('log_items') . ' WHERE id_item=%i ORDER BY date ASC',
379
+                    'SELECT date, id_user FROM '.prefixTable('log_items').' WHERE id_item=%i ORDER BY date ASC',
380 380
                     $item['id']
381 381
                 );
382 382
                 DB::insert(
@@ -406,8 +406,8 @@  discard block
 block discarded – undo
406 406
         echo prepareExchangedData(
407 407
             array(
408 408
                 'error' => false,
409
-                'message' => $lang->get('last_execution') . ' ' .
410
-                    date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) time()) .
409
+                'message' => $lang->get('last_execution').' '.
410
+                    date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) time()).
411 411
                     '<i class="fas fa-check text-success ml-2"></i>',
412 412
             ),
413 413
             'encode'
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
             break;
444 444
         }
445 445
 
446
-        require_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
446
+        require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
447 447
         updateCacheTable('reload', NULL);
448 448
 
449 449
         // Log
@@ -459,8 +459,8 @@  discard block
 block discarded – undo
459 459
         echo prepareExchangedData(
460 460
             [
461 461
                 'error' => false,
462
-                'message' => $lang->get('last_execution') . ' ' .
463
-                    date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) time()) .
462
+                'message' => $lang->get('last_execution').' '.
463
+                    date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) time()).
464 464
                     '<i class="fas fa-check text-success mr-2"></i>',
465 465
             ],
466 466
             'encode'
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
         $session->set('user-reencrypt_old_salt', file_get_contents(SECUREPATH.'/'.SECUREFILE));
503 503
 
504 504
         // generate new saltkey
505
-        $old_sk_filename = SECUREPATH.'/'.SECUREFILE . date('Y_m_d', mktime(0, 0, 0, (int) date('m'), (int) date('d'), (int) date('y'))) . '.' . time();
505
+        $old_sk_filename = SECUREPATH.'/'.SECUREFILE.date('Y_m_d', mktime(0, 0, 0, (int) date('m'), (int) date('d'), (int) date('y'))).'.'.time();
506 506
         copy(
507 507
             SECUREPATH.'/'.SECUREFILE,
508 508
             $old_sk_filename
@@ -531,13 +531,13 @@  discard block
 block discarded – undo
531 531
         logEvents($SETTINGS, 'system', 'change_salt_key', (string) $session->get('user-id'), $session->get('user-login'));
532 532
 
533 533
         // get number of items to change
534
-        DB::query('SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i', 0);
534
+        DB::query('SELECT id FROM '.prefixTable('items').' WHERE perso = %i', 0);
535 535
         $nb_of_items = DB::count();
536 536
 
537 537
         // create backup table
538
-        DB::query('DROP TABLE IF EXISTS ' . prefixTable('sk_reencrypt_backup'));
538
+        DB::query('DROP TABLE IF EXISTS '.prefixTable('sk_reencrypt_backup'));
539 539
         DB::query(
540
-            'CREATE TABLE `' . prefixTable('sk_reencrypt_backup') . '` (
540
+            'CREATE TABLE `'.prefixTable('sk_reencrypt_backup').'` (
541 541
             `id` int(12) NOT null AUTO_INCREMENT,
542 542
             `current_table` varchar(100) NOT NULL,
543 543
             `current_field` varchar(500) NOT NULL,
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
         );
566 566
 
567 567
         // delete previous backup files
568
-        $files = glob($SETTINGS['path_to_upload_folder'] . '/*'); // get all file names
568
+        $files = glob($SETTINGS['path_to_upload_folder'].'/*'); // get all file names
569 569
         foreach ($files as $file) { // iterate files
570 570
             if (is_file($file)) {
571 571
                 $file_parts = pathinfo($file);
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
                 echo prepareExchangedData(
653 653
                     array(
654 654
                         'error' => true,
655
-                        'message' => 'Input `' . $objects[0] . '` is not allowed',
655
+                        'message' => 'Input `'.$objects[0].'` is not allowed',
656 656
                         'nbOfItems' => '',
657 657
                         'nextAction' => '',
658 658
                     ),
@@ -665,9 +665,9 @@  discard block
 block discarded – undo
665 665
                 //change all encrypted data in Items (passwords)
666 666
                 $rows = DB::query(
667 667
                     'SELECT id, pw, pw_iv
668
-                    FROM ' . prefixTable('items') . '
668
+                    FROM ' . prefixTable('items').'
669 669
                     WHERE perso = %s
670
-                    LIMIT ' . $post_start . ', ' . $post_length,
670
+                    LIMIT ' . $post_start.', '.$post_length,
671 671
                     '0'
672 672
                 );
673 673
                 foreach ($rows as $record) {
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
                             'current_field' => 'pw',
680 680
                             'value_id' => $record['id'],
681 681
                             'value' => $record['pw'],
682
-                            'current_sql' => 'UPDATE ' . prefixTable('items') . " SET pw = '" . $record['pw'] . "' WHERE id = '" . $record['id'] . "';",
682
+                            'current_sql' => 'UPDATE '.prefixTable('items')." SET pw = '".$record['pw']."' WHERE id = '".$record['id']."';",
683 683
                             'value2' => 'none',
684 684
                             'result' => 'none',
685 685
                         )
@@ -728,9 +728,9 @@  discard block
 block discarded – undo
728 728
                 //change all encrypted data in Logs (passwords)
729 729
                 $rows = DB::query(
730 730
                     'SELECT raison, increment_id
731
-                    FROM ' . prefixTable('log_items') . "
731
+                    FROM ' . prefixTable('log_items')."
732 732
                     WHERE action = %s AND raison LIKE 'at_pw :%'
733
-                    LIMIT " . $post_start . ', ' . $post_length,
733
+                    LIMIT " . $post_start.', '.$post_length,
734 734
                     'at_modification'
735 735
                 );
736 736
                 foreach ($rows as $record) {
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
                             'current_field' => 'raison',
743 743
                             'value_id' => $record['increment_id'],
744 744
                             'value' => $record['raison'],
745
-                            'current_sql' => 'UPDATE ' . prefixTable('log_items') . " SET raison = '" . $record['raison'] . "' WHERE increment_id = '" . $record['increment_id'] . "';",
745
+                            'current_sql' => 'UPDATE '.prefixTable('log_items')." SET raison = '".$record['raison']."' WHERE increment_id = '".$record['increment_id']."';",
746 746
                             'value2' => 'none',
747 747
                             'result' => 'none',
748 748
                         )
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
                         DB::update(
771 771
                             prefixTable('log_items'),
772 772
                             array(
773
-                                'raison' => 'at_pw :' . $encrypt['string'],
773
+                                'raison' => 'at_pw :'.$encrypt['string'],
774 774
                                 'encryption_type' => 'defuse',
775 775
                             ),
776 776
                             'increment_id = %i',
@@ -795,8 +795,8 @@  discard block
 block discarded – undo
795 795
                 //change all encrypted data in CATEGORIES (passwords)
796 796
                 $rows = DB::query(
797 797
                     'SELECT id, data
798
-                    FROM ' . prefixTable('categories_items') . '
799
-                    LIMIT ' . $post_start . ', ' . $post_length
798
+                    FROM ' . prefixTable('categories_items').'
799
+                    LIMIT ' . $post_start.', '.$post_length
800 800
                 );
801 801
                 foreach ($rows as $record) {
802 802
                     // backup data
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
                             'current_field' => 'data',
808 808
                             'value_id' => $record['id'],
809 809
                             'value' => $record['data'],
810
-                            'current_sql' => 'UPDATE ' . prefixTable('categories_items') . " SET data = '" . $record['data'] . "' WHERE id = '" . $record['id'] . "';",
810
+                            'current_sql' => 'UPDATE '.prefixTable('categories_items')." SET data = '".$record['data']."' WHERE id = '".$record['id']."';",
811 811
                             'value2' => 'none',
812 812
                             'result' => 'none',
813 813
                         )
@@ -855,9 +855,9 @@  discard block
 block discarded – undo
855 855
                 // Change all encrypted data in FILES (passwords)
856 856
                 $rows = DB::query(
857 857
                     'SELECT id, file, status
858
-                    FROM ' . prefixTable('files') . "
858
+                    FROM ' . prefixTable('files')."
859 859
                     WHERE status = 'encrypted'
860
-                    LIMIT " . $post_start . ', ' . $post_length
860
+                    LIMIT " . $post_start.', '.$post_length
861 861
                 );
862 862
                 foreach ($rows as $record) {
863 863
                     // backup data
@@ -875,20 +875,20 @@  discard block
 block discarded – undo
875 875
                     );
876 876
                     $newID = DB::insertId();
877 877
 
878
-                    if (file_exists($SETTINGS['path_to_upload_folder'] . '/' . $record['file'])) {
878
+                    if (file_exists($SETTINGS['path_to_upload_folder'].'/'.$record['file'])) {
879 879
                         // make a copy of file
880 880
                         if (!copy(
881
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record['file'],
882
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record['file'] . '.copy'
881
+                            $SETTINGS['path_to_upload_folder'].'/'.$record['file'],
882
+                            $SETTINGS['path_to_upload_folder'].'/'.$record['file'].'.copy'
883 883
                         )) {
884 884
                             $error = 'Copy not possible';
885 885
                             exit;
886 886
                         } else {
887 887
                             // prepare a bck of file (that will not be deleted)
888
-                            $backup_filename = $record['file'] . '.bck-change-sk.' . time();
888
+                            $backup_filename = $record['file'].'.bck-change-sk.'.time();
889 889
                             copy(
890
-                                $SETTINGS['path_to_upload_folder'] . '/' . $record['file'],
891
-                                $SETTINGS['path_to_upload_folder'] . '/' . $backup_filename
890
+                                $SETTINGS['path_to_upload_folder'].'/'.$record['file'],
891
+                                $SETTINGS['path_to_upload_folder'].'/'.$backup_filename
892 892
                             );
893 893
                         }
894 894
 
@@ -896,22 +896,22 @@  discard block
 block discarded – undo
896 896
                         // STEP1 - Do decryption
897 897
                         prepareFileWithDefuse(
898 898
                             'decrypt',
899
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record['file'],
900
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record['file'] . '_encrypted'
899
+                            $SETTINGS['path_to_upload_folder'].'/'.$record['file'],
900
+                            $SETTINGS['path_to_upload_folder'].'/'.$record['file'].'_encrypted'
901 901
                         );
902 902
 
903 903
                         // Do cleanup of files
904
-                        unlink($SETTINGS['path_to_upload_folder'] . '/' . $record['file']);
904
+                        unlink($SETTINGS['path_to_upload_folder'].'/'.$record['file']);
905 905
 
906 906
                         // STEP2 - Do encryption
907 907
                         prepareFileWithDefuse(
908 908
                             'encryp',
909
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record['file'] . '_encrypted',
910
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record['file']
909
+                            $SETTINGS['path_to_upload_folder'].'/'.$record['file'].'_encrypted',
910
+                            $SETTINGS['path_to_upload_folder'].'/'.$record['file']
911 911
                         );
912 912
 
913 913
                         // Do cleanup of files
914
-                        unlink($SETTINGS['path_to_upload_folder'] . '/' . $record['file'] . '_encrypted');
914
+                        unlink($SETTINGS['path_to_upload_folder'].'/'.$record['file'].'_encrypted');
915 915
 
916 916
                         // Update backup table
917 917
                         DB::update(
@@ -937,13 +937,13 @@  discard block
 block discarded – undo
937 937
                 // do some things for new object
938 938
                 if (isset($objects[0])) {
939 939
                     if ($objects[0] === 'logs') {
940
-                        DB::query('SELECT increment_id FROM ' . prefixTable('log_items') . " WHERE action = %s AND raison LIKE 'at_pw :%'", 'at_modification');
940
+                        DB::query('SELECT increment_id FROM '.prefixTable('log_items')." WHERE action = %s AND raison LIKE 'at_pw :%'", 'at_modification');
941 941
                     } elseif ($objects[0] === 'files') {
942
-                        DB::query('SELECT id FROM ' . prefixTable('files'));
942
+                        DB::query('SELECT id FROM '.prefixTable('files'));
943 943
                     } elseif ($objects[0] === 'categories') {
944
-                        DB::query('SELECT id FROM ' . prefixTable('categories_items'));
944
+                        DB::query('SELECT id FROM '.prefixTable('categories_items'));
945 945
                     } elseif ($objects[0] === 'custfields') {
946
-                        DB::query('SELECT raison FROM ' . prefixTable('log_items') . " WHERE action = %s AND raison LIKE 'at_pw :%'", 'at_modification');
946
+                        DB::query('SELECT raison FROM '.prefixTable('log_items')." WHERE action = %s AND raison LIKE 'at_pw :%'", 'at_modification');
947 947
                     }
948 948
                     $nb_of_items = DB::count();
949 949
                 } else {
@@ -1063,12 +1063,12 @@  discard block
 block discarded – undo
1063 1063
                 );
1064 1064
             } elseif ($record['current_table'] === 'files') {
1065 1065
                 // restore backup file
1066
-                if (file_exists($SETTINGS['path_to_upload_folder'] . '/' . $record['value'])) {
1067
-                    unlink($SETTINGS['path_to_upload_folder'] . '/' . $record['value']);
1068
-                    if (file_exists($SETTINGS['path_to_upload_folder'] . '/' . $record['value2'])) {
1066
+                if (file_exists($SETTINGS['path_to_upload_folder'].'/'.$record['value'])) {
1067
+                    unlink($SETTINGS['path_to_upload_folder'].'/'.$record['value']);
1068
+                    if (file_exists($SETTINGS['path_to_upload_folder'].'/'.$record['value2'])) {
1069 1069
                         rename(
1070
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record['value2'],
1071
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record['value']
1070
+                            $SETTINGS['path_to_upload_folder'].'/'.$record['value2'],
1071
+                            $SETTINGS['path_to_upload_folder'].'/'.$record['value']
1072 1072
                         );
1073 1073
                     }
1074 1074
                 }
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
         }
1088 1088
 
1089 1089
         // drop table
1090
-        DB::query('DROP TABLE IF EXISTS ' . prefixTable('sk_reencrypt_backup'));
1090
+        DB::query('DROP TABLE IF EXISTS '.prefixTable('sk_reencrypt_backup'));
1091 1091
 
1092 1092
         // Send back
1093 1093
         echo prepareExchangedData(
@@ -1130,17 +1130,17 @@  discard block
 block discarded – undo
1130 1130
         // delete files
1131 1131
         $rows = DB::query(
1132 1132
             'SELECT value, value2
1133
-            FROM ' . prefixTable('sk_reencrypt_backup') . "
1133
+            FROM ' . prefixTable('sk_reencrypt_backup')."
1134 1134
             WHERE current_table = 'files'"
1135 1135
         );
1136 1136
         foreach ($rows as $record) {
1137
-            if (file_exists($SETTINGS['path_to_upload_folder'] . '/' . $record['value2'])) {
1138
-                unlink($SETTINGS['path_to_upload_folder'] . '/' . $record['value2']);
1137
+            if (file_exists($SETTINGS['path_to_upload_folder'].'/'.$record['value2'])) {
1138
+                unlink($SETTINGS['path_to_upload_folder'].'/'.$record['value2']);
1139 1139
             }
1140 1140
         }
1141 1141
 
1142 1142
         // drop table
1143
-        DB::query('DROP TABLE IF EXISTS ' . prefixTable('sk_reencrypt_backup'));
1143
+        DB::query('DROP TABLE IF EXISTS '.prefixTable('sk_reencrypt_backup'));
1144 1144
 
1145 1145
         echo '[{"status":"done"}]';
1146 1146
         break;
@@ -1171,7 +1171,7 @@  discard block
 block discarded – undo
1171 1171
                 'encode'
1172 1172
             );
1173 1173
         } else {
1174
-            require_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
1174
+            require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
1175 1175
 
1176 1176
             //send email
1177 1177
             $emailSettings = new EmailSettings($SETTINGS);
@@ -1209,13 +1209,13 @@  discard block
 block discarded – undo
1209 1209
             break;
1210 1210
         }
1211 1211
 
1212
-        include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
1212
+        include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
1213 1213
         $emailSettings = new EmailSettings($SETTINGS);
1214 1214
         $emailService = new EmailService();
1215 1215
 
1216 1216
         $rows = DB::query(
1217 1217
             'SELECT *
1218
-            FROM ' . prefixTable('emails') . '
1218
+            FROM ' . prefixTable('emails').'
1219 1219
             WHERE status = %s OR status = %s',
1220 1220
             'not_sent',
1221 1221
             ''
@@ -1301,13 +1301,13 @@  discard block
 block discarded – undo
1301 1301
             break;
1302 1302
         }
1303 1303
 
1304
-        include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
1304
+        include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
1305 1305
 
1306 1306
         // Instatiate email settings and service
1307 1307
         $emailSettings = new EmailSettings($SETTINGS);
1308 1308
         $emailService = new EmailService();
1309 1309
 
1310
-        $rows = DB::query('SELECT * FROM ' . prefixTable('emails') . ' WHERE status = %s OR status = %s', 'not_sent', '');
1310
+        $rows = DB::query('SELECT * FROM '.prefixTable('emails').' WHERE status = %s OR status = %s', 'not_sent', '');
1311 1311
         foreach ($rows as $record) {
1312 1312
             //send email
1313 1313
             $email = $emailService->sendMail(
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
             break;
1377 1377
         }
1378 1378
 
1379
-        require_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
1379
+        require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
1380 1380
 
1381 1381
         // init
1382 1382
         $filesList = array();
@@ -1389,7 +1389,7 @@  discard block
 block discarded – undo
1389 1389
                 FROM ' . prefixTable('files')
1390 1390
             );
1391 1391
             foreach ($rows as $record) {
1392
-                if (is_file($SETTINGS['path_to_upload_folder'] . '/' . $record['file'])) {
1392
+                if (is_file($SETTINGS['path_to_upload_folder'].'/'.$record['file'])) {
1393 1393
                     $addFile = false;
1394 1394
                     if (($post_option === 'attachments-decrypt' && $record['status'] === 'encrypted')
1395 1395
                         || ($post_option === 'attachments-encrypt' && $record['status'] === 'clear')
@@ -1454,8 +1454,8 @@  discard block
 block discarded – undo
1454 1454
         $post_list = filter_var_array($post_list, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
1455 1455
         $post_counter = filter_var($post_counter, FILTER_SANITIZE_NUMBER_INT);
1456 1456
 
1457
-        include $SETTINGS['cpassman_dir'] . '/includes/config/settings.php';
1458
-        include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
1457
+        include $SETTINGS['cpassman_dir'].'/includes/config/settings.php';
1458
+        include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
1459 1459
 
1460 1460
         $cpt = 0;
1461 1461
         $continu = true;
@@ -1468,33 +1468,33 @@  discard block
 block discarded – undo
1468 1468
                 // Get file name
1469 1469
                 $file_info = DB::queryFirstRow(
1470 1470
                     'SELECT file
1471
-                    FROM ' . prefixTable('files') . '
1471
+                    FROM ' . prefixTable('files').'
1472 1472
                     WHERE id = %i',
1473 1473
                     $file
1474 1474
                 );
1475 1475
 
1476 1476
                 // skip file is Coherancey not respected
1477
-                if (is_file($SETTINGS['path_to_upload_folder'] . '/' . $file_info['file'])) {
1477
+                if (is_file($SETTINGS['path_to_upload_folder'].'/'.$file_info['file'])) {
1478 1478
                     // Case where we want to decrypt
1479 1479
                     if ($post_option === 'decrypt') {
1480 1480
                         prepareFileWithDefuse(
1481 1481
                             'decrypt',
1482
-                            $SETTINGS['path_to_upload_folder'] . '/' . $file_info['file'],
1483
-                            $SETTINGS['path_to_upload_folder'] . '/defuse_temp_' . $file_info['file'],
1482
+                            $SETTINGS['path_to_upload_folder'].'/'.$file_info['file'],
1483
+                            $SETTINGS['path_to_upload_folder'].'/defuse_temp_'.$file_info['file'],
1484 1484
                         );
1485 1485
                         // Case where we want to encrypt
1486 1486
                     } elseif ($post_option === 'encrypt') {
1487 1487
                         prepareFileWithDefuse(
1488 1488
                             'encrypt',
1489
-                            $SETTINGS['path_to_upload_folder'] . '/' . $file_info['file'],
1490
-                            $SETTINGS['path_to_upload_folder'] . '/defuse_temp_' . $file_info['file'],
1489
+                            $SETTINGS['path_to_upload_folder'].'/'.$file_info['file'],
1490
+                            $SETTINGS['path_to_upload_folder'].'/defuse_temp_'.$file_info['file'],
1491 1491
                         );
1492 1492
                     }
1493 1493
                     // Do file cleanup
1494
-                    fileDelete($SETTINGS['path_to_upload_folder'] . '/' . $file_info['file'], $SETTINGS);
1494
+                    fileDelete($SETTINGS['path_to_upload_folder'].'/'.$file_info['file'], $SETTINGS);
1495 1495
                     rename(
1496
-                        $SETTINGS['path_to_upload_folder'] . '/defuse_temp_' . $file_info['file'],
1497
-                        $SETTINGS['path_to_upload_folder'] . '/' . $file_info['file']
1496
+                        $SETTINGS['path_to_upload_folder'].'/defuse_temp_'.$file_info['file'],
1497
+                        $SETTINGS['path_to_upload_folder'].'/'.$file_info['file']
1498 1498
                     );
1499 1499
 
1500 1500
                     // store in DB
@@ -1529,8 +1529,8 @@  discard block
 block discarded – undo
1529 1529
                 $post_option === 'attachments-decrypt' ? 'clear' : 'encrypted'
1530 1530
             );
1531 1531
 
1532
-            $message = $lang->get('last_execution') . ' ' .
1533
-                date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) time()) .
1532
+            $message = $lang->get('last_execution').' '.
1533
+                date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) time()).
1534 1534
                 '<i class="fas fa-check text-success ml-2 mr-3"></i>';
1535 1535
         }
1536 1536
 
@@ -1624,7 +1624,7 @@  discard block
 block discarded – undo
1624 1624
             $post_id = filter_var($dataReceived['id'], FILTER_SANITIZE_NUMBER_INT);
1625 1625
 
1626 1626
             DB::query(
1627
-                'DELETE FROM ' . prefixTable('api') . ' WHERE increment_id = %i',
1627
+                'DELETE FROM '.prefixTable('api').' WHERE increment_id = %i',
1628 1628
                 $post_id
1629 1629
             );
1630 1630
         }
@@ -1719,7 +1719,7 @@  discard block
 block discarded – undo
1719 1719
             // Delete existing key
1720 1720
         } elseif (null !== $post_action && $post_action === 'delete') {
1721 1721
             $post_id = filter_var($dataReceived['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
1722
-            DB::query('DELETE FROM ' . prefixTable('api') . ' WHERE increment_id=%i', $post_id);
1722
+            DB::query('DELETE FROM '.prefixTable('api').' WHERE increment_id=%i', $post_id);
1723 1723
         }
1724 1724
 
1725 1725
         echo prepareExchangedData(
@@ -1734,7 +1734,7 @@  discard block
 block discarded – undo
1734 1734
 
1735 1735
     case 'save_api_status':
1736 1736
         // Do query
1737
-        DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'api');
1737
+        DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'api');
1738 1738
         $counter = DB::count();
1739 1739
         if ($counter === 0) {
1740 1740
             DB::insert(
@@ -1763,7 +1763,7 @@  discard block
 block discarded – undo
1763 1763
 
1764 1764
     case 'run_duo_config_check':
1765 1765
         //Libraries call
1766
-        require_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
1766
+        require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
1767 1767
         // Check KEY
1768 1768
         if ($post_key !== $session->get('key')) {
1769 1769
             echo prepareExchangedData(
@@ -1869,7 +1869,7 @@  discard block
 block discarded – undo
1869 1869
         } else {
1870 1870
             $tmp = 1;
1871 1871
         }
1872
-        DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'google_authentication');
1872
+        DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'google_authentication');
1873 1873
         $counter = DB::count();
1874 1874
         if ($counter === 0) {
1875 1875
             DB::insert(
@@ -1897,7 +1897,7 @@  discard block
 block discarded – undo
1897 1897
 
1898 1898
         // ga_website_name
1899 1899
         if (is_null($dataReceived['ga_website_name']) === false) {
1900
-            DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'ga_website_name');
1900
+            DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'ga_website_name');
1901 1901
             $counter = DB::count();
1902 1902
             if ($counter === 0) {
1903 1903
                 DB::insert(
@@ -1927,7 +1927,7 @@  discard block
 block discarded – undo
1927 1927
         }
1928 1928
 
1929 1929
         // send data
1930
-        echo '[{"result" : "' . addslashes($lang['done']) . '" , "error" : ""}]';
1930
+        echo '[{"result" : "'.addslashes($lang['done']).'" , "error" : ""}]';
1931 1931
         break;
1932 1932
 
1933 1933
     case 'save_agses_options':
@@ -1950,7 +1950,7 @@  discard block
 block discarded – undo
1950 1950
 
1951 1951
         // agses_hosted_url
1952 1952
         if (!is_null($dataReceived['agses_hosted_url'])) {
1953
-            DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'agses_hosted_url');
1953
+            DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'agses_hosted_url');
1954 1954
             $counter = DB::count();
1955 1955
             if ($counter === 0) {
1956 1956
                 DB::insert(
@@ -1981,7 +1981,7 @@  discard block
 block discarded – undo
1981 1981
 
1982 1982
         // agses_hosted_id
1983 1983
         if (!is_null($dataReceived['agses_hosted_id'])) {
1984
-            DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'agses_hosted_id');
1984
+            DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'agses_hosted_id');
1985 1985
             $counter = DB::count();
1986 1986
             if ($counter === 0) {
1987 1987
                 DB::insert(
@@ -2012,7 +2012,7 @@  discard block
 block discarded – undo
2012 2012
 
2013 2013
         // agses_hosted_apikey
2014 2014
         if (!is_null($dataReceived['agses_hosted_apikey'])) {
2015
-            DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'agses_hosted_apikey');
2015
+            DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'agses_hosted_apikey');
2016 2016
             $counter = DB::count();
2017 2017
             if ($counter === 0) {
2018 2018
                 DB::insert(
@@ -2042,7 +2042,7 @@  discard block
 block discarded – undo
2042 2042
         }
2043 2043
 
2044 2044
         // send data
2045
-        echo '[{"result" : "' . addslashes($lang['done']) . '" , "error" : ""}]';
2045
+        echo '[{"result" : "'.addslashes($lang['done']).'" , "error" : ""}]';
2046 2046
         break;
2047 2047
 
2048 2048
     case 'save_option_change':
@@ -2083,7 +2083,7 @@  discard block
 block discarded – undo
2083 2083
 
2084 2084
         // Check if setting is already in DB. If NO then insert, if YES then update.
2085 2085
         $data = DB::query(
2086
-            'SELECT * FROM ' . prefixTable('misc') . '
2086
+            'SELECT * FROM '.prefixTable('misc').'
2087 2087
             WHERE type = %s AND intitule = %s',
2088 2088
             'admin',
2089 2089
             $post_field
@@ -2106,7 +2106,7 @@  discard block
 block discarded – undo
2106 2106
                     array(
2107 2107
                         'valeur' => time(),
2108 2108
                         'type' => 'admin',
2109
-                        'intitule' => $post_field . '_time',
2109
+                        'intitule' => $post_field.'_time',
2110 2110
                         'updated_at' => time(),
2111 2111
                     )
2112 2112
                 );
@@ -2128,10 +2128,10 @@  discard block
 block discarded – undo
2128 2128
             if ($post_field === 'send_stats') {
2129 2129
                 // Check if previous time exists, if not them insert this value in DB
2130 2130
                 DB::query(
2131
-                    'SELECT * FROM ' . prefixTable('misc') . '
2131
+                    'SELECT * FROM '.prefixTable('misc').'
2132 2132
                     WHERE type = %s AND intitule = %s',
2133 2133
                     'admin',
2134
-                    $post_field . '_time'
2134
+                    $post_field.'_time'
2135 2135
                 );
2136 2136
                 $counter = DB::count();
2137 2137
                 if ($counter === 0) {
@@ -2140,7 +2140,7 @@  discard block
 block discarded – undo
2140 2140
                         array(
2141 2141
                             'valeur' => 0,
2142 2142
                             'type' => 'admin',
2143
-                            'intitule' => $post_field . '_time',
2143
+                            'intitule' => $post_field.'_time',
2144 2144
                             'created_at' => time(),
2145 2145
                         )
2146 2146
                     );
@@ -2162,13 +2162,13 @@  discard block
 block discarded – undo
2162 2162
         // special Cases
2163 2163
         if ($post_field === 'cpassman_url') {
2164 2164
             // update also jsUrl for CSFP protection
2165
-            $jsUrl = $post_value . '/includes/libraries/csrfp/js/csrfprotector.js';
2165
+            $jsUrl = $post_value.'/includes/libraries/csrfp/js/csrfprotector.js';
2166 2166
             $csrfp_file = '../includes/libraries/csrfp/libs/csrfp.config.php';
2167 2167
             $data = file_get_contents($csrfp_file);
2168 2168
             $posJsUrl = strpos($data, '"jsUrl" => "');
2169 2169
             $posEndLine = strpos($data, '",', $posJsUrl);
2170 2170
             $line = substr($data, $posJsUrl, ($posEndLine - $posJsUrl + 2));
2171
-            $newdata = str_replace($line, '"jsUrl" => "' . filter_var($jsUrl, FILTER_SANITIZE_FULL_SPECIAL_CHARS) . '",', $data);
2171
+            $newdata = str_replace($line, '"jsUrl" => "'.filter_var($jsUrl, FILTER_SANITIZE_FULL_SPECIAL_CHARS).'",', $data);
2172 2172
             file_put_contents($csrfp_file, $newdata);
2173 2173
         } elseif ($post_field === 'restricted_to_input' && (int) $post_value === 0) {
2174 2174
             DB::update(
@@ -2187,7 +2187,7 @@  discard block
 block discarded – undo
2187 2187
         echo prepareExchangedData(
2188 2188
             array(
2189 2189
                 'error' => false,
2190
-                'misc' => $counter . ' ; ' . $SETTINGS[$post_field],
2190
+                'misc' => $counter.' ; '.$SETTINGS[$post_field],
2191 2191
                 'message' => empty($post_translate) === false ? $lang->get($post_translate) : '',
2192 2192
             ),
2193 2193
             'encode'
@@ -2230,7 +2230,7 @@  discard block
 block discarded – undo
2230 2230
 
2231 2231
         // send statistics
2232 2232
         if (null !== $post_status) {
2233
-            DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'send_stats');
2233
+            DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'send_stats');
2234 2234
             $counter = DB::count();
2235 2235
             if ($counter === 0) {
2236 2236
                 DB::insert(
@@ -2261,7 +2261,7 @@  discard block
 block discarded – undo
2261 2261
 
2262 2262
         // send statistics items
2263 2263
         if (null !== $post_list) {
2264
-            DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'send_statistics_items');
2264
+            DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'send_statistics_items');
2265 2265
             $counter = DB::count();
2266 2266
             if ($counter === 0) {
2267 2267
                 DB::insert(
@@ -2307,7 +2307,7 @@  discard block
 block discarded – undo
2307 2307
             break;
2308 2308
         }
2309 2309
 
2310
-        if (DB::query("SHOW TABLES LIKE '" . prefixTable('sk_reencrypt_backup') . "'")) {
2310
+        if (DB::query("SHOW TABLES LIKE '".prefixTable('sk_reencrypt_backup')."'")) {
2311 2311
             if (DB::count() === 1) {
2312 2312
                 echo 1;
2313 2313
             } else {
@@ -2368,7 +2368,7 @@  discard block
 block discarded – undo
2368 2368
 
2369 2369
         $rows = DB::query(
2370 2370
             'SELECT id, title
2371
-                FROM ' . prefixTable('roles_title') . '
2371
+                FROM ' . prefixTable('roles_title').'
2372 2372
                 ORDER BY title ASC'
2373 2373
         );
2374 2374
         foreach ($rows as $record) {
@@ -2500,7 +2500,7 @@  discard block
 block discarded – undo
2500 2500
 
2501 2501
         $ignoredFiles = DB::queryFirstField(
2502 2502
             'SELECT valeur 
2503
-            FROM ' . prefixTable('misc') . ' 
2503
+            FROM ' . prefixTable('misc').' 
2504 2504
             WHERE type = %s AND intitule = %s',
2505 2505
             'admin',
2506 2506
             'ignored_unknown_files'
@@ -2543,7 +2543,7 @@  discard block
 block discarded – undo
2543 2543
         // Get ignored unknown files
2544 2544
         $existingData = DB::queryFirstRow(
2545 2545
             'SELECT valeur 
2546
-            FROM ' . prefixTable('misc') . ' 
2546
+            FROM ' . prefixTable('misc').' 
2547 2547
             WHERE type = %s AND intitule = %s',
2548 2548
             'admin',
2549 2549
             'ignored_unknown_files'
@@ -2600,7 +2600,7 @@  discard block
 block discarded – undo
2600 2600
         // Get the list of files to delete
2601 2601
         $filesToDelete = DB::queryFirstField(
2602 2602
             'SELECT valeur 
2603
-            FROM ' . prefixTable('misc') . ' 
2603
+            FROM ' . prefixTable('misc').' 
2604 2604
             WHERE type = %s AND intitule = %s',
2605 2605
             'admin',
2606 2606
             'unknown_files'
@@ -2646,7 +2646,7 @@  discard block
 block discarded – undo
2646 2646
         // Get some TP USER info
2647 2647
         $userInfo = DB::queryFirstRow(
2648 2648
             'SELECT id, public_key, private_key, pw
2649
-            FROM ' . prefixTable('users') . ' 
2649
+            FROM ' . prefixTable('users').' 
2650 2650
             WHERE id = %i',
2651 2651
             TP_USER_ID,
2652 2652
         );
@@ -2695,7 +2695,7 @@  discard block
 block discarded – undo
2695 2695
     $lang = new Language($session->get('user-language') ?? 'english');
2696 2696
 
2697 2697
     $results = [];
2698
-    $fullPath = __DIR__ . '/../';
2698
+    $fullPath = __DIR__.'/../';
2699 2699
     
2700 2700
     foreach ($files as $file) {
2701 2701
         // Normalize path separators for cross-platform compatibility
@@ -2744,7 +2744,7 @@  discard block
 block discarded – undo
2744 2744
         }
2745 2745
         
2746 2746
         // Try to delete the file
2747
-        $deleteResult = '';//@unlink($normalizedPath);
2747
+        $deleteResult = ''; //@unlink($normalizedPath);
2748 2748
         
2749 2749
         if ($deleteResult) {
2750 2750
             $results[$normalizedPath] = [
@@ -2774,7 +2774,7 @@  discard block
 block discarded – undo
2774 2774
  */
2775 2775
 function filesIntegrityCheck($baseDir): array
2776 2776
 {
2777
-    $referenceFile = __DIR__ . '/../files_reference.txt';
2777
+    $referenceFile = __DIR__.'/../files_reference.txt';
2778 2778
 
2779 2779
     $unknownFiles = findUnknownFiles($baseDir, $referenceFile);
2780 2780
 
@@ -2812,7 +2812,7 @@  discard block
 block discarded – undo
2812 2812
                 $dir,
2813 2813
                 FilesystemIterator::SKIP_DOTS
2814 2814
             ),
2815
-            function ($current, $key, $iterator) {
2815
+            function($current, $key, $iterator) {
2816 2816
                 // Ignore hidden files and folders
2817 2817
                 if ($current->getFilename()[0] === '.') {
2818 2818
                     return false;
@@ -2826,7 +2826,7 @@  discard block
 block discarded – undo
2826 2826
     foreach ($iterator as $file) {
2827 2827
         try {
2828 2828
             if ($file->isFile()) {
2829
-                $relativePath = str_replace($dir . DIRECTORY_SEPARATOR, '', $file->getPathname());
2829
+                $relativePath = str_replace($dir.DIRECTORY_SEPARATOR, '', $file->getPathname());
2830 2830
                 $relativePath = str_replace('\\', '/', $relativePath); // Normalisation Windows/Linux
2831 2831
 
2832 2832
                 // Split relatif path into parts
@@ -2892,7 +2892,7 @@  discard block
 block discarded – undo
2892 2892
     // Get ignored files
2893 2893
     $ignoredFiles = DB::queryFirstField(
2894 2894
         'SELECT valeur 
2895
-        FROM ' . prefixTable('misc') . ' 
2895
+        FROM ' . prefixTable('misc').' 
2896 2896
         WHERE type = %s AND intitule = %s',
2897 2897
         'admin',
2898 2898
         'ignored_unknown_files'
@@ -2911,7 +2911,7 @@  discard block
 block discarded – undo
2911 2911
 function tablesIntegrityCheck(): array
2912 2912
 {
2913 2913
     // Get integrity tables file
2914
-    $integrityTablesFile = TEAMPASS_ROOT_PATH . '/includes/tables_integrity.json';
2914
+    $integrityTablesFile = TEAMPASS_ROOT_PATH.'/includes/tables_integrity.json';
2915 2915
     if (file_exists($integrityTablesFile) === false) {
2916 2916
         return [
2917 2917
             'error' => true,
@@ -2929,7 +2929,7 @@  discard block
 block discarded – undo
2929 2929
     // Get all tables
2930 2930
     $tables = [];
2931 2931
     foreach (DB::queryFirstColumn("SHOW TABLES") as $table) {
2932
-        $tables[] = str_replace(DB_PREFIX, "", $table);;
2932
+        $tables[] = str_replace(DB_PREFIX, "", $table); ;
2933 2933
     }
2934 2934
     // Prepare the integrity check
2935 2935
     $tablesInError = [];
@@ -2995,7 +2995,7 @@  discard block
 block discarded – undo
2995 2995
 
2996 2996
         // Compare hashes
2997 2997
         $expectedHash = $referenceData[$file];
2998
-        $actualHash = md5_file($baseDir . '/' . $file);
2998
+        $actualHash = md5_file($baseDir.'/'.$file);
2999 2999
 
3000 3000
         if ($expectedHash !== $actualHash) {
3001 3001
             $issues[] = "$file (expected: <i>$expectedHash</i>, actual: <i>$actualHash</i>)";
@@ -3048,7 +3048,7 @@  discard block
 block discarded – undo
3048 3048
     foreach ($iterator as $file) {
3049 3049
         if ($file->isFile()) {
3050 3050
             // Build relative path
3051
-            $relativePath = str_replace($dir . DIRECTORY_SEPARATOR, '', $file->getPathname());
3051
+            $relativePath = str_replace($dir.DIRECTORY_SEPARATOR, '', $file->getPathname());
3052 3052
             $relativePath = str_replace('\\', '/', $relativePath); // Normalize for Windows
3053 3053
             // Calculate hash
3054 3054
             $files[$relativePath] = md5_file($file->getPathname());
@@ -3078,8 +3078,8 @@  discard block
 block discarded – undo
3078 3078
     // Loop on items
3079 3079
     $item = DB::queryFirstRow(
3080 3080
         'SELECT i.id, i.pw, s.share_key, s.increment_id
3081
-        FROM ' . prefixTable('items') . ' i
3082
-        INNER JOIN ' . prefixTable('sharekeys_items') . ' s ON i.id = s.object_id
3081
+        FROM ' . prefixTable('items').' i
3082
+        INNER JOIN ' . prefixTable('sharekeys_items').' s ON i.id = s.object_id
3083 3083
         WHERE i.perso = %i
3084 3084
             AND s.user_id = %i
3085 3085
         ORDER BY RAND()
@@ -3108,7 +3108,7 @@  discard block
 block discarded – undo
3108 3108
         // Get all items in database
3109 3109
         $rows = DB::queryFirstRow(
3110 3110
             'SELECT count(*) as counter
3111
-            FROM ' . prefixTable('sharekeys_items') . ' s
3111
+            FROM ' . prefixTable('sharekeys_items').' s
3112 3112
             WHERE s.user_id = %i',
3113 3113
             TP_USER_ID
3114 3114
         );
Please login to merge, or discard this patch.
sources/main.functions.php 1 patch
Spacing   +168 added lines, -170 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
     }
@@ -362,20 +362,20 @@  discard block
 block discarded – undo
362 362
     // get complete list of ROLES
363 363
     $tmp = explode(';', $idFonctions);
364 364
     $rows = DB::query(
365
-        'SELECT * FROM ' . prefixTable('roles_title') . '
365
+        'SELECT * FROM '.prefixTable('roles_title').'
366 366
         ORDER BY title ASC'
367 367
     );
368 368
     foreach ($rows as $record) {
369
-        if (! empty($record['id']) && ! in_array($record['id'], $tmp)) {
369
+        if (!empty($record['id']) && !in_array($record['id'], $tmp)) {
370 370
             array_push($tmp, $record['id']);
371 371
         }
372 372
     }
373 373
     $session->set('user-roles', implode(';', $tmp));
374 374
     $session->set('user-admin', 1);
375 375
     // Check if admin has created Folders and Roles
376
-    DB::query('SELECT * FROM ' . prefixTable('nested_tree') . '');
376
+    DB::query('SELECT * FROM '.prefixTable('nested_tree').'');
377 377
     $session->set('user-nb_folders', DB::count());
378
-    DB::query('SELECT * FROM ' . prefixTable('roles_title'));
378
+    DB::query('SELECT * FROM '.prefixTable('roles_title'));
379 379
     $session->set('user-nb_roles', DB::count());
380 380
 
381 381
     return true;
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
     // Does this user is allowed to see other items
459 459
     $inc = 0;
460 460
     $rows = DB::query(
461
-        'SELECT id, id_tree FROM ' . prefixTable('items') . '
461
+        'SELECT id, id_tree FROM '.prefixTable('items').'
462 462
             WHERE restricted_to LIKE %ss AND inactif = %s'.
463 463
             (count($allowedFolders) > 0 ? ' AND id_tree NOT IN ('.implode(',', $allowedFolders).')' : ''),
464 464
         $globalsUserId,
@@ -475,8 +475,8 @@  discard block
 block discarded – undo
475 475
     // Check for the users roles if some specific rights exist on items
476 476
     $rows = DB::query(
477 477
         'SELECT i.id_tree, r.item_id
478
-        FROM ' . prefixTable('items') . ' as i
479
-        INNER JOIN ' . prefixTable('restriction_to_roles') . ' as r ON (r.item_id=i.id)
478
+        FROM ' . prefixTable('items').' as i
479
+        INNER JOIN ' . prefixTable('restriction_to_roles').' as r ON (r.item_id=i.id)
480 480
         WHERE i.id_tree <> "" '.
481 481
         (count($userRoles) > 0 ? 'AND r.role_id IN %li ' : '').
482 482
         'ORDER BY i.id_tree ASC',
@@ -520,18 +520,18 @@  discard block
 block discarded – undo
520 520
     $session->set('system-list_restricted_folders_for_items', $restrictedFoldersForItems);
521 521
     $session->set('user-forbiden_personal_folders', $noAccessPersonalFolders);
522 522
     // Folders and Roles numbers
523
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('nested_tree') . '');
524
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('nested_tree') . '');
523
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('nested_tree').'');
524
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('nested_tree').'');
525 525
     $session->set('user-nb_folders', DB::count());
526
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('roles_title'));
527
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('roles_title'));
526
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('roles_title'));
527
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('roles_title'));
528 528
     $session->set('user-nb_roles', DB::count());
529 529
     // check if change proposals on User's items
530 530
     if (isset($SETTINGS['enable_suggestion']) === true && (int) $SETTINGS['enable_suggestion'] === 1) {
531 531
         $countNewItems = DB::query(
532 532
             'SELECT COUNT(*)
533
-            FROM ' . prefixTable('items_change') . ' AS c
534
-            LEFT JOIN ' . prefixTable('log_items') . ' AS i ON (c.item_id = i.id_item)
533
+            FROM ' . prefixTable('items_change').' AS c
534
+            LEFT JOIN ' . prefixTable('log_items').' AS i ON (c.item_id = i.id_item)
535 535
             WHERE i.action = %s AND i.id_user = %i',
536 536
             'at_creation',
537 537
             $globalsUserId
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 {
559 559
     $rows = DB::query(
560 560
         'SELECT *
561
-        FROM ' . prefixTable('roles_values') . '
561
+        FROM ' . prefixTable('roles_values').'
562 562
         WHERE type IN %ls'.(count($userRoles) > 0 ? ' AND role_id IN %li' : ''),
563 563
         ['W', 'ND', 'NE', 'NDNE', 'R'],
564 564
         $userRoles,
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
     ) {
626 626
         $persoFld = DB::queryFirstRow(
627 627
             'SELECT id
628
-            FROM ' . prefixTable('nested_tree') . '
628
+            FROM ' . prefixTable('nested_tree').'
629 629
             WHERE title = %s AND personal_folder = %i'.
630 630
             (count($allowedFolders) > 0 ? ' AND id NOT IN ('.implode(',', $allowedFolders).')' : ''),
631 631
             $globalsUserId,
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
     }
659 659
     $persoFlds = DB::query(
660 660
         'SELECT id
661
-        FROM ' . prefixTable('nested_tree') . '
661
+        FROM ' . prefixTable('nested_tree').'
662 662
         WHERE %l',
663 663
         $where
664 664
     );
@@ -726,12 +726,12 @@  discard block
 block discarded – undo
726 726
     //Load Tree
727 727
     $tree = new NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title');
728 728
     // truncate table
729
-    DB::query('TRUNCATE TABLE ' . prefixTable('cache'));
729
+    DB::query('TRUNCATE TABLE '.prefixTable('cache'));
730 730
     // reload date
731 731
     $rows = DB::query(
732 732
         'SELECT *
733
-        FROM ' . prefixTable('items') . ' as i
734
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
733
+        FROM ' . prefixTable('items').' as i
734
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
735 735
         AND l.action = %s
736 736
         AND i.inactif = %i',
737 737
         'at_creation',
@@ -743,18 +743,18 @@  discard block
 block discarded – undo
743 743
             $tags = '';
744 744
             $itemTags = DB::query(
745 745
                 'SELECT tag
746
-                FROM ' . prefixTable('tags') . '
746
+                FROM ' . prefixTable('tags').'
747 747
                 WHERE item_id = %i AND tag != ""',
748 748
                 $record['id']
749 749
             );
750 750
             foreach ($itemTags as $itemTag) {
751
-                $tags .= $itemTag['tag'] . ' ';
751
+                $tags .= $itemTag['tag'].' ';
752 752
             }
753 753
 
754 754
             // Get renewal period
755 755
             $resNT = DB::queryFirstRow(
756 756
                 'SELECT renewal_period
757
-                FROM ' . prefixTable('nested_tree') . '
757
+                FROM ' . prefixTable('nested_tree').'
758 758
                 WHERE id = %i',
759 759
                 $record['id_tree']
760 760
             );
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
                     // Is this a User id?
768 768
                     $user = DB::queryFirstRow(
769 769
                         'SELECT id, login
770
-                        FROM ' . prefixTable('users') . '
770
+                        FROM ' . prefixTable('users').'
771 771
                         WHERE id = %i',
772 772
                         $elem->title
773 773
                     );
@@ -785,11 +785,11 @@  discard block
 block discarded – undo
785 785
                     'id' => $record['id'],
786 786
                     'label' => $record['label'],
787 787
                     'description' => $record['description'] ?? '',
788
-                    'url' => isset($record['url']) && ! empty($record['url']) ? $record['url'] : '0',
788
+                    'url' => isset($record['url']) && !empty($record['url']) ? $record['url'] : '0',
789 789
                     'tags' => $tags,
790 790
                     'id_tree' => $record['id_tree'],
791 791
                     'perso' => $record['perso'],
792
-                    'restricted_to' => isset($record['restricted_to']) && ! empty($record['restricted_to']) ? $record['restricted_to'] : '0',
792
+                    'restricted_to' => isset($record['restricted_to']) && !empty($record['restricted_to']) ? $record['restricted_to'] : '0',
793 793
                     'login' => $record['login'] ?? '',
794 794
                     'folder' => implode(' » ', $folder),
795 795
                     'author' => $record['id_user'],
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
     // get new value from db
819 819
     $data = DB::queryFirstRow(
820 820
         'SELECT label, description, id_tree, perso, restricted_to, login, url
821
-        FROM ' . prefixTable('items') . '
821
+        FROM ' . prefixTable('items').'
822 822
         WHERE id=%i',
823 823
         $ident
824 824
     );
@@ -826,12 +826,12 @@  discard block
 block discarded – undo
826 826
     $tags = '';
827 827
     $itemTags = DB::query(
828 828
         'SELECT tag
829
-            FROM ' . prefixTable('tags') . '
829
+            FROM ' . prefixTable('tags').'
830 830
             WHERE item_id = %i AND tag != ""',
831 831
         $ident
832 832
     );
833 833
     foreach ($itemTags as $itemTag) {
834
-        $tags .= $itemTag['tag'] . ' ';
834
+        $tags .= $itemTag['tag'].' ';
835 835
     }
836 836
     // form id_tree to full foldername
837 837
     $folder = [];
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
             // Is this a User id?
843 843
             $user = DB::queryFirstRow(
844 844
                 'SELECT id, login
845
-                FROM ' . prefixTable('users') . '
845
+                FROM ' . prefixTable('users').'
846 846
                 WHERE id = %i',
847 847
                 $elem->title
848 848
             );
@@ -860,10 +860,10 @@  discard block
 block discarded – undo
860 860
             'label' => $data['label'],
861 861
             'description' => $data['description'],
862 862
             'tags' => $tags,
863
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
863
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
864 864
             'id_tree' => $data['id_tree'],
865 865
             'perso' => $data['perso'],
866
-            'restricted_to' => isset($data['restricted_to']) && ! empty($data['restricted_to']) ? $data['restricted_to'] : '0',
866
+            'restricted_to' => isset($data['restricted_to']) && !empty($data['restricted_to']) ? $data['restricted_to'] : '0',
867 867
             'login' => $data['login'] ?? '',
868 868
             'folder' => implode(' » ', $folder),
869 869
             'author' => $session->get('user-id'),
@@ -893,8 +893,8 @@  discard block
 block discarded – undo
893 893
     // get new value from db
894 894
     $data = DB::queryFirstRow(
895 895
         'SELECT i.label, i.description, i.id_tree as id_tree, i.perso, i.restricted_to, i.id, i.login, i.url, l.date
896
-        FROM ' . prefixTable('items') . ' as i
897
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
896
+        FROM ' . prefixTable('items').' as i
897
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
898 898
         WHERE i.id = %i
899 899
         AND l.action = %s',
900 900
         $ident,
@@ -904,12 +904,12 @@  discard block
 block discarded – undo
904 904
     $tags = '';
905 905
     $itemTags = DB::query(
906 906
         'SELECT tag
907
-            FROM ' . prefixTable('tags') . '
907
+            FROM ' . prefixTable('tags').'
908 908
             WHERE item_id = %i AND tag != ""',
909 909
         $ident
910 910
     );
911 911
     foreach ($itemTags as $itemTag) {
912
-        $tags .= $itemTag['tag'] . ' ';
912
+        $tags .= $itemTag['tag'].' ';
913 913
     }
914 914
     // form id_tree to full foldername
915 915
     $folder = [];
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
             // Is this a User id?
921 921
             $user = DB::queryFirstRow(
922 922
                 'SELECT id, login
923
-                FROM ' . prefixTable('users') . '
923
+                FROM ' . prefixTable('users').'
924 924
                 WHERE id = %i',
925 925
                 $elem->title
926 926
             );
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
             'label' => $data['label'],
940 940
             'description' => $data['description'],
941 941
             'tags' => empty($tags) === false ? $tags : 'None',
942
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
942
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
943 943
             'id_tree' => $data['id_tree'],
944 944
             'perso' => isset($data['perso']) && empty($data['perso']) === false && $data['perso'] !== 'None' ? $data['perso'] : '0',
945 945
             'restricted_to' => isset($data['restricted_to']) && empty($data['restricted_to']) === false ? $data['restricted_to'] : '0',
@@ -961,53 +961,53 @@  discard block
 block discarded – undo
961 961
 function getStatisticsData(array $SETTINGS): array
962 962
 {
963 963
     DB::query(
964
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
964
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
965 965
         0
966 966
     );
967 967
     $counter_folders = DB::count();
968 968
     DB::query(
969
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
969
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
970 970
         1
971 971
     );
972 972
     $counter_folders_perso = DB::count();
973 973
     DB::query(
974
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
974
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
975 975
         0
976 976
     );
977 977
     $counter_items = DB::count();
978 978
         DB::query(
979
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
979
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
980 980
         1
981 981
     );
982 982
     $counter_items_perso = DB::count();
983 983
         DB::query(
984
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE login NOT IN (%s, %s, %s)',
984
+        'SELECT id FROM '.prefixTable('users').' WHERE login NOT IN (%s, %s, %s)',
985 985
         'OTV', 'TP', 'API'
986 986
     );
987 987
     $counter_users = DB::count();
988 988
         DB::query(
989
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE admin = %i',
989
+        'SELECT id FROM '.prefixTable('users').' WHERE admin = %i',
990 990
         1
991 991
     );
992 992
     $admins = DB::count();
993 993
     DB::query(
994
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE gestionnaire = %i',
994
+        'SELECT id FROM '.prefixTable('users').' WHERE gestionnaire = %i',
995 995
         1
996 996
     );
997 997
     $managers = DB::count();
998 998
     DB::query(
999
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE read_only = %i',
999
+        'SELECT id FROM '.prefixTable('users').' WHERE read_only = %i',
1000 1000
         1
1001 1001
     );
1002 1002
     $readOnly = DB::count();
1003 1003
     // list the languages
1004 1004
     $usedLang = [];
1005 1005
     $tp_languages = DB::query(
1006
-        'SELECT name FROM ' . prefixTable('languages')
1006
+        'SELECT name FROM '.prefixTable('languages')
1007 1007
     );
1008 1008
     foreach ($tp_languages as $tp_language) {
1009 1009
         DB::query(
1010
-            'SELECT * FROM ' . prefixTable('users') . ' WHERE user_language = %s',
1010
+            'SELECT * FROM '.prefixTable('users').' WHERE user_language = %s',
1011 1011
             $tp_language['name']
1012 1012
         );
1013 1013
         $usedLang[$tp_language['name']] = round((DB::count() * 100 / $counter_users), 0);
@@ -1016,12 +1016,12 @@  discard block
 block discarded – undo
1016 1016
     // get list of ips
1017 1017
     $usedIp = [];
1018 1018
     $tp_ips = DB::query(
1019
-        'SELECT user_ip FROM ' . prefixTable('users')
1019
+        'SELECT user_ip FROM '.prefixTable('users')
1020 1020
     );
1021 1021
     foreach ($tp_ips as $ip) {
1022 1022
         if (array_key_exists($ip['user_ip'], $usedIp)) {
1023 1023
             $usedIp[$ip['user_ip']] += $usedIp[$ip['user_ip']];
1024
-        } elseif (! empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
1024
+        } elseif (!empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
1025 1025
             $usedIp[$ip['user_ip']] = 1;
1026 1026
         }
1027 1027
     }
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
         <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;">
1117 1117
         <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;">
1118 1118
         <br><div style="float:right;">' .
1119
-        $textMail .
1119
+        $textMail.
1120 1120
         '<br><br></td></tr></table>
1121 1121
     </td></tr></table>
1122 1122
     <br></body></html>';
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 {
1198 1198
     array_walk_recursive(
1199 1199
         $array,
1200
-        static function (&$item): void {
1200
+        static function(&$item): void {
1201 1201
             if (mb_detect_encoding((string) $item, 'utf-8', true) === false) {
1202 1202
                 $item = mb_convert_encoding($item, 'ISO-8859-1', 'UTF-8');
1203 1203
             }
@@ -1308,7 +1308,7 @@  discard block
 block discarded – undo
1308 1308
  */
1309 1309
 function prefixTable(string $table): string
1310 1310
 {
1311
-    $safeTable = htmlspecialchars(DB_PREFIX . $table);
1311
+    $safeTable = htmlspecialchars(DB_PREFIX.$table);
1312 1312
     return $safeTable;
1313 1313
 }
1314 1314
 
@@ -1425,7 +1425,7 @@  discard block
 block discarded – undo
1425 1425
 function send_syslog($message, $host, $port, $component = 'teampass'): void
1426 1426
 {
1427 1427
     $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
1428
-    $syslog_message = '<123>' . date('M d H:i:s ') . $component . ': ' . $message;
1428
+    $syslog_message = '<123>'.date('M d H:i:s ').$component.': '.$message;
1429 1429
     socket_sendto($sock, (string) $syslog_message, strlen($syslog_message), 0, (string) $host, (int) $port);
1430 1430
     socket_close($sock);
1431 1431
 }
@@ -1472,14 +1472,14 @@  discard block
 block discarded – undo
1472 1472
     if (isset($SETTINGS['syslog_enable']) === true && (int) $SETTINGS['syslog_enable'] === 1) {
1473 1473
         if ($type === 'user_mngt') {
1474 1474
             send_syslog(
1475
-                'action=' . str_replace('at_', '', $label) . ' attribute=user user=' . $who . ' userid="' . $login . '" change="' . $field_1 . '" ',
1475
+                'action='.str_replace('at_', '', $label).' attribute=user user='.$who.' userid="'.$login.'" change="'.$field_1.'" ',
1476 1476
                 $SETTINGS['syslog_host'],
1477 1477
                 $SETTINGS['syslog_port'],
1478 1478
                 'teampass'
1479 1479
             );
1480 1480
         } else {
1481 1481
             send_syslog(
1482
-                'action=' . $type . ' attribute=' . $label . ' user=' . $who . ' userid="' . $login . '" ',
1482
+                'action='.$type.' attribute='.$label.' user='.$who.' userid="'.$login.'" ',
1483 1483
                 $SETTINGS['syslog_host'],
1484 1484
                 $SETTINGS['syslog_port'],
1485 1485
                 'teampass'
@@ -1554,7 +1554,7 @@  discard block
 block discarded – undo
1554 1554
         if (empty($item_label) === true) {
1555 1555
             $dataItem = DB::queryFirstRow(
1556 1556
                 'SELECT id, id_tree, label
1557
-                FROM ' . prefixTable('items') . '
1557
+                FROM ' . prefixTable('items').'
1558 1558
                 WHERE id = %i',
1559 1559
                 $item_id
1560 1560
             );
@@ -1562,11 +1562,11 @@  discard block
 block discarded – undo
1562 1562
         }
1563 1563
 
1564 1564
         send_syslog(
1565
-            'action=' . str_replace('at_', '', $action) .
1566
-                ' attribute=' . str_replace('at_', '', $attribute[0]) .
1567
-                ' itemno=' . $item_id .
1568
-                ' user=' . (is_null($login) === true ? '' : addslashes((string) $login)) .
1569
-                ' itemname="' . addslashes($item_label) . '"',
1565
+            'action='.str_replace('at_', '', $action).
1566
+                ' attribute='.str_replace('at_', '', $attribute[0]).
1567
+                ' itemno='.$item_id.
1568
+                ' user='.(is_null($login) === true ? '' : addslashes((string) $login)).
1569
+                ' itemname="'.addslashes($item_label).'"',
1570 1570
             $SETTINGS['syslog_host'],
1571 1571
             $SETTINGS['syslog_port'],
1572 1572
             'teampass'
@@ -1597,8 +1597,8 @@  discard block
 block discarded – undo
1597 1597
     // send email to user that what to be notified
1598 1598
     $notification = DB::queryFirstField(
1599 1599
         'SELECT email
1600
-        FROM ' . prefixTable('notification') . ' AS n
1601
-        INNER JOIN ' . prefixTable('users') . ' AS u ON (n.user_id = u.id)
1600
+        FROM ' . prefixTable('notification').' AS n
1601
+        INNER JOIN ' . prefixTable('users').' AS u ON (n.user_id = u.id)
1602 1602
         WHERE n.item_id = %i AND n.user_id != %i',
1603 1603
         $item_id,
1604 1604
         $globalsUserId
@@ -1609,7 +1609,7 @@  discard block
 block discarded – undo
1609 1609
         // Get list of changes
1610 1610
         $htmlChanges = '<ul>';
1611 1611
         foreach ($changes as $change) {
1612
-            $htmlChanges .= '<li>' . $change . '</li>';
1612
+            $htmlChanges .= '<li>'.$change.'</li>';
1613 1613
         }
1614 1614
         $htmlChanges .= '</ul>';
1615 1615
         // send email
@@ -1646,15 +1646,15 @@  discard block
 block discarded – undo
1646 1646
     $path = '';
1647 1647
     foreach ($arbo as $elem) {
1648 1648
         if (empty($path) === true) {
1649
-            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES) . ' ';
1649
+            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES).' ';
1650 1650
         } else {
1651
-            $path .= '&#8594; ' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1651
+            $path .= '&#8594; '.htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1652 1652
         }
1653 1653
     }
1654 1654
 
1655 1655
     // Build text to show user
1656 1656
     if (empty($label) === false) {
1657
-        return empty($path) === true ? addslashes($label) : addslashes($label) . ' (' . $path . ')';
1657
+        return empty($path) === true ? addslashes($label) : addslashes($label).' ('.$path.')';
1658 1658
     }
1659 1659
     return empty($path) === true ? '' : $path;
1660 1660
 }
@@ -1710,7 +1710,7 @@  discard block
 block discarded – undo
1710 1710
 {
1711 1711
     // Perform a copy if the file exists
1712 1712
     if (file_exists($configFilePath)) {
1713
-        $backupFilePath = $configFilePath . '.' . date('Y_m_d_His', time());
1713
+        $backupFilePath = $configFilePath.'.'.date('Y_m_d_His', time());
1714 1714
         if (!copy($configFilePath, $backupFilePath)) {
1715 1715
             return "ERROR: Could not copy file '$configFilePath'";
1716 1716
         }
@@ -1718,10 +1718,10 @@  discard block
 block discarded – undo
1718 1718
 
1719 1719
     // Regenerate the config file
1720 1720
     $data = ["<?php\n", "global \$SETTINGS;\n", "\$SETTINGS = array (\n"];
1721
-    $rows = DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s', 'admin');
1721
+    $rows = DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type=%s', 'admin');
1722 1722
     foreach ($rows as $record) {
1723 1723
         $value = getEncryptedValue($record['valeur'], $record['is_encrypted']);
1724
-        $data[] = "    '{$record['intitule']}' => '". htmlspecialchars_decode($value, ENT_COMPAT) . "',\n";
1724
+        $data[] = "    '{$record['intitule']}' => '".htmlspecialchars_decode($value, ENT_COMPAT)."',\n";
1725 1725
     }
1726 1726
     $data[] = ");\n";
1727 1727
     $data = array_unique($data);
@@ -1766,7 +1766,7 @@  discard block
 block discarded – undo
1766 1766
 {
1767 1767
     global $SETTINGS;
1768 1768
     /* LOAD CPASSMAN SETTINGS */
1769
-    if (! isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
1769
+    if (!isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
1770 1770
         $SETTINGS = [];
1771 1771
         $SETTINGS['duplicate_folder'] = 0;
1772 1772
         //by default, this is set to 0;
@@ -1776,7 +1776,7 @@  discard block
 block discarded – undo
1776 1776
         //by default, this value is set to 5;
1777 1777
         $settings = [];
1778 1778
         $rows = DB::query(
1779
-            'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s_type OR type=%s_type2',
1779
+            'SELECT * FROM '.prefixTable('misc').' WHERE type=%s_type OR type=%s_type2',
1780 1780
             [
1781 1781
                 'type' => 'admin',
1782 1782
                 'type2' => 'settings',
@@ -1808,7 +1808,7 @@  discard block
 block discarded – undo
1808 1808
     $source_cf = [];
1809 1809
     $rows = DB::query(
1810 1810
         'SELECT id_category
1811
-            FROM ' . prefixTable('categories_folders') . '
1811
+            FROM ' . prefixTable('categories_folders').'
1812 1812
             WHERE id_folder = %i',
1813 1813
         $source_id
1814 1814
     );
@@ -1819,7 +1819,7 @@  discard block
 block discarded – undo
1819 1819
     $target_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
         $target_id
1825 1825
     );
@@ -1914,10 +1914,10 @@  discard block
 block discarded – undo
1914 1914
     } catch (CryptoException\WrongKeyOrModifiedCiphertextException $ex) {
1915 1915
         $err = 'wrong_key';
1916 1916
     } catch (CryptoException\EnvironmentIsBrokenException $ex) {
1917
-        error_log('TEAMPASS-Error-Environment: ' . $ex->getMessage());
1917
+        error_log('TEAMPASS-Error-Environment: '.$ex->getMessage());
1918 1918
         $err = 'environment_error';
1919 1919
     } catch (CryptoException\IOException $ex) {
1920
-        error_log('TEAMPASS-Error-General: ' . $ex->getMessage());
1920
+        error_log('TEAMPASS-Error-General: '.$ex->getMessage());
1921 1921
         $err = 'general_error';
1922 1922
     }
1923 1923
 
@@ -1950,10 +1950,10 @@  discard block
 block discarded – undo
1950 1950
     } catch (CryptoException\WrongKeyOrModifiedCiphertextException $ex) {
1951 1951
         $err = 'wrong_key';
1952 1952
     } catch (CryptoException\EnvironmentIsBrokenException $ex) {
1953
-        error_log('TEAMPASS-Error-Environment: ' . $ex->getMessage());
1953
+        error_log('TEAMPASS-Error-Environment: '.$ex->getMessage());
1954 1954
         $err = 'environment_error';
1955 1955
     } catch (CryptoException\IOException $ex) {
1956
-        error_log('TEAMPASS-Error-General: ' . $ex->getMessage());
1956
+        error_log('TEAMPASS-Error-General: '.$ex->getMessage());
1957 1957
         $err = 'general_error';
1958 1958
     }
1959 1959
 
@@ -2039,7 +2039,7 @@  discard block
 block discarded – undo
2039 2039
 ) {
2040 2040
     // Check if the path exists
2041 2041
     $path = basename($path);
2042
-    if (! file_exists($path)) {
2042
+    if (!file_exists($path)) {
2043 2043
         return false;
2044 2044
     }
2045 2045
 
@@ -2092,7 +2092,7 @@  discard block
 block discarded – undo
2092 2092
     // Load item data
2093 2093
     $data = DB::queryFirstRow(
2094 2094
         'SELECT id_tree
2095
-        FROM ' . prefixTable('items') . '
2095
+        FROM ' . prefixTable('items').'
2096 2096
         WHERE id = %i',
2097 2097
         $item_id
2098 2098
     );
@@ -2155,7 +2155,7 @@  discard block
 block discarded – undo
2155 2155
         }
2156 2156
         $host .= substr(explode(".", $email[1])[0], -1, 1);
2157 2157
     }
2158
-    $email = $name . "@" . $host . "." . explode(".", $email[1])[1];
2158
+    $email = $name."@".$host.".".explode(".", $email[1])[1];
2159 2159
     return $email;
2160 2160
 }
2161 2161
 
@@ -2186,11 +2186,11 @@  discard block
 block discarded – undo
2186 2186
 function formatSizeUnits(int $bytes): string
2187 2187
 {
2188 2188
     if ($bytes >= 1073741824) {
2189
-        $bytes = number_format($bytes / 1073741824, 2) . ' GB';
2189
+        $bytes = number_format($bytes / 1073741824, 2).' GB';
2190 2190
     } elseif ($bytes >= 1048576) {
2191
-        $bytes = number_format($bytes / 1048576, 2) . ' MB';
2191
+        $bytes = number_format($bytes / 1048576, 2).' MB';
2192 2192
     } elseif ($bytes >= 1024) {
2193
-        $bytes = number_format($bytes / 1024, 2) . ' KB';
2193
+        $bytes = number_format($bytes / 1024, 2).' KB';
2194 2194
     } elseif ($bytes > 1) {
2195 2195
         $bytes .= ' bytes';
2196 2196
     } elseif ($bytes === 1) {
@@ -2439,7 +2439,7 @@  discard block
 block discarded – undo
2439 2439
     $cipher->enableContinuousBuffer();
2440 2440
 
2441 2441
     // Encrypt the file content
2442
-    $filePath = filter_var($fileInPath . '/' . $fileInName, FILTER_SANITIZE_URL);
2442
+    $filePath = filter_var($fileInPath.'/'.$fileInName, FILTER_SANITIZE_URL);
2443 2443
     $fileContent = file_get_contents($filePath);
2444 2444
     $plaintext = $fileContent;
2445 2445
     $ciphertext = $cipher->encrypt($plaintext);
@@ -2447,9 +2447,9 @@  discard block
 block discarded – undo
2447 2447
     // Save new file
2448 2448
     // deepcode ignore InsecureHash: is simply used to get a unique name
2449 2449
     $hash = uniqid('', true);
2450
-    $fileOut = $fileInPath . '/' . TP_FILE_PREFIX . $hash;
2450
+    $fileOut = $fileInPath.'/'.TP_FILE_PREFIX.$hash;
2451 2451
     file_put_contents($fileOut, $ciphertext);
2452
-    unlink($fileInPath . '/' . $fileInName);
2452
+    unlink($fileInPath.'/'.$fileInName);
2453 2453
     return [
2454 2454
         'fileHash' => base64_encode($hash),
2455 2455
         'objectKey' => base64_encode($objectKey),
@@ -2465,9 +2465,9 @@  discard block
 block discarded – undo
2465 2465
  *
2466 2466
  * @return string|array
2467 2467
  */
2468
-function decryptFile(string $fileName, string $filePath, string $key): string|array
2468
+function decryptFile(string $fileName, string $filePath, string $key): string | array
2469 2469
 {
2470
-    if (! defined('FILE_BUFFER_SIZE')) {
2470
+    if (!defined('FILE_BUFFER_SIZE')) {
2471 2471
         define('FILE_BUFFER_SIZE', 128 * 1024);
2472 2472
     }
2473 2473
     
@@ -2484,7 +2484,7 @@  discard block
 block discarded – undo
2484 2484
     $cipher->enableContinuousBuffer();
2485 2485
     $cipher->disablePadding();
2486 2486
     // Get file content
2487
-    $safeFilePath = realpath($filePath . '/' . TP_FILE_PREFIX . $safeFileName);
2487
+    $safeFilePath = realpath($filePath.'/'.TP_FILE_PREFIX.$safeFileName);
2488 2488
     if ($safeFilePath !== false && file_exists($safeFilePath)) {
2489 2489
         $ciphertext = file_get_contents(filter_var($safeFilePath, FILTER_SANITIZE_URL));
2490 2490
     } else {
@@ -2580,7 +2580,7 @@  discard block
 block discarded – undo
2580 2580
         // Only create the sharekey for a user
2581 2581
         $user = DB::queryFirstRow(
2582 2582
             'SELECT public_key
2583
-            FROM ' . prefixTable('users') . '
2583
+            FROM ' . prefixTable('users').'
2584 2584
             WHERE id = %i
2585 2585
             AND public_key != ""',
2586 2586
             $userId
@@ -2621,7 +2621,7 @@  discard block
 block discarded – undo
2621 2621
         }
2622 2622
         $users = DB::query(
2623 2623
             'SELECT id, public_key
2624
-            FROM ' . prefixTable('users') . '
2624
+            FROM ' . prefixTable('users').'
2625 2625
             WHERE id NOT IN %li
2626 2626
             AND public_key != ""',
2627 2627
             $user_ids
@@ -2630,7 +2630,7 @@  discard block
 block discarded – undo
2630 2630
         foreach ($users as $user) {
2631 2631
             // Insert in DB the new object key for this item by user
2632 2632
             if (count($objectKeyArray) === 0) {
2633
-                if (WIP === true) error_log('TEAMPASS Debug - storeUsersShareKey case1 - ' . $object_name . ' - ' . $post_object_id . ' - ' . $user['id'] . ' - ' . $objectKey);
2633
+                if (WIP === true) error_log('TEAMPASS Debug - storeUsersShareKey case1 - '.$object_name.' - '.$post_object_id.' - '.$user['id'].' - '.$objectKey);
2634 2634
                 DB::insert(
2635 2635
                     $object_name,
2636 2636
                     [
@@ -2644,7 +2644,7 @@  discard block
 block discarded – undo
2644 2644
                 );
2645 2645
             } else {
2646 2646
                 foreach ($objectKeyArray as $object) {
2647
-                    if (WIP === true) error_log('TEAMPASS Debug - storeUsersShareKey case2 - ' . $object_name . ' - ' . $object['objectId'] . ' - ' . $user['id'] . ' - ' . $object['objectKey']);
2647
+                    if (WIP === true) error_log('TEAMPASS Debug - storeUsersShareKey case2 - '.$object_name.' - '.$object['objectId'].' - '.$user['id'].' - '.$object['objectKey']);
2648 2648
                     DB::insert(
2649 2649
                         $object_name,
2650 2650
                         [
@@ -2672,7 +2672,7 @@  discard block
 block discarded – undo
2672 2672
 function isBase64(string $str): bool
2673 2673
 {
2674 2674
     $str = (string) trim($str);
2675
-    if (! isset($str[0])) {
2675
+    if (!isset($str[0])) {
2676 2676
         return false;
2677 2677
     }
2678 2678
 
@@ -2746,7 +2746,7 @@  discard block
 block discarded – undo
2746 2746
     } catch (\LdapRecord\Auth\BindException $e) {
2747 2747
         $error = $e->getDetailedError();
2748 2748
         if ($error && defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
2749
-            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage(). " - ".$error->getDiagnosticMessage());
2749
+            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage()." - ".$error->getDiagnosticMessage());
2750 2750
         }
2751 2751
         // deepcode ignore ServerLeak: No important data is sent
2752 2752
         echo 'An error occurred.';
@@ -2763,7 +2763,7 @@  discard block
 block discarded – undo
2763 2763
     } catch (\LdapRecord\Auth\BindException $e) {
2764 2764
         $error = $e->getDetailedError();
2765 2765
         if ($error && defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
2766
-            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage(). " - ".$error->getDiagnosticMessage());
2766
+            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage()." - ".$error->getDiagnosticMessage());
2767 2767
         }
2768 2768
         // deepcode ignore ServerLeak: No important data is sent
2769 2769
         echo 'An error occurred.';
@@ -2790,7 +2790,7 @@  discard block
 block discarded – undo
2790 2790
     // expect if personal item
2791 2791
     DB::delete(
2792 2792
         prefixTable('sharekeys_items'),
2793
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
2793
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
2794 2794
         $userId
2795 2795
     );
2796 2796
     // Remove all item sharekeys files
@@ -2798,8 +2798,8 @@  discard block
 block discarded – undo
2798 2798
         prefixTable('sharekeys_files'),
2799 2799
         'user_id = %i AND object_id NOT IN (
2800 2800
             SELECT f.id 
2801
-            FROM ' . prefixTable('items') . ' AS i 
2802
-            INNER JOIN ' . prefixTable('files') . ' AS f ON f.id_item = i.id
2801
+            FROM ' . prefixTable('items').' AS i 
2802
+            INNER JOIN ' . prefixTable('files').' AS f ON f.id_item = i.id
2803 2803
             WHERE i.perso = 1
2804 2804
         )',
2805 2805
         $userId
@@ -2809,8 +2809,8 @@  discard block
 block discarded – undo
2809 2809
         prefixTable('sharekeys_fields'),
2810 2810
         'user_id = %i AND object_id NOT IN (
2811 2811
             SELECT c.id 
2812
-            FROM ' . prefixTable('items') . ' AS i 
2813
-            INNER JOIN ' . prefixTable('categories_items') . ' AS c ON c.item_id = i.id
2812
+            FROM ' . prefixTable('items').' AS i 
2813
+            INNER JOIN ' . prefixTable('categories_items').' AS c ON c.item_id = i.id
2814 2814
             WHERE i.perso = 1
2815 2815
         )',
2816 2816
         $userId
@@ -2818,13 +2818,13 @@  discard block
 block discarded – undo
2818 2818
     // Remove all item sharekeys logs
2819 2819
     DB::delete(
2820 2820
         prefixTable('sharekeys_logs'),
2821
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
2821
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
2822 2822
         $userId
2823 2823
     );
2824 2824
     // Remove all item sharekeys suggestions
2825 2825
     DB::delete(
2826 2826
         prefixTable('sharekeys_suggestions'),
2827
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
2827
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
2828 2828
         $userId
2829 2829
     );
2830 2830
     return false;
@@ -2845,7 +2845,7 @@  discard block
 block discarded – undo
2845 2845
         foreach (DateTimeZone::listIdentifiers() as $timezone) {
2846 2846
             $now->setTimezone(new DateTimeZone($timezone));
2847 2847
             $offsets[] = $offset = $now->getOffset();
2848
-            $timezones[$timezone] = '(' . format_GMT_offset($offset) . ') ' . format_timezone_name($timezone);
2848
+            $timezones[$timezone] = '('.format_GMT_offset($offset).') '.format_timezone_name($timezone);
2849 2849
         }
2850 2850
 
2851 2851
         array_multisort($offsets, $timezones);
@@ -2865,7 +2865,7 @@  discard block
 block discarded – undo
2865 2865
 {
2866 2866
     $hours = intval($offset / 3600);
2867 2867
     $minutes = abs(intval($offset % 3600 / 60));
2868
-    return 'GMT' . ($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
2868
+    return 'GMT'.($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
2869 2869
 }
2870 2870
 
2871 2871
 /**
@@ -2964,8 +2964,7 @@  discard block
 block discarded – undo
2964 2964
 {
2965 2965
     if (isset($array[$key]) === true
2966 2966
         && (is_int($value) === true ?
2967
-            (int) $array[$key] === $value :
2968
-            (string) $array[$key] === $value)
2967
+            (int) $array[$key] === $value : (string) $array[$key] === $value)
2969 2968
     ) {
2970 2969
         return true;
2971 2970
     }
@@ -2987,8 +2986,7 @@  discard block
 block discarded – undo
2987 2986
 {
2988 2987
     if (isset($var) === false
2989 2988
         || (is_int($value) === true ?
2990
-            (int) $var === $value :
2991
-            (string) $var === $value)
2989
+            (int) $var === $value : (string) $var === $value)
2992 2990
     ) {
2993 2991
         return true;
2994 2992
     }
@@ -3039,7 +3037,7 @@  discard block
 block discarded – undo
3039 3037
  */
3040 3038
 function isSetArrayOfValues(array $arrayOfValues): bool
3041 3039
 {
3042
-    foreach($arrayOfValues as $value) {
3040
+    foreach ($arrayOfValues as $value) {
3043 3041
         if (isset($value) === false) {
3044 3042
             return false;
3045 3043
         }
@@ -3061,7 +3059,7 @@  discard block
 block discarded – undo
3061 3059
     /*PHP8 - integer|string*/$value
3062 3060
 ) : bool
3063 3061
 {
3064
-    foreach($arrayOfVars as $variable) {
3062
+    foreach ($arrayOfVars as $variable) {
3065 3063
         if ($variable !== $value) {
3066 3064
             return false;
3067 3065
         }
@@ -3081,7 +3079,7 @@  discard block
 block discarded – undo
3081 3079
     /*PHP8 - integer|string*/$value
3082 3080
 ) : bool
3083 3081
 {
3084
-    foreach($arrayOfVars as $variable) {
3082
+    foreach ($arrayOfVars as $variable) {
3085 3083
         if ($variable === $value) {
3086 3084
             return true;
3087 3085
         }
@@ -3095,7 +3093,7 @@  discard block
 block discarded – undo
3095 3093
  * @param string|int|null $value
3096 3094
  * @return boolean
3097 3095
  */
3098
-function isValueSetNullEmpty(string|int|null $value) : bool
3096
+function isValueSetNullEmpty(string | int | null $value) : bool
3099 3097
 {
3100 3098
     if (is_null($value) === true || empty($value) === true) {
3101 3099
         return true;
@@ -3150,7 +3148,7 @@  discard block
 block discarded – undo
3150 3148
  * @param array     $filters
3151 3149
  * @return array|string
3152 3150
  */
3153
-function dataSanitizer(array $data, array $filters): array|string
3151
+function dataSanitizer(array $data, array $filters): array | string
3154 3152
 {
3155 3153
     // Load Sanitizer library
3156 3154
     $sanitizer = new Sanitizer($data, $filters);
@@ -3179,7 +3177,7 @@  discard block
 block discarded – undo
3179 3177
     // Exists ?
3180 3178
     $userCacheId = DB::queryFirstRow(
3181 3179
         'SELECT increment_id
3182
-        FROM ' . prefixTable('cache_tree') . '
3180
+        FROM ' . prefixTable('cache_tree').'
3183 3181
         WHERE user_id = %i',
3184 3182
         $user_id
3185 3183
     );
@@ -3230,7 +3228,7 @@  discard block
 block discarded – undo
3230 3228
  */
3231 3229
 function pourcentage(float $nombre, float $total, float $pourcentage): float
3232 3230
 { 
3233
-    $resultat = ($nombre/$total) * $pourcentage;
3231
+    $resultat = ($nombre / $total) * $pourcentage;
3234 3232
     return round($resultat);
3235 3233
 }
3236 3234
 
@@ -3260,7 +3258,7 @@  discard block
 block discarded – undo
3260 3258
 
3261 3259
     // Get last folder update
3262 3260
     $lastFolderChange = DB::queryFirstRow(
3263
-        'SELECT valeur FROM ' . prefixTable('misc') . '
3261
+        'SELECT valeur FROM '.prefixTable('misc').'
3264 3262
         WHERE type = %s AND intitule = %s',
3265 3263
         'timestamp',
3266 3264
         'last_folder_change'
@@ -3281,7 +3279,7 @@  discard block
 block discarded – undo
3281 3279
     // Does this user has a tree cache
3282 3280
     $userCacheTree = DB::queryFirstRow(
3283 3281
         'SELECT '.$fieldName.'
3284
-        FROM ' . prefixTable('cache_tree') . '
3282
+        FROM ' . prefixTable('cache_tree').'
3285 3283
         WHERE user_id = %i',
3286 3284
         $session->get('user-id')
3287 3285
     );
@@ -3319,7 +3317,7 @@  discard block
 block discarded – undo
3319 3317
     if (count($folderIds) === 0) {
3320 3318
         $folderIds = DB::queryFirstColumn(
3321 3319
             'SELECT id
3322
-            FROM ' . prefixTable('nested_tree') . '
3320
+            FROM ' . prefixTable('nested_tree').'
3323 3321
             WHERE personal_folder=%i',
3324 3322
             0
3325 3323
         );
@@ -3336,8 +3334,8 @@  discard block
 block discarded – undo
3336 3334
         $rows_tmp = DB::query(
3337 3335
             'SELECT c.id, c.title, c.level, c.type, c.masked, c.order, c.encrypted_data, c.role_visibility, c.is_mandatory,
3338 3336
             f.id_category AS category_id
3339
-            FROM ' . prefixTable('categories_folders') . ' AS f
3340
-            INNER JOIN ' . prefixTable('categories') . ' AS c ON (f.id_category = c.parent_id)
3337
+            FROM ' . prefixTable('categories_folders').' AS f
3338
+            INNER JOIN ' . prefixTable('categories').' AS c ON (f.id_category = c.parent_id)
3341 3339
             WHERE id_folder=%i',
3342 3340
             $folder
3343 3341
         );
@@ -3363,7 +3361,7 @@  discard block
 block discarded – undo
3363 3361
         $valTemp = '';
3364 3362
         $data = DB::queryFirstRow(
3365 3363
             'SELECT valeur
3366
-            FROM ' . prefixTable('misc') . '
3364
+            FROM ' . prefixTable('misc').'
3367 3365
             WHERE type = %s AND intitule=%i',
3368 3366
             'complex',
3369 3367
             $folder
@@ -3380,14 +3378,14 @@  discard block
 block discarded – undo
3380 3378
         $valTemp = '';
3381 3379
         $rows_tmp = DB::query(
3382 3380
             'SELECT t.title
3383
-            FROM ' . prefixTable('roles_values') . ' as v
3384
-            INNER JOIN ' . prefixTable('roles_title') . ' as t ON (v.role_id = t.id)
3381
+            FROM ' . prefixTable('roles_values').' as v
3382
+            INNER JOIN ' . prefixTable('roles_title').' as t ON (v.role_id = t.id)
3385 3383
             WHERE v.folder_id = %i
3386 3384
             GROUP BY title',
3387 3385
             $folder
3388 3386
         );
3389 3387
         foreach ($rows_tmp as $record) {
3390
-            $valTemp .= (empty($valTemp) === true ? '' : ' - ') . $record['title'];
3388
+            $valTemp .= (empty($valTemp) === true ? '' : ' - ').$record['title'];
3391 3389
         }
3392 3390
         $arr_data['visibilityRoles'] = $valTemp;
3393 3391
 
@@ -3420,7 +3418,7 @@  discard block
 block discarded – undo
3420 3418
         // loop on users and check if user has this role
3421 3419
         $rows = DB::query(
3422 3420
             'SELECT id, fonction_id
3423
-            FROM ' . prefixTable('users') . '
3421
+            FROM ' . prefixTable('users').'
3424 3422
             WHERE id != %i AND admin = 0 AND fonction_id IS NOT NULL AND fonction_id != ""',
3425 3423
             $session->get('user-id')
3426 3424
         );
@@ -3452,7 +3450,7 @@  discard block
 block discarded – undo
3452 3450
 
3453 3451
     $val = DB::queryFirstRow(
3454 3452
         'SELECT *
3455
-        FROM ' . prefixTable('users') . '
3453
+        FROM ' . prefixTable('users').'
3456 3454
         WHERE id = %i',
3457 3455
         $userId
3458 3456
     );
@@ -3468,12 +3466,12 @@  discard block
 block discarded – undo
3468 3466
 function upgradeRequired(): bool
3469 3467
 {
3470 3468
     // Get settings.php
3471
-    include_once __DIR__. '/../includes/config/settings.php';
3469
+    include_once __DIR__.'/../includes/config/settings.php';
3472 3470
 
3473 3471
     // Get timestamp in DB
3474 3472
     $val = DB::queryFirstRow(
3475 3473
         'SELECT valeur
3476
-        FROM ' . prefixTable('misc') . '
3474
+        FROM ' . prefixTable('misc').'
3477 3475
         WHERE type = %s AND intitule = %s',
3478 3476
         'admin',
3479 3477
         'upgrade_timestamp'
@@ -3524,7 +3522,7 @@  discard block
 block discarded – undo
3524 3522
     // prepapre background tasks for item keys generation        
3525 3523
     $userTP = DB::queryFirstRow(
3526 3524
         'SELECT pw, public_key, private_key
3527
-        FROM ' . prefixTable('users') . '
3525
+        FROM ' . prefixTable('users').'
3528 3526
         WHERE id = %i',
3529 3527
         TP_USER_ID
3530 3528
     );
@@ -3585,7 +3583,7 @@  discard block
 block discarded – undo
3585 3583
     }
3586 3584
 
3587 3585
     // Generate new keys
3588
-    if ($user_self_change === true && empty($recovery_public_key) === false && empty($recovery_private_key) === false){
3586
+    if ($user_self_change === true && empty($recovery_public_key) === false && empty($recovery_private_key) === false) {
3589 3587
         $userKeys = [
3590 3588
             'public_key' => $recovery_public_key,
3591 3589
             'private_key_clear' => $recovery_private_key,
@@ -3628,8 +3626,8 @@  discard block
 block discarded – undo
3628 3626
             'process_type' => 'create_user_keys',
3629 3627
             'arguments' => json_encode([
3630 3628
                 'new_user_id' => (int) $userId,
3631
-                'new_user_pwd' => cryption($passwordClear, '','encrypt')['string'],
3632
-                'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '','encrypt')['string'],
3629
+                'new_user_pwd' => cryption($passwordClear, '', 'encrypt')['string'],
3630
+                'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '', 'encrypt')['string'],
3633 3631
                 'owner_id' => (int) TP_USER_ID,
3634 3632
                 'creator_pwd' => $userTP['pw'],
3635 3633
                 'send_email' => $sendEmailToUser === true ? 1 : 0,
@@ -3700,19 +3698,19 @@  discard block
 block discarded – undo
3700 3698
 
3701 3699
     // Prepare the subtask queries
3702 3700
     $queries = [
3703
-        'step20' => 'SELECT * FROM ' . prefixTable('items'),
3701
+        'step20' => 'SELECT * FROM '.prefixTable('items'),
3704 3702
 
3705
-        'step30' => 'SELECT * FROM ' . prefixTable('log_items') . 
3703
+        'step30' => 'SELECT * FROM '.prefixTable('log_items'). 
3706 3704
                     ' WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"',
3707 3705
 
3708
-        'step40' => 'SELECT * FROM ' . prefixTable('categories_items') . 
3706
+        'step40' => 'SELECT * FROM '.prefixTable('categories_items'). 
3709 3707
                     ' WHERE encryption_type = "teampass_aes"',
3710 3708
 
3711
-        'step50' => 'SELECT * FROM ' . prefixTable('suggestion'),
3709
+        'step50' => 'SELECT * FROM '.prefixTable('suggestion'),
3712 3710
 
3713
-        'step60' => 'SELECT * FROM ' . prefixTable('files') . ' AS f
3714
-                        INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = f.id_item
3715
-                        WHERE f.status = "' . TP_ENCRYPTION_NAME . '"'
3711
+        'step60' => 'SELECT * FROM '.prefixTable('files').' AS f
3712
+                        INNER JOIN ' . prefixTable('items').' AS i ON i.id = f.id_item
3713
+                        WHERE f.status = "' . TP_ENCRYPTION_NAME.'"'
3716 3714
     ];
3717 3715
 
3718 3716
     // Perform loop on $queries to create sub-tasks
@@ -3902,7 +3900,7 @@  discard block
 block discarded – undo
3902 3900
  */
3903 3901
 function createTaskForItem(
3904 3902
     string $processType,
3905
-    string|array $taskName,
3903
+    string | array $taskName,
3906 3904
     int $itemId,
3907 3905
     int $userId,
3908 3906
     string $objectKey,
@@ -3926,7 +3924,7 @@  discard block
 block discarded – undo
3926 3924
                 'object_key' => $objectKey,
3927 3925
                 'author' => (int) $userId,
3928 3926
             ]),
3929
-            'item_id' => (int) $parentId !== -1 ?  $parentId : null,
3927
+            'item_id' => (int) $parentId !== -1 ? $parentId : null,
3930 3928
         )
3931 3929
     );
3932 3930
     $processId = DB::insertId();
@@ -3936,7 +3934,7 @@  discard block
 block discarded – undo
3936 3934
     if (is_array($taskName) === false) {
3937 3935
         $taskName = [$taskName];
3938 3936
     }
3939
-    foreach($taskName as $task) {
3937
+    foreach ($taskName as $task) {
3940 3938
         if (WIP === true) error_log('createTaskForItem - task: '.$task);
3941 3939
         switch ($task) {
3942 3940
             case 'item_password':
@@ -4033,7 +4031,7 @@  discard block
 block discarded – undo
4033 4031
  * @param integer $user_id
4034 4032
  * @return void
4035 4033
  */
4036
-function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id=0)
4034
+function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id = 0)
4037 4035
 {
4038 4036
     if ($allUsers === true) {
4039 4037
         // Load class DB
@@ -4043,7 +4041,7 @@  discard block
 block discarded – undo
4043 4041
 
4044 4042
         $users = DB::query(
4045 4043
             'SELECT id
4046
-            FROM ' . prefixTable('users') . '
4044
+            FROM ' . prefixTable('users').'
4047 4045
             WHERE id NOT IN ('.OTV_USER_ID.', '.TP_USER_ID.', '.SSH_USER_ID.', '.API_USER_ID.')
4048 4046
             ORDER BY login ASC'
4049 4047
         );
@@ -4061,7 +4059,7 @@  discard block
 block discarded – undo
4061 4059
  * @param integer $user_id
4062 4060
  * @return void
4063 4061
  */
4064
-function purgeUnnecessaryKeysForUser(int $user_id=0)
4062
+function purgeUnnecessaryKeysForUser(int $user_id = 0)
4065 4063
 {
4066 4064
     if ($user_id === 0) {
4067 4065
         return;
@@ -4072,8 +4070,8 @@  discard block
 block discarded – undo
4072 4070
 
4073 4071
     $personalItems = DB::queryFirstColumn(
4074 4072
         'SELECT id
4075
-        FROM ' . prefixTable('items') . ' AS i
4076
-        INNER JOIN ' . prefixTable('log_items') . ' AS li ON li.id_item = i.id
4073
+        FROM ' . prefixTable('items').' AS i
4074
+        INNER JOIN ' . prefixTable('log_items').' AS li ON li.id_item = i.id
4077 4075
         WHERE i.perso = 1 AND li.action = "at_creation" AND li.id_user IN (%i, '.TP_USER_ID.')',
4078 4076
         $user_id
4079 4077
     );
@@ -4122,7 +4120,7 @@  discard block
 block discarded – undo
4122 4120
     // Check if user exists
4123 4121
     $userInfo = DB::queryFirstRow(
4124 4122
         'SELECT login
4125
-        FROM ' . prefixTable('users') . '
4123
+        FROM ' . prefixTable('users').'
4126 4124
         WHERE id = %i',
4127 4125
         $userId
4128 4126
     );
@@ -4131,7 +4129,7 @@  discard block
 block discarded – undo
4131 4129
         $now = (int) time();
4132 4130
         // Prepare file content
4133 4131
         $export_value = file_get_contents(__DIR__."/../includes/core/teampass_ascii.txt")."\n".
4134
-            "Generation date: ".date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now)."\n\n".
4132
+            "Generation date: ".date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now)."\n\n".
4135 4133
             "RECOVERY KEYS - Not to be shared - To be store safely\n\n".
4136 4134
             "Public Key:\n".$session->get('user-public_key')."\n\n".
4137 4135
             "Private Key:\n".$session->get('user-private_key')."\n\n";
@@ -4154,7 +4152,7 @@  discard block
 block discarded – undo
4154 4152
         return prepareExchangedData(
4155 4153
             array(
4156 4154
                 'error' => false,
4157
-                'datetime' => date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now),
4155
+                'datetime' => date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now),
4158 4156
                 'timestamp' => $now,
4159 4157
                 'content' => base64_encode($export_value),
4160 4158
                 'login' => $userInfo['login'],
@@ -4180,8 +4178,8 @@  discard block
 block discarded – undo
4180 4178
  */
4181 4179
 function loadClasses(string $className = ''): void
4182 4180
 {
4183
-    require_once __DIR__. '/../includes/config/include.php';
4184
-    require_once __DIR__. '/../includes/config/settings.php';
4181
+    require_once __DIR__.'/../includes/config/include.php';
4182
+    require_once __DIR__.'/../includes/config/settings.php';
4185 4183
     require_once __DIR__.'/../vendor/autoload.php';
4186 4184
 
4187 4185
     if (defined('DB_PASSWD_CLEAR') === false) {
@@ -4394,7 +4392,7 @@  discard block
 block discarded – undo
4394 4392
 
4395 4393
     // Get current user hash
4396 4394
     $userHash = DB::queryFirstRow(
4397
-        "SELECT pw FROM " . prefixtable('users') . " WHERE id = %d;",
4395
+        "SELECT pw FROM ".prefixtable('users')." WHERE id = %d;",
4398 4396
         $session->get('user-id')
4399 4397
     )['pw'];
4400 4398
 
@@ -4442,11 +4440,11 @@  discard block
 block discarded – undo
4442 4440
         }
4443 4441
         
4444 4442
         // Alternative: serialize ou json selon le contexte
4445
-        return get_class($value) . (method_exists($value, 'getId') ? '#' . $value->getId() : '');
4443
+        return get_class($value).(method_exists($value, 'getId') ? '#'.$value->getId() : '');
4446 4444
     }
4447 4445
     
4448 4446
     if (is_resource($value)) {
4449
-        return 'Resource#' . get_resource_id($value) . ' of type ' . get_resource_type($value);
4447
+        return 'Resource#'.get_resource_id($value).' of type '.get_resource_type($value);
4450 4448
     }
4451 4449
     
4452 4450
     // Cas par défaut
@@ -4466,7 +4464,7 @@  discard block
 block discarded – undo
4466 4464
     // Refuse access if user does not exist and/or is admin
4467 4465
     $user = DB::queryFirstRow(
4468 4466
         'SELECT admin
4469
-        FROM ' . prefixTable('users') . '
4467
+        FROM ' . prefixTable('users').'
4470 4468
         WHERE id = %i',
4471 4469
         $userId
4472 4470
     );
@@ -4477,8 +4475,8 @@  discard block
 block discarded – undo
4477 4475
     // Get file info
4478 4476
     $file = DB::queryFirstRow(
4479 4477
         'SELECT f.id_item, i.id_tree
4480
-        FROM ' . prefixTable('files') . ' as f
4481
-        INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = f.id_item
4478
+        FROM ' . prefixTable('files').' as f
4479
+        INNER JOIN ' . prefixTable('items').' AS i ON i.id = f.id_item
4482 4480
         WHERE f.id = %i',
4483 4481
         $fileId
4484 4482
     );
@@ -4487,7 +4485,7 @@  discard block
 block discarded – undo
4487 4485
     }
4488 4486
 
4489 4487
     // Check if user has access to the item
4490
-    include_once __DIR__. '/items.queries.php';
4488
+    include_once __DIR__.'/items.queries.php';
4491 4489
     $itemAccess = getCurrentAccessRights(
4492 4490
         (int) filter_var($userId, FILTER_SANITIZE_NUMBER_INT),
4493 4491
         (int) filter_var($file['id_item'], FILTER_SANITIZE_NUMBER_INT),
Please login to merge, or discard this patch.
sources/folders.class.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
         $parentComplexity = $this->checkComplexityLevel($parentFolderData, $complexity, $parent_id);
93 93
         if (isset($parentComplexity['error']) && $parentComplexity['error'] === true) {
94
-            return $this->errorResponse($this->lang->get('error_folder_complexity_lower_than_top_folder') . " [<b>{$this->settings['TP_PW_COMPLEXITY'][$parentComplexity['valeur']][1]}</b>]");
94
+            return $this->errorResponse($this->lang->get('error_folder_complexity_lower_than_top_folder')." [<b>{$this->settings['TP_PW_COMPLEXITY'][$parentComplexity['valeur']][1]}</b>]");
95 95
         }
96 96
 
97 97
         return $this->createFolder($params, array_merge($parentFolderData, $parentComplexity), $options);
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
         ) {
145 145
             DB::query(
146 146
                 'SELECT *
147
-                FROM ' . prefixTable('nested_tree') . '
147
+                FROM ' . prefixTable('nested_tree').'
148 148
                 WHERE title = %s AND personal_folder = 0',
149 149
                 $title
150 150
             );
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         //check if parent folder is personal
169 169
         $data = DB::queryFirstRow(
170 170
             'SELECT personal_folder, bloquer_creation, bloquer_modification
171
-            FROM ' . prefixTable('nested_tree') . '
171
+            FROM ' . prefixTable('nested_tree').'
172 172
             WHERE id = %i',
173 173
             $parent_id
174 174
         );
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
             // get complexity level for this folder
208 208
             $data = DB::queryFirstRow(
209 209
                 'SELECT valeur
210
-                FROM ' . prefixTable('misc') . '
210
+                FROM ' . prefixTable('misc').'
211 211
                 WHERE intitule = %i AND type = %s',
212 212
                 $parent_id,
213 213
                 'complex'
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
      */
279 279
     private function canCreateFolder($isPersonal, $user_is_admin, $user_is_manager, $user_can_manage_all_users, $user_can_create_root_folder)
280 280
     {
281
-        return (int)$isPersonal === 1 ||
282
-            (int)$user_is_admin === 1 ||
283
-            ((int)$user_is_manager === 1 || (int)$user_can_manage_all_users === 1) ||
281
+        return (int) $isPersonal === 1 ||
282
+            (int) $user_is_admin === 1 ||
283
+            ((int) $user_is_manager === 1 || (int) $user_can_manage_all_users === 1) ||
284 284
             ($this->settings['enable_user_can_create_folders'] ?? false) ||
285
-            ((int)$user_can_create_root_folder === 1);
285
+            ((int) $user_can_create_root_folder === 1);
286 286
     }
287 287
 
288 288
     /**
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
         $path = '';
363 363
         $tree_path = $tree->getPath(0, false);
364 364
         foreach ($tree_path as $fld) {
365
-            $path .= empty($path) ? $fld->title : '/' . $fld->title;
365
+            $path .= empty($path) ? $fld->title : '/'.$fld->title;
366 366
         }
367 367
 
368 368
         $new_json = [
@@ -378,13 +378,13 @@  discard block
 block discarded – undo
378 378
 
379 379
         $cache_tree = DB::queryFirstRow(
380 380
             'SELECT increment_id, folders, visible_folders 
381
-            FROM ' . prefixTable('cache_tree') . ' 
381
+            FROM ' . prefixTable('cache_tree').' 
382 382
             WHERE user_id = %i', 
383 383
             (int) $user_id
384 384
         );
385 385
 
386 386
         if (empty($cache_tree)) {
387
-<<<<<<< HEAD
387
+<< << <<< HEAD
388 388
             DB::insert(
389 389
                 prefixTable('cache_tree'), 
390 390
                 [
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -119,8 +119,9 @@
 block discarded – undo
119 119
      */
120 120
     private function isParentFolderAllowed($parent_id, $user_accessible_folders, $user_is_admin, $user_can_create_root_folder)
121 121
     {
122
-        if ($parent_id == 0 && $user_can_create_root_folder == true)
123
-	    return true;
122
+        if ($parent_id == 0 && $user_can_create_root_folder == true) {
123
+        	    return true;
124
+        }
124 125
 
125 126
         if (in_array($parent_id, $user_accessible_folders) === false
126 127
             && (int) $user_is_admin !== 1
Please login to merge, or discard this patch.
scripts/background_tasks___handler.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 use TeampassClasses\ConfigManager\ConfigManager;
31 31
 
32 32
 require_once __DIR__.'/../sources/main.functions.php';
33
-require_once __DIR__ . '/taskLogger.php';
33
+require_once __DIR__.'/taskLogger.php';
34 34
 
35 35
 class BackgroundTasksHandler {
36 36
     private $settings;
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     public function processBackgroundTasks() {
56 56
         // Prevent multiple concurrent executions
57 57
         if (!$this->acquireProcessLock()) {
58
-            if (LOG_TASKS=== true) $this->logger->log('Process already running', 'INFO');
58
+            if (LOG_TASKS === true) $this->logger->log('Process already running', 'INFO');
59 59
             return false;
60 60
         }
61 61
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
             $this->processTaskBatches();
65 65
             $this->performMaintenanceTasks();
66 66
         } catch (Exception $e) {
67
-            if (LOG_TASKS=== true) $this->logger->log('Task processing error: ' . $e->getMessage(), 'ERROR');
67
+            if (LOG_TASKS === true) $this->logger->log('Task processing error: '.$e->getMessage(), 'ERROR');
68 68
         } finally {
69 69
             $this->releaseProcessLock();
70 70
         }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             return false;
84 84
         }
85 85
         
86
-        fwrite($fp, (string)getmypid());
86
+        fwrite($fp, (string) getmypid());
87 87
         return true;
88 88
     }
89 89
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     private function cleanupStaleTasks() {
102 102
         // Mark tasks as failed if they've been running too long
103 103
         DB::query(
104
-            'UPDATE ' . prefixTable('background_tasks') . ' 
104
+            'UPDATE '.prefixTable('background_tasks').' 
105 105
             SET is_in_progress = -1, 
106 106
                 finished_at = %i, 
107 107
                 status = "failed",
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 
115 115
         // Remove very old failed tasks
116 116
         DB::query(
117
-            'DELETE t, st FROM ' . prefixTable('background_tasks') . ' t
118
-            INNER JOIN ' . prefixTable('background_subtasks') . ' st ON (t.increment_id = st.task_id)
117
+            'DELETE t, st FROM '.prefixTable('background_tasks').' t
118
+            INNER JOIN ' . prefixTable('background_subtasks').' st ON (t.increment_id = st.task_id)
119 119
             WHERE t.finished_at < %i 
120 120
             AND t.status = %s',
121 121
             time() - $this->maxTimeBeforeRemoval,
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         
133 133
         // Check if the maximum number of parallel tasks is reached
134 134
         if ($runningTasks >= $this->maxParallelTasks) {
135
-            if (LOG_TASKS=== true) $this->logger->log('Wait ... '.$runningTasks.' out of '.$this->maxParallelTasks.' are already running ', 'INFO');
135
+            if (LOG_TASKS === true) $this->logger->log('Wait ... '.$runningTasks.' out of '.$this->maxParallelTasks.' are already running ', 'INFO');
136 136
             return;
137 137
         }
138 138
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
         // Fetch next batch of tasks
142 142
         $tasks = DB::query(
143 143
             'SELECT increment_id, process_type, arguments 
144
-            FROM ' . prefixTable('background_tasks') . '
144
+            FROM ' . prefixTable('background_tasks').'
145 145
             WHERE is_in_progress = 0 
146 146
             AND (finished_at IS NULL OR finished_at = "")
147 147
             ORDER BY increment_id ASC
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         );
151 151
 
152 152
         foreach ($tasks as $task) {
153
-            if (LOG_TASKS=== true) $this->logger->log('Launching '.$task['increment_id'], 'INFO');
153
+            if (LOG_TASKS === true) $this->logger->log('Launching '.$task['increment_id'], 'INFO');
154 154
             $this->processIndividualTask($task);
155 155
         }
156 156
     }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
      * @param array $task The task to process.
162 162
      */
163 163
     private function processIndividualTask(array $task) {
164
-        if (LOG_TASKS=== true)  $this->logger->log('Starting task: ' . print_r($task, true), 'INFO');
164
+        if (LOG_TASKS === true)  $this->logger->log('Starting task: '.print_r($task, true), 'INFO');
165 165
 
166 166
         // Store progress in the database        
167 167
         DB::update(
@@ -179,19 +179,19 @@  discard block
 block discarded – undo
179 179
         // Prepare process
180 180
         $process = new Process([
181 181
             PHP_BINARY,
182
-            __DIR__ . '/background_tasks___worker.php',
182
+            __DIR__.'/background_tasks___worker.php',
183 183
             $task['increment_id'],
184 184
             $task['process_type'],
185 185
             $task['arguments']
186 186
         ]);
187 187
 
188 188
         // Launch process
189
-        try{
189
+        try {
190 190
             $process->setTimeout($this->maxExecutionTime);
191 191
             $process->mustRun();
192 192
 
193 193
         } catch (Exception $e) {
194
-            if (LOG_TASKS=== true) $this->logger->log('Error launching task: ' . $e->getMessage(), 'ERROR');
194
+            if (LOG_TASKS === true) $this->logger->log('Error launching task: '.$e->getMessage(), 'ERROR');
195 195
             DB::update(
196 196
                 prefixTable('background_tasks'),
197 197
                 [
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
     private function countRunningTasks(): int {
214 214
         return DB::queryFirstField(
215 215
             'SELECT COUNT(*) 
216
-            FROM ' . prefixTable('background_tasks') . ' 
216
+            FROM ' . prefixTable('background_tasks').' 
217 217
             WHERE is_in_progress = 1'
218 218
         );
219 219
     }
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
      */
235 235
     private function cleanMultipleItemsEdition() {
236 236
         DB::query(
237
-            'DELETE i1 FROM ' . prefixTable('items_edition') . ' i1
237
+            'DELETE i1 FROM '.prefixTable('items_edition').' i1
238 238
             JOIN (
239 239
                 SELECT user_id, item_id, MIN(timestamp) AS oldest_timestamp
240
-                FROM ' . prefixTable('items_edition') . '
240
+                FROM ' . prefixTable('items_edition').'
241 241
                 GROUP BY user_id, item_id
242 242
             ) i2 ON i1.user_id = i2.user_id AND i1.item_id = i2.item_id
243 243
             WHERE i1.timestamp > i2.oldest_timestamp'
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
      */
251 251
     private function handleItemTokensExpiration() {
252 252
         DB::query(
253
-            'DELETE FROM ' . prefixTable('items_edition') . '
253
+            'DELETE FROM '.prefixTable('items_edition').'
254 254
             WHERE timestamp < %i',
255 255
             time() - ($this->settings['delay_item_edition'] * 60 ?: EDITION_LOCK_PERIOD)
256 256
         );
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
         // 1. Get all finished tasks older than the cutoff timestamp
268 268
         //    and that are not in progress
269 269
         $tasks = DB::query(
270
-            'SELECT increment_id FROM ' . prefixTable('background_tasks') . '
270
+            'SELECT increment_id FROM '.prefixTable('background_tasks').'
271 271
             WHERE status = %s AND is_in_progress = %i AND finished_at < %s',
272 272
             'completed',
273 273
             -1,
@@ -282,19 +282,19 @@  discard block
 block discarded – undo
282 282
     
283 283
         // 2. Delete all subtasks related to these tasks
284 284
         DB::query(
285
-            'DELETE FROM ' . prefixTable('background_subtasks') . '
285
+            'DELETE FROM '.prefixTable('background_subtasks').'
286 286
             WHERE task_id IN %ls',
287 287
             $taskIds
288 288
         );
289 289
     
290 290
         // 3. Delete the tasks themselves
291 291
         DB::query(
292
-            'DELETE FROM ' . prefixTable('background_tasks') . '
292
+            'DELETE FROM '.prefixTable('background_tasks').'
293 293
             WHERE increment_id IN %ls',
294 294
             $taskIds
295 295
         );
296 296
     
297
-        if (LOG_TASKS=== true) $this->logger->log('Old finished tasks cleaned: ' . count($taskIds), 'INFO');
297
+        if (LOG_TASKS === true) $this->logger->log('Old finished tasks cleaned: '.count($taskIds), 'INFO');
298 298
     }
299 299
 }
300 300
 
@@ -308,5 +308,5 @@  discard block
 block discarded – undo
308 308
     $tasksHandler = new BackgroundTasksHandler($settings);
309 309
     $tasksHandler->processBackgroundTasks();
310 310
 } catch (Exception $e) {
311
-    error_log('Teampass Background Tasks Error: ' . $e->getMessage());
311
+    error_log('Teampass Background Tasks Error: '.$e->getMessage());
312 312
 }
313 313
\ No newline at end of file
Please login to merge, or discard this patch.