wp_hash() and server secret.

git-svn-id: https://develop.svn.wordpress.org/trunk@3810 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2006-05-31 00:24:03 +00:00
parent cc7d9c46f3
commit feb562c29f
4 changed files with 36 additions and 6 deletions

View File

@@ -142,7 +142,7 @@ class WP_Object_Cache {
return false;
}
$cache_file = $this->cache_dir.$this->get_group_dir($group)."/".md5($id.DB_PASSWORD).'.php';
$cache_file = $this->cache_dir.$this->get_group_dir($group)."/".$this->hash($id).'.php';
if (!file_exists($cache_file)) {
$this->non_existant_objects[$group][$id] = true;
$this->cache_misses += 1;
@@ -173,6 +173,18 @@ class WP_Object_Cache {
return "{$this->blog_id}/$group";
}
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);
} else {
return md5($data . $wp_server_secret);
}
}
function load_group_from_db($group) {
global $wpdb;
@@ -322,7 +334,7 @@ class WP_Object_Cache {
$ids = array_unique($ids);
foreach ($ids as $id) {
$cache_file = $group_dir.md5($id.DB_PASSWORD).'.php';
$cache_file = $group_dir.$this->hash($id).'.php';
// Remove the cache file if the key is not set.
if (!isset ($this->cache[$group][$id])) {
@@ -414,7 +426,7 @@ class WP_Object_Cache {
if (defined('CACHE_EXPIRATION_TIME'))
$this->expiration_time = CACHE_EXPIRATION_TIME;
$this->blog_id = md5($blog_id);
$this->blog_id = $this->hash($blog_id);
}
}
?>