aboutsummaryrefslogtreecommitdiffstats
path: root/managing-ui/lib/functions.common.inc.php
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2017-05-27 20:33:11 +0200
committersteckbrief <steckbrief@chefmail.de>2017-05-27 20:34:06 +0200
commitb7515c5d9c5fc3c622376818570c05a03c74fe17 (patch)
tree38ebba18eb38d16f94afd821430ced2bcf63a739 /managing-ui/lib/functions.common.inc.php
parent6bd2862f8f6b37f145097767ebbbedbc5e243443 (diff)
managing-ui: initial commit0.2
added possibility to manage uploaded files simple php ui to delete uploaded files
Diffstat (limited to 'managing-ui/lib/functions.common.inc.php')
-rw-r--r--managing-ui/lib/functions.common.inc.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/managing-ui/lib/functions.common.inc.php b/managing-ui/lib/functions.common.inc.php
new file mode 100644
index 0000000..eb18594
--- /dev/null
+++ b/managing-ui/lib/functions.common.inc.php
@@ -0,0 +1,29 @@
+<?php
+/*
+ * This file contains functions commonly used.
+ */
+
+/**
+ * Copied from http://rogerstringer.com/2013/11/15/generate-uuids-php/
+ */
+function generate_uuid() {
+ return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
+ mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
+ mt_rand( 0, 0xffff ),
+ mt_rand( 0, 0x0fff ) | 0x4000,
+ mt_rand( 0, 0x3fff ) | 0x8000,
+ mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
+ );
+}
+
+function format_size($size, $precision = 2) {
+ $sizes = ['bytes', 'Kb', 'Mb', 'Gb', 'Tb'];
+ $i = 0;
+ while (1023 < $size && $i < count($sizes) - 1) {
+ $size /= 1023;
+ ++$i;
+ }
+
+ return number_format($size, $precision).' '.$sizes[$i];
+}
+?> \ No newline at end of file