note 107512 added to function.uniqid
| From: | redtraider at gmail dot com | Date: | Tue, 14 Feb 2012 12:37:59 +0000 |
| Subject: | note 107512 added to function.uniqid | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186124@lists.php.net to get a copy of this message | ||
I use this function to generate microsoft-compatible GUID's.
<?php
public function create_guid($namespace = '') {
static $guid = '';
$uid = uniqid("", true);
$data = $namespace;
$data .= $_SERVER['REQUEST_TIME'];
$data .= $_SERVER['HTTP_USER_AGENT'];
$data .= $_SERVER['LOCAL_ADDR'];
$data .= $_SERVER['LOCAL_PORT'];
$data .= $_SERVER['REMOTE_ADDR'];
$data .= $_SERVER['REMOTE_PORT'];
$hash = strtoupper(hash('ripemd128', $uid . $guid . md5($data)));
$guid = '{' .
substr($hash, 0, 8) .
'-' .
substr($hash, 8, 4) .
'-' .
substr($hash, 12, 4) .
'-' .
substr($hash, 16, 4) .
'-' .
substr($hash, 20, 12) .
'}';
return $guid;
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 91.146.45.119
----
Manual Page -- http://www.php.net/manual/en/function.uniqid.php
Edit -- https://master.php.net/note/edit/107512
Del: integrated -- https://master.php.net/note/delete/107512/integrated
Del: useless -- https://master.php.net/note/delete/107512/useless
Del: bad code -- https://master.php.net/note/delete/107512/bad+code
Del: spam -- https://master.php.net/note/delete/107512/spam
Del: non-english -- https://master.php.net/note/delete/107512/non-english
Del: in docs -- https://master.php.net/note/delete/107512/in+docs
Del: other reasons-- https://master.php.net/note/delete/107512
Reject -- https://master.php.net/note/reject/107512
Search -- https://master.php.net/manage/user-notes.php