Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/sitepres.../classes/utilitie...
File: wpml-uuid.php
<?php
[0] Fix | Delete
[1] Fix | Delete
class WPML_UUID {
[2] Fix | Delete
/**
[3] Fix | Delete
* @param string $object_id
[4] Fix | Delete
* @param string $object_type
[5] Fix | Delete
* @param int $timestamp
[6] Fix | Delete
*
[7] Fix | Delete
* @return string
[8] Fix | Delete
*/
[9] Fix | Delete
public function get( $object_id, $object_type, $timestamp = null ) {
[10] Fix | Delete
$timestamp = $timestamp ? $timestamp : time();
[11] Fix | Delete
$name = $object_id . ':' . $object_type . ':' . $timestamp;
[12] Fix | Delete
[13] Fix | Delete
return $this->get_uuid_v5( $name, wpml_get_site_id() );
[14] Fix | Delete
}
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* RFC 4122 compliant UUIDs.
[18] Fix | Delete
*
[19] Fix | Delete
* The RFC 4122 specification defines a Uniform Resource Name namespace for
[20] Fix | Delete
* UUIDs (Universally Unique Identifier), also known as GUIDs (Globally
[21] Fix | Delete
* Unique Identifier). A UUID is 128 bits long, and requires no central
[22] Fix | Delete
* registration process.
[23] Fix | Delete
*
[24] Fix | Delete
* @package UUID
[25] Fix | Delete
* @license https://www.gnu.org/licenses/gpl-2.0.txt GPLv2
[26] Fix | Delete
* @author bjornjohansen
[27] Fix | Delete
* @see https://bjornjohansen.no/uuid-as-wordpress-guid
[28] Fix | Delete
*
[29] Fix | Delete
* RFC 4122 compliant UUID version 5.
[30] Fix | Delete
*
[31] Fix | Delete
* @param string $name The name to generate the UUID from.
[32] Fix | Delete
* @param string $ns_uuid Namespace UUID. Default is for the NS when name string is a URL.
[33] Fix | Delete
*
[34] Fix | Delete
* @return string The UUID string.
[35] Fix | Delete
*/
[36] Fix | Delete
public function get_uuid_v5( $name, $ns_uuid = '6ba7b811-9dad-11d1-80b4-00c04fd430c8' ) {
[37] Fix | Delete
// Compute the hash of the name space ID concatenated with the name.
[38] Fix | Delete
$hash = sha1( $ns_uuid . $name );
[39] Fix | Delete
[40] Fix | Delete
// Intialize the octets with the 16 first octets of the hash, and adjust specific bits later.
[41] Fix | Delete
$octets = str_split( substr( $hash, 0, 16 ), 1 );
[42] Fix | Delete
[43] Fix | Delete
/*
[44] Fix | Delete
* Set version to 0101 (UUID version 5).
[45] Fix | Delete
*
[46] Fix | Delete
* Set the four most significant bits (bits 12 through 15) of the
[47] Fix | Delete
* time_hi_and_version field to the appropriate 4-bit version number
[48] Fix | Delete
* from Section 4.1.3.
[49] Fix | Delete
*
[50] Fix | Delete
* That is 0101 for version 5.
[51] Fix | Delete
* time_hi_and_version is octets 6–7
[52] Fix | Delete
*/
[53] Fix | Delete
$octets[6] = chr( ord( $octets[6] ) & 0x0f | 0x50 );
[54] Fix | Delete
[55] Fix | Delete
/*
[56] Fix | Delete
* Set the UUID variant to the one defined by RFC 4122, according to RFC 4122 section 4.1.1.
[57] Fix | Delete
*
[58] Fix | Delete
* Set the two most significant bits (bits 6 and 7) of the
[59] Fix | Delete
* clock_seq_hi_and_reserved to zero and one, respectively.
[60] Fix | Delete
*
[61] Fix | Delete
* clock_seq_hi_and_reserved is octet 8
[62] Fix | Delete
*/
[63] Fix | Delete
$octets[8] = chr( ord( $octets[8] ) & 0x3f | 0x80 );
[64] Fix | Delete
[65] Fix | Delete
// Hex encode the octets for string representation.
[66] Fix | Delete
$octets = array_map( 'bin2hex', $octets );
[67] Fix | Delete
[68] Fix | Delete
// Return the octets in the format specified by the ABNF in RFC 4122 section 3.
[69] Fix | Delete
return vsprintf( '%s%s-%s-%s-%s-%s%s%s', str_split( implode( '', $octets ), 4 ) );
[70] Fix | Delete
}
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function