X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/wordpress.git/blobdiff_plain/11be8dc178e77d0b46189bbd8e33a216a9b90942..refs/tags/wordpress-2.8.2-scripts:/wp-login.php
diff --git a/wp-login.php b/wp-login.php
index dab6324f..62898123 100644
--- a/wp-login.php
+++ b/wp-login.php
@@ -8,7 +8,7 @@
* @package WordPress
*/
-/** Make sure that the WordPress bootstrap has ran before continuing. */
+/** Make sure that the WordPress bootstrap has run before continuing. */
require( dirname(__FILE__) . '/wp-load.php' );
// Redirect to https login if forced to use SSL
@@ -39,7 +39,11 @@ if ( force_ssl_admin() && !is_ssl() ) {
* @param WP_Error $wp_error Optional. WordPress Error Object
*/
function login_header($title = 'Log In', $message = '', $wp_error = '') {
- global $error;
+ global $error, $is_iphone;
+
+ // Don't index any of these forms
+ add_filter( 'pre_option_blog_public', create_function( '$a', 'return 0;' ) );
+ add_action( 'login_head', 'noindex' );
if ( empty($wp_error) )
$wp_error = new WP_Error();
@@ -52,13 +56,25 @@ function login_header($title = 'Log In', $message = '', $wp_error = '') {
+
+
+
query($wpdb->prepare("UPDATE $wpdb->users SET user_activation_key = %s WHERE user_login = %s", $key, $user_login));
+ $wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login));
}
$message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n";
$message .= get_option('siteurl') . "\r\n\r\n";
@@ -147,7 +163,12 @@ function retrieve_password() {
$message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n";
$message .= site_url("wp-login.php?action=rp&key=$key", 'login') . "\r\n";
- if ( !wp_mail($user_email, sprintf(__('[%s] Password Reset'), get_option('blogname')), $message) )
+ $title = sprintf(__('[%s] Password Reset'), get_option('blogname'));
+
+ $title = apply_filters('retrieve_password_title', $title);
+ $message = apply_filters('retrieve_password_message', $message, $key);
+
+ if ( $message && !wp_mail($user_email, $title, $message) )
die('
' . __('The e-mail could not be sent.') . "
\n" . __('Possible reason: your host may have disabled the mail() function...') . '
');
return true;
@@ -173,17 +194,24 @@ function reset_password($key) {
if ( empty( $user ) )
return new WP_Error('invalid_key', __('Invalid key'));
- do_action('password_reset', $user);
-
// Generate something random for a password...
$new_pass = wp_generate_password();
+
+ do_action('password_reset', $user, $new_pass);
+
wp_set_password($new_pass, $user->ID);
+ update_usermeta($user->ID, 'default_password_nag', true); //Set up the Password change nag.
$message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
$message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
$message .= site_url('wp-login.php', 'login') . "\r\n";
- if ( !wp_mail($user->user_email, sprintf(__('[%s] Your new password'), get_option('blogname')), $message) )
- die('
' . __('The e-mail could not be sent.') . "
\n" . __('Possible reason: your host may have disabled the mail() function...') . '
');
+ $title = sprintf(__('[%s] Your new password'), get_option('blogname'));
+
+ $title = apply_filters('password_reset_title', $title);
+ $message = apply_filters('password_reset_message', $message, $new_pass);
+
+ if ( $message && !wp_mail($user->user_email, $title, $message) )
+ die('
' . __('The e-mail could not be sent.') . "
\n" . __('Possible reason: your host may have disabled the mail() function...') . '
');
wp_password_change_notification($user);
@@ -244,12 +272,16 @@ function register_new_user($user_login, $user_email) {
// Main
//
-$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
+$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login';
$errors = new WP_Error();
if ( isset($_GET['key']) )
$action = 'resetpass';
+// validate action so as to default to the login screen
+if ( !in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_' . $action) )
+ $action = 'login';
+
nocache_headers();
header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));
@@ -268,6 +300,9 @@ setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);
if ( SITECOOKIEPATH != COOKIEPATH )
setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
+// allow plugins to override the default actions, and to add extra actions if they want
+do_action('login_form_' . $action);
+
$http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
switch ($action) {
@@ -306,10 +341,10 @@ case 'retrievepassword' :
@@ -373,15 +408,16 @@ case 'register' :
@@ -434,7 +470,7 @@ default:
if ( !is_wp_error($user) ) {
// If the user can't edit posts, send them to their profile.
- if ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' ) )
+ if ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) )
$redirect_to = admin_url('profile.php');
wp_safe_redirect($redirect_to);
exit();
@@ -459,24 +495,24 @@ default:
login_header(__('Log In'), '', $errors);
if ( isset($_POST['log']) )
- $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? attribute_escape(stripslashes($_POST['log'])) : '';
+ $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr(stripslashes($_POST['log'])) : '';
?>