You are here

function _ctools_uuid_generate_php in Chaos Tool Suite (ctools) 7

Generates a UUID v4 using PHP code.

Based on code from

See also

http://php.net/uniqid#65879 , but corrected.

1 string reference to '_ctools_uuid_generate_php'
ctools_uuid_generate in ./ctools.module
Wrapper function to create UUIDs via ctools, falls back on UUID module if it is enabled. This code is a copy of uuid.inc from the uuid module.

File

includes/uuid.inc, line 39
Enables ctools generated modules to use UUIDs without the UUID module enabled. Per the ctools.module, this file only gets included if UUID doesn't exist.

Code

function _ctools_uuid_generate_php() {

  // The field names refer to RFC 4122 section 4.1.2.
  return sprintf('%04x%04x-%04x-4%03x-%04x-%04x%04x%04x', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 4095), bindec(substr_replace(sprintf('%016b', mt_rand(0, 65535)), '10', 0, 2)), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
}