Changes in trunk/wp-login.php [17465:15090]
- File:
-
- 1 edited
-
trunk/wp-login.php (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-login.php
r17465 r15090 80 80 } 81 81 82 do_action( 'login_enqueue_scripts' ); 83 do_action( 'login_head' ); ?> 82 do_action('login_head'); ?> 84 83 </head> 85 84 <body class="login"> 86 85 <?php if ( !is_multisite() ) { ?> 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>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> 88 87 <?php } else { ?> 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>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> 90 89 <?php } 91 90 … … 117 116 } 118 117 } // End of login_header() 119 120 /**121 * Outputs the footer for the login page.122 *123 * @param string $input_id Which input to auto-focus124 */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 <?php135 }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 <?php142 }143 144 118 function wp_shake_js() { 145 119 global $is_iphone; … … 213 187 $wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login)); 214 188 } 215 $message = __('Someone requested that the password be reset for the following account:') . "\r\n\r\n";189 $message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n"; 216 190 $message .= network_site_url() . "\r\n\r\n"; 217 191 $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\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"; 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"; 221 194 222 195 if ( is_multisite() ) … … 239 212 240 213 /** 241 * Retrieves a user row based on password reset key and login214 * Handles resetting the user's password. 242 215 * 243 216 * @uses $wpdb WordPress Database object 244 217 * 245 218 * @param string $key Hash to validate sending user's password 246 * @param string $login The user login 247 * 248 * @return object|WP_Error 219 * @return bool|WP_Error 249 220 */ 250 function check_password_reset_key($key, $login) {221 function reset_password($key, $login) { 251 222 global $wpdb; 252 223 … … 260 231 261 232 $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $key, $login)); 262 263 233 if ( empty( $user ) ) 264 234 return new WP_Error('invalid_key', __('Invalid key')); 265 235 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) { 236 // Generate something random for a password... 237 $new_pass = wp_generate_password(); 238 277 239 do_action('password_reset', $user, $new_pass); 278 240 279 241 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 else 250 // The blogname option is escaped with esc_html on the way into the database in sanitize_option 251 // 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...') ); 280 261 281 262 wp_password_change_notification($user); 263 264 return true; 282 265 } 283 266 … … 322 305 return $errors; 323 306 324 $user_pass = wp_generate_password( 12, false);307 $user_pass = wp_generate_password(); 325 308 $user_id = wp_create_user( $sanitized_user_login, $user_pass, $user_email ); 326 309 if ( ! $user_id ) { … … 386 369 case 'lostpassword' : 387 370 case 'retrievepassword' : 388 389 371 if ( $http_post ) { 390 372 $errors = retrieve_password(); … … 400 382 401 383 do_action('lost_password'); 402 login_header(__('Lost Password'), '<p class="message">' . __('Please enter your username or e mail address. You will receive a link to create a new password via email.') . '</p>', $errors);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); 403 385 404 386 $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : ''; … … 417 399 418 400 <p id="nav"> 401 <?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 : ?> 419 405 <a href="<?php echo site_url('wp-login.php', 'login') ?>"><?php _e('Log in') ?></a> 420 <?php if (get_option('users_can_register')) : ?>421 | <a href="<?php echo site_url('wp-login.php?action=register', 'login') ?>"><?php _e('Register') ?></a>422 406 <?php endif; ?> 423 407 </p> 424 408 425 <?php 426 login_footer('user_login'); 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 427 420 break; 428 421 429 422 case 'resetpass' : 430 423 case 'rp' : 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'); 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 483 434 break; 484 435 … … 486 437 if ( is_multisite() ) { 487 438 // Multisite uses wp-signup.php 488 wp_redirect( apply_filters( 'wp_signup_location', site_url('wp-signup.php')) );439 wp_redirect( apply_filters( 'wp_signup_location', get_bloginfo('wpurl') . '/wp-signup.php' ) ); 489 440 exit; 490 441 } 491 442 492 443 if ( !get_option('users_can_register') ) { 493 wp_redirect( site_url('wp-login.php?registration=disabled'));444 wp_redirect('wp-login.php?registration=disabled'); 494 445 exit(); 495 446 } … … 498 449 $user_email = ''; 499 450 if ( $http_post ) { 451 require_once( ABSPATH . WPINC . '/registration.php'); 452 500 453 $user_login = $_POST['user_login']; 501 454 $user_email = $_POST['user_email']; … … 533 486 </p> 534 487 535 <?php 536 login_footer('user_login'); 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 537 499 break; 538 500 … … 584 546 <?php exit; 585 547 } 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 } 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'); 596 551 wp_safe_redirect($redirect_to); 597 552 exit(); … … 665 620 </p> 666 621 </div> 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>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> 668 623 <?php } else { ?> 669 624 </div> … … 675 630 <?php if ( $user_login || $interim_login ) { ?> 676 631 d = document.getElementById('user_pass'); 677 d.value = '';678 632 <?php } else { ?> 679 633 d = document.getElementById('user_login'); 680 <?php if ( 'invalid_username' == $errors->get_error_code() ) { ?> 681 if( d.value != '' ) 634 <?php } ?> 682 635 d.value = ''; 683 <?php684 }685 }?>686 636 d.focus(); 687 d.select();688 637 } catch(e){} 689 638 }, 200); … … 695 644 if(typeof wpOnload=='function')wpOnload(); 696 645 </script> 697 <?php do_action( 'login_footer' ); ?>698 646 </body> 699 647 </html>
Note: See TracChangeset
for help on using the changeset viewer.