WordPress.org

WordPress MU

Changeset 557


Ignore:
Timestamp:
06/09/06 18:26:07 (8 years ago)
Author:
donncha
Message:

New signup page

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-inst/wp-signup.php

    r543 r557  
    11<?php 
     2 
     3/* 
     4die(' 
     5<div style="line-height: 1.6em; font-family:Verdana, Arial, Helvetica, sans-serif; width: 350px; margin: auto;"> 
     6<p>Blog registration is temporarily disabled. Thanks for your patience. </p> 
     7 
     8<p align="right">&#8212; <em>Matt</em></p> 
     9 
     10</div> 
     11'); 
     12 
     13 
     14 
     15 
     16die( 'Blog registration is disabled for a few minutes. Sorry for the interupption. Please try again later.'); // disabled for ibbackup 
     17*/ 
    218require ('wp-config.php'); 
     19 
     20//graceful_fail('Signups are disabled for a few minutes. Sorry! Please try again soon.'); 
     21 
    322require_once( ABSPATH . WPINC . '/registration-functions.php'); 
    423 
     
    1433    font-size: 24px; 
    1534} 
    16 #language { 
    17     margin-top: .5em; 
    18 } 
    1935.error { 
    2036    background-color: #f66; 
     
    2238</style> 
    2339<?php 
    24 function show_signup_form($blog_id = '', $blog_title = '', $user_email = '', $errors = '') { 
    25     global $current_user, $current_site, $wpdb; 
    26  
    27     if ( ! is_wp_error($errors) ) 
    28         $errors = new WP_Error(); 
    29  
    30     echo '<h2>' . __('Get your own WordPress MU blog in seconds') . '</h2>'; 
    31  
    32     if ( $errors->get_error_code() ) { 
    33         print "<p>There was a problem, please correct the form below and try again.</p>"; 
    34     } 
    35 ?> 
    36  
    37 <form name="setupform" id="setupform" method="post" action=""> 
    38 <input type="hidden" name="stage" value="1"> 
    39 <table border="0" width="100%" cellpadding="9"> 
    40 <?php 
     40function show_blog_form($blog_id = '', $blog_title = '', $errors = '') { 
     41    global $current_site; 
     42 
    4143    // Blog name/Username 
    42     if ( $errors->get_error_message('blog_id') || $errors->get_error_message('user_name') ) { 
     44    if ( $errors->get_error_message('blog_id') ) 
    4345        print '<tr class="error">'; 
    44     } else { 
     46    else 
    4547        print '<tr>'; 
    46     } 
    47     if ( !is_user_logged_in() ) 
    48         echo '<th valign="top">' . __('Username:') . '</th><td>'; 
    49     else 
    50         echo '<th valign="top">' . __('Blog Domain:') . '</th><td>'; 
    51  
    52     if ( $errmsg = $errors->get_error_message('user_name') ) { 
     48 
     49    echo '<th valign="top">' . __('Blog Domain:') . '</th><td>'; 
     50 
     51    if ( $errmsg = $errors->get_error_message('blog_id') ) { 
    5352?><p><strong><?php echo $errmsg ?></strong></p><?php 
    54     } else if ( $errmsg = $errors->get_error_message('blog_id') ) { 
    55 ?><p><strong><?php echo $errmsg ?></strong></p><?php 
    56     } 
    57     if ( constant( 'VHOST' ) == 'yes' ) 
    58         echo '<input name="blog_id" type="text" id="blog_id" value="'.$blog_id.'" maxlength="50" style="width:40%; text-align: right; font-size: 30px;" /><span style="font-size: 30px">' .  $current_site->domain . '</span><br />'; 
    59     else 
    60         echo '<span style="font-size: 30px">' .  $current_site->domain . '/</span><input name="blog_id" type="text" id="blog_id" value="'.$blog_id.'" maxlength="50" style="width:40%; font-size: 30px;" /><br />'; 
    61  
    62     if ( !is_user_logged_in() ) print 'At least 4 letters and numbers only, please. It cannot be changed so choose carefully!)</td> </tr>'; 
     53    } 
     54    print '<input name="blog_id" type="text" id="blog_id" value="'.$blog_id.'" maxlength="50" style="width:40%; text-align: right; font-size: 30px;" /><span style="font-size: 30px">.' . $current_site->domain . '</span><br />'; 
     55    if ( !is_user_logged_in() ) print '(<strong>Your address will be domain.' . $current_site->domain . '.</strong> Must be at least 4 characters, letters and numbers only. It cannot be changed so choose carefully!)</td> </tr>'; 
    6356 
    6457    // Blog Title 
     
    7568    print '<input name="blog_title" type="text" id="blog_title" value="'.wp_specialchars($blog_title, 1).'" /></td> 
    7669        </tr>'; 
     70?> 
     71<tr> 
     72<th scope="row"  valign="top">Privacy:</th> 
     73<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> 
     74</tr> 
     75<?php 
     76} 
     77 
     78function validate_blog_form() { 
     79    if ( is_user_logged_in() ) 
     80        $user = wp_get_current_user(); 
     81    else 
     82        $user = ''; 
     83 
     84    $result = wpmu_validate_blog_signup($_POST['blog_id'], $_POST['blog_title'], $user);     
     85 
     86    return $result; 
     87} 
     88 
     89function show_user_form($user_name = '', $user_email = '', $errors = '') { 
     90    // Blog name/Username 
     91    if ( $errors->get_error_message('user_name') ) { 
     92        print '<tr class="error">'; 
     93    } else { 
     94        print '<tr>'; 
     95    } 
     96 
     97    echo '<th valign="top">' . __('Username:') . '</th><td>'; 
     98 
     99    if ( $errmsg = $errors->get_error_message('user_name') ) { 
     100?><p><strong><?php echo $errmsg ?></strong></p><?php 
     101    } 
     102 
     103    print '<input name="user_name" type="text" id="user_name" value="'.$user_name.'" maxlength="50" style="width:50%; font-size: 30px;" /><br />'; 
     104    print '(Must be at least 4 characters, letters and numbers only.)</td> </tr>'; 
    77105 
    78106    // User Email 
    79     // Don't show email field if user is logged in. 
    80     if ( !is_user_logged_in() ) { 
    81         if ( $errors->get_error_message('user_email') ) { 
    82             print '<tr class="error">'; 
    83         } else { 
    84             print '<tr>'; 
    85         } 
     107    if ( $errors->get_error_message('user_email') ) { 
     108        print '<tr class="error">'; 
     109    } else { 
     110        print '<tr>'; 
     111    } 
    86112?><th valign="top">Email&nbsp;Address:</th><td><?php 
    87113 
    88         if ( $errmsg = $errors->get_error_message('user_email') ) { 
     114    if ( $errmsg = $errors->get_error_message('user_email') ) { 
    89115?><p><strong><?php echo $errmsg ?></strong></p><?php 
    90         } 
    91         print ' 
    92         <input name="user_email" type="text" id="user_email" value="'.wp_specialchars($user_email, 1).'" maxlength="200" /><br /> (We&#8217;ll send your password to this address, so double-check it.)</td> 
    93         </tr>'; 
    94     } 
     116    } 
     117    print ' 
     118    <input name="user_email" type="text" id="user_email" value="'.wp_specialchars($user_email, 1).'" maxlength="200" /><br /> (We&#8217;ll send your password to this address, so <strong>triple-check it</strong>.)</td> 
     119    </tr>'; 
    95120 
    96121    if ( $errmsg = $errors->get_error_message('generic') ) 
    97122        print '<tr class="error"> <th colspan="2">'.$errmsg.'</th> </tr>'; 
     123} 
     124 
     125function validate_user_form() { 
     126    $result = wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']);  
     127 
     128    return $result; 
     129} 
     130 
     131function signup_another_blog($blog_id = '', $blog_title = '', $errors = '') { 
     132    global $current_user, $wpdb, $domain, $current_site; 
     133 
     134    if ( ! is_wp_error($errors) ) 
     135        $errors = new WP_Error(); 
     136 
     137    echo '<h2>' . printf( __('Get <em>another</em> %s blog in seconds'), $current_site->site_name ) . '</h2>'; 
     138 
     139    if ( $errors->get_error_code() ) { 
     140        print "<p>There was a problem, please correct the form below and try again.</p>"; 
     141    } 
     142 
     143?> 
     144<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> 
     145<p>Here are the blogs you already have:</p> 
     146<ul> 
     147<?php  
     148    $blogs = get_blogs_of_user($current_user->ID); 
     149 
     150    if ( ! empty($blogs) ) foreach ( $blogs as $blog ) { 
     151        $display = str_replace(".$domain", '', $blog->domain); 
     152        echo "<li><a href='https://$blog->domain/'>$display</a></li>"; 
     153    } 
     154?> 
     155</ul> 
     156<p><?php _e("If you&#8217;re not going to use a great blog domain, leave it for a new user. Now have at it!") ?></p> 
     157<form name="setupform" id="setupform" method="post" action="wp-signup.php"> 
     158<input type="hidden" name="stage" value="gimmeanotherblog"> 
     159<table border="0" width="100%" cellpadding="9"> 
     160<?php 
     161    show_blog_form($blog_id, $blog_title, $errors); 
    98162?> 
    99163<tr> 
    100164<th scope="row"  valign="top">&nbsp;</th> 
    101 <td><input id="submit" type="submit" name="Submit" class="submit" value="Sign Up &raquo;" /></td> 
    102 </tr> 
    103 <?php 
    104     do_action('signup_form'); 
    105     print ' 
    106     </table> 
    107     </form>'; 
    108 } 
    109  
    110 function show_signup_confirm_form($domain, $path, $blog_title, $user_name, $user_email, $meta) { 
     165<td><input id="submit" type="submit" name="Submit" class="submit" value="Create Blog &raquo;" /></td> 
     166</tr> 
     167</table> 
     168</form> 
     169<?php 
     170} 
     171 
     172function validate_another_blog_signup() { 
     173    global $current_user; 
     174 
     175    $result = validate_blog_form(); 
     176    extract($result); 
     177     
     178    if ( $errors->get_error_code() ) { 
     179        signup_another_blog($blog_id, $blog_title, $errors); 
     180        return; 
     181    } 
     182         
     183    $public = (int) $_POST['blog_public']; 
     184    $meta = array ('lang_id' => 'en', 'public' => $public); 
     185 
     186    wpmu_create_blog($domain, $path, $blog_title, $current_user->id, $meta); 
     187    confirm_another_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta);       
     188} 
     189 
     190function confirm_another_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta) { 
     191?> 
     192<h2><?php printf(__('%s Is Yours'), $domain) ?></h2> 
     193<p><?php printf(__('%1$s is your new blog.  <a href="%2$s">Login</a> as "%3$s" using your existing password.'), $domain, "http://${domain}${path}wp-login.php", $user_name) ?></p> 
     194<?php 
     195    do_action('signup_finished'); 
     196} 
     197 
     198function signup_user($user_name = '', $user_email = '', $errors = '') { 
     199    global $current_site; 
     200 
     201    if ( ! is_wp_error($errors) ) 
     202        $errors = new WP_Error(); 
     203?>   
     204<h2><?php printf( __('Get your own %s account in seconds'), $current_site->site_name ) ?></h2> 
     205<p>Fill out this one-step form and you'll be blogging seconds later!</p> 
     206<form name="setupform" id="setupform" method="post" action="wp-signup.php"> 
     207<input type="hidden" name="stage" value="validate-user-signup"> 
     208<table border="0" width="100%" cellpadding="9"> 
     209<?php show_user_form($user_name, $user_email, $errors); ?> 
     210<th scope="row"  valign="top">&nbsp;</th> 
     211<td> 
     212<p> 
     213<input id="signupblog" type="radio" name="signup_for" value="blog" checked="checked" /> 
     214<label for="signupblog">Gimme a blog! (Like username.<?php echo $current_site->domain ?>)</label> 
     215<br /> 
     216<input id="signupuser" type="radio" name="signup_for" value="user" /> 
     217<label for="signupuser">Just an username, please.</label> 
     218</p> 
     219</td> 
     220</tr> 
     221<tr> 
     222<th scope="row"  valign="top">&nbsp;</th> 
     223<td><input id="submit" type="submit" name="Submit" class="submit" value="Next &raquo;" /></td> 
     224</tr> 
     225</table> 
     226</form> 
     227<?php 
     228 
     229} 
     230 
     231function validate_user_signup() { 
     232    $result = validate_user_form(); 
     233    extract($result); 
     234     
     235    if ( $errors->get_error_code() ) { 
     236        signup_user($user_name, $user_email, $errors); 
     237        return;  
     238    } 
     239 
     240    if ( 'blog' == $_POST['signup_for'] ) { 
     241        signup_blog($user_name, $user_email); 
     242        return; 
     243    } 
     244 
     245    wpmu_signup_user($user_name, $user_email); 
     246 
     247    confirm_user_signup($user_name, $user_email); 
     248} 
     249 
     250function confirm_user_signup($user_name, $user_email) { 
     251?> 
     252<h2><?php printf(__('%s Is Your New Username'), $user_name) ?></h2> 
     253<p><?php _e('But, before you can start using your new username, <strong>you must activate it</strong>.') ?></p> 
     254<p><?php printf(__('Check your inbox at <strong>%1$s</strong> and click the link given.  '),  $user_email) ?></p> 
     255<p><?php _e('If you do not activate your username within two days, you will have to sign up again.'); ?></p> 
     256<?php 
     257} 
     258 
     259function signup_blog($user_name = '', $user_email = '', $blog_id = '', $blog_title = '', $errors = '') { 
     260    if ( ! is_wp_error($errors) ) 
     261        $errors = new WP_Error(); 
     262 
     263    if ( empty($blog_id) ) 
     264        $blog_id = $user_name; 
     265?>   
     266<form name="setupform" id="setupform" method="post" action="wp-signup.php"> 
     267<input type="hidden" name="stage" value="validate-blog-signup"> 
     268<input type="hidden" name="user_name" value="<?php echo $user_name ?>"> 
     269<input type="hidden" name="user_email" value="<?php echo $user_email ?>"> 
     270<table border="0" width="100%" cellpadding="9"> 
     271<?php show_blog_form($blog_id, $blog_title, $errors); ?> 
     272<tr> 
     273<th scope="row"  valign="top">&nbsp;</th> 
     274<td><input id="submit" type="submit" name="Submit" class="submit" value="Signup &raquo;" /></td> 
     275</tr> 
     276</table> 
     277</form> 
     278<?php 
     279} 
     280 
     281function validate_blog_signup() { 
     282    // Re-validate user info. 
     283    $result = wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']); 
     284    extract($result); 
     285 
     286    if ( $errors->get_error_code() ) { 
     287        signup_user($user_name, $user_email, $errors); 
     288        return; 
     289    } 
     290     
     291    $result = wpmu_validate_blog_signup($_POST['blog_id'], $_POST['blog_title']); 
     292    extract($result); 
     293 
     294    if ( $errors->get_error_code() ) { 
     295        signup_blog($user_name, $user_email, $blog_id, $blog_title, $errors); 
     296        return; 
     297    } 
     298 
     299    $public = (int) $_POST['blog_public']; 
     300    $meta = array ('lang_id' => 'en', 'public' => $public); 
     301          
     302    wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta); 
     303 
     304    confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta); 
     305} 
     306 
     307function confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta) { 
    111308?> 
    112309<h2><?php printf(__('%s Is Yours'), $domain) ?></h2> 
     
    118315} 
    119316 
    120 function show_create_confirm_form($domain, $path, $blog_title, $user_name, $user_email, $meta) { 
    121 ?> 
    122 <h2><?php printf(__('%s Is Yours'), $domain) ?></h2> 
    123 <p><?php printf(__('%1$s is your new blog.  <a href="%2$s">Login</a> as "%3$s" using your existing password.'), $domain, "http://${domain}${path}wp-login.php", $user_name) ?></p> 
    124 <?php 
    125     do_action('signup_finished'); 
    126 } 
    127  
    128 function validate_signup_form() { 
    129     global $current_user; 
    130     if ( is_user_logged_in() ) 
    131         $result = wpmu_validate_signup($_POST['blog_id'], $_POST['blog_title'], $current_user, $current_user->user_email);   
    132     else 
    133         $result = wpmu_validate_signup($_POST['blog_id'], $_POST['blog_title'], $_POST['blog_id'], $_POST['user_email']); 
    134     extract($result); 
    135  
    136     if ( empty($errors) ) 
    137         $errors = new WP_Error(); 
     317// Main 
     318$blog_id = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null; 
    138319     
    139     if ( $errors->get_error_code() ) { 
    140         show_signup_form($blog_id, $blog_title, $user_email, $errors); 
    141         return; 
    142     } 
    143     $errors = new WP_Error(); 
    144  
    145     if (empty ($blog_id)) { 
    146         $errors->add('blog_id', __("Sorry, your blog domain may only contain the characters a-z or 0-9!")); 
    147         show_signup_form($blog_id, $blog_title, $user_email, $errors); 
    148         return; 
    149     } 
    150  
    151     $public = (int) $_POST['blog_public']; 
    152     $meta = array (); 
    153  
    154     if ( is_user_logged_in() ) { 
    155         wpmu_create_blog($domain, $path, $blog_title, $current_user->id, $meta); 
    156         show_create_confirm_form($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta);      
    157     } else { 
    158         wpmu_signup($domain, $path, $blog_title, $blog_id, $user_email, $meta); 
    159         show_signup_confirm_form($domain, $path, $blog_title, $blog_id, $user_email, $meta); 
    160     } 
    161 } 
    162  
    163320switch ($_POST['stage']) { 
    164     case "1" : 
    165         validate_signup_form(); 
     321    case 'validate-user-signup' : 
     322        validate_user_signup(); 
     323        break; 
     324    case 'validate-blog-signup': 
     325        validate_blog_signup(); 
     326        break; 
     327    case 'gimmeanotherblog': 
     328        validate_another_blog_signup(); 
    166329        break; 
    167330    default : 
    168         $user_login = ''; 
    169         $blog_title = ''; 
    170         $email = ''; 
    171         if ($_GET['new']) 
    172             $user_login = stripslashes($_GET['new']); 
    173  
    174         show_signup_form($user_login, $blog_title, $email); 
     331        if ( is_user_logged_in() ) 
     332            signup_another_blog($blog_id); 
     333        else 
     334            signup_user(); 
     335 
     336        if ($blog_id) { 
     337?><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 
     338        } 
    175339        break; 
    176340} 
Note: See TracChangeset for help on using the changeset viewer.