mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01: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 $warm_cache_hits = 0;
|
||||
var $cache_misses = 0;
|
||||
var $secret = '';
|
||||
|
||||
function acquire_lock() {
|
||||
// Acquire a write lock.
|
||||
@ -174,14 +175,10 @@ class WP_Object_Cache {
|
||||
}
|
||||
|
||||
function hash($data) {
|
||||
global $wp_server_secret;
|
||||
if ( empty($wp_server_secret) )
|
||||
$wp_server_secret = DB_PASSWORD;
|
||||
|
||||
if ( function_exists('hash_hmac') ) {
|
||||
return hash_hmac('md5', $data, $wp_server_secret);
|
||||
return hash_hmac('md5', $data, $this->secret);
|
||||
} else {
|
||||
return md5($data . $wp_server_secret);
|
||||
return md5($data . $this->secret);
|
||||
}
|
||||
}
|
||||
|
||||
@ -397,7 +394,7 @@ class WP_Object_Cache {
|
||||
}
|
||||
|
||||
function WP_Object_Cache() {
|
||||
global $blog_id;
|
||||
global $blog_id, $wpdb;
|
||||
|
||||
if (defined('DISABLE_CACHE'))
|
||||
return;
|
||||
@ -426,6 +423,11 @@ class WP_Object_Cache {
|
||||
if (defined('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);
|
||||
}
|
||||
}
|
||||
|
@ -508,16 +508,24 @@ function wp_create_nonce($action = -1) {
|
||||
}
|
||||
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') ) :
|
||||
function wp_hash($data) {
|
||||
$secret = get_option('secret');
|
||||
if ( empty($secret) )
|
||||
$secret = DB_PASSWORD;
|
||||
$salt = wp_salt();
|
||||
|
||||
if ( function_exists('hash_hmac') ) {
|
||||
return hash_hmac('md5', $data, $secret);
|
||||
return hash_hmac('md5', $data, $salt);
|
||||
} else {
|
||||
return md5($data . $secret);
|
||||
return md5($data . $salt);
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
Loading…
Reference in New Issue
Block a user