Added Feature to Display Disk Space Usage

# Changes:
- Added disk space calculation logic to the `index.php` file.
- Updated the file listing footer to include total, used, and remaining disk space information.
- Utilized `disk_total_space`, `disk_free_space`, and `fm_get_filesize` functions to obtain and format disk space information.
- Ensured that the feature works seamlessly with existing functionalities and adheres to the project's coding standards.

 # Benefits:
- Users with multiple mounted drives on their servers can easily see how much disk space is available, used, and remaining on each drive, facilitating better disk space management.
- Enhances user experience by providing valuable disk space information, aiding in capacity planning and preventing potential issues related to disk space exhaustion.
- Helps in monitoring disk space usage directly from the file manager without needing to use external tools or commands.

 # Use Case:
- As someone managing a server with multiple mounted drives, this feature is invaluable for monitoring the disk space usage on each drive. It helps in ensuring that none of the drives are nearing capacity, which could lead to performance degradation or even system failures. Having this information readily available within Tiny File Manager streamlines the process of managing disk space and ensures that I can take timely action if needed, such as cleaning up old files or moving data to other drives with more available space.
This commit is contained in:
hppanpaliya 2023-10-17 21:49:07 -04:00
parent 8e87afae5b
commit 40ebbcbbb3
No known key found for this signature in database
GPG key ID: E76B4F90C2B10FAE

View file

@ -2202,10 +2202,25 @@ $tableTheme = (FM_THEME == "dark") ? "text-white bg-dark table-dark" : "bg-white
</tfoot>
<?php
} else { ?>
<?php
// Get total and free space
$total = disk_total_space(FM_ROOT_PATH.'/'.FM_PATH);
$free = disk_free_space(FM_ROOT_PATH.'/'.FM_PATH);
// Format sizes
$total_size = fm_get_filesize($total);
$free_size = fm_get_filesize($free);
$total_used_size = fm_get_filesize($total - $free);
?>
<tfoot>
<tr>
<td class="gray" colspan="<?php echo (!FM_IS_WIN && !$hide_Cols) ? (FM_READONLY ? '6' :'7') : (FM_READONLY ? '4' : '5') ?>">
<?php echo lng('FullSize').': <span class="badge text-bg-light border-radius-0">'.fm_get_filesize($all_files_size).'</span>' ?>
<?php echo lng('UsedSpace').': <span class="badge text-bg-light border-radius-0">' .$total_used_size.'</span>'; ?>
<?php echo lng('RemainingSpace').': <span class="badge text-bg-light border-radius-0">' .$free_size.'</span>'; ?>
<?php echo lng('File').': <span class="badge text-bg-light border-radius-0">'.$num_files.'</span>' ?>
<?php echo lng('Folder').': <span class="badge text-bg-light border-radius-0">'.$num_folders.'</span>' ?>
</td>
@ -4287,6 +4302,8 @@ function lng($txt) {
$tr['en']['Invalid characters in file or folder name'] = 'Invalid characters in file or folder name';
$tr['en']['Operations with archives are not available'] = 'Operations with archives are not available';
$tr['en']['File or folder with this path already exists'] = 'File or folder with this path already exists';
$tr['en']['RemainingSpace'] = 'Remaining Space';
$tr['en']['UsedSpace'] = 'Used Space';
$i18n = fm_get_translations($tr);
$tr = $i18n ? $i18n : $tr;