123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <?php
- if (!defined('STATUSNET')) {
-
-
- exit(1);
- }
- class UUID
- {
- const REGEX = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}';
- protected $str = null;
-
- function __construct()
- {
- $this->str = self::gen();
- }
-
- function __toString()
- {
- return $this->str;
- }
-
- function getString()
- {
- return $this->str;
- }
-
- static function gen()
- {
- return sprintf('%s-%s-%04x-%04x-%s',
-
- common_random_hexstr(4),
-
- common_random_hexstr(2),
-
-
- (hexdec(common_random_hexstr(2)) & 0x0fff) | 0x4000,
-
-
-
-
- (hexdec(common_random_hexstr(2)) & 0x3fff) | 0x8000,
-
- common_random_hexstr(6));
- }
- }
|