summaryrefslogtreecommitdiffstats
path: root/inc/util.inc.php
diff options
context:
space:
mode:
authorUdo Walter2017-09-01 15:27:06 +0200
committerUdo Walter2017-09-01 15:27:06 +0200
commit599c259845cd94a0bb64233b9935ea8c38be65b0 (patch)
treef6b2601d774aa5a0ca8785015d997545ef9952f7 /inc/util.inc.php
parent[js_stupidtable] changed one-line code to formatted code; (diff)
parent[locationinfo] Add backend for Microsoft Exchange Server (diff)
downloadslx-admin-599c259845cd94a0bb64233b9935ea8c38be65b0.tar.gz
slx-admin-599c259845cd94a0bb64233b9935ea8c38be65b0.tar.xz
slx-admin-599c259845cd94a0bb64233b9935ea8c38be65b0.zip
Merge remote-tracking branch 'origin/master' into permission-manager
Diffstat (limited to 'inc/util.inc.php')
-rw-r--r--inc/util.inc.php30
1 files changed, 29 insertions, 1 deletions
diff --git a/inc/util.inc.php b/inc/util.inc.php
index 5d1a4563..9bcfdf13 100644
--- a/inc/util.inc.php
+++ b/inc/util.inc.php
@@ -12,7 +12,7 @@ class Util
*/
public static function traceError($message)
{
- if ((defined('API') && API) || (defined('AJAX') && AJAX)) {
+ if ((defined('API') && API) || (defined('AJAX') && AJAX) || php_sapi_name() === 'cli') {
error_log('API ERROR: ' . $message);
error_log(self::formatBacktracePlain(debug_backtrace()));
}
@@ -434,4 +434,32 @@ SADFACE;
return $bytes;
}
+ /**
+ * @return string a random UUID, v4.
+ */
+ public static function randomUuid()
+ {
+ $b = unpack('h8a/h4b/h12c', self::randomBytes(12));
+ return sprintf('%08s-%04s-%04x-%04x-%012s',
+
+ // 32 bits for "time_low"
+ $b['a'],
+
+ // 16 bits for "time_mid"
+ $b['b'],
+
+ // 16 bits for "time_hi_and_version",
+ // four most significant bits holds version number 4
+ mt_rand(0, 0x0fff) | 0x4000,
+
+ // 16 bits, 8 bits for "clk_seq_hi_res",
+ // 8 bits for "clk_seq_low",
+ // two most significant bits holds zero and one for variant DCE1.1
+ mt_rand(0, 0x3fff) | 0x8000,
+
+ // 48 bits for "node"
+ $b['c']
+ );
+ }
+
}