Passed
Push — master ( 8995ac...1b609d )
by Nils
06:33
created
api/Controller/Api/BaseController.php 1 patch
Spacing   +3 added lines, -3 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
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     {
75 75
         $filters = [];
76 76
         $array_size = count($array);
77
-        for ($i=0; $i < $array_size; $i++) {
77
+        for ($i = 0; $i < $array_size; $i++) {
78 78
             array_push($filters, 'trim|escape');
79 79
         }
80 80
         
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      * @param mixed  $data
93 93
      * @param string $httpHeader
94 94
      */
95
-    protected function sendOutput($data, $httpHeaders=array()): void
95
+    protected function sendOutput($data, $httpHeaders = array()): void
96 96
     {
97 97
         header_remove('Set-Cookie');
98 98
 
Please login to merge, or discard this patch.
api/Controller/Api/ItemController.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
      */
41 41
     private function getUserPrivateKey(array $userData): ?string
42 42
     {
43
-        include_once API_ROOT_PATH . '/inc/jwt_utils.php';
43
+        include_once API_ROOT_PATH.'/inc/jwt_utils.php';
44 44
 
45 45
         // Verify session_key exists in JWT payload
46 46
         if (!isset($userData['session_key']) || empty($userData['session_key'])) {
47
-            error_log('getUserPrivateKey: Missing session_key in JWT token for user ID ' . $userData['id']);
47
+            error_log('getUserPrivateKey: Missing session_key in JWT token for user ID '.$userData['id']);
48 48
             return null;
49 49
         }
50 50
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
             // SQL where clause with folders list
89 89
             if (isset($arrQueryStringParams['folders']) === true) {
90 90
                 // convert the folders to an array
91
-                $arrQueryStringParams['folders'] = explode(',', str_replace( array('[',']') , ''  , $arrQueryStringParams['folders']));
91
+                $arrQueryStringParams['folders'] = explode(',', str_replace(array('[', ']'), '', $arrQueryStringParams['folders']));
92 92
 
93 93
                 // ensure to only use the intersection
94 94
                 $foldersList = implode(',', array_intersect($arrQueryStringParams['folders'], $userData['folders_list']));
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
                 } else {
257 257
                     // Gérer le cas où les paramètres ne sont pas un tableau
258 258
                     $strErrorDesc = 'Data not consistent';
259
-                    $strErrorHeader = 'Expected array, received ' . gettype($arrQueryStringParams);
259
+                    $strErrorHeader = 'Expected array, received '.gettype($arrQueryStringParams);
260 260
                 }
261 261
             }
262 262
         } else {
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
             // SQL where clause with item id
308 308
             if (isset($arrQueryStringParams['id']) === true) {
309 309
                 // build sql where clause by ID
310
-                $sqlExtra = ' WHERE i.id = '.$arrQueryStringParams['id'] . $sql_constraint;
310
+                $sqlExtra = ' WHERE i.id = '.$arrQueryStringParams['id'].$sql_constraint;
311 311
             } else if (isset($arrQueryStringParams['label']) === true) {
312 312
                 // build sql where clause by LABEL
313
-                $sqlExtra = ' WHERE i.label '.(isset($arrQueryStringParams['like']) === true && (int) $arrQueryStringParams['like'] === 1 ? ' LIKE '.$arrQueryStringParams['label'] : ' = '.$arrQueryStringParams['label']) . $sql_constraint;
313
+                $sqlExtra = ' WHERE i.label '.(isset($arrQueryStringParams['like']) === true && (int) $arrQueryStringParams['like'] === 1 ? ' LIKE '.$arrQueryStringParams['label'] : ' = '.$arrQueryStringParams['label']).$sql_constraint;
314 314
             } else if (isset($arrQueryStringParams['description']) === true) {
315 315
                 // build sql where clause by LABEL
316 316
                 $sqlExtra = ' WHERE i.description '.(isset($arrQueryStringParams['like']) === true && (int) $arrQueryStringParams['like'] === 1 ? ' LIKE '.$arrQueryStringParams['description'] : ' = '.$arrQueryStringParams['description']).$sql_constraint;
Please login to merge, or discard this patch.
api/Model/AuthModel.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -231,7 +231,7 @@
 block discarded – undo
231 231
         $configManager = new ConfigManager();
232 232
         $SETTINGS = $configManager->getAllSettings();
233 233
 
234
-		$payload = [
234
+        $payload = [
235 235
             'username' => $login,
236 236
             'id' => $id,
237 237
             'exp' => (time() + $SETTINGS['api_token_duration'] + 600),
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     public function getUserAuth(string $login, string $password, string $apikey): array
50 50
     {
51 51
         // Sanitize
52
-        include_once API_ROOT_PATH . '/../sources/main.functions.php';
52
+        include_once API_ROOT_PATH.'/../sources/main.functions.php';
53 53
         $inputData = dataSanitizer(
54 54
             [
55 55
                 'login' => isset($login) === true ? $login : '',
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
             // Check if user exists
75 75
             $userInfo = DB::queryfirstrow(
76 76
                 "SELECT u.id, u.pw, u.login, u.admin, u.gestionnaire, u.can_manage_all_users, u.fonction_id, u.can_create_root_folder, u.public_key, u.private_key, u.personal_folder, u.fonction_id, u.groupes_visibles, u.groupes_interdits, a.value AS user_api_key, a.allowed_folders as user_api_allowed_folders, a.enabled, a.allowed_to_create, a.allowed_to_read, a.allowed_to_update, a.allowed_to_delete
77
-                FROM " . prefixTable('users') . " AS u
78
-                INNER JOIN " . prefixTable('api') . " AS a ON (a.user_id=u.id)
77
+                FROM " . prefixTable('users')." AS u
78
+                INNER JOIN " . prefixTable('api')." AS a ON (a.user_id=u.id)
79 79
                 WHERE login = %s",
80 80
                 $inputData['login']
81 81
             );
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
                 // Encrypt the decrypted private key with the session key
120 120
                 // This allows us to store it securely in the database without exposing it
121
-                require_once API_ROOT_PATH . '/inc/encryption_utils.php';
121
+                require_once API_ROOT_PATH.'/inc/encryption_utils.php';
122 122
                 $encryptedPrivateKey = encrypt_with_session_key($privateKeyClear, $sessionKey);
123 123
 
124 124
                 if ($encryptedPrivateKey === false) {
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
         if (count($userFunctionId) > 0) {
286 286
             $rows = DB::query(
287 287
                 'SELECT * 
288
-                FROM ' . prefixTable('roles_values') . '
288
+                FROM ' . prefixTable('roles_values').'
289 289
                 WHERE role_id IN %li  AND type IN ("W", "ND", "NE", "NDNE", "R")',
290 290
                 $userFunctionId
291 291
             );
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
         $inc = 0;
312 312
         $rows = DB::query(
313 313
             'SELECT id, id_tree 
314
-            FROM ' . prefixTable('items') . '
314
+            FROM ' . prefixTable('items').'
315 315
             WHERE restricted_to LIKE %s'.
316 316
             (count($userFunctionId) > 0 ? ' AND id_tree NOT IN %li' : ''),
317 317
             $userInfo['id'],
@@ -326,8 +326,8 @@  discard block
 block discarded – undo
326 326
         // Check for the users roles if some specific rights exist on items
327 327
         $rows = DB::query(
328 328
             'SELECT i.id_tree, r.item_id
329
-            FROM ' . prefixTable('items') . ' AS i
330
-            INNER JOIN ' . prefixTable('restriction_to_roles') . ' AS r ON (r.item_id=i.id)
329
+            FROM ' . prefixTable('items').' AS i
330
+            INNER JOIN ' . prefixTable('restriction_to_roles').' AS r ON (r.item_id=i.id)
331 331
             WHERE '.(count($userFunctionId) > 0 ? ' id_tree NOT IN %li AND ' : '').' i.id_tree != ""
332 332
             ORDER BY i.id_tree ASC',
333 333
             count($userFunctionId) > 0 ? $userFunctionId : DB::sqleval('0')
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
         // Add all personal folders
344 344
         $rows = DB::queryFirstRow(
345 345
             'SELECT id 
346
-            FROM ' . prefixTable('nested_tree') . '
346
+            FROM ' . prefixTable('nested_tree').'
347 347
             WHERE title = %i AND personal_folder = 1'.
348 348
             (count($userFunctionId) > 0 ? ' AND id NOT IN %li' : ''),
349 349
             $userInfo['id'],
Please login to merge, or discard this patch.
api/inc/bootstrap.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -25,18 +25,18 @@  discard block
 block discarded – undo
25 25
 
26 26
 use TeampassClasses\ConfigManager\ConfigManager;
27 27
 
28
-define("API_ROOT_PATH", __DIR__ . "/..");
28
+define("API_ROOT_PATH", __DIR__."/..");
29 29
 
30 30
 // include main configuration file
31
-require API_ROOT_PATH . '/../sources/main.functions.php';
31
+require API_ROOT_PATH.'/../sources/main.functions.php';
32 32
 
33 33
 // include the base controller file
34
-require API_ROOT_PATH . "/Controller/Api/BaseController.php";
34
+require API_ROOT_PATH."/Controller/Api/BaseController.php";
35 35
 
36 36
 // include the use model file
37
-require API_ROOT_PATH . "/Model/UserModel.php";
38
-require API_ROOT_PATH . "/Model/ItemModel.php";
39
-require API_ROOT_PATH . "/Model/FolderModel.php";
37
+require API_ROOT_PATH."/Model/UserModel.php";
38
+require API_ROOT_PATH."/Model/ItemModel.php";
39
+require API_ROOT_PATH."/Model/FolderModel.php";
40 40
 
41 41
 /**
42 42
  * Launch expected action for ITEM
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
         return;
57 57
     }
58 58
     // Perform the action
59
-    require API_ROOT_PATH . "/Controller/Api/ItemController.php";    
59
+    require API_ROOT_PATH."/Controller/Api/ItemController.php";    
60 60
     $objFeedController = new ItemController();
61
-    $strMethodName = $actions[0] . 'Action';
61
+    $strMethodName = $actions[0].'Action';
62 62
     $objFeedController->{$strMethodName}($userData);
63 63
 }
64 64
 
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
         return;
81 81
     }
82 82
     // Perform the action
83
-    require API_ROOT_PATH . "/Controller/Api/FolderController.php";
83
+    require API_ROOT_PATH."/Controller/Api/FolderController.php";
84 84
     $objFeedController = new FolderController();
85
-    $strMethodName = $actions[0] . 'Action';
85
+    $strMethodName = $actions[0].'Action';
86 86
     $objFeedController->{$strMethodName}($userData);
87 87
 }
88 88
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
  */
140 140
 function verifyAuth(): string
141 141
 {
142
-    include_once API_ROOT_PATH . '/inc/jwt_utils.php';
142
+    include_once API_ROOT_PATH.'/inc/jwt_utils.php';
143 143
     $bearer_token = get_bearer_token();
144 144
 
145 145
     if (empty($bearer_token) === false && is_jwt_valid($bearer_token) === true) {
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
  */
170 170
 function getDataFromToken(): string
171 171
 {
172
-    include_once API_ROOT_PATH . '/inc/jwt_utils.php';
172
+    include_once API_ROOT_PATH.'/inc/jwt_utils.php';
173 173
     $bearer_token = get_bearer_token();
174 174
 
175 175
     if (empty($bearer_token) === false) {
Please login to merge, or discard this patch.
api/inc/jwt_utils.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -148,34 +148,34 @@  discard block
 block discarded – undo
148 148
  */
149 149
 function get_user_keys(int $userId, string $keyTempo, string $sessionKey): ?array
150 150
 {
151
-    require_once API_ROOT_PATH . '/inc/encryption_utils.php';
151
+    require_once API_ROOT_PATH.'/inc/encryption_utils.php';
152 152
 
153 153
     // Retrieve user's public key and encrypted private key from database
154 154
     $userInfo = DB::queryfirstrow(
155 155
         "SELECT u.public_key, u.key_tempo, a.encrypted_private_key
156
-        FROM " . prefixTable('users') . " AS u
157
-        INNER JOIN " . prefixTable('api') . " AS a ON (a.user_id = u.id)
156
+        FROM " . prefixTable('users')." AS u
157
+        INNER JOIN " . prefixTable('api')." AS a ON (a.user_id = u.id)
158 158
         WHERE u.id = %i",
159 159
         $userId
160 160
     );
161 161
 
162 162
     if (DB::count() === 0) {
163 163
         // User not found or no API configuration
164
-        error_log('[API] get_user_keys: User not found or no API config for user ID ' . $userId);
164
+        error_log('[API] get_user_keys: User not found or no API config for user ID '.$userId);
165 165
         return null;
166 166
     }
167 167
 
168 168
     // Validate key_tempo matches (security check - ensures session is still valid)
169 169
     if ($userInfo['key_tempo'] !== $keyTempo) {
170 170
         // Session invalid or expired
171
-        error_log('[API] get_user_keys: Invalid key_tempo for user ID ' . $userId);
171
+        error_log('[API] get_user_keys: Invalid key_tempo for user ID '.$userId);
172 172
         return null;
173 173
     }
174 174
 
175 175
     // Check if encrypted private key exists
176 176
     if (empty($userInfo['encrypted_private_key'])) {
177 177
         // No encrypted key found - user needs to re-authenticate
178
-        error_log('[API] get_user_keys: No encrypted private key found for user ID ' . $userId);
178
+        error_log('[API] get_user_keys: No encrypted private key found for user ID '.$userId);
179 179
         return null;
180 180
     }
181 181
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 
196 196
     if ($privateKeyDecrypted === false) {
197 197
         // Decryption failed - wrong key or tampered data
198
-        error_log('[API] get_user_keys: Failed to decrypt private key for user ID ' . $userId);
198
+        error_log('[API] get_user_keys: Failed to decrypt private key for user ID '.$userId);
199 199
         return null;
200 200
     }
201 201
 
Please login to merge, or discard this patch.
api/inc/encryption_utils.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 function encrypt_with_session_key(string $data, string $key)
48 48
 {
49 49
     if (strlen($key) !== 32) {
50
-        error_log('[API] encrypt_with_session_key: Invalid key length. Expected 32 bytes, got ' . strlen($key));
50
+        error_log('[API] encrypt_with_session_key: Invalid key length. Expected 32 bytes, got '.strlen($key));
51 51
         return false;
52 52
     }
53 53
 
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
 
75 75
         // Combine nonce + tag + ciphertext and encode in base64
76 76
         // Format: [12 bytes nonce][16 bytes tag][variable ciphertext]
77
-        return base64_encode($nonce . $tag . $ciphertext);
77
+        return base64_encode($nonce.$tag.$ciphertext);
78 78
 
79 79
     } catch (Exception $e) {
80
-        error_log('[API] encrypt_with_session_key: Exception - ' . $e->getMessage());
80
+        error_log('[API] encrypt_with_session_key: Exception - '.$e->getMessage());
81 81
         return false;
82 82
     }
83 83
 }
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 function decrypt_with_session_key(string $encryptedData, string $key)
96 96
 {
97 97
     if (strlen($key) !== 32) {
98
-        error_log('[API] decrypt_with_session_key: Invalid key length. Expected 32 bytes, got ' . strlen($key));
98
+        error_log('[API] decrypt_with_session_key: Invalid key length. Expected 32 bytes, got '.strlen($key));
99 99
         return false;
100 100
     }
101 101
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         return $plaintext;
137 137
 
138 138
     } catch (Exception $e) {
139
-        error_log('[API] decrypt_with_session_key: Exception - ' . $e->getMessage());
139
+        error_log('[API] decrypt_with_session_key: Exception - '.$e->getMessage());
140 140
         return false;
141 141
     }
142 142
 }
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
     'ignore_this_password_is_lost' => 'I no longer remember my previous password. I understand that it will reset the password for my personal items.',
Please login to merge, or discard this patch.
sources/main.queries.php 1 patch
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 ) {
80 80
     // Not allowed page
81 81
     $session->set('system-error_code', ERR_NOT_ALLOWED);
82
-    include $SETTINGS['cpassman_dir'] . '/error.php';
82
+    include $SETTINGS['cpassman_dir'].'/error.php';
83 83
     exit;
84 84
 }
85 85
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
             // Get current user hash
277 277
             $userHash = DB::queryFirstRow(
278
-                "SELECT pw FROM " . prefixtable('users') . " WHERE id = %d;",
278
+                "SELECT pw FROM ".prefixtable('users')." WHERE id = %d;",
279 279
                 $session->get('user-id')
280 280
             )['pw'];
281 281
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
  * @param string $post_key
332 332
  * @return string
333 333
  */
334
-function userHandler(string $post_type, array|null|string $dataReceived, array $SETTINGS, string $post_key): string
334
+function userHandler(string $post_type, array | null | string $dataReceived, array $SETTINGS, string $post_key): string
335 335
 {
336 336
     $session = SessionManager::getSession();
337 337
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
     if (isset($dataReceived['user_id'])) {
367 367
         // Get info about user to modify
368 368
         $targetUserInfos = DB::queryFirstRow(
369
-            'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM ' . prefixTable('users') . '
369
+            'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM '.prefixTable('users').'
370 370
             WHERE id = %i',
371 371
             $dataReceived['user_id']
372 372
         );
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
         case 'mail_me'://action_mail
516 516
             // Get info about user to send email
517 517
             $data_user = DB::queryFirstRow(
518
-                'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM ' . prefixTable('users') . '
518
+                'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM '.prefixTable('users').'
519 519
                 WHERE email = %s',
520 520
                 filter_var($dataReceived['receipt'], FILTER_SANITIZE_FULL_SPECIAL_CHARS)
521 521
             );
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
     if (isset($dataReceived['user_id'])) {
635 635
         // Get info about user to modify
636 636
         $targetUserInfos = DB::queryFirstRow(
637
-            'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM ' . prefixTable('users') . '
637
+            'SELECT admin, gestionnaire, can_manage_all_users, isAdministratedByRole FROM '.prefixTable('users').'
638 638
             WHERE id = %i',
639 639
             $dataReceived['user_id']
640 640
         );
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 
719 719
             // Get current user hash
720 720
             $userHash = DB::queryFirstRow(
721
-                "SELECT pw FROM " . prefixtable('users') . " WHERE id = %d;",
721
+                "SELECT pw FROM ".prefixtable('users')." WHERE id = %d;",
722 722
                 $session->get('user-id')
723 723
             )['pw'];
724 724
 
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 
757 757
                 // Get current user hash
758 758
                 $userHash = DB::queryFirstRow(
759
-                    "SELECT pw FROM " . prefixtable('users') . " WHERE id = %d;",
759
+                    "SELECT pw FROM ".prefixtable('users')." WHERE id = %d;",
760 760
                     $session->get('user-id')
761 761
                 )['pw'];
762 762
 
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
 
801 801
                 // Get current user hash
802 802
                 $userHash = DB::queryFirstRow(
803
-                    "SELECT pw FROM " . prefixtable('users') . " WHERE id = %i;",
803
+                    "SELECT pw FROM ".prefixtable('users')." WHERE id = %i;",
804 804
                     $session->get('user-id')
805 805
                 )['pw'];
806 806
 
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
  * @param array $SETTINGS
845 845
  * @return string
846 846
  */
847
-function systemHandler(string $post_type, array|null|string $dataReceived, array $SETTINGS): string
847
+function systemHandler(string $post_type, array | null | string $dataReceived, array $SETTINGS): string
848 848
 {
849 849
     $session = SessionManager::getSession();
850 850
     switch ($post_type) {
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
                 )
946 946
             );
947 947
 
948
-            return '[{"token" : "' . $token . '"}]';
948
+            return '[{"token" : "'.$token.'"}]';
949 949
 
950 950
         /*
951 951
         * Default case
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
 }
962 962
 
963 963
 
964
-function utilsHandler(string $post_type, array|null|string $dataReceived, array $SETTINGS): string
964
+function utilsHandler(string $post_type, array | null | string $dataReceived, array $SETTINGS): string
965 965
 {
966 966
     switch ($post_type) {
967 967
         /*
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
         array(
1031 1031
             'error' => false,
1032 1032
             'timestamp' => $session->get('user-session_duration'),
1033
-            'max_time_to_add' => intdiv((($maximum_session_expiration_time*60) - ((int) $session->get('user-session_duration') - time())), 60),
1033
+            'max_time_to_add' => intdiv((($maximum_session_expiration_time * 60) - ((int) $session->get('user-session_duration') - time())), 60),
1034 1034
             'max_session_duration' => $maximum_session_expiration_time,
1035 1035
         ),
1036 1036
         'encode'
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
     // get number of items
1083 1083
     DB::queryFirstRow(
1084 1084
         'SELECT increment_id
1085
-        FROM ' . prefixTable('sharekeys_items') .
1085
+        FROM ' . prefixTable('sharekeys_items').
1086 1086
         ' WHERE user_id = %i',
1087 1087
         $userId
1088 1088
     );
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
         // check if expected security level is reached
1138 1138
         $dataUser = DB::queryFirstRow(
1139 1139
             'SELECT *
1140
-            FROM ' . prefixTable('users') . ' WHERE id = %i',
1140
+            FROM ' . prefixTable('users').' WHERE id = %i',
1141 1141
             $post_user_id
1142 1142
         );
1143 1143
 
@@ -1158,8 +1158,8 @@  discard block
 block discarded – undo
1158 1158
         if (empty($dataUser['fonction_id']) === false) {
1159 1159
             $data = DB::queryFirstRow(
1160 1160
                 'SELECT complexity
1161
-                FROM ' . prefixTable('roles_title') . '
1162
-                WHERE id IN (' . $dataUser['fonction_id'] . ')
1161
+                FROM ' . prefixTable('roles_title').'
1162
+                WHERE id IN (' . $dataUser['fonction_id'].')
1163 1163
                 ORDER BY complexity DESC'
1164 1164
             );
1165 1165
         } else {
@@ -1172,8 +1172,8 @@  discard block
 block discarded – undo
1172 1172
             return prepareExchangedData(
1173 1173
                 array(
1174 1174
                     'error' => true,
1175
-                    'message' => '<div style="margin:10px 0 10px 15px;">' . $lang->get('complexity_level_not_reached') . '.<br>' .
1176
-                        $lang->get('expected_complexity_level') . ': <b>' . TP_PW_COMPLEXITY[$data['complexity']][1] . '</b></div>',
1175
+                    'message' => '<div style="margin:10px 0 10px 15px;">'.$lang->get('complexity_level_not_reached').'.<br>'.
1176
+                        $lang->get('expected_complexity_level').': <b>'.TP_PW_COMPLEXITY[$data['complexity']][1].'</b></div>',
1177 1177
                 ),
1178 1178
                 'encode'
1179 1179
             );
@@ -1277,14 +1277,14 @@  discard block
 block discarded – undo
1277 1277
         // Get data about user
1278 1278
         $dataUser = DB::queryFirstRow(
1279 1279
             'SELECT id, email, pw
1280
-            FROM ' . prefixTable('users') . '
1280
+            FROM ' . prefixTable('users').'
1281 1281
             WHERE login = %s',
1282 1282
             $post_login
1283 1283
         );
1284 1284
     } else {
1285 1285
         $dataUser = DB::queryFirstRow(
1286 1286
             'SELECT id, login, email, pw
1287
-            FROM ' . prefixTable('users') . '
1287
+            FROM ' . prefixTable('users').'
1288 1288
             WHERE id = %i',
1289 1289
             $post_id
1290 1290
         );
@@ -1338,7 +1338,7 @@  discard block
 block discarded – undo
1338 1338
     // Check if token already used
1339 1339
     $dataToken = DB::queryFirstRow(
1340 1340
         'SELECT end_timestamp, reason
1341
-        FROM ' . prefixTable('tokens') . '
1341
+        FROM ' . prefixTable('tokens').'
1342 1342
         WHERE token = %s AND user_id = %i',
1343 1343
         $post_token,
1344 1344
         $dataUser['id']
@@ -1349,11 +1349,11 @@  discard block
 block discarded – undo
1349 1349
         return prepareExchangedData(
1350 1350
             array(
1351 1351
                 'error' => true,
1352
-                'message' => 'TOKEN already used',//$lang->get('no_email_set'),
1352
+                'message' => 'TOKEN already used', //$lang->get('no_email_set'),
1353 1353
             ),
1354 1354
             'encode'
1355 1355
         );
1356
-    } elseif(DB::count() === 0) {
1356
+    } elseif (DB::count() === 0) {
1357 1357
         // Store token for this action
1358 1358
         DB::insert(
1359 1359
             prefixTable('tokens'),
@@ -1415,7 +1415,7 @@  discard block
 block discarded – undo
1415 1415
                 'email' => $dataUser['email'],
1416 1416
                 'email_result' => str_replace(
1417 1417
                     '#email#',
1418
-                    '<b>' . obfuscateEmail($dataUser['email']) . '</b>',
1418
+                    '<b>'.obfuscateEmail($dataUser['email']).'</b>',
1419 1419
                     addslashes($lang->get('admin_email_result_ok'))
1420 1420
                 ),
1421 1421
             ),
@@ -1431,7 +1431,7 @@  discard block
 block discarded – undo
1431 1431
             'email' => $dataUser['email'],
1432 1432
             'email_result' => str_replace(
1433 1433
                 '#email#',
1434
-                '<b>' . obfuscateEmail($dataUser['email']) . '</b>',
1434
+                '<b>'.obfuscateEmail($dataUser['email']).'</b>',
1435 1435
                 addslashes($lang->get('admin_email_result_ok'))
1436 1436
             ),
1437 1437
         ),
@@ -1448,7 +1448,7 @@  discard block
 block discarded – undo
1448 1448
 
1449 1449
     if (isKeyExistingAndEqual('enable_send_email_on_user_login', 1, $SETTINGS) === true) {
1450 1450
         $row = DB::queryFirstRow(
1451
-            'SELECT valeur FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s',
1451
+            'SELECT valeur FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s',
1452 1452
             'cron',
1453 1453
             'sending_emails'
1454 1454
         );
@@ -1456,7 +1456,7 @@  discard block
 block discarded – undo
1456 1456
         if ((int) (time() - $row['valeur']) >= 300 || (int) $row['valeur'] === 0) {
1457 1457
             $rows = DB::query(
1458 1458
                 'SELECT *
1459
-                FROM ' . prefixTable('emails') .
1459
+                FROM ' . prefixTable('emails').
1460 1460
                 ' WHERE status != %s',
1461 1461
                 'sent'
1462 1462
             );
@@ -1508,8 +1508,8 @@  discard block
 block discarded – undo
1508 1508
     $arr_html = array();
1509 1509
     $rows = DB::query(
1510 1510
         'SELECT i.id AS id, i.label AS label, i.id_tree AS id_tree, l.date, i.perso AS perso, i.restricted_to AS restricted
1511
-        FROM ' . prefixTable('log_items') . ' AS l
1512
-        RIGHT JOIN ' . prefixTable('items') . ' AS i ON (l.id_item = i.id)
1511
+        FROM ' . prefixTable('log_items').' AS l
1512
+        RIGHT JOIN ' . prefixTable('items').' AS i ON (l.id_item = i.id)
1513 1513
         WHERE l.action = %s AND l.id_user = %i
1514 1514
         ORDER BY l.date DESC
1515 1515
         LIMIT 0, 100',
@@ -1541,7 +1541,7 @@  discard block
 block discarded – undo
1541 1541
     if (isKeyExistingAndEqual('enable_suggestion', 1, $SETTINGS) === true
1542 1542
         && ((int) $session->get('user-admin') === 1 || (int) $session->get('user-manager') === 1)
1543 1543
     ) {
1544
-        DB::query('SELECT * FROM ' . prefixTable('suggestion'));
1544
+        DB::query('SELECT * FROM '.prefixTable('suggestion'));
1545 1545
         $nb_suggestions_waiting = DB::count();
1546 1546
     }
1547 1547
 
@@ -1576,13 +1576,13 @@  discard block
 block discarded – undo
1576 1576
             if ($data === 'stat_languages') {
1577 1577
                 $tmp = '';
1578 1578
                 foreach ($stats_data[$data] as $key => $value) {
1579
-                    $tmp .= $tmp === '' ? $key . '-' . $value : ',' . $key . '-' . $value;
1579
+                    $tmp .= $tmp === '' ? $key.'-'.$value : ','.$key.'-'.$value;
1580 1580
                 }
1581 1581
                 $statsToSend[$data] = $tmp;
1582 1582
             } elseif ($data === 'stat_country') {
1583 1583
                 $tmp = '';
1584 1584
                 foreach ($stats_data[$data] as $key => $value) {
1585
-                    $tmp .= $tmp === '' ? $key . '-' . $value : ',' . $key . '-' . $value;
1585
+                    $tmp .= $tmp === '' ? $key.'-'.$value : ','.$key.'-'.$value;
1586 1586
                 }
1587 1587
                 $statsToSend[$data] = $tmp;
1588 1588
             } else {
@@ -1669,7 +1669,7 @@  discard block
 block discarded – undo
1669 1669
             $url_found = $value;
1670 1670
             if (empty($url_found) === false) {
1671 1671
                 $tmp = parse_url($url_found);
1672
-                $anonym_url = $tmp['scheme'] . '://<anonym_url>' . (isset($tmp['path']) === true ? $tmp['path'] : '');
1672
+                $anonym_url = $tmp['scheme'].'://<anonym_url>'.(isset($tmp['path']) === true ? $tmp['path'] : '');
1673 1673
                 $value = $anonym_url;
1674 1674
             } else {
1675 1675
                 $value = '';
@@ -1699,7 +1699,7 @@  discard block
 block discarded – undo
1699 1699
     $teampass_errors = '';
1700 1700
     $rows = DB::query(
1701 1701
         'SELECT label, date AS error_date
1702
-        FROM ' . prefixTable('log_system') . "
1702
+        FROM ' . prefixTable('log_system')."
1703 1703
         WHERE `type` LIKE 'error'
1704 1704
         ORDER BY `date` DESC
1705 1705
         LIMIT 0, 10"
@@ -1707,9 +1707,9 @@  discard block
 block discarded – undo
1707 1707
     if (DB::count() > 0) {
1708 1708
         foreach ($rows as $record) {
1709 1709
             if (empty($teampass_errors) === true) {
1710
-                $teampass_errors = ' * ' . date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['error_date']) . ' - ' . $record['label'];
1710
+                $teampass_errors = ' * '.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['error_date']).' - '.$record['label'];
1711 1711
             } else {
1712
-                $teampass_errors .= ' * ' . date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['error_date']) . ' - ' . $record['label'];
1712
+                $teampass_errors .= ' * '.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['error_date']).' - '.$record['label'];
1713 1713
             }
1714 1714
         }
1715 1715
     }
@@ -1721,7 +1721,7 @@  discard block
 block discarded – undo
1721 1721
 
1722 1722
     // Now prepare text
1723 1723
     $txt = '### Page on which it happened
1724
-' . $data['current_page'] . '
1724
+' . $data['current_page'].'
1725 1725
 
1726 1726
 ### Steps to reproduce
1727 1727
 1.
@@ -1736,39 +1736,39 @@  discard block
 block discarded – undo
1736 1736
 Tell us what happens instead
1737 1737
 
1738 1738
 ### Server configuration
1739
-**Operating system**: ' . php_uname() . '
1739
+**Operating system**: ' . php_uname().'
1740 1740
 
1741
-**Web server:** ' . $_SERVER['SERVER_SOFTWARE'] . '
1741
+**Web server:** ' . $_SERVER['SERVER_SOFTWARE'].'
1742 1742
 
1743
-**Database:** ' . ($link === false ? $lang->get('undefined') : mysqli_get_server_info($link)) . '
1743
+**Database:** ' . ($link === false ? $lang->get('undefined') : mysqli_get_server_info($link)).'
1744 1744
 
1745
-**PHP version:** ' . PHP_VERSION . '
1745
+**PHP version:** ' . PHP_VERSION.'
1746 1746
 
1747
-**Teampass version:** ' . TP_VERSION . '.' . TP_VERSION_MINOR . '
1747
+**Teampass version:** ' . TP_VERSION.'.'.TP_VERSION_MINOR.'
1748 1748
 
1749 1749
 **Teampass configuration variables:**
1750 1750
 ```
1751
-' . $list_of_options . '
1751
+' . $list_of_options.'
1752 1752
 ```
1753 1753
 
1754 1754
 **Updated from an older Teampass or fresh install:**
1755 1755
 
1756 1756
 ### Client configuration
1757 1757
 
1758
-**Browser:** ' . $data['browser_name'] . ' - ' . $data['browser_version'] . '
1758
+**Browser:** ' . $data['browser_name'].' - '.$data['browser_version'].'
1759 1759
 
1760
-**Operating system:** ' . $data['os'] . ' - ' . $data['os_archi'] . 'bits
1760
+**Operating system:** ' . $data['os'].' - '.$data['os_archi'].'bits
1761 1761
 
1762 1762
 ### Logs
1763 1763
 
1764 1764
 #### Web server error log
1765 1765
 ```
1766
-' . $err['message'] . ' - ' . $err['file'] . ' (' . $err['line'] . ')
1766
+' . $err['message'].' - '.$err['file'].' ('.$err['line'].')
1767 1767
 ```
1768 1768
 
1769 1769
 #### Teampass 10 last system errors
1770 1770
 ```
1771
-' . $teampass_errors . '
1771
+' . $teampass_errors.'
1772 1772
 ```
1773 1773
 
1774 1774
 #### Log from the web-browser developer console (CTRL + SHIFT + i)
@@ -1810,7 +1810,7 @@  discard block
 block discarded – undo
1810 1810
         // Check if user exists
1811 1811
         $userInfo = DB::queryFirstRow(
1812 1812
             'SELECT public_key, private_key, pw, auth_type
1813
-            FROM ' . prefixTable('users') . '
1813
+            FROM ' . prefixTable('users').'
1814 1814
             WHERE id = %i',
1815 1815
             $post_user_id
1816 1816
         );
@@ -1819,9 +1819,9 @@  discard block
 block discarded – undo
1819 1819
             // Get one item
1820 1820
             $currentUserKey = DB::queryFirstRow(
1821 1821
                 'SELECT object_id, share_key, increment_id
1822
-                FROM ' . prefixTable('sharekeys_items') . ' AS si
1823
-                INNER JOIN ' . prefixTable('items') . ' AS i ON  (i.id = si.object_id)
1824
-                INNER JOIN ' . prefixTable('nested_tree') . ' AS nt ON  (i.id_tree = nt.id)
1822
+                FROM ' . prefixTable('sharekeys_items').' AS si
1823
+                INNER JOIN ' . prefixTable('items').' AS i ON  (i.id = si.object_id)
1824
+                INNER JOIN ' . prefixTable('nested_tree').' AS nt ON  (i.id_tree = nt.id)
1825 1825
                 WHERE user_id = %i AND nt.personal_folder = %i',
1826 1826
                 $post_user_id,
1827 1827
                 0
@@ -1940,7 +1940,7 @@  discard block
 block discarded – undo
1940 1940
         // Get user info
1941 1941
         $userData = DB::queryFirstRow(
1942 1942
             'SELECT private_key
1943
-            FROM ' . prefixTable('users') . '
1943
+            FROM ' . prefixTable('users').'
1944 1944
             WHERE id = %i',
1945 1945
             $post_user_id
1946 1946
         );
@@ -2021,7 +2021,7 @@  discard block
 block discarded – undo
2021 2021
         // Get user info
2022 2022
         $userData = DB::queryFirstRow(
2023 2023
             'SELECT email, auth_type, login
2024
-            FROM ' . prefixTable('users') . '
2024
+            FROM ' . prefixTable('users').'
2025 2025
             WHERE id = %i',
2026 2026
             $post_user_id
2027 2027
         );
@@ -2119,7 +2119,7 @@  discard block
 block discarded – undo
2119 2119
         // Get user info
2120 2120
         $userData = DB::queryFirstRow(
2121 2121
             'SELECT email, auth_type, login
2122
-            FROM ' . prefixTable('users') . '
2122
+            FROM ' . prefixTable('users').'
2123 2123
             WHERE id = %i',
2124 2124
             $userId
2125 2125
         );
@@ -2185,7 +2185,7 @@  discard block
 block discarded – undo
2185 2185
         // Check if user exists
2186 2186
         DB::queryFirstRow(
2187 2187
             'SELECT *
2188
-            FROM ' . prefixTable('users') . '
2188
+            FROM ' . prefixTable('users').'
2189 2189
             WHERE id = %i',
2190 2190
             $post_user_id
2191 2191
         );
@@ -2255,7 +2255,7 @@  discard block
 block discarded – undo
2255 2255
         // Check if user exists
2256 2256
         $userInfo = DB::queryFirstRow(
2257 2257
             'SELECT public_key
2258
-            FROM ' . prefixTable('users') . '
2258
+            FROM ' . prefixTable('users').'
2259 2259
             WHERE id = %i',
2260 2260
             $post_user_id
2261 2261
         );
@@ -2403,15 +2403,15 @@  discard block
 block discarded – undo
2403 2403
     // Loop on items
2404 2404
     $rows = DB::query(
2405 2405
         'SELECT id, pw
2406
-        FROM ' . prefixTable('items') . '
2406
+        FROM ' . prefixTable('items').'
2407 2407
         WHERE perso = 0
2408
-        LIMIT ' . $post_start . ', ' . $post_length
2408
+        LIMIT ' . $post_start.', '.$post_length
2409 2409
     );
2410 2410
     foreach ($rows as $record) {
2411 2411
         // Get itemKey from current user
2412 2412
         $currentUserKey = DB::queryFirstRow(
2413 2413
             'SELECT share_key, increment_id
2414
-            FROM ' . prefixTable('sharekeys_items') . '
2414
+            FROM ' . prefixTable('sharekeys_items').'
2415 2415
             WHERE object_id = %i AND user_id = %i',
2416 2416
             $record['id'],
2417 2417
             $session->get('user-id')
@@ -2443,7 +2443,7 @@  discard block
 block discarded – undo
2443 2443
             if ((int) $post_user_id !== (int) $session->get('user-id')) {
2444 2444
                 $currentUserKey = DB::queryFirstRow(
2445 2445
                     'SELECT increment_id
2446
-                    FROM ' . prefixTable('sharekeys_items') . '
2446
+                    FROM ' . prefixTable('sharekeys_items').'
2447 2447
                     WHERE object_id = %i AND user_id = %i',
2448 2448
                     $record['id'],
2449 2449
                     $post_user_id
@@ -2476,7 +2476,7 @@  discard block
 block discarded – undo
2476 2476
     // SHould we change step?
2477 2477
     DB::query(
2478 2478
         'SELECT *
2479
-        FROM ' . prefixTable('items') . '
2479
+        FROM ' . prefixTable('items').'
2480 2480
         WHERE perso = 0'
2481 2481
     );
2482 2482
 
@@ -2501,15 +2501,15 @@  discard block
 block discarded – undo
2501 2501
     // Loop on logs
2502 2502
     $rows = DB::query(
2503 2503
         'SELECT increment_id
2504
-        FROM ' . prefixTable('log_items') . '
2504
+        FROM ' . prefixTable('log_items').'
2505 2505
         WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"
2506
-        LIMIT ' . $post_start . ', ' . $post_length
2506
+        LIMIT ' . $post_start.', '.$post_length
2507 2507
     );
2508 2508
     foreach ($rows as $record) {
2509 2509
         // Get itemKey from current user
2510 2510
         $currentUserKey = DB::queryFirstRow(
2511 2511
             'SELECT share_key
2512
-            FROM ' . prefixTable('sharekeys_logs') . '
2512
+            FROM ' . prefixTable('sharekeys_logs').'
2513 2513
             WHERE object_id = %i AND user_id = %i',
2514 2514
             $record['increment_id'],
2515 2515
             $session->get('user-id')
@@ -2541,7 +2541,7 @@  discard block
 block discarded – undo
2541 2541
             if ((int) $post_user_id !== (int) $session->get('user-id')) {
2542 2542
                 $currentUserKey = DB::queryFirstRow(
2543 2543
                     'SELECT increment_id
2544
-                    FROM ' . prefixTable('sharekeys_items') . '
2544
+                    FROM ' . prefixTable('sharekeys_items').'
2545 2545
                     WHERE object_id = %i AND user_id = %i',
2546 2546
                     $record['id'],
2547 2547
                     $post_user_id
@@ -2563,7 +2563,7 @@  discard block
 block discarded – undo
2563 2563
     // SHould we change step?
2564 2564
     DB::query(
2565 2565
         'SELECT increment_id
2566
-        FROM ' . prefixTable('log_items') . '
2566
+        FROM ' . prefixTable('log_items').'
2567 2567
         WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"'
2568 2568
     );
2569 2569
 
@@ -2588,15 +2588,15 @@  discard block
 block discarded – undo
2588 2588
     // Loop on fields
2589 2589
     $rows = DB::query(
2590 2590
         'SELECT id
2591
-        FROM ' . prefixTable('categories_items') . '
2591
+        FROM ' . prefixTable('categories_items').'
2592 2592
         WHERE encryption_type = "teampass_aes"
2593
-        LIMIT ' . $post_start . ', ' . $post_length
2593
+        LIMIT ' . $post_start.', '.$post_length
2594 2594
     );
2595 2595
     foreach ($rows as $record) {
2596 2596
         // Get itemKey from current user
2597 2597
         $currentUserKey = DB::queryFirstRow(
2598 2598
             'SELECT share_key
2599
-            FROM ' . prefixTable('sharekeys_fields') . '
2599
+            FROM ' . prefixTable('sharekeys_fields').'
2600 2600
             WHERE object_id = %i AND user_id = %i',
2601 2601
             $record['id'],
2602 2602
             $session->get('user-id')
@@ -2628,7 +2628,7 @@  discard block
 block discarded – undo
2628 2628
             if ((int) $post_user_id !== (int) $session->get('user-id')) {
2629 2629
                 $currentUserKey = DB::queryFirstRow(
2630 2630
                     'SELECT increment_id
2631
-                    FROM ' . prefixTable('sharekeys_items') . '
2631
+                    FROM ' . prefixTable('sharekeys_items').'
2632 2632
                     WHERE object_id = %i AND user_id = %i',
2633 2633
                     $record['id'],
2634 2634
                     $post_user_id
@@ -2650,7 +2650,7 @@  discard block
 block discarded – undo
2650 2650
     // SHould we change step?
2651 2651
     DB::query(
2652 2652
         'SELECT *
2653
-        FROM ' . prefixTable('categories_items') . '
2653
+        FROM ' . prefixTable('categories_items').'
2654 2654
         WHERE encryption_type = "teampass_aes"'
2655 2655
     );
2656 2656
 
@@ -2675,14 +2675,14 @@  discard block
 block discarded – undo
2675 2675
     // Loop on suggestions
2676 2676
     $rows = DB::query(
2677 2677
         'SELECT id
2678
-        FROM ' . prefixTable('suggestion') . '
2679
-        LIMIT ' . $post_start . ', ' . $post_length
2678
+        FROM ' . prefixTable('suggestion').'
2679
+        LIMIT ' . $post_start.', '.$post_length
2680 2680
     );
2681 2681
     foreach ($rows as $record) {
2682 2682
         // Get itemKey from current user
2683 2683
         $currentUserKey = DB::queryFirstRow(
2684 2684
             'SELECT share_key
2685
-            FROM ' . prefixTable('sharekeys_suggestions') . '
2685
+            FROM ' . prefixTable('sharekeys_suggestions').'
2686 2686
             WHERE object_id = %i AND user_id = %i',
2687 2687
             $record['id'],
2688 2688
             $session->get('user-id')
@@ -2714,7 +2714,7 @@  discard block
 block discarded – undo
2714 2714
             if ((int) $post_user_id !== (int) $session->get('user-id')) {
2715 2715
                 $currentUserKey = DB::queryFirstRow(
2716 2716
                     'SELECT increment_id
2717
-                    FROM ' . prefixTable('sharekeys_items') . '
2717
+                    FROM ' . prefixTable('sharekeys_items').'
2718 2718
                     WHERE object_id = %i AND user_id = %i',
2719 2719
                     $record['id'],
2720 2720
                     $post_user_id
@@ -2760,15 +2760,15 @@  discard block
 block discarded – undo
2760 2760
     // Loop on files
2761 2761
     $rows = DB::query(
2762 2762
         'SELECT id
2763
-        FROM ' . prefixTable('files') . '
2764
-        WHERE status = "' . TP_ENCRYPTION_NAME . '"
2765
-        LIMIT ' . $post_start . ', ' . $post_length
2763
+        FROM ' . prefixTable('files').'
2764
+        WHERE status = "' . TP_ENCRYPTION_NAME.'"
2765
+        LIMIT ' . $post_start.', '.$post_length
2766 2766
     ); //aes_encryption
2767 2767
     foreach ($rows as $record) {
2768 2768
         // Get itemKey from current user
2769 2769
         $currentUserKey = DB::queryFirstRow(
2770 2770
             'SELECT share_key
2771
-            FROM ' . prefixTable('sharekeys_files') . '
2771
+            FROM ' . prefixTable('sharekeys_files').'
2772 2772
             WHERE object_id = %i AND user_id = %i',
2773 2773
             $record['id'],
2774 2774
             $session->get('user-id')
@@ -2800,7 +2800,7 @@  discard block
 block discarded – undo
2800 2800
             if ((int) $post_user_id !== (int) $session->get('user-id')) {
2801 2801
                 $currentUserKey = DB::queryFirstRow(
2802 2802
                     'SELECT increment_id
2803
-                    FROM ' . prefixTable('sharekeys_items') . '
2803
+                    FROM ' . prefixTable('sharekeys_items').'
2804 2804
                     WHERE object_id = %i AND user_id = %i',
2805 2805
                     $record['id'],
2806 2806
                     $post_user_id
@@ -2822,8 +2822,8 @@  discard block
 block discarded – undo
2822 2822
     // SHould we change step?
2823 2823
     DB::query(
2824 2824
         'SELECT *
2825
-        FROM ' . prefixTable('files') . '
2826
-        WHERE status = "' . TP_ENCRYPTION_NAME . '"'
2825
+        FROM ' . prefixTable('files').'
2826
+        WHERE status = "' . TP_ENCRYPTION_NAME.'"'
2827 2827
     );
2828 2828
 
2829 2829
     $next_start = (int) $post_start + (int) $post_length;
@@ -2856,9 +2856,9 @@  discard block
 block discarded – undo
2856 2856
     if (count($session->get('user-personal_folders')) > 0) {
2857 2857
         $rows = DB::query(
2858 2858
             'SELECT id, pw
2859
-            FROM ' . prefixTable('items') . '
2859
+            FROM ' . prefixTable('items').'
2860 2860
             WHERE perso = 1 AND id_tree IN %ls AND encryption_type = %s
2861
-            LIMIT ' . $post_start . ', ' . $post_length,
2861
+            LIMIT ' . $post_start.', '.$post_length,
2862 2862
             $session->get('user-personal_folders'),
2863 2863
             "defuse"
2864 2864
         );
@@ -2866,7 +2866,7 @@  discard block
 block discarded – undo
2866 2866
             // Get itemKey from current user
2867 2867
             $currentUserKey = DB::queryFirstRow(
2868 2868
                 'SELECT share_key, increment_id
2869
-                FROM ' . prefixTable('sharekeys_items') . '
2869
+                FROM ' . prefixTable('sharekeys_items').'
2870 2870
                 WHERE object_id = %i AND user_id = %i',
2871 2871
                 $record['id'],
2872 2872
                 $session->get('user-id')
@@ -2893,7 +2893,7 @@  discard block
 block discarded – undo
2893 2893
                 if ((int) $post_user_id !== (int) $session->get('user-id')) {
2894 2894
                     $currentUserKey = DB::queryFirstRow(
2895 2895
                         'SELECT increment_id
2896
-                        FROM ' . prefixTable('sharekeys_items') . '
2896
+                        FROM ' . prefixTable('sharekeys_items').'
2897 2897
                         WHERE object_id = %i AND user_id = %i',
2898 2898
                         $record['id'],
2899 2899
                         $post_user_id
@@ -2916,7 +2916,7 @@  discard block
 block discarded – undo
2916 2916
     // SHould we change step?
2917 2917
     DB::query(
2918 2918
         'SELECT *
2919
-        FROM ' . prefixTable('items') . '
2919
+        FROM ' . prefixTable('items').'
2920 2920
         WHERE perso = 0'
2921 2921
     );
2922 2922
 
@@ -2944,7 +2944,7 @@  discard block
 block discarded – undo
2944 2944
         // Check if user exists
2945 2945
         $userInfo = DB::queryFirstRow(
2946 2946
             'SELECT public_key, encrypted_psk
2947
-            FROM ' . prefixTable('users') . '
2947
+            FROM ' . prefixTable('users').'
2948 2948
             WHERE id = %i',
2949 2949
             $post_user_id
2950 2950
         );
@@ -2970,7 +2970,7 @@  discard block
 block discarded – undo
2970 2970
                 if ($post_counterItemsToTreat === -1) {
2971 2971
                     DB::query(
2972 2972
                         'SELECT id
2973
-                        FROM ' . prefixTable('items') . '
2973
+                        FROM ' . prefixTable('items').'
2974 2974
                         WHERE perso = 1 AND id_tree IN %ls AND encryption_type != %s',
2975 2975
                         $session->get('user-personal_folders'),
2976 2976
                         'teampass_aes'
@@ -2983,7 +2983,7 @@  discard block
 block discarded – undo
2983 2983
                 // Loop on persoanl items
2984 2984
                 $rows = DB::query(
2985 2985
                     'SELECT id, pw
2986
-                    FROM ' . prefixTable('items') . '
2986
+                    FROM ' . prefixTable('items').'
2987 2987
                     WHERE perso = 1 AND id_tree IN %ls AND encryption_type != %s
2988 2988
                     LIMIT ' . $post_length,
2989 2989
                     $session->get('user-personal_folders'),
@@ -3027,7 +3027,7 @@  discard block
 block discarded – undo
3027 3027
                     // Loop on files
3028 3028
                     $rows = DB::query(
3029 3029
                         'SELECT id, file
3030
-                        FROM ' . prefixTable('files') . '
3030
+                        FROM ' . prefixTable('files').'
3031 3031
                         WHERE status != %s
3032 3032
                         AND id_item = %i',
3033 3033
                         TP_ENCRYPTION_NAME,
@@ -3038,13 +3038,13 @@  discard block
 block discarded – undo
3038 3038
                         // Now decrypt the file
3039 3039
                         prepareFileWithDefuse(
3040 3040
                             'decrypt',
3041
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record2['file'],
3042
-                            $SETTINGS['path_to_upload_folder'] . '/' . $record2['file'] . '.delete',
3041
+                            $SETTINGS['path_to_upload_folder'].'/'.$record2['file'],
3042
+                            $SETTINGS['path_to_upload_folder'].'/'.$record2['file'].'.delete',
3043 3043
                             $post_user_psk
3044 3044
                         );
3045 3045
 
3046 3046
                         // Encrypt the file
3047
-                        $encryptedFile = encryptFile($record2['file'] . '.delete', $SETTINGS['path_to_upload_folder']);
3047
+                        $encryptedFile = encryptFile($record2['file'].'.delete', $SETTINGS['path_to_upload_folder']);
3048 3048
 
3049 3049
                         DB::update(
3050 3050
                             prefixTable('files'),
@@ -3067,7 +3067,7 @@  discard block
 block discarded – undo
3067 3067
                         );
3068 3068
 
3069 3069
                         // Unlink original file
3070
-                        unlink($SETTINGS['path_to_upload_folder'] . '/' . $record2['file']);
3070
+                        unlink($SETTINGS['path_to_upload_folder'].'/'.$record2['file']);
3071 3071
                     }
3072 3072
                 }
3073 3073
 
@@ -3075,7 +3075,7 @@  discard block
 block discarded – undo
3075 3075
                 $next_start = (int) $post_start + (int) $post_length;
3076 3076
                 DB::query(
3077 3077
                     'SELECT id
3078
-                    FROM ' . prefixTable('items') . '
3078
+                    FROM ' . prefixTable('items').'
3079 3079
                     WHERE perso = 1 AND id_tree IN %ls AND encryption_type != %s',
3080 3080
                     $session->get('user-personal_folders'),
3081 3081
                     'teampass_aes'
@@ -3145,7 +3145,7 @@  discard block
 block discarded – undo
3145 3145
         // Get user info
3146 3146
         $userData = DB::queryFirstRow(
3147 3147
             'SELECT special, auth_type, is_ready_for_usage, ongoing_process_id, otp_provided, keys_recovery_time
3148
-            FROM ' . prefixTable('users') . '
3148
+            FROM ' . prefixTable('users').'
3149 3149
             WHERE id = %i',
3150 3150
             $post_user_id
3151 3151
         );
@@ -3192,7 +3192,7 @@  discard block
 block discarded – undo
3192 3192
         // Get user info
3193 3193
         $userData = DB::queryFirstRow(
3194 3194
             'SELECT auth_type, login, private_key
3195
-            FROM ' . prefixTable('users') . '
3195
+            FROM ' . prefixTable('users').'
3196 3196
             WHERE id = %i',
3197 3197
             $post_user_id
3198 3198
         );
@@ -3242,7 +3242,7 @@  discard block
 block discarded – undo
3242 3242
                 return prepareExchangedData(
3243 3243
                     array(
3244 3244
                         'error' => false,
3245
-                        'message' => $lang->get('done'),'',
3245
+                        'message' => $lang->get('done'), '',
3246 3246
                     ),
3247 3247
                     'encode'
3248 3248
                 );
@@ -3291,7 +3291,7 @@  discard block
 block discarded – undo
3291 3291
         // Get user info
3292 3292
         $userData = DB::queryFirstRow(
3293 3293
             'SELECT u.auth_type, u.login, u.private_key, u.special
3294
-            FROM ' . prefixTable('users') . ' AS u
3294
+            FROM ' . prefixTable('users').' AS u
3295 3295
             WHERE u.id = %i',
3296 3296
             $post_user_id
3297 3297
         );
@@ -3327,7 +3327,7 @@  discard block
 block discarded – undo
3327 3327
                     return prepareExchangedData(
3328 3328
                         array(
3329 3329
                             'error' => false,
3330
-                            'message' => $lang->get('done'),'',
3330
+                            'message' => $lang->get('done'), '',
3331 3331
                         ),
3332 3332
                         'encode'
3333 3333
                     );
@@ -3349,8 +3349,8 @@  discard block
 block discarded – undo
3349 3349
                 // Get one itemKey from current user
3350 3350
                 $currentUserKey = DB::queryFirstRow(
3351 3351
                     'SELECT ski.share_key, ski.increment_id, l.id_user
3352
-                    FROM ' . prefixTable('sharekeys_items') . ' AS ski
3353
-                    INNER JOIN ' . prefixTable('log_items') . ' AS l ON ski.object_id = l.id_item
3352
+                    FROM ' . prefixTable('sharekeys_items').' AS ski
3353
+                    INNER JOIN ' . prefixTable('log_items').' AS l ON ski.object_id = l.id_item
3354 3354
                     WHERE ski.user_id = %i
3355 3355
                     ORDER BY RAND()
3356 3356
                     LIMIT 1',
@@ -3418,8 +3418,8 @@  discard block
 block discarded – undo
3418 3418
                             'process_type' => 'create_user_keys',
3419 3419
                             'arguments' => json_encode([
3420 3420
                                 'new_user_id' => (int) $post_user_id,
3421
-                                'new_user_pwd' => cryption($post_previous_pwd, '','encrypt')['string'],
3422
-                                'new_user_private_key' => cryption($validPreviousKey['private_key'], '','encrypt')['string'],
3421
+                                'new_user_pwd' => cryption($post_previous_pwd, '', 'encrypt')['string'],
3422
+                                'new_user_private_key' => cryption($validPreviousKey['private_key'], '', 'encrypt')['string'],
3423 3423
                                 'send_email' => 0,
3424 3424
                                 'otp_provided_new_value' => 0,
3425 3425
                                 'user_self_change' => 1,
@@ -3489,7 +3489,7 @@  discard block
 block discarded – undo
3489 3489
             id,
3490 3490
             private_key,
3491 3491
             created_at
3492
-        FROM " . prefixTable('user_private_keys') . "
3492
+        FROM " . prefixTable('user_private_keys')."
3493 3493
         WHERE user_id = %i
3494 3494
         ORDER BY created_at DESC, id DESC",
3495 3495
         $userId
@@ -3511,9 +3511,9 @@  discard block
 block discarded – undo
3511 3511
             // Select one personal item share_key to test decryption
3512 3512
             $currentUserItemKey = DB::queryFirstRow(
3513 3513
                 'SELECT si.share_key, si.increment_id, l.id_user, i.perso
3514
-                FROM ' . prefixTable('sharekeys_items') . ' AS si
3515
-                INNER JOIN ' . prefixTable('log_items') . ' AS l ON si.object_id = l.id_item
3516
-                INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = l.id_item
3514
+                FROM ' . prefixTable('sharekeys_items').' AS si
3515
+                INNER JOIN ' . prefixTable('log_items').' AS l ON si.object_id = l.id_item
3516
+                INNER JOIN ' . prefixTable('items').' AS i ON i.id = l.id_item
3517 3517
                 WHERE si.user_id = %i AND i.perso = 1 AND si.share_key != ""
3518 3518
                 ORDER BY RAND()
3519 3519
                 LIMIT 1',
@@ -3564,7 +3564,7 @@  discard block
 block discarded – undo
3564 3564
             $session->get('user-id')
3565 3565
         );
3566 3566
         // Return data
3567
-        return '[{"new_value":"' . $session->get('user-session_duration') . '"}]';
3567
+        return '[{"new_value":"'.$session->get('user-session_duration').'"}]';
3568 3568
     }
3569 3569
     
3570 3570
     return '[{"new_value":"expired"}]';
@@ -3602,8 +3602,8 @@  discard block
 block discarded – undo
3602 3602
 {
3603 3603
     $personalItems = DB::query(
3604 3604
         'SELECT i.id, i.pw, s.share_key, s.increment_id
3605
-        FROM ' . prefixTable('items') . ' i
3606
-        INNER JOIN ' . prefixTable('sharekeys_items') . ' s ON i.id = s.object_id
3605
+        FROM ' . prefixTable('items').' i
3606
+        INNER JOIN ' . prefixTable('sharekeys_items').' s ON i.id = s.object_id
3607 3607
         WHERE i.perso = %i
3608 3608
         AND s.user_id = %i',
3609 3609
         1,
Please login to merge, or discard this patch.
sources/admin.queries.php 1 patch
Spacing   +141 added lines, -141 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
 
@@ -1620,7 +1620,7 @@  discard block
 block discarded – undo
1620 1620
             $post_id = filter_var($dataReceived['id'], FILTER_SANITIZE_NUMBER_INT);
1621 1621
 
1622 1622
             DB::query(
1623
-                'DELETE FROM ' . prefixTable('api') . ' WHERE increment_id = %i',
1623
+                'DELETE FROM '.prefixTable('api').' WHERE increment_id = %i',
1624 1624
                 $post_id
1625 1625
             );
1626 1626
         }
@@ -1715,7 +1715,7 @@  discard block
 block discarded – undo
1715 1715
             // Delete existing key
1716 1716
         } elseif (null !== $post_action && $post_action === 'delete') {
1717 1717
             $post_id = filter_var($dataReceived['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
1718
-            DB::query('DELETE FROM ' . prefixTable('api') . ' WHERE increment_id=%i', $post_id);
1718
+            DB::query('DELETE FROM '.prefixTable('api').' WHERE increment_id=%i', $post_id);
1719 1719
         }
1720 1720
 
1721 1721
         echo prepareExchangedData(
@@ -1730,7 +1730,7 @@  discard block
 block discarded – undo
1730 1730
 
1731 1731
     case 'save_api_status':
1732 1732
         // Do query
1733
-        DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'api');
1733
+        DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'api');
1734 1734
         $counter = DB::count();
1735 1735
         if ($counter === 0) {
1736 1736
             DB::insert(
@@ -1759,7 +1759,7 @@  discard block
 block discarded – undo
1759 1759
 
1760 1760
     case 'run_duo_config_check':
1761 1761
         //Libraries call
1762
-        require_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
1762
+        require_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
1763 1763
         // Check KEY
1764 1764
         if ($post_key !== $session->get('key')) {
1765 1765
             echo prepareExchangedData(
@@ -1865,7 +1865,7 @@  discard block
 block discarded – undo
1865 1865
         } else {
1866 1866
             $tmp = 1;
1867 1867
         }
1868
-        DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'google_authentication');
1868
+        DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'google_authentication');
1869 1869
         $counter = DB::count();
1870 1870
         if ($counter === 0) {
1871 1871
             DB::insert(
@@ -1893,7 +1893,7 @@  discard block
 block discarded – undo
1893 1893
 
1894 1894
         // ga_website_name
1895 1895
         if (is_null($dataReceived['ga_website_name']) === false) {
1896
-            DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'ga_website_name');
1896
+            DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'ga_website_name');
1897 1897
             $counter = DB::count();
1898 1898
             if ($counter === 0) {
1899 1899
                 DB::insert(
@@ -1923,7 +1923,7 @@  discard block
 block discarded – undo
1923 1923
         }
1924 1924
 
1925 1925
         // send data
1926
-        echo '[{"result" : "' . addslashes($lang['done']) . '" , "error" : ""}]';
1926
+        echo '[{"result" : "'.addslashes($lang['done']).'" , "error" : ""}]';
1927 1927
         break;
1928 1928
 
1929 1929
     case 'save_agses_options':
@@ -1946,7 +1946,7 @@  discard block
 block discarded – undo
1946 1946
 
1947 1947
         // agses_hosted_url
1948 1948
         if (!is_null($dataReceived['agses_hosted_url'])) {
1949
-            DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'agses_hosted_url');
1949
+            DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'agses_hosted_url');
1950 1950
             $counter = DB::count();
1951 1951
             if ($counter === 0) {
1952 1952
                 DB::insert(
@@ -1977,7 +1977,7 @@  discard block
 block discarded – undo
1977 1977
 
1978 1978
         // agses_hosted_id
1979 1979
         if (!is_null($dataReceived['agses_hosted_id'])) {
1980
-            DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'agses_hosted_id');
1980
+            DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'agses_hosted_id');
1981 1981
             $counter = DB::count();
1982 1982
             if ($counter === 0) {
1983 1983
                 DB::insert(
@@ -2008,7 +2008,7 @@  discard block
 block discarded – undo
2008 2008
 
2009 2009
         // agses_hosted_apikey
2010 2010
         if (!is_null($dataReceived['agses_hosted_apikey'])) {
2011
-            DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'agses_hosted_apikey');
2011
+            DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'agses_hosted_apikey');
2012 2012
             $counter = DB::count();
2013 2013
             if ($counter === 0) {
2014 2014
                 DB::insert(
@@ -2038,7 +2038,7 @@  discard block
 block discarded – undo
2038 2038
         }
2039 2039
 
2040 2040
         // send data
2041
-        echo '[{"result" : "' . addslashes($lang['done']) . '" , "error" : ""}]';
2041
+        echo '[{"result" : "'.addslashes($lang['done']).'" , "error" : ""}]';
2042 2042
         break;
2043 2043
 
2044 2044
     case 'save_option_change':
@@ -2079,7 +2079,7 @@  discard block
 block discarded – undo
2079 2079
 
2080 2080
         // Check if setting is already in DB. If NO then insert, if YES then update.
2081 2081
         $data = DB::query(
2082
-            'SELECT * FROM ' . prefixTable('misc') . '
2082
+            'SELECT * FROM '.prefixTable('misc').'
2083 2083
             WHERE type = %s AND intitule = %s',
2084 2084
             'admin',
2085 2085
             $post_field
@@ -2102,7 +2102,7 @@  discard block
 block discarded – undo
2102 2102
                     array(
2103 2103
                         'valeur' => time(),
2104 2104
                         'type' => 'admin',
2105
-                        'intitule' => $post_field . '_time',
2105
+                        'intitule' => $post_field.'_time',
2106 2106
                         'updated_at' => time(),
2107 2107
                     )
2108 2108
                 );
@@ -2124,10 +2124,10 @@  discard block
 block discarded – undo
2124 2124
             if ($post_field === 'send_stats') {
2125 2125
                 // Check if previous time exists, if not them insert this value in DB
2126 2126
                 DB::query(
2127
-                    'SELECT * FROM ' . prefixTable('misc') . '
2127
+                    'SELECT * FROM '.prefixTable('misc').'
2128 2128
                     WHERE type = %s AND intitule = %s',
2129 2129
                     'admin',
2130
-                    $post_field . '_time'
2130
+                    $post_field.'_time'
2131 2131
                 );
2132 2132
                 $counter = DB::count();
2133 2133
                 if ($counter === 0) {
@@ -2136,7 +2136,7 @@  discard block
 block discarded – undo
2136 2136
                         array(
2137 2137
                             'valeur' => 0,
2138 2138
                             'type' => 'admin',
2139
-                            'intitule' => $post_field . '_time',
2139
+                            'intitule' => $post_field.'_time',
2140 2140
                             'created_at' => time(),
2141 2141
                         )
2142 2142
                     );
@@ -2158,13 +2158,13 @@  discard block
 block discarded – undo
2158 2158
         // special Cases
2159 2159
         if ($post_field === 'cpassman_url') {
2160 2160
             // update also jsUrl for CSFP protection
2161
-            $jsUrl = $post_value . '/includes/libraries/csrfp/js/csrfprotector.js';
2161
+            $jsUrl = $post_value.'/includes/libraries/csrfp/js/csrfprotector.js';
2162 2162
             $csrfp_file = '../includes/libraries/csrfp/libs/csrfp.config.php';
2163 2163
             $data = file_get_contents($csrfp_file);
2164 2164
             $posJsUrl = strpos($data, '"jsUrl" => "');
2165 2165
             $posEndLine = strpos($data, '",', $posJsUrl);
2166 2166
             $line = substr($data, $posJsUrl, ($posEndLine - $posJsUrl + 2));
2167
-            $newdata = str_replace($line, '"jsUrl" => "' . filter_var($jsUrl, FILTER_SANITIZE_FULL_SPECIAL_CHARS) . '",', $data);
2167
+            $newdata = str_replace($line, '"jsUrl" => "'.filter_var($jsUrl, FILTER_SANITIZE_FULL_SPECIAL_CHARS).'",', $data);
2168 2168
             file_put_contents($csrfp_file, $newdata);
2169 2169
         } elseif ($post_field === 'restricted_to_input' && (int) $post_value === 0) {
2170 2170
             DB::update(
@@ -2183,7 +2183,7 @@  discard block
 block discarded – undo
2183 2183
         echo prepareExchangedData(
2184 2184
             array(
2185 2185
                 'error' => false,
2186
-                'misc' => $counter . ' ; ' . $SETTINGS[$post_field],
2186
+                'misc' => $counter.' ; '.$SETTINGS[$post_field],
2187 2187
                 'message' => empty($post_translate) === false ? $lang->get($post_translate) : '',
2188 2188
             ),
2189 2189
             'encode'
@@ -2226,7 +2226,7 @@  discard block
 block discarded – undo
2226 2226
 
2227 2227
         // send statistics
2228 2228
         if (null !== $post_status) {
2229
-            DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'send_stats');
2229
+            DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'send_stats');
2230 2230
             $counter = DB::count();
2231 2231
             if ($counter === 0) {
2232 2232
                 DB::insert(
@@ -2257,7 +2257,7 @@  discard block
 block discarded – undo
2257 2257
 
2258 2258
         // send statistics items
2259 2259
         if (null !== $post_list) {
2260
-            DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s', 'admin', 'send_statistics_items');
2260
+            DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s', 'admin', 'send_statistics_items');
2261 2261
             $counter = DB::count();
2262 2262
             if ($counter === 0) {
2263 2263
                 DB::insert(
@@ -2303,7 +2303,7 @@  discard block
 block discarded – undo
2303 2303
             break;
2304 2304
         }
2305 2305
 
2306
-        if (DB::query("SHOW TABLES LIKE '" . prefixTable('sk_reencrypt_backup') . "'")) {
2306
+        if (DB::query("SHOW TABLES LIKE '".prefixTable('sk_reencrypt_backup')."'")) {
2307 2307
             if (DB::count() === 1) {
2308 2308
                 echo 1;
2309 2309
             } else {
@@ -2364,7 +2364,7 @@  discard block
 block discarded – undo
2364 2364
 
2365 2365
         $rows = DB::query(
2366 2366
             'SELECT id, title
2367
-                FROM ' . prefixTable('roles_title') . '
2367
+                FROM ' . prefixTable('roles_title').'
2368 2368
                 ORDER BY title ASC'
2369 2369
         );
2370 2370
         foreach ($rows as $record) {
@@ -2496,7 +2496,7 @@  discard block
 block discarded – undo
2496 2496
 
2497 2497
         $ignoredFiles = DB::queryFirstField(
2498 2498
             'SELECT valeur 
2499
-            FROM ' . prefixTable('misc') . ' 
2499
+            FROM ' . prefixTable('misc').' 
2500 2500
             WHERE type = %s AND intitule = %s',
2501 2501
             'admin',
2502 2502
             'ignored_unknown_files'
@@ -2539,7 +2539,7 @@  discard block
 block discarded – undo
2539 2539
         // Get ignored unknown files
2540 2540
         $existingData = DB::queryFirstRow(
2541 2541
             'SELECT valeur 
2542
-            FROM ' . prefixTable('misc') . ' 
2542
+            FROM ' . prefixTable('misc').' 
2543 2543
             WHERE type = %s AND intitule = %s',
2544 2544
             'admin',
2545 2545
             'ignored_unknown_files'
@@ -2596,7 +2596,7 @@  discard block
 block discarded – undo
2596 2596
         // Get the list of files to delete
2597 2597
         $filesToDelete = DB::queryFirstField(
2598 2598
             'SELECT valeur 
2599
-            FROM ' . prefixTable('misc') . ' 
2599
+            FROM ' . prefixTable('misc').' 
2600 2600
             WHERE type = %s AND intitule = %s',
2601 2601
             'admin',
2602 2602
             'unknown_files'
@@ -2642,7 +2642,7 @@  discard block
 block discarded – undo
2642 2642
         // Get some TP USER info
2643 2643
         $userInfo = DB::queryFirstRow(
2644 2644
             'SELECT id, public_key, private_key, pw
2645
-            FROM ' . prefixTable('users') . ' 
2645
+            FROM ' . prefixTable('users').' 
2646 2646
             WHERE id = %i',
2647 2647
             TP_USER_ID,
2648 2648
         );
@@ -2688,8 +2688,8 @@  discard block
 block discarded – undo
2688 2688
 
2689 2689
         $users = DB::query(
2690 2690
             'SELECT u.id, u.public_key, a.increment_id
2691
-            FROM ' . prefixTable('users') . ' AS u
2692
-            LEFT JOIN ' . prefixTable('api') . ' AS a 
2691
+            FROM ' . prefixTable('users').' AS u
2692
+            LEFT JOIN ' . prefixTable('api').' AS a 
2693 2693
                 ON a.user_id = u.id AND a.type = %s
2694 2694
             WHERE u.disabled = %i AND u.deleted_at IS NULL AND u.public_key IS NOT NULL AND u.admin = %i
2695 2695
             ORDER BY u.login ASC',
@@ -2746,7 +2746,7 @@  discard block
 block discarded – undo
2746 2746
     $lang = new Language($session->get('user-language') ?? 'english');
2747 2747
 
2748 2748
     $results = [];
2749
-    $fullPath = __DIR__ . '/../';
2749
+    $fullPath = __DIR__.'/../';
2750 2750
     
2751 2751
     foreach ($files as $file) {
2752 2752
         // Normalize path separators for cross-platform compatibility
@@ -2795,7 +2795,7 @@  discard block
 block discarded – undo
2795 2795
         }
2796 2796
         
2797 2797
         // Try to delete the file
2798
-        $deleteResult = '';//@unlink($normalizedPath);
2798
+        $deleteResult = ''; //@unlink($normalizedPath);
2799 2799
         
2800 2800
         if ($deleteResult) {
2801 2801
             $results[$normalizedPath] = [
@@ -2825,7 +2825,7 @@  discard block
 block discarded – undo
2825 2825
  */
2826 2826
 function filesIntegrityCheck($baseDir): array
2827 2827
 {
2828
-    $referenceFile = __DIR__ . '/../files_reference.txt';
2828
+    $referenceFile = __DIR__.'/../files_reference.txt';
2829 2829
 
2830 2830
     $unknownFiles = findUnknownFiles($baseDir, $referenceFile);
2831 2831
 
@@ -2863,7 +2863,7 @@  discard block
 block discarded – undo
2863 2863
                 $dir,
2864 2864
                 FilesystemIterator::SKIP_DOTS
2865 2865
             ),
2866
-            function ($current, $key, $iterator) {
2866
+            function($current, $key, $iterator) {
2867 2867
                 // Ignore hidden files and folders
2868 2868
                 if ($current->getFilename()[0] === '.') {
2869 2869
                     return false;
@@ -2877,7 +2877,7 @@  discard block
 block discarded – undo
2877 2877
     foreach ($iterator as $file) {
2878 2878
         try {
2879 2879
             if ($file->isFile()) {
2880
-                $relativePath = str_replace($dir . DIRECTORY_SEPARATOR, '', $file->getPathname());
2880
+                $relativePath = str_replace($dir.DIRECTORY_SEPARATOR, '', $file->getPathname());
2881 2881
                 $relativePath = str_replace('\\', '/', $relativePath); // Normalisation Windows/Linux
2882 2882
 
2883 2883
                 // Split relatif path into parts
@@ -2943,7 +2943,7 @@  discard block
 block discarded – undo
2943 2943
     // Get ignored files
2944 2944
     $ignoredFiles = DB::queryFirstField(
2945 2945
         'SELECT valeur 
2946
-        FROM ' . prefixTable('misc') . ' 
2946
+        FROM ' . prefixTable('misc').' 
2947 2947
         WHERE type = %s AND intitule = %s',
2948 2948
         'admin',
2949 2949
         'ignored_unknown_files'
@@ -2962,7 +2962,7 @@  discard block
 block discarded – undo
2962 2962
 function tablesIntegrityCheck(): array
2963 2963
 {
2964 2964
     // Get integrity tables file
2965
-    $integrityTablesFile = TEAMPASS_ROOT_PATH . '/includes/tables_integrity.json';
2965
+    $integrityTablesFile = TEAMPASS_ROOT_PATH.'/includes/tables_integrity.json';
2966 2966
     if (file_exists($integrityTablesFile) === false) {
2967 2967
         return [
2968 2968
             'error' => true,
@@ -2980,7 +2980,7 @@  discard block
 block discarded – undo
2980 2980
     // Get all tables
2981 2981
     $tables = [];
2982 2982
     foreach (DB::queryFirstColumn("SHOW TABLES") as $table) {
2983
-        $tables[] = str_replace(DB_PREFIX, "", $table);;
2983
+        $tables[] = str_replace(DB_PREFIX, "", $table); ;
2984 2984
     }
2985 2985
     // Prepare the integrity check
2986 2986
     $tablesInError = [];
@@ -3046,7 +3046,7 @@  discard block
 block discarded – undo
3046 3046
 
3047 3047
         // Compare hashes
3048 3048
         $expectedHash = $referenceData[$file];
3049
-        $actualHash = md5_file($baseDir . '/' . $file);
3049
+        $actualHash = md5_file($baseDir.'/'.$file);
3050 3050
 
3051 3051
         if ($expectedHash !== $actualHash) {
3052 3052
             $issues[] = "$file (expected: <i>$expectedHash</i>, actual: <i>$actualHash</i>)";
@@ -3099,7 +3099,7 @@  discard block
 block discarded – undo
3099 3099
     foreach ($iterator as $file) {
3100 3100
         if ($file->isFile()) {
3101 3101
             // Build relative path
3102
-            $relativePath = str_replace($dir . DIRECTORY_SEPARATOR, '', $file->getPathname());
3102
+            $relativePath = str_replace($dir.DIRECTORY_SEPARATOR, '', $file->getPathname());
3103 3103
             $relativePath = str_replace('\\', '/', $relativePath); // Normalize for Windows
3104 3104
             // Calculate hash
3105 3105
             $files[$relativePath] = md5_file($file->getPathname());
@@ -3129,8 +3129,8 @@  discard block
 block discarded – undo
3129 3129
     // Loop on items
3130 3130
     $item = DB::queryFirstRow(
3131 3131
         'SELECT i.id, i.pw, s.share_key, s.increment_id
3132
-        FROM ' . prefixTable('items') . ' i
3133
-        INNER JOIN ' . prefixTable('sharekeys_items') . ' s ON i.id = s.object_id
3132
+        FROM ' . prefixTable('items').' i
3133
+        INNER JOIN ' . prefixTable('sharekeys_items').' s ON i.id = s.object_id
3134 3134
         WHERE i.perso = %i
3135 3135
             AND s.user_id = %i
3136 3136
         ORDER BY RAND()
@@ -3159,7 +3159,7 @@  discard block
 block discarded – undo
3159 3159
         // Get all items in database
3160 3160
         $rows = DB::queryFirstRow(
3161 3161
             'SELECT count(*) as counter
3162
-            FROM ' . prefixTable('sharekeys_items') . ' s
3162
+            FROM ' . prefixTable('sharekeys_items').' s
3163 3163
             WHERE s.user_id = %i',
3164 3164
             TP_USER_ID
3165 3165
         );
Please login to merge, or discard this patch.