wp/wp-activate.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
     1 <?php
     1 <?php
     2 /**
     2 /**
     3  * Confirms that the activation key that is sent in an email after a user signs
     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.
     4  * up for a new site matches the key for that user and then displays confirmation.
     5  *
     5  *
     6  * @package WordPress
     6  * @package WordPress
     7  */
     7  */
     8 
     8 
     9 define( 'WP_INSTALLING', true );
     9 define( 'WP_INSTALLING', true );
    12 require( dirname(__FILE__) . '/wp-load.php' );
    12 require( dirname(__FILE__) . '/wp-load.php' );
    13 
    13 
    14 require( dirname( __FILE__ ) . '/wp-blog-header.php' );
    14 require( dirname( __FILE__ ) . '/wp-blog-header.php' );
    15 
    15 
    16 if ( !is_multisite() ) {
    16 if ( !is_multisite() ) {
    17 	wp_redirect( site_url( '/wp-login.php?action=register' ) );
    17 	wp_redirect( wp_registration_url() );
    18 	die();
    18 	die();
    19 }
    19 }
       
    20 
       
    21 nocache_headers();
    20 
    22 
    21 if ( is_object( $wp_object_cache ) )
    23 if ( is_object( $wp_object_cache ) )
    22 	$wp_object_cache->cache_enabled = false;
    24 	$wp_object_cache->cache_enabled = false;
    23 
    25 
    24 // Fix for page title
    26 // Fix for page title
    30  * @since 3.0.0
    32  * @since 3.0.0
    31  */
    33  */
    32 do_action( 'activate_header' );
    34 do_action( 'activate_header' );
    33 
    35 
    34 /**
    36 /**
    35  * Adds an action hook specific to this page that fires on wp_head
    37  * Adds an action hook specific to this page.
    36  *
    38  *
    37  * @since MU
    39  * Fires on {@see 'wp_head'}.
       
    40  *
       
    41  * @since MU (3.0.0)
    38  */
    42  */
    39 function do_activate_header() {
    43 function do_activate_header() {
    40     /**
    44 	/**
    41      * Fires before the Site Activation page is loaded, but on the wp_head action.
    45 	 * Fires before the Site Activation page is loaded.
       
    46 	 *
       
    47 	 * Fires on the {@see 'wp_head'} action.
    42      *
    48      *
    43      * @since 3.0.0
    49      * @since 3.0.0
    44      */
    50      */
    45     do_action( 'activate_wp_head' );
    51     do_action( 'activate_wp_head' );
    46 }
    52 }
    47 add_action( 'wp_head', 'do_activate_header' );
    53 add_action( 'wp_head', 'do_activate_header' );
    48 
    54 
    49 /**
    55 /**
    50  * Loads styles specific to this page.
    56  * Loads styles specific to this page.
    51  *
    57  *
    52  * @since MU
    58  * @since MU (3.0.0)
    53  */
    59  */
    54 function wpmu_activate_stylesheet() {
    60 function wpmu_activate_stylesheet() {
    55 	?>
    61 	?>
    56 	<style type="text/css">
    62 	<style type="text/css">
    57 		form { margin-top: 2em; }
    63 		form { margin-top: 2em; }
    58 		#submit, #key { width: 90%; font-size: 24px; }
    64 		#submit, #key { width: 90%; font-size: 24px; }
    59 		#language { margin-top: .5em; }
    65 		#language { margin-top: .5em; }
    60 		.error { background: #f66; }
    66 		.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; }
    67 		span.h3 { padding: 0 8px; font-size: 1.3em; font-weight: bold; }
    62 	</style>
    68 	</style>
    63 	<?php
    69 	<?php
    64 }
    70 }
    65 add_action( 'wp_head', 'wpmu_activate_stylesheet' );
    71 add_action( 'wp_head', 'wpmu_activate_stylesheet' );
    66 
    72 
    67 get_header();
    73 get_header( 'wp-activate' );
    68 ?>
    74 ?>
    69 
    75 
    70 <div id="content" class="widecolumn">
    76 <div id="signup-content" class="widecolumn">
       
    77 	<div class="wp-activate-container">
    71 	<?php if ( empty($_GET['key']) && empty($_POST['key']) ) { ?>
    78 	<?php if ( empty($_GET['key']) && empty($_POST['key']) ) { ?>
    72 
    79 
    73 		<h2><?php _e('Activation Key Required') ?></h2>
    80 		<h2><?php _e('Activation Key Required') ?></h2>
    74 		<form name="activateform" id="activateform" method="post" action="<?php echo network_site_url('wp-activate.php'); ?>">
    81 		<form name="activateform" id="activateform" method="post" action="<?php echo network_site_url('wp-activate.php'); ?>">
    75 			<p>
    82 			<p>
    85 
    92 
    86 		$key = !empty($_GET['key']) ? $_GET['key'] : $_POST['key'];
    93 		$key = !empty($_GET['key']) ? $_GET['key'] : $_POST['key'];
    87 		$result = wpmu_activate_signup( $key );
    94 		$result = wpmu_activate_signup( $key );
    88 		if ( is_wp_error($result) ) {
    95 		if ( is_wp_error($result) ) {
    89 			if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
    96 			if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
    90 			    $signup = $result->get_error_data();
    97 				$signup = $result->get_error_data();
    91 				?>
    98 				?>
    92 				<h2><?php _e('Your account is now active!'); ?></h2>
    99 				<h2><?php _e('Your account is now active!'); ?></h2>
    93 				<?php
   100 				<?php
    94 				echo '<p class="lead-in">';
   101 				echo '<p class="lead-in">';
    95 				if ( $signup->domain . $signup->path == '' ) {
   102 				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() );
   103 					printf(
       
   104 						/* translators: 1: login URL, 2: username, 3: user email, 4: lost password URL */
       
   105 						__( '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>.' ),
       
   106 						network_site_url( 'wp-login.php', 'login' ),
       
   107 						$signup->user_login,
       
   108 						$signup->user_email,
       
   109 						wp_lostpassword_url()
       
   110 					);
    97 				} else {
   111 				} 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() );
   112 					printf(
       
   113 						/* translators: 1: site URL, 2: username, 3: user email, 4: lost password URL */
       
   114 						__( 'Your site at %1$s is active. You may now log in to your 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>.' ),
       
   115 						sprintf( '<a href="http://%1$s">%1$s</a>', $signup->domain ),
       
   116 						$signup->user_login,
       
   117 						$signup->user_email,
       
   118 						wp_lostpassword_url()
       
   119 					);
    99 				}
   120 				}
   100 				echo '</p>';
   121 				echo '</p>';
   101 			} else {
   122 			} else {
   102 				?>
   123 				?>
   103 				<h2><?php _e('An error occurred during the activation'); ?></h2>
   124 				<h2><?php _e( 'An error occurred during the activation' ); ?></h2>
       
   125 				<p><?php echo $result->get_error_message(); ?></p>
   104 				<?php
   126 				<?php
   105 			    echo '<p>'.$result->get_error_message().'</p>';
       
   106 			}
   127 			}
   107 		} else {
   128 		} else {
   108 			$url = isset( $result['blog_id'] ) ? get_blogaddress_by_id( (int) $result['blog_id'] ) : '';
   129 			$url = isset( $result['blog_id'] ) ? get_home_url( (int) $result['blog_id'] ) : '';
   109 			$user = get_userdata( (int) $result['user_id'] );
   130 			$user = get_userdata( (int) $result['user_id'] );
   110 			?>
   131 			?>
   111 			<h2><?php _e('Your account is now active!'); ?></h2>
   132 			<h2><?php _e('Your account is now active!'); ?></h2>
   112 
   133 
   113 			<div id="signup-welcome">
   134 			<div id="signup-welcome">
   114 				<p><span class="h3"><?php _e('Username:'); ?></span> <?php echo $user->user_login ?></p>
   135 				<p><span class="h3"><?php _e('Username:'); ?></span> <?php echo $user->user_login ?></p>
   115 				<p><span class="h3"><?php _e('Password:'); ?></span> <?php echo $result['password']; ?></p>
   136 				<p><span class="h3"><?php _e('Password:'); ?></span> <?php echo $result['password']; ?></p>
   116 			</div>
   137 			</div>
   117 
   138 
   118 			<?php if ( $url && $url != network_home_url( '', 'http' ) ) : ?>
   139 			<?php if ( $url && $url != network_home_url( '', 'http' ) ) :
   119 				<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>
   140 				switch_to_blog( (int) $result['blog_id'] );
       
   141 				$login_url = wp_login_url();
       
   142 				restore_current_blog();
       
   143 				?>
       
   144 				<p class="view"><?php
       
   145 					/* translators: 1: site URL, 2: login URL */
       
   146 					printf( __( 'Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>' ), $url, esc_url( $login_url ) );
       
   147 				?></p>
   120 			<?php else: ?>
   148 			<?php else: ?>
   121 				<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>
   149 				<p class="view"><?php
       
   150 					/* translators: 1: login URL, 2: network home URL */
       
   151 					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() );
       
   152 				?></p>
   122 			<?php endif;
   153 			<?php endif;
   123 		}
   154 		}
   124 	}
   155 	}
   125 	?>
   156 	?>
       
   157 	</div>
   126 </div>
   158 </div>
   127 <script type="text/javascript">
   159 <script type="text/javascript">
   128 	var key_input = document.getElementById('key');
   160 	var key_input = document.getElementById('key');
   129 	key_input && key_input.focus();
   161 	key_input && key_input.focus();
   130 </script>
   162 </script>
   131 <?php get_footer();
   163 <?php get_footer( 'wp-activate' );