Ticket #27881: wp-salt.diff
File wp-salt.diff, 2.9 KB (added by , 11 years ago) |
---|
-
src/wp-includes/pluggable.php
1746 1746 $duplicated_keys = array( 'put your unique phrase here' => true ); 1747 1747 foreach ( array( 'AUTH', 'SECURE_AUTH', 'LOGGED_IN', 'NONCE', 'SECRET' ) as $first ) { 1748 1748 foreach ( array( 'KEY', 'SALT' ) as $second ) { 1749 if ( ! defined( "{$first}_{$second}" ) ) 1749 if ( ! defined( "{$first}_{$second}" ) ) { 1750 1750 continue; 1751 } 1751 1752 $value = constant( "{$first}_{$second}" ); 1752 1753 $duplicated_keys[ $value ] = isset( $duplicated_keys[ $value ] ); 1753 1754 } … … 1754 1755 } 1755 1756 } 1756 1757 1757 $key = $salt = ''; 1758 if ( defined( 'SECRET_KEY' ) && SECRET_KEY && empty( $duplicated_keys[ SECRET_KEY ] ) ) 1759 $key = SECRET_KEY; 1760 if ( 'auth' == $scheme && defined( 'SECRET_SALT' ) && SECRET_SALT && empty( $duplicated_keys[ SECRET_SALT ] ) ) 1761 $salt = SECRET_SALT; 1758 $values = array( 1759 'key' => '', 1760 'salt' => '' 1761 ); 1762 if ( defined( 'SECRET_KEY' ) && SECRET_KEY && empty( $duplicated_keys[ SECRET_KEY ] ) ) { 1763 $values['key'] = SECRET_KEY; 1764 } 1765 if ( 'auth' == $scheme && defined( 'SECRET_SALT' ) && SECRET_SALT && empty( $duplicated_keys[ SECRET_SALT ] ) ) { 1766 $values['salt'] = SECRET_SALT; 1767 } 1762 1768 1763 1769 if ( in_array( $scheme, array( 'auth', 'secure_auth', 'logged_in', 'nonce' ) ) ) { 1764 1770 foreach ( array( 'key', 'salt' ) as $type ) { 1765 1771 $const = strtoupper( "{$scheme}_{$type}" ); 1766 1772 if ( defined( $const ) && constant( $const ) && empty( $duplicated_keys[ constant( $const ) ] ) ) { 1767 $ $type= constant( $const );1768 } elseif ( ! $ $type) {1769 $ $type= get_site_option( "{$scheme}_{$type}" );1770 if ( ! $ $type) {1771 $ $type= wp_generate_password( 64, true, true );1772 update_site_option( "{$scheme}_{$type}", $ $type);1773 $values[ $type ] = constant( $const ); 1774 } elseif ( ! $values[ $type ] ) { 1775 $values[ $type ] = get_site_option( "{$scheme}_{$type}" ); 1776 if ( ! $values[ $type ] ) { 1777 $values[ $type ] = wp_generate_password( 64, true, true ); 1778 update_site_option( "{$scheme}_{$type}", $values[ $type ] ); 1773 1779 } 1774 1780 } 1775 1781 } 1776 1782 } else { 1777 if ( ! $ key) {1778 $ key= get_site_option( 'secret_key' );1779 if ( ! $ key) {1780 $ key= wp_generate_password( 64, true, true );1781 update_site_option( 'secret_key', $ key);1783 if ( ! $values['key'] ) { 1784 $values['key'] = get_site_option( 'secret_key' ); 1785 if ( ! $values['key'] ) { 1786 $values['key'] = wp_generate_password( 64, true, true ); 1787 update_site_option( 'secret_key', $values['key'] ); 1782 1788 } 1783 1789 } 1784 $ salt = hash_hmac( 'md5', $scheme, $key);1790 $values['salt'] = hash_hmac( 'md5', $scheme, $values['key'] ); 1785 1791 } 1786 1792 1787 $cached_salts[ $scheme ] = $ key . $salt;1793 $cached_salts[ $scheme ] = $values['key'] . $values['salt']; 1788 1794 1789 1795 /** This filter is documented in wp-includes/pluggable.php */ 1790 1796 return apply_filters( 'salt', $cached_salts[ $scheme ], $scheme );