Passed
Push — wip_sessions ( b55e55...384f5b )
by Nils
05:05
created
pages/backups.js.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('backups') === false) {
69 69
     // Not allowed page
70 70
     $session->set('system-error_code', ERR_NOT_ALLOWED);
71
-    include $SETTINGS['cpassman_dir'] . '/error.php';
71
+    include $SETTINGS['cpassman_dir'].'/error.php';
72 72
     exit;
73 73
 }
74 74
 ?>
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
                             // ERROR
138 138
                             toastr.remove();
139 139
                             toastr.error(
140
-                                '<?php echo $lang->get('server_answer_error') . '<br />' . $lang->get('server_returned_data') . ':<br />'; ?>' + data.error,
140
+                                '<?php echo $lang->get('server_answer_error').'<br />'.$lang->get('server_returned_data').':<br />'; ?>' + data.error,
141 141
                                 '<?php echo $lang->get('error'); ?>', {
142 142
                                     timeOut: 5000,
143 143
                                     progressBar: true
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
                                         // error
165 165
                                         toastr.remove();
166 166
                                         toastr.error(
167
-                                            '<?php echo $lang->get('server_answer_error') . '<br />' . $lang->get('server_returned_data') . ':<br />'; ?>' + data.error,
167
+                                            '<?php echo $lang->get('server_answer_error').'<br />'.$lang->get('server_returned_data').':<br />'; ?>' + data.error,
168 168
                                             '<?php echo $lang->get('error'); ?>', {
169 169
                                                 timeOut: 5000,
170 170
                                                 progressBar: true
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
                             // ERROR
236 236
                             toastr.remove();
237 237
                             toastr.error(
238
-                                '<?php echo $lang->get('server_answer_error') . '<br />' . $lang->get('server_returned_data') . ':<br />'; ?>' + data.error,
238
+                                '<?php echo $lang->get('server_answer_error').'<br />'.$lang->get('server_returned_data').':<br />'; ?>' + data.error,
239 239
                                 '<?php echo $lang->get('error'); ?>', {
240 240
                                     timeOut: 5000,
241 241
                                     progressBar: true
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
     // PREPARE UPLOADER with plupload
272 272
 <?php
273 273
 $maxFileSize = (strrpos($SETTINGS['upload_maxfilesize'], 'mb') === false)
274
-    ? $SETTINGS['upload_maxfilesize'] . 'mb'
274
+    ? $SETTINGS['upload_maxfilesize'].'mb'
275 275
     : $SETTINGS['upload_maxfilesize'];
276 276
 ?>
277 277
 
Please login to merge, or discard this patch.
pages/utilities.logs.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('utilities.logs') === false) {
67 67
     // Not allowed page
68 68
     $session->set('system-error_code', ERR_NOT_ALLOWED);
69
-    include $SETTINGS['cpassman_dir'] . '/error.php';
69
+    include $SETTINGS['cpassman_dir'].'/error.php';
70 70
     exit;
71 71
 }
72 72
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
                                             echo $session->has('user-admin') && (int) $session->get('user-admin') && null !== $session->get('user-admin') && (int) $session->get('user-admin') === 1 ? '' : ' hidden';
204 204
                                             ?>">
205 205
                         <div class="form-group">
206
-                            <h5><i class="fas fa-broom mr-2"></i><?php echo $lang->get('purge') . ' ' . $lang->get('date_range'); ?></h5>
206
+                            <h5><i class="fas fa-broom mr-2"></i><?php echo $lang->get('purge').' '.$lang->get('date_range'); ?></h5>
207 207
                             <div class="input-group">
208 208
                                 <div class="input-group-prepend">
209 209
                                     <span class="input-group-text">
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
                                     <select class="form-control" id="purge-filter-user">
227 227
                                         <option value="-1"><?php echo $lang->get('all'); ?></option>
228 228
                                     <?php
229
-                                    $rows = DB::query('SELECT id, name, lastname FROM ' . prefixTable('users') . ' WHERE admin = 0');
229
+                                    $rows = DB::query('SELECT id, name, lastname FROM '.prefixTable('users').' WHERE admin = 0');
230 230
 foreach ($rows as $record) {
231 231
     echo '
232 232
                                         <option value="'.$record['id'].'">'.$record['name'].' '.$record['lastname'].'</option>';
Please login to merge, or discard this patch.
pages/profile.php 1 patch
Spacing   +33 added lines, -34 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('profile') === false) {
65 65
     // Not allowed page
66 66
     $session->set('system-error_code', ERR_NOT_ALLOWED);
67
-    include $SETTINGS['cpassman_dir'] . '/error.php';
67
+    include $SETTINGS['cpassman_dir'].'/error.php';
68 68
     exit;
69 69
 }
70 70
 
@@ -96,25 +96,25 @@  discard block
 block discarded – undo
96 96
 // prepare list of timezones
97 97
 $zones = timezone_list();
98 98
 // prepare list of languages
99
-$languages = DB::query('SELECT label, name FROM ' . prefixTable('languages') . ' ORDER BY label ASC');
99
+$languages = DB::query('SELECT label, name FROM '.prefixTable('languages').' ORDER BY label ASC');
100 100
 // Do some stats
101
-DB::query('SELECT id_item FROM ' . prefixTable('log_items') . ' WHERE action = "at_creation" AND  id_user = "' . $session->get('user-id') . '"');
101
+DB::query('SELECT id_item FROM '.prefixTable('log_items').' WHERE action = "at_creation" AND  id_user = "'.$session->get('user-id').'"');
102 102
 $userItemsNumber = DB::count();
103
-DB::query('SELECT id_item FROM ' . prefixTable('log_items') . ' WHERE action = "at_modification" AND  id_user = "' . $session->get('user-id') . '"');
103
+DB::query('SELECT id_item FROM '.prefixTable('log_items').' WHERE action = "at_modification" AND  id_user = "'.$session->get('user-id').'"');
104 104
 $userModificationNumber = DB::count();
105
-DB::query('SELECT id_item FROM ' . prefixTable('log_items') . ' WHERE action = "at_shown" AND  id_user = "' . $session->get('user-id') . '"');
105
+DB::query('SELECT id_item FROM '.prefixTable('log_items').' WHERE action = "at_shown" AND  id_user = "'.$session->get('user-id').'"');
106 106
 $userSeenItemsNumber = DB::count();
107
-DB::query('SELECT id_item FROM ' . prefixTable('log_items') . ' WHERE action = "at_password_shown" AND  id_user = "' . $session->get('user-id') . '"');
107
+DB::query('SELECT id_item FROM '.prefixTable('log_items').' WHERE action = "at_password_shown" AND  id_user = "'.$session->get('user-id').'"');
108 108
 $userSeenPasswordsNumber = DB::count();
109 109
 $userInfo = DB::queryFirstRow(
110 110
     'SELECT avatar, last_pw_change
111
-    FROM ' . prefixTable('users') . ' 
112
-    WHERE id = "' . $session->get('user-id') . '"'
111
+    FROM ' . prefixTable('users').' 
112
+    WHERE id = "' . $session->get('user-id').'"'
113 113
 );
114 114
 if (empty($userInfo['avatar']) === true) {
115
-    $avatar = $SETTINGS['cpassman_url'] . '/includes/images/photo.jpg';
115
+    $avatar = $SETTINGS['cpassman_url'].'/includes/images/photo.jpg';
116 116
 } else {
117
-    $avatar = $SETTINGS['cpassman_url'] . '/includes/avatars/' . $userInfo['avatar'];
117
+    $avatar = $SETTINGS['cpassman_url'].'/includes/avatars/'.$userInfo['avatar'];
118 118
 }
119 119
 
120 120
 // Get Groups name
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 foreach ($session->get('user-roles_array') as $role) {
123 123
     $tmp = DB::queryFirstRow(
124 124
         'SELECT title 
125
-        FROM ' . prefixTable('roles_title') . ' 
126
-        WHERE id = "' . $role . '"'
125
+        FROM ' . prefixTable('roles_title').' 
126
+        WHERE id = "' . $role.'"'
127 127
     );
128 128
     if ($tmp !== null) {
129 129
         array_push($userParOfGroups, $tmp['title']);
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
                         <h3 id="profile-username" class="text-center">
168 168
                             <?php
169 169
                             if (null !== $session->get('user-name') && empty($session->get('user-name')) === false) {
170
-                                echo $session->get('user-name') . ' ' . $session->get('user-lastname');
170
+                                echo $session->get('user-name').' '.$session->get('user-lastname');
171 171
                             } else {
172 172
                                 echo $session->get('user-login');
173 173
                             }
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
                                             } else {
236 236
                                                 echo date('d/m/Y', (int) $session->get('user-last_connection'));
237 237
                                             }
238
-                                            echo ' ' . $lang->get('at') . ' ';
238
+                                            echo ' '.$lang->get('at').' ';
239 239
                                             if (isset($SETTINGS['time_format']) === true) {
240 240
                                                 echo date($SETTINGS['time_format'], (int) $session->get('user-last_connection'));
241 241
                                             } else {
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                                         </a>
246 246
                                     </li>
247 247
                                     <?php
248
-                                    if (null !== $session->get('user-last_pw_change') && ! empty($session->get('user-last_pw_change') === true)) {
248
+                                    if (null !== $session->get('user-last_pw_change') && !empty($session->get('user-last_pw_change') === true)) {
249 249
                                         // Handle last password change string
250 250
                                         if ($session->has('user-last_pw_change') && null !== $session->get('user-last_pw_change')) {
251 251
                                             if (isset($SETTINGS['date_format']) === true) {
@@ -265,12 +265,12 @@  discard block
 block discarded – undo
265 265
                                         ) {
266 266
                                             $numDaysBeforePwExpiration = '';
267 267
                                         } else {
268
-                                            $numDaysBeforePwExpiration = $LANG['index_pw_expiration'] . ' ' . $session->get('user-num_days_before_exp') . ' ' . $LANG['days'] . '.';
268
+                                            $numDaysBeforePwExpiration = $LANG['index_pw_expiration'].' '.$session->get('user-num_days_before_exp').' '.$LANG['days'].'.';
269 269
                                         }
270 270
                                         echo '
271 271
                                     <li class="list-group-item">
272
-                                        <b><i class="fas fa-calendar-alt fa-fw fa-lg mr-2"></i>' . $lang->get('index_last_pw_change') . '</b>
273
-                                        <a class="float-right">' . $last_pw_change . ' ' . $numDaysBeforePwExpiration . '</a>
272
+                                        <b><i class="fas fa-calendar-alt fa-fw fa-lg mr-2"></i>' . $lang->get('index_last_pw_change').'</b>
273
+                                        <a class="float-right">' . $last_pw_change.' '.$numDaysBeforePwExpiration.'</a>
274 274
                                     </li>';
275 275
                                     }
276 276
                                     ?>
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
                                     if (isset($SETTINGS['api']) === true && (int) $SETTINGS['api'] === 1) {
291 291
                                         echo '
292 292
                                     <li class="list-group-item">
293
-                                        <b><i class="fas fa-paper-plane fa-fw fa-lg mr-2"></i>' . $lang->get('user_profile_api_key') . '</b>
293
+                                        <b><i class="fas fa-paper-plane fa-fw fa-lg mr-2"></i>' . $lang->get('user_profile_api_key').'</b>
294 294
                                         <a class="float-right" id="profile-user-api-token">',
295 295
                                             null !== $session->get('user-api_key') ? $session->get('user-api_key') : '',
296 296
                                         '</a>
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
                                         <ul class="">
327 327
                                             <?php
328 328
                                                 foreach ($session->get('user-unsuccessfull_login_attempts_list') as $entry) {
329
-                                                    echo '<li class="">' . $entry . '</li>';
329
+                                                    echo '<li class="">'.$entry.'</li>';
330 330
                                                 } ?>
331 331
                                         </ul>
332 332
                                     </div>
@@ -339,12 +339,12 @@  discard block
 block discarded – undo
339 339
                                         <?php
340 340
                                         $rows = DB::query(
341 341
                                             'SELECT label AS labelAction, date, null
342
-                                                    FROM ' . prefixTable('log_system') . '
342
+                                                    FROM ' . prefixTable('log_system').'
343 343
                                                     WHERE qui = %i
344 344
                                                     UNION
345 345
                                                     SELECT l.action, l.date, i.label AS itemLabel
346
-                                                    FROM ' . prefixTable('log_items') . ' AS l
347
-                                                    INNER JOIN ' . prefixTable('items') . ' AS i ON (l.id_item = i.id)
346
+                                                    FROM ' . prefixTable('log_items').' AS l
347
+                                                    INNER JOIN ' . prefixTable('items').' AS i ON (l.id_item = i.id)
348 348
                                                     WHERE l.id_user = %i AND l.action IN ("at_access")
349 349
                                                     ORDER BY date DESC
350 350
                                                     LIMIT 0, 40',
@@ -358,9 +358,9 @@  discard block
 block discarded – undo
358 358
                                                 $text = $lang->get($record['labelAction']);
359 359
                                             }
360 360
                                             if (empty($record['NULL']) === false) {
361
-                                                $text .= ' ' . $lang->get('for') . ' <span class="font-weight-light">' . addslashes($record['NULL']) . '</span>';
361
+                                                $text .= ' '.$lang->get('for').' <span class="font-weight-light">'.addslashes($record['NULL']).'</span>';
362 362
                                             }
363
-                                            echo '<li class="list-group-item">' . date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['date']) . ' - ' . $text . '</li>';
363
+                                            echo '<li class="list-group-item">'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['date']).' - '.$text.'</li>';
364 364
                                         }
365 365
                                         ?>
366 366
                                     </ul>
@@ -398,11 +398,10 @@  discard block
 block discarded – undo
398 398
                                                 <?php
399 399
                                                 foreach ($zones as $key => $zone) {
400 400
                                                     echo '
401
-                                                <option value="' . $key . '"',
401
+                                                <option value="' . $key.'"',
402 402
                                                     $session->has('user-timezone') && $session->get('user-timezone') && null !== $session->get('user-timezone') && $session->get('user-timezone') === $key ?
403
-                                                    ' selected' :
404
-                                                    (isset($SETTINGS['timezone']) === true && $SETTINGS['timezone'] === $key ? ' selected' : ''),
405
-                                                '>' . $zone . '</option>';
403
+                                                    ' selected' : (isset($SETTINGS['timezone']) === true && $SETTINGS['timezone'] === $key ? ' selected' : ''),
404
+                                                '>'.$zone.'</option>';
406 405
                                                 }
407 406
                                                 ?>
408 407
                                             </select>
@@ -414,10 +413,10 @@  discard block
 block discarded – undo
414 413
                                             <select class="form-control" id="profile-user-language">
415 414
                                                 <?php
416 415
                                                     foreach ($languages as $language) {
417
-                                                        echo '<option value="' . $language['name'] . '"',
416
+                                                        echo '<option value="'.$language['name'].'"',
418 417
                                                         strtolower($session->get('user-language')) === strtolower($language['name']) ?
419 418
                                                         ' selected="selected"' : '',
420
-                                                    '>' . $language['label'] . '</option>';
419
+                                                    '>'.$language['label'].'</option>';
421 420
                                                     }
422 421
                                                 ?>
423 422
                                             </select>
@@ -429,11 +428,11 @@  discard block
 block discarded – undo
429 428
                                         <div class="col-sm-10">
430 429
                                             <select class="form-control" id="profile-user-treeloadstrategy">
431 430
                                                 
432
-                                                <option value="sequential" <?php echo $session->has('user-tree_load_strategy') && $session->get('user-tree_load_strategy') && null !== $session->get('user-tree_load_strategy') && $session->get('user-tree_load_strategy') === 'sequential' ? ' selected' : '';?>>
431
+                                                <option value="sequential" <?php echo $session->has('user-tree_load_strategy') && $session->get('user-tree_load_strategy') && null !== $session->get('user-tree_load_strategy') && $session->get('user-tree_load_strategy') === 'sequential' ? ' selected' : ''; ?>>
433 432
                                                     <?php echo $lang->get('sequential'); ?>
434 433
                                                 </option>
435 434
                                                 
436
-                                                <option value="full" <?php echo $session->has('user-tree_load_strategy') && $session->get('user-tree_load_strategy') && null !== $session->get('user-tree_load_strategy') && $session->get('user-tree_load_strategy') === 'full' ? ' selected' : '';?>>
435
+                                                <option value="full" <?php echo $session->has('user-tree_load_strategy') && $session->get('user-tree_load_strategy') && null !== $session->get('user-tree_load_strategy') && $session->get('user-tree_load_strategy') === 'full' ? ' selected' : ''; ?>>
437 436
                                                     <?php echo $lang->get('full'); ?>
438 437
                                                 </option>
439 438
                                             </select>
@@ -468,7 +467,7 @@  discard block
 block discarded – undo
468 467
                                                 <button type="button" class="btn btn-warning float-right ml-2" id="profile-avatar-file"><?php echo $lang->get('upload_new_avatar'); ?></button>
469 468
                                                 <?php
470 469
                                                 if (isset($SETTINGS['api']) === true && (int) $SETTINGS['api'] === 1) {
471
-                                                    echo '<button type="button" class="btn btn-warning float-right" id="profile-button-api_token">' . $lang->get('generate_api_token') . '</button>';
470
+                                                    echo '<button type="button" class="btn btn-warning float-right" id="profile-button-api_token">'.$lang->get('generate_api_token').'</button>';
472 471
                                                 }
473 472
                                                 ?>
474 473
                                                 <div id="profile-avatar-file-container" class="hidden"></div>
Please login to merge, or discard this patch.
sources/core.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -54,16 +54,16 @@  discard block
 block discarded – undo
54 54
 {
55 55
     // Load AntiXSS
56 56
     $antiXss = new AntiXSS();
57
-    if (! headers_sent()) {    //If headers not sent yet... then do php redirect
58
-        header('Location: ' . $antiXss->xss_clean($url));
57
+    if (!headers_sent()) {    //If headers not sent yet... then do php redirect
58
+        header('Location: '.$antiXss->xss_clean($url));
59 59
     }
60 60
 
61 61
     //If headers are sent... do java redirect... if java disabled, do html redirect.
62 62
     echo '<script type="text/javascript">';
63
-    echo 'window.location.href="' . $antiXss->xss_clean($url) . '";';
63
+    echo 'window.location.href="'.$antiXss->xss_clean($url).'";';
64 64
     echo '</script>';
65 65
     echo '<noscript>';
66
-    echo '<meta http-equiv="refresh" content="0;url=' . $antiXss->xss_clean($url) . '" />';
66
+    echo '<meta http-equiv="refresh" content="0;url='.$antiXss->xss_clean($url).'" />';
67 67
     echo '</noscript>';
68 68
 }
69 69
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     && isset($SETTINGS['enable_sts']) === true
90 90
     && (int) $SETTINGS['enable_sts'] === 1
91 91
 ) {
92
-    teampassRedirect('https://' . $server['http_host'] . $server['request_uri']);
92
+    teampassRedirect('https://'.$server['http_host'].$server['request_uri']);
93 93
 }
94 94
 
95 95
 // Load pwComplexity
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
 // LOAD CPASSMAN SETTINGS
111 111
 if (
112 112
     isset($SETTINGS['cpassman_dir']) === true
113
-    && is_dir($SETTINGS['cpassman_dir'] . '/install') === true
113
+    && is_dir($SETTINGS['cpassman_dir'].'/install') === true
114 114
 ) {
115 115
     // Should we delete folder INSTALL?
116 116
     $row = DB::queryFirstRow(
117
-        'SELECT valeur FROM ' . prefixTable('misc') . ' WHERE type=%s AND intitule=%s',
117
+        'SELECT valeur FROM '.prefixTable('misc').' WHERE type=%s AND intitule=%s',
118 118
         'install',
119 119
         'clear_install_folder'
120 120
     );
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
             if ($directories !== false) {
133 133
                 $files = array_diff($directories, ['.', '..']);
134 134
                 foreach ($files as $file) {
135
-                    if (is_dir($dir . '/' . $file)) {
136
-                        delTree($dir . '/' . $file);
135
+                    if (is_dir($dir.'/'.$file)) {
136
+                        delTree($dir.'/'.$file);
137 137
                     } else {
138 138
                         try {
139
-                            unlink($dir . '/' . $file);
139
+                            unlink($dir.'/'.$file);
140 140
                         } catch (Exception $e) {
141 141
                             // do nothing... php will ignore and continue
142 142
                         }
@@ -150,13 +150,13 @@  discard block
 block discarded – undo
150 150
             return false;
151 151
         }
152 152
 
153
-        if (is_dir($SETTINGS['cpassman_dir'] . '/install')) {
153
+        if (is_dir($SETTINGS['cpassman_dir'].'/install')) {
154 154
             // Set the permissions on the install directory and delete
155 155
             // is server Windows or Linux?
156 156
             if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
157
-                recursiveChmod($SETTINGS['cpassman_dir'] . '/install', 0755, 0440);
157
+                recursiveChmod($SETTINGS['cpassman_dir'].'/install', 0755, 0440);
158 158
             }
159
-            delTree($SETTINGS['cpassman_dir'] . '/install');
159
+            delTree($SETTINGS['cpassman_dir'].'/install');
160 160
         }
161 161
 
162 162
         // Delete temporary install table
@@ -174,10 +174,10 @@  discard block
 block discarded – undo
174 174
 // Load Languages stuff
175 175
 if (isset($languagesList) === false) {
176 176
     $languagesList = [];
177
-    $rows = DB::query('SELECT * FROM ' . prefixTable('languages') . ' GROUP BY name, label, code, flag, id ORDER BY name ASC');
177
+    $rows = DB::query('SELECT * FROM '.prefixTable('languages').' GROUP BY name, label, code, flag, id ORDER BY name ASC');
178 178
     foreach ($rows as $record) {
179 179
         array_push($languagesList, $record['name']);
180
-        if ($session->get('user-language') === $record['name'] ) {
180
+        if ($session->get('user-language') === $record['name']) {
181 181
             $session->set('user-language_flag', $record['flag']);
182 182
             $session->set('user-language_code', $record['code']);
183 183
             //$session->set('user-language_label', $record['label']);
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 // CHECK IF SESSION EXISTS AND IF SESSION IS VALID
236 236
 if (empty($session->get('user-session_duration')) === false) {
237 237
     $dataSession = DB::queryFirstRow(
238
-        'SELECT key_tempo FROM ' . prefixTable('users') . ' WHERE id=%i',
238
+        'SELECT key_tempo FROM '.prefixTable('users').' WHERE id=%i',
239 239
         $session->get('user-id')
240 240
     );
241 241
 } else {
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
     && ($session->has('user-admin') && $session->get('user-admin') && null !== $session->get('user-admin') && $session->get('user-admin') === 1)
300 300
 ) {
301 301
     $row = DB::queryFirstRow(
302
-        'SELECT valeur FROM ' . prefixTable('misc') . ' WHERE type=%s_type AND intitule=%s_intitule',
302
+        'SELECT valeur FROM '.prefixTable('misc').' WHERE type=%s_type AND intitule=%s_intitule',
303 303
         [
304 304
             'type' => 'admin',
305 305
             'intitule' => 'teampass_version',
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 
341 341
         syslog(
342 342
             LOG_WARNING,
343
-            'Unlog user: ' . date('Y/m/d H:i:s') . " {$server['remote_addr']} ({$server['http_user_agent']})"
343
+            'Unlog user: '.date('Y/m/d H:i:s')." {$server['remote_addr']} ({$server['http_user_agent']})"
344 344
         );
345 345
         // erase session table
346 346
         $_SESSION = [];
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 if ($session->has('user-timezone') && null !== $session->get('user-id') && empty($session->get('user-id')) === false) {
397 397
     // query on user
398 398
     $data = DB::queryfirstrow(
399
-        'SELECT login, admin, gestionnaire, can_manage_all_users, groupes_visibles, groupes_interdits, fonction_id, last_connexion, roles_from_ad_groups FROM ' . prefixTable('users') . ' WHERE id=%i',
399
+        'SELECT login, admin, gestionnaire, can_manage_all_users, groupes_visibles, groupes_interdits, fonction_id, last_connexion, roles_from_ad_groups FROM '.prefixTable('users').' WHERE id=%i',
400 400
         $session->get('user-id')
401 401
     );
402 402
     //Check if user has been deleted or unlogged
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
             $data['groupes_visibles'],
444 444
             $data['groupes_interdits'],
445 445
             $data['admin'],
446
-            is_null($data['roles_from_ad_groups']) === true ? $data['fonction_id'] : (empty($data['roles_from_ad_groups']) === true ? $data['fonction_id'] : $data['fonction_id'] . ';' . $data['roles_from_ad_groups']),
446
+            is_null($data['roles_from_ad_groups']) === true ? $data['fonction_id'] : (empty($data['roles_from_ad_groups']) === true ? $data['fonction_id'] : $data['fonction_id'].';'.$data['roles_from_ad_groups']),
447 447
             $SETTINGS
448 448
         );
449 449
         if ($session->has('user-can_create_root_folder') && (int) $session->get('user-can_create_root_folder') && null !== $session->get('user-can_create_root_folder') && (int) $session->get('user-can_create_root_folder') === 1) {
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
     $session->set('system-item_fields', []);
479 479
     $rows = DB::query(
480 480
         'SELECT *
481
-            FROM ' . prefixTable('categories') . '
481
+            FROM ' . prefixTable('categories').'
482 482
             WHERE level=%i',
483 483
         '0'
484 484
     );
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
         // get each field
488 488
         $rows2 = DB::query(
489 489
             'SELECT *
490
-            FROM ' . prefixTable('categories') . '
490
+            FROM ' . prefixTable('categories').'
491 491
             WHERE parent_id=%i
492 492
             ORDER BY `order` ASC',
493 493
             $record['id']
@@ -574,5 +574,5 @@  discard block
 block discarded – undo
574 574
 }
575 575
 
576 576
 /* CHECK NUMBER OF USER ONLINE */
577
-DB::query('SELECT * FROM ' . prefixTable('users') . ' WHERE timestamp>=%i', time() - 600);
577
+DB::query('SELECT * FROM '.prefixTable('users').' WHERE timestamp>=%i', time() - 600);
578 578
 $session->set('system-nb_users_online', DB::count());
Please login to merge, or discard this patch.
error.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
     // Update table by deleting ID
61 61
     if ($session->has('user-id') && null !== $session->get('user-id')) {
62 62
         DB::update(
63
-            DB_PREFIX . 'users',
63
+            DB_PREFIX.'users',
64 64
             [
65 65
                 'key_tempo' => '',
66 66
             ],
Please login to merge, or discard this patch.
sources/roles.queries.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 ) {
70 70
     // Not allowed page
71 71
     $session->set('system-error_code', ERR_NOT_ALLOWED);
72
-    include $SETTINGS['cpassman_dir'] . '/error.php';
72
+    include $SETTINGS['cpassman_dir'].'/error.php';
73 73
     exit;
74 74
 }
75 75
 
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
                         );
451 451
 
452 452
                         // add new role to user
453
-                        $tmp = $data_tmp['fonction_id'] . (substr($data_tmp['fonction_id'], -1) == ';' ? $role_id : ';' . $role_id);
453
+                        $tmp = $data_tmp['fonction_id'].(substr($data_tmp['fonction_id'], -1) == ';' ? $role_id : ';'.$role_id);
454 454
                         $session->set('user-roles', str_replace(';;', ';', $tmp));
455 455
 
456 456
                         // store in DB
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
                         $groupsData = $openLdapExtra->getADGroups($ldapConnection, $SETTINGS);
723 723
                         break;
724 724
                     default:
725
-                        throw new Exception("Unsupported LDAP type: " . $SETTINGS['ldap_type']);
725
+                        throw new Exception("Unsupported LDAP type: ".$SETTINGS['ldap_type']);
726 726
                 }
727 727
             } catch (Exception $e) {
728 728
                 echo prepareExchangedData(array(
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
                 // Handle successful retrieval of groups
740 740
                 // exists in Teampass
741 741
                 //error_log("Error: " . print_r($groupsData['userGroups'], true));
742
-                foreach($groupsData['userGroups'] as $key => $group) {
742
+                foreach ($groupsData['userGroups'] as $key => $group) {
743 743
                     $role_detail = DB::queryfirstrow(
744 744
                         'SELECT a.increment_id as increment_id, a.role_id as role_id, r.title as title
745 745
                         FROM '.prefixTable('ldap_groups_roles').' AS a
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
             
765 765
             // Get all groups in Teampass
766 766
             $teampassRoles = array();
767
-            $rows = DB::query('SELECT id,title FROM ' . prefixTable('roles_title'));
767
+            $rows = DB::query('SELECT id,title FROM '.prefixTable('roles_title'));
768 768
             foreach ($rows as $record) {
769 769
                 array_push(
770 770
                     $teampassRoles,
Please login to merge, or discard this patch.
sources/identify.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 if ($checkUserAccess->checkSession() === false) {
88 88
     // Not allowed page
89 89
     $session->set('system-error_code', ERR_NOT_ALLOWED);
90
-    include $SETTINGS['cpassman_dir'] . '/error.php';
90
+    include $SETTINGS['cpassman_dir'].'/error.php';
91 91
     exit;
92 92
 }
93 93
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
      * @param array $SETTINGS
123 123
      * @return bool|string
124 124
      */
125
-    function handleAuthAttempts($post_data, $SETTINGS): bool|string
125
+    function handleAuthAttempts($post_data, $SETTINGS): bool | string
126 126
     {
127 127
         $session = SessionManager::getSession();
128 128
         $lang = new Language();
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
     $sessionPwdAttempts = $session->get('pwd_attempts');
235 235
     $sessionUrl = $session->get('user-initial_url');
236 236
     $server = [];
237
-    $server['PHP_AUTH_USER'] =  $request->server->get('PHP_AUTH_USER');
237
+    $server['PHP_AUTH_USER'] = $request->server->get('PHP_AUTH_USER');
238 238
     $server['PHP_AUTH_PW'] = $request->server->get('PHP_AUTH_PW');
239 239
     
240 240
     // decrypt and retreive data in JSON format
@@ -249,18 +249,18 @@  discard block
 block discarded – undo
249 249
     }
250 250
 
251 251
     // Check if Duo auth is in progress and pass the pw and login back to the standard login process
252
-    if(
252
+    if (
253 253
         isKeyExistingAndEqual('duo', 1, $SETTINGS) === true
254 254
         && $dataReceived['user_2fa_selection'] === 'duo'
255 255
         && $session->get('user-duo_status') === 'IN_PROGRESS'
256 256
         && !empty($dataReceived['duo_state'])
257
-    ){
257
+    ) {
258 258
         $key = hash('sha256', $dataReceived['duo_state']);
259 259
         $iv = substr(hash('sha256', $dataReceived['duo_state']), 0, 16);
260 260
         $duo_data_dec = openssl_decrypt(base64_decode($session->get('user-duo_status')), 'AES-256-CBC', $key, 0, $iv);
261 261
         // Clear the data from the Duo process to continue clean with the standard login process
262
-        $session->set('user-duo_data','');
263
-        if($duo_data_dec === false){
262
+        $session->set('user-duo_data', '');
263
+        if ($duo_data_dec === false) {
264 264
             echo prepareExchangedData(
265 265
                 [
266 266
                     'error' => true,
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
         $dataReceived['login'] = $duo_data['duo_login'];
276 276
     }
277 277
 
278
-    if(isset($dataReceived['pw']) === false || isset($dataReceived['login']) === false) {
278
+    if (isset($dataReceived['pw']) === false || isset($dataReceived['login']) === false) {
279 279
         echo json_encode([
280 280
             'data' => prepareExchangedData(
281 281
                 [
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
         }
545 545
         // Append with roles from AD groups
546 546
         if (is_null($userInfo['roles_from_ad_groups']) === false) {
547
-            $userInfo['fonction_id'] = empty($userInfo['fonction_id'])  === true ? $userInfo['roles_from_ad_groups'] : $userInfo['fonction_id']. ';' . $userInfo['roles_from_ad_groups'];
547
+            $userInfo['fonction_id'] = empty($userInfo['fonction_id']) === true ? $userInfo['roles_from_ad_groups'] : $userInfo['fonction_id'].';'.$userInfo['roles_from_ad_groups'];
548 548
         }
549 549
         // store
550 550
         $session->set('user-roles', $userInfo['fonction_id']);
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
         if (count($session->get('user-roles_array')) > 0) {
557 557
             $rolesList = DB::query(
558 558
                 'SELECT id, title, complexity
559
-                FROM ' . prefixTable('roles_title') . '
559
+                FROM ' . prefixTable('roles_title').'
560 560
                 WHERE id IN %li',
561 561
                 $session->get('user-roles_array')
562 562
             );
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
             if ($adjustPermissions) {
603 603
                 $session->set('user-admin', (int) $userInfo['admin']);
604 604
                 $session->set('user-manager', (int) $userInfo['gestionnaire']);
605
-                $session->set('user-can_manage_all_users',(int)  $userInfo['can_manage_all_users']);
605
+                $session->set('user-can_manage_all_users', (int) $userInfo['can_manage_all_users']);
606 606
                 $session->set('user-read_only', (int) $userInfo['read_only']);
607 607
                 DB::update(
608 608
                     prefixTable('users'),
@@ -674,10 +674,10 @@  discard block
 block discarded – undo
674 674
         $session->set('user-latest_items_tab', []);
675 675
         $session->set('user-nb_roles', 0);
676 676
         foreach ($session->get('user-latest_items') as $item) {
677
-            if (! empty($item)) {
677
+            if (!empty($item)) {
678 678
                 $dataLastItems = DB::queryFirstRow(
679 679
                     'SELECT id,label,id_tree
680
-                    FROM ' . prefixTable('items') . '
680
+                    FROM ' . prefixTable('items').'
681 681
                     WHERE id=%i',
682 682
                     $item
683 683
                 );
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
                     [
687 687
                         'id' => $item,
688 688
                         'label' => $dataLastItems['label'],
689
-                        'url' => 'index.php?page=items&amp;group=' . $dataLastItems['id_tree'] . '&amp;id=' . $item,
689
+                        'url' => 'index.php?page=items&amp;group='.$dataLastItems['id_tree'].'&amp;id='.$item,
690 690
                     ],
691 691
                     'add'
692 692
                 );
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
         // Get cahce tree info
697 697
         $cacheTreeData = DB::queryFirstRow(
698 698
             'SELECT visible_folders
699
-            FROM ' . prefixTable('cache_tree') . '
699
+            FROM ' . prefixTable('cache_tree').'
700 700
             WHERE user_id=%i',
701 701
             (int) $session->get('user-id')
702 702
         );
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
             && (int) $sessionAdmin !== 1
729 729
         ) {
730 730
             // get all Admin users
731
-            $val = DB::queryfirstrow('SELECT email FROM ' . prefixTable('users') . " WHERE admin = %i and email != ''", 1);
731
+            $val = DB::queryfirstrow('SELECT email FROM '.prefixTable('users')." WHERE admin = %i and email != ''", 1);
732 732
             if (DB::count() > 0) {
733 733
                 // Add email to table
734 734
                 prepareSendingEmail(
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
                             '#tp_time#',
741 741
                         ],
742 742
                         [
743
-                            ' ' . $session->get('user-login') . ' (IP: ' . getClientIpServer() . ')',
743
+                            ' '.$session->get('user-login').' (IP: '.getClientIpServer().')',
744 744
                             date($SETTINGS['date_format'], (int) $session->get('user-last_connection')),
745 745
                             date($SETTINGS['time_format'], (int) $session->get('user-last_connection')),
746 746
                         ],
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 {
888 888
     $rows = DB::query(
889 889
         'SELECT date
890
-        FROM ' . prefixTable('log_system') . "
890
+        FROM ' . prefixTable('log_system')."
891 891
         WHERE field_1 = %s
892 892
         AND type = 'failed_auth'
893 893
         AND label = 'password_is_not_correct'
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
         foreach ($rows as $record) {
902 902
             array_push(
903 903
                 $arrAttempts,
904
-                date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['date'])
904
+                date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['date'])
905 905
             );
906 906
         }
907 907
     }
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
     $ldapConnection
956 956
 ) : bool
957 957
 {
958
-    include_once $SETTINGS['cpassman_dir'] . '/sources/main.functions.php';
958
+    include_once $SETTINGS['cpassman_dir'].'/sources/main.functions.php';
959 959
 
960 960
     if ((int) $userInfoDisabled === 1) {
961 961
         return false;
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
                 $openLdapExtra = new OpenLdapExtra();
1164 1164
                 break;
1165 1165
             default:
1166
-                throw new Exception("Unsupported LDAP type: " . $SETTINGS['ldap_type']);
1166
+                throw new Exception("Unsupported LDAP type: ".$SETTINGS['ldap_type']);
1167 1167
         }
1168 1168
     } catch (Exception $e) {
1169 1169
         return [
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
         // 2- Get user info from AD
1177 1177
         // We want to isolate attribute ldap_user_attribute or mostly samAccountName
1178 1178
         $userADInfos = $ldapConnection->query()
1179
-            ->where((isset($SETTINGS['ldap_user_attribute']) ===true && empty($SETTINGS['ldap_user_attribute']) === false) ? $SETTINGS['ldap_user_attribute'] : 'samaccountname', '=', $username)
1179
+            ->where((isset($SETTINGS['ldap_user_attribute']) === true && empty($SETTINGS['ldap_user_attribute']) === false) ? $SETTINGS['ldap_user_attribute'] : 'samaccountname', '=', $username)
1180 1180
             ->firstOrFail();
1181 1181
 
1182 1182
         // Is user enabled? Only ActiveDirectory
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
         // For OpenLDAP and others, we use attribute dn
1196 1196
         $userAuthAttempt = $ldapConnection->auth()->attempt(
1197 1197
             $SETTINGS['ldap_type'] === 'ActiveDirectory' ?
1198
-                $userADInfos['userprincipalname'][0] :  // refering to https://ldaprecord.com/docs/core/v2/authentication#basic-authentication
1198
+                $userADInfos['userprincipalname'][0] : // refering to https://ldaprecord.com/docs/core/v2/authentication#basic-authentication
1199 1199
                 $userADInfos['dn'],
1200 1200
             $passwordClear
1201 1201
         );
@@ -1212,7 +1212,7 @@  discard block
 block discarded – undo
1212 1212
         $error = $e->getDetailedError();
1213 1213
         return [
1214 1214
             'error' => true,
1215
-            'message' => $lang->get('error')." - ".(isset($error) === true ? $error->getErrorCode()." - ".$error->getErrorMessage(). "<br>".$error->getDiagnosticMessage() : $e),
1215
+            'message' => $lang->get('error')." - ".(isset($error) === true ? $error->getErrorCode()." - ".$error->getErrorMessage()."<br>".$error->getDiagnosticMessage() : $e),
1216 1216
 
1217 1217
         ];
1218 1218
     }
@@ -1277,7 +1277,7 @@  discard block
 block discarded – undo
1277 1277
         // error
1278 1278
         return [
1279 1279
             'error' => true,
1280
-            'message' => "Error: Unsupported LDAP type: " . $SETTINGS['ldap_type'],
1280
+            'message' => "Error: Unsupported LDAP type: ".$SETTINGS['ldap_type'],
1281 1281
         ];
1282 1282
     }
1283 1283
     
@@ -1312,12 +1312,12 @@  discard block
 block discarded – undo
1312 1312
     if (isset($SETTINGS['enable_ad_users_with_ad_groups']) === true && (int) $SETTINGS['enable_ad_users_with_ad_groups'] === 1) {
1313 1313
         // Get user groups from AD
1314 1314
         $user_ad_groups = [];
1315
-        foreach($groups as $group) {
1315
+        foreach ($groups as $group) {
1316 1316
             //print_r($group);
1317 1317
             // get relation role id for AD group
1318 1318
             $role = DB::queryFirstRow(
1319 1319
                 'SELECT lgr.role_id
1320
-                FROM ' . prefixTable('ldap_groups_roles') . ' AS lgr
1320
+                FROM ' . prefixTable('ldap_groups_roles').' AS lgr
1321 1321
                 WHERE lgr.ldap_group_id = %i',
1322 1322
                 $group
1323 1323
             );
@@ -1466,7 +1466,7 @@  discard block
 block discarded – undo
1466 1466
     }
1467 1467
 
1468 1468
     // Now check yubico validity
1469
-    include_once $SETTINGS['cpassman_dir'] . '/includes/libraries/Authentication/Yubico/Yubico.php';
1469
+    include_once $SETTINGS['cpassman_dir'].'/includes/libraries/Authentication/Yubico/Yubico.php';
1470 1470
     $yubi = new Auth_Yubico($yubico_user_id, $yubico_user_key);
1471 1471
     $auth = $yubi->verify($yubico_key);
1472 1472
     //, null, null, null, 60
@@ -1620,7 +1620,7 @@  discard block
 block discarded – undo
1620 1620
             $mfaMessage = $lang->get('ga_flash_qr_and_login');
1621 1621
             // generate new QR
1622 1622
             $new_2fa_qr = $tfa->getQRCodeImageAsDataUri(
1623
-                'Teampass - ' . $username,
1623
+                'Teampass - '.$username,
1624 1624
                 $userInfo['ga']
1625 1625
             );
1626 1626
             // clear temporary code from DB
@@ -1633,7 +1633,7 @@  discard block
 block discarded – undo
1633 1633
                 $userInfo['id']
1634 1634
             );
1635 1635
             $firstTime = [
1636
-                'value' => '<img src="' . $new_2fa_qr . '">',
1636
+                'value' => '<img src="'.$new_2fa_qr.'">',
1637 1637
                 'user_admin' => isset($sessionAdmin) ? (int) $sessionAdmin : '',
1638 1638
                 'initial_url' => isset($sessionUrl) === true ? $sessionUrl : '',
1639 1639
                 'pwd_attempts' => (int) $sessionPwdAttempts,
@@ -1789,7 +1789,7 @@  discard block
 block discarded – undo
1789 1789
         }*/
1790 1790
         return [
1791 1791
             'error' => true,
1792
-            'message' => $duo_error . $lang->get('duo_error_check_config'),
1792
+            'message' => $duo_error.$lang->get('duo_error_check_config'),
1793 1793
             'pwd_attempts' => (int) $sessionPwdAttempts,
1794 1794
             'debug_message' => $e->getMessage(),
1795 1795
             'proceedIdentification' => false,
@@ -1805,7 +1805,7 @@  discard block
 block discarded – undo
1805 1805
         } catch (DuoException $e) {
1806 1806
             return [
1807 1807
                 'error' => true,
1808
-                'message' => $duo_error . $lang->get('duo_error_url'),
1808
+                'message' => $duo_error.$lang->get('duo_error_url'),
1809 1809
                 'pwd_attempts' => (int) $sessionPwdAttempts,
1810 1810
                 'debug_message' => $e->getMessage(),
1811 1811
                 'proceedIdentification' => false,
@@ -1813,7 +1813,7 @@  discard block
 block discarded – undo
1813 1813
         }
1814 1814
         
1815 1815
         // Somethimes Duo return success but fail to return a URL, double check if the URL has been created
1816
-        if (!empty($duo_redirect_url) && isset($duo_redirect_url) && filter_var($duo_redirect_url,FILTER_SANITIZE_URL)) {
1816
+        if (!empty($duo_redirect_url) && isset($duo_redirect_url) && filter_var($duo_redirect_url, FILTER_SANITIZE_URL)) {
1817 1817
             // Since Duo Universal requires a redirect, let's store some info when the user get's back after completing the Duo prompt
1818 1818
             $key = hash('sha256', $duo_state);
1819 1819
             $iv = substr(hash('sha256', $duo_state), 0, 16);
@@ -1841,7 +1841,7 @@  discard block
 block discarded – undo
1841 1841
         } else {
1842 1842
             return [
1843 1843
                 'error' => true,
1844
-                'message' => $duo_error . $lang->get('duo_error_url'),
1844
+                'message' => $duo_error.$lang->get('duo_error_url'),
1845 1845
                 'pwd_attempts' => (int) $sessionPwdAttempts,
1846 1846
                 'proceedIdentification' => false,
1847 1847
             ];
@@ -1862,8 +1862,8 @@  discard block
 block discarded – undo
1862 1862
         // return the response (which should be the user name)
1863 1863
         if ($decoded_token['preferred_username'] === $username) {
1864 1864
             $session->set('user-duo_status', 'COMPLET');
1865
-            $session->set('user-duo_state','');
1866
-            $session->set('user-duo_data','');
1865
+            $session->set('user-duo_state', '');
1866
+            $session->set('user-duo_data', '');
1867 1867
             $session->set('user-login', $username);
1868 1868
 
1869 1869
             return [
@@ -1874,9 +1874,9 @@  discard block
 block discarded – undo
1874 1874
             ];
1875 1875
         } else {
1876 1876
             // Something wrong, username from the original Duo request is different than the one received now
1877
-            $session->set('user-duo_status','');
1878
-            $session->set('user-duo_state','');
1879
-            $session->set('user-duo_data','');
1877
+            $session->set('user-duo_status', '');
1878
+            $session->set('user-duo_state', '');
1879
+            $session->set('user-duo_data', '');
1880 1880
 
1881 1881
             return [
1882 1882
                 'error' => true,
@@ -1887,9 +1887,9 @@  discard block
 block discarded – undo
1887 1887
         }
1888 1888
     }
1889 1889
     // If we are here something wrong
1890
-    $session->set('user-duo_status','');
1891
-    $session->set('user-duo_state','');
1892
-    $session->set('user-duo_data','');
1890
+    $session->set('user-duo_status', '');
1891
+    $session->set('user-duo_state', '');
1892
+    $session->set('user-duo_data', '');
1893 1893
     return [
1894 1894
         'error' => true,
1895 1895
         'message' => $lang->get('duo_login_mismatch'),
@@ -2045,8 +2045,8 @@  discard block
 block discarded – undo
2045 2045
     public function get_user_info($login, $enable_ad_user_auto_creation) {
2046 2046
         $data = DB::queryFirstRow(
2047 2047
             'SELECT u.*, a.value AS api_key
2048
-            FROM ' . prefixTable('users') . ' AS u
2049
-            LEFT JOIN ' . prefixTable('api') . ' AS a ON (u.id = a.user_id)
2048
+            FROM ' . prefixTable('users').' AS u
2049
+            LEFT JOIN ' . prefixTable('api').' AS a ON (u.id = a.user_id)
2050 2050
             WHERE login = %s AND deleted_at IS NULL',
2051 2051
             $login
2052 2052
         );
@@ -2396,15 +2396,15 @@  discard block
 block discarded – undo
2396 2396
 
2397 2397
             if ($ret['error'] !== false) {
2398 2398
                 logEvents($SETTINGS, 'failed_auth', 'bad_duo_mfa', '', stripslashes($username), stripslashes($username));
2399
-                $session->set('user-duo_status','');
2400
-                $session->set('user-duo_state','');
2401
-                $session->set('user-duo_data','');
2399
+                $session->set('user-duo_status', '');
2400
+                $session->set('user-duo_state', '');
2401
+                $session->set('user-duo_data', '');
2402 2402
                 return [
2403 2403
                     'error' => true,
2404 2404
                     'mfaData' => $ret,
2405 2405
                     'mfaQRCodeInfos' => false,
2406 2406
                 ];
2407
-            } else if ($ret['duo_url_ready'] === true){
2407
+            } else if ($ret['duo_url_ready'] === true) {
2408 2408
                 return [
2409 2409
                     'error' => false,
2410 2410
                     'mfaData' => $ret,
Please login to merge, or discard this patch.
sources/main.functions.php 1 patch
Spacing   +148 added lines, -151 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
 // Load config if $SETTINGS not defined
52 52
 if (isset($SETTINGS['cpassman_dir']) === false || empty($SETTINGS['cpassman_dir']) === true) {
53
-    include_once __DIR__ . '/../includes/config/tp.config.php';
53
+    include_once __DIR__.'/../includes/config/tp.config.php';
54 54
 }
55 55
 
56 56
 header('Content-type: text/html; charset=utf-8');
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
  */
220 220
 function trimElement($chaine, string $element): string
221 221
 {
222
-    if (! empty($chaine)) {
222
+    if (!empty($chaine)) {
223 223
         if (is_array($chaine) === true) {
224 224
             $chaine = implode(';', $chaine);
225 225
         }
@@ -267,8 +267,8 @@  discard block
 block discarded – undo
267 267
  */
268 268
 function db_error_handler(array $params): void
269 269
 {
270
-    echo 'Error: ' . $params['error'] . "<br>\n";
271
-    echo 'Query: ' . $params['query'] . "<br>\n";
270
+    echo 'Error: '.$params['error']."<br>\n";
271
+    echo 'Query: '.$params['query']."<br>\n";
272 272
     throw new Exception('Error - Query', 1);
273 273
 }
274 274
 
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
     $globalsVisibleFolders = $session->get('user-accessible_folders');
349 349
     $globalsPersonalVisibleFolders = $session->get('user-personal_visible_folders');
350 350
     // Get list of Folders
351
-    $rows = DB::query('SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i', 0);
351
+    $rows = DB::query('SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i', 0);
352 352
     foreach ($rows as $record) {
353 353
         array_push($groupesVisibles, $record['id']);
354 354
     }
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
     }
368 368
     // Get ID of personal folder
369 369
     $persfld = DB::queryfirstrow(
370
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE title = %s',
370
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE title = %s',
371 371
         $globalsUserId
372 372
     );
373 373
     if (empty($persfld['id']) === false) {
@@ -387,20 +387,20 @@  discard block
 block discarded – undo
387 387
     // get complete list of ROLES
388 388
     $tmp = explode(';', $idFonctions);
389 389
     $rows = DB::query(
390
-        'SELECT * FROM ' . prefixTable('roles_title') . '
390
+        'SELECT * FROM '.prefixTable('roles_title').'
391 391
         ORDER BY title ASC'
392 392
     );
393 393
     foreach ($rows as $record) {
394
-        if (! empty($record['id']) && ! in_array($record['id'], $tmp)) {
394
+        if (!empty($record['id']) && !in_array($record['id'], $tmp)) {
395 395
             array_push($tmp, $record['id']);
396 396
         }
397 397
     }
398 398
     $session->set('user-roles', implode(';', $tmp));
399 399
     $session->set('user-admin', 1);
400 400
     // Check if admin has created Folders and Roles
401
-    DB::query('SELECT * FROM ' . prefixTable('nested_tree') . '');
401
+    DB::query('SELECT * FROM '.prefixTable('nested_tree').'');
402 402
     $session->set('user-nb_folders', DB::count());
403
-    DB::query('SELECT * FROM ' . prefixTable('roles_title'));
403
+    DB::query('SELECT * FROM '.prefixTable('roles_title'));
404 404
     $session->set('user-nb_roles', DB::count());
405 405
 
406 406
     return true;
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
     // Does this user is allowed to see other items
484 484
     $inc = 0;
485 485
     $rows = DB::query(
486
-        'SELECT id, id_tree FROM ' . prefixTable('items') . '
486
+        'SELECT id, id_tree FROM '.prefixTable('items').'
487 487
             WHERE restricted_to LIKE %ss AND inactif = %s'.
488 488
             (count($allowedFolders) > 0 ? ' AND id_tree NOT IN ('.implode(',', $allowedFolders).')' : ''),
489 489
         $globalsUserId,
@@ -500,8 +500,8 @@  discard block
 block discarded – undo
500 500
     // Check for the users roles if some specific rights exist on items
501 501
     $rows = DB::query(
502 502
         'SELECT i.id_tree, r.item_id
503
-        FROM ' . prefixTable('items') . ' as i
504
-        INNER JOIN ' . prefixTable('restriction_to_roles') . ' as r ON (r.item_id=i.id)
503
+        FROM ' . prefixTable('items').' as i
504
+        INNER JOIN ' . prefixTable('restriction_to_roles').' as r ON (r.item_id=i.id)
505 505
         WHERE i.id_tree <> "" '.
506 506
         (count($userRoles) > 0 ? 'AND r.role_id IN %li ' : '').
507 507
         'ORDER BY i.id_tree ASC',
@@ -555,16 +555,16 @@  discard block
 block discarded – undo
555 555
         ), SORT_NUMERIC)
556 556
     );
557 557
     // Folders and Roles numbers
558
-    DB::queryfirstrow('SELECT id FROM ' . prefixTable('nested_tree') . '');
558
+    DB::queryfirstrow('SELECT id FROM '.prefixTable('nested_tree').'');
559 559
     $session->set('user-nb_folders', DB::count());
560
-    DB::queryfirstrow('SELECT id FROM ' . prefixTable('roles_title'));
560
+    DB::queryfirstrow('SELECT id FROM '.prefixTable('roles_title'));
561 561
     $session->set('user-nb_roles', DB::count());
562 562
     // check if change proposals on User's items
563 563
     if (isset($SETTINGS['enable_suggestion']) === true && (int) $SETTINGS['enable_suggestion'] === 1) {
564 564
         $countNewItems = DB::query(
565 565
             'SELECT COUNT(*)
566
-            FROM ' . prefixTable('items_change') . ' AS c
567
-            LEFT JOIN ' . prefixTable('log_items') . ' AS i ON (c.item_id = i.id_item)
566
+            FROM ' . prefixTable('items_change').' AS c
567
+            LEFT JOIN ' . prefixTable('log_items').' AS i ON (c.item_id = i.id_item)
568 568
             WHERE i.action = %s AND i.id_user = %i',
569 569
             'at_creation',
570 570
             $globalsUserId
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 {
592 592
     $rows = DB::query(
593 593
         'SELECT *
594
-        FROM ' . prefixTable('roles_values') . '
594
+        FROM ' . prefixTable('roles_values').'
595 595
         WHERE type IN %ls'.(count($userRoles) > 0 ? ' AND role_id IN %li' : ''),
596 596
         ['W', 'ND', 'NE', 'NDNE', 'R'],
597 597
         $userRoles,
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
     ) {
659 659
         $persoFld = DB::queryfirstrow(
660 660
             'SELECT id
661
-            FROM ' . prefixTable('nested_tree') . '
661
+            FROM ' . prefixTable('nested_tree').'
662 662
             WHERE title = %s AND personal_folder = %i'.
663 663
             (count($allowedFolders) > 0 ? ' AND id NOT IN ('.implode(',', $allowedFolders).')' : ''),
664 664
             $globalsUserId,
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
     }
692 692
     $persoFlds = DB::query(
693 693
         'SELECT id
694
-        FROM ' . prefixTable('nested_tree') . '
694
+        FROM ' . prefixTable('nested_tree').'
695 695
         WHERE %l',
696 696
         $where
697 697
     );
@@ -759,12 +759,12 @@  discard block
 block discarded – undo
759 759
     //Load Tree
760 760
     $tree = new NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title');
761 761
     // truncate table
762
-    DB::query('TRUNCATE TABLE ' . prefixTable('cache'));
762
+    DB::query('TRUNCATE TABLE '.prefixTable('cache'));
763 763
     // reload date
764 764
     $rows = DB::query(
765 765
         'SELECT *
766
-        FROM ' . prefixTable('items') . ' as i
767
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
766
+        FROM ' . prefixTable('items').' as i
767
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
768 768
         AND l.action = %s
769 769
         AND i.inactif = %i',
770 770
         'at_creation',
@@ -776,18 +776,18 @@  discard block
 block discarded – undo
776 776
             $tags = '';
777 777
             $itemTags = DB::query(
778 778
                 'SELECT tag
779
-                FROM ' . prefixTable('tags') . '
779
+                FROM ' . prefixTable('tags').'
780 780
                 WHERE item_id = %i AND tag != ""',
781 781
                 $record['id']
782 782
             );
783 783
             foreach ($itemTags as $itemTag) {
784
-                $tags .= $itemTag['tag'] . ' ';
784
+                $tags .= $itemTag['tag'].' ';
785 785
             }
786 786
 
787 787
             // Get renewal period
788 788
             $resNT = DB::queryfirstrow(
789 789
                 'SELECT renewal_period
790
-                FROM ' . prefixTable('nested_tree') . '
790
+                FROM ' . prefixTable('nested_tree').'
791 791
                 WHERE id = %i',
792 792
                 $record['id_tree']
793 793
             );
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
                     // Is this a User id?
801 801
                     $user = DB::queryfirstrow(
802 802
                         'SELECT id, login
803
-                        FROM ' . prefixTable('users') . '
803
+                        FROM ' . prefixTable('users').'
804 804
                         WHERE id = %i',
805 805
                         $elem->title
806 806
                     );
@@ -818,11 +818,11 @@  discard block
 block discarded – undo
818 818
                     'id' => $record['id'],
819 819
                     'label' => $record['label'],
820 820
                     'description' => $record['description'] ?? '',
821
-                    'url' => isset($record['url']) && ! empty($record['url']) ? $record['url'] : '0',
821
+                    'url' => isset($record['url']) && !empty($record['url']) ? $record['url'] : '0',
822 822
                     'tags' => $tags,
823 823
                     'id_tree' => $record['id_tree'],
824 824
                     'perso' => $record['perso'],
825
-                    'restricted_to' => isset($record['restricted_to']) && ! empty($record['restricted_to']) ? $record['restricted_to'] : '0',
825
+                    'restricted_to' => isset($record['restricted_to']) && !empty($record['restricted_to']) ? $record['restricted_to'] : '0',
826 826
                     'login' => $record['login'] ?? '',
827 827
                     'folder' => implode(' > ', $folder),
828 828
                     'author' => $record['id_user'],
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
     // get new value from db
852 852
     $data = DB::queryfirstrow(
853 853
         'SELECT label, description, id_tree, perso, restricted_to, login, url
854
-        FROM ' . prefixTable('items') . '
854
+        FROM ' . prefixTable('items').'
855 855
         WHERE id=%i',
856 856
         $ident
857 857
     );
@@ -859,12 +859,12 @@  discard block
 block discarded – undo
859 859
     $tags = '';
860 860
     $itemTags = DB::query(
861 861
         'SELECT tag
862
-            FROM ' . prefixTable('tags') . '
862
+            FROM ' . prefixTable('tags').'
863 863
             WHERE item_id = %i AND tag != ""',
864 864
         $ident
865 865
     );
866 866
     foreach ($itemTags as $itemTag) {
867
-        $tags .= $itemTag['tag'] . ' ';
867
+        $tags .= $itemTag['tag'].' ';
868 868
     }
869 869
     // form id_tree to full foldername
870 870
     $folder = [];
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
             // Is this a User id?
876 876
             $user = DB::queryfirstrow(
877 877
                 'SELECT id, login
878
-                FROM ' . prefixTable('users') . '
878
+                FROM ' . prefixTable('users').'
879 879
                 WHERE id = %i',
880 880
                 $elem->title
881 881
             );
@@ -893,10 +893,10 @@  discard block
 block discarded – undo
893 893
             'label' => $data['label'],
894 894
             'description' => $data['description'],
895 895
             'tags' => $tags,
896
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
896
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
897 897
             'id_tree' => $data['id_tree'],
898 898
             'perso' => $data['perso'],
899
-            'restricted_to' => isset($data['restricted_to']) && ! empty($data['restricted_to']) ? $data['restricted_to'] : '0',
899
+            'restricted_to' => isset($data['restricted_to']) && !empty($data['restricted_to']) ? $data['restricted_to'] : '0',
900 900
             'login' => $data['login'] ?? '',
901 901
             'folder' => implode(' » ', $folder),
902 902
             'author' => $session->get('user-id'),
@@ -926,8 +926,8 @@  discard block
 block discarded – undo
926 926
     // get new value from db
927 927
     $data = DB::queryFirstRow(
928 928
         'SELECT i.label, i.description, i.id_tree as id_tree, i.perso, i.restricted_to, i.id, i.login, i.url, l.date
929
-        FROM ' . prefixTable('items') . ' as i
930
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
929
+        FROM ' . prefixTable('items').' as i
930
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
931 931
         WHERE i.id = %i
932 932
         AND l.action = %s',
933 933
         $ident,
@@ -937,12 +937,12 @@  discard block
 block discarded – undo
937 937
     $tags = '';
938 938
     $itemTags = DB::query(
939 939
         'SELECT tag
940
-            FROM ' . prefixTable('tags') . '
940
+            FROM ' . prefixTable('tags').'
941 941
             WHERE item_id = %i AND tag != ""',
942 942
         $ident
943 943
     );
944 944
     foreach ($itemTags as $itemTag) {
945
-        $tags .= $itemTag['tag'] . ' ';
945
+        $tags .= $itemTag['tag'].' ';
946 946
     }
947 947
     // form id_tree to full foldername
948 948
     $folder = [];
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
             // Is this a User id?
954 954
             $user = DB::queryfirstrow(
955 955
                 'SELECT id, login
956
-                FROM ' . prefixTable('users') . '
956
+                FROM ' . prefixTable('users').'
957 957
                 WHERE id = %i',
958 958
                 $elem->title
959 959
             );
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
             'label' => $data['label'],
973 973
             'description' => $data['description'],
974 974
             'tags' => isset($tags) && empty($tags) === false ? $tags : 'None',
975
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
975
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
976 976
             'id_tree' => $data['id_tree'],
977 977
             'perso' => isset($data['perso']) && empty($data['perso']) === false && $data['perso'] !== 'None' ? $data['perso'] : '0',
978 978
             'restricted_to' => isset($data['restricted_to']) && empty($data['restricted_to']) === false ? $data['restricted_to'] : '0',
@@ -994,52 +994,52 @@  discard block
 block discarded – undo
994 994
 function getStatisticsData(array $SETTINGS): array
995 995
 {
996 996
     DB::query(
997
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
997
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
998 998
         0
999 999
     );
1000 1000
     $counter_folders = DB::count();
1001 1001
     DB::query(
1002
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
1002
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
1003 1003
         1
1004 1004
     );
1005 1005
     $counter_folders_perso = DB::count();
1006 1006
     DB::query(
1007
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
1007
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
1008 1008
         0
1009 1009
     );
1010 1010
     $counter_items = DB::count();
1011 1011
         DB::query(
1012
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
1012
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
1013 1013
         1
1014 1014
     );
1015 1015
     $counter_items_perso = DB::count();
1016 1016
         DB::query(
1017
-        'SELECT id FROM ' . prefixTable('users') . ''
1017
+        'SELECT id FROM '.prefixTable('users').''
1018 1018
     );
1019 1019
     $counter_users = DB::count();
1020 1020
         DB::query(
1021
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE admin = %i',
1021
+        'SELECT id FROM '.prefixTable('users').' WHERE admin = %i',
1022 1022
         1
1023 1023
     );
1024 1024
     $admins = DB::count();
1025 1025
     DB::query(
1026
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE gestionnaire = %i',
1026
+        'SELECT id FROM '.prefixTable('users').' WHERE gestionnaire = %i',
1027 1027
         1
1028 1028
     );
1029 1029
     $managers = DB::count();
1030 1030
     DB::query(
1031
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE read_only = %i',
1031
+        'SELECT id FROM '.prefixTable('users').' WHERE read_only = %i',
1032 1032
         1
1033 1033
     );
1034 1034
     $readOnly = DB::count();
1035 1035
     // list the languages
1036 1036
     $usedLang = [];
1037 1037
     $tp_languages = DB::query(
1038
-        'SELECT name FROM ' . prefixTable('languages')
1038
+        'SELECT name FROM '.prefixTable('languages')
1039 1039
     );
1040 1040
     foreach ($tp_languages as $tp_language) {
1041 1041
         DB::query(
1042
-            'SELECT * FROM ' . prefixTable('users') . ' WHERE user_language = %s',
1042
+            'SELECT * FROM '.prefixTable('users').' WHERE user_language = %s',
1043 1043
             $tp_language['name']
1044 1044
         );
1045 1045
         $usedLang[$tp_language['name']] = round((DB::count() * 100 / $counter_users), 0);
@@ -1048,12 +1048,12 @@  discard block
 block discarded – undo
1048 1048
     // get list of ips
1049 1049
     $usedIp = [];
1050 1050
     $tp_ips = DB::query(
1051
-        'SELECT user_ip FROM ' . prefixTable('users')
1051
+        'SELECT user_ip FROM '.prefixTable('users')
1052 1052
     );
1053 1053
     foreach ($tp_ips as $ip) {
1054 1054
         if (array_key_exists($ip['user_ip'], $usedIp)) {
1055 1055
             $usedIp[$ip['user_ip']] += $usedIp[$ip['user_ip']];
1056
-        } elseif (! empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
1056
+        } elseif (!empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
1057 1057
             $usedIp[$ip['user_ip']] = 1;
1058 1058
         }
1059 1059
     }
@@ -1206,7 +1206,7 @@  discard block
 block discarded – undo
1206 1206
 {
1207 1207
     // Load PHPMailer
1208 1208
     $mail = new PHPMailer(true);
1209
-    $languageDir = $SETTINGS['cpassman_dir'] . '/vendor/phpmailer/phpmailer/language/';
1209
+    $languageDir = $SETTINGS['cpassman_dir'].'/vendor/phpmailer/phpmailer/language/';
1210 1210
 
1211 1211
     try {
1212 1212
         // Set language and SMTPDebug
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
         <table width="600" cellpadding="0" cellspacing="0" border="0" class="container" bgcolor="#ffffff" style="border-spacing: 0; border-bottom: 1px solid #e0e0e0; box-shadow: 0 0 3px #ddd; color: #434343; font-family: Helvetica, Verdana, sans-serif;">
1298 1298
         <tr><td class="container-padding" bgcolor="#ffffff" style="border-collapse: collapse; border-left: 1px solid #e0e0e0; background-color: #ffffff; padding-left: 30px; padding-right: 30px;">
1299 1299
         <br><div style="float:right;">' .
1300
-        $textMail .
1300
+        $textMail.
1301 1301
         '<br><br></td></tr></table>
1302 1302
     </td></tr></table>
1303 1303
     <br></body></html>';
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
  */
1311 1311
 function generateKey(): string
1312 1312
 {
1313
-    return substr(md5(rand() . rand()), 0, 15);
1313
+    return substr(md5(rand().rand()), 0, 15);
1314 1314
 }
1315 1315
 
1316 1316
 /**
@@ -1388,7 +1388,7 @@  discard block
 block discarded – undo
1388 1388
 {
1389 1389
     array_walk_recursive(
1390 1390
         $array,
1391
-        static function (&$item): void {
1391
+        static function(&$item): void {
1392 1392
             if (mb_detect_encoding((string) $item, 'utf-8', true) === false) {
1393 1393
                 $item = mb_convert_encoding($item, 'ISO-8859-1', 'UTF-8');
1394 1394
             }
@@ -1481,7 +1481,7 @@  discard block
 block discarded – undo
1481 1481
  */
1482 1482
 function prefixTable(string $table): string
1483 1483
 {
1484
-    $safeTable = htmlspecialchars(DB_PREFIX . $table);
1484
+    $safeTable = htmlspecialchars(DB_PREFIX.$table);
1485 1485
     if (empty($safeTable) === false) {
1486 1486
         // sanitize string
1487 1487
         return $safeTable;
@@ -1545,7 +1545,7 @@  discard block
 block discarded – undo
1545 1545
 function send_syslog($message, $host, $port, $component = 'teampass'): void
1546 1546
 {
1547 1547
     $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
1548
-    $syslog_message = '<123>' . date('M d H:i:s ') . $component . ': ' . $message;
1548
+    $syslog_message = '<123>'.date('M d H:i:s ').$component.': '.$message;
1549 1549
     socket_sendto($sock, (string) $syslog_message, strlen($syslog_message), 0, (string) $host, (int) $port);
1550 1550
     socket_close($sock);
1551 1551
 }
@@ -1592,14 +1592,14 @@  discard block
 block discarded – undo
1592 1592
     if (isset($SETTINGS['syslog_enable']) === true && (int) $SETTINGS['syslog_enable'] === 1) {
1593 1593
         if ($type === 'user_mngt') {
1594 1594
             send_syslog(
1595
-                'action=' . str_replace('at_', '', $label) . ' attribute=user user=' . $who . ' userid="' . $login . '" change="' . $field_1 . '" ',
1595
+                'action='.str_replace('at_', '', $label).' attribute=user user='.$who.' userid="'.$login.'" change="'.$field_1.'" ',
1596 1596
                 $SETTINGS['syslog_host'],
1597 1597
                 $SETTINGS['syslog_port'],
1598 1598
                 'teampass'
1599 1599
             );
1600 1600
         } else {
1601 1601
             send_syslog(
1602
-                'action=' . $type . ' attribute=' . $label . ' user=' . $who . ' userid="' . $login . '" ',
1602
+                'action='.$type.' attribute='.$label.' user='.$who.' userid="'.$login.'" ',
1603 1603
                 $SETTINGS['syslog_host'],
1604 1604
                 $SETTINGS['syslog_port'],
1605 1605
                 'teampass'
@@ -1673,7 +1673,7 @@  discard block
 block discarded – undo
1673 1673
         if (empty($item_label) === true) {
1674 1674
             $dataItem = DB::queryfirstrow(
1675 1675
                 'SELECT id, id_tree, label
1676
-                FROM ' . prefixTable('items') . '
1676
+                FROM ' . prefixTable('items').'
1677 1677
                 WHERE id = %i',
1678 1678
                 $item_id
1679 1679
             );
@@ -1681,11 +1681,11 @@  discard block
 block discarded – undo
1681 1681
         }
1682 1682
 
1683 1683
         send_syslog(
1684
-            'action=' . str_replace('at_', '', $action) .
1685
-                ' attribute=' . str_replace('at_', '', $attribute[0]) .
1686
-                ' itemno=' . $item_id .
1687
-                ' user=' . is_null($login) === true ? '' : addslashes((string) $login) .
1688
-                ' itemname="' . addslashes($item_label) . '"',
1684
+            'action='.str_replace('at_', '', $action).
1685
+                ' attribute='.str_replace('at_', '', $attribute[0]).
1686
+                ' itemno='.$item_id.
1687
+                ' user='.is_null($login) === true ? '' : addslashes((string) $login).
1688
+                ' itemname="'.addslashes($item_label).'"',
1689 1689
             $SETTINGS['syslog_host'],
1690 1690
             $SETTINGS['syslog_port'],
1691 1691
             'teampass'
@@ -1717,8 +1717,8 @@  discard block
 block discarded – undo
1717 1717
     $notification = DB::queryOneColumn(
1718 1718
         'email',
1719 1719
         'SELECT *
1720
-        FROM ' . prefixTable('notification') . ' AS n
1721
-        INNER JOIN ' . prefixTable('users') . ' AS u ON (n.user_id = u.id)
1720
+        FROM ' . prefixTable('notification').' AS n
1721
+        INNER JOIN ' . prefixTable('users').' AS u ON (n.user_id = u.id)
1722 1722
         WHERE n.item_id = %i AND n.user_id != %i',
1723 1723
         $item_id,
1724 1724
         $globalsUserId
@@ -1729,7 +1729,7 @@  discard block
 block discarded – undo
1729 1729
         // Get list of changes
1730 1730
         $htmlChanges = '<ul>';
1731 1731
         foreach ($changes as $change) {
1732
-            $htmlChanges .= '<li>' . $change . '</li>';
1732
+            $htmlChanges .= '<li>'.$change.'</li>';
1733 1733
         }
1734 1734
         $htmlChanges .= '</ul>';
1735 1735
         // send email
@@ -1766,15 +1766,15 @@  discard block
 block discarded – undo
1766 1766
     $path = '';
1767 1767
     foreach ($arbo as $elem) {
1768 1768
         if (empty($path) === true) {
1769
-            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES) . ' ';
1769
+            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES).' ';
1770 1770
         } else {
1771
-            $path .= '&#8594; ' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1771
+            $path .= '&#8594; '.htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1772 1772
         }
1773 1773
     }
1774 1774
 
1775 1775
     // Build text to show user
1776 1776
     if (empty($label) === false) {
1777
-        return empty($path) === true ? addslashes($label) : addslashes($label) . ' (' . $path . ')';
1777
+        return empty($path) === true ? addslashes($label) : addslashes($label).' ('.$path.')';
1778 1778
     }
1779 1779
     return empty($path) === true ? '' : $path;
1780 1780
 }
@@ -1831,7 +1831,7 @@  discard block
 block discarded – undo
1831 1831
  */
1832 1832
 function handleConfigFile($action, $SETTINGS, $field = null, $value = null)
1833 1833
 {
1834
-    $tp_config_file = $SETTINGS['cpassman_dir'] . '/includes/config/tp.config.php';
1834
+    $tp_config_file = $SETTINGS['cpassman_dir'].'/includes/config/tp.config.php';
1835 1835
 
1836 1836
     // Load class DB
1837 1837
     loadClasses('DB');
@@ -1839,8 +1839,8 @@  discard block
 block discarded – undo
1839 1839
     if (file_exists($tp_config_file) === false || $action === 'rebuild') {
1840 1840
         // perform a copy
1841 1841
         if (file_exists($tp_config_file)) {
1842
-            if (! copy($tp_config_file, $tp_config_file . '.' . date('Y_m_d_His', time()))) {
1843
-                return "ERROR: Could not copy file '" . $tp_config_file . "'";
1842
+            if (!copy($tp_config_file, $tp_config_file.'.'.date('Y_m_d_His', time()))) {
1843
+                return "ERROR: Could not copy file '".$tp_config_file."'";
1844 1844
             }
1845 1845
         }
1846 1846
 
@@ -1850,11 +1850,11 @@  discard block
 block discarded – undo
1850 1850
         $data[1] = "global \$SETTINGS;\n";
1851 1851
         $data[2] = "\$SETTINGS = array (\n";
1852 1852
         $rows = DB::query(
1853
-            'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s',
1853
+            'SELECT * FROM '.prefixTable('misc').' WHERE type=%s',
1854 1854
             'admin'
1855 1855
         );
1856 1856
         foreach ($rows as $record) {
1857
-            array_push($data, "    '" . $record['intitule'] . "' => '" . htmlspecialchars_decode($record['valeur'], ENT_COMPAT) . "',\n");
1857
+            array_push($data, "    '".$record['intitule']."' => '".htmlspecialchars_decode($record['valeur'], ENT_COMPAT)."',\n");
1858 1858
         }
1859 1859
         array_push($data, ");\n");
1860 1860
         $data = array_unique($data);
@@ -1868,15 +1868,15 @@  discard block
 block discarded – undo
1868 1868
                 break;
1869 1869
             }
1870 1870
 
1871
-            if (stristr($line, "'" . $field . "' => '")) {
1872
-                $data[$inc] = "    '" . $field . "' => '" . htmlspecialchars_decode($value ?? '', ENT_COMPAT) . "',\n";
1871
+            if (stristr($line, "'".$field."' => '")) {
1872
+                $data[$inc] = "    '".$field."' => '".htmlspecialchars_decode($value ?? '', ENT_COMPAT)."',\n";
1873 1873
                 $bFound = true;
1874 1874
                 break;
1875 1875
             }
1876 1876
             ++$inc;
1877 1877
         }
1878 1878
         if ($bFound === false) {
1879
-            $data[$inc] = "    '" . $field . "' => '" . htmlspecialchars_decode($value ?? '', ENT_COMPAT). "',\n);\n";
1879
+            $data[$inc] = "    '".$field."' => '".htmlspecialchars_decode($value ?? '', ENT_COMPAT)."',\n);\n";
1880 1880
         }
1881 1881
     }
1882 1882
 
@@ -1906,7 +1906,7 @@  discard block
 block discarded – undo
1906 1906
 {
1907 1907
     global $SETTINGS;
1908 1908
     /* LOAD CPASSMAN SETTINGS */
1909
-    if (! isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
1909
+    if (!isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
1910 1910
         $SETTINGS = [];
1911 1911
         $SETTINGS['duplicate_folder'] = 0;
1912 1912
         //by default, this is set to 0;
@@ -1916,7 +1916,7 @@  discard block
 block discarded – undo
1916 1916
         //by default, this value is set to 5;
1917 1917
         $settings = [];
1918 1918
         $rows = DB::query(
1919
-            'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s_type OR type=%s_type2',
1919
+            'SELECT * FROM '.prefixTable('misc').' WHERE type=%s_type OR type=%s_type2',
1920 1920
             [
1921 1921
                 'type' => 'admin',
1922 1922
                 'type2' => 'settings',
@@ -1948,7 +1948,7 @@  discard block
 block discarded – undo
1948 1948
     $source_cf = [];
1949 1949
     $rows = DB::QUERY(
1950 1950
         'SELECT id_category
1951
-            FROM ' . prefixTable('categories_folders') . '
1951
+            FROM ' . prefixTable('categories_folders').'
1952 1952
             WHERE id_folder = %i',
1953 1953
         $source_id
1954 1954
     );
@@ -1959,7 +1959,7 @@  discard block
 block discarded – undo
1959 1959
     $target_cf = [];
1960 1960
     $rows = DB::QUERY(
1961 1961
         'SELECT id_category
1962
-            FROM ' . prefixTable('categories_folders') . '
1962
+            FROM ' . prefixTable('categories_folders').'
1963 1963
             WHERE id_folder = %i',
1964 1964
         $target_id
1965 1965
     );
@@ -2177,7 +2177,7 @@  discard block
 block discarded – undo
2177 2177
     int  $dirPerm = 0755
2178 2178
 ) {
2179 2179
     // Check if the path exists
2180
-    if (! file_exists($path)) {
2180
+    if (!file_exists($path)) {
2181 2181
         return false;
2182 2182
     }
2183 2183
 
@@ -2230,7 +2230,7 @@  discard block
 block discarded – undo
2230 2230
     // Load item data
2231 2231
     $data = DB::queryFirstRow(
2232 2232
         'SELECT id_tree
2233
-        FROM ' . prefixTable('items') . '
2233
+        FROM ' . prefixTable('items').'
2234 2234
         WHERE id = %i',
2235 2235
         $item_id
2236 2236
     );
@@ -2293,7 +2293,7 @@  discard block
 block discarded – undo
2293 2293
         }
2294 2294
         $host .= substr(explode(".", $email[1])[0], -1, 1);
2295 2295
     }
2296
-    $email = $name . "@" . $host . "." . explode(".", $email[1])[1];
2296
+    $email = $name."@".$host.".".explode(".", $email[1])[1];
2297 2297
     return $email;
2298 2298
 }
2299 2299
 
@@ -2316,7 +2316,7 @@  discard block
 block discarded – undo
2316 2316
     
2317 2317
     // Insert log in DB
2318 2318
     return DB::query(
2319
-        'SELECT ' . $fields . '
2319
+        'SELECT '.$fields.'
2320 2320
         FROM ' . prefixTable($table)
2321 2321
     );
2322 2322
 }
@@ -2331,11 +2331,11 @@  discard block
 block discarded – undo
2331 2331
 function formatSizeUnits(int $bytes): string
2332 2332
 {
2333 2333
     if ($bytes >= 1073741824) {
2334
-        $bytes = number_format($bytes / 1073741824, 2) . ' GB';
2334
+        $bytes = number_format($bytes / 1073741824, 2).' GB';
2335 2335
     } elseif ($bytes >= 1048576) {
2336
-        $bytes = number_format($bytes / 1048576, 2) . ' MB';
2336
+        $bytes = number_format($bytes / 1048576, 2).' MB';
2337 2337
     } elseif ($bytes >= 1024) {
2338
-        $bytes = number_format($bytes / 1024, 2) . ' KB';
2338
+        $bytes = number_format($bytes / 1024, 2).' KB';
2339 2339
     } elseif ($bytes > 1) {
2340 2340
         $bytes .= ' bytes';
2341 2341
     } elseif ($bytes === 1) {
@@ -2580,14 +2580,14 @@  discard block
 block discarded – undo
2580 2580
 
2581 2581
         // Encrypt the file content
2582 2582
         $plaintext = file_get_contents(
2583
-            filter_var($fileInPath . '/' . $fileInName, FILTER_SANITIZE_URL)
2583
+            filter_var($fileInPath.'/'.$fileInName, FILTER_SANITIZE_URL)
2584 2584
         );
2585 2585
         $ciphertext = $cipher->encrypt($plaintext);
2586 2586
         // Save new file
2587 2587
         $hash = md5($plaintext);
2588
-        $fileOut = $fileInPath . '/' . TP_FILE_PREFIX . $hash;
2588
+        $fileOut = $fileInPath.'/'.TP_FILE_PREFIX.$hash;
2589 2589
         file_put_contents($fileOut, $ciphertext);
2590
-        unlink($fileInPath . '/' . $fileInName);
2590
+        unlink($fileInPath.'/'.$fileInName);
2591 2591
         return [
2592 2592
             'fileHash' => base64_encode($hash),
2593 2593
             'objectKey' => base64_encode($objectKey),
@@ -2608,7 +2608,7 @@  discard block
 block discarded – undo
2608 2608
  */
2609 2609
 function decryptFile(string $fileName, string $filePath, string $key): string
2610 2610
 {
2611
-    if (! defined('FILE_BUFFER_SIZE')) {
2611
+    if (!defined('FILE_BUFFER_SIZE')) {
2612 2612
         define('FILE_BUFFER_SIZE', 128 * 1024);
2613 2613
     }
2614 2614
     
@@ -2624,7 +2624,7 @@  discard block
 block discarded – undo
2624 2624
         $cipher->enableContinuousBuffer();
2625 2625
         $cipher->disablePadding();
2626 2626
         // Get file content
2627
-        $ciphertext = file_get_contents($filePath . '/' . TP_FILE_PREFIX . $fileName);
2627
+        $ciphertext = file_get_contents($filePath.'/'.TP_FILE_PREFIX.$fileName);
2628 2628
         // Decrypt file content and return
2629 2629
         return base64_encode($cipher->decrypt($ciphertext));
2630 2630
     /*} else {
@@ -2706,8 +2706,8 @@  discard block
 block discarded – undo
2706 2706
         // Only create the sharekey for a user
2707 2707
         $user = DB::queryFirstRow(
2708 2708
             'SELECT public_key
2709
-            FROM ' . prefixTable('users') . '
2710
-            WHERE id = ' . (int) $session->get('user-id') . '
2709
+            FROM ' . prefixTable('users').'
2710
+            WHERE id = ' . (int) $session->get('user-id').'
2711 2711
             AND public_key != ""'
2712 2712
         );
2713 2713
 
@@ -2743,10 +2743,9 @@  discard block
 block discarded – undo
2743 2743
         //DB::debugmode(true);
2744 2744
         $users = DB::query(
2745 2745
             'SELECT id, public_key
2746
-            FROM ' . prefixTable('users') . '
2746
+            FROM ' . prefixTable('users').'
2747 2747
             WHERE ' . ($onlyForUser === true ? 
2748
-                'id IN ("' . TP_USER_ID . '","' . $session->get('user-id') . '") ' : 
2749
-                'id NOT IN ("' . OTV_USER_ID . '","' . SSH_USER_ID . '","' . API_USER_ID . '") ') . '
2748
+                'id IN ("'.TP_USER_ID.'","'.$session->get('user-id').'") ' : 'id NOT IN ("'.OTV_USER_ID.'","'.SSH_USER_ID.'","'.API_USER_ID.'") ').'
2750 2749
             AND public_key != ""'
2751 2750
         );
2752 2751
         //DB::debugmode(false);
@@ -2793,7 +2792,7 @@  discard block
 block discarded – undo
2793 2792
 function isBase64(string $str): bool
2794 2793
 {
2795 2794
     $str = (string) trim($str);
2796
-    if (! isset($str[0])) {
2795
+    if (!isset($str[0])) {
2797 2796
         return false;
2798 2797
     }
2799 2798
 
@@ -2866,7 +2865,7 @@  discard block
 block discarded – undo
2866 2865
         $connection->connect();
2867 2866
     } catch (\LdapRecord\Auth\BindException $e) {
2868 2867
         $error = $e->getDetailedError();
2869
-        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage(). '<br>'.$error->getDiagnosticMessage();
2868
+        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage().'<br>'.$error->getDiagnosticMessage();
2870 2869
         return false;
2871 2870
     }
2872 2871
 
@@ -2879,7 +2878,7 @@  discard block
 block discarded – undo
2879 2878
         }
2880 2879
     } catch (\LdapRecord\Auth\BindException $e) {
2881 2880
         $error = $e->getDetailedError();
2882
-        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage(). '<br>'.$error->getDiagnosticMessage();
2881
+        echo 'Error : '.$error->getErrorCode().' - '.$error->getErrorMessage().'<br>'.$error->getDiagnosticMessage();
2883 2882
         return false;
2884 2883
     }
2885 2884
 
@@ -2903,7 +2902,7 @@  discard block
 block discarded – undo
2903 2902
     // expect if personal item
2904 2903
     DB::delete(
2905 2904
         prefixTable('sharekeys_items'),
2906
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
2905
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
2907 2906
         $userId
2908 2907
     );
2909 2908
     // Remove all item sharekeys files
@@ -2911,8 +2910,8 @@  discard block
 block discarded – undo
2911 2910
         prefixTable('sharekeys_files'),
2912 2911
         'user_id = %i AND object_id NOT IN (
2913 2912
             SELECT f.id 
2914
-            FROM ' . prefixTable('items') . ' AS i 
2915
-            INNER JOIN ' . prefixTable('files') . ' AS f ON f.id_item = i.id
2913
+            FROM ' . prefixTable('items').' AS i 
2914
+            INNER JOIN ' . prefixTable('files').' AS f ON f.id_item = i.id
2916 2915
             WHERE i.perso = 1
2917 2916
         )',
2918 2917
         $userId
@@ -2922,8 +2921,8 @@  discard block
 block discarded – undo
2922 2921
         prefixTable('sharekeys_fields'),
2923 2922
         'user_id = %i AND object_id NOT IN (
2924 2923
             SELECT c.id 
2925
-            FROM ' . prefixTable('items') . ' AS i 
2926
-            INNER JOIN ' . prefixTable('categories_items') . ' AS c ON c.item_id = i.id
2924
+            FROM ' . prefixTable('items').' AS i 
2925
+            INNER JOIN ' . prefixTable('categories_items').' AS c ON c.item_id = i.id
2927 2926
             WHERE i.perso = 1
2928 2927
         )',
2929 2928
         $userId
@@ -2931,13 +2930,13 @@  discard block
 block discarded – undo
2931 2930
     // Remove all item sharekeys logs
2932 2931
     DB::delete(
2933 2932
         prefixTable('sharekeys_logs'),
2934
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
2933
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
2935 2934
         $userId
2936 2935
     );
2937 2936
     // Remove all item sharekeys suggestions
2938 2937
     DB::delete(
2939 2938
         prefixTable('sharekeys_suggestions'),
2940
-        'user_id = %i AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
2939
+        'user_id = %i AND object_id NOT IN (SELECT i.id FROM '.prefixTable('items').' AS i WHERE i.perso = 1)',
2941 2940
         $userId
2942 2941
     );
2943 2942
     return false;
@@ -2958,7 +2957,7 @@  discard block
 block discarded – undo
2958 2957
         foreach (DateTimeZone::listIdentifiers() as $timezone) {
2959 2958
             $now->setTimezone(new DateTimeZone($timezone));
2960 2959
             $offsets[] = $offset = $now->getOffset();
2961
-            $timezones[$timezone] = '(' . format_GMT_offset($offset) . ') ' . format_timezone_name($timezone);
2960
+            $timezones[$timezone] = '('.format_GMT_offset($offset).') '.format_timezone_name($timezone);
2962 2961
         }
2963 2962
 
2964 2963
         array_multisort($offsets, $timezones);
@@ -2978,7 +2977,7 @@  discard block
 block discarded – undo
2978 2977
 {
2979 2978
     $hours = intval($offset / 3600);
2980 2979
     $minutes = abs(intval($offset % 3600 / 60));
2981
-    return 'GMT' . ($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
2980
+    return 'GMT'.($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
2982 2981
 }
2983 2982
 
2984 2983
 /**
@@ -3078,8 +3077,7 @@  discard block
 block discarded – undo
3078 3077
 {
3079 3078
     if (isset($array[$key]) === true
3080 3079
         && (is_int($value) === true ?
3081
-            (int) $array[$key] === $value :
3082
-            (string) $array[$key] === $value)
3080
+            (int) $array[$key] === $value : (string) $array[$key] === $value)
3083 3081
     ) {
3084 3082
         return true;
3085 3083
     }
@@ -3101,8 +3099,7 @@  discard block
 block discarded – undo
3101 3099
 {
3102 3100
     if (isset($var) === false
3103 3101
         || (is_int($value) === true ?
3104
-            (int) $var === $value :
3105
-            (string) $var === $value)
3102
+            (int) $var === $value : (string) $var === $value)
3106 3103
     ) {
3107 3104
         return true;
3108 3105
     }
@@ -3153,7 +3150,7 @@  discard block
 block discarded – undo
3153 3150
  */
3154 3151
 function isSetArrayOfValues(array $arrayOfValues): bool
3155 3152
 {
3156
-    foreach($arrayOfValues as $value) {
3153
+    foreach ($arrayOfValues as $value) {
3157 3154
         if (isset($value) === false) {
3158 3155
             return false;
3159 3156
         }
@@ -3175,7 +3172,7 @@  discard block
 block discarded – undo
3175 3172
     /*PHP8 - integer|string*/$value
3176 3173
 ) : bool
3177 3174
 {
3178
-    foreach($arrayOfVars as $variable) {
3175
+    foreach ($arrayOfVars as $variable) {
3179 3176
         if ($variable !== $value) {
3180 3177
             return false;
3181 3178
         }
@@ -3195,7 +3192,7 @@  discard block
 block discarded – undo
3195 3192
     /*PHP8 - integer|string*/$value
3196 3193
 ) : bool
3197 3194
 {
3198
-    foreach($arrayOfVars as $variable) {
3195
+    foreach ($arrayOfVars as $variable) {
3199 3196
         if ($variable === $value) {
3200 3197
             return true;
3201 3198
         }
@@ -3263,7 +3260,7 @@  discard block
 block discarded – undo
3263 3260
  * @param array     $filters
3264 3261
  * @return array|string
3265 3262
  */
3266
-function dataSanitizer(array $data, array $filters): array|string
3263
+function dataSanitizer(array $data, array $filters): array | string
3267 3264
 {
3268 3265
     // Load Sanitizer library
3269 3266
     $sanitizer = new Sanitizer($data, $filters);
@@ -3292,7 +3289,7 @@  discard block
 block discarded – undo
3292 3289
     // Exists ?
3293 3290
     $userCacheId = DB::queryfirstrow(
3294 3291
         'SELECT increment_id
3295
-        FROM ' . prefixTable('cache_tree') . '
3292
+        FROM ' . prefixTable('cache_tree').'
3296 3293
         WHERE user_id = %i',
3297 3294
         $user_id
3298 3295
     );
@@ -3343,7 +3340,7 @@  discard block
 block discarded – undo
3343 3340
  */
3344 3341
 function pourcentage(float $nombre, float $total, float $pourcentage): float
3345 3342
 { 
3346
-    $resultat = ($nombre/$total) * $pourcentage;
3343
+    $resultat = ($nombre / $total) * $pourcentage;
3347 3344
     return round($resultat);
3348 3345
 }
3349 3346
 
@@ -3373,7 +3370,7 @@  discard block
 block discarded – undo
3373 3370
 
3374 3371
     // Get last folder update
3375 3372
     $lastFolderChange = DB::queryfirstrow(
3376
-        'SELECT valeur FROM ' . prefixTable('misc') . '
3373
+        'SELECT valeur FROM '.prefixTable('misc').'
3377 3374
         WHERE type = %s AND intitule = %s',
3378 3375
         'timestamp',
3379 3376
         'last_folder_change'
@@ -3403,7 +3400,7 @@  discard block
 block discarded – undo
3403 3400
     // Does this user has a tree cache
3404 3401
     $userCacheTree = DB::queryfirstrow(
3405 3402
         'SELECT '.$fieldName.'
3406
-        FROM ' . prefixTable('cache_tree') . '
3403
+        FROM ' . prefixTable('cache_tree').'
3407 3404
         WHERE user_id = %i',
3408 3405
         $session->get('user-id')
3409 3406
     );
@@ -3445,7 +3442,7 @@  discard block
 block discarded – undo
3445 3442
     if (count($folderIds) === 0) {
3446 3443
         $folderIds = DB::queryFirstColumn(
3447 3444
             'SELECT id
3448
-            FROM ' . prefixTable('nested_tree') . '
3445
+            FROM ' . prefixTable('nested_tree').'
3449 3446
             WHERE personal_folder=%i',
3450 3447
             0
3451 3448
         );
@@ -3462,8 +3459,8 @@  discard block
 block discarded – undo
3462 3459
         $rows_tmp = DB::query(
3463 3460
             'SELECT c.id, c.title, c.level, c.type, c.masked, c.order, c.encrypted_data, c.role_visibility, c.is_mandatory,
3464 3461
             f.id_category AS category_id
3465
-            FROM ' . prefixTable('categories_folders') . ' AS f
3466
-            INNER JOIN ' . prefixTable('categories') . ' AS c ON (f.id_category = c.parent_id)
3462
+            FROM ' . prefixTable('categories_folders').' AS f
3463
+            INNER JOIN ' . prefixTable('categories').' AS c ON (f.id_category = c.parent_id)
3467 3464
             WHERE id_folder=%i',
3468 3465
             $folder
3469 3466
         );
@@ -3489,7 +3486,7 @@  discard block
 block discarded – undo
3489 3486
         $valTemp = '';
3490 3487
         $data = DB::queryFirstRow(
3491 3488
             'SELECT valeur
3492
-            FROM ' . prefixTable('misc') . '
3489
+            FROM ' . prefixTable('misc').'
3493 3490
             WHERE type = %s AND intitule=%i',
3494 3491
             'complex',
3495 3492
             $folder
@@ -3506,14 +3503,14 @@  discard block
 block discarded – undo
3506 3503
         $valTemp = '';
3507 3504
         $rows_tmp = DB::query(
3508 3505
             'SELECT t.title
3509
-            FROM ' . prefixTable('roles_values') . ' as v
3510
-            INNER JOIN ' . prefixTable('roles_title') . ' as t ON (v.role_id = t.id)
3506
+            FROM ' . prefixTable('roles_values').' as v
3507
+            INNER JOIN ' . prefixTable('roles_title').' as t ON (v.role_id = t.id)
3511 3508
             WHERE v.folder_id = %i
3512 3509
             GROUP BY title',
3513 3510
             $folder
3514 3511
         );
3515 3512
         foreach ($rows_tmp as $record) {
3516
-            $valTemp .= (empty($valTemp) === true ? '' : ' - ') . $record['title'];
3513
+            $valTemp .= (empty($valTemp) === true ? '' : ' - ').$record['title'];
3517 3514
         }
3518 3515
         $arr_data['visibilityRoles'] = $valTemp;
3519 3516
 
@@ -3546,7 +3543,7 @@  discard block
 block discarded – undo
3546 3543
         // loop on users and check if user has this role
3547 3544
         $rows = DB::query(
3548 3545
             'SELECT id, fonction_id
3549
-            FROM ' . prefixTable('users') . '
3546
+            FROM ' . prefixTable('users').'
3550 3547
             WHERE id != %i AND admin = 0 AND fonction_id IS NOT NULL AND fonction_id != ""',
3551 3548
             $session->get('user-id')
3552 3549
         );
@@ -3578,7 +3575,7 @@  discard block
 block discarded – undo
3578 3575
 
3579 3576
     $val = DB::queryfirstrow(
3580 3577
         'SELECT *
3581
-        FROM ' . prefixTable('users') . '
3578
+        FROM ' . prefixTable('users').'
3582 3579
         WHERE id = %i',
3583 3580
         $userId
3584 3581
     );
@@ -3594,12 +3591,12 @@  discard block
 block discarded – undo
3594 3591
 function upgradeRequired(): bool
3595 3592
 {
3596 3593
     // Get settings.php
3597
-    include_once __DIR__. '/../includes/config/settings.php';
3594
+    include_once __DIR__.'/../includes/config/settings.php';
3598 3595
 
3599 3596
     // Get timestamp in DB
3600 3597
     $val = DB::queryfirstrow(
3601 3598
         'SELECT valeur
3602
-        FROM ' . prefixTable('misc') . '
3599
+        FROM ' . prefixTable('misc').'
3603 3600
         WHERE type = %s AND intitule = %s',
3604 3601
         'admin',
3605 3602
         'upgrade_timestamp'
@@ -3654,7 +3651,7 @@  discard block
 block discarded – undo
3654 3651
     // prepapre background tasks for item keys generation        
3655 3652
     $userTP = DB::queryFirstRow(
3656 3653
         'SELECT pw, public_key, private_key
3657
-        FROM ' . prefixTable('users') . '
3654
+        FROM ' . prefixTable('users').'
3658 3655
         WHERE id = %i',
3659 3656
         TP_USER_ID
3660 3657
     );
@@ -3688,7 +3685,7 @@  discard block
 block discarded – undo
3688 3685
     }
3689 3686
 
3690 3687
     // Generate new keys
3691
-    if ($user_self_change === true && empty($recovery_public_key) === false && empty($recovery_private_key) === false){
3688
+    if ($user_self_change === true && empty($recovery_public_key) === false && empty($recovery_private_key) === false) {
3692 3689
         $userKeys = [
3693 3690
             'public_key' => $recovery_public_key,
3694 3691
             'private_key_clear' => $recovery_private_key,
@@ -3728,8 +3725,8 @@  discard block
 block discarded – undo
3728 3725
             'process_type' => 'create_user_keys',
3729 3726
             'arguments' => json_encode([
3730 3727
                 'new_user_id' => (int) $userId,
3731
-                'new_user_pwd' => cryption($passwordClear, '','encrypt')['string'],
3732
-                'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '','encrypt')['string'],
3728
+                'new_user_pwd' => cryption($passwordClear, '', 'encrypt')['string'],
3729
+                'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '', 'encrypt')['string'],
3733 3730
                 'owner_id' => (int) TP_USER_ID,
3734 3731
                 'creator_pwd' => $userTP['pw'],
3735 3732
                 'send_email' => $sendEmailToUser === true ? 1 : 0,
@@ -4037,7 +4034,7 @@  discard block
 block discarded – undo
4037 4034
  * @param integer $user_id
4038 4035
  * @return void
4039 4036
  */
4040
-function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id=0)
4037
+function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id = 0)
4041 4038
 {
4042 4039
     if ($allUsers === true) {
4043 4040
         // Load class DB
@@ -4047,7 +4044,7 @@  discard block
 block discarded – undo
4047 4044
 
4048 4045
         $users = DB::query(
4049 4046
             'SELECT id
4050
-            FROM ' . prefixTable('users') . '
4047
+            FROM ' . prefixTable('users').'
4051 4048
             WHERE id NOT IN ('.OTV_USER_ID.', '.TP_USER_ID.', '.SSH_USER_ID.', '.API_USER_ID.')
4052 4049
             ORDER BY login ASC'
4053 4050
         );
@@ -4065,7 +4062,7 @@  discard block
 block discarded – undo
4065 4062
  * @param integer $user_id
4066 4063
  * @return void
4067 4064
  */
4068
-function purgeUnnecessaryKeysForUser(int $user_id=0)
4065
+function purgeUnnecessaryKeysForUser(int $user_id = 0)
4069 4066
 {
4070 4067
     if ($user_id === 0) {
4071 4068
         return;
@@ -4076,8 +4073,8 @@  discard block
 block discarded – undo
4076 4073
 
4077 4074
     $personalItems = DB::queryFirstColumn(
4078 4075
         'SELECT id
4079
-        FROM ' . prefixTable('items') . ' AS i
4080
-        INNER JOIN ' . prefixTable('log_items') . ' AS li ON li.id_item = i.id
4076
+        FROM ' . prefixTable('items').' AS i
4077
+        INNER JOIN ' . prefixTable('log_items').' AS li ON li.id_item = i.id
4081 4078
         WHERE i.perso = 1 AND li.action = "at_creation" AND li.id_user IN (%i, '.TP_USER_ID.')',
4082 4079
         $user_id
4083 4080
     );
@@ -4126,7 +4123,7 @@  discard block
 block discarded – undo
4126 4123
     // Check if user exists
4127 4124
     $userInfo = DB::queryFirstRow(
4128 4125
         'SELECT pw, public_key, private_key, login, name
4129
-        FROM ' . prefixTable('users') . '
4126
+        FROM ' . prefixTable('users').'
4130 4127
         WHERE id = %i',
4131 4128
         $userId
4132 4129
     );
@@ -4136,7 +4133,7 @@  discard block
 block discarded – undo
4136 4133
 
4137 4134
         // Prepare file content
4138 4135
         $export_value = file_get_contents(__DIR__."/../includes/core/teampass_ascii.txt")."\n".
4139
-            "Generation date: ".date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now)."\n\n".
4136
+            "Generation date: ".date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now)."\n\n".
4140 4137
             "RECOVERY KEYS - Not to be shared - To be store safely\n\n".
4141 4138
             "Public Key:\n".$userInfo['public_key']."\n\n".
4142 4139
             "Private Key:\n".decryptPrivateKey($session->get('user-password'), $userInfo['private_key'])."\n\n";
@@ -4159,7 +4156,7 @@  discard block
 block discarded – undo
4159 4156
         return prepareExchangedData(
4160 4157
             array(
4161 4158
                 'error' => false,
4162
-                'datetime' => date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now),
4159
+                'datetime' => date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now),
4163 4160
                 'timestamp' => $now,
4164 4161
                 'content' => base64_encode($export_value),
4165 4162
                 'login' => $userInfo['login'],
@@ -4185,8 +4182,8 @@  discard block
 block discarded – undo
4185 4182
  */
4186 4183
 function loadClasses(string $className = ''): void
4187 4184
 {
4188
-    require_once __DIR__. '/../includes/config/include.php';
4189
-    require_once __DIR__. '/../includes/config/settings.php';
4185
+    require_once __DIR__.'/../includes/config/include.php';
4186
+    require_once __DIR__.'/../includes/config/settings.php';
4190 4187
     require_once __DIR__.'/../vendor/autoload.php';
4191 4188
 
4192 4189
     if (defined('DB_PASSWD_CLEAR') === false) {
Please login to merge, or discard this patch.