Passed
Pull Request — master (#5000)
by Nils
10:04 queued 03:51
created
sources/logs.datatables.php 1 patch
Spacing   +25 added lines, -27 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 ) {
77 77
     // Not allowed page
78 78
     $session->set('system-error_code', ERR_NOT_ALLOWED);
79
-    include $SETTINGS['cpassman_dir'] . '/error.php';
79
+    include $SETTINGS['cpassman_dir'].'/error.php';
80 80
     exit;
81 81
 }
82 82
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     
169 169
     // Output
170 170
     $sOutput = '{';
171
-    $sOutput .= '"sEcho": '. $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
171
+    $sOutput .= '"sEcho": '.$request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
172 172
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
173 173
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
174 174
     $sOutput .= '"aaData": ';
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
         //col1
182 182
         $sOutput .= '"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['date']).'", ';
183 183
         //col2
184
-        $sOutput .= '"'.str_replace([chr(10), chr(13)], [' ', ' '],(string) $record['label']).'", ';
184
+        $sOutput .= '"'.str_replace([chr(10), chr(13)], [' ', ' '], (string) $record['label']).'", ';
185 185
         //col3
186 186
         $sOutput .= '"'.(string) $record['name'].' '.(string) $record['lastname'].' ['.(string) $record['login'].']"';
187 187
         //Finish the line
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 
243 243
     // Output
244 244
     $sOutput = '{';
245
-    $sOutput .= '"sEcho": '. $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
245
+    $sOutput .= '"sEcho": '.$request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
246 246
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
247 247
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
248 248
     $sOutput .= '"aaData": ';
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 
317 317
     // Output
318 318
     $sOutput = '{';
319
-    $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
319
+    $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
320 320
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
321 321
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
322 322
     $sOutput .= '"aaData": ';
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 
391 391
     // Output
392 392
     $sOutput = '{';
393
-    $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
393
+    $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
394 394
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
395 395
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
396 396
     $sOutput .= '"aaData": [ ';
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 
496 496
     // Output
497 497
     $sOutput = '{';
498
-    $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
498
+    $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
499 499
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
500 500
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
501 501
     $sOutput .= '"aaData": [ ';
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
         $iTotal = 0;
580 580
     }
581 581
     $sOutput = '{';
582
-    $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
582
+    $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
583 583
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
584 584
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
585 585
     $sOutput .= '"aaData": ';
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 
656 656
     // Output
657 657
     $sOutput = '{';
658
-    $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
658
+    $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
659 659
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
660 660
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
661 661
     $sOutput .= '"aaData": ';
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 
726 726
     // Output
727 727
     $sOutput = '{';
728
-    $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
728
+    $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
729 729
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
730 730
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
731 731
     $sOutput .= '"aaData": ';
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 
800 800
     // Output
801 801
     $sOutput = '{';
802
-    $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
802
+    $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
803 803
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
804 804
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
805 805
     $sOutput .= '"aaData": ';
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
             FROM '.prefixTable('background_tasks').' AS p 
878 878
             LEFT JOIN '.prefixTable('users').' AS u ON %l
879 879
             WHERE %l ORDER BY %l %l LIMIT %i, %i';
880
-    $params = ['u.id = json_extract(p.arguments, "$[0]")',$sWhere, $orderColumn, $orderDirection, $sLimitStart, $sLimitLength];
880
+    $params = ['u.id = json_extract(p.arguments, "$[0]")', $sWhere, $orderColumn, $orderDirection, $sLimitStart, $sLimitLength];
881 881
 
882 882
     // Get the records
883 883
     $rows = DB::query($sql, ...$params);
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
 
886 886
     // Output
887 887
     $sOutput = '{';
888
-    $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
888
+    $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
889 889
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
890 890
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
891 891
     $sOutput .= '"aaData": ';
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
         //col1
901 901
         $sOutput .= '"<span data-done=\"'.$record['is_in_progress'].'\" data-type=\"'.$record['process_type'].'\" data-process-id=\"'.$record['increment_id'].'\"></span>", ';
902 902
         //col2
903
-        $sOutput .= '"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['created_at']).'", ';
903
+        $sOutput .= '"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['created_at']).'", ';
904 904
         //col3
905 905
         $sOutput .= '"<div class=\"progress mt-2\"><div class=\"progress-bar\" style=\"width: '.$subtaskProgress.'\">'.$subtaskProgress.'</div></div>", ';
906 906
         //col4
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
         // col5
910 910
         if (in_array($record['process_type'], array('create_user_keys', 'item_copy')) === true) {
911 911
             $data_user = DB::queryFirstRow(
912
-                'SELECT name, lastname FROM ' . prefixTable('users') . '
912
+                'SELECT name, lastname FROM '.prefixTable('users').'
913 913
                 WHERE id = %i',
914 914
                 json_decode($record['arguments'], true)['new_user_id']
915 915
             );
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
     FROM '.prefixTable('background_tasks').' AS p 
967 967
     LEFT JOIN '.prefixTable('users').' AS u ON %l
968 968
     WHERE %l ORDER BY %l %l LIMIT %i, %i';
969
-    $params = ['u.id = json_extract(p.arguments, "$[0]")',$sWhere, $orderColumn, $orderDirection, $sLimitStart, $sLimitLength];
969
+    $params = ['u.id = json_extract(p.arguments, "$[0]")', $sWhere, $orderColumn, $orderDirection, $sLimitStart, $sLimitLength];
970 970
 
971 971
     // Get the records
972 972
     $rows = DB::query($sql, ...$params);
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
 
975 975
     // Output
976 976
     $sOutput = '{';
977
-    $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', ';
977
+    $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', ';
978 978
     $sOutput .= '"iTotalRecords": '.$iTotal.', ';
979 979
     $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', ';
980 980
     $sOutput .= '"aaData": ';
@@ -990,13 +990,12 @@  discard block
 block discarded – undo
990 990
         //col1
991 991
         $sOutput .= '"'.(is_null($record['error_message']) ? '' : addslashes($record['error_message'])).'", ';
992 992
         //col2
993
-        $sOutput .= '"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['created_at']).'", ';
993
+        $sOutput .= '"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['created_at']).'", ';
994 994
         //col3
995 995
         $sOutput .= is_null($record['started_at']) === false ?
996
-            ('"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['started_at']).'", ') :
997
-                ('"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['created_at']).'", ');
996
+            ('"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['started_at']).'", ') : ('"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['created_at']).'", ');
998 997
         //col4
999
-        $sOutput .= '"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['finished_at']).'", '; 
998
+        $sOutput .= '"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['finished_at']).'", '; 
1000 999
         // col7
1001 1000
         $sOutput .= '"'.gmdate('H:i:s', (int) $record['finished_at'] - (is_null($record['started_at']) === false ? (int) $record['started_at'] : (int) $record['created_at'])).'",';
1002 1001
         //col5
@@ -1019,11 +1018,10 @@  discard block
 block discarded – undo
1019 1018
         // col6
1020 1019
         $arguments = json_decode($record['arguments'], true);
1021 1020
         $newUserId = array_key_exists('new_user_id', $arguments) ? 
1022
-            $arguments['new_user_id'] : 
1023
-            (array_key_exists('user_id', $arguments) ? $arguments['user_id'] : null);
1021
+            $arguments['new_user_id'] : (array_key_exists('user_id', $arguments) ? $arguments['user_id'] : null);
1024 1022
         if ($record['process_type'] === 'create_user_keys' && is_null($newUserId) === false && empty($newUserId) === false) {
1025 1023
             $data_user = DB::queryFirstRow(
1026
-                'SELECT name, lastname, login FROM ' . prefixTable('users') . '
1024
+                'SELECT name, lastname, login FROM '.prefixTable('users').'
1027 1025
                 WHERE id = %i',
1028 1026
                 $newUserId
1029 1027
             );
@@ -1040,7 +1038,7 @@  discard block
 block discarded – undo
1040 1038
         } elseif ($record['process_type'] === 'user_build_cache_tree') {
1041 1039
             $user = json_decode($record['arguments'], true)['user_id'];
1042 1040
             $data_user = DB::queryFirstRow(
1043
-                'SELECT name, lastname, login FROM ' . prefixTable('users') . '
1041
+                'SELECT name, lastname, login FROM '.prefixTable('users').'
1044 1042
                 WHERE id = %i',
1045 1043
                 $user
1046 1044
             );
@@ -1075,7 +1073,7 @@  discard block
 block discarded – undo
1075 1073
 {
1076 1074
     $subtasks = DB::query(
1077 1075
         'SELECT *
1078
-        FROM ' . prefixTable('background_subtasks') . '
1076
+        FROM ' . prefixTable('background_subtasks').'
1079 1077
         WHERE task_id = %i',
1080 1078
         $id
1081 1079
     );
@@ -1091,5 +1089,5 @@  discard block
 block discarded – undo
1091 1089
         $i++;
1092 1090
     }
1093 1091
 
1094
-    return ($finished_nb !== 0 ? pourcentage($finished_nb, $nb, 100) : 0) .'%';
1092
+    return ($finished_nb !== 0 ? pourcentage($finished_nb, $nb, 100) : 0).'%';
1095 1093
 }
Please login to merge, or discard this patch.
sources/admin.queries.php 1 patch
Switch Indentation   +247 added lines, -247 removed lines patch added patch discarded remove patch
@@ -2904,8 +2904,8 @@  discard block
 block discarded – undo
2904 2904
 // LIVE ACTIVITY ENDPOINT
2905 2905
 // ========================================
2906 2906
 
2907
-case 'get_live_activity':
2908
-    /**
2907
+    case 'get_live_activity':
2908
+        /**
2909 2909
      * Get recent activity (last 5 minutes, max 10 entries)
2910 2910
      * 
2911 2911
      * @return array [{
@@ -2919,26 +2919,26 @@  discard block
 block discarded – undo
2919 2919
      * }]
2920 2920
      */
2921 2921
     
2922
-    $timestamp5min = time() - 300; // 5 minutes ago
2922
+        $timestamp5min = time() - 300; // 5 minutes ago
2923 2923
     
2924
-    $activities = DB::query(
2925
-        'SELECT l.date, l.id_user, u.login, l.action, l.raison, l.id_item, i.label 
2924
+        $activities = DB::query(
2925
+            'SELECT l.date, l.id_user, u.login, l.action, l.raison, l.id_item, i.label 
2926 2926
         FROM ' . prefixTable('log_items') . ' AS l
2927 2927
         LEFT JOIN ' . prefixTable('users') . ' AS u ON l.id_user = u.id
2928 2928
         LEFT JOIN ' . prefixTable('items') . ' AS i ON l.id_item = i.id
2929 2929
         WHERE l.date > %i
2930 2930
         ORDER BY l.date DESC
2931 2931
         LIMIT 10',
2932
-        $timestamp5min
2933
-    );
2934
-    $activities = secureOutput($activities, ['login']);
2932
+            $timestamp5min
2933
+        );
2934
+        $activities = secureOutput($activities, ['login']);
2935 2935
     
2936
-    $activityList = array();
2936
+        $activityList = array();
2937 2937
     
2938
-    foreach ($activities as $activity) {
2939
-        // Translate action to readable text
2940
-        $actionText = '';
2941
-        switch ($activity['action']) {
2938
+        foreach ($activities as $activity) {
2939
+            // Translate action to readable text
2940
+            $actionText = '';
2941
+            switch ($activity['action']) {
2942 2942
             case 'at_shown':
2943 2943
                 $actionText = $lang->get('action_accessed');
2944 2944
                 break;
@@ -2962,7 +2962,7 @@  discard block
 block discarded – undo
2962 2962
                 break;
2963 2963
             default:
2964 2964
                 $actionText = $activity['action'];
2965
-        }
2965
+            }
2966 2966
         
2967 2967
         $activityList[] = array(
2968 2968
             'timestamp' => (int) $activity['date'],
@@ -2988,8 +2988,8 @@  discard block
 block discarded – undo
2988 2988
 // SYSTEM STATUS ENDPOINT
2989 2989
 // ========================================
2990 2990
 
2991
-case 'get_system_status':
2992
-    /**
2991
+    case 'get_system_status':
2992
+        /**
2993 2993
      * Get system status (tasks queue)
2994 2994
      * 
2995 2995
      * @return array {
@@ -2998,49 +2998,49 @@  discard block
 block discarded – undo
2998 2998
      * }
2999 2999
      */
3000 3000
         
3001
-    // Tasks queue count
3002
-    $tasksQueue = DB::queryFirstField(
3003
-        'SELECT COUNT(*) FROM ' . prefixTable('background_tasks') . ' 
3001
+        // Tasks queue count
3002
+        $tasksQueue = DB::queryFirstField(
3003
+            'SELECT COUNT(*) FROM ' . prefixTable('background_tasks') . ' 
3004 3004
         WHERE finished_at IS NULL OR finished_at = 0'
3005
-    );
3005
+        );
3006 3006
     
3007
-    // Last cron execution
3008
-    $lastCronLog = DB::queryFirstRow(
3009
-        'SELECT created_at FROM ' . prefixTable('background_tasks_logs') . ' 
3007
+        // Last cron execution
3008
+        $lastCronLog = DB::queryFirstRow(
3009
+            'SELECT created_at FROM ' . prefixTable('background_tasks_logs') . ' 
3010 3010
         ORDER BY created_at DESC 
3011 3011
         LIMIT 1'
3012
-    );
3012
+        );
3013 3013
     
3014
-    $lastCronText = $lang->get('never');
3015
-    if ($lastCronLog && isset($lastCronLog['created_at'])) {
3016
-        $timeDiff = time() - (int) $lastCronLog['created_at'];
3017
-        if ($timeDiff < 60) {
3018
-            $lastCronText = $timeDiff . 's ' . $lang->get('ago');
3019
-        } elseif ($timeDiff < 3600) {
3020
-            $lastCronText = floor($timeDiff / 60) . 'm ' . $lang->get('ago');
3021
-        } elseif ($timeDiff < 86400) {
3022
-            $lastCronText = floor($timeDiff / 3600) . 'h ' . $lang->get('ago');
3023
-        } else {
3024
-            $lastCronText = floor($timeDiff / 86400) . 'd ' . $lang->get('ago');
3014
+        $lastCronText = $lang->get('never');
3015
+        if ($lastCronLog && isset($lastCronLog['created_at'])) {
3016
+            $timeDiff = time() - (int) $lastCronLog['created_at'];
3017
+            if ($timeDiff < 60) {
3018
+                $lastCronText = $timeDiff . 's ' . $lang->get('ago');
3019
+            } elseif ($timeDiff < 3600) {
3020
+                $lastCronText = floor($timeDiff / 60) . 'm ' . $lang->get('ago');
3021
+            } elseif ($timeDiff < 86400) {
3022
+                $lastCronText = floor($timeDiff / 3600) . 'h ' . $lang->get('ago');
3023
+            } else {
3024
+                $lastCronText = floor($timeDiff / 86400) . 'd ' . $lang->get('ago');
3025
+            }
3025 3026
         }
3026
-    }
3027 3027
     
3028
-    echo prepareExchangedData(
3029
-        array(
3030
-            'error' => false,
3031
-            'tasks_queue' => (int) $tasksQueue,
3032
-            'last_cron' => $lastCronText,
3033
-        ),
3034
-        'encode'
3035
-    );
3036
-    break;
3028
+        echo prepareExchangedData(
3029
+            array(
3030
+                'error' => false,
3031
+                'tasks_queue' => (int) $tasksQueue,
3032
+                'last_cron' => $lastCronText,
3033
+            ),
3034
+            'encode'
3035
+        );
3036
+        break;
3037 3037
 
3038
-// ========================================
3039
-// SYSTEM HEALTH ENDPOINT
3040
-// ========================================
3038
+    // ========================================
3039
+    // SYSTEM HEALTH ENDPOINT
3040
+    // ========================================
3041 3041
 
3042
-case 'get_system_health':
3043
-    /**
3042
+    case 'get_system_health':
3043
+        /**
3044 3044
      * Get system health checks
3045 3045
      * 
3046 3046
      * @return array {
@@ -3052,97 +3052,97 @@  discard block
 block discarded – undo
3052 3052
      * }
3053 3053
      */
3054 3054
     
3055
-    // Encryption check
3056
-    $encryptionStatus = 'success';
3057
-    $encryptionText = $lang->get('health_status_ok');
3055
+        // Encryption check
3056
+        $encryptionStatus = 'success';
3057
+        $encryptionText = $lang->get('health_status_ok');
3058 3058
     
3059
-    // Check if secure file exists
3060
-    if (isset($SETTINGS['securepath']) && isset($SETTINGS['securefile']) && !file_exists($SETTINGS['securepath'] . DIRECTORY_SEPARATOR . $SETTINGS['securefile'])) {
3061
-        $encryptionStatus = 'danger';
3062
-        $encryptionText = $lang->get('health_secure_file_missing');
3063
-    }
3059
+        // Check if secure file exists
3060
+        if (isset($SETTINGS['securepath']) && isset($SETTINGS['securefile']) && !file_exists($SETTINGS['securepath'] . DIRECTORY_SEPARATOR . $SETTINGS['securefile'])) {
3061
+            $encryptionStatus = 'danger';
3062
+            $encryptionText = $lang->get('health_secure_file_missing');
3063
+        }
3064 3064
     
3065
-    // Active sessions count
3066
-    $sessionsCount = DB::queryFirstField(
3067
-        'SELECT COUNT(*) FROM ' . prefixTable('users') . ' 
3065
+        // Active sessions count
3066
+        $sessionsCount = DB::queryFirstField(
3067
+            'SELECT COUNT(*) FROM ' . prefixTable('users') . ' 
3068 3068
         WHERE session_end > %i',
3069
-        time()
3070
-    );
3069
+            time()
3070
+        );
3071 3071
     
3072
-    // Is cron installed
3073
-    DB::query(
3074
-        'SELECT valeur
3072
+        // Is cron installed
3073
+        DB::query(
3074
+            'SELECT valeur
3075 3075
         FROM ' . prefixTable('misc') . '
3076 3076
         WHERE type = %s AND intitule = %s and valeur >= %d',
3077
-        'admin',
3078
-        'last_cron_exec',
3079
-        time() - 600 // max 10 minutes
3080
-    );
3077
+            'admin',
3078
+            'last_cron_exec',
3079
+            time() - 600 // max 10 minutes
3080
+        );
3081 3081
 
3082
-    if (DB::count() === 0) {
3083
-        $cronStatus = 'danger';
3084
-        $cronText = $lang->get('error');
3085
-    } else {
3086
-        // Cron check (last execution should be < 2 minutes ago)
3087
-        $lastCron = DB::queryFirstField(
3088
-            'SELECT created_at FROM ' . prefixTable('background_tasks_logs') . ' 
3082
+        if (DB::count() === 0) {
3083
+            $cronStatus = 'danger';
3084
+            $cronText = $lang->get('error');
3085
+        } else {
3086
+            // Cron check (last execution should be < 2 minutes ago)
3087
+            $lastCron = DB::queryFirstField(
3088
+                'SELECT created_at FROM ' . prefixTable('background_tasks_logs') . ' 
3089 3089
             ORDER BY created_at DESC 
3090 3090
             LIMIT 1'
3091
-        );
3091
+            );
3092 3092
         
3093
-        $cronStatus = 'success';
3094
-        $cronText = $lang->get('health_status_ok');
3093
+            $cronStatus = 'success';
3094
+            $cronText = $lang->get('health_status_ok');
3095 3095
         
3096
-        if (!$lastCron || (time() - (int) $lastCron) > 120) {
3097
-            $cronStatus = 'warning';
3098
-            $cronText = $lang->get('health_cron_delayed');
3096
+            if (!$lastCron || (time() - (int) $lastCron) > 120) {
3097
+                $cronStatus = 'warning';
3098
+                $cronText = $lang->get('health_cron_delayed');
3099
+            }
3099 3100
         }
3100
-    }
3101 3101
     
3102
-    // Unknown files count
3103
-    $unknownFilesData = DB::queryFirstField(
3104
-        'SELECT valeur FROM ' . prefixTable('misc') . ' 
3102
+        // Unknown files count
3103
+        $unknownFilesData = DB::queryFirstField(
3104
+            'SELECT valeur FROM ' . prefixTable('misc') . ' 
3105 3105
         WHERE type = %s AND intitule = %s',
3106
-        'admin',
3107
-        'unknown_files'
3108
-    );
3106
+            'admin',
3107
+            'unknown_files'
3108
+        );
3109 3109
     
3110
-    $unknownFilesCount = 0;
3111
-    if ($unknownFilesData) {
3112
-        $unknownFiles = json_decode($unknownFilesData, true);
3113
-        if (is_array($unknownFiles)) {
3114
-            $unknownFilesCount = count($unknownFiles);
3110
+        $unknownFilesCount = 0;
3111
+        if ($unknownFilesData) {
3112
+            $unknownFiles = json_decode($unknownFilesData, true);
3113
+            if (is_array($unknownFiles)) {
3114
+                $unknownFilesCount = count($unknownFiles);
3115
+            }
3115 3116
         }
3116
-    }
3117 3117
     
3118
-    echo prepareExchangedData(
3119
-        array(
3120
-            'error' => false,
3121
-            'encryption' => array(
3122
-                'status' => $encryptionStatus,
3123
-                'text' => $encryptionText,
3124
-            ),
3125
-            'sessions' => array(
3126
-                'count' => (int) $sessionsCount,
3127
-            ),
3128
-            'cron' => array(
3129
-                'status' => $cronStatus,
3130
-                'text' => $cronText,
3131
-            ),
3132
-            'unknown_files' => array(
3133
-                'count' => $unknownFilesCount,
3118
+        echo prepareExchangedData(
3119
+            array(
3120
+                'error' => false,
3121
+                'encryption' => array(
3122
+                    'status' => $encryptionStatus,
3123
+                    'text' => $encryptionText,
3124
+                ),
3125
+                'sessions' => array(
3126
+                    'count' => (int) $sessionsCount,
3127
+                ),
3128
+                'cron' => array(
3129
+                    'status' => $cronStatus,
3130
+                    'text' => $cronText,
3131
+                ),
3132
+                'unknown_files' => array(
3133
+                    'count' => $unknownFilesCount,
3134
+                ),
3134 3135
             ),
3135
-        ),
3136
-        'encode'
3137
-    );
3138
-    break;
3136
+            'encode'
3137
+        );
3138
+        break;
3139 3139
 
3140
-// ========================================
3141
-// QUICK ACTIONS - CLEAN OLD LOGS
3142
-// ========================================
3140
+    // ========================================
3141
+    // QUICK ACTIONS - CLEAN OLD LOGS
3142
+    // ========================================
3143 3143
 
3144
-case 'clean_old_logs':
3145
-    /**
3144
+    case 'clean_old_logs':
3145
+        /**
3146 3146
      * Clean logs older than 90 days
3147 3147
      * 
3148 3148
      * @return array {
@@ -3152,54 +3152,54 @@  discard block
 block discarded – undo
3152 3152
      * }
3153 3153
      */
3154 3154
     
3155
-    $threshold = time() - (90 * 86400); // 90 days ago
3155
+        $threshold = time() - (90 * 86400); // 90 days ago
3156 3156
     
3157
-    // Delete old log_items entries
3158
-    DB::delete(
3159
-        prefixTable('log_items'),
3160
-        'date < %i',
3161
-        $threshold
3162
-    );
3157
+        // Delete old log_items entries
3158
+        DB::delete(
3159
+            prefixTable('log_items'),
3160
+            'date < %i',
3161
+            $threshold
3162
+        );
3163 3163
     
3164
-    $deletedItems = DB::affectedRows();
3164
+        $deletedItems = DB::affectedRows();
3165 3165
     
3166
-    // Delete old log_system entries
3167
-    DB::delete(
3168
-        prefixTable('log_system'),
3169
-        'date < %i',
3170
-        $threshold
3171
-    );
3166
+        // Delete old log_system entries
3167
+        DB::delete(
3168
+            prefixTable('log_system'),
3169
+            'date < %i',
3170
+            $threshold
3171
+        );
3172 3172
     
3173
-    $deletedSystem = DB::affectedRows();
3173
+        $deletedSystem = DB::affectedRows();
3174 3174
     
3175
-    $totalDeleted = $deletedItems + $deletedSystem;
3175
+        $totalDeleted = $deletedItems + $deletedSystem;
3176 3176
     
3177
-    // Log the action
3178
-    logEvents(
3179
-        $SETTINGS,
3180
-        'admin_action',
3181
-        'clean_old_logs',
3182
-        (string) $session->get('user-id'),
3183
-        $session->get('user-login'),
3184
-        'Cleaned ' . $totalDeleted . ' old log entries'
3185
-    );
3177
+        // Log the action
3178
+        logEvents(
3179
+            $SETTINGS,
3180
+            'admin_action',
3181
+            'clean_old_logs',
3182
+            (string) $session->get('user-id'),
3183
+            $session->get('user-login'),
3184
+            'Cleaned ' . $totalDeleted . ' old log entries'
3185
+        );
3186 3186
     
3187
-    echo prepareExchangedData(
3188
-        array(
3189
-            'error' => false,
3190
-            'message' => $lang->get('admin_logs_cleaned_success'),
3191
-            'deleted_count' => $totalDeleted,
3192
-        ),
3193
-        'encode'
3194
-    );
3195
-    break;
3187
+        echo prepareExchangedData(
3188
+            array(
3189
+                'error' => false,
3190
+                'message' => $lang->get('admin_logs_cleaned_success'),
3191
+                'deleted_count' => $totalDeleted,
3192
+            ),
3193
+            'encode'
3194
+        );
3195
+        break;
3196 3196
 
3197
-// ========================================
3198
-// QUICK ACTIONS - TEST ENCRYPTION (KEPT FOR COMPATIBILITY)
3199
-// ========================================
3197
+    // ========================================
3198
+    // QUICK ACTIONS - TEST ENCRYPTION (KEPT FOR COMPATIBILITY)
3199
+    // ========================================
3200 3200
 
3201
-case 'test_encryption':
3202
-    /**
3201
+    case 'test_encryption':
3202
+        /**
3203 3203
      * Test encryption system integrity
3204 3204
      * 
3205 3205
      * @return array {
@@ -3208,117 +3208,117 @@  discard block
 block discarded – undo
3208 3208
      * }
3209 3209
      */
3210 3210
     
3211
-    try {
3212
-        // Test string
3213
-        $testString = 'TeamPass Encryption Test ' . time();
3211
+        try {
3212
+            // Test string
3213
+            $testString = 'TeamPass Encryption Test ' . time();
3214 3214
         
3215
-        // Get encryption key
3216
-        $key = file_get_contents($SETTINGS['securepath'] . DIRECTORY_SEPARATOR . $SETTINGS['securefile']);
3215
+            // Get encryption key
3216
+            $key = file_get_contents($SETTINGS['securepath'] . DIRECTORY_SEPARATOR . $SETTINGS['securefile']);
3217 3217
         
3218
-        if ($key === false) {
3219
-            throw new Exception($lang->get('admin_encryption_key_not_found'));
3220
-        }
3218
+            if ($key === false) {
3219
+                throw new Exception($lang->get('admin_encryption_key_not_found'));
3220
+            }
3221 3221
         
3222
-        // Use Defuse encryption (TeamPass's current encryption method)
3223
-        require_once $SETTINGS['cpassman_dir'] . '/vendor/defuse/php-encryption/src/Exception/EnvironmentIsBrokenException.php';
3224
-        require_once $SETTINGS['cpassman_dir'] . '/vendor/defuse/php-encryption/src/Exception/BadFormatException.php';
3225
-        require_once $SETTINGS['cpassman_dir'] . '/vendor/defuse/php-encryption/src/Exception/WrongKeyOrModifiedCiphertextException.php';
3226
-        require_once $SETTINGS['cpassman_dir'] . '/vendor/defuse/php-encryption/src/Crypto.php';
3227
-        require_once $SETTINGS['cpassman_dir'] . '/vendor/defuse/php-encryption/src/Key.php';
3222
+            // Use Defuse encryption (TeamPass's current encryption method)
3223
+            require_once $SETTINGS['cpassman_dir'] . '/vendor/defuse/php-encryption/src/Exception/EnvironmentIsBrokenException.php';
3224
+            require_once $SETTINGS['cpassman_dir'] . '/vendor/defuse/php-encryption/src/Exception/BadFormatException.php';
3225
+            require_once $SETTINGS['cpassman_dir'] . '/vendor/defuse/php-encryption/src/Exception/WrongKeyOrModifiedCiphertextException.php';
3226
+            require_once $SETTINGS['cpassman_dir'] . '/vendor/defuse/php-encryption/src/Crypto.php';
3227
+            require_once $SETTINGS['cpassman_dir'] . '/vendor/defuse/php-encryption/src/Key.php';
3228 3228
         
3229
-        $encryptionKey = \Defuse\Crypto\Key::loadFromAsciiSafeString($key);
3229
+            $encryptionKey = \Defuse\Crypto\Key::loadFromAsciiSafeString($key);
3230 3230
         
3231
-        // Encrypt test string
3232
-        $encrypted = \Defuse\Crypto\Crypto::encrypt($testString, $encryptionKey);
3231
+            // Encrypt test string
3232
+            $encrypted = \Defuse\Crypto\Crypto::encrypt($testString, $encryptionKey);
3233 3233
         
3234
-        // Decrypt test string
3235
-        $decrypted = \Defuse\Crypto\Crypto::decrypt($encrypted, $encryptionKey);
3234
+            // Decrypt test string
3235
+            $decrypted = \Defuse\Crypto\Crypto::decrypt($encrypted, $encryptionKey);
3236 3236
         
3237
-        // Verify
3238
-        if ($decrypted !== $testString) {
3239
-            throw new Exception($lang->get('admin_encryption_test_failed'));
3240
-        }
3237
+            // Verify
3238
+            if ($decrypted !== $testString) {
3239
+                throw new Exception($lang->get('admin_encryption_test_failed'));
3240
+            }
3241 3241
         
3242
-        // Log the test
3243
-        logEvents(
3244
-            $SETTINGS,
3245
-            'admin_action',
3246
-            'test_encryption',
3247
-            (string) $session->get('user-id'),
3248
-            $session->get('user-login'),
3249
-            'Encryption test successful'
3250
-        );
3242
+            // Log the test
3243
+            logEvents(
3244
+                $SETTINGS,
3245
+                'admin_action',
3246
+                'test_encryption',
3247
+                (string) $session->get('user-id'),
3248
+                $session->get('user-login'),
3249
+                'Encryption test successful'
3250
+            );
3251 3251
         
3252
-        echo prepareExchangedData(
3253
-            array(
3254
-                'error' => false,
3255
-                'message' => $lang->get('admin_encryption_test_success'),
3256
-            ),
3257
-            'encode'
3258
-        );
3252
+            echo prepareExchangedData(
3253
+                array(
3254
+                    'error' => false,
3255
+                    'message' => $lang->get('admin_encryption_test_success'),
3256
+                ),
3257
+                'encode'
3258
+            );
3259 3259
         
3260
-    } catch (Exception $e) {
3261
-        echo prepareExchangedData(
3262
-            array(
3263
-                'error' => true,
3264
-                'message' => $e->getMessage(),
3265
-            ),
3266
-            'encode'
3267
-        );
3268
-    }
3269
-    break;
3260
+        } catch (Exception $e) {
3261
+            echo prepareExchangedData(
3262
+                array(
3263
+                    'error' => true,
3264
+                    'message' => $e->getMessage(),
3265
+                ),
3266
+                'encode'
3267
+            );
3268
+        }
3269
+        break;
3270 3270
 
3271
-// ========================================
3272
-// QUICK ACTIONS - EXPORT STATISTICS
3273
-// ========================================
3271
+    // ========================================
3272
+    // QUICK ACTIONS - EXPORT STATISTICS
3273
+    // ========================================
3274 3274
 
3275
-case 'export_statistics':
3276
-    /**
3275
+    case 'export_statistics':
3276
+        /**
3277 3277
      * Export statistics as CSV file
3278 3278
      * 
3279 3279
      * @return void (file download)
3280 3280
      */
3281 3281
     
3282
-    // Set headers for CSV download
3283
-    header('Content-Type: text/csv; charset=utf-8');
3284
-    header('Content-Disposition: attachment; filename="teampass_statistics_' . date('Y-m-d_H-i-s') . '.csv"');
3282
+        // Set headers for CSV download
3283
+        header('Content-Type: text/csv; charset=utf-8');
3284
+        header('Content-Disposition: attachment; filename="teampass_statistics_' . date('Y-m-d_H-i-s') . '.csv"');
3285 3285
     
3286
-    // Create output stream
3287
-    $output = fopen('php://output', 'w');
3286
+        // Create output stream
3287
+        $output = fopen('php://output', 'w');
3288 3288
     
3289
-    // Write CSV headers
3290
-    fputcsv($output, array(
3291
-        $lang->get('admin_export_metric'),
3292
-        $lang->get('admin_export_value'),
3293
-    ));
3289
+        // Write CSV headers
3290
+        fputcsv($output, array(
3291
+            $lang->get('admin_export_metric'),
3292
+            $lang->get('admin_export_value'),
3293
+        ));
3294 3294
     
3295
-    // Gather statistics
3296
-    $stats = array(
3297
-        $lang->get('active_users') => DB::queryFirstField('SELECT COUNT(*) FROM ' . prefixTable('users') . ' WHERE disabled = 0'),
3298
-        $lang->get('total_items') => DB::queryFirstField('SELECT COUNT(*) FROM ' . prefixTable('items') . ' WHERE inactif = 0'),
3299
-        $lang->get('total_folders') => DB::queryFirstField('SELECT COUNT(*) FROM ' . prefixTable('nested_tree')),
3300
-        $lang->get('logs_24h') => DB::queryFirstField('SELECT COUNT(*) FROM ' . prefixTable('log_items') . ' WHERE date > ' . (time() - 86400)),
3301
-    );
3295
+        // Gather statistics
3296
+        $stats = array(
3297
+            $lang->get('active_users') => DB::queryFirstField('SELECT COUNT(*) FROM ' . prefixTable('users') . ' WHERE disabled = 0'),
3298
+            $lang->get('total_items') => DB::queryFirstField('SELECT COUNT(*) FROM ' . prefixTable('items') . ' WHERE inactif = 0'),
3299
+            $lang->get('total_folders') => DB::queryFirstField('SELECT COUNT(*) FROM ' . prefixTable('nested_tree')),
3300
+            $lang->get('logs_24h') => DB::queryFirstField('SELECT COUNT(*) FROM ' . prefixTable('log_items') . ' WHERE date > ' . (time() - 86400)),
3301
+        );
3302 3302
     
3303
-    // Write statistics
3304
-    foreach ($stats as $metric => $value) {
3305
-        fputcsv($output, array($metric, $value));
3306
-    }
3303
+        // Write statistics
3304
+        foreach ($stats as $metric => $value) {
3305
+            fputcsv($output, array($metric, $value));
3306
+        }
3307 3307
     
3308
-    fclose($output);
3308
+        fclose($output);
3309 3309
     
3310
-    // Log the export
3311
-    logEvents(
3312
-        $SETTINGS,
3313
-        'admin_action',
3314
-        'export_statistics',
3315
-        (string) $session->get('user-id'),
3316
-        $session->get('user-login'),
3317
-        'Statistics exported'
3318
-    );
3310
+        // Log the export
3311
+        logEvents(
3312
+            $SETTINGS,
3313
+            'admin_action',
3314
+            'export_statistics',
3315
+            (string) $session->get('user-id'),
3316
+            $session->get('user-login'),
3317
+            'Statistics exported'
3318
+        );
3319 3319
     
3320
-    exit;
3321
-    break;
3320
+        exit;
3321
+        break;
3322 3322
     
3323 3323
 }
3324 3324
 
Please login to merge, or discard this patch.
sources/main.functions.php 1 patch
Spacing   +224 added lines, -226 removed lines patch added patch discarded remove patch
@@ -99,19 +99,19 @@  discard block
 block discarded – undo
99 99
             $text = Crypto::decrypt($message, $key);
100 100
         }
101 101
     } catch (CryptoException\WrongKeyOrModifiedCiphertextException $ex) {
102
-        error_log('TEAMPASS-Error-Wrong key or modified ciphertext: ' . $ex->getMessage());
102
+        error_log('TEAMPASS-Error-Wrong key or modified ciphertext: '.$ex->getMessage());
103 103
         $err = 'wrong_key_or_modified_ciphertext';
104 104
     } catch (CryptoException\BadFormatException $ex) {
105
-        error_log('TEAMPASS-Error-Bad format exception: ' . $ex->getMessage());
105
+        error_log('TEAMPASS-Error-Bad format exception: '.$ex->getMessage());
106 106
         $err = 'bad_format';
107 107
     } catch (CryptoException\EnvironmentIsBrokenException $ex) {
108
-        error_log('TEAMPASS-Error-Environment: ' . $ex->getMessage());
108
+        error_log('TEAMPASS-Error-Environment: '.$ex->getMessage());
109 109
         $err = 'environment_error';
110 110
     } catch (CryptoException\IOException $ex) {
111
-        error_log('TEAMPASS-Error-IO: ' . $ex->getMessage());
111
+        error_log('TEAMPASS-Error-IO: '.$ex->getMessage());
112 112
         $err = 'io_error';
113 113
     } catch (Exception $ex) {
114
-        error_log('TEAMPASS-Error-Unexpected exception: ' . $ex->getMessage());
114
+        error_log('TEAMPASS-Error-Unexpected exception: '.$ex->getMessage());
115 115
         $err = 'unexpected_error';
116 116
     }
117 117
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
  */
197 197
 function trimElement($chaine, string $element): string
198 198
 {
199
-    if (! empty($chaine)) {
199
+    if (!empty($chaine)) {
200 200
         if (is_array($chaine) === true) {
201 201
             $chaine = implode(';', $chaine);
202 202
         }
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
  */
245 245
 function db_error_handler(array $params): void
246 246
 {
247
-    echo 'Error: ' . $params['error'] . "<br>\n";
248
-    echo 'Query: ' . $params['query'] . "<br>\n";
247
+    echo 'Error: '.$params['error']."<br>\n";
248
+    echo 'Query: '.$params['query']."<br>\n";
249 249
     throw new Exception('Error - Query', 1);
250 250
 }
251 251
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
     $session->set('user-forbiden_personal_folders', []);
320 320
     
321 321
     // Get list of Folders
322
-    $rows = DB::query('SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i', 0);
322
+    $rows = DB::query('SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i', 0);
323 323
     foreach ($rows as $record) {
324 324
         array_push($groupesVisibles, $record['id']);
325 325
     }
@@ -328,20 +328,20 @@  discard block
 block discarded – undo
328 328
     // get complete list of ROLES
329 329
     $tmp = array_filter(explode(';', $idFonctions !== null ? $idFonctions : ''));
330 330
     $rows = DB::query(
331
-        'SELECT * FROM ' . prefixTable('roles_title') . '
331
+        'SELECT * FROM '.prefixTable('roles_title').'
332 332
         ORDER BY title ASC'
333 333
     );
334 334
     foreach ($rows as $record) {
335
-        if (! empty($record['id']) && ! in_array($record['id'], $tmp)) {
335
+        if (!empty($record['id']) && !in_array($record['id'], $tmp)) {
336 336
             array_push($tmp, $record['id']);
337 337
         }
338 338
     }
339 339
     $session->set('user-roles', implode(';', $tmp));
340 340
     $session->set('user-admin', 1);
341 341
     // Check if admin has created Folders and Roles
342
-    DB::query('SELECT * FROM ' . prefixTable('nested_tree') . '');
342
+    DB::query('SELECT * FROM '.prefixTable('nested_tree').'');
343 343
     $session->set('user-nb_folders', DB::count());
344
-    DB::query('SELECT * FROM ' . prefixTable('roles_title'));
344
+    DB::query('SELECT * FROM '.prefixTable('roles_title'));
345 345
     $session->set('user-nb_roles', DB::count());
346 346
 
347 347
     return true;
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
     // Does this user is allowed to see other items
425 425
     $inc = 0;
426 426
     $rows = DB::query(
427
-        'SELECT id, id_tree FROM ' . prefixTable('items') . '
427
+        'SELECT id, id_tree FROM '.prefixTable('items').'
428 428
             WHERE restricted_to LIKE %ss AND inactif = %s'.
429 429
             (count($allowedFolders) > 0 ? ' AND id_tree NOT IN ('.implode(',', $allowedFolders).')' : ''),
430 430
         $globalsUserId,
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
     // Check for the users roles if some specific rights exist on items
442 442
     $rows = DB::query(
443 443
         'SELECT i.id_tree, r.item_id
444
-        FROM ' . prefixTable('items') . ' as i
445
-        INNER JOIN ' . prefixTable('restriction_to_roles') . ' as r ON (r.item_id=i.id)
444
+        FROM ' . prefixTable('items').' as i
445
+        INNER JOIN ' . prefixTable('restriction_to_roles').' as r ON (r.item_id=i.id)
446 446
         WHERE i.id_tree <> "" '.
447 447
         (count($userRoles) > 0 ? 'AND r.role_id IN %li ' : '').
448 448
         'ORDER BY i.id_tree ASC',
@@ -486,18 +486,18 @@  discard block
 block discarded – undo
486 486
     $session->set('system-list_restricted_folders_for_items', $restrictedFoldersForItems);
487 487
     $session->set('user-forbiden_personal_folders', $noAccessPersonalFolders);
488 488
     // Folders and Roles numbers
489
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('nested_tree') . '');
490
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('nested_tree') . '');
489
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('nested_tree').'');
490
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('nested_tree').'');
491 491
     $session->set('user-nb_folders', DB::count());
492
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('roles_title'));
493
-    DB::queryFirstRow('SELECT id FROM ' . prefixTable('roles_title'));
492
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('roles_title'));
493
+    DB::queryFirstRow('SELECT id FROM '.prefixTable('roles_title'));
494 494
     $session->set('user-nb_roles', DB::count());
495 495
     // check if change proposals on User's items
496 496
     if (isset($SETTINGS['enable_suggestion']) === true && (int) $SETTINGS['enable_suggestion'] === 1) {
497 497
         $countNewItems = DB::query(
498 498
             'SELECT COUNT(*)
499
-            FROM ' . prefixTable('items_change') . ' AS c
500
-            LEFT JOIN ' . prefixTable('log_items') . ' AS i ON (c.item_id = i.id_item)
499
+            FROM ' . prefixTable('items_change').' AS c
500
+            LEFT JOIN ' . prefixTable('log_items').' AS i ON (c.item_id = i.id_item)
501 501
             WHERE i.action = %s AND i.id_user = %i',
502 502
             'at_creation',
503 503
             $globalsUserId
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 {
525 525
     $rows = DB::query(
526 526
         'SELECT *
527
-        FROM ' . prefixTable('roles_values') . '
527
+        FROM ' . prefixTable('roles_values').'
528 528
         WHERE type IN %ls'.(count($userRoles) > 0 ? ' AND role_id IN %li' : ''),
529 529
         ['W', 'ND', 'NE', 'NDNE', 'R'],
530 530
         $userRoles,
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
     ) {
592 592
         $persoFld = DB::queryFirstRow(
593 593
             'SELECT id
594
-            FROM ' . prefixTable('nested_tree') . '
594
+            FROM ' . prefixTable('nested_tree').'
595 595
             WHERE title = %s AND personal_folder = %i'.
596 596
             (count($allowedFolders) > 0 ? ' AND id NOT IN ('.implode(',', $allowedFolders).')' : ''),
597 597
             $globalsUserId,
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
     }
625 625
     $persoFlds = DB::query(
626 626
         'SELECT id
627
-        FROM ' . prefixTable('nested_tree') . '
627
+        FROM ' . prefixTable('nested_tree').'
628 628
         WHERE %l',
629 629
         $where
630 630
     );
@@ -692,12 +692,12 @@  discard block
 block discarded – undo
692 692
     //Load Tree
693 693
     $tree = new NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title');
694 694
     // truncate table
695
-    DB::query('TRUNCATE TABLE ' . prefixTable('cache'));
695
+    DB::query('TRUNCATE TABLE '.prefixTable('cache'));
696 696
     // reload date
697 697
     $rows = DB::query(
698 698
         'SELECT *
699
-        FROM ' . prefixTable('items') . ' as i
700
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
699
+        FROM ' . prefixTable('items').' as i
700
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
701 701
         AND l.action = %s
702 702
         AND i.inactif = %i',
703 703
         'at_creation',
@@ -709,18 +709,18 @@  discard block
 block discarded – undo
709 709
             $tags = '';
710 710
             $itemTags = DB::query(
711 711
                 'SELECT tag
712
-                FROM ' . prefixTable('tags') . '
712
+                FROM ' . prefixTable('tags').'
713 713
                 WHERE item_id = %i AND tag != ""',
714 714
                 $record['id']
715 715
             );
716 716
             foreach ($itemTags as $itemTag) {
717
-                $tags .= $itemTag['tag'] . ' ';
717
+                $tags .= $itemTag['tag'].' ';
718 718
             }
719 719
 
720 720
             // Get renewal period
721 721
             $resNT = DB::queryFirstRow(
722 722
                 'SELECT renewal_period
723
-                FROM ' . prefixTable('nested_tree') . '
723
+                FROM ' . prefixTable('nested_tree').'
724 724
                 WHERE id = %i',
725 725
                 $record['id_tree']
726 726
             );
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
                     // Is this a User id?
734 734
                     $user = DB::queryFirstRow(
735 735
                         'SELECT login
736
-                        FROM ' . prefixTable('users') . '
736
+                        FROM ' . prefixTable('users').'
737 737
                         WHERE id = %i',
738 738
                         $elem->title
739 739
                     );
@@ -751,11 +751,11 @@  discard block
 block discarded – undo
751 751
                     'id' => $record['id'],
752 752
                     'label' => $record['label'],
753 753
                     'description' => $record['description'] ?? '',
754
-                    'url' => isset($record['url']) && ! empty($record['url']) ? $record['url'] : '0',
754
+                    'url' => isset($record['url']) && !empty($record['url']) ? $record['url'] : '0',
755 755
                     'tags' => $tags,
756 756
                     'id_tree' => $record['id_tree'],
757 757
                     'perso' => $record['perso'],
758
-                    'restricted_to' => isset($record['restricted_to']) && ! empty($record['restricted_to']) ? $record['restricted_to'] : '0',
758
+                    'restricted_to' => isset($record['restricted_to']) && !empty($record['restricted_to']) ? $record['restricted_to'] : '0',
759 759
                     'login' => $record['login'] ?? '',
760 760
                     'folder' => implode(' » ', $folder),
761 761
                     'author' => $record['id_user'],
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
     // get new value from db
785 785
     $data = DB::queryFirstRow(
786 786
         'SELECT label, description, id_tree, perso, restricted_to, login, url
787
-        FROM ' . prefixTable('items') . '
787
+        FROM ' . prefixTable('items').'
788 788
         WHERE id=%i',
789 789
         $ident
790 790
     );
@@ -792,12 +792,12 @@  discard block
 block discarded – undo
792 792
     $tags = '';
793 793
     $itemTags = DB::query(
794 794
         'SELECT tag
795
-            FROM ' . prefixTable('tags') . '
795
+            FROM ' . prefixTable('tags').'
796 796
             WHERE item_id = %i AND tag != ""',
797 797
         $ident
798 798
     );
799 799
     foreach ($itemTags as $itemTag) {
800
-        $tags .= $itemTag['tag'] . ' ';
800
+        $tags .= $itemTag['tag'].' ';
801 801
     }
802 802
     // form id_tree to full foldername
803 803
     $folder = [];
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
             // Is this a User id?
809 809
             $user = DB::queryFirstRow(
810 810
                 'SELECT id, login
811
-                FROM ' . prefixTable('users') . '
811
+                FROM ' . prefixTable('users').'
812 812
                 WHERE id = %i',
813 813
                 $elem->title
814 814
             );
@@ -826,10 +826,10 @@  discard block
 block discarded – undo
826 826
             'label' => $data['label'],
827 827
             'description' => $data['description'],
828 828
             'tags' => $tags,
829
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
829
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
830 830
             'id_tree' => $data['id_tree'],
831 831
             'perso' => $data['perso'],
832
-            'restricted_to' => isset($data['restricted_to']) && ! empty($data['restricted_to']) ? $data['restricted_to'] : '0',
832
+            'restricted_to' => isset($data['restricted_to']) && !empty($data['restricted_to']) ? $data['restricted_to'] : '0',
833 833
             'login' => $data['login'] ?? '',
834 834
             'folder' => implode(' » ', $folder),
835 835
             'author' => $session->get('user-id'),
@@ -859,8 +859,8 @@  discard block
 block discarded – undo
859 859
     // get new value from db
860 860
     $data = DB::queryFirstRow(
861 861
         'SELECT i.label, i.description, i.id_tree as id_tree, i.perso, i.restricted_to, i.id, i.login, i.url, l.date
862
-        FROM ' . prefixTable('items') . ' as i
863
-        INNER JOIN ' . prefixTable('log_items') . ' as l ON (l.id_item = i.id)
862
+        FROM ' . prefixTable('items').' as i
863
+        INNER JOIN ' . prefixTable('log_items').' as l ON (l.id_item = i.id)
864 864
         WHERE i.id = %i
865 865
         AND l.action = %s',
866 866
         $ident,
@@ -870,12 +870,12 @@  discard block
 block discarded – undo
870 870
     $tags = '';
871 871
     $itemTags = DB::query(
872 872
         'SELECT tag
873
-            FROM ' . prefixTable('tags') . '
873
+            FROM ' . prefixTable('tags').'
874 874
             WHERE item_id = %i AND tag != ""',
875 875
         $ident
876 876
     );
877 877
     foreach ($itemTags as $itemTag) {
878
-        $tags .= $itemTag['tag'] . ' ';
878
+        $tags .= $itemTag['tag'].' ';
879 879
     }
880 880
     // form id_tree to full foldername
881 881
     $folder = [];
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
             // Is this a User id?
887 887
             $user = DB::queryFirstRow(
888 888
                 'SELECT id, login
889
-                FROM ' . prefixTable('users') . '
889
+                FROM ' . prefixTable('users').'
890 890
                 WHERE id = %i',
891 891
                 $elem->title
892 892
             );
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
             'label' => $data['label'],
906 906
             'description' => $data['description'],
907 907
             'tags' => empty($tags) === false ? $tags : 'None',
908
-            'url' => isset($data['url']) && ! empty($data['url']) ? $data['url'] : '0',
908
+            'url' => isset($data['url']) && !empty($data['url']) ? $data['url'] : '0',
909 909
             'id_tree' => $data['id_tree'],
910 910
             'perso' => isset($data['perso']) && empty($data['perso']) === false && $data['perso'] !== 'None' ? $data['perso'] : '0',
911 911
             'restricted_to' => isset($data['restricted_to']) && empty($data['restricted_to']) === false ? $data['restricted_to'] : '0',
@@ -927,53 +927,53 @@  discard block
 block discarded – undo
927 927
 function getStatisticsData(array $SETTINGS): array
928 928
 {
929 929
     DB::query(
930
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
930
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
931 931
         0
932 932
     );
933 933
     $counter_folders = DB::count();
934 934
     DB::query(
935
-        'SELECT id FROM ' . prefixTable('nested_tree') . ' WHERE personal_folder = %i',
935
+        'SELECT id FROM '.prefixTable('nested_tree').' WHERE personal_folder = %i',
936 936
         1
937 937
     );
938 938
     $counter_folders_perso = DB::count();
939 939
     DB::query(
940
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
940
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
941 941
         0
942 942
     );
943 943
     $counter_items = DB::count();
944 944
         DB::query(
945
-        'SELECT id FROM ' . prefixTable('items') . ' WHERE perso = %i',
945
+        'SELECT id FROM '.prefixTable('items').' WHERE perso = %i',
946 946
         1
947 947
     );
948 948
     $counter_items_perso = DB::count();
949 949
         DB::query(
950
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE login NOT IN (%s, %s, %s)',
950
+        'SELECT id FROM '.prefixTable('users').' WHERE login NOT IN (%s, %s, %s)',
951 951
         'OTV', 'TP', 'API'
952 952
     );
953 953
     $counter_users = DB::count();
954 954
         DB::query(
955
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE admin = %i',
955
+        'SELECT id FROM '.prefixTable('users').' WHERE admin = %i',
956 956
         1
957 957
     );
958 958
     $admins = DB::count();
959 959
     DB::query(
960
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE gestionnaire = %i',
960
+        'SELECT id FROM '.prefixTable('users').' WHERE gestionnaire = %i',
961 961
         1
962 962
     );
963 963
     $managers = DB::count();
964 964
     DB::query(
965
-        'SELECT id FROM ' . prefixTable('users') . ' WHERE read_only = %i',
965
+        'SELECT id FROM '.prefixTable('users').' WHERE read_only = %i',
966 966
         1
967 967
     );
968 968
     $readOnly = DB::count();
969 969
     // list the languages
970 970
     $usedLang = [];
971 971
     $tp_languages = DB::query(
972
-        'SELECT name FROM ' . prefixTable('languages')
972
+        'SELECT name FROM '.prefixTable('languages')
973 973
     );
974 974
     foreach ($tp_languages as $tp_language) {
975 975
         DB::query(
976
-            'SELECT * FROM ' . prefixTable('users') . ' WHERE user_language = %s',
976
+            'SELECT * FROM '.prefixTable('users').' WHERE user_language = %s',
977 977
             $tp_language['name']
978 978
         );
979 979
         $usedLang[$tp_language['name']] = round((DB::count() * 100 / $counter_users), 0);
@@ -982,12 +982,12 @@  discard block
 block discarded – undo
982 982
     // get list of ips
983 983
     $usedIp = [];
984 984
     $tp_ips = DB::query(
985
-        'SELECT user_ip FROM ' . prefixTable('users')
985
+        'SELECT user_ip FROM '.prefixTable('users')
986 986
     );
987 987
     foreach ($tp_ips as $ip) {
988 988
         if (array_key_exists($ip['user_ip'], $usedIp)) {
989 989
             $usedIp[$ip['user_ip']] += $usedIp[$ip['user_ip']];
990
-        } elseif (! empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
990
+        } elseif (!empty($ip['user_ip']) && $ip['user_ip'] !== 'none') {
991 991
             $usedIp[$ip['user_ip']] = 1;
992 992
         }
993 993
     }
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
         <table width="600" cellpadding="0" cellspacing="0" border="0" class="container" bgcolor="#ffffff" style="border-spacing: 0; border-bottom: 1px solid #e0e0e0; box-shadow: 0 0 3px #ddd; color: #434343; font-family: Helvetica, Verdana, sans-serif;">
1083 1083
         <tr><td class="container-padding" bgcolor="#ffffff" style="border-collapse: collapse; border-left: 1px solid #e0e0e0; background-color: #ffffff; padding-left: 30px; padding-right: 30px;">
1084 1084
         <br><div style="float:right;">' .
1085
-        $textMail .
1085
+        $textMail.
1086 1086
         '<br><br></td></tr></table>
1087 1087
     </td></tr></table>
1088 1088
     <br></body></html>';
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
 {
1164 1164
     array_walk_recursive(
1165 1165
         $array,
1166
-        static function (&$item): void {
1166
+        static function(&$item): void {
1167 1167
             if (mb_detect_encoding((string) $item, 'utf-8', true) === false) {
1168 1168
                 $item = mb_convert_encoding($item, 'ISO-8859-1', 'UTF-8');
1169 1169
             }
@@ -1274,7 +1274,7 @@  discard block
 block discarded – undo
1274 1274
  */
1275 1275
 function prefixTable(string $table): string
1276 1276
 {
1277
-    $safeTable = htmlspecialchars(DB_PREFIX . $table);
1277
+    $safeTable = htmlspecialchars(DB_PREFIX.$table);
1278 1278
     return $safeTable;
1279 1279
 }
1280 1280
 
@@ -1391,7 +1391,7 @@  discard block
 block discarded – undo
1391 1391
 function send_syslog($message, $host, $port, $component = 'teampass'): void
1392 1392
 {
1393 1393
     $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
1394
-    $syslog_message = '<123>' . date('M d H:i:s ') . $component . ': ' . $message;
1394
+    $syslog_message = '<123>'.date('M d H:i:s ').$component.': '.$message;
1395 1395
     socket_sendto($sock, (string) $syslog_message, strlen($syslog_message), 0, (string) $host, (int) $port);
1396 1396
     socket_close($sock);
1397 1397
 }
@@ -1438,14 +1438,14 @@  discard block
 block discarded – undo
1438 1438
     if (isset($SETTINGS['syslog_enable']) === true && (int) $SETTINGS['syslog_enable'] === 1) {
1439 1439
         if ($type === 'user_mngt') {
1440 1440
             send_syslog(
1441
-                'action=' . str_replace('at_', '', $label) . ' attribute=user user=' . $who . ' userid="' . $login . '" change="' . $field_1 . '" ',
1441
+                'action='.str_replace('at_', '', $label).' attribute=user user='.$who.' userid="'.$login.'" change="'.$field_1.'" ',
1442 1442
                 $SETTINGS['syslog_host'],
1443 1443
                 $SETTINGS['syslog_port'],
1444 1444
                 'teampass'
1445 1445
             );
1446 1446
         } else {
1447 1447
             send_syslog(
1448
-                'action=' . $type . ' attribute=' . $label . ' user=' . $who . ' userid="' . $login . '" ',
1448
+                'action='.$type.' attribute='.$label.' user='.$who.' userid="'.$login.'" ',
1449 1449
                 $SETTINGS['syslog_host'],
1450 1450
                 $SETTINGS['syslog_port'],
1451 1451
                 'teampass'
@@ -1520,7 +1520,7 @@  discard block
 block discarded – undo
1520 1520
         if (empty($item_label) === true) {
1521 1521
             $dataItem = DB::queryFirstRow(
1522 1522
                 'SELECT id, id_tree, label
1523
-                FROM ' . prefixTable('items') . '
1523
+                FROM ' . prefixTable('items').'
1524 1524
                 WHERE id = %i',
1525 1525
                 $item_id
1526 1526
             );
@@ -1528,11 +1528,11 @@  discard block
 block discarded – undo
1528 1528
         }
1529 1529
 
1530 1530
         send_syslog(
1531
-            'action=' . str_replace('at_', '', $action) .
1532
-                ' attribute=' . str_replace('at_', '', $attribute[0]) .
1533
-                ' itemno=' . $item_id .
1534
-                ' user=' . (is_null($login) === true ? '' : addslashes((string) $login)) .
1535
-                ' itemname="' . addslashes($item_label) . '"',
1531
+            'action='.str_replace('at_', '', $action).
1532
+                ' attribute='.str_replace('at_', '', $attribute[0]).
1533
+                ' itemno='.$item_id.
1534
+                ' user='.(is_null($login) === true ? '' : addslashes((string) $login)).
1535
+                ' itemname="'.addslashes($item_label).'"',
1536 1536
             $SETTINGS['syslog_host'],
1537 1537
             $SETTINGS['syslog_port'],
1538 1538
             'teampass'
@@ -1563,8 +1563,8 @@  discard block
 block discarded – undo
1563 1563
     // send email to user that what to be notified
1564 1564
     $notification = DB::queryFirstField(
1565 1565
         'SELECT email
1566
-        FROM ' . prefixTable('notification') . ' AS n
1567
-        INNER JOIN ' . prefixTable('users') . ' AS u ON (n.user_id = u.id)
1566
+        FROM ' . prefixTable('notification').' AS n
1567
+        INNER JOIN ' . prefixTable('users').' AS u ON (n.user_id = u.id)
1568 1568
         WHERE n.item_id = %i AND n.user_id != %i',
1569 1569
         $item_id,
1570 1570
         $globalsUserId
@@ -1575,7 +1575,7 @@  discard block
 block discarded – undo
1575 1575
         // Get list of changes
1576 1576
         $htmlChanges = '<ul>';
1577 1577
         foreach ($changes as $change) {
1578
-            $htmlChanges .= '<li>' . $change . '</li>';
1578
+            $htmlChanges .= '<li>'.$change.'</li>';
1579 1579
         }
1580 1580
         $htmlChanges .= '</ul>';
1581 1581
         // send email
@@ -1612,15 +1612,15 @@  discard block
 block discarded – undo
1612 1612
     $path = '';
1613 1613
     foreach ($arbo as $elem) {
1614 1614
         if (empty($path) === true) {
1615
-            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES) . ' ';
1615
+            $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES).' ';
1616 1616
         } else {
1617
-            $path .= '&#8594; ' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1617
+            $path .= '&#8594; '.htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES);
1618 1618
         }
1619 1619
     }
1620 1620
 
1621 1621
     // Build text to show user
1622 1622
     if (empty($label) === false) {
1623
-        return empty($path) === true ? addslashes($label) : addslashes($label) . ' (' . $path . ')';
1623
+        return empty($path) === true ? addslashes($label) : addslashes($label).' ('.$path.')';
1624 1624
     }
1625 1625
     return empty($path) === true ? '' : $path;
1626 1626
 }
@@ -1676,7 +1676,7 @@  discard block
 block discarded – undo
1676 1676
 {
1677 1677
     // Perform a copy if the file exists
1678 1678
     if (file_exists($configFilePath)) {
1679
-        $backupFilePath = $configFilePath . '.' . date('Y_m_d_His', time());
1679
+        $backupFilePath = $configFilePath.'.'.date('Y_m_d_His', time());
1680 1680
         if (!copy($configFilePath, $backupFilePath)) {
1681 1681
             return "ERROR: Could not copy file '$configFilePath'";
1682 1682
         }
@@ -1684,10 +1684,10 @@  discard block
 block discarded – undo
1684 1684
 
1685 1685
     // Regenerate the config file
1686 1686
     $data = ["<?php\n", "global \$SETTINGS;\n", "\$SETTINGS = array (\n"];
1687
-    $rows = DB::query('SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s', 'admin');
1687
+    $rows = DB::query('SELECT * FROM '.prefixTable('misc').' WHERE type=%s', 'admin');
1688 1688
     foreach ($rows as $record) {
1689 1689
         $value = getEncryptedValue($record['valeur'], $record['is_encrypted']);
1690
-        $data[] = "    '{$record['intitule']}' => '". htmlspecialchars_decode($value, ENT_COMPAT) . "',\n";
1690
+        $data[] = "    '{$record['intitule']}' => '".htmlspecialchars_decode($value, ENT_COMPAT)."',\n";
1691 1691
     }
1692 1692
     $data[] = ");\n";
1693 1693
     $data = array_unique($data);
@@ -1732,7 +1732,7 @@  discard block
 block discarded – undo
1732 1732
 {
1733 1733
     global $SETTINGS;
1734 1734
     /* LOAD CPASSMAN SETTINGS */
1735
-    if (! isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
1735
+    if (!isset($SETTINGS['loaded']) || $SETTINGS['loaded'] !== 1) {
1736 1736
         $SETTINGS = [];
1737 1737
         $SETTINGS['duplicate_folder'] = 0;
1738 1738
         //by default, this is set to 0;
@@ -1742,7 +1742,7 @@  discard block
 block discarded – undo
1742 1742
         //by default, this value is set to 5;
1743 1743
         $settings = [];
1744 1744
         $rows = DB::query(
1745
-            'SELECT * FROM ' . prefixTable('misc') . ' WHERE type=%s_type OR type=%s_type2',
1745
+            'SELECT * FROM '.prefixTable('misc').' WHERE type=%s_type OR type=%s_type2',
1746 1746
             [
1747 1747
                 'type' => 'admin',
1748 1748
                 'type2' => 'settings',
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
     $source_cf = [];
1775 1775
     $rows = DB::query(
1776 1776
         'SELECT id_category
1777
-            FROM ' . prefixTable('categories_folders') . '
1777
+            FROM ' . prefixTable('categories_folders').'
1778 1778
             WHERE id_folder = %i',
1779 1779
         $source_id
1780 1780
     );
@@ -1785,7 +1785,7 @@  discard block
 block discarded – undo
1785 1785
     $target_cf = [];
1786 1786
     $rows = DB::query(
1787 1787
         'SELECT id_category
1788
-            FROM ' . prefixTable('categories_folders') . '
1788
+            FROM ' . prefixTable('categories_folders').'
1789 1789
             WHERE id_folder = %i',
1790 1790
         $target_id
1791 1791
     );
@@ -1880,10 +1880,10 @@  discard block
 block discarded – undo
1880 1880
     } catch (CryptoException\WrongKeyOrModifiedCiphertextException $ex) {
1881 1881
         $err = 'wrong_key';
1882 1882
     } catch (CryptoException\EnvironmentIsBrokenException $ex) {
1883
-        error_log('TEAMPASS-Error-Environment: ' . $ex->getMessage());
1883
+        error_log('TEAMPASS-Error-Environment: '.$ex->getMessage());
1884 1884
         $err = 'environment_error';
1885 1885
     } catch (CryptoException\IOException $ex) {
1886
-        error_log('TEAMPASS-Error-General: ' . $ex->getMessage());
1886
+        error_log('TEAMPASS-Error-General: '.$ex->getMessage());
1887 1887
         $err = 'general_error';
1888 1888
     }
1889 1889
 
@@ -1915,10 +1915,10 @@  discard block
 block discarded – undo
1915 1915
     } catch (CryptoException\WrongKeyOrModifiedCiphertextException $ex) {
1916 1916
         $err = 'wrong_key';
1917 1917
     } catch (CryptoException\EnvironmentIsBrokenException $ex) {
1918
-        error_log('TEAMPASS-Error-Environment: ' . $ex->getMessage());
1918
+        error_log('TEAMPASS-Error-Environment: '.$ex->getMessage());
1919 1919
         $err = 'environment_error';
1920 1920
     } catch (CryptoException\IOException $ex) {
1921
-        error_log('TEAMPASS-Error-General: ' . $ex->getMessage());
1921
+        error_log('TEAMPASS-Error-General: '.$ex->getMessage());
1922 1922
         $err = 'general_error';
1923 1923
     }
1924 1924
 
@@ -2004,7 +2004,7 @@  discard block
 block discarded – undo
2004 2004
 ) {
2005 2005
     // Check if the path exists
2006 2006
     $path = basename($path);
2007
-    if (! file_exists($path)) {
2007
+    if (!file_exists($path)) {
2008 2008
         return false;
2009 2009
     }
2010 2010
 
@@ -2057,7 +2057,7 @@  discard block
 block discarded – undo
2057 2057
     // Load item data
2058 2058
     $data = DB::queryFirstRow(
2059 2059
         'SELECT id_tree
2060
-        FROM ' . prefixTable('items') . '
2060
+        FROM ' . prefixTable('items').'
2061 2061
         WHERE id = %i',
2062 2062
         $item_id
2063 2063
     );
@@ -2120,7 +2120,7 @@  discard block
 block discarded – undo
2120 2120
         }
2121 2121
         $host .= substr(explode(".", $email[1])[0], -1, 1);
2122 2122
     }
2123
-    $email = $name . "@" . $host . "." . explode(".", $email[1])[1];
2123
+    $email = $name."@".$host.".".explode(".", $email[1])[1];
2124 2124
     return $email;
2125 2125
 }
2126 2126
 
@@ -2151,11 +2151,11 @@  discard block
 block discarded – undo
2151 2151
 function formatSizeUnits(int $bytes): string
2152 2152
 {
2153 2153
     if ($bytes >= 1073741824) {
2154
-        $bytes = number_format($bytes / 1073741824, 2) . ' GB';
2154
+        $bytes = number_format($bytes / 1073741824, 2).' GB';
2155 2155
     } elseif ($bytes >= 1048576) {
2156
-        $bytes = number_format($bytes / 1048576, 2) . ' MB';
2156
+        $bytes = number_format($bytes / 1048576, 2).' MB';
2157 2157
     } elseif ($bytes >= 1024) {
2158
-        $bytes = number_format($bytes / 1024, 2) . ' KB';
2158
+        $bytes = number_format($bytes / 1024, 2).' KB';
2159 2159
     } elseif ($bytes > 1) {
2160 2160
         $bytes .= ' bytes';
2161 2161
     } elseif ($bytes === 1) {
@@ -2322,7 +2322,7 @@  discard block
 block discarded – undo
2322 2322
  */
2323 2323
 function generateKeyIntegrityHash(string $userSeed, string $publicKey, string $serverSecret): string
2324 2324
 {
2325
-    return hash_hmac('sha256', $userSeed . $publicKey, $serverSecret);
2325
+    return hash_hmac('sha256', $userSeed.$publicKey, $serverSecret);
2326 2326
 }
2327 2327
 
2328 2328
 /**
@@ -2397,7 +2397,7 @@  discard block
 block discarded – undo
2397 2397
                 'security_alert',
2398 2398
                 'key_integrity_check_failed',
2399 2399
                 (string) $userInfo['id'],
2400
-                'User: ' . $userInfo['login']
2400
+                'User: '.$userInfo['login']
2401 2401
             );
2402 2402
             return [
2403 2403
                 'success' => false,
@@ -2444,7 +2444,7 @@  discard block
 block discarded – undo
2444 2444
             'user_connection',
2445 2445
             'auto_reencryption_success',
2446 2446
             (string) $userInfo['id'],
2447
-            'User: ' . $userInfo['login']
2447
+            'User: '.$userInfo['login']
2448 2448
         );
2449 2449
 
2450 2450
         // Store in session for immediate use
@@ -2463,12 +2463,12 @@  discard block
 block discarded – undo
2463 2463
             'security_alert',
2464 2464
             'auto_reencryption_failed',
2465 2465
             (string) $userInfo['id'],
2466
-            'User: ' . $userInfo['login'] . ' - Error: ' . $e->getMessage()
2466
+            'User: '.$userInfo['login'].' - Error: '.$e->getMessage()
2467 2467
         );
2468 2468
 
2469 2469
         return [
2470 2470
             'success' => false,
2471
-            'error' => 'decryption_failed: ' . $e->getMessage(),
2471
+            'error' => 'decryption_failed: '.$e->getMessage(),
2472 2472
             'private_key_clear' => '',
2473 2473
         ];
2474 2474
     }
@@ -2539,7 +2539,7 @@  discard block
 block discarded – undo
2539 2539
         'security_alert',
2540 2540
         'auto_reencryption_critical_failure',
2541 2541
         (string) $userId,
2542
-        'User: ' . $userInfo['login'] . ' - disabled due to key recovery failure'
2542
+        'User: '.$userInfo['login'].' - disabled due to key recovery failure'
2543 2543
     );
2544 2544
 
2545 2545
     return false;
@@ -2697,7 +2697,7 @@  discard block
 block discarded – undo
2697 2697
     $cipher->enableContinuousBuffer();
2698 2698
 
2699 2699
     // Encrypt the file content
2700
-    $filePath = filter_var($fileInPath . '/' . $fileInName, FILTER_SANITIZE_URL);
2700
+    $filePath = filter_var($fileInPath.'/'.$fileInName, FILTER_SANITIZE_URL);
2701 2701
     $fileContent = file_get_contents($filePath);
2702 2702
     $plaintext = $fileContent;
2703 2703
     $ciphertext = $cipher->encrypt($plaintext);
@@ -2705,9 +2705,9 @@  discard block
 block discarded – undo
2705 2705
     // Save new file
2706 2706
     // deepcode ignore InsecureHash: is simply used to get a unique name
2707 2707
     $hash = uniqid('', true);
2708
-    $fileOut = $fileInPath . '/' . TP_FILE_PREFIX . $hash;
2708
+    $fileOut = $fileInPath.'/'.TP_FILE_PREFIX.$hash;
2709 2709
     file_put_contents($fileOut, $ciphertext);
2710
-    unlink($fileInPath . '/' . $fileInName);
2710
+    unlink($fileInPath.'/'.$fileInName);
2711 2711
     return [
2712 2712
         'fileHash' => base64_encode($hash),
2713 2713
         'objectKey' => base64_encode($objectKey),
@@ -2723,9 +2723,9 @@  discard block
 block discarded – undo
2723 2723
  *
2724 2724
  * @return string|array
2725 2725
  */
2726
-function decryptFile(string $fileName, string $filePath, string $key): string|array
2726
+function decryptFile(string $fileName, string $filePath, string $key): string | array
2727 2727
 {
2728
-    if (! defined('FILE_BUFFER_SIZE')) {
2728
+    if (!defined('FILE_BUFFER_SIZE')) {
2729 2729
         define('FILE_BUFFER_SIZE', 128 * 1024);
2730 2730
     }
2731 2731
     
@@ -2742,7 +2742,7 @@  discard block
 block discarded – undo
2742 2742
     $cipher->enableContinuousBuffer();
2743 2743
     $cipher->disablePadding();
2744 2744
     // Get file content
2745
-    $safeFilePath = realpath($filePath . '/' . TP_FILE_PREFIX . $safeFileName);
2745
+    $safeFilePath = realpath($filePath.'/'.TP_FILE_PREFIX.$safeFileName);
2746 2746
     if ($safeFilePath !== false && file_exists($safeFilePath)) {
2747 2747
         $ciphertext = file_get_contents(filter_var($safeFilePath, FILTER_SANITIZE_URL));
2748 2748
     } else {
@@ -2838,7 +2838,7 @@  discard block
 block discarded – undo
2838 2838
     }
2839 2839
     $users = DB::query(
2840 2840
         'SELECT id, public_key
2841
-        FROM ' . prefixTable('users') . '
2841
+        FROM ' . prefixTable('users').'
2842 2842
         WHERE id NOT IN %li
2843 2843
         AND public_key != ""',
2844 2844
         $user_ids
@@ -2847,7 +2847,7 @@  discard block
 block discarded – undo
2847 2847
         // Insert in DB the new object key for this item by user
2848 2848
         if (count($objectKeyArray) === 0) {
2849 2849
             if (WIP === true) {
2850
-                error_log('TEAMPASS Debug - storeUsersShareKey case1 - ' . $object_name . ' - ' . $post_object_id . ' - ' . $user['id']);
2850
+                error_log('TEAMPASS Debug - storeUsersShareKey case1 - '.$object_name.' - '.$post_object_id.' - '.$user['id']);
2851 2851
             }
2852 2852
             
2853 2853
             insertOrUpdateSharekey(
@@ -2859,7 +2859,7 @@  discard block
 block discarded – undo
2859 2859
         } else {
2860 2860
             foreach ($objectKeyArray as $object) {
2861 2861
                 if (WIP === true) {
2862
-                    error_log('TEAMPASS Debug - storeUsersShareKey case2 - ' . $object_name . ' - ' . $object['objectId'] . ' - ' . $user['id']);
2862
+                    error_log('TEAMPASS Debug - storeUsersShareKey case2 - '.$object_name.' - '.$object['objectId'].' - '.$user['id']);
2863 2863
                 }
2864 2864
                 
2865 2865
                 insertOrUpdateSharekey(
@@ -2891,7 +2891,7 @@  discard block
 block discarded – undo
2891 2891
 ): bool {
2892 2892
     try {
2893 2893
         DB::query(
2894
-            'INSERT INTO ' . $tableName . ' 
2894
+            'INSERT INTO '.$tableName.' 
2895 2895
             (object_id, user_id, share_key) 
2896 2896
             VALUES (%i, %i, %s)
2897 2897
             ON DUPLICATE KEY UPDATE share_key = VALUES(share_key)',
@@ -2901,7 +2901,7 @@  discard block
 block discarded – undo
2901 2901
         );
2902 2902
         return true;
2903 2903
     } catch (Exception $e) {
2904
-        error_log('TEAMPASS Error - insertOrUpdateSharekey: ' . $e->getMessage());
2904
+        error_log('TEAMPASS Error - insertOrUpdateSharekey: '.$e->getMessage());
2905 2905
         return false;
2906 2906
     }
2907 2907
 }
@@ -2916,7 +2916,7 @@  discard block
 block discarded – undo
2916 2916
 function isBase64(string $str): bool
2917 2917
 {
2918 2918
     $str = (string) trim($str);
2919
-    if (! isset($str[0])) {
2919
+    if (!isset($str[0])) {
2920 2920
         return false;
2921 2921
     }
2922 2922
 
@@ -2990,7 +2990,7 @@  discard block
 block discarded – undo
2990 2990
     } catch (\LdapRecord\Auth\BindException $e) {
2991 2991
         $error = $e->getDetailedError();
2992 2992
         if ($error && defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
2993
-            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage(). " - ".$error->getDiagnosticMessage());
2993
+            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage()." - ".$error->getDiagnosticMessage());
2994 2994
         }
2995 2995
         // deepcode ignore ServerLeak: No important data is sent
2996 2996
         echo 'An error occurred.';
@@ -3007,7 +3007,7 @@  discard block
 block discarded – undo
3007 3007
     } catch (\LdapRecord\Auth\BindException $e) {
3008 3008
         $error = $e->getDetailedError();
3009 3009
         if ($error && defined('LOG_TO_SERVER') && LOG_TO_SERVER === true) {
3010
-            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage(). " - ".$error->getDiagnosticMessage());
3010
+            error_log('TEAMPASS Error - LDAP - '.$error->getErrorCode()." - ".$error->getErrorMessage()." - ".$error->getDiagnosticMessage());
3011 3011
         }
3012 3012
         // deepcode ignore ServerLeak: No important data is sent
3013 3013
         echo 'An error occurred.';
@@ -3043,7 +3043,7 @@  discard block
 block discarded – undo
3043 3043
     // expect if personal item
3044 3044
     DB::delete(
3045 3045
         prefixTable('sharekeys_items'),
3046
-        'user_id = %i',// AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)'',
3046
+        'user_id = %i', // AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)'',
3047 3047
         $userId
3048 3048
     );
3049 3049
     // Remove all item sharekeys files
@@ -3067,7 +3067,7 @@  discard block
 block discarded – undo
3067 3067
     // Remove all item sharekeys suggestions
3068 3068
     DB::delete(
3069 3069
         prefixTable('sharekeys_suggestions'),
3070
-        'user_id = %i',// AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
3070
+        'user_id = %i', // AND object_id NOT IN (SELECT i.id FROM ' . prefixTable('items') . ' AS i WHERE i.perso = 1)',
3071 3071
         $userId
3072 3072
     );
3073 3073
     return false;
@@ -3088,7 +3088,7 @@  discard block
 block discarded – undo
3088 3088
         foreach (DateTimeZone::listIdentifiers() as $timezone) {
3089 3089
             $now->setTimezone(new DateTimeZone($timezone));
3090 3090
             $offsets[] = $offset = $now->getOffset();
3091
-            $timezones[$timezone] = '(' . format_GMT_offset($offset) . ') ' . format_timezone_name($timezone);
3091
+            $timezones[$timezone] = '('.format_GMT_offset($offset).') '.format_timezone_name($timezone);
3092 3092
         }
3093 3093
 
3094 3094
         array_multisort($offsets, $timezones);
@@ -3108,7 +3108,7 @@  discard block
 block discarded – undo
3108 3108
 {
3109 3109
     $hours = intval($offset / 3600);
3110 3110
     $minutes = abs(intval($offset % 3600 / 60));
3111
-    return 'GMT' . ($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
3111
+    return 'GMT'.($offset ? sprintf('%+03d:%02d', $hours, $minutes) : '');
3112 3112
 }
3113 3113
 
3114 3114
 /**
@@ -3207,8 +3207,7 @@  discard block
 block discarded – undo
3207 3207
 {
3208 3208
     if (isset($array[$key]) === true
3209 3209
         && (is_int($value) === true ?
3210
-            (int) $array[$key] === $value :
3211
-            (string) $array[$key] === $value)
3210
+            (int) $array[$key] === $value : (string) $array[$key] === $value)
3212 3211
     ) {
3213 3212
         return true;
3214 3213
     }
@@ -3230,8 +3229,7 @@  discard block
 block discarded – undo
3230 3229
 {
3231 3230
     if (isset($var) === false
3232 3231
         || (is_int($value) === true ?
3233
-            (int) $var === $value :
3234
-            (string) $var === $value)
3232
+            (int) $var === $value : (string) $var === $value)
3235 3233
     ) {
3236 3234
         return true;
3237 3235
     }
@@ -3282,7 +3280,7 @@  discard block
 block discarded – undo
3282 3280
  */
3283 3281
 function isSetArrayOfValues(array $arrayOfValues): bool
3284 3282
 {
3285
-    foreach($arrayOfValues as $value) {
3283
+    foreach ($arrayOfValues as $value) {
3286 3284
         if (isset($value) === false) {
3287 3285
             return false;
3288 3286
         }
@@ -3304,7 +3302,7 @@  discard block
 block discarded – undo
3304 3302
     /*PHP8 - integer|string*/$value
3305 3303
 ) : bool
3306 3304
 {
3307
-    foreach($arrayOfVars as $variable) {
3305
+    foreach ($arrayOfVars as $variable) {
3308 3306
         if ($variable !== $value) {
3309 3307
             return false;
3310 3308
         }
@@ -3324,7 +3322,7 @@  discard block
 block discarded – undo
3324 3322
     /*PHP8 - integer|string*/$value
3325 3323
 ) : bool
3326 3324
 {
3327
-    foreach($arrayOfVars as $variable) {
3325
+    foreach ($arrayOfVars as $variable) {
3328 3326
         if ($variable === $value) {
3329 3327
             return true;
3330 3328
         }
@@ -3338,7 +3336,7 @@  discard block
 block discarded – undo
3338 3336
  * @param string|int|null $value
3339 3337
  * @return boolean
3340 3338
  */
3341
-function isValueSetNullEmpty(string|int|null $value) : bool
3339
+function isValueSetNullEmpty(string | int | null $value) : bool
3342 3340
 {
3343 3341
     if (is_null($value) === true || empty($value) === true) {
3344 3342
         return true;
@@ -3393,7 +3391,7 @@  discard block
 block discarded – undo
3393 3391
  * @param array     $filters
3394 3392
  * @return array|string
3395 3393
  */
3396
-function dataSanitizer(array $data, array $filters): array|string
3394
+function dataSanitizer(array $data, array $filters): array | string
3397 3395
 {
3398 3396
     // Load Sanitizer library
3399 3397
     $sanitizer = new Sanitizer($data, $filters);
@@ -3422,7 +3420,7 @@  discard block
 block discarded – undo
3422 3420
     // Exists ?
3423 3421
     $userCacheId = DB::queryFirstRow(
3424 3422
         'SELECT increment_id
3425
-        FROM ' . prefixTable('cache_tree') . '
3423
+        FROM ' . prefixTable('cache_tree').'
3426 3424
         WHERE user_id = %i',
3427 3425
         $user_id
3428 3426
     );
@@ -3473,7 +3471,7 @@  discard block
 block discarded – undo
3473 3471
  */
3474 3472
 function pourcentage(float $nombre, float $total, float $pourcentage): float
3475 3473
 { 
3476
-    $resultat = ($nombre/$total) * $pourcentage;
3474
+    $resultat = ($nombre / $total) * $pourcentage;
3477 3475
     return round($resultat);
3478 3476
 }
3479 3477
 
@@ -3503,7 +3501,7 @@  discard block
 block discarded – undo
3503 3501
 
3504 3502
     // Get last folder update
3505 3503
     $lastFolderChange = DB::queryFirstRow(
3506
-        'SELECT valeur FROM ' . prefixTable('misc') . '
3504
+        'SELECT valeur FROM '.prefixTable('misc').'
3507 3505
         WHERE type = %s AND intitule = %s',
3508 3506
         'timestamp',
3509 3507
         'last_folder_change'
@@ -3524,7 +3522,7 @@  discard block
 block discarded – undo
3524 3522
     // Does this user has a tree cache
3525 3523
     $userCacheTree = DB::queryFirstRow(
3526 3524
         'SELECT '.$fieldName.'
3527
-        FROM ' . prefixTable('cache_tree') . '
3525
+        FROM ' . prefixTable('cache_tree').'
3528 3526
         WHERE user_id = %i',
3529 3527
         $session->get('user-id')
3530 3528
     );
@@ -3562,7 +3560,7 @@  discard block
 block discarded – undo
3562 3560
     if (count($folderIds) === 0) {
3563 3561
         $folderIds = DB::queryFirstColumn(
3564 3562
             'SELECT id
3565
-            FROM ' . prefixTable('nested_tree') . '
3563
+            FROM ' . prefixTable('nested_tree').'
3566 3564
             WHERE personal_folder=%i',
3567 3565
             0
3568 3566
         );
@@ -3579,8 +3577,8 @@  discard block
 block discarded – undo
3579 3577
         $rows_tmp = DB::query(
3580 3578
             'SELECT c.id, c.title, c.level, c.type, c.masked, c.order, c.encrypted_data, c.role_visibility, c.is_mandatory,
3581 3579
             f.id_category AS category_id
3582
-            FROM ' . prefixTable('categories_folders') . ' AS f
3583
-            INNER JOIN ' . prefixTable('categories') . ' AS c ON (f.id_category = c.parent_id)
3580
+            FROM ' . prefixTable('categories_folders').' AS f
3581
+            INNER JOIN ' . prefixTable('categories').' AS c ON (f.id_category = c.parent_id)
3584 3582
             WHERE id_folder=%i',
3585 3583
             $folder
3586 3584
         );
@@ -3606,7 +3604,7 @@  discard block
 block discarded – undo
3606 3604
         $valTemp = '';
3607 3605
         $data = DB::queryFirstRow(
3608 3606
             'SELECT valeur
3609
-            FROM ' . prefixTable('misc') . '
3607
+            FROM ' . prefixTable('misc').'
3610 3608
             WHERE type = %s AND intitule=%i',
3611 3609
             'complex',
3612 3610
             $folder
@@ -3623,14 +3621,14 @@  discard block
 block discarded – undo
3623 3621
         $valTemp = '';
3624 3622
         $rows_tmp = DB::query(
3625 3623
             'SELECT t.title
3626
-            FROM ' . prefixTable('roles_values') . ' as v
3627
-            INNER JOIN ' . prefixTable('roles_title') . ' as t ON (v.role_id = t.id)
3624
+            FROM ' . prefixTable('roles_values').' as v
3625
+            INNER JOIN ' . prefixTable('roles_title').' as t ON (v.role_id = t.id)
3628 3626
             WHERE v.folder_id = %i
3629 3627
             GROUP BY title',
3630 3628
             $folder
3631 3629
         );
3632 3630
         foreach ($rows_tmp as $record) {
3633
-            $valTemp .= (empty($valTemp) === true ? '' : ' - ') . $record['title'];
3631
+            $valTemp .= (empty($valTemp) === true ? '' : ' - ').$record['title'];
3634 3632
         }
3635 3633
         $arr_data['visibilityRoles'] = $valTemp;
3636 3634
 
@@ -3663,7 +3661,7 @@  discard block
 block discarded – undo
3663 3661
         // loop on users and check if user has this role
3664 3662
         $rows = DB::query(
3665 3663
             'SELECT id, fonction_id
3666
-            FROM ' . prefixTable('users') . '
3664
+            FROM ' . prefixTable('users').'
3667 3665
             WHERE id != %i AND admin = 0 AND fonction_id IS NOT NULL AND fonction_id != ""',
3668 3666
             $session->get('user-id')
3669 3667
         );
@@ -3695,7 +3693,7 @@  discard block
 block discarded – undo
3695 3693
 
3696 3694
     $val = DB::queryFirstRow(
3697 3695
         'SELECT *
3698
-        FROM ' . prefixTable('users') . '
3696
+        FROM ' . prefixTable('users').'
3699 3697
         WHERE id = %i',
3700 3698
         $userId
3701 3699
     );
@@ -3711,12 +3709,12 @@  discard block
 block discarded – undo
3711 3709
 function upgradeRequired(): bool
3712 3710
 {
3713 3711
     // Get settings.php
3714
-    include_once __DIR__. '/../includes/config/settings.php';
3712
+    include_once __DIR__.'/../includes/config/settings.php';
3715 3713
 
3716 3714
     // Get timestamp in DB
3717 3715
     $val = DB::queryFirstRow(
3718 3716
         'SELECT valeur
3719
-        FROM ' . prefixTable('misc') . '
3717
+        FROM ' . prefixTable('misc').'
3720 3718
         WHERE type = %s AND intitule = %s',
3721 3719
         'admin',
3722 3720
         'upgrade_timestamp'
@@ -3769,7 +3767,7 @@  discard block
 block discarded – undo
3769 3767
     // prepapre background tasks for item keys generation        
3770 3768
     $userTP = DB::queryFirstRow(
3771 3769
         'SELECT pw, public_key, private_key
3772
-        FROM ' . prefixTable('users') . '
3770
+        FROM ' . prefixTable('users').'
3773 3771
         WHERE id = %i',
3774 3772
         TP_USER_ID
3775 3773
     );
@@ -3830,7 +3828,7 @@  discard block
 block discarded – undo
3830 3828
     }
3831 3829
 
3832 3830
     // Generate new keys
3833
-    if ($user_self_change === true && empty($recovery_public_key) === false && empty($recovery_private_key) === false){
3831
+    if ($user_self_change === true && empty($recovery_public_key) === false && empty($recovery_private_key) === false) {
3834 3832
         $userKeys = [
3835 3833
             'public_key' => $recovery_public_key,
3836 3834
             'private_key_clear' => $recovery_private_key,
@@ -3881,8 +3879,8 @@  discard block
 block discarded – undo
3881 3879
             'process_type' => 'create_user_keys',
3882 3880
             'arguments' => json_encode([
3883 3881
                 'new_user_id' => (int) $userId,
3884
-                'new_user_pwd' => cryption($passwordClear, '','encrypt')['string'],
3885
-                'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '','encrypt')['string'],
3882
+                'new_user_pwd' => cryption($passwordClear, '', 'encrypt')['string'],
3883
+                'new_user_code' => cryption(empty($encryptionKey) === true ? uniqidReal(20) : $encryptionKey, '', 'encrypt')['string'],
3886 3884
                 'owner_id' => (int) TP_USER_ID,
3887 3885
                 'creator_pwd' => $userTP['pw'],
3888 3886
                 'send_email' => $sendEmailToUser === true ? 1 : 0,
@@ -3954,19 +3952,19 @@  discard block
 block discarded – undo
3954 3952
 
3955 3953
     // Prepare the subtask queries
3956 3954
     $queries = [
3957
-        'step20' => 'SELECT * FROM ' . prefixTable('items'),
3955
+        'step20' => 'SELECT * FROM '.prefixTable('items'),
3958 3956
 
3959
-        'step30' => 'SELECT * FROM ' . prefixTable('log_items') . 
3957
+        'step30' => 'SELECT * FROM '.prefixTable('log_items'). 
3960 3958
                     ' WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"',
3961 3959
 
3962
-        'step40' => 'SELECT * FROM ' . prefixTable('categories_items') . 
3960
+        'step40' => 'SELECT * FROM '.prefixTable('categories_items'). 
3963 3961
                     ' WHERE encryption_type = "teampass_aes"',
3964 3962
 
3965
-        'step50' => 'SELECT * FROM ' . prefixTable('suggestion'),
3963
+        'step50' => 'SELECT * FROM '.prefixTable('suggestion'),
3966 3964
 
3967
-        'step60' => 'SELECT * FROM ' . prefixTable('files') . ' AS f
3968
-                        INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = f.id_item
3969
-                        WHERE f.status = "' . TP_ENCRYPTION_NAME . '"'
3965
+        'step60' => 'SELECT * FROM '.prefixTable('files').' AS f
3966
+                        INNER JOIN ' . prefixTable('items').' AS i ON i.id = f.id_item
3967
+                        WHERE f.status = "' . TP_ENCRYPTION_NAME.'"'
3970 3968
     ];
3971 3969
 
3972 3970
     // Perform loop on $queries to create sub-tasks
@@ -4156,7 +4154,7 @@  discard block
 block discarded – undo
4156 4154
  */
4157 4155
 function createTaskForItem(
4158 4156
     string $processType,
4159
-    string|array $taskName,
4157
+    string | array $taskName,
4160 4158
     int $itemId,
4161 4159
     int $userId,
4162 4160
     string $objectKey,
@@ -4180,7 +4178,7 @@  discard block
 block discarded – undo
4180 4178
                 'object_key' => $objectKey,
4181 4179
                 'author' => (int) $userId,
4182 4180
             ]),
4183
-            'item_id' => (int) $parentId !== -1 ?  $parentId : null,
4181
+            'item_id' => (int) $parentId !== -1 ? $parentId : null,
4184 4182
         )
4185 4183
     );
4186 4184
     $processId = DB::insertId();
@@ -4190,7 +4188,7 @@  discard block
 block discarded – undo
4190 4188
     if (is_array($taskName) === false) {
4191 4189
         $taskName = [$taskName];
4192 4190
     }
4193
-    foreach($taskName as $task) {
4191
+    foreach ($taskName as $task) {
4194 4192
         if (WIP === true) error_log('createTaskForItem - task: '.$task);
4195 4193
         switch ($task) {
4196 4194
             case 'item_password':
@@ -4287,7 +4285,7 @@  discard block
 block discarded – undo
4287 4285
  * @param integer $user_id
4288 4286
  * @return void
4289 4287
  */
4290
-function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id=0)
4288
+function purgeUnnecessaryKeys(bool $allUsers = true, int $user_id = 0)
4291 4289
 {
4292 4290
     if ($allUsers === true) {
4293 4291
         // Load class DB
@@ -4297,7 +4295,7 @@  discard block
 block discarded – undo
4297 4295
 
4298 4296
         $users = DB::query(
4299 4297
             'SELECT id
4300
-            FROM ' . prefixTable('users') . '
4298
+            FROM ' . prefixTable('users').'
4301 4299
             WHERE id NOT IN ('.OTV_USER_ID.', '.TP_USER_ID.', '.SSH_USER_ID.', '.API_USER_ID.')
4302 4300
             ORDER BY login ASC'
4303 4301
         );
@@ -4315,7 +4313,7 @@  discard block
 block discarded – undo
4315 4313
  * @param integer $user_id
4316 4314
  * @return void
4317 4315
  */
4318
-function purgeUnnecessaryKeysForUser(int $user_id=0)
4316
+function purgeUnnecessaryKeysForUser(int $user_id = 0)
4319 4317
 {
4320 4318
     if ($user_id === 0) {
4321 4319
         return;
@@ -4326,8 +4324,8 @@  discard block
 block discarded – undo
4326 4324
 
4327 4325
     $personalItems = DB::queryFirstColumn(
4328 4326
         'SELECT id
4329
-        FROM ' . prefixTable('items') . ' AS i
4330
-        INNER JOIN ' . prefixTable('log_items') . ' AS li ON li.id_item = i.id
4327
+        FROM ' . prefixTable('items').' AS i
4328
+        INNER JOIN ' . prefixTable('log_items').' AS li ON li.id_item = i.id
4331 4329
         WHERE i.perso = 1 AND li.action = "at_creation" AND li.id_user IN (%i, '.TP_USER_ID.')',
4332 4330
         $user_id
4333 4331
     );
@@ -4337,28 +4335,28 @@  discard block
 block discarded – undo
4337 4335
             prefixTable('sharekeys_items'),
4338 4336
             'object_id IN %li AND user_id NOT IN %ls',
4339 4337
             $personalItems,
4340
-            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4338
+            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4341 4339
         );
4342 4340
         // Files keys
4343 4341
         DB::delete(
4344 4342
             prefixTable('sharekeys_files'),
4345 4343
             'object_id IN %li AND user_id NOT IN %ls',
4346 4344
             $personalItems,
4347
-            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4345
+            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4348 4346
         );
4349 4347
         // Fields keys
4350 4348
         DB::delete(
4351 4349
             prefixTable('sharekeys_fields'),
4352 4350
             'object_id IN %li AND user_id NOT IN %ls',
4353 4351
             $personalItems,
4354
-            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4352
+            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4355 4353
         );
4356 4354
         // Logs keys
4357 4355
         DB::delete(
4358 4356
             prefixTable('sharekeys_logs'),
4359 4357
             'object_id IN %li AND user_id NOT IN %ls',
4360 4358
             $personalItems,
4361
-            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4359
+            [$user_id, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4362 4360
         );
4363 4361
     }
4364 4362
 }
@@ -4376,7 +4374,7 @@  discard block
 block discarded – undo
4376 4374
     // Check if user exists
4377 4375
     $userInfo = DB::queryFirstRow(
4378 4376
         'SELECT login
4379
-        FROM ' . prefixTable('users') . '
4377
+        FROM ' . prefixTable('users').'
4380 4378
         WHERE id = %i',
4381 4379
         $userId
4382 4380
     );
@@ -4385,7 +4383,7 @@  discard block
 block discarded – undo
4385 4383
         $now = (int) time();
4386 4384
         // Prepare file content
4387 4385
         $export_value = file_get_contents(__DIR__."/../includes/core/teampass_ascii.txt")."\n".
4388
-            "Generation date: ".date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now)."\n\n".
4386
+            "Generation date: ".date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now)."\n\n".
4389 4387
             "RECOVERY KEYS - Not to be shared - To be store safely\n\n".
4390 4388
             "Public Key:\n".$session->get('user-public_key')."\n\n".
4391 4389
             "Private Key:\n".$session->get('user-private_key')."\n\n";
@@ -4408,7 +4406,7 @@  discard block
 block discarded – undo
4408 4406
         return prepareExchangedData(
4409 4407
             array(
4410 4408
                 'error' => false,
4411
-                'datetime' => date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], $now),
4409
+                'datetime' => date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], $now),
4412 4410
                 'timestamp' => $now,
4413 4411
                 'content' => base64_encode($export_value),
4414 4412
                 'login' => $userInfo['login'],
@@ -4434,8 +4432,8 @@  discard block
 block discarded – undo
4434 4432
  */
4435 4433
 function loadClasses(string $className = ''): void
4436 4434
 {
4437
-    require_once __DIR__. '/../includes/config/include.php';
4438
-    require_once __DIR__. '/../includes/config/settings.php';
4435
+    require_once __DIR__.'/../includes/config/include.php';
4436
+    require_once __DIR__.'/../includes/config/settings.php';
4439 4437
     require_once __DIR__.'/../vendor/autoload.php';
4440 4438
 
4441 4439
     if (defined('DB_PASSWD_CLEAR') === false) {
@@ -4648,7 +4646,7 @@  discard block
 block discarded – undo
4648 4646
 
4649 4647
     // Get current user hash
4650 4648
     $userHash = DB::queryFirstRow(
4651
-        "SELECT pw FROM " . prefixtable('users') . " WHERE id = %d;",
4649
+        "SELECT pw FROM ".prefixtable('users')." WHERE id = %d;",
4652 4650
         $session->get('user-id')
4653 4651
     )['pw'];
4654 4652
 
@@ -4696,11 +4694,11 @@  discard block
 block discarded – undo
4696 4694
         }
4697 4695
         
4698 4696
         // Alternative: serialize ou json selon le contexte
4699
-        return get_class($value) . (method_exists($value, 'getId') ? '#' . $value->getId() : '');
4697
+        return get_class($value).(method_exists($value, 'getId') ? '#'.$value->getId() : '');
4700 4698
     }
4701 4699
     
4702 4700
     if (is_resource($value)) {
4703
-        return 'Resource#' . get_resource_id($value) . ' of type ' . get_resource_type($value);
4701
+        return 'Resource#'.get_resource_id($value).' of type '.get_resource_type($value);
4704 4702
     }
4705 4703
     
4706 4704
     // Cas par défaut
@@ -4720,7 +4718,7 @@  discard block
 block discarded – undo
4720 4718
     // Refuse access if user does not exist and/or is admin
4721 4719
     $user = DB::queryFirstRow(
4722 4720
         'SELECT admin
4723
-        FROM ' . prefixTable('users') . '
4721
+        FROM ' . prefixTable('users').'
4724 4722
         WHERE id = %i',
4725 4723
         $userId
4726 4724
     );
@@ -4731,8 +4729,8 @@  discard block
 block discarded – undo
4731 4729
     // Get file info
4732 4730
     $file = DB::queryFirstRow(
4733 4731
         'SELECT f.id_item, i.id_tree
4734
-        FROM ' . prefixTable('files') . ' as f
4735
-        INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = f.id_item
4732
+        FROM ' . prefixTable('files').' as f
4733
+        INNER JOIN ' . prefixTable('items').' AS i ON i.id = f.id_item
4736 4734
         WHERE f.id = %i',
4737 4735
         $fileId
4738 4736
     );
@@ -4741,7 +4739,7 @@  discard block
 block discarded – undo
4741 4739
     }
4742 4740
 
4743 4741
     // Check if user has access to the item
4744
-    include_once __DIR__. '/items.queries.php';
4742
+    include_once __DIR__.'/items.queries.php';
4745 4743
     $itemAccess = getCurrentAccessRights(
4746 4744
         (int) filter_var($userId, FILTER_SANITIZE_NUMBER_INT),
4747 4745
         (int) filter_var($file['id_item'], FILTER_SANITIZE_NUMBER_INT),
@@ -4774,7 +4772,7 @@  discard block
 block discarded – undo
4774 4772
     // Refuse access if user does not exist and/or is not admin
4775 4773
     $user = DB::queryFirstRow(
4776 4774
         'SELECT admin
4777
-        FROM ' . prefixTable('users') . '
4775
+        FROM ' . prefixTable('users').'
4778 4776
         WHERE id = %i',
4779 4777
         $userId
4780 4778
     );
@@ -4785,7 +4783,7 @@  discard block
 block discarded – undo
4785 4783
     // Ensure that user has performed the backup
4786 4784
     DB::queryFirstRow(
4787 4785
         'SELECT f.id
4788
-        FROM ' . prefixTable('log_system') . ' as f
4786
+        FROM ' . prefixTable('log_system').' as f
4789 4787
         WHERE f.type = %s AND f.label = %s AND f.qui = %i AND f.field_1 = %s',
4790 4788
         'admin_action',
4791 4789
         'dataBase backup',
@@ -4812,7 +4810,7 @@  discard block
 block discarded – undo
4812 4810
     // Refuse access if user does not exist and/or is admin
4813 4811
     $user = DB::queryFirstRow(
4814 4812
         'SELECT admin
4815
-        FROM ' . prefixTable('users') . '
4813
+        FROM ' . prefixTable('users').'
4816 4814
         WHERE id = %i',
4817 4815
         $userId
4818 4816
     );
@@ -4823,7 +4821,7 @@  discard block
 block discarded – undo
4823 4821
     // Get item info
4824 4822
     $item = DB::queryFirstRow(
4825 4823
         'SELECT i.perso, i.id_tree
4826
-        FROM ' . prefixTable('items') . ' as i
4824
+        FROM ' . prefixTable('items').' as i
4827 4825
         WHERE i.id = %i',
4828 4826
         $itemId
4829 4827
     );
@@ -4834,7 +4832,7 @@  discard block
 block discarded – undo
4834 4832
     // Get item owner
4835 4833
     $itemOwner = DB::queryFirstRow(
4836 4834
         'SELECT li.id_user
4837
-        FROM ' . prefixTable('log_items') . ' as li
4835
+        FROM ' . prefixTable('log_items').' as li
4838 4836
         WHERE li.id_item = %i AND li.action = %s',
4839 4837
         $itemId,
4840 4838
         'at_creation'
@@ -4848,25 +4846,25 @@  discard block
 block discarded – undo
4848 4846
         prefixTable('sharekeys_items'),
4849 4847
         'object_id = %i AND user_id NOT IN %ls',
4850 4848
         $itemId,
4851
-        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4849
+        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4852 4850
     );
4853 4851
     DB::delete(
4854 4852
         prefixTable('sharekeys_files'),
4855 4853
         'object_id IN (SELECT id FROM '.prefixTable('files').' WHERE id_item = %i) AND user_id NOT IN %ls',
4856 4854
         $itemId,
4857
-        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4855
+        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4858 4856
     );
4859 4857
     DB::delete(
4860 4858
         prefixTable('sharekeys_fields'),
4861 4859
         'object_id IN (SELECT id FROM '.prefixTable('fields').' WHERE id_item = %i) AND user_id NOT IN %ls',
4862 4860
         $itemId,
4863
-        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4861
+        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4864 4862
     );
4865 4863
     DB::delete(
4866 4864
         prefixTable('sharekeys_logs'),
4867 4865
         'object_id IN (SELECT id FROM '.prefixTable('log_items').' WHERE id_item = %i) AND user_id NOT IN %ls',
4868 4866
         $itemId,
4869
-        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID,SSH_USER_ID]
4867
+        [$userId, TP_USER_ID, API_USER_ID, OTV_USER_ID, SSH_USER_ID]
4870 4868
     );
4871 4869
 
4872 4870
     return true;
@@ -4938,7 +4936,7 @@  discard block
 block discarded – undo
4938 4936
     
4939 4937
     // 2. Check if user actually has personal items to migrate
4940 4938
     $personalFolderId = DB::queryFirstField(
4941
-        "SELECT id FROM ".prefixTable('nested_tree') ."
4939
+        "SELECT id FROM ".prefixTable('nested_tree')."
4942 4940
          WHERE personal_folder = 1 
4943 4941
          AND title = %s",
4944 4942
         $userId
@@ -5018,8 +5016,8 @@  discard block
 block discarded – undo
5018 5016
             'process_type' => 'migrate_user_personal_items',
5019 5017
             'arguments' => json_encode([
5020 5018
                 'user_id' => (int) $userId,
5021
-                'user_pwd' => cryption($passwordClear, '','encrypt')['string'],
5022
-                'user_private_key' => cryption($privateKeyDecrypted, '','encrypt')['string'],
5019
+                'user_pwd' => cryption($passwordClear, '', 'encrypt')['string'],
5020
+                'user_private_key' => cryption($privateKeyDecrypted, '', 'encrypt')['string'],
5023 5021
                 'personal_folders_ids' => $personalFolderIds,
5024 5022
             ]),
5025 5023
             'is_in_progress' => 0,
@@ -5048,19 +5046,19 @@  discard block
 block discarded – undo
5048 5046
 {
5049 5047
     // Prepare the subtask queries
5050 5048
     $queries = [
5051
-        'user-personal-items-migration-step10' => 'SELECT * FROM ' . prefixTable('items'),
5049
+        'user-personal-items-migration-step10' => 'SELECT * FROM '.prefixTable('items'),
5052 5050
 
5053
-        'user-personal-items-migration-step20' => 'SELECT * FROM ' . prefixTable('log_items') . 
5051
+        'user-personal-items-migration-step20' => 'SELECT * FROM '.prefixTable('log_items'). 
5054 5052
                     ' WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"',
5055 5053
 
5056
-        'user-personal-items-migration-step30' => 'SELECT * FROM ' . prefixTable('categories_items') . 
5054
+        'user-personal-items-migration-step30' => 'SELECT * FROM '.prefixTable('categories_items'). 
5057 5055
                     ' WHERE encryption_type = "teampass_aes"',
5058 5056
 
5059
-        'user-personal-items-migration-step40' => 'SELECT * FROM ' . prefixTable('suggestion'),
5057
+        'user-personal-items-migration-step40' => 'SELECT * FROM '.prefixTable('suggestion'),
5060 5058
 
5061
-        'user-personal-items-migration-step50' => 'SELECT * FROM ' . prefixTable('files') . ' AS f
5062
-                        INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = f.id_item
5063
-                        WHERE f.status = "' . TP_ENCRYPTION_NAME . '"'
5059
+        'user-personal-items-migration-step50' => 'SELECT * FROM '.prefixTable('files').' AS f
5060
+                        INNER JOIN ' . prefixTable('items').' AS i ON i.id = f.id_item
5061
+                        WHERE f.status = "' . TP_ENCRYPTION_NAME.'"'
5064 5062
     ];
5065 5063
 
5066 5064
     // Perform loop on $queries to create sub-tasks
@@ -5093,7 +5091,7 @@  discard block
 block discarded – undo
5093 5091
 {
5094 5092
     // 1. Insert or update the item with current timestamp
5095 5093
     DB::query(
5096
-        'INSERT INTO ' . prefixTable('users_latest_items') . ' (user_id, item_id, accessed_at)
5094
+        'INSERT INTO '.prefixTable('users_latest_items').' (user_id, item_id, accessed_at)
5097 5095
         VALUES (%i, %i, NOW())
5098 5096
         ON DUPLICATE KEY UPDATE accessed_at = NOW()',
5099 5097
         $userId,
@@ -5102,12 +5100,12 @@  discard block
 block discarded – undo
5102 5100
     
5103 5101
     // 2. Keep only the 20 most recent items (delete older ones)
5104 5102
     DB::query(
5105
-        'DELETE FROM ' . prefixTable('users_latest_items') . '
5103
+        'DELETE FROM '.prefixTable('users_latest_items').'
5106 5104
         WHERE user_id = %i
5107 5105
         AND increment_id NOT IN (
5108 5106
             SELECT increment_id FROM (
5109 5107
                 SELECT increment_id 
5110
-                FROM ' . prefixTable('users_latest_items') . '
5108
+                FROM ' . prefixTable('users_latest_items').'
5111 5109
                 WHERE user_id = %i
5112 5110
                 ORDER BY accessed_at DESC
5113 5111
                 LIMIT 20
@@ -5153,14 +5151,14 @@  discard block
 block discarded – undo
5153 5151
          GROUP_CONCAT(DISTINCT CASE WHEN ur.source = "ad" THEN ur.role_id END ORDER BY ur.role_id SEPARATOR ";") AS roles_from_ad_groups,
5154 5152
          GROUP_CONCAT(DISTINCT uf.item_id ORDER BY uf.created_at SEPARATOR ";") AS favourites,
5155 5153
          GROUP_CONCAT(DISTINCT ul.item_id ORDER BY ul.accessed_at DESC SEPARATOR ";") AS latest_items
5156
-        FROM ' . prefixTable('users') . ' AS u
5157
-        LEFT JOIN ' . prefixTable('api') . ' AS a ON (u.id = a.user_id)
5158
-        LEFT JOIN ' . prefixTable('users_groups') . ' AS ug ON (u.id = ug.user_id)
5159
-        LEFT JOIN ' . prefixTable('users_groups_forbidden') . ' AS ugf ON (u.id = ugf.user_id)
5160
-        LEFT JOIN ' . prefixTable('users_roles') . ' AS ur ON (u.id = ur.user_id)
5161
-        LEFT JOIN ' . prefixTable('users_favorites') . ' AS uf ON (u.id = uf.user_id)
5162
-        LEFT JOIN ' . prefixTable('users_latest_items') . ' AS ul ON (u.id = ul.user_id)
5163
-        WHERE ' . $whereClause . '
5154
+        FROM ' . prefixTable('users').' AS u
5155
+        LEFT JOIN ' . prefixTable('api').' AS a ON (u.id = a.user_id)
5156
+        LEFT JOIN ' . prefixTable('users_groups').' AS ug ON (u.id = ug.user_id)
5157
+        LEFT JOIN ' . prefixTable('users_groups_forbidden').' AS ugf ON (u.id = ugf.user_id)
5158
+        LEFT JOIN ' . prefixTable('users_roles').' AS ur ON (u.id = ur.user_id)
5159
+        LEFT JOIN ' . prefixTable('users_favorites').' AS uf ON (u.id = uf.user_id)
5160
+        LEFT JOIN ' . prefixTable('users_latest_items').' AS ul ON (u.id = ul.user_id)
5161
+        WHERE ' . $whereClause.'
5164 5162
         GROUP BY u.id',
5165 5163
         $whereParam
5166 5164
     );
@@ -5175,7 +5173,7 @@  discard block
 block discarded – undo
5175 5173
         $data['latest_items'] = $data['latest_items'] ?? '';
5176 5174
     }
5177 5175
     
5178
-    return $data;//secureOutput($data, $antiXss);
5176
+    return $data; //secureOutput($data, $antiXss);
5179 5177
 }
5180 5178
 
5181 5179
 
@@ -5190,7 +5188,7 @@  discard block
 block discarded – undo
5190 5188
 function addUserGroup(int $userId, int $groupId): void
5191 5189
 {
5192 5190
     DB::query(
5193
-        'INSERT IGNORE INTO ' . prefixTable('users_groups') . ' (user_id, group_id)
5191
+        'INSERT IGNORE INTO '.prefixTable('users_groups').' (user_id, group_id)
5194 5192
         VALUES (%i, %i)',
5195 5193
         $userId,
5196 5194
         $groupId
@@ -5203,7 +5201,7 @@  discard block
 block discarded – undo
5203 5201
 function removeUserGroup(int $userId, int $groupId): void
5204 5202
 {
5205 5203
     DB::query(
5206
-        'DELETE FROM ' . prefixTable('users_groups') . '
5204
+        'DELETE FROM '.prefixTable('users_groups').'
5207 5205
         WHERE user_id = %i AND group_id = %i',
5208 5206
         $userId,
5209 5207
         $groupId
@@ -5220,7 +5218,7 @@  discard block
 block discarded – undo
5220 5218
 {
5221 5219
     // Delete all existing groups
5222 5220
     DB::query(
5223
-        'DELETE FROM ' . prefixTable('users_groups') . ' WHERE user_id = %i',
5221
+        'DELETE FROM '.prefixTable('users_groups').' WHERE user_id = %i',
5224 5222
         $userId
5225 5223
     );
5226 5224
     
@@ -5240,7 +5238,7 @@  discard block
 block discarded – undo
5240 5238
 function getUserGroups(int $userId): array
5241 5239
 {
5242 5240
     $result = DB::query(
5243
-        'SELECT group_id FROM ' . prefixTable('users_groups') . ' 
5241
+        'SELECT group_id FROM '.prefixTable('users_groups').' 
5244 5242
         WHERE user_id = %i ORDER BY group_id',
5245 5243
         $userId
5246 5244
     );
@@ -5257,7 +5255,7 @@  discard block
 block discarded – undo
5257 5255
 function addUserForbiddenGroup(int $userId, int $groupId): void
5258 5256
 {
5259 5257
     DB::query(
5260
-        'INSERT IGNORE INTO ' . prefixTable('users_groups_forbidden') . ' (user_id, group_id)
5258
+        'INSERT IGNORE INTO '.prefixTable('users_groups_forbidden').' (user_id, group_id)
5261 5259
         VALUES (%i, %i)',
5262 5260
         $userId,
5263 5261
         $groupId
@@ -5270,7 +5268,7 @@  discard block
 block discarded – undo
5270 5268
 function removeUserForbiddenGroup(int $userId, int $groupId): void
5271 5269
 {
5272 5270
     DB::query(
5273
-        'DELETE FROM ' . prefixTable('users_groups_forbidden') . '
5271
+        'DELETE FROM '.prefixTable('users_groups_forbidden').'
5274 5272
         WHERE user_id = %i AND group_id = %i',
5275 5273
         $userId,
5276 5274
         $groupId
@@ -5283,7 +5281,7 @@  discard block
 block discarded – undo
5283 5281
 function setUserForbiddenGroups(int $userId, array $groupIds): void
5284 5282
 {
5285 5283
     DB::query(
5286
-        'DELETE FROM ' . prefixTable('users_groups_forbidden') . ' WHERE user_id = %i',
5284
+        'DELETE FROM '.prefixTable('users_groups_forbidden').' WHERE user_id = %i',
5287 5285
         $userId
5288 5286
     );
5289 5287
     
@@ -5300,7 +5298,7 @@  discard block
 block discarded – undo
5300 5298
 function getUserForbiddenGroups(int $userId): array
5301 5299
 {
5302 5300
     $result = DB::query(
5303
-        'SELECT group_id FROM ' . prefixTable('users_groups_forbidden') . ' 
5301
+        'SELECT group_id FROM '.prefixTable('users_groups_forbidden').' 
5304 5302
         WHERE user_id = %i ORDER BY group_id',
5305 5303
         $userId
5306 5304
     );
@@ -5319,7 +5317,7 @@  discard block
 block discarded – undo
5319 5317
 function addUserRole(int $userId, int $roleId, string $source = 'manual'): void
5320 5318
 {
5321 5319
     DB::query(
5322
-        'INSERT IGNORE INTO ' . prefixTable('users_roles') . ' (user_id, role_id, source)
5320
+        'INSERT IGNORE INTO '.prefixTable('users_roles').' (user_id, role_id, source)
5323 5321
         VALUES (%i, %i, %s)',
5324 5322
         $userId,
5325 5323
         $roleId,
@@ -5333,7 +5331,7 @@  discard block
 block discarded – undo
5333 5331
 function removeUserRole(int $userId, int $roleId, string $source = 'manual'): void
5334 5332
 {
5335 5333
     DB::query(
5336
-        'DELETE FROM ' . prefixTable('users_roles') . '
5334
+        'DELETE FROM '.prefixTable('users_roles').'
5337 5335
         WHERE user_id = %i AND role_id = %i AND source = %s',
5338 5336
         $userId,
5339 5337
         $roleId,
@@ -5347,7 +5345,7 @@  discard block
 block discarded – undo
5347 5345
 function removeUserRolesBySource(int $userId, string $source): void
5348 5346
 {
5349 5347
     DB::query(
5350
-        'DELETE FROM ' . prefixTable('users_roles') . '
5348
+        'DELETE FROM '.prefixTable('users_roles').'
5351 5349
         WHERE user_id = %i AND source = %s',
5352 5350
         $userId,
5353 5351
         $source
@@ -5381,14 +5379,14 @@  discard block
 block discarded – undo
5381 5379
 {
5382 5380
     if ($source !== null) {
5383 5381
         $result = DB::query(
5384
-            'SELECT role_id FROM ' . prefixTable('users_roles') . ' 
5382
+            'SELECT role_id FROM '.prefixTable('users_roles').' 
5385 5383
             WHERE user_id = %i AND source = %s ORDER BY role_id',
5386 5384
             $userId,
5387 5385
             $source
5388 5386
         );
5389 5387
     } else {
5390 5388
         $result = DB::query(
5391
-            'SELECT role_id FROM ' . prefixTable('users_roles') . ' 
5389
+            'SELECT role_id FROM '.prefixTable('users_roles').' 
5392 5390
             WHERE user_id = %i ORDER BY role_id',
5393 5391
             $userId
5394 5392
         );
@@ -5406,7 +5404,7 @@  discard block
 block discarded – undo
5406 5404
 function addUserFavorite(int $userId, int $itemId): void
5407 5405
 {
5408 5406
     DB::query(
5409
-        'INSERT IGNORE INTO ' . prefixTable('users_favorites') . ' (user_id, item_id)
5407
+        'INSERT IGNORE INTO '.prefixTable('users_favorites').' (user_id, item_id)
5410 5408
         VALUES (%i, %i)',
5411 5409
         $userId,
5412 5410
         $itemId
@@ -5419,7 +5417,7 @@  discard block
 block discarded – undo
5419 5417
 function removeUserFavorite(int $userId, int $itemId): void
5420 5418
 {
5421 5419
     DB::query(
5422
-        'DELETE FROM ' . prefixTable('users_favorites') . '
5420
+        'DELETE FROM '.prefixTable('users_favorites').'
5423 5421
         WHERE user_id = %i AND item_id = %i',
5424 5422
         $userId,
5425 5423
         $itemId
@@ -5432,7 +5430,7 @@  discard block
 block discarded – undo
5432 5430
 function toggleUserFavorite(int $userId, int $itemId): bool
5433 5431
 {
5434 5432
     $exists = DB::queryFirstRow(
5435
-        'SELECT increment_id FROM ' . prefixTable('users_favorites') . '
5433
+        'SELECT increment_id FROM '.prefixTable('users_favorites').'
5436 5434
         WHERE user_id = %i AND item_id = %i',
5437 5435
         $userId,
5438 5436
         $itemId
@@ -5453,7 +5451,7 @@  discard block
 block discarded – undo
5453 5451
 function setUserFavorites(int $userId, array $itemIds): void
5454 5452
 {
5455 5453
     DB::query(
5456
-        'DELETE FROM ' . prefixTable('users_favorites') . ' WHERE user_id = %i',
5454
+        'DELETE FROM '.prefixTable('users_favorites').' WHERE user_id = %i',
5457 5455
         $userId
5458 5456
     );
5459 5457
     
@@ -5470,7 +5468,7 @@  discard block
 block discarded – undo
5470 5468
 function getUserFavorites(int $userId): array
5471 5469
 {
5472 5470
     $result = DB::query(
5473
-        'SELECT item_id FROM ' . prefixTable('users_favorites') . ' 
5471
+        'SELECT item_id FROM '.prefixTable('users_favorites').' 
5474 5472
         WHERE user_id = %i ORDER BY created_at DESC',
5475 5473
         $userId
5476 5474
     );
@@ -5483,7 +5481,7 @@  discard block
 block discarded – undo
5483 5481
 function isUserFavorite(int $userId, int $itemId): bool
5484 5482
 {
5485 5483
     $result = DB::queryFirstRow(
5486
-        'SELECT increment_id FROM ' . prefixTable('users_favorites') . '
5484
+        'SELECT increment_id FROM '.prefixTable('users_favorites').'
5487 5485
         WHERE user_id = %i AND item_id = %i',
5488 5486
         $userId,
5489 5487
         $itemId
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
     $userLoginSafe = htmlspecialchars($record['login'], ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
96 96
     $usersList[$userLoginSafe] = [
@@ -102,16 +102,16 @@  discard block
 block discarded – undo
102 102
 // Get list of roles
103 103
 $arrRoles = [];
104 104
 $listRoles = '';
105
-$rows = DB::query('SELECT id,title FROM ' . prefixTable('roles_title') . ' ORDER BY title ASC');
105
+$rows = DB::query('SELECT id,title FROM '.prefixTable('roles_title').' ORDER BY title ASC');
106 106
 foreach ($rows as $reccord) {
107 107
     $arrRoles[$reccord['title']] = [
108 108
         'id' => $reccord['id'],
109 109
         'title' => $reccord['title'],
110 110
     ];
111 111
     if (empty($listRoles)) {
112
-        $listRoles = $reccord['id'] . '#' . $reccord['title'];
112
+        $listRoles = $reccord['id'].'#'.$reccord['title'];
113 113
     } else {
114
-        $listRoles .= ';' . $reccord['id'] . '#' . $reccord['title'];
114
+        $listRoles .= ';'.$reccord['id'].'#'.$reccord['title'];
115 115
     }
116 116
 }
117 117
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
                         <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>
187 187
                         <?php
188 188
                         echo isset($SETTINGS['item_extra_fields']) === true && (int) $SETTINGS['item_extra_fields'] === 1 ? '
189
-                            <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
+                            <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>' : '';
190 190
                         ?>
191 191
                     </ul>
192 192
                 </div><!-- /.card-header -->
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
                                                 <?php
256 256
                                                 for ($i = 4; $i <= $SETTINGS['pwd_maximum_length']; ++$i) {
257 257
                                                     echo '
258
-                                                <option>' . $i . '</option>';
258
+                                                <option>' . $i.'</option>';
259 259
                                                 }
260 260
                                                 ?>
261 261
                                             </select>
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
                                     <span class="ml-2 col-md-1 clear-me-html" id="form-item-icon-show"></span>
286 286
                                 </div>
287 287
                                 <small class='form-text text-muted'>
288
-                                    <?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
+                                    <?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>
289 289
                                 </small>
290 290
                             </div>
291 291
 
@@ -473,39 +473,39 @@  discard block
 block discarded – undo
473 473
                             <div class="tab-pane" id="tab_4">
474 474
                                 <div id="form-item-field" class="hidden">
475 475
                                     <?php
476
-                                        $session_item_fields = $session->get('system-item_fields');//print_r($session_item_fields);
476
+                                        $session_item_fields = $session->get('system-item_fields'); //print_r($session_item_fields);
477 477
                                         if (isset($session_item_fields) === true) {
478 478
                                             foreach ($session_item_fields as $category) {
479 479
                                                 //print_r($category);
480 480
                                                 echo '
481
-                                            <div class="callout callout-info form-item-category hidden" id="form-item-category-' . $category['id'] . '">
482
-                                                <h5>' . $category['title'] . '</h5>
481
+                                            <div class="callout callout-info form-item-category hidden" id="form-item-category-' . $category['id'].'">
482
+                                                <h5>' . $category['title'].'</h5>
483 483
                                                 <p>';
484 484
                                                 foreach ($category['fields'] as $field) {
485 485
                                                     if ($field['type'] === 'textarea') {
486 486
                                                         echo '
487
-                                                    <div class="form-group mb-3 form-item-field" id="form-item-field-' . $field['id'] . '" data-field-id="' . $field['id'] . '">
487
+                                                    <div class="form-group mb-3 form-item-field" id="form-item-field-' . $field['id'].'" data-field-id="'.$field['id'].'">
488 488
                                                         <label>' . $field['title'],
489 489
                                                             $field['is_mandatory'] === '1' ?
490
-                                                                '<span class="fa-solid fa-fire text-danger ml-1 infotip" title="' . $lang->get('is_mandatory') . '"></span>' : '',
490
+                                                                '<span class="fa-solid fa-fire text-danger ml-1 infotip" title="'.$lang->get('is_mandatory').'"></span>' : '',
491 491
                                                             '</label>
492
-                                                        <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
+                                                        <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>
493 493
                                                     </div>';
494 494
                                                     } else {
495 495
                                                         echo '
496
-                                                    <div class="input-group mb-3 form-item-field" id="form-item-field-' . $field['id'] . '" data-field-id="' . $field['id'] . '">
496
+                                                    <div class="input-group mb-3 form-item-field" id="form-item-field-' . $field['id'].'" data-field-id="'.$field['id'].'">
497 497
                                                         <div class="input-group-prepend">
498 498
                                                             <span class="input-group-text">' . $field['title'],
499 499
                                                             $field['is_mandatory'] === '1' ?
500
-                                                                '<span class="fa-solid fa-fire text-danger ml-1 infotip" title="' . $lang->get('is_mandatory') . '"></span>' : '',
500
+                                                                '<span class="fa-solid fa-fire text-danger ml-1 infotip" title="'.$lang->get('is_mandatory').'"></span>' : '',
501 501
                                                             '</span>
502 502
                                                         </div>
503
-                                                        <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
+                                                        <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">
504 504
                                                     </div>';
505 505
                                                     }
506 506
                                                     if (!empty($field['regex'])) {
507 507
                                                         echo '
508
-                                                    <div>Regex: '. $field['regex'] .'</div>
508
+                                                    <div>Regex: '. $field['regex'].'</div>
509 509
                                                         ';
510 510
                                                     }
511 511
                                                 }
@@ -516,8 +516,8 @@  discard block
 block discarded – undo
516 516
                                                 ) {
517 517
                                                     echo '
518 518
                                                     <div class="form-check icheck-blue">
519
-                                                        <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'] . '">
520
-                                                        <label class="form-check-label ml-3" for="template_' . $category['id'] . '">' . $lang->get('main_template') . '</label>
519
+                                                        <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'].'">
520
+                                                        <label class="form-check-label ml-3" for="template_' . $category['id'].'">'.$lang->get('main_template').'</label>
521 521
                                                     </div>';
522 522
                                                 }
523 523
                                                 echo '
@@ -527,8 +527,8 @@  discard block
 block discarded – undo
527 527
                                         } else {
528 528
                                             echo
529 529
                                             '<div class="alert alert-info">
530
-                                                <h5><i class="icon fa fa-info mr-3"></i>' . $lang->get('information') . '</h5>
531
-                                                ' . $lang->get('no_fields') . '
530
+                                                <h5><i class="icon fa fa-info mr-3"></i>' . $lang->get('information').'</h5>
531
+                                                ' . $lang->get('no_fields').'
532 532
                                             </div>';
533 533
                                         } ?>
534 534
                                 </div>
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
                         <p><?php
670 670
                             echo str_replace(
671 671
         ['##otv_expiration_period##', '. '],
672
-        ['<span class="text-bold text-primary">' . $SETTINGS['otv_expiration_period'] . '</span>', '<br>'],
672
+        ['<span class="text-bold text-primary">'.$SETTINGS['otv_expiration_period'].'</span>', '<br>'],
673 673
         $lang->get('otv_message')
674 674
     );
675 675
                             ?></p>
@@ -687,9 +687,9 @@  discard block
 block discarded – undo
687 687
 
688 688
                     <div class="row">
689 689
                         <div class="form-group col-4">
690
-                            <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
+                            <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>
691 691
                             <div class="input-group mb-3">
692
-                                <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
+                                <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']; ?>">
693 693
                             </div>
694 694
                         </div>
695 695
 
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
                             <select class="form-control form-folder-control select2" style="width:100%;" id="form-folder-add-complexicity" required>
778 778
                                 <?php
779 779
                                 foreach (TP_PW_COMPLEXITY as $key => $value) {
780
-                                    echo '<option value="' . $key . '">' . $value[1] . '</option>';
780
+                                    echo '<option value="'.$key.'">'.$value[1].'</option>';
781 781
                                 }
782 782
                                 ?>
783 783
                             </select>
@@ -795,14 +795,14 @@  discard block
 block discarded – undo
795 795
                             <label><?php echo $lang->get('icon'); ?></label>
796 796
                             <input type="text" class="form-control form-folder-control" id="form-folder-add-icon">
797 797
                             <small class='form-text text-muted'>
798
-                                <?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
+                                <?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>
799 799
                             </small>
800 800
                         </div>
801 801
                         <div class="form-group">
802 802
                             <label><?php echo $lang->get('icon_on_selection'); ?></label>
803 803
                             <input type="text" class="form-control form-folder-control" id="form-folder-add-icon-selected">
804 804
                             <small class='form-text text-muted'>
805
-                                <?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
+                                <?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>
806 806
                             </small>
807 807
                         </div>
808 808
                     </div>
@@ -1263,18 +1263,18 @@  discard block
 block discarded – undo
1263 1263
                                 <?php
1264 1264
                                     foreach ($session_item_fields as $elem) {
1265 1265
                                         echo '
1266
-                                <div class="callout callout-info card-item-category hidden" id="card-item-category-' . $elem['id'] . '">
1267
-                                    <h5>' . $elem['title'] . '</h5>
1266
+                                <div class="callout callout-info card-item-category hidden" id="card-item-category-' . $elem['id'].'">
1267
+                                    <h5>' . $elem['title'].'</h5>
1268 1268
                                     <p>
1269 1269
                                         <ul class="list-group list-group-unbordered mb-3">';
1270 1270
                                         foreach ($elem['fields'] as $field) {
1271 1271
                                             echo '
1272
-                                            <li class="list-group-item card-item-field hidden" id="card-item-field-' . $field['id'] . '">
1273
-                                                <span id="card-item-field-title-' . $field['id'] . '"><b>' . $field['title'] . '</b></span>
1274
-                                                <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'] . '">
1272
+                                            <li class="list-group-item card-item-field hidden" id="card-item-field-' . $field['id'].'">
1273
+                                                <span id="card-item-field-title-' . $field['id'].'"><b>'.$field['title'].'</b></span>
1274
+                                                <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'].'">
1275 1275
                                                     <i class="fa-solid fa-copy"></i>
1276 1276
                                                 </button>
1277
-                                                <span class="card-item-field-value float-right ml-1" id="card-item-field-value-' . $field['id'] . '"></span>
1277
+                                                <span class="card-item-field-value float-right ml-1" id="card-item-field-value-' . $field['id'].'"></span>
1278 1278
                                             </li>';
1279 1279
                                         }
1280 1280
                                         echo '
Please login to merge, or discard this patch.