<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* ----------------------------------------------------------------------------
* Editor : PhpStorm 2017.1.2
* Date : 4/23/2017
* Time : 6:11 AM
* Authors : Raymond L King Sr.
* ----------------------------------------------------------------------------
*
* Class uuid_helper
*
* @project ci3
* @author Raymond L King Sr.
* @link http://www.procoversfx.com
* @copyright Copyright (c) 2009 - 2017 Pro Covers FX, LLC.
* @license http://www.procoversfx.com/license
* ----------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------------
/**
* guid_v4 ()
* --------------------------------------------------------------------
*/
if ( ! function_exists('guid_v4'))
{
/**
* guid_v4 ()
* ---------------------------------------------------------------------------
*
* USAGE: $code = guid_v4();
*
* @return string
*/
function guid_v4()
{
if (function_exists('com_create_guid') === true)
{
return trim(com_create_guid(), '{}');
}
$data = openssl_random_pseudo_bytes(16);
// set version to 0100
$data[6] = chr(ord($data[6]) & 0x0f | 0x40);
// set bits 6-7 to 10
$data[8] = chr(ord($data[8]) & 0x3f | 0x80);
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
}
}
/**
* ----------------------------------------------------------------------------
* Filename: uuid_helper.php
* Location: ./application/helpers/uuid_helper.php
* ----------------------------------------------------------------------------
*/