Make WordPress Core


Ignore:
Timestamp:
05/31/2006 12:24:03 AM (20 years ago)
Author:
ryan
Message:

wp_hash() and server secret.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/cache.php

    r3798 r3810  
    143143        }
    144144
    145         $cache_file = $this->cache_dir.$this->get_group_dir($group)."/".md5($id.DB_PASSWORD).'.php';
     145        $cache_file = $this->cache_dir.$this->get_group_dir($group)."/".$this->hash($id).'.php';
    146146        if (!file_exists($cache_file)) {
    147147            $this->non_existant_objects[$group][$id] = true;
     
    172172
    173173        return "{$this->blog_id}/$group";
     174    }
     175
     176    function hash($data) {
     177        global $wp_server_secret;
     178        if ( empty($wp_server_secret) )
     179            $wp_server_secret = DB_PASSWORD;
     180
     181        if ( function_exists('hash_hmac') ) {
     182            return hash_hmac('md5', $data, $wp_server_secret);
     183        } else {
     184            return md5($data . $wp_server_secret);
     185        }
    174186    }
    175187
     
    323335            $ids = array_unique($ids);
    324336            foreach ($ids as $id) {
    325                 $cache_file = $group_dir.md5($id.DB_PASSWORD).'.php';
     337                $cache_file = $group_dir.$this->hash($id).'.php';
    326338
    327339                // Remove the cache file if the key is not set.
     
    415427            $this->expiration_time = CACHE_EXPIRATION_TIME;
    416428
    417         $this->blog_id = md5($blog_id);
     429        $this->blog_id = $this->hash($blog_id);
    418430    }
    419431}
Note: See TracChangeset for help on using the changeset viewer.