2 require( dirname(__FILE__) . '/wp-config.php' );
4 $action = $_REQUEST['action'];
9 header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));
11 if ( defined('RELOCATE') ) { // Move flag is set
12 if ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) )
13 $_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] );
15 $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
16 if ( dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != get_settings('siteurl') )
17 update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) );
25 do_action('wp_logout');
28 $redirect_to = 'wp-login.php';
29 if ( isset($_REQUEST['redirect_to']) )
30 $redirect_to = $_REQUEST['redirect_to'];
32 wp_redirect($redirect_to);
38 do_action('lost_password');
40 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
41 <html xmlns="http://www.w3.org/1999/xhtml">
43 <title>WordPress » <?php _e('Lost Password') ?></title>
44 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
45 <link rel="stylesheet" href="<?php echo get_settings('siteurl'); ?>/wp-admin/wp-admin.css" type="text/css" />
46 <script type="text/javascript">
48 // focus on first input field
49 document.getElementById('user_login').focus();
51 window.onload = focusit;
53 <style type="text/css">
54 #user_login, #email, #submit {
61 <h1><a href="http://wordpress.org/">WordPress</a></h1>
62 <p><?php _e('Please enter your information here. We will send you a new password.') ?></p>
65 echo "<div id='login_error'>$error</div>";
68 <form name="lostpass" action="wp-login.php" method="post" id="lostpass">
70 <input type="hidden" name="action" value="retrievepassword" />
71 <label><?php _e('Username:') ?><br />
72 <input type="text" name="user_login" id="user_login" value="" size="20" tabindex="1" /></label></p>
73 <p><label><?php _e('E-mail:') ?><br />
74 <input type="text" name="email" id="email" value="" size="25" tabindex="2" /></label><br />
76 <p class="submit"><input type="submit" name="submit" id="submit" value="<?php _e('Retrieve Password'); ?> »" tabindex="3" /></p>
79 <li><a href="<?php bloginfo('home'); ?>/" title="<?php _e('Are you lost?') ?>">« <?php _e('Back to blog') ?></a></li>
80 <?php if (get_settings('users_can_register')) : ?>
81 <li><a href="<?php bloginfo('wpurl'); ?>/wp-register.php"><?php _e('Register') ?></a></li>
83 <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li>
91 case 'retrievepassword':
92 $user_data = get_userdatabylogin($_POST['user_login']);
93 // redefining user_login ensures we return the right case in the email
94 $user_login = $user_data->user_login;
95 $user_email = $user_data->user_email;
97 if (!$user_email || $user_email != $_POST['email'])
98 die(sprintf(__('Sorry, that user does not seem to exist in our database. Perhaps you have the wrong username or e-mail address? <a href="%s">Try again</a>.'), 'wp-login.php?action=lostpassword'));
100 do_action('retreive_password', $user_login); // Misspelled and deprecated.
101 do_action('retrieve_password', $user_login);
103 // Generate something random for a password... md5'ing current time with a rand salt
104 $key = substr( md5( uniqid( microtime() ) ), 0, 50);
105 // now insert the new pass md5'd into the db
106 $wpdb->query("UPDATE $wpdb->users SET user_activation_key = '$key' WHERE user_login = '$user_login'");
107 $message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n";
108 $message .= get_option('siteurl') . "\r\n\r\n";
109 $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
110 $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n";
111 $message .= get_settings('siteurl') . "/wp-login.php?action=resetpass&key=$key\r\n";
113 $m = wp_mail($user_email, sprintf(__('[%s] Password Reset'), get_settings('blogname')), $message);
116 echo '<p>' . __('The e-mail could not be sent.') . "<br />\n";
117 echo __('Possible reason: your host may have disabled the mail() function...') . "</p>";
120 echo '<p>' . sprintf(__("The e-mail was sent successfully to %s's e-mail address."), $user_login) . '<br />';
121 echo "<a href='wp-login.php' title='" . __('Check your e-mail first, of course') . "'>" . __('Click here to login!') . '</a></p>';
129 // Generate something random for a password... md5'ing current time with a rand salt
130 $key = preg_replace('/a-z0-9/i', '', $_GET['key']);
132 die( __('Sorry, that key does not appear to be valid.') );
133 $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_activation_key = '$key'");
135 die( __('Sorry, that key does not appear to be valid.') );
137 do_action('password_reset');
139 $new_pass = substr( md5( uniqid( microtime() ) ), 0, 7);
140 $wpdb->query("UPDATE $wpdb->users SET user_pass = MD5('$new_pass'), user_activation_key = '' WHERE user_login = '$user->user_login'");
141 wp_cache_delete($user->ID, 'users');
142 wp_cache_delete($user->user_login, 'userlogins');
143 $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
144 $message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
145 $message .= get_settings('siteurl') . "/wp-login.php\r\n";
147 $m = wp_mail($user->user_email, sprintf(__('[%s] Your new password'), get_settings('blogname')), $message);
150 echo '<p>' . __('The e-mail could not be sent.') . "<br />\n";
151 echo __('Possible reason: your host may have disabled the mail() function...') . '</p>';
154 echo '<p>' . sprintf(__('Your new password is in the mail.'), $user_login) . '<br />';
155 echo "<a href='wp-login.php' title='" . __('Check your e-mail first, of course') . "'>" . __('Click here to login!') . '</a></p>';
156 // send a copy of password change notification to the admin
157 $message = sprintf(__('Password Lost and Changed for user: %s'), $user->user_login) . "\r\n";
158 wp_mail(get_settings('admin_email'), sprintf(__('[%s] Password Lost/Change'), get_settings('blogname')), $message);
168 $using_cookie = false;
169 if ( !isset( $_REQUEST['redirect_to'] ) )
170 $redirect_to = 'wp-admin/';
172 $redirect_to = $_REQUEST['redirect_to'];
175 $user_login = $_POST['log'];
176 $user_login = sanitize_user( $user_login );
177 $user_pass = $_POST['pwd'];
178 $rememberme = $_POST['rememberme'];
180 $cookie_login = wp_get_cookie_login();
181 if ( ! empty($cookie_login) ) {
182 $using_cookie = true;
183 $user_login = $cookie_login['login'];
184 $user_pass = $cookie_login['password'];
188 do_action('wp_authenticate', array(&$user_login, &$user_pass));
190 if ( $user_login && $user_pass ) {
191 $user = new WP_User(0, $user_login);
193 // If the user can't edit posts, send them to their profile.
194 if ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' ) )
195 $redirect_to = get_settings('siteurl') . '/wp-admin/profile.php';
197 if ( wp_login($user_login, $user_pass, $using_cookie) ) {
198 if ( !$using_cookie )
199 wp_setcookie($user_login, $user_pass, false, '', '', $rememberme);
200 do_action('wp_login', $user_login);
201 wp_redirect($redirect_to);
205 $error = __('Your session has expired.');
207 } else if ( $user_login || $user_pass ) {
208 $error = __('<strong>Error</strong>: The password field is empty.');
211 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
212 <html xmlns="http://www.w3.org/1999/xhtml">
214 <title>WordPress › <?php _e('Login') ?></title>
215 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
216 <link rel="stylesheet" href="<?php bloginfo('wpurl'); ?>/wp-admin/wp-admin.css" type="text/css" />
217 <script type="text/javascript">
219 document.getElementById('log').focus();
221 window.onload = focusit;
227 <h1><a href="http://wordpress.org/">WordPress</a></h1>
230 echo "<div id='login_error'>$error</div>";
233 <form name="loginform" id="loginform" action="wp-login.php" method="post">
234 <p><label><?php _e('Username:') ?><br /><input type="text" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1); ?>" size="20" tabindex="1" /></label></p>
235 <p><label><?php _e('Password:') ?><br /> <input type="password" name="pwd" id="pwd" value="" size="20" tabindex="2" /></label></p>
237 <label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="3" />
238 <?php _e('Remember me'); ?></label></p>
240 <input type="submit" name="submit" id="submit" value="<?php _e('Login'); ?> »" tabindex="4" />
241 <input type="hidden" name="redirect_to" value="<?php echo wp_specialchars($redirect_to); ?>" />
245 <li><a href="<?php bloginfo('home'); ?>/" title="<?php _e('Are you lost?') ?>">« <?php _e('Back to blog') ?></a></li>
246 <?php if (get_settings('users_can_register')) : ?>
247 <li><a href="<?php bloginfo('wpurl'); ?>/wp-register.php"><?php _e('Register') ?></a></li>
249 <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=lostpassword" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a></li>
258 } // end action switch