| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
require ('wp-config.php'); |
|---|
| 4 |
|
|---|
| 5 |
require_once( ABSPATH . WPINC . '/registration.php'); |
|---|
| 6 |
|
|---|
| 7 |
do_action("signup_header"); |
|---|
| 8 |
if( $current_blog->domain != $current_site->domain ) { |
|---|
| 9 |
header( "Location: http://" . $current_site->domain . $current_site->path . "wp-signup.php" ); |
|---|
| 10 |
die(); |
|---|
| 11 |
} |
|---|
| 12 |
|
|---|
| 13 |
get_header(); |
|---|
| 14 |
?> |
|---|
| 15 |
<div id="content" class="widecolumn"> |
|---|
| 16 |
<style type="text/css"> |
|---|
| 17 |
form { margin-top: 2em; } |
|---|
| 18 |
#submit, #blog_title, #user_email { |
|---|
| 19 |
width: 90%; |
|---|
| 20 |
font-size: 24px; |
|---|
| 21 |
} |
|---|
| 22 |
.error { |
|---|
| 23 |
background-color: #f66; |
|---|
| 24 |
} |
|---|
| 25 |
</style> |
|---|
| 26 |
<?php |
|---|
| 27 |
function show_blog_form($blog_id = '', $blog_title = '', $errors = '') { |
|---|
| 28 |
global $current_site; |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
if ( $errors->get_error_message('blog_id') ) |
|---|
| 32 |
print '<tr class="error">'; |
|---|
| 33 |
else |
|---|
| 34 |
print '<tr>'; |
|---|
| 35 |
|
|---|
| 36 |
if( constant( "VHOST" ) == 'no' ) |
|---|
| 37 |
echo '<th valign="top">' . __('Blog Name:') . '</th><td>'; |
|---|
| 38 |
else |
|---|
| 39 |
echo '<th valign="top">' . __('Blog Domain:') . '</th><td>'; |
|---|
| 40 |
|
|---|
| 41 |
if ( $errmsg = $errors->get_error_message('blog_id') ) { |
|---|
| 42 |
?><p><strong><?php echo $errmsg ?></strong></p><?php |
|---|
| 43 |
} |
|---|
| 44 |
if( constant( "VHOST" ) == 'no' ) { |
|---|
| 45 |
print '<span style="font-size: 20px">' . $current_site->domain . $current_site->path . '</span><input name="blog_id" type="text" id="blog_id" value="'.$blog_id.'" maxlength="50" style="width:40%; text-align: left; font-size: 20px;" /><br />'; |
|---|
| 46 |
} else { |
|---|
| 47 |
print '<input name="blog_id" type="text" id="blog_id" value="'.$blog_id.'" maxlength="50" style="width:40%; text-align: right; font-size: 20px;" /><span style="font-size: 20px">' . $current_site->domain . $current_site->path . '</span><br />'; |
|---|
| 48 |
} |
|---|
| 49 |
if ( !is_user_logged_in() ) { |
|---|
| 50 |
print '(<strong>Your address will be '; |
|---|
| 51 |
if( constant( "VHOST" ) == 'no' ) { |
|---|
| 52 |
print $current_site->domain . $current_site->path . 'blogname'; |
|---|
| 53 |
} else { |
|---|
| 54 |
print 'domain.' . $current_site->domain . $current_site->path; |
|---|
| 55 |
} |
|---|
| 56 |
print '.</strong> Must be at least 4 characters, letters and numbers only. It cannot be changed so choose carefully!)</td> </tr>'; |
|---|
| 57 |
} |
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
if ( $errors->get_error_message('blog_title')) { |
|---|
| 61 |
print '<tr class="error">'; |
|---|
| 62 |
} else { |
|---|
| 63 |
print '<tr>'; |
|---|
| 64 |
} |
|---|
| 65 |
?><th valign="top" width="120">Blog Title:</th><td><?php |
|---|
| 66 |
|
|---|
| 67 |
if ( $errmsg = $errors->get_error_message('blog_title') ) { |
|---|
| 68 |
?><p><strong><?php echo $errmsg ?></strong></p><?php |
|---|
| 69 |
} |
|---|
| 70 |
print '<input name="blog_title" type="text" id="blog_title" value="'.wp_specialchars($blog_title, 1).'" /></td> |
|---|
| 71 |
</tr>'; |
|---|
| 72 |
?> |
|---|
| 73 |
<tr> |
|---|
| 74 |
<th scope="row" valign="top">Privacy:</th> |
|---|
| 75 |
<td><label><input type="checkbox" name="blog_public" value="1" checked="checked" /> <?php _e('I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.'); ?></label></td> |
|---|
| 76 |
</tr> |
|---|
| 77 |
<?php |
|---|
| 78 |
} |
|---|
| 79 |
|
|---|
| 80 |
function validate_blog_form() { |
|---|
| 81 |
if ( is_user_logged_in() ) |
|---|
| 82 |
$user = wp_get_current_user(); |
|---|
| 83 |
else |
|---|
| 84 |
$user = ''; |
|---|
| 85 |
|
|---|
| 86 |
$result = wpmu_validate_blog_signup($_POST['blog_id'], $_POST['blog_title'], $user); |
|---|
| 87 |
|
|---|
| 88 |
return $result; |
|---|
| 89 |
} |
|---|
| 90 |
|
|---|
| 91 |
function show_user_form($user_name = '', $user_email = '', $errors = '') { |
|---|
| 92 |
|
|---|
| 93 |
if ( $errors->get_error_message('user_name') ) { |
|---|
| 94 |
print '<tr class="error">'; |
|---|
| 95 |
} else { |
|---|
| 96 |
print '<tr>'; |
|---|
| 97 |
} |
|---|
| 98 |
|
|---|
| 99 |
echo '<th valign="top">' . __('Username:') . '</th><td>'; |
|---|
| 100 |
|
|---|
| 101 |
if ( $errmsg = $errors->get_error_message('user_name') ) { |
|---|
| 102 |
?><p><strong><?php echo $errmsg ?></strong></p><?php |
|---|
| 103 |
} |
|---|
| 104 |
|
|---|
| 105 |
print '<input name="user_name" type="text" id="user_name" value="'.$user_name.'" maxlength="50" style="width:50%; font-size: 30px;" /><br />'; |
|---|
| 106 |
print '(Must be at least 4 characters, letters and numbers only.)</td> </tr>'; |
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
if ( $errors->get_error_message('user_email') ) { |
|---|
| 110 |
print '<tr class="error">'; |
|---|
| 111 |
} else { |
|---|
| 112 |
print '<tr>'; |
|---|
| 113 |
} |
|---|
| 114 |
?><th valign="top">Email Address:</th><td><?php |
|---|
| 115 |
|
|---|
| 116 |
if ( $errmsg = $errors->get_error_message('user_email') ) { |
|---|
| 117 |
?><p><strong><?php echo $errmsg ?></strong></p><?php |
|---|
| 118 |
} |
|---|
| 119 |
print ' |
|---|
| 120 |
<input name="user_email" type="text" id="user_email" value="'.wp_specialchars($user_email, 1).'" maxlength="200" /><br /> (We’ll send your password to this address, so <strong>triple-check it</strong>.)</td> |
|---|
| 121 |
</tr>'; |
|---|
| 122 |
|
|---|
| 123 |
if ( $errmsg = $errors->get_error_message('generic') ) |
|---|
| 124 |
print '<tr class="error"> <th colspan="2">'.$errmsg.'</th> </tr>'; |
|---|
| 125 |
} |
|---|
| 126 |
|
|---|
| 127 |
function validate_user_form() { |
|---|
| 128 |
$result = wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']); |
|---|
| 129 |
|
|---|
| 130 |
return $result; |
|---|
| 131 |
} |
|---|
| 132 |
|
|---|
| 133 |
function signup_another_blog($blog_id = '', $blog_title = '', $errors = '') { |
|---|
| 134 |
global $current_user, $wpdb, $domain, $current_site; |
|---|
| 135 |
|
|---|
| 136 |
if ( ! is_wp_error($errors) ) |
|---|
| 137 |
$errors = new WP_Error(); |
|---|
| 138 |
|
|---|
| 139 |
echo '<h2>' . sprintf( __('Get <em>another</em> %s blog in seconds'), $current_site->site_name ) . '</h2>'; |
|---|
| 140 |
|
|---|
| 141 |
if ( $errors->get_error_code() ) { |
|---|
| 142 |
print "<p>There was a problem, please correct the form below and try again.</p>"; |
|---|
| 143 |
} |
|---|
| 144 |
|
|---|
| 145 |
?> |
|---|
| 146 |
<p>Welcome back, <?php echo $current_user->display_name; ?>. By filling out the form below, you can <strong>add another blog to your account</strong>. There is no limit to the number of blogs you can have, so create to your heart's content, but blog responsibly.</p> |
|---|
| 147 |
<p>Here are the blogs you already have:</p> |
|---|
| 148 |
<ul> |
|---|
| 149 |
<?php |
|---|
| 150 |
$blogs = get_blogs_of_user($current_user->ID); |
|---|
| 151 |
|
|---|
| 152 |
if ( ! empty($blogs) ) foreach ( $blogs as $blog ) { |
|---|
| 153 |
echo "<li><a href='" . $blog->domain . $blog->path . "'>" . $blog->domain . $blog->path . "</a></li>"; |
|---|
| 154 |
} |
|---|
| 155 |
?> |
|---|
| 156 |
</ul> |
|---|
| 157 |
<p><?php _e("If you’re not going to use a great blog domain, leave it for a new user. Now have at it!") ?></p> |
|---|
| 158 |
<form name="setupform" id="setupform" method="post" action="wp-signup.php"> |
|---|
| 159 |
<input type="hidden" name="stage" value="gimmeanotherblog"> |
|---|
| 160 |
<table border="0" width="100%" cellpadding="9"> |
|---|
| 161 |
<?php |
|---|
| 162 |
show_blog_form($blog_id, $blog_title, $errors); |
|---|
| 163 |
?> |
|---|
| 164 |
<tr> |
|---|
| 165 |
<th scope="row" valign="top"> </th> |
|---|
| 166 |
<td><input id="submit" type="submit" name="Submit" class="submit" value="Create Blog »" /></td> |
|---|
| 167 |
</tr> |
|---|
| 168 |
</table> |
|---|
| 169 |
</form> |
|---|
| 170 |
<?php |
|---|
| 171 |
} |
|---|
| 172 |
|
|---|
| 173 |
function validate_another_blog_signup() { |
|---|
| 174 |
global $current_user; |
|---|
| 175 |
|
|---|
| 176 |
$result = validate_blog_form(); |
|---|
| 177 |
extract($result); |
|---|
| 178 |
|
|---|
| 179 |
if ( $errors->get_error_code() ) { |
|---|
| 180 |
signup_another_blog($blog_id, $blog_title, $errors); |
|---|
| 181 |
return; |
|---|
| 182 |
} |
|---|
| 183 |
|
|---|
| 184 |
$public = (int) $_POST['blog_public']; |
|---|
| 185 |
$meta = array ('lang_id' => 'en', 'public' => $public); |
|---|
| 186 |
|
|---|
| 187 |
wpmu_create_blog($domain, $path, $blog_title, $current_user->id, $meta); |
|---|
| 188 |
confirm_another_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta); |
|---|
| 189 |
} |
|---|
| 190 |
|
|---|
| 191 |
function confirm_another_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta) { |
|---|
| 192 |
?> |
|---|
| 193 |
<h2><?php printf(__('%s Is Yours'), $domain.$path ) ?></h2> |
|---|
| 194 |
<p><?php printf(__('<a href="http://%1$s">http://%2$s</a> is your new blog. <a href="%3$s">Login</a> as "%4$s" using your existing password.'), $domain.$path, $domain.$path, "http://" . $domain.$path . "wp-login.php", $user_name) ?></p> |
|---|
| 195 |
<?php |
|---|
| 196 |
do_action('signup_finished'); |
|---|
| 197 |
} |
|---|
| 198 |
|
|---|
| 199 |
function signup_user($user_name = '', $user_email = '', $errors = '') { |
|---|
| 200 |
global $current_site; |
|---|
| 201 |
|
|---|
| 202 |
if ( ! is_wp_error($errors) ) |
|---|
| 203 |
$errors = new WP_Error(); |
|---|
| 204 |
?> |
|---|
| 205 |
<h2><?php printf( __('Get your own %s account in seconds'), $current_site->site_name ) ?></h2> |
|---|
| 206 |
<p>Fill out this one-step form and you'll be blogging seconds later!</p> |
|---|
| 207 |
<form name="setupform" id="setupform" method="post" action="wp-signup.php"> |
|---|
| 208 |
<input type="hidden" name="stage" value="validate-user-signup"> |
|---|
| 209 |
<table border="0" width="100%" cellpadding="9"> |
|---|
| 210 |
<?php show_user_form($user_name, $user_email, $errors); ?> |
|---|
| 211 |
<th scope="row" valign="top"> </th> |
|---|
| 212 |
<td> |
|---|
| 213 |
<p> |
|---|
| 214 |
<input id="signupblog" type="radio" name="signup_for" value="blog" checked="checked" /> |
|---|
| 215 |
<label for="signupblog">Gimme a blog! (Like username.<?php echo $current_site->domain ?>)</label> |
|---|
| 216 |
<br /> |
|---|
| 217 |
<input id="signupuser" type="radio" name="signup_for" value="user" /> |
|---|
| 218 |
<label for="signupuser">Just a username, please.</label> |
|---|
| 219 |
</p> |
|---|
| 220 |
</td> |
|---|
| 221 |
</tr> |
|---|
| 222 |
<tr> |
|---|
| 223 |
<th scope="row" valign="top"> </th> |
|---|
| 224 |
<td><input id="submit" type="submit" name="Submit" class="submit" value="Next »" /></td> |
|---|
| 225 |
</tr> |
|---|
| 226 |
</table> |
|---|
| 227 |
</form> |
|---|
| 228 |
<?php |
|---|
| 229 |
|
|---|
| 230 |
} |
|---|
| 231 |
|
|---|
| 232 |
function validate_user_signup() { |
|---|
| 233 |
$result = validate_user_form(); |
|---|
| 234 |
extract($result); |
|---|
| 235 |
|
|---|
| 236 |
if ( $errors->get_error_code() ) { |
|---|
| 237 |
signup_user($user_name, $user_email, $errors); |
|---|
| 238 |
return; |
|---|
| 239 |
} |
|---|
| 240 |
|
|---|
| 241 |
if ( 'blog' == $_POST['signup_for'] ) { |
|---|
| 242 |
signup_blog($user_name, $user_email); |
|---|
| 243 |
return; |
|---|
| 244 |
} |
|---|
| 245 |
|
|---|
| 246 |
wpmu_signup_user($user_name, $user_email); |
|---|
| 247 |
|
|---|
| 248 |
confirm_user_signup($user_name, $user_email); |
|---|
| 249 |
} |
|---|
| 250 |
|
|---|
| 251 |
function confirm_user_signup($user_name, $user_email) { |
|---|
| 252 |
?> |
|---|
| 253 |
<h2><?php printf(__('%s Is Your New Username'), $user_name) ?></h2> |
|---|
| 254 |
<p><?php _e('But, before you can start using your new username, <strong>you must activate it</strong>.') ?></p> |
|---|
| 255 |
<p><?php printf(__('Check your inbox at <strong>%1$s</strong> and click the link given. '), $user_email) ?></p> |
|---|
| 256 |
<p><?php _e('If you do not activate your username within two days, you will have to sign up again.'); ?></p> |
|---|
| 257 |
<?php |
|---|
| 258 |
} |
|---|
| 259 |
|
|---|
| 260 |
function signup_blog($user_name = '', $user_email = '', $blog_id = '', $blog_title = '', $errors = '') { |
|---|
| 261 |
if ( ! is_wp_error($errors) ) |
|---|
| 262 |
$errors = new WP_Error(); |
|---|
| 263 |
|
|---|
| 264 |
if ( empty($blog_id) ) |
|---|
| 265 |
$blog_id = $user_name; |
|---|
| 266 |
?> |
|---|
| 267 |
<form name="setupform" id="setupform" method="post" action="wp-signup.php"> |
|---|
| 268 |
<input type="hidden" name="stage" value="validate-blog-signup"> |
|---|
| 269 |
<input type="hidden" name="user_name" value="<?php echo $user_name ?>"> |
|---|
| 270 |
<input type="hidden" name="user_email" value="<?php echo $user_email ?>"> |
|---|
| 271 |
<table border="0" width="100%" cellpadding="9"> |
|---|
| 272 |
<?php show_blog_form($blog_id, $blog_title, $errors); ?> |
|---|
| 273 |
<tr> |
|---|
| 274 |
<th scope="row" valign="top"> </th> |
|---|
| 275 |
<td><input id="submit" type="submit" name="Submit" class="submit" value="Signup »" /></td> |
|---|
| 276 |
</tr> |
|---|
| 277 |
</table> |
|---|
| 278 |
</form> |
|---|
| 279 |
<?php |
|---|
| 280 |
} |
|---|
| 281 |
|
|---|
| 282 |
function validate_blog_signup() { |
|---|
| 283 |
|
|---|
| 284 |
$result = wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']); |
|---|
| 285 |
extract($result); |
|---|
| 286 |
|
|---|
| 287 |
if ( $errors->get_error_code() ) { |
|---|
| 288 |
signup_user($user_name, $user_email, $errors); |
|---|
| 289 |
return; |
|---|
| 290 |
} |
|---|
| 291 |
|
|---|
| 292 |
$result = wpmu_validate_blog_signup($_POST['blog_id'], $_POST['blog_title']); |
|---|
| 293 |
extract($result); |
|---|
| 294 |
|
|---|
| 295 |
if ( $errors->get_error_code() ) { |
|---|
| 296 |
signup_blog($user_name, $user_email, $blog_id, $blog_title, $errors); |
|---|
| 297 |
return; |
|---|
| 298 |
} |
|---|
| 299 |
|
|---|
| 300 |
$public = (int) $_POST['blog_public']; |
|---|
| 301 |
$meta = array ('lang_id' => 'en', 'public' => $public); |
|---|
| 302 |
|
|---|
| 303 |
wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta); |
|---|
| 304 |
|
|---|
| 305 |
confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta); |
|---|
| 306 |
} |
|---|
| 307 |
|
|---|
| 308 |
function confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta) { |
|---|
| 309 |
?> |
|---|
| 310 |
<h2><?php printf(__('%s Is Yours'), $domain.$path) ?></h2> |
|---|
| 311 |
<p><?php _e('But, before you can start using your blog, <strong>you must activate it</strong>.') ?></p> |
|---|
| 312 |
<p><?php printf(__('Check your inbox at <strong>%1$s</strong> and click the link given. '), $user_email) ?></p> |
|---|
| 313 |
<p><?php _e('If you do not activate your blog within two days, you will have to sign up again.'); ?></p> |
|---|
| 314 |
<?php |
|---|
| 315 |
do_action('signup_finished'); |
|---|
| 316 |
} |
|---|
| 317 |
|
|---|
| 318 |
|
|---|
| 319 |
$blog_id = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null; |
|---|
| 320 |
if( $_POST['blog_public'] != 1 ) |
|---|
| 321 |
$_POST['blog_public'] = 0; |
|---|
| 322 |
|
|---|
| 323 |
switch ($_POST['stage']) { |
|---|
| 324 |
case 'validate-user-signup' : |
|---|
| 325 |
validate_user_signup(); |
|---|
| 326 |
break; |
|---|
| 327 |
case 'validate-blog-signup': |
|---|
| 328 |
validate_blog_signup(); |
|---|
| 329 |
break; |
|---|
| 330 |
case 'gimmeanotherblog': |
|---|
| 331 |
validate_another_blog_signup(); |
|---|
| 332 |
break; |
|---|
| 333 |
default : |
|---|
| 334 |
if ( is_user_logged_in() ) |
|---|
| 335 |
signup_another_blog($blog_id); |
|---|
| 336 |
else |
|---|
| 337 |
signup_user( $blog_id ); |
|---|
| 338 |
|
|---|
| 339 |
if ($blog_id) { |
|---|
| 340 |
?><p><em>The blog you were looking for, <strong><?php echo $blog_id ?>.<?php echo $current_site->domain ?></strong> doesn't exist but you can create it now!</em></p><?php |
|---|
| 341 |
} |
|---|
| 342 |
break; |
|---|
| 343 |
} |
|---|
| 344 |
?> |
|---|
| 345 |
</div> |
|---|
| 346 |
|
|---|
| 347 |
<?php get_footer(); ?> |
|---|
| 348 |
|
|---|