[ Index ]

WordPress Source Cross Reference

title

Body

[close]

/ -> wp-register.php (source)

   1  <?php
   2  require('./wp-config.php');
   3  require_once( ABSPATH . WPINC . '/registration.php');
   4  
   5  $action = $_REQUEST['action'];
   6  if ( !get_settings('users_can_register') )
   7      $action = 'disabled';
   8  
   9  header( 'Content-Type: ' . get_bloginfo('html_type') . '; charset=' . get_bloginfo('charset') );
  10  
  11  switch( $action ) {
  12  
  13  case 'register':
  14  
  15      $user_login = sanitize_user( $_POST['user_login'] );
  16      $user_email = $_POST['user_email'];
  17  
  18      $errors = array();
  19  
  20      if ( $user_login == '' )
  21          $errors['user_login'] = __('<strong>ERROR</strong>: Please enter a username.');
  22  
  23      /* checking e-mail address */
  24      if ($user_email == '') {
  25          $errors['user_email'] = __('<strong>ERROR</strong>: Please type your e-mail address.');
  26      } else if (!is_email($user_email)) {
  27          $errors['user_email'] = __('<strong>ERROR</strong>: The email address isn&#8217;t correct.');
  28          $user_email = '';
  29      }
  30  
  31      if ( ! validate_username($user_login) ) {
  32          $errors['user_login'] = __('<strong>ERROR</strong>: This username is invalid.  Please enter a valid username.');
  33          $user_login = '';
  34      }
  35  
  36      if ( username_exists( $user_login ) )
  37          $errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.');
  38  
  39      if ( email_exists( $user_email ) )
  40          $errors['user_email'] = __('<strong>ERROR</strong>: This email is already registered, please choose another one.');
  41  
  42      if ( 0 == count($errors) ) {
  43          $password = substr( md5( uniqid( microtime() ) ), 0, 7);
  44  
  45          $user_id = wp_create_user( $user_login, $password, $user_email );
  46          if ( !$user_id )
  47              $errors['user_id'] = sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_settings('admin_email'));
  48          else
  49              wp_new_user_notification($user_id, $password);
  50      }
  51  
  52      if ( 0 == count($errors) ) {
  53  
  54      ?>
  55  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  56  <html xmlns="http://www.w3.org/1999/xhtml">
  57  <head>
  58      <title>WordPress &raquo; <?php _e('Registration Complete') ?></title>
  59      <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
  60      <link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css" />
  61      <style type="text/css">
  62      .submit {
  63          font-size: 1.7em;
  64      }
  65      </style>
  66  </head>
  67  <body>
  68  
  69  <div id="login"> 
  70      <h2><?php _e('Registration Complete') ?></h2>
  71      <p><?php printf(__('Username: %s'), "<strong>" . wp_specialchars($user_login) . "</strong>") ?><br />
  72      <?php printf(__('Password: %s'), '<strong>' . __('emailed to you') . '</strong>') ?> <br />
  73      <?php printf(__('E-mail: %s'), "<strong>" . wp_specialchars($user_email) . "</strong>") ?></p>
  74      <p class="submit"><a href="wp-login.php"><?php _e('Login &raquo;'); ?></a></p>
  75  </div>
  76  </body>
  77  </html>
  78  
  79          <?php
  80          break;
  81      }
  82  
  83  default:
  84  
  85  ?>
  86  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  87  <html xmlns="http://www.w3.org/1999/xhtml">
  88  <head>
  89      <title>WordPress &raquo; <?php _e('Registration Form') ?></title>
  90      <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
  91      <link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css" />
  92      <style type="text/css">
  93      #user_email, #user_login, #submit {
  94          font-size: 1.7em;
  95      }
  96      </style>
  97  </head>
  98  
  99  <body>
 100  <div id="login">
 101  <h1><a href="http://wordpress.org/">WordPress</a></h1>
 102  <h2><?php _e('Register for this blog') ?></h2>
 103  <?php if ( isset($errors) ) : ?>
 104  <div class="error">
 105      <p>
 106      <?php
 107      foreach($errors as $error) echo "$error<br />";
 108      ?>
 109      </p>
 110  </div>
 111  <?php endif; ?>
 112  <form method="post" action="wp-register.php" id="registerform">
 113      <p><input type="hidden" name="action" value="register" />
 114      <label for="user_login"><?php _e('Username:') ?></label><br /> <input type="text" name="user_login" id="user_login" size="20" maxlength="20" value="<?php echo wp_specialchars($user_login); ?>" /><br /></p>
 115      <p><label for="user_email"><?php _e('E-mail:') ?></label><br /> <input type="text" name="user_email" id="user_email" size="25" maxlength="100" value="<?php echo wp_specialchars($user_email); ?>" /></p>
 116      <p><?php _e('A password will be emailed to you.') ?></p>
 117      <p class="submit"><input type="submit" value="<?php _e('Register &raquo;') ?>" id="submit" name="submit" /></p>
 118  </form>
 119  <ul>
 120      <li><a href="<?php bloginfo('home'); ?>/" title="<?php _e('Are you lost?') ?>">&laquo; <?php _e('Back to blog') ?></a></li>
 121      <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li>
 122      <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=lostpassword" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a></li>
 123  </ul>
 124  </div>
 125  
 126  </body>
 127  </html>
 128  <?php
 129  
 130  break;
 131  
 132  case 'disabled':
 133  
 134      ?>
 135  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 136  <html xmlns="http://www.w3.org/1999/xhtml">
 137  <head>
 138      <title>WordPress &raquo; <?php _e('Registration Currently Disabled') ?></title>
 139      <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
 140      <link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css">
 141  </head>
 142  
 143  <body>
 144  
 145  <div id="login">
 146      <h2><?php _e('Registration Disabled') ?></h2>
 147      <p><?php _e('User registration is currently not allowed.') ?><br />
 148      <a href="<?php echo get_settings('home'); ?>/" title="<?php _e('Go back to the blog') ?>"><?php _e('Home') ?></a>
 149      </p>
 150  </div>
 151  
 152  </body>
 153  </html>
 154  
 155      <?php
 156  break;
 157  
 158  }
 159  ?>

Your comment here...

Name: Location:
Comments:


List: Classes | Functions | Variables | Constants | Tables

Generated: Sat Jul 15 11:57:04 2006 Courtesy of Taragana