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.../inc/utilitie...
File: wpml-data-encryptor.class.php
<?php
[0] Fix | Delete
// phpcs:disable PHPCompatibility.Constants.NewConstants.openssl_raw_dataFound -- This and the following exceptions are made as function and version checks are also made
[1] Fix | Delete
// phpcs:disable PHPCompatibility.Constants.RemovedConstants.mcrypt_mode_ecbDeprecatedRemoved
[2] Fix | Delete
// phpcs:disable PHPCompatibility.Constants.RemovedConstants.mcrypt_randDeprecatedRemoved
[3] Fix | Delete
// phpcs:disable PHPCompatibility.Constants.RemovedConstants.mcrypt_rijndael_256DeprecatedRemoved
[4] Fix | Delete
// phpcs:disable PHPCompatibility.Extensions.RemovedExtensions.mcryptDeprecatedRemoved
[5] Fix | Delete
// phpcs:disable PHPCompatibility.FunctionUse.NewFunctionParameters.openssl_decrypt_ivFound
[6] Fix | Delete
// phpcs:disable PHPCompatibility.FunctionUse.NewFunctionParameters.openssl_encrypt_ivFound
[7] Fix | Delete
// phpcs:disable PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_create_ivDeprecatedRemoved
[8] Fix | Delete
// phpcs:disable PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_decryptDeprecatedRemoved
[9] Fix | Delete
// phpcs:disable PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_encryptDeprecatedRemoved
[10] Fix | Delete
// phpcs:disable PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_get_iv_sizeDeprecatedRemoved
[11] Fix | Delete
[12] Fix | Delete
class WPML_Data_Encryptor {
[13] Fix | Delete
[14] Fix | Delete
const SALT_CHARS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_ []{}<>~`+=,.;:/?|';
[15] Fix | Delete
const SALT_LENGTH = 64;
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* @var string $method
[19] Fix | Delete
*/
[20] Fix | Delete
private $method;
[21] Fix | Delete
/**
[22] Fix | Delete
* @var string $key
[23] Fix | Delete
*/
[24] Fix | Delete
private $key;
[25] Fix | Delete
/**
[26] Fix | Delete
* @var string $iv
[27] Fix | Delete
*/
[28] Fix | Delete
private $iv;
[29] Fix | Delete
[30] Fix | Delete
/**
[31] Fix | Delete
* @var string
[32] Fix | Delete
*/
[33] Fix | Delete
private $library = false;
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* WPML_Data_Encryptor constructor.
[37] Fix | Delete
*
[38] Fix | Delete
* @param string $key_salt
[39] Fix | Delete
* @param string $method
[40] Fix | Delete
*
[41] Fix | Delete
*/
[42] Fix | Delete
public function __construct( $key_salt = '', $method = 'AES-256-CTR' ) {
[43] Fix | Delete
[44] Fix | Delete
if ( ! $key_salt ) {
[45] Fix | Delete
$key_salt = $this->get_key_salt();
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
if ( function_exists( 'openssl_encrypt' ) && function_exists( 'openssl_decrypt' )
[49] Fix | Delete
&& version_compare( phpversion(), '5.3.2', '>' ) ) {
[50] Fix | Delete
[51] Fix | Delete
$methods = openssl_get_cipher_methods();
[52] Fix | Delete
if ( ! in_array( $method, $methods ) && ! empty( $methods ) ) {
[53] Fix | Delete
$this->method = $methods[0];
[54] Fix | Delete
} else {
[55] Fix | Delete
$this->method = $method;
[56] Fix | Delete
}
[57] Fix | Delete
$this->library = 'openssl';
[58] Fix | Delete
$this->key = substr( sha1( $key_salt, true ), 0, 16 );
[59] Fix | Delete
$this->iv = substr( $key_salt, 0, 16 );
[60] Fix | Delete
[61] Fix | Delete
} else if ( function_exists( 'mcrypt_encrypt' ) && function_exists( 'mcrypt_decrypt' ) ) { // PHP 5.2 support
[62] Fix | Delete
$this->library = 'mcrypt';
[63] Fix | Delete
$this->key = substr( NONCE_KEY, 0, 24 );
[64] Fix | Delete
$this->iv = mcrypt_create_iv( mcrypt_get_iv_size( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB ), MCRYPT_RAND );
[65] Fix | Delete
[66] Fix | Delete
}
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
/**
[70] Fix | Delete
* @param string $data
[71] Fix | Delete
*
[72] Fix | Delete
* @return string
[73] Fix | Delete
*/
[74] Fix | Delete
public function encrypt( $data ) {
[75] Fix | Delete
if ( $this->library === 'openssl' ) {
[76] Fix | Delete
$encrypted_data = openssl_encrypt( $data, $this->method, $this->key, OPENSSL_RAW_DATA, $this->iv );
[77] Fix | Delete
} elseif ( $this->library === 'mcrypt' ) { // PHP 5.2 support
[78] Fix | Delete
$encrypted_data = mcrypt_encrypt( MCRYPT_RIJNDAEL_256, $this->key, $data, MCRYPT_MODE_ECB, $this->iv );
[79] Fix | Delete
$encrypted_data = preg_replace( '/\x00/', '', $encrypted_data ); // strip padding added to match the block size
[80] Fix | Delete
} else {
[81] Fix | Delete
$encrypted_data = $data;
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
return $encrypted_data;
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
/**
[88] Fix | Delete
* @param string $encrypted_data
[89] Fix | Delete
*
[90] Fix | Delete
* @return string
[91] Fix | Delete
*/
[92] Fix | Delete
public function decrypt( $encrypted_data ) {
[93] Fix | Delete
[94] Fix | Delete
if ( $this->library === 'openssl' ) {
[95] Fix | Delete
$data = openssl_decrypt( $encrypted_data, $this->method, $this->key, OPENSSL_RAW_DATA, $this->iv );
[96] Fix | Delete
} elseif ( $this->library === 'mcrypt' ) { // PHP 5.2 support
[97] Fix | Delete
$data = mcrypt_decrypt( MCRYPT_RIJNDAEL_256, $this->key, $encrypted_data, MCRYPT_MODE_ECB, $this->iv );
[98] Fix | Delete
$data = preg_replace( '/\x00/', '', $data );
[99] Fix | Delete
} else {
[100] Fix | Delete
$data = $encrypted_data;
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
return $data;
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
/**
[107] Fix | Delete
* @param string $library
[108] Fix | Delete
*/
[109] Fix | Delete
public function set_crypt_library( $library ){
[110] Fix | Delete
$this->library = $library;
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
/**
[114] Fix | Delete
* @return string
[115] Fix | Delete
*/
[116] Fix | Delete
public function get_crypt_library(){
[117] Fix | Delete
return $this->library;
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
/**
[121] Fix | Delete
* @return string
[122] Fix | Delete
*/
[123] Fix | Delete
private function get_key_salt() {
[124] Fix | Delete
if ( defined( 'NONCE_SALT' ) ){
[125] Fix | Delete
return NONCE_SALT;
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
return $this->generate_salt_key();
[129] Fix | Delete
}
[130] Fix | Delete
[131] Fix | Delete
/**
[132] Fix | Delete
* @return string
[133] Fix | Delete
*/
[134] Fix | Delete
private function generate_salt_key() {
[135] Fix | Delete
$salt_key = '';
[136] Fix | Delete
for ( $i = 0; $i < self::SALT_LENGTH; $i++ ) {
[137] Fix | Delete
$salt_key .= substr( self::SALT_CHARS, mt_rand( 0, strlen( self::SALT_CHARS ) - 1 ), 1 );
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
return $salt_key;
[141] Fix | Delete
}
[142] Fix | Delete
}
[143] Fix | Delete
// phpcs:enable PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_get_iv_sizeDeprecatedRemoved
[144] Fix | Delete
// phpcs:enable PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_encryptDeprecatedRemoved
[145] Fix | Delete
// phpcs:enable PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_decryptDeprecatedRemoved
[146] Fix | Delete
// phpcs:enable PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_create_ivDeprecatedRemoved
[147] Fix | Delete
// phpcs:enable PHPCompatibility.FunctionUse.NewFunctionParameters.openssl_encrypt_ivFound
[148] Fix | Delete
// phpcs:enable PHPCompatibility.FunctionUse.NewFunctionParameters.openssl_decrypt_ivFound
[149] Fix | Delete
// phpcs:enable PHPCompatibility.Extensions.RemovedExtensions.mcryptDeprecatedRemoved
[150] Fix | Delete
// phpcs:enable PHPCompatibility.Constants.RemovedConstants.mcrypt_rijndael_256DeprecatedRemoved
[151] Fix | Delete
// phpcs:enable PHPCompatibility.Constants.RemovedConstants.mcrypt_randDeprecatedRemoved
[152] Fix | Delete
// phpcs:enable PHPCompatibility.Constants.RemovedConstants.mcrypt_mode_ecbDeprecatedRemoved
[153] Fix | Delete
// phpcs:enable PHPCompatibility.Constants.NewConstants.openssl_raw_dataFound
[154] Fix | Delete
[155] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function