Changeset 19771
- Timestamp:
- 01/27/2012 06:52:20 PM (13 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/default-constants.php
r19712 r19771 141 141 */ 142 142 function wp_cookie_constants( ) { 143 global $wp_default_secret_key;144 145 143 /** 146 144 * Used to guarantee unique hash cookies … … 156 154 157 155 /** 158 * Should be exactly the same as the default value of SECRET_KEY in wp-config-sample.php159 * @since 2.5.0160 */161 $wp_default_secret_key = 'put your unique phrase here';162 163 /**164 156 * @since 2.0.0 165 157 */ -
trunk/wp-includes/pluggable.php
r19726 r19771 1307 1307 * @link https://api.wordpress.org/secret-key/1.1/salt/ Create secrets for wp-config.php 1308 1308 * 1309 * @param string $scheme Authentication scheme 1309 * @param string $scheme Authentication scheme (auth, secure_auth, logged_in, nonce) 1310 1310 * @return string Salt value 1311 1311 */ 1312 function wp_salt($scheme = 'auth') { 1313 global $wp_default_secret_key; 1314 $secret_key = ''; 1315 if ( defined('SECRET_KEY') && ('' != SECRET_KEY) && ( $wp_default_secret_key != SECRET_KEY) ) 1316 $secret_key = SECRET_KEY; 1317 1318 if ( 'auth' == $scheme ) { 1319 if ( defined('AUTH_KEY') && ('' != AUTH_KEY) && ( $wp_default_secret_key != AUTH_KEY) ) 1320 $secret_key = AUTH_KEY; 1321 1322 if ( defined('AUTH_SALT') && ('' != AUTH_SALT) && ( $wp_default_secret_key != AUTH_SALT) ) { 1323 $salt = AUTH_SALT; 1324 } elseif ( defined('SECRET_SALT') && ('' != SECRET_SALT) && ( $wp_default_secret_key != SECRET_SALT) ) { 1325 $salt = SECRET_SALT; 1326 } else { 1327 $salt = get_site_option('auth_salt'); 1328 if ( empty($salt) ) { 1329 $salt = wp_generate_password( 64, true, true ); 1330 update_site_option('auth_salt', $salt); 1312 function wp_salt( $scheme = 'auth' ) { 1313 global $wp_secret_key_default; // This is set for localized builds for versions > 3.4.0. 1314 1315 static $duplicated_keys; 1316 if ( null === $duplicated_keys ) { 1317 $duplicated_keys = array( 'put your unique phrase here' => true ); 1318 foreach ( array( 'AUTH', 'SECURE_AUTH', 'LOGGED_IN', 'NONCE', 'SECRET' ) as $first ) { 1319 foreach ( array( 'KEY', 'SALT' ) as $second ) { 1320 if ( ! defined( "{$first}_{$second}" ) ) 1321 continue; 1322 $value = constant( "{$first}_{$second}" ); 1323 $duplicated_keys[ $value ] = isset( $duplicated_keys[ $value ] ); 1331 1324 } 1332 1325 } 1333 } elseif ( 'secure_auth' == $scheme ) { 1334 if ( defined('SECURE_AUTH_KEY') && ('' != SECURE_AUTH_KEY) && ( $wp_default_secret_key != SECURE_AUTH_KEY) ) 1335 $secret_key = SECURE_AUTH_KEY; 1336 1337 if ( defined('SECURE_AUTH_SALT') && ('' != SECURE_AUTH_SALT) && ( $wp_default_secret_key != SECURE_AUTH_SALT) ) { 1338 $salt = SECURE_AUTH_SALT; 1339 } else { 1340 $salt = get_site_option('secure_auth_salt'); 1341 if ( empty($salt) ) { 1342 $salt = wp_generate_password( 64, true, true ); 1343 update_site_option('secure_auth_salt', $salt); 1344 } 1345 } 1346 } elseif ( 'logged_in' == $scheme ) { 1347 if ( defined('LOGGED_IN_KEY') && ('' != LOGGED_IN_KEY) && ( $wp_default_secret_key != LOGGED_IN_KEY) ) 1348 $secret_key = LOGGED_IN_KEY; 1349 1350 if ( defined('LOGGED_IN_SALT') && ('' != LOGGED_IN_SALT) && ( $wp_default_secret_key != LOGGED_IN_SALT) ) { 1351 $salt = LOGGED_IN_SALT; 1352 } else { 1353 $salt = get_site_option('logged_in_salt'); 1354 if ( empty($salt) ) { 1355 $salt = wp_generate_password( 64, true, true ); 1356 update_site_option('logged_in_salt', $salt); 1357 } 1358 } 1359 } elseif ( 'nonce' == $scheme ) { 1360 if ( defined('NONCE_KEY') && ('' != NONCE_KEY) && ( $wp_default_secret_key != NONCE_KEY) ) 1361 $secret_key = NONCE_KEY; 1362 1363 if ( defined('NONCE_SALT') && ('' != NONCE_SALT) && ( $wp_default_secret_key != NONCE_SALT) ) { 1364 $salt = NONCE_SALT; 1365 } else { 1366 $salt = get_site_option('nonce_salt'); 1367 if ( empty($salt) ) { 1368 $salt = wp_generate_password( 64, true, true ); 1369 update_site_option('nonce_salt', $salt); 1326 if ( ! empty( $wp_secret_key_default ) ) 1327 $duplicated_keys[ $wp_secret_key_default ] = true; 1328 } 1329 1330 $key = $salt = ''; 1331 if ( defined( 'SECRET_KEY' ) && SECRET_KEY && empty( $duplicated_keys[ SECRET_KEY ] ) ) 1332 $key = SECRET_KEY; 1333 if ( 'auth' == $scheme && defined( 'SECRET_SALT' ) && SECRET_SALT && empty( $duplicated_keys[ SECRET_SALT ] ) ) 1334 $salt = SECRET_SALT; 1335 1336 if ( in_array( $scheme, array( 'auth', 'secure_auth', 'logged_in', 'nonce' ) ) ) { 1337 foreach ( array( 'key', 'salt' ) as $type ) { 1338 $const = strtoupper( "{$scheme}_{$type}" ); 1339 if ( defined( $const ) && constant( $const ) && empty( $duplicated_keys[ constant( $const ) ] ) ) { 1340 $$type = constant( $const ); 1341 } elseif ( ! $$type ) { 1342 $$type = get_site_option( "{$scheme}_{$type}" ); 1343 if ( ! $$type ) { 1344 $$type = wp_generate_password( 64, true, true ); 1345 update_site_option( "{$scheme}_{$type}", $$type ); 1346 } 1370 1347 } 1371 1348 } 1372 1349 } else { 1373 // ensure each auth scheme has its own unique salt 1374 $salt = hash_hmac('md5', $scheme, $secret_key); 1375 } 1376 1377 return apply_filters('salt', $secret_key . $salt, $scheme); 1350 if ( ! $key ) { 1351 $key = get_site_option( 'secret_key' ); 1352 if ( ! $key ) { 1353 $key = wp_generate_password( 64, true, true ); 1354 update_site_option( 'secret_key', $key ); 1355 } 1356 } 1357 $salt = hash_hmac( 'md5', $scheme, $key ); 1358 } 1359 1360 return apply_filters('salt', $key . $salt, $scheme); 1378 1361 } 1379 1362 endif;
Note: See TracChangeset
for help on using the changeset viewer.