]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-login.php
WordPress 3.9.2-scripts
[autoinstalls/wordpress.git] / wp-login.php
index 042f29a820fdfc7f5646435dbcee52f56bbf8426..0197167f65cb1c00d6ded3ec669b017177b59917 100644 (file)
@@ -30,8 +30,8 @@ if ( force_ssl_admin() && ! is_ssl() ) {
  * @param string $wp_error Optional. The error to pass. Default empty.
  * @param WP_Error $wp_error Optional. WordPress Error Object
  */
  * @param string $wp_error Optional. The error to pass. Default empty.
  * @param WP_Error $wp_error Optional. WordPress Error Object
  */
-function login_header($title = 'Log In', $message = '', $wp_error = '') {
-       global $error, $interim_login, $current_site, $action;
+function login_header( $title = 'Log In', $message = '', $wp_error = '' ) {
+       global $error, $interim_login, $action;
 
        // Don't index any of these forms
        add_action( 'login_head', 'wp_no_robots' );
 
        // Don't index any of these forms
        add_action( 'login_head', 'wp_no_robots' );
@@ -57,14 +57,18 @@ function login_header($title = 'Log In', $message = '', $wp_error = '') {
                add_action( 'login_head', 'wp_shake_js', 12 );
 
        ?><!DOCTYPE html>
                add_action( 'login_head', 'wp_shake_js', 12 );
 
        ?><!DOCTYPE html>
-       <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
+       <!--[if IE 8]>
+               <html xmlns="http://www.w3.org/1999/xhtml" class="ie8" <?php language_attributes(); ?>>
+       <![endif]-->
+       <!--[if !(IE 8) ]><!-->
+               <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
+       <!--<![endif]-->
        <head>
        <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
        <title><?php bloginfo('name'); ?> &rsaquo; <?php echo $title; ?></title>
        <?php
 
        <head>
        <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
        <title><?php bloginfo('name'); ?> &rsaquo; <?php echo $title; ?></title>
        <?php
 
-       wp_admin_css( 'wp-admin', true );
-       wp_admin_css( 'colors-fresh', true );
+       wp_admin_css( 'login', true );
 
        // Remove all stored post data on logging out.
        // This could be added by add_action('login_head'...) like wp_shake_js()
 
        // Remove all stored post data on logging out.
        // This could be added by add_action('login_head'...) like wp_shake_js()
@@ -90,9 +94,9 @@ function login_header($title = 'Log In', $message = '', $wp_error = '') {
 
        if ( is_multisite() ) {
                $login_header_url   = network_home_url();
 
        if ( is_multisite() ) {
                $login_header_url   = network_home_url();
-               $login_header_title = $current_site->site_name;
+               $login_header_title = get_current_site()->site_name;
        } else {
        } else {
-               $login_header_url   = __( 'http://wordpress.org/' );
+               $login_header_url   = __( 'https://wordpress.org/' );
                $login_header_title = __( 'Powered by WordPress' );
        }
 
                $login_header_title = __( 'Powered by WordPress' );
        }
 
@@ -127,6 +131,7 @@ function login_header($title = 'Log In', $message = '', $wp_error = '') {
                if ( 'success' ===  $interim_login )
                        $classes[] = 'interim-login-success';
        }
                if ( 'success' ===  $interim_login )
                        $classes[] = 'interim-login-success';
        }
+       $classes[] =' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
 
        /**
         * Filter the login page body classes.
 
        /**
         * Filter the login page body classes.
@@ -262,7 +267,7 @@ function wp_login_viewport_meta() {
  * @return bool|WP_Error True: when finish. WP_Error on error
  */
 function retrieve_password() {
  * @return bool|WP_Error True: when finish. WP_Error on error
  */
 function retrieve_password() {
-       global $wpdb, $current_site, $wp_hasher;
+       global $wpdb, $wp_hasher;
 
        $errors = new WP_Error();
 
 
        $errors = new WP_Error();
 
@@ -299,8 +304,8 @@ function retrieve_password() {
        /**
         * Fires before a new password is retrieved.
         *
        /**
         * Fires before a new password is retrieved.
         *
-        * @since 1.5.2
-        * @deprecated 1.5.2 Misspelled. Use 'retrieve_password' hook instead.
+        * @since 1.5.0
+        * @deprecated 1.5.1 Misspelled. Use 'retrieve_password' hook instead.
         *
         * @param string $user_login The user login name.
         */
         *
         * @param string $user_login The user login name.
         */
@@ -308,7 +313,7 @@ function retrieve_password() {
        /**
         * Fires before a new password is retrieved.
         *
        /**
         * Fires before a new password is retrieved.
         *
-        * @since 1.5.2
+        * @since 1.5.1
         *
         * @param string $user_login The user login name.
         */
         *
         * @param string $user_login The user login name.
         */
@@ -384,7 +389,7 @@ function retrieve_password() {
         */
        $message = apply_filters( 'retrieve_password_message', $message, $key );
 
         */
        $message = apply_filters( 'retrieve_password_message', $message, $key );
 
-       if ( $message && !wp_mail($user_email, $title, $message) )
+       if ( $message && !wp_mail( $user_email, wp_specialchars_decode( $title ), $message ) )
                wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function.') );
 
        return true;
                wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function.') );
 
        return true;
@@ -508,7 +513,7 @@ case 'retrievepassword' :
        /**
         * Fires before the lost password form.
         *
        /**
         * Fires before the lost password form.
         *
-        * @since 1.5.2
+        * @since 1.5.1
         */
        do_action( 'lost_password' );
 
         */
        do_action( 'lost_password' );
 
@@ -542,7 +547,7 @@ if ( get_option( 'users_can_register' ) ) :
        /**
         * Filter the registration URL below the login form.
         *
        /**
         * Filter the registration URL below the login form.
         *
-        * @since 1.5.2
+        * @since 1.5.0
         *
         * @param string $registration_url Registration URL.
         */
         *
         * @param string $registration_url Registration URL.
         */
@@ -557,10 +562,25 @@ break;
 
 case 'resetpass' :
 case 'rp' :
 
 case 'resetpass' :
 case 'rp' :
-       $user = check_password_reset_key($_GET['key'], $_GET['login']);
+       list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) );
+       $rp_cookie = 'wp-resetpass-' . COOKIEHASH;
+       if ( isset( $_GET['key'] ) ) {
+               $value = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), wp_unslash( $_GET['key'] ) );
+               setcookie( $rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
+               wp_safe_redirect( remove_query_arg( array( 'key', 'login' ) ) );
+               exit;
+       }
+
+       if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
+               list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
+               $user = check_password_reset_key( $rp_key, $rp_login );
+       } else {
+               $user = false;
+       }
 
 
-       if ( is_wp_error($user) ) {
-               if ( $user->get_error_code() === 'expired_key' )
+       if ( ! $user || is_wp_error( $user ) ) {
+               setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
+               if ( $user && $user->get_error_code() === 'expired_key' )
                        wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) );
                else
                        wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) );
                        wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) );
                else
                        wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) );
@@ -584,6 +604,7 @@ case 'rp' :
 
        if ( ( ! $errors->get_error_code() ) && isset( $_POST['pass1'] ) && !empty( $_POST['pass1'] ) ) {
                reset_password($user, $_POST['pass1']);
 
        if ( ( ! $errors->get_error_code() ) && isset( $_POST['pass1'] ) && !empty( $_POST['pass1'] ) ) {
                reset_password($user, $_POST['pass1']);
+               setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
                login_header( __( 'Password Reset' ), '<p class="message reset-pass">' . __( 'Your password has been reset.' ) . ' <a href="' . esc_url( wp_login_url() ) . '">' . __( 'Log in' ) . '</a></p>' );
                login_footer();
                exit;
                login_header( __( 'Password Reset' ), '<p class="message reset-pass">' . __( 'Your password has been reset.' ) . ' <a href="' . esc_url( wp_login_url() ) . '">' . __( 'Log in' ) . '</a></p>' );
                login_footer();
                exit;
@@ -595,8 +616,8 @@ case 'rp' :
        login_header(__('Reset Password'), '<p class="message reset-pass">' . __('Enter your new password below.') . '</p>', $errors );
 
 ?>
        login_header(__('Reset Password'), '<p class="message reset-pass">' . __('Enter your new password below.') . '</p>', $errors );
 
 ?>
-<form name="resetpassform" id="resetpassform" action="<?php echo esc_url( site_url( 'wp-login.php?action=resetpass&key=' . urlencode( $_GET['key'] ) . '&login=' . urlencode( $_GET['login'] ), 'login_post' ) ); ?>" method="post" autocomplete="off">
-       <input type="hidden" id="user_login" value="<?php echo esc_attr( $_GET['login'] ); ?>" autocomplete="off" />
+<form name="resetpassform" id="resetpassform" action="<?php echo esc_url( site_url( 'wp-login.php?action=resetpass', 'login_post' ) ); ?>" method="post" autocomplete="off">
+       <input type="hidden" id="user_login" value="<?php echo esc_attr( $rp_login ); ?>" autocomplete="off" />
 
        <p>
                <label for="pass1"><?php _e('New password') ?><br />
 
        <p>
                <label for="pass1"><?php _e('New password') ?><br />
@@ -608,9 +629,20 @@ case 'rp' :
        </p>
 
        <div id="pass-strength-result" class="hide-if-no-js"><?php _e('Strength indicator'); ?></div>
        </p>
 
        <div id="pass-strength-result" class="hide-if-no-js"><?php _e('Strength indicator'); ?></div>
-       <p class="description indicator-hint"><?php _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).'); ?></p>
+       <p class="description indicator-hint"><?php _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers, and symbols like ! " ? $ % ^ &amp; ).'); ?></p>
 
        <br class="clear" />
 
        <br class="clear" />
+
+       <?php
+       /**
+        * Fires following the 'Strength indicator' meter in the user password reset form.
+        *
+        * @since 3.9.0
+        *
+        * @param WP_User $user User object of the user whose password is being reset.
+        */
+       do_action( 'resetpass_form', $user );
+       ?>
        <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Reset Password'); ?>" /></p>
 </form>
 
        <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Reset Password'); ?>" /></p>
 </form>
 
@@ -740,11 +772,18 @@ default:
        if ( !$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos($redirect_to, 'https') ) && ( 0 === strpos($redirect_to, 'http') ) )
                $secure_cookie = false;
 
        if ( !$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos($redirect_to, 'https') ) && ( 0 === strpos($redirect_to, 'http') ) )
                $secure_cookie = false;
 
-       // If cookies are disabled we can't log in even with a valid user+pass
-       if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) )
-               $user = new WP_Error('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress."));
-       else
-               $user = wp_signon('', $secure_cookie);
+       $user = wp_signon( '', $secure_cookie );
+
+       if ( empty( $_COOKIE[ LOGGED_IN_COOKIE ] ) ) {
+               if ( headers_sent() ) {
+                       $user = new WP_Error( 'test_cookie', sprintf( __( '<strong>ERROR</strong>: Cookies are blocked due to unexpected output. For help, please see <a href="%1$s">this documentation</a> or try the <a href="%2$s">support forums</a>.' ),
+                               __( 'http://codex.wordpress.org/Cookies' ), __( 'https://wordpress.org/support/' ) ) );
+               } elseif ( isset( $_POST['testcookie'] ) && empty( $_COOKIE[ TEST_COOKIE ] ) ) {
+                       // If cookies are disabled we can't log in even with a valid user+pass
+                       $user = new WP_Error( 'test_cookie', sprintf( __( '<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.' ),
+                               __( 'http://codex.wordpress.org/Cookies' ) ) );
+               }
+       }
 
        $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
        /**
 
        $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
        /**