Make WordPress Core

Changeset 3810


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

wp_hash() and server secret.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/upgrade-schema.php

    r3772 r3810  
    225225                add_option('upload_path', 'wp-content/uploads');
    226226        }
     227       
     228        // 2.0.3
     229        add_option('secret', md5(uniqid(microtime())));
     230
    227231        // 2.1
    228232        add_option('blog_public', 1);
  • 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}
  • trunk/wp-includes/pluggable-functions.php

    r3783 r3810  
    492492
    493493        //Allow for expanding range, but only do one check if we can
    494         if( substr(md5($i . DB_PASSWORD . $action . $uid), -12, 10) == $nonce || substr(md5(($i - 1) . DB_PASSWORD . $action . $uid), -12, 10) == $nonce )
     494        if( substr(wp_hash($i . $action . $uid), -12, 10) == $nonce || substr(wp_hash(($i - 1) . $action . $uid), -12, 10) == $nonce )
    495495                return true;
    496496        return false;
     
    505505        $i = ceil(time() / 43200);
    506506       
    507         return substr(md5($i . DB_PASSWORD . $action . $uid), -12, 10);
     507        return substr(wp_hash($i . $action . $uid), -12, 10);
     508}
     509endif;
     510
     511if ( !function_exists('wp_hash') ) :
     512function wp_hash($data) {
     513        $secret = get_option('secret');
     514        if ( empty($secret) )
     515                $secret = DB_PASSWORD;
     516
     517        if ( function_exists('hash_hmac') ) {
     518                return hash_hmac('md5', $data, $secret);
     519        } else {
     520                return md5($data . $secret);
     521        }
    508522}
    509523endif;
  • trunk/wp-includes/version.php

    r3798 r3810  
    44
    55$wp_version = '2.1-alpha1';
    6 $wp_db_version = 3797;
     6$wp_db_version = 3809;
    77
    88?>
Note: See TracChangeset for help on using the changeset viewer.