2003-04-01 16:12:34 +02:00
< ? php
2004-05-18 22:54:58 +02:00
require ( './wp-config.php' );
2005-07-09 03:27:46 +02:00
require_once ( ABSPATH . WPINC . '/registration-functions.php' );
2003-04-01 16:12:34 +02:00
2005-07-09 03:27:46 +02:00
$action = $_REQUEST [ 'action' ];
2005-04-19 05:35:48 +02:00
if ( ! get_settings ( 'users_can_register' ) )
2003-04-01 16:12:34 +02:00
$action = 'disabled' ;
2005-04-19 05:35:48 +02:00
header ( 'Content-Type: ' . get_bloginfo ( 'html_type' ) . '; charset=' . get_bloginfo ( 'charset' ) );
2003-04-01 16:12:34 +02:00
2005-07-09 03:27:46 +02:00
switch ( $action ) {
2003-04-01 16:12:34 +02:00
2003-06-20 07:16:08 +02:00
case 'register' :
2003-04-01 16:12:34 +02:00
2005-06-13 01:14:52 +02:00
$user_login = sanitize_user ( $_POST [ 'user_login' ] );
2004-04-21 00:56:47 +02:00
$user_email = $_POST [ 'user_email' ];
2006-02-12 08:53:23 +01:00
2005-07-12 17:53:13 +02:00
$errors = array ();
2006-02-12 08:53:23 +01:00
2005-06-13 01:14:52 +02:00
if ( $user_login == '' )
2005-07-12 17:53:13 +02:00
$errors [ 'user_login' ] = __ ( '<strong>ERROR</strong>: Please enter a username.' );
2003-04-01 16:12:34 +02:00
/* checking e-mail address */
2003-06-20 07:16:08 +02:00
if ( $user_email == '' ) {
2005-07-12 17:53:13 +02:00
$errors [ 'user_email' ] = __ ( '<strong>ERROR</strong>: Please type your e-mail address.' );
2003-04-01 16:12:34 +02:00
} else if ( ! is_email ( $user_email )) {
2005-07-12 17:53:13 +02:00
$errors [ 'user_email' ] = __ ( '<strong>ERROR</strong>: The email address isn’t correct.' );
2003-04-01 16:12:34 +02:00
}
2006-01-25 04:09:16 +01:00
if ( ! validate_username ( $user_login ) )
$errors [ 'user_login' ] = __ ( '<strong>ERROR</strong>: This username is invalid. Please enter a valid username.' );
if ( username_exists ( $user_login ) )
2005-07-12 17:53:13 +02:00
$errors [ 'user_login' ] = __ ( '<strong>ERROR</strong>: This username is already registered, please choose another one.' );
2003-04-01 16:12:34 +02:00
2006-02-09 09:11:26 +01:00
if ( email_exists ( $user_email ) )
$errors [ 'user_email' ] = __ ( '<strong>ERROR</strong>: This email is already registered, please choose another one.' );
2005-11-17 02:18:16 +01:00
2005-09-14 02:03:02 +02:00
if ( 0 == count ( $errors ) ) {
$password = substr ( md5 ( uniqid ( microtime () ) ), 0 , 7 );
$user_id = wp_create_user ( $user_login , $password , $user_email );
if ( ! $user_id )
$errors [ 'user_id' ] = sprintf ( __ ( '<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !' ), get_settings ( 'admin_email' ));
else
wp_new_user_notification ( $user_id , $password );
2003-04-01 16:12:34 +02:00
}
2006-02-12 08:53:23 +01:00
2005-09-14 02:03:02 +02:00
if ( 0 == count ( $errors ) ) {
2006-02-09 09:11:26 +01:00
2003-06-20 07:16:08 +02:00
?>
<! DOCTYPE html PUBLIC " -//W3C//DTD XHTML 1.0 Transitional//EN " " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
< html xmlns = " http://www.w3.org/1999/xhtml " >
2003-04-01 16:12:34 +02:00
< head >
2005-02-11 01:51:39 +01:00
< title > WordPress & raquo ; < ? php _e ( 'Registration Complete' ) ?> </title>
2006-02-12 08:53:23 +01:00
< meta http - equiv = " Content-Type " content = " <?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?> " />
2003-09-12 18:46:46 +02:00
< link rel = " stylesheet " href = " wp-admin/wp-admin.css " type = " text/css " />
2005-02-11 01:51:39 +01:00
< style type = " text/css " >
. submit {
font - size : 1.7 em ;
}
</ style >
2003-04-01 16:12:34 +02:00
</ head >
2003-06-20 07:16:08 +02:00
< body >
< div id = " login " >
2004-04-25 21:33:12 +02:00
< h2 >< ? php _e ( 'Registration Complete' ) ?> </h2>
2005-03-13 18:06:18 +01:00
< p >< ? php printf ( __ ( 'Username: %s' ), " <strong> $user_login </strong> " ) ?> <br />
< ? php printf ( __ ( 'Password: %s' ), '<strong>' . __ ( 'emailed to you' ) . '</strong>' ) ?> <br />
< ? php printf ( __ ( 'E-mail: %s' ), " <strong> $user_email </strong> " ) ?> </p>
2006-02-17 02:29:33 +01:00
< p class = " submit " >< a href = " wp-login.php " >< ? php _e ( 'Login »' ); ?> </a></p>
2003-04-01 16:12:34 +02:00
</ div >
</ body >
</ html >
2005-07-12 17:53:13 +02:00
< ? php
break ;
}
2003-04-01 16:12:34 +02:00
default :
?>
2003-06-20 07:16:08 +02:00
<! DOCTYPE html PUBLIC " -//W3C//DTD XHTML 1.0 Transitional//EN " " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
< html xmlns = " http://www.w3.org/1999/xhtml " >
< head >
2004-05-18 22:54:58 +02:00
< title > WordPress & raquo ; < ? php _e ( 'Registration Form' ) ?> </title>
2005-02-14 05:36:57 +01:00
< meta http - equiv = " Content-Type " content = " <?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?> " />
2003-09-12 18:46:46 +02:00
< link rel = " stylesheet " href = " wp-admin/wp-admin.css " type = " text/css " />
2005-02-05 03:19:00 +01:00
< style type = " text/css " >
#user_email, #user_login, #submit {
font - size : 1.7 em ;
}
</ style >
2003-04-01 16:12:34 +02:00
</ head >
2003-06-20 07:16:08 +02:00
< body >
< div id = " login " >
2005-02-05 03:19:00 +01:00
< h1 >< a href = " http://wordpress.org/ " > WordPress </ a ></ h1 >
< h2 >< ? php _e ( 'Register for this blog' ) ?> </h2>
2005-07-12 17:53:13 +02:00
< ? php if ( isset ( $errors ) ) : ?>
< div class = " error " >
2006-02-09 09:11:26 +01:00
< p >
2005-07-12 17:53:13 +02:00
< ? php
2006-02-09 09:11:26 +01:00
foreach ( $errors as $error ) echo " $error <br /> " ;
2005-07-12 17:53:13 +02:00
?>
2006-02-09 09:11:26 +01:00
</ p >
2005-07-12 17:53:13 +02:00
</ div >
< ? php endif ; ?>
2005-02-05 03:19:00 +01:00
< form method = " post " action = " wp-register.php " id = " registerform " >
< p >< input type = " hidden " name = " action " value = " register " />
2005-07-12 17:53:13 +02:00
< 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 $user_login; ?>" /><br /></p>
< 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 $user_email; ?>" /></p>
2005-12-05 17:58:26 +01:00
< p >< ? php _e ( 'A password will be emailed to you.' ) ?> </p>
2006-02-17 02:29:33 +01:00
< p class = " submit " >< input type = " submit " value = " <?php _e('Register »') ?> " id = " submit " name = " submit " /></ p >
2003-04-01 16:12:34 +02:00
</ form >
2005-02-05 03:19:00 +01:00
< ul >
2005-11-17 11:10:10 +01:00
< li >< a href = " <?php bloginfo('home'); ?>/ " title = " <?php _e('Are you lost?') ?> " >& laquo ; < ? php _e ( 'Back to blog' ) ?> </a></li>
2005-02-05 03:19:00 +01:00
< li >< a href = " <?php bloginfo('wpurl'); ?>/wp-login.php " >< ? php _e ( 'Login' ) ?> </a></li>
< 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>
</ ul >
2003-06-20 07:16:08 +02:00
</ div >
2003-04-01 16:12:34 +02:00
</ body >
</ html >
2003-06-20 07:16:08 +02:00
< ? php
2003-04-01 16:12:34 +02:00
break ;
2005-07-12 17:53:13 +02:00
case 'disabled' :
?>
<! DOCTYPE html PUBLIC " -//W3C//DTD XHTML 1.0 Transitional//EN " " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
< html xmlns = " http://www.w3.org/1999/xhtml " >
< head >
< title > WordPress & raquo ; < ? php _e ( 'Registration Currently Disabled' ) ?> </title>
2005-07-23 08:39:57 +02:00
< meta http - equiv = " Content-Type " content = " <?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?> " />
2005-07-12 17:53:13 +02:00
< link rel = " stylesheet " href = " wp-admin/wp-admin.css " type = " text/css " >
</ head >
< body >
< div id = " login " >
< h2 >< ? php _e ( 'Registration Disabled' ) ?> </h2>
< p >< ? php _e ( 'User registration is currently not allowed.' ) ?> <br />
2005-11-17 11:10:10 +01:00
< a href = " <?php echo get_settings('home'); ?>/ " title = " <?php _e('Go back to the blog') ?> " >< ? php _e ( 'Home' ) ?> </a>
2005-07-12 17:53:13 +02:00
</ p >
</ div >
</ body >
</ html >
< ? php
break ;
2004-02-09 20:29:35 +01:00
}
2005-07-12 17:53:13 +02:00
?>