Passed
Push — master ( e9bc10...106709 )
by Nils
07:23
created
sources/admin.queries.php 1 patch
Switch Indentation   +246 added lines, -246 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,25 +2919,25 @@  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
-    );
2932
+            $timestamp5min
2933
+        );
2934 2934
     
2935
-    $activityList = array();
2935
+        $activityList = array();
2936 2936
     
2937
-    foreach ($activities as $activity) {
2938
-        // Translate action to readable text
2939
-        $actionText = '';
2940
-        switch ($activity['action']) {
2937
+        foreach ($activities as $activity) {
2938
+            // Translate action to readable text
2939
+            $actionText = '';
2940
+            switch ($activity['action']) {
2941 2941
             case 'at_shown':
2942 2942
                 $actionText = $lang->get('action_accessed');
2943 2943
                 break;
@@ -2961,7 +2961,7 @@  discard block
 block discarded – undo
2961 2961
                 break;
2962 2962
             default:
2963 2963
                 $actionText = $activity['action'];
2964
-        }
2964
+            }
2965 2965
         
2966 2966
         $activityList[] = array(
2967 2967
             'timestamp' => (int) $activity['date'],
@@ -2987,8 +2987,8 @@  discard block
 block discarded – undo
2987 2987
 // SYSTEM STATUS ENDPOINT
2988 2988
 // ========================================
2989 2989
 
2990
-case 'get_system_status':
2991
-    /**
2990
+    case 'get_system_status':
2991
+        /**
2992 2992
      * Get system status (CPU, RAM, disk, tasks queue)
2993 2993
      * 
2994 2994
      * @return array {
@@ -2997,49 +2997,49 @@  discard block
 block discarded – undo
2997 2997
      * }
2998 2998
      */
2999 2999
         
3000
-    // Tasks queue count
3001
-    $tasksQueue = DB::queryFirstField(
3002
-        'SELECT COUNT(*) FROM ' . prefixTable('background_tasks') . ' 
3000
+        // Tasks queue count
3001
+        $tasksQueue = DB::queryFirstField(
3002
+            'SELECT COUNT(*) FROM ' . prefixTable('background_tasks') . ' 
3003 3003
         WHERE finished_at IS NULL OR finished_at = 0'
3004
-    );
3004
+        );
3005 3005
     
3006
-    // Last cron execution
3007
-    $lastCronLog = DB::queryFirstRow(
3008
-        'SELECT created_at FROM ' . prefixTable('background_tasks_logs') . ' 
3006
+        // Last cron execution
3007
+        $lastCronLog = DB::queryFirstRow(
3008
+            'SELECT created_at FROM ' . prefixTable('background_tasks_logs') . ' 
3009 3009
         ORDER BY created_at DESC 
3010 3010
         LIMIT 1'
3011
-    );
3011
+        );
3012 3012
     
3013
-    $lastCronText = $lang->get('never');
3014
-    if ($lastCronLog && isset($lastCronLog['created_at'])) {
3015
-        $timeDiff = time() - (int) $lastCronLog['created_at'];
3016
-        if ($timeDiff < 60) {
3017
-            $lastCronText = $timeDiff . 's ' . $lang->get('ago');
3018
-        } elseif ($timeDiff < 3600) {
3019
-            $lastCronText = floor($timeDiff / 60) . 'm ' . $lang->get('ago');
3020
-        } elseif ($timeDiff < 86400) {
3021
-            $lastCronText = floor($timeDiff / 3600) . 'h ' . $lang->get('ago');
3022
-        } else {
3023
-            $lastCronText = floor($timeDiff / 86400) . 'd ' . $lang->get('ago');
3013
+        $lastCronText = $lang->get('never');
3014
+        if ($lastCronLog && isset($lastCronLog['created_at'])) {
3015
+            $timeDiff = time() - (int) $lastCronLog['created_at'];
3016
+            if ($timeDiff < 60) {
3017
+                $lastCronText = $timeDiff . 's ' . $lang->get('ago');
3018
+            } elseif ($timeDiff < 3600) {
3019
+                $lastCronText = floor($timeDiff / 60) . 'm ' . $lang->get('ago');
3020
+            } elseif ($timeDiff < 86400) {
3021
+                $lastCronText = floor($timeDiff / 3600) . 'h ' . $lang->get('ago');
3022
+            } else {
3023
+                $lastCronText = floor($timeDiff / 86400) . 'd ' . $lang->get('ago');
3024
+            }
3024 3025
         }
3025
-    }
3026 3026
     
3027
-    echo prepareExchangedData(
3028
-        array(
3029
-            'error' => false,
3030
-            'tasks_queue' => (int) $tasksQueue,
3031
-            'last_cron' => $lastCronText,
3032
-        ),
3033
-        'encode'
3034
-    );
3035
-    break;
3027
+        echo prepareExchangedData(
3028
+            array(
3029
+                'error' => false,
3030
+                'tasks_queue' => (int) $tasksQueue,
3031
+                'last_cron' => $lastCronText,
3032
+            ),
3033
+            'encode'
3034
+        );
3035
+        break;
3036 3036
 
3037
-// ========================================
3038
-// SYSTEM HEALTH ENDPOINT
3039
-// ========================================
3037
+    // ========================================
3038
+    // SYSTEM HEALTH ENDPOINT
3039
+    // ========================================
3040 3040
 
3041
-case 'get_system_health':
3042
-    /**
3041
+    case 'get_system_health':
3042
+        /**
3043 3043
      * Get system health checks
3044 3044
      * 
3045 3045
      * @return array {
@@ -3051,97 +3051,97 @@  discard block
 block discarded – undo
3051 3051
      * }
3052 3052
      */
3053 3053
     
3054
-    // Encryption check
3055
-    $encryptionStatus = 'success';
3056
-    $encryptionText = $lang->get('health_status_ok');
3054
+        // Encryption check
3055
+        $encryptionStatus = 'success';
3056
+        $encryptionText = $lang->get('health_status_ok');
3057 3057
     
3058
-    // Check if secure file exists
3059
-    if (isset($SETTINGS['securepath']) && isset($SETTINGS['securefile']) && !file_exists($SETTINGS['securepath'] . DIRECTORY_SEPARATOR . $SETTINGS['securefile'])) {
3060
-        $encryptionStatus = 'danger';
3061
-        $encryptionText = $lang->get('health_secure_file_missing');
3062
-    }
3058
+        // Check if secure file exists
3059
+        if (isset($SETTINGS['securepath']) && isset($SETTINGS['securefile']) && !file_exists($SETTINGS['securepath'] . DIRECTORY_SEPARATOR . $SETTINGS['securefile'])) {
3060
+            $encryptionStatus = 'danger';
3061
+            $encryptionText = $lang->get('health_secure_file_missing');
3062
+        }
3063 3063
     
3064
-    // Active sessions count
3065
-    $sessionsCount = DB::queryFirstField(
3066
-        'SELECT COUNT(*) FROM ' . prefixTable('users') . ' 
3064
+        // Active sessions count
3065
+        $sessionsCount = DB::queryFirstField(
3066
+            'SELECT COUNT(*) FROM ' . prefixTable('users') . ' 
3067 3067
         WHERE session_end > %i',
3068
-        time()
3069
-    );
3068
+            time()
3069
+        );
3070 3070
     
3071
-    // Is cron installed
3072
-    DB::query(
3073
-        'SELECT valeur
3071
+        // Is cron installed
3072
+        DB::query(
3073
+            'SELECT valeur
3074 3074
         FROM ' . prefixTable('misc') . '
3075 3075
         WHERE type = %s AND intitule = %s and valeur >= %d',
3076
-        'admin',
3077
-        'last_cron_exec',
3078
-        time() - 600 // max 10 minutes
3079
-    );
3076
+            'admin',
3077
+            'last_cron_exec',
3078
+            time() - 600 // max 10 minutes
3079
+        );
3080 3080
 
3081
-    if (DB::count() === 0) {
3082
-        $cronStatus = 'danger';
3083
-        $cronText = $lang->get('error');
3084
-    } else {
3085
-        // Cron check (last execution should be < 2 minutes ago)
3086
-        $lastCron = DB::queryFirstField(
3087
-            'SELECT created_at FROM ' . prefixTable('background_tasks_logs') . ' 
3081
+        if (DB::count() === 0) {
3082
+            $cronStatus = 'danger';
3083
+            $cronText = $lang->get('error');
3084
+        } else {
3085
+            // Cron check (last execution should be < 2 minutes ago)
3086
+            $lastCron = DB::queryFirstField(
3087
+                'SELECT created_at FROM ' . prefixTable('background_tasks_logs') . ' 
3088 3088
             ORDER BY created_at DESC 
3089 3089
             LIMIT 1'
3090
-        );
3090
+            );
3091 3091
         
3092
-        $cronStatus = 'success';
3093
-        $cronText = $lang->get('health_status_ok');
3092
+            $cronStatus = 'success';
3093
+            $cronText = $lang->get('health_status_ok');
3094 3094
         
3095
-        if (!$lastCron || (time() - (int) $lastCron) > 120) {
3096
-            $cronStatus = 'warning';
3097
-            $cronText = $lang->get('health_cron_delayed');
3095
+            if (!$lastCron || (time() - (int) $lastCron) > 120) {
3096
+                $cronStatus = 'warning';
3097
+                $cronText = $lang->get('health_cron_delayed');
3098
+            }
3098 3099
         }
3099
-    }
3100 3100
     
3101
-    // Unknown files count
3102
-    $unknownFilesData = DB::queryFirstField(
3103
-        'SELECT valeur FROM ' . prefixTable('misc') . ' 
3101
+        // Unknown files count
3102
+        $unknownFilesData = DB::queryFirstField(
3103
+            'SELECT valeur FROM ' . prefixTable('misc') . ' 
3104 3104
         WHERE type = %s AND intitule = %s',
3105
-        'admin',
3106
-        'unknown_files'
3107
-    );
3105
+            'admin',
3106
+            'unknown_files'
3107
+        );
3108 3108
     
3109
-    $unknownFilesCount = 0;
3110
-    if ($unknownFilesData) {
3111
-        $unknownFiles = json_decode($unknownFilesData, true);
3112
-        if (is_array($unknownFiles)) {
3113
-            $unknownFilesCount = count($unknownFiles);
3109
+        $unknownFilesCount = 0;
3110
+        if ($unknownFilesData) {
3111
+            $unknownFiles = json_decode($unknownFilesData, true);
3112
+            if (is_array($unknownFiles)) {
3113
+                $unknownFilesCount = count($unknownFiles);
3114
+            }
3114 3115
         }
3115
-    }
3116 3116
     
3117
-    echo prepareExchangedData(
3118
-        array(
3119
-            'error' => false,
3120
-            'encryption' => array(
3121
-                'status' => $encryptionStatus,
3122
-                'text' => $encryptionText,
3123
-            ),
3124
-            'sessions' => array(
3125
-                'count' => (int) $sessionsCount,
3126
-            ),
3127
-            'cron' => array(
3128
-                'status' => $cronStatus,
3129
-                'text' => $cronText,
3130
-            ),
3131
-            'unknown_files' => array(
3132
-                'count' => $unknownFilesCount,
3117
+        echo prepareExchangedData(
3118
+            array(
3119
+                'error' => false,
3120
+                'encryption' => array(
3121
+                    'status' => $encryptionStatus,
3122
+                    'text' => $encryptionText,
3123
+                ),
3124
+                'sessions' => array(
3125
+                    'count' => (int) $sessionsCount,
3126
+                ),
3127
+                'cron' => array(
3128
+                    'status' => $cronStatus,
3129
+                    'text' => $cronText,
3130
+                ),
3131
+                'unknown_files' => array(
3132
+                    'count' => $unknownFilesCount,
3133
+                ),
3133 3134
             ),
3134
-        ),
3135
-        'encode'
3136
-    );
3137
-    break;
3135
+            'encode'
3136
+        );
3137
+        break;
3138 3138
 
3139
-// ========================================
3140
-// QUICK ACTIONS - CLEAN OLD LOGS
3141
-// ========================================
3139
+    // ========================================
3140
+    // QUICK ACTIONS - CLEAN OLD LOGS
3141
+    // ========================================
3142 3142
 
3143
-case 'clean_old_logs':
3144
-    /**
3143
+    case 'clean_old_logs':
3144
+        /**
3145 3145
      * Clean logs older than 90 days
3146 3146
      * 
3147 3147
      * @return array {
@@ -3151,54 +3151,54 @@  discard block
 block discarded – undo
3151 3151
      * }
3152 3152
      */
3153 3153
     
3154
-    $threshold = time() - (90 * 86400); // 90 days ago
3154
+        $threshold = time() - (90 * 86400); // 90 days ago
3155 3155
     
3156
-    // Delete old log_items entries
3157
-    DB::delete(
3158
-        prefixTable('log_items'),
3159
-        'date < %i',
3160
-        $threshold
3161
-    );
3156
+        // Delete old log_items entries
3157
+        DB::delete(
3158
+            prefixTable('log_items'),
3159
+            'date < %i',
3160
+            $threshold
3161
+        );
3162 3162
     
3163
-    $deletedItems = DB::affectedRows();
3163
+        $deletedItems = DB::affectedRows();
3164 3164
     
3165
-    // Delete old log_system entries
3166
-    DB::delete(
3167
-        prefixTable('log_system'),
3168
-        'date < %i',
3169
-        $threshold
3170
-    );
3165
+        // Delete old log_system entries
3166
+        DB::delete(
3167
+            prefixTable('log_system'),
3168
+            'date < %i',
3169
+            $threshold
3170
+        );
3171 3171
     
3172
-    $deletedSystem = DB::affectedRows();
3172
+        $deletedSystem = DB::affectedRows();
3173 3173
     
3174
-    $totalDeleted = $deletedItems + $deletedSystem;
3174
+        $totalDeleted = $deletedItems + $deletedSystem;
3175 3175
     
3176
-    // Log the action
3177
-    logEvents(
3178
-        $SETTINGS,
3179
-        'admin_action',
3180
-        'clean_old_logs',
3181
-        (string) $session->get('user-id'),
3182
-        $session->get('user-login'),
3183
-        'Cleaned ' . $totalDeleted . ' old log entries'
3184
-    );
3176
+        // Log the action
3177
+        logEvents(
3178
+            $SETTINGS,
3179
+            'admin_action',
3180
+            'clean_old_logs',
3181
+            (string) $session->get('user-id'),
3182
+            $session->get('user-login'),
3183
+            'Cleaned ' . $totalDeleted . ' old log entries'
3184
+        );
3185 3185
     
3186
-    echo prepareExchangedData(
3187
-        array(
3188
-            'error' => false,
3189
-            'message' => $lang->get('admin_logs_cleaned_success'),
3190
-            'deleted_count' => $totalDeleted,
3191
-        ),
3192
-        'encode'
3193
-    );
3194
-    break;
3186
+        echo prepareExchangedData(
3187
+            array(
3188
+                'error' => false,
3189
+                'message' => $lang->get('admin_logs_cleaned_success'),
3190
+                'deleted_count' => $totalDeleted,
3191
+            ),
3192
+            'encode'
3193
+        );
3194
+        break;
3195 3195
 
3196
-// ========================================
3197
-// QUICK ACTIONS - TEST ENCRYPTION (KEPT FOR COMPATIBILITY)
3198
-// ========================================
3196
+    // ========================================
3197
+    // QUICK ACTIONS - TEST ENCRYPTION (KEPT FOR COMPATIBILITY)
3198
+    // ========================================
3199 3199
 
3200
-case 'test_encryption':
3201
-    /**
3200
+    case 'test_encryption':
3201
+        /**
3202 3202
      * Test encryption system integrity
3203 3203
      * 
3204 3204
      * @return array {
@@ -3207,117 +3207,117 @@  discard block
 block discarded – undo
3207 3207
      * }
3208 3208
      */
3209 3209
     
3210
-    try {
3211
-        // Test string
3212
-        $testString = 'TeamPass Encryption Test ' . time();
3210
+        try {
3211
+            // Test string
3212
+            $testString = 'TeamPass Encryption Test ' . time();
3213 3213
         
3214
-        // Get encryption key
3215
-        $key = file_get_contents($SETTINGS['securepath'] . DIRECTORY_SEPARATOR . $SETTINGS['securefile']);
3214
+            // Get encryption key
3215
+            $key = file_get_contents($SETTINGS['securepath'] . DIRECTORY_SEPARATOR . $SETTINGS['securefile']);
3216 3216
         
3217
-        if ($key === false) {
3218
-            throw new Exception($lang->get('admin_encryption_key_not_found'));
3219
-        }
3217
+            if ($key === false) {
3218
+                throw new Exception($lang->get('admin_encryption_key_not_found'));
3219
+            }
3220 3220
         
3221
-        // Use Defuse encryption (TeamPass's current encryption method)
3222
-        require_once $SETTINGS['cpassman_dir'] . '/vendor/defuse/php-encryption/src/Exception/EnvironmentIsBrokenException.php';
3223
-        require_once $SETTINGS['cpassman_dir'] . '/vendor/defuse/php-encryption/src/Exception/BadFormatException.php';
3224
-        require_once $SETTINGS['cpassman_dir'] . '/vendor/defuse/php-encryption/src/Exception/WrongKeyOrModifiedCiphertextException.php';
3225
-        require_once $SETTINGS['cpassman_dir'] . '/vendor/defuse/php-encryption/src/Crypto.php';
3226
-        require_once $SETTINGS['cpassman_dir'] . '/vendor/defuse/php-encryption/src/Key.php';
3221
+            // Use Defuse encryption (TeamPass's current encryption method)
3222
+            require_once $SETTINGS['cpassman_dir'] . '/vendor/defuse/php-encryption/src/Exception/EnvironmentIsBrokenException.php';
3223
+            require_once $SETTINGS['cpassman_dir'] . '/vendor/defuse/php-encryption/src/Exception/BadFormatException.php';
3224
+            require_once $SETTINGS['cpassman_dir'] . '/vendor/defuse/php-encryption/src/Exception/WrongKeyOrModifiedCiphertextException.php';
3225
+            require_once $SETTINGS['cpassman_dir'] . '/vendor/defuse/php-encryption/src/Crypto.php';
3226
+            require_once $SETTINGS['cpassman_dir'] . '/vendor/defuse/php-encryption/src/Key.php';
3227 3227
         
3228
-        $encryptionKey = \Defuse\Crypto\Key::loadFromAsciiSafeString($key);
3228
+            $encryptionKey = \Defuse\Crypto\Key::loadFromAsciiSafeString($key);
3229 3229
         
3230
-        // Encrypt test string
3231
-        $encrypted = \Defuse\Crypto\Crypto::encrypt($testString, $encryptionKey);
3230
+            // Encrypt test string
3231
+            $encrypted = \Defuse\Crypto\Crypto::encrypt($testString, $encryptionKey);
3232 3232
         
3233
-        // Decrypt test string
3234
-        $decrypted = \Defuse\Crypto\Crypto::decrypt($encrypted, $encryptionKey);
3233
+            // Decrypt test string
3234
+            $decrypted = \Defuse\Crypto\Crypto::decrypt($encrypted, $encryptionKey);
3235 3235
         
3236
-        // Verify
3237
-        if ($decrypted !== $testString) {
3238
-            throw new Exception($lang->get('admin_encryption_test_failed'));
3239
-        }
3236
+            // Verify
3237
+            if ($decrypted !== $testString) {
3238
+                throw new Exception($lang->get('admin_encryption_test_failed'));
3239
+            }
3240 3240
         
3241
-        // Log the test
3242
-        logEvents(
3243
-            $SETTINGS,
3244
-            'admin_action',
3245
-            'test_encryption',
3246
-            (string) $session->get('user-id'),
3247
-            $session->get('user-login'),
3248
-            'Encryption test successful'
3249
-        );
3241
+            // Log the test
3242
+            logEvents(
3243
+                $SETTINGS,
3244
+                'admin_action',
3245
+                'test_encryption',
3246
+                (string) $session->get('user-id'),
3247
+                $session->get('user-login'),
3248
+                'Encryption test successful'
3249
+            );
3250 3250
         
3251
-        echo prepareExchangedData(
3252
-            array(
3253
-                'error' => false,
3254
-                'message' => $lang->get('admin_encryption_test_success'),
3255
-            ),
3256
-            'encode'
3257
-        );
3251
+            echo prepareExchangedData(
3252
+                array(
3253
+                    'error' => false,
3254
+                    'message' => $lang->get('admin_encryption_test_success'),
3255
+                ),
3256
+                'encode'
3257
+            );
3258 3258
         
3259
-    } catch (Exception $e) {
3260
-        echo prepareExchangedData(
3261
-            array(
3262
-                'error' => true,
3263
-                'message' => $e->getMessage(),
3264
-            ),
3265
-            'encode'
3266
-        );
3267
-    }
3268
-    break;
3259
+        } catch (Exception $e) {
3260
+            echo prepareExchangedData(
3261
+                array(
3262
+                    'error' => true,
3263
+                    'message' => $e->getMessage(),
3264
+                ),
3265
+                'encode'
3266
+            );
3267
+        }
3268
+        break;
3269 3269
 
3270
-// ========================================
3271
-// QUICK ACTIONS - EXPORT STATISTICS
3272
-// ========================================
3270
+    // ========================================
3271
+    // QUICK ACTIONS - EXPORT STATISTICS
3272
+    // ========================================
3273 3273
 
3274
-case 'export_statistics':
3275
-    /**
3274
+    case 'export_statistics':
3275
+        /**
3276 3276
      * Export statistics as CSV file
3277 3277
      * 
3278 3278
      * @return void (file download)
3279 3279
      */
3280 3280
     
3281
-    // Set headers for CSV download
3282
-    header('Content-Type: text/csv; charset=utf-8');
3283
-    header('Content-Disposition: attachment; filename="teampass_statistics_' . date('Y-m-d_H-i-s') . '.csv"');
3281
+        // Set headers for CSV download
3282
+        header('Content-Type: text/csv; charset=utf-8');
3283
+        header('Content-Disposition: attachment; filename="teampass_statistics_' . date('Y-m-d_H-i-s') . '.csv"');
3284 3284
     
3285
-    // Create output stream
3286
-    $output = fopen('php://output', 'w');
3285
+        // Create output stream
3286
+        $output = fopen('php://output', 'w');
3287 3287
     
3288
-    // Write CSV headers
3289
-    fputcsv($output, array(
3290
-        $lang->get('admin_export_metric'),
3291
-        $lang->get('admin_export_value'),
3292
-    ));
3288
+        // Write CSV headers
3289
+        fputcsv($output, array(
3290
+            $lang->get('admin_export_metric'),
3291
+            $lang->get('admin_export_value'),
3292
+        ));
3293 3293
     
3294
-    // Gather statistics
3295
-    $stats = array(
3296
-        $lang->get('active_users') => DB::queryFirstField('SELECT COUNT(*) FROM ' . prefixTable('users') . ' WHERE disabled = 0'),
3297
-        $lang->get('total_items') => DB::queryFirstField('SELECT COUNT(*) FROM ' . prefixTable('items') . ' WHERE inactif = 0'),
3298
-        $lang->get('total_folders') => DB::queryFirstField('SELECT COUNT(*) FROM ' . prefixTable('nested_tree')),
3299
-        $lang->get('logs_24h') => DB::queryFirstField('SELECT COUNT(*) FROM ' . prefixTable('log_items') . ' WHERE date > ' . (time() - 86400)),
3300
-    );
3294
+        // Gather statistics
3295
+        $stats = array(
3296
+            $lang->get('active_users') => DB::queryFirstField('SELECT COUNT(*) FROM ' . prefixTable('users') . ' WHERE disabled = 0'),
3297
+            $lang->get('total_items') => DB::queryFirstField('SELECT COUNT(*) FROM ' . prefixTable('items') . ' WHERE inactif = 0'),
3298
+            $lang->get('total_folders') => DB::queryFirstField('SELECT COUNT(*) FROM ' . prefixTable('nested_tree')),
3299
+            $lang->get('logs_24h') => DB::queryFirstField('SELECT COUNT(*) FROM ' . prefixTable('log_items') . ' WHERE date > ' . (time() - 86400)),
3300
+        );
3301 3301
     
3302
-    // Write statistics
3303
-    foreach ($stats as $metric => $value) {
3304
-        fputcsv($output, array($metric, $value));
3305
-    }
3302
+        // Write statistics
3303
+        foreach ($stats as $metric => $value) {
3304
+            fputcsv($output, array($metric, $value));
3305
+        }
3306 3306
     
3307
-    fclose($output);
3307
+        fclose($output);
3308 3308
     
3309
-    // Log the export
3310
-    logEvents(
3311
-        $SETTINGS,
3312
-        'admin_action',
3313
-        'export_statistics',
3314
-        (string) $session->get('user-id'),
3315
-        $session->get('user-login'),
3316
-        'Statistics exported'
3317
-    );
3309
+        // Log the export
3310
+        logEvents(
3311
+            $SETTINGS,
3312
+            'admin_action',
3313
+            'export_statistics',
3314
+            (string) $session->get('user-id'),
3315
+            $session->get('user-login'),
3316
+            'Statistics exported'
3317
+        );
3318 3318
     
3319
-    exit;
3320
-    break;
3319
+        exit;
3320
+        break;
3321 3321
     
3322 3322
 }
3323 3323
 
Please login to merge, or discard this patch.