Passed
Pull Request — master (#4682)
by Nils
06:11
created
api/Model/UserModel.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
     {
30 30
         return DB::query(
31 31
             'SELECT * 
32
-            FROM ' . prefixTable('users') . '
32
+            FROM ' . prefixTable('users').'
33 33
             ORDER BY id ASC LIMIT %i',
34 34
             $limit
35 35
         );
Please login to merge, or discard this patch.
api/Model/ItemModel.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -50,18 +50,18 @@  discard block
 block discarded – undo
50 50
         // Get items
51 51
         $rows = DB::query(
52 52
             'SELECT i.id, label, description, i.pw, i.url, i.id_tree, i.login, i.email, i.viewed_no, i.fa_icon, i.inactif, i.perso, t.title as folder_label
53
-            FROM ' . prefixTable('items') . ' AS i
53
+            FROM ' . prefixTable('items').' AS i
54 54
             LEFT JOIN '.prefixTable('nested_tree').' as t ON (t.id = i.id_tree) '.
55
-            $sqlExtra . 
56
-            " ORDER BY i.id ASC" .
57
-            ($limit > 0 ? " LIMIT ". $limit : '')
55
+            $sqlExtra. 
56
+            " ORDER BY i.id ASC".
57
+            ($limit > 0 ? " LIMIT ".$limit : '')
58 58
         );
59 59
 
60 60
         $ret = [];
61 61
         foreach ($rows as $row) {
62 62
             $userKey = DB::queryfirstrow(
63 63
                 'SELECT share_key
64
-                FROM ' . prefixTable('sharekeys_items') . '
64
+                FROM ' . prefixTable('sharekeys_items').'
65 65
                 WHERE user_id = %i AND object_id = %i',
66 66
                 $userId,
67 67
                 $row['id']
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
                 if (empty($path) === true) {
99 99
                     $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
100 100
                 } else {
101
-                    $path .= '/' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
101
+                    $path .= '/'.htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
102 102
                 }
103 103
             }
104 104
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     ) : array
149 149
     {
150 150
         try {
151
-            include_once API_ROOT_PATH . '/../sources/main.functions.php';
151
+            include_once API_ROOT_PATH.'/../sources/main.functions.php';
152 152
 
153 153
             // Load config
154 154
             $configManager = new ConfigManager();
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
         }
272 272
 
273 273
         if (strlen($password) > $SETTINGS['pwd_maximum_length']) {
274
-            throw new Exception('Password is too long (max allowed is ' . $SETTINGS['pwd_maximum_length'] . ' characters)');
274
+            throw new Exception('Password is too long (max allowed is '.$SETTINGS['pwd_maximum_length'].' characters)');
275 275
         }
276 276
     }
277 277
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
     {
285 285
         $dataFolderSettings = DB::queryFirstRow(
286 286
             'SELECT bloquer_creation, bloquer_modification, personal_folder
287
-            FROM ' . prefixTable('nested_tree') . ' 
287
+            FROM ' . prefixTable('nested_tree').' 
288 288
             WHERE id = %i',
289 289
             $folderId
290 290
         );
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
     {
308 308
         $folderComplexity = DB::queryFirstRow(
309 309
             'SELECT valeur
310
-            FROM ' . prefixTable('misc') . '
310
+            FROM ' . prefixTable('misc').'
311 311
             WHERE type = %s AND intitule = %i',
312 312
             'complex',
313 313
             $itemInfos['folderId']
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
     private function checkForDuplicates(string $label, array $SETTINGS, array $itemInfos) : void
336 336
     {
337 337
         DB::queryFirstRow(
338
-            'SELECT * FROM ' . prefixTable('items') . '
338
+            'SELECT * FROM '.prefixTable('items').'
339 339
             WHERE label = %s AND inactif = %i',
340 340
             $label,
341 341
             0
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -342,8 +342,8 @@
 block discarded – undo
342 342
         );
343 343
 
344 344
         if (DB::count() > 0 && (
345
-	     (isset($SETTINGS['duplicate_item']) && (int) $SETTINGS['duplicate_item'] === 0)
346
-	     && (int) $itemInfos['personal_folder'] === 0)
345
+            (isset($SETTINGS['duplicate_item']) && (int) $SETTINGS['duplicate_item'] === 0)
346
+         && (int) $itemInfos['personal_folder'] === 0)
347 347
         ) {
348 348
             throw new Exception('Similar item already exists. Duplicates are not allowed.');
349 349
         }
Please login to merge, or discard this patch.
pages/profile.php 2 patches
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -401,12 +401,13 @@
 block discarded – undo
401 401
                                             <select class="form-control" id="profile-user-timezone">
402 402
                                                 <?php foreach ($zones as $key => $zone): ?>
403 403
                                                     <option value="<?php echo $key; ?>"<?php 
404
-                                                        if ($session->has('user-timezone'))
405
-                                                            if($session->get('user-timezone') === $key)
404
+                                                        if ($session->has('user-timezone')) {
405
+                                                                                                                    if($session->get('user-timezone') === $key)
406 406
                                                                 echo ' selected';
407
-                                                            elseif ($session->get('user-timezone') === 'not_defined')
408
-                                                                if (isset($SETTINGS['timezone']) && $SETTINGS['timezone'] === $key)
407
+                                                        } elseif ($session->get('user-timezone') === 'not_defined') {
408
+                                                                                                                            if (isset($SETTINGS['timezone']) && $SETTINGS['timezone'] === $key)
409 409
                                                                     echo ' selected';
410
+                                                            }
410 411
                                                     ?>><?php echo $zone; ?></option>
411 412
                                                 <?php endforeach; ?>
412 413
                                             </select>
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('profile') === false) {
68 68
     // Not allowed page
69 69
     $session->set('system-error_code', ERR_NOT_ALLOWED);
70
-    include $SETTINGS['cpassman_dir'] . '/error.php';
70
+    include $SETTINGS['cpassman_dir'].'/error.php';
71 71
     exit;
72 72
 }
73 73
 
@@ -100,49 +100,49 @@  discard block
 block discarded – undo
100 100
 $zones = timezone_list();
101 101
 // prepare list of languages
102 102
 $languages = DB::query(
103
-    'SELECT label, name FROM ' . prefixTable('languages') . ' ORDER BY label ASC'
103
+    'SELECT label, name FROM '.prefixTable('languages').' ORDER BY label ASC'
104 104
 );
105 105
 
106 106
 // Do some stats
107 107
 $userItemsNumber = DB::queryFirstField(
108 108
     'SELECT COUNT(id_item) as count
109
-    FROM ' . prefixTable('log_items') . '
109
+    FROM ' . prefixTable('log_items').'
110 110
     WHERE action = "at_creation" AND  id_user = %i',
111 111
     $session->get('user-id')
112 112
 );
113 113
 
114 114
 $userModificationNumber = DB::queryFirstField(
115 115
     'SELECT COUNT(id_item) as count
116
-    FROM ' . prefixTable('log_items') . '
116
+    FROM ' . prefixTable('log_items').'
117 117
     WHERE action = "at_modification" AND  id_user = %i',
118 118
     $session->get('user-id')
119 119
 );
120 120
 
121 121
 $userSeenItemsNumber = DB::queryFirstField(
122 122
     'SELECT COUNT(id_item) as count
123
-    FROM ' . prefixTable('log_items') . '
123
+    FROM ' . prefixTable('log_items').'
124 124
     WHERE action = "at_shown" AND  id_user = %i',
125 125
     $session->get('user-id')
126 126
 );
127 127
 
128 128
 $userSeenPasswordsNumber = DB::queryFirstField(
129 129
     'SELECT COUNT(id_item)
130
-    FROM ' . prefixTable('log_items') . '
130
+    FROM ' . prefixTable('log_items').'
131 131
     WHERE action = "at_password_shown" AND  id_user = %i',
132 132
     $session->get('user-id')
133 133
 );
134 134
 
135 135
 $userInfo = DB::queryFirstRow(
136 136
     'SELECT avatar, last_pw_change
137
-    FROM ' . prefixTable('users') . ' 
137
+    FROM ' . prefixTable('users').' 
138 138
     WHERE id = %i',
139 139
     $session->get('user-id')
140 140
 );
141 141
 
142 142
 if (empty($userInfo['avatar']) === true) {
143
-    $avatar = $SETTINGS['cpassman_url'] . '/includes/images/photo.jpg';
143
+    $avatar = $SETTINGS['cpassman_url'].'/includes/images/photo.jpg';
144 144
 } else {
145
-    $avatar = $SETTINGS['cpassman_url'] . '/includes/avatars/' . $userInfo['avatar'];
145
+    $avatar = $SETTINGS['cpassman_url'].'/includes/avatars/'.$userInfo['avatar'];
146 146
 }
147 147
 
148 148
 // Get Groups name
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 foreach ($session->get('user-roles_array') as $role) {
151 151
     $tmp = DB::queryFirstRow(
152 152
         'SELECT title 
153
-        FROM ' . prefixTable('roles_title') . ' 
153
+        FROM ' . prefixTable('roles_title').' 
154 154
         WHERE id = %i',
155 155
         $role
156 156
     );
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
                         <h3 id="profile-username" class="text-center">
197 197
                             <?php
198 198
                             if (null !== $session->get('user-name') && empty($session->get('user-name')) === false) {
199
-                                echo $session->get('user-name') . ' ' . $session->get('user-lastname');
199
+                                echo $session->get('user-name').' '.$session->get('user-lastname');
200 200
                             } else {
201 201
                                 echo $session->get('user-login');
202 202
                             }
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
                                             } else {
265 265
                                                 echo date('d/m/Y', (int) $session->get('user-last_connection'));
266 266
                                             }
267
-                                            echo ' ' . $lang->get('at') . ' ';
267
+                                            echo ' '.$lang->get('at').' ';
268 268
                                             if (isset($SETTINGS['time_format']) === true) {
269 269
                                                 echo date($SETTINGS['time_format'], (int) $session->get('user-last_connection'));
270 270
                                             } else {
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
                                         </a>
275 275
                                     </li>
276 276
                                     <?php
277
-                                    if (null !== $session->get('user-last_pw_change') && ! empty($session->get('user-last_pw_change') === true)) {
277
+                                    if (null !== $session->get('user-last_pw_change') && !empty($session->get('user-last_pw_change') === true)) {
278 278
                                         // Handle last password change string
279 279
                                         if ($session->has('user-last_pw_change') && null !== $session->get('user-last_pw_change')) {
280 280
                                             if (isset($SETTINGS['date_format']) === true) {
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
                                         ) {
295 295
                                             $numDaysBeforePwExpiration = '';
296 296
                                         } else {
297
-                                            $numDaysBeforePwExpiration = $LANG['index_pw_expiration'] . ' ' . $session->get('user-num_days_before_exp') . ' ' . $LANG['days'] . '.';
297
+                                            $numDaysBeforePwExpiration = $LANG['index_pw_expiration'].' '.$session->get('user-num_days_before_exp').' '.$LANG['days'].'.';
298 298
                                         }
299 299
                                         echo '
300 300
                                     <li class="list-group-item">
301
-                                        <b><i class="fas fa-calendar-alt fa-fw fa-lg mr-2"></i>' . $lang->get('index_last_pw_change') . '</b>
302
-                                        <a class="float-right">' . $last_pw_change . ' ' . $numDaysBeforePwExpiration . '</a>
301
+                                        <b><i class="fas fa-calendar-alt fa-fw fa-lg mr-2"></i>' . $lang->get('index_last_pw_change').'</b>
302
+                                        <a class="float-right">' . $last_pw_change.' '.$numDaysBeforePwExpiration.'</a>
303 303
                                     </li>';
304 304
                                     }
305 305
                                     ?>
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
                                     if (isset($SETTINGS['api']) === true && (int) $SETTINGS['api'] === 1) {
320 320
                                         echo '
321 321
                                     <li class="list-group-item">
322
-                                        <b><i class="fas fa-paper-plane fa-fw fa-lg mr-2"></i>' . $lang->get('user_profile_api_key') . '</b>
322
+                                        <b><i class="fas fa-paper-plane fa-fw fa-lg mr-2"></i>' . $lang->get('user_profile_api_key').'</b>
323 323
                                         <button class="btn btn-sm btn-primary float-right" id="copy-api-key"><i class="fa-regular fa-copy  pointer"></i></button>
324 324
                                         <a class="float-right mr-2" id="profile-user-api-token">',
325 325
                                             null !== $session->get('user-api_key') ? $session->get('user-api_key') : '',
@@ -337,12 +337,12 @@  discard block
 block discarded – undo
337 337
                                         <?php
338 338
                                         $rows = DB::query(
339 339
                                             'SELECT label AS labelAction, date, null
340
-                                                    FROM ' . prefixTable('log_system') . '
340
+                                                    FROM ' . prefixTable('log_system').'
341 341
                                                     WHERE qui = %i
342 342
                                                     UNION
343 343
                                                     SELECT l.action, l.date, i.label AS itemLabel
344
-                                                    FROM ' . prefixTable('log_items') . ' AS l
345
-                                                    INNER JOIN ' . prefixTable('items') . ' AS i ON (l.id_item = i.id)
344
+                                                    FROM ' . prefixTable('log_items').' AS l
345
+                                                    INNER JOIN ' . prefixTable('items').' AS i ON (l.id_item = i.id)
346 346
                                                     WHERE l.id_user = %i AND l.action IN ("at_access")
347 347
                                                     ORDER BY date DESC
348 348
                                                     LIMIT 0, 40',
@@ -356,9 +356,9 @@  discard block
 block discarded – undo
356 356
                                                 $text = $lang->get($record['labelAction']);
357 357
                                             }
358 358
                                             if (empty($record['NULL']) === false) {
359
-                                                $text .= ' ' . $lang->get('for') . ' <span class="font-weight-light">' . addslashes($record['NULL']) . '</span>';
359
+                                                $text .= ' '.$lang->get('for').' <span class="font-weight-light">'.addslashes($record['NULL']).'</span>';
360 360
                                             }
361
-                                            echo '<li class="list-group-item">' . date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['date']) . ' - ' . $text . '</li>';
361
+                                            echo '<li class="list-group-item">'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['date']).' - '.$text.'</li>';
362 362
                                         }
363 363
                                         ?>
364 364
                                     </ul>
@@ -392,13 +392,13 @@  discard block
 block discarded – undo
392 392
                                 <?php endif; /* disable_user_edit_profile */
393 393
                                 if (($SETTINGS['disable_user_edit_timezone'] ?? '0') === '0') : ?>
394 394
                                     <div class="form-group">
395
-                                        <label class="col-sm-10 control-label"><?php echo $lang->get('timezone_selection');?></label>
395
+                                        <label class="col-sm-10 control-label"><?php echo $lang->get('timezone_selection'); ?></label>
396 396
                                         <div class="col-sm-10">
397 397
                                             <select class="form-control" id="profile-user-timezone">
398 398
                                                 <?php foreach ($zones as $key => $zone): ?>
399 399
                                                     <option value="<?php echo $key; ?>"<?php 
400 400
                                                         if ($session->has('user-timezone'))
401
-                                                            if($session->get('user-timezone') === $key)
401
+                                                            if ($session->get('user-timezone') === $key)
402 402
                                                                 echo ' selected';
403 403
                                                             elseif ($session->get('user-timezone') === 'not_defined')
404 404
                                                                 if (isset($SETTINGS['timezone']) && $SETTINGS['timezone'] === $key)
@@ -416,10 +416,10 @@  discard block
 block discarded – undo
416 416
                                             <select class="form-control" id="profile-user-language">
417 417
                                                 <?php
418 418
                                                     foreach ($languages as $language) {
419
-                                                        echo '<option value="' . $language['name'] . '"',
419
+                                                        echo '<option value="'.$language['name'].'"',
420 420
                                                         strtolower($session->get('user-language')) === strtolower($language['name']) ?
421 421
                                                         ' selected="selected"' : '',
422
-                                                    '>' . $language['label'] . '</option>';
422
+                                                    '>'.$language['label'].'</option>';
423 423
                                                     }
424 424
                                                 ?>
425 425
                                             </select>
@@ -432,11 +432,11 @@  discard block
 block discarded – undo
432 432
                                         <div class="col-sm-10">
433 433
                                             <select class="form-control" id="profile-user-treeloadstrategy">
434 434
                                                 
435
-                                                <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' : '';?>>
435
+                                                <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' : ''; ?>>
436 436
                                                     <?php echo $lang->get('sequential'); ?>
437 437
                                                 </option>
438 438
                                                 
439
-                                                <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' : '';?>>
439
+                                                <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' : ''; ?>>
440 440
                                                     <?php echo $lang->get('full'); ?>
441 441
                                                 </option>
442 442
                                             </select>
@@ -449,11 +449,11 @@  discard block
 block discarded – undo
449 449
                                         <div class="col-sm-10">
450 450
                                             <select class="form-control" id="profile-user-split_view_mode">
451 451
                                                 
452
-                                                <option value="0" <?php echo $session->has('user-split_view_mode') && $session->get('user-split_view_mode') && null !== $session->get('user-split_view_mode') && $session->get('user-split_view_mode') === 0 ? 'selected' : '';?>>
452
+                                                <option value="0" <?php echo $session->has('user-split_view_mode') && $session->get('user-split_view_mode') && null !== $session->get('user-split_view_mode') && $session->get('user-split_view_mode') === 0 ? 'selected' : ''; ?>>
453 453
                                                     <?php echo $lang->get('no'); ?>
454 454
                                                 </option>
455 455
                                                 
456
-                                                <option value="1" <?php echo $session->has('user-split_view_mode') && $session->get('user-split_view_mode') && null !== $session->get('user-split_view_mode') && (int) $session->get('user-split_view_mode') === 1 ? 'selected' : '';?>>
456
+                                                <option value="1" <?php echo $session->has('user-split_view_mode') && $session->get('user-split_view_mode') && null !== $session->get('user-split_view_mode') && (int) $session->get('user-split_view_mode') === 1 ? 'selected' : ''; ?>>
457 457
                                                     <?php echo $lang->get('yes'); ?>
458 458
                                                 </option>
459 459
                                             </select>
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
                                                 <?php 
472 472
                                                 }
473 473
                                                 if (isset($SETTINGS['api']) === true && (int) $SETTINGS['api'] === 1) {
474
-                                                    echo '<button type="button" class="btn btn-warning float-right" id="profile-button-api_token">' . $lang->get('generate_api_token') . '</button>';
474
+                                                    echo '<button type="button" class="btn btn-warning float-right" id="profile-button-api_token">'.$lang->get('generate_api_token').'</button>';
475 475
                                                 }
476 476
                                                 ?>
477 477
                                                 <div id="profile-avatar-file-container" class="hidden"></div>
Please login to merge, or discard this patch.
api/Controller/Api/ItemController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
             // SQL where clause with folders list
56 56
             if (isset($arrQueryStringParams['folders']) === true) {
57 57
                 // convert the folders to an array
58
-                $arrQueryStringParams['folders'] = explode(',', str_replace( array('[',']') , ''  , $arrQueryStringParams['folders']));
58
+                $arrQueryStringParams['folders'] = explode(',', str_replace(array('[', ']'), '', $arrQueryStringParams['folders']));
59 59
 
60 60
                 // ensure to only use the intersection
61 61
                 $foldersList = implode(',', array_intersect($arrQueryStringParams['folders'], $userData['folders_list']));
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
                 } else {
217 217
                     // Gérer le cas où les paramètres ne sont pas un tableau
218 218
                     $strErrorDesc = 'Data not consistent';
219
-                    $strErrorHeader = 'Expected array, received ' . gettype($arrQueryStringParams);
219
+                    $strErrorHeader = 'Expected array, received '.gettype($arrQueryStringParams);
220 220
                 }
221 221
             }
222 222
         } else {
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
             // SQL where clause with item id
264 264
             if (isset($arrQueryStringParams['id']) === true) {
265 265
                 // build sql where clause by ID
266
-                $sqlExtra = ' WHERE i.id = '.$arrQueryStringParams['id'] . $sql_constraint;
266
+                $sqlExtra = ' WHERE i.id = '.$arrQueryStringParams['id'].$sql_constraint;
267 267
             } else if (isset($arrQueryStringParams['label']) === true) {
268 268
                 // build sql where clause by LABEL
269
-                $sqlExtra = ' WHERE i.label '.(isset($arrQueryStringParams['like']) === true && (int) $arrQueryStringParams['like'] === 1 ? ' LIKE '.$arrQueryStringParams['label'] : ' = '.$arrQueryStringParams['label']) . $sql_constraint;
269
+                $sqlExtra = ' WHERE i.label '.(isset($arrQueryStringParams['like']) === true && (int) $arrQueryStringParams['like'] === 1 ? ' LIKE '.$arrQueryStringParams['label'] : ' = '.$arrQueryStringParams['label']).$sql_constraint;
270 270
             } else if (isset($arrQueryStringParams['description']) === true) {
271 271
                 // build sql where clause by LABEL
272 272
                 $sqlExtra = ' WHERE i.description '.(isset($arrQueryStringParams['like']) === true && (int) $arrQueryStringParams['like'] === 1 ? ' LIKE '.$arrQueryStringParams['description'] : ' = '.$arrQueryStringParams['description']).$sql_constraint;
Please login to merge, or discard this patch.
api/inc/jwt_utils.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -37,45 +37,45 @@  discard block
 block discarded – undo
37 37
  * @return boolean
38 38
  */
39 39
 function is_jwt_valid($jwt) {
40
-	try {
41
-		$decoded = (array) JWT::decode($jwt, new Key(DB_PASSWD, 'HS256'));
40
+    try {
41
+        $decoded = (array) JWT::decode($jwt, new Key(DB_PASSWD, 'HS256'));
42 42
 
43
-		// Check if expiration is reached
44
-		if ($decoded['exp'] - time() < 0) {
45
-			return false;
46
-		}
43
+        // Check if expiration is reached
44
+        if ($decoded['exp'] - time() < 0) {
45
+            return false;
46
+        }
47 47
 /*
48 48
 		$decoded1 = JWT::decode($jwt, new Key(DB_PASSWD, 'HS256'), $headers = new stdClass());
49 49
 		print_r($headers);
50 50
 */
51 51
 
52
-		return true;
53
-	} catch (InvalidArgumentException $e) {
54
-		// provided key/key-array is empty or malformed.
55
-		return false;
56
-	} catch (DomainException $e) {
57
-		// provided algorithm is unsupported OR
58
-		// provided key is invalid OR
59
-		// unknown error thrown in openSSL or libsodium OR
60
-		// libsodium is required but not available.
61
-		return false;
62
-	} catch (SignatureInvalidException $e) {
63
-		// provided JWT signature verification failed.
64
-		return false;
65
-	} catch (BeforeValidException $e) {
66
-		// provided JWT is trying to be used before "nbf" claim OR
67
-		// provided JWT is trying to be used before "iat" claim.
68
-		return false;
69
-	} catch (ExpiredException $e) {
70
-		// provided JWT is trying to be used after "exp" claim.
71
-		return false;
72
-	} catch (UnexpectedValueException $e) {
73
-		// provided JWT is malformed OR
74
-		// provided JWT is missing an algorithm / using an unsupported algorithm OR
75
-		// provided JWT algorithm does not match provided key OR
76
-		// provided key ID in key/key-array is empty or invalid.
77
-		return false;
78
-	}
52
+        return true;
53
+    } catch (InvalidArgumentException $e) {
54
+        // provided key/key-array is empty or malformed.
55
+        return false;
56
+    } catch (DomainException $e) {
57
+        // provided algorithm is unsupported OR
58
+        // provided key is invalid OR
59
+        // unknown error thrown in openSSL or libsodium OR
60
+        // libsodium is required but not available.
61
+        return false;
62
+    } catch (SignatureInvalidException $e) {
63
+        // provided JWT signature verification failed.
64
+        return false;
65
+    } catch (BeforeValidException $e) {
66
+        // provided JWT is trying to be used before "nbf" claim OR
67
+        // provided JWT is trying to be used before "iat" claim.
68
+        return false;
69
+    } catch (ExpiredException $e) {
70
+        // provided JWT is trying to be used after "exp" claim.
71
+        return false;
72
+    } catch (UnexpectedValueException $e) {
73
+        // provided JWT is malformed OR
74
+        // provided JWT is missing an algorithm / using an unsupported algorithm OR
75
+        // provided JWT algorithm does not match provided key OR
76
+        // provided key ID in key/key-array is empty or invalid.
77
+        return false;
78
+    }
79 79
 }
80 80
 
81 81
 function base64url_encode($data) {
@@ -84,24 +84,24 @@  discard block
 block discarded – undo
84 84
 
85 85
 function get_authorization_header()
86 86
 {
87
-	$request = symfonyRequest::createFromGlobals();
88
-	$authorizationHeader = $request->headers->get('Authorization');
89
-	$headers = null;
87
+    $request = symfonyRequest::createFromGlobals();
88
+    $authorizationHeader = $request->headers->get('Authorization');
89
+    $headers = null;
90 90
 	
91
-	// Check if the authorization header is not empty
92
-	if (!empty($authorizationHeader)) {
93
-		$headers = trim($authorizationHeader);
94
-	} else if (function_exists('apache_request_headers') === true) {
95
-		$requestHeaders = (array) apache_request_headers();
96
-		// Server-side fix for bug in old Android versions (a nice side-effect of this fix means we don't care about capitalization for Authorization)
97
-		$requestHeaders = array_combine(array_map('ucwords', array_keys($requestHeaders)), array_values($requestHeaders));
98
-		//print_r($requestHeaders);
99
-		if (isset($requestHeaders['Authorization']) === true) {
100
-			$headers = trim($requestHeaders['Authorization']);
101
-		}
102
-	}
91
+    // Check if the authorization header is not empty
92
+    if (!empty($authorizationHeader)) {
93
+        $headers = trim($authorizationHeader);
94
+    } else if (function_exists('apache_request_headers') === true) {
95
+        $requestHeaders = (array) apache_request_headers();
96
+        // Server-side fix for bug in old Android versions (a nice side-effect of this fix means we don't care about capitalization for Authorization)
97
+        $requestHeaders = array_combine(array_map('ucwords', array_keys($requestHeaders)), array_values($requestHeaders));
98
+        //print_r($requestHeaders);
99
+        if (isset($requestHeaders['Authorization']) === true) {
100
+            $headers = trim($requestHeaders['Authorization']);
101
+        }
102
+    }
103 103
 	
104
-	return $headers;
104
+    return $headers;
105 105
 }
106 106
 
107 107
 function get_bearer_token() {
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
 
119 119
 function get_bearer_data($jwt) {
120 120
     // split the jwt
121
-	$tokenParts = explode('.', $jwt);
122
-	$payload = base64_decode($tokenParts[1]);
121
+    $tokenParts = explode('.', $jwt);
122
+    $payload = base64_decode($tokenParts[1]);
123 123
 	
124 124
     // HEADER: Get the access token from the header
125 125
     if (empty($payload) === false) {
Please login to merge, or discard this patch.
api/index.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 header("Access-Control-Allow-Methods: POST, GET");
40 40
 header("Access-Control-Max-Age: 3600");
41 41
 header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
42
-require __DIR__ . "/inc/bootstrap.php";
42
+require __DIR__."/inc/bootstrap.php";
43 43
 
44 44
 // sanitize url segments
45 45
 $base = new BaseController();
46 46
 $uri = $base->getUriSegments();
47 47
 if (!is_array($uri)) {
48
-    $uri = [$uri];  // ensure $uril is table
48
+    $uri = [$uri]; // ensure $uril is table
49 49
 }
50 50
 
51 51
 // Prepare DB password
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 if ($uri[0] === 'authorize') {
62 62
     // Is API enabled in Teampass settings
63 63
     if ($apiStatus['error'] === false) {
64
-        require API_ROOT_PATH . "/Controller/Api/AuthController.php";
64
+        require API_ROOT_PATH."/Controller/Api/AuthController.php";
65 65
         $objFeedController = new AuthController();
66
-        $strMethodName = $uri[0] . 'Action';
66
+        $strMethodName = $uri[0].'Action';
67 67
         $objFeedController->{$strMethodName}();
68 68
     } else {
69 69
         // Error management
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
 
90 90
     // action related to USER
91 91
     } elseif ($controller === 'user') {
92
-        require API_ROOT_PATH . "/Controller/Api/UserController.php";
92
+        require API_ROOT_PATH."/Controller/Api/UserController.php";
93 93
         $objFeedController = new UserController();
94
-        $strMethodName = (string) $action . 'Action';
94
+        $strMethodName = (string) $action.'Action';
95 95
         $objFeedController->{$strMethodName}();
96 96
 
97 97
     // action related to ITEM
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
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 ) {
78 78
     // Not allowed page
79 79
     $session->set('system-error_code', ERR_NOT_ALLOWED);
80
-    include $SETTINGS['cpassman_dir'] . '/error.php';
80
+    include $SETTINGS['cpassman_dir'].'/error.php';
81 81
     exit;
82 82
 }
83 83
 
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
                         );
463 463
 
464 464
                         // add new role to user
465
-                        $tmp = $data_tmp['fonction_id'] . (substr($data_tmp['fonction_id'], -1) == ';' ? $role_id : ';' . $role_id);
465
+                        $tmp = $data_tmp['fonction_id'].(substr($data_tmp['fonction_id'], -1) == ';' ? $role_id : ';'.$role_id);
466 466
                         $session->set('user-roles', str_replace(';;', ';', $tmp));
467 467
 
468 468
                         // store in DB
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
                         $groupsData = $openLdapExtra->getADGroups($ldapConnection, $SETTINGS);
724 724
                         break;
725 725
                     default:
726
-                        throw new Exception("Unsupported LDAP type: " . $SETTINGS['ldap_type']);
726
+                        throw new Exception("Unsupported LDAP type: ".$SETTINGS['ldap_type']);
727 727
                 }
728 728
             } catch (Exception $e) {
729 729
                 if (defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
             } else {
744 744
                 // Handle successful retrieval of groups
745 745
                 // exists in Teampass
746
-                foreach($groupsData['userGroups'] as $key => $group) {
746
+                foreach ($groupsData['userGroups'] as $key => $group) {
747 747
                     $role_detail = DB::queryfirstrow(
748 748
                         'SELECT a.increment_id as increment_id, a.role_id as role_id, r.title as title
749 749
                         FROM '.prefixTable('ldap_groups_roles').' AS a
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
             
769 769
             // Get all groups in Teampass
770 770
             $teampassRoles = array();
771
-            $rows = DB::query('SELECT id,title FROM ' . prefixTable('roles_title'));
771
+            $rows = DB::query('SELECT id,title FROM '.prefixTable('roles_title'));
772 772
             foreach ($rows as $record) {
773 773
                 array_push(
774 774
                     $teampassRoles,
Please login to merge, or discard this patch.
sources/ldap.queries.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 ) {
81 81
     // Not allowed page
82 82
     $session->set('system-error_code', ERR_NOT_ALLOWED);
83
-    include $SETTINGS['cpassman_dir'] . '/error.php';
83
+    include $SETTINGS['cpassman_dir'].'/error.php';
84 84
     exit;
85 85
 }
86 86
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
                     $openLdapExtra = new OpenLdapExtra();
155 155
                     break;
156 156
                 default:
157
-                    throw new Exception("Unsupported LDAP type: " . $SETTINGS['ldap_type']);
157
+                    throw new Exception("Unsupported LDAP type: ".$SETTINGS['ldap_type']);
158 158
             }
159 159
         } catch (Exception $e) {
160 160
             if (defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
             // 2- Get user info from AD
174 174
             // We want to isolate attribute ldap_user_attribute or mostly samAccountName
175 175
             $userADInfos = $ldapConnection->query()
176
-                ->where((isset($SETTINGS['ldap_user_attribute']) ===true && empty($SETTINGS['ldap_user_attribute']) === false) ? $SETTINGS['ldap_user_attribute'] : 'samaccountname', '=', $post_username)
176
+                ->where((isset($SETTINGS['ldap_user_attribute']) === true && empty($SETTINGS['ldap_user_attribute']) === false) ? $SETTINGS['ldap_user_attribute'] : 'samaccountname', '=', $post_username)
177 177
                 ->firstOrFail();
178 178
 
179 179
             // Is user enabled? Only ActiveDirectory
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
         } catch (\LdapRecord\Query\ObjectNotFoundException $e) {
195 195
             $error = $e->getDetailedError();
196 196
             if ($error && defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
197
-                error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage(). " - ".$error->getDiagnosticMessage());
197
+                error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage()." - ".$error->getDiagnosticMessage());
198 198
             } 
199 199
             // deepcode ignore ServerLeak: No important data is sent and is encrypted before being sent
200 200
             echo prepareExchangedData(
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
             // For OpenLDAP and others, we use attribute dn
214 214
             $userAuthAttempt = $ldapConnection->auth()->attempt(
215 215
                 $SETTINGS['ldap_type'] === 'ActiveDirectory' ?
216
-                    $userADInfos['userprincipalname'][0] :  // refering to https://ldaprecord.com/docs/core/v2/authentication#basic-authentication
216
+                    $userADInfos['userprincipalname'][0] : // refering to https://ldaprecord.com/docs/core/v2/authentication#basic-authentication
217 217
                     $userADInfos['dn'],
218 218
                 $post_password
219 219
             );
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
         } catch (\LdapRecord\Query\ObjectNotFoundException $e) {
233 233
             $error = $e->getDetailedError();
234 234
             if ($error && defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
235
-                error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage(). " - ".$error->getDiagnosticMessage());
235
+                error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage()." - ".$error->getDiagnosticMessage());
236 236
             }
237 237
             // deepcode ignore ServerLeak: No important data is sent and is encrypted before being sent
238 238
             echo prepareExchangedData(
Please login to merge, or discard this patch.
scripts/background_tasks___functions.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
 function provideLog(string $message, array $SETTINGS)
103 103
 {
104 104
     if (defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
105
-        error_log((string) date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], time()) . ' - '.$message);
105
+        error_log((string) date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], time()).' - '.$message);
106 106
     }
107 107
 }
108 108
 
109
-function performVisibleFoldersHtmlUpdate (int $user_id)
109
+function performVisibleFoldersHtmlUpdate(int $user_id)
110 110
 {
111 111
     $html = [];
112 112
 
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
 
117 117
     // get current folders visible for user
118 118
     $cache_tree = DB::queryFirstRow(
119
-        'SELECT increment_id, data FROM ' . prefixTable('cache_tree') . ' WHERE user_id = %i',
119
+        'SELECT increment_id, data FROM '.prefixTable('cache_tree').' WHERE user_id = %i',
120 120
         $user_id
121 121
     );
122
-    $folders = json_decode($cache_tree['data'], true);//print_r($folders);
122
+    $folders = json_decode($cache_tree['data'], true); //print_r($folders);
123 123
     foreach ($folders as $folder) {
124 124
         $idFolder = (int) explode("li_", $folder['id'])[1];
125 125
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 
133 133
         // get folder info
134 134
         $folder = DB::queryFirstRow(
135
-            'SELECT title, parent_id, personal_folder FROM ' . prefixTable('nested_tree') . ' WHERE id = %i',
135
+            'SELECT title, parent_id, personal_folder FROM '.prefixTable('nested_tree').' WHERE id = %i',
136 136
             $idFolder
137 137
         );
138 138
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 function subTaskStatus($taskId)
168 168
 {
169 169
     $subTasks = DB::query(
170
-        'SELECT * FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i',
170
+        'SELECT * FROM '.prefixTable('background_subtasks').' WHERE task_id = %i',
171 171
         $taskId
172 172
     );
173 173
 
Please login to merge, or discard this patch.