wp/wp-activate.php
changeset 0 d970ebf37754
child 5 5e2f62d02dcd
equal deleted inserted replaced
-1:000000000000 0:d970ebf37754
       
     1 <?php
       
     2 /**
       
     3  * Confirms that the activation key that is sent in an email after a user signs
       
     4  * up for a new blog matches the key for that user and then displays confirmation.
       
     5  *
       
     6  * @package WordPress
       
     7  */
       
     8 
       
     9 define( 'WP_INSTALLING', true );
       
    10 
       
    11 /** Sets up the WordPress Environment. */
       
    12 require( dirname(__FILE__) . '/wp-load.php' );
       
    13 
       
    14 require( dirname( __FILE__ ) . '/wp-blog-header.php' );
       
    15 
       
    16 if ( !is_multisite() ) {
       
    17 	wp_redirect( site_url( '/wp-login.php?action=register' ) );
       
    18 	die();
       
    19 }
       
    20 
       
    21 if ( is_object( $wp_object_cache ) )
       
    22 	$wp_object_cache->cache_enabled = false;
       
    23 
       
    24 // Fix for page title
       
    25 $wp_query->is_404 = false;
       
    26 
       
    27 /**
       
    28  * Fires before the Site Activation page is loaded.
       
    29  *
       
    30  * @since 3.0
       
    31  */
       
    32 do_action( 'activate_header' );
       
    33 
       
    34 /**
       
    35  * Adds an action hook specific to this page that fires on wp_head
       
    36  *
       
    37  * @since MU
       
    38  */
       
    39 function do_activate_header() {
       
    40     /**
       
    41      * Fires before the Site Activation page is loaded, but on the wp_head action.
       
    42      *
       
    43      * @since 3.0
       
    44      */
       
    45     do_action( 'activate_wp_head' );
       
    46 }
       
    47 add_action( 'wp_head', 'do_activate_header' );
       
    48 
       
    49 /**
       
    50  * Loads styles specific to this page.
       
    51  *
       
    52  * @since MU
       
    53  */
       
    54 function wpmu_activate_stylesheet() {
       
    55 	?>
       
    56 	<style type="text/css">
       
    57 		form { margin-top: 2em; }
       
    58 		#submit, #key { width: 90%; font-size: 24px; }
       
    59 		#language { margin-top: .5em; }
       
    60 		.error { background: #f66; }
       
    61 		span.h3 { padding: 0 8px; font-size: 1.3em; font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; font-weight: bold; color: #333; }
       
    62 	</style>
       
    63 	<?php
       
    64 }
       
    65 add_action( 'wp_head', 'wpmu_activate_stylesheet' );
       
    66 
       
    67 get_header();
       
    68 ?>
       
    69 
       
    70 <div id="content" class="widecolumn">
       
    71 	<?php if ( empty($_GET['key']) && empty($_POST['key']) ) { ?>
       
    72 
       
    73 		<h2><?php _e('Activation Key Required') ?></h2>
       
    74 		<form name="activateform" id="activateform" method="post" action="<?php echo network_site_url('wp-activate.php'); ?>">
       
    75 			<p>
       
    76 			    <label for="key"><?php _e('Activation Key:') ?></label>
       
    77 			    <br /><input type="text" name="key" id="key" value="" size="50" />
       
    78 			</p>
       
    79 			<p class="submit">
       
    80 			    <input id="submit" type="submit" name="Submit" class="submit" value="<?php esc_attr_e('Activate') ?>" />
       
    81 			</p>
       
    82 		</form>
       
    83 
       
    84 	<?php } else {
       
    85 
       
    86 		$key = !empty($_GET['key']) ? $_GET['key'] : $_POST['key'];
       
    87 		$result = wpmu_activate_signup($key);
       
    88 		if ( is_wp_error($result) ) {
       
    89 			if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
       
    90 			    $signup = $result->get_error_data();
       
    91 				?>
       
    92 				<h2><?php _e('Your account is now active!'); ?></h2>
       
    93 				<?php
       
    94 				echo '<p class="lead-in">';
       
    95 				if ( $signup->domain . $signup->path == '' ) {
       
    96 					printf( __('Your account has been activated. You may now <a href="%1$s">log in</a> to the site using your chosen username of &#8220;%2$s&#8221;. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.'), network_site_url( 'wp-login.php', 'login' ), $signup->user_login, $signup->user_email, wp_lostpassword_url() );
       
    97 				} else {
       
    98 					printf( __('Your site at <a href="%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of &#8220;%3$s&#8221;. Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, wp_lostpassword_url() );
       
    99 				}
       
   100 				echo '</p>';
       
   101 			} else {
       
   102 				?>
       
   103 				<h2><?php _e('An error occurred during the activation'); ?></h2>
       
   104 				<?php
       
   105 			    echo '<p>'.$result->get_error_message().'</p>';
       
   106 			}
       
   107 		} else {
       
   108 			extract($result);
       
   109 			$url = get_blogaddress_by_id( (int) $blog_id);
       
   110 			$user = get_userdata( (int) $user_id);
       
   111 			?>
       
   112 			<h2><?php _e('Your account is now active!'); ?></h2>
       
   113 
       
   114 			<div id="signup-welcome">
       
   115 				<p><span class="h3"><?php _e('Username:'); ?></span> <?php echo $user->user_login ?></p>
       
   116 				<p><span class="h3"><?php _e('Password:'); ?></span> <?php echo $password; ?></p>
       
   117 			</div>
       
   118 
       
   119 			<?php if ( $url != network_home_url('', 'http') ) : ?>
       
   120 				<p class="view"><?php printf( __('Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>'), $url, $url . 'wp-login.php' ); ?></p>
       
   121 			<?php else: ?>
       
   122 				<p class="view"><?php printf( __('Your account is now activated. <a href="%1$s">Log in</a> or go back to the <a href="%2$s">homepage</a>.' ), network_site_url('wp-login.php', 'login'), network_home_url() ); ?></p>
       
   123 			<?php endif;
       
   124 		}
       
   125 	}
       
   126 	?>
       
   127 </div>
       
   128 <script type="text/javascript">
       
   129 	var key_input = document.getElementById('key');
       
   130 	key_input && key_input.focus();
       
   131 </script>
       
   132 <?php get_footer(); ?>