Passed
Push — master ( b61ff7...0d33c7 )
by Nils
05:51
created
pages/profile.js.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('profile') === false) {
74 74
     // Not allowed page
75 75
     $session->set('system-error_code', ERR_NOT_ALLOWED);
76
-    include $SETTINGS['cpassman_dir'] . '/error.php';
76
+    include $SETTINGS['cpassman_dir'].'/error.php';
77 77
     exit;
78 78
 }
79 79
 ?>
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     })
98 98
 
99 99
     // Select user properties
100
-    $('#profile-user-language option[value=<?php echo $session->get('user-language');?>').attr('selected','selected');
100
+    $('#profile-user-language option[value=<?php echo $session->get('user-language'); ?>').attr('selected','selected');
101 101
 
102 102
 
103 103
     // AVATAR IMPORT
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 
296 296
                     // reload page in case of language change
297 297
                     if ($('#profile-user-language').val()
298
-                        && $('#profile-user-language').val().toLowerCase() !== '<?php echo $session->get('user-language');?>') {
298
+                        && $('#profile-user-language').val().toLowerCase() !== '<?php echo $session->get('user-language'); ?>') {
299 299
                         // prepare reload
300 300
                         $(this).delay(3000).queue(function() {
301 301
                             document.location.href = "index.php?page=profile";
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
                         // Inform user
307 307
                         toastr.remove();
308 308
                         toastr.info(
309
-                            '<?php echo $lang->get('alert_page_will_reload') . ' ... ' . $lang->get('please_wait'); ?>',
309
+                            '<?php echo $lang->get('alert_page_will_reload').' ... '.$lang->get('please_wait'); ?>',
310 310
                             '', {
311 311
                                 timeOut: 3000,
312 312
                                 progressBar: true
@@ -410,27 +410,27 @@  discard block
 block discarded – undo
410 410
         "defaultText": "<?php echo $lang->get('index_pw_level_txt'); ?>",
411 411
         "ratings": [
412 412
             {
413
-                "minScore": <?php echo TP_PW_STRENGTH_1;?>,
413
+                "minScore": <?php echo TP_PW_STRENGTH_1; ?>,
414 414
                 "className": "meterWarn",
415 415
                 "text": "<?php echo $lang->get('complex_level1'); ?>"
416 416
             },
417 417
             {
418
-                "minScore": <?php echo TP_PW_STRENGTH_2;?>,
418
+                "minScore": <?php echo TP_PW_STRENGTH_2; ?>,
419 419
                 "className": "meterWarn",
420 420
                 "text": "<?php echo $lang->get('complex_level2'); ?>"
421 421
             },
422 422
             {
423
-                "minScore": <?php echo TP_PW_STRENGTH_3;?>,
423
+                "minScore": <?php echo TP_PW_STRENGTH_3; ?>,
424 424
                 "className": "meterGood",
425 425
                 "text": "<?php echo $lang->get('complex_level3'); ?>"
426 426
             },
427 427
             {
428
-                "minScore": <?php echo TP_PW_STRENGTH_4;?>,
428
+                "minScore": <?php echo TP_PW_STRENGTH_4; ?>,
429 429
                 "className": "meterGood",
430 430
                 "text": "<?php echo $lang->get('complex_level4'); ?>"
431 431
             },
432 432
             {
433
-                "minScore": <?php echo TP_PW_STRENGTH_5;?>,
433
+                "minScore": <?php echo TP_PW_STRENGTH_5; ?>,
434 434
                 "className": "meterExcel",
435 435
                 "text": "<?php echo $lang->get('complex_level5'); ?>"
436 436
             }
@@ -523,27 +523,27 @@  discard block
 block discarded – undo
523 523
         "defaultText": "<?php echo $lang->get('index_pw_level_txt'); ?>",
524 524
         "ratings": [
525 525
             {
526
-                "minScore": <?php echo TP_PW_STRENGTH_1;?>,
526
+                "minScore": <?php echo TP_PW_STRENGTH_1; ?>,
527 527
                 "className": "meterWarn",
528 528
                 "text": "<?php echo $lang->get('complex_level1'); ?>"
529 529
             },
530 530
             {
531
-                "minScore": <?php echo TP_PW_STRENGTH_2;?>,
531
+                "minScore": <?php echo TP_PW_STRENGTH_2; ?>,
532 532
                 "className": "meterWarn",
533 533
                 "text": "<?php echo $lang->get('complex_level2'); ?>"
534 534
             },
535 535
             {
536
-                "minScore": <?php echo TP_PW_STRENGTH_3;?>,
536
+                "minScore": <?php echo TP_PW_STRENGTH_3; ?>,
537 537
                 "className": "meterGood",
538 538
                 "text": "<?php echo $lang->get('complex_level3'); ?>"
539 539
             },
540 540
             {
541
-                "minScore": <?php echo TP_PW_STRENGTH_4;?>,
541
+                "minScore": <?php echo TP_PW_STRENGTH_4; ?>,
542 542
                 "className": "meterGood",
543 543
                 "text": "<?php echo $lang->get('complex_level4'); ?>"
544 544
             },
545 545
             {
546
-                "minScore": <?php echo TP_PW_STRENGTH_5;?>,
546
+                "minScore": <?php echo TP_PW_STRENGTH_5; ?>,
547 547
                 "className": "meterExcel",
548 548
                 "text": "<?php echo $lang->get('complex_level5'); ?>"
549 549
             }
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
         }
560 560
     });
561 561
 
562
-    $('#profile-keys_download-date').text('<?php echo null === $session->get('user-keys_recovery_time') ? $lang->get('none') : date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $session->get('user-keys_recovery_time')); ?>');
562
+    $('#profile-keys_download-date').text('<?php echo null === $session->get('user-keys_recovery_time') ? $lang->get('none') : date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $session->get('user-keys_recovery_time')); ?>');
563 563
 
564 564
     $("#open-dialog-keys-download").on('click', function(event) {
565 565
         event.preventDefault();
Please login to merge, or discard this patch.
pages/items.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('items') === false) {
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
 // Define Timezone
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
 // Get list of users
92 92
 $usersList = [];
93
-$rows = DB::query('SELECT id,login,email FROM ' . prefixTable('users') . ' ORDER BY login ASC');
93
+$rows = DB::query('SELECT id,login,email FROM '.prefixTable('users').' ORDER BY login ASC');
94 94
 foreach ($rows as $record) {
95 95
     $usersList[$record['login']] = [
96 96
         'id' => $record['id'],
@@ -101,16 +101,16 @@  discard block
 block discarded – undo
101 101
 // Get list of roles
102 102
 $arrRoles = [];
103 103
 $listRoles = '';
104
-$rows = DB::query('SELECT id,title FROM ' . prefixTable('roles_title') . ' ORDER BY title ASC');
104
+$rows = DB::query('SELECT id,title FROM '.prefixTable('roles_title').' ORDER BY title ASC');
105 105
 foreach ($rows as $reccord) {
106 106
     $arrRoles[$reccord['title']] = [
107 107
         'id' => $reccord['id'],
108 108
         'title' => $reccord['title'],
109 109
     ];
110 110
     if (empty($listRoles)) {
111
-        $listRoles = $reccord['id'] . '#' . $reccord['title'];
111
+        $listRoles = $reccord['id'].'#'.$reccord['title'];
112 112
     } else {
113
-        $listRoles .= ';' . $reccord['id'] . '#' . $reccord['title'];
113
+        $listRoles .= ';'.$reccord['id'].'#'.$reccord['title'];
114 114
     }
115 115
 }
116 116
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
                         <li class="nav-item"><a class="nav-link" href="#tab_3" data-toggle="tab"><i class="fa-solid fa-archive mr-2"></i><?php echo $lang->get('attachments'); ?></a></li>
186 186
                         <?php
187 187
                         echo isset($SETTINGS['item_extra_fields']) === true && (int) $SETTINGS['item_extra_fields'] === 1 ? '
188
-                            <li class="nav-item"><a class="nav-link" href="#tab_4" data-toggle="tab"><i class="fa-solid fa-cubes mr-2"></i>' . $lang->get('fields') . '</a></li>' : '';
188
+                            <li class="nav-item"><a class="nav-link" href="#tab_4" data-toggle="tab"><i class="fa-solid fa-cubes mr-2"></i>' . $lang->get('fields').'</a></li>' : '';
189 189
                         ?>
190 190
                     </ul>
191 191
                 </div><!-- /.card-header -->
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
                                                 <?php
255 255
                                                 for ($i = 4; $i <= $SETTINGS['pwd_maximum_length']; ++$i) {
256 256
                                                     echo '
257
-                                                <option>' . $i . '</option>';
257
+                                                <option>' . $i.'</option>';
258 258
                                                 }
259 259
                                                 ?>
260 260
                                             </select>
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
                                     <span class="ml-2 col-md-1 clear-me-html" id="form-item-icon-show"></span>
285 285
                                 </div>
286 286
                                 <small class='form-text text-muted'>
287
-                                    <?php echo $lang->get('fontawesome_icon_tip'); ?><a href="<?php echo FONTAWESOME_URL;?>" target="_blank"><i class="fa-solid fa-external-link-alt ml-1"></i></a>
287
+                                    <?php echo $lang->get('fontawesome_icon_tip'); ?><a href="<?php echo FONTAWESOME_URL; ?>" target="_blank"><i class="fa-solid fa-external-link-alt ml-1"></i></a>
288 288
                                 </small>
289 289
                             </div>
290 290
 
@@ -472,39 +472,39 @@  discard block
 block discarded – undo
472 472
                             <div class="tab-pane" id="tab_4">
473 473
                                 <div id="form-item-field" class="hidden">
474 474
                                     <?php
475
-                                        $session_item_fields = $session->get('system-item_fields');//print_r($session_item_fields);
475
+                                        $session_item_fields = $session->get('system-item_fields'); //print_r($session_item_fields);
476 476
                                         if (isset($session_item_fields) === true) {
477 477
                                             foreach ($session_item_fields as $category) {
478 478
                                                 //print_r($category);
479 479
                                                 echo '
480
-                                            <div class="callout callout-info form-item-category hidden" id="form-item-category-' . $category['id'] . '">
481
-                                                <h5>' . $category['title'] . '</h5>
480
+                                            <div class="callout callout-info form-item-category hidden" id="form-item-category-' . $category['id'].'">
481
+                                                <h5>' . $category['title'].'</h5>
482 482
                                                 <p>';
483 483
                                                 foreach ($category['fields'] as $field) {
484 484
                                                     if ($field['type'] === 'textarea') {
485 485
                                                         echo '
486
-                                                    <div class="form-group mb-3 form-item-field" id="form-item-field-' . $field['id'] . '" data-field-id="' . $field['id'] . '">
486
+                                                    <div class="form-group mb-3 form-item-field" id="form-item-field-' . $field['id'].'" data-field-id="'.$field['id'].'">
487 487
                                                         <label>' . $field['title'],
488 488
                                                             $field['is_mandatory'] === '1' ?
489
-                                                                '<span class="fa-solid fa-fire text-danger ml-1 infotip" title="' . $lang->get('is_mandatory') . '"></span>' : '',
489
+                                                                '<span class="fa-solid fa-fire text-danger ml-1 infotip" title="'.$lang->get('is_mandatory').'"></span>' : '',
490 490
                                                             '</label>
491
-                                                        <textarea class="form-control form-item-control form-item-field-custom" rows="2" data-field-name="' . $field['id'] . '" data-field-mandatory="' . $field['is_mandatory'] . '" data-field-regex="' . $field['regex'] . '" data-change-ongoing="0"></textarea>
491
+                                                        <textarea class="form-control form-item-control form-item-field-custom" rows="2" data-field-name="' . $field['id'].'" data-field-mandatory="'.$field['is_mandatory'].'" data-field-regex="'.$field['regex'].'" data-change-ongoing="0"></textarea>
492 492
                                                     </div>';
493 493
                                                     } else {
494 494
                                                         echo '
495
-                                                    <div class="input-group mb-3 form-item-field" id="form-item-field-' . $field['id'] . '" data-field-id="' . $field['id'] . '">
495
+                                                    <div class="input-group mb-3 form-item-field" id="form-item-field-' . $field['id'].'" data-field-id="'.$field['id'].'">
496 496
                                                         <div class="input-group-prepend">
497 497
                                                             <span class="input-group-text">' . $field['title'],
498 498
                                                             $field['is_mandatory'] === '1' ?
499
-                                                                '<span class="fa-solid fa-fire text-danger ml-1 infotip" title="' . $lang->get('is_mandatory') . '"></span>' : '',
499
+                                                                '<span class="fa-solid fa-fire text-danger ml-1 infotip" title="'.$lang->get('is_mandatory').'"></span>' : '',
500 500
                                                             '</span>
501 501
                                                         </div>
502
-                                                        <input type="' . $field['type'] . '" class="form-control form-item-control form-item-field-custom" data-field-name="' . $field['id'] . '" data-field-mandatory="' . $field['is_mandatory'] . '" data-field-regex="' . $field['regex'] . '" data-change-ongoing="0">
502
+                                                        <input type="' . $field['type'].'" class="form-control form-item-control form-item-field-custom" data-field-name="'.$field['id'].'" data-field-mandatory="'.$field['is_mandatory'].'" data-field-regex="'.$field['regex'].'" data-change-ongoing="0">
503 503
                                                     </div>';
504 504
                                                     }
505 505
                                                     if (!empty($field['regex'])) {
506 506
                                                         echo '
507
-                                                    <div>Regex: '. $field['regex'] .'</div>
507
+                                                    <div>Regex: '. $field['regex'].'</div>
508 508
                                                         ';
509 509
                                                     }
510 510
                                                 }
@@ -515,8 +515,8 @@  discard block
 block discarded – undo
515 515
                                                 ) {
516 516
                                                     echo '
517 517
                                                     <div class="form-check icheck-blue">
518
-                                                        <input type="checkbox" class="form-check-input form-check-input-template form-item-control flat-blue" data-category-id="' . $category['id'] . '" data-change-ongoing="0" data-field-name="template" id="template_' . $category['id'] . '">
519
-                                                        <label class="form-check-label ml-3" for="template_' . $category['id'] . '">' . $lang->get('main_template') . '</label>
518
+                                                        <input type="checkbox" class="form-check-input form-check-input-template form-item-control flat-blue" data-category-id="' . $category['id'].'" data-change-ongoing="0" data-field-name="template" id="template_'.$category['id'].'">
519
+                                                        <label class="form-check-label ml-3" for="template_' . $category['id'].'">'.$lang->get('main_template').'</label>
520 520
                                                     </div>';
521 521
                                                 }
522 522
                                                 echo '
@@ -526,8 +526,8 @@  discard block
 block discarded – undo
526 526
                                         } else {
527 527
                                             echo
528 528
                                             '<div class="alert alert-info">
529
-                                                <h5><i class="icon fa fa-info mr-3"></i>' . $lang->get('information') . '</h5>
530
-                                                ' . $lang->get('no_fields') . '
529
+                                                <h5><i class="icon fa fa-info mr-3"></i>' . $lang->get('information').'</h5>
530
+                                                ' . $lang->get('no_fields').'
531 531
                                             </div>';
532 532
                                         } ?>
533 533
                                 </div>
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
                         <p><?php
669 669
                             echo str_replace(
670 670
         ['##otv_expiration_period##', '. '],
671
-        ['<span class="text-bold text-primary">' . $SETTINGS['otv_expiration_period'] . '</span>', '<br>'],
671
+        ['<span class="text-bold text-primary">'.$SETTINGS['otv_expiration_period'].'</span>', '<br>'],
672 672
         $lang->get('otv_message')
673 673
     );
674 674
                             ?></p>
@@ -686,9 +686,9 @@  discard block
 block discarded – undo
686 686
 
687 687
                     <div class="row">
688 688
                         <div class="form-group col-4">
689
-                            <label for="form-item-otv-days"><i class="fa-regular fa-calendar-days mr-2"></i><?php echo $lang->get('number_of_days'); ?> (<?php echo $lang->get('maximum').': '.$SETTINGS['otv_expiration_period'];?>)</label>
689
+                            <label for="form-item-otv-days"><i class="fa-regular fa-calendar-days mr-2"></i><?php echo $lang->get('number_of_days'); ?> (<?php echo $lang->get('maximum').': '.$SETTINGS['otv_expiration_period']; ?>)</label>
690 690
                             <div class="input-group mb-3">
691
-                                <input type="number" class="form-control clear-me-val" id="form-item-otv-days" min="0" max="<?php echo $SETTINGS['otv_expiration_period'];?>" value="<?php echo $SETTINGS['otv_expiration_period'];?>">
691
+                                <input type="number" class="form-control clear-me-val" id="form-item-otv-days" min="0" max="<?php echo $SETTINGS['otv_expiration_period']; ?>" value="<?php echo $SETTINGS['otv_expiration_period']; ?>">
692 692
                             </div>
693 693
                         </div>
694 694
 
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
                             <select class="form-control form-folder-control select2" style="width:100%;" id="form-folder-add-complexicity" required>
777 777
                                 <?php
778 778
                                 foreach (TP_PW_COMPLEXITY as $key => $value) {
779
-                                    echo '<option value="' . $key . '">' . $value[1] . '</option>';
779
+                                    echo '<option value="'.$key.'">'.$value[1].'</option>';
780 780
                                 }
781 781
                                 ?>
782 782
                             </select>
@@ -794,14 +794,14 @@  discard block
 block discarded – undo
794 794
                             <label><?php echo $lang->get('icon'); ?></label>
795 795
                             <input type="text" class="form-control form-folder-control" id="form-folder-add-icon">
796 796
                             <small class='form-text text-muted'>
797
-                                <?php echo $lang->get('fontawesome_icon_tip'); ?><a href="<?php echo FONTAWESOME_URL;?>" target="_blank"><i class="fa-solid fa-external-link-alt ml-1"></i></a>
797
+                                <?php echo $lang->get('fontawesome_icon_tip'); ?><a href="<?php echo FONTAWESOME_URL; ?>" target="_blank"><i class="fa-solid fa-external-link-alt ml-1"></i></a>
798 798
                             </small>
799 799
                         </div>
800 800
                         <div class="form-group">
801 801
                             <label><?php echo $lang->get('icon_on_selection'); ?></label>
802 802
                             <input type="text" class="form-control form-folder-control" id="form-folder-add-icon-selected">
803 803
                             <small class='form-text text-muted'>
804
-                                <?php echo $lang->get('fontawesome_icon_tip'); ?><a href="<?php echo FONTAWESOME_URL;?>" target="_blank"><i class="fa-solid fa-external-link-alt ml-1"></i></a>
804
+                                <?php echo $lang->get('fontawesome_icon_tip'); ?><a href="<?php echo FONTAWESOME_URL; ?>" target="_blank"><i class="fa-solid fa-external-link-alt ml-1"></i></a>
805 805
                             </small>
806 806
                         </div>
807 807
                     </div>
@@ -1212,18 +1212,18 @@  discard block
 block discarded – undo
1212 1212
                                 <?php
1213 1213
                                     foreach ($session_item_fields as $elem) {
1214 1214
                                         echo '
1215
-                                <div class="callout callout-info card-item-category hidden" id="card-item-category-' . $elem['id'] . '">
1216
-                                    <h5>' . $elem['title'] . '</h5>
1215
+                                <div class="callout callout-info card-item-category hidden" id="card-item-category-' . $elem['id'].'">
1216
+                                    <h5>' . $elem['title'].'</h5>
1217 1217
                                     <p>
1218 1218
                                         <ul class="list-group list-group-unbordered mb-3">';
1219 1219
                                         foreach ($elem['fields'] as $field) {
1220 1220
                                             echo '
1221
-                                            <li class="list-group-item card-item-field hidden" id="card-item-field-' . $field['id'] . '">
1222
-                                                <span id="card-item-field-title-' . $field['id'] . '"><b>' . $field['title'] . '</b></span>
1223
-                                                <button type="button" class="float-right btn btn-secondary btn-sm ml-1 btn-copy-clipboard-clear"  data-clipboard-target="card-item-field-value-' . $field['id'] . '">
1221
+                                            <li class="list-group-item card-item-field hidden" id="card-item-field-' . $field['id'].'">
1222
+                                                <span id="card-item-field-title-' . $field['id'].'"><b>'.$field['title'].'</b></span>
1223
+                                                <button type="button" class="float-right btn btn-secondary btn-sm ml-1 btn-copy-clipboard-clear"  data-clipboard-target="card-item-field-value-' . $field['id'].'">
1224 1224
                                                     <i class="fa-solid fa-copy"></i>
1225 1225
                                                 </button>
1226
-                                                <span class="card-item-field-value float-right ml-1" id="card-item-field-value-' . $field['id'] . '"></span>
1226
+                                                <span class="card-item-field-value float-right ml-1" id="card-item-field-value-' . $field['id'].'"></span>
1227 1227
                                             </li>';
1228 1228
                                         }
1229 1229
                                         echo '
Please login to merge, or discard this patch.
sources/tools.queries.php 2 patches
Switch Indentation   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -91,215 +91,215 @@
 block discarded – undo
91 91
 switch ($post_type) {
92 92
 //##########################################################
93 93
 //CASE for creating a DB backup
94
-case 'perform_fix_pf_items-step1':
95
-    // Check KEY
96
-    if (!hash_equals((string) $session->get('key'), (string) $post_key)) {
97
-        echo prepareExchangedData(
98
-            array(
99
-                'error' => true,
100
-                'message' => $lang->get('key_is_not_correct'),
101
-            ),
102
-            'encode'
103
-        );
104
-        break;
105
-    }
106
-    // Is admin?
107
-    if ((int) $session->get('user-admin') !== 1) {
108
-        echo prepareExchangedData(
109
-            array(
110
-                'error' => true,
111
-                'message' => $lang->get('error_not_allowed_to'),
112
-            ),
113
-            'encode'
114
-        );
115
-        break;
116
-    }
94
+    case 'perform_fix_pf_items-step1':
95
+        // Check KEY
96
+        if (!hash_equals((string) $session->get('key'), (string) $post_key)) {
97
+            echo prepareExchangedData(
98
+                array(
99
+                    'error' => true,
100
+                    'message' => $lang->get('key_is_not_correct'),
101
+                ),
102
+                'encode'
103
+            );
104
+            break;
105
+        }
106
+        // Is admin?
107
+        if ((int) $session->get('user-admin') !== 1) {
108
+            echo prepareExchangedData(
109
+                array(
110
+                    'error' => true,
111
+                    'message' => $lang->get('error_not_allowed_to'),
112
+                ),
113
+                'encode'
114
+            );
115
+            break;
116
+        }
117 117
 
118
-    // decrypt and retrieve data in JSON format
119
-    $dataReceived = prepareExchangedData(
120
-        $post_data,
121
-        'decode'
122
-    );
118
+        // decrypt and retrieve data in JSON format
119
+        $dataReceived = prepareExchangedData(
120
+            $post_data,
121
+            'decode'
122
+        );
123 123
 
124
-    $userId = filter_var($dataReceived['userId'], FILTER_SANITIZE_NUMBER_INT);
124
+        $userId = filter_var($dataReceived['userId'], FILTER_SANITIZE_NUMBER_INT);
125 125
 
126
-    // Get user info
127
-    $userInfo = DB::queryFirstRow(
128
-        'SELECT private_key, public_key, psk, encrypted_psk
126
+        // Get user info
127
+        $userInfo = DB::queryFirstRow(
128
+            'SELECT private_key, public_key, psk, encrypted_psk
129 129
         FROM teampass_users
130 130
         WHERE id = %i',
131
-        $userId
132
-    );
131
+            $userId
132
+        );
133 133
 
134
-    // Get user's private folders
135
-    $userPFRoot = DB::queryFirstRow(
136
-        'SELECT id
134
+        // Get user's private folders
135
+        $userPFRoot = DB::queryFirstRow(
136
+            'SELECT id
137 137
         FROM teampass_nested_tree
138 138
         WHERE title = %i',
139
-        $userId
140
-    );
141
-    if (DB::count() === 0) {
142
-        echo prepareExchangedData(
143
-            array(
144
-                'error' => true,
145
-                'message' => 'User has no personal folders',
146
-            ),
147
-            'encode'
148
-        );
149
-        break;
150
-    }
151
-    $personalFolders = [];
152
-    $tree = new NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title');
153
-    $tree->rebuild();
154
-    $folders = $tree->getDescendants($userPFRoot['id'], true);
155
-    foreach ($folders as $folder) {
156
-        array_push($personalFolders, $folder->id);
157
-    }
158
-
159
-    //Show done
160
-    echo prepareExchangedData(
161
-        array(
162
-            'error' => false,
163
-            'message' => 'Personal Folders found: ',
164
-            'personalFolders' => json_encode($personalFolders),
165
-        ),
166
-        'encode'
167
-    );
168
-    break;
169
-
170
-case 'perform_fix_pf_items-step2':
171
-    // Check KEY
172
-    if (!hash_equals((string) $session->get('key'), (string) $post_key)) {
173
-        echo prepareExchangedData(
174
-            array(
175
-                'error' => true,
176
-                'message' => $lang->get('key_is_not_correct'),
177
-            ),
178
-            'encode'
139
+            $userId
179 140
         );
180
-        break;
181
-    }
182
-    // Is admin?
183
-    if ((int) $session->get('user-admin') !== 1) {
141
+        if (DB::count() === 0) {
142
+            echo prepareExchangedData(
143
+                array(
144
+                    'error' => true,
145
+                    'message' => 'User has no personal folders',
146
+                ),
147
+                'encode'
148
+            );
149
+            break;
150
+        }
151
+        $personalFolders = [];
152
+        $tree = new NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title');
153
+        $tree->rebuild();
154
+        $folders = $tree->getDescendants($userPFRoot['id'], true);
155
+        foreach ($folders as $folder) {
156
+            array_push($personalFolders, $folder->id);
157
+        }
158
+
159
+        //Show done
184 160
         echo prepareExchangedData(
185 161
             array(
186
-                'error' => true,
187
-                'message' => $lang->get('error_not_allowed_to'),
162
+                'error' => false,
163
+                'message' => 'Personal Folders found: ',
164
+                'personalFolders' => json_encode($personalFolders),
188 165
             ),
189 166
             'encode'
190 167
         );
191 168
         break;
192
-    }
193 169
 
194
-    // decrypt and retrieve data in JSON format
195
-    $dataReceived = prepareExchangedData(
196
-        $post_data,
197
-        'decode'
198
-    );
170
+    case 'perform_fix_pf_items-step2':
171
+        // Check KEY
172
+        if (!hash_equals((string) $session->get('key'), (string) $post_key)) {
173
+            echo prepareExchangedData(
174
+                array(
175
+                    'error' => true,
176
+                    'message' => $lang->get('key_is_not_correct'),
177
+                ),
178
+                'encode'
179
+            );
180
+            break;
181
+        }
182
+        // Is admin?
183
+        if ((int) $session->get('user-admin') !== 1) {
184
+            echo prepareExchangedData(
185
+                array(
186
+                    'error' => true,
187
+                    'message' => $lang->get('error_not_allowed_to'),
188
+                ),
189
+                'encode'
190
+            );
191
+            break;
192
+        }
199 193
 
200
-    $userId = filter_var($dataReceived['userId'], FILTER_SANITIZE_NUMBER_INT);
201
-    $personalFolders = filter_var($dataReceived['personalFolders'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
194
+        // decrypt and retrieve data in JSON format
195
+        $dataReceived = prepareExchangedData(
196
+            $post_data,
197
+            'decode'
198
+        );
199
+
200
+        $userId = filter_var($dataReceived['userId'], FILTER_SANITIZE_NUMBER_INT);
201
+        $personalFolders = filter_var($dataReceived['personalFolders'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
202 202
 
203
-    // Delete all private items with sharekeys
204
-    $pfiSharekeys = DB::queryFirstColumn(
205
-        'select s.increment_id
203
+        // Delete all private items with sharekeys
204
+        $pfiSharekeys = DB::queryFirstColumn(
205
+            'select s.increment_id
206 206
         from teampass_sharekeys_items as s
207 207
         INNER JOIN teampass_items AS i ON (i.id = s.object_id)
208 208
         WHERE s.user_id = %i AND i.perso = 1 AND i.id_tree IN %ls',
209
-        $userId,
210
-        $personalFolders
211
-    );
212
-    $pfiSharekeysCount = DB::count();
213
-    if ($pfiSharekeysCount > 0) {
214
-        DB::delete(
215
-            "teampass_sharekeys_items",
216
-            "increment_id IN %ls",
217
-            $pfiSharekeys
209
+            $userId,
210
+            $personalFolders
218 211
         );
219
-    }
212
+        $pfiSharekeysCount = DB::count();
213
+        if ($pfiSharekeysCount > 0) {
214
+            DB::delete(
215
+                "teampass_sharekeys_items",
216
+                "increment_id IN %ls",
217
+                $pfiSharekeys
218
+            );
219
+        }
220 220
 
221 221
     
222
-    //Show done
223
-    echo prepareExchangedData(
224
-        array(
225
-            'error' => false,
226
-            'message' => '<br>Number of Sharekeys for private items DELETED: ',
227
-            'nbDeleted' => $pfiSharekeysCount,
228
-            'personalFolders' => json_encode($personalFolders),
229
-        ),
230
-        'encode'
231
-    );
232
-    break;
233
-
234
-case 'perform_fix_pf_items-step3':
235
-    // Check KEY
236
-    if (!hash_equals((string) $session->get('key'), (string) $post_key)) {
237
-        echo prepareExchangedData(
238
-            array(
239
-                'error' => true,
240
-                'message' => $lang->get('key_is_not_correct'),
241
-            ),
242
-            'encode'
243
-        );
244
-        break;
245
-    }
246
-    // Is admin?
247
-    if ((int) $session->get('user-admin') !== 1) {
222
+        //Show done
248 223
         echo prepareExchangedData(
249 224
             array(
250
-                'error' => true,
251
-                'message' => $lang->get('error_not_allowed_to'),
225
+                'error' => false,
226
+                'message' => '<br>Number of Sharekeys for private items DELETED: ',
227
+                'nbDeleted' => $pfiSharekeysCount,
228
+                'personalFolders' => json_encode($personalFolders),
252 229
             ),
253 230
             'encode'
254 231
         );
255 232
         break;
256
-    }
257 233
 
258
-    // decrypt and retrieve data in JSON format
259
-    $dataReceived = prepareExchangedData(
260
-        $post_data,
261
-        'decode'
262
-    );
234
+    case 'perform_fix_pf_items-step3':
235
+        // Check KEY
236
+        if (!hash_equals((string) $session->get('key'), (string) $post_key)) {
237
+            echo prepareExchangedData(
238
+                array(
239
+                    'error' => true,
240
+                    'message' => $lang->get('key_is_not_correct'),
241
+                ),
242
+                'encode'
243
+            );
244
+            break;
245
+        }
246
+        // Is admin?
247
+        if ((int) $session->get('user-admin') !== 1) {
248
+            echo prepareExchangedData(
249
+                array(
250
+                    'error' => true,
251
+                    'message' => $lang->get('error_not_allowed_to'),
252
+                ),
253
+                'encode'
254
+            );
255
+            break;
256
+        }
257
+
258
+        // decrypt and retrieve data in JSON format
259
+        $dataReceived = prepareExchangedData(
260
+            $post_data,
261
+            'decode'
262
+        );
263 263
 
264
-    $userId = filter_var($dataReceived['userId'], FILTER_SANITIZE_NUMBER_INT);
265
-    $personalFolders = filter_var($dataReceived['personalFolders'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
264
+        $userId = filter_var($dataReceived['userId'], FILTER_SANITIZE_NUMBER_INT);
265
+        $personalFolders = filter_var($dataReceived['personalFolders'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
266 266
 
267
-    // Update from items_old to items all the private itemsitems that have been converted to teampass_aes
268
-    // Get all key back
269
-    $items = DB::query(
270
-        "SELECT id
267
+        // Update from items_old to items all the private itemsitems that have been converted to teampass_aes
268
+        // Get all key back
269
+        $items = DB::query(
270
+            "SELECT id
271 271
         FROM teampass_items
272 272
         WHERE id_tree IN %ls AND encryption_type = %s",
273
-        $personalFolders,
274
-        "teampass_aes"
275
-    );
276
-    //DB::debugMode(false);
277
-    $nbItems = DB::count();
278
-    foreach ($items as $item) {
279
-        $defusePwd = DB::queryFirstField("SELECT pw FROM teampass_items_old WHERE id = %i", $item['id']);
280
-        DB::update(
281
-            "teampass_items",
282
-            ['pw' => $defusePwd, "encryption_type" => "defuse"],
283
-            "id = %i",
284
-            $item['id']
273
+            $personalFolders,
274
+            "teampass_aes"
285 275
         );
286
-    }
276
+        //DB::debugMode(false);
277
+        $nbItems = DB::count();
278
+        foreach ($items as $item) {
279
+            $defusePwd = DB::queryFirstField("SELECT pw FROM teampass_items_old WHERE id = %i", $item['id']);
280
+            DB::update(
281
+                "teampass_items",
282
+                ['pw' => $defusePwd, "encryption_type" => "defuse"],
283
+                "id = %i",
284
+                $item['id']
285
+            );
286
+        }
287 287
 
288 288
     
289
-    //Show done
290
-    echo prepareExchangedData(
291
-        array(
292
-            'error' => false,
293
-            'message' => '<br>Number of items reseted to Defuse: ',
294
-            'nbItems' => $nbItems,
295
-            'personalFolders' => json_encode($personalFolders),
296
-        ),
297
-        'encode'
298
-    );
299
-    break;
300
-
301
-    /* TOOL #2 - Fixing items master keys */
302
-    /*
289
+        //Show done
290
+        echo prepareExchangedData(
291
+            array(
292
+                'error' => false,
293
+                'message' => '<br>Number of items reseted to Defuse: ',
294
+                'nbItems' => $nbItems,
295
+                'personalFolders' => json_encode($personalFolders),
296
+            ),
297
+            'encode'
298
+        );
299
+        break;
300
+
301
+        /* TOOL #2 - Fixing items master keys */
302
+        /*
303 303
     * STEP 1 - Check if we have the correct pwd for TP_USER
304 304
     */
305 305
     case 'perform_fix_items_master_keys-step1':
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('tools') === false) {
71 71
     // Not allowed page
72 72
     $session->set('system-error_code', ERR_NOT_ALLOWED);
73
-    include $SETTINGS['cpassman_dir'] . '/error.php';
73
+    include $SETTINGS['cpassman_dir'].'/error.php';
74 74
     exit;
75 75
 }
76 76
 
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
         // Get PT_USER info
336 336
         $userInfo = DB::queryFirstRow(
337 337
             'SELECT pw, public_key, private_key, login, name
338
-            FROM ' . prefixTable('users') . '
338
+            FROM ' . prefixTable('users').'
339 339
             WHERE id = %i',
340 340
             TP_USER_ID
341 341
         );
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
         // Get one itemKey from current user
373 373
         $currentUserKey = DB::queryFirstRow(
374 374
             'SELECT ski.share_key, ski.increment_id AS increment_id, l.id_user
375
-            FROM ' . prefixTable('sharekeys_items') . ' AS ski
376
-            INNER JOIN ' . prefixTable('log_items') . ' AS l ON ski.object_id = l.id_item
375
+            FROM ' . prefixTable('sharekeys_items').' AS ski
376
+            INNER JOIN ' . prefixTable('log_items').' AS l ON ski.object_id = l.id_item
377 377
             WHERE ski.user_id = %i
378 378
             ORDER BY RAND()
379 379
             LIMIT 1',
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
                 echo  prepareExchangedData(
393 393
                     array(
394 394
                         'error' => true,
395
-                        'message' => 'No issue found, normal process should work. This process is now finished. (item id : ' . $currentUserKey['increment_id'] . ')',
395
+                        'message' => 'No issue found, normal process should work. This process is now finished. (item id : '.$currentUserKey['increment_id'].')',
396 396
                     ),
397 397
                     'encode'
398 398
                 );
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
         // Get user info
453 453
         $userInfo = DB::queryFirstRow(
454 454
             'SELECT public_key, private_key
455
-            FROM ' . prefixTable('users') . '
455
+            FROM ' . prefixTable('users').'
456 456
             WHERE id = %i',
457 457
             $userId
458 458
         );
@@ -475,8 +475,8 @@  discard block
 block discarded – undo
475 475
         // Get one itemKey from current user
476 476
         $currentUserKey = DB::queryFirstRow(
477 477
             'SELECT ski.share_key, ski.increment_id AS increment_id, l.id_user
478
-            FROM ' . prefixTable('sharekeys_items') . ' AS ski
479
-            INNER JOIN ' . prefixTable('log_items') . ' AS l ON ski.object_id = l.id_item
478
+            FROM ' . prefixTable('sharekeys_items').' AS ski
479
+            INNER JOIN ' . prefixTable('log_items').' AS l ON ski.object_id = l.id_item
480 480
             WHERE ski.user_id = %i
481 481
             ORDER BY RAND()
482 482
             LIMIT 1',
@@ -514,8 +514,8 @@  discard block
 block discarded – undo
514 514
                 // Get number of users to treat
515 515
                 DB::query(
516 516
                     'SELECT i.id 
517
-                    FROM ' . prefixTable('items') . ' AS i
518
-                    INNER JOIN ' . prefixTable('sharekeys_items') . ' AS si ON i.id = si.object_id
517
+                    FROM ' . prefixTable('items').' AS i
518
+                    INNER JOIN ' . prefixTable('sharekeys_items').' AS si ON i.id = si.object_id
519 519
                     WHERE i.perso = %i AND si.user_id = %i;',
520 520
                     0,
521 521
                     $userId
@@ -597,11 +597,11 @@  discard block
 block discarded – undo
597 597
             // Loop on items
598 598
             $rows = DB::query(
599 599
                 'SELECT si.object_id AS object_id, si.share_key AS share_key, i.pw AS pw, si.increment_id as increment_id
600
-                FROM ' . prefixTable('sharekeys_items') . ' AS si
601
-                INNER JOIN ' . prefixTable('items') . ' AS i ON (i.id = si.object_id)
600
+                FROM ' . prefixTable('sharekeys_items').' AS si
601
+                INNER JOIN ' . prefixTable('items').' AS i ON (i.id = si.object_id)
602 602
                 WHERE si.user_id = %i
603 603
                 ORDER BY si.increment_id ASC
604
-                LIMIT ' . $startIndex . ', ' . $limit,
604
+                LIMIT ' . $startIndex.', '.$limit,
605 605
                 $userId
606 606
             );        
607 607
             
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
                     // It will be updated if already exists
626 626
                     $currentTPUserKey = DB::queryFirstRow(
627 627
                         'SELECT increment_id, user_id, share_key
628
-                        FROM ' . prefixTable('sharekeys_items') . '
628
+                        FROM ' . prefixTable('sharekeys_items').'
629 629
                         WHERE object_id = %i AND user_id = %i',
630 630
                         $record['object_id'],
631 631
                         TP_USER_ID
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
             DB::commit();
662 662
         } catch (Exception $e) {
663 663
             DB::rollback();
664
-            error_log("Teampass - Error: Keys treatment: " . $e->getMessage());
664
+            error_log("Teampass - Error: Keys treatment: ".$e->getMessage());
665 665
         }
666 666
 
667 667
         $nextIndex = (int) $startIndex + (int) $limit;
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
             // Get PT_USER info
718 718
             DB::queryFirstRow(
719 719
                 'SELECT operation_code
720
-                FROM ' . prefixTable('sharekeys_backup') . '
720
+                FROM ' . prefixTable('sharekeys_backup').'
721 721
                 WHERE operation_code = %s',
722 722
                 $operationCode
723 723
             );
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
                 // using increment_id_value in order to update the correct record
728 728
                 $rows = DB::query(
729 729
                     'SELECT *
730
-                    FROM ' . prefixTable('sharekeys_backup') . '
730
+                    FROM ' . prefixTable('sharekeys_backup').'
731 731
                     WHERE operation_code = %s',
732 732
                     $operationCode
733 733
                 );
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
 
747 747
                 // Delete all sharekeys for this operation
748 748
                 DB::query(
749
-                    'DELETE FROM ' . prefixTable('sharekeys_backup') . '
749
+                    'DELETE FROM '.prefixTable('sharekeys_backup').'
750 750
                     WHERE operation_code = %i',
751 751
                     $operationCode
752 752
                 );
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
             // Get operation info
810 810
             DB::query(
811 811
                 'SELECT operation_code
812
-                FROM ' . prefixTable('sharekeys_backup') . '
812
+                FROM ' . prefixTable('sharekeys_backup').'
813 813
                 WHERE operation_code = %s',
814 814
                 $operationCode
815 815
             );
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
             if ($nbKeys > 0) {
819 819
                 // Delete all sharekeys for this operation
820 820
                 DB::query(
821
-                    'DELETE FROM ' . prefixTable('sharekeys_backup') . '
821
+                    'DELETE FROM '.prefixTable('sharekeys_backup').'
822 822
                     WHERE operation_code = %s',
823 823
                     $operationCode
824 824
                 );
Please login to merge, or discard this patch.
sources/users.logs.datatable.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 ) {
76 76
     // Not allowed page
77 77
     $session->set('system-error_code', ERR_NOT_ALLOWED);
78
-    include $SETTINGS['cpassman_dir'] . '/error.php';
78
+    include $SETTINGS['cpassman_dir'].'/error.php';
79 79
     exit;
80 80
 }
81 81
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     if (isset($order['column']) && preg_match('#^(asc|desc)$#i', $order['dir'])) {
146 146
         $columnIndex = $order['column'];
147 147
         $dir = $inputData['dir'];
148
-        $sOrder .= $aColumns[$columnIndex] . ' ' . $dir . ', ';
148
+        $sOrder .= $aColumns[$columnIndex].' '.$dir.', ';
149 149
     }
150 150
 
151 151
     $sOrder = substr_replace($sOrder, '', -2);
Please login to merge, or discard this patch.
sources/folders.class.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@
 block discarded – undo
113 113
     private function isParentFolderAllowed($parent_id, $user_accessible_folders, $user_is_admin, $user_can_create_root_folder)
114 114
     {
115 115
         if ($parent_id == 0 && $user_can_create_root_folder == true)
116
-	    return true;
116
+        return true;
117 117
 
118 118
         if (in_array($parent_id, $user_accessible_folders) === false
119 119
             && (int) $user_is_admin !== 1
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -112,8 +112,9 @@  discard block
 block discarded – undo
112 112
      */
113 113
     private function isParentFolderAllowed($parent_id, $user_accessible_folders, $user_is_admin, $user_can_create_root_folder)
114 114
     {
115
-        if ($parent_id == 0 && $user_can_create_root_folder == true)
116
-	    return true;
115
+        if ($parent_id == 0 && $user_can_create_root_folder == true) {
116
+        	    return true;
117
+        }
117 118
 
118 119
         if (in_array($parent_id, $user_accessible_folders) === false
119 120
             && (int) $user_is_admin !== 1
@@ -438,8 +439,9 @@  discard block
 block discarded – undo
438 439
             )['count'];
439 440
 
440 441
             // Don't insert duplicates
441
-            if ($count > 0)
442
-                continue;
442
+            if ($count > 0) {
443
+                            continue;
444
+            }
443 445
 
444 446
             // Insert new background task
445 447
             DB::insert(
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
         $parentComplexity = $this->checkComplexityLevel($parentFolderData, $complexity, $parent_id);
93 93
         if (isset($parentComplexity['error']) && $parentComplexity['error'] === true) {
94
-            return $this->errorResponse($this->lang->get('error_folder_complexity_lower_than_top_folder') . " [<b>{$this->settings['TP_PW_COMPLEXITY'][$parentComplexity['valeur']][1]}</b>]");
94
+            return $this->errorResponse($this->lang->get('error_folder_complexity_lower_than_top_folder')." [<b>{$this->settings['TP_PW_COMPLEXITY'][$parentComplexity['valeur']][1]}</b>]");
95 95
         }
96 96
 
97 97
         return $this->createFolder($params, array_merge($parentFolderData, $parentComplexity), $options);
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
         ) {
145 145
             DB::query(
146 146
                 'SELECT *
147
-                FROM ' . prefixTable('nested_tree') . '
147
+                FROM ' . prefixTable('nested_tree').'
148 148
                 WHERE title = %s AND personal_folder = 0',
149 149
                 $title
150 150
             );
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         //check if parent folder is personal
169 169
         $data = DB::queryFirstRow(
170 170
             'SELECT personal_folder, bloquer_creation, bloquer_modification
171
-            FROM ' . prefixTable('nested_tree') . '
171
+            FROM ' . prefixTable('nested_tree').'
172 172
             WHERE id = %i',
173 173
             $parent_id
174 174
         );
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
             // get complexity level for this folder
208 208
             $data = DB::queryFirstRow(
209 209
                 'SELECT valeur
210
-                FROM ' . prefixTable('misc') . '
210
+                FROM ' . prefixTable('misc').'
211 211
                 WHERE intitule = %i AND type = %s',
212 212
                 $parent_id,
213 213
                 'complex'
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
      */
279 279
     private function canCreateFolder($isPersonal, $user_is_admin, $user_is_manager, $user_can_manage_all_users, $user_can_create_root_folder)
280 280
     {
281
-        return (int)$isPersonal === 1 ||
282
-            (int)$user_is_admin === 1 ||
283
-            ((int)$user_is_manager === 1 || (int)$user_can_manage_all_users === 1) ||
281
+        return (int) $isPersonal === 1 ||
282
+            (int) $user_is_admin === 1 ||
283
+            ((int) $user_is_manager === 1 || (int) $user_can_manage_all_users === 1) ||
284 284
             ($this->settings['enable_user_can_create_folders'] ?? false) ||
285
-            ((int)$user_can_create_root_folder === 1);
285
+            ((int) $user_can_create_root_folder === 1);
286 286
     }
287 287
 
288 288
     /**
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
         $path = '';
363 363
         $tree_path = $tree->getPath(0, false);
364 364
         foreach ($tree_path as $fld) {
365
-            $path .= empty($path) ? $fld->title : '/' . $fld->title;
365
+            $path .= empty($path) ? $fld->title : '/'.$fld->title;
366 366
         }
367 367
 
368 368
         $new_json = [
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 
379 379
         $cache_tree = DB::queryFirstRow(
380 380
             'SELECT increment_id, folders, visible_folders 
381
-            FROM ' . prefixTable('cache_tree') . ' 
381
+            FROM ' . prefixTable('cache_tree').' 
382 382
             WHERE user_id = %i', 
383 383
             (int) $user_id
384 384
         );
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
     private function manageFolderPermissions($parent_id, $newId, $user_roles, $access_rights, $user_is_admin)
420 420
     {
421 421
         if ($parent_id !== 0 && $this->settings['subfolder_rights_as_parent'] ?? false) {
422
-            $rows = DB::query('SELECT role_id, type FROM ' . prefixTable('roles_values') . ' WHERE folder_id = %i', $parent_id);
422
+            $rows = DB::query('SELECT role_id, type FROM '.prefixTable('roles_values').' WHERE folder_id = %i', $parent_id);
423 423
             foreach ($rows as $record) {
424 424
                 DB::insert(prefixTable('roles_values'), [
425 425
                     'role_id' => $record['role_id'],
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
                     'type' => $record['type'],
428 428
                 ]);
429 429
             }
430
-        } elseif ((int)$user_is_admin !== 1) {
430
+        } elseif ((int) $user_is_admin !== 1) {
431 431
             foreach (array_unique(explode(';', $user_roles)) as $role) {
432 432
                 if (!empty($role)) {
433 433
                     DB::insert(prefixTable('roles_values'), [
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
      */
446 446
     private function copyCustomFieldsCategories($parent_id, $newId)
447 447
     {
448
-        $rows = DB::query('SELECT id_category FROM ' . prefixTable('categories_folders') . ' WHERE id_folder = %i', $parent_id);
448
+        $rows = DB::query('SELECT id_category FROM '.prefixTable('categories_folders').' WHERE id_folder = %i', $parent_id);
449 449
         foreach ($rows as $record) {
450 450
             DB::insert(prefixTable('categories_folders'), [
451 451
                 'id_category' => $record['id_category'],
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
             // Search for existing job
471 471
             $count = DB::queryFirstRow(
472 472
                 'SELECT COUNT(*) AS count
473
-                FROM ' . prefixTable('background_tasks') . '
473
+                FROM ' . prefixTable('background_tasks').'
474 474
                 WHERE is_in_progress = %i AND process_type = %s AND arguments = %s',
475 475
                 0,
476 476
                 'user_build_cache_tree',
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
         return [
505 505
             'error' => true,
506 506
             'message' => $message,
507
-            'newId' => '' . $newIdSuffix,
507
+            'newId' => ''.$newIdSuffix,
508 508
         ];
509 509
     }
510 510
 }
Please login to merge, or discard this patch.
sources/import.queries.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1364,4 +1364,4 @@
 block discarded – undo
1364 1364
     $string = str_replace("{%}", "?", $string);
1365 1365
     // Trim and return.
1366 1366
     return trim($string);
1367
-  }
1367
+    }
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 ) {
80 80
     // Not allowed page
81 81
     $session->set('system-error_code', ERR_NOT_ALLOWED);
82
-    include $SETTINGS['cpassman_dir'] . '/error.php';
82
+    include $SETTINGS['cpassman_dir'].'/error.php';
83 83
     exit;
84 84
 }
85 85
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         );
168 168
 
169 169
         // Initialisation
170
-        $file = $SETTINGS['path_to_files_folder'] . '/' . $data['valeur'];
170
+        $file = $SETTINGS['path_to_files_folder'].'/'.$data['valeur'];
171 171
         $importation_possible = true;
172 172
         $valuesToImport = [];
173 173
         $items_number = 0;
@@ -224,26 +224,26 @@  discard block
 block discarded – undo
224 224
                 'ISO-8859-1',
225 225
                 'ISO-8859-15',
226 226
                 'Windows-1252',
227
-                'Windows-1251',  // Cyrillique
228
-                'CP1251',        // Cyrillique alternatif
229
-                'KOI8-R',        // Cyrillique russe
230
-                'Shift_JIS',     // Japonais
231
-                'EUC-JP',        // Japonais
232
-                'ISO-2022-JP',   // Japonais
233
-                'TIS-620',       // ThaĂŻ
234
-                'Windows-874',   // ThaĂŻ Windows
235
-                'Big5',          // Chinois traditionnel
236
-                'GB2312',        // Chinois simplifié
237
-                'GBK',           // Chinois simplifié étendu
238
-                'EUC-KR',        // Coréen
239
-                'ISO-8859-2',    // Europe centrale
240
-                'ISO-8859-5',    // Cyrillique ISO
241
-                'ISO-8859-7',    // Grec
242
-                'Windows-1250',  // Europe centrale
243
-                'Windows-1253',  // Grec
244
-                'Windows-1254',  // Turc
245
-                'Windows-1255',  // Hébreu
246
-                'Windows-1256',  // Arabe
227
+                'Windows-1251', // Cyrillique
228
+                'CP1251', // Cyrillique alternatif
229
+                'KOI8-R', // Cyrillique russe
230
+                'Shift_JIS', // Japonais
231
+                'EUC-JP', // Japonais
232
+                'ISO-2022-JP', // Japonais
233
+                'TIS-620', // ThaĂŻ
234
+                'Windows-874', // ThaĂŻ Windows
235
+                'Big5', // Chinois traditionnel
236
+                'GB2312', // Chinois simplifié
237
+                'GBK', // Chinois simplifié étendu
238
+                'EUC-KR', // Coréen
239
+                'ISO-8859-2', // Europe centrale
240
+                'ISO-8859-5', // Cyrillique ISO
241
+                'ISO-8859-7', // Grec
242
+                'Windows-1250', // Europe centrale
243
+                'Windows-1253', // Grec
244
+                'Windows-1254', // Turc
245
+                'Windows-1255', // Hébreu
246
+                'Windows-1256', // Arabe
247 247
             ];
248 248
 
249 249
             // Get the list of encodings supported by the system
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 
287 287
         // Get the data and ensure columns are correctly mapped
288 288
         $interpreter = new Interpreter();
289
-        $interpreter->addObserver(function (array $row) use (&$valuesToImport, $header) {
289
+        $interpreter->addObserver(function(array $row) use (&$valuesToImport, $header) {
290 290
             $rowData = array_combine($header, $row);
291 291
 
292 292
             if ($rowData !== false) {
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
             // Handle multiple lignes description
340 340
             if (strpos($comments, '<br>') !== false || strpos($label, '<br>') !== false) {
341 341
                 $continue_on_next_line = true;
342
-                $comment .= " " . $label . " " . $comments;
342
+                $comment .= " ".$label." ".$comments;
343 343
             } else {
344 344
                 // Insert previous line if changing line
345 345
                 if (!empty($label)) {
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
                     // Insert in batch
349 349
                     $batchInsert[] = array(
350 350
                         'label'        => $label,
351
-                        'description'  => $comment . $comments,
351
+                        'description'  => $comment.$comments,
352 352
                         'pwd'          => $pwd,
353 353
                         'url'          => $url,
354 354
                         'folder'       => ((int) $session->get('user-admin') === 1 || (int) $session->get('user-manager') === 1 || (int) $session->get('user-can_manage_all_users') === 1) ? $folder : '',
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
             // Insert in batch
380 380
             $batchInsert[] = array(
381 381
                 'label'        => $label,
382
-                'description'  => $comment . $comments,
382
+                'description'  => $comment.$comments,
383 383
                 'pwd'          => $pwd,
384 384
                 'url'          => $url,
385 385
                 'folder'       => ((int) $session->get('user-admin') === 1 || (int) $session->get('user-manager') === 1 || (int) $session->get('user-can_manage_all_users') === 1) ? $folder : '',
@@ -403,10 +403,10 @@  discard block
 block discarded – undo
403 403
             $values = [];
404 404
 
405 405
             foreach ($batchInsert as $data) {
406
-                $values[] = "('" . implode("','", array_map('addslashes', $data)) . "')";
406
+                $values[] = "('".implode("','", array_map('addslashes', $data))."')";
407 407
             }
408 408
 
409
-            $sql = "INSERT INTO `$tableName` (`label`, `description`, `pwd`, `url`, `folder`, `login`, `operation_id`) VALUES " . implode(',', $values);
409
+            $sql = "INSERT INTO `$tableName` (`label`, `description`, `pwd`, `url`, `folder`, `login`, `operation_id`) VALUES ".implode(',', $values);
410 410
 
411 411
             DB::query($sql);
412 412
         }
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
             $parentId = $dataReceived['folderId']; // Strating with provided folder
490 490
 
491 491
             foreach ($parts as $part) {
492
-                $currentPath = trim($currentPath . "/" . $part, "/");
492
+                $currentPath = trim($currentPath."/".$part, "/");
493 493
                 $currentFolder = $part;
494 494
 
495 495
                 // Check if this folder has already been created
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
                         // Get ID of existing folder
551 551
                         $ret = DB::queryFirstRow(
552 552
                             'SELECT *
553
-                            FROM ' . prefixTable('nested_tree') . '
553
+                            FROM ' . prefixTable('nested_tree').'
554 554
                             WHERE title = %s',
555 555
                             $currentFolder
556 556
                         );
@@ -760,9 +760,9 @@  discard block
 block discarded – undo
760 760
                 ];
761 761
 
762 762
                 error_log(
763
-                    'SQL Error during import | increment_id: ' . $item['increment_id'] .
764
-                    ' | Message: ' . $e->getMessage() .
765
-                    ' | StackTrace: ' . $e->getTraceAsString()
763
+                    'SQL Error during import | increment_id: '.$item['increment_id'].
764
+                    ' | Message: '.$e->getMessage().
765
+                    ' | StackTrace: '.$e->getTraceAsString()
766 766
                 );
767 767
             }
768 768
         }
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
         ];
1072 1072
         $startPathLevel = 1;
1073 1073
 
1074
-        foreach($post_folders as $folder) {
1074
+        foreach ($post_folders as $folder) {
1075 1075
             // get parent id
1076 1076
             if (!isset($arrFolders[$folder['parentFolderId']])) {
1077 1077
                 // If parent folder is not in the array, it means it is the destination folder
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
         DB::startTransaction();
1148 1148
 
1149 1149
         // Import all items
1150
-        foreach($post_items as $item) {
1150
+        foreach ($post_items as $item) {
1151 1151
             // get info about this folder
1152 1152
             $destinationFolderMore = DB::queryFirstRow(
1153 1153
                 'SELECT title FROM '.prefixTable('nested_tree').' WHERE id = %i',
@@ -1178,7 +1178,7 @@  discard block
 block discarded – undo
1178 1178
                     'pw' => $cryptedStuff['encrypted'],
1179 1179
                     'pw_iv' => '',
1180 1180
                     'url' => substr($item['URL'], 0, 500),
1181
-                    'id_tree' => isset($post_folders[$item['parentFolderId']]['id']) ? (int)$post_folders[$item['parentFolderId']]['id'] : 0,
1181
+                    'id_tree' => isset($post_folders[$item['parentFolderId']]['id']) ? (int) $post_folders[$item['parentFolderId']]['id'] : 0,
1182 1182
                     'login' => substr($item['UserName'], 0, 500),
1183 1183
                     'anyone_can_modify' => $$inputData['editAll'],
1184 1184
                     'encryption_type' => 'teampass_aes',
@@ -1313,7 +1313,7 @@  discard block
 block discarded – undo
1313 1313
 
1314 1314
         //For each role to which the user depends on, add the folder just created.
1315 1315
         // (if not personal, otherwise, add to user-personal_folders)
1316
-        if ( $isPersonalFolder ) {
1316
+        if ($isPersonalFolder) {
1317 1317
             SessionManager::addRemoveFromSessionArray('user-personal_folders', [$id], 'add');
1318 1318
         } else {
1319 1319
             foreach ($session->get('system-array_roles') as $role) {
@@ -1384,7 +1384,7 @@  discard block
 block discarded – undo
1384 1384
     ];
1385 1385
 }
1386 1386
 
1387
-spl_autoload_register(function ($class) {
1387
+spl_autoload_register(function($class) {
1388 1388
     $prefix = 'League\\Csv\\';
1389 1389
     $base_dir = __DIR__.'/src/';
1390 1390
     $len = strlen($prefix);
Please login to merge, or discard this patch.
scripts/traits/ItemHandlerTrait.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 trait ItemHandlerTrait {    
30 30
 
31 31
     private function generateUserPasswordKeys($arguments) {
32
-        if (LOG_TASKS=== true) $this->logger->log('Processing generateUserPasswordKeys : '.print_r($arguments, true), 'DEBUG');
32
+        if (LOG_TASKS === true) $this->logger->log('Processing generateUserPasswordKeys : '.print_r($arguments, true), 'DEBUG');
33 33
         // Generate keys for user passwords   
34 34
         storeUsersShareKey(
35 35
             prefixTable('sharekeys_items'),
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
      * @param array $taskData
50 50
      */
51 51
     private function generateUserFileKeys($taskData) {    
52
-        if (LOG_TASKS=== true) $this->logger->log('Processing generateUserFileKeys : '.print_r($taskData, true), 'DEBUG');
53
-        foreach($taskData['files_keys'] as $file) {
52
+        if (LOG_TASKS === true) $this->logger->log('Processing generateUserFileKeys : '.print_r($taskData, true), 'DEBUG');
53
+        foreach ($taskData['files_keys'] as $file) {
54 54
             storeUsersShareKey(
55 55
                 prefixTable('sharekeys_files'),
56 56
                 0,
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
      * @param array $arguments
71 71
      */
72 72
     private function generateUserFieldKeys($arguments) {
73
-        if (LOG_TASKS=== true) $this->logger->log('Processing generateUserFieldKeys : '.print_r($arguments, true), 'DEBUG');
74
-        foreach($arguments['fields_keys'] as $field) {
75
-            $this->logger->log('Processing generateUserFieldKeys for: ' . $field['object_id'], 'DEBUG');
73
+        if (LOG_TASKS === true) $this->logger->log('Processing generateUserFieldKeys : '.print_r($arguments, true), 'DEBUG');
74
+        foreach ($arguments['fields_keys'] as $field) {
75
+            $this->logger->log('Processing generateUserFieldKeys for: '.$field['object_id'], 'DEBUG');
76 76
             storeUsersShareKey(
77 77
                 prefixTable('sharekeys_fields'),
78 78
                 0,
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 trait ItemHandlerTrait {    
30 30
 
31 31
     private function generateUserPasswordKeys($arguments) {
32
-        if (LOG_TASKS=== true) $this->logger->log('Processing generateUserPasswordKeys : '.print_r($arguments, true), 'DEBUG');
32
+        if (LOG_TASKS=== true) {
33
+            $this->logger->log('Processing generateUserPasswordKeys : '.print_r($arguments, true), 'DEBUG');
34
+        }
33 35
         // Generate keys for user passwords   
34 36
         storeUsersShareKey(
35 37
             prefixTable('sharekeys_items'),
@@ -49,7 +51,9 @@  discard block
 block discarded – undo
49 51
      * @param array $taskData
50 52
      */
51 53
     private function generateUserFileKeys($taskData) {    
52
-        if (LOG_TASKS=== true) $this->logger->log('Processing generateUserFileKeys : '.print_r($taskData, true), 'DEBUG');
54
+        if (LOG_TASKS=== true) {
55
+            $this->logger->log('Processing generateUserFileKeys : '.print_r($taskData, true), 'DEBUG');
56
+        }
53 57
         foreach($taskData['files_keys'] as $file) {
54 58
             storeUsersShareKey(
55 59
                 prefixTable('sharekeys_files'),
@@ -70,7 +74,9 @@  discard block
 block discarded – undo
70 74
      * @param array $arguments
71 75
      */
72 76
     private function generateUserFieldKeys($arguments) {
73
-        if (LOG_TASKS=== true) $this->logger->log('Processing generateUserFieldKeys : '.print_r($arguments, true), 'DEBUG');
77
+        if (LOG_TASKS=== true) {
78
+            $this->logger->log('Processing generateUserFieldKeys : '.print_r($arguments, true), 'DEBUG');
79
+        }
74 80
         foreach($arguments['fields_keys'] as $field) {
75 81
             $this->logger->log('Processing generateUserFieldKeys for: ' . $field['object_id'], 'DEBUG');
76 82
             storeUsersShareKey(
Please login to merge, or discard this patch.
scripts/task_maintenance_users_personal_folder.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     //get through all users with enabled personnal folder.
81 81
     $users = DB::query(
82 82
         'SELECT id, login, email
83
-        FROM ' . prefixTable('users') . '
83
+        FROM ' . prefixTable('users').'
84 84
         WHERE id NOT IN ('.OTV_USER_ID.', '.TP_USER_ID.', '.SSH_USER_ID.', '.API_USER_ID.')
85 85
         AND personal_folder = 1
86 86
         ORDER BY login ASC'
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         //if folder doesn't exist then create it
90 90
         $data = DB::queryFirstRow(
91 91
             'SELECT id
92
-            FROM ' . prefixTable('nested_tree') . '
92
+            FROM ' . prefixTable('nested_tree').'
93 93
             WHERE title = %s AND parent_id = %i',
94 94
             $user['id'],
95 95
             0
Please login to merge, or discard this patch.
scripts/background_tasks___do_calculation.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     // get count of Items in this folder
73 73
     $get = DB::queryFirstRow(
74 74
         'SELECT count(*) as num_results
75
-        FROM ' . prefixTable('items') . '
75
+        FROM ' . prefixTable('items').'
76 76
         WHERE inactif = %i AND id_tree = %i',
77 77
         0,
78 78
         $child->id
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
     $ret[$child->id]['id'] = $child->id;
82 82
 
83 83
     // get number of subfolders
84
-    $nodeDescendants =$tree->getDescendants($child->id, false, false, true);
84
+    $nodeDescendants = $tree->getDescendants($child->id, false, false, true);
85 85
     $ret[$child->id]['subfoldersCount'] = count($nodeDescendants);
86 86
 
87 87
     // get items number in subfolders
88 88
     if (count($nodeDescendants) > 0) {
89 89
         $get = DB::queryFirstRow(
90 90
             'SELECT count(*) as num_results
91
-            FROM ' . prefixTable('items') . '
91
+            FROM ' . prefixTable('items').'
92 92
             WHERE inactif = %i AND id_tree IN (%l)',
93 93
             0,
94 94
             implode(',', $nodeDescendants)
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     // Get item key
140 140
     $itemKey = DB::queryFirstRow(
141 141
         'SELECT share_key
142
-        FROM ' . prefixTable('sharekeys_items') . '
142
+        FROM ' . prefixTable('sharekeys_items').'
143 143
         WHERE user_id = %i AND object_id = %i',
144 144
         TP_USER_ID,
145 145
         $item['itemId']
Please login to merge, or discard this patch.