|
|
@ -1,10 +1,14 @@
|
|
|
|
<?php /* -*- php -*- */
|
|
|
|
<?php /* -*- php -*- */
|
|
|
|
|
|
|
|
|
|
|
|
function fulcrm_uuid_stir_mt_srand() {
|
|
|
|
function fulcrm_uuid_stir_mt_srand() {
|
|
|
|
|
|
|
|
if ( function_exists( 'drupal_random_bytes' ) )
|
|
|
|
|
|
|
|
mt_srand( crc32( drupal_random_bytes( 4 ) ) );
|
|
|
|
|
|
|
|
else if ( function_exists( 'microtime' ) )
|
|
|
|
|
|
|
|
mt_srand( crc32( microtime() ) );
|
|
|
|
|
|
|
|
else {
|
|
|
|
$e1 = variable_get( 'fulcrm_uuid_entropy_1', '' );
|
|
|
|
$e1 = variable_get( 'fulcrm_uuid_entropy_1', '' );
|
|
|
|
mt_srand( crc32( $e1 ) );
|
|
|
|
mt_srand( crc32( $e1 ) );
|
|
|
|
if ( function_exists( 'microtime' ) )
|
|
|
|
}
|
|
|
|
mt_srand( crc32( microtime() ) );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function fulcrm_uuid_stir_entropy() {
|
|
|
|
function fulcrm_uuid_stir_entropy() {
|
|
|
@ -12,6 +16,9 @@ function fulcrm_uuid_stir_entropy() {
|
|
|
|
|
|
|
|
|
|
|
|
$entropy = '';
|
|
|
|
$entropy = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( function_exists( 'drupal_random_bytes' ) ) {
|
|
|
|
|
|
|
|
$entropy .= drupal_random_bytes( 32 );
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$entropy .= mt_rand();
|
|
|
|
$entropy .= mt_rand();
|
|
|
|
$entropy .= rand();
|
|
|
|
$entropy .= rand();
|
|
|
|
|
|
|
|
|
|
|
@ -30,6 +37,7 @@ function fulcrm_uuid_stir_entropy() {
|
|
|
|
$handle = fopen( '/dev/urandom', 'r' );
|
|
|
|
$handle = fopen( '/dev/urandom', 'r' );
|
|
|
|
$entropy .= fread( $handle, 32 );
|
|
|
|
$entropy .= fread( $handle, 32 );
|
|
|
|
fclose( $handle );
|
|
|
|
fclose( $handle );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$old_entropy = ( variable_get( 'fulcrm_uuid_entropy_1', '' ) .
|
|
|
|
$old_entropy = ( variable_get( 'fulcrm_uuid_entropy_1', '' ) .
|
|
|
|
variable_get( 'fulcrm_uuid_entropy_2', '' ) );
|
|
|
|
variable_get( 'fulcrm_uuid_entropy_2', '' ) );
|
|
|
@ -44,11 +52,20 @@ function fulcrm_uuid_cron() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function fulcrm_uuid_uuid4() {
|
|
|
|
function fulcrm_uuid_uuid4() {
|
|
|
|
|
|
|
|
static $data = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( function_exists( 'drupal_random_bytes' ) )
|
|
|
|
|
|
|
|
$data = $data . drupal_random_bytes( 4 );
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
$data = $data . uniqid( $more_entropy = true );
|
|
|
|
|
|
|
|
|
|
|
|
$data = ( variable_get( 'fulcrm_uuid_entropy_2', '' ) .
|
|
|
|
$data = ( variable_get( 'fulcrm_uuid_entropy_2', '' ) .
|
|
|
|
uniqid( $more_entropy = true ) .
|
|
|
|
$data .
|
|
|
|
variable_get( 'fulcrm_uuid_entropy_2', '' ) );
|
|
|
|
variable_get( 'fulcrm_uuid_entropy_2', '' ) );
|
|
|
|
$data = hex2bin( md5( $data ) );
|
|
|
|
|
|
|
|
$data[ 6 ] = chr( ord( $data[ 6 ] ) & 0x0f | 0x40 );
|
|
|
|
$data = md5( $data );
|
|
|
|
$data[ 8 ] = chr( ord( $data[ 8 ] ) & 0x3f | 0x80 );
|
|
|
|
$rdata = hex2bin( $data );
|
|
|
|
return vsprintf( '%s%s-%s-%s-%s-%s%s%s', str_split( bin2hex( $data ), 4 ) );
|
|
|
|
$rdata[ 6 ] = chr( ord( $rdata[ 6 ] ) & 0x0f | 0x40 );
|
|
|
|
|
|
|
|
$rdata[ 8 ] = chr( ord( $rdata[ 8 ] ) & 0x3f | 0x80 );
|
|
|
|
|
|
|
|
return vsprintf( '%s%s-%s-%s-%s-%s%s%s', str_split( bin2hex( $rdata ), 4 ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|