]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-login.php
WordPress 3.6.1-scripts
[autoinstalls/wordpress.git] / wp-login.php
index 209341fa6adef8a5b00c28daa4bc6829a01b080f..532ffd970de3025aaca22dfe7184ff3ecac64eda 100644 (file)
@@ -65,7 +65,16 @@ function login_header($title = 'Log In', $message = '', $wp_error = '') {
        wp_admin_css( 'colors-fresh', true );
 
        if ( wp_is_mobile() ) { ?>
-               <meta name="viewport" content="width=320; initial-scale=0.9; maximum-scale=1.0; user-scalable=0;" /><?php
+               <meta name="viewport" content="width=320, initial-scale=0.9, maximum-scale=1.0, user-scalable=0" /><?php
+       }
+
+       // Remove all stored post data on logging out.
+       // This could be added by add_action('login_head'...) like wp_shake_js()
+       // but maybe better if it's not removable by plugins
+       if ( 'loggedout' == $wp_error->get_error_code() ) {
+               ?>
+               <script>if("sessionStorage" in window){try{for(var key in sessionStorage){if(key.indexOf("wp-autosave-")!=-1){sessionStorage.removeItem(key)}}}catch(e){}};</script>
+               <?php
        }
 
        do_action( 'login_enqueue_scripts' );
@@ -82,16 +91,23 @@ function login_header($title = 'Log In', $message = '', $wp_error = '') {
        $login_header_url   = apply_filters( 'login_headerurl',   $login_header_url   );
        $login_header_title = apply_filters( 'login_headertitle', $login_header_title );
 
-       // Don't allow interim logins to navigate away from the page.
-       if ( $interim_login )
-               $login_header_url = '#';
-
        $classes = array( 'login-action-' . $action, 'wp-core-ui' );
        if ( wp_is_mobile() )
                $classes[] = 'mobile';
        if ( is_rtl() )
                $classes[] = 'rtl';
+       if ( $interim_login ) {
+               $classes[] = 'interim-login';
+               ?>
+               <style type="text/css">html{background-color: transparent;}</style>
+               <?php
+
+               if ( 'success' ===  $interim_login )
+                       $classes[] = 'interim-login-success';
+       }
+
        $classes = apply_filters( 'login_body_class', $classes, $action );
+
        ?>
        </head>
        <body class="login <?php echo esc_attr( implode( ' ', $classes ) ); ?>">
@@ -248,7 +264,7 @@ function retrieve_password() {
        $message = apply_filters('retrieve_password_message', $message, $key);
 
        if ( $message && !wp_mail($user_email, $title, $message) )
-               wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') );
+               wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function.') );
 
        return true;
 }
@@ -338,7 +354,7 @@ function register_new_user( $user_login, $user_email ) {
        $user_pass = wp_generate_password( 12, false);
        $user_id = wp_create_user( $sanitized_user_login, $user_pass, $user_email );
        if ( ! $user_id ) {
-               $errors->add( 'registerfail', sprintf( __( '<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !' ), get_option( 'admin_email' ) ) );
+               $errors->add( 'registerfail', sprintf( __( '<strong>ERROR</strong>: Couldn&#8217;t register you&hellip; please contact the <a href="mailto:%s">webmaster</a> !' ), get_option( 'admin_email' ) ) );
                return $errors;
        }
 
@@ -386,6 +402,8 @@ do_action( 'login_init' );
 do_action( 'login_form_' . $action );
 
 $http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
+$interim_login = isset($_REQUEST['interim-login']);
+
 switch ($action) {
 
 case 'postpass' :
@@ -393,7 +411,7 @@ case 'postpass' :
        $hasher = new PasswordHash( 8, true );
 
        // 10 days
-       setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( stripslashes( $_POST['post_password'] ) ), time() + 10 * DAY_IN_SECONDS, COOKIEPATH );
+       setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), time() + 10 * DAY_IN_SECONDS, COOKIEPATH );
 
        wp_safe_redirect( wp_get_referer() );
        exit();
@@ -428,7 +446,7 @@ case 'retrievepassword' :
        do_action('lost_password');
        login_header(__('Lost Password'), '<p class="message">' . __('Please enter your username or email address. You will receive a link to create a new password via email.') . '</p>', $errors);
 
-       $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : '';
+       $user_login = isset($_POST['user_login']) ? wp_unslash($_POST['user_login']) : '';
 
 ?>
 
@@ -445,7 +463,7 @@ case 'retrievepassword' :
 <p id="nav">
 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e('Log in') ?></a>
 <?php if ( get_option( 'users_can_register' ) ) : ?>
- | <a href="<?php echo esc_url( site_url( 'wp-login.php?action=register', 'login' ) ); ?>"><?php _e( 'Register' ); ?></a>
+ | <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?>
 <?php endif; ?>
 </p>
 
@@ -482,7 +500,7 @@ case 'rp' :
        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">
+<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" />
 
        <p>
@@ -504,7 +522,7 @@ case 'rp' :
 <p id="nav">
 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a>
 <?php if ( get_option( 'users_can_register' ) ) : ?>
- | <a href="<?php echo esc_url( site_url( 'wp-login.php?action=register', 'login' ) ); ?>"><?php _e( 'Register' ); ?></a>
+ | <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?>
 <?php endif; ?>
 </p>
 
@@ -544,11 +562,11 @@ case 'register' :
 <form name="registerform" id="registerform" action="<?php echo esc_url( site_url('wp-login.php?action=register', 'login_post') ); ?>" method="post">
        <p>
                <label for="user_login"><?php _e('Username') ?><br />
-               <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr(stripslashes($user_login)); ?>" size="20" /></label>
+               <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr(wp_unslash($user_login)); ?>" size="20" /></label>
        </p>
        <p>
                <label for="user_email"><?php _e('E-mail') ?><br />
-               <input type="text" name="user_email" id="user_email" class="input" value="<?php echo esc_attr(stripslashes($user_email)); ?>" size="25" /></label>
+               <input type="text" name="user_email" id="user_email" class="input" value="<?php echo esc_attr(wp_unslash($user_email)); ?>" size="25" /></label>
        </p>
 <?php do_action('register_form'); ?>
        <p id="reg_passmail"><?php _e('A password will be e-mailed to you.') ?></p>
@@ -569,7 +587,6 @@ break;
 case 'login' :
 default:
        $secure_cookie = '';
-       $interim_login = isset($_REQUEST['interim-login']);
        $customize_login = isset( $_REQUEST['customize-login'] );
        if ( $customize_login )
                wp_enqueue_script( 'customize-base' );
@@ -609,13 +626,8 @@ default:
        if ( !is_wp_error($user) && !$reauth ) {
                if ( $interim_login ) {
                        $message = '<p class="message">' . __('You have logged in successfully.') . '</p>';
+                       $interim_login = 'success';
                        login_header( '', $message ); ?>
-
-                       <?php if ( ! $customize_login ) : ?>
-                       <script type="text/javascript">setTimeout( function(){window.close()}, 8000);</script>
-                       <p class="alignright">
-                       <input type="button" class="button-primary" value="<?php esc_attr_e('Close'); ?>" onclick="window.close()" /></p>
-                       <?php endif; ?>
                        </div>
                        <?php do_action( 'login_footer' ); ?>
                        <?php if ( $customize_login ) : ?>
@@ -647,21 +659,26 @@ default:
        if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) )
                $errors->add('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."));
 
-       // Some parts of this script use the main login form to display a message
-       if              ( isset($_GET['loggedout']) && true == $_GET['loggedout'] )
-               $errors->add('loggedout', __('You are now logged out.'), 'message');
-       elseif  ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] )
-               $errors->add('registerdisabled', __('User registration is currently not allowed.'));
-       elseif  ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] )
-               $errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message');
-       elseif  ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] )
-               $errors->add('newpass', __('Check your e-mail for your new password.'), 'message');
-       elseif  ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] )
-               $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message');
-       elseif  ( $interim_login )
-               $errors->add('expired', __('Your session has expired. Please log-in again.'), 'message');
-       elseif ( strpos( $redirect_to, 'about.php?updated' ) )
-               $errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to experience the awesomeness.' ), 'message' );
+       if ( $interim_login ) {
+               if ( ! $errors->get_error_code() )
+                       $errors->add('expired', __('Session expired. Please log in again. You will not move away from this page.'), 'message');
+       } else {
+               // Some parts of this script use the main login form to display a message
+               if              ( isset($_GET['loggedout']) && true == $_GET['loggedout'] )
+                       $errors->add('loggedout', __('You are now logged out.'), 'message');
+               elseif  ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] )
+                       $errors->add('registerdisabled', __('User registration is currently not allowed.'));
+               elseif  ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] )
+                       $errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message');
+               elseif  ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] )
+                       $errors->add('newpass', __('Check your e-mail for your new password.'), 'message');
+               elseif  ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] )
+                       $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message');
+               elseif ( strpos( $redirect_to, 'about.php?updated' ) )
+                       $errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to experience the awesomeness.' ), 'message' );
+       }
+
+       $errors = apply_filters( 'wp_login_errors', $errors, $redirect_to );
 
        // Clear any stale cookies.
        if ( $reauth )
@@ -670,7 +687,7 @@ default:
        login_header(__('Log In'), '', $errors);
 
        if ( isset($_POST['log']) )
-               $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr(stripslashes($_POST['log'])) : '';
+               $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr(wp_unslash($_POST['log'])) : '';
        $rememberme = ! empty( $_POST['rememberme'] );
 ?>
 
@@ -699,14 +716,13 @@ default:
        </p>
 </form>
 
-<?php if ( !$interim_login ) { ?>
+<?php if ( ! $interim_login ) { ?>
 <p id="nav">
-<?php if ( isset($_GET['checkemail']) && in_array( $_GET['checkemail'], array('confirm', 'newpass') ) ) : ?>
-<?php elseif ( get_option('users_can_register') ) : ?>
-<a href="<?php echo esc_url( site_url( 'wp-login.php?action=register', 'login' ) ); ?>"><?php _e( 'Register' ); ?></a> |
-<a href="<?php echo esc_url( wp_lostpassword_url() ); ?>" title="<?php esc_attr_e( 'Password Lost and Found' ); ?>"><?php _e( 'Lost your password?' ); ?></a>
-<?php else : ?>
-<a href="<?php echo esc_url( wp_lostpassword_url() ); ?>" title="<?php esc_attr_e( 'Password Lost and Found' ); ?>"><?php _e( 'Lost your password?' ); ?></a>
+<?php if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) : ?>
+       <?php if ( get_option( 'users_can_register' ) ) : ?>
+               <?php echo apply_filters( 'register', sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ) ); ?> |
+       <?php endif; ?>
+       <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>" title="<?php esc_attr_e( 'Password Lost and Found' ); ?>"><?php _e( 'Lost your password?' ); ?></a>
 <?php endif; ?>
 </p>
 <?php } ?>
@@ -735,6 +751,17 @@ d.select();
 wp_attempt_focus();
 <?php } ?>
 if(typeof wpOnload=='function')wpOnload();
+<?php if ( $interim_login ) { ?>
+(function(){
+try {
+       var i, links = document.getElementsByTagName('a');
+       for ( i in links ) {
+               if ( links[i].href )
+                       links[i].target = '_blank';
+       }
+} catch(e){}
+}());
+<?php } ?>
 </script>
 
 <?php