Make WordPress Core

Changeset 13614


Ignore:
Timestamp:
03/06/2010 09:01:58 PM (16 years ago)
Author:
nacin
Message:

Add nag for missing authentication keys in network.php. See #11816

Location:
trunk/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/network.php

    r13613 r13614  
    180180define( 'PATH_CURRENT_SITE', '<?php echo $base; ?>' );
    181181define( 'SITE_ID_CURRENT_SITE', 1 );
    182 define( 'BLOG_ID_CURRENT_SITE', 1 );</textarea></li>
     182define( 'BLOG_ID_CURRENT_SITE', 1 );</textarea>
     183<?php
     184        $keys_salts = array( 'AUTH_KEY' => '', 'SECURE_AUTH_KEY' => '', 'LOGGED_IN_KEY' => '', 'NONCE_KEY' => '', 'AUTH_SALT' => '', 'SECURE_AUTH_SALT' => '', 'LOGGED_IN_SALT' => '', 'NONCE_SALT' => '' );
     185        foreach ( $keys_salts as $c => $v ) {
     186                if ( defined( $c ) )
     187                        unset( $keys_salts[ $c ] );
     188        }
     189        if ( ! empty( $keys_salts ) ) {
     190                $from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
     191                if ( is_wp_error( $from_api ) ) {
     192                        foreach ( $keys_salts as $c => $v ) {
     193                                $keys_salts[ $c ] = wp_generate_password( 64, true, true );
     194                        }
     195                } else {
     196                        $from_api = explode( "\n", wp_remote_retrieve_body( $from_api ) );
     197                        foreach ( $keys_salts as $c => $v ) {
     198                                $keys_salts[ $c ] = substr( array_shift( $from_api ), 28, 64 );
     199                        }
     200                }
     201                $num_keys_salts = count( $keys_salts );
     202?>
     203        <p><?php
     204                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>
     205        <textarea class="code" readonly="readonly" cols="100" rows="<?php echo $num_keys_salts; ?>"><?php
     206        foreach ( $keys_salts as $c => $v ) {
     207                echo "\ndefine( '$c', '$v' );";
     208        }
     209?></textarea>
     210<?php   
     211        }
     212?>
     213</li>
    183214<?php
    184215
     
    211242</textarea></li>
    212243                </ol>
     244                <p>Once you complete these steps, your network is enabled and configured. <a href="<?php echo esc_url( admin_url() ); ?>">Return to Dashboard</a></p>
    213245<?php
    214246}
  • trunk/wp-admin/setup-config.php

    r13232 r13614  
    194194                $secret_keys = array();
    195195                require_once( ABSPATH . WPINC . '/pluggable.php' );
    196                 for ( $i = 0; $i < 8; $i++ )
     196                for ( $i = 0; $i < 8; $i++ ) {
    197197                        $secret_keys[] = wp_generate_password( 64, true, true );
     198                }
    198199        } else {
    199200                $secret_keys = explode( "\n", wp_remote_retrieve_body( $secret_keys ) );
    200                 foreach ( $secret_keys as $k => $v )
     201                foreach ( $secret_keys as $k => $v ) {
    201202                        $secret_keys[$k] = substr( $v, 28, 64 );
     203                }
    202204        }
    203205        $key = 0;
Note: See TracChangeset for help on using the changeset viewer.