summaryrefslogtreecommitdiffstats
path: root/admin/WebConsole/includes
diff options
context:
space:
mode:
authorramon <ramongomez@us.es>2017-10-16 16:13:59 +0000
committerramon <ramongomez@us.es>2017-10-16 16:13:59 +0000
commitd610135c9b6ee43d13bce5e5b6e4ce51c59a3648 (patch)
tree49dfaaf3a3b39f4741a559322060113587fd7e56 /admin/WebConsole/includes
parent4073d146fec96ca89608a8e54ca2a6e5a25332ae (diff)
#810: Convertir datos a bytes para ruta REST {{{/repository/images}}}; propiedades de repositorio convierte tamaños a valor legible.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5463 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'admin/WebConsole/includes')
-rw-r--r--admin/WebConsole/includes/comunes.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/admin/WebConsole/includes/comunes.php b/admin/WebConsole/includes/comunes.php
index 35e53697..b0dade06 100644
--- a/admin/WebConsole/includes/comunes.php
+++ b/admin/WebConsole/includes/comunes.php
@@ -380,3 +380,19 @@
}
return($selecHtml);
}
+
+ /*
+ * Devuelve el valor legible para un tamaño (en múltiplos de 1024).
+ * Nota: obtenido de la documentación de PHP (php.net).
+ * Parámetros:
+ * bytes - tamaño en bytes (entero)
+ * Devielve:
+ * cadena con número en formato de sistema internacional (2 decimales)
+ */
+ function humanSize($bytes) {
+ $si_prefix = array( 'B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB' );
+ $base = 1024;
+ $class = min((int)log($bytes , $base) , count($si_prefix) - 1);
+ return sprintf('%1.2f' , $bytes / pow($base,$class)) . ' ' . $si_prefix[$class];
+ }
+