Skip to content

Commit bfef7e7

Browse files
committed
[FIX] Mark nicesize() as deprecated, use niceSize() via ISO standard.
1 parent 61a51c0 commit bfef7e7

File tree

6 files changed

+42
-27
lines changed

6 files changed

+42
-27
lines changed

core/functions/actions/files.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ function ls($curpath, array $options = [])
160160
echo '<tr>';
161161
echo '<td>' . $dirs_array[$i]['text'] . '</td>';
162162
echo '<td class="text-nowrap">' . evolutionCMS()->toDateFormat($dirs_array[$i]['stats']['9']) . '</td>';
163-
echo '<td class="text-right">' . nicesize($dirs_array[$i]['stats']['7']) . '</td>';
163+
echo '<td class="text-right">' . niceSize($dirs_array[$i]['stats']['7']) . '</td>';
164164
echo '<td class="actions text-right">';
165165
echo $dirs_array[$i]['rename'];
166166
echo $dirs_array[$i]['delete'];
@@ -175,8 +175,8 @@ function ls($curpath, array $options = [])
175175
$filesizes += $files_array[$i]['stats']['7'];
176176
echo '<tr ' . markRow($files_array[$i]['file'], get_by_key($_REQUEST, 'path'), get_by_key($_REQUEST, 'mode')) . '>';
177177
echo '<td>' . $files_array[$i]['text'] . '</td>';
178-
echo '<td class="text-nowrap">' . evolutionCMS()->toDateFormat($files_array[$i]['stats']['9']) . '</td>';
179-
echo '<td class="text-right">' . nicesize($files_array[$i]['stats']['7']) . '</td>';
178+
echo '<td class="text-nowrap">' . evo()->toDateFormat($files_array[$i]['stats']['9']) . '</td>';
179+
echo '<td class="text-right">' . niceSize($files_array[$i]['stats']['7']) . '</td>';
180180
echo '<td class="actions text-right">';
181181
echo $files_array[$i]['unzip'];
182182
echo $files_array[$i]['view'];
@@ -425,7 +425,7 @@ function fileupload()
425425
if ($userfile['error'] == 0) {
426426
$img = (strpos($userfile['type'],
427427
'image') !== false) ? '<br /><img src="' . $path . '" height="75" />' : '';
428-
$msg .= "<p>" . $_lang['files_file_type'] . $userfile['type'] . ", " . nicesize(filesize($userfile['tmp_name'])) . $img . '</p>';
428+
$msg .= "<p>" . $_lang['files_file_type'] . $userfile['type'] . ", " . niceSize(filesize($userfile['tmp_name'])) . $img . '</p>';
429429
}
430430

431431
$userfilename = $userfile['tmp_name'];

core/functions/helper.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,23 +119,23 @@ function is_cli()
119119
}
120120
}
121121

122-
if (!function_exists('nicesize')) {
122+
if (!function_exists('niceSize')) {
123123
/**
124124
* Format file size in human-readable format.
125125
*
126126
* Converts bytes to appropriate unit (B, KB, MB, GB, TB) with proper rounding.
127127
* Uses modern ISO/IEC 80000 standard formatting with uppercase units.
128128
*
129-
* @param int $size File size in bytes
129+
* @param int|float $size File size in bytes
130130
* @return string Formatted file size with unit
131131
*
132132
* @example
133-
* nicesize(1024); // "1 KB"
134-
* nicesize(1048576); // "1 MB"
135-
* nicesize(1536); // "1.5 KB"
136-
* nicesize(0); // "0 B"
133+
* niceSize(1024); // "1 KB"
134+
* niceSize(1048576); // "1 MB"
135+
* niceSize(1536); // "1.5 KB"
136+
* niceSize(0); // "0 B"
137137
*/
138-
function nicesize($size)
138+
function niceSize($size)
139139
{
140140
$units = ['B', 'KB', 'MB', 'GB', 'TB'];
141141
$unitIndex = 0;
@@ -149,6 +149,17 @@ function nicesize($size)
149149
}
150150
}
151151

152+
if (!function_exists('nicesize')) {
153+
/**
154+
* @deprecated since EVO 3.2.7, use niceSize()
155+
* @TODO: will be delete EVO 3.5
156+
*/
157+
function nicesize($size)
158+
{
159+
return niceSize($size);
160+
}
161+
}
162+
152163
if (!function_exists('data_is_json')) {
153164
/**
154165
* @param $string

core/src/Core.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6266,7 +6266,8 @@ public function messageQuit($msg = 'unspecified error', $query = '', $is_error =
62666266
/**
62676267
* @param $backtrace
62686268
* @return string
6269-
* @deprecated
6269+
* @deprecated since EVO 3.2.7
6270+
* @TODO: will be delete EVO 3.5
62706271
*/
62716272
public function get_backtrace($backtrace)
62726273
{
@@ -6316,23 +6317,26 @@ public function stripAlias($alias)
63166317
/**
63176318
* @param $size
63186319
* @return string
6319-
* @deprecated
6320+
* @deprecated since EVO 3.2.7
6321+
* @TODO: will be delete EVO 3.5
63206322
*/
63216323
public function nicesize($size)
63226324
{
6323-
return nicesize($size);
6325+
return niceSize($size);
63246326
}
63256327

63266328
/**
6327-
* @deprecated use UrlProcessor::getHiddenIdFromAlias()
6329+
* @deprecated since EVO 3.2.7, use UrlProcessor::getHiddenIdFromAlias()
6330+
* @TODO: will be delete EVO 3.5
63286331
*/
63296332
public function getHiddenIdFromAlias($parentid, $alias)
63306333
{
63316334
return UrlProcessor::getHiddenIdFromAlias($parentid, $alias);
63326335
}
63336336

63346337
/**
6335-
* @deprecated use UrlProcessor::getIdFromAlias()
6338+
* @deprecated since EVO 3.2.7, use UrlProcessor::getIdFromAlias()
6339+
* @TODO: will be delete EVO 3.5
63366340
*/
63376341
public function getIdFromAlias($alias)
63386342
{

core/src/Legacy/Modifiers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,8 +1246,8 @@ public function getValueFromPreset($key, $value, $cmd, $opt)
12461246
return $arr[$idx];
12471247
case 'getimage':
12481248
return $this->includeMdfFile('getimage');
1249-
case 'nicesize':
1250-
return nicesize($value);
1249+
case 'niceSize':
1250+
return niceSize($value);
12511251
case 'googlemap':
12521252
case 'googlemaps':
12531253
if (empty($opt)) {

manager/actions/bkmanager.static.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -353,18 +353,18 @@ class="form-check-input"
353353
EvolutionCMS()->getDatabase()->getConfig('prefix') . 'manager_log',
354354
);
355355
if (EvolutionCMS()->hasPermission('settings') && in_array($db_status['Name'], $truncateable) && $db_status['Rows'] > 0) {
356-
echo '<td class="text-xs-right"><a class="text-danger" href="index.php?a=54&mode=93&u=' . $db_status['Name'] . '" title="' . $_lang['truncate_table'] . '">' . nicesize($db_status['Data_length'] + $db_status['Data_free']) . '</a>' . '</td>' . "\n";
356+
echo '<td class="text-xs-right"><a class="text-danger" href="index.php?a=54&mode=93&u=' . $db_status['Name'] . '" title="' . $_lang['truncate_table'] . '">' . niceSize($db_status['Data_length'] + $db_status['Data_free']) . '</a>' . '</td>' . "\n";
357357
} else {
358-
echo '<td class="text-xs-right">' . nicesize($db_status['Data_length'] + $db_status['Data_free']) . '</td>' . "\n";
358+
echo '<td class="text-xs-right">' . niceSize($db_status['Data_length'] + $db_status['Data_free']) . '</td>' . "\n";
359359
}
360360

361361
if (EvolutionCMS()->hasPermission('settings')) {
362-
echo '<td class="text-xs-right">' . ($db_status['Data_free'] > 0 ? '<a class="text-danger" href="index.php?a=54&mode=93&t=' . $db_status['Name'] . '" title="' . $_lang['optimize_table'] . '">' . nicesize($db_status['Data_free']) . '</a>' : '-') . '</td>' . "\n";
362+
echo '<td class="text-xs-right">' . ($db_status['Data_free'] > 0 ? '<a class="text-danger" href="index.php?a=54&mode=93&t=' . $db_status['Name'] . '" title="' . $_lang['optimize_table'] . '">' . niceSize($db_status['Data_free']) . '</a>' : '-') . '</td>' . "\n";
363363
} else {
364-
echo '<td class="text-xs-right">' . ($db_status['Data_free'] > 0 ? nicesize($db_status['Data_free']) : '-') . '</td>' . "\n";
364+
echo '<td class="text-xs-right">' . ($db_status['Data_free'] > 0 ? niceSize($db_status['Data_free']) : '-') . '</td>' . "\n";
365365
}
366366

367-
echo '<td class="text-xs-right">' . nicesize($db_status['Data_length'] - $db_status['Data_free']) . '</td>' . "\n" . '<td class="text-xs-right">' . EvolutionCMS()->nicesize($db_status['Index_length']) . '</td>' . "\n" . '<td class="text-xs-right">' . EvolutionCMS()->nicesize($db_status['Index_length'] + $db_status['Data_length'] + $db_status['Data_free']) . '</td>' . "\n" . "</tr>";
367+
echo '<td class="text-xs-right">' . niceSize($db_status['Data_length'] - $db_status['Data_free']) . '</td>' . "\n" . '<td class="text-xs-right">' . niceSize($db_status['Index_length']) . '</td>' . "\n" . '<td class="text-xs-right">' . EvolutionCMS()->nicesize($db_status['Index_length'] + $db_status['Data_length'] + $db_status['Data_free']) . '</td>' . "\n" . "</tr>";
368368

369369
$total += $db_status['Index_length'] + $db_status['Data_length'];
370370
$totaloverhead += $db_status['Data_free'];
@@ -375,9 +375,9 @@ class="form-check-input"
375375
<tr>
376376
<td class="text-xs-right"><?= $_lang['database_table_totals'] ?></td>
377377
<td colspan="4">&nbsp;</td>
378-
<td class="text-xs-right"><?= $totaloverhead > 0 ? '<b class="text-danger">' . nicesize($totaloverhead) . '</b><br />(' . number_format($totaloverhead) . ' B)' : '-' ?></td>
378+
<td class="text-xs-right"><?= $totaloverhead > 0 ? '<b class="text-danger">' . niceSize($totaloverhead) . '</b><br />(' . number_format($totaloverhead) . ' B)' : '-' ?></td>
379379
<td colspan="2">&nbsp;</td>
380-
<td class="text-xs-right"><?= "<b>" . nicesize($total) . "</b><br />(" . number_format($total) . " B)" ?></td>
380+
<td class="text-xs-right"><?= "<b>" . niceSize($total) . "</b><br />(" . number_format($total) . " B)" ?></td>
381381
</tr>
382382
</tfoot>
383383
</table>
@@ -539,7 +539,7 @@ class="<?= $_style['icon_save'] ?>"></i> <?= $_lang["bkmgr_snapshot_submit"] ?>
539539
arsort($files);
540540
while ($file = array_shift($files)) {
541541
$filename = substr($file, strrpos($file, '/') + 1);
542-
$filesize = nicesize(filesize($file));
542+
$filesize = niceSize(filesize($file));
543543

544544
$file = fopen($file, "r");
545545
$count = 0;

manager/actions/files.dynamic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ function renameFile(file) {
435435
<?php
436436
echo $_lang['files_directories'] . ': <b>' . $folders . '</b> ';
437437
echo $_lang['files_files'] . ': <b>' . $files . '</b> ';
438-
echo $_lang['files_data'] . ': <b><span dir="ltr">' . nicesize($filesizes) . '</span></b> ';
438+
echo $_lang['files_data'] . ': <b><span dir="ltr">' . niceSize($filesizes) . '</span></b> ';
439439
echo $_lang['files_dirwritable'] . ' <b>' . (is_writable($startpath) == 1 ? $_lang['yes'] . '.' : $_lang['no']) . '.</b>'
440440
?>
441441
</p>

0 commit comments

Comments
 (0)