mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-09 07:00:01 +00:00
wp_salt() and more hash work.
git-svn-id: http://svn.automattic.com/wordpress/trunk@3811 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a50330dd45
commit
e38d68adac
@ -64,6 +64,7 @@ class WP_Object_Cache {
|
|||||||
var $cold_cache_hits = 0;
|
var $cold_cache_hits = 0;
|
||||||
var $warm_cache_hits = 0;
|
var $warm_cache_hits = 0;
|
||||||
var $cache_misses = 0;
|
var $cache_misses = 0;
|
||||||
|
var $secret = '';
|
||||||
|
|
||||||
function acquire_lock() {
|
function acquire_lock() {
|
||||||
// Acquire a write lock.
|
// Acquire a write lock.
|
||||||
@ -174,14 +175,10 @@ class WP_Object_Cache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hash($data) {
|
function hash($data) {
|
||||||
global $wp_server_secret;
|
|
||||||
if ( empty($wp_server_secret) )
|
|
||||||
$wp_server_secret = DB_PASSWORD;
|
|
||||||
|
|
||||||
if ( function_exists('hash_hmac') ) {
|
if ( function_exists('hash_hmac') ) {
|
||||||
return hash_hmac('md5', $data, $wp_server_secret);
|
return hash_hmac('md5', $data, $this->secret);
|
||||||
} else {
|
} else {
|
||||||
return md5($data . $wp_server_secret);
|
return md5($data . $this->secret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -397,7 +394,7 @@ class WP_Object_Cache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function WP_Object_Cache() {
|
function WP_Object_Cache() {
|
||||||
global $blog_id;
|
global $blog_id, $wpdb;
|
||||||
|
|
||||||
if (defined('DISABLE_CACHE'))
|
if (defined('DISABLE_CACHE'))
|
||||||
return;
|
return;
|
||||||
@ -426,6 +423,11 @@ class WP_Object_Cache {
|
|||||||
if (defined('CACHE_EXPIRATION_TIME'))
|
if (defined('CACHE_EXPIRATION_TIME'))
|
||||||
$this->expiration_time = CACHE_EXPIRATION_TIME;
|
$this->expiration_time = CACHE_EXPIRATION_TIME;
|
||||||
|
|
||||||
|
if ( defined('WP_SECRET') )
|
||||||
|
$this->secret = WP_SECRET;
|
||||||
|
else
|
||||||
|
$this->secret = DB_PASSWORD . DB_USER . DB_NAME . DB_HOST . ABSPATH;
|
||||||
|
|
||||||
$this->blog_id = $this->hash($blog_id);
|
$this->blog_id = $this->hash($blog_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -508,16 +508,24 @@ function wp_create_nonce($action = -1) {
|
|||||||
}
|
}
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
if ( !function_exists('wp_salt') ) :
|
||||||
|
function wp_salt() {
|
||||||
|
$salt = get_option('secret');
|
||||||
|
if ( empty($salt) )
|
||||||
|
$salt = DB_PASSWORD . DB_USER . DB_NAME . DB_HOST . ABSPATH;
|
||||||
|
|
||||||
|
return $salt;
|
||||||
|
}
|
||||||
|
endif;
|
||||||
|
|
||||||
if ( !function_exists('wp_hash') ) :
|
if ( !function_exists('wp_hash') ) :
|
||||||
function wp_hash($data) {
|
function wp_hash($data) {
|
||||||
$secret = get_option('secret');
|
$salt = wp_salt();
|
||||||
if ( empty($secret) )
|
|
||||||
$secret = DB_PASSWORD;
|
|
||||||
|
|
||||||
if ( function_exists('hash_hmac') ) {
|
if ( function_exists('hash_hmac') ) {
|
||||||
return hash_hmac('md5', $data, $secret);
|
return hash_hmac('md5', $data, $salt);
|
||||||
} else {
|
} else {
|
||||||
return md5($data . $secret);
|
return md5($data . $salt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endif;
|
endif;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user