Optimize the keys/salts textarea. fixes #15092.

git-svn-id: https://develop.svn.wordpress.org/trunk@16746 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2010-12-06 15:26:30 +00:00
parent 2c44ffcc57
commit 3e38f2e429
1 changed files with 5 additions and 8 deletions

View File

@ -365,27 +365,24 @@ define( 'BLOG_ID_CURRENT_SITE', 1 );</textarea>
if ( defined( $c ) )
unset( $keys_salts[ $c ] );
}
if ( ! empty( $keys_salts ) ) {
if ( ! empty( $keys_salts ) ) {
$keys_salts_str = '';
$from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
if ( is_wp_error( $from_api ) ) {
foreach ( $keys_salts as $c => $v ) {
$keys_salts[ $c ] = wp_generate_password( 64, true, true );
$keys_salts_str .= "\ndefine( '$c', '" . wp_generate_password( 64, true, true ) . "' );";
}
} else {
$from_api = explode( "\n", wp_remote_retrieve_body( $from_api ) );
foreach ( $keys_salts as $c => $v ) {
$keys_salts[ $c ] = substr( array_shift( $from_api ), 28, 64 );
$keys_salts_str .= "\ndefine( '$c', '" . substr( array_shift( $from_api ), 28, 64 ) . "' );";
}
}
$num_keys_salts = count( $keys_salts );
?>
<p><?php
echo _n( 'This unique authentication key is also missing from your <code>wp-config.php</code> file.', 'These unique authentication keys are also missing from your <code>wp-config.php</code> file.', $num_keys_salts ); ?> <?php _e( 'To make your installation more secure, you should also add:' ) ?></p>
<textarea class="code" readonly="readonly" cols="100" rows="<?php echo $num_keys_salts; ?>"><?php
foreach ( $keys_salts as $c => $v ) {
echo "\ndefine( '$c', '" . esc_textarea( $v ) . "' );";
}
?></textarea>
<textarea class="code" readonly="readonly" cols="100" rows="<?php echo $num_keys_salts; ?>"><?php echo esc_textarea( $keys_salts_str ); ?></textarea>
<?php
}
?>