commitment, nothing

This commit is contained in:
jerry
2021-02-21 22:17:34 +08:00
parent f6c2131ebf
commit c50ae245bd
6 changed files with 45 additions and 18 deletions

View File

@@ -317,4 +317,16 @@ function getAllFdByConnectType(string $type = 'default'): array {
function zm_atomic($name) {
return \ZM\Store\ZMAtomic::get($name);
}
function uuidgen($uppercase = false) {
try {
$data = random_bytes(16);
} catch (Exception $e) {
return "";
}
$data[6] = chr(ord($data[6]) & 0x0f | 0x40);
$data[8] = chr(ord($data[8]) & 0x3f | 0x80);
return $uppercase ? strtoupper(vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4))) :
vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
}