mirror of
https://github.com/friendica/friendica
synced 2025-04-27 21:50:11 +00:00
moved get_guid to System::createGUID
This commit is contained in:
parent
3a179860e5
commit
c829e43725
21 changed files with 105 additions and 88 deletions
|
@ -175,9 +175,36 @@ EOT;
|
|||
killme();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a GUID with the given parameters
|
||||
*
|
||||
* @param int $size The size of the GUID (default is 16)
|
||||
* @param bool|string $prefix A given prefix (default is empty)
|
||||
* @return string a generated GUID
|
||||
*/
|
||||
public static function createGUID($size = 16, $prefix = '')
|
||||
{
|
||||
if (is_bool($prefix) && !$prefix) {
|
||||
$prefix = '';
|
||||
} elseif (!isset($prefix)) {
|
||||
$prefix = hash('crc32', self::getApp()->get_hostname());
|
||||
}
|
||||
|
||||
while (strlen($prefix) < ($size - 13)) {
|
||||
$prefix .= mt_rand();
|
||||
}
|
||||
|
||||
if ($size >= 24) {
|
||||
$prefix = substr($prefix, 0, $size - 22);
|
||||
return str_replace('.', '', uniqid($prefix, true));
|
||||
} else {
|
||||
$prefix = substr($prefix, 0, max($size - 13, 0));
|
||||
return uniqid($prefix);
|
||||
}
|
||||
}
|
||||
|
||||
/// @todo Move the following functions from boot.php
|
||||
/*
|
||||
function get_guid($size = 16, $prefix = "")
|
||||
function killme()
|
||||
function goaway($s)
|
||||
function local_user()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue