Subversion Repositories oidinfo_api

Rev

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

Rev 12 Rev 13
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-02-28
6
 * Version 2020-09-12
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 363... Line 363...
363
                return trim(uuid_create(UUID_TYPE_TIME));
363
                return trim(uuid_create(UUID_TYPE_TIME));
364
        }
364
        }
365
 
365
 
366
        # On Debian: aptitude install uuid-runtime
366
        # On Debian: aptitude install uuid-runtime
367
        $out = array();
367
        $out = array();
-
 
368
        $ec = -1;
368
        exec('uuidgen -t', $out, $ec);
369
        exec('uuidgen -t', $out, $ec);
369
        if ($ec == 0) return $out[0];
370
        if ($ec == 0) return $out[0];
370
 
371
 
371
        # TODO: Implement the time based generation routine ourselves!
372
        # TODO: Implement the time based generation routine ourselves!
372
        # At the moment we cannot determine the time based UUID
373
        # At the moment we cannot determine the time based UUID
Line 425... Line 426...
425
                return trim(uuid_create(UUID_TYPE_RANDOM));
426
                return trim(uuid_create(UUID_TYPE_RANDOM));
426
        }
427
        }
427
 
428
 
428
        # On Debian: aptitude install uuid-runtime
429
        # On Debian: aptitude install uuid-runtime
429
        $out = array();
430
        $out = array();
-
 
431
        $ec = -1;
430
        exec('uuidgen -r', $out, $ec);
432
        exec('uuidgen -r', $out, $ec);
431
        if ($ec == 0) return $out[0];
433
        if ($ec == 0) return $out[0];
432
 
434
 
433
        # On Debian Jessie: UUID V4 (Random)
435
        # On Debian Jessie: UUID V4 (Random)
434
        if (file_exists('/proc/sys/kernel/random/uuid')) {
436
        if (file_exists('/proc/sys/kernel/random/uuid')) {