raw
mp-wp_genesis           1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * WordPress User Page
mp-wp_genesis 4 *
mp-wp_genesis 5 * Handles authentication, registering, resetting passwords, forgot password,
mp-wp_genesis 6 * and other user handling.
mp-wp_genesis 7 *
mp-wp_genesis 8 * @package WordPress
mp-wp_genesis 9 */
mp-wp_genesis 10
mp-wp_genesis 11 /** Make sure that the WordPress bootstrap has ran before continuing. */
mp-wp_genesis 12 require( dirname(__FILE__) . '/wp-load.php' );
mp-wp_genesis 13
mp-wp_genesis 14 // Redirect to https login if forced to use SSL
mp-wp_genesis 15 if ( force_ssl_admin() && !is_ssl() ) {
mp-wp_genesis 16 if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
mp-wp_genesis 17 wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
mp-wp_genesis 18 exit();
mp-wp_genesis 19 } else {
mp-wp_genesis 20 wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
mp-wp_genesis 21 exit();
mp-wp_genesis 22 }
mp-wp_genesis 23 }
mp-wp_genesis 24
mp-wp_genesis 25 /**
mp-wp_genesis 26 * Outputs the header for the login page.
mp-wp_genesis 27 *
mp-wp_genesis 28 * @uses do_action() Calls the 'login_head' for outputting HTML in the Log In
mp-wp_genesis 29 * header.
mp-wp_genesis 30 * @uses apply_filters() Calls 'login_headerurl' for the top login link.
mp-wp_genesis 31 * @uses apply_filters() Calls 'login_headertitle' for the top login title.
mp-wp_genesis 32 * @uses apply_filters() Calls 'login_message' on the message to display in the
mp-wp_genesis 33 * header.
mp-wp_genesis 34 * @uses $error The error global, which is checked for displaying errors.
mp-wp_genesis 35 *
mp-wp_genesis 36 * @param string $title Optional. WordPress Log In Page title to display in
mp-wp_genesis 37 * <title/> element.
mp-wp_genesis 38 * @param string $message Optional. Message to display in header.
mp-wp_genesis 39 * @param WP_Error $wp_error Optional. WordPress Error Object
mp-wp_genesis 40 */
mp-wp_genesis 41 function login_header($title = 'Log In', $message = '', $wp_error = '') {
mp-wp_genesis 42 global $error;
mp-wp_genesis 43
mp-wp_genesis 44 if ( empty($wp_error) )
mp-wp_genesis 45 $wp_error = new WP_Error();
mp-wp_genesis 46 ?>
mp-wp_genesis 47 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
mp-wp_genesis 48 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
mp-wp_genesis 49 <head>
mp-wp_genesis 50 <title><?php bloginfo('name'); ?> &rsaquo; <?php echo $title; ?></title>
mp-wp_genesis 51 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
mp-wp_genesis 52 <?php
mp-wp_genesis 53 wp_admin_css( 'login', true );
mp-wp_genesis 54 wp_admin_css( 'colors-fresh', true );
mp-wp_genesis 55 do_action('login_head'); ?>
mp-wp_genesis 56 </head>
mp-wp_genesis 57 <body class="login">
mp-wp_genesis 58
mp-wp_remove-all-... 59 <div id="login"><h1>MP-WP</h1>
mp-wp_genesis 60 <?php
mp-wp_genesis 61 if ( !empty( $message ) ) echo apply_filters('login_message', $message) . "\n";
mp-wp_genesis 62
mp-wp_genesis 63 // Incase a plugin uses $error rather than the $errors object
mp-wp_genesis 64 if ( !empty( $error ) ) {
mp-wp_genesis 65 $wp_error->add('error', $error);
mp-wp_genesis 66 unset($error);
mp-wp_genesis 67 }
mp-wp_genesis 68
mp-wp_genesis 69 if ( $wp_error->get_error_code() ) {
mp-wp_genesis 70 $errors = '';
mp-wp_genesis 71 $messages = '';
mp-wp_genesis 72 foreach ( $wp_error->get_error_codes() as $code ) {
mp-wp_genesis 73 $severity = $wp_error->get_error_data($code);
mp-wp_genesis 74 foreach ( $wp_error->get_error_messages($code) as $error ) {
mp-wp_genesis 75 if ( 'message' == $severity )
mp-wp_genesis 76 $messages .= ' ' . $error . "<br />\n";
mp-wp_genesis 77 else
mp-wp_genesis 78 $errors .= ' ' . $error . "<br />\n";
mp-wp_genesis 79 }
mp-wp_genesis 80 }
mp-wp_genesis 81 if ( !empty($errors) )
mp-wp_genesis 82 echo '<div id="login_error">' . apply_filters('login_errors', $errors) . "</div>\n";
mp-wp_genesis 83 if ( !empty($messages) )
mp-wp_genesis 84 echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
mp-wp_genesis 85 }
mp-wp_genesis 86 } // End of login_header()
mp-wp_genesis 87
mp-wp_genesis 88 /**
mp-wp_genesis 89 * Handles sending password retrieval email to user.
mp-wp_genesis 90 *
mp-wp_genesis 91 * @uses $wpdb WordPress Database object
mp-wp_genesis 92 *
mp-wp_genesis 93 * @return bool|WP_Error True: when finish. WP_Error on error
mp-wp_genesis 94 */
mp-wp_genesis 95 function retrieve_password() {
mp-wp_genesis 96 global $wpdb;
mp-wp_genesis 97
mp-wp_genesis 98 $errors = new WP_Error();
mp-wp_genesis 99
mp-wp_genesis 100 if ( empty( $_POST['user_login'] ) && empty( $_POST['user_email'] ) )
mp-wp_genesis 101 $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.'));
mp-wp_genesis 102
mp-wp_genesis 103 if ( strpos($_POST['user_login'], '@') ) {
mp-wp_genesis 104 $user_data = get_user_by_email(trim($_POST['user_login']));
mp-wp_genesis 105 if ( empty($user_data) )
mp-wp_genesis 106 $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
mp-wp_genesis 107 } else {
mp-wp_genesis 108 $login = trim($_POST['user_login']);
mp-wp_genesis 109 $user_data = get_userdatabylogin($login);
mp-wp_genesis 110 }
mp-wp_genesis 111
mp-wp_genesis 112 do_action('lostpassword_post');
mp-wp_genesis 113
mp-wp_genesis 114 if ( $errors->get_error_code() )
mp-wp_genesis 115 return $errors;
mp-wp_genesis 116
mp-wp_genesis 117 if ( !$user_data ) {
mp-wp_genesis 118 $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.'));
mp-wp_genesis 119 return $errors;
mp-wp_genesis 120 }
mp-wp_genesis 121
mp-wp_genesis 122 // redefining user_login ensures we return the right case in the email
mp-wp_genesis 123 $user_login = $user_data->user_login;
mp-wp_genesis 124 $user_email = $user_data->user_email;
mp-wp_genesis 125
mp-wp_genesis 126 do_action('retreive_password', $user_login); // Misspelled and deprecated
mp-wp_genesis 127 do_action('retrieve_password', $user_login);
mp-wp_genesis 128
mp-wp_genesis 129 $allow = apply_filters('allow_password_reset', true, $user_data->ID);
mp-wp_genesis 130
mp-wp_genesis 131 if ( ! $allow )
mp-wp_genesis 132 return new WP_Error('no_password_reset', __('Password reset is not allowed for this user'));
mp-wp_genesis 133 else if ( is_wp_error($allow) )
mp-wp_genesis 134 return $allow;
mp-wp_genesis 135
mp-wp_genesis 136 $key = $wpdb->get_var($wpdb->prepare("SELECT user_activation_key FROM $wpdb->users WHERE user_login = %s", $user_login));
mp-wp_genesis 137 if ( empty($key) ) {
mp-wp_genesis 138 // Generate something random for a key...
mp-wp_genesis 139 $key = wp_generate_password(20, false);
mp-wp_genesis 140 do_action('retrieve_password_key', $user_login, $key);
mp-wp_genesis 141 // Now insert the new md5 key into the db
mp-wp_genesis 142 $wpdb->query($wpdb->prepare("UPDATE $wpdb->users SET user_activation_key = %s WHERE user_login = %s", $key, $user_login));
mp-wp_genesis 143 }
mp-wp_genesis 144 $message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n";
mp-wp_genesis 145 $message .= get_option('siteurl') . "\r\n\r\n";
mp-wp_genesis 146 $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
mp-wp_genesis 147 $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n";
mp-wp_genesis 148 $message .= site_url("wp-login.php?action=rp&key=$key", 'login') . "\r\n";
mp-wp_genesis 149
mp-wp_genesis 150 if ( !wp_mail($user_email, sprintf(__('[%s] Password Reset'), get_option('blogname')), $message) )
mp-wp_genesis 151 die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
mp-wp_genesis 152
mp-wp_genesis 153 return true;
mp-wp_genesis 154 }
mp-wp_genesis 155
mp-wp_genesis 156 /**
mp-wp_genesis 157 * Handles resetting the user's password.
mp-wp_genesis 158 *
mp-wp_genesis 159 * @uses $wpdb WordPress Database object
mp-wp_genesis 160 *
mp-wp_genesis 161 * @param string $key Hash to validate sending user's password
mp-wp_genesis 162 * @return bool|WP_Error
mp-wp_genesis 163 */
mp-wp_genesis 164 function reset_password($key) {
mp-wp_genesis 165 global $wpdb;
mp-wp_genesis 166
mp-wp_genesis 167 $key = preg_replace('/[^a-z0-9]/i', '', $key);
mp-wp_genesis 168
mp-wp_genesis 169 if ( empty( $key ) )
mp-wp_genesis 170 return new WP_Error('invalid_key', __('Invalid key'));
mp-wp_genesis 171
mp-wp_genesis 172 $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s", $key));
mp-wp_genesis 173 if ( empty( $user ) )
mp-wp_genesis 174 return new WP_Error('invalid_key', __('Invalid key'));
mp-wp_genesis 175
mp-wp_genesis 176 do_action('password_reset', $user);
mp-wp_genesis 177
mp-wp_genesis 178 // Generate something random for a password...
mp-wp_genesis 179 $new_pass = wp_generate_password();
mp-wp_genesis 180 wp_set_password($new_pass, $user->ID);
mp-wp_genesis 181 $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
mp-wp_genesis 182 $message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
mp-wp_genesis 183 $message .= site_url('wp-login.php', 'login') . "\r\n";
mp-wp_genesis 184
mp-wp_genesis 185 if ( !wp_mail($user->user_email, sprintf(__('[%s] Your new password'), get_option('blogname')), $message) )
mp-wp_genesis 186 die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
mp-wp_genesis 187
mp-wp_genesis 188 wp_password_change_notification($user);
mp-wp_genesis 189
mp-wp_genesis 190 return true;
mp-wp_genesis 191 }
mp-wp_genesis 192
mp-wp_genesis 193 /**
mp-wp_genesis 194 * Handles registering a new user.
mp-wp_genesis 195 *
mp-wp_genesis 196 * @param string $user_login User's username for logging in
mp-wp_genesis 197 * @param string $user_email User's email address to send password and add
mp-wp_genesis 198 * @return int|WP_Error Either user's ID or error on failure.
mp-wp_genesis 199 */
mp-wp_genesis 200 function register_new_user($user_login, $user_email) {
mp-wp_genesis 201 $errors = new WP_Error();
mp-wp_genesis 202
mp-wp_genesis 203 $user_login = sanitize_user( $user_login );
mp-wp_genesis 204 $user_email = apply_filters( 'user_registration_email', $user_email );
mp-wp_genesis 205
mp-wp_genesis 206 // Check the username
mp-wp_genesis 207 if ( $user_login == '' )
mp-wp_genesis 208 $errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.'));
mp-wp_genesis 209 elseif ( !validate_username( $user_login ) ) {
mp-wp_genesis 210 $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.'));
mp-wp_genesis 211 $user_login = '';
mp-wp_genesis 212 } elseif ( username_exists( $user_login ) )
mp-wp_genesis 213 $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.'));
mp-wp_genesis 214
mp-wp_genesis 215 // Check the e-mail address
mp-wp_genesis 216 if ($user_email == '') {
mp-wp_genesis 217 $errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.'));
mp-wp_genesis 218 } elseif ( !is_email( $user_email ) ) {
mp-wp_genesis 219 $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn&#8217;t correct.'));
mp-wp_genesis 220 $user_email = '';
mp-wp_genesis 221 } elseif ( email_exists( $user_email ) )
mp-wp_genesis 222 $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'));
mp-wp_genesis 223
mp-wp_genesis 224 do_action('register_post', $user_login, $user_email, $errors);
mp-wp_genesis 225
mp-wp_genesis 226 $errors = apply_filters( 'registration_errors', $errors );
mp-wp_genesis 227
mp-wp_genesis 228 if ( $errors->get_error_code() )
mp-wp_genesis 229 return $errors;
mp-wp_genesis 230
mp-wp_genesis 231 $user_pass = wp_generate_password();
mp-wp_genesis 232 $user_id = wp_create_user( $user_login, $user_pass, $user_email );
mp-wp_genesis 233 if ( !$user_id ) {
mp-wp_genesis 234 $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')));
mp-wp_genesis 235 return $errors;
mp-wp_genesis 236 }
mp-wp_genesis 237
mp-wp_genesis 238 wp_new_user_notification($user_id, $user_pass);
mp-wp_genesis 239
mp-wp_genesis 240 return $user_id;
mp-wp_genesis 241 }
mp-wp_genesis 242
mp-wp_genesis 243 //
mp-wp_genesis 244 // Main
mp-wp_genesis 245 //
mp-wp_genesis 246
mp-wp_genesis 247 $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
mp-wp_genesis 248 $errors = new WP_Error();
mp-wp_genesis 249
mp-wp_genesis 250 if ( isset($_GET['key']) )
mp-wp_genesis 251 $action = 'resetpass';
mp-wp_genesis 252
mp-wp_genesis 253 nocache_headers();
mp-wp_genesis 254
mp-wp_genesis 255 header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));
mp-wp_genesis 256
mp-wp_genesis 257 if ( defined('RELOCATE') ) { // Move flag is set
mp-wp_genesis 258 if ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) )
mp-wp_genesis 259 $_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] );
mp-wp_genesis 260
mp-wp_genesis 261 $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
mp-wp_genesis 262 if ( dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != get_option('siteurl') )
mp-wp_genesis 263 update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) );
mp-wp_genesis 264 }
mp-wp_genesis 265
mp-wp_genesis 266 //Set a cookie now to see if they are supported by the browser.
mp-wp_genesis 267 setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);
mp-wp_genesis 268 if ( SITECOOKIEPATH != COOKIEPATH )
mp-wp_genesis 269 setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
mp-wp_genesis 270
mp-wp_genesis 271 $http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
mp-wp_genesis 272 switch ($action) {
mp-wp_genesis 273
mp-wp_genesis 274 case 'logout' :
mp-wp_genesis 275 check_admin_referer('log-out');
mp-wp_genesis 276 wp_logout();
mp-wp_genesis 277
mp-wp_genesis 278 $redirect_to = 'wp-login.php?loggedout=true';
mp-wp_genesis 279 if ( isset( $_REQUEST['redirect_to'] ) )
mp-wp_genesis 280 $redirect_to = $_REQUEST['redirect_to'];
mp-wp_genesis 281
mp-wp_genesis 282 wp_safe_redirect($redirect_to);
mp-wp_genesis 283 exit();
mp-wp_genesis 284
mp-wp_genesis 285 break;
mp-wp_genesis 286
mp-wp_genesis 287 case 'lostpassword' :
mp-wp_genesis 288 case 'retrievepassword' :
mp-wp_genesis 289 if ( $http_post ) {
mp-wp_genesis 290 $errors = retrieve_password();
mp-wp_genesis 291 if ( !is_wp_error($errors) ) {
mp-wp_genesis 292 wp_redirect('wp-login.php?checkemail=confirm');
mp-wp_genesis 293 exit();
mp-wp_genesis 294 }
mp-wp_genesis 295 }
mp-wp_genesis 296
mp-wp_genesis 297 if ( isset($_GET['error']) && 'invalidkey' == $_GET['error'] ) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.'));
mp-wp_genesis 298
mp-wp_genesis 299 do_action('lost_password');
mp-wp_genesis 300 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);
mp-wp_genesis 301
mp-wp_genesis 302 $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : '';
mp-wp_genesis 303
mp-wp_genesis 304 ?>
mp-wp_genesis 305
mp-wp_genesis 306 <form name="lostpasswordform" id="lostpasswordform" action="<?php echo site_url('wp-login.php?action=lostpassword', 'login_post') ?>" method="post">
mp-wp_genesis 307 <p>
mp-wp_genesis 308 <label><?php _e('Username or E-mail:') ?><br />
mp-wp_genesis 309 <input type="text" name="user_login" id="user_login" class="input" value="<?php echo attribute_escape($user_login); ?>" size="20" tabindex="10" /></label>
mp-wp_genesis 310 </p>
mp-wp_genesis 311 <?php do_action('lostpassword_form'); ?>
mp-wp_remove-all-... 312 <p class="submit"><input type="submit" name="wp-submit" class="button-primary" id="wp-submit" value="<?php _e('Get New Password'); ?>" tabindex="100" /></p>
mp-wp_genesis 313 </form>
mp-wp_genesis 314
mp-wp_genesis 315 <p id="nav">
mp-wp_genesis 316 <?php if (get_option('users_can_register')) : ?>
mp-wp_genesis 317 <a href="<?php echo site_url('wp-login.php', 'login') ?>"><?php _e('Log in') ?></a> |
mp-wp_genesis 318 <a href="<?php echo site_url('wp-login.php?action=register', 'login') ?>"><?php _e('Register') ?></a>
mp-wp_genesis 319 <?php else : ?>
mp-wp_genesis 320 <a href="<?php echo site_url('wp-login.php', 'login') ?>"><?php _e('Log in') ?></a>
mp-wp_genesis 321 <?php endif; ?>
mp-wp_genesis 322 </p>
mp-wp_genesis 323
mp-wp_genesis 324 </div>
mp-wp_genesis 325
mp-wp_genesis 326 <p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('&larr; Back to %s'), get_bloginfo('title', 'display' )); ?></a></p>
mp-wp_genesis 327
mp-wp_genesis 328 </body>
mp-wp_genesis 329 </html>
mp-wp_genesis 330 <?php
mp-wp_genesis 331 break;
mp-wp_genesis 332
mp-wp_genesis 333 case 'resetpass' :
mp-wp_genesis 334 case 'rp' :
mp-wp_genesis 335 $errors = reset_password($_GET['key']);
mp-wp_genesis 336
mp-wp_genesis 337 if ( ! is_wp_error($errors) ) {
mp-wp_genesis 338 wp_redirect('wp-login.php?checkemail=newpass');
mp-wp_genesis 339 exit();
mp-wp_genesis 340 }
mp-wp_genesis 341
mp-wp_genesis 342 wp_redirect('wp-login.php?action=lostpassword&error=invalidkey');
mp-wp_genesis 343 exit();
mp-wp_genesis 344
mp-wp_genesis 345 break;
mp-wp_genesis 346
mp-wp_genesis 347 case 'register' :
mp-wp_genesis 348 if ( !get_option('users_can_register') ) {
mp-wp_genesis 349 wp_redirect('wp-login.php?registration=disabled');
mp-wp_genesis 350 exit();
mp-wp_genesis 351 }
mp-wp_genesis 352
mp-wp_genesis 353 $user_login = '';
mp-wp_genesis 354 $user_email = '';
mp-wp_genesis 355 if ( $http_post ) {
mp-wp_genesis 356 require_once( ABSPATH . WPINC . '/registration.php');
mp-wp_genesis 357
mp-wp_genesis 358 $user_login = $_POST['user_login'];
mp-wp_genesis 359 $user_email = $_POST['user_email'];
mp-wp_genesis 360 $errors = register_new_user($user_login, $user_email);
mp-wp_genesis 361 if ( !is_wp_error($errors) ) {
mp-wp_genesis 362 wp_redirect('wp-login.php?checkemail=registered');
mp-wp_genesis 363 exit();
mp-wp_genesis 364 }
mp-wp_genesis 365 }
mp-wp_genesis 366
mp-wp_genesis 367 login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>', $errors);
mp-wp_genesis 368 ?>
mp-wp_genesis 369
mp-wp_genesis 370 <form name="registerform" id="registerform" action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post">
mp-wp_genesis 371 <p>
mp-wp_genesis 372 <label><?php _e('Username') ?><br />
mp-wp_genesis 373 <input type="text" name="user_login" id="user_login" class="input" value="<?php echo attribute_escape(stripslashes($user_login)); ?>" size="20" tabindex="10" /></label>
mp-wp_genesis 374 </p>
mp-wp_genesis 375 <p>
mp-wp_genesis 376 <label><?php _e('E-mail') ?><br />
mp-wp_genesis 377 <input type="text" name="user_email" id="user_email" class="input" value="<?php echo attribute_escape(stripslashes($user_email)); ?>" size="25" tabindex="20" /></label>
mp-wp_genesis 378 </p>
mp-wp_genesis 379 <?php do_action('register_form'); ?>
mp-wp_genesis 380 <p id="reg_passmail"><?php _e('A password will be e-mailed to you.') ?></p>
mp-wp_remove-all-... 381 <p class="submit"><input type="submit" name="wp-submit" class="button-primary" id="wp-submit" value="<?php _e('Register'); ?>" tabindex="100" /></p>
mp-wp_genesis 382 </form>
mp-wp_genesis 383
mp-wp_genesis 384 <p id="nav">
mp-wp_genesis 385 <a href="<?php echo site_url('wp-login.php', 'login') ?>"><?php _e('Log in') ?></a> |
mp-wp_genesis 386 <a href="<?php echo site_url('wp-login.php?action=lostpassword', 'login') ?>" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a>
mp-wp_genesis 387 </p>
mp-wp_genesis 388
mp-wp_genesis 389 </div>
mp-wp_genesis 390
mp-wp_genesis 391 <p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('&larr; Back to %s'), get_bloginfo('title', 'display' )); ?></a></p>
mp-wp_genesis 392
mp-wp_genesis 393 </body>
mp-wp_genesis 394 </html>
mp-wp_genesis 395 <?php
mp-wp_genesis 396 break;
mp-wp_genesis 397
mp-wp_genesis 398 case 'login' :
mp-wp_genesis 399 default:
mp-wp_genesis 400 $secure_cookie = '';
mp-wp_genesis 401
mp-wp_genesis 402 // If the user wants ssl but the session is not ssl, force a secure cookie.
mp-wp_genesis 403 if ( !empty($_POST['log']) && !force_ssl_admin() ) {
mp-wp_genesis 404 $user_name = sanitize_user($_POST['log']);
mp-wp_genesis 405 if ( $user = get_userdatabylogin($user_name) ) {
mp-wp_genesis 406 if ( get_user_option('use_ssl', $user->ID) ) {
mp-wp_genesis 407 $secure_cookie = true;
mp-wp_genesis 408 force_ssl_admin(true);
mp-wp_genesis 409 }
mp-wp_genesis 410 }
mp-wp_genesis 411 }
mp-wp_genesis 412
mp-wp_genesis 413 if ( isset( $_REQUEST['redirect_to'] ) ) {
mp-wp_genesis 414 $redirect_to = $_REQUEST['redirect_to'];
mp-wp_genesis 415 // Redirect to https if user wants ssl
mp-wp_genesis 416 if ( $secure_cookie && false !== strpos($redirect_to, 'wp-admin') )
mp-wp_genesis 417 $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
mp-wp_genesis 418 } else {
mp-wp_genesis 419 $redirect_to = admin_url();
mp-wp_genesis 420 }
mp-wp_genesis 421
mp-wp_genesis 422 if ( !$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos($redirect_to, 'https') ) && ( 0 === strpos($redirect_to, 'http') ) )
mp-wp_genesis 423 $secure_cookie = false;
mp-wp_genesis 424
mp-wp_genesis 425 $user = wp_signon('', $secure_cookie);
mp-wp_genesis 426
mp-wp_genesis 427 $redirect_to = apply_filters('login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user);
mp-wp_genesis 428
mp-wp_genesis 429 if ( !is_wp_error($user) ) {
mp-wp_genesis 430 // If the user can't edit posts, send them to their profile.
mp-wp_genesis 431 if ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' ) )
mp-wp_genesis 432 $redirect_to = admin_url('profile.php');
mp-wp_genesis 433 wp_safe_redirect($redirect_to);
mp-wp_genesis 434 exit();
mp-wp_genesis 435 }
mp-wp_genesis 436
mp-wp_genesis 437 $errors = $user;
mp-wp_genesis 438 // Clear errors if loggedout is set.
mp-wp_genesis 439 if ( !empty($_GET['loggedout']) )
mp-wp_genesis 440 $errors = new WP_Error();
mp-wp_genesis 441
mp-wp_genesis 442 // If cookies are disabled we can't log in even with a valid user+pass
mp-wp_genesis 443 if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) )
mp-wp_genesis 444 $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."));
mp-wp_genesis 445
mp-wp_genesis 446 // Some parts of this script use the main login form to display a message
mp-wp_genesis 447 if ( isset($_GET['loggedout']) && TRUE == $_GET['loggedout'] ) $errors->add('loggedout', __('You are now logged out.'), 'message');
mp-wp_genesis 448 elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] ) $errors->add('registerdisabled', __('User registration is currently not allowed.'));
mp-wp_genesis 449 elseif ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] ) $errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message');
mp-wp_genesis 450 elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] ) $errors->add('newpass', __('Check your e-mail for your new password.'), 'message');
mp-wp_genesis 451 elseif ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message');
mp-wp_genesis 452
mp-wp_genesis 453 login_header(__('Log In'), '', $errors);
mp-wp_genesis 454
mp-wp_genesis 455 if ( isset($_POST['log']) )
mp-wp_genesis 456 $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? attribute_escape(stripslashes($_POST['log'])) : '';
mp-wp_genesis 457 ?>
mp-wp_genesis 458
mp-wp_genesis 459 <?php if ( !isset($_GET['checkemail']) || !in_array( $_GET['checkemail'], array('confirm', 'newpass') ) ) : ?>
mp-wp_genesis 460 <form name="loginform" id="loginform" action="<?php echo site_url('wp-login.php', 'login_post') ?>" method="post">
mp-wp_genesis 461 <p>
mp-wp_genesis 462 <label><?php _e('Username') ?><br />
mp-wp_genesis 463 <input type="text" name="log" id="user_login" class="input" value="<?php echo $user_login; ?>" size="20" tabindex="10" /></label>
mp-wp_genesis 464 </p>
mp-wp_genesis 465 <p>
mp-wp_genesis 466 <label><?php _e('Password') ?><br />
mp-wp_genesis 467 <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" tabindex="20" /></label>
mp-wp_genesis 468 </p>
mp-wp_genesis 469 <?php do_action('login_form'); ?>
mp-wp_genesis 470 <p class="forgetmenot"><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90" /> <?php _e('Remember Me'); ?></label></p>
mp-wp_genesis 471 <p class="submit">
mp-wp_remove-all-... 472 <input type="submit" name="wp-submit" class="button-primary" id="wp-submit" value="<?php _e('Log In'); ?>" tabindex="100" />
mp-wp_genesis 473 <input type="hidden" name="redirect_to" value="<?php echo attribute_escape($redirect_to); ?>" />
mp-wp_genesis 474 <input type="hidden" name="testcookie" value="1" />
mp-wp_genesis 475 </p>
mp-wp_genesis 476 </form>
mp-wp_genesis 477 <?php endif; ?>
mp-wp_genesis 478
mp-wp_genesis 479 <p id="nav">
mp-wp_genesis 480 <?php if ( isset($_GET['checkemail']) && in_array( $_GET['checkemail'], array('confirm', 'newpass') ) ) : ?>
mp-wp_genesis 481 <?php elseif (get_option('users_can_register')) : ?>
mp-wp_genesis 482 <a href="<?php echo site_url('wp-login.php?action=register', 'login') ?>"><?php _e('Register') ?></a> |
mp-wp_genesis 483 <a href="<?php echo site_url('wp-login.php?action=lostpassword', 'login') ?>" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a>
mp-wp_genesis 484 <?php else : ?>
mp-wp_genesis 485 <a href="<?php echo site_url('wp-login.php?action=lostpassword', 'login') ?>" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a>
mp-wp_genesis 486 <?php endif; ?>
mp-wp_genesis 487 </p>
mp-wp_genesis 488
mp-wp_genesis 489 </div>
mp-wp_genesis 490
mp-wp_genesis 491 <p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('&larr; Back to %s'), get_bloginfo('title', 'display' )); ?></a></p>
mp-wp_genesis 492
mp-wp_genesis 493 </body>
mp-wp_genesis 494 </html>
mp-wp_genesis 495 <?php
mp-wp_genesis 496
mp-wp_genesis 497 break;
mp-wp_genesis 498 } // end action switch
mp-wp_genesis 499 ?>