Welcome Guest, Not a member yet? Register   Sign In
Sending a Code to an Email Address in CodeIgniter
#10

Here is a simple helper version.

PHP Code:
<?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
 * ----------------------------------------------------------------------------
 */ 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
RE: Sending a Code to an Email Address in CodeIgniter - by InsiteFX - 04-23-2017, 03:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB