Changes in trunk/wp-login.php [15090:17465]
- File:
-
- 1 edited
-
trunk/wp-login.php (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-login.php
r15090 r17465 80 80 } 81 81 82 do_action('login_head'); ?> 82 do_action( 'login_enqueue_scripts' ); 83 do_action( 'login_head' ); ?> 83 84 </head> 84 85 <body class="login"> 85 86 <?php if ( !is_multisite() ) { ?> 86 <div id="login"><h1><a href="<?php echo apply_filters('login_headerurl', 'http://wordpress.org/'); ?>" title="<?php echo apply_filters('login_headertitle', __('Powered by WordPress')); ?>"><?php bloginfo('name'); ?></a></h1>87 <div id="login"><h1><a href="<?php echo apply_filters('login_headerurl', 'http://wordpress.org/'); ?>" title="<?php echo apply_filters('login_headertitle', esc_attr__('Powered by WordPress')); ?>"><?php bloginfo('name'); ?></a></h1> 87 88 <?php } else { ?> 88 <div id="login"><h1><a href="<?php echo apply_filters('login_headerurl', network_home_url() ); ?>" title="<?php echo apply_filters('login_headertitle', $current_site->site_name); ?>"><span class="hide"><?php bloginfo('name'); ?></span></a></h1>89 <div id="login"><h1><a href="<?php echo apply_filters('login_headerurl', network_home_url() ); ?>" title="<?php echo apply_filters('login_headertitle', esc_attr($current_site->site_name) ); ?>"><span class="hide"><?php bloginfo('name'); ?></span></a></h1> 89 90 <?php } 90 91 … … 116 117 } 117 118 } // End of login_header() 119 120 /** 121 * Outputs the footer for the login page. 122 * 123 * @param string $input_id Which input to auto-focus 124 */ 125 function login_footer($input_id = '') { 126 echo "</div>\n"; 127 128 if ( !empty($input_id) ) { 129 ?> 130 <script type="text/javascript"> 131 try{document.getElementById('<?php echo $input_id; ?>').focus();}catch(e){} 132 if(typeof wpOnload=='function')wpOnload(); 133 </script> 134 <?php 135 } 136 ?> 137 <p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php esc_attr_e('Are you lost?') ?>"><?php printf(__('← Back to %s'), get_bloginfo('title', 'display' )); ?></a></p> 138 <?php do_action('login_footer'); ?> 139 </body> 140 </html> 141 <?php 142 } 143 118 144 function wp_shake_js() { 119 145 global $is_iphone; … … 187 213 $wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login)); 188 214 } 189 $message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n";215 $message = __('Someone requested that the password be reset for the following account:') . "\r\n\r\n"; 190 216 $message .= network_site_url() . "\r\n\r\n"; 191 217 $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; 192 $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n"; 193 $message .= network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . "\r\n"; 218 $message .= __('If this was a mistake, just ignore this email and nothing will happen.') . "\r\n\r\n"; 219 $message .= __('To reset your password, visit the following address:') . "\r\n\r\n"; 220 $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . ">\r\n"; 194 221 195 222 if ( is_multisite() ) … … 212 239 213 240 /** 214 * Handles resetting the user's password.241 * Retrieves a user row based on password reset key and login 215 242 * 216 243 * @uses $wpdb WordPress Database object 217 244 * 218 245 * @param string $key Hash to validate sending user's password 219 * @return bool|WP_Error 246 * @param string $login The user login 247 * 248 * @return object|WP_Error 220 249 */ 221 function reset_password($key, $login) {250 function check_password_reset_key($key, $login) { 222 251 global $wpdb; 223 252 … … 231 260 232 261 $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $key, $login)); 262 233 263 if ( empty( $user ) ) 234 264 return new WP_Error('invalid_key', __('Invalid key')); 235 265 236 // Generate something random for a password... 237 $new_pass = wp_generate_password(); 238 266 return $user; 267 } 268 269 /** 270 * Handles resetting the user's password. 271 * 272 * @uses $wpdb WordPress Database object 273 * 274 * @param string $key Hash to validate sending user's password 275 */ 276 function reset_password($user, $new_pass) { 239 277 do_action('password_reset', $user, $new_pass); 240 278 241 279 wp_set_password($new_pass, $user->ID); 242 update_user_option($user->ID, 'default_password_nag', true, true); //Set up the Password change nag.243 $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";244 $message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";245 $message .= site_url('wp-login.php', 'login') . "\r\n";246 247 if ( is_multisite() )248 $blogname = $GLOBALS['current_site']->site_name;249 else250 // The blogname option is escaped with esc_html on the way into the database in sanitize_option251 // we want to reverse this for the plain text arena of emails.252 $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);253 254 $title = sprintf( __('[%s] Your new password'), $blogname );255 256 $title = apply_filters('password_reset_title', $title);257 $message = apply_filters('password_reset_message', $message, $new_pass);258 259 if ( $message && !wp_mail($user->user_email, $title, $message) )260 wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') );261 280 262 281 wp_password_change_notification($user); 263 264 return true;265 282 } 266 283 … … 305 322 return $errors; 306 323 307 $user_pass = wp_generate_password( );324 $user_pass = wp_generate_password( 12, false); 308 325 $user_id = wp_create_user( $sanitized_user_login, $user_pass, $user_email ); 309 326 if ( ! $user_id ) { … … 369 386 case 'lostpassword' : 370 387 case 'retrievepassword' : 388 371 389 if ( $http_post ) { 372 390 $errors = retrieve_password(); … … 382 400 383 401 do_action('lost_password'); 384 login_header(__('Lost Password'), '<p class="message">' . __('Please enter your username or e -mail address. You will receive a new password via e-mail.') . '</p>', $errors);402 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); 385 403 386 404 $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : ''; … … 399 417 400 418 <p id="nav"> 419 <a href="<?php echo site_url('wp-login.php', 'login') ?>"><?php _e('Log in') ?></a> 401 420 <?php if (get_option('users_can_register')) : ?> 402 <a href="<?php echo site_url('wp-login.php', 'login') ?>"><?php _e('Log in') ?></a> | 403 <a href="<?php echo site_url('wp-login.php?action=register', 'login') ?>"><?php _e('Register') ?></a> 404 <?php else : ?> 405 <a href="<?php echo site_url('wp-login.php', 'login') ?>"><?php _e('Log in') ?></a> 421 | <a href="<?php echo site_url('wp-login.php?action=register', 'login') ?>"><?php _e('Register') ?></a> 406 422 <?php endif; ?> 407 423 </p> 408 424 409 </div> 410 411 <p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('← Back to %s'), get_bloginfo('title', 'display' )); ?></a></p> 412 413 <script type="text/javascript"> 414 try{document.getElementById('user_login').focus();}catch(e){} 415 if(typeof wpOnload=='function')wpOnload(); 416 </script> 417 </body> 418 </html> 419 <?php 425 <?php 426 login_footer('user_login'); 420 427 break; 421 428 422 429 case 'resetpass' : 423 430 case 'rp' : 424 $errors = reset_password($_GET['key'], $_GET['login']); 425 426 if ( ! is_wp_error($errors) ) { 427 wp_redirect('wp-login.php?checkemail=newpass'); 428 exit(); 429 } 430 431 wp_redirect('wp-login.php?action=lostpassword&error=invalidkey'); 432 exit(); 433 431 $user = check_password_reset_key($_GET['key'], $_GET['login']); 432 433 if ( is_wp_error($user) ) { 434 wp_redirect( site_url('wp-login.php?action=lostpassword&error=invalidkey') ); 435 exit; 436 } 437 438 $errors = ''; 439 440 if ( isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2'] ) { 441 $errors = new WP_Error('password_reset_mismatch', __('The passwords do not match.')); 442 } elseif ( isset($_POST['pass1']) && !empty($_POST['pass1']) ) { 443 reset_password($user, $_POST['pass1']); 444 login_header(__('Password Reset'), '<p class="message reset-pass">' . __('Your password has been reset.') . ' <a href="' . site_url('wp-login.php', 'login') . '">' . __('Log in') . '</a></p>'); 445 login_footer(); 446 exit; 447 } 448 449 wp_enqueue_script('utils'); 450 wp_enqueue_script('user-profile'); 451 452 login_header(__('Reset Password'), '<p class="message reset-pass">' . __('Enter your new password below.') . '</p>', $errors ); 453 454 ?> 455 <form name="resetpassform" id="resetpassform" action="<?php echo site_url('wp-login.php?action=resetpass&key=' . urlencode($_GET['key']) . '&login=' . urlencode($_GET['login']), 'login_post') ?>" method="post"> 456 <input type="hidden" id="user_login" value="<?php echo esc_attr( $_GET['login'] ); ?>" autocomplete="off" /> 457 458 <p> 459 <label><?php _e('New password') ?><br /> 460 <input type="password" name="pass1" id="pass1" class="input" size="20" value="" autocomplete="off" /></label> 461 </p> 462 <p> 463 <label><?php _e('Confirm new password') ?><br /> 464 <input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off" /></label> 465 </p> 466 467 <div id="pass-strength-result" class="hide-if-no-js"><?php _e('Strength indicator'); ?></div> 468 <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 ! " ? $ % ^ & ).'); ?></p> 469 470 <br class="clear" /> 471 <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="<?php esc_attr_e('Reset Password'); ?>" tabindex="100" /></p> 472 </form> 473 474 <p id="nav"> 475 <a href="<?php echo site_url('wp-login.php', 'login') ?>"><?php _e('Log in') ?></a> 476 <?php if (get_option('users_can_register')) : ?> 477 | <a href="<?php echo site_url('wp-login.php?action=register', 'login') ?>"><?php _e('Register') ?></a> 478 <?php endif; ?> 479 </p> 480 481 <?php 482 login_footer('user_pass'); 434 483 break; 435 484 … … 437 486 if ( is_multisite() ) { 438 487 // Multisite uses wp-signup.php 439 wp_redirect( apply_filters( 'wp_signup_location', get_bloginfo('wpurl') . '/wp-signup.php') );488 wp_redirect( apply_filters( 'wp_signup_location', site_url('wp-signup.php') ) ); 440 489 exit; 441 490 } 442 491 443 492 if ( !get_option('users_can_register') ) { 444 wp_redirect( 'wp-login.php?registration=disabled');493 wp_redirect( site_url('wp-login.php?registration=disabled') ); 445 494 exit(); 446 495 } … … 449 498 $user_email = ''; 450 499 if ( $http_post ) { 451 require_once( ABSPATH . WPINC . '/registration.php');452 453 500 $user_login = $_POST['user_login']; 454 501 $user_email = $_POST['user_email']; … … 486 533 </p> 487 534 488 </div> 489 490 <p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('← Back to %s'), get_bloginfo('title', 'display' )); ?></a></p> 491 492 <script type="text/javascript"> 493 try{document.getElementById('user_login').focus();}catch(e){} 494 if(typeof wpOnload=='function')wpOnload(); 495 </script> 496 </body> 497 </html> 498 <?php 535 <?php 536 login_footer('user_login'); 499 537 break; 500 538 … … 546 584 <?php exit; 547 585 } 548 // If the user can't edit posts, send them to their profile. 549 if ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) 550 $redirect_to = admin_url('profile.php'); 586 587 if ( ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) { 588 // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile. 589 if ( is_multisite() && !get_active_blog_for_user($user->id) ) 590 $redirect_to = user_admin_url(); 591 elseif ( is_multisite() && !$user->has_cap('read') ) 592 $redirect_to = get_dashboard_url( $user->id ); 593 elseif ( !$user->has_cap('edit_posts') ) 594 $redirect_to = admin_url('profile.php'); 595 } 551 596 wp_safe_redirect($redirect_to); 552 597 exit(); … … 620 665 </p> 621 666 </div> 622 <p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('← Back to %s'), get_bloginfo('title', 'display' )); ?></a></p>667 <p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php esc_attr_e('Are you lost?') ?>"><?php printf(__('← Back to %s'), get_bloginfo('title', 'display' )); ?></a></p> 623 668 <?php } else { ?> 624 669 </div> … … 630 675 <?php if ( $user_login || $interim_login ) { ?> 631 676 d = document.getElementById('user_pass'); 677 d.value = ''; 632 678 <?php } else { ?> 633 679 d = document.getElementById('user_login'); 634 <?php } ?> 680 <?php if ( 'invalid_username' == $errors->get_error_code() ) { ?> 681 if( d.value != '' ) 635 682 d.value = ''; 683 <?php 684 } 685 }?> 636 686 d.focus(); 687 d.select(); 637 688 } catch(e){} 638 689 }, 200); … … 644 695 if(typeof wpOnload=='function')wpOnload(); 645 696 </script> 697 <?php do_action( 'login_footer' ); ?> 646 698 </body> 647 699 </html>
Note: See TracChangeset
for help on using the changeset viewer.