本文整理汇总了PHP中uuid_create函数的典型用法代码示例。如果您正苦于以下问题:PHP uuid_create函数的具体用法?PHP uuid_create怎么用?PHP uuid_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uuid_create函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: UUID
/**
* Universally Unique Identifier v4
*
* @param int $b
* @return UUID, if $b returns binary(16)
*/
public function UUID($b = null)
{
if ($this->debug) {
$this->debug->log(__METHOD__);
}
if (function_exists('uuid_create')) {
$uuid = uuid_create();
} else {
$uuid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xfff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
}
return $b ? pack('H*', str_replace('-', '', $uuid)) : $uuid;
}
开发者ID:nbari,项目名称:DALMP,代码行数:18,代码来源:Database.php
示例2: generate
/**
* {@inheritdoc}
*/
public function generate(EntityManager $em, $entity)
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
return substr(com_create_guid(), 1, 36);
}
return uuid_create(UUID_TYPE_RANDOM);
}
开发者ID:creof,项目名称:doctrine2-php-uuid-generator,代码行数:10,代码来源:PhpUuidGenerator.php
示例3: companies_viewcontent_alm_customers_BeforeInsert
function companies_viewcontent_alm_customers_BeforeInsert(&$sender)
{
$companies_viewcontent_alm_customers_BeforeInsert = true;
$Component =& $sender;
$Container =& CCGetParentContainer($sender);
global $companies_viewcontent;
//Compatibility
//End companies_viewcontent_alm_customers_BeforeInsert
//Custom Code @26-2A29BDB7
// -------------------------
// Write your own code here.
$guid = uuid_create();
global $lastguid;
$lastguid = $guid;
$userid = CCGetUserID();
$businesspartner = CCGetFromPost("businesspartner", array());
$businesspartner_list = "";
foreach ($businesspartner as $partner) {
$businesspartner_list .= $partner . ",";
}
$companies_viewcontent->alm_customers->businesspartner->SetValue($businesspartner_list);
$companies_viewcontent->alm_customers->created_iduser->SetValue($userid);
$companies_viewcontent->alm_customers->hidguid->SetValue($guid);
$companies_viewcontent->alm_customers->assigned_to->SetValue($userid);
// -------------------------
//End Custom Code
//Close companies_viewcontent_alm_customers_BeforeInsert @2-560BEAB8
return $companies_viewcontent_alm_customers_BeforeInsert;
}
开发者ID:wangshipeng,项目名称:license_manager,代码行数:29,代码来源:companies_viewcontent_events.php
示例4: instance
private static function instance()
{
if (!is_resource(self::$_uuid)) {
uuid_create(&self::$_uuid);
}
return self::$_uuid;
}
开发者ID:jlaprise,项目名称:Pandra,代码行数:7,代码来源:UUID.class.php
示例5: generateUUID
/**
* Generates a universally unique identifier (UUID) according to RFC 4122.
* The algorithm used here, might not be completely random.
*
* If php-uuid was installed it will be used instead to speed up the process.
*
* @return string The universally unique id
* @todo Optionally generate type 1 and type 5 UUIDs.
*/
public static function generateUUID()
{
if (is_callable('uuid_create')) {
return strtolower(uuid_create(UUID_TYPE_RANDOM));
}
return (string) Uuid::uuid4();
}
开发者ID:cerlestes,项目名称:flow-development-collection,代码行数:16,代码来源:Algorithms.php
示例6: loadEmpty
/**
* Initialize an empty calendar.
* @param array $defaults
* @return \QuipXml\Xml\QuipXmlElement
*/
public static function loadEmpty($defaults = NULL)
{
$uid = function_exists('uuid_create') ? uuid_create() : uniqid('quip-cal-');
$defaults = array_merge(array('uid' => $uid, 'name' => 'New Calendar', 'timezone' => 'Etc/UTC'), (array) $defaults);
$ical = implode("\n", array('BEGIN:VCALENDAR', 'VERSION:2.0', 'PRODID:QuipCalendar', 'CALSCALE:GREGORIAN', 'UID:' . $defaults['uid'], 'X-WR-CALNAME:' . $defaults['name'], 'X-WR-TIMEZONE:' . $defaults['timezone'], 'END:VCALENDAR'));
return QuipCalendar::loadIcal($ical);
}
开发者ID:wittiws,项目名称:quipxml,代码行数:12,代码来源:QuipCalendar.php
示例7: generateId
public function generateId()
{
if (extension_loaded('uuid')) {
return uuid_create();
}
// @codingStandardsIgnoreStart
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xfff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
// @codingStandardsIgnoreEnd
}
开发者ID:metro-q,项目名称:metro,代码行数:9,代码来源:UuidGenerator.php
示例8: generate
/**
* generate
*
* v4
*/
public static function generate()
{
if (!function_exists('uuid_create')) {
return false;
}
uuid_create(&$context);
uuid_make($context, UUID_MAKE_V4);
uuid_export($context, UUID_FMT_STR, &$uuid);
return trim($uuid);
}
开发者ID:highhair20,项目名称:glo,代码行数:15,代码来源:Uuid.php
示例9: getId
/**
* 生成UUID
* @param string $value 待解密字符串
* @return string
*/
public function getId()
{
if (function_exists('uuid_create') && !function_exists('uuid_make')) {
$id = uuid_create(UUID_TYPE_DEFAULT);
} elseif (function_exists('com_create_guid')) {
$id = strtolower(trim(com_create_guid(), '{}'));
} else {
$id = $this->createId();
}
return $id;
}
开发者ID:connwap135,项目名称:ectouch,代码行数:16,代码来源:Encrypter.php
示例10: generateUuid
public function generateUuid()
{
// what are we doing?
$log = usingLog()->startAction("generate a UUID");
// do we have the UUID extension?
$uuid = uuid_create();
// log it
$log->endAction("'{$uuid}'");
// all done
return $uuid;
}
开发者ID:datasift,项目名称:storyplayer,代码行数:11,代码来源:FromUuid.php
示例11: v5
/**
* Generates version 5 UUID: SHA-1 hash of URL
*/
public static function v5($i_url)
{
if (!function_exists('uuid_create')) {
return false;
}
if (!strlen($i_url)) {
$i_url = self::v1();
}
uuid_create(&$context);
uuid_create(&$namespace);
uuid_make($context, UUID_MAKE_V5, $namespace, $i_url);
uuid_export($context, UUID_FMT_STR, &$uuid);
return trim($uuid);
}
开发者ID:rolwi,项目名称:koala,代码行数:17,代码来源:UUIDWrapper.class.php
示例12: ensure
/**
* On long running deamons i've seen a lost resource. This checks the resource and creates it if needed.
*
*/
protected static function ensure()
{
if (is_resource(self::$uuidobject)) {
return true;
}
if (!iHRIS_Module_UUID_Map::hasUUID()) {
return false;
}
uuid_create(&self::$uuidobject);
if (!is_resource(self::$uuidobject)) {
return false;
}
return true;
}
开发者ID:apelon-ohie,项目名称:ihris-site,代码行数:18,代码来源:iHRIS_UUID_Map_ossp.php
示例13: generate
/**
* Generate a 36-character RFC 4122 UUID, without the urn:uuid: prefix.
*
* @see http://www.ietf.org/rfc/rfc4122.txt
* @see http://labs.omniti.com/alexandria/trunk/OmniTI/Util/UUID.php
*/
public function generate()
{
if (extension_loaded('uuid')) {
$this->_uuid = uuid_create();
} else {
list($time_mid, $time_low) = explode(' ', microtime());
$time_low = (int) $time_low;
$time_mid = (int) substr($time_mid, 2) & 0xffff;
$time_high = mt_rand(0, 0xfff) | 0x4000;
$clock = mt_rand(0, 0x3fff) | 0x8000;
$node_low = function_exists('zend_thread_id') ? zend_thread_id() : getmypid();
$node_high = isset($_SERVER['SERVER_ADDR']) ? ip2long($_SERVER['SERVER_ADDR']) : crc32(php_uname());
$node = bin2hex(pack('nN', $node_low, $node_high));
$this->_uuid = sprintf('%08x-%04x-%04x-%04x-%s', $time_low, $time_mid, $time_high, $clock, $node);
}
}
开发者ID:netcon-source,项目名称:apps,代码行数:22,代码来源:Uuid.php
示例14: contacts_subhobbies_maintcontent_alm_customers_contacts_su_BeforeInsert
function contacts_subhobbies_maintcontent_alm_customers_contacts_su_BeforeInsert(&$sender)
{
$contacts_subhobbies_maintcontent_alm_customers_contacts_su_BeforeInsert = true;
$Component =& $sender;
$Container =& CCGetParentContainer($sender);
global $contacts_subhobbies_maintcontent;
//Compatibility
//End contacts_subhobbies_maintcontent_alm_customers_contacts_su_BeforeInsert
//Custom Code @13-2A29BDB7
// -------------------------
// Write your own code here.
$guid = uuid_create();
$contacts_subhobbies_maintcontent->alm_customers_contacts_su->created_iduser->SetValue(CCGetUserID());
$contacts_subhobbies_maintcontent->alm_customers_contacts_su->hidguid->SetValue($guid);
// -------------------------
//End Custom Code
//Close contacts_subhobbies_maintcontent_alm_customers_contacts_su_BeforeInsert @2-71F6BE98
return $contacts_subhobbies_maintcontent_alm_customers_contacts_su_BeforeInsert;
}
开发者ID:wangshipeng,项目名称:license_manager,代码行数:19,代码来源:contacts_subhobbies_maintcontent_events.php
示例15: settings_maintcontent_options_BeforeInsert
function settings_maintcontent_options_BeforeInsert(&$sender)
{
$settings_maintcontent_options_BeforeInsert = true;
$Component =& $sender;
$Container =& CCGetParentContainer($sender);
global $settings_maintcontent;
//Compatibility
//End settings_maintcontent_options_BeforeInsert
//Custom Code @15-2A29BDB7
// -------------------------
// Write your own code here.
$guid = uuid_create();
$settings_maintcontent->options->hidguid->SetValue($guid);
$settings_maintcontent->options->created_iduser->SetValue(CCGetUserID());
// -------------------------
//End Custom Code
//Close settings_maintcontent_options_BeforeInsert @5-59596C86
return $settings_maintcontent_options_BeforeInsert;
}
开发者ID:wangshipeng,项目名称:license_manager,代码行数:19,代码来源:settings_maintcontent_events.php
示例16: v4
/**
* Generates version 4 UUID: random
*/
public static function v4()
{
//try and use the PECL UUID library
if (function_exists('uuid_create') and defined('UUID_TYPE_RANDOM')) {
return \uuid_create(UUID_TYPE_RANDOM);
}
//if not we have to do it ourselfex becuase the PECL implementaiton is worthless
$prBits = null;
$fp = @fopen('/dev/urandom', 'rb');
if ($fp !== false) {
$prBits .= @fread($fp, 16);
@fclose($fp);
} else {
// If /dev/urandom isn't available (eg: in non-unix systems), use mt_rand().
$prBits = "";
for ($cnt = 0; $cnt < 16; $cnt++) {
$prBits .= chr(mt_rand(0, 255));
}
}
$timeLow = bin2hex(substr($prBits, 0, 4));
$timeMid = bin2hex(substr($prBits, 4, 2));
$timeHiAndVersion = bin2hex(substr($prBits, 6, 2));
$clockSeqHiAndReserved = bin2hex(substr($prBits, 8, 2));
$node = bin2hex(substr($prBits, 10, 6));
/**
* Set the four most significant bits (bits 12 through 15) of the
* $timeHiAndVersion field to the 4-bit version number from
* Section 4.1.3.
* @see http://tools.ietf.org/html/rfc4122#section-4.1.3
*/
$timeHiAndVersion = hexdec($timeHiAndVersion);
$timeHiAndVersion = $timeHiAndVersion >> 4;
$timeHiAndVersion = $timeHiAndVersion | 0x4000;
/**
* Set the two most significant bits (bits 6 and 7) of the
* $clockSeqHiAndReserved to zero and one, respectively.
*/
$clockSeqHiAndReserved = hexdec($clockSeqHiAndReserved);
$clockSeqHiAndReserved = $clockSeqHiAndReserved >> 2;
$clockSeqHiAndReserved = $clockSeqHiAndReserved | 0x8000;
return sprintf('%08s-%04s-%04x-%04x-%012s', $timeLow, $timeMid, $timeHiAndVersion, $clockSeqHiAndReserved, $node);
}
开发者ID:jazzee,项目名称:foundation,代码行数:45,代码来源:UUID.php
示例17: resellers_maintcontent_alm_resellers_BeforeInsert
function resellers_maintcontent_alm_resellers_BeforeInsert(&$sender)
{
$resellers_maintcontent_alm_resellers_BeforeInsert = true;
$Component =& $sender;
$Container =& CCGetParentContainer($sender);
global $resellers_maintcontent;
//Compatibility
//End resellers_maintcontent_alm_resellers_BeforeInsert
//Custom Code @15-2A29BDB7
// -------------------------
// Write your own code here.
$guid = uuid_create();
global $lastguid;
$lastguid = $guid;
$resellers_maintcontent->alm_resellers->created_iduser->SetValue(CCGetUserID());
$resellers_maintcontent->alm_resellers->hidguid->SetValue($guid);
// -------------------------
//End Custom Code
//Close resellers_maintcontent_alm_resellers_BeforeInsert @2-F1DAC32C
return $resellers_maintcontent_alm_resellers_BeforeInsert;
}
开发者ID:wangshipeng,项目名称:license_manager,代码行数:21,代码来源:resellers_maintcontent_events.php
示例18: products_suite_maintcontent_alm_product_suites_BeforeInsert
function products_suite_maintcontent_alm_product_suites_BeforeInsert(&$sender)
{
$products_suite_maintcontent_alm_product_suites_BeforeInsert = true;
$Component =& $sender;
$Container =& CCGetParentContainer($sender);
global $products_suite_maintcontent;
//Compatibility
//End products_suite_maintcontent_alm_product_suites_BeforeInsert
//Custom Code @30-2A29BDB7
// -------------------------
// Write your own code here.
$guid = uuid_create();
global $lastguid;
$lastguid = $guid;
$products_suite_maintcontent->alm_product_suites->created_iduser->SetValue(CCGetUserID());
$products_suite_maintcontent->alm_product_suites->hidguid->SetValue($guid);
// -------------------------
//End Custom Code
//Close products_suite_maintcontent_alm_product_suites_BeforeInsert @2-29050226
return $products_suite_maintcontent_alm_product_suites_BeforeInsert;
}
开发者ID:wangshipeng,项目名称:license_manager,代码行数:21,代码来源:products_suite_maintcontent_events.php
示例19: generate
/**
* @brief Generate a UUID
*
* @param mixed $version The version to generate (default UUID_V4)
* @param mixed $url The URL to use for V3 and V5 UUIDs.
* @return string The UUID
*/
public function generate($version = self::UUID_V4, $url = null)
{
// Implementation for pecl uuid
$hu = null;
switch ($version) {
case self::UUID_V1:
$uuid = \uuid_create(\UUID_TYPE_DCE);
break;
case self::UUID_V3:
return null;
break;
case self::UUID_V4:
$uuid = \uuid_create(\UUID_TYPE_RANDOM);
break;
case self::UUID_V5:
return null;
break;
default:
return null;
}
return trim($uuid);
}
开发者ID:noccy80,项目名称:cherryphp,代码行数:29,代码来源:pecluuidimpl.php
示例20: generate
/**
* @brief Generate a UUID
*
* @param mixed $version The version to generate (default UUID_V4)
* @param mixed $url The URL to use for V3 and V5 UUIDs.
* @return string The UUID
*/
public function generate($version = self::UUID_V4, $url = null)
{
// Implementation for ossp-uuid
$hu = null;
$ustr = null;
switch ($version) {
case self::UUID_V1:
\uuid_create($hu);
\uuid_make($hu, \UUID_MAKE_V1 | \UUID_MAKE_MC);
break;
case self::UUID_V3:
\uuid_create($hu);
if (!$url) {
return null;
}
$ns = null;
\uuid_create($ns);
\uuid_make($hu, \UUID_MAKE_V3, $ns, $url);
\uuid_destroy($ns);
break;
case self::UUID_V4:
\uuid_create($hu);
\uuid_make($hu, \UUID_MAKE_V4);
break;
case self::UUID_V5:
\uuid_create($hu);
\uuid_create($ns);
\uuid_make($hu, \UUID_MAKE_V5, $ns, $url);
\uuid_destroy($ns);
break;
default:
return null;
}
\uuid_export($hu, UUID_FMT_STR, $ustr);
$uuid = $ustr;
return trim($uuid);
}
开发者ID:noccy80,项目名称:cherryphp,代码行数:44,代码来源:osspuuidimpl.php
注:本文中的uuid_create函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论