aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ogs/common/util.inc.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ogs/common/util.inc.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/ogs/common/util.inc.php b/ogs/common/util.inc.php
new file mode 100644
index 0000000..b931205
--- /dev/null
+++ b/ogs/common/util.inc.php
@@ -0,0 +1,42 @@
1<?
2// Some generic utilities which may be used by any services
3
4function inc_lluuid($lluuid)
5{
6 $partB = substr($lluuid, 15);
7 $partB = (float)base_convert($partB,16,10)+1;
8 $partB = sprintf('%016x', $partB);
9 $partA = substr($lluuid, 0, 16);
10
11 if(substr($lluuid,15,16)=='FFFFFFFFFFFFFFFE') {
12 $partA = (float)base_convert($partA,16,10)+1;
13 $partA = sprintf('%016x', $partA);
14 }
15
16 $returnval = sprintf('%s%s',$partA, $partB);
17
18 return $returnval;
19}
20
21function format_lluuid($uuid)
22{
23 return strtolower(substr($uuid,0,8)."-".substr($uuid,8,4)."-".substr($uuid,12,4)."-".substr($uuid,16,4)."-".substr($uuid,20));
24}
25
26function output_xml_block($blockname, $data) {
27 echo("<$blockname>\n");
28 foreach($data as $name => $value) {
29 echo(" <$name>$value</$name>\n");
30 }
31 echo("</$blockname>\n");
32}
33
34function rand_uuid()
35{
36 return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
37 mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
38 mt_rand( 0, 0x0fff ) | 0x4000,
39 mt_rand( 0, 0x3fff ) | 0x8000,
40 mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) );
41}
42?>