opensim-www – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 eva 1 <?php
2 class UUID {
3 /**
4 * Generates version 1: MAC address
5 */
6 public static function v1() {
7 if (!function_exists('uuid_create'))
8 return false;
9  
10 uuid_create($context);
11 uuid_make($context, UUID_MAKE_V1);
12 uuid_export($context, UUID_FMT_STR, $uuid);
13 return trim($uuid);
14 }
15  
16 /**
17 * Generates version 3 UUID: MD5 hash of URL
18 */
19 public static function v3($i_url) {
20 if (!function_exists('uuid_create'))
21 return false;
22  
23 if (!strlen($i_url))
24 $i_url = self::v1();
25  
26 uuid_create($context);
27 uuid_create($namespace);
28  
29 uuid_make($context, UUID_MAKE_V3, $namespace, $i_url);
30 uuid_export($context, UUID_FMT_STR, $uuid);
31 return trim($uuid);
32 }
33  
34 /**
35 * Generates version 4 UUID: random
36 */
37 public static function v4() {
38 if (!function_exists('uuid_create'))
39 return false;
40  
41 uuid_create($context);
42  
43 uuid_make($context, UUID_MAKE_V4);
44 uuid_export($context, UUID_FMT_STR, $uuid);
45 return trim($uuid);
46 }
47  
48 /**
49 * Generates version 5 UUID: SHA-1 hash of URL
50 */
51 public static function v5($i_url) {
52 if (!function_exists('uuid_create'))
53 return false;
54  
55 if (!strlen($i_url))
56 $i_url = self::v1();
57  
58 uuid_create($context);
59 uuid_create($namespace);
60  
61 uuid_make($context, UUID_MAKE_V5, $namespace, $i_url);
62 uuid_export($context, UUID_FMT_STR, $uuid);
63 return trim($uuid);
64 }
65 }
66 ?>