Subversion Repositories oidplus

Rev

Rev 444 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 444 Rev 448
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
 * UUID utils for PHP
4
 * UUID utils for PHP
5
 * Copyright 2011-2020 Daniel Marschall, ViaThinkSoft
5
 * Copyright 2011 - 2020 Daniel Marschall, ViaThinkSoft
6
 * Version 2020-10-21
6
 * Version 2020-10-25
7
 *
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
10
 * You may obtain a copy of the License at
11
 *
11
 *
Line 339... Line 339...
339
        $x = gmp_init($uuid, 16);
339
        $x = gmp_init($uuid, 16);
340
        return '2.25.'.gmp_strval($x, 10); # TODO: parameter with or without leading dot
340
        return '2.25.'.gmp_strval($x, 10); # TODO: parameter with or without leading dot
341
}
341
}
342
 
342
 
343
function gen_uuid($prefer_timebased = true) {
343
function gen_uuid($prefer_timebased = true) {
344
        if ($prefer_timebased) $uuid = gen_uuid_timebased();
344
        $uuid = $prefer_timebased ? gen_uuid_timebased() : false;
345
        if ($uuid === false) $uuid = gen_uuid_random();
345
        if ($uuid === false) $uuid = gen_uuid_random();
346
        return $uuid;
346
        return $uuid;
347
}
347
}
348
 
348
 
349
// Version 1 (Time based) UUID
349
// Version 1 (Time based) UUID