| 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); |
| | 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 ] ); |
| 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; |
| 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; |
| | 1331 | $key = $salt = ''; |
| | 1332 | if ( defined( 'SECRET_KEY' ) && SECRET_KEY && empty( $duplicated_keys[ SECRET_KEY ] ) ) |
| | 1333 | $key = SECRET_KEY; |
| | 1334 | if ( 'auth' == $scheme && defined( 'SECRET_SALT' ) && SECRET_SALT && empty( $duplicated_keys[ SECRET_SALT ] ) ) |
| | 1335 | $salt = SECRET_SALT; |
| 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); |
| | 1337 | if ( in_array( $scheme, array( 'auth', 'secure_auth', 'logged_in', 'nonce' ) ) ) { |
| | 1338 | foreach ( array( 'key', 'salt' ) as $type ) { |
| | 1339 | $const = strtoupper( "{$scheme}_{$type}" ); |
| | 1340 | if ( defined( $const ) && constant( $const ) && empty( $duplicated_keys[ constant( $const ) ] ) ) { |
| | 1341 | $$type = constant( $const ); |
| | 1342 | } elseif ( ! $$type ) { |
| | 1343 | $$type = get_site_option( "{$scheme}_{$type}" ); |
| | 1344 | if ( ! $$type ) { |
| | 1345 | $$type = wp_generate_password( 64, true, true ); |
| | 1346 | update_site_option( "{$scheme}_{$type}", $$type ); |
| | 1347 | } |
| 1373 | | // ensure each auth scheme has its own unique salt |
| 1374 | | $salt = hash_hmac('md5', $scheme, $secret_key); |
| | 1351 | if ( ! $key ) { |
| | 1352 | $key = get_site_option( 'secret_key' ); |
| | 1353 | if ( ! $key ) { |
| | 1354 | $key = wp_generate_password( 64, true, true ); |
| | 1355 | update_site_option( 'secret_key', $key ); |
| | 1356 | } |
| | 1357 | } |
| | 1358 | $salt = hash_hmac( 'md5', $scheme, $key ); |